@annotorious/openseadragon 3.4.7 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,23 +1,23 @@
1
- (function(Zt,ve){typeof exports=="object"&&typeof module<"u"?ve(exports,require("openseadragon")):typeof define=="function"&&define.amd?define(["exports","openseadragon"],ve):(Zt=typeof globalThis<"u"?globalThis:Zt||self,ve(Zt.AnnotoriousOSD={},Zt.OpenSeadragon))})(this,function(Zt,ve){"use strict";var sI=Object.defineProperty;var nI=(Zt,ve,fi)=>ve in Zt?sI(Zt,ve,{enumerable:!0,configurable:!0,writable:!0,value:fi}):Zt[ve]=fi;var $t=(Zt,ve,fi)=>nI(Zt,typeof ve!="symbol"?ve+"":ve,fi);var fi=Object.prototype.hasOwnProperty;function pi(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--&&pi(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(fi.call(r,e)&&++i&&!fi.call(t,e)||!(e in t)||!pi(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}var ea=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(ea||{});const xe=[];for(let r=0;r<256;++r)xe.push((r+256).toString(16).slice(1));function Fg(r,t=0){return(xe[r[t+0]]+xe[r[t+1]]+xe[r[t+2]]+xe[r[t+3]]+"-"+xe[r[t+4]]+xe[r[t+5]]+"-"+xe[r[t+6]]+xe[r[t+7]]+"-"+xe[r[t+8]]+xe[r[t+9]]+"-"+xe[r[t+10]]+xe[r[t+11]]+xe[r[t+12]]+xe[r[t+13]]+xe[r[t+14]]+xe[r[t+15]]).toLowerCase()}let ra;const kg=new Uint8Array(16);function Ug(){if(!ra){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ra=crypto.getRandomValues.bind(crypto)}return ra(kg)}const Gg=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),uu={randomUUID:Gg};function Hg(r,t,e){var i;if(uu.randomUUID&&!r)return uu.randomUUID();r=r||{};const s=r.random??((i=r.rng)==null?void 0:i.call(r))??Ug();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,Fg(s)}const ia=r=>{const t=e=>{const i={...e};return e.created&&typeof e.created=="string"&&(i.created=new Date(e.created)),e.updated&&typeof e.updated=="string"&&(i.updated=new Date(e.updated)),i};return{...r,bodies:(r.bodies||[]).map(t),target:t(r.target)}},$g=(r,t,e,i)=>({id:Hg(),annotation:typeof r=="string"?r:r.id,created:e||new Date,creator:i,...t}),Xg=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},Vg=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},zg=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!pi(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),Yg=(r,t)=>!pi(r.target,t.target),Wg=(r,t)=>{const e=Xg(r,t),i=Vg(r,t),s=zg(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:Yg(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var $r=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))($r||{});const jg=(r,t)=>{const e=new Set((r.created||[]).map(c=>c.id)),i=new Set((r.updated||[]).map(({newValue:c})=>c.id)),s=new Set((t.created||[]).map(c=>c.id)),n=new Set((t.deleted||[]).map(c=>c.id)),o=new Set((t.updated||[]).map(({oldValue:c})=>c.id)),a=new Set((t.updated||[]).filter(({oldValue:c})=>e.has(c.id)||i.has(c.id)).map(({oldValue:c})=>c.id)),l=[...(r.created||[]).filter(c=>!n.has(c.id)).map(c=>o.has(c.id)?t.updated.find(({oldValue:d})=>d.id===c.id).newValue:c),...t.created||[]],h=[...(r.deleted||[]).filter(c=>!s.has(c.id)),...(t.deleted||[]).filter(c=>!e.has(c.id))],u=[...(r.updated||[]).filter(({newValue:c})=>!n.has(c.id)).map(c=>{const{oldValue:d,newValue:f}=c;if(o.has(f.id)){const p=t.updated.find(m=>m.oldValue.id===f.id).newValue;return Wg(d,p)}else return c}),...(t.updated||[]).filter(({oldValue:c})=>!a.has(c.id))];return{created:l,deleted:h,updated:u}};let qg=()=>({emit(r,...t){for(let e=this.events[r]||[],i=0,s=e.length;i<s;i++)e[i](...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 Kg=250,Zg=(r,t)=>{const e=qg(),i=(t==null?void 0:t.changes)||[];let s=t?t.pointer:-1,n=!1,o=0;const a=p=>{if(!n){const{changes:m}=p,_=performance.now();if(_-o>Kg)i.splice(s+1),i.push(m),s=i.length-1;else{const y=i.length-1;i[y]=jg(i[y],m)}o=_}n=!1};r.observe(a,{origin:$r.LOCAL});const l=p=>p&&p.length>0&&r.bulkDeleteAnnotations(p),h=p=>p&&p.length>0&&r.bulkAddAnnotations(p,!1),u=p=>p&&p.length>0&&r.bulkUpdateAnnotations(p.map(({oldValue:m})=>m)),c=p=>p&&p.length>0&&r.bulkUpdateAnnotations(p.map(({newValue:m})=>m)),d=p=>p&&p.length>0&&r.bulkAddAnnotations(p,!1),f=p=>p&&p.length>0&&r.bulkDeleteAnnotations(p);return{canRedo:()=>i.length-1>s,canUndo:()=>s>-1,destroy:()=>r.unobserve(a),getHistory:()=>({changes:[...i],pointer:s}),on:(p,m)=>e.on(p,m),redo:()=>{if(i.length-1>s){n=!0;const{created:p,updated:m,deleted:_}=i[s+1];h(p),c(m),f(_),e.emit("redo",i[s+1]),s+=1}},undo:()=>{if(s>-1){n=!0;const{created:p,updated:m,deleted:_}=i[s];l(p),u(m),d(_),e.emit("undo",i[s]),s-=1}}}},Qg=(r,t,e,i)=>{const{hover:s,selection:n,store:o,viewport:a}=r,l=new Map;let h=[],u,c;const d=(y,v)=>{l.has(y)?l.get(y).push(v):l.set(y,[v])},f=(y,v)=>{const g=l.get(y);if(g){const x=g.indexOf(v);x!==-1&&g.splice(x,1)}},p=(y,v,g)=>{l.has(y)&&setTimeout(()=>{l.get(y).forEach(x=>{if(e){const E=Array.isArray(v)?v.map(S=>e.serialize(S)):e.serialize(v),R=g?g instanceof PointerEvent?g:e.serialize(g):void 0;x(E,R)}else x(v,g)})},1)},m=()=>{const{selected:y}=n,v=(y||[]).map(({id:g})=>o.getAnnotation(g));v.forEach(g=>{const x=h.find(E=>E.id===g.id);(!x||!pi(x,g))&&p("updateAnnotation",g,x)}),h=h.map(g=>v.find(({id:E})=>E===g.id)||g)};n.subscribe(({selected:y})=>{if(!(h.length===0&&y.length===0)){if(h.length===0&&y.length>0)h=y.map(({id:v})=>o.getAnnotation(v));else if(h.length>0&&y.length===0)h.forEach(v=>{const g=o.getAnnotation(v.id);g&&!pi(g,v)&&p("updateAnnotation",g,v)}),h=[];else{const v=new Set(h.map(x=>x.id)),g=new Set(y.map(({id:x})=>x));h.filter(x=>!g.has(x.id)).forEach(x=>{const E=o.getAnnotation(x.id);E&&!pi(E,x)&&p("updateAnnotation",E,x)}),h=[...h.filter(x=>g.has(x.id)),...y.filter(({id:x})=>!v.has(x)).map(({id:x})=>o.getAnnotation(x))]}p("selectionChanged",h)}}),s.subscribe(y=>{!u&&y?p("mouseEnterAnnotation",o.getAnnotation(y)):u&&!y?p("mouseLeaveAnnotation",o.getAnnotation(u)):u&&y&&(p("mouseLeaveAnnotation",o.getAnnotation(u)),p("mouseEnterAnnotation",o.getAnnotation(y))),u=y}),a==null||a.subscribe(y=>p("viewportIntersect",y.map(v=>o.getAnnotation(v)))),o.observe(y=>{i&&(c&&clearTimeout(c),c=setTimeout(m,1e3));const{created:v,deleted:g}=y.changes;(v||[]).forEach(x=>p("createAnnotation",x)),(g||[]).forEach(x=>p("deleteAnnotation",x)),(y.changes.updated||[]).filter(x=>[...x.bodiesCreated||[],...x.bodiesDeleted||[],...x.bodiesUpdated||[]].length>0).forEach(({oldValue:x,newValue:E})=>{const R=h.find(S=>S.id===x.id)||x;h=h.map(S=>S.id===x.id?E:S),p("updateAnnotation",E,R)})},{origin:$r.LOCAL}),o.observe(y=>{if(h){const v=new Set(h.map(x=>x.id)),g=(y.changes.updated||[]).filter(({newValue:x})=>v.has(x.id)).map(({newValue:x})=>x);g.length>0&&(h=h.map(x=>g.find(R=>R.id===x.id)||x))}},{origin:$r.REMOTE});const _=y=>v=>{const{updated:g}=v;y?(g||[]).forEach(x=>p("updateAnnotation",x.oldValue,x.newValue)):(g||[]).forEach(x=>p("updateAnnotation",x.newValue,x.oldValue))};return t.on("undo",_(!0)),t.on("redo",_(!1)),{on:d,off:f,emit:p}},Jg=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:[]}),ty=(r,t,e)=>{const{store:i,selection:s}=r,n=y=>{if(e){const{parsed:v,error:g}=e.parse(y);v?i.addAnnotation(v,$r.REMOTE):console.error(g)}else i.addAnnotation(ia(y),$r.REMOTE)},o=()=>s.clear(),a=()=>i.clear(),l=y=>{const v=i.getAnnotation(y);return e&&v?e.serialize(v):v},h=()=>e?i.all().map(e.serialize):i.all(),u=()=>{var y;const v=(((y=s.selected)==null?void 0:y.map(g=>g.id))||[]).map(g=>i.getAnnotation(g)).filter(Boolean);return e?v.map(e.serialize):v},c=(y,v=!0)=>fetch(y).then(g=>g.json()).then(g=>(f(g,v),g)),d=y=>{if(typeof y=="string"){const v=i.getAnnotation(y);if(i.deleteAnnotation(y),v)return e?e.serialize(v):v}else{const v=e?e.parse(y).parsed:y;if(v)return i.deleteAnnotation(v),y}},f=(y,v=!0)=>{if(e){const g=e.parseAll||Jg(e),{parsed:x,failed:E}=g(y);E.length>0&&console.warn(`Discarded ${E.length} invalid annotations`,E),i.bulkAddAnnotations(x,v,$r.REMOTE)}else i.bulkAddAnnotations(y.map(ia),v,$r.REMOTE)},p=(y,v)=>{y?s.setSelected(y,v):s.clear()},m=y=>{s.clear(),s.setUserSelectAction(y)},_=y=>{if(e){const v=e.parse(y).parsed,g=e.serialize(i.getAnnotation(v.id));return i.updateAnnotation(v),g}else{const v=i.getAnnotation(y.id);return i.updateAnnotation(ia(y)),v}};return{addAnnotation:n,cancelSelected:o,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getHistory:t.getHistory,getSelected:u,loadAnnotations:c,redo:t.redo,removeAnnotation:d,setAnnotations:f,setSelected:p,setUserSelectAction:m,undo:t.undo,updateAnnotation:_}},ey="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let ry=r=>crypto.getRandomValues(new Uint8Array(r)),iy=(r,t,e)=>{let i=(2<<Math.log2(r.length-1))-1,s=-~(1.6*i*t/r.length);return(n=t)=>{let o="";for(;;){let a=e(s),l=s|0;for(;l--;)if(o+=r[a[l]&i]||"",o.length>=n)return o}}},sy=(r,t=21)=>iy(r,t|0,ry),ny=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=ey[e[r]&63];return t};const oy=()=>({isGuest:!0,id:sy("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),ay=["#ff7c00","#1ac938","#e8000b","#8b2be2","#9f4800","#f14cc1","#ffc400","#00d7ff","#023eff"],ly=()=>{const r=[...ay];return{assignRandomColor:()=>{const t=Math.floor(Math.random()*r.length),e=r[t];return r.splice(t,1),e},releaseColor:t=>r.push(t)}};ny();var hy=Object.defineProperty,uy=(r,t,e)=>t in r?hy(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xt=(r,t,e)=>uy(r,typeof t!="symbol"?t+"":t,e);function Dt(){}function sa(r,t){for(const e in t)r[e]=t[e];return r}function cu(r){return r()}function du(){return Object.create(null)}function $e(r){r.forEach(cu)}function Vt(r){return typeof r=="function"}function le(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function cy(r){return Object.keys(r).length===0}function fu(r,...t){if(r==null){for(const i of t)i(void 0);return Dt}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function na(r,t,e){r.$$.on_destroy.push(fu(t,e))}function dy(r,t,e,i){if(r){const s=pu(r,t,e,i);return r[0](s)}}function pu(r,t,e,i){return r[1]&&i?sa(e.ctx.slice(),r[1](i(t))):e.ctx}function fy(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 py(r,t,e,i,s,n){if(s){const o=pu(t,e,i,n);r.p(o,s)}}function my(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 mu(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function wt(r,t){r.appendChild(t)}function it(r,t,e){r.insertBefore(t,e||null)}function rt(r){r.parentNode&&r.parentNode.removeChild(r)}function mi(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function Z(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function gu(r){return document.createTextNode(r)}function Oe(){return gu(" ")}function Fe(){return gu("")}function Rt(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function b(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function gy(r){return Array.from(r.childNodes)}function cr(r,t,e){r.classList.toggle(t,!!e)}function yy(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let Ms;function Ps(r){Ms=r}function yu(){if(!Ms)throw new Error("Function called outside component initialization");return Ms}function gi(r){yu().$$.on_mount.push(r)}function Xr(){const r=yu();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=yy(t,e,{cancelable:i});return s.slice().forEach(o=>{o.call(r,n)}),!n.defaultPrevented}return!0}}function Ce(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const $i=[],bn=[];let Xi=[];const _u=[],vu=Promise.resolve();let oa=!1;function xu(){oa||(oa=!0,vu.then(Eu))}function bu(){return xu(),vu}function aa(r){Xi.push(r)}const la=new Set;let Vi=0;function Eu(){if(Vi!==0)return;const r=Ms;do{try{for(;Vi<$i.length;){const t=$i[Vi];Vi++,Ps(t),_y(t.$$)}}catch(t){throw $i.length=0,Vi=0,t}for(Ps(null),$i.length=0,Vi=0;bn.length;)bn.pop()();for(let t=0;t<Xi.length;t+=1){const e=Xi[t];la.has(e)||(la.add(e),e())}Xi.length=0}while($i.length);for(;_u.length;)_u.pop()();oa=!1,la.clear(),Ps(r)}function _y(r){if(r.fragment!==null){r.update(),$e(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(aa)}}function vy(r){const t=[],e=[];Xi.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),Xi=t}const En=new Set;let yi;function Ie(){yi={r:0,c:[],p:yi}}function Re(){yi.r||$e(yi.c),yi=yi.p}function ot(r,t){r&&r.i&&(En.delete(r),r.i(t))}function gt(r,t,e,i){if(r&&r.o){if(En.has(r))return;En.add(r),yi.c.push(()=>{En.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function ke(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function be(r){r&&r.c()}function ce(r,t,e){const{fragment:i,after_update:s}=r.$$;i&&i.m(t,e),aa(()=>{const n=r.$$.on_mount.map(cu).filter(Vt);r.$$.on_destroy?r.$$.on_destroy.push(...n):$e(n),r.$$.on_mount=[]}),s.forEach(aa)}function de(r,t){const e=r.$$;e.fragment!==null&&(vy(e.after_update),$e(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function xy(r,t){r.$$.dirty[0]===-1&&($i.push(r),xu(),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=Ms;Ps(r);const h=r.$$={fragment:null,ctx:[],props:n,update:Dt,not_equal:s,bound:du(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:du(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let u=!1;if(h.ctx=e?e(r,t.props||{},(c,d,...f)=>{const p=f.length?f[0]:d;return h.ctx&&s(h.ctx[c],h.ctx[c]=p)&&(!h.skip_bound&&h.bound[c]&&h.bound[c](p),u&&xy(r,c)),d}):[],h.update(),u=!0,$e(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const c=gy(t.target);h.fragment&&h.fragment.l(c),c.forEach(rt)}else h.fragment&&h.fragment.c();t.intro&&ot(r.$$.fragment),ce(r,t.target,t.anchor),Eu()}Ps(l)}class De{constructor(){Xt(this,"$$"),Xt(this,"$$set")}$destroy(){de(this,1),this.$destroy=Dt}$on(t,e){if(!Vt(e))return Dt;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&&!cy(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const by="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(by);var Tt=(r=>(r.ELLIPSE="ELLIPSE",r.MULTIPOLYGLON="MULTIPOLYGON",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(Tt||{}),Ey={exports:{}};(function(r){(function(){function t(a,l){var h=a.x-l.x,u=a.y-l.y;return h*h+u*u}function e(a,l,h){var u=l.x,c=l.y,d=h.x-u,f=h.y-c;if(d!==0||f!==0){var p=((a.x-u)*d+(a.y-c)*f)/(d*d+f*f);p>1?(u=h.x,c=h.y):p>0&&(u+=d*p,c+=f*p)}return d=a.x-u,f=a.y-c,d*d+f*f}function i(a,l){for(var h=a[0],u=[h],c,d=1,f=a.length;d<f;d++)c=a[d],t(c,h)>l&&(u.push(c),h=c);return h!==c&&u.push(c),u}function s(a,l,h,u,c){for(var d=u,f,p=l+1;p<h;p++){var m=e(a[p],a[l],a[h]);m>d&&(f=p,d=m)}d>u&&(f-l>1&&s(a,l,f,u,c),c.push(a[f]),h-f>1&&s(a,f,h,u,c))}function n(a,l){var h=a.length-1,u=[a[0]];return s(a,0,h,l,u),u.push(a[h]),u}function o(a,l,h){if(a.length<=2)return a;var u=l!==void 0?l*l:1;return a=h?a:i(a,u),a=n(a,u),a}r.exports=o,r.exports.default=o})()})(Ey);const ha={},wn=(r,t)=>ha[r]=t,ua=r=>ha[r.type].area(r),wy=(r,t,e)=>ha[r.type].intersects(r,t,e),Ue=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}},ca=r=>{let t=0,e=r.length-1;for(let i=0;i<r.length;i++)t+=(r[e][0]+r[i][0])*(r[e][1]-r[i][1]),e=i;return Math.abs(.5*t)},da=(r,t,e)=>{let i=!1;for(let s=0,n=r.length-1;s<r.length;n=s++){const o=r[s][0],a=r[s][1],l=r[n][0],h=r[n][1];a>e!=h>e&&t<(l-o)*(e-a)/(h-a)+o&&(i=!i)}return i},Ty=(r,t=!0)=>{let e="M ";return r.forEach(([i,s],n)=>{n===0?e+=`${i},${s}`:e+=` L ${i},${s}`}),t&&(e+=" Z"),e},Ay={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),u=t-i,c=e-s,d=l*u+h*c,f=h*u-l*c;return d*d/(n*n)+f*f/(o*o)<=1}};wn(Tt.ELLIPSE,Ay);const Sy={area:r=>{const{polygons:t}=r.geometry;return t.reduce((e,i)=>{const[s,...n]=i.rings,o=ca(s.points),a=n.reduce((l,h)=>l+ca(h.points),0);return e+o-a},0)},intersects:(r,t,e)=>{const{polygons:i}=r.geometry;for(const s of i){const[n,...o]=s.rings;if(da(n.points,t,e)){let a=!1;for(const l of o)if(da(l.points,t,e)){a=!0;break}if(!a)return!0}}return!1}},fa=r=>{const t=r.reduce((e,i)=>[...e,...i.rings[0].points],[]);return Ue(t)},Ze=r=>r.rings.map(t=>Ty(t.points)).join(" "),Cy=r=>r.polygons.reduce((t,e)=>[...t,...e.rings.reduce((i,s)=>[...i,...s.points],[])],[]);wn(Tt.MULTIPOLYGLON,Sy);const Iy={area:r=>{const t=r.geometry.points;return ca(t)},intersects:(r,t,e)=>{const i=r.geometry.points;return da(i,t,e)}};wn(Tt.POLYGON,Iy);const Ry={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};wn(Tt.RECTANGLE,Ry);const ze=r=>Tn(r.target),Tn=r=>{var t,e;return(r==null?void 0:r.annotation)!==void 0&&((e=(t=r==null?void 0:r.selector)==null?void 0:t.geometry)==null?void 0:e.bounds)!==void 0},My=(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,u,c]=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,u,c].map(parseFloat);return{type:Tt.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}}}},Py=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}`}},wu="http://www.w3.org/2000/svg",Tu=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},Oy=r=>{const t=new XMLSerializer().serializeToString(r.documentElement).replace("<svg>",`<svg xmlns="${wu}">`);return new DOMParser().parseFromString(t,"image/svg+xml").documentElement},Au=r=>{const t=new DOMParser().parseFromString(r,"image/svg+xml"),e=t.lookupPrefix(wu),i=t.lookupNamespaceURI(null);return e||i?Tu(t).firstChild:Tu(Oy(t)).firstChild},ee=" ";function Ny(r){let t="";Array.isArray(r)||(r=[r]);for(let e=0;e<r.length;e++){const i=r[e];if(i.type===G.CLOSE_PATH)t+="z";else if(i.type===G.HORIZ_LINE_TO)t+=(i.relative?"h":"H")+i.x;else if(i.type===G.VERT_LINE_TO)t+=(i.relative?"v":"V")+i.y;else if(i.type===G.MOVE_TO)t+=(i.relative?"m":"M")+i.x+ee+i.y;else if(i.type===G.LINE_TO)t+=(i.relative?"l":"L")+i.x+ee+i.y;else if(i.type===G.CURVE_TO)t+=(i.relative?"c":"C")+i.x1+ee+i.y1+ee+i.x2+ee+i.y2+ee+i.x+ee+i.y;else if(i.type===G.SMOOTH_CURVE_TO)t+=(i.relative?"s":"S")+i.x2+ee+i.y2+ee+i.x+ee+i.y;else if(i.type===G.QUAD_TO)t+=(i.relative?"q":"Q")+i.x1+ee+i.y1+ee+i.x+ee+i.y;else if(i.type===G.SMOOTH_QUAD_TO)t+=(i.relative?"t":"T")+i.x+ee+i.y;else if(i.type===G.ARC)t+=(i.relative?"a":"A")+i.rX+ee+i.rY+ee+i.xRot+ee+ +i.lArcFlag+ee+ +i.sweepFlag+ee+i.x+ee+i.y;else throw new Error(`Unexpected command type "${i==null?void 0:i.type}" at index ${e}.`)}return t}function pa([r,t],e){return[r*Math.cos(e)-t*Math.sin(e),r*Math.sin(e)+t*Math.cos(e)]}function Qe(...r){for(let t=0;t<r.length;t++)if(typeof r[t]!="number")throw new Error(`assertNumbers arguments[${t}] is not a number. ${typeof r[t]} == typeof ${r[t]}`);return!0}const Vr=Math.PI;function ma(r,t,e){r.lArcFlag=r.lArcFlag===0?0:1,r.sweepFlag=r.sweepFlag===0?0:1;let{rX:i,rY:s}=r;const{x:n,y:o}=r;if(Math.abs(i)<1e-10||Math.abs(s)<1e-10){r.rX=0,r.rY=0,r.cX=(t+n)/2,r.cY=(e+o)/2,r.phi1=0,r.phi2=0;return}i=Math.abs(r.rX),s=Math.abs(r.rY);const a=r.xRot/180*Vr,[l,h]=pa([(t-n)/2,(e-o)/2],-a),u=Math.pow(l,2)/Math.pow(i,2)+Math.pow(h,2)/Math.pow(s,2);1<u&&(i*=Math.sqrt(u),s*=Math.sqrt(u)),r.rX=i,r.rY=s;const c=Math.pow(i,2)*Math.pow(h,2)+Math.pow(s,2)*Math.pow(l,2),d=(r.lArcFlag!==r.sweepFlag?1:-1)*Math.sqrt(Math.max(0,(Math.pow(i,2)*Math.pow(s,2)-c)/c)),f=i*h/s*d,p=-s*l/i*d,m=pa([f,p],a);r.cX=m[0]+(t+n)/2,r.cY=m[1]+(e+o)/2,r.phi1=Math.atan2((h-p)/s,(l-f)/i),r.phi2=Math.atan2((-h-p)/s,(-l-f)/i),r.sweepFlag===0&&r.phi2>r.phi1&&(r.phi2-=2*Vr),r.sweepFlag===1&&r.phi2<r.phi1&&(r.phi2+=2*Vr),r.phi1*=180/Vr,r.phi2*=180/Vr}function Su(r,t,e){Qe(r,t,e);const i=r*r+t*t-e*e;if(0>i)return[];if(i===0)return[[r*e/(r*r+t*t),t*e/(r*r+t*t)]];const s=Math.sqrt(i);return[[(r*e+t*s)/(r*r+t*t),(t*e-r*s)/(r*r+t*t)],[(r*e-t*s)/(r*r+t*t),(t*e+r*s)/(r*r+t*t)]]}const _i=Math.PI/180;function Cu(r,t,e){return(1-e)*r+e*t}function Iu(r,t,e,i){return r+Math.cos(i/180*Vr)*t+Math.sin(i/180*Vr)*e}function Ru(r,t,e,i){const s=t-r,n=e-t,o=i-e,a=3*s+3*o-6*n,l=(n-s)*6,h=3*s;return Math.abs(a)<1e-6?Math.abs(l)<1e-6?[]:[-h/l]:Dy(l/a,h/a,1e-6)}function Mu(r,t,e,i,s){const n=1-s,o=n*n*n,a=3*n*n*s,l=3*n*s*s,h=s*s*s;return r*o+t*a+e*l+i*h}function Dy(r,t,e=1e-6){const i=r*r/4-t;if(i<-e)return[];if(i<=e)return[-r/2];const s=Math.sqrt(i);return[-(r/2)-s,-(r/2)+s]}function Ly(r,t,e){r.cX||ma(r,t,e);const i=r.xRot/180*Vr;if(Math.abs(r.rX)<1e-10||Math.abs(r.rY)<1e-10)return[{relative:r.relative,type:G.CURVE_TO,x1:t+(r.x-t)/3,y1:e+(r.y-e)/3,x2:t+2*(r.x-t)/3,y2:e+2*(r.y-e)/3,x:r.x,y:r.y}];const s=Math.min(r.phi1,r.phi2),n=Math.max(r.phi1,r.phi2),o=n-s,a=Math.ceil(o/90),l=new Array(a);let h=t,u=e;const c=(d,f)=>{const[p,m]=pa([d*r.rX,f*r.rY],i);return[r.cX+p,r.cY+m]};for(let d=0;d<a;d++){const f=Cu(r.phi1,r.phi2,d/a),p=Cu(r.phi1,r.phi2,(d+1)/a),m=p-f,_=4/3*Math.tan(m*_i/4),y=Math.cos(f*_i)-_*Math.sin(f*_i),v=Math.sin(f*_i)+_*Math.cos(f*_i),g=Math.cos(p*_i),x=Math.sin(p*_i),E=g+_*x,R=x-_*g,S=c(y,v),M=c(E,R),P=c(g,x),F={relative:r.relative,type:G.CURVE_TO,x:P[0],y:P[1],x1:S[0],y1:S[1],x2:M[0],y2:M[1]};r.relative&&(F.x1-=h,F.y1-=u,F.x2-=h,F.y2-=u,F.x-=h,F.y-=u),h=P[0],u=P[1],l[d]=F}return l}function ga(r,t,e){const i=t[0]-r[0],s=t[1]-r[1],n=e[0]-r[0],o=e[1]-r[1],a=i*o-s*n;if(!(Math.abs(a)<1e-10))return!1;const l=i*n+s*o,h=i*i+s*s,u=n*n+o*o;return 0<=l&&l<=u&&h<=u}function By(r,t=!0){if(r.length<2)return r;const e=re.INFO((n,o,a)=>({...n,x:n.x??o,y:n.y??a,relative:n.relative??!1})),i=[];let s=[];for(const n of r){const o=e(n);o.type===G.MOVE_TO&&s.length>0&&(t?i.push(...An(s)):i.unshift(...An(s)),s=[]),s.push(o)}return s.length>0&&(t?i.push(...An(s)):i.unshift(...An(s))),i}function An(r){var t;const e=((t=r[r.length-1])==null?void 0:t.type)===G.CLOSE_PATH,i=e?r.length-2:r.length-1,s=[{type:G.MOVE_TO,relative:!1,x:r[i].x,y:r[i].y}];for(let n=i;n>0;n--){const o=r[n],a=r[n-1];if(o.relative)throw new Error("Relative command are not supported convert first with `toAbs()`");switch(o.type){case G.HORIZ_LINE_TO:s.push({type:G.HORIZ_LINE_TO,relative:!1,x:a.x});break;case G.VERT_LINE_TO:s.push({type:G.VERT_LINE_TO,relative:!1,y:a.y});break;case G.LINE_TO:case G.MOVE_TO:s.push({type:G.LINE_TO,relative:!1,x:a.x,y:a.y});break;case G.CURVE_TO:s.push({type:G.CURVE_TO,relative:!1,x:a.x,y:a.y,x1:o.x2,y1:o.y2,x2:o.x1,y2:o.y1});break;case G.SMOOTH_CURVE_TO:throw new Error("Unsupported command: S (smooth cubic bezier)");case G.SMOOTH_QUAD_TO:throw new Error("Unsupported command: T (smooth quadratic bezier)");case G.ARC:throw new Error("Unsupported command: A (arc)");case G.QUAD_TO:throw new Error("Unsupported command: Q (quadratic bezier)")}}return e&&s.push({type:G.CLOSE_PATH}),s}function Fy(r=1e13){Qe(r);function t(e){return Math.round(e*r)/r}return function(e){return"x1"in e&&typeof e.x1<"u"&&(e.x1=t(e.x1)),"y1"in e&&typeof e.y1<"u"&&(e.y1=t(e.y1)),"x2"in e&&typeof e.x2<"u"&&(e.x2=t(e.x2)),"y2"in e&&typeof e.y2<"u"&&(e.y2=t(e.y2)),"x"in e&&typeof e.x<"u"&&(e.x=t(e.x)),"y"in e&&typeof e.y<"u"&&(e.y=t(e.y)),"rX"in e&&typeof e.rX<"u"&&(e.rX=t(e.rX)),"rY"in e&&typeof e.rY<"u"&&(e.rY=t(e.rY)),e}}function Pu(){return Je((r,t,e)=>(r.relative&&(typeof r.x1<"u"&&(r.x1+=t),typeof r.y1<"u"&&(r.y1+=e),typeof r.x2<"u"&&(r.x2+=t),typeof r.y2<"u"&&(r.y2+=e),typeof r.x<"u"&&(r.x+=t),typeof r.y<"u"&&(r.y+=e),r.relative=!1),r))}function ky(){return Je((r,t,e)=>(r.relative||(typeof r.x1<"u"&&(r.x1-=t),typeof r.y1<"u"&&(r.y1-=e),typeof r.x2<"u"&&(r.x2-=t),typeof r.y2<"u"&&(r.y2-=e),typeof r.x<"u"&&(r.x-=t),typeof r.y<"u"&&(r.y-=e),r.relative=!0),r))}function Uy(r=!0,t=!0,e=!0,i=!0){return Je((s,n,o,a,l)=>{if(isNaN(a)&&!(s.type&G.MOVE_TO))throw new Error("path must start with moveto");if(t&&s.type&G.HORIZ_LINE_TO&&(s.type=G.LINE_TO,s.y=s.relative?0:o),e&&s.type&G.VERT_LINE_TO&&(s.type=G.LINE_TO,s.x=s.relative?0:n),r&&s.type&G.CLOSE_PATH&&(s.type=G.LINE_TO,s.x=s.relative?a-n:a,s.y=s.relative?l-o:l),s.type&G.ARC&&(s.rX===0||s.rY===0)&&(s.type=G.LINE_TO,delete s.rX,delete s.rY,delete s.xRot,delete s.lArcFlag,delete s.sweepFlag),i&&s.type&G.QUAD_TO){const h=[n,o],u=s.relative?[n+s.x1,o+s.y1]:[s.x1,s.y1],c=s.relative?[n+s.x,o+s.y]:[s.x,s.y];ga(h,u,c)&&(s.type=G.LINE_TO,delete s.x1,delete s.y1)}if(i&&s.type&G.CURVE_TO){const h=[n,o],u=s.relative?[n+s.x1,o+s.y1]:[s.x1,s.y1],c=s.relative?[n+s.x2,o+s.y2]:[s.x2,s.y2],d=s.relative?[n+s.x,o+s.y]:[s.x,s.y];ga(h,u,d)&&ga(h,c,d)&&(s.type=G.LINE_TO,delete s.x1,delete s.y1,delete s.x2,delete s.y2)}return s})}function Ou(){let r=NaN,t=NaN,e=NaN,i=NaN;return Je((s,n,o)=>(s.type&G.SMOOTH_CURVE_TO&&(s.type=G.CURVE_TO,r=isNaN(r)?n:r,t=isNaN(t)?o:t,s.x1=s.relative?n-r:2*n-r,s.y1=s.relative?o-t:2*o-t),s.type&G.CURVE_TO?(r=s.relative?n+s.x2:s.x2,t=s.relative?o+s.y2:s.y2):(r=NaN,t=NaN),s.type&G.SMOOTH_QUAD_TO&&(s.type=G.QUAD_TO,e=isNaN(e)?n:e,i=isNaN(i)?o:i,s.x1=s.relative?n-e:2*n-e,s.y1=s.relative?o-i:2*o-i),s.type&G.QUAD_TO?(e=s.relative?n+s.x1:s.x1,i=s.relative?o+s.y1:s.y1):(e=NaN,i=NaN),s))}function Nu(){let r=NaN,t=NaN;return Je((e,i,s)=>{if(e.type&G.SMOOTH_QUAD_TO&&(e.type=G.QUAD_TO,r=isNaN(r)?i:r,t=isNaN(t)?s:t,e.x1=e.relative?i-r:2*i-r,e.y1=e.relative?s-t:2*s-t),e.type&G.QUAD_TO){r=e.relative?i+e.x1:e.x1,t=e.relative?s+e.y1:e.y1;const n=e.x1,o=e.y1;e.type=G.CURVE_TO,e.x1=((e.relative?0:i)+n*2)/3,e.y1=((e.relative?0:s)+o*2)/3,e.x2=(e.x+n*2)/3,e.y2=(e.y+o*2)/3}else r=NaN,t=NaN;return e})}function Je(r){let t=0,e=0,i=NaN,s=NaN;return function(n){if(isNaN(i)&&!(n.type&G.MOVE_TO))throw new Error("path must start with moveto");const o=r(n,t,e,i,s);return n.type&G.CLOSE_PATH&&(t=i,e=s),"x"in n&&typeof n.x<"u"&&(t=n.relative?t+n.x:n.x),"y"in n&&typeof n.y<"u"&&(e=n.relative?e+n.y:n.y),n.type&G.MOVE_TO&&(i=t,s=e),o}}function Gy(r=0){Qe(r);let t=NaN,e=NaN,i=NaN,s=NaN;return Je((n,o,a,l,h)=>{const u=Math.abs;let c=!1,d=0,f=0;if(n.type&G.SMOOTH_CURVE_TO&&(d=isNaN(t)?0:o-t,f=isNaN(e)?0:a-e),n.type&(G.CURVE_TO|G.SMOOTH_CURVE_TO)?(t=n.relative?o+n.x2:n.x2,e=n.relative?a+n.y2:n.y2):(t=NaN,e=NaN),n.type&G.SMOOTH_QUAD_TO?(i=isNaN(i)?o:2*o-i,s=isNaN(s)?a:2*a-s):n.type&G.QUAD_TO?(i=n.relative?o+n.x1:n.x1,s=n.relative?a+n.y1:n.y2):(i=NaN,s=NaN),n.type&G.LINE_COMMANDS||n.type&G.ARC&&(n.rX===0||n.rY===0||!n.lArcFlag)||n.type&G.CURVE_TO||n.type&G.SMOOTH_CURVE_TO||n.type&G.QUAD_TO||n.type&G.SMOOTH_QUAD_TO){const p=typeof n.x>"u"?0:n.relative?n.x:n.x-o,m=typeof n.y>"u"?0:n.relative?n.y:n.y-a;d=isNaN(i)?typeof n.x1>"u"?d:n.relative?n.x:n.x1-o:i-o,f=isNaN(s)?typeof n.y1>"u"?f:n.relative?n.y:n.y1-a:s-a;const _=typeof n.x2>"u"?0:n.relative?n.x:n.x2-o,y=typeof n.y2>"u"?0:n.relative?n.y:n.y2-a;u(p)<=r&&u(m)<=r&&u(d)<=r&&u(f)<=r&&u(_)<=r&&u(y)<=r&&(c=!0)}return n.type&G.CLOSE_PATH&&u(o-l)<=r&&u(a-h)<=r&&(c=!0),c?[]:n})}function zr(r,t,e,i,s,n){return Qe(r,t,e,i,s,n),Je((o,a,l,h)=>{const u=o.x1,c=o.x2,d=o.relative&&!isNaN(h),f=typeof o.x<"u"?o.x:d?0:a,p=typeof o.y<"u"?o.y:d?0:l;o.type&G.HORIZ_LINE_TO&&t!==0&&(o.type=G.LINE_TO,o.y=o.relative?0:l),o.type&G.VERT_LINE_TO&&e!==0&&(o.type=G.LINE_TO,o.x=o.relative?0:a),typeof o.x<"u"&&(o.x=o.x*r+p*e+(d?0:s)),typeof o.y<"u"&&(o.y=f*t+o.y*i+(d?0:n)),typeof o.x1<"u"&&(o.x1=o.x1*r+o.y1*e+(d?0:s)),typeof o.y1<"u"&&(o.y1=u*t+o.y1*i+(d?0:n)),typeof o.x2<"u"&&(o.x2=o.x2*r+o.y2*e+(d?0:s)),typeof o.y2<"u"&&(o.y2=c*t+o.y2*i+(d?0:n));function m(y){return y*y}const _=r*i-t*e;if(typeof o.xRot<"u"&&(r!==1||t!==0||e!==0||i!==1))if(_===0)delete o.rX,delete o.rY,delete o.xRot,delete o.lArcFlag,delete o.sweepFlag,o.type=G.LINE_TO;else{const y=o.xRot*Math.PI/180,v=Math.sin(y),g=Math.cos(y),x=1/m(o.rX),E=1/m(o.rY),R=m(g)*x+m(v)*E,S=2*v*g*(x-E),M=m(v)*x+m(g)*E,P=R*i*i-S*t*i+M*t*t,F=S*(r*i+t*e)-2*(R*e*i+M*r*t),U=R*e*e-S*r*e+M*r*r,I=(Math.atan2(F,P-U)+Math.PI)%Math.PI/2,A=Math.sin(I),w=Math.cos(I);o.rX=Math.abs(_)/Math.sqrt(P*m(w)+F*A*w+U*m(A)),o.rY=Math.abs(_)/Math.sqrt(P*m(A)-F*A*w+U*m(w)),o.xRot=I*180/Math.PI}return typeof o.sweepFlag<"u"&&0>_&&(o.sweepFlag=+!o.sweepFlag),o})}function Hy(r,t=0,e=0){Qe(r,t,e);const i=Math.sin(r),s=Math.cos(r);return zr(s,i,-i,s,t-t*s+e*i,e-t*i-e*s)}function $y(r,t=0){return Qe(r,t),zr(1,0,0,1,r,t)}function Xy(r,t=r){return Qe(r,t),zr(r,0,0,t,0,0)}function Vy(r){return Qe(r),zr(1,0,Math.tan(r),1,0,0)}function zy(r){return Qe(r),zr(1,Math.tan(r),0,1,0,0)}function Yy(r=0){return Qe(r),zr(-1,0,0,1,r,0)}function Wy(r=0){return Qe(r),zr(1,0,0,-1,0,r)}function jy(){return Je((r,t,e)=>G.ARC===r.type?Ly(r,r.relative?0:t,r.relative?0:e):r)}function qy(){return Je((r,t,e)=>(r.relative&&(t=0,e=0),G.ARC===r.type&&ma(r,t,e),r))}function Du(){return r=>({...r})}function Ky(){const r=Du(),t=Pu(),e=Nu(),i=Ou(),s=Je((n,o,a)=>{const l=i(e(t(r(n))));function h(c){c>s.maxX&&(s.maxX=c),c<s.minX&&(s.minX=c)}function u(c){c>s.maxY&&(s.maxY=c),c<s.minY&&(s.minY=c)}if(l.type&G.DRAWING_COMMANDS&&(h(o),u(a)),l.type&G.HORIZ_LINE_TO&&h(l.x),l.type&G.VERT_LINE_TO&&u(l.y),l.type&G.LINE_TO&&(h(l.x),u(l.y)),l.type&G.CURVE_TO){h(l.x),u(l.y);const c=Ru(o,l.x1,l.x2,l.x);for(const f of c)0<f&&1>f&&h(Mu(o,l.x1,l.x2,l.x,f));const d=Ru(a,l.y1,l.y2,l.y);for(const f of d)0<f&&1>f&&u(Mu(a,l.y1,l.y2,l.y,f))}if(l.type&G.ARC){h(l.x),u(l.y),ma(l,o,a);const c=l.xRot/180*Math.PI,d=Math.cos(c)*l.rX,f=Math.sin(c)*l.rX,p=-Math.sin(c)*l.rY,m=Math.cos(c)*l.rY,[_,y]=l.phi1<l.phi2?[l.phi1,l.phi2]:-180>l.phi2?[l.phi2+360,l.phi1+360]:[l.phi2,l.phi1],v=([E,R])=>{const S=Math.atan2(R,E)*180/Math.PI;return S<_?S+360:S},g=Su(p,-d,0).map(v);for(const E of g)E>_&&E<y&&h(Iu(l.cX,d,p,E));const x=Su(m,-f,0).map(v);for(const E of x)E>_&&E<y&&u(Iu(l.cY,f,m,E))}return n});return s.minX=1/0,s.maxX=-1/0,s.minY=1/0,s.maxY=-1/0,s}const re={ROUND:Fy,TO_ABS:Pu,TO_REL:ky,NORMALIZE_HVZ:Uy,NORMALIZE_ST:Ou,QT_TO_C:Nu,INFO:Je,SANITIZE:Gy,MATRIX:zr,ROTATE:Hy,TRANSLATE:$y,SCALE:Xy,SKEW_X:Vy,SKEW_Y:zy,X_AXIS_SYMMETRY:Yy,Y_AXIS_SYMMETRY:Wy,A_TO_C:jy,ANNOTATE_ARCS:qy,CLONE:Du,CALCULATE_BOUNDS:Ky,REVERSE_PATH:By};class Lu{round(t){return this.transform(re.ROUND(t))}toAbs(){return this.transform(re.TO_ABS())}toRel(){return this.transform(re.TO_REL())}normalizeHVZ(t,e,i){return this.transform(re.NORMALIZE_HVZ(t,e,i))}normalizeST(){return this.transform(re.NORMALIZE_ST())}qtToC(){return this.transform(re.QT_TO_C())}aToC(){return this.transform(re.A_TO_C())}sanitize(t){return this.transform(re.SANITIZE(t))}translate(t,e){return this.transform(re.TRANSLATE(t,e))}scale(t,e){return this.transform(re.SCALE(t,e))}rotate(t,e,i){return this.transform(re.ROTATE(t,e,i))}matrix(t,e,i,s,n,o){return this.transform(re.MATRIX(t,e,i,s,n,o))}skewX(t){return this.transform(re.SKEW_X(t))}skewY(t){return this.transform(re.SKEW_Y(t))}xSymmetry(t){return this.transform(re.X_AXIS_SYMMETRY(t))}ySymmetry(t){return this.transform(re.Y_AXIS_SYMMETRY(t))}annotateArcs(){return this.transform(re.ANNOTATE_ARCS())}}const Zy=r=>r===" "||r===" "||r==="\r"||r===`
2
- `,Bu=r=>48<=r.charCodeAt(0)&&r.charCodeAt(0)<=57;class Qy extends Lu{constructor(){super(),Xt(this,"curNumber",""),Xt(this,"curCommandType",-1),Xt(this,"curCommandRelative",!1),Xt(this,"canParseCommandOrComma",!0),Xt(this,"curNumberHasExp",!1),Xt(this,"curNumberHasExpDigits",!1),Xt(this,"curNumberHasDecimal",!1),Xt(this,"curArgs",[])}finish(t=[]){if(this.parse(" ",t),this.curArgs.length!==0||!this.canParseCommandOrComma)throw new SyntaxError("Unterminated command at the path end.");return t}parse(t,e=[]){const i=s=>{e.push(s),this.curArgs.length=0,this.canParseCommandOrComma=!0};for(let s=0;s<t.length;s++){const n=t[s],o=this.curCommandType===G.ARC&&(this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber.length===1&&(this.curNumber==="0"||this.curNumber==="1"),a=Bu(n)&&(this.curNumber==="0"&&n==="0"||o);if(Bu(n)&&!a){this.curNumber+=n,this.curNumberHasExpDigits=this.curNumberHasExp;continue}if(n==="e"||n==="E"){this.curNumber+=n,this.curNumberHasExp=!0;continue}if((n==="-"||n==="+")&&this.curNumberHasExp&&!this.curNumberHasExpDigits){this.curNumber+=n;continue}if(n==="."&&!this.curNumberHasExp&&!this.curNumberHasDecimal&&!o){this.curNumber+=n,this.curNumberHasDecimal=!0;continue}if(this.curNumber&&this.curCommandType!==-1){const l=Number(this.curNumber);if(isNaN(l))throw new SyntaxError(`Invalid number ending at ${s}`);if(this.curCommandType===G.ARC){if(this.curArgs.length===0||this.curArgs.length===1){if(0>l)throw new SyntaxError(`Expected positive number, got "${l}" at index "${s}"`)}else if((this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber!=="0"&&this.curNumber!=="1")throw new SyntaxError(`Expected a flag, got "${this.curNumber}" at index "${s}"`)}this.curArgs.push(l),this.curArgs.length===Jy[this.curCommandType]&&(G.HORIZ_LINE_TO===this.curCommandType?i({type:G.HORIZ_LINE_TO,relative:this.curCommandRelative,x:l}):G.VERT_LINE_TO===this.curCommandType?i({type:G.VERT_LINE_TO,relative:this.curCommandRelative,y:l}):this.curCommandType===G.MOVE_TO||this.curCommandType===G.LINE_TO||this.curCommandType===G.SMOOTH_QUAD_TO?(i({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),G.MOVE_TO===this.curCommandType&&(this.curCommandType=G.LINE_TO)):this.curCommandType===G.CURVE_TO?i({type:G.CURVE_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x2:this.curArgs[2],y2:this.curArgs[3],x:this.curArgs[4],y:this.curArgs[5]}):this.curCommandType===G.SMOOTH_CURVE_TO?i({type:G.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===G.QUAD_TO?i({type:G.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===G.ARC&&i({type:G.ARC,relative:this.curCommandRelative,rX:this.curArgs[0],rY:this.curArgs[1],xRot:this.curArgs[2],lArcFlag:this.curArgs[3],sweepFlag:this.curArgs[4],x:this.curArgs[5],y:this.curArgs[6]})),this.curNumber="",this.curNumberHasExpDigits=!1,this.curNumberHasExp=!1,this.curNumberHasDecimal=!1,this.canParseCommandOrComma=!0}if(!Zy(n)){if(n===","&&this.canParseCommandOrComma){this.canParseCommandOrComma=!1;continue}if(n==="+"||n==="-"||n==="."){this.curNumber=n,this.curNumberHasDecimal=n===".";continue}if(a){this.curNumber=n,this.curNumberHasDecimal=!1;continue}if(this.curArgs.length!==0)throw new SyntaxError(`Unterminated command at index ${s}.`);if(!this.canParseCommandOrComma)throw new SyntaxError(`Unexpected character "${n}" at index ${s}. Command cannot follow comma`);if(this.canParseCommandOrComma=!1,n==="z"||n==="Z"){e.push({type:G.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1;continue}else if(n==="h"||n==="H")this.curCommandType=G.HORIZ_LINE_TO,this.curCommandRelative=n==="h";else if(n==="v"||n==="V")this.curCommandType=G.VERT_LINE_TO,this.curCommandRelative=n==="v";else if(n==="m"||n==="M")this.curCommandType=G.MOVE_TO,this.curCommandRelative=n==="m";else if(n==="l"||n==="L")this.curCommandType=G.LINE_TO,this.curCommandRelative=n==="l";else if(n==="c"||n==="C")this.curCommandType=G.CURVE_TO,this.curCommandRelative=n==="c";else if(n==="s"||n==="S")this.curCommandType=G.SMOOTH_CURVE_TO,this.curCommandRelative=n==="s";else if(n==="q"||n==="Q")this.curCommandType=G.QUAD_TO,this.curCommandRelative=n==="q";else if(n==="t"||n==="T")this.curCommandType=G.SMOOTH_QUAD_TO,this.curCommandRelative=n==="t";else if(n==="a"||n==="A")this.curCommandType=G.ARC,this.curCommandRelative=n==="a";else throw new SyntaxError(`Unexpected character "${n}" at index ${s}.`)}}return e}transform(t){return Object.create(this,{parse:{value(e,i=[]){const s=Object.getPrototypeOf(this).parse.call(this,e);for(const n of s){const o=t(n);Array.isArray(o)?i.push(...o):i.push(o)}return i}}})}}const Gt=class ru extends Lu{constructor(t){super(),Xt(this,"commands"),typeof t=="string"?this.commands=ru.parse(t):this.commands=t}encode(){return ru.encode(this.commands)}getBounds(){const t=re.CALCULATE_BOUNDS();return this.transform(t),t}transform(t){const e=[];for(const i of this.commands){const s=t(i);Array.isArray(s)?e.push(...s):e.push(s)}return this.commands=e,this}reverse(t=!0){return this.commands=re.REVERSE_PATH(this.commands,t),this}static encode(t){return Ny(t)}static parse(t){const e=new Qy,i=[];return e.parse(t,i),e.finish(i),i}};Xt(Gt,"CLOSE_PATH",1),Xt(Gt,"MOVE_TO",2),Xt(Gt,"HORIZ_LINE_TO",4),Xt(Gt,"VERT_LINE_TO",8),Xt(Gt,"LINE_TO",16),Xt(Gt,"CURVE_TO",32),Xt(Gt,"SMOOTH_CURVE_TO",64),Xt(Gt,"QUAD_TO",128),Xt(Gt,"SMOOTH_QUAD_TO",256),Xt(Gt,"ARC",512),Xt(Gt,"LINE_COMMANDS",Gt.LINE_TO|Gt.HORIZ_LINE_TO|Gt.VERT_LINE_TO),Xt(Gt,"DRAWING_COMMANDS",Gt.HORIZ_LINE_TO|Gt.VERT_LINE_TO|Gt.LINE_TO|Gt.CURVE_TO|Gt.SMOOTH_CURVE_TO|Gt.QUAD_TO|Gt.SMOOTH_QUAD_TO|Gt.ARC);let G=Gt;const Jy={[G.MOVE_TO]:2,[G.LINE_TO]:2,[G.HORIZ_LINE_TO]:1,[G.VERT_LINE_TO]:1,[G.CLOSE_PATH]:0,[G.QUAD_TO]:4,[G.SMOOTH_QUAD_TO]:2,[G.CURVE_TO]:6,[G.SMOOTH_CURVE_TO]:4,[G.ARC]:7},t_=r=>{const t=new G(r).toAbs().commands,e=[];let i=[],s=null;for(const n of t)switch(n.type){case G.MOVE_TO:i.length>0&&(e.push({points:i}),i=[]),s=[n.x,n.y],i.push(s);break;case G.LINE_TO:i.push([n.x,n.y]);break;case G.HORIZ_LINE_TO:const o=i[i.length-1][1];i.push([n.x,o]);break;case G.VERT_LINE_TO:const a=i[i.length-1][0];i.push([a,n.y]);break;case G.CURVE_TO:case G.SMOOTH_CURVE_TO:case G.QUAD_TO:case G.SMOOTH_QUAD_TO:case G.ARC:i.push([n.x,n.y]);break}if(i.length>2&&e.push({points:i}),e.length>0){const n=Ue(e[0].points);return{rings:e,bounds:n}}},e_=r=>{const[t,e,i]=r.match(/(<polygon points=["|'])([^("|')]*)/)||[],s=i.split(" ").map(n=>n.split(",").map(parseFloat));return{type:Tt.POLYGON,geometry:{points:s,bounds:Ue(s)}}},r_=r=>{const t=Au(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:Tt.ELLIPSE,geometry:{cx:e,cy:i,rx:s,ry:n,bounds:o}}},i_=r=>{const t=Au(r),e=(t.nodeName==="path"?[t]:Array.from(t.querySelectorAll("path"))).map(n=>n.getAttribute("d")||"").map(n=>t_(n)).filter(Boolean),i=e.reduce((n,o)=>[...n,...o.rings[0].points],[]),s=Ue(i);return e.length===1&&e[0].rings.length===1?{type:Tt.POLYGON,geometry:{points:i,bounds:s}}:{type:Tt.MULTIPOLYGLON,geometry:{polygons:e,bounds:s}}},s_=r=>{const t=typeof r=="string"?r:r.value;if(t.includes("<polygon points="))return e_(t);if(t.includes("<path "))return i_(t);if(t.includes("<ellipse "))return r_(t);throw"Unsupported SVG shape: "+t},n_=r=>`<g>${r.polygons.map(t=>`<path fill-rule="evenodd" d="${Ze(t)}" />`).join("")}</g>`,o_=r=>{let t;if(r.type===Tt.POLYGON){const e=r.geometry,{points:i}=e;t=`<svg><polygon points="${i.map(s=>s.join(",")).join(" ")}" /></svg>`}else if(r.type===Tt.ELLIPSE){const e=r.geometry;t=`<svg><ellipse cx="${e.cx}" cy="${e.cy}" rx="${e.rx}" ry="${e.ry}" /></svg>`}else if(r.type===Tt.MULTIPOLYGLON){const e=r.geometry;t=`<svg>${n_(e)}</svg>`}if(t)return{type:"SvgSelector",value:t};throw`Unsupported shape type: ${r.type}`},Ee=[];for(let r=0;r<256;++r)Ee.push((r+256).toString(16).slice(1));function a_(r,t=0){return(Ee[r[t+0]]+Ee[r[t+1]]+Ee[r[t+2]]+Ee[r[t+3]]+"-"+Ee[r[t+4]]+Ee[r[t+5]]+"-"+Ee[r[t+6]]+Ee[r[t+7]]+"-"+Ee[r[t+8]]+Ee[r[t+9]]+"-"+Ee[r[t+10]]+Ee[r[t+11]]+Ee[r[t+12]]+Ee[r[t+13]]+Ee[r[t+14]]+Ee[r[t+15]]).toLowerCase()}let ya;const l_=new Uint8Array(16);function h_(){if(!ya){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ya=crypto.getRandomValues.bind(crypto)}return ya(l_)}const u_=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Fu={randomUUID:u_};function ku(r,t,e){var i;if(Fu.randomUUID&&!r)return Fu.randomUUID();r=r||{};const s=r.random??((i=r.rng)==null?void 0:i.call(r))??h_();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,a_(s)}var Uu=Object.prototype.hasOwnProperty;function Yr(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--&&Yr(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(Uu.call(r,e)&&++i&&!Uu.call(t,e)||!(e in t)||!Yr(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}function _a(){}function c_(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}const zi=[];function va(r,t=_a){let e;const i=new Set;function s(a){if(c_(r,a)&&(r=a,e)){const l=!zi.length;for(const h of i)h[1](),zi.push(h,r);if(l){for(let h=0;h<zi.length;h+=2)zi[h][0](zi[h+1]);zi.length=0}}}function n(a){s(a(r))}function o(a,l=_a){const h=[a,l];return i.add(h),i.size===1&&(e=t(s,n)||_a),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:o}}const d_=r=>{const{subscribe:t,set:e}=va();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 Gu=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(Gu||{});const Sn={selected:[]},f_=(r,t,e)=>{const{subscribe:i,set:s}=va(Sn);let n=t,o=Sn;i(m=>o=m);const a=()=>{Yr(o,Sn)||s(Sn)},l=()=>{var m;return((m=o.selected)==null?void 0:m.length)===0},h=m=>{if(l())return!1;const _=typeof m=="string"?m:m.id;return o.selected.some(y=>y.id===_)},u=(m,_)=>{let y;if(Array.isArray(m)){if(y=m.map(g=>r.getAnnotation(g)).filter(Boolean),y.length<m.length){console.warn("Invalid selection: "+m.filter(g=>!y.some(x=>x.id===g)));return}}else{const g=r.getAnnotation(m);if(!g){console.warn("Invalid selection: "+m);return}y=[g]}const v=y.reduce((g,x)=>{const E=xa(x,n,e);return E==="EDIT"?[...g,{id:x.id,editable:!0}]:E==="SELECT"?[...g,{id:x.id}]:g},[]);s({selected:v,event:_})},c=(m,_)=>{const y=Array.isArray(m)?m:[m],v=y.map(g=>r.getAnnotation(g)).filter(g=>!!g);s({selected:v.map(g=>{const x=_===void 0?xa(g,n,e)==="EDIT":_;return{id:g.id,editable:x}})}),v.length!==y.length&&console.warn("Invalid selection",m)},d=m=>{if(l())return!1;const{selected:_}=o;_.some(({id:y})=>m.includes(y))&&s({selected:_.filter(({id:y})=>!m.includes(y))})},f=m=>{n=m,c(o.selected.map(({id:_})=>_))},p=m=>xa(m,n,e);return r.observe(({changes:m})=>d((m.deleted||[]).map(_=>_.id))),{get event(){return o?o.event:null},get selected(){return o?[...o.selected]:null},get userSelectAction(){return n},clear:a,evalSelectAction:p,isEmpty:l,isSelected:h,setSelected:c,setUserSelectAction:f,subscribe:i,userSelect:u}},xa=(r,t,e)=>{const i=e?e.serialize(r):r;return typeof t=="function"?t(i):t||"EDIT"},we=[];for(let r=0;r<256;++r)we.push((r+256).toString(16).slice(1));function p_(r,t=0){return(we[r[t+0]]+we[r[t+1]]+we[r[t+2]]+we[r[t+3]]+"-"+we[r[t+4]]+we[r[t+5]]+"-"+we[r[t+6]]+we[r[t+7]]+"-"+we[r[t+8]]+we[r[t+9]]+"-"+we[r[t+10]]+we[r[t+11]]+we[r[t+12]]+we[r[t+13]]+we[r[t+14]]+we[r[t+15]]).toLowerCase()}let ba;const m_=new Uint8Array(16);function g_(){if(!ba){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ba=crypto.getRandomValues.bind(crypto)}return ba(m_)}const y_=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Hu={randomUUID:y_};function __(r,t,e){var i;if(Hu.randomUUID&&!r)return Hu.randomUUID();r=r||{};const s=r.random??((i=r.rng)==null?void 0:i.call(r))??g_();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,p_(s)}const Ea=r=>{const t=e=>{const i={...e};return e.created&&typeof e.created=="string"&&(i.created=new Date(e.created)),e.updated&&typeof e.updated=="string"&&(i.updated=new Date(e.updated)),i};return{...r,bodies:(r.bodies||[]).map(t),target:t(r.target)}},v_=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},x_=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},b_=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!Yr(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),E_=(r,t)=>!Yr(r.target,t.target),$u=(r,t)=>{const e=v_(r,t),i=x_(r,t),s=b_(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:E_(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var Bt=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(Bt||{});const w_=(r,t)=>{var e,i;const{changes:s,origin:n}=t;if(!(r.options.origin?r.options.origin===n:n!=="SILENT"))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(u=>a(u.bodiesCreated)||a(u.bodiesDeleted)||a(u.bodiesUpdated)),h=(i=s.updated)==null?void 0:i.some(u=>u.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},T_=(r,t)=>{const e=new Set((r.created||[]).map(c=>c.id)),i=new Set((r.updated||[]).map(({newValue:c})=>c.id)),s=new Set((t.created||[]).map(c=>c.id)),n=new Set((t.deleted||[]).map(c=>c.id)),o=new Set((t.updated||[]).map(({oldValue:c})=>c.id)),a=new Set((t.updated||[]).filter(({oldValue:c})=>e.has(c.id)||i.has(c.id)).map(({oldValue:c})=>c.id)),l=[...(r.created||[]).filter(c=>!n.has(c.id)).map(c=>o.has(c.id)?t.updated.find(({oldValue:d})=>d.id===c.id).newValue:c),...t.created||[]],h=[...(r.deleted||[]).filter(c=>!s.has(c.id)),...(t.deleted||[]).filter(c=>!e.has(c.id))],u=[...(r.updated||[]).filter(({newValue:c})=>!n.has(c.id)).map(c=>{const{oldValue:d,newValue:f}=c;if(o.has(f.id)){const p=t.updated.find(m=>m.oldValue.id===f.id).newValue;return $u(d,p)}else return c}),...(t.updated||[]).filter(({oldValue:c})=>!a.has(c.id))];return{created:l,deleted:h,updated:u}},Cn=r=>{const t=r.id===void 0?__():r.id;return{...r,id:t,bodies:r.bodies===void 0?[]:r.bodies.map(e=>({...e,annotation:t})),target:{...r.target,annotation:t}}},A_=r=>r.id!==void 0,S_=()=>{const r=new Map,t=new Map,e=[],i=(I,A={})=>{e.push({onChange:I,options:A})},s=I=>{const A=e.findIndex(w=>w.onChange==I);A>-1&&e.splice(A,1)},n=(I,A)=>{const w={origin:I,changes:{created:A.created||[],updated:A.updated||[],deleted:A.deleted||[]},state:[...r.values()]};e.forEach(C=>{w_(C,w)&&C.onChange(w)})},o=(I,A=Bt.LOCAL)=>{if(I.id&&r.get(I.id))throw Error(`Cannot add annotation ${I.id} - exists already`);{const w=Cn(I);r.set(w.id,w),w.bodies.forEach(C=>t.set(C.id,w.id)),n(A,{created:[w]})}},a=(I,A)=>{const w=Cn(typeof I=="string"?A:I),C=typeof I=="string"?I:I.id,D=C&&r.get(C);if(D){const N=$u(D,w);return C===w.id?r.set(C,w):(r.delete(C),r.set(w.id,w)),D.bodies.forEach(B=>t.delete(B.id)),w.bodies.forEach(B=>t.set(B.id,w.id)),N}else console.warn(`Cannot update annotation ${C} - does not exist`)},l=(I,A=Bt.LOCAL,w=Bt.LOCAL)=>{const C=A_(A)?w:A,D=a(I,A);D&&n(C,{updated:[D]})},h=(I,A=Bt.LOCAL)=>{r.get(I.id)?l(I,A):o(I,A)},u=(I,A=Bt.LOCAL)=>{const w=I.reduce((C,D)=>{const N=a(D);return N?[...C,N]:C},[]);w.length>0&&n(A,{updated:w})},c=(I,A=Bt.LOCAL)=>{const w=I.map(Cn),{toAdd:C,toUpdate:D}=w.reduce((B,V)=>r.get(V.id)?{...B,toUpdate:[...B.toUpdate,V]}:{...B,toAdd:[...B.toAdd,V]},{toAdd:[],toUpdate:[]}),N=D.map(B=>a(B,A)).filter(Boolean);C.forEach(B=>{r.set(B.id,B),B.bodies.forEach(V=>t.set(V.id,B.id))}),n(A,{created:C,updated:N})},d=(I,A=Bt.LOCAL)=>{const w=r.get(I.annotation);if(w){const C={...w,bodies:[...w.bodies,I]};r.set(w.id,C),t.set(I.id,C.id),n(A,{updated:[{oldValue:w,newValue:C,bodiesCreated:[I]}]})}else console.warn(`Attempt to add body to missing annotation: ${I.annotation}`)},f=()=>[...r.values()],p=(I=Bt.LOCAL)=>{const A=[...r.values()];r.clear(),t.clear(),n(I,{deleted:A})},m=(I,A=!0,w=Bt.LOCAL)=>{const C=I.map(Cn);if(A){const D=[...r.values()];r.clear(),t.clear(),C.forEach(N=>{r.set(N.id,N),N.bodies.forEach(B=>t.set(B.id,N.id))}),n(w,{created:C,deleted:D})}else{const D=I.reduce((N,B)=>{const V=B.id&&r.get(B.id);return V?[...N,V]:N},[]);if(D.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${D.map(N=>N.id).join(", ")}`);C.forEach(N=>{r.set(N.id,N),N.bodies.forEach(B=>t.set(B.id,N.id))}),n(w,{created:C})}},_=I=>{const A=typeof I=="string"?I:I.id,w=r.get(A);if(w)return r.delete(A),w.bodies.forEach(C=>t.delete(C.id)),w;console.warn(`Attempt to delete missing annotation: ${A}`)},y=(I,A=Bt.LOCAL)=>{const w=_(I);w&&n(A,{deleted:[w]})},v=(I,A=Bt.LOCAL)=>{const w=I.reduce((C,D)=>{const N=_(D);return N?[...C,N]:C},[]);w.length>0&&n(A,{deleted:w})},g=I=>{const A=r.get(I.annotation);if(A){const w=A.bodies.find(C=>C.id===I.id);if(w){t.delete(w.id);const C={...A,bodies:A.bodies.filter(D=>D.id!==I.id)};return r.set(A.id,C),{oldValue:A,newValue:C,bodiesDeleted:[w]}}else console.warn(`Attempt to delete missing body ${I.id} from annotation ${I.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${I.annotation}`)},x=(I,A=Bt.LOCAL)=>{const w=g(I);w&&n(A,{updated:[w]})},E=(I,A=Bt.LOCAL)=>{const w=I.map(C=>g(C)).filter(Boolean);w.length>0&&n(A,{updated:w})},R=I=>{const A=r.get(I);return A?{...A}:void 0},S=I=>{const A=t.get(I);if(A){const w=R(A).bodies.find(C=>C.id===I);if(w)return w;console.error(`Store integrity error: body ${I} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${I}`)},M=(I,A)=>{if(I.annotation!==A.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const w=r.get(I.annotation);if(w){const C=w.bodies.find(N=>N.id===I.id),D={...w,bodies:w.bodies.map(N=>N.id===C.id?A:N)};return r.set(w.id,D),C.id!==A.id&&(t.delete(C.id),t.set(A.id,D.id)),{oldValue:w,newValue:D,bodiesUpdated:[{oldBody:C,newBody:A}]}}else console.warn(`Attempt to add body to missing annotation ${I.annotation}`)},P=(I,A,w=Bt.LOCAL)=>{const C=M(I,A);C&&n(w,{updated:[C]})},F=(I,A=Bt.LOCAL)=>{const w=I.map(C=>M({id:C.id,annotation:C.annotation},C)).filter(Boolean);n(A,{updated:w})},U=I=>{const A=r.get(I.annotation);if(A){const w={...A,target:{...A.target,...I}};return r.set(A.id,w),{oldValue:A,newValue:w,targetUpdated:{oldTarget:A.target,newTarget:I}}}else console.warn(`Attempt to update target on missing annotation: ${I.annotation}`)};return{addAnnotation:o,addBody:d,all:f,bulkAddAnnotations:m,bulkDeleteAnnotations:v,bulkDeleteBodies:E,bulkUpdateAnnotations:u,bulkUpdateBodies:F,bulkUpdateTargets:(I,A=Bt.LOCAL)=>{const w=I.map(C=>U(C)).filter(Boolean);w.length>0&&n(A,{updated:w})},bulkUpsertAnnotations:c,clear:p,deleteAnnotation:y,deleteBody:x,getAnnotation:R,getBody:S,observe:i,unobserve:s,updateAnnotation:l,updateBody:P,updateTarget:(I,A=Bt.LOCAL)=>{const w=U(I);w&&n(A,{updated:[w]})},upsertAnnotation:h}},C_=r=>({...r,subscribe:t=>{const e=i=>t(i.state);return r.observe(e),t(r.all()),()=>r.unobserve(e)}});let I_=()=>({emit(r,...t){for(let e=this.events[r]||[],i=0,s=e.length;i<s;i++)e[i](...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 R_=250,M_=(r,t)=>{const e=I_(),i=(t==null?void 0:t.changes)||[];let s=t?t.pointer:-1,n=!1,o=0;const a=p=>{if(!n){const{changes:m}=p,_=performance.now();if(_-o>R_)i.splice(s+1),i.push(m),s=i.length-1;else{const y=i.length-1;i[y]=T_(i[y],m)}o=_}n=!1};r.observe(a,{origin:Bt.LOCAL});const l=p=>p&&p.length>0&&r.bulkDeleteAnnotations(p),h=p=>p&&p.length>0&&r.bulkAddAnnotations(p,!1),u=p=>p&&p.length>0&&r.bulkUpdateAnnotations(p.map(({oldValue:m})=>m)),c=p=>p&&p.length>0&&r.bulkUpdateAnnotations(p.map(({newValue:m})=>m)),d=p=>p&&p.length>0&&r.bulkAddAnnotations(p,!1),f=p=>p&&p.length>0&&r.bulkDeleteAnnotations(p);return{canRedo:()=>i.length-1>s,canUndo:()=>s>-1,destroy:()=>r.unobserve(a),getHistory:()=>({changes:[...i],pointer:s}),on:(p,m)=>e.on(p,m),redo:()=>{if(i.length-1>s){n=!0;const{created:p,updated:m,deleted:_}=i[s+1];h(p),c(m),f(_),e.emit("redo",i[s+1]),s+=1}},undo:()=>{if(s>-1){n=!0;const{created:p,updated:m,deleted:_}=i[s];l(p),u(m),d(_),e.emit("undo",i[s]),s-=1}}}},P_=()=>{const{subscribe:r,set:t}=va([]);return{subscribe:r,set:t}},O_=(r,t,e,i)=>{const{hover:s,selection:n,store:o,viewport:a}=r,l=new Map;let h=[],u,c;const d=(y,v)=>{l.has(y)?l.get(y).push(v):l.set(y,[v])},f=(y,v)=>{const g=l.get(y);if(g){const x=g.indexOf(v);x!==-1&&g.splice(x,1)}},p=(y,v,g)=>{l.has(y)&&setTimeout(()=>{l.get(y).forEach(x=>{if(e){const E=Array.isArray(v)?v.map(S=>e.serialize(S)):e.serialize(v),R=g?g instanceof PointerEvent?g:e.serialize(g):void 0;x(E,R)}else x(v,g)})},1)},m=()=>{const{selected:y}=n,v=(y||[]).map(({id:g})=>o.getAnnotation(g));v.forEach(g=>{const x=h.find(E=>E.id===g.id);(!x||!Yr(x,g))&&p("updateAnnotation",g,x)}),h=h.map(g=>v.find(({id:x})=>x===g.id)||g)};n.subscribe(({selected:y})=>{if(!(h.length===0&&y.length===0)){if(h.length===0&&y.length>0)h=y.map(({id:v})=>o.getAnnotation(v));else if(h.length>0&&y.length===0)h.forEach(v=>{const g=o.getAnnotation(v.id);g&&!Yr(g,v)&&p("updateAnnotation",g,v)}),h=[];else{const v=new Set(h.map(x=>x.id)),g=new Set(y.map(({id:x})=>x));h.filter(x=>!g.has(x.id)).forEach(x=>{const E=o.getAnnotation(x.id);E&&!Yr(E,x)&&p("updateAnnotation",E,x)}),h=[...h.filter(x=>g.has(x.id)),...y.filter(({id:x})=>!v.has(x)).map(({id:x})=>o.getAnnotation(x))]}p("selectionChanged",h)}}),s.subscribe(y=>{!u&&y?p("mouseEnterAnnotation",o.getAnnotation(y)):u&&!y?p("mouseLeaveAnnotation",o.getAnnotation(u)):u&&y&&(p("mouseLeaveAnnotation",o.getAnnotation(u)),p("mouseEnterAnnotation",o.getAnnotation(y))),u=y}),a==null||a.subscribe(y=>p("viewportIntersect",y.map(v=>o.getAnnotation(v)))),o.observe(y=>{i&&(c&&clearTimeout(c),c=setTimeout(m,1e3));const{created:v,deleted:g}=y.changes;(v||[]).forEach(x=>p("createAnnotation",x)),(g||[]).forEach(x=>p("deleteAnnotation",x)),(y.changes.updated||[]).filter(x=>[...x.bodiesCreated||[],...x.bodiesDeleted||[],...x.bodiesUpdated||[]].length>0).forEach(({oldValue:x,newValue:E})=>{const R=h.find(S=>S.id===x.id)||x;h=h.map(S=>S.id===x.id?E:S),p("updateAnnotation",E,R)})},{origin:Bt.LOCAL}),o.observe(y=>{if(h){const v=new Set(h.map(x=>x.id)),g=(y.changes.updated||[]).filter(({newValue:x})=>v.has(x.id)).map(({newValue:x})=>x);g.length>0&&(h=h.map(x=>g.find(E=>E.id===x.id)||x))}},{origin:Bt.REMOTE});const _=y=>v=>{const{updated:g}=v;y?(g||[]).forEach(x=>p("updateAnnotation",x.oldValue,x.newValue)):(g||[]).forEach(x=>p("updateAnnotation",x.newValue,x.oldValue))};return t.on("undo",_(!0)),t.on("redo",_(!1)),{on:d,off:f,emit:p}},N_=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:[]}),D_=(r,t,e)=>{const{store:i,selection:s}=r,n=y=>{if(e){const{parsed:v,error:g}=e.parse(y);v?i.addAnnotation(v,Bt.REMOTE):console.error(g)}else i.addAnnotation(Ea(y),Bt.REMOTE)},o=()=>s.clear(),a=()=>i.clear(),l=y=>{const v=i.getAnnotation(y);return e&&v?e.serialize(v):v},h=()=>e?i.all().map(e.serialize):i.all(),u=()=>{var y;const v=(((y=s.selected)==null?void 0:y.map(g=>g.id))||[]).map(g=>i.getAnnotation(g)).filter(Boolean);return e?v.map(e.serialize):v},c=(y,v=!0)=>fetch(y).then(g=>g.json()).then(g=>(f(g,v),g)),d=y=>{if(typeof y=="string"){const v=i.getAnnotation(y);if(i.deleteAnnotation(y),v)return e?e.serialize(v):v}else{const v=e?e.parse(y).parsed:y;if(v)return i.deleteAnnotation(v),y}},f=(y,v=!0)=>{if(e){const g=e.parseAll||N_(e),{parsed:x,failed:E}=g(y);E.length>0&&console.warn(`Discarded ${E.length} invalid annotations`,E),i.bulkAddAnnotations(x,v,Bt.REMOTE)}else i.bulkAddAnnotations(y.map(Ea),v,Bt.REMOTE)},p=(y,v)=>{y?s.setSelected(y,v):s.clear()},m=y=>{s.clear(),s.setUserSelectAction(y)},_=y=>{if(e){const v=e.parse(y).parsed,g=e.serialize(i.getAnnotation(v.id));return i.updateAnnotation(v),g}else{const v=i.getAnnotation(y.id);return i.updateAnnotation(Ea(y)),v}};return{addAnnotation:n,cancelSelected:o,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getHistory:t.getHistory,getSelected:u,loadAnnotations:c,redo:t.redo,removeAnnotation:d,setAnnotations:f,setSelected:p,setUserSelectAction:m,undo:t.undo,updateAnnotation:_}},L_=(r,t,e)=>typeof t=="function"?t(r,e):t,B_=(r,t)=>typeof r!="function"&&typeof t!="function"?{...r||{},...t||{}}:(e,i)=>{const s=typeof r=="function"?r(e,i):r,n=typeof t=="function"?t(e,i):t;return{...s||{},...n||{}}},F_="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let k_=r=>crypto.getRandomValues(new Uint8Array(r)),U_=(r,t,e)=>{let i=(2<<Math.log2(r.length-1))-1,s=-~(1.6*i*t/r.length);return(n=t)=>{let o="";for(;;){let a=e(s),l=s|0;for(;l--;)if(o+=r[a[l]&i]||"",o.length>=n)return o}}},G_=(r,t=21)=>U_(r,t|0,k_),H_=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=F_[e[r]&63];return t};const $_=()=>({isGuest:!0,id:G_("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),X_=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}`},Xu=r=>r?typeof r=="object"?{...r}:r:void 0,V_=(r,t)=>(Array.isArray(r)?r:[r]).map(e=>{const{id:i,type:s,purpose:n,value:o,created:a,modified:l,creator:h,...u}=e;return{id:i||`temp-${X_(e)}`,annotation:t,type:s,purpose:n,value:o,creator:Xu(h),created:a?new Date(a):void 0,updated:l?new Date(l):void 0,...u}}),z_=r=>r.map(t=>{var e;const{annotation:i,created:s,updated:n,...o}=t,a={...o,created:s==null?void 0:s.toISOString(),modified:n==null?void 0:n.toISOString()};return(e=a.id)!=null&&e.startsWith("temp-")&&delete a.id,a});H_();const Y_=(r,t={strict:!0,invertY:!1})=>({parse:e=>W_(e,t),serialize:e=>j_(e,r,t)}),W_=(r,t={strict:!0,invertY:!1})=>{const e=r.id||ku(),{creator:i,created:s,modified:n,body:o,...a}=r,l=V_(o||[],e),h=Array.isArray(r.target)?r.target[0]:r.target,u=typeof h=="string"?h:Array.isArray(h.selector)?h.selector[0]:h.selector,c=typeof u=="string"||(u==null?void 0:u.type)==="FragmentSelector"?My(u,t.invertY):(u==null?void 0:u.type)==="SvgSelector"?s_(u):void 0,d=Array.isArray(a.target)?a.target[0]:a.targret;return c||!t.strict?{parsed:{...a,id:e,bodies:l,target:{created:s?new Date(s):void 0,creator:Xu(i),updated:n?new Date(n):void 0,...typeof d=="string"?{}:d,annotation:e,selector:c||u}}}:{error:Error(`Invalid selector: ${JSON.stringify(u)}`)}},j_=(r,t,e={strict:!0,invertY:!1})=>{const{selector:i,creator:s,created:n,updated:o,updatedBy:a,...l}=r.target;let h;try{h=i.type==Tt.RECTANGLE?Py(i.geometry):o_(i)}catch(c){if(e.strict)throw c;h=i}const u={...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:r.id,type:"Annotation",body:z_(r.bodies),created:n==null?void 0:n.toISOString(),creator:s,modified:o==null?void 0:o.toISOString(),target:{...l,source:t,type:"SpecificResource",selector:h}};return delete u.bodies,"annotation"in u.target&&delete u.target.annotation,u},wa=(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))},Yi=[];function q_(r,t=Dt){let e;const i=new Set;function s(a){if(le(r,a)&&(r=a,e)){const l=!Yi.length;for(const h of i)h[1](),Yi.push(h,r);if(l){for(let h=0;h<Yi.length;h+=2)Yi[h][0](Yi[h+1]);Yi.length=0}}}function n(a){s(a(r))}function o(a,l=Dt){const h=[a,l];return i.add(h),i.size===1&&(e=t(s,n)||Dt),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:o}}const K_=(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}`)},Z_=(r,t)=>{K_(r,t);const{subscribe:e,set:i}=q_(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}},Os=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:s,stroke:n,strokeWidth:o,strokeOpacity:a}=e;let l="";return i&&(l+=`fill:${i};`,l+=`fill-opacity:${s||"0.25"};`),n&&(l+=`stroke:${n};`,l+=`stroke-width:${o||"1"};`,l+=`stroke-opacity:${a||"1"};`),l}},In=(r,t=0)=>{const{minX:e,minY:i,maxX:s,maxY:n}=r;return{x:e-t,y:i-t,w:s-e+2*t,h:n-i+2*t}},Cr=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,Q_=r=>({}),Vu=r=>({grab:r[0]});function J_(r){let t,e,i,s;const n=r[8].default,o=dy(n,r,r[7],Vu);return{c(){t=Z("g"),o&&o.c(),b(t,"class","a9s-annotation selected")},m(a,l){it(a,t,l),o&&o.m(t,null),e=!0,i||(s=[Rt(t,"pointerup",r[2]),Rt(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&128)&&py(o,n,a,a[7],e?fy(n,a[7],l,Q_):my(a[7]),Vu)},i(a){e||(ot(o,a),e=!0)},o(a){gt(o,a),e=!1},d(a){a&&rt(t),o&&o.d(a),i=!1,$e(s)}}}function t0(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=Xr();let{shape:o}=t,{editor:a}=t,{transform:l}=t,{svgEl:h}=t,u,c,d;const f=_=>y=>{if(u=_,h){const{left:v,top:g}=h.getBoundingClientRect(),x=y.clientX-v,E=y.clientY-g;c=l.elementToImage(x,E)}else{const{offsetX:v,offsetY:g}=y;c=l.elementToImage(v,g)}d=o,y.target.setPointerCapture(y.pointerId),n("grab",y)},p=_=>{if(u){const[y,v]=l.elementToImage(_.offsetX,_.offsetY),g=[y-c[0],v-c[1]];e(3,o=a(d,u,g)),n("change",o)}},m=_=>{_.target.releasePointerCapture(_.pointerId),u=void 0,d=o,n("release",_)};return r.$$set=_=>{"shape"in _&&e(3,o=_.shape),"editor"in _&&e(4,a=_.editor),"transform"in _&&e(5,l=_.transform),"svgEl"in _&&e(6,h=_.svgEl),"$$scope"in _&&e(7,s=_.$$scope)},[f,p,m,o,a,l,h,s,i]}class Ta extends De{constructor(t){super(),Ne(this,t,t0,J_,le,{shape:3,editor:4,transform:5,svgEl:6})}}function e0(r){let t,e,i,s,n,o,a,l,h=r[3]&&zu(r);return{c(){t=Z("g"),e=Z("circle"),h&&h.c(),s=Z("circle"),b(e,"class","a9s-handle-buffer"),b(e,"cx",r[0]),b(e,"cy",r[1]),b(e,"r",i=r[5]+6/r[2]),b(s,"class",n=`a9s-handle-dot${r[3]?" selected":""}`),b(s,"cx",r[0]),b(s,"cy",r[1]),b(s,"r",r[5]),b(t,"class",o=`a9s-handle ${r[8].class||""}`.trim())},m(u,c){it(u,t,c),wt(t,e),h&&h.m(t,null),wt(t,s),a||(l=[Rt(e,"pointerenter",r[11]),Rt(e,"pointerleave",r[12]),Rt(e,"pointerdown",r[13]),Rt(e,"pointerdown",r[6]),Rt(e,"pointerup",r[14]),Rt(e,"pointerup",r[7])],a=!0)},p(u,c){c&1&&b(e,"cx",u[0]),c&2&&b(e,"cy",u[1]),c&36&&i!==(i=u[5]+6/u[2])&&b(e,"r",i),u[3]?h?h.p(u,c):(h=zu(u),h.c(),h.m(t,s)):h&&(h.d(1),h=null),c&8&&n!==(n=`a9s-handle-dot${u[3]?" selected":""}`)&&b(s,"class",n),c&1&&b(s,"cx",u[0]),c&2&&b(s,"cy",u[1]),c&32&&b(s,"r",u[5]),c&256&&o!==(o=`a9s-handle ${u[8].class||""}`.trim())&&b(t,"class",o)},d(u){u&&rt(t),h&&h.d(),a=!1,$e(l)}}}function r0(r){let t,e,i,s,n,o,a,l,h;return{c(){t=Z("g"),e=Z("circle"),s=Z("circle"),o=Z("circle"),b(e,"cx",r[0]),b(e,"cy",r[1]),b(e,"r",i=r[5]*10),b(e,"class","a9s-touch-halo"),cr(e,"touched",r[4]),b(s,"cx",r[0]),b(s,"cy",r[1]),b(s,"r",n=r[5]+10/r[2]),b(s,"class","a9s-handle-buffer"),b(o,"class","a9s-handle-dot"),b(o,"cx",r[0]),b(o,"cy",r[1]),b(o,"r",a=r[5]+2/r[2]),b(t,"class","a9s-touch-handle")},m(u,c){it(u,t,c),wt(t,e),wt(t,s),wt(t,o),l||(h=[Rt(s,"pointerdown",r[9]),Rt(s,"pointerup",r[10]),Rt(s,"pointerdown",r[6]),Rt(s,"pointerup",r[7])],l=!0)},p(u,c){c&1&&b(e,"cx",u[0]),c&2&&b(e,"cy",u[1]),c&32&&i!==(i=u[5]*10)&&b(e,"r",i),c&16&&cr(e,"touched",u[4]),c&1&&b(s,"cx",u[0]),c&2&&b(s,"cy",u[1]),c&36&&n!==(n=u[5]+10/u[2])&&b(s,"r",n),c&1&&b(o,"cx",u[0]),c&2&&b(o,"cy",u[1]),c&36&&a!==(a=u[5]+2/u[2])&&b(o,"r",a)},d(u){u&&rt(t),l=!1,$e(h)}}}function zu(r){let t,e;return{c(){t=Z("circle"),b(t,"class","a9s-handle-selected"),b(t,"cx",r[0]),b(t,"cy",r[1]),b(t,"r",e=r[5]+8/r[2])},m(i,s){it(i,t,s)},p(i,s){s&1&&b(t,"cx",i[0]),s&2&&b(t,"cy",i[1]),s&36&&e!==(e=i[5]+8/i[2])&&b(t,"r",e)},d(i){i&&rt(t)}}}function i0(r){let t;function e(s,n){return Cr?r0:e0}let i=e()(r);return{c(){i.c(),t=Fe()},m(s,n){i.m(s,n),it(s,t,n)},p(s,[n]){i.p(s,n)},i:Dt,o:Dt,d(s){s&&rt(t),i.d(s)}}}function s0(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t,{selected:a=void 0}=t,l=!1;const h=y=>{y.pointerType==="touch"&&e(4,l=!0)},u=()=>e(4,l=!1);function c(y){Ce.call(this,r,y)}function d(y){Ce.call(this,r,y)}function f(y){Ce.call(this,r,y)}function p(y){Ce.call(this,r,y)}function m(y){Ce.call(this,r,y)}function _(y){Ce.call(this,r,y)}return r.$$set=y=>{e(8,t=sa(sa({},t),mu(y))),"x"in y&&e(0,s=y.x),"y"in y&&e(1,n=y.y),"scale"in y&&e(2,o=y.scale),"selected"in y&&e(3,a=y.selected)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=4/o)},t=mu(t),[s,n,o,a,l,i,h,u,t,c,d,f,p,m,_]}class Wi extends De{constructor(t){super(),Ne(this,t,s0,i0,le,{x:0,y:1,scale:2,selected:3})}}function n0(r){let t,e,i,s,n,o,a;return{c(){t=Z("g"),e=Z("circle"),s=Z("circle"),n=Z("circle"),b(e,"class","a9s-polygon-midpoint-buffer svelte-12ykj76"),b(e,"cx",r[0]),b(e,"cy",r[1]),b(e,"r",i=1.75*r[2]),b(s,"class","a9s-polygon-midpoint-outer svelte-12ykj76"),b(s,"cx",r[0]),b(s,"cy",r[1]),b(s,"r",r[2]),b(n,"class","a9s-polygon-midpoint-inner svelte-12ykj76"),b(n,"cx",r[0]),b(n,"cy",r[1]),b(n,"r",r[2]),b(t,"class","a9s-polygon-midpoint svelte-12ykj76")},m(l,h){it(l,t,h),wt(t,e),wt(t,s),wt(t,n),o||(a=[Rt(e,"pointerdown",r[5]),Rt(e,"pointerdown",r[3])],o=!0)},p(l,h){h&1&&b(e,"cx",l[0]),h&2&&b(e,"cy",l[1]),h&4&&i!==(i=1.75*l[2])&&b(e,"r",i),h&1&&b(s,"cx",l[0]),h&2&&b(s,"cy",l[1]),h&4&&b(s,"r",l[2]),h&1&&b(n,"cx",l[0]),h&2&&b(n,"cy",l[1]),h&4&&b(n,"r",l[2])},d(l){l&&rt(t),o=!1,$e(a)}}}function o0(r){let t;return{c(){t=Z("circle"),b(t,"cx",r[0]),b(t,"cy",r[1]),b(t,"r",r[2])},m(e,i){it(e,t,i)},p(e,i){i&1&&b(t,"cx",e[0]),i&2&&b(t,"cy",e[1]),i&4&&b(t,"r",e[2])},d(e){e&&rt(t)}}}function a0(r){let t;function e(s,n){return Cr?o0:n0}let i=e()(r);return{c(){i.c(),t=Fe()},m(s,n){i.m(s,n),it(s,t,n)},p(s,[n]){i.p(s,n)},i:Dt,o:Dt,d(s){s&&rt(t),i.d(s)}}}function l0(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t;const a=h=>{h.pointerType};function l(h){Ce.call(this,r,h)}return r.$$set=h=>{"x"in h&&e(0,s=h.x),"y"in h&&e(1,n=h.y),"scale"in h&&e(4,o=h.scale)},r.$$.update=()=>{r.$$.dirty&16&&e(2,i=4/o)},[s,n,i,a,o,l]}class Yu extends De{constructor(t){super(),Ne(this,t,l0,a0,le,{x:0,y:1,scale:4})}}function Aa(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function Wu(r,t,e){const i=r.slice();return i[28]=t[e],i[30]=e,i}function Sa(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function Ca(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function ju(r){let t,e,i,s;return{c(){t=Z("circle"),b(t,"cx",e=r[28][0]),b(t,"cy",i=r[28][1]),b(t,"r",s=Ns/r[3]),b(t,"class","svelte-1h2slbm")},m(n,o){it(n,t,o)},p(n,o){o[0]&1088&&e!==(e=n[28][0])&&b(t,"cx",e),o[0]&1088&&i!==(i=n[28][1])&&b(t,"cy",i),o[0]&8&&s!==(s=Ns/n[3])&&b(t,"r",s)},d(n){n&&rt(t)}}}function qu(r){let t,e,i,s,n,o,a,l,h,u;return{c(){t=Z("mask"),e=Z("rect"),a=Z("circle"),b(e,"x",i=r[9].x),b(e,"y",s=r[9].y),b(e,"width",n=r[9].w),b(e,"height",o=r[9].h),b(e,"class","svelte-1h2slbm"),b(a,"cx",l=r[28][0]),b(a,"cy",h=r[28][1]),b(a,"r",u=Ns/r[3]),b(a,"class","svelte-1h2slbm"),b(t,"id",`${r[19]}-inner`),b(t,"class","a9s-polygon-editor-mask svelte-1h2slbm")},m(c,d){it(c,t,d),wt(t,e),wt(t,a)},p(c,d){d[0]&512&&i!==(i=c[9].x)&&b(e,"x",i),d[0]&512&&s!==(s=c[9].y)&&b(e,"y",s),d[0]&512&&n!==(n=c[9].w)&&b(e,"width",n),d[0]&512&&o!==(o=c[9].h)&&b(e,"height",o),d[0]&1088&&l!==(l=c[28][0])&&b(a,"cx",l),d[0]&1088&&h!==(h=c[28][1])&&b(a,"cy",h),d[0]&8&&u!==(u=Ns/c[3])&&b(a,"r",u)},d(c){c&&rt(t)}}}function Ku(r){let t,e;return t=new Wi({props:{class:"a9s-corner-handle",x:r[28][0],y:r[28][1],scale:r[3],selected:r[8].includes(r[30])}}),t.$on("pointerenter",r[11]),t.$on("pointerleave",r[12]),t.$on("pointerdown",r[15]),t.$on("pointerdown",function(){Vt(r[27](`HANDLE-${r[30]}`))&&r[27](`HANDLE-${r[30]}`).apply(this,arguments)}),t.$on("pointerup",r[16](r[30])),{c(){be(t.$$.fragment)},m(i,s){ce(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&32&&(n.x=r[28][0]),s[0]&32&&(n.y=r[28][1]),s[0]&8&&(n.scale=r[3]),s[0]&256&&(n.selected=r[8].includes(r[30])),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){gt(t.$$.fragment,i),e=!1},d(i){de(t,i)}}}function Zu(r){let t,e;return t=new Yu({props:{x:r[28][0],y:r[28][1],scale:r[3]}}),t.$on("pointerdown",function(){Vt(r[18](r[6]))&&r[18](r[6]).apply(this,arguments)}),{c(){be(t.$$.fragment)},m(i,s){ce(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&1088&&(n.x=r[28][0]),s[0]&1088&&(n.y=r[28][1]),s[0]&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){gt(t.$$.fragment,i),e=!1},d(i){de(t,i)}}}function h0(r){let t,e,i,s,n,o,a,l,h,u,c,d,f,p,m,_,y,v,g,x,E,R=r[6]!==void 0&&!r[7]&&ju(Ca(r)),S=r[6]!==void 0&&!r[7]&&qu(Sa(r)),M=ke(r[5].points),P=[];for(let I=0;I<M.length;I+=1)P[I]=Ku(Wu(r,M,I));const F=I=>gt(P[I],1,1,()=>{P[I]=null});let U=r[6]!==void 0&&!r[7]&&Zu(Aa(r));return{c(){t=Z("defs"),e=Z("mask"),i=Z("rect"),l=Z("polygon"),R&&R.c(),S&&S.c(),u=Oe(),c=Z("polygon"),f=Oe(),p=Z("polygon"),_=Oe();for(let I=0;I<P.length;I+=1)P[I].c();y=Oe(),U&&U.c(),v=Fe(),b(i,"x",s=r[9].x),b(i,"y",n=r[9].y),b(i,"width",o=r[9].w),b(i,"height",a=r[9].h),b(i,"class","svelte-1h2slbm"),b(l,"points",h=r[5].points.map(Qu).join(" ")),b(l,"class","svelte-1h2slbm"),b(e,"id",`${r[19]}-outer`),b(e,"class","a9s-polygon-editor-mask svelte-1h2slbm"),b(c,"class","a9s-outer"),b(c,"mask",`url(#${r[19]}-outer)`),b(c,"points",d=r[5].points.map(Ju).join(" ")),b(p,"class","a9s-inner a9s-shape-handle"),b(p,"mask",`url(#${r[19]}-inner)`),b(p,"style",r[1]),b(p,"points",m=r[5].points.map(tc).join(" "))},m(I,A){it(I,t,A),wt(t,e),wt(e,i),wt(e,l),R&&R.m(e,null),S&&S.m(t,null),it(I,u,A),it(I,c,A),it(I,f,A),it(I,p,A),it(I,_,A);for(let w=0;w<P.length;w+=1)P[w]&&P[w].m(I,A);it(I,y,A),U&&U.m(I,A),it(I,v,A),g=!0,x||(E=[Rt(c,"pointerup",r[14]),Rt(c,"pointerdown",function(){Vt(r[27]("SHAPE"))&&r[27]("SHAPE").apply(this,arguments)}),Rt(p,"pointermove",r[13]),Rt(p,"pointerup",r[14]),Rt(p,"pointerdown",function(){Vt(r[27]("SHAPE"))&&r[27]("SHAPE").apply(this,arguments)})],x=!0)},p(I,A){if(r=I,(!g||A[0]&512&&s!==(s=r[9].x))&&b(i,"x",s),(!g||A[0]&512&&n!==(n=r[9].y))&&b(i,"y",n),(!g||A[0]&512&&o!==(o=r[9].w))&&b(i,"width",o),(!g||A[0]&512&&a!==(a=r[9].h))&&b(i,"height",a),(!g||A[0]&32&&h!==(h=r[5].points.map(Qu).join(" ")))&&b(l,"points",h),r[6]!==void 0&&!r[7]?R?R.p(Ca(r),A):(R=ju(Ca(r)),R.c(),R.m(e,null)):R&&(R.d(1),R=null),r[6]!==void 0&&!r[7]?S?S.p(Sa(r),A):(S=qu(Sa(r)),S.c(),S.m(t,null)):S&&(S.d(1),S=null),(!g||A[0]&32&&d!==(d=r[5].points.map(Ju).join(" ")))&&b(c,"points",d),(!g||A[0]&2)&&b(p,"style",r[1]),(!g||A[0]&32&&m!==(m=r[5].points.map(tc).join(" ")))&&b(p,"points",m),A[0]&134322472){M=ke(r[5].points);let w;for(w=0;w<M.length;w+=1){const C=Wu(r,M,w);P[w]?(P[w].p(C,A),ot(P[w],1)):(P[w]=Ku(C),P[w].c(),ot(P[w],1),P[w].m(y.parentNode,y))}for(Ie(),w=M.length;w<P.length;w+=1)F(w);Re()}r[6]!==void 0&&!r[7]?U?(U.p(Aa(r),A),A[0]&192&&ot(U,1)):(U=Zu(Aa(r)),U.c(),ot(U,1),U.m(v.parentNode,v)):U&&(Ie(),gt(U,1,1,()=>{U=null}),Re())},i(I){if(!g){for(let A=0;A<M.length;A+=1)ot(P[A]);ot(U),g=!0}},o(I){P=P.filter(Boolean);for(let A=0;A<P.length;A+=1)gt(P[A]);gt(U),g=!1},d(I){I&&(rt(t),rt(u),rt(c),rt(f),rt(p),rt(_),rt(y),rt(v)),R&&R.d(),S&&S.d(),mi(P,I),U&&U.d(I),x=!1,$e(E)}}}function u0(r){let t,e;return t=new Ta({props:{shape:r[0],transform:r[2],editor:r[17],svgEl:r[4],$$slots:{default:[h0,({grab:i})=>({27:i}),({grab:i})=>[i?134217728:0]]},$$scope:{ctx:r}}}),t.$on("change",r[20]),t.$on("grab",r[21]),t.$on("release",r[22]),{c(){be(t.$$.fragment)},m(i,s){ce(t,i,s),e=!0},p(i,s){const n={};s[0]&1&&(n.shape=i[0]),s[0]&4&&(n.transform=i[2]),s[0]&16&&(n.svgEl=i[4]),s[0]&134219754|s[1]&1&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){gt(t.$$.fragment,i),e=!1},d(i){de(t,i)}}}const c0=250,d0=1e3,f0=12,Ns=4.5,Qu=r=>r.join(","),Ju=r=>r.join(","),tc=r=>r.join(",");function p0(r,t,e){let i,s,n;const o=Xr();let{shape:a}=t,{computedStyle:l}=t,{transform:h}=t,{viewportScale:u=1}=t,{svgEl:c}=t,d,f=!1,p,m=[];const _=()=>e(7,f=!0),y=()=>e(7,f=!1),v=w=>{if(m.length>0||!s.some(O=>O.visible)){e(6,d=void 0);return}const[C,D]=h.elementToImage(w.offsetX,w.offsetY),N=O=>Math.pow(O[0]-C,2)+Math.pow(O[1]-D,2),B=i.points.reduce((O,k)=>N(k)<N(O)?k:O),V=s.filter(O=>O.visible).reduce((O,k)=>N(k.point)<N(O.point)?k:O),L=Math.pow(d0/u,2);N(B)<L||N(V.point)<L?e(6,d=s.indexOf(V)):e(6,d=void 0)},g=()=>{document.activeElement!==c&&c.focus()},x=()=>{e(8,m=[]),g()},E=w=>{e(7,f=!0),w.preventDefault(),w.stopPropagation(),p=performance.now()},R=w=>C=>{if(!p||Cr||performance.now()-p>c0)return;const D=m.includes(w);C.metaKey||C.ctrlKey||C.shiftKey?D?e(8,m=m.filter(N=>N!==w)):e(8,m=[...m,w]):D&&m.length>1?e(8,m=[w]):D?e(8,m=[]):e(8,m=[w]),g()},S=(w,C,D)=>{g();let N;const B=w.geometry;m.length>1?N=B.points.map(([L,O],k)=>m.includes(k)?[L+D[0],O+D[1]]:[L,O]):C==="SHAPE"?N=B.points.map(([L,O])=>[L+D[0],O+D[1]]):N=B.points.map(([L,O],k)=>C===`HANDLE-${k}`?[L+D[0],O+D[1]]:[L,O]);const V=Ue(N);return{...w,geometry:{points:N,bounds:V}}},M=w=>async C=>{C.stopPropagation();const D=[...i.points.slice(0,w+1),s[w].point,...i.points.slice(w+1)],N=Ue(D);o("change",{...a,geometry:{points:D,bounds:N}}),await bu();const B=[...document.querySelectorAll(".a9s-handle")][w+1];if(B!=null&&B.firstChild){const V=new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:C.clientX,clientY:C.clientY,pointerId:C.pointerId,pointerType:C.pointerType,isPrimary:C.isPrimary,buttons:C.buttons});B.firstChild.dispatchEvent(V)}},P=()=>{if(i.points.length<4)return;const w=i.points.filter((D,N)=>!m.includes(N)),C=Ue(w);o("change",{...a,geometry:{points:w,bounds:C}}),e(8,m=[])};gi(()=>{if(Cr)return;const w=C=>{(C.key==="Delete"||C.key==="Backspace")&&(C.preventDefault(),P())};return c.addEventListener("pointermove",v),c.addEventListener("keydown",w),()=>{c.removeEventListener("pointermove",v),c.removeEventListener("keydown",w)}});const F=`polygon-mask-${Math.random().toString(36).substring(2,12)}`;function U(w){Ce.call(this,r,w)}function I(w){Ce.call(this,r,w)}function A(w){Ce.call(this,r,w)}return r.$$set=w=>{"shape"in w&&e(0,a=w.shape),"computedStyle"in w&&e(1,l=w.computedStyle),"transform"in w&&e(2,h=w.transform),"viewportScale"in w&&e(3,u=w.viewportScale),"svgEl"in w&&e(4,c=w.svgEl)},r.$$.update=()=>{r.$$.dirty[0]&1&&e(5,i=a.geometry),r.$$.dirty[0]&40&&e(10,s=Cr?[]:i.points.map((w,C)=>{const D=C===i.points.length-1?i.points[0]:i.points[C+1],N=(w[0]+D[0])/2,B=(w[1]+D[1])/2,V=Math.sqrt(Math.pow(D[0]-N,2)+Math.pow(D[1]-B,2))>f0/u;return{point:[N,B],visible:V}})),r.$$.dirty[0]&40&&e(9,n=In(i.bounds,Ns/u))},[a,l,h,u,c,i,d,f,m,n,s,_,y,v,x,E,R,S,M,F,U,I,A]}class m0 extends De{constructor(t){super(),Ne(this,t,p0,u0,le,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}function g0(r){let t,e,i,s,n,o,a,l,h,u,c,d,f,p,m,_,y,v,g,x,E,R,S,M,P,F,U,I,A,w,C,D,N,B,V,L,O,k,X,Y,q,pt,_t,W,bt,dt,mt,xt,Mt,Nt,_e,jt,et,Ke,mn;return dt=new Wi({props:{class:"a9s-corner-handle-topleft",x:r[5].x,y:r[5].y,scale:r[3]}}),dt.$on("pointerdown",function(){Vt(r[12]("TOP_LEFT"))&&r[12]("TOP_LEFT").apply(this,arguments)}),xt=new Wi({props:{class:"a9s-corner-handle-topright",x:r[5].x+r[5].w,y:r[5].y,scale:r[3]}}),xt.$on("pointerdown",function(){Vt(r[12]("TOP_RIGHT"))&&r[12]("TOP_RIGHT").apply(this,arguments)}),Nt=new Wi({props:{class:"a9s-corner-handle-bottomright",x:r[5].x+r[5].w,y:r[5].y+r[5].h,scale:r[3]}}),Nt.$on("pointerdown",function(){Vt(r[12]("BOTTOM_RIGHT"))&&r[12]("BOTTOM_RIGHT").apply(this,arguments)}),jt=new Wi({props:{class:"a9s-corner-handle-bottomleft",x:r[5].x,y:r[5].y+r[5].h,scale:r[3]}}),jt.$on("pointerdown",function(){Vt(r[12]("BOTTOM_LEFT"))&&r[12]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=Z("defs"),e=Z("mask"),i=Z("rect"),l=Z("rect"),f=Oe(),p=Z("rect"),g=Oe(),x=Z("rect"),P=Oe(),F=Z("rect"),w=Oe(),C=Z("rect"),V=Oe(),L=Z("rect"),Y=Oe(),q=Z("rect"),bt=Oe(),be(dt.$$.fragment),mt=Oe(),be(xt.$$.fragment),Mt=Oe(),be(Nt.$$.fragment),_e=Oe(),be(jt.$$.fragment),b(i,"class","rect-mask-bg svelte-1njczvj"),b(i,"x",s=r[6].x),b(i,"y",n=r[6].y),b(i,"width",o=r[6].w),b(i,"height",a=r[6].h),b(l,"class","rect-mask-fg svelte-1njczvj"),b(l,"x",h=r[5].x),b(l,"y",u=r[5].y),b(l,"width",c=r[5].w),b(l,"height",d=r[5].h),b(e,"id",r[8]),b(e,"class","a9s-rectangle-editor-mask svelte-1njczvj"),b(p,"class","a9s-outer"),b(p,"mask",`url(#${r[8]})`),b(p,"x",m=r[5].x),b(p,"y",_=r[5].y),b(p,"width",y=r[5].w),b(p,"height",v=r[5].h),b(x,"class","a9s-inner a9s-shape-handle"),b(x,"style",r[1]),b(x,"x",E=r[5].x),b(x,"y",R=r[5].y),b(x,"width",S=r[5].w),b(x,"height",M=r[5].h),b(F,"class","a9s-edge-handle a9s-edge-handle-top"),b(F,"x",U=r[5].x),b(F,"y",I=r[5].y),b(F,"height",1),b(F,"width",A=r[5].w),b(C,"class","a9s-edge-handle a9s-edge-handle-right"),b(C,"x",D=r[5].x+r[5].w),b(C,"y",N=r[5].y),b(C,"height",B=r[5].h),b(C,"width",1),b(L,"class","a9s-edge-handle a9s-edge-handle-bottom"),b(L,"x",O=r[5].x),b(L,"y",k=r[5].y+r[5].h),b(L,"height",1),b(L,"width",X=r[5].w),b(q,"class","a9s-edge-handle a9s-edge-handle-left"),b(q,"x",pt=r[5].x),b(q,"y",_t=r[5].y),b(q,"height",W=r[5].h),b(q,"width",1)},m(j,H){it(j,t,H),wt(t,e),wt(e,i),wt(e,l),it(j,f,H),it(j,p,H),it(j,g,H),it(j,x,H),it(j,P,H),it(j,F,H),it(j,w,H),it(j,C,H),it(j,V,H),it(j,L,H),it(j,Y,H),it(j,q,H),it(j,bt,H),ce(dt,j,H),it(j,mt,H),ce(xt,j,H),it(j,Mt,H),ce(Nt,j,H),it(j,_e,H),ce(jt,j,H),et=!0,Ke||(mn=[Rt(p,"pointerdown",function(){Vt(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),Rt(x,"pointerdown",function(){Vt(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),Rt(F,"pointerdown",function(){Vt(r[12]("TOP"))&&r[12]("TOP").apply(this,arguments)}),Rt(C,"pointerdown",function(){Vt(r[12]("RIGHT"))&&r[12]("RIGHT").apply(this,arguments)}),Rt(L,"pointerdown",function(){Vt(r[12]("BOTTOM"))&&r[12]("BOTTOM").apply(this,arguments)}),Rt(q,"pointerdown",function(){Vt(r[12]("LEFT"))&&r[12]("LEFT").apply(this,arguments)})],Ke=!0)},p(j,H){r=j,(!et||H&64&&s!==(s=r[6].x))&&b(i,"x",s),(!et||H&64&&n!==(n=r[6].y))&&b(i,"y",n),(!et||H&64&&o!==(o=r[6].w))&&b(i,"width",o),(!et||H&64&&a!==(a=r[6].h))&&b(i,"height",a),(!et||H&32&&h!==(h=r[5].x))&&b(l,"x",h),(!et||H&32&&u!==(u=r[5].y))&&b(l,"y",u),(!et||H&32&&c!==(c=r[5].w))&&b(l,"width",c),(!et||H&32&&d!==(d=r[5].h))&&b(l,"height",d),(!et||H&32&&m!==(m=r[5].x))&&b(p,"x",m),(!et||H&32&&_!==(_=r[5].y))&&b(p,"y",_),(!et||H&32&&y!==(y=r[5].w))&&b(p,"width",y),(!et||H&32&&v!==(v=r[5].h))&&b(p,"height",v),(!et||H&2)&&b(x,"style",r[1]),(!et||H&32&&E!==(E=r[5].x))&&b(x,"x",E),(!et||H&32&&R!==(R=r[5].y))&&b(x,"y",R),(!et||H&32&&S!==(S=r[5].w))&&b(x,"width",S),(!et||H&32&&M!==(M=r[5].h))&&b(x,"height",M),(!et||H&32&&U!==(U=r[5].x))&&b(F,"x",U),(!et||H&32&&I!==(I=r[5].y))&&b(F,"y",I),(!et||H&32&&A!==(A=r[5].w))&&b(F,"width",A),(!et||H&32&&D!==(D=r[5].x+r[5].w))&&b(C,"x",D),(!et||H&32&&N!==(N=r[5].y))&&b(C,"y",N),(!et||H&32&&B!==(B=r[5].h))&&b(C,"height",B),(!et||H&32&&O!==(O=r[5].x))&&b(L,"x",O),(!et||H&32&&k!==(k=r[5].y+r[5].h))&&b(L,"y",k),(!et||H&32&&X!==(X=r[5].w))&&b(L,"width",X),(!et||H&32&&pt!==(pt=r[5].x))&&b(q,"x",pt),(!et||H&32&&_t!==(_t=r[5].y))&&b(q,"y",_t),(!et||H&32&&W!==(W=r[5].h))&&b(q,"height",W);const kr={};H&32&&(kr.x=r[5].x),H&32&&(kr.y=r[5].y),H&8&&(kr.scale=r[3]),dt.$set(kr);const Ur={};H&32&&(Ur.x=r[5].x+r[5].w),H&32&&(Ur.y=r[5].y),H&8&&(Ur.scale=r[3]),xt.$set(Ur);const Gr={};H&32&&(Gr.x=r[5].x+r[5].w),H&32&&(Gr.y=r[5].y+r[5].h),H&8&&(Gr.scale=r[3]),Nt.$set(Gr);const Hr={};H&32&&(Hr.x=r[5].x),H&32&&(Hr.y=r[5].y+r[5].h),H&8&&(Hr.scale=r[3]),jt.$set(Hr)},i(j){et||(ot(dt.$$.fragment,j),ot(xt.$$.fragment,j),ot(Nt.$$.fragment,j),ot(jt.$$.fragment,j),et=!0)},o(j){gt(dt.$$.fragment,j),gt(xt.$$.fragment,j),gt(Nt.$$.fragment,j),gt(jt.$$.fragment,j),et=!1},d(j){j&&(rt(t),rt(f),rt(p),rt(g),rt(x),rt(P),rt(F),rt(w),rt(C),rt(V),rt(L),rt(Y),rt(q),rt(bt),rt(mt),rt(Mt),rt(_e)),de(dt,j),de(xt,j),de(Nt,j),de(jt,j),Ke=!1,$e(mn)}}}function y0(r){let t,e;return t=new Ta({props:{shape:r[0],transform:r[2],editor:r[7],svgEl:r[4],$$slots:{default:[g0,({grab:i})=>({12:i}),({grab:i})=>i?4096:0]},$$scope:{ctx:r}}}),t.$on("grab",r[9]),t.$on("change",r[10]),t.$on("release",r[11]),{c(){be(t.$$.fragment)},m(i,s){ce(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&16&&(n.svgEl=i[4]),s&12394&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){gt(t.$$.fragment,i),e=!1},d(i){de(t,i)}}}function _0(r,t,e){let i,s,{shape:n}=t,{computedStyle:o}=t,{transform:a}=t,{viewportScale:l=1}=t,{svgEl:h}=t;const u=(m,_,y)=>{const v=m.geometry.bounds;let[g,x]=[v.minX,v.minY],[E,R]=[v.maxX,v.maxY];const[S,M]=y;if(_==="SHAPE")g+=S,E+=S,x+=M,R+=M;else{switch(_){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{x+=M;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{R+=M;break}}switch(_){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{g+=S;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{E+=S;break}}}const P=Math.min(g,E),F=Math.min(x,R),U=Math.abs(E-g),I=Math.abs(R-x);return{...m,geometry:{x:P,y:F,w:U,h:I,bounds:{minX:P,minY:F,maxX:P+U,maxY:F+I}}}},c=`rect-mask-${Math.random().toString(36).substring(2,12)}`;function d(m){Ce.call(this,r,m)}function f(m){Ce.call(this,r,m)}function p(m){Ce.call(this,r,m)}return r.$$set=m=>{"shape"in m&&e(0,n=m.shape),"computedStyle"in m&&e(1,o=m.computedStyle),"transform"in m&&e(2,a=m.transform),"viewportScale"in m&&e(3,l=m.viewportScale),"svgEl"in m&&e(4,h=m.svgEl)},r.$$.update=()=>{r.$$.dirty&1&&e(5,i=n.geometry),r.$$.dirty&40&&e(6,s=In(i.bounds,2/l))},[n,o,a,l,h,i,s,u,c,d,f,p]}class v0 extends De{constructor(t){super(),Ne(this,t,_0,y0,le,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4})}}var ec=Object.prototype.hasOwnProperty;function Ia(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--&&Ia(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(ec.call(r,e)&&++i&&!ec.call(t,e)||!(e in t)||!Ia(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}const x0=12,b0=(r,t)=>r.polygons.reduce((e,i,s)=>{const n=i.rings.reduce((o,a,l)=>{const h=a.points.map((u,c)=>{const d=c===a.points.length-1?a.points[0]:a.points[c+1],f=(u[0]+d[0])/2,p=(u[1]+d[1])/2,m=Math.sqrt(Math.pow(d[0]-f,2)+Math.pow(d[1]-p,2))>x0/t;return{point:[f,p],visible:m,elementIdx:s,ringIdx:l,pointIdx:c}});return[...o,...h]},[]);return[...e,...n]},[]);function Ra(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function rc(r,t,e){const i=r.slice();return i[30]=t[e],i[32]=e,i}function ic(r,t,e){const i=r.slice();return i[33]=t[e],i[35]=e,i}function sc(r,t,e){const i=r.slice();return i[29]=t[e],i[37]=e,i}function Ma(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function Pa(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function nc(r){let t,e,i,s;return{c(){t=Z("circle"),b(t,"cx",e=r[29][0]),b(t,"cy",i=r[29][1]),b(t,"r",s=Ds/r[3]),b(t,"class","svelte-1vxo6dc")},m(n,o){it(n,t,o)},p(n,o){o[0]&1088&&e!==(e=n[29][0])&&b(t,"cx",e),o[0]&1088&&i!==(i=n[29][1])&&b(t,"cy",i),o[0]&8&&s!==(s=Ds/n[3])&&b(t,"r",s)},d(n){n&&rt(t)}}}function oc(r){let t,e,i,s,n,o,a,l,h,u;return{c(){t=Z("mask"),e=Z("rect"),a=Z("circle"),b(e,"x",i=r[9].x),b(e,"y",s=r[9].y),b(e,"width",n=r[9].w),b(e,"height",o=r[9].h),b(e,"class","svelte-1vxo6dc"),b(a,"cx",l=r[29][0]),b(a,"cy",h=r[29][1]),b(a,"r",u=Ds/r[3]),b(a,"class","svelte-1vxo6dc"),b(t,"id",`${r[18]}-${r[32]}-inner`),b(t,"class","a9s-multipolygon-editor-mask svelte-1vxo6dc")},m(c,d){it(c,t,d),wt(t,e),wt(t,a)},p(c,d){d[0]&512&&i!==(i=c[9].x)&&b(e,"x",i),d[0]&512&&s!==(s=c[9].y)&&b(e,"y",s),d[0]&512&&n!==(n=c[9].w)&&b(e,"width",n),d[0]&512&&o!==(o=c[9].h)&&b(e,"height",o),d[0]&1088&&l!==(l=c[29][0])&&b(a,"cx",l),d[0]&1088&&h!==(h=c[29][1])&&b(a,"cy",h),d[0]&8&&u!==(u=Ds/c[3])&&b(a,"r",u)},d(c){c&&rt(t)}}}function ac(r){let t,e;function i(...s){return r[19](r[32],r[35],r[37],...s)}return t=new Wi({props:{class:"a9s-corner-handle",x:r[29][0],y:r[29][1],scale:r[3],selected:r[8].some(i)}}),t.$on("pointerenter",r[11]),t.$on("pointerleave",r[12]),t.$on("pointerdown",r[14]),t.$on("pointerdown",function(){Vt(r[28](`HANDLE-${r[32]}-${r[35]}-${r[37]}`))&&r[28](`HANDLE-${r[32]}-${r[35]}-${r[37]}`).apply(this,arguments)}),t.$on("pointerup",r[15](r[32],r[35],r[37])),{c(){be(t.$$.fragment)},m(s,n){ce(t,s,n),e=!0},p(s,n){r=s;const o={};n[0]&32&&(o.x=r[29][0]),n[0]&32&&(o.y=r[29][1]),n[0]&8&&(o.scale=r[3]),n[0]&256&&(o.selected=r[8].some(i)),t.$set(o)},i(s){e||(ot(t.$$.fragment,s),e=!0)},o(s){gt(t.$$.fragment,s),e=!1},d(s){de(t,s)}}}function lc(r){let t,e,i=ke(r[33].points),s=[];for(let o=0;o<i.length;o+=1)s[o]=ac(sc(r,i,o));const n=o=>gt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Fe()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);it(o,t,a),e=!0},p(o,a){if(a[0]&268491048){i=ke(o[33].points);let l;for(l=0;l<i.length;l+=1){const h=sc(o,i,l);s[l]?(s[l].p(h,a),ot(s[l],1)):(s[l]=ac(h),s[l].c(),ot(s[l],1),s[l].m(t.parentNode,t))}for(Ie(),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(Boolean);for(let a=0;a<s.length;a+=1)gt(s[a]);e=!1},d(o){o&&rt(t),mi(s,o)}}}function hc(r){let t,e,i,s,n,o,a,l,h,u,c,d,f,p,m,_,y,v=r[6]!==void 0&&!r[7]&&nc(Pa(r)),g=r[6]!==void 0&&!r[7]&&oc(Ma(r)),x=ke(r[30].rings),E=[];for(let S=0;S<x.length;S+=1)E[S]=lc(ic(r,x,S));const R=S=>gt(E[S],1,1,()=>{E[S]=null});return{c(){t=Z("g"),e=Z("defs"),i=Z("mask"),s=Z("rect"),h=Z("path"),v&&v.c(),g&&g.c(),c=Z("path"),f=Z("path");for(let S=0;S<E.length;S+=1)E[S].c();b(s,"x",n=r[9].x),b(s,"y",o=r[9].y),b(s,"width",a=r[9].w),b(s,"height",l=r[9].h),b(s,"class","svelte-1vxo6dc"),b(h,"d",u=Ze(r[30])),b(h,"class","svelte-1vxo6dc"),b(i,"id",`${r[18]}-${r[32]}-outer`),b(i,"class","a9s-multipolygon-editor-mask svelte-1vxo6dc"),b(c,"class","a9s-outer"),b(c,"mask",`url(#${r[18]}-${r[32]}-outer)`),b(c,"fill-rule","evenodd"),b(c,"d",d=Ze(r[30])),b(f,"class","a9s-inner"),b(f,"mask",`url(#${r[18]}-${r[32]}-inner)`),b(f,"style",r[1]),b(f,"fill-rule","evenodd"),b(f,"d",p=Ze(r[30]))},m(S,M){it(S,t,M),wt(t,e),wt(e,i),wt(i,s),wt(i,h),v&&v.m(i,null),g&&g.m(e,null),wt(t,c),wt(t,f);for(let P=0;P<E.length;P+=1)E[P]&&E[P].m(t,null);m=!0,_||(y=[Rt(c,"pointerup",r[13]),Rt(c,"pointerdown",function(){Vt(r[28]("SHAPE"))&&r[28]("SHAPE").apply(this,arguments)}),Rt(f,"pointerup",r[13]),Rt(f,"pointerdown",function(){Vt(r[28]("SHAPE"))&&r[28]("SHAPE").apply(this,arguments)})],_=!0)},p(S,M){if(r=S,(!m||M[0]&512&&n!==(n=r[9].x))&&b(s,"x",n),(!m||M[0]&512&&o!==(o=r[9].y))&&b(s,"y",o),(!m||M[0]&512&&a!==(a=r[9].w))&&b(s,"width",a),(!m||M[0]&512&&l!==(l=r[9].h))&&b(s,"height",l),(!m||M[0]&32&&u!==(u=Ze(r[30])))&&b(h,"d",u),r[6]!==void 0&&!r[7]?v?v.p(Pa(r),M):(v=nc(Pa(r)),v.c(),v.m(i,null)):v&&(v.d(1),v=null),r[6]!==void 0&&!r[7]?g?g.p(Ma(r),M):(g=oc(Ma(r)),g.c(),g.m(e,null)):g&&(g.d(1),g=null),(!m||M[0]&32&&d!==(d=Ze(r[30])))&&b(c,"d",d),(!m||M[0]&2)&&b(f,"style",r[1]),(!m||M[0]&32&&p!==(p=Ze(r[30])))&&b(f,"d",p),M[0]&268491048){x=ke(r[30].rings);let P;for(P=0;P<x.length;P+=1){const F=ic(r,x,P);E[P]?(E[P].p(F,M),ot(E[P],1)):(E[P]=lc(F),E[P].c(),ot(E[P],1),E[P].m(t,null))}for(Ie(),P=x.length;P<E.length;P+=1)R(P);Re()}},i(S){if(!m){for(let M=0;M<x.length;M+=1)ot(E[M]);m=!0}},o(S){E=E.filter(Boolean);for(let M=0;M<E.length;M+=1)gt(E[M]);m=!1},d(S){S&&rt(t),v&&v.d(),g&&g.d(),mi(E,S),_=!1,$e(y)}}}function uc(r){let t,e;return t=new Yu({props:{x:r[29][0],y:r[29][1],scale:r[3]}}),t.$on("pointerdown",function(){Vt(r[17](r[6]))&&r[17](r[6]).apply(this,arguments)}),{c(){be(t.$$.fragment)},m(i,s){ce(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&1088&&(n.x=r[29][0]),s[0]&1088&&(n.y=r[29][1]),s[0]&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){gt(t.$$.fragment,i),e=!1},d(i){de(t,i)}}}function E0(r){let t,e,i,s=ke(r[5].polygons),n=[];for(let l=0;l<s.length;l+=1)n[l]=hc(rc(r,s,l));const o=l=>gt(n[l],1,1,()=>{n[l]=null});let a=r[6]!==void 0&&!r[7]&&uc(Ra(r));return{c(){for(let l=0;l<n.length;l+=1)n[l].c();t=Oe(),a&&a.c(),e=Fe()},m(l,h){for(let u=0;u<n.length;u+=1)n[u]&&n[u].m(l,h);it(l,t,h),a&&a.m(l,h),it(l,e,h),i=!0},p(l,h){if(h[0]&268763114){s=ke(l[5].polygons);let u;for(u=0;u<s.length;u+=1){const c=rc(l,s,u);n[u]?(n[u].p(c,h),ot(n[u],1)):(n[u]=hc(c),n[u].c(),ot(n[u],1),n[u].m(t.parentNode,t))}for(Ie(),u=s.length;u<n.length;u+=1)o(u);Re()}l[6]!==void 0&&!l[7]?a?(a.p(Ra(l),h),h[0]&192&&ot(a,1)):(a=uc(Ra(l)),a.c(),ot(a,1),a.m(e.parentNode,e)):a&&(Ie(),gt(a,1,1,()=>{a=null}),Re())},i(l){if(!i){for(let h=0;h<s.length;h+=1)ot(n[h]);ot(a),i=!0}},o(l){n=n.filter(Boolean);for(let h=0;h<n.length;h+=1)gt(n[h]);gt(a),i=!1},d(l){l&&(rt(t),rt(e)),mi(n,l),a&&a.d(l)}}}function w0(r){let t,e;return t=new Ta({props:{shape:r[0],transform:r[2],editor:r[16],svgEl:r[4],$$slots:{default:[E0,({grab:i})=>({28:i}),({grab:i})=>[i?268435456:0]]},$$scope:{ctx:r}}}),t.$on("change",r[20]),t.$on("grab",r[21]),t.$on("release",r[22]),{c(){be(t.$$.fragment)},m(i,s){ce(t,i,s),e=!0},p(i,s){const n={};s[0]&1&&(n.shape=i[0]),s[0]&4&&(n.transform=i[2]),s[0]&16&&(n.svgEl=i[4]),s[0]&268437482|s[1]&128&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){gt(t.$$.fragment,i),e=!1},d(i){de(t,i)}}}const T0=250,A0=1e3,Ds=4.5;function S0(r,t,e){let i,s,n;const o=Xr();let{shape:a}=t,{computedStyle:l}=t,{transform:h}=t,{viewportScale:u=1}=t,{svgEl:c}=t,d,f=!1,p,m=[];const _=()=>e(7,f=!0),y=()=>e(7,f=!1),v=C=>{if(m.length>0||!s.some(k=>k.visible)){e(6,d=void 0);return}const[D,N]=h.elementToImage(C.offsetX,C.offsetY),B=k=>Math.pow(k[0]-D,2)+Math.pow(k[1]-N,2),V=Cy(i).reduce((k,X)=>B(X)<B(k)?X:k),L=s.filter(k=>k.visible).reduce((k,X)=>B(X.point)<B(k.point)?X:k),O=Math.pow(A0/u,2);B(V)<O||B(L.point)<O?e(6,d=s.indexOf(L)):e(6,d=void 0)},g=()=>{document.activeElement!==c&&c.focus()},x=()=>{e(8,m=[]),g()},E=C=>{e(7,f=!0),C.preventDefault(),C.stopPropagation(),p=performance.now()},R=(C,D,N)=>B=>{if(!p||Cr||performance.now()-p>T0)return;const V=O=>O.polygon===C&&O.ring===D&&O.point===N,L=m.some(V);B.metaKey||B.ctrlKey||B.shiftKey?L?e(8,m=m.filter(O=>!V(O))):e(8,m=[...m,{polygon:C,ring:D,point:N}]):L&&m.length>1?e(8,m=[{polygon:C,ring:D,point:N}]):L?e(8,m=[]):e(8,m=[{polygon:C,ring:D,point:N}]),g()},S=(C,D,N)=>{g();const B=C.geometry.polygons;let V;if(D==="SHAPE")V=B.map(L=>{const O=L.rings.map((X,Y)=>({points:X.points.map((q,pt)=>[q[0]+N[0],q[1]+N[1]])})),k=Ue(O[0].points);return{rings:O,bounds:k}});else{const[L,O,k,X]=D.split("-").map(Y=>parseInt(Y));V=B.map((Y,q)=>{if(q===O){const pt=Y.rings.map((W,bt)=>bt===k?{points:W.points.map((dt,mt)=>mt===X?[dt[0]+N[0],dt[1]+N[1]]:dt)}:W),_t=Ue(pt[0].points);return{rings:pt,bounds:_t}}else return Y})}return{...C,geometry:{polygons:V,bounds:fa(V)}}},M=C=>async D=>{D.stopPropagation();const N=s[C],B=i.polygons.map((L,O)=>{if(O===N.elementIdx){const k=L.rings.map((Y,q)=>q===N.ringIdx?{points:[...Y.points.slice(0,N.pointIdx+1),N.point,...Y.points.slice(N.pointIdx+1)]}:Y),X=Ue(k[0].points);return{rings:k,bounds:X}}else return L});o("change",{...a,geometry:{polygons:B,bounds:fa(B)}}),await bu();const V=[...document.querySelectorAll(".a9s-handle")][C+1];if(V!=null&&V.firstChild){const L=new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:D.clientX,clientY:D.clientY,pointerId:D.pointerId,pointerType:D.pointerType,isPrimary:D.isPrimary,buttons:D.buttons});V.firstChild.dispatchEvent(L)}},P=()=>{const C=i.polygons.map((D,N)=>{if(m.some(B=>B.polygon===N)){const B=D.rings.map((L,O)=>m.some(k=>k.polygon===N&&k.ring===O)&&L.points.length>3?{points:L.points.filter((k,X)=>!m.some(Y=>Y.polygon===N&&Y.ring===O&&Y.point===X))}:L),V=Ue(B[0].points);return{rings:B,bounds:V}}else return D});!Ia(i.polygons,C)&&(o("change",{...a,geometry:{polygons:C,bounds:fa(C)}}),e(8,m=[]))};gi(()=>{if(Cr)return;const C=D=>{(D.key==="Delete"||D.key==="Backspace")&&(D.preventDefault(),P())};return c.addEventListener("pointermove",v),c.addEventListener("keydown",C),()=>{c.removeEventListener("pointermove",v),c.removeEventListener("keydown",C)}});const F=`polygon-mask-${Math.random().toString(36).substring(2,12)}`,U=(C,D,N,{polygon:B,ring:V,point:L})=>B===C&&V===D&&L===N;function I(C){Ce.call(this,r,C)}function A(C){Ce.call(this,r,C)}function w(C){Ce.call(this,r,C)}return r.$$set=C=>{"shape"in C&&e(0,a=C.shape),"computedStyle"in C&&e(1,l=C.computedStyle),"transform"in C&&e(2,h=C.transform),"viewportScale"in C&&e(3,u=C.viewportScale),"svgEl"in C&&e(4,c=C.svgEl)},r.$$.update=()=>{r.$$.dirty[0]&1&&e(5,i=a.geometry),r.$$.dirty[0]&40&&e(10,s=Cr?[]:b0(i,u)),r.$$.dirty[0]&40&&e(9,n=In(i.bounds,Ds/u))},[a,l,h,u,c,i,d,f,m,n,s,_,y,x,E,R,S,M,F,U,I,A,w]}class C0 extends De{constructor(t){super(),Ne(this,t,S0,w0,le,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}const cc=new Map([[Tt.RECTANGLE,v0],[Tt.POLYGON,m0],[Tt.MULTIPOLYGLON,C0]]),dc=r=>cc.get(r.type),fc=(r,t)=>cc.set(r,t);function I0(r,t,e){let i;const s=Xr();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:u}=t,c;return gi(()=>(e(6,c=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:u,svgEl:l.closest("svg")}})),c.$on("change",d=>{c.$$set({shape:d.detail}),s("change",d.detail)}),c.$on("grab",d=>s("grab",d.detail)),c.$on("release",d=>s("release",d.detail)),()=>{c.$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,u=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=Os(n,a)),r.$$.dirty&65&&n&&(c==null||c.$set({shape:n.target.selector})),r.$$.dirty&80&&c&&c.$set({transform:h}),r.$$.dirty&96&&c&&c.$set({viewportScale:u}),r.$$.dirty&192&&c&&i&&c.$set({computedStyle:i})},[n,o,a,l,h,u,c,i]}class R0 extends De{constructor(t){super(),Ne(this,t,I0,null,le,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}function M0(r,t,e){const i=Xr();let{drawingMode:s}=t,{target:n}=t,{tool:o}=t,{transform:a}=t,{viewportScale:l}=t,h;return gi(()=>{const u=n.closest("svg"),c=[],d=(f,p,m)=>{u==null||u.addEventListener(f,p,m),c.push(()=>u==null?void 0:u.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)),()=>{c.forEach(f=>f()),h.$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),"viewportScale"in u&&e(4,l=u.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 P0 extends De{constructor(t){super(),Ne(this,t,M0,null,le,{drawingMode:0,target:1,tool:2,transform:3,viewportScale:4})}}function pc(r){let t,e,i,s,n,o,a,l,h,u;return{c(){t=Z("defs"),e=Z("mask"),i=Z("rect"),l=Z("rect"),h=Z("rect"),u=Z("rect"),b(i,"class","rect-mask-bg svelte-1a76qe7"),b(i,"x",s=r[1]-r[5]),b(i,"y",n=r[2]-r[5]),b(i,"width",o=r[3]+2*r[5]),b(i,"height",a=r[4]+2*r[5]),b(l,"class","rect-mask-fg svelte-1a76qe7"),b(l,"x",r[1]),b(l,"y",r[2]),b(l,"width",r[3]),b(l,"height",r[4]),b(e,"id",r[6]),b(e,"class","a9s-rubberband-rectangle-mask svelte-1a76qe7"),b(h,"class","a9s-outer"),b(h,"mask",`url(#${r[6]})`),b(h,"x",r[1]),b(h,"y",r[2]),b(h,"width",r[3]),b(h,"height",r[4]),b(u,"class","a9s-inner"),b(u,"x",r[1]),b(u,"y",r[2]),b(u,"width",r[3]),b(u,"height",r[4])},m(c,d){it(c,t,d),wt(t,e),wt(e,i),wt(e,l),it(c,h,d),it(c,u,d)},p(c,d){d&34&&s!==(s=c[1]-c[5])&&b(i,"x",s),d&36&&n!==(n=c[2]-c[5])&&b(i,"y",n),d&40&&o!==(o=c[3]+2*c[5])&&b(i,"width",o),d&48&&a!==(a=c[4]+2*c[5])&&b(i,"height",a),d&2&&b(l,"x",c[1]),d&4&&b(l,"y",c[2]),d&8&&b(l,"width",c[3]),d&16&&b(l,"height",c[4]),d&2&&b(h,"x",c[1]),d&4&&b(h,"y",c[2]),d&8&&b(h,"width",c[3]),d&16&&b(h,"height",c[4]),d&2&&b(u,"x",c[1]),d&4&&b(u,"y",c[2]),d&8&&b(u,"width",c[3]),d&16&&b(u,"height",c[4])},d(c){c&&(rt(t),rt(h),rt(u))}}}function O0(r){let t,e=r[0]&&pc(r);return{c(){t=Z("g"),e&&e.c(),b(t,"class","a9s-annotation a9s-rubberband")},m(i,s){it(i,t,s),e&&e.m(t,null)},p(i,[s]){i[0]?e?e.p(i,s):(e=pc(i),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:Dt,o:Dt,d(i){i&&rt(t),e&&e.d()}}}function N0(r,t,e){let i;const s=Xr();let{addEventListener:n}=t,{drawingMode:o}=t,{transform:a}=t,{viewportScale:l=1}=t,h,u,c,d,f,p,m;const _=E=>{const R=E;h=performance.now(),o==="drag"&&(e(0,u=a.elementToImage(R.offsetX,R.offsetY)),c=u,e(1,d=u[0]),e(2,f=u[1]),e(3,p=1),e(4,m=1))},y=E=>{const R=E;u&&(c=a.elementToImage(R.offsetX,R.offsetY),e(1,d=Math.min(c[0],u[0])),e(2,f=Math.min(c[1],u[1])),e(3,p=Math.abs(c[0]-u[0])),e(4,m=Math.abs(c[1]-u[1])))},v=E=>{const R=E,S=performance.now()-h;if(o==="click"){if(S>300)return;u?g():(e(0,u=a.elementToImage(R.offsetX,R.offsetY)),c=u,e(1,d=u[0]),e(2,f=u[1]),e(3,p=1),e(4,m=1))}else u&&(S>300||p*m>100?(R.stopPropagation(),g()):(e(0,u=void 0),c=void 0))},g=()=>{if(p*m>15){const E={type:Tt.RECTANGLE,geometry:{bounds:{minX:d,minY:f,maxX:d+p,maxY:f+m},x:d,y:f,w:p,h:m}};s("create",E)}e(0,u=void 0),c=void 0};gi(()=>{n("pointerdown",_),n("pointermove",y),n("pointerup",v,!0)});const x=`rect-mask-${Math.random().toString(36).substring(2,12)}`;return r.$$set=E=>{"addEventListener"in E&&e(7,n=E.addEventListener),"drawingMode"in E&&e(8,o=E.drawingMode),"transform"in E&&e(9,a=E.transform),"viewportScale"in E&&e(10,l=E.viewportScale)},r.$$.update=()=>{r.$$.dirty&1024&&e(5,i=2/l)},[u,d,f,p,m,i,x,n,o,a,l]}class D0 extends De{constructor(t){super(),Ne(this,t,N0,O0,le,{addEventListener:7,drawingMode:8,transform:9,viewportScale:10})}}function Oa(r){const t=r.slice(),e=t[2].map(i=>i.join(",")).join(" ");return t[19]=e,t}function mc(r){let t,e,i,s,n,o,a,l,h,u,c,d,f,p,m=r[1]&&gc(r);return{c(){t=Z("defs"),e=Z("mask"),i=Z("rect"),l=Z("polygon"),u=Z("polygon"),d=Z("polygon"),m&&m.c(),p=Fe(),b(i,"x",s=r[3].x),b(i,"y",n=r[3].y),b(i,"width",o=r[3].w),b(i,"height",a=r[3].h),b(i,"class","svelte-18wrg3t"),b(l,"points",h=r[19]),b(l,"class","svelte-18wrg3t"),b(e,"id",r[5]),b(e,"class","a9s-rubberband-polygon-mask svelte-18wrg3t"),b(u,"class","a9s-outer"),b(u,"mask",`url(#${r[5]})`),b(u,"points",c=r[19]),b(d,"class","a9s-inner"),b(d,"points",f=r[19])},m(_,y){it(_,t,y),wt(t,e),wt(e,i),wt(e,l),it(_,u,y),it(_,d,y),m&&m.m(_,y),it(_,p,y)},p(_,y){y&8&&s!==(s=_[3].x)&&b(i,"x",s),y&8&&n!==(n=_[3].y)&&b(i,"y",n),y&8&&o!==(o=_[3].w)&&b(i,"width",o),y&8&&a!==(a=_[3].h)&&b(i,"height",a),y&4&&h!==(h=_[19])&&b(l,"points",h),y&4&&c!==(c=_[19])&&b(u,"points",c),y&4&&f!==(f=_[19])&&b(d,"points",f),_[1]?m?m.p(_,y):(m=gc(_),m.c(),m.m(p.parentNode,p)):m&&(m.d(1),m=null)},d(_){_&&(rt(t),rt(u),rt(d),rt(p)),m&&m.d(_)}}}function gc(r){let t,e,i;return{c(){t=Z("circle"),b(t,"class","a9s-handle svelte-18wrg3t"),b(t,"cx",e=r[0][0][0]),b(t,"cy",i=r[0][0][1]),b(t,"r",r[4])},m(s,n){it(s,t,n)},p(s,n){n&1&&e!==(e=s[0][0][0])&&b(t,"cx",e),n&1&&i!==(i=s[0][0][1])&&b(t,"cy",i),n&16&&b(t,"r",s[4])},d(s){s&&rt(t)}}}function L0(r){let t,e=r[3]&&mc(Oa(r));return{c(){t=Z("g"),e&&e.c(),b(t,"class","a9s-annotation a9s-rubberband")},m(i,s){it(i,t,s),e&&e.m(t,null)},p(i,[s]){i[3]?e?e.p(Oa(i),s):(e=mc(Oa(i)),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:Dt,o:Dt,d(i){i&&rt(t),e&&e.d()}}}const B0=20,F0=1500;function k0(r,t,e){let i,s,n;const o=Xr();let{addEventListener:a}=t,{drawingMode:l}=t,{transform:h}=t,{viewportScale:u=1}=t,c,d=[],f,p,m=!1;const _=R=>{const S=R,{timeStamp:M,offsetX:P,offsetY:F}=S;if(c={timeStamp:M,offsetX:P,offsetY:F},l==="drag"&&d.length===0){const U=h.elementToImage(S.offsetX,S.offsetY);d.push(U),e(10,f=U)}},y=R=>{const S=R;if(p&&clearTimeout(p),d.length>0){if(e(10,f=h.elementToImage(S.offsetX,S.offsetY)),d.length>2){const M=wa(f,d[0])*u;e(1,m=M<B0)}S.pointerType==="touch"&&(p=setTimeout(()=>{g()},F0))}},v=R=>{const S=R;if(p&&clearTimeout(p),l==="click"){const M=S.timeStamp-c.timeStamp,P=wa([c.offsetX,c.offsetY],[S.offsetX,S.offsetY]);if(M>300||P>15)return;if(m)x();else if(d.length===0){const F=h.elementToImage(S.offsetX,S.offsetY);d.push(F),e(10,f=F)}else d.push(f)}else{if(d.length===1&&wa(d[0],f)<=4){e(0,d=[]),e(10,f=void 0);return}S.stopImmediatePropagation(),m?x():d.push(f)}},g=()=>{if(!f)return;const R=d.slice(0,-1);if(R.length<3)return;const S={type:Tt.POLYGON,geometry:{bounds:Ue(d),points:R}};ua(S)>4&&(e(0,d=[]),e(10,f=void 0),o("create",S))},x=()=>{const R={type:Tt.POLYGON,geometry:{bounds:Ue(d),points:[...d]}};e(0,d=[]),e(10,f=void 0),o("create",R)};gi(()=>{a("pointerdown",_,!0),a("pointermove",y),a("pointerup",v,!0),a("dblclick",g,!0)});const E=`polygon-mask-${Math.random().toString(36).substring(2,12)}`;return r.$$set=R=>{"addEventListener"in R&&e(6,a=R.addEventListener),"drawingMode"in R&&e(7,l=R.drawingMode),"transform"in R&&e(8,h=R.transform),"viewportScale"in R&&e(9,u=R.viewportScale)},r.$$.update=()=>{r.$$.dirty&512&&e(4,i=4/u),r.$$.dirty&1027&&e(2,s=f?m?d:[...d,f]:[]),r.$$.dirty&516&&e(3,n=s.length>0?In(Ue(s),2/u):void 0)},[d,m,s,n,i,E,a,l,h,u,f]}class U0 extends De{constructor(t){super(),Ne(this,t,k0,L0,le,{addEventListener:6,drawingMode:7,transform:8,viewportScale:9})}}const Na=new Map([["rectangle",{tool:D0}],["polygon",{tool:U0}]]),Rn=()=>[...Na.keys()],Mn=r=>Na.get(r),yc=(r,t,e={})=>Na.set(r,{tool:t,opts:e});function G0(r){let t,e,i,s,n;return{c(){t=Z("g"),e=Z("ellipse"),s=Z("ellipse"),b(e,"class","a9s-outer"),b(e,"style",i=r[1]?"display:none;":void 0),b(e,"cx",r[2]),b(e,"cy",r[3]),b(e,"rx",r[4]),b(e,"ry",r[5]),b(s,"class","a9s-inner"),b(s,"style",r[1]),b(s,"cx",r[2]),b(s,"cy",r[3]),b(s,"rx",r[4]),b(s,"ry",r[5]),b(t,"class","a9s-annotation"),b(t,"data-id",n=r[0].id)},m(o,a){it(o,t,a),wt(t,e),wt(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&b(e,"style",i),a&2&&b(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&b(t,"data-id",n)},i:Dt,o:Dt,d(o){o&&rt(t)}}}function H0(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:o}=t;const{cx:a,cy:l,rx:h,ry:u}=n;return r.$$set=c=>{"annotation"in c&&e(0,s=c.annotation),"geom"in c&&e(6,n=c.geom),"style"in c&&e(7,o=c.style)},r.$$.update=()=>{r.$$.dirty&129&&e(1,i=Os(s,o))},[s,i,a,l,h,u,n,o]}class $0 extends De{constructor(t){super(),Ne(this,t,H0,G0,le,{annotation:0,geom:6,style:7})}}function _c(r,t,e){const i=r.slice();return i[5]=t[e],i}function vc(r){let t,e,i;return{c(){t=Z("path"),i=Z("path"),b(t,"class","a9s-outer"),b(t,"style",e=r[1]?"display:none;":void 0),b(t,"fill-rule","evenodd"),b(t,"d",Ze(r[5])),b(i,"class","a9s-inner"),b(i,"style",r[1]),b(i,"fill-rule","evenodd"),b(i,"d",Ze(r[5]))},m(s,n){it(s,t,n),it(s,i,n)},p(s,n){n&2&&e!==(e=s[1]?"display:none;":void 0)&&b(t,"style",e),n&2&&b(i,"style",s[1])},d(s){s&&(rt(t),rt(i))}}}function X0(r){let t,e,i=ke(r[2]),s=[];for(let n=0;n<i.length;n+=1)s[n]=vc(_c(r,i,n));return{c(){t=Z("g");for(let n=0;n<s.length;n+=1)s[n].c();b(t,"class","a9s-annotation"),b(t,"data-id",e=r[0].id)},m(n,o){it(n,t,o);for(let a=0;a<s.length;a+=1)s[a]&&s[a].m(t,null)},p(n,[o]){if(o&6){i=ke(n[2]);let a;for(a=0;a<i.length;a+=1){const l=_c(n,i,a);s[a]?s[a].p(l,o):(s[a]=vc(l),s[a].c(),s[a].m(t,null))}for(;a<s.length;a+=1)s[a].d(1);s.length=i.length}o&1&&e!==(e=n[0].id)&&b(t,"data-id",e)},i:Dt,o:Dt,d(n){n&&rt(t),mi(s,n)}}}function V0(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:o}=t;const{polygons: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=Os(s,o))},[s,i,a,n,o]}class z0 extends De{constructor(t){super(),Ne(this,t,V0,X0,le,{annotation:0,geom:3,style:4})}}function Y0(r){let t,e,i,s,n;return{c(){t=Z("g"),e=Z("polygon"),s=Z("polygon"),b(e,"class","a9s-outer"),b(e,"style",i=r[1]?"display:none;":void 0),b(e,"points",r[2].map(W0).join(" ")),b(s,"class","a9s-inner"),b(s,"style",r[1]),b(s,"points",r[2].map(j0).join(" ")),b(t,"class","a9s-annotation"),b(t,"data-id",n=r[0].id)},m(o,a){it(o,t,a),wt(t,e),wt(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&b(e,"style",i),a&2&&b(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&b(t,"data-id",n)},i:Dt,o:Dt,d(o){o&&rt(t)}}}const W0=r=>r.join(","),j0=r=>r.join(",");function q0(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=Os(s,o))},[s,i,a,n,o]}class K0 extends De{constructor(t){super(),Ne(this,t,q0,Y0,le,{annotation:0,geom:3,style:4})}}function Z0(r){let t,e,i,s,n;return{c(){t=Z("g"),e=Z("rect"),s=Z("rect"),b(e,"class","a9s-outer"),b(e,"style",i=r[5]?"display:none;":void 0),b(e,"x",r[4]),b(e,"y",r[3]),b(e,"width",r[2]),b(e,"height",r[1]),b(s,"class","a9s-inner"),b(s,"style",r[5]),b(s,"x",r[4]),b(s,"y",r[3]),b(s,"width",r[2]),b(s,"height",r[1]),b(t,"class","a9s-annotation"),b(t,"data-id",n=r[0].id)},m(o,a){it(o,t,a),wt(t,e),wt(t,s)},p(o,[a]){a&32&&i!==(i=o[5]?"display:none;":void 0)&&b(e,"style",i),a&16&&b(e,"x",o[4]),a&8&&b(e,"y",o[3]),a&4&&b(e,"width",o[2]),a&2&&b(e,"height",o[1]),a&32&&b(s,"style",o[5]),a&16&&b(s,"x",o[4]),a&8&&b(s,"y",o[3]),a&4&&b(s,"width",o[2]),a&2&&b(s,"height",o[1]),a&1&&n!==(n=o[0].id)&&b(t,"data-id",n)},i:Dt,o:Dt,d(o){o&&rt(t)}}}function Q0(r,t,e){let i,s,n,o,a,{annotation:l}=t,{geom:h}=t,{style:u}=t;return r.$$set=c=>{"annotation"in c&&e(0,l=c.annotation),"geom"in c&&e(6,h=c.geom),"style"in c&&e(7,u=c.style)},r.$$.update=()=>{r.$$.dirty&129&&e(5,i=Os(l,u)),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,u]}class J0 extends De{constructor(t){super(),Ne(this,t,Q0,Z0,le,{annotation:0,geom:6,style:7})}}const tv=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]}}),ev=250,rv=(r,t)=>{const e=Xr();let i;return{onPointerDown:()=>i=performance.now(),onPointerUp:s=>{if(performance.now()-i<ev){const{x:n,y:o}=xc(s,r),a=t.getAt(n,o);a?e("click",{originalEvent:s,annotation:a}):e("click",{originalEvent:s})}}}},xc=(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())};function bc(r,t,e){const i=r.slice();i[39]=t[e];const s=i[24](i[39].target.selector);return i[40]=s,i}function Ec(r,t,e){const i=r.slice();return i[43]=t[e],i}function Da(r){const t=r.slice(),e=t[43].target.selector;return t[46]=e,t}function wc(r){let t=r[43],e,i,s=Tc(r);return{c(){s.c(),e=Fe()},m(n,o){s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&65536&&le(t,t=n[43])?(Ie(),gt(s,1,1,Dt),Re(),s=Tc(n),s.c(),ot(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ot(s),i=!0)},o(n){gt(s),i=!1},d(n){n&&rt(e),s.d(n)}}}function iv(r){let t,e;return t=new z0({props:{annotation:r[43],geom:r[46].geometry,style:r[1]}}),{c(){be(t.$$.fragment)},m(i,s){ce(t,i,s),e=!0},p(i,s){const n={};s[0]&65536&&(n.annotation=i[43]),s[0]&65536&&(n.geom=i[46].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){gt(t.$$.fragment,i),e=!1},d(i){de(t,i)}}}function sv(r){let t,e;return t=new K0({props:{annotation:r[43],geom:r[46].geometry,style:r[1]}}),{c(){be(t.$$.fragment)},m(i,s){ce(t,i,s),e=!0},p(i,s){const n={};s[0]&65536&&(n.annotation=i[43]),s[0]&65536&&(n.geom=i[46].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){gt(t.$$.fragment,i),e=!1},d(i){de(t,i)}}}function nv(r){let t,e;return t=new J0({props:{annotation:r[43],geom:r[46].geometry,style:r[1]}}),{c(){be(t.$$.fragment)},m(i,s){ce(t,i,s),e=!0},p(i,s){const n={};s[0]&65536&&(n.annotation=i[43]),s[0]&65536&&(n.geom=i[46].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){gt(t.$$.fragment,i),e=!1},d(i){de(t,i)}}}function ov(r){var t;let e,i;return e=new $0({props:{annotation:r[43],geom:(t=r[46])==null?void 0:t.geometry,style:r[1]}}),{c(){be(e.$$.fragment)},m(s,n){ce(e,s,n),i=!0},p(s,n){var o;const a={};n[0]&65536&&(a.annotation=s[43]),n[0]&65536&&(a.geom=(o=s[46])==null?void 0:o.geometry),n[0]&2&&(a.style=s[1]),e.$set(a)},i(s){i||(ot(e.$$.fragment,s),i=!0)},o(s){gt(e.$$.fragment,s),i=!1},d(s){de(e,s)}}}function Tc(r){let t,e,i,s;const n=[ov,nv,sv,iv],o=[];function a(l,h){var u,c,d,f;return((u=l[46])==null?void 0:u.type)===Tt.ELLIPSE?0:((c=l[46])==null?void 0:c.type)===Tt.RECTANGLE?1:((d=l[46])==null?void 0:d.type)===Tt.POLYGON?2:((f=l[46])==null?void 0:f.type)===Tt.MULTIPOLYGLON?3:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Fe()},m(l,h){~t&&o[t].m(l,h),it(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(Ie(),gt(o[u],1,1,()=>{o[u]=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){gt(e),s=!1},d(l){l&&rt(i),~t&&o[t].d(l)}}}function Ac(r){let t=ze(r[43])&&!r[9](r[43]),e,i,s=t&&wc(Da(r));return{c(){s&&s.c(),e=Fe()},m(n,o){s&&s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&66048&&(t=ze(n[43])&&!n[9](n[43])),t?s?(s.p(Da(n),o),o[0]&66048&&ot(s,1)):(s=wc(Da(n)),s.c(),ot(s,1),s.m(e.parentNode,e)):s&&(Ie(),gt(s,1,1,()=>{s=null}),Re())},i(n){i||(ot(s),i=!0)},o(n){gt(s),i=!1},d(n){n&&rt(e),s&&s.d(n)}}}function Sc(r){let t,e,i,s;const n=[lv,av],o=[];function a(l,h){return l[8]?0:l[14]&&l[0]?1:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Fe()},m(l,h){~t&&o[t].m(l,h),it(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(Ie(),gt(o[u],1,1,()=>{o[u]=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){gt(e),s=!1},d(l){l&&rt(i),~t&&o[t].d(l)}}}function av(r){let t=`${r[2]}-${r[5]}`,e,i,s=Cc(r);return{c(){s.c(),e=Fe()},m(n,o){s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&36&&le(t,t=`${n[2]}-${n[5]}`)?(Ie(),gt(s,1,1,Dt),Re(),s=Cc(n),s.c(),ot(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ot(s),i=!0)},o(n){gt(s),i=!1},d(n){n&&rt(e),s.d(n)}}}function lv(r){let t,e,i=ke(r[8]),s=[];for(let o=0;o<i.length;o+=1)s[o]=Mc(bc(r,i,o));const n=o=>gt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Fe()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);it(o,t,a),e=!0},p(o,a){if(a[0]&21107010){i=ke(o[8]);let l;for(l=0;l<i.length;l+=1){const h=bc(o,i,l);s[l]?(s[l].p(h,a),ot(s[l],1)):(s[l]=Mc(h),s[l].c(),ot(s[l],1),s[l].m(t.parentNode,t))}for(Ie(),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(Boolean);for(let a=0;a<s.length;a+=1)gt(s[a]);e=!1},d(o){o&&rt(t),mi(s,o)}}}function Cc(r){let t,e;return t=new P0({props:{target:r[6],tool:r[14],drawingMode:r[13],transform:r[12],viewportScale:r[17]}}),t.$on("create",r[21]),{c(){be(t.$$.fragment)},m(i,s){ce(t,i,s),e=!0},p(i,s){const n={};s[0]&64&&(n.target=i[6]),s[0]&16384&&(n.tool=i[14]),s[0]&8192&&(n.drawingMode=i[13]),s[0]&4096&&(n.transform=i[12]),s[0]&131072&&(n.viewportScale=i[17]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){gt(t.$$.fragment,i),e=!1},d(i){de(t,i)}}}function Ic(r){let t=r[39].id,e,i,s=Rc(r);return{c(){s.c(),e=Fe()},m(n,o){s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&256&&le(t,t=n[39].id)?(Ie(),gt(s,1,1,Dt),Re(),s=Rc(n),s.c(),ot(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ot(s),i=!0)},o(n){gt(s),i=!1},d(n){n&&rt(e),s.d(n)}}}function Rc(r){let t,e;return t=new R0({props:{target:r[6],editor:r[24](r[39].target.selector),annotation:r[39],style:r[1],transform:r[12],viewportScale:r[17]}}),t.$on("change",function(){Vt(r[22](r[39]))&&r[22](r[39]).apply(this,arguments)}),{c(){be(t.$$.fragment)},m(i,s){ce(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&64&&(n.target=r[6]),s[0]&256&&(n.editor=r[24](r[39].target.selector)),s[0]&256&&(n.annotation=r[39]),s[0]&2&&(n.style=r[1]),s[0]&4096&&(n.transform=r[12]),s[0]&131072&&(n.viewportScale=r[17]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){gt(t.$$.fragment,i),e=!1},d(i){de(t,i)}}}function Mc(r){let t,e,i=r[40]&&Ic(r);return{c(){i&&i.c(),t=Fe()},m(s,n){i&&i.m(s,n),it(s,t,n),e=!0},p(s,n){s[40]?i?(i.p(s,n),n[0]&256&&ot(i,1)):(i=Ic(s),i.c(),ot(i,1),i.m(t.parentNode,t)):i&&(Ie(),gt(i,1,1,()=>{i=null}),Re())},i(s){e||(ot(i),e=!0)},o(s){gt(i),e=!1},d(s){s&&rt(t),i&&i.d(s)}}}function hv(r){let t,e,i,s,n,o,a=ke(r[16].filter(r[34])),l=[];for(let c=0;c<a.length;c+=1)l[c]=Ac(Ec(r,a,c));const h=c=>gt(l[c],1,1,()=>{l[c]=null});let u=r[6]&&Sc(r);return{c(){t=Z("svg"),e=Z("g");for(let c=0;c<l.length;c+=1)l[c].c();i=Z("g"),u&&u.c(),b(i,"class","drawing"),b(t,"role","application"),b(t,"tabindex",0),b(t,"class","a9s-annotationlayer"),cr(t,"drawing",r[14]),cr(t,"editing",r[8]),cr(t,"hidden",!r[3]),cr(t,"hover",r[15])},m(c,d){it(c,t,d),wt(t,e);for(let f=0;f<l.length;f+=1)l[f]&&l[f].m(e,null);wt(t,i),u&&u.m(i,null),r[35](i),r[36](t),s=!0,n||(o=[Rt(t,"pointerup",function(){Vt(r[10])&&r[10].apply(this,arguments)}),Rt(t,"pointerdown",function(){Vt(r[11])&&r[11].apply(this,arguments)}),Rt(t,"pointermove",r[23])],n=!0)},p(c,d){if(r=c,d[0]&66050){a=ke(r[16].filter(r[34]));let f;for(f=0;f<a.length;f+=1){const p=Ec(r,a,f);l[f]?(l[f].p(p,d),ot(l[f],1)):(l[f]=Ac(p),l[f].c(),ot(l[f],1),l[f].m(e,null))}for(Ie(),f=a.length;f<l.length;f+=1)h(f);Re()}r[6]?u?(u.p(r,d),d[0]&64&&ot(u,1)):(u=Sc(r),u.c(),ot(u,1),u.m(i,null)):u&&(Ie(),gt(u,1,1,()=>{u=null}),Re()),(!s||d[0]&16384)&&cr(t,"drawing",r[14]),(!s||d[0]&256)&&cr(t,"editing",r[8]),(!s||d[0]&8)&&cr(t,"hidden",!r[3]),(!s||d[0]&32768)&&cr(t,"hover",r[15])},i(c){if(!s){for(let d=0;d<a.length;d+=1)ot(l[d]);ot(u),s=!0}},o(c){l=l.filter(Boolean);for(let d=0;d<l.length;d+=1)gt(l[d]);gt(u),s=!1},d(c){c&&rt(t),mi(l,c),u&&u.d(),r[35](null),r[36](null),n=!1,$e(o)}}}function uv(r,t,e){let i,s,n,o,a,l,h,u,c,d,f,p=Dt,m=()=>(p(),p=fu(w,W=>e(17,f=W)),w);r.$$.on_destroy.push(()=>p());let{drawingEnabled:_}=t,{image:y}=t,{preferredDrawingMode:v}=t,{state:g}=t,{style:x=void 0}=t,{toolName:E=Rn()[0]}=t,{user:R}=t,{visible:S=!0}=t,M=0;const P=()=>e(5,M+=1),F=()=>E,U=()=>_;let I,A,w;gi(()=>m(e(7,w=Z_(y,A))));const{hover:C,selection:D,store:N}=g;na(r,C,W=>e(15,u=W)),na(r,D,W=>e(33,c=W)),na(r,N,W=>e(16,d=W));let B,V;const L=W=>{B&&N.unobserve(B);const bt=W.filter(({editable:dt})=>dt).map(({id:dt})=>dt);bt.length>0?(e(8,V=bt.map(dt=>N.getAnnotation(dt)).filter(dt=>dt&&ze(dt))),B=dt=>{const{updated:mt}=dt.changes;e(8,V=mt==null?void 0:mt.map(xt=>xt.newValue))},N.observe(B,{annotations:bt})):e(8,V=void 0)},O=W=>{const bt=ku(),dt={id:bt,bodies:[],target:{annotation:bt,selector:W.detail,creator:R,created:new Date}};N.addAnnotation(dt),D.setSelected(dt.id)},k=W=>bt=>{var dt;const{target:mt}=W,xt=10*60*1e3,Mt=((dt=mt.creator)==null?void 0:dt.id)!==R.id||!mt.created||new Date().getTime()-mt.created.getTime()>xt;N.updateTarget({...mt,selector:bt.detail,created:Mt?mt.created:new Date,updated:Mt?new Date:void 0,updatedBy:Mt?R:void 0})},X=W=>{const{x:bt,y:dt}=xc(W,A),mt=N.getAt(bt,dt);mt?u!==mt.id&&C.set(mt.id):C.set(void 0)},Y=W=>dc(W),q=W=>ze(W);function pt(W){bn[W?"unshift":"push"](()=>{I=W,e(6,I)})}function _t(W){bn[W?"unshift":"push"](()=>{A=W,e(4,A)})}return r.$$set=W=>{"drawingEnabled"in W&&e(0,_=W.drawingEnabled),"image"in W&&e(25,y=W.image),"preferredDrawingMode"in W&&e(26,v=W.preferredDrawingMode),"state"in W&&e(27,g=W.state),"style"in W&&e(1,x=W.style),"toolName"in W&&e(2,E=W.toolName),"user"in W&&e(28,R=W.user),"visible"in W&&e(3,S=W.visible)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(14,{tool:i,opts:s}=Mn(E)||{tool:void 0,opts:void 0},i,(e(32,s),e(2,E))),r.$$.dirty[0]&67108864|r.$$.dirty[1]&2&&e(13,n=(s==null?void 0:s.drawingMode)||v),r.$$.dirty[0]&16&&e(12,o=tv(A)),r.$$.dirty[0]&16&&e(11,{onPointerDown:a,onPointerUp:l}=rv(A,N),a,(e(10,l),e(4,A))),r.$$.dirty[1]&4&&e(9,h=W=>c.selected.find(bt=>bt.id===W.id&&bt.editable)),r.$$.dirty[1]&4&&L(c.selected)},[_,x,E,S,A,M,I,w,V,h,l,a,o,n,i,u,d,f,C,D,N,O,k,X,Y,y,v,g,R,P,F,U,s,c,q,pt,_t]}class cv extends De{constructor(t){super(),Ne(this,t,uv,hv,le,{drawingEnabled:0,image:25,preferredDrawingMode:26,state:27,style:1,toolName:2,user:28,visible:3,cancelDrawing:29,getDrawingTool:30,isDrawingEnabled:31},null,[-1,-1])}get cancelDrawing(){return this.$$.ctx[29]}get getDrawingTool(){return this.$$.ctx[30]}get isDrawingEnabled(){return this.$$.ctx[31]}}function Pc(r,t,e=0,i=r.length-1,s=dv){for(;i>e;){if(i-e>600){const l=i-e+1,h=t-e+1,u=Math.log(l),c=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*c*(l-c)/l)*(h-l/2<0?-1:1),f=Math.max(e,Math.floor(t-h*c/l+d)),p=Math.min(i,Math.floor(t+(l-h)*c/l+d));Pc(r,t,f,p,s)}const n=r[t];let o=e,a=i;for(Ls(r,e,t),s(r[i],n)>0&&Ls(r,e,i);o<a;){for(Ls(r,o,a),o++,a--;s(r[o],n)<0;)o++;for(;s(r[a],n)>0;)a--}s(r[e],n)===0?Ls(r,e,a):(a++,Ls(r,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function Ls(r,t,e){const i=r[t];r[t]=r[e],r[e]=i}function dv(r,t){return r<t?-1:r>t?1:0}class fv{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(!On(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;On(t,l)&&(e.leaf?i.push(a):Ba(t,l)?this._all(a,i):n.push(a))}e=n.pop()}return i}collides(t){let e=this.data;if(!On(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(On(t,o)){if(e.leaf||Ba(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=qi([]),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 u=pv(t,i.children,e);if(u!==-1)return i.children.splice(u,1),n.push(i),this._condense(n),this}!h&&!i.leaf&&Ba(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=qi(t.slice(e,i+1)),ji(a,this.toBBox),a;s||(s=Math.ceil(Math.log(n)/Math.log(o)),o=Math.ceil(n/Math.pow(o,s-1))),a=qi([]),a.leaf=!1,a.height=s;const l=Math.ceil(n/o),h=l*Math.ceil(Math.sqrt(o));Oc(t,e,i,h,this.compareMinX);for(let u=e;u<=i;u+=h){const c=Math.min(u+h-1,i);Oc(t,u,c,l,this.compareMinY);for(let d=u;d<=c;d+=l){const f=Math.min(d+l-1,c);a.children.push(this._build(t,d,f,s-1))}}return ji(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],u=La(h),c=yv(t,h)-u;c<o?(o=c,n=u<n?u:n,a=h):c===o&&u<n&&(n=u,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),Fs(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=qi(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,ji(i,this.toBBox),ji(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=qi([t,e]),this.data.height=t.height+1,this.data.leaf=!1,ji(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=Bs(t,0,a,this.toBBox),h=Bs(t,a,i,this.toBBox),u=_v(l,h),c=La(l)+La(h);u<n?(n=u,s=a,o=c<o?c:o):u===n&&c<o&&(o=c,s=a)}return s||i-e}_chooseSplitAxis(t,e,i){const s=t.leaf?this.compareMinX:mv,n=t.leaf?this.compareMinY:gv,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=Bs(t,0,e,n),a=Bs(t,i-e,i,n);let l=Pn(o)+Pn(a);for(let h=e;h<i-e;h++){const u=t.children[h];Fs(o,t.leaf?n(u):u),l+=Pn(o)}for(let h=i-e-1;h>=e;h--){const u=t.children[h];Fs(a,t.leaf?n(u):u),l+=Pn(a)}return l}_adjustParentBBoxes(t,e,i){for(let s=i;s>=0;s--)Fs(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():ji(t[e],this.toBBox)}}function pv(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 ji(r,t){Bs(r,0,r.children.length,t,r)}function Bs(r,t,e,i,s){s||(s=qi(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];Fs(s,r.leaf?i(o):o)}return s}function Fs(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 mv(r,t){return r.minX-t.minX}function gv(r,t){return r.minY-t.minY}function La(r){return(r.maxX-r.minX)*(r.maxY-r.minY)}function Pn(r){return r.maxX-r.minX+(r.maxY-r.minY)}function yv(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 _v(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 Ba(r,t){return r.minX<=t.minX&&r.minY<=t.minY&&t.maxX<=r.maxX&&t.maxY<=r.maxY}function On(r,t){return t.minX<=r.maxX&&t.minY<=r.maxY&&t.maxX>=r.minX&&t.maxY>=r.minY}function qi(r){return{children:r,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Oc(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;Pc(r,o,t,e,s),n.push(t,o,o,e)}}const vv=()=>{const r=new fv,t=new Map,e=()=>[...t.values()],i=()=>{r.clear(),t.clear()},s=o=>{if(!Tn(o))return;const{minX:a,minY:l,maxX:h,maxY:u}=o.selector.geometry.bounds,c={minX:a,minY:l,maxX:h,maxY:u,target:o};r.insert(c),t.set(o.annotation,c)},n=o=>{if(!Tn(o))return;const a=t.get(o.annotation);a&&r.remove(a),t.delete(o.annotation)};return{all:e,clear:i,getAt:(o,a,l)=>{const h=r.search({minX:o,minY:a,maxX:o,maxY:a}).map(u=>u.target).filter(u=>u.selector.type===Tt.RECTANGLE||wy(u.selector,o,a));return h.length>0?(h.sort((u,c)=>ua(u.selector)-ua(c.selector)),h):[]},getIntersecting:(o,a,l,h)=>r.search({minX:o,minY:a,maxX:o+l,maxY:a+h}).map(u=>u.target),insert:s,remove:n,set:(o,a=!0)=>{a&&i();const l=o.reduce((h,u)=>{if(Tn(u)){const{minX:c,minY:d,maxX:f,maxY:p}=u.selector.geometry.bounds;return[...h,{minX:c,minY:d,maxX:f,maxY:p,target:u}]}else return h},[]);l.forEach(h=>t.set(h.target.annotation,h)),r.load(l)},size:()=>r.all().length,update:(o,a)=>{n(o),s(a)}}},Nc=r=>{const t=S_(),e=vv(),i=f_(t,r.userSelectAction,r.adapter),s=d_(t),n=P_();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,l)=>{const h=e.getAt(o,a,l);if(l)return h.map(u=>t.getAnnotation(u.annotation)).filter(Boolean).filter(l)[0];{const u=h[0];return u?t.getAnnotation(u.annotation):void 0}},getIntersecting:(o,a,l,h)=>e.getIntersecting(o,a,l,h).map(u=>t.getAnnotation(u.annotation)).filter(Boolean)},selection:i,hover:s,viewport:n}},xv=r=>{const t=Nc(r);return{...t,store:C_(t.store)}},bv=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},Dc=r=>{const t=bv(r),e=t>.6?"dark":"light";return console.log(`[Annotorious] Image brightness: ${t.toFixed(1)}. Setting ${e} theme.`),e},Lc=(r,t,e)=>t.setAttribute("data-theme",e==="auto"?Dc(r):e),Bc=(r,t)=>({...r,drawingEnabled:r.drawingEnabled===void 0?t.drawingEnabled:r.drawingEnabled,drawingMode:r.drawingMode||t.drawingMode,userSelectAction:r.userSelectAction||t.userSelectAction,theme:r.theme||t.theme}),Fc=typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1,kc=(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=()=>{Fc?e.removeEventListener("keydown",s):e.removeEventListener("keydown",i)};return Fc?e.addEventListener("keydown",s):e.addEventListener("keydown",i),{destroy:n}},Ev=(r,t={})=>{if(!r)throw"Missing argument: image";const e=typeof r=="string"?document.getElementById(r):r,i=Bc(t,{drawingEnabled:!0,drawingMode:"drag",userSelectAction:Gu.EDIT,theme:"light"}),s=xv(i),{selection:n,store:o}=s,a=M_(o,i.initialHistory),l=O_(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 u=kc(a);let c=$_();Lc(e,h,i.theme);const d=new cv({target:h,props:{drawingEnabled:!!i.drawingEnabled,image:e,preferredDrawingMode:i.drawingMode,state:s,style:i.style,user:c}});d.$on("click",I=>{const{originalEvent:A,annotation:w}=I.detail;w?n.userSelect(w.id,A):n.isEmpty()||n.clear()});const f=D_(s,a,i.adapter),p=()=>d.cancelDrawing(),m=()=>{d.$destroy(),h.parentNode.insertBefore(e,h),h.parentNode.removeChild(h),u.destroy(),a.destroy()},_=()=>d.getDrawingTool(),y=()=>c,v=()=>d.isDrawingEnabled(),g=(I,A,w)=>yc(I,A,w),x=(I,A)=>fc(I,A),E=I=>{if(!Mn(I))throw`No drawing tool named ${I}`;d.$set({toolName:I})},R=I=>d.$set({drawingEnabled:I}),S=I=>{console.warn("Filter not implemented yet")},M=I=>d.$set({style:I}),P=I=>Lc(e,h,I),F=I=>{c=I,d.$set({user:I})},U=I=>d.$set({visible:I});return{...f,cancelDrawing:p,destroy:m,getDrawingTool:_,getUser:y,isDrawingEnabled:v,listDrawingTools:Rn,on:l.on,off:l.off,registerDrawingTool:g,registerShapeEditor:x,setDrawingEnabled:R,setDrawingTool:E,setFilter:S,setStyle:M,setTheme:P,setUser:F,setVisible:U,element:h,state:s}};function Qt(){}function Fa(r,t){for(const e in t)r[e]=t[e];return r}function Uc(r){return r()}function Gc(){return Object.create(null)}function Ye(r){r.forEach(Uc)}function Jt(r){return typeof r=="function"}function qt(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function wv(r){return Object.keys(r).length===0}function Tv(r,...t){if(r==null){for(const i of t)i(void 0);return Qt}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function Nn(r,t,e){r.$$.on_destroy.push(Tv(t,e))}function Hc(r,t,e,i){if(r){const s=$c(r,t,e,i);return r[0](s)}}function $c(r,t,e,i){return r[1]&&i?Fa(e.ctx.slice(),r[1](i(t))):e.ctx}function Xc(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 Vc(r,t,e,i,s,n){if(s){const o=$c(t,e,i,n);r.p(o,s)}}function zc(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 Yc(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}const ka=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function Ct(r,t){r.appendChild(t)}function at(r,t,e){r.insertBefore(t,e||null)}function nt(r){r.parentNode&&r.parentNode.removeChild(r)}function Wr(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function st(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function Ua(r){return document.createTextNode(r)}function Le(){return Ua(" ")}function Ge(){return Ua("")}function Pt(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function T(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function Av(r){return Array.from(r.childNodes)}function Sv(r,t){t=""+t,r.data!==t&&(r.data=t)}function jr(r,t,e){r.classList.toggle(t,!!e)}function Cv(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let ks;function Us(r){ks=r}function Ga(){if(!ks)throw new Error("Function called outside component initialization");return ks}function vi(r){Ga().$$.on_mount.push(r)}function Iv(r){Ga().$$.on_destroy.push(r)}function Ki(){const r=Ga();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=Cv(t,e,{cancelable:i});return s.slice().forEach(o=>{o.call(r,n)}),!n.defaultPrevented}return!0}}function Me(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const Zi=[],Dn=[];let Qi=[];const Wc=[],jc=Promise.resolve();let Ha=!1;function qc(){Ha||(Ha=!0,jc.then(Zc))}function Kc(){return qc(),jc}function $a(r){Qi.push(r)}const Xa=new Set;let Ji=0;function Zc(){if(Ji!==0)return;const r=ks;do{try{for(;Ji<Zi.length;){const t=Zi[Ji];Ji++,Us(t),Rv(t.$$)}}catch(t){throw Zi.length=0,Ji=0,t}for(Us(null),Zi.length=0,Ji=0;Dn.length;)Dn.pop()();for(let t=0;t<Qi.length;t+=1){const e=Qi[t];Xa.has(e)||(Xa.add(e),e())}Qi.length=0}while(Zi.length);for(;Wc.length;)Wc.pop()();Ha=!1,Xa.clear(),Us(r)}function Rv(r){if(r.fragment!==null){r.update(),Ye(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach($a)}}function Mv(r){const t=[],e=[];Qi.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),Qi=t}const Ln=new Set;let xi;function fe(){xi={r:0,c:[],p:xi}}function pe(){xi.r||Ye(xi.c),xi=xi.p}function K(r,t){r&&r.i&&(Ln.delete(r),r.i(t))}function lt(r,t,e,i){if(r&&r.o){if(Ln.has(r))return;Ln.add(r),xi.c.push(()=>{Ln.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function Pe(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function Ht(r){r&&r.c()}function Ft(r,t,e){const{fragment:i,after_update:s}=r.$$;i&&i.m(t,e),$a(()=>{const n=r.$$.on_mount.map(Uc).filter(Jt);r.$$.on_destroy?r.$$.on_destroy.push(...n):Ye(n),r.$$.on_mount=[]}),s.forEach($a)}function kt(r,t){const e=r.$$;e.fragment!==null&&(Mv(e.after_update),Ye(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function Pv(r,t){r.$$.dirty[0]===-1&&(Zi.push(r),qc(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function ie(r,t,e,i,s,n,o=null,a=[-1]){const l=ks;Us(r);const h=r.$$={fragment:null,ctx:[],props:n,update:Qt,not_equal:s,bound:Gc(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:Gc(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let u=!1;if(h.ctx=e?e(r,t.props||{},(c,d,...f)=>{const p=f.length?f[0]:d;return h.ctx&&s(h.ctx[c],h.ctx[c]=p)&&(!h.skip_bound&&h.bound[c]&&h.bound[c](p),u&&Pv(r,c)),d}):[],h.update(),u=!0,Ye(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const c=Av(t.target);h.fragment&&h.fragment.l(c),c.forEach(nt)}else h.fragment&&h.fragment.c();t.intro&&K(r.$$.fragment),Ft(r,t.target,t.anchor),Zc()}Us(l)}class se{constructor(){$t(this,"$$");$t(this,"$$set")}$destroy(){kt(this,1),this.$destroy=Qt}$on(t,e){if(!Jt(e))return Qt;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&&!wv(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const Ov="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Ov);var qr=(r=>(r.ELLIPSE="ELLIPSE",r.MULTIPOLYGLON="MULTIPOLYGON",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(qr||{}),Gs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Va(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Nv(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 Qc={exports:{}};(function(r){(function(){function t(a,l){var h=a.x-l.x,u=a.y-l.y;return h*h+u*u}function e(a,l,h){var u=l.x,c=l.y,d=h.x-u,f=h.y-c;if(d!==0||f!==0){var p=((a.x-u)*d+(a.y-c)*f)/(d*d+f*f);p>1?(u=h.x,c=h.y):p>0&&(u+=d*p,c+=f*p)}return d=a.x-u,f=a.y-c,d*d+f*f}function i(a,l){for(var h=a[0],u=[h],c,d=1,f=a.length;d<f;d++)c=a[d],t(c,h)>l&&(u.push(c),h=c);return h!==c&&u.push(c),u}function s(a,l,h,u,c){for(var d=u,f,p=l+1;p<h;p++){var m=e(a[p],a[l],a[h]);m>d&&(f=p,d=m)}d>u&&(f-l>1&&s(a,l,f,u,c),c.push(a[f]),h-f>1&&s(a,f,h,u,c))}function n(a,l){var h=a.length-1,u=[a[0]];return s(a,0,h,l,u),u.push(a[h]),u}function o(a,l,h){if(a.length<=2)return a;var u=l!==void 0?l*l:1;return a=h?a:i(a,u),a=n(a,u),a}r.exports=o,r.exports.default=o})()})(Qc);var Dv=Qc.exports;const Lv=Va(Dv),Bn=(r,t)=>t,dr=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}},za=r=>{let t=0,e=r.length-1;for(let i=0;i<r.length;i++)t+=(r[e][0]+r[i][0])*(r[e][1]-r[i][1]),e=i;return Math.abs(.5*t)},Ya=(r,t,e)=>{let i=!1;for(let s=0,n=r.length-1;s<r.length;n=s++){const o=r[s][0],a=r[s][1],l=r[n][0],h=r[n][1];a>e!=h>e&&t<(l-o)*(e-a)/(h-a)+o&&(i=!i)}return i},Bv=(r,t=!0)=>{let e="M ";return r.forEach(([i,s],n)=>{n===0?e+=`${i},${s}`:e+=` L ${i},${s}`}),t&&(e+=" Z"),e},Jc=(r,t=1)=>{const e=r.map(([i,s])=>({x:i,y:s}));return Lv(e,t,!0).map(i=>[i.x,i.y])},Fv={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),u=t-i,c=e-s,d=l*u+h*c,f=h*u-l*c;return d*d/(n*n)+f*f/(o*o)<=1}};Bn(qr.ELLIPSE,Fv);const kv={area:r=>{const{polygons:t}=r.geometry;return t.reduce((e,i)=>{const[s,...n]=i.rings,o=za(s.points),a=n.reduce((l,h)=>l+za(h.points),0);return e+o-a},0)},intersects:(r,t,e)=>{const{polygons:i}=r.geometry;for(const s of i){const[n,...o]=s.rings;if(Ya(n.points,t,e)){let a=!1;for(const l of o)if(Ya(l.points,t,e)){a=!0;break}if(!a)return!0}}return!1}},Fn=r=>{const t=r.reduce((e,i)=>[...e,...i.rings[0].points],[]);return dr(t)},ts=r=>r.rings.map(e=>Bv(e.points)).join(" "),Uv=r=>r.polygons.reduce((t,e)=>[...t,...e.rings.reduce((i,s)=>[...i,...s.points],[])],[]),Gv=(r,t=1)=>{const e=r.geometry.polygons.map(s=>{const n=s.rings.map(a=>{const l=Jc(a.points,t);return{...a,points:l}}),o=dr(n[0].points);return{...s,rings:n,bounds:o}}),i=Fn(e);return{...r,geometry:{...r.geometry,polygons:e,bounds:i}}};Bn(qr.MULTIPOLYGLON,kv);const Hv={area:r=>{const t=r.geometry.points;return za(t)},intersects:(r,t,e)=>{const i=r.geometry.points;return Ya(i,t,e)}},$v=(r,t=1)=>{const e=Jc(r.geometry.points,t),i=dr(e);return{...r,geometry:{...r.geometry,bounds:i,points:e}}};Bn(qr.POLYGON,Hv);const Xv={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};Bn(qr.RECTANGLE,Xv);const ne=" ";function Vv(r){let t="";Array.isArray(r)||(r=[r]);for(let e=0;e<r.length;e++){const i=r[e];if(i.type===$.CLOSE_PATH)t+="z";else if(i.type===$.HORIZ_LINE_TO)t+=(i.relative?"h":"H")+i.x;else if(i.type===$.VERT_LINE_TO)t+=(i.relative?"v":"V")+i.y;else if(i.type===$.MOVE_TO)t+=(i.relative?"m":"M")+i.x+ne+i.y;else if(i.type===$.LINE_TO)t+=(i.relative?"l":"L")+i.x+ne+i.y;else if(i.type===$.CURVE_TO)t+=(i.relative?"c":"C")+i.x1+ne+i.y1+ne+i.x2+ne+i.y2+ne+i.x+ne+i.y;else if(i.type===$.SMOOTH_CURVE_TO)t+=(i.relative?"s":"S")+i.x2+ne+i.y2+ne+i.x+ne+i.y;else if(i.type===$.QUAD_TO)t+=(i.relative?"q":"Q")+i.x1+ne+i.y1+ne+i.x+ne+i.y;else if(i.type===$.SMOOTH_QUAD_TO)t+=(i.relative?"t":"T")+i.x+ne+i.y;else if(i.type===$.ARC)t+=(i.relative?"a":"A")+i.rX+ne+i.rY+ne+i.xRot+ne+ +i.lArcFlag+ne+ +i.sweepFlag+ne+i.x+ne+i.y;else throw new Error(`Unexpected command type "${i==null?void 0:i.type}" at index ${e}.`)}return t}function Wa([r,t],e){return[r*Math.cos(e)-t*Math.sin(e),r*Math.sin(e)+t*Math.cos(e)]}function tr(...r){for(let t=0;t<r.length;t++)if(typeof r[t]!="number")throw new Error(`assertNumbers arguments[${t}] is not a number. ${typeof r[t]} == typeof ${r[t]}`);return!0}const Kr=Math.PI;function ja(r,t,e){r.lArcFlag=r.lArcFlag===0?0:1,r.sweepFlag=r.sweepFlag===0?0:1;let{rX:i,rY:s}=r;const{x:n,y:o}=r;if(Math.abs(i)<1e-10||Math.abs(s)<1e-10){r.rX=0,r.rY=0,r.cX=(t+n)/2,r.cY=(e+o)/2,r.phi1=0,r.phi2=0;return}i=Math.abs(r.rX),s=Math.abs(r.rY);const a=r.xRot/180*Kr,[l,h]=Wa([(t-n)/2,(e-o)/2],-a),u=Math.pow(l,2)/Math.pow(i,2)+Math.pow(h,2)/Math.pow(s,2);1<u&&(i*=Math.sqrt(u),s*=Math.sqrt(u)),r.rX=i,r.rY=s;const c=Math.pow(i,2)*Math.pow(h,2)+Math.pow(s,2)*Math.pow(l,2),d=(r.lArcFlag!==r.sweepFlag?1:-1)*Math.sqrt(Math.max(0,(Math.pow(i,2)*Math.pow(s,2)-c)/c)),f=i*h/s*d,p=-s*l/i*d,m=Wa([f,p],a);r.cX=m[0]+(t+n)/2,r.cY=m[1]+(e+o)/2,r.phi1=Math.atan2((h-p)/s,(l-f)/i),r.phi2=Math.atan2((-h-p)/s,(-l-f)/i),r.sweepFlag===0&&r.phi2>r.phi1&&(r.phi2-=2*Kr),r.sweepFlag===1&&r.phi2<r.phi1&&(r.phi2+=2*Kr),r.phi1*=180/Kr,r.phi2*=180/Kr}function td(r,t,e){tr(r,t,e);const i=r*r+t*t-e*e;if(0>i)return[];if(i===0)return[[r*e/(r*r+t*t),t*e/(r*r+t*t)]];const s=Math.sqrt(i);return[[(r*e+t*s)/(r*r+t*t),(t*e-r*s)/(r*r+t*t)],[(r*e-t*s)/(r*r+t*t),(t*e+r*s)/(r*r+t*t)]]}const bi=Math.PI/180;function ed(r,t,e){return(1-e)*r+e*t}function rd(r,t,e,i){return r+Math.cos(i/180*Kr)*t+Math.sin(i/180*Kr)*e}function id(r,t,e,i){const n=t-r,o=e-t,a=i-e,l=3*n+3*a-6*o,h=(o-n)*6,u=3*n;return Math.abs(l)<1e-6?Math.abs(h)<1e-6?[]:[-u/h]:zv(h/l,u/l,1e-6)}function sd(r,t,e,i,s){const n=1-s,o=n*n*n,a=3*n*n*s,l=3*n*s*s,h=s*s*s;return r*o+t*a+e*l+i*h}function zv(r,t,e=1e-6){const i=r*r/4-t;if(i<-e)return[];if(i<=e)return[-r/2];const s=Math.sqrt(i);return[-(r/2)-s,-(r/2)+s]}function Yv(r,t,e){r.cX||ja(r,t,e);const i=r.xRot/180*Kr;if(Math.abs(r.rX)<1e-10||Math.abs(r.rY)<1e-10)return[{relative:r.relative,type:$.CURVE_TO,x1:t+(r.x-t)/3,y1:e+(r.y-e)/3,x2:t+2*(r.x-t)/3,y2:e+2*(r.y-e)/3,x:r.x,y:r.y}];const s=Math.min(r.phi1,r.phi2),n=Math.max(r.phi1,r.phi2),o=n-s,a=Math.ceil(o/90),l=new Array(a);let h=t,u=e;const c=(d,f)=>{const[p,m]=Wa([d*r.rX,f*r.rY],i);return[r.cX+p,r.cY+m]};for(let d=0;d<a;d++){const f=ed(r.phi1,r.phi2,d/a),p=ed(r.phi1,r.phi2,(d+1)/a),m=p-f,_=4/3*Math.tan(m*bi/4),y=Math.cos(f*bi)-_*Math.sin(f*bi),v=Math.sin(f*bi)+_*Math.cos(f*bi),g=Math.cos(p*bi),x=Math.sin(p*bi),E=g+_*x,R=x-_*g,S=c(y,v),M=c(E,R),P=c(g,x),F={relative:r.relative,type:$.CURVE_TO,x:P[0],y:P[1],x1:S[0],y1:S[1],x2:M[0],y2:M[1]};r.relative&&(F.x1-=h,F.y1-=u,F.x2-=h,F.y2-=u,F.x-=h,F.y-=u),h=P[0],u=P[1],l[d]=F}return l}function qa(r,t,e){const i=t[0]-r[0],s=t[1]-r[1],n=e[0]-r[0],o=e[1]-r[1],a=i*o-s*n;if(!(Math.abs(a)<1e-10))return!1;const h=i*n+s*o,u=i*i+s*s,c=n*n+o*o;return 0<=h&&h<=c&&u<=c}function Wv(r,t=!0){if(r.length<2)return r;const e=oe.INFO((n,o,a)=>({...n,x:n.x??o,y:n.y??a,relative:n.relative??!1})),i=[];let s=[];for(const n of r){const o=e(n);o.type===$.MOVE_TO&&s.length>0&&(t?i.push(...kn(s)):i.unshift(...kn(s)),s=[]),s.push(o)}return s.length>0&&(t?i.push(...kn(s)):i.unshift(...kn(s))),i}function kn(r){var s;const t=((s=r[r.length-1])==null?void 0:s.type)===$.CLOSE_PATH,e=t?r.length-2:r.length-1,i=[{type:$.MOVE_TO,relative:!1,x:r[e].x,y:r[e].y}];for(let n=e;n>0;n--){const o=r[n],a=r[n-1];if(o.relative)throw new Error("Relative command are not supported convert first with `toAbs()`");switch(o.type){case $.HORIZ_LINE_TO:i.push({type:$.HORIZ_LINE_TO,relative:!1,x:a.x});break;case $.VERT_LINE_TO:i.push({type:$.VERT_LINE_TO,relative:!1,y:a.y});break;case $.LINE_TO:case $.MOVE_TO:i.push({type:$.LINE_TO,relative:!1,x:a.x,y:a.y});break;case $.CURVE_TO:i.push({type:$.CURVE_TO,relative:!1,x:a.x,y:a.y,x1:o.x2,y1:o.y2,x2:o.x1,y2:o.y1});break;case $.SMOOTH_CURVE_TO:throw new Error("Unsupported command: S (smooth cubic bezier)");case $.SMOOTH_QUAD_TO:throw new Error("Unsupported command: T (smooth quadratic bezier)");case $.ARC:throw new Error("Unsupported command: A (arc)");case $.QUAD_TO:throw new Error("Unsupported command: Q (quadratic bezier)")}}return t&&i.push({type:$.CLOSE_PATH}),i}function jv(r=1e13){tr(r);function t(e){return Math.round(e*r)/r}return function(i){return"x1"in i&&typeof i.x1<"u"&&(i.x1=t(i.x1)),"y1"in i&&typeof i.y1<"u"&&(i.y1=t(i.y1)),"x2"in i&&typeof i.x2<"u"&&(i.x2=t(i.x2)),"y2"in i&&typeof i.y2<"u"&&(i.y2=t(i.y2)),"x"in i&&typeof i.x<"u"&&(i.x=t(i.x)),"y"in i&&typeof i.y<"u"&&(i.y=t(i.y)),"rX"in i&&typeof i.rX<"u"&&(i.rX=t(i.rX)),"rY"in i&&typeof i.rY<"u"&&(i.rY=t(i.rY)),i}}function nd(){return er((r,t,e)=>(r.relative&&(typeof r.x1<"u"&&(r.x1+=t),typeof r.y1<"u"&&(r.y1+=e),typeof r.x2<"u"&&(r.x2+=t),typeof r.y2<"u"&&(r.y2+=e),typeof r.x<"u"&&(r.x+=t),typeof r.y<"u"&&(r.y+=e),r.relative=!1),r))}function qv(){return er((r,t,e)=>(r.relative||(typeof r.x1<"u"&&(r.x1-=t),typeof r.y1<"u"&&(r.y1-=e),typeof r.x2<"u"&&(r.x2-=t),typeof r.y2<"u"&&(r.y2-=e),typeof r.x<"u"&&(r.x-=t),typeof r.y<"u"&&(r.y-=e),r.relative=!0),r))}function Kv(r=!0,t=!0,e=!0,i=!0){return er((s,n,o,a,l)=>{if(isNaN(a)&&!(s.type&$.MOVE_TO))throw new Error("path must start with moveto");if(t&&s.type&$.HORIZ_LINE_TO&&(s.type=$.LINE_TO,s.y=s.relative?0:o),e&&s.type&$.VERT_LINE_TO&&(s.type=$.LINE_TO,s.x=s.relative?0:n),r&&s.type&$.CLOSE_PATH&&(s.type=$.LINE_TO,s.x=s.relative?a-n:a,s.y=s.relative?l-o:l),s.type&$.ARC&&(s.rX===0||s.rY===0)&&(s.type=$.LINE_TO,delete s.rX,delete s.rY,delete s.xRot,delete s.lArcFlag,delete s.sweepFlag),i&&s.type&$.QUAD_TO){const h=[n,o],u=s.relative?[n+s.x1,o+s.y1]:[s.x1,s.y1],c=s.relative?[n+s.x,o+s.y]:[s.x,s.y];qa(h,u,c)&&(s.type=$.LINE_TO,delete s.x1,delete s.y1)}if(i&&s.type&$.CURVE_TO){const h=[n,o],u=s.relative?[n+s.x1,o+s.y1]:[s.x1,s.y1],c=s.relative?[n+s.x2,o+s.y2]:[s.x2,s.y2],d=s.relative?[n+s.x,o+s.y]:[s.x,s.y];qa(h,u,d)&&qa(h,c,d)&&(s.type=$.LINE_TO,delete s.x1,delete s.y1,delete s.x2,delete s.y2)}return s})}function od(){let r=NaN,t=NaN,e=NaN,i=NaN;return er((s,n,o)=>(s.type&$.SMOOTH_CURVE_TO&&(s.type=$.CURVE_TO,r=isNaN(r)?n:r,t=isNaN(t)?o:t,s.x1=s.relative?n-r:2*n-r,s.y1=s.relative?o-t:2*o-t),s.type&$.CURVE_TO?(r=s.relative?n+s.x2:s.x2,t=s.relative?o+s.y2:s.y2):(r=NaN,t=NaN),s.type&$.SMOOTH_QUAD_TO&&(s.type=$.QUAD_TO,e=isNaN(e)?n:e,i=isNaN(i)?o:i,s.x1=s.relative?n-e:2*n-e,s.y1=s.relative?o-i:2*o-i),s.type&$.QUAD_TO?(e=s.relative?n+s.x1:s.x1,i=s.relative?o+s.y1:s.y1):(e=NaN,i=NaN),s))}function ad(){let r=NaN,t=NaN;return er((e,i,s)=>{if(e.type&$.SMOOTH_QUAD_TO&&(e.type=$.QUAD_TO,r=isNaN(r)?i:r,t=isNaN(t)?s:t,e.x1=e.relative?i-r:2*i-r,e.y1=e.relative?s-t:2*s-t),e.type&$.QUAD_TO){r=e.relative?i+e.x1:e.x1,t=e.relative?s+e.y1:e.y1;const n=e.x1,o=e.y1;e.type=$.CURVE_TO,e.x1=((e.relative?0:i)+n*2)/3,e.y1=((e.relative?0:s)+o*2)/3,e.x2=(e.x+n*2)/3,e.y2=(e.y+o*2)/3}else r=NaN,t=NaN;return e})}function er(r){let t=0,e=0,i=NaN,s=NaN;return function(o){if(isNaN(i)&&!(o.type&$.MOVE_TO))throw new Error("path must start with moveto");const a=r(o,t,e,i,s);return o.type&$.CLOSE_PATH&&(t=i,e=s),"x"in o&&typeof o.x<"u"&&(t=o.relative?t+o.x:o.x),"y"in o&&typeof o.y<"u"&&(e=o.relative?e+o.y:o.y),o.type&$.MOVE_TO&&(i=t,s=e),a}}function Zv(r=0){tr(r);let t=NaN,e=NaN,i=NaN,s=NaN;return er((n,o,a,l,h)=>{const u=Math.abs;let c=!1,d=0,f=0;if(n.type&$.SMOOTH_CURVE_TO&&(d=isNaN(t)?0:o-t,f=isNaN(e)?0:a-e),n.type&($.CURVE_TO|$.SMOOTH_CURVE_TO)?(t=n.relative?o+n.x2:n.x2,e=n.relative?a+n.y2:n.y2):(t=NaN,e=NaN),n.type&$.SMOOTH_QUAD_TO?(i=isNaN(i)?o:2*o-i,s=isNaN(s)?a:2*a-s):n.type&$.QUAD_TO?(i=n.relative?o+n.x1:n.x1,s=n.relative?a+n.y1:n.y2):(i=NaN,s=NaN),n.type&$.LINE_COMMANDS||n.type&$.ARC&&(n.rX===0||n.rY===0||!n.lArcFlag)||n.type&$.CURVE_TO||n.type&$.SMOOTH_CURVE_TO||n.type&$.QUAD_TO||n.type&$.SMOOTH_QUAD_TO){const p=typeof n.x>"u"?0:n.relative?n.x:n.x-o,m=typeof n.y>"u"?0:n.relative?n.y:n.y-a;d=isNaN(i)?typeof n.x1>"u"?d:n.relative?n.x:n.x1-o:i-o,f=isNaN(s)?typeof n.y1>"u"?f:n.relative?n.y:n.y1-a:s-a;const _=typeof n.x2>"u"?0:n.relative?n.x:n.x2-o,y=typeof n.y2>"u"?0:n.relative?n.y:n.y2-a;u(p)<=r&&u(m)<=r&&u(d)<=r&&u(f)<=r&&u(_)<=r&&u(y)<=r&&(c=!0)}return n.type&$.CLOSE_PATH&&u(o-l)<=r&&u(a-h)<=r&&(c=!0),c?[]:n})}function Zr(r,t,e,i,s,n){return tr(r,t,e,i,s,n),er((o,a,l,h)=>{const u=o.x1,c=o.x2,d=o.relative&&!isNaN(h),f=typeof o.x<"u"?o.x:d?0:a,p=typeof o.y<"u"?o.y:d?0:l;o.type&$.HORIZ_LINE_TO&&t!==0&&(o.type=$.LINE_TO,o.y=o.relative?0:l),o.type&$.VERT_LINE_TO&&e!==0&&(o.type=$.LINE_TO,o.x=o.relative?0:a),typeof o.x<"u"&&(o.x=o.x*r+p*e+(d?0:s)),typeof o.y<"u"&&(o.y=f*t+o.y*i+(d?0:n)),typeof o.x1<"u"&&(o.x1=o.x1*r+o.y1*e+(d?0:s)),typeof o.y1<"u"&&(o.y1=u*t+o.y1*i+(d?0:n)),typeof o.x2<"u"&&(o.x2=o.x2*r+o.y2*e+(d?0:s)),typeof o.y2<"u"&&(o.y2=c*t+o.y2*i+(d?0:n));function m(y){return y*y}const _=r*i-t*e;if(typeof o.xRot<"u"&&(r!==1||t!==0||e!==0||i!==1))if(_===0)delete o.rX,delete o.rY,delete o.xRot,delete o.lArcFlag,delete o.sweepFlag,o.type=$.LINE_TO;else{const y=o.xRot*Math.PI/180,v=Math.sin(y),g=Math.cos(y),x=1/m(o.rX),E=1/m(o.rY),R=m(g)*x+m(v)*E,S=2*v*g*(x-E),M=m(v)*x+m(g)*E,P=R*i*i-S*t*i+M*t*t,F=S*(r*i+t*e)-2*(R*e*i+M*r*t),U=R*e*e-S*r*e+M*r*r,I=(Math.atan2(F,P-U)+Math.PI)%Math.PI/2,A=Math.sin(I),w=Math.cos(I);o.rX=Math.abs(_)/Math.sqrt(P*m(w)+F*A*w+U*m(A)),o.rY=Math.abs(_)/Math.sqrt(P*m(A)-F*A*w+U*m(w)),o.xRot=I*180/Math.PI}return typeof o.sweepFlag<"u"&&0>_&&(o.sweepFlag=+!o.sweepFlag),o})}function Qv(r,t=0,e=0){tr(r,t,e);const i=Math.sin(r),s=Math.cos(r);return Zr(s,i,-i,s,t-t*s+e*i,e-t*i-e*s)}function Jv(r,t=0){return tr(r,t),Zr(1,0,0,1,r,t)}function t1(r,t=r){return tr(r,t),Zr(r,0,0,t,0,0)}function e1(r){return tr(r),Zr(1,0,Math.tan(r),1,0,0)}function r1(r){return tr(r),Zr(1,Math.tan(r),0,1,0,0)}function i1(r=0){return tr(r),Zr(-1,0,0,1,r,0)}function s1(r=0){return tr(r),Zr(1,0,0,-1,0,r)}function n1(){return er((r,t,e)=>$.ARC===r.type?Yv(r,r.relative?0:t,r.relative?0:e):r)}function o1(){return er((r,t,e)=>(r.relative&&(t=0,e=0),$.ARC===r.type&&ja(r,t,e),r))}function ld(){return r=>({...r})}function a1(){const r=ld(),t=nd(),e=ad(),i=od(),s=er((n,o,a)=>{const l=i(e(t(r(n))));function h(c){c>s.maxX&&(s.maxX=c),c<s.minX&&(s.minX=c)}function u(c){c>s.maxY&&(s.maxY=c),c<s.minY&&(s.minY=c)}if(l.type&$.DRAWING_COMMANDS&&(h(o),u(a)),l.type&$.HORIZ_LINE_TO&&h(l.x),l.type&$.VERT_LINE_TO&&u(l.y),l.type&$.LINE_TO&&(h(l.x),u(l.y)),l.type&$.CURVE_TO){h(l.x),u(l.y);const c=id(o,l.x1,l.x2,l.x);for(const f of c)0<f&&1>f&&h(sd(o,l.x1,l.x2,l.x,f));const d=id(a,l.y1,l.y2,l.y);for(const f of d)0<f&&1>f&&u(sd(a,l.y1,l.y2,l.y,f))}if(l.type&$.ARC){h(l.x),u(l.y),ja(l,o,a);const c=l.xRot/180*Math.PI,d=Math.cos(c)*l.rX,f=Math.sin(c)*l.rX,p=-Math.sin(c)*l.rY,m=Math.cos(c)*l.rY,[_,y]=l.phi1<l.phi2?[l.phi1,l.phi2]:-180>l.phi2?[l.phi2+360,l.phi1+360]:[l.phi2,l.phi1],v=([E,R])=>{const M=Math.atan2(R,E)*180/Math.PI;return M<_?M+360:M},g=td(p,-d,0).map(v);for(const E of g)E>_&&E<y&&h(rd(l.cX,d,p,E));const x=td(m,-f,0).map(v);for(const E of x)E>_&&E<y&&u(rd(l.cY,f,m,E))}return n});return s.minX=1/0,s.maxX=-1/0,s.minY=1/0,s.maxY=-1/0,s}const oe={ROUND:jv,TO_ABS:nd,TO_REL:qv,NORMALIZE_HVZ:Kv,NORMALIZE_ST:od,QT_TO_C:ad,INFO:er,SANITIZE:Zv,MATRIX:Zr,ROTATE:Qv,TRANSLATE:Jv,SCALE:t1,SKEW_X:e1,SKEW_Y:r1,X_AXIS_SYMMETRY:i1,Y_AXIS_SYMMETRY:s1,A_TO_C:n1,ANNOTATE_ARCS:o1,CLONE:ld,CALCULATE_BOUNDS:a1,REVERSE_PATH:Wv};class hd{round(t){return this.transform(oe.ROUND(t))}toAbs(){return this.transform(oe.TO_ABS())}toRel(){return this.transform(oe.TO_REL())}normalizeHVZ(t,e,i){return this.transform(oe.NORMALIZE_HVZ(t,e,i))}normalizeST(){return this.transform(oe.NORMALIZE_ST())}qtToC(){return this.transform(oe.QT_TO_C())}aToC(){return this.transform(oe.A_TO_C())}sanitize(t){return this.transform(oe.SANITIZE(t))}translate(t,e){return this.transform(oe.TRANSLATE(t,e))}scale(t,e){return this.transform(oe.SCALE(t,e))}rotate(t,e,i){return this.transform(oe.ROTATE(t,e,i))}matrix(t,e,i,s,n,o){return this.transform(oe.MATRIX(t,e,i,s,n,o))}skewX(t){return this.transform(oe.SKEW_X(t))}skewY(t){return this.transform(oe.SKEW_Y(t))}xSymmetry(t){return this.transform(oe.X_AXIS_SYMMETRY(t))}ySymmetry(t){return this.transform(oe.Y_AXIS_SYMMETRY(t))}annotateArcs(){return this.transform(oe.ANNOTATE_ARCS())}}const l1=r=>r===" "||r===" "||r==="\r"||r===`
3
- `,ud=r=>48<=r.charCodeAt(0)&&r.charCodeAt(0)<=57;class h1 extends hd{constructor(){super();$t(this,"curNumber","");$t(this,"curCommandType",-1);$t(this,"curCommandRelative",!1);$t(this,"canParseCommandOrComma",!0);$t(this,"curNumberHasExp",!1);$t(this,"curNumberHasExpDigits",!1);$t(this,"curNumberHasDecimal",!1);$t(this,"curArgs",[])}finish(e=[]){if(this.parse(" ",e),this.curArgs.length!==0||!this.canParseCommandOrComma)throw new SyntaxError("Unterminated command at the path end.");return e}parse(e,i=[]){const s=n=>{i.push(n),this.curArgs.length=0,this.canParseCommandOrComma=!0};for(let n=0;n<e.length;n++){const o=e[n],a=this.curCommandType===$.ARC&&(this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber.length===1&&(this.curNumber==="0"||this.curNumber==="1"),l=ud(o)&&(this.curNumber==="0"&&o==="0"||a);if(ud(o)&&!l){this.curNumber+=o,this.curNumberHasExpDigits=this.curNumberHasExp;continue}if(o==="e"||o==="E"){this.curNumber+=o,this.curNumberHasExp=!0;continue}if((o==="-"||o==="+")&&this.curNumberHasExp&&!this.curNumberHasExpDigits){this.curNumber+=o;continue}if(o==="."&&!this.curNumberHasExp&&!this.curNumberHasDecimal&&!a){this.curNumber+=o,this.curNumberHasDecimal=!0;continue}if(this.curNumber&&this.curCommandType!==-1){const h=Number(this.curNumber);if(isNaN(h))throw new SyntaxError(`Invalid number ending at ${n}`);if(this.curCommandType===$.ARC){if(this.curArgs.length===0||this.curArgs.length===1){if(0>h)throw new SyntaxError(`Expected positive number, got "${h}" at index "${n}"`)}else if((this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber!=="0"&&this.curNumber!=="1")throw new SyntaxError(`Expected a flag, got "${this.curNumber}" at index "${n}"`)}this.curArgs.push(h),this.curArgs.length===u1[this.curCommandType]&&($.HORIZ_LINE_TO===this.curCommandType?s({type:$.HORIZ_LINE_TO,relative:this.curCommandRelative,x:h}):$.VERT_LINE_TO===this.curCommandType?s({type:$.VERT_LINE_TO,relative:this.curCommandRelative,y:h}):this.curCommandType===$.MOVE_TO||this.curCommandType===$.LINE_TO||this.curCommandType===$.SMOOTH_QUAD_TO?(s({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),$.MOVE_TO===this.curCommandType&&(this.curCommandType=$.LINE_TO)):this.curCommandType===$.CURVE_TO?s({type:$.CURVE_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x2:this.curArgs[2],y2:this.curArgs[3],x:this.curArgs[4],y:this.curArgs[5]}):this.curCommandType===$.SMOOTH_CURVE_TO?s({type:$.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===$.QUAD_TO?s({type:$.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===$.ARC&&s({type:$.ARC,relative:this.curCommandRelative,rX:this.curArgs[0],rY:this.curArgs[1],xRot:this.curArgs[2],lArcFlag:this.curArgs[3],sweepFlag:this.curArgs[4],x:this.curArgs[5],y:this.curArgs[6]})),this.curNumber="",this.curNumberHasExpDigits=!1,this.curNumberHasExp=!1,this.curNumberHasDecimal=!1,this.canParseCommandOrComma=!0}if(!l1(o)){if(o===","&&this.canParseCommandOrComma){this.canParseCommandOrComma=!1;continue}if(o==="+"||o==="-"||o==="."){this.curNumber=o,this.curNumberHasDecimal=o===".";continue}if(l){this.curNumber=o,this.curNumberHasDecimal=!1;continue}if(this.curArgs.length!==0)throw new SyntaxError(`Unterminated command at index ${n}.`);if(!this.canParseCommandOrComma)throw new SyntaxError(`Unexpected character "${o}" at index ${n}. Command cannot follow comma`);if(this.canParseCommandOrComma=!1,o==="z"||o==="Z"){i.push({type:$.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1;continue}else if(o==="h"||o==="H")this.curCommandType=$.HORIZ_LINE_TO,this.curCommandRelative=o==="h";else if(o==="v"||o==="V")this.curCommandType=$.VERT_LINE_TO,this.curCommandRelative=o==="v";else if(o==="m"||o==="M")this.curCommandType=$.MOVE_TO,this.curCommandRelative=o==="m";else if(o==="l"||o==="L")this.curCommandType=$.LINE_TO,this.curCommandRelative=o==="l";else if(o==="c"||o==="C")this.curCommandType=$.CURVE_TO,this.curCommandRelative=o==="c";else if(o==="s"||o==="S")this.curCommandType=$.SMOOTH_CURVE_TO,this.curCommandRelative=o==="s";else if(o==="q"||o==="Q")this.curCommandType=$.QUAD_TO,this.curCommandRelative=o==="q";else if(o==="t"||o==="T")this.curCommandType=$.SMOOTH_QUAD_TO,this.curCommandRelative=o==="t";else if(o==="a"||o==="A")this.curCommandType=$.ARC,this.curCommandRelative=o==="a";else throw new SyntaxError(`Unexpected character "${o}" at index ${n}.`)}}return i}transform(e){return Object.create(this,{parse:{value(s,n=[]){const o=Object.getPrototypeOf(this).parse.call(this,s);for(const a of o){const l=e(a);Array.isArray(l)?n.push(...l):n.push(l)}return n}}})}}const Lt=class Lt extends hd{constructor(e){super();$t(this,"commands");typeof e=="string"?this.commands=Lt.parse(e):this.commands=e}encode(){return Lt.encode(this.commands)}getBounds(){const e=oe.CALCULATE_BOUNDS();return this.transform(e),e}transform(e){const i=[];for(const s of this.commands){const n=e(s);Array.isArray(n)?i.push(...n):i.push(n)}return this.commands=i,this}reverse(e=!0){return this.commands=oe.REVERSE_PATH(this.commands,e),this}static encode(e){return Vv(e)}static parse(e){const i=new h1,s=[];return i.parse(e,s),i.finish(s),s}};$t(Lt,"CLOSE_PATH",1),$t(Lt,"MOVE_TO",2),$t(Lt,"HORIZ_LINE_TO",4),$t(Lt,"VERT_LINE_TO",8),$t(Lt,"LINE_TO",16),$t(Lt,"CURVE_TO",32),$t(Lt,"SMOOTH_CURVE_TO",64),$t(Lt,"QUAD_TO",128),$t(Lt,"SMOOTH_QUAD_TO",256),$t(Lt,"ARC",512),$t(Lt,"LINE_COMMANDS",Lt.LINE_TO|Lt.HORIZ_LINE_TO|Lt.VERT_LINE_TO),$t(Lt,"DRAWING_COMMANDS",Lt.HORIZ_LINE_TO|Lt.VERT_LINE_TO|Lt.LINE_TO|Lt.CURVE_TO|Lt.SMOOTH_CURVE_TO|Lt.QUAD_TO|Lt.SMOOTH_QUAD_TO|Lt.ARC);let $=Lt;const u1={[$.MOVE_TO]:2,[$.LINE_TO]:2,[$.HORIZ_LINE_TO]:1,[$.VERT_LINE_TO]:1,[$.CLOSE_PATH]:0,[$.QUAD_TO]:4,[$.SMOOTH_QUAD_TO]:2,[$.CURVE_TO]:6,[$.SMOOTH_CURVE_TO]:4,[$.ARC]:7},Te=[];for(let r=0;r<256;++r)Te.push((r+256).toString(16).slice(1));function c1(r,t=0){return(Te[r[t+0]]+Te[r[t+1]]+Te[r[t+2]]+Te[r[t+3]]+"-"+Te[r[t+4]]+Te[r[t+5]]+"-"+Te[r[t+6]]+Te[r[t+7]]+"-"+Te[r[t+8]]+Te[r[t+9]]+"-"+Te[r[t+10]]+Te[r[t+11]]+Te[r[t+12]]+Te[r[t+13]]+Te[r[t+14]]+Te[r[t+15]]).toLowerCase()}let Ka;const d1=new Uint8Array(16);function f1(){if(!Ka){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Ka=crypto.getRandomValues.bind(crypto)}return Ka(d1)}const cd={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function p1(r,t,e){var s;if(cd.randomUUID&&!r)return cd.randomUUID();r=r||{};const i=r.random??((s=r.rng)==null?void 0:s.call(r))??f1();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=i[6]&15|64,i[8]=i[8]&63|128,c1(i)}const m1=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:s,stroke:n,strokeWidth:o,strokeOpacity:a}=e;let l="";return i&&(l+=`fill:${i};`,l+=`fill-opacity:${s||"0.25"};`),n&&(l+=`stroke:${n};`,l+=`stroke-width:${o||"1"};`,l+=`stroke-opacity:${a||"1"};`),l}},Za=(r,t=0)=>{const{minX:e,minY:i,maxX:s,maxY:n}=r;return{x:e-t,y:i-t,w:s-e+2*t,h:n-i+2*t}},Qr=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,g1=r=>({}),dd=r=>({grab:r[0]});function y1(r){let t,e,i,s;const n=r[8].default,o=Hc(n,r,r[7],dd);return{c(){t=st("g"),o&&o.c(),T(t,"class","a9s-annotation selected")},m(a,l){at(a,t,l),o&&o.m(t,null),e=!0,i||(s=[Pt(t,"pointerup",r[2]),Pt(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&128)&&Vc(o,n,a,a[7],e?Xc(n,a[7],l,g1):zc(a[7]),dd)},i(a){e||(K(o,a),e=!0)},o(a){lt(o,a),e=!1},d(a){a&&nt(t),o&&o.d(a),i=!1,Ye(s)}}}function _1(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=Ki();let{shape:o}=t,{editor:a}=t,{transform:l}=t,{svgEl:h}=t,u,c,d;const f=_=>y=>{if(u=_,h){const{left:g,top:x}=h.getBoundingClientRect(),E=y.clientX-g,R=y.clientY-x;c=l.elementToImage(E,R)}else{const{offsetX:g,offsetY:x}=y;c=l.elementToImage(g,x)}d=o,y.target.setPointerCapture(y.pointerId),n("grab",y)},p=_=>{if(u){const[y,v]=l.elementToImage(_.offsetX,_.offsetY),g=[y-c[0],v-c[1]];e(3,o=a(d,u,g)),n("change",o)}},m=_=>{_.target.releasePointerCapture(_.pointerId),u=void 0,d=o,n("release",_)};return r.$$set=_=>{"shape"in _&&e(3,o=_.shape),"editor"in _&&e(4,a=_.editor),"transform"in _&&e(5,l=_.transform),"svgEl"in _&&e(6,h=_.svgEl),"$$scope"in _&&e(7,s=_.$$scope)},[f,p,m,o,a,l,h,s,i]}class Qa extends se{constructor(t){super(),ie(this,t,_1,y1,qt,{shape:3,editor:4,transform:5,svgEl:6})}}function v1(r){let t,e,i,s,n,o,a,l,h=r[3]&&fd(r);return{c(){t=st("g"),e=st("circle"),h&&h.c(),s=st("circle"),T(e,"class","a9s-handle-buffer"),T(e,"cx",r[0]),T(e,"cy",r[1]),T(e,"r",i=r[5]+6/r[2]),T(s,"class",n=`a9s-handle-dot${r[3]?" selected":""}`),T(s,"cx",r[0]),T(s,"cy",r[1]),T(s,"r",r[5]),T(t,"class",o=`a9s-handle ${r[8].class||""}`.trim())},m(u,c){at(u,t,c),Ct(t,e),h&&h.m(t,null),Ct(t,s),a||(l=[Pt(e,"pointerenter",r[11]),Pt(e,"pointerleave",r[12]),Pt(e,"pointerdown",r[13]),Pt(e,"pointerdown",r[6]),Pt(e,"pointerup",r[14]),Pt(e,"pointerup",r[7])],a=!0)},p(u,c){c&1&&T(e,"cx",u[0]),c&2&&T(e,"cy",u[1]),c&36&&i!==(i=u[5]+6/u[2])&&T(e,"r",i),u[3]?h?h.p(u,c):(h=fd(u),h.c(),h.m(t,s)):h&&(h.d(1),h=null),c&8&&n!==(n=`a9s-handle-dot${u[3]?" selected":""}`)&&T(s,"class",n),c&1&&T(s,"cx",u[0]),c&2&&T(s,"cy",u[1]),c&32&&T(s,"r",u[5]),c&256&&o!==(o=`a9s-handle ${u[8].class||""}`.trim())&&T(t,"class",o)},d(u){u&&nt(t),h&&h.d(),a=!1,Ye(l)}}}function x1(r){let t,e,i,s,n,o,a,l,h;return{c(){t=st("g"),e=st("circle"),s=st("circle"),o=st("circle"),T(e,"cx",r[0]),T(e,"cy",r[1]),T(e,"r",i=r[5]*10),T(e,"class","a9s-touch-halo"),jr(e,"touched",r[4]),T(s,"cx",r[0]),T(s,"cy",r[1]),T(s,"r",n=r[5]+10/r[2]),T(s,"class","a9s-handle-buffer"),T(o,"class","a9s-handle-dot"),T(o,"cx",r[0]),T(o,"cy",r[1]),T(o,"r",a=r[5]+2/r[2]),T(t,"class","a9s-touch-handle")},m(u,c){at(u,t,c),Ct(t,e),Ct(t,s),Ct(t,o),l||(h=[Pt(s,"pointerdown",r[9]),Pt(s,"pointerup",r[10]),Pt(s,"pointerdown",r[6]),Pt(s,"pointerup",r[7])],l=!0)},p(u,c){c&1&&T(e,"cx",u[0]),c&2&&T(e,"cy",u[1]),c&32&&i!==(i=u[5]*10)&&T(e,"r",i),c&16&&jr(e,"touched",u[4]),c&1&&T(s,"cx",u[0]),c&2&&T(s,"cy",u[1]),c&36&&n!==(n=u[5]+10/u[2])&&T(s,"r",n),c&1&&T(o,"cx",u[0]),c&2&&T(o,"cy",u[1]),c&36&&a!==(a=u[5]+2/u[2])&&T(o,"r",a)},d(u){u&&nt(t),l=!1,Ye(h)}}}function fd(r){let t,e;return{c(){t=st("circle"),T(t,"class","a9s-handle-selected"),T(t,"cx",r[0]),T(t,"cy",r[1]),T(t,"r",e=r[5]+8/r[2])},m(i,s){at(i,t,s)},p(i,s){s&1&&T(t,"cx",i[0]),s&2&&T(t,"cy",i[1]),s&36&&e!==(e=i[5]+8/i[2])&&T(t,"r",e)},d(i){i&&nt(t)}}}function b1(r){let t;function e(n,o){return Qr?x1:v1}let s=e()(r);return{c(){s.c(),t=Ge()},m(n,o){s.m(n,o),at(n,t,o)},p(n,[o]){s.p(n,o)},i:Qt,o:Qt,d(n){n&&nt(t),s.d(n)}}}function E1(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t,{selected:a=void 0}=t,l=!1;const h=y=>{y.pointerType==="touch"&&e(4,l=!0)},u=()=>e(4,l=!1);function c(y){Me.call(this,r,y)}function d(y){Me.call(this,r,y)}function f(y){Me.call(this,r,y)}function p(y){Me.call(this,r,y)}function m(y){Me.call(this,r,y)}function _(y){Me.call(this,r,y)}return r.$$set=y=>{e(8,t=Fa(Fa({},t),Yc(y))),"x"in y&&e(0,s=y.x),"y"in y&&e(1,n=y.y),"scale"in y&&e(2,o=y.scale),"selected"in y&&e(3,a=y.selected)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=4/o)},t=Yc(t),[s,n,o,a,l,i,h,u,t,c,d,f,p,m,_]}class es extends se{constructor(t){super(),ie(this,t,E1,b1,qt,{x:0,y:1,scale:2,selected:3})}}function w1(r){let t,e,i,s,n,o,a;return{c(){t=st("g"),e=st("circle"),s=st("circle"),n=st("circle"),T(e,"class","a9s-polygon-midpoint-buffer svelte-12ykj76"),T(e,"cx",r[0]),T(e,"cy",r[1]),T(e,"r",i=1.75*r[2]),T(s,"class","a9s-polygon-midpoint-outer svelte-12ykj76"),T(s,"cx",r[0]),T(s,"cy",r[1]),T(s,"r",r[2]),T(n,"class","a9s-polygon-midpoint-inner svelte-12ykj76"),T(n,"cx",r[0]),T(n,"cy",r[1]),T(n,"r",r[2]),T(t,"class","a9s-polygon-midpoint svelte-12ykj76")},m(l,h){at(l,t,h),Ct(t,e),Ct(t,s),Ct(t,n),o||(a=[Pt(e,"pointerdown",r[5]),Pt(e,"pointerdown",r[3])],o=!0)},p(l,h){h&1&&T(e,"cx",l[0]),h&2&&T(e,"cy",l[1]),h&4&&i!==(i=1.75*l[2])&&T(e,"r",i),h&1&&T(s,"cx",l[0]),h&2&&T(s,"cy",l[1]),h&4&&T(s,"r",l[2]),h&1&&T(n,"cx",l[0]),h&2&&T(n,"cy",l[1]),h&4&&T(n,"r",l[2])},d(l){l&&nt(t),o=!1,Ye(a)}}}function T1(r){let t;return{c(){t=st("circle"),T(t,"cx",r[0]),T(t,"cy",r[1]),T(t,"r",r[2])},m(e,i){at(e,t,i)},p(e,i){i&1&&T(t,"cx",e[0]),i&2&&T(t,"cy",e[1]),i&4&&T(t,"r",e[2])},d(e){e&&nt(t)}}}function A1(r){let t;function e(n,o){return Qr?T1:w1}let s=e()(r);return{c(){s.c(),t=Ge()},m(n,o){s.m(n,o),at(n,t,o)},p(n,[o]){s.p(n,o)},i:Qt,o:Qt,d(n){n&&nt(t),s.d(n)}}}function S1(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t;const a=h=>{h.pointerType};function l(h){Me.call(this,r,h)}return r.$$set=h=>{"x"in h&&e(0,s=h.x),"y"in h&&e(1,n=h.y),"scale"in h&&e(4,o=h.scale)},r.$$.update=()=>{r.$$.dirty&16&&e(2,i=4/o)},[s,n,i,a,o,l]}class pd extends se{constructor(t){super(),ie(this,t,S1,A1,qt,{x:0,y:1,scale:4})}}function Ja(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function md(r,t,e){const i=r.slice();return i[28]=t[e],i[30]=e,i}function tl(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function el(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function gd(r){let t,e,i,s;return{c(){t=st("circle"),T(t,"cx",e=r[28][0]),T(t,"cy",i=r[28][1]),T(t,"r",s=Hs/r[3]),T(t,"class","svelte-1h2slbm")},m(n,o){at(n,t,o)},p(n,o){o[0]&1088&&e!==(e=n[28][0])&&T(t,"cx",e),o[0]&1088&&i!==(i=n[28][1])&&T(t,"cy",i),o[0]&8&&s!==(s=Hs/n[3])&&T(t,"r",s)},d(n){n&&nt(t)}}}function yd(r){let t,e,i,s,n,o,a,l,h,u;return{c(){t=st("mask"),e=st("rect"),a=st("circle"),T(e,"x",i=r[9].x),T(e,"y",s=r[9].y),T(e,"width",n=r[9].w),T(e,"height",o=r[9].h),T(e,"class","svelte-1h2slbm"),T(a,"cx",l=r[28][0]),T(a,"cy",h=r[28][1]),T(a,"r",u=Hs/r[3]),T(a,"class","svelte-1h2slbm"),T(t,"id",`${r[19]}-inner`),T(t,"class","a9s-polygon-editor-mask svelte-1h2slbm")},m(c,d){at(c,t,d),Ct(t,e),Ct(t,a)},p(c,d){d[0]&512&&i!==(i=c[9].x)&&T(e,"x",i),d[0]&512&&s!==(s=c[9].y)&&T(e,"y",s),d[0]&512&&n!==(n=c[9].w)&&T(e,"width",n),d[0]&512&&o!==(o=c[9].h)&&T(e,"height",o),d[0]&1088&&l!==(l=c[28][0])&&T(a,"cx",l),d[0]&1088&&h!==(h=c[28][1])&&T(a,"cy",h),d[0]&8&&u!==(u=Hs/c[3])&&T(a,"r",u)},d(c){c&&nt(t)}}}function _d(r){let t,e;return t=new es({props:{class:"a9s-corner-handle",x:r[28][0],y:r[28][1],scale:r[3],selected:r[8].includes(r[30])}}),t.$on("pointerenter",r[11]),t.$on("pointerleave",r[12]),t.$on("pointerdown",r[15]),t.$on("pointerdown",function(){Jt(r[27](`HANDLE-${r[30]}`))&&r[27](`HANDLE-${r[30]}`).apply(this,arguments)}),t.$on("pointerup",r[16](r[30])),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&32&&(n.x=r[28][0]),s[0]&32&&(n.y=r[28][1]),s[0]&8&&(n.scale=r[3]),s[0]&256&&(n.selected=r[8].includes(r[30])),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function vd(r){let t,e;return t=new pd({props:{x:r[28][0],y:r[28][1],scale:r[3]}}),t.$on("pointerdown",function(){Jt(r[18](r[6]))&&r[18](r[6]).apply(this,arguments)}),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&1088&&(n.x=r[28][0]),s[0]&1088&&(n.y=r[28][1]),s[0]&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function C1(r){let t,e,i,s,n,o,a,l,h,u,c,d,f,p,m,_,y,v,g,x,E,R=r[6]!==void 0&&!r[7]&&gd(el(r)),S=r[6]!==void 0&&!r[7]&&yd(tl(r)),M=Pe(r[5].points),P=[];for(let I=0;I<M.length;I+=1)P[I]=_d(md(r,M,I));const F=I=>lt(P[I],1,1,()=>{P[I]=null});let U=r[6]!==void 0&&!r[7]&&vd(Ja(r));return{c(){t=st("defs"),e=st("mask"),i=st("rect"),l=st("polygon"),R&&R.c(),S&&S.c(),u=Le(),c=st("polygon"),f=Le(),p=st("polygon"),_=Le();for(let I=0;I<P.length;I+=1)P[I].c();y=Le(),U&&U.c(),v=Ge(),T(i,"x",s=r[9].x),T(i,"y",n=r[9].y),T(i,"width",o=r[9].w),T(i,"height",a=r[9].h),T(i,"class","svelte-1h2slbm"),T(l,"points",h=r[5].points.map(xd).join(" ")),T(l,"class","svelte-1h2slbm"),T(e,"id",`${r[19]}-outer`),T(e,"class","a9s-polygon-editor-mask svelte-1h2slbm"),T(c,"class","a9s-outer"),T(c,"mask",`url(#${r[19]}-outer)`),T(c,"points",d=r[5].points.map(bd).join(" ")),T(p,"class","a9s-inner a9s-shape-handle"),T(p,"mask",`url(#${r[19]}-inner)`),T(p,"style",r[1]),T(p,"points",m=r[5].points.map(Ed).join(" "))},m(I,A){at(I,t,A),Ct(t,e),Ct(e,i),Ct(e,l),R&&R.m(e,null),S&&S.m(t,null),at(I,u,A),at(I,c,A),at(I,f,A),at(I,p,A),at(I,_,A);for(let w=0;w<P.length;w+=1)P[w]&&P[w].m(I,A);at(I,y,A),U&&U.m(I,A),at(I,v,A),g=!0,x||(E=[Pt(c,"pointerup",r[14]),Pt(c,"pointerdown",function(){Jt(r[27]("SHAPE"))&&r[27]("SHAPE").apply(this,arguments)}),Pt(p,"pointermove",r[13]),Pt(p,"pointerup",r[14]),Pt(p,"pointerdown",function(){Jt(r[27]("SHAPE"))&&r[27]("SHAPE").apply(this,arguments)})],x=!0)},p(I,A){if(r=I,(!g||A[0]&512&&s!==(s=r[9].x))&&T(i,"x",s),(!g||A[0]&512&&n!==(n=r[9].y))&&T(i,"y",n),(!g||A[0]&512&&o!==(o=r[9].w))&&T(i,"width",o),(!g||A[0]&512&&a!==(a=r[9].h))&&T(i,"height",a),(!g||A[0]&32&&h!==(h=r[5].points.map(xd).join(" ")))&&T(l,"points",h),r[6]!==void 0&&!r[7]?R?R.p(el(r),A):(R=gd(el(r)),R.c(),R.m(e,null)):R&&(R.d(1),R=null),r[6]!==void 0&&!r[7]?S?S.p(tl(r),A):(S=yd(tl(r)),S.c(),S.m(t,null)):S&&(S.d(1),S=null),(!g||A[0]&32&&d!==(d=r[5].points.map(bd).join(" ")))&&T(c,"points",d),(!g||A[0]&2)&&T(p,"style",r[1]),(!g||A[0]&32&&m!==(m=r[5].points.map(Ed).join(" ")))&&T(p,"points",m),A[0]&134322472){M=Pe(r[5].points);let w;for(w=0;w<M.length;w+=1){const C=md(r,M,w);P[w]?(P[w].p(C,A),K(P[w],1)):(P[w]=_d(C),P[w].c(),K(P[w],1),P[w].m(y.parentNode,y))}for(fe(),w=M.length;w<P.length;w+=1)F(w);pe()}r[6]!==void 0&&!r[7]?U?(U.p(Ja(r),A),A[0]&192&&K(U,1)):(U=vd(Ja(r)),U.c(),K(U,1),U.m(v.parentNode,v)):U&&(fe(),lt(U,1,1,()=>{U=null}),pe())},i(I){if(!g){for(let A=0;A<M.length;A+=1)K(P[A]);K(U),g=!0}},o(I){P=P.filter(Boolean);for(let A=0;A<P.length;A+=1)lt(P[A]);lt(U),g=!1},d(I){I&&(nt(t),nt(u),nt(c),nt(f),nt(p),nt(_),nt(y),nt(v)),R&&R.d(),S&&S.d(),Wr(P,I),U&&U.d(I),x=!1,Ye(E)}}}function I1(r){let t,e;return t=new Qa({props:{shape:r[0],transform:r[2],editor:r[17],svgEl:r[4],$$slots:{default:[C1,({grab:i})=>({27:i}),({grab:i})=>[i?134217728:0]]},$$scope:{ctx:r}}}),t.$on("change",r[20]),t.$on("grab",r[21]),t.$on("release",r[22]),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s[0]&1&&(n.shape=i[0]),s[0]&4&&(n.transform=i[2]),s[0]&16&&(n.svgEl=i[4]),s[0]&134219754|s[1]&1&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}const R1=250,M1=1e3,P1=12,Hs=4.5,xd=r=>r.join(","),bd=r=>r.join(","),Ed=r=>r.join(",");function O1(r,t,e){let i,s,n;const o=Ki();let{shape:a}=t,{computedStyle:l}=t,{transform:h}=t,{viewportScale:u=1}=t,{svgEl:c}=t,d,f=!1,p,m=[];const _=()=>e(7,f=!0),y=()=>e(7,f=!1),v=w=>{if(m.length>0||!s.some(k=>k.visible)){e(6,d=void 0);return}const[C,D]=h.elementToImage(w.offsetX,w.offsetY),N=k=>Math.pow(k[0]-C,2)+Math.pow(k[1]-D,2),B=i.points.reduce((k,X)=>N(X)<N(k)?X:k),V=s.filter(k=>k.visible).reduce((k,X)=>N(X.point)<N(k.point)?X:k),L=Math.pow(M1/u,2);N(B)<L||N(V.point)<L?e(6,d=s.indexOf(V)):e(6,d=void 0)},g=()=>{document.activeElement!==c&&c.focus()},x=()=>{e(8,m=[]),g()},E=w=>{e(7,f=!0),w.preventDefault(),w.stopPropagation(),p=performance.now()},R=w=>C=>{if(!p||Qr||performance.now()-p>R1)return;const D=m.includes(w);C.metaKey||C.ctrlKey||C.shiftKey?D?e(8,m=m.filter(N=>N!==w)):e(8,m=[...m,w]):D&&m.length>1?e(8,m=[w]):D?e(8,m=[]):e(8,m=[w]),g()},S=(w,C,D)=>{g();let N;const B=w.geometry;m.length>1?N=B.points.map(([L,O],k)=>m.includes(k)?[L+D[0],O+D[1]]:[L,O]):C==="SHAPE"?N=B.points.map(([L,O])=>[L+D[0],O+D[1]]):N=B.points.map(([L,O],k)=>C===`HANDLE-${k}`?[L+D[0],O+D[1]]:[L,O]);const V=dr(N);return{...w,geometry:{points:N,bounds:V}}},M=w=>async C=>{C.stopPropagation();const D=[...i.points.slice(0,w+1),s[w].point,...i.points.slice(w+1)],N=dr(D);o("change",{...a,geometry:{points:D,bounds:N}}),await Kc();const B=[...document.querySelectorAll(".a9s-handle")][w+1];if(B!=null&&B.firstChild){const V=new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:C.clientX,clientY:C.clientY,pointerId:C.pointerId,pointerType:C.pointerType,isPrimary:C.isPrimary,buttons:C.buttons});B.firstChild.dispatchEvent(V)}},P=()=>{if(i.points.length<4)return;const w=i.points.filter((D,N)=>!m.includes(N)),C=dr(w);o("change",{...a,geometry:{points:w,bounds:C}}),e(8,m=[])};vi(()=>{if(Qr)return;const w=C=>{(C.key==="Delete"||C.key==="Backspace")&&(C.preventDefault(),P())};return c.addEventListener("pointermove",v),c.addEventListener("keydown",w),()=>{c.removeEventListener("pointermove",v),c.removeEventListener("keydown",w)}});const F=`polygon-mask-${Math.random().toString(36).substring(2,12)}`;function U(w){Me.call(this,r,w)}function I(w){Me.call(this,r,w)}function A(w){Me.call(this,r,w)}return r.$$set=w=>{"shape"in w&&e(0,a=w.shape),"computedStyle"in w&&e(1,l=w.computedStyle),"transform"in w&&e(2,h=w.transform),"viewportScale"in w&&e(3,u=w.viewportScale),"svgEl"in w&&e(4,c=w.svgEl)},r.$$.update=()=>{r.$$.dirty[0]&1&&e(5,i=a.geometry),r.$$.dirty[0]&40&&e(10,s=Qr?[]:i.points.map((w,C)=>{const D=C===i.points.length-1?i.points[0]:i.points[C+1],N=(w[0]+D[0])/2,B=(w[1]+D[1])/2,L=Math.sqrt(Math.pow(D[0]-N,2)+Math.pow(D[1]-B,2))>P1/u;return{point:[N,B],visible:L}})),r.$$.dirty[0]&40&&e(9,n=Za(i.bounds,Hs/u))},[a,l,h,u,c,i,d,f,m,n,s,_,y,v,x,E,R,S,M,F,U,I,A]}class N1 extends se{constructor(t){super(),ie(this,t,O1,I1,qt,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}function D1(r){let t,e,i,s,n,o,a,l,h,u,c,d,f,p,m,_,y,v,g,x,E,R,S,M,P,F,U,I,A,w,C,D,N,B,V,L,O,k,X,Y,q,pt,_t,W,bt,dt,mt,xt,Mt,Nt,_e,jt,et,Ke,mn;return dt=new es({props:{class:"a9s-corner-handle-topleft",x:r[5].x,y:r[5].y,scale:r[3]}}),dt.$on("pointerdown",function(){Jt(r[12]("TOP_LEFT"))&&r[12]("TOP_LEFT").apply(this,arguments)}),xt=new es({props:{class:"a9s-corner-handle-topright",x:r[5].x+r[5].w,y:r[5].y,scale:r[3]}}),xt.$on("pointerdown",function(){Jt(r[12]("TOP_RIGHT"))&&r[12]("TOP_RIGHT").apply(this,arguments)}),Nt=new es({props:{class:"a9s-corner-handle-bottomright",x:r[5].x+r[5].w,y:r[5].y+r[5].h,scale:r[3]}}),Nt.$on("pointerdown",function(){Jt(r[12]("BOTTOM_RIGHT"))&&r[12]("BOTTOM_RIGHT").apply(this,arguments)}),jt=new es({props:{class:"a9s-corner-handle-bottomleft",x:r[5].x,y:r[5].y+r[5].h,scale:r[3]}}),jt.$on("pointerdown",function(){Jt(r[12]("BOTTOM_LEFT"))&&r[12]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=st("defs"),e=st("mask"),i=st("rect"),l=st("rect"),f=Le(),p=st("rect"),g=Le(),x=st("rect"),P=Le(),F=st("rect"),w=Le(),C=st("rect"),V=Le(),L=st("rect"),Y=Le(),q=st("rect"),bt=Le(),Ht(dt.$$.fragment),mt=Le(),Ht(xt.$$.fragment),Mt=Le(),Ht(Nt.$$.fragment),_e=Le(),Ht(jt.$$.fragment),T(i,"class","rect-mask-bg svelte-1njczvj"),T(i,"x",s=r[6].x),T(i,"y",n=r[6].y),T(i,"width",o=r[6].w),T(i,"height",a=r[6].h),T(l,"class","rect-mask-fg svelte-1njczvj"),T(l,"x",h=r[5].x),T(l,"y",u=r[5].y),T(l,"width",c=r[5].w),T(l,"height",d=r[5].h),T(e,"id",r[8]),T(e,"class","a9s-rectangle-editor-mask svelte-1njczvj"),T(p,"class","a9s-outer"),T(p,"mask",`url(#${r[8]})`),T(p,"x",m=r[5].x),T(p,"y",_=r[5].y),T(p,"width",y=r[5].w),T(p,"height",v=r[5].h),T(x,"class","a9s-inner a9s-shape-handle"),T(x,"style",r[1]),T(x,"x",E=r[5].x),T(x,"y",R=r[5].y),T(x,"width",S=r[5].w),T(x,"height",M=r[5].h),T(F,"class","a9s-edge-handle a9s-edge-handle-top"),T(F,"x",U=r[5].x),T(F,"y",I=r[5].y),T(F,"height",1),T(F,"width",A=r[5].w),T(C,"class","a9s-edge-handle a9s-edge-handle-right"),T(C,"x",D=r[5].x+r[5].w),T(C,"y",N=r[5].y),T(C,"height",B=r[5].h),T(C,"width",1),T(L,"class","a9s-edge-handle a9s-edge-handle-bottom"),T(L,"x",O=r[5].x),T(L,"y",k=r[5].y+r[5].h),T(L,"height",1),T(L,"width",X=r[5].w),T(q,"class","a9s-edge-handle a9s-edge-handle-left"),T(q,"x",pt=r[5].x),T(q,"y",_t=r[5].y),T(q,"height",W=r[5].h),T(q,"width",1)},m(j,H){at(j,t,H),Ct(t,e),Ct(e,i),Ct(e,l),at(j,f,H),at(j,p,H),at(j,g,H),at(j,x,H),at(j,P,H),at(j,F,H),at(j,w,H),at(j,C,H),at(j,V,H),at(j,L,H),at(j,Y,H),at(j,q,H),at(j,bt,H),Ft(dt,j,H),at(j,mt,H),Ft(xt,j,H),at(j,Mt,H),Ft(Nt,j,H),at(j,_e,H),Ft(jt,j,H),et=!0,Ke||(mn=[Pt(p,"pointerdown",function(){Jt(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),Pt(x,"pointerdown",function(){Jt(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),Pt(F,"pointerdown",function(){Jt(r[12]("TOP"))&&r[12]("TOP").apply(this,arguments)}),Pt(C,"pointerdown",function(){Jt(r[12]("RIGHT"))&&r[12]("RIGHT").apply(this,arguments)}),Pt(L,"pointerdown",function(){Jt(r[12]("BOTTOM"))&&r[12]("BOTTOM").apply(this,arguments)}),Pt(q,"pointerdown",function(){Jt(r[12]("LEFT"))&&r[12]("LEFT").apply(this,arguments)})],Ke=!0)},p(j,H){r=j,(!et||H&64&&s!==(s=r[6].x))&&T(i,"x",s),(!et||H&64&&n!==(n=r[6].y))&&T(i,"y",n),(!et||H&64&&o!==(o=r[6].w))&&T(i,"width",o),(!et||H&64&&a!==(a=r[6].h))&&T(i,"height",a),(!et||H&32&&h!==(h=r[5].x))&&T(l,"x",h),(!et||H&32&&u!==(u=r[5].y))&&T(l,"y",u),(!et||H&32&&c!==(c=r[5].w))&&T(l,"width",c),(!et||H&32&&d!==(d=r[5].h))&&T(l,"height",d),(!et||H&32&&m!==(m=r[5].x))&&T(p,"x",m),(!et||H&32&&_!==(_=r[5].y))&&T(p,"y",_),(!et||H&32&&y!==(y=r[5].w))&&T(p,"width",y),(!et||H&32&&v!==(v=r[5].h))&&T(p,"height",v),(!et||H&2)&&T(x,"style",r[1]),(!et||H&32&&E!==(E=r[5].x))&&T(x,"x",E),(!et||H&32&&R!==(R=r[5].y))&&T(x,"y",R),(!et||H&32&&S!==(S=r[5].w))&&T(x,"width",S),(!et||H&32&&M!==(M=r[5].h))&&T(x,"height",M),(!et||H&32&&U!==(U=r[5].x))&&T(F,"x",U),(!et||H&32&&I!==(I=r[5].y))&&T(F,"y",I),(!et||H&32&&A!==(A=r[5].w))&&T(F,"width",A),(!et||H&32&&D!==(D=r[5].x+r[5].w))&&T(C,"x",D),(!et||H&32&&N!==(N=r[5].y))&&T(C,"y",N),(!et||H&32&&B!==(B=r[5].h))&&T(C,"height",B),(!et||H&32&&O!==(O=r[5].x))&&T(L,"x",O),(!et||H&32&&k!==(k=r[5].y+r[5].h))&&T(L,"y",k),(!et||H&32&&X!==(X=r[5].w))&&T(L,"width",X),(!et||H&32&&pt!==(pt=r[5].x))&&T(q,"x",pt),(!et||H&32&&_t!==(_t=r[5].y))&&T(q,"y",_t),(!et||H&32&&W!==(W=r[5].h))&&T(q,"height",W);const kr={};H&32&&(kr.x=r[5].x),H&32&&(kr.y=r[5].y),H&8&&(kr.scale=r[3]),dt.$set(kr);const Ur={};H&32&&(Ur.x=r[5].x+r[5].w),H&32&&(Ur.y=r[5].y),H&8&&(Ur.scale=r[3]),xt.$set(Ur);const Gr={};H&32&&(Gr.x=r[5].x+r[5].w),H&32&&(Gr.y=r[5].y+r[5].h),H&8&&(Gr.scale=r[3]),Nt.$set(Gr);const Hr={};H&32&&(Hr.x=r[5].x),H&32&&(Hr.y=r[5].y+r[5].h),H&8&&(Hr.scale=r[3]),jt.$set(Hr)},i(j){et||(K(dt.$$.fragment,j),K(xt.$$.fragment,j),K(Nt.$$.fragment,j),K(jt.$$.fragment,j),et=!0)},o(j){lt(dt.$$.fragment,j),lt(xt.$$.fragment,j),lt(Nt.$$.fragment,j),lt(jt.$$.fragment,j),et=!1},d(j){j&&(nt(t),nt(f),nt(p),nt(g),nt(x),nt(P),nt(F),nt(w),nt(C),nt(V),nt(L),nt(Y),nt(q),nt(bt),nt(mt),nt(Mt),nt(_e)),kt(dt,j),kt(xt,j),kt(Nt,j),kt(jt,j),Ke=!1,Ye(mn)}}}function L1(r){let t,e;return t=new Qa({props:{shape:r[0],transform:r[2],editor:r[7],svgEl:r[4],$$slots:{default:[D1,({grab:i})=>({12:i}),({grab:i})=>i?4096:0]},$$scope:{ctx:r}}}),t.$on("grab",r[9]),t.$on("change",r[10]),t.$on("release",r[11]),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&16&&(n.svgEl=i[4]),s&12394&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function B1(r,t,e){let i,s,{shape:n}=t,{computedStyle:o}=t,{transform:a}=t,{viewportScale:l=1}=t,{svgEl:h}=t;const u=(m,_,y)=>{const v=m.geometry.bounds;let[g,x]=[v.minX,v.minY],[E,R]=[v.maxX,v.maxY];const[S,M]=y;if(_==="SHAPE")g+=S,E+=S,x+=M,R+=M;else{switch(_){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{x+=M;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{R+=M;break}}switch(_){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{g+=S;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{E+=S;break}}}const P=Math.min(g,E),F=Math.min(x,R),U=Math.abs(E-g),I=Math.abs(R-x);return{...m,geometry:{x:P,y:F,w:U,h:I,bounds:{minX:P,minY:F,maxX:P+U,maxY:F+I}}}},c=`rect-mask-${Math.random().toString(36).substring(2,12)}`;function d(m){Me.call(this,r,m)}function f(m){Me.call(this,r,m)}function p(m){Me.call(this,r,m)}return r.$$set=m=>{"shape"in m&&e(0,n=m.shape),"computedStyle"in m&&e(1,o=m.computedStyle),"transform"in m&&e(2,a=m.transform),"viewportScale"in m&&e(3,l=m.viewportScale),"svgEl"in m&&e(4,h=m.svgEl)},r.$$.update=()=>{r.$$.dirty&1&&e(5,i=n.geometry),r.$$.dirty&40&&e(6,s=Za(i.bounds,2/l))},[n,o,a,l,h,i,s,u,c,d,f,p]}class F1 extends se{constructor(t){super(),ie(this,t,B1,L1,qt,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4})}}var wd=Object.prototype.hasOwnProperty;function rl(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--&&rl(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(wd.call(r,e)&&++i&&!wd.call(t,e)||!(e in t)||!rl(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}const k1=12,U1=(r,t)=>r.polygons.reduce((e,i,s)=>{const n=i.rings.reduce((o,a,l)=>{const h=a.points.map((u,c)=>{const d=c===a.points.length-1?a.points[0]:a.points[c+1],f=(u[0]+d[0])/2,p=(u[1]+d[1])/2,_=Math.sqrt(Math.pow(d[0]-f,2)+Math.pow(d[1]-p,2))>k1/t;return{point:[f,p],visible:_,elementIdx:s,ringIdx:l,pointIdx:c}});return[...o,...h]},[]);return[...e,...n]},[]);function il(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function Td(r,t,e){const i=r.slice();return i[30]=t[e],i[32]=e,i}function Ad(r,t,e){const i=r.slice();return i[33]=t[e],i[35]=e,i}function Sd(r,t,e){const i=r.slice();return i[29]=t[e],i[37]=e,i}function sl(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function nl(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function Cd(r){let t,e,i,s;return{c(){t=st("circle"),T(t,"cx",e=r[29][0]),T(t,"cy",i=r[29][1]),T(t,"r",s=$s/r[3]),T(t,"class","svelte-1vxo6dc")},m(n,o){at(n,t,o)},p(n,o){o[0]&1088&&e!==(e=n[29][0])&&T(t,"cx",e),o[0]&1088&&i!==(i=n[29][1])&&T(t,"cy",i),o[0]&8&&s!==(s=$s/n[3])&&T(t,"r",s)},d(n){n&&nt(t)}}}function Id(r){let t,e,i,s,n,o,a,l,h,u;return{c(){t=st("mask"),e=st("rect"),a=st("circle"),T(e,"x",i=r[9].x),T(e,"y",s=r[9].y),T(e,"width",n=r[9].w),T(e,"height",o=r[9].h),T(e,"class","svelte-1vxo6dc"),T(a,"cx",l=r[29][0]),T(a,"cy",h=r[29][1]),T(a,"r",u=$s/r[3]),T(a,"class","svelte-1vxo6dc"),T(t,"id",`${r[18]}-${r[32]}-inner`),T(t,"class","a9s-multipolygon-editor-mask svelte-1vxo6dc")},m(c,d){at(c,t,d),Ct(t,e),Ct(t,a)},p(c,d){d[0]&512&&i!==(i=c[9].x)&&T(e,"x",i),d[0]&512&&s!==(s=c[9].y)&&T(e,"y",s),d[0]&512&&n!==(n=c[9].w)&&T(e,"width",n),d[0]&512&&o!==(o=c[9].h)&&T(e,"height",o),d[0]&1088&&l!==(l=c[29][0])&&T(a,"cx",l),d[0]&1088&&h!==(h=c[29][1])&&T(a,"cy",h),d[0]&8&&u!==(u=$s/c[3])&&T(a,"r",u)},d(c){c&&nt(t)}}}function Rd(r){let t,e;function i(...s){return r[19](r[32],r[35],r[37],...s)}return t=new es({props:{class:"a9s-corner-handle",x:r[29][0],y:r[29][1],scale:r[3],selected:r[8].some(i)}}),t.$on("pointerenter",r[11]),t.$on("pointerleave",r[12]),t.$on("pointerdown",r[14]),t.$on("pointerdown",function(){Jt(r[28](`HANDLE-${r[32]}-${r[35]}-${r[37]}`))&&r[28](`HANDLE-${r[32]}-${r[35]}-${r[37]}`).apply(this,arguments)}),t.$on("pointerup",r[15](r[32],r[35],r[37])),{c(){Ht(t.$$.fragment)},m(s,n){Ft(t,s,n),e=!0},p(s,n){r=s;const o={};n[0]&32&&(o.x=r[29][0]),n[0]&32&&(o.y=r[29][1]),n[0]&8&&(o.scale=r[3]),n[0]&256&&(o.selected=r[8].some(i)),t.$set(o)},i(s){e||(K(t.$$.fragment,s),e=!0)},o(s){lt(t.$$.fragment,s),e=!1},d(s){kt(t,s)}}}function Md(r){let t,e,i=Pe(r[33].points),s=[];for(let o=0;o<i.length;o+=1)s[o]=Rd(Sd(r,i,o));const n=o=>lt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Ge()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);at(o,t,a),e=!0},p(o,a){if(a[0]&268491048){i=Pe(o[33].points);let l;for(l=0;l<i.length;l+=1){const h=Sd(o,i,l);s[l]?(s[l].p(h,a),K(s[l],1)):(s[l]=Rd(h),s[l].c(),K(s[l],1),s[l].m(t.parentNode,t))}for(fe(),l=i.length;l<s.length;l+=1)n(l);pe()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)K(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)lt(s[a]);e=!1},d(o){o&&nt(t),Wr(s,o)}}}function Pd(r){let t,e,i,s,n,o,a,l,h,u,c,d,f,p,m,_,y,v=r[6]!==void 0&&!r[7]&&Cd(nl(r)),g=r[6]!==void 0&&!r[7]&&Id(sl(r)),x=Pe(r[30].rings),E=[];for(let S=0;S<x.length;S+=1)E[S]=Md(Ad(r,x,S));const R=S=>lt(E[S],1,1,()=>{E[S]=null});return{c(){t=st("g"),e=st("defs"),i=st("mask"),s=st("rect"),h=st("path"),v&&v.c(),g&&g.c(),c=st("path"),f=st("path");for(let S=0;S<E.length;S+=1)E[S].c();T(s,"x",n=r[9].x),T(s,"y",o=r[9].y),T(s,"width",a=r[9].w),T(s,"height",l=r[9].h),T(s,"class","svelte-1vxo6dc"),T(h,"d",u=ts(r[30])),T(h,"class","svelte-1vxo6dc"),T(i,"id",`${r[18]}-${r[32]}-outer`),T(i,"class","a9s-multipolygon-editor-mask svelte-1vxo6dc"),T(c,"class","a9s-outer"),T(c,"mask",`url(#${r[18]}-${r[32]}-outer)`),T(c,"fill-rule","evenodd"),T(c,"d",d=ts(r[30])),T(f,"class","a9s-inner"),T(f,"mask",`url(#${r[18]}-${r[32]}-inner)`),T(f,"style",r[1]),T(f,"fill-rule","evenodd"),T(f,"d",p=ts(r[30]))},m(S,M){at(S,t,M),Ct(t,e),Ct(e,i),Ct(i,s),Ct(i,h),v&&v.m(i,null),g&&g.m(e,null),Ct(t,c),Ct(t,f);for(let P=0;P<E.length;P+=1)E[P]&&E[P].m(t,null);m=!0,_||(y=[Pt(c,"pointerup",r[13]),Pt(c,"pointerdown",function(){Jt(r[28]("SHAPE"))&&r[28]("SHAPE").apply(this,arguments)}),Pt(f,"pointerup",r[13]),Pt(f,"pointerdown",function(){Jt(r[28]("SHAPE"))&&r[28]("SHAPE").apply(this,arguments)})],_=!0)},p(S,M){if(r=S,(!m||M[0]&512&&n!==(n=r[9].x))&&T(s,"x",n),(!m||M[0]&512&&o!==(o=r[9].y))&&T(s,"y",o),(!m||M[0]&512&&a!==(a=r[9].w))&&T(s,"width",a),(!m||M[0]&512&&l!==(l=r[9].h))&&T(s,"height",l),(!m||M[0]&32&&u!==(u=ts(r[30])))&&T(h,"d",u),r[6]!==void 0&&!r[7]?v?v.p(nl(r),M):(v=Cd(nl(r)),v.c(),v.m(i,null)):v&&(v.d(1),v=null),r[6]!==void 0&&!r[7]?g?g.p(sl(r),M):(g=Id(sl(r)),g.c(),g.m(e,null)):g&&(g.d(1),g=null),(!m||M[0]&32&&d!==(d=ts(r[30])))&&T(c,"d",d),(!m||M[0]&2)&&T(f,"style",r[1]),(!m||M[0]&32&&p!==(p=ts(r[30])))&&T(f,"d",p),M[0]&268491048){x=Pe(r[30].rings);let P;for(P=0;P<x.length;P+=1){const F=Ad(r,x,P);E[P]?(E[P].p(F,M),K(E[P],1)):(E[P]=Md(F),E[P].c(),K(E[P],1),E[P].m(t,null))}for(fe(),P=x.length;P<E.length;P+=1)R(P);pe()}},i(S){if(!m){for(let M=0;M<x.length;M+=1)K(E[M]);m=!0}},o(S){E=E.filter(Boolean);for(let M=0;M<E.length;M+=1)lt(E[M]);m=!1},d(S){S&&nt(t),v&&v.d(),g&&g.d(),Wr(E,S),_=!1,Ye(y)}}}function Od(r){let t,e;return t=new pd({props:{x:r[29][0],y:r[29][1],scale:r[3]}}),t.$on("pointerdown",function(){Jt(r[17](r[6]))&&r[17](r[6]).apply(this,arguments)}),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&1088&&(n.x=r[29][0]),s[0]&1088&&(n.y=r[29][1]),s[0]&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function G1(r){let t,e,i,s=Pe(r[5].polygons),n=[];for(let l=0;l<s.length;l+=1)n[l]=Pd(Td(r,s,l));const o=l=>lt(n[l],1,1,()=>{n[l]=null});let a=r[6]!==void 0&&!r[7]&&Od(il(r));return{c(){for(let l=0;l<n.length;l+=1)n[l].c();t=Le(),a&&a.c(),e=Ge()},m(l,h){for(let u=0;u<n.length;u+=1)n[u]&&n[u].m(l,h);at(l,t,h),a&&a.m(l,h),at(l,e,h),i=!0},p(l,h){if(h[0]&268763114){s=Pe(l[5].polygons);let u;for(u=0;u<s.length;u+=1){const c=Td(l,s,u);n[u]?(n[u].p(c,h),K(n[u],1)):(n[u]=Pd(c),n[u].c(),K(n[u],1),n[u].m(t.parentNode,t))}for(fe(),u=s.length;u<n.length;u+=1)o(u);pe()}l[6]!==void 0&&!l[7]?a?(a.p(il(l),h),h[0]&192&&K(a,1)):(a=Od(il(l)),a.c(),K(a,1),a.m(e.parentNode,e)):a&&(fe(),lt(a,1,1,()=>{a=null}),pe())},i(l){if(!i){for(let h=0;h<s.length;h+=1)K(n[h]);K(a),i=!0}},o(l){n=n.filter(Boolean);for(let h=0;h<n.length;h+=1)lt(n[h]);lt(a),i=!1},d(l){l&&(nt(t),nt(e)),Wr(n,l),a&&a.d(l)}}}function H1(r){let t,e;return t=new Qa({props:{shape:r[0],transform:r[2],editor:r[16],svgEl:r[4],$$slots:{default:[G1,({grab:i})=>({28:i}),({grab:i})=>[i?268435456:0]]},$$scope:{ctx:r}}}),t.$on("change",r[20]),t.$on("grab",r[21]),t.$on("release",r[22]),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s[0]&1&&(n.shape=i[0]),s[0]&4&&(n.transform=i[2]),s[0]&16&&(n.svgEl=i[4]),s[0]&268437482|s[1]&128&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}const $1=250,X1=1e3,$s=4.5;function V1(r,t,e){let i,s,n;const o=Ki();let{shape:a}=t,{computedStyle:l}=t,{transform:h}=t,{viewportScale:u=1}=t,{svgEl:c}=t,d,f=!1,p,m=[];const _=()=>e(7,f=!0),y=()=>e(7,f=!1),v=C=>{if(m.length>0||!s.some(X=>X.visible)){e(6,d=void 0);return}const[D,N]=h.elementToImage(C.offsetX,C.offsetY),B=X=>Math.pow(X[0]-D,2)+Math.pow(X[1]-N,2),V=Uv(i).reduce((X,Y)=>B(Y)<B(X)?Y:X),L=s.filter(X=>X.visible).reduce((X,Y)=>B(Y.point)<B(X.point)?Y:X),O=Math.pow(X1/u,2);B(V)<O||B(L.point)<O?e(6,d=s.indexOf(L)):e(6,d=void 0)},g=()=>{document.activeElement!==c&&c.focus()},x=()=>{e(8,m=[]),g()},E=C=>{e(7,f=!0),C.preventDefault(),C.stopPropagation(),p=performance.now()},R=(C,D,N)=>B=>{if(!p||Qr||performance.now()-p>$1)return;const V=O=>O.polygon===C&&O.ring===D&&O.point===N,L=m.some(V);B.metaKey||B.ctrlKey||B.shiftKey?L?e(8,m=m.filter(O=>!V(O))):e(8,m=[...m,{polygon:C,ring:D,point:N}]):L&&m.length>1?e(8,m=[{polygon:C,ring:D,point:N}]):L?e(8,m=[]):e(8,m=[{polygon:C,ring:D,point:N}]),g()},S=(C,D,N)=>{g();const B=C.geometry.polygons;let V;if(D==="SHAPE")V=B.map(L=>{const O=L.rings.map((X,Y)=>({points:X.points.map((pt,_t)=>[pt[0]+N[0],pt[1]+N[1]])})),k=dr(O[0].points);return{rings:O,bounds:k}});else{const[L,O,k,X]=D.split("-").map(Y=>parseInt(Y));V=B.map((Y,q)=>{if(q===O){const pt=Y.rings.map((W,bt)=>bt===k?{points:W.points.map((mt,xt)=>xt===X?[mt[0]+N[0],mt[1]+N[1]]:mt)}:W),_t=dr(pt[0].points);return{rings:pt,bounds:_t}}else return Y})}return{...C,geometry:{polygons:V,bounds:Fn(V)}}},M=C=>async D=>{D.stopPropagation();const N=s[C],B=i.polygons.map((L,O)=>{if(O===N.elementIdx){const k=L.rings.map((Y,q)=>q===N.ringIdx?{points:[...Y.points.slice(0,N.pointIdx+1),N.point,...Y.points.slice(N.pointIdx+1)]}:Y),X=dr(k[0].points);return{rings:k,bounds:X}}else return L});o("change",{...a,geometry:{polygons:B,bounds:Fn(B)}}),await Kc();const V=[...document.querySelectorAll(".a9s-handle")][C+1];if(V!=null&&V.firstChild){const L=new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:D.clientX,clientY:D.clientY,pointerId:D.pointerId,pointerType:D.pointerType,isPrimary:D.isPrimary,buttons:D.buttons});V.firstChild.dispatchEvent(L)}},P=()=>{const C=i.polygons.map((N,B)=>{if(m.some(L=>L.polygon===B)){const L=N.rings.map((k,X)=>m.some(q=>q.polygon===B&&q.ring===X)&&k.points.length>3?{points:k.points.filter((pt,_t)=>!m.some(W=>W.polygon===B&&W.ring===X&&W.point===_t))}:k),O=dr(L[0].points);return{rings:L,bounds:O}}else return N});!rl(i.polygons,C)&&(o("change",{...a,geometry:{polygons:C,bounds:Fn(C)}}),e(8,m=[]))};vi(()=>{if(Qr)return;const C=D=>{(D.key==="Delete"||D.key==="Backspace")&&(D.preventDefault(),P())};return c.addEventListener("pointermove",v),c.addEventListener("keydown",C),()=>{c.removeEventListener("pointermove",v),c.removeEventListener("keydown",C)}});const F=`polygon-mask-${Math.random().toString(36).substring(2,12)}`,U=(C,D,N,{polygon:B,ring:V,point:L})=>B===C&&V===D&&L===N;function I(C){Me.call(this,r,C)}function A(C){Me.call(this,r,C)}function w(C){Me.call(this,r,C)}return r.$$set=C=>{"shape"in C&&e(0,a=C.shape),"computedStyle"in C&&e(1,l=C.computedStyle),"transform"in C&&e(2,h=C.transform),"viewportScale"in C&&e(3,u=C.viewportScale),"svgEl"in C&&e(4,c=C.svgEl)},r.$$.update=()=>{r.$$.dirty[0]&1&&e(5,i=a.geometry),r.$$.dirty[0]&40&&e(10,s=Qr?[]:U1(i,u)),r.$$.dirty[0]&40&&e(9,n=Za(i.bounds,$s/u))},[a,l,h,u,c,i,d,f,m,n,s,_,y,x,E,R,S,M,F,U,I,A,w]}class z1 extends se{constructor(t){super(),ie(this,t,V1,H1,qt,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}qr.RECTANGLE,qr.POLYGON,qr.MULTIPOLYGLON;function Y1(r,t,e){let i;const s=Ki();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:u}=t,c;return vi(()=>(e(6,c=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:u,svgEl:l.closest("svg")}})),c.$on("change",d=>{c.$$set({shape:d.detail}),s("change",d.detail)}),c.$on("grab",d=>s("grab",d.detail)),c.$on("release",d=>s("release",d.detail)),()=>{c.$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,u=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=m1(n,a)),r.$$.dirty&65&&n&&(c==null||c.$set({shape:n.target.selector})),r.$$.dirty&80&&c&&c.$set({transform:h}),r.$$.dirty&96&&c&&c.$set({viewportScale:u}),r.$$.dirty&192&&c&&i&&c.$set({computedStyle:i})},[n,o,a,l,h,u,c,i]}class W1 extends se{constructor(t){super(),ie(this,t,Y1,null,qt,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1;var Ei=(r=>(r[r.WEBGL_LEGACY=0]="WEBGL_LEGACY",r[r.WEBGL=1]="WEBGL",r[r.WEBGL2=2]="WEBGL2",r))(Ei||{}),Nd=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.WEBGL=1]="WEBGL",r[r.CANVAS=2]="CANVAS",r))(Nd||{}),ol=(r=>(r[r.COLOR=16384]="COLOR",r[r.DEPTH=256]="DEPTH",r[r.STENCIL=1024]="STENCIL",r))(ol||{}),yt=(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))(yt||{}),fr=(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))(fr||{}),z=(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))(z||{}),rs=(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))(rs||{}),ft=(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))(ft||{}),J=(r=>(r[r.FLOAT=0]="FLOAT",r[r.INT=1]="INT",r[r.UINT=2]="UINT",r))(J||{}),Ir=(r=>(r[r.NEAREST=0]="NEAREST",r[r.LINEAR=1]="LINEAR",r))(Ir||{}),Jr=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(Jr||{}),pr=(r=>(r[r.OFF=0]="OFF",r[r.POW2=1]="POW2",r[r.ON=2]="ON",r[r.ON_MANUAL=3]="ON_MANUAL",r))(pr||{}),He=(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))(He||{}),mr=(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))(mr||{}),al=(r=>(r[r.AUTO=0]="AUTO",r[r.MANUAL=1]="MANUAL",r))(al||{}),We=(r=>(r.LOW="lowp",r.MEDIUM="mediump",r.HIGH="highp",r))(We||{}),he=(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))(he||{}),ae=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(ae||{}),gr=(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))(gr||{});const tt={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 ll=/iPhone/i,Dd=/iPod/i,Ld=/iPad/i,Bd=/\biOS-universal(?:.+)Mac\b/i,hl=/\bAndroid(?:.+)Mobile\b/i,Fd=/Android/i,is=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Un=/Silk/i,Rr=/Windows Phone/i,kd=/\bWindows(?:.+)ARM\b/i,Ud=/BlackBerry/i,Gd=/BB10/i,Hd=/Opera Mini/i,$d=/\b(CriOS|Chrome)(?:.+)Mobile/i,Xd=/Mobile(?:.+)Firefox\b/i,Vd=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function j1(r){return function(t){return t.test(r)}}function zd(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=j1(e),n={apple:{phone:s(ll)&&!s(Rr),ipod:s(Dd),tablet:!s(ll)&&(s(Ld)||Vd(t))&&!s(Rr),universal:s(Bd),device:(s(ll)||s(Dd)||s(Ld)||s(Bd)||Vd(t))&&!s(Rr)},amazon:{phone:s(is),tablet:!s(is)&&s(Un),device:s(is)||s(Un)},android:{phone:!s(Rr)&&s(is)||!s(Rr)&&s(hl),tablet:!s(Rr)&&!s(is)&&!s(hl)&&(s(Un)||s(Fd)),device:!s(Rr)&&(s(is)||s(Un)||s(hl)||s(Fd))||s(/\bokhttp\b/i)},windows:{phone:s(Rr),tablet:s(kd),device:s(Rr)||s(kd)},other:{blackberry:s(Ud),blackberry10:s(Gd),opera:s(Hd),firefox:s(Xd),chrome:s($d),device:s(Ud)||s(Gd)||s(Hd)||s(Xd)||s($d)},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 q1=zd.default??zd,Mr=q1(globalThis.navigator);tt.RETINA_PREFIX=/@([0-9\.]+)x/,tt.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var Yd={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,u){this.fn=l,this.context=h,this.once=u||!1}function n(l,h,u,c,d){if(typeof u!="function")throw new TypeError("The listener must be a function");var f=new s(u,c||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=[],u,c;if(this._eventsCount===0)return h;for(c in u=this._events)t.call(u,c)&&h.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(u)):h},a.prototype.listeners=function(h){var u=e?e+h:h,c=this._events[u];if(!c)return[];if(c.fn)return[c.fn];for(var d=0,f=c.length,p=new Array(f);d<f;d++)p[d]=c[d].fn;return p},a.prototype.listenerCount=function(h){var u=e?e+h:h,c=this._events[u];return c?c.fn?1:c.length:0},a.prototype.emit=function(h,u,c,d,f,p){var m=e?e+h:h;if(!this._events[m])return!1;var _=this._events[m],y=arguments.length,v,g;if(_.fn){switch(_.once&&this.removeListener(h,_.fn,void 0,!0),y){case 1:return _.fn.call(_.context),!0;case 2:return _.fn.call(_.context,u),!0;case 3:return _.fn.call(_.context,u,c),!0;case 4:return _.fn.call(_.context,u,c,d),!0;case 5:return _.fn.call(_.context,u,c,d,f),!0;case 6:return _.fn.call(_.context,u,c,d,f,p),!0}for(g=1,v=new Array(y-1);g<y;g++)v[g-1]=arguments[g];_.fn.apply(_.context,v)}else{var x=_.length,E;for(g=0;g<x;g++)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,u);break;case 3:_[g].fn.call(_[g].context,u,c);break;case 4:_[g].fn.call(_[g].context,u,c,d);break;default:if(!v)for(E=1,v=new Array(y-1);E<y;E++)v[E-1]=arguments[E];_[g].fn.apply(_[g].context,v)}}return!0},a.prototype.on=function(h,u,c){return n(this,h,u,c,!1)},a.prototype.once=function(h,u,c){return n(this,h,u,c,!0)},a.prototype.removeListener=function(h,u,c,d){var f=e?e+h:h;if(!this._events[f])return this;if(!u)return o(this,f),this;var p=this._events[f];if(p.fn)p.fn===u&&(!d||p.once)&&(!c||p.context===c)&&o(this,f);else{for(var m=0,_=[],y=p.length;m<y;m++)(p[m].fn!==u||d&&!p[m].once||c&&p[m].context!==c)&&_.push(p[m]);_.length?this._events[f]=_.length===1?_[0]:_:o(this,f)}return this},a.prototype.removeAllListeners=function(h){var u;return h?(u=e?e+h:h,this._events[u]&&o(this,u)):(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})(Yd);var K1=Yd.exports;const Xs=Va(K1);var ul={exports:{}};ul.exports=Gn,ul.exports.default=Gn;function Gn(r,t,e){e=e||2;var i=t&&t.length,s=i?t[0]*e:r.length,n=Wd(r,0,s,e,!0),o=[];if(!n||n.next===n.prev)return o;var a,l,h,u,c,d,f;if(i&&(n=ex(r,t,n,e)),r.length>80*e){a=h=r[0],l=u=r[1];for(var p=e;p<s;p+=e)c=r[p],d=r[p+1],c<a&&(a=c),d<l&&(l=d),c>h&&(h=c),d>u&&(u=d);f=Math.max(h-a,u-l),f=f!==0?32767/f:0}return Vs(n,o,e,a,l,f,0),o}function Wd(r,t,e,i,s){var n,o;if(s===fl(r,t,e,i)>0)for(n=t;n<e;n+=i)o=Kd(n,r[n],r[n+1],o);else for(n=e-i;n>=t;n-=i)o=Kd(n,r[n],r[n+1],o);return o&&Hn(o,o.next)&&(Ys(o),o=o.next),o}function wi(r,t){if(!r)return r;t||(t=r);var e=r,i;do if(i=!1,!e.steiner&&(Hn(e,e.next)||zt(e.prev,e,e.next)===0)){if(Ys(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function Vs(r,t,e,i,s,n,o){if(r){!o&&n&&ox(r,i,s,n);for(var a=r,l,h;r.prev!==r.next;){if(l=r.prev,h=r.next,n?Q1(r,i,s,n):Z1(r)){t.push(l.i/e|0),t.push(r.i/e|0),t.push(h.i/e|0),Ys(r),r=h.next,a=h.next;continue}if(r=h,r===a){o?o===1?(r=J1(wi(r),t,e),Vs(r,t,e,i,s,n,2)):o===2&&tx(r,t,e,i,s,n):Vs(wi(r),t,e,i,s,n,1);break}}}}function Z1(r){var t=r.prev,e=r,i=r.next;if(zt(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,u=s<n?s<o?s:o:n<o?n:o,c=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>=u&&p.x<=d&&p.y>=c&&p.y<=f&&ss(s,a,n,l,o,h,p.x,p.y)&&zt(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Q1(r,t,e,i){var s=r.prev,n=r,o=r.next;if(zt(s,n,o)>=0)return!1;for(var a=s.x,l=n.x,h=o.x,u=s.y,c=n.y,d=o.y,f=a<l?a<h?a:h:l<h?l:h,p=u<c?u<d?u:d:c<d?c:d,m=a>l?a>h?a:h:l>h?l:h,_=u>c?u>d?u:d:c>d?c:d,y=cl(f,p,t,e,i),v=cl(m,_,t,e,i),g=r.prevZ,x=r.nextZ;g&&g.z>=y&&x&&x.z<=v;){if(g.x>=f&&g.x<=m&&g.y>=p&&g.y<=_&&g!==s&&g!==o&&ss(a,u,l,c,h,d,g.x,g.y)&&zt(g.prev,g,g.next)>=0||(g=g.prevZ,x.x>=f&&x.x<=m&&x.y>=p&&x.y<=_&&x!==s&&x!==o&&ss(a,u,l,c,h,d,x.x,x.y)&&zt(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;g&&g.z>=y;){if(g.x>=f&&g.x<=m&&g.y>=p&&g.y<=_&&g!==s&&g!==o&&ss(a,u,l,c,h,d,g.x,g.y)&&zt(g.prev,g,g.next)>=0)return!1;g=g.prevZ}for(;x&&x.z<=v;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=_&&x!==s&&x!==o&&ss(a,u,l,c,h,d,x.x,x.y)&&zt(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function J1(r,t,e){var i=r;do{var s=i.prev,n=i.next.next;!Hn(s,n)&&jd(s,i,i.next,n)&&zs(s,n)&&zs(n,s)&&(t.push(s.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),Ys(i),Ys(i.next),i=r=n),i=i.next}while(i!==r);return wi(i)}function tx(r,t,e,i,s,n){var o=r;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&hx(o,a)){var l=qd(o,a);o=wi(o,o.next),l=wi(l,l.next),Vs(o,t,e,i,s,n,0),Vs(l,t,e,i,s,n,0);return}a=a.next}o=o.next}while(o!==r)}function ex(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=Wd(r,a,l,i,!1),h===h.next&&(h.steiner=!0),s.push(lx(h));for(s.sort(rx),n=0;n<s.length;n++)e=ix(s[n],e);return e}function rx(r,t){return r.x-t.x}function ix(r,t){var e=sx(r,t);if(!e)return t;var i=qd(e,r);return wi(i,i.next),wi(e,e.next)}function sx(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,u=o.y,c=1/0,d;e=o;do i>=e.x&&e.x>=h&&i!==e.x&&ss(s<u?i:n,s,h,u,s<u?n:i,s,e.x,e.y)&&(d=Math.abs(s-e.y)/(i-e.x),zs(e,r)&&(d<c||d===c&&(e.x>o.x||e.x===o.x&&nx(o,e)))&&(o=e,c=d)),e=e.next;while(e!==l);return o}function nx(r,t){return zt(r.prev,r,t.prev)<0&&zt(t.next,r,r.next)<0}function ox(r,t,e,i){var s=r;do s.z===0&&(s.z=cl(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,ax(s)}function ax(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 cl(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 lx(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 ss(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 hx(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!ux(r,t)&&(zs(r,t)&&zs(t,r)&&cx(r,t)&&(zt(r.prev,r,t.prev)||zt(r,t.prev,t))||Hn(r,t)&&zt(r.prev,r,r.next)>0&&zt(t.prev,t,t.next)>0)}function zt(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Hn(r,t){return r.x===t.x&&r.y===t.y}function jd(r,t,e,i){var s=Xn(zt(r,t,e)),n=Xn(zt(r,t,i)),o=Xn(zt(e,i,r)),a=Xn(zt(e,i,t));return!!(s!==n&&o!==a||s===0&&$n(r,e,t)||n===0&&$n(r,i,t)||o===0&&$n(e,r,i)||a===0&&$n(e,t,i))}function $n(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 Xn(r){return r>0?1:r<0?-1:0}function ux(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&&jd(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function zs(r,t){return zt(r.prev,r,r.next)<0?zt(r,t,r.next)>=0&&zt(r,r.prev,t)>=0:zt(r,t,r.prev)<0||zt(r,r.next,t)<0}function cx(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 qd(r,t){var e=new dl(r.i,r.x,r.y),i=new dl(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 Kd(r,t,e,i){var s=new dl(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 Ys(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 dl(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}Gn.deviation=function(r,t,e,i){var s=t&&t.length,n=s?t[0]*e:r.length,o=Math.abs(fl(r,0,n,e));if(s)for(var a=0,l=t.length;a<l;a++){var h=t[a]*e,u=a<l-1?t[a+1]*e:r.length;o-=Math.abs(fl(r,h,u,e))}var c=0;for(a=0;a<i.length;a+=3){var d=i[a]*e,f=i[a+1]*e,p=i[a+2]*e;c+=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&&c===0?0:Math.abs((c-o)/o)};function fl(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}Gn.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 dx=ul.exports;const fx=Va(dx);var Vn={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */Vn.exports,function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=r&&!r.nodeType&&r,n=typeof Gs=="object"&&Gs;(n.global===n||n.window===n||n.self===n)&&(e=n);var o,a=2147483647,l=36,h=1,u=26,c=38,d=700,f=72,p=128,m="-",_=/^xn--/,y=/[^\x20-\x7E]/,v=/[\x2E\u3002\uFF0E\uFF61]/g,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,E=Math.floor,R=String.fromCharCode,S;function M(L){throw new RangeError(g[L])}function P(L,O){for(var k=L.length,X=[];k--;)X[k]=O(L[k]);return X}function F(L,O){var k=L.split("@"),X="";k.length>1&&(X=k[0]+"@",L=k[1]),L=L.replace(v,".");var Y=L.split("."),q=P(Y,O).join(".");return X+q}function U(L){for(var O=[],k=0,X=L.length,Y,q;k<X;)Y=L.charCodeAt(k++),Y>=55296&&Y<=56319&&k<X?(q=L.charCodeAt(k++),(q&64512)==56320?O.push(((Y&1023)<<10)+(q&1023)+65536):(O.push(Y),k--)):O.push(Y);return O}function I(L){return P(L,function(O){var k="";return O>65535&&(O-=65536,k+=R(O>>>10&1023|55296),O=56320|O&1023),k+=R(O),k}).join("")}function A(L){return L-48<10?L-22:L-65<26?L-65:L-97<26?L-97:l}function w(L,O){return L+22+75*(L<26)-((O!=0)<<5)}function C(L,O,k){var X=0;for(L=k?E(L/d):L>>1,L+=E(L/O);L>x*u>>1;X+=l)L=E(L/x);return E(X+(x+1)*L/(L+c))}function D(L){var O=[],k=L.length,X,Y=0,q=p,pt=f,_t,W,bt,dt,mt,xt,Mt,Nt,_e;for(_t=L.lastIndexOf(m),_t<0&&(_t=0),W=0;W<_t;++W)L.charCodeAt(W)>=128&&M("not-basic"),O.push(L.charCodeAt(W));for(bt=_t>0?_t+1:0;bt<k;){for(dt=Y,mt=1,xt=l;bt>=k&&M("invalid-input"),Mt=A(L.charCodeAt(bt++)),(Mt>=l||Mt>E((a-Y)/mt))&&M("overflow"),Y+=Mt*mt,Nt=xt<=pt?h:xt>=pt+u?u:xt-pt,!(Mt<Nt);xt+=l)_e=l-Nt,mt>E(a/_e)&&M("overflow"),mt*=_e;X=O.length+1,pt=C(Y-dt,X,dt==0),E(Y/X)>a-q&&M("overflow"),q+=E(Y/X),Y%=X,O.splice(Y++,0,q)}return I(O)}function N(L){var O,k,X,Y,q,pt,_t,W,bt,dt,mt,xt=[],Mt,Nt,_e,jt;for(L=U(L),Mt=L.length,O=p,k=0,q=f,pt=0;pt<Mt;++pt)mt=L[pt],mt<128&&xt.push(R(mt));for(X=Y=xt.length,Y&&xt.push(m);X<Mt;){for(_t=a,pt=0;pt<Mt;++pt)mt=L[pt],mt>=O&&mt<_t&&(_t=mt);for(Nt=X+1,_t-O>E((a-k)/Nt)&&M("overflow"),k+=(_t-O)*Nt,O=_t,pt=0;pt<Mt;++pt)if(mt=L[pt],mt<O&&++k>a&&M("overflow"),mt==O){for(W=k,bt=l;dt=bt<=q?h:bt>=q+u?u:bt-q,!(W<dt);bt+=l)jt=W-dt,_e=l-dt,xt.push(R(w(dt+jt%_e,0))),W=E(jt/_e);xt.push(R(w(W,0))),q=C(k,Nt,X==Y),k=0,++X}++k,++O}return xt.join("")}function B(L){return F(L,function(O){return _.test(O)?D(O.slice(4).toLowerCase()):O})}function V(L){return F(L,function(O){return y.test(O)?"xn--"+N(O):O})}if(o={version:"1.4.1",ucs2:{decode:U,encode:I},decode:D,encode:N,toASCII:V,toUnicode:B},i&&s)if(r.exports==i)s.exports=o;else for(S in o)o.hasOwnProperty(S)&&(i[S]=o[S]);else e.punycode=o})(Gs)}(Vn,Vn.exports);var px=Vn.exports,ns=TypeError;const mx=Nv(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var pl=typeof Map=="function"&&Map.prototype,ml=Object.getOwnPropertyDescriptor&&pl?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,zn=pl&&ml&&typeof ml.get=="function"?ml.get:null,Zd=pl&&Map.prototype.forEach,gl=typeof Set=="function"&&Set.prototype,yl=Object.getOwnPropertyDescriptor&&gl?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Yn=gl&&yl&&typeof yl.get=="function"?yl.get:null,Qd=gl&&Set.prototype.forEach,gx=typeof WeakMap=="function"&&WeakMap.prototype,Ws=gx?WeakMap.prototype.has:null,yx=typeof WeakSet=="function"&&WeakSet.prototype,js=yx?WeakSet.prototype.has:null,_x=typeof WeakRef=="function"&&WeakRef.prototype,Jd=_x?WeakRef.prototype.deref:null,vx=Boolean.prototype.valueOf,xx=Object.prototype.toString,bx=Function.prototype.toString,Ex=String.prototype.match,_l=String.prototype.slice,ti=String.prototype.replace,wx=String.prototype.toUpperCase,tf=String.prototype.toLowerCase,ef=RegExp.prototype.test,rf=Array.prototype.concat,yr=Array.prototype.join,Tx=Array.prototype.slice,sf=Math.floor,vl=typeof BigInt=="function"?BigInt.prototype.valueOf:null,xl=Object.getOwnPropertySymbols,bl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,os=typeof Symbol=="function"&&typeof Symbol.iterator=="object",qs=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===os||!0)?Symbol.toStringTag:null,nf=Object.prototype.propertyIsEnumerable,of=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function af(r,t){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||ef.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var i=r<0?-sf(-r):sf(r);if(i!==r){var s=String(i),n=_l.call(t,s.length+1);return ti.call(s,e,"$&_")+"."+ti.call(ti.call(n,/([0-9]{3})/g,"$&_"),/_$/,"")}}return ti.call(t,e,"$&_")}var El=mx,lf=El.custom,hf=ff(lf)?lf:null,uf={__proto__:null,double:'"',single:"'"},Ax={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},Wn=function r(t,e,i,s){var n=e||{};if(Pr(n,"quoteStyle")&&!Pr(uf,n.quoteStyle))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 mf(t,n);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var l=String(t);return a?af(t,l):l}if(typeof t=="bigint"){var h=String(t)+"n";return a?af(t,h):h}var u=typeof n.depth>"u"?5:n.depth;if(typeof i>"u"&&(i=0),i>=u&&u>0&&typeof t=="object")return wl(t)?"[Array]":"[Object]";var c=Xx(n,i);if(typeof s>"u")s=[];else if(pf(s,t)>=0)return"[Circular]";function d(A,w,C){if(w&&(s=Tx.call(s),s.push(w)),C){var D={depth:n.depth};return Pr(n,"quoteStyle")&&(D.quoteStyle=n.quoteStyle),r(A,D,i+1,s)}return r(A,n,i+1,s)}if(typeof t=="function"&&!df(t)){var f=Dx(t),p=jn(t,d);return"[Function"+(f?": "+f:" (anonymous)")+"]"+(p.length>0?" { "+yr.call(p,", ")+" }":"")}if(ff(t)){var m=os?ti.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):bl.call(t);return typeof t=="object"&&!os?Ks(m):m}if(Gx(t)){for(var _="<"+tf.call(String(t.nodeName)),y=t.attributes||[],v=0;v<y.length;v++)_+=" "+y[v].name+"="+cf(Sx(y[v].value),"double",n);return _+=">",t.childNodes&&t.childNodes.length&&(_+="..."),_+="</"+tf.call(String(t.nodeName))+">",_}if(wl(t)){if(t.length===0)return"[]";var g=jn(t,d);return c&&!$x(g)?"["+Al(g,c)+"]":"[ "+yr.call(g,", ")+" ]"}if(Ix(t)){var x=jn(t,d);return!("cause"in Error.prototype)&&"cause"in t&&!nf.call(t,"cause")?"{ ["+String(t)+"] "+yr.call(rf.call("[cause]: "+d(t.cause),x),", ")+" }":x.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+yr.call(x,", ")+" }"}if(typeof t=="object"&&o){if(hf&&typeof t[hf]=="function"&&El)return El(t,{depth:u-i});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(Lx(t)){var E=[];return Zd&&Zd.call(t,function(A,w){E.push(d(w,t,!0)+" => "+d(A,t))}),gf("Map",zn.call(t),E,c)}if(kx(t)){var R=[];return Qd&&Qd.call(t,function(A){R.push(d(A,t))}),gf("Set",Yn.call(t),R,c)}if(Bx(t))return Tl("WeakMap");if(Ux(t))return Tl("WeakSet");if(Fx(t))return Tl("WeakRef");if(Mx(t))return Ks(d(Number(t)));if(Ox(t))return Ks(d(vl.call(t)));if(Px(t))return Ks(vx.call(t));if(Rx(t))return Ks(d(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(typeof globalThis<"u"&&t===globalThis||typeof Gs<"u"&&t===Gs)return"{ [object globalThis] }";if(!Cx(t)&&!df(t)){var S=jn(t,d),M=of?of(t)===Object.prototype:t instanceof Object||t.constructor===Object,P=t instanceof Object?"":"null prototype",F=!M&&qs&&Object(t)===t&&qs in t?_l.call(ei(t),8,-1):P?"Object":"",U=M||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",I=U+(F||P?"["+yr.call(rf.call([],F||[],P||[]),": ")+"] ":"");return S.length===0?I+"{}":c?I+"{"+Al(S,c)+"}":I+"{ "+yr.call(S,", ")+" }"}return String(t)};function cf(r,t,e){var i=e.quoteStyle||t,s=uf[i];return s+r+s}function Sx(r){return ti.call(String(r),/"/g,"&quot;")}function Ti(r){return!qs||!(typeof r=="object"&&(qs in r||typeof r[qs]<"u"))}function wl(r){return ei(r)==="[object Array]"&&Ti(r)}function Cx(r){return ei(r)==="[object Date]"&&Ti(r)}function df(r){return ei(r)==="[object RegExp]"&&Ti(r)}function Ix(r){return ei(r)==="[object Error]"&&Ti(r)}function Rx(r){return ei(r)==="[object String]"&&Ti(r)}function Mx(r){return ei(r)==="[object Number]"&&Ti(r)}function Px(r){return ei(r)==="[object Boolean]"&&Ti(r)}function ff(r){if(os)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!bl)return!1;try{return bl.call(r),!0}catch{}return!1}function Ox(r){if(!r||typeof r!="object"||!vl)return!1;try{return vl.call(r),!0}catch{}return!1}var Nx=Object.prototype.hasOwnProperty||function(r){return r in this};function Pr(r,t){return Nx.call(r,t)}function ei(r){return xx.call(r)}function Dx(r){if(r.name)return r.name;var t=Ex.call(bx.call(r),/^function\s*([\w$]+)/);return t?t[1]:null}function pf(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 Lx(r){if(!zn||!r||typeof r!="object")return!1;try{zn.call(r);try{Yn.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function Bx(r){if(!Ws||!r||typeof r!="object")return!1;try{Ws.call(r,Ws);try{js.call(r,js)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function Fx(r){if(!Jd||!r||typeof r!="object")return!1;try{return Jd.call(r),!0}catch{}return!1}function kx(r){if(!Yn||!r||typeof r!="object")return!1;try{Yn.call(r);try{zn.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function Ux(r){if(!js||!r||typeof r!="object")return!1;try{js.call(r,js);try{Ws.call(r,Ws)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function Gx(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function mf(r,t){if(r.length>t.maxStringLength){var e=r.length-t.maxStringLength,i="... "+e+" more character"+(e>1?"s":"");return mf(_l.call(r,0,t.maxStringLength),t)+i}var s=Ax[t.quoteStyle||"single"];s.lastIndex=0;var n=ti.call(ti.call(r,s,"\\$1"),/[\x00-\x1f]/g,Hx);return cf(n,"single",t)}function Hx(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":"")+wx.call(t.toString(16))}function Ks(r){return"Object("+r+")"}function Tl(r){return r+" { ? }"}function gf(r,t,e,i){var s=i?Al(e,i):yr.call(e,", ");return r+" ("+t+") {"+s+"}"}function $x(r){for(var t=0;t<r.length;t++)if(pf(r[t],`
4
- `)>=0)return!1;return!0}function Xx(r,t){var e;if(r.indent===" ")e=" ";else if(typeof r.indent=="number"&&r.indent>0)e=yr.call(Array(r.indent+1)," ");else return null;return{base:e,prev:yr.call(Array(t+1),e)}}function Al(r,t){if(r.length===0)return"";var e=`
1
+ (function(te,xe){typeof exports=="object"&&typeof module<"u"?xe(exports,require("openseadragon")):typeof define=="function"&&define.amd?define(["exports","openseadragon"],xe):(te=typeof globalThis<"u"?globalThis:te||self,xe(te.AnnotoriousOSD={},te.OpenSeadragon))})(this,function(te,xe){"use strict";var vI=Object.defineProperty;var xI=(te,xe,fi)=>xe in te?vI(te,xe,{enumerable:!0,configurable:!0,writable:!0,value:fi}):te[xe]=fi;var Ht=(te,xe,fi)=>xI(te,typeof xe!="symbol"?xe+"":xe,fi);var fi=Object.prototype.hasOwnProperty;function pi(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--&&pi(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(fi.call(r,e)&&++i&&!fi.call(t,e)||!(e in t)||!pi(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}var sa=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(sa||{});const be=[];for(let r=0;r<256;++r)be.push((r+256).toString(16).slice(1));function Xg(r,t=0){return(be[r[t+0]]+be[r[t+1]]+be[r[t+2]]+be[r[t+3]]+"-"+be[r[t+4]]+be[r[t+5]]+"-"+be[r[t+6]]+be[r[t+7]]+"-"+be[r[t+8]]+be[r[t+9]]+"-"+be[r[t+10]]+be[r[t+11]]+be[r[t+12]]+be[r[t+13]]+be[r[t+14]]+be[r[t+15]]).toLowerCase()}let na;const Vg=new Uint8Array(16);function zg(){if(!na){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");na=crypto.getRandomValues.bind(crypto)}return na(Vg)}const Yg=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),pu={randomUUID:Yg};function jg(r,t,e){var i;if(pu.randomUUID&&!r)return pu.randomUUID();r=r||{};const s=r.random??((i=r.rng)==null?void 0:i.call(r))??zg();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,Xg(s)}const oa=r=>{const t=e=>{const i={...e};return e.created&&typeof e.created=="string"&&(i.created=new Date(e.created)),e.updated&&typeof e.updated=="string"&&(i.updated=new Date(e.updated)),i};return{...r,bodies:(r.bodies||[]).map(t),target:t(r.target)}},Wg=(r,t,e,i)=>({id:jg(),annotation:typeof r=="string"?r:r.id,created:e||new Date,creator:i,...t}),qg=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},Kg=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},Zg=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!pi(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),Qg=(r,t)=>!pi(r.target,t.target),Jg=(r,t)=>{const e=qg(r,t),i=Kg(r,t),s=Zg(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:Qg(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var Xr=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(Xr||{});const ty=(r,t)=>{const e=new Set((r.created||[]).map(c=>c.id)),i=new Set((r.updated||[]).map(({newValue:c})=>c.id)),s=new Set((t.created||[]).map(c=>c.id)),n=new Set((t.deleted||[]).map(c=>c.id)),o=new Set((t.updated||[]).map(({oldValue:c})=>c.id)),a=new Set((t.updated||[]).filter(({oldValue:c})=>e.has(c.id)||i.has(c.id)).map(({oldValue:c})=>c.id)),l=[...(r.created||[]).filter(c=>!n.has(c.id)).map(c=>o.has(c.id)?t.updated.find(({oldValue:d})=>d.id===c.id).newValue:c),...t.created||[]],h=[...(r.deleted||[]).filter(c=>!s.has(c.id)),...(t.deleted||[]).filter(c=>!e.has(c.id))],u=[...(r.updated||[]).filter(({newValue:c})=>!n.has(c.id)).map(c=>{const{oldValue:d,newValue:f}=c;if(o.has(f.id)){const p=t.updated.find(m=>m.oldValue.id===f.id).newValue;return Jg(d,p)}else return c}),...(t.updated||[]).filter(({oldValue:c})=>!a.has(c.id))];return{created:l,deleted:h,updated:u}};let ey=()=>({emit(r,...t){for(let e=this.events[r]||[],i=0,s=e.length;i<s;i++)e[i](...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 ry=250,iy=(r,t)=>{const e=ey(),i=(t==null?void 0:t.changes)||[];let s=t?t.pointer:-1,n=!1,o=0;const a=p=>{if(!n){const{changes:m}=p,_=performance.now();if(_-o>ry)i.splice(s+1),i.push(m),s=i.length-1;else{const y=i.length-1;i[y]=ty(i[y],m)}o=_}n=!1};r.observe(a,{origin:Xr.LOCAL});const l=p=>p&&p.length>0&&r.bulkDeleteAnnotations(p),h=p=>p&&p.length>0&&r.bulkAddAnnotations(p,!1),u=p=>p&&p.length>0&&r.bulkUpdateAnnotations(p.map(({oldValue:m})=>m)),c=p=>p&&p.length>0&&r.bulkUpdateAnnotations(p.map(({newValue:m})=>m)),d=p=>p&&p.length>0&&r.bulkAddAnnotations(p,!1),f=p=>p&&p.length>0&&r.bulkDeleteAnnotations(p);return{canRedo:()=>i.length-1>s,canUndo:()=>s>-1,destroy:()=>r.unobserve(a),getHistory:()=>({changes:[...i],pointer:s}),on:(p,m)=>e.on(p,m),redo:()=>{if(i.length-1>s){n=!0;const{created:p,updated:m,deleted:_}=i[s+1];h(p),c(m),f(_),e.emit("redo",i[s+1]),s+=1}},undo:()=>{if(s>-1){n=!0;const{created:p,updated:m,deleted:_}=i[s];l(p),u(m),d(_),e.emit("undo",i[s]),s-=1}}}},sy=(r,t,e,i)=>{const{hover:s,selection:n,store:o,viewport:a}=r,l=new Map;let h=[],u,c;const d=(y,v)=>{l.has(y)?l.get(y).push(v):l.set(y,[v])},f=(y,v)=>{const g=l.get(y);if(g){const x=g.indexOf(v);x!==-1&&g.splice(x,1)}},p=(y,v,g)=>{l.has(y)&&setTimeout(()=>{l.get(y).forEach(x=>{if(e){const T=Array.isArray(v)?v.map(S=>e.serialize(S)):e.serialize(v),M=g?g instanceof PointerEvent?g:e.serialize(g):void 0;x(T,M)}else x(v,g)})},1)},m=()=>{const{selected:y}=n,v=(y||[]).map(({id:g})=>o.getAnnotation(g));v.forEach(g=>{const x=h.find(T=>T.id===g.id);(!x||!pi(x,g))&&p("updateAnnotation",g,x)}),h=h.map(g=>v.find(({id:T})=>T===g.id)||g)};n.subscribe(({selected:y})=>{if(!(h.length===0&&y.length===0)){if(h.length===0&&y.length>0)h=y.map(({id:v})=>o.getAnnotation(v));else if(h.length>0&&y.length===0)h.forEach(v=>{const g=o.getAnnotation(v.id);g&&!pi(g,v)&&p("updateAnnotation",g,v)}),h=[];else{const v=new Set(h.map(x=>x.id)),g=new Set(y.map(({id:x})=>x));h.filter(x=>!g.has(x.id)).forEach(x=>{const T=o.getAnnotation(x.id);T&&!pi(T,x)&&p("updateAnnotation",T,x)}),h=[...h.filter(x=>g.has(x.id)),...y.filter(({id:x})=>!v.has(x)).map(({id:x})=>o.getAnnotation(x))]}p("selectionChanged",h)}}),s.subscribe(y=>{!u&&y?p("mouseEnterAnnotation",o.getAnnotation(y)):u&&!y?p("mouseLeaveAnnotation",o.getAnnotation(u)):u&&y&&(p("mouseLeaveAnnotation",o.getAnnotation(u)),p("mouseEnterAnnotation",o.getAnnotation(y))),u=y}),a==null||a.subscribe(y=>p("viewportIntersect",y.map(v=>o.getAnnotation(v)))),o.observe(y=>{i&&(c&&clearTimeout(c),c=setTimeout(m,1e3));const{created:v,deleted:g}=y.changes;(v||[]).forEach(x=>p("createAnnotation",x)),(g||[]).forEach(x=>p("deleteAnnotation",x)),(y.changes.updated||[]).filter(x=>[...x.bodiesCreated||[],...x.bodiesDeleted||[],...x.bodiesUpdated||[]].length>0).forEach(({oldValue:x,newValue:T})=>{const M=h.find(S=>S.id===x.id)||x;h=h.map(S=>S.id===x.id?T:S),p("updateAnnotation",T,M)})},{origin:Xr.LOCAL}),o.observe(y=>{if(h){const v=new Set(h.map(x=>x.id)),g=(y.changes.updated||[]).filter(({newValue:x})=>v.has(x.id)).map(({newValue:x})=>x);g.length>0&&(h=h.map(x=>g.find(M=>M.id===x.id)||x))}},{origin:Xr.REMOTE});const _=y=>v=>{const{updated:g}=v;y?(g||[]).forEach(x=>p("updateAnnotation",x.oldValue,x.newValue)):(g||[]).forEach(x=>p("updateAnnotation",x.newValue,x.oldValue))};return t.on("undo",_(!0)),t.on("redo",_(!1)),{on:d,off:f,emit:p}},ny=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:[]}),oy=(r,t,e)=>{const{store:i,selection:s}=r,n=y=>{if(e){const{parsed:v,error:g}=e.parse(y);v?i.addAnnotation(v,Xr.REMOTE):console.error(g)}else i.addAnnotation(oa(y),Xr.REMOTE)},o=()=>s.clear(),a=()=>i.clear(),l=y=>{const v=i.getAnnotation(y);return e&&v?e.serialize(v):v},h=()=>e?i.all().map(e.serialize):i.all(),u=()=>{var y;const v=(((y=s.selected)==null?void 0:y.map(g=>g.id))||[]).map(g=>i.getAnnotation(g)).filter(Boolean);return e?v.map(e.serialize):v},c=(y,v=!0)=>fetch(y).then(g=>g.json()).then(g=>(f(g,v),g)),d=y=>{if(typeof y=="string"){const v=i.getAnnotation(y);if(i.deleteAnnotation(y),v)return e?e.serialize(v):v}else{const v=e?e.parse(y).parsed:y;if(v)return i.deleteAnnotation(v),y}},f=(y,v=!0)=>{if(e){const g=e.parseAll||ny(e),{parsed:x,failed:T}=g(y);T.length>0&&console.warn(`Discarded ${T.length} invalid annotations`,T),i.bulkAddAnnotations(x,v,Xr.REMOTE)}else i.bulkAddAnnotations(y.map(oa),v,Xr.REMOTE)},p=(y,v)=>{y?s.setSelected(y,v):s.clear()},m=y=>{s.clear(),s.setUserSelectAction(y)},_=y=>{if(e){const v=e.parse(y).parsed,g=e.serialize(i.getAnnotation(v.id));return i.updateAnnotation(v),g}else{const v=i.getAnnotation(y.id);return i.updateAnnotation(oa(y)),v}};return{addAnnotation:n,cancelSelected:o,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getHistory:t.getHistory,getSelected:u,loadAnnotations:c,redo:t.redo,removeAnnotation:d,setAnnotations:f,setSelected:p,setUserSelectAction:m,undo:t.undo,updateAnnotation:_}},ay="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let ly=r=>crypto.getRandomValues(new Uint8Array(r)),hy=(r,t,e)=>{let i=(2<<Math.log2(r.length-1))-1,s=-~(1.6*i*t/r.length);return(n=t)=>{let o="";for(;;){let a=e(s),l=s|0;for(;l--;)if(o+=r[a[l]&i]||"",o.length>=n)return o}}},uy=(r,t=21)=>hy(r,t|0,ly),cy=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=ay[e[r]&63];return t};const dy=()=>({isGuest:!0,id:uy("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),fy=["#ff7c00","#1ac938","#e8000b","#8b2be2","#9f4800","#f14cc1","#ffc400","#00d7ff","#023eff"],py=()=>{const r=[...fy];return{assignRandomColor:()=>{const t=Math.floor(Math.random()*r.length),e=r[t];return r.splice(t,1),e},releaseColor:t=>r.push(t)}};cy();var my=Object.defineProperty,gy=(r,t,e)=>t in r?my(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xt=(r,t,e)=>gy(r,typeof t!="symbol"?t+"":t,e);function Pt(){}function aa(r,t){for(const e in t)r[e]=t[e];return r}function mu(r){return r()}function gu(){return Object.create(null)}function He(r){r.forEach(mu)}function Vt(r){return typeof r=="function"}function ne(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function yy(r){return Object.keys(r).length===0}function yu(r,...t){if(r==null){for(const i of t)i(void 0);return Pt}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function la(r,t,e){r.$$.on_destroy.push(yu(t,e))}function _y(r,t,e,i){if(r){const s=_u(r,t,e,i);return r[0](s)}}function _u(r,t,e,i){return r[1]&&i?aa(e.ctx.slice(),r[1](i(t))):e.ctx}function vy(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 xy(r,t,e,i,s,n){if(s){const o=_u(t,e,i,n);r.p(o,s)}}function by(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 vu(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function Tt(r,t){r.appendChild(t)}function it(r,t,e){r.insertBefore(t,e||null)}function rt(r){r.parentNode&&r.parentNode.removeChild(r)}function mi(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function K(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function xu(r){return document.createTextNode(r)}function De(){return xu(" ")}function Fe(){return xu("")}function Rt(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function b(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function Ey(r){return Array.from(r.childNodes)}function cr(r,t,e){r.classList.toggle(t,!!e)}function wy(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let Os;function Ns(r){Os=r}function bu(){if(!Os)throw new Error("Function called outside component initialization");return Os}function gi(r){bu().$$.on_mount.push(r)}function Vr(){const r=bu();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=wy(t,e,{cancelable:i});return s.slice().forEach(o=>{o.call(r,n)}),!n.defaultPrevented}return!0}}function Ce(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const Hi=[],Tn=[];let Xi=[];const Eu=[],wu=Promise.resolve();let ha=!1;function Tu(){ha||(ha=!0,wu.then(Su))}function Au(){return Tu(),wu}function ua(r){Xi.push(r)}const ca=new Set;let Vi=0;function Su(){if(Vi!==0)return;const r=Os;do{try{for(;Vi<Hi.length;){const t=Hi[Vi];Vi++,Ns(t),Ty(t.$$)}}catch(t){throw Hi.length=0,Vi=0,t}for(Ns(null),Hi.length=0,Vi=0;Tn.length;)Tn.pop()();for(let t=0;t<Xi.length;t+=1){const e=Xi[t];ca.has(e)||(ca.add(e),e())}Xi.length=0}while(Hi.length);for(;Eu.length;)Eu.pop()();ha=!1,ca.clear(),Ns(r)}function Ty(r){if(r.fragment!==null){r.update(),He(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(ua)}}function Ay(r){const t=[],e=[];Xi.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),Xi=t}const An=new Set;let yi;function Ie(){yi={r:0,c:[],p:yi}}function Re(){yi.r||He(yi.c),yi=yi.p}function at(r,t){r&&r.i&&(An.delete(r),r.i(t))}function gt(r,t,e,i){if(r&&r.o){if(An.has(r))return;An.add(r),yi.c.push(()=>{An.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function ke(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function fe(r){r&&r.c()}function he(r,t,e){const{fragment:i,after_update:s}=r.$$;i&&i.m(t,e),ua(()=>{const n=r.$$.on_mount.map(mu).filter(Vt);r.$$.on_destroy?r.$$.on_destroy.push(...n):He(n),r.$$.on_mount=[]}),s.forEach(ua)}function ue(r,t){const e=r.$$;e.fragment!==null&&(Ay(e.after_update),He(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function Sy(r,t){r.$$.dirty[0]===-1&&(Hi.push(r),Tu(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function Me(r,t,e,i,s,n,o=null,a=[-1]){const l=Os;Ns(r);const h=r.$$={fragment:null,ctx:[],props:n,update:Pt,not_equal:s,bound:gu(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:gu(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let u=!1;if(h.ctx=e?e(r,t.props||{},(c,d,...f)=>{const p=f.length?f[0]:d;return h.ctx&&s(h.ctx[c],h.ctx[c]=p)&&(!h.skip_bound&&h.bound[c]&&h.bound[c](p),u&&Sy(r,c)),d}):[],h.update(),u=!0,He(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const c=Ey(t.target);h.fragment&&h.fragment.l(c),c.forEach(rt)}else h.fragment&&h.fragment.c();t.intro&&at(r.$$.fragment),he(r,t.target,t.anchor),Su()}Ns(l)}class Pe{constructor(){Xt(this,"$$"),Xt(this,"$$set")}$destroy(){ue(this,1),this.$destroy=Pt}$on(t,e){if(!Vt(e))return Pt;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&&!yy(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const Cy="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Cy);var xt=(r=>(r.ELLIPSE="ELLIPSE",r.MULTIPOLYGON="MULTIPOLYGON",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r.LINE="LINE",r))(xt||{}),Iy={exports:{}};(function(r){(function(){function t(a,l){var h=a.x-l.x,u=a.y-l.y;return h*h+u*u}function e(a,l,h){var u=l.x,c=l.y,d=h.x-u,f=h.y-c;if(d!==0||f!==0){var p=((a.x-u)*d+(a.y-c)*f)/(d*d+f*f);p>1?(u=h.x,c=h.y):p>0&&(u+=d*p,c+=f*p)}return d=a.x-u,f=a.y-c,d*d+f*f}function i(a,l){for(var h=a[0],u=[h],c,d=1,f=a.length;d<f;d++)c=a[d],t(c,h)>l&&(u.push(c),h=c);return h!==c&&u.push(c),u}function s(a,l,h,u,c){for(var d=u,f,p=l+1;p<h;p++){var m=e(a[p],a[l],a[h]);m>d&&(f=p,d=m)}d>u&&(f-l>1&&s(a,l,f,u,c),c.push(a[f]),h-f>1&&s(a,f,h,u,c))}function n(a,l){var h=a.length-1,u=[a[0]];return s(a,0,h,l,u),u.push(a[h]),u}function o(a,l,h){if(a.length<=2)return a;var u=l!==void 0?l*l:1;return a=h?a:i(a,u),a=n(a,u),a}r.exports=o,r.exports.default=o})()})(Iy);const da={},Ds=(r,t)=>da[r]=t,fa=r=>da[r.type].area(r),Ry=(r,t,e,i)=>da[r.type].intersects(r,t,e,i),Ue=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}},pa=r=>{let t=0,e=r.length-1;for(let i=0;i<r.length;i++)t+=(r[e][0]+r[i][0])*(r[e][1]-r[i][1]),e=i;return Math.abs(.5*t)},ma=(r,t,e)=>{let i=!1;for(let s=0,n=r.length-1;s<r.length;n=s++){const o=r[s][0],a=r[s][1],l=r[n][0],h=r[n][1];a>e!=h>e&&t<(l-o)*(e-a)/(h-a)+o&&(i=!i)}return i},My=(r,t=!0)=>{let e="M ";return r.forEach(([i,s],n)=>{n===0?e+=`${i},${s}`:e+=` L ${i},${s}`}),t&&(e+=" Z"),e},Sn=(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))},Py={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),u=t-i,c=e-s,d=l*u+h*c,f=h*u-l*c;return d*d/(n*n)+f*f/(o*o)<=1}};Ds(xt.ELLIPSE,Py);const Oy={area:r=>0,intersects:(r,t,e,i=2)=>{const[[s,n],[o,a]]=r.geometry.points,l=Math.abs((a-n)*t-(o-s)*e+o*n-a*s),h=Sn([s,n],[o,a]);return l/h<=i}};Ds(xt.LINE,Oy);const Ny={area:r=>{const{polygons:t}=r.geometry;return t.reduce((e,i)=>{const[s,...n]=i.rings,o=pa(s.points),a=n.reduce((l,h)=>l+pa(h.points),0);return e+o-a},0)},intersects:(r,t,e)=>{const{polygons:i}=r.geometry;for(const s of i){const[n,...o]=s.rings;if(ma(n.points,t,e)){let a=!1;for(const l of o)if(ma(l.points,t,e)){a=!0;break}if(!a)return!0}}return!1}},ga=r=>{const t=r.reduce((e,i)=>[...e,...i.rings[0].points],[]);return Ue(t)},Ze=r=>r.rings.map(t=>My(t.points)).join(" "),Dy=r=>r.polygons.reduce((t,e)=>[...t,...e.rings.reduce((i,s)=>[...i,...s.points],[])],[]);Ds(xt.MULTIPOLYGON,Ny);const Ly={area:r=>{const t=r.geometry.points;return pa(t)},intersects:(r,t,e)=>{const i=r.geometry.points;return ma(i,t,e)}};Ds(xt.POLYGON,Ly);const By={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};Ds(xt.RECTANGLE,By);const ze=r=>Cn(r.target),Cn=r=>{var t,e;return(r==null?void 0:r.annotation)!==void 0&&((e=(t=r==null?void 0:r.selector)==null?void 0:t.geometry)==null?void 0:e.bounds)!==void 0},Fy=(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,u,c]=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,u,c].map(parseFloat);return{type:xt.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}}}},ky=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}`}},Cu="http://www.w3.org/2000/svg",Iu=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},Uy=r=>{const t=new XMLSerializer().serializeToString(r.documentElement).replace("<svg>",`<svg xmlns="${Cu}">`);return new DOMParser().parseFromString(t,"image/svg+xml").documentElement},ya=r=>{const t=new DOMParser().parseFromString(r,"image/svg+xml"),e=t.lookupPrefix(Cu),i=t.lookupNamespaceURI(null);return e||i?Iu(t).firstChild:Iu(Uy(t)).firstChild},oe=" ";function Gy(r){let t="";Array.isArray(r)||(r=[r]);for(let e=0;e<r.length;e++){const i=r[e];if(i.type===G.CLOSE_PATH)t+="z";else if(i.type===G.HORIZ_LINE_TO)t+=(i.relative?"h":"H")+i.x;else if(i.type===G.VERT_LINE_TO)t+=(i.relative?"v":"V")+i.y;else if(i.type===G.MOVE_TO)t+=(i.relative?"m":"M")+i.x+oe+i.y;else if(i.type===G.LINE_TO)t+=(i.relative?"l":"L")+i.x+oe+i.y;else if(i.type===G.CURVE_TO)t+=(i.relative?"c":"C")+i.x1+oe+i.y1+oe+i.x2+oe+i.y2+oe+i.x+oe+i.y;else if(i.type===G.SMOOTH_CURVE_TO)t+=(i.relative?"s":"S")+i.x2+oe+i.y2+oe+i.x+oe+i.y;else if(i.type===G.QUAD_TO)t+=(i.relative?"q":"Q")+i.x1+oe+i.y1+oe+i.x+oe+i.y;else if(i.type===G.SMOOTH_QUAD_TO)t+=(i.relative?"t":"T")+i.x+oe+i.y;else if(i.type===G.ARC)t+=(i.relative?"a":"A")+i.rX+oe+i.rY+oe+i.xRot+oe+ +i.lArcFlag+oe+ +i.sweepFlag+oe+i.x+oe+i.y;else throw new Error(`Unexpected command type "${i==null?void 0:i.type}" at index ${e}.`)}return t}function _a([r,t],e){return[r*Math.cos(e)-t*Math.sin(e),r*Math.sin(e)+t*Math.cos(e)]}function Qe(...r){for(let t=0;t<r.length;t++)if(typeof r[t]!="number")throw new Error(`assertNumbers arguments[${t}] is not a number. ${typeof r[t]} == typeof ${r[t]}`);return!0}const zr=Math.PI;function va(r,t,e){r.lArcFlag=r.lArcFlag===0?0:1,r.sweepFlag=r.sweepFlag===0?0:1;let{rX:i,rY:s}=r;const{x:n,y:o}=r;if(Math.abs(i)<1e-10||Math.abs(s)<1e-10){r.rX=0,r.rY=0,r.cX=(t+n)/2,r.cY=(e+o)/2,r.phi1=0,r.phi2=0;return}i=Math.abs(r.rX),s=Math.abs(r.rY);const a=r.xRot/180*zr,[l,h]=_a([(t-n)/2,(e-o)/2],-a),u=Math.pow(l,2)/Math.pow(i,2)+Math.pow(h,2)/Math.pow(s,2);1<u&&(i*=Math.sqrt(u),s*=Math.sqrt(u)),r.rX=i,r.rY=s;const c=Math.pow(i,2)*Math.pow(h,2)+Math.pow(s,2)*Math.pow(l,2),d=(r.lArcFlag!==r.sweepFlag?1:-1)*Math.sqrt(Math.max(0,(Math.pow(i,2)*Math.pow(s,2)-c)/c)),f=i*h/s*d,p=-s*l/i*d,m=_a([f,p],a);r.cX=m[0]+(t+n)/2,r.cY=m[1]+(e+o)/2,r.phi1=Math.atan2((h-p)/s,(l-f)/i),r.phi2=Math.atan2((-h-p)/s,(-l-f)/i),r.sweepFlag===0&&r.phi2>r.phi1&&(r.phi2-=2*zr),r.sweepFlag===1&&r.phi2<r.phi1&&(r.phi2+=2*zr),r.phi1*=180/zr,r.phi2*=180/zr}function Ru(r,t,e){Qe(r,t,e);const i=r*r+t*t-e*e;if(0>i)return[];if(i===0)return[[r*e/(r*r+t*t),t*e/(r*r+t*t)]];const s=Math.sqrt(i);return[[(r*e+t*s)/(r*r+t*t),(t*e-r*s)/(r*r+t*t)],[(r*e-t*s)/(r*r+t*t),(t*e+r*s)/(r*r+t*t)]]}const _i=Math.PI/180;function Mu(r,t,e){return(1-e)*r+e*t}function Pu(r,t,e,i){return r+Math.cos(i/180*zr)*t+Math.sin(i/180*zr)*e}function Ou(r,t,e,i){const s=t-r,n=e-t,o=i-e,a=3*s+3*o-6*n,l=(n-s)*6,h=3*s;return Math.abs(a)<1e-6?Math.abs(l)<1e-6?[]:[-h/l]:$y(l/a,h/a,1e-6)}function Nu(r,t,e,i,s){const n=1-s,o=n*n*n,a=3*n*n*s,l=3*n*s*s,h=s*s*s;return r*o+t*a+e*l+i*h}function $y(r,t,e=1e-6){const i=r*r/4-t;if(i<-e)return[];if(i<=e)return[-r/2];const s=Math.sqrt(i);return[-(r/2)-s,-(r/2)+s]}function Hy(r,t,e){r.cX||va(r,t,e);const i=r.xRot/180*zr;if(Math.abs(r.rX)<1e-10||Math.abs(r.rY)<1e-10)return[{relative:r.relative,type:G.CURVE_TO,x1:t+(r.x-t)/3,y1:e+(r.y-e)/3,x2:t+2*(r.x-t)/3,y2:e+2*(r.y-e)/3,x:r.x,y:r.y}];const s=Math.min(r.phi1,r.phi2),n=Math.max(r.phi1,r.phi2),o=n-s,a=Math.ceil(o/90),l=new Array(a);let h=t,u=e;const c=(d,f)=>{const[p,m]=_a([d*r.rX,f*r.rY],i);return[r.cX+p,r.cY+m]};for(let d=0;d<a;d++){const f=Mu(r.phi1,r.phi2,d/a),p=Mu(r.phi1,r.phi2,(d+1)/a),m=p-f,_=4/3*Math.tan(m*_i/4),y=Math.cos(f*_i)-_*Math.sin(f*_i),v=Math.sin(f*_i)+_*Math.cos(f*_i),g=Math.cos(p*_i),x=Math.sin(p*_i),T=g+_*x,M=x-_*g,S=c(y,v),R=c(T,M),P=c(g,x),F={relative:r.relative,type:G.CURVE_TO,x:P[0],y:P[1],x1:S[0],y1:S[1],x2:R[0],y2:R[1]};r.relative&&(F.x1-=h,F.y1-=u,F.x2-=h,F.y2-=u,F.x-=h,F.y-=u),h=P[0],u=P[1],l[d]=F}return l}function In(r,t,e){const i=t[0]-r[0],s=t[1]-r[1],n=e[0]-r[0],o=e[1]-r[1],a=i*o-s*n;if(!(Math.abs(a)<1e-10))return!1;const l=i*n+s*o,h=i*i+s*s,u=n*n+o*o;return 0<=l&&l<=u&&h<=u}function Xy(r){if(r.length<=2)return r;const t=[],e=r.map(Zt.INFO((s,n,o)=>{const a="relative"in s&&s.relative;return["x"in s?s.x+(a?n:0):n,"y"in s?s.y+(a?o:0):o]}));let i=e[0];t.push(r[0]);for(let s=1;s<r.length;s++){const n=r[s],o=r[s+1];if(s<r.length-1&&o&&n.type&G.LINE_COMMANDS&&o.type&G.LINE_COMMANDS){const a=e[s+1];if(In(i,e[s],a)){"relative"in o&&o.relative&&("x"in o&&(o.x=a[0]-i[0]),"y"in o&&(o.y=a[1]-i[1]));continue}}t.push(n),i=e[s]}return t}function Vy(r,t=!0){if(r.length<2)return r;const e=Zt.INFO((n,o,a)=>({...n,x:n.x??o,y:n.y??a,relative:n.relative??!1})),i=[];let s=[];for(const n of r){const o=e(n);o.type===G.MOVE_TO&&s.length>0&&(t?i.push(...Rn(s)):i.unshift(...Rn(s)),s=[]),s.push(o)}return s.length>0&&(t?i.push(...Rn(s)):i.unshift(...Rn(s))),i}function Rn(r){var t;const e=((t=r[r.length-1])==null?void 0:t.type)===G.CLOSE_PATH,i=e?r.length-2:r.length-1,s=[{type:G.MOVE_TO,relative:!1,x:r[i].x,y:r[i].y}];for(let n=i;n>0;n--){const o=r[n],a=r[n-1];if(o.relative)throw new Error("Relative command are not supported convert first with `toAbs()`");switch(o.type){case G.HORIZ_LINE_TO:s.push({type:G.HORIZ_LINE_TO,relative:!1,x:a.x});break;case G.VERT_LINE_TO:s.push({type:G.VERT_LINE_TO,relative:!1,y:a.y});break;case G.LINE_TO:case G.MOVE_TO:s.push({type:G.LINE_TO,relative:!1,x:a.x,y:a.y});break;case G.CURVE_TO:s.push({type:G.CURVE_TO,relative:!1,x:a.x,y:a.y,x1:o.x2,y1:o.y2,x2:o.x1,y2:o.y1});break;case G.SMOOTH_CURVE_TO:throw new Error("Unsupported command: S (smooth cubic bezier)");case G.SMOOTH_QUAD_TO:throw new Error("Unsupported command: T (smooth quadratic bezier)");case G.ARC:throw new Error("Unsupported command: A (arc)");case G.QUAD_TO:throw new Error("Unsupported command: Q (quadratic bezier)")}}return e&&s.push({type:G.CLOSE_PATH}),s}function zy(r=1e13){Qe(r);function t(e){return Math.round(e*r)/r}return function(e){return"x1"in e&&typeof e.x1<"u"&&(e.x1=t(e.x1)),"y1"in e&&typeof e.y1<"u"&&(e.y1=t(e.y1)),"x2"in e&&typeof e.x2<"u"&&(e.x2=t(e.x2)),"y2"in e&&typeof e.y2<"u"&&(e.y2=t(e.y2)),"x"in e&&typeof e.x<"u"&&(e.x=t(e.x)),"y"in e&&typeof e.y<"u"&&(e.y=t(e.y)),"rX"in e&&typeof e.rX<"u"&&(e.rX=t(e.rX)),"rY"in e&&typeof e.rY<"u"&&(e.rY=t(e.rY)),e}}function Du(){return Je((r,t,e)=>(r.relative&&(typeof r.x1<"u"&&(r.x1+=t),typeof r.y1<"u"&&(r.y1+=e),typeof r.x2<"u"&&(r.x2+=t),typeof r.y2<"u"&&(r.y2+=e),typeof r.x<"u"&&(r.x+=t),typeof r.y<"u"&&(r.y+=e),r.relative=!1),r))}function Yy(){return Je((r,t,e)=>(r.relative||(typeof r.x1<"u"&&(r.x1-=t),typeof r.y1<"u"&&(r.y1-=e),typeof r.x2<"u"&&(r.x2-=t),typeof r.y2<"u"&&(r.y2-=e),typeof r.x<"u"&&(r.x-=t),typeof r.y<"u"&&(r.y-=e),r.relative=!0),r))}function jy(r=!0,t=!0,e=!0,i=!0){return Je((s,n,o,a,l)=>{if(isNaN(a)&&!(s.type&G.MOVE_TO))throw new Error("path must start with moveto");if(t&&s.type&G.HORIZ_LINE_TO&&(s.type=G.LINE_TO,s.y=s.relative?0:o),e&&s.type&G.VERT_LINE_TO&&(s.type=G.LINE_TO,s.x=s.relative?0:n),r&&s.type&G.CLOSE_PATH&&(s.type=G.LINE_TO,s.x=s.relative?a-n:a,s.y=s.relative?l-o:l),s.type&G.ARC&&(s.rX===0||s.rY===0)&&(s.type=G.LINE_TO,delete s.rX,delete s.rY,delete s.xRot,delete s.lArcFlag,delete s.sweepFlag),i&&s.type&G.QUAD_TO){const h=[n,o],u=s.relative?[n+s.x1,o+s.y1]:[s.x1,s.y1],c=s.relative?[n+s.x,o+s.y]:[s.x,s.y];In(h,u,c)&&(s.type=G.LINE_TO,delete s.x1,delete s.y1)}if(i&&s.type&G.CURVE_TO){const h=[n,o],u=s.relative?[n+s.x1,o+s.y1]:[s.x1,s.y1],c=s.relative?[n+s.x2,o+s.y2]:[s.x2,s.y2],d=s.relative?[n+s.x,o+s.y]:[s.x,s.y];In(h,u,d)&&In(h,c,d)&&(s.type=G.LINE_TO,delete s.x1,delete s.y1,delete s.x2,delete s.y2)}return s})}function Lu(){let r=NaN,t=NaN,e=NaN,i=NaN;return Je((s,n,o)=>(s.type&G.SMOOTH_CURVE_TO&&(s.type=G.CURVE_TO,r=isNaN(r)?n:r,t=isNaN(t)?o:t,s.x1=s.relative?n-r:2*n-r,s.y1=s.relative?o-t:2*o-t),s.type&G.CURVE_TO?(r=s.relative?n+s.x2:s.x2,t=s.relative?o+s.y2:s.y2):(r=NaN,t=NaN),s.type&G.SMOOTH_QUAD_TO&&(s.type=G.QUAD_TO,e=isNaN(e)?n:e,i=isNaN(i)?o:i,s.x1=s.relative?n-e:2*n-e,s.y1=s.relative?o-i:2*o-i),s.type&G.QUAD_TO?(e=s.relative?n+s.x1:s.x1,i=s.relative?o+s.y1:s.y1):(e=NaN,i=NaN),s))}function Bu(){let r=NaN,t=NaN;return Je((e,i,s)=>{if(e.type&G.SMOOTH_QUAD_TO&&(e.type=G.QUAD_TO,r=isNaN(r)?i:r,t=isNaN(t)?s:t,e.x1=e.relative?i-r:2*i-r,e.y1=e.relative?s-t:2*s-t),e.type&G.QUAD_TO){r=e.relative?i+e.x1:e.x1,t=e.relative?s+e.y1:e.y1;const n=e.x1,o=e.y1;e.type=G.CURVE_TO,e.x1=((e.relative?0:i)+n*2)/3,e.y1=((e.relative?0:s)+o*2)/3,e.x2=(e.x+n*2)/3,e.y2=(e.y+o*2)/3}else r=NaN,t=NaN;return e})}function Je(r){let t=0,e=0,i=NaN,s=NaN;return function(n){if(isNaN(i)&&!(n.type&G.MOVE_TO))throw new Error("path must start with moveto");const o=r(n,t,e,i,s);return n.type&G.CLOSE_PATH&&(t=i,e=s),"x"in n&&typeof n.x<"u"&&(t=n.relative?t+n.x:n.x),"y"in n&&typeof n.y<"u"&&(e=n.relative?e+n.y:n.y),n.type&G.MOVE_TO&&(i=t,s=e),o}}function Wy(r=0){Qe(r);let t=NaN,e=NaN,i=NaN,s=NaN;return Je((n,o,a,l,h)=>{const u=Math.abs;let c=!1,d=0,f=0;if(n.type&G.SMOOTH_CURVE_TO&&(d=isNaN(t)?0:o-t,f=isNaN(e)?0:a-e),n.type&(G.CURVE_TO|G.SMOOTH_CURVE_TO)?(t=n.relative?o+n.x2:n.x2,e=n.relative?a+n.y2:n.y2):(t=NaN,e=NaN),n.type&G.SMOOTH_QUAD_TO?(i=isNaN(i)?o:2*o-i,s=isNaN(s)?a:2*a-s):n.type&G.QUAD_TO?(i=n.relative?o+n.x1:n.x1,s=n.relative?a+n.y1:n.y2):(i=NaN,s=NaN),n.type&G.LINE_COMMANDS||n.type&G.ARC&&(n.rX===0||n.rY===0||!n.lArcFlag)||n.type&G.CURVE_TO||n.type&G.SMOOTH_CURVE_TO||n.type&G.QUAD_TO||n.type&G.SMOOTH_QUAD_TO){const p=typeof n.x>"u"?0:n.relative?n.x:n.x-o,m=typeof n.y>"u"?0:n.relative?n.y:n.y-a;d=isNaN(i)?typeof n.x1>"u"?d:n.relative?n.x:n.x1-o:i-o,f=isNaN(s)?typeof n.y1>"u"?f:n.relative?n.y:n.y1-a:s-a;const _=typeof n.x2>"u"?0:n.relative?n.x:n.x2-o,y=typeof n.y2>"u"?0:n.relative?n.y:n.y2-a;u(p)<=r&&u(m)<=r&&u(d)<=r&&u(f)<=r&&u(_)<=r&&u(y)<=r&&(c=!0)}return n.type&G.CLOSE_PATH&&u(o-l)<=r&&u(a-h)<=r&&(c=!0),c?[]:n})}function Yr(r,t,e,i,s,n){return Qe(r,t,e,i,s,n),Je((o,a,l,h)=>{const u=o.x1,c=o.x2,d=o.relative&&!isNaN(h),f=typeof o.x<"u"?o.x:d?0:a,p=typeof o.y<"u"?o.y:d?0:l;o.type&G.HORIZ_LINE_TO&&t!==0&&(o.type=G.LINE_TO,o.y=o.relative?0:l),o.type&G.VERT_LINE_TO&&e!==0&&(o.type=G.LINE_TO,o.x=o.relative?0:a),typeof o.x<"u"&&(o.x=o.x*r+p*e+(d?0:s)),typeof o.y<"u"&&(o.y=f*t+o.y*i+(d?0:n)),typeof o.x1<"u"&&(o.x1=o.x1*r+o.y1*e+(d?0:s)),typeof o.y1<"u"&&(o.y1=u*t+o.y1*i+(d?0:n)),typeof o.x2<"u"&&(o.x2=o.x2*r+o.y2*e+(d?0:s)),typeof o.y2<"u"&&(o.y2=c*t+o.y2*i+(d?0:n));function m(y){return y*y}const _=r*i-t*e;if(typeof o.xRot<"u"&&(r!==1||t!==0||e!==0||i!==1))if(_===0)delete o.rX,delete o.rY,delete o.xRot,delete o.lArcFlag,delete o.sweepFlag,o.type=G.LINE_TO;else{const y=o.xRot*Math.PI/180,v=Math.sin(y),g=Math.cos(y),x=1/m(o.rX),T=1/m(o.rY),M=m(g)*x+m(v)*T,S=2*v*g*(x-T),R=m(v)*x+m(g)*T,P=M*i*i-S*t*i+R*t*t,F=S*(r*i+t*e)-2*(M*e*i+R*r*t),U=M*e*e-S*r*e+R*r*r,I=(Math.atan2(F,P-U)+Math.PI)%Math.PI/2,A=Math.sin(I),w=Math.cos(I);o.rX=Math.abs(_)/Math.sqrt(P*m(w)+F*A*w+U*m(A)),o.rY=Math.abs(_)/Math.sqrt(P*m(A)-F*A*w+U*m(w)),o.xRot=I*180/Math.PI}return typeof o.sweepFlag<"u"&&0>_&&(o.sweepFlag=+!o.sweepFlag),o})}function qy(r,t=0,e=0){Qe(r,t,e);const i=Math.sin(r),s=Math.cos(r);return Yr(s,i,-i,s,t-t*s+e*i,e-t*i-e*s)}function Ky(r,t=0){return Qe(r,t),Yr(1,0,0,1,r,t)}function Zy(r,t=r){return Qe(r,t),Yr(r,0,0,t,0,0)}function Qy(r){return Qe(r),Yr(1,0,Math.tan(r),1,0,0)}function Jy(r){return Qe(r),Yr(1,Math.tan(r),0,1,0,0)}function t_(r=0){return Qe(r),Yr(-1,0,0,1,r,0)}function e_(r=0){return Qe(r),Yr(1,0,0,-1,0,r)}function r_(){return Je((r,t,e)=>G.ARC===r.type?Hy(r,r.relative?0:t,r.relative?0:e):r)}function i_(){return Je((r,t,e)=>(r.relative&&(t=0,e=0),G.ARC===r.type&&va(r,t,e),r))}function Fu(){return r=>({...r})}function s_(){const r=Fu(),t=Du(),e=Bu(),i=Lu(),s=Je((n,o,a)=>{const l=i(e(t(r(n))));function h(c){c>s.maxX&&(s.maxX=c),c<s.minX&&(s.minX=c)}function u(c){c>s.maxY&&(s.maxY=c),c<s.minY&&(s.minY=c)}if(l.type&G.DRAWING_COMMANDS&&(h(o),u(a)),l.type&G.HORIZ_LINE_TO&&h(l.x),l.type&G.VERT_LINE_TO&&u(l.y),l.type&G.LINE_TO&&(h(l.x),u(l.y)),l.type&G.CURVE_TO){h(l.x),u(l.y);const c=Ou(o,l.x1,l.x2,l.x);for(const f of c)0<f&&1>f&&h(Nu(o,l.x1,l.x2,l.x,f));const d=Ou(a,l.y1,l.y2,l.y);for(const f of d)0<f&&1>f&&u(Nu(a,l.y1,l.y2,l.y,f))}if(l.type&G.ARC){h(l.x),u(l.y),va(l,o,a);const c=l.xRot/180*Math.PI,d=Math.cos(c)*l.rX,f=Math.sin(c)*l.rX,p=-Math.sin(c)*l.rY,m=Math.cos(c)*l.rY,[_,y]=l.phi1<l.phi2?[l.phi1,l.phi2]:-180>l.phi2?[l.phi2+360,l.phi1+360]:[l.phi2,l.phi1],v=([T,M])=>{const S=Math.atan2(M,T)*180/Math.PI;return S<_?S+360:S},g=Ru(p,-d,0).map(v);for(const T of g)T>_&&T<y&&h(Pu(l.cX,d,p,T));const x=Ru(m,-f,0).map(v);for(const T of x)T>_&&T<y&&u(Pu(l.cY,f,m,T))}return n});return s.minX=1/0,s.maxX=-1/0,s.minY=1/0,s.maxY=-1/0,s}const Zt={ROUND:zy,TO_ABS:Du,TO_REL:Yy,NORMALIZE_HVZ:jy,NORMALIZE_ST:Lu,QT_TO_C:Bu,INFO:Je,SANITIZE:Wy,MATRIX:Yr,ROTATE:qy,TRANSLATE:Ky,SCALE:Zy,SKEW_X:Qy,SKEW_Y:Jy,X_AXIS_SYMMETRY:t_,Y_AXIS_SYMMETRY:e_,A_TO_C:r_,ANNOTATE_ARCS:i_,CLONE:Fu,CALCULATE_BOUNDS:s_,REVERSE_PATH:Vy,REMOVE_COLLINEAR:Xy};class ku{round(t){return this.transform(Zt.ROUND(t))}toAbs(){return this.transform(Zt.TO_ABS())}toRel(){return this.transform(Zt.TO_REL())}normalizeHVZ(t,e,i){return this.transform(Zt.NORMALIZE_HVZ(t,e,i))}normalizeST(){return this.transform(Zt.NORMALIZE_ST())}qtToC(){return this.transform(Zt.QT_TO_C())}aToC(){return this.transform(Zt.A_TO_C())}sanitize(t){return this.transform(Zt.SANITIZE(t))}translate(t,e){return this.transform(Zt.TRANSLATE(t,e))}scale(t,e){return this.transform(Zt.SCALE(t,e))}rotate(t,e,i){return this.transform(Zt.ROTATE(t,e,i))}matrix(t,e,i,s,n,o){return this.transform(Zt.MATRIX(t,e,i,s,n,o))}skewX(t){return this.transform(Zt.SKEW_X(t))}skewY(t){return this.transform(Zt.SKEW_Y(t))}xSymmetry(t){return this.transform(Zt.X_AXIS_SYMMETRY(t))}ySymmetry(t){return this.transform(Zt.Y_AXIS_SYMMETRY(t))}annotateArcs(){return this.transform(Zt.ANNOTATE_ARCS())}}const n_=r=>r===" "||r===" "||r==="\r"||r===`
2
+ `,Uu=r=>48<=r.charCodeAt(0)&&r.charCodeAt(0)<=57;class o_ extends ku{constructor(){super(),Xt(this,"curNumber",""),Xt(this,"curCommandType",-1),Xt(this,"curCommandRelative",!1),Xt(this,"canParseCommandOrComma",!0),Xt(this,"curNumberHasExp",!1),Xt(this,"curNumberHasExpDigits",!1),Xt(this,"curNumberHasDecimal",!1),Xt(this,"curArgs",[])}finish(t=[]){if(this.parse(" ",t),this.curArgs.length!==0||!this.canParseCommandOrComma)throw new SyntaxError("Unterminated command at the path end.");return t}parse(t,e=[]){const i=s=>{e.push(s),this.curArgs.length=0,this.canParseCommandOrComma=!0};for(let s=0;s<t.length;s++){const n=t[s],o=this.curCommandType===G.ARC&&(this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber.length===1&&(this.curNumber==="0"||this.curNumber==="1"),a=Uu(n)&&(this.curNumber==="0"&&n==="0"||o);if(Uu(n)&&!a){this.curNumber+=n,this.curNumberHasExpDigits=this.curNumberHasExp;continue}if(n==="e"||n==="E"){this.curNumber+=n,this.curNumberHasExp=!0;continue}if((n==="-"||n==="+")&&this.curNumberHasExp&&!this.curNumberHasExpDigits){this.curNumber+=n;continue}if(n==="."&&!this.curNumberHasExp&&!this.curNumberHasDecimal&&!o){this.curNumber+=n,this.curNumberHasDecimal=!0;continue}if(this.curNumber&&this.curCommandType!==-1){const l=Number(this.curNumber);if(isNaN(l))throw new SyntaxError(`Invalid number ending at ${s}`);if(this.curCommandType===G.ARC){if(this.curArgs.length===0||this.curArgs.length===1){if(0>l)throw new SyntaxError(`Expected positive number, got "${l}" at index "${s}"`)}else if((this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber!=="0"&&this.curNumber!=="1")throw new SyntaxError(`Expected a flag, got "${this.curNumber}" at index "${s}"`)}this.curArgs.push(l),this.curArgs.length===a_[this.curCommandType]&&(G.HORIZ_LINE_TO===this.curCommandType?i({type:G.HORIZ_LINE_TO,relative:this.curCommandRelative,x:l}):G.VERT_LINE_TO===this.curCommandType?i({type:G.VERT_LINE_TO,relative:this.curCommandRelative,y:l}):this.curCommandType===G.MOVE_TO||this.curCommandType===G.LINE_TO||this.curCommandType===G.SMOOTH_QUAD_TO?(i({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),G.MOVE_TO===this.curCommandType&&(this.curCommandType=G.LINE_TO)):this.curCommandType===G.CURVE_TO?i({type:G.CURVE_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x2:this.curArgs[2],y2:this.curArgs[3],x:this.curArgs[4],y:this.curArgs[5]}):this.curCommandType===G.SMOOTH_CURVE_TO?i({type:G.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===G.QUAD_TO?i({type:G.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===G.ARC&&i({type:G.ARC,relative:this.curCommandRelative,rX:this.curArgs[0],rY:this.curArgs[1],xRot:this.curArgs[2],lArcFlag:this.curArgs[3],sweepFlag:this.curArgs[4],x:this.curArgs[5],y:this.curArgs[6]})),this.curNumber="",this.curNumberHasExpDigits=!1,this.curNumberHasExp=!1,this.curNumberHasDecimal=!1,this.canParseCommandOrComma=!0}if(!n_(n)){if(n===","&&this.canParseCommandOrComma){this.canParseCommandOrComma=!1;continue}if(n==="+"||n==="-"||n==="."){this.curNumber=n,this.curNumberHasDecimal=n===".";continue}if(a){this.curNumber=n,this.curNumberHasDecimal=!1;continue}if(this.curArgs.length!==0)throw new SyntaxError(`Unterminated command at index ${s}.`);if(!this.canParseCommandOrComma)throw new SyntaxError(`Unexpected character "${n}" at index ${s}. Command cannot follow comma`);if(this.canParseCommandOrComma=!1,n==="z"||n==="Z"){e.push({type:G.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1;continue}else if(n==="h"||n==="H")this.curCommandType=G.HORIZ_LINE_TO,this.curCommandRelative=n==="h";else if(n==="v"||n==="V")this.curCommandType=G.VERT_LINE_TO,this.curCommandRelative=n==="v";else if(n==="m"||n==="M")this.curCommandType=G.MOVE_TO,this.curCommandRelative=n==="m";else if(n==="l"||n==="L")this.curCommandType=G.LINE_TO,this.curCommandRelative=n==="l";else if(n==="c"||n==="C")this.curCommandType=G.CURVE_TO,this.curCommandRelative=n==="c";else if(n==="s"||n==="S")this.curCommandType=G.SMOOTH_CURVE_TO,this.curCommandRelative=n==="s";else if(n==="q"||n==="Q")this.curCommandType=G.QUAD_TO,this.curCommandRelative=n==="q";else if(n==="t"||n==="T")this.curCommandType=G.SMOOTH_QUAD_TO,this.curCommandRelative=n==="t";else if(n==="a"||n==="A")this.curCommandType=G.ARC,this.curCommandRelative=n==="a";else throw new SyntaxError(`Unexpected character "${n}" at index ${s}.`)}}return e}transform(t){return Object.create(this,{parse:{value(e,i=[]){const s=Object.getPrototypeOf(this).parse.call(this,e);for(const n of s){const o=t(n);Array.isArray(o)?i.push(...o):i.push(o)}return i}}})}}const $t=class ou extends ku{constructor(t){super(),Xt(this,"commands"),typeof t=="string"?this.commands=ou.parse(t):this.commands=t}encode(){return ou.encode(this.commands)}getBounds(){const t=Zt.CALCULATE_BOUNDS();return this.transform(t),t}transform(t){const e=[];for(const i of this.commands){const s=t(i);Array.isArray(s)?e.push(...s):e.push(s)}return this.commands=e,this}reverse(t=!0){return this.commands=Zt.REVERSE_PATH(this.commands,t),this}removeCollinear(){return this.commands=Zt.REMOVE_COLLINEAR(this.commands),this}static encode(t){return Gy(t)}static parse(t){const e=new o_,i=[];return e.parse(t,i),e.finish(i),i}};Xt($t,"CLOSE_PATH",1),Xt($t,"MOVE_TO",2),Xt($t,"HORIZ_LINE_TO",4),Xt($t,"VERT_LINE_TO",8),Xt($t,"LINE_TO",16),Xt($t,"CURVE_TO",32),Xt($t,"SMOOTH_CURVE_TO",64),Xt($t,"QUAD_TO",128),Xt($t,"SMOOTH_QUAD_TO",256),Xt($t,"ARC",512),Xt($t,"LINE_COMMANDS",$t.LINE_TO|$t.HORIZ_LINE_TO|$t.VERT_LINE_TO),Xt($t,"DRAWING_COMMANDS",$t.HORIZ_LINE_TO|$t.VERT_LINE_TO|$t.LINE_TO|$t.CURVE_TO|$t.SMOOTH_CURVE_TO|$t.QUAD_TO|$t.SMOOTH_QUAD_TO|$t.ARC);let G=$t;const a_={[G.MOVE_TO]:2,[G.LINE_TO]:2,[G.HORIZ_LINE_TO]:1,[G.VERT_LINE_TO]:1,[G.CLOSE_PATH]:0,[G.QUAD_TO]:4,[G.SMOOTH_QUAD_TO]:2,[G.CURVE_TO]:6,[G.SMOOTH_CURVE_TO]:4,[G.ARC]:7},l_=r=>{const t=new G(r).toAbs().commands,e=[];let i=[],s=null;for(const n of t)switch(n.type){case G.MOVE_TO:i.length>0&&(e.push({points:i}),i=[]),s=[n.x,n.y],i.push(s);break;case G.LINE_TO:i.push([n.x,n.y]);break;case G.HORIZ_LINE_TO:const o=i[i.length-1][1];i.push([n.x,o]);break;case G.VERT_LINE_TO:const a=i[i.length-1][0];i.push([a,n.y]);break;case G.CURVE_TO:case G.SMOOTH_CURVE_TO:case G.QUAD_TO:case G.SMOOTH_QUAD_TO:case G.ARC:i.push([n.x,n.y]);break}if(i.length>2&&e.push({points:i}),e.length>0){const n=Ue(e[0].points);return{rings:e,bounds:n}}},h_=r=>{const[t,e,i]=r.match(/(<polygon points=["|'])([^("|')]*)/)||[],s=i.split(" ").map(n=>n.split(",").map(parseFloat));return{type:xt.POLYGON,geometry:{points:s,bounds:Ue(s)}}},u_=r=>{const t=ya(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:xt.ELLIPSE,geometry:{cx:e,cy:i,rx:s,ry:n,bounds:o}}},c_=r=>{const t=ya(r),e=parseFloat(t.getAttribute("x1")),i=parseFloat(t.getAttribute("x2")),s=parseFloat(t.getAttribute("y1")),n=parseFloat(t.getAttribute("y2")),o={minX:Math.min(e,i),minY:Math.min(s,n),maxX:Math.max(e,i),maxY:Math.max(s,n)};return{type:xt.LINE,geometry:{points:[[e,s],[i,n]],bounds:o}}},d_=r=>{const t=ya(r),e=(t.nodeName==="path"?[t]:Array.from(t.querySelectorAll("path"))).map(n=>n.getAttribute("d")||"").map(n=>l_(n)).filter(Boolean),i=e.reduce((n,o)=>[...n,...o.rings[0].points],[]),s=Ue(i);return e.length===1&&e[0].rings.length===1?{type:xt.POLYGON,geometry:{points:i,bounds:s}}:{type:xt.MULTIPOLYGON,geometry:{polygons:e,bounds:s}}},f_=r=>{const t=typeof r=="string"?r:r.value;if(t.includes("<polygon points="))return h_(t);if(t.includes("<path "))return d_(t);if(t.includes("<ellipse "))return u_(t);if(t.includes("<line "))return c_(t);throw"Unsupported SVG shape: "+t},p_=r=>`<g>${r.polygons.map(t=>`<path fill-rule="evenodd" d="${Ze(t)}" />`).join("")}</g>`,m_=r=>{let t;switch(r.type){case xt.POLYGON:{const e=r.geometry,{points:i}=e;t=`<svg><polygon points="${i.map(s=>s.join(",")).join(" ")}" /></svg>`;break}case xt.ELLIPSE:{const e=r.geometry;t=`<svg><ellipse cx="${e.cx}" cy="${e.cy}" rx="${e.rx}" ry="${e.ry}" /></svg>`;break}case xt.MULTIPOLYGON:{const e=r.geometry;t=`<svg>${p_(e)}</svg>`;break}case xt.LINE:{const e=r.geometry,[[i,s],[n,o]]=e.points;t=`<svg><line x1="${i}" y1="${s}" x2="${n}" y2="${o}" /></svg>`;break}}if(t)return{type:"SvgSelector",value:t};throw`Unsupported shape type: ${r.type}`},Ee=[];for(let r=0;r<256;++r)Ee.push((r+256).toString(16).slice(1));function g_(r,t=0){return(Ee[r[t+0]]+Ee[r[t+1]]+Ee[r[t+2]]+Ee[r[t+3]]+"-"+Ee[r[t+4]]+Ee[r[t+5]]+"-"+Ee[r[t+6]]+Ee[r[t+7]]+"-"+Ee[r[t+8]]+Ee[r[t+9]]+"-"+Ee[r[t+10]]+Ee[r[t+11]]+Ee[r[t+12]]+Ee[r[t+13]]+Ee[r[t+14]]+Ee[r[t+15]]).toLowerCase()}let xa;const y_=new Uint8Array(16);function __(){if(!xa){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");xa=crypto.getRandomValues.bind(crypto)}return xa(y_)}const v_=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Gu={randomUUID:v_};function $u(r,t,e){var i;if(Gu.randomUUID&&!r)return Gu.randomUUID();r=r||{};const s=r.random??((i=r.rng)==null?void 0:i.call(r))??__();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,g_(s)}var Hu=Object.prototype.hasOwnProperty;function jr(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--&&jr(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(Hu.call(r,e)&&++i&&!Hu.call(t,e)||!(e in t)||!jr(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}function ba(){}function x_(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}const zi=[];function Ea(r,t=ba){let e;const i=new Set;function s(a){if(x_(r,a)&&(r=a,e)){const l=!zi.length;for(const h of i)h[1](),zi.push(h,r);if(l){for(let h=0;h<zi.length;h+=2)zi[h][0](zi[h+1]);zi.length=0}}}function n(a){s(a(r))}function o(a,l=ba){const h=[a,l];return i.add(h),i.size===1&&(e=t(s,n)||ba),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:o}}const b_=r=>{const{subscribe:t,set:e}=Ea();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 Xu=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(Xu||{});const Mn={selected:[]},E_=(r,t,e)=>{const{subscribe:i,set:s}=Ea(Mn);let n=t,o=Mn;i(m=>o=m);const a=()=>{jr(o,Mn)||s(Mn)},l=()=>{var m;return((m=o.selected)==null?void 0:m.length)===0},h=m=>{if(l())return!1;const _=typeof m=="string"?m:m.id;return o.selected.some(y=>y.id===_)},u=(m,_)=>{let y;if(Array.isArray(m)){if(y=m.map(g=>r.getAnnotation(g)).filter(Boolean),y.length<m.length){console.warn("Invalid selection: "+m.filter(g=>!y.some(x=>x.id===g)));return}}else{const g=r.getAnnotation(m);if(!g){console.warn("Invalid selection: "+m);return}y=[g]}const v=y.reduce((g,x)=>{const T=p(x);return T==="EDIT"?[...g,{id:x.id,editable:!0}]:T==="SELECT"?[...g,{id:x.id}]:g},[]);s({selected:v,event:_})},c=(m,_)=>{const y=Array.isArray(m)?m:[m],v=y.map(g=>r.getAnnotation(g)).filter(g=>!!g);s({selected:v.map(g=>{const x=_===void 0?p(g)==="EDIT":_;return{id:g.id,editable:x}})}),v.length!==y.length&&console.warn("Invalid selection",m)},d=m=>{if(l())return!1;const{selected:_}=o;_.some(({id:y})=>m.includes(y))&&s({selected:_.filter(({id:y})=>!m.includes(y))})},f=m=>{n=m,c(o.selected.map(({id:_})=>_))},p=m=>w_(m,n,e);return r.observe(({changes:m})=>d((m.deleted||[]).map(_=>_.id))),{get event(){return o?o.event:null},get selected(){return o?[...o.selected]:null},get userSelectAction(){return n},clear:a,evalSelectAction:p,isEmpty:l,isSelected:h,setSelected:c,setUserSelectAction:f,subscribe:i,userSelect:u}},w_=(r,t,e)=>{const i=e?e.serialize(r):r;return typeof t=="function"?t(i):t||"EDIT"},we=[];for(let r=0;r<256;++r)we.push((r+256).toString(16).slice(1));function T_(r,t=0){return(we[r[t+0]]+we[r[t+1]]+we[r[t+2]]+we[r[t+3]]+"-"+we[r[t+4]]+we[r[t+5]]+"-"+we[r[t+6]]+we[r[t+7]]+"-"+we[r[t+8]]+we[r[t+9]]+"-"+we[r[t+10]]+we[r[t+11]]+we[r[t+12]]+we[r[t+13]]+we[r[t+14]]+we[r[t+15]]).toLowerCase()}let wa;const A_=new Uint8Array(16);function S_(){if(!wa){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");wa=crypto.getRandomValues.bind(crypto)}return wa(A_)}const C_=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Vu={randomUUID:C_};function I_(r,t,e){var i;if(Vu.randomUUID&&!r)return Vu.randomUUID();r=r||{};const s=r.random??((i=r.rng)==null?void 0:i.call(r))??S_();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,T_(s)}const Ta=r=>{const t=e=>{const i={...e};return e.created&&typeof e.created=="string"&&(i.created=new Date(e.created)),e.updated&&typeof e.updated=="string"&&(i.updated=new Date(e.updated)),i};return{...r,bodies:(r.bodies||[]).map(t),target:t(r.target)}},R_=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},M_=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},P_=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!jr(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),O_=(r,t)=>!jr(r.target,t.target),zu=(r,t)=>{const e=R_(r,t),i=M_(r,t),s=P_(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:O_(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var kt=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(kt||{});const N_=(r,t)=>{var e,i;const{changes:s,origin:n}=t;if(!(r.options.origin?r.options.origin===n:n!=="SILENT"))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(u=>a(u.bodiesCreated)||a(u.bodiesDeleted)||a(u.bodiesUpdated)),h=(i=s.updated)==null?void 0:i.some(u=>u.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},D_=(r,t)=>{const e=new Set((r.created||[]).map(c=>c.id)),i=new Set((r.updated||[]).map(({newValue:c})=>c.id)),s=new Set((t.created||[]).map(c=>c.id)),n=new Set((t.deleted||[]).map(c=>c.id)),o=new Set((t.updated||[]).map(({oldValue:c})=>c.id)),a=new Set((t.updated||[]).filter(({oldValue:c})=>e.has(c.id)||i.has(c.id)).map(({oldValue:c})=>c.id)),l=[...(r.created||[]).filter(c=>!n.has(c.id)).map(c=>o.has(c.id)?t.updated.find(({oldValue:d})=>d.id===c.id).newValue:c),...t.created||[]],h=[...(r.deleted||[]).filter(c=>!s.has(c.id)),...(t.deleted||[]).filter(c=>!e.has(c.id))],u=[...(r.updated||[]).filter(({newValue:c})=>!n.has(c.id)).map(c=>{const{oldValue:d,newValue:f}=c;if(o.has(f.id)){const p=t.updated.find(m=>m.oldValue.id===f.id).newValue;return zu(d,p)}else return c}),...(t.updated||[]).filter(({oldValue:c})=>!a.has(c.id))];return{created:l,deleted:h,updated:u}},Pn=r=>{const t=r.id===void 0?I_():r.id;return{...r,id:t,bodies:r.bodies===void 0?[]:r.bodies.map(e=>({...e,annotation:t})),target:{...r.target,annotation:t}}},L_=r=>r.id!==void 0,B_=()=>{const r=new Map,t=new Map,e=[],i=(I,A={})=>{e.push({onChange:I,options:A})},s=I=>{const A=e.findIndex(w=>w.onChange==I);A>-1&&e.splice(A,1)},n=(I,A)=>{const w={origin:I,changes:{created:A.created||[],updated:A.updated||[],deleted:A.deleted||[]},state:[...r.values()]};e.forEach(C=>{N_(C,w)&&C.onChange(w)})},o=(I,A=kt.LOCAL)=>{if(I.id&&r.get(I.id))throw Error(`Cannot add annotation ${I.id} - exists already`);{const w=Pn(I);r.set(w.id,w),w.bodies.forEach(C=>t.set(C.id,w.id)),n(A,{created:[w]})}},a=(I,A)=>{const w=Pn(typeof I=="string"?A:I),C=typeof I=="string"?I:I.id,L=C&&r.get(C);if(L){const O=zu(L,w);return C===w.id?r.set(C,w):(r.delete(C),r.set(w.id,w)),L.bodies.forEach(B=>t.delete(B.id)),w.bodies.forEach(B=>t.set(B.id,w.id)),O}else console.warn(`Cannot update annotation ${C} - does not exist`)},l=(I,A=kt.LOCAL,w=kt.LOCAL)=>{const C=L_(A)?w:A,L=a(I,A);L&&n(C,{updated:[L]})},h=(I,A=kt.LOCAL)=>{r.get(I.id)?l(I,A):o(I,A)},u=(I,A=kt.LOCAL)=>{const w=I.reduce((C,L)=>{const O=a(L);return O?[...C,O]:C},[]);w.length>0&&n(A,{updated:w})},c=(I,A=kt.LOCAL)=>{const w=I.map(Pn),{toAdd:C,toUpdate:L}=w.reduce((B,V)=>r.get(V.id)?{...B,toUpdate:[...B.toUpdate,V]}:{...B,toAdd:[...B.toAdd,V]},{toAdd:[],toUpdate:[]}),O=L.map(B=>a(B,A)).filter(Boolean);C.forEach(B=>{r.set(B.id,B),B.bodies.forEach(V=>t.set(V.id,B.id))}),n(A,{created:C,updated:O})},d=(I,A=kt.LOCAL)=>{const w=r.get(I.annotation);if(w){const C={...w,bodies:[...w.bodies,I]};r.set(w.id,C),t.set(I.id,C.id),n(A,{updated:[{oldValue:w,newValue:C,bodiesCreated:[I]}]})}else console.warn(`Attempt to add body to missing annotation: ${I.annotation}`)},f=()=>[...r.values()],p=(I=kt.LOCAL)=>{const A=[...r.values()];r.clear(),t.clear(),n(I,{deleted:A})},m=(I,A=!0,w=kt.LOCAL)=>{const C=I.map(Pn);if(A){const L=[...r.values()];r.clear(),t.clear(),C.forEach(O=>{r.set(O.id,O),O.bodies.forEach(B=>t.set(B.id,O.id))}),n(w,{created:C,deleted:L})}else{const L=I.reduce((O,B)=>{const V=B.id&&r.get(B.id);return V?[...O,V]:O},[]);if(L.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${L.map(O=>O.id).join(", ")}`);C.forEach(O=>{r.set(O.id,O),O.bodies.forEach(B=>t.set(B.id,O.id))}),n(w,{created:C})}},_=I=>{const A=typeof I=="string"?I:I.id,w=r.get(A);if(w)return r.delete(A),w.bodies.forEach(C=>t.delete(C.id)),w;console.warn(`Attempt to delete missing annotation: ${A}`)},y=(I,A=kt.LOCAL)=>{const w=_(I);w&&n(A,{deleted:[w]})},v=(I,A=kt.LOCAL)=>{const w=I.reduce((C,L)=>{const O=_(L);return O?[...C,O]:C},[]);w.length>0&&n(A,{deleted:w})},g=I=>{const A=r.get(I.annotation);if(A){const w=A.bodies.find(C=>C.id===I.id);if(w){t.delete(w.id);const C={...A,bodies:A.bodies.filter(L=>L.id!==I.id)};return r.set(A.id,C),{oldValue:A,newValue:C,bodiesDeleted:[w]}}else console.warn(`Attempt to delete missing body ${I.id} from annotation ${I.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${I.annotation}`)},x=(I,A=kt.LOCAL)=>{const w=g(I);w&&n(A,{updated:[w]})},T=(I,A=kt.LOCAL)=>{const w=I.map(C=>g(C)).filter(Boolean);w.length>0&&n(A,{updated:w})},M=I=>{const A=r.get(I);return A?{...A}:void 0},S=I=>{const A=t.get(I);if(A){const w=M(A).bodies.find(C=>C.id===I);if(w)return w;console.error(`Store integrity error: body ${I} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${I}`)},R=(I,A)=>{if(I.annotation!==A.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const w=r.get(I.annotation);if(w){const C=w.bodies.find(O=>O.id===I.id),L={...w,bodies:w.bodies.map(O=>O.id===C.id?A:O)};return r.set(w.id,L),C.id!==A.id&&(t.delete(C.id),t.set(A.id,L.id)),{oldValue:w,newValue:L,bodiesUpdated:[{oldBody:C,newBody:A}]}}else console.warn(`Attempt to add body to missing annotation ${I.annotation}`)},P=(I,A,w=kt.LOCAL)=>{const C=R(I,A);C&&n(w,{updated:[C]})},F=(I,A=kt.LOCAL)=>{const w=I.map(C=>R({id:C.id,annotation:C.annotation},C)).filter(Boolean);n(A,{updated:w})},U=I=>{const A=r.get(I.annotation);if(A){const w={...A,target:{...A.target,...I}};return r.set(A.id,w),{oldValue:A,newValue:w,targetUpdated:{oldTarget:A.target,newTarget:I}}}else console.warn(`Attempt to update target on missing annotation: ${I.annotation}`)};return{addAnnotation:o,addBody:d,all:f,bulkAddAnnotations:m,bulkDeleteAnnotations:v,bulkDeleteBodies:T,bulkUpdateAnnotations:u,bulkUpdateBodies:F,bulkUpdateTargets:(I,A=kt.LOCAL)=>{const w=I.map(C=>U(C)).filter(Boolean);w.length>0&&n(A,{updated:w})},bulkUpsertAnnotations:c,clear:p,deleteAnnotation:y,deleteBody:x,getAnnotation:M,getBody:S,observe:i,unobserve:s,updateAnnotation:l,updateBody:P,updateTarget:(I,A=kt.LOCAL)=>{const w=U(I);w&&n(A,{updated:[w]})},upsertAnnotation:h}},F_=r=>({...r,subscribe:t=>{const e=i=>t(i.state);return r.observe(e),t(r.all()),()=>r.unobserve(e)}});let k_=()=>({emit(r,...t){for(let e=this.events[r]||[],i=0,s=e.length;i<s;i++)e[i](...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 U_=250,G_=(r,t)=>{const e=k_(),i=(t==null?void 0:t.changes)||[];let s=t?t.pointer:-1,n=!1,o=0;const a=p=>{if(!n){const{changes:m}=p,_=performance.now();if(_-o>U_)i.splice(s+1),i.push(m),s=i.length-1;else{const y=i.length-1;i[y]=D_(i[y],m)}o=_}n=!1};r.observe(a,{origin:kt.LOCAL});const l=p=>p&&p.length>0&&r.bulkDeleteAnnotations(p),h=p=>p&&p.length>0&&r.bulkAddAnnotations(p,!1),u=p=>p&&p.length>0&&r.bulkUpdateAnnotations(p.map(({oldValue:m})=>m)),c=p=>p&&p.length>0&&r.bulkUpdateAnnotations(p.map(({newValue:m})=>m)),d=p=>p&&p.length>0&&r.bulkAddAnnotations(p,!1),f=p=>p&&p.length>0&&r.bulkDeleteAnnotations(p);return{canRedo:()=>i.length-1>s,canUndo:()=>s>-1,destroy:()=>r.unobserve(a),getHistory:()=>({changes:[...i],pointer:s}),on:(p,m)=>e.on(p,m),redo:()=>{if(i.length-1>s){n=!0;const{created:p,updated:m,deleted:_}=i[s+1];h(p),c(m),f(_),e.emit("redo",i[s+1]),s+=1}},undo:()=>{if(s>-1){n=!0;const{created:p,updated:m,deleted:_}=i[s];l(p),u(m),d(_),e.emit("undo",i[s]),s-=1}}}},$_=()=>{const{subscribe:r,set:t}=Ea([]);return{subscribe:r,set:t}},H_=(r,t,e,i)=>{const{hover:s,selection:n,store:o,viewport:a}=r,l=new Map;let h=[],u,c;const d=(y,v)=>{l.has(y)?l.get(y).push(v):l.set(y,[v])},f=(y,v)=>{const g=l.get(y);if(g){const x=g.indexOf(v);x!==-1&&g.splice(x,1)}},p=(y,v,g)=>{l.has(y)&&setTimeout(()=>{l.get(y).forEach(x=>{if(e){const T=Array.isArray(v)?v.map(S=>e.serialize(S)):e.serialize(v),M=g?g instanceof PointerEvent?g:e.serialize(g):void 0;x(T,M)}else x(v,g)})},1)},m=()=>{const{selected:y}=n,v=(y||[]).map(({id:g})=>o.getAnnotation(g));v.forEach(g=>{const x=h.find(T=>T.id===g.id);(!x||!jr(x,g))&&p("updateAnnotation",g,x)}),h=h.map(g=>v.find(({id:x})=>x===g.id)||g)};n.subscribe(({selected:y})=>{if(!(h.length===0&&y.length===0)){if(h.length===0&&y.length>0)h=y.map(({id:v})=>o.getAnnotation(v));else if(h.length>0&&y.length===0)h.forEach(v=>{const g=o.getAnnotation(v.id);g&&!jr(g,v)&&p("updateAnnotation",g,v)}),h=[];else{const v=new Set(h.map(x=>x.id)),g=new Set(y.map(({id:x})=>x));h.filter(x=>!g.has(x.id)).forEach(x=>{const T=o.getAnnotation(x.id);T&&!jr(T,x)&&p("updateAnnotation",T,x)}),h=[...h.filter(x=>g.has(x.id)),...y.filter(({id:x})=>!v.has(x)).map(({id:x})=>o.getAnnotation(x))]}p("selectionChanged",h)}}),s.subscribe(y=>{!u&&y?p("mouseEnterAnnotation",o.getAnnotation(y)):u&&!y?p("mouseLeaveAnnotation",o.getAnnotation(u)):u&&y&&(p("mouseLeaveAnnotation",o.getAnnotation(u)),p("mouseEnterAnnotation",o.getAnnotation(y))),u=y}),a==null||a.subscribe(y=>p("viewportIntersect",y.map(v=>o.getAnnotation(v)))),o.observe(y=>{i&&(c&&clearTimeout(c),c=setTimeout(m,1e3));const{created:v,deleted:g}=y.changes;(v||[]).forEach(x=>p("createAnnotation",x)),(g||[]).forEach(x=>p("deleteAnnotation",x)),(y.changes.updated||[]).filter(x=>[...x.bodiesCreated||[],...x.bodiesDeleted||[],...x.bodiesUpdated||[]].length>0).forEach(({oldValue:x,newValue:T})=>{const M=h.find(S=>S.id===x.id)||x;h=h.map(S=>S.id===x.id?T:S),p("updateAnnotation",T,M)})},{origin:kt.LOCAL}),o.observe(y=>{if(h){const v=new Set(h.map(x=>x.id)),g=(y.changes.updated||[]).filter(({newValue:x})=>v.has(x.id)).map(({newValue:x})=>x);g.length>0&&(h=h.map(x=>g.find(T=>T.id===x.id)||x))}},{origin:kt.REMOTE});const _=y=>v=>{const{updated:g}=v;y?(g||[]).forEach(x=>p("updateAnnotation",x.oldValue,x.newValue)):(g||[]).forEach(x=>p("updateAnnotation",x.newValue,x.oldValue))};return t.on("undo",_(!0)),t.on("redo",_(!1)),{on:d,off:f,emit:p}},X_=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:[]}),V_=(r,t,e)=>{const{store:i,selection:s}=r,n=y=>{if(e){const{parsed:v,error:g}=e.parse(y);v?i.addAnnotation(v,kt.REMOTE):console.error(g)}else i.addAnnotation(Ta(y),kt.REMOTE)},o=()=>s.clear(),a=()=>i.clear(),l=y=>{const v=i.getAnnotation(y);return e&&v?e.serialize(v):v},h=()=>e?i.all().map(e.serialize):i.all(),u=()=>{var y;const v=(((y=s.selected)==null?void 0:y.map(g=>g.id))||[]).map(g=>i.getAnnotation(g)).filter(Boolean);return e?v.map(e.serialize):v},c=(y,v=!0)=>fetch(y).then(g=>g.json()).then(g=>(f(g,v),g)),d=y=>{if(typeof y=="string"){const v=i.getAnnotation(y);if(i.deleteAnnotation(y),v)return e?e.serialize(v):v}else{const v=e?e.parse(y).parsed:y;if(v)return i.deleteAnnotation(v),y}},f=(y,v=!0)=>{if(e){const g=e.parseAll||X_(e),{parsed:x,failed:T}=g(y);T.length>0&&console.warn(`Discarded ${T.length} invalid annotations`,T),i.bulkAddAnnotations(x,v,kt.REMOTE)}else i.bulkAddAnnotations(y.map(Ta),v,kt.REMOTE)},p=(y,v)=>{y?s.setSelected(y,v):s.clear()},m=y=>{s.clear(),s.setUserSelectAction(y)},_=y=>{if(e){const v=e.parse(y).parsed,g=e.serialize(i.getAnnotation(v.id));return i.updateAnnotation(v),g}else{const v=i.getAnnotation(y.id);return i.updateAnnotation(Ta(y)),v}};return{addAnnotation:n,cancelSelected:o,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getHistory:t.getHistory,getSelected:u,loadAnnotations:c,redo:t.redo,removeAnnotation:d,setAnnotations:f,setSelected:p,setUserSelectAction:m,undo:t.undo,updateAnnotation:_}},z_=(r,t,e)=>typeof t=="function"?t(r,e):t,Y_=(r,t)=>typeof r!="function"&&typeof t!="function"?{...r||{},...t||{}}:(e,i)=>{const s=typeof r=="function"?r(e,i):r,n=typeof t=="function"?t(e,i):t;return{...s||{},...n||{}}},j_="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let W_=r=>crypto.getRandomValues(new Uint8Array(r)),q_=(r,t,e)=>{let i=(2<<Math.log2(r.length-1))-1,s=-~(1.6*i*t/r.length);return(n=t)=>{let o="";for(;;){let a=e(s),l=s|0;for(;l--;)if(o+=r[a[l]&i]||"",o.length>=n)return o}}},K_=(r,t=21)=>q_(r,t|0,W_),Z_=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=j_[e[r]&63];return t};const Q_=()=>({isGuest:!0,id:K_("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),J_=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}`},Yu=r=>r?typeof r=="object"?{...r}:r:void 0,t0=(r,t)=>(Array.isArray(r)?r:[r]).map(e=>{const{id:i,type:s,purpose:n,value:o,created:a,modified:l,creator:h,...u}=e;return{id:i||`temp-${J_(e)}`,annotation:t,type:s,purpose:n,value:o,creator:Yu(h),created:a?new Date(a):void 0,updated:l?new Date(l):void 0,...u}}),e0=r=>r.map(t=>{var e;const{annotation:i,created:s,updated:n,...o}=t,a={...o,created:s==null?void 0:s.toISOString(),modified:n==null?void 0:n.toISOString()};return(e=a.id)!=null&&e.startsWith("temp-")&&delete a.id,a});Z_();const r0=(r,t={strict:!0,invertY:!1})=>({parse:e=>i0(e,t),serialize:e=>s0(e,r,t)}),i0=(r,t={strict:!0,invertY:!1})=>{const e=r.id||$u(),{creator:i,created:s,modified:n,body:o,...a}=r,l=t0(o||[],e),h=Array.isArray(r.target)?r.target[0]:r.target,u=typeof h=="string"?h:Array.isArray(h.selector)?h.selector[0]:h.selector,c=typeof u=="string"||(u==null?void 0:u.type)==="FragmentSelector"?Fy(u,t.invertY):(u==null?void 0:u.type)==="SvgSelector"?f_(u):void 0,d=Array.isArray(a.target)?a.target[0]:a.targret;return c||!t.strict?{parsed:{...a,id:e,bodies:l,target:{created:s?new Date(s):void 0,creator:Yu(i),updated:n?new Date(n):void 0,...typeof d=="string"?{}:d,annotation:e,selector:c||u}}}:{error:Error(`Invalid selector: ${JSON.stringify(u)}`)}},s0=(r,t,e={strict:!0,invertY:!1})=>{const{selector:i,creator:s,created:n,updated:o,updatedBy:a,...l}=r.target;let h;try{h=i.type==xt.RECTANGLE?ky(i.geometry):m_(i)}catch(c){if(e.strict)throw c;h=i}const u={...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:r.id,type:"Annotation",body:e0(r.bodies),created:n==null?void 0:n.toISOString(),creator:s,modified:o==null?void 0:o.toISOString(),target:{...l,source:t,type:"SpecificResource",selector:h}};return delete u.bodies,"annotation"in u.target&&delete u.target.annotation,u},Yi=[];function n0(r,t=Pt){let e;const i=new Set;function s(a){if(ne(r,a)&&(r=a,e)){const l=!Yi.length;for(const h of i)h[1](),Yi.push(h,r);if(l){for(let h=0;h<Yi.length;h+=2)Yi[h][0](Yi[h+1]);Yi.length=0}}}function n(a){s(a(r))}function o(a,l=Pt){const h=[a,l];return i.add(h),i.size===1&&(e=t(s,n)||Pt),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:o}}const o0=(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}`)},a0=(r,t)=>{o0(r,t);const{subscribe:e,set:i}=n0(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}},ji=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:s,stroke:n,strokeWidth:o,strokeOpacity:a}=e;let l="";return i&&(l+=`fill:${i};`,l+=`fill-opacity:${s||"0.25"};`),n&&(l+=`stroke:${n};`,l+=`stroke-width:${o||"1"};`,l+=`stroke-opacity:${a||"1"};`),l}},On=(r,t=0)=>{const{minX:e,minY:i,maxX:s,maxY:n}=r;return{x:e-t,y:i-t,w:s-e+2*t,h:n-i+2*t}},Cr=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,l0=r=>({}),ju=r=>({grab:r[0]});function h0(r){let t,e,i,s;const n=r[8].default,o=_y(n,r,r[7],ju);return{c(){t=K("g"),o&&o.c(),b(t,"class","a9s-annotation selected")},m(a,l){it(a,t,l),o&&o.m(t,null),e=!0,i||(s=[Rt(t,"pointerup",r[2]),Rt(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&128)&&xy(o,n,a,a[7],e?vy(n,a[7],l,l0):by(a[7]),ju)},i(a){e||(at(o,a),e=!0)},o(a){gt(o,a),e=!1},d(a){a&&rt(t),o&&o.d(a),i=!1,He(s)}}}function u0(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=Vr();let{shape:o}=t,{editor:a}=t,{transform:l}=t,{svgEl:h}=t,u,c,d;const f=_=>y=>{if(u=_,h){const{left:v,top:g}=h.getBoundingClientRect(),x=y.clientX-v,T=y.clientY-g;c=l.elementToImage(x,T)}else{const{offsetX:v,offsetY:g}=y;c=l.elementToImage(v,g)}d=o,y.target.setPointerCapture(y.pointerId),n("grab",y)},p=_=>{if(u){const[y,v]=l.elementToImage(_.offsetX,_.offsetY),g=[y-c[0],v-c[1]];e(3,o=a(d,u,g)),n("change",o)}},m=_=>{_.target.releasePointerCapture(_.pointerId),u=void 0,d=o,n("release",_)};return r.$$set=_=>{"shape"in _&&e(3,o=_.shape),"editor"in _&&e(4,a=_.editor),"transform"in _&&e(5,l=_.transform),"svgEl"in _&&e(6,h=_.svgEl),"$$scope"in _&&e(7,s=_.$$scope)},[f,p,m,o,a,l,h,s,i]}class Aa extends Pe{constructor(t){super(),Me(this,t,u0,h0,ne,{shape:3,editor:4,transform:5,svgEl:6})}}function c0(r){let t,e,i,s,n,o,a,l,h=r[3]&&Wu(r);return{c(){t=K("g"),e=K("circle"),h&&h.c(),s=K("circle"),b(e,"class","a9s-handle-buffer"),b(e,"cx",r[0]),b(e,"cy",r[1]),b(e,"r",i=r[5]+6/r[2]),b(s,"class",n=`a9s-handle-dot${r[3]?" selected":""}`),b(s,"cx",r[0]),b(s,"cy",r[1]),b(s,"r",r[5]),b(t,"class",o=`a9s-handle ${r[8].class||""}`.trim())},m(u,c){it(u,t,c),Tt(t,e),h&&h.m(t,null),Tt(t,s),a||(l=[Rt(e,"pointerenter",r[11]),Rt(e,"pointerleave",r[12]),Rt(e,"pointerdown",r[13]),Rt(e,"pointerdown",r[6]),Rt(e,"pointerup",r[14]),Rt(e,"pointerup",r[7])],a=!0)},p(u,c){c&1&&b(e,"cx",u[0]),c&2&&b(e,"cy",u[1]),c&36&&i!==(i=u[5]+6/u[2])&&b(e,"r",i),u[3]?h?h.p(u,c):(h=Wu(u),h.c(),h.m(t,s)):h&&(h.d(1),h=null),c&8&&n!==(n=`a9s-handle-dot${u[3]?" selected":""}`)&&b(s,"class",n),c&1&&b(s,"cx",u[0]),c&2&&b(s,"cy",u[1]),c&32&&b(s,"r",u[5]),c&256&&o!==(o=`a9s-handle ${u[8].class||""}`.trim())&&b(t,"class",o)},d(u){u&&rt(t),h&&h.d(),a=!1,He(l)}}}function d0(r){let t,e,i,s,n,o,a,l,h;return{c(){t=K("g"),e=K("circle"),s=K("circle"),o=K("circle"),b(e,"cx",r[0]),b(e,"cy",r[1]),b(e,"r",i=r[5]*10),b(e,"class","a9s-touch-halo"),cr(e,"touched",r[4]),b(s,"cx",r[0]),b(s,"cy",r[1]),b(s,"r",n=r[5]+10/r[2]),b(s,"class","a9s-handle-buffer"),b(o,"class","a9s-handle-dot"),b(o,"cx",r[0]),b(o,"cy",r[1]),b(o,"r",a=r[5]+2/r[2]),b(t,"class","a9s-touch-handle")},m(u,c){it(u,t,c),Tt(t,e),Tt(t,s),Tt(t,o),l||(h=[Rt(s,"pointerdown",r[9]),Rt(s,"pointerup",r[10]),Rt(s,"pointerdown",r[6]),Rt(s,"pointerup",r[7])],l=!0)},p(u,c){c&1&&b(e,"cx",u[0]),c&2&&b(e,"cy",u[1]),c&32&&i!==(i=u[5]*10)&&b(e,"r",i),c&16&&cr(e,"touched",u[4]),c&1&&b(s,"cx",u[0]),c&2&&b(s,"cy",u[1]),c&36&&n!==(n=u[5]+10/u[2])&&b(s,"r",n),c&1&&b(o,"cx",u[0]),c&2&&b(o,"cy",u[1]),c&36&&a!==(a=u[5]+2/u[2])&&b(o,"r",a)},d(u){u&&rt(t),l=!1,He(h)}}}function Wu(r){let t,e;return{c(){t=K("circle"),b(t,"class","a9s-handle-selected"),b(t,"cx",r[0]),b(t,"cy",r[1]),b(t,"r",e=r[5]+8/r[2])},m(i,s){it(i,t,s)},p(i,s){s&1&&b(t,"cx",i[0]),s&2&&b(t,"cy",i[1]),s&36&&e!==(e=i[5]+8/i[2])&&b(t,"r",e)},d(i){i&&rt(t)}}}function f0(r){let t;function e(s,n){return Cr?d0:c0}let i=e()(r);return{c(){i.c(),t=Fe()},m(s,n){i.m(s,n),it(s,t,n)},p(s,[n]){i.p(s,n)},i:Pt,o:Pt,d(s){s&&rt(t),i.d(s)}}}function p0(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t,{selected:a=void 0}=t,l=!1;const h=y=>{y.pointerType==="touch"&&e(4,l=!0)},u=()=>e(4,l=!1);function c(y){Ce.call(this,r,y)}function d(y){Ce.call(this,r,y)}function f(y){Ce.call(this,r,y)}function p(y){Ce.call(this,r,y)}function m(y){Ce.call(this,r,y)}function _(y){Ce.call(this,r,y)}return r.$$set=y=>{e(8,t=aa(aa({},t),vu(y))),"x"in y&&e(0,s=y.x),"y"in y&&e(1,n=y.y),"scale"in y&&e(2,o=y.scale),"selected"in y&&e(3,a=y.selected)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=4/o)},t=vu(t),[s,n,o,a,l,i,h,u,t,c,d,f,p,m,_]}class Wi extends Pe{constructor(t){super(),Me(this,t,p0,f0,ne,{x:0,y:1,scale:2,selected:3})}}function m0(r){let t,e,i,s,n,o,a;return{c(){t=K("g"),e=K("circle"),s=K("circle"),n=K("circle"),b(e,"class","a9s-polygon-midpoint-buffer svelte-12ykj76"),b(e,"cx",r[0]),b(e,"cy",r[1]),b(e,"r",i=1.75*r[2]),b(s,"class","a9s-polygon-midpoint-outer svelte-12ykj76"),b(s,"cx",r[0]),b(s,"cy",r[1]),b(s,"r",r[2]),b(n,"class","a9s-polygon-midpoint-inner svelte-12ykj76"),b(n,"cx",r[0]),b(n,"cy",r[1]),b(n,"r",r[2]),b(t,"class","a9s-polygon-midpoint svelte-12ykj76")},m(l,h){it(l,t,h),Tt(t,e),Tt(t,s),Tt(t,n),o||(a=[Rt(e,"pointerdown",r[5]),Rt(e,"pointerdown",r[3])],o=!0)},p(l,h){h&1&&b(e,"cx",l[0]),h&2&&b(e,"cy",l[1]),h&4&&i!==(i=1.75*l[2])&&b(e,"r",i),h&1&&b(s,"cx",l[0]),h&2&&b(s,"cy",l[1]),h&4&&b(s,"r",l[2]),h&1&&b(n,"cx",l[0]),h&2&&b(n,"cy",l[1]),h&4&&b(n,"r",l[2])},d(l){l&&rt(t),o=!1,He(a)}}}function g0(r){let t;return{c(){t=K("circle"),b(t,"cx",r[0]),b(t,"cy",r[1]),b(t,"r",r[2])},m(e,i){it(e,t,i)},p(e,i){i&1&&b(t,"cx",e[0]),i&2&&b(t,"cy",e[1]),i&4&&b(t,"r",e[2])},d(e){e&&rt(t)}}}function y0(r){let t;function e(s,n){return Cr?g0:m0}let i=e()(r);return{c(){i.c(),t=Fe()},m(s,n){i.m(s,n),it(s,t,n)},p(s,[n]){i.p(s,n)},i:Pt,o:Pt,d(s){s&&rt(t),i.d(s)}}}function _0(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t;const a=h=>{h.pointerType};function l(h){Ce.call(this,r,h)}return r.$$set=h=>{"x"in h&&e(0,s=h.x),"y"in h&&e(1,n=h.y),"scale"in h&&e(4,o=h.scale)},r.$$.update=()=>{r.$$.dirty&16&&e(2,i=4/o)},[s,n,i,a,o,l]}class qu extends Pe{constructor(t){super(),Me(this,t,_0,y0,ne,{x:0,y:1,scale:4})}}function Sa(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function Ku(r,t,e){const i=r.slice();return i[28]=t[e],i[30]=e,i}function Ca(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function Ia(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function Zu(r){let t,e,i,s;return{c(){t=K("circle"),b(t,"cx",e=r[28][0]),b(t,"cy",i=r[28][1]),b(t,"r",s=Ls/r[3]),b(t,"class","svelte-1h2slbm")},m(n,o){it(n,t,o)},p(n,o){o[0]&1088&&e!==(e=n[28][0])&&b(t,"cx",e),o[0]&1088&&i!==(i=n[28][1])&&b(t,"cy",i),o[0]&8&&s!==(s=Ls/n[3])&&b(t,"r",s)},d(n){n&&rt(t)}}}function Qu(r){let t,e,i,s,n,o,a,l,h,u;return{c(){t=K("mask"),e=K("rect"),a=K("circle"),b(e,"x",i=r[9].x),b(e,"y",s=r[9].y),b(e,"width",n=r[9].w),b(e,"height",o=r[9].h),b(e,"class","svelte-1h2slbm"),b(a,"cx",l=r[28][0]),b(a,"cy",h=r[28][1]),b(a,"r",u=Ls/r[3]),b(a,"class","svelte-1h2slbm"),b(t,"id",`${r[19]}-inner`),b(t,"class","a9s-polygon-editor-mask svelte-1h2slbm")},m(c,d){it(c,t,d),Tt(t,e),Tt(t,a)},p(c,d){d[0]&512&&i!==(i=c[9].x)&&b(e,"x",i),d[0]&512&&s!==(s=c[9].y)&&b(e,"y",s),d[0]&512&&n!==(n=c[9].w)&&b(e,"width",n),d[0]&512&&o!==(o=c[9].h)&&b(e,"height",o),d[0]&1088&&l!==(l=c[28][0])&&b(a,"cx",l),d[0]&1088&&h!==(h=c[28][1])&&b(a,"cy",h),d[0]&8&&u!==(u=Ls/c[3])&&b(a,"r",u)},d(c){c&&rt(t)}}}function Ju(r){let t,e;return t=new Wi({props:{class:"a9s-corner-handle",x:r[28][0],y:r[28][1],scale:r[3],selected:r[8].includes(r[30])}}),t.$on("pointerenter",r[11]),t.$on("pointerleave",r[12]),t.$on("pointerdown",r[15]),t.$on("pointerdown",function(){Vt(r[27](`HANDLE-${r[30]}`))&&r[27](`HANDLE-${r[30]}`).apply(this,arguments)}),t.$on("pointerup",r[16](r[30])),{c(){fe(t.$$.fragment)},m(i,s){he(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&32&&(n.x=r[28][0]),s[0]&32&&(n.y=r[28][1]),s[0]&8&&(n.scale=r[3]),s[0]&256&&(n.selected=r[8].includes(r[30])),t.$set(n)},i(i){e||(at(t.$$.fragment,i),e=!0)},o(i){gt(t.$$.fragment,i),e=!1},d(i){ue(t,i)}}}function tc(r){let t,e;return t=new qu({props:{x:r[28][0],y:r[28][1],scale:r[3]}}),t.$on("pointerdown",function(){Vt(r[18](r[6]))&&r[18](r[6]).apply(this,arguments)}),{c(){fe(t.$$.fragment)},m(i,s){he(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&1088&&(n.x=r[28][0]),s[0]&1088&&(n.y=r[28][1]),s[0]&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(at(t.$$.fragment,i),e=!0)},o(i){gt(t.$$.fragment,i),e=!1},d(i){ue(t,i)}}}function v0(r){let t,e,i,s,n,o,a,l,h,u,c,d,f,p,m,_,y,v,g,x,T,M=r[6]!==void 0&&!r[7]&&Zu(Ia(r)),S=r[6]!==void 0&&!r[7]&&Qu(Ca(r)),R=ke(r[5].points),P=[];for(let I=0;I<R.length;I+=1)P[I]=Ju(Ku(r,R,I));const F=I=>gt(P[I],1,1,()=>{P[I]=null});let U=r[6]!==void 0&&!r[7]&&tc(Sa(r));return{c(){t=K("defs"),e=K("mask"),i=K("rect"),l=K("polygon"),M&&M.c(),S&&S.c(),u=De(),c=K("polygon"),f=De(),p=K("polygon"),_=De();for(let I=0;I<P.length;I+=1)P[I].c();y=De(),U&&U.c(),v=Fe(),b(i,"x",s=r[9].x),b(i,"y",n=r[9].y),b(i,"width",o=r[9].w),b(i,"height",a=r[9].h),b(i,"class","svelte-1h2slbm"),b(l,"points",h=r[5].points.map(ec).join(" ")),b(l,"class","svelte-1h2slbm"),b(e,"id",`${r[19]}-outer`),b(e,"class","a9s-polygon-editor-mask svelte-1h2slbm"),b(c,"class","a9s-outer"),b(c,"mask",`url(#${r[19]}-outer)`),b(c,"points",d=r[5].points.map(rc).join(" ")),b(p,"class","a9s-inner a9s-shape-handle"),b(p,"mask",`url(#${r[19]}-inner)`),b(p,"style",r[1]),b(p,"points",m=r[5].points.map(ic).join(" "))},m(I,A){it(I,t,A),Tt(t,e),Tt(e,i),Tt(e,l),M&&M.m(e,null),S&&S.m(t,null),it(I,u,A),it(I,c,A),it(I,f,A),it(I,p,A),it(I,_,A);for(let w=0;w<P.length;w+=1)P[w]&&P[w].m(I,A);it(I,y,A),U&&U.m(I,A),it(I,v,A),g=!0,x||(T=[Rt(c,"pointerup",r[14]),Rt(c,"pointerdown",function(){Vt(r[27]("SHAPE"))&&r[27]("SHAPE").apply(this,arguments)}),Rt(p,"pointermove",r[13]),Rt(p,"pointerup",r[14]),Rt(p,"pointerdown",function(){Vt(r[27]("SHAPE"))&&r[27]("SHAPE").apply(this,arguments)})],x=!0)},p(I,A){if(r=I,(!g||A[0]&512&&s!==(s=r[9].x))&&b(i,"x",s),(!g||A[0]&512&&n!==(n=r[9].y))&&b(i,"y",n),(!g||A[0]&512&&o!==(o=r[9].w))&&b(i,"width",o),(!g||A[0]&512&&a!==(a=r[9].h))&&b(i,"height",a),(!g||A[0]&32&&h!==(h=r[5].points.map(ec).join(" ")))&&b(l,"points",h),r[6]!==void 0&&!r[7]?M?M.p(Ia(r),A):(M=Zu(Ia(r)),M.c(),M.m(e,null)):M&&(M.d(1),M=null),r[6]!==void 0&&!r[7]?S?S.p(Ca(r),A):(S=Qu(Ca(r)),S.c(),S.m(t,null)):S&&(S.d(1),S=null),(!g||A[0]&32&&d!==(d=r[5].points.map(rc).join(" ")))&&b(c,"points",d),(!g||A[0]&2)&&b(p,"style",r[1]),(!g||A[0]&32&&m!==(m=r[5].points.map(ic).join(" ")))&&b(p,"points",m),A[0]&134322472){R=ke(r[5].points);let w;for(w=0;w<R.length;w+=1){const C=Ku(r,R,w);P[w]?(P[w].p(C,A),at(P[w],1)):(P[w]=Ju(C),P[w].c(),at(P[w],1),P[w].m(y.parentNode,y))}for(Ie(),w=R.length;w<P.length;w+=1)F(w);Re()}r[6]!==void 0&&!r[7]?U?(U.p(Sa(r),A),A[0]&192&&at(U,1)):(U=tc(Sa(r)),U.c(),at(U,1),U.m(v.parentNode,v)):U&&(Ie(),gt(U,1,1,()=>{U=null}),Re())},i(I){if(!g){for(let A=0;A<R.length;A+=1)at(P[A]);at(U),g=!0}},o(I){P=P.filter(Boolean);for(let A=0;A<P.length;A+=1)gt(P[A]);gt(U),g=!1},d(I){I&&(rt(t),rt(u),rt(c),rt(f),rt(p),rt(_),rt(y),rt(v)),M&&M.d(),S&&S.d(),mi(P,I),U&&U.d(I),x=!1,He(T)}}}function x0(r){let t,e;return t=new Aa({props:{shape:r[0],transform:r[2],editor:r[17],svgEl:r[4],$$slots:{default:[v0,({grab:i})=>({27:i}),({grab:i})=>[i?134217728:0]]},$$scope:{ctx:r}}}),t.$on("change",r[20]),t.$on("grab",r[21]),t.$on("release",r[22]),{c(){fe(t.$$.fragment)},m(i,s){he(t,i,s),e=!0},p(i,s){const n={};s[0]&1&&(n.shape=i[0]),s[0]&4&&(n.transform=i[2]),s[0]&16&&(n.svgEl=i[4]),s[0]&134219754|s[1]&1&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(at(t.$$.fragment,i),e=!0)},o(i){gt(t.$$.fragment,i),e=!1},d(i){ue(t,i)}}}const b0=250,E0=1e3,w0=12,Ls=4.5,ec=r=>r.join(","),rc=r=>r.join(","),ic=r=>r.join(",");function T0(r,t,e){let i,s,n;const o=Vr();let{shape:a}=t,{computedStyle:l}=t,{transform:h}=t,{viewportScale:u=1}=t,{svgEl:c}=t,d,f=!1,p,m=[];const _=()=>e(7,f=!0),y=()=>e(7,f=!1),v=w=>{if(m.length>0||!s.some(N=>N.visible)){e(6,d=void 0);return}const[C,L]=h.elementToImage(w.offsetX,w.offsetY),O=N=>Math.pow(N[0]-C,2)+Math.pow(N[1]-L,2),B=i.points.reduce((N,H)=>O(H)<O(N)?H:N),V=s.filter(N=>N.visible).reduce((N,H)=>O(H.point)<O(N.point)?H:N),D=Math.pow(E0/u,2);O(B)<D||O(V.point)<D?e(6,d=s.indexOf(V)):e(6,d=void 0)},g=()=>{document.activeElement!==c&&c.focus()},x=()=>{e(8,m=[]),g()},T=w=>{e(7,f=!0),w.preventDefault(),w.stopPropagation(),p=performance.now()},M=w=>C=>{if(!p||Cr||performance.now()-p>b0)return;const L=m.includes(w);C.metaKey||C.ctrlKey||C.shiftKey?L?e(8,m=m.filter(O=>O!==w)):e(8,m=[...m,w]):L&&m.length>1?e(8,m=[w]):L?e(8,m=[]):e(8,m=[w]),g()},S=(w,C,L)=>{g();let O;const B=w.geometry;m.length>1?O=B.points.map(([D,N],H)=>m.includes(H)?[D+L[0],N+L[1]]:[D,N]):C==="SHAPE"?O=B.points.map(([D,N])=>[D+L[0],N+L[1]]):O=B.points.map(([D,N],H)=>C===`HANDLE-${H}`?[D+L[0],N+L[1]]:[D,N]);const V=Ue(O);return{...w,geometry:{points:O,bounds:V}}},R=w=>async C=>{C.stopPropagation();const L=[...i.points.slice(0,w+1),s[w].point,...i.points.slice(w+1)],O=Ue(L);o("change",{...a,geometry:{points:L,bounds:O}}),await Au();const B=[...document.querySelectorAll(".a9s-handle")][w+1];if(B!=null&&B.firstChild){const V=new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:C.clientX,clientY:C.clientY,pointerId:C.pointerId,pointerType:C.pointerType,isPrimary:C.isPrimary,buttons:C.buttons});B.firstChild.dispatchEvent(V)}},P=()=>{if(i.points.length-m.length<3)return;const w=i.points.filter((L,O)=>!m.includes(O)),C=Ue(w);o("change",{...a,geometry:{points:w,bounds:C}}),e(8,m=[])};gi(()=>{if(Cr)return;const w=C=>{(C.key==="Delete"||C.key==="Backspace")&&(C.preventDefault(),P())};return c.addEventListener("pointermove",v),c.addEventListener("keydown",w),()=>{c.removeEventListener("pointermove",v),c.removeEventListener("keydown",w)}});const F=`polygon-mask-${Math.random().toString(36).substring(2,12)}`;function U(w){Ce.call(this,r,w)}function I(w){Ce.call(this,r,w)}function A(w){Ce.call(this,r,w)}return r.$$set=w=>{"shape"in w&&e(0,a=w.shape),"computedStyle"in w&&e(1,l=w.computedStyle),"transform"in w&&e(2,h=w.transform),"viewportScale"in w&&e(3,u=w.viewportScale),"svgEl"in w&&e(4,c=w.svgEl)},r.$$.update=()=>{r.$$.dirty[0]&1&&e(5,i=a.geometry),r.$$.dirty[0]&40&&e(10,s=Cr?[]:i.points.map((w,C)=>{const L=C===i.points.length-1?i.points[0]:i.points[C+1],O=(w[0]+L[0])/2,B=(w[1]+L[1])/2,V=Math.sqrt(Math.pow(L[0]-O,2)+Math.pow(L[1]-B,2))>w0/u;return{point:[O,B],visible:V}})),r.$$.dirty[0]&40&&e(9,n=On(i.bounds,Ls/u))},[a,l,h,u,c,i,d,f,m,n,s,_,y,v,x,T,M,S,R,F,U,I,A]}class A0 extends Pe{constructor(t){super(),Me(this,t,T0,x0,ne,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}function S0(r){let t,e,i,s,n,o,a,l,h,u,c,d,f,p,m,_,y,v,g,x,T,M,S,R,P,F,U,I,A,w,C,L,O,B,V,D,N,H,k,z,Y,pt,_t,W,Et,nt,mt,vt,Mt,Dt,ve,Kt,et,Ke,_n;return nt=new Wi({props:{class:"a9s-corner-handle-topleft",x:r[5].x,y:r[5].y,scale:r[3]}}),nt.$on("pointerdown",function(){Vt(r[12]("TOP_LEFT"))&&r[12]("TOP_LEFT").apply(this,arguments)}),vt=new Wi({props:{class:"a9s-corner-handle-topright",x:r[5].x+r[5].w,y:r[5].y,scale:r[3]}}),vt.$on("pointerdown",function(){Vt(r[12]("TOP_RIGHT"))&&r[12]("TOP_RIGHT").apply(this,arguments)}),Dt=new Wi({props:{class:"a9s-corner-handle-bottomright",x:r[5].x+r[5].w,y:r[5].y+r[5].h,scale:r[3]}}),Dt.$on("pointerdown",function(){Vt(r[12]("BOTTOM_RIGHT"))&&r[12]("BOTTOM_RIGHT").apply(this,arguments)}),Kt=new Wi({props:{class:"a9s-corner-handle-bottomleft",x:r[5].x,y:r[5].y+r[5].h,scale:r[3]}}),Kt.$on("pointerdown",function(){Vt(r[12]("BOTTOM_LEFT"))&&r[12]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=K("defs"),e=K("mask"),i=K("rect"),l=K("rect"),f=De(),p=K("rect"),g=De(),x=K("rect"),P=De(),F=K("rect"),w=De(),C=K("rect"),V=De(),D=K("rect"),z=De(),Y=K("rect"),Et=De(),fe(nt.$$.fragment),mt=De(),fe(vt.$$.fragment),Mt=De(),fe(Dt.$$.fragment),ve=De(),fe(Kt.$$.fragment),b(i,"class","rect-mask-bg svelte-1njczvj"),b(i,"x",s=r[6].x),b(i,"y",n=r[6].y),b(i,"width",o=r[6].w),b(i,"height",a=r[6].h),b(l,"class","rect-mask-fg svelte-1njczvj"),b(l,"x",h=r[5].x),b(l,"y",u=r[5].y),b(l,"width",c=r[5].w),b(l,"height",d=r[5].h),b(e,"id",r[8]),b(e,"class","a9s-rectangle-editor-mask svelte-1njczvj"),b(p,"class","a9s-outer"),b(p,"mask",`url(#${r[8]})`),b(p,"x",m=r[5].x),b(p,"y",_=r[5].y),b(p,"width",y=r[5].w),b(p,"height",v=r[5].h),b(x,"class","a9s-inner a9s-shape-handle"),b(x,"style",r[1]),b(x,"x",T=r[5].x),b(x,"y",M=r[5].y),b(x,"width",S=r[5].w),b(x,"height",R=r[5].h),b(F,"class","a9s-edge-handle a9s-edge-handle-top"),b(F,"x",U=r[5].x),b(F,"y",I=r[5].y),b(F,"height",1),b(F,"width",A=r[5].w),b(C,"class","a9s-edge-handle a9s-edge-handle-right"),b(C,"x",L=r[5].x+r[5].w),b(C,"y",O=r[5].y),b(C,"height",B=r[5].h),b(C,"width",1),b(D,"class","a9s-edge-handle a9s-edge-handle-bottom"),b(D,"x",N=r[5].x),b(D,"y",H=r[5].y+r[5].h),b(D,"height",1),b(D,"width",k=r[5].w),b(Y,"class","a9s-edge-handle a9s-edge-handle-left"),b(Y,"x",pt=r[5].x),b(Y,"y",_t=r[5].y),b(Y,"height",W=r[5].h),b(Y,"width",1)},m(q,$){it(q,t,$),Tt(t,e),Tt(e,i),Tt(e,l),it(q,f,$),it(q,p,$),it(q,g,$),it(q,x,$),it(q,P,$),it(q,F,$),it(q,w,$),it(q,C,$),it(q,V,$),it(q,D,$),it(q,z,$),it(q,Y,$),it(q,Et,$),he(nt,q,$),it(q,mt,$),he(vt,q,$),it(q,Mt,$),he(Dt,q,$),it(q,ve,$),he(Kt,q,$),et=!0,Ke||(_n=[Rt(p,"pointerdown",function(){Vt(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),Rt(x,"pointerdown",function(){Vt(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),Rt(F,"pointerdown",function(){Vt(r[12]("TOP"))&&r[12]("TOP").apply(this,arguments)}),Rt(C,"pointerdown",function(){Vt(r[12]("RIGHT"))&&r[12]("RIGHT").apply(this,arguments)}),Rt(D,"pointerdown",function(){Vt(r[12]("BOTTOM"))&&r[12]("BOTTOM").apply(this,arguments)}),Rt(Y,"pointerdown",function(){Vt(r[12]("LEFT"))&&r[12]("LEFT").apply(this,arguments)})],Ke=!0)},p(q,$){r=q,(!et||$&64&&s!==(s=r[6].x))&&b(i,"x",s),(!et||$&64&&n!==(n=r[6].y))&&b(i,"y",n),(!et||$&64&&o!==(o=r[6].w))&&b(i,"width",o),(!et||$&64&&a!==(a=r[6].h))&&b(i,"height",a),(!et||$&32&&h!==(h=r[5].x))&&b(l,"x",h),(!et||$&32&&u!==(u=r[5].y))&&b(l,"y",u),(!et||$&32&&c!==(c=r[5].w))&&b(l,"width",c),(!et||$&32&&d!==(d=r[5].h))&&b(l,"height",d),(!et||$&32&&m!==(m=r[5].x))&&b(p,"x",m),(!et||$&32&&_!==(_=r[5].y))&&b(p,"y",_),(!et||$&32&&y!==(y=r[5].w))&&b(p,"width",y),(!et||$&32&&v!==(v=r[5].h))&&b(p,"height",v),(!et||$&2)&&b(x,"style",r[1]),(!et||$&32&&T!==(T=r[5].x))&&b(x,"x",T),(!et||$&32&&M!==(M=r[5].y))&&b(x,"y",M),(!et||$&32&&S!==(S=r[5].w))&&b(x,"width",S),(!et||$&32&&R!==(R=r[5].h))&&b(x,"height",R),(!et||$&32&&U!==(U=r[5].x))&&b(F,"x",U),(!et||$&32&&I!==(I=r[5].y))&&b(F,"y",I),(!et||$&32&&A!==(A=r[5].w))&&b(F,"width",A),(!et||$&32&&L!==(L=r[5].x+r[5].w))&&b(C,"x",L),(!et||$&32&&O!==(O=r[5].y))&&b(C,"y",O),(!et||$&32&&B!==(B=r[5].h))&&b(C,"height",B),(!et||$&32&&N!==(N=r[5].x))&&b(D,"x",N),(!et||$&32&&H!==(H=r[5].y+r[5].h))&&b(D,"y",H),(!et||$&32&&k!==(k=r[5].w))&&b(D,"width",k),(!et||$&32&&pt!==(pt=r[5].x))&&b(Y,"x",pt),(!et||$&32&&_t!==(_t=r[5].y))&&b(Y,"y",_t),(!et||$&32&&W!==(W=r[5].h))&&b(Y,"height",W);const Ur={};$&32&&(Ur.x=r[5].x),$&32&&(Ur.y=r[5].y),$&8&&(Ur.scale=r[3]),nt.$set(Ur);const Gr={};$&32&&(Gr.x=r[5].x+r[5].w),$&32&&(Gr.y=r[5].y),$&8&&(Gr.scale=r[3]),vt.$set(Gr);const $r={};$&32&&($r.x=r[5].x+r[5].w),$&32&&($r.y=r[5].y+r[5].h),$&8&&($r.scale=r[3]),Dt.$set($r);const Hr={};$&32&&(Hr.x=r[5].x),$&32&&(Hr.y=r[5].y+r[5].h),$&8&&(Hr.scale=r[3]),Kt.$set(Hr)},i(q){et||(at(nt.$$.fragment,q),at(vt.$$.fragment,q),at(Dt.$$.fragment,q),at(Kt.$$.fragment,q),et=!0)},o(q){gt(nt.$$.fragment,q),gt(vt.$$.fragment,q),gt(Dt.$$.fragment,q),gt(Kt.$$.fragment,q),et=!1},d(q){q&&(rt(t),rt(f),rt(p),rt(g),rt(x),rt(P),rt(F),rt(w),rt(C),rt(V),rt(D),rt(z),rt(Y),rt(Et),rt(mt),rt(Mt),rt(ve)),ue(nt,q),ue(vt,q),ue(Dt,q),ue(Kt,q),Ke=!1,He(_n)}}}function C0(r){let t,e;return t=new Aa({props:{shape:r[0],transform:r[2],editor:r[7],svgEl:r[4],$$slots:{default:[S0,({grab:i})=>({12:i}),({grab:i})=>i?4096:0]},$$scope:{ctx:r}}}),t.$on("grab",r[9]),t.$on("change",r[10]),t.$on("release",r[11]),{c(){fe(t.$$.fragment)},m(i,s){he(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&16&&(n.svgEl=i[4]),s&12394&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(at(t.$$.fragment,i),e=!0)},o(i){gt(t.$$.fragment,i),e=!1},d(i){ue(t,i)}}}function I0(r,t,e){let i,s,{shape:n}=t,{computedStyle:o}=t,{transform:a}=t,{viewportScale:l=1}=t,{svgEl:h}=t;const u=(m,_,y)=>{const v=m.geometry.bounds;let[g,x]=[v.minX,v.minY],[T,M]=[v.maxX,v.maxY];const[S,R]=y;if(_==="SHAPE")g+=S,T+=S,x+=R,M+=R;else{switch(_){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{x+=R;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{M+=R;break}}switch(_){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{g+=S;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{T+=S;break}}}const P=Math.min(g,T),F=Math.min(x,M),U=Math.abs(T-g),I=Math.abs(M-x);return{...m,geometry:{x:P,y:F,w:U,h:I,bounds:{minX:P,minY:F,maxX:P+U,maxY:F+I}}}},c=`rect-mask-${Math.random().toString(36).substring(2,12)}`;function d(m){Ce.call(this,r,m)}function f(m){Ce.call(this,r,m)}function p(m){Ce.call(this,r,m)}return r.$$set=m=>{"shape"in m&&e(0,n=m.shape),"computedStyle"in m&&e(1,o=m.computedStyle),"transform"in m&&e(2,a=m.transform),"viewportScale"in m&&e(3,l=m.viewportScale),"svgEl"in m&&e(4,h=m.svgEl)},r.$$.update=()=>{r.$$.dirty&1&&e(5,i=n.geometry),r.$$.dirty&40&&e(6,s=On(i.bounds,2/l))},[n,o,a,l,h,i,s,u,c,d,f,p]}class R0 extends Pe{constructor(t){super(),Me(this,t,I0,C0,ne,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4})}}var sc=Object.prototype.hasOwnProperty;function Ra(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--&&Ra(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(sc.call(r,e)&&++i&&!sc.call(t,e)||!(e in t)||!Ra(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}const M0=12,P0=(r,t)=>r.polygons.reduce((e,i,s)=>{const n=i.rings.reduce((o,a,l)=>{const h=a.points.map((u,c)=>{const d=c===a.points.length-1?a.points[0]:a.points[c+1],f=(u[0]+d[0])/2,p=(u[1]+d[1])/2,m=Math.sqrt(Math.pow(d[0]-f,2)+Math.pow(d[1]-p,2))>M0/t;return{point:[f,p],visible:m,elementIdx:s,ringIdx:l,pointIdx:c}});return[...o,...h]},[]);return[...e,...n]},[]);function Ma(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function nc(r,t,e){const i=r.slice();return i[30]=t[e],i[32]=e,i}function oc(r,t,e){const i=r.slice();return i[33]=t[e],i[35]=e,i}function ac(r,t,e){const i=r.slice();return i[29]=t[e],i[37]=e,i}function Pa(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function Oa(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function lc(r){let t,e,i,s;return{c(){t=K("circle"),b(t,"cx",e=r[29][0]),b(t,"cy",i=r[29][1]),b(t,"r",s=Bs/r[3]),b(t,"class","svelte-1vxo6dc")},m(n,o){it(n,t,o)},p(n,o){o[0]&1088&&e!==(e=n[29][0])&&b(t,"cx",e),o[0]&1088&&i!==(i=n[29][1])&&b(t,"cy",i),o[0]&8&&s!==(s=Bs/n[3])&&b(t,"r",s)},d(n){n&&rt(t)}}}function hc(r){let t,e,i,s,n,o,a,l,h,u;return{c(){t=K("mask"),e=K("rect"),a=K("circle"),b(e,"x",i=r[9].x),b(e,"y",s=r[9].y),b(e,"width",n=r[9].w),b(e,"height",o=r[9].h),b(e,"class","svelte-1vxo6dc"),b(a,"cx",l=r[29][0]),b(a,"cy",h=r[29][1]),b(a,"r",u=Bs/r[3]),b(a,"class","svelte-1vxo6dc"),b(t,"id",`${r[18]}-${r[32]}-inner`),b(t,"class","a9s-multipolygon-editor-mask svelte-1vxo6dc")},m(c,d){it(c,t,d),Tt(t,e),Tt(t,a)},p(c,d){d[0]&512&&i!==(i=c[9].x)&&b(e,"x",i),d[0]&512&&s!==(s=c[9].y)&&b(e,"y",s),d[0]&512&&n!==(n=c[9].w)&&b(e,"width",n),d[0]&512&&o!==(o=c[9].h)&&b(e,"height",o),d[0]&1088&&l!==(l=c[29][0])&&b(a,"cx",l),d[0]&1088&&h!==(h=c[29][1])&&b(a,"cy",h),d[0]&8&&u!==(u=Bs/c[3])&&b(a,"r",u)},d(c){c&&rt(t)}}}function uc(r){let t,e;function i(...s){return r[19](r[32],r[35],r[37],...s)}return t=new Wi({props:{class:"a9s-corner-handle",x:r[29][0],y:r[29][1],scale:r[3],selected:r[8].some(i)}}),t.$on("pointerenter",r[11]),t.$on("pointerleave",r[12]),t.$on("pointerdown",r[14]),t.$on("pointerdown",function(){Vt(r[28](`HANDLE-${r[32]}-${r[35]}-${r[37]}`))&&r[28](`HANDLE-${r[32]}-${r[35]}-${r[37]}`).apply(this,arguments)}),t.$on("pointerup",r[15](r[32],r[35],r[37])),{c(){fe(t.$$.fragment)},m(s,n){he(t,s,n),e=!0},p(s,n){r=s;const o={};n[0]&32&&(o.x=r[29][0]),n[0]&32&&(o.y=r[29][1]),n[0]&8&&(o.scale=r[3]),n[0]&256&&(o.selected=r[8].some(i)),t.$set(o)},i(s){e||(at(t.$$.fragment,s),e=!0)},o(s){gt(t.$$.fragment,s),e=!1},d(s){ue(t,s)}}}function cc(r){let t,e,i=ke(r[33].points),s=[];for(let o=0;o<i.length;o+=1)s[o]=uc(ac(r,i,o));const n=o=>gt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Fe()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);it(o,t,a),e=!0},p(o,a){if(a[0]&268491048){i=ke(o[33].points);let l;for(l=0;l<i.length;l+=1){const h=ac(o,i,l);s[l]?(s[l].p(h,a),at(s[l],1)):(s[l]=uc(h),s[l].c(),at(s[l],1),s[l].m(t.parentNode,t))}for(Ie(),l=i.length;l<s.length;l+=1)n(l);Re()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)at(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)gt(s[a]);e=!1},d(o){o&&rt(t),mi(s,o)}}}function dc(r){let t,e,i,s,n,o,a,l,h,u,c,d,f,p,m,_,y,v=r[6]!==void 0&&!r[7]&&lc(Oa(r)),g=r[6]!==void 0&&!r[7]&&hc(Pa(r)),x=ke(r[30].rings),T=[];for(let S=0;S<x.length;S+=1)T[S]=cc(oc(r,x,S));const M=S=>gt(T[S],1,1,()=>{T[S]=null});return{c(){t=K("g"),e=K("defs"),i=K("mask"),s=K("rect"),h=K("path"),v&&v.c(),g&&g.c(),c=K("path"),f=K("path");for(let S=0;S<T.length;S+=1)T[S].c();b(s,"x",n=r[9].x),b(s,"y",o=r[9].y),b(s,"width",a=r[9].w),b(s,"height",l=r[9].h),b(s,"class","svelte-1vxo6dc"),b(h,"d",u=Ze(r[30])),b(h,"class","svelte-1vxo6dc"),b(i,"id",`${r[18]}-${r[32]}-outer`),b(i,"class","a9s-multipolygon-editor-mask svelte-1vxo6dc"),b(c,"class","a9s-outer"),b(c,"mask",`url(#${r[18]}-${r[32]}-outer)`),b(c,"fill-rule","evenodd"),b(c,"d",d=Ze(r[30])),b(f,"class","a9s-inner"),b(f,"mask",`url(#${r[18]}-${r[32]}-inner)`),b(f,"style",r[1]),b(f,"fill-rule","evenodd"),b(f,"d",p=Ze(r[30]))},m(S,R){it(S,t,R),Tt(t,e),Tt(e,i),Tt(i,s),Tt(i,h),v&&v.m(i,null),g&&g.m(e,null),Tt(t,c),Tt(t,f);for(let P=0;P<T.length;P+=1)T[P]&&T[P].m(t,null);m=!0,_||(y=[Rt(c,"pointerup",r[13]),Rt(c,"pointerdown",function(){Vt(r[28]("SHAPE"))&&r[28]("SHAPE").apply(this,arguments)}),Rt(f,"pointerup",r[13]),Rt(f,"pointerdown",function(){Vt(r[28]("SHAPE"))&&r[28]("SHAPE").apply(this,arguments)})],_=!0)},p(S,R){if(r=S,(!m||R[0]&512&&n!==(n=r[9].x))&&b(s,"x",n),(!m||R[0]&512&&o!==(o=r[9].y))&&b(s,"y",o),(!m||R[0]&512&&a!==(a=r[9].w))&&b(s,"width",a),(!m||R[0]&512&&l!==(l=r[9].h))&&b(s,"height",l),(!m||R[0]&32&&u!==(u=Ze(r[30])))&&b(h,"d",u),r[6]!==void 0&&!r[7]?v?v.p(Oa(r),R):(v=lc(Oa(r)),v.c(),v.m(i,null)):v&&(v.d(1),v=null),r[6]!==void 0&&!r[7]?g?g.p(Pa(r),R):(g=hc(Pa(r)),g.c(),g.m(e,null)):g&&(g.d(1),g=null),(!m||R[0]&32&&d!==(d=Ze(r[30])))&&b(c,"d",d),(!m||R[0]&2)&&b(f,"style",r[1]),(!m||R[0]&32&&p!==(p=Ze(r[30])))&&b(f,"d",p),R[0]&268491048){x=ke(r[30].rings);let P;for(P=0;P<x.length;P+=1){const F=oc(r,x,P);T[P]?(T[P].p(F,R),at(T[P],1)):(T[P]=cc(F),T[P].c(),at(T[P],1),T[P].m(t,null))}for(Ie(),P=x.length;P<T.length;P+=1)M(P);Re()}},i(S){if(!m){for(let R=0;R<x.length;R+=1)at(T[R]);m=!0}},o(S){T=T.filter(Boolean);for(let R=0;R<T.length;R+=1)gt(T[R]);m=!1},d(S){S&&rt(t),v&&v.d(),g&&g.d(),mi(T,S),_=!1,He(y)}}}function fc(r){let t,e;return t=new qu({props:{x:r[29][0],y:r[29][1],scale:r[3]}}),t.$on("pointerdown",function(){Vt(r[17](r[6]))&&r[17](r[6]).apply(this,arguments)}),{c(){fe(t.$$.fragment)},m(i,s){he(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&1088&&(n.x=r[29][0]),s[0]&1088&&(n.y=r[29][1]),s[0]&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(at(t.$$.fragment,i),e=!0)},o(i){gt(t.$$.fragment,i),e=!1},d(i){ue(t,i)}}}function O0(r){let t,e,i,s=ke(r[5].polygons),n=[];for(let l=0;l<s.length;l+=1)n[l]=dc(nc(r,s,l));const o=l=>gt(n[l],1,1,()=>{n[l]=null});let a=r[6]!==void 0&&!r[7]&&fc(Ma(r));return{c(){for(let l=0;l<n.length;l+=1)n[l].c();t=De(),a&&a.c(),e=Fe()},m(l,h){for(let u=0;u<n.length;u+=1)n[u]&&n[u].m(l,h);it(l,t,h),a&&a.m(l,h),it(l,e,h),i=!0},p(l,h){if(h[0]&268763114){s=ke(l[5].polygons);let u;for(u=0;u<s.length;u+=1){const c=nc(l,s,u);n[u]?(n[u].p(c,h),at(n[u],1)):(n[u]=dc(c),n[u].c(),at(n[u],1),n[u].m(t.parentNode,t))}for(Ie(),u=s.length;u<n.length;u+=1)o(u);Re()}l[6]!==void 0&&!l[7]?a?(a.p(Ma(l),h),h[0]&192&&at(a,1)):(a=fc(Ma(l)),a.c(),at(a,1),a.m(e.parentNode,e)):a&&(Ie(),gt(a,1,1,()=>{a=null}),Re())},i(l){if(!i){for(let h=0;h<s.length;h+=1)at(n[h]);at(a),i=!0}},o(l){n=n.filter(Boolean);for(let h=0;h<n.length;h+=1)gt(n[h]);gt(a),i=!1},d(l){l&&(rt(t),rt(e)),mi(n,l),a&&a.d(l)}}}function N0(r){let t,e;return t=new Aa({props:{shape:r[0],transform:r[2],editor:r[16],svgEl:r[4],$$slots:{default:[O0,({grab:i})=>({28:i}),({grab:i})=>[i?268435456:0]]},$$scope:{ctx:r}}}),t.$on("change",r[20]),t.$on("grab",r[21]),t.$on("release",r[22]),{c(){fe(t.$$.fragment)},m(i,s){he(t,i,s),e=!0},p(i,s){const n={};s[0]&1&&(n.shape=i[0]),s[0]&4&&(n.transform=i[2]),s[0]&16&&(n.svgEl=i[4]),s[0]&268437482|s[1]&128&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(at(t.$$.fragment,i),e=!0)},o(i){gt(t.$$.fragment,i),e=!1},d(i){ue(t,i)}}}const D0=250,L0=1e3,Bs=4.5;function B0(r,t,e){let i,s,n;const o=Vr();let{shape:a}=t,{computedStyle:l}=t,{transform:h}=t,{viewportScale:u=1}=t,{svgEl:c}=t,d,f=!1,p,m=[];const _=()=>e(7,f=!0),y=()=>e(7,f=!1),v=C=>{if(m.length>0||!s.some(H=>H.visible)){e(6,d=void 0);return}const[L,O]=h.elementToImage(C.offsetX,C.offsetY),B=H=>Math.pow(H[0]-L,2)+Math.pow(H[1]-O,2),V=Dy(i).reduce((H,k)=>B(k)<B(H)?k:H),D=s.filter(H=>H.visible).reduce((H,k)=>B(k.point)<B(H.point)?k:H),N=Math.pow(L0/u,2);B(V)<N||B(D.point)<N?e(6,d=s.indexOf(D)):e(6,d=void 0)},g=()=>{document.activeElement!==c&&c.focus()},x=()=>{e(8,m=[]),g()},T=C=>{e(7,f=!0),C.preventDefault(),C.stopPropagation(),p=performance.now()},M=(C,L,O)=>B=>{if(!p||Cr||performance.now()-p>D0)return;const V=N=>N.polygon===C&&N.ring===L&&N.point===O,D=m.some(V);B.metaKey||B.ctrlKey||B.shiftKey?D?e(8,m=m.filter(N=>!V(N))):e(8,m=[...m,{polygon:C,ring:L,point:O}]):D&&m.length>1?e(8,m=[{polygon:C,ring:L,point:O}]):D?e(8,m=[]):e(8,m=[{polygon:C,ring:L,point:O}]),g()},S=(C,L,O)=>{g();const B=C.geometry.polygons;let V;if(L==="SHAPE")V=B.map(D=>{const N=D.rings.map((k,z)=>({points:k.points.map((Y,pt)=>[Y[0]+O[0],Y[1]+O[1]])})),H=Ue(N[0].points);return{rings:N,bounds:H}});else{const[D,N,H,k]=L.split("-").map(z=>parseInt(z));V=B.map((z,Y)=>{if(Y===N){const pt=z.rings.map((W,Et)=>Et===H?{points:W.points.map((nt,mt)=>mt===k?[nt[0]+O[0],nt[1]+O[1]]:nt)}:W),_t=Ue(pt[0].points);return{rings:pt,bounds:_t}}else return z})}return{...C,geometry:{polygons:V,bounds:ga(V)}}},R=C=>async L=>{L.stopPropagation();const O=s[C],B=i.polygons.map((D,N)=>{if(N===O.elementIdx){const H=D.rings.map((z,Y)=>Y===O.ringIdx?{points:[...z.points.slice(0,O.pointIdx+1),O.point,...z.points.slice(O.pointIdx+1)]}:z),k=Ue(H[0].points);return{rings:H,bounds:k}}else return D});o("change",{...a,geometry:{polygons:B,bounds:ga(B)}}),await Au();const V=[...document.querySelectorAll(".a9s-handle")][C+1];if(V!=null&&V.firstChild){const D=new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:L.clientX,clientY:L.clientY,pointerId:L.pointerId,pointerType:L.pointerType,isPrimary:L.isPrimary,buttons:L.buttons});V.firstChild.dispatchEvent(D)}},P=()=>{const C=i.polygons.map((L,O)=>{if(m.some(B=>B.polygon===O)){const B=L.rings.map((D,N)=>{const H=m.filter(k=>k.polygon===O&&k.ring===N);return H.length&&D.points.length-H.length>=3?{points:D.points.filter((k,z)=>!H.some(Y=>Y.point===z))}:D}),V=Ue(B[0].points);return{rings:B,bounds:V}}else return L});!Ra(i.polygons,C)&&(o("change",{...a,geometry:{polygons:C,bounds:ga(C)}}),e(8,m=[]))};gi(()=>{if(Cr)return;const C=L=>{(L.key==="Delete"||L.key==="Backspace")&&(L.preventDefault(),P())};return c.addEventListener("pointermove",v),c.addEventListener("keydown",C),()=>{c.removeEventListener("pointermove",v),c.removeEventListener("keydown",C)}});const F=`polygon-mask-${Math.random().toString(36).substring(2,12)}`,U=(C,L,O,{polygon:B,ring:V,point:D})=>B===C&&V===L&&D===O;function I(C){Ce.call(this,r,C)}function A(C){Ce.call(this,r,C)}function w(C){Ce.call(this,r,C)}return r.$$set=C=>{"shape"in C&&e(0,a=C.shape),"computedStyle"in C&&e(1,l=C.computedStyle),"transform"in C&&e(2,h=C.transform),"viewportScale"in C&&e(3,u=C.viewportScale),"svgEl"in C&&e(4,c=C.svgEl)},r.$$.update=()=>{r.$$.dirty[0]&1&&e(5,i=a.geometry),r.$$.dirty[0]&40&&e(10,s=Cr?[]:P0(i,u)),r.$$.dirty[0]&40&&e(9,n=On(i.bounds,Bs/u))},[a,l,h,u,c,i,d,f,m,n,s,_,y,x,T,M,S,R,F,U,I,A,w]}class F0 extends Pe{constructor(t){super(),Me(this,t,B0,N0,ne,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}const pc=new Map([[xt.RECTANGLE,R0],[xt.POLYGON,A0],[xt.MULTIPOLYGON,F0]]),mc=r=>pc.get(r.type),gc=(r,t)=>pc.set(r,t);function k0(r,t,e){let i;const s=Vr();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:u}=t,c;return gi(()=>(e(6,c=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:u,svgEl:l.closest("svg")}})),c.$on("change",d=>{c.$$set({shape:d.detail}),s("change",d.detail)}),c.$on("grab",d=>s("grab",d.detail)),c.$on("release",d=>s("release",d.detail)),()=>{c.$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,u=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=ji(n,a)),r.$$.dirty&65&&n&&(c==null||c.$set({shape:n.target.selector})),r.$$.dirty&80&&c&&c.$set({transform:h}),r.$$.dirty&96&&c&&c.$set({viewportScale:u}),r.$$.dirty&192&&c&&i&&c.$set({computedStyle:i})},[n,o,a,l,h,u,c,i]}class U0 extends Pe{constructor(t){super(),Me(this,t,k0,null,ne,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}function G0(r,t,e){const i=Vr();let{drawingMode:s}=t,{target:n}=t,{tool:o}=t,{transform:a}=t,{viewportScale:l}=t,h;return gi(()=>{const u=n.closest("svg"),c=[],d=(f,p,m)=>{u==null||u.addEventListener(f,p,m),c.push(()=>u==null?void 0:u.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)),()=>{c.forEach(f=>f()),h.$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),"viewportScale"in u&&e(4,l=u.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 $0 extends Pe{constructor(t){super(),Me(this,t,G0,null,ne,{drawingMode:0,target:1,tool:2,transform:3,viewportScale:4})}}function yc(r){let t,e,i,s,n,o,a,l,h,u;return{c(){t=K("defs"),e=K("mask"),i=K("rect"),l=K("rect"),h=K("rect"),u=K("rect"),b(i,"class","rect-mask-bg svelte-1a76qe7"),b(i,"x",s=r[1]-r[5]),b(i,"y",n=r[2]-r[5]),b(i,"width",o=r[3]+2*r[5]),b(i,"height",a=r[4]+2*r[5]),b(l,"class","rect-mask-fg svelte-1a76qe7"),b(l,"x",r[1]),b(l,"y",r[2]),b(l,"width",r[3]),b(l,"height",r[4]),b(e,"id",r[6]),b(e,"class","a9s-rubberband-rectangle-mask svelte-1a76qe7"),b(h,"class","a9s-outer"),b(h,"mask",`url(#${r[6]})`),b(h,"x",r[1]),b(h,"y",r[2]),b(h,"width",r[3]),b(h,"height",r[4]),b(u,"class","a9s-inner"),b(u,"x",r[1]),b(u,"y",r[2]),b(u,"width",r[3]),b(u,"height",r[4])},m(c,d){it(c,t,d),Tt(t,e),Tt(e,i),Tt(e,l),it(c,h,d),it(c,u,d)},p(c,d){d&34&&s!==(s=c[1]-c[5])&&b(i,"x",s),d&36&&n!==(n=c[2]-c[5])&&b(i,"y",n),d&40&&o!==(o=c[3]+2*c[5])&&b(i,"width",o),d&48&&a!==(a=c[4]+2*c[5])&&b(i,"height",a),d&2&&b(l,"x",c[1]),d&4&&b(l,"y",c[2]),d&8&&b(l,"width",c[3]),d&16&&b(l,"height",c[4]),d&2&&b(h,"x",c[1]),d&4&&b(h,"y",c[2]),d&8&&b(h,"width",c[3]),d&16&&b(h,"height",c[4]),d&2&&b(u,"x",c[1]),d&4&&b(u,"y",c[2]),d&8&&b(u,"width",c[3]),d&16&&b(u,"height",c[4])},d(c){c&&(rt(t),rt(h),rt(u))}}}function H0(r){let t,e=r[0]&&yc(r);return{c(){t=K("g"),e&&e.c(),b(t,"class","a9s-annotation a9s-rubberband")},m(i,s){it(i,t,s),e&&e.m(t,null)},p(i,[s]){i[0]?e?e.p(i,s):(e=yc(i),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:Pt,o:Pt,d(i){i&&rt(t),e&&e.d()}}}function X0(r,t,e){let i;const s=Vr();let{addEventListener:n}=t,{drawingMode:o}=t,{transform:a}=t,{viewportScale:l=1}=t,h,u,c,d,f,p,m;const _=T=>{const M=T;h=performance.now(),o==="drag"&&(e(0,u=a.elementToImage(M.offsetX,M.offsetY)),c=u,e(1,d=u[0]),e(2,f=u[1]),e(3,p=1),e(4,m=1))},y=T=>{const M=T;u&&(c=a.elementToImage(M.offsetX,M.offsetY),e(1,d=Math.min(c[0],u[0])),e(2,f=Math.min(c[1],u[1])),e(3,p=Math.abs(c[0]-u[0])),e(4,m=Math.abs(c[1]-u[1])))},v=T=>{const M=T,S=performance.now()-h;if(o==="click"){if(S>300)return;u?g():(e(0,u=a.elementToImage(M.offsetX,M.offsetY)),c=u,e(1,d=u[0]),e(2,f=u[1]),e(3,p=1),e(4,m=1))}else u&&(S>300||p*m>100?(M.stopPropagation(),g()):(e(0,u=void 0),c=void 0))},g=()=>{if(p*m>15){const T={type:xt.RECTANGLE,geometry:{bounds:{minX:d,minY:f,maxX:d+p,maxY:f+m},x:d,y:f,w:p,h:m}};s("create",T)}e(0,u=void 0),c=void 0};gi(()=>{n("pointerdown",_),n("pointermove",y),n("pointerup",v,!0)});const x=`rect-mask-${Math.random().toString(36).substring(2,12)}`;return r.$$set=T=>{"addEventListener"in T&&e(7,n=T.addEventListener),"drawingMode"in T&&e(8,o=T.drawingMode),"transform"in T&&e(9,a=T.transform),"viewportScale"in T&&e(10,l=T.viewportScale)},r.$$.update=()=>{r.$$.dirty&1024&&e(5,i=2/l)},[u,d,f,p,m,i,x,n,o,a,l]}class V0 extends Pe{constructor(t){super(),Me(this,t,X0,H0,ne,{addEventListener:7,drawingMode:8,transform:9,viewportScale:10})}}function Na(r){const t=r.slice(),e=t[2].map(i=>i.join(",")).join(" ");return t[19]=e,t}function _c(r){let t,e,i,s,n,o,a,l,h,u,c,d,f,p,m=r[1]&&vc(r);return{c(){t=K("defs"),e=K("mask"),i=K("rect"),l=K("polygon"),u=K("polygon"),d=K("polygon"),m&&m.c(),p=Fe(),b(i,"x",s=r[3].x),b(i,"y",n=r[3].y),b(i,"width",o=r[3].w),b(i,"height",a=r[3].h),b(i,"class","svelte-18wrg3t"),b(l,"points",h=r[19]),b(l,"class","svelte-18wrg3t"),b(e,"id",r[5]),b(e,"class","a9s-rubberband-polygon-mask svelte-18wrg3t"),b(u,"class","a9s-outer"),b(u,"mask",`url(#${r[5]})`),b(u,"points",c=r[19]),b(d,"class","a9s-inner"),b(d,"points",f=r[19])},m(_,y){it(_,t,y),Tt(t,e),Tt(e,i),Tt(e,l),it(_,u,y),it(_,d,y),m&&m.m(_,y),it(_,p,y)},p(_,y){y&8&&s!==(s=_[3].x)&&b(i,"x",s),y&8&&n!==(n=_[3].y)&&b(i,"y",n),y&8&&o!==(o=_[3].w)&&b(i,"width",o),y&8&&a!==(a=_[3].h)&&b(i,"height",a),y&4&&h!==(h=_[19])&&b(l,"points",h),y&4&&c!==(c=_[19])&&b(u,"points",c),y&4&&f!==(f=_[19])&&b(d,"points",f),_[1]?m?m.p(_,y):(m=vc(_),m.c(),m.m(p.parentNode,p)):m&&(m.d(1),m=null)},d(_){_&&(rt(t),rt(u),rt(d),rt(p)),m&&m.d(_)}}}function vc(r){let t,e,i;return{c(){t=K("circle"),b(t,"class","a9s-handle svelte-18wrg3t"),b(t,"cx",e=r[0][0][0]),b(t,"cy",i=r[0][0][1]),b(t,"r",r[4])},m(s,n){it(s,t,n)},p(s,n){n&1&&e!==(e=s[0][0][0])&&b(t,"cx",e),n&1&&i!==(i=s[0][0][1])&&b(t,"cy",i),n&16&&b(t,"r",s[4])},d(s){s&&rt(t)}}}function z0(r){let t,e=r[3]&&_c(Na(r));return{c(){t=K("g"),e&&e.c(),b(t,"class","a9s-annotation a9s-rubberband")},m(i,s){it(i,t,s),e&&e.m(t,null)},p(i,[s]){i[3]?e?e.p(Na(i),s):(e=_c(Na(i)),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:Pt,o:Pt,d(i){i&&rt(t),e&&e.d()}}}const Y0=20,j0=1500;function W0(r,t,e){let i,s,n;const o=Vr();let{addEventListener:a}=t,{drawingMode:l}=t,{transform:h}=t,{viewportScale:u=1}=t,c,d=[],f,p,m=!1;const _=M=>{const S=M,{timeStamp:R,offsetX:P,offsetY:F}=S;if(c={timeStamp:R,offsetX:P,offsetY:F},l==="drag"&&d.length===0){const U=h.elementToImage(S.offsetX,S.offsetY);d.push(U),e(10,f=U)}},y=M=>{const S=M;if(p&&clearTimeout(p),d.length>0){if(e(10,f=h.elementToImage(S.offsetX,S.offsetY)),d.length>2){const R=Sn(f,d[0])*u;e(1,m=R<Y0)}S.pointerType==="touch"&&(p=setTimeout(()=>{g()},j0))}},v=M=>{const S=M;if(p&&clearTimeout(p),l==="click"){const R=S.timeStamp-c.timeStamp,P=Sn([c.offsetX,c.offsetY],[S.offsetX,S.offsetY]);if(R>300||P>15)return;if(m)x();else if(d.length===0){const F=h.elementToImage(S.offsetX,S.offsetY);d.push(F),e(10,f=F)}else d.push(f)}else{if(d.length===1&&Sn(d[0],f)<=4){e(0,d=[]),e(10,f=void 0);return}S.stopImmediatePropagation(),m?x():d.push(f)}},g=()=>{if(!f)return;const M=d.slice(0,-1);if(M.length<3)return;const S={type:xt.POLYGON,geometry:{bounds:Ue(d),points:M}};fa(S)>4&&(e(0,d=[]),e(10,f=void 0),o("create",S))},x=()=>{const M={type:xt.POLYGON,geometry:{bounds:Ue(d),points:[...d]}};e(0,d=[]),e(10,f=void 0),o("create",M)};gi(()=>{a("pointerdown",_,!0),a("pointermove",y),a("pointerup",v,!0),a("dblclick",g,!0)});const T=`polygon-mask-${Math.random().toString(36).substring(2,12)}`;return r.$$set=M=>{"addEventListener"in M&&e(6,a=M.addEventListener),"drawingMode"in M&&e(7,l=M.drawingMode),"transform"in M&&e(8,h=M.transform),"viewportScale"in M&&e(9,u=M.viewportScale)},r.$$.update=()=>{r.$$.dirty&512&&e(4,i=4/u),r.$$.dirty&1027&&e(2,s=f?m?d:[...d,f]:[]),r.$$.dirty&516&&e(3,n=s.length>0?On(Ue(s),2/u):void 0)},[d,m,s,n,i,T,a,l,h,u,f]}class q0 extends Pe{constructor(t){super(),Me(this,t,W0,z0,ne,{addEventListener:6,drawingMode:7,transform:8,viewportScale:9})}}const Da=new Map([["rectangle",{tool:V0}],["polygon",{tool:q0}]]),Nn=()=>[...Da.keys()],Dn=r=>Da.get(r),xc=(r,t,e={})=>Da.set(r,{tool:t,opts:e});function K0(r){let t,e,i,s,n;return{c(){t=K("g"),e=K("ellipse"),s=K("ellipse"),b(e,"class","a9s-outer"),b(e,"style",i=r[1]?"display:none;":void 0),b(e,"cx",r[2]),b(e,"cy",r[3]),b(e,"rx",r[4]),b(e,"ry",r[5]),b(s,"class","a9s-inner"),b(s,"style",r[1]),b(s,"cx",r[2]),b(s,"cy",r[3]),b(s,"rx",r[4]),b(s,"ry",r[5]),b(t,"class","a9s-annotation"),b(t,"data-id",n=r[0].id)},m(o,a){it(o,t,a),Tt(t,e),Tt(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&b(e,"style",i),a&2&&b(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&b(t,"data-id",n)},i:Pt,o:Pt,d(o){o&&rt(t)}}}function Z0(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:o}=t;const{cx:a,cy:l,rx:h,ry:u}=n;return r.$$set=c=>{"annotation"in c&&e(0,s=c.annotation),"geom"in c&&e(6,n=c.geom),"style"in c&&e(7,o=c.style)},r.$$.update=()=>{r.$$.dirty&129&&e(1,i=ji(s,o))},[s,i,a,l,h,u,n,o]}class Q0 extends Pe{constructor(t){super(),Me(this,t,Z0,K0,ne,{annotation:0,geom:6,style:7})}}function bc(r,t,e){const i=r.slice();return i[5]=t[e],i}function Ec(r){let t,e,i;return{c(){t=K("path"),i=K("path"),b(t,"class","a9s-outer"),b(t,"style",e=r[1]?"display:none;":void 0),b(t,"fill-rule","evenodd"),b(t,"d",Ze(r[5])),b(i,"class","a9s-inner"),b(i,"style",r[1]),b(i,"fill-rule","evenodd"),b(i,"d",Ze(r[5]))},m(s,n){it(s,t,n),it(s,i,n)},p(s,n){n&2&&e!==(e=s[1]?"display:none;":void 0)&&b(t,"style",e),n&2&&b(i,"style",s[1])},d(s){s&&(rt(t),rt(i))}}}function J0(r){let t,e,i=ke(r[2]),s=[];for(let n=0;n<i.length;n+=1)s[n]=Ec(bc(r,i,n));return{c(){t=K("g");for(let n=0;n<s.length;n+=1)s[n].c();b(t,"class","a9s-annotation"),b(t,"data-id",e=r[0].id)},m(n,o){it(n,t,o);for(let a=0;a<s.length;a+=1)s[a]&&s[a].m(t,null)},p(n,[o]){if(o&6){i=ke(n[2]);let a;for(a=0;a<i.length;a+=1){const l=bc(n,i,a);s[a]?s[a].p(l,o):(s[a]=Ec(l),s[a].c(),s[a].m(t,null))}for(;a<s.length;a+=1)s[a].d(1);s.length=i.length}o&1&&e!==(e=n[0].id)&&b(t,"data-id",e)},i:Pt,o:Pt,d(n){n&&rt(t),mi(s,n)}}}function tv(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:o}=t;const{polygons: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=ji(s,o))},[s,i,a,n,o]}class ev extends Pe{constructor(t){super(),Me(this,t,tv,J0,ne,{annotation:0,geom:3,style:4})}}function rv(r){let t,e,i,s,n;return{c(){t=K("g"),e=K("polygon"),s=K("polygon"),b(e,"class","a9s-outer"),b(e,"style",i=r[1]?"display:none;":void 0),b(e,"points",r[2].map(iv).join(" ")),b(s,"class","a9s-inner"),b(s,"style",r[1]),b(s,"points",r[2].map(sv).join(" ")),b(t,"class","a9s-annotation"),b(t,"data-id",n=r[0].id)},m(o,a){it(o,t,a),Tt(t,e),Tt(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&b(e,"style",i),a&2&&b(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&b(t,"data-id",n)},i:Pt,o:Pt,d(o){o&&rt(t)}}}const iv=r=>r.join(","),sv=r=>r.join(",");function nv(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=ji(s,o))},[s,i,a,n,o]}class ov extends Pe{constructor(t){super(),Me(this,t,nv,rv,ne,{annotation:0,geom:3,style:4})}}function av(r){let t,e,i,s,n;return{c(){t=K("g"),e=K("rect"),s=K("rect"),b(e,"class","a9s-outer"),b(e,"style",i=r[5]?"display:none;":void 0),b(e,"x",r[4]),b(e,"y",r[3]),b(e,"width",r[2]),b(e,"height",r[1]),b(s,"class","a9s-inner"),b(s,"style",r[5]),b(s,"x",r[4]),b(s,"y",r[3]),b(s,"width",r[2]),b(s,"height",r[1]),b(t,"class","a9s-annotation"),b(t,"data-id",n=r[0].id)},m(o,a){it(o,t,a),Tt(t,e),Tt(t,s)},p(o,[a]){a&32&&i!==(i=o[5]?"display:none;":void 0)&&b(e,"style",i),a&16&&b(e,"x",o[4]),a&8&&b(e,"y",o[3]),a&4&&b(e,"width",o[2]),a&2&&b(e,"height",o[1]),a&32&&b(s,"style",o[5]),a&16&&b(s,"x",o[4]),a&8&&b(s,"y",o[3]),a&4&&b(s,"width",o[2]),a&2&&b(s,"height",o[1]),a&1&&n!==(n=o[0].id)&&b(t,"data-id",n)},i:Pt,o:Pt,d(o){o&&rt(t)}}}function lv(r,t,e){let i,s,n,o,a,{annotation:l}=t,{geom:h}=t,{style:u}=t;return r.$$set=c=>{"annotation"in c&&e(0,l=c.annotation),"geom"in c&&e(6,h=c.geom),"style"in c&&e(7,u=c.style)},r.$$.update=()=>{r.$$.dirty&129&&e(5,i=ji(l,u)),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,u]}class hv extends Pe{constructor(t){super(),Me(this,t,lv,av,ne,{annotation:0,geom:6,style:7})}}function uv(r){let t,e,i,s,n;return{c(){t=K("g"),e=K("line"),s=K("line"),b(e,"class","a9s-outer"),b(e,"style",i=r[1]?"display:none;":void 0),b(e,"x1",r[2]),b(e,"y1",r[3]),b(e,"x2",r[4]),b(e,"y2",r[5]),b(s,"class","a9s-inner"),b(s,"style",r[1]),b(s,"x1",r[2]),b(s,"y1",r[3]),b(s,"x2",r[4]),b(s,"y2",r[5]),b(t,"class","a9s-annotation"),b(t,"data-id",n=r[0].id)},m(o,a){it(o,t,a),Tt(t,e),Tt(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&b(e,"style",i),a&2&&b(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&b(t,"data-id",n)},i:Pt,o:Pt,d(o){o&&rt(t)}}}function cv(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:o}=t;const{points:a}=n,[[l,h],[u,c]]=a;return r.$$set=d=>{"annotation"in d&&e(0,s=d.annotation),"geom"in d&&e(6,n=d.geom),"style"in d&&e(7,o=d.style)},r.$$.update=()=>{r.$$.dirty&129&&e(1,i=ji(s,o))},[s,i,l,h,u,c,n,o]}class dv extends Pe{constructor(t){super(),Me(this,t,cv,uv,ne,{annotation:0,geom:6,style:7})}}const fv=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]}}),pv=250,mv=(r,t)=>{const e=Vr();let i;return{onPointerDown:()=>i=performance.now(),onPointerUp:s=>{if(performance.now()-i<pv){const{x:n,y:o}=wc(s,r),a=t.getAt(n,o);a?e("click",{originalEvent:s,annotation:a}):e("click",{originalEvent:s})}}}},wc=(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())};function Tc(r,t,e){const i=r.slice();i[39]=t[e];const s=i[24](i[39].target.selector);return i[40]=s,i}function Ac(r,t,e){const i=r.slice();return i[43]=t[e],i}function La(r){const t=r.slice(),e=t[43].target.selector;return t[46]=e,t}function Sc(r){let t=r[43],e,i,s=Cc(r);return{c(){s.c(),e=Fe()},m(n,o){s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&65536&&ne(t,t=n[43])?(Ie(),gt(s,1,1,Pt),Re(),s=Cc(n),s.c(),at(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(at(s),i=!0)},o(n){gt(s),i=!1},d(n){n&&rt(e),s.d(n)}}}function gv(r){let t,e;return t=new dv({props:{annotation:r[43],geom:r[46].geometry,style:r[1]}}),{c(){fe(t.$$.fragment)},m(i,s){he(t,i,s),e=!0},p(i,s){const n={};s[0]&65536&&(n.annotation=i[43]),s[0]&65536&&(n.geom=i[46].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(at(t.$$.fragment,i),e=!0)},o(i){gt(t.$$.fragment,i),e=!1},d(i){ue(t,i)}}}function yv(r){let t,e;return t=new ev({props:{annotation:r[43],geom:r[46].geometry,style:r[1]}}),{c(){fe(t.$$.fragment)},m(i,s){he(t,i,s),e=!0},p(i,s){const n={};s[0]&65536&&(n.annotation=i[43]),s[0]&65536&&(n.geom=i[46].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(at(t.$$.fragment,i),e=!0)},o(i){gt(t.$$.fragment,i),e=!1},d(i){ue(t,i)}}}function _v(r){let t,e;return t=new ov({props:{annotation:r[43],geom:r[46].geometry,style:r[1]}}),{c(){fe(t.$$.fragment)},m(i,s){he(t,i,s),e=!0},p(i,s){const n={};s[0]&65536&&(n.annotation=i[43]),s[0]&65536&&(n.geom=i[46].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(at(t.$$.fragment,i),e=!0)},o(i){gt(t.$$.fragment,i),e=!1},d(i){ue(t,i)}}}function vv(r){let t,e;return t=new hv({props:{annotation:r[43],geom:r[46].geometry,style:r[1]}}),{c(){fe(t.$$.fragment)},m(i,s){he(t,i,s),e=!0},p(i,s){const n={};s[0]&65536&&(n.annotation=i[43]),s[0]&65536&&(n.geom=i[46].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(at(t.$$.fragment,i),e=!0)},o(i){gt(t.$$.fragment,i),e=!1},d(i){ue(t,i)}}}function xv(r){var t;let e,i;return e=new Q0({props:{annotation:r[43],geom:(t=r[46])==null?void 0:t.geometry,style:r[1]}}),{c(){fe(e.$$.fragment)},m(s,n){he(e,s,n),i=!0},p(s,n){var o;const a={};n[0]&65536&&(a.annotation=s[43]),n[0]&65536&&(a.geom=(o=s[46])==null?void 0:o.geometry),n[0]&2&&(a.style=s[1]),e.$set(a)},i(s){i||(at(e.$$.fragment,s),i=!0)},o(s){gt(e.$$.fragment,s),i=!1},d(s){ue(e,s)}}}function Cc(r){let t,e,i,s;const n=[xv,vv,_v,yv,gv],o=[];function a(l,h){var u,c,d,f,p;return((u=l[46])==null?void 0:u.type)===xt.ELLIPSE?0:((c=l[46])==null?void 0:c.type)===xt.RECTANGLE?1:((d=l[46])==null?void 0:d.type)===xt.POLYGON?2:((f=l[46])==null?void 0:f.type)===xt.MULTIPOLYGON?3:((p=l[46])==null?void 0:p.type)===xt.LINE?4:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Fe()},m(l,h){~t&&o[t].m(l,h),it(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(Ie(),gt(o[u],1,1,()=>{o[u]=null}),Re()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),at(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(at(e),s=!0)},o(l){gt(e),s=!1},d(l){l&&rt(i),~t&&o[t].d(l)}}}function Ic(r){let t=ze(r[43])&&!r[9](r[43]),e,i,s=t&&Sc(La(r));return{c(){s&&s.c(),e=Fe()},m(n,o){s&&s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&66048&&(t=ze(n[43])&&!n[9](n[43])),t?s?(s.p(La(n),o),o[0]&66048&&at(s,1)):(s=Sc(La(n)),s.c(),at(s,1),s.m(e.parentNode,e)):s&&(Ie(),gt(s,1,1,()=>{s=null}),Re())},i(n){i||(at(s),i=!0)},o(n){gt(s),i=!1},d(n){n&&rt(e),s&&s.d(n)}}}function Rc(r){let t,e,i,s;const n=[Ev,bv],o=[];function a(l,h){return l[8]?0:l[14]&&l[0]?1:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Fe()},m(l,h){~t&&o[t].m(l,h),it(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(Ie(),gt(o[u],1,1,()=>{o[u]=null}),Re()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),at(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(at(e),s=!0)},o(l){gt(e),s=!1},d(l){l&&rt(i),~t&&o[t].d(l)}}}function bv(r){let t=`${r[2]}-${r[5]}`,e,i,s=Mc(r);return{c(){s.c(),e=Fe()},m(n,o){s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&36&&ne(t,t=`${n[2]}-${n[5]}`)?(Ie(),gt(s,1,1,Pt),Re(),s=Mc(n),s.c(),at(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(at(s),i=!0)},o(n){gt(s),i=!1},d(n){n&&rt(e),s.d(n)}}}function Ev(r){let t,e,i=ke(r[8]),s=[];for(let o=0;o<i.length;o+=1)s[o]=Nc(Tc(r,i,o));const n=o=>gt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Fe()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);it(o,t,a),e=!0},p(o,a){if(a[0]&21107010){i=ke(o[8]);let l;for(l=0;l<i.length;l+=1){const h=Tc(o,i,l);s[l]?(s[l].p(h,a),at(s[l],1)):(s[l]=Nc(h),s[l].c(),at(s[l],1),s[l].m(t.parentNode,t))}for(Ie(),l=i.length;l<s.length;l+=1)n(l);Re()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)at(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)gt(s[a]);e=!1},d(o){o&&rt(t),mi(s,o)}}}function Mc(r){let t,e;return t=new $0({props:{target:r[6],tool:r[14],drawingMode:r[13],transform:r[12],viewportScale:r[17]}}),t.$on("create",r[21]),{c(){fe(t.$$.fragment)},m(i,s){he(t,i,s),e=!0},p(i,s){const n={};s[0]&64&&(n.target=i[6]),s[0]&16384&&(n.tool=i[14]),s[0]&8192&&(n.drawingMode=i[13]),s[0]&4096&&(n.transform=i[12]),s[0]&131072&&(n.viewportScale=i[17]),t.$set(n)},i(i){e||(at(t.$$.fragment,i),e=!0)},o(i){gt(t.$$.fragment,i),e=!1},d(i){ue(t,i)}}}function Pc(r){let t=r[39].id,e,i,s=Oc(r);return{c(){s.c(),e=Fe()},m(n,o){s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&256&&ne(t,t=n[39].id)?(Ie(),gt(s,1,1,Pt),Re(),s=Oc(n),s.c(),at(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(at(s),i=!0)},o(n){gt(s),i=!1},d(n){n&&rt(e),s.d(n)}}}function Oc(r){let t,e;return t=new U0({props:{target:r[6],editor:r[24](r[39].target.selector),annotation:r[39],style:r[1],transform:r[12],viewportScale:r[17]}}),t.$on("change",function(){Vt(r[22](r[39]))&&r[22](r[39]).apply(this,arguments)}),{c(){fe(t.$$.fragment)},m(i,s){he(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&64&&(n.target=r[6]),s[0]&256&&(n.editor=r[24](r[39].target.selector)),s[0]&256&&(n.annotation=r[39]),s[0]&2&&(n.style=r[1]),s[0]&4096&&(n.transform=r[12]),s[0]&131072&&(n.viewportScale=r[17]),t.$set(n)},i(i){e||(at(t.$$.fragment,i),e=!0)},o(i){gt(t.$$.fragment,i),e=!1},d(i){ue(t,i)}}}function Nc(r){let t,e,i=r[40]&&Pc(r);return{c(){i&&i.c(),t=Fe()},m(s,n){i&&i.m(s,n),it(s,t,n),e=!0},p(s,n){s[40]?i?(i.p(s,n),n[0]&256&&at(i,1)):(i=Pc(s),i.c(),at(i,1),i.m(t.parentNode,t)):i&&(Ie(),gt(i,1,1,()=>{i=null}),Re())},i(s){e||(at(i),e=!0)},o(s){gt(i),e=!1},d(s){s&&rt(t),i&&i.d(s)}}}function wv(r){let t,e,i,s,n,o,a=ke(r[16].filter(r[34])),l=[];for(let c=0;c<a.length;c+=1)l[c]=Ic(Ac(r,a,c));const h=c=>gt(l[c],1,1,()=>{l[c]=null});let u=r[6]&&Rc(r);return{c(){t=K("svg"),e=K("g");for(let c=0;c<l.length;c+=1)l[c].c();i=K("g"),u&&u.c(),b(i,"class","drawing"),b(t,"role","application"),b(t,"tabindex",0),b(t,"class","a9s-annotationlayer"),cr(t,"drawing",r[14]),cr(t,"editing",r[8]),cr(t,"hidden",!r[3]),cr(t,"hover",r[15])},m(c,d){it(c,t,d),Tt(t,e);for(let f=0;f<l.length;f+=1)l[f]&&l[f].m(e,null);Tt(t,i),u&&u.m(i,null),r[35](i),r[36](t),s=!0,n||(o=[Rt(t,"pointerup",function(){Vt(r[10])&&r[10].apply(this,arguments)}),Rt(t,"pointerdown",function(){Vt(r[11])&&r[11].apply(this,arguments)}),Rt(t,"pointermove",r[23])],n=!0)},p(c,d){if(r=c,d[0]&66050){a=ke(r[16].filter(r[34]));let f;for(f=0;f<a.length;f+=1){const p=Ac(r,a,f);l[f]?(l[f].p(p,d),at(l[f],1)):(l[f]=Ic(p),l[f].c(),at(l[f],1),l[f].m(e,null))}for(Ie(),f=a.length;f<l.length;f+=1)h(f);Re()}r[6]?u?(u.p(r,d),d[0]&64&&at(u,1)):(u=Rc(r),u.c(),at(u,1),u.m(i,null)):u&&(Ie(),gt(u,1,1,()=>{u=null}),Re()),(!s||d[0]&16384)&&cr(t,"drawing",r[14]),(!s||d[0]&256)&&cr(t,"editing",r[8]),(!s||d[0]&8)&&cr(t,"hidden",!r[3]),(!s||d[0]&32768)&&cr(t,"hover",r[15])},i(c){if(!s){for(let d=0;d<a.length;d+=1)at(l[d]);at(u),s=!0}},o(c){l=l.filter(Boolean);for(let d=0;d<l.length;d+=1)gt(l[d]);gt(u),s=!1},d(c){c&&rt(t),mi(l,c),u&&u.d(),r[35](null),r[36](null),n=!1,He(o)}}}function Tv(r,t,e){let i,s,n,o,a,l,h,u,c,d,f,p=Pt,m=()=>(p(),p=yu(w,W=>e(17,f=W)),w);r.$$.on_destroy.push(()=>p());let{drawingEnabled:_}=t,{image:y}=t,{preferredDrawingMode:v}=t,{state:g}=t,{style:x=void 0}=t,{toolName:T=Nn()[0]}=t,{user:M}=t,{visible:S=!0}=t,R=0;const P=()=>e(5,R+=1),F=()=>T,U=()=>_;let I,A,w;gi(()=>m(e(7,w=a0(y,A))));const{hover:C,selection:L,store:O}=g;la(r,C,W=>e(15,u=W)),la(r,L,W=>e(33,c=W)),la(r,O,W=>e(16,d=W));let B,V;const D=W=>{B&&O.unobserve(B);const Et=W.filter(({editable:nt})=>nt).map(({id:nt})=>nt);Et.length>0?(e(8,V=Et.map(nt=>O.getAnnotation(nt)).filter(nt=>nt&&ze(nt))),B=nt=>{const{updated:mt}=nt.changes;e(8,V=mt==null?void 0:mt.map(vt=>vt.newValue))},O.observe(B,{annotations:Et})):e(8,V=void 0)},N=W=>{const Et=$u(),nt={id:Et,bodies:[],target:{annotation:Et,selector:W.detail,creator:M,created:new Date}};O.addAnnotation(nt),L.setSelected(nt.id)},H=W=>Et=>{var nt;const{target:mt}=W,vt=10*60*1e3,Mt=((nt=mt.creator)==null?void 0:nt.id)!==M.id||!mt.created||new Date().getTime()-mt.created.getTime()>vt;O.updateTarget({...mt,selector:Et.detail,created:Mt?mt.created:new Date,updated:Mt?new Date:void 0,updatedBy:Mt?M:void 0})},k=W=>{const{x:Et,y:nt}=wc(W,A),mt=O.getAt(Et,nt);mt?u!==mt.id&&C.set(mt.id):C.set(void 0)},z=W=>mc(W),Y=W=>ze(W);function pt(W){Tn[W?"unshift":"push"](()=>{I=W,e(6,I)})}function _t(W){Tn[W?"unshift":"push"](()=>{A=W,e(4,A)})}return r.$$set=W=>{"drawingEnabled"in W&&e(0,_=W.drawingEnabled),"image"in W&&e(25,y=W.image),"preferredDrawingMode"in W&&e(26,v=W.preferredDrawingMode),"state"in W&&e(27,g=W.state),"style"in W&&e(1,x=W.style),"toolName"in W&&e(2,T=W.toolName),"user"in W&&e(28,M=W.user),"visible"in W&&e(3,S=W.visible)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(14,{tool:i,opts:s}=Dn(T)||{tool:void 0,opts:void 0},i,(e(32,s),e(2,T))),r.$$.dirty[0]&67108864|r.$$.dirty[1]&2&&e(13,n=(s==null?void 0:s.drawingMode)||v),r.$$.dirty[0]&16&&e(12,o=fv(A)),r.$$.dirty[0]&16&&e(11,{onPointerDown:a,onPointerUp:l}=mv(A,O),a,(e(10,l),e(4,A))),r.$$.dirty[1]&4&&e(9,h=W=>c.selected.find(Et=>Et.id===W.id&&Et.editable)),r.$$.dirty[1]&4&&D(c.selected)},[_,x,T,S,A,R,I,w,V,h,l,a,o,n,i,u,d,f,C,L,O,N,H,k,z,y,v,g,M,P,F,U,s,c,Y,pt,_t]}class Av extends Pe{constructor(t){super(),Me(this,t,Tv,wv,ne,{drawingEnabled:0,image:25,preferredDrawingMode:26,state:27,style:1,toolName:2,user:28,visible:3,cancelDrawing:29,getDrawingTool:30,isDrawingEnabled:31},null,[-1,-1])}get cancelDrawing(){return this.$$.ctx[29]}get getDrawingTool(){return this.$$.ctx[30]}get isDrawingEnabled(){return this.$$.ctx[31]}}function Dc(r,t,e=0,i=r.length-1,s=Sv){for(;i>e;){if(i-e>600){const l=i-e+1,h=t-e+1,u=Math.log(l),c=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*c*(l-c)/l)*(h-l/2<0?-1:1),f=Math.max(e,Math.floor(t-h*c/l+d)),p=Math.min(i,Math.floor(t+(l-h)*c/l+d));Dc(r,t,f,p,s)}const n=r[t];let o=e,a=i;for(Fs(r,e,t),s(r[i],n)>0&&Fs(r,e,i);o<a;){for(Fs(r,o,a),o++,a--;s(r[o],n)<0;)o++;for(;s(r[a],n)>0;)a--}s(r[e],n)===0?Fs(r,e,a):(a++,Fs(r,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function Fs(r,t,e){const i=r[t];r[t]=r[e],r[e]=i}function Sv(r,t){return r<t?-1:r>t?1:0}class Cv{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(!Bn(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;Bn(t,l)&&(e.leaf?i.push(a):Fa(t,l)?this._all(a,i):n.push(a))}e=n.pop()}return i}collides(t){let e=this.data;if(!Bn(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(Bn(t,o)){if(e.leaf||Fa(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=Ki([]),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 u=Iv(t,i.children,e);if(u!==-1)return i.children.splice(u,1),n.push(i),this._condense(n),this}!h&&!i.leaf&&Fa(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=Ki(t.slice(e,i+1)),qi(a,this.toBBox),a;s||(s=Math.ceil(Math.log(n)/Math.log(o)),o=Math.ceil(n/Math.pow(o,s-1))),a=Ki([]),a.leaf=!1,a.height=s;const l=Math.ceil(n/o),h=l*Math.ceil(Math.sqrt(o));Lc(t,e,i,h,this.compareMinX);for(let u=e;u<=i;u+=h){const c=Math.min(u+h-1,i);Lc(t,u,c,l,this.compareMinY);for(let d=u;d<=c;d+=l){const f=Math.min(d+l-1,c);a.children.push(this._build(t,d,f,s-1))}}return qi(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],u=Ba(h),c=Pv(t,h)-u;c<o?(o=c,n=u<n?u:n,a=h):c===o&&u<n&&(n=u,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),Us(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=Ki(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,qi(i,this.toBBox),qi(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=Ki([t,e]),this.data.height=t.height+1,this.data.leaf=!1,qi(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=ks(t,0,a,this.toBBox),h=ks(t,a,i,this.toBBox),u=Ov(l,h),c=Ba(l)+Ba(h);u<n?(n=u,s=a,o=c<o?c:o):u===n&&c<o&&(o=c,s=a)}return s||i-e}_chooseSplitAxis(t,e,i){const s=t.leaf?this.compareMinX:Rv,n=t.leaf?this.compareMinY:Mv,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=ks(t,0,e,n),a=ks(t,i-e,i,n);let l=Ln(o)+Ln(a);for(let h=e;h<i-e;h++){const u=t.children[h];Us(o,t.leaf?n(u):u),l+=Ln(o)}for(let h=i-e-1;h>=e;h--){const u=t.children[h];Us(a,t.leaf?n(u):u),l+=Ln(a)}return l}_adjustParentBBoxes(t,e,i){for(let s=i;s>=0;s--)Us(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():qi(t[e],this.toBBox)}}function Iv(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 qi(r,t){ks(r,0,r.children.length,t,r)}function ks(r,t,e,i,s){s||(s=Ki(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];Us(s,r.leaf?i(o):o)}return s}function Us(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 Rv(r,t){return r.minX-t.minX}function Mv(r,t){return r.minY-t.minY}function Ba(r){return(r.maxX-r.minX)*(r.maxY-r.minY)}function Ln(r){return r.maxX-r.minX+(r.maxY-r.minY)}function Pv(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 Ov(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 Fa(r,t){return r.minX<=t.minX&&r.minY<=t.minY&&t.maxX<=r.maxX&&t.maxY<=r.maxY}function Bn(r,t){return t.minX<=r.maxX&&t.minY<=r.maxY&&t.maxX>=r.minX&&t.maxY>=r.minY}function Ki(r){return{children:r,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Lc(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;Dc(r,o,t,e,s),n.push(t,o,o,e)}}const Nv=()=>{const r=new Cv,t=new Map,e=()=>[...t.values()],i=()=>{r.clear(),t.clear()},s=o=>{if(!Cn(o))return;const{minX:a,minY:l,maxX:h,maxY:u}=o.selector.geometry.bounds,c={minX:a,minY:l,maxX:h,maxY:u,target:o};r.insert(c),t.set(o.annotation,c)},n=o=>{if(!Cn(o))return;const a=t.get(o.annotation);a&&r.remove(a),t.delete(o.annotation)};return{all:e,clear:i,getAt:(o,a,l,h=0)=>{const u=r.search({minX:o-h,minY:a-h,maxX:o+h,maxY:a+h}).map(c=>c.target).filter(c=>c.selector.type===xt.RECTANGLE||Ry(c.selector,o,a,h));return u.length>0?(u.sort((c,d)=>fa(c.selector)-fa(d.selector)),u):[]},getIntersecting:(o,a,l,h)=>r.search({minX:o,minY:a,maxX:o+l,maxY:a+h}).map(u=>u.target),insert:s,remove:n,set:(o,a=!0)=>{a&&i();const l=o.reduce((h,u)=>{if(Cn(u)){const{minX:c,minY:d,maxX:f,maxY:p}=u.selector.geometry.bounds;return[...h,{minX:c,minY:d,maxX:f,maxY:p,target:u}]}else return h},[]);l.forEach(h=>t.set(h.target.annotation,h)),r.load(l)},size:()=>r.all().length,update:(o,a)=>{n(o),s(a)}}},Bc=r=>{const t=B_(),e=Nv(),i=E_(t,r.userSelectAction,r.adapter),s=b_(t),n=$_();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,l,h)=>{const u=e.getAt(o,a,l,h);if(l)return u.map(c=>t.getAnnotation(c.annotation)).filter(Boolean).filter(l)[0];{const c=u[0];return c?t.getAnnotation(c.annotation):void 0}},getIntersecting:(o,a,l,h)=>e.getIntersecting(o,a,l,h).map(u=>t.getAnnotation(u.annotation)).filter(Boolean)},selection:i,hover:s,viewport:n}},Dv=r=>{const t=Bc(r);return{...t,store:F_(t.store)}},Lv=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},Fc=r=>{const t=Lv(r),e=t>.6?"dark":"light";return console.log(`[Annotorious] Image brightness: ${t.toFixed(1)}. Setting ${e} theme.`),e},kc=(r,t,e)=>t.setAttribute("data-theme",e==="auto"?Fc(r):e),Uc=(r,t)=>({...r,drawingEnabled:r.drawingEnabled===void 0?t.drawingEnabled:r.drawingEnabled,drawingMode:r.drawingMode||t.drawingMode,userSelectAction:r.userSelectAction||t.userSelectAction,theme:r.theme||t.theme}),Gc=typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1,$c=(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=()=>{Gc?e.removeEventListener("keydown",s):e.removeEventListener("keydown",i)};return Gc?e.addEventListener("keydown",s):e.addEventListener("keydown",i),{destroy:n}},Bv=(r,t={})=>{if(!r)throw"Missing argument: image";const e=typeof r=="string"?document.getElementById(r):r,i=Uc(t,{drawingEnabled:!0,drawingMode:"drag",userSelectAction:Xu.EDIT,theme:"light"}),s=Dv(i),{selection:n,store:o}=s,a=G_(o,i.initialHistory),l=H_(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 u=$c(a);let c=Q_();kc(e,h,i.theme);const d=new Av({target:h,props:{drawingEnabled:!!i.drawingEnabled,image:e,preferredDrawingMode:i.drawingMode,state:s,style:i.style,user:c}});d.$on("click",I=>{const{originalEvent:A,annotation:w}=I.detail;w?n.userSelect(w.id,A):n.isEmpty()||n.clear()});const f=V_(s,a,i.adapter),p=()=>d.cancelDrawing(),m=()=>{d.$destroy(),h.parentNode.insertBefore(e,h),h.parentNode.removeChild(h),u.destroy(),a.destroy()},_=()=>d.getDrawingTool(),y=()=>c,v=()=>d.isDrawingEnabled(),g=(I,A,w)=>xc(I,A,w),x=(I,A)=>gc(I,A),T=I=>{if(!Dn(I))throw`No drawing tool named ${I}`;d.$set({toolName:I})},M=I=>d.$set({drawingEnabled:I}),S=I=>{console.warn("Filter not implemented yet")},R=I=>d.$set({style:I}),P=I=>kc(e,h,I),F=I=>{c=I,d.$set({user:I})},U=I=>d.$set({visible:I});return{...f,cancelDrawing:p,destroy:m,getDrawingTool:_,getUser:y,isDrawingEnabled:v,listDrawingTools:Nn,on:l.on,off:l.off,registerDrawingTool:g,registerShapeEditor:x,setDrawingEnabled:M,setDrawingTool:T,setFilter:S,setStyle:R,setTheme:P,setUser:F,setVisible:U,element:h,state:s}};function zt(){}function ka(r,t){for(const e in t)r[e]=t[e];return r}function Hc(r){return r()}function Xc(){return Object.create(null)}function Ye(r){r.forEach(Hc)}function ee(r){return typeof r=="function"}function Yt(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function Fv(r){return Object.keys(r).length===0}function kv(r,...t){if(r==null){for(const i of t)i(void 0);return zt}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function Fn(r,t,e){r.$$.on_destroy.push(kv(t,e))}function Vc(r,t,e,i){if(r){const s=zc(r,t,e,i);return r[0](s)}}function zc(r,t,e,i){return r[1]&&i?ka(e.ctx.slice(),r[1](i(t))):e.ctx}function Yc(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 jc(r,t,e,i,s,n){if(s){const o=zc(t,e,i,n);r.p(o,s)}}function Wc(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 qc(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}const Ua=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function Ct(r,t){r.appendChild(t)}function lt(r,t,e){r.insertBefore(t,e||null)}function ot(r){r.parentNode&&r.parentNode.removeChild(r)}function Wr(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function st(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function Ga(r){return document.createTextNode(r)}function Le(){return Ga(" ")}function Ge(){return Ga("")}function Ot(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function E(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function Uv(r){return Array.from(r.childNodes)}function Gv(r,t){t=""+t,r.data!==t&&(r.data=t)}function qr(r,t,e){r.classList.toggle(t,!!e)}function $v(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let Gs;function $s(r){Gs=r}function $a(){if(!Gs)throw new Error("Function called outside component initialization");return Gs}function vi(r){$a().$$.on_mount.push(r)}function Hv(r){$a().$$.on_destroy.push(r)}function Zi(){const r=$a();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=$v(t,e,{cancelable:i});return s.slice().forEach(o=>{o.call(r,n)}),!n.defaultPrevented}return!0}}function Oe(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const Qi=[],kn=[];let Ji=[];const Kc=[],Zc=Promise.resolve();let Ha=!1;function Qc(){Ha||(Ha=!0,Zc.then(td))}function Jc(){return Qc(),Zc}function Xa(r){Ji.push(r)}const Va=new Set;let ts=0;function td(){if(ts!==0)return;const r=Gs;do{try{for(;ts<Qi.length;){const t=Qi[ts];ts++,$s(t),Xv(t.$$)}}catch(t){throw Qi.length=0,ts=0,t}for($s(null),Qi.length=0,ts=0;kn.length;)kn.pop()();for(let t=0;t<Ji.length;t+=1){const e=Ji[t];Va.has(e)||(Va.add(e),e())}Ji.length=0}while(Qi.length);for(;Kc.length;)Kc.pop()();Ha=!1,Va.clear(),$s(r)}function Xv(r){if(r.fragment!==null){r.update(),Ye(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(Xa)}}function Vv(r){const t=[],e=[];Ji.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),Ji=t}const Un=new Set;let xi;function pe(){xi={r:0,c:[],p:xi}}function me(){xi.r||Ye(xi.c),xi=xi.p}function Z(r,t){r&&r.i&&(Un.delete(r),r.i(t))}function ht(r,t,e,i){if(r&&r.o){if(Un.has(r))return;Un.add(r),xi.c.push(()=>{Un.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function Ne(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function Ut(r){r&&r.c()}function Bt(r,t,e){const{fragment:i,after_update:s}=r.$$;i&&i.m(t,e),Xa(()=>{const n=r.$$.on_mount.map(Hc).filter(ee);r.$$.on_destroy?r.$$.on_destroy.push(...n):Ye(n),r.$$.on_mount=[]}),s.forEach(Xa)}function Ft(r,t){const e=r.$$;e.fragment!==null&&(Vv(e.after_update),Ye(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function zv(r,t){r.$$.dirty[0]===-1&&(Qi.push(r),Qc(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function re(r,t,e,i,s,n,o=null,a=[-1]){const l=Gs;$s(r);const h=r.$$={fragment:null,ctx:[],props:n,update:zt,not_equal:s,bound:Xc(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:Xc(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let u=!1;if(h.ctx=e?e(r,t.props||{},(c,d,...f)=>{const p=f.length?f[0]:d;return h.ctx&&s(h.ctx[c],h.ctx[c]=p)&&(!h.skip_bound&&h.bound[c]&&h.bound[c](p),u&&zv(r,c)),d}):[],h.update(),u=!0,Ye(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const c=Uv(t.target);h.fragment&&h.fragment.l(c),c.forEach(ot)}else h.fragment&&h.fragment.c();t.intro&&Z(r.$$.fragment),Bt(r,t.target,t.anchor),td()}$s(l)}class ie{constructor(){Ht(this,"$$");Ht(this,"$$set")}$destroy(){Ft(this,1),this.$destroy=zt}$on(t,e){if(!ee(e))return zt;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&&!Fv(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const Yv="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Yv);var Ir=(r=>(r.ELLIPSE="ELLIPSE",r.MULTIPOLYGON="MULTIPOLYGON",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r.LINE="LINE",r))(Ir||{}),Hs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function za(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function jv(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 ed={exports:{}};(function(r){(function(){function t(a,l){var h=a.x-l.x,u=a.y-l.y;return h*h+u*u}function e(a,l,h){var u=l.x,c=l.y,d=h.x-u,f=h.y-c;if(d!==0||f!==0){var p=((a.x-u)*d+(a.y-c)*f)/(d*d+f*f);p>1?(u=h.x,c=h.y):p>0&&(u+=d*p,c+=f*p)}return d=a.x-u,f=a.y-c,d*d+f*f}function i(a,l){for(var h=a[0],u=[h],c,d=1,f=a.length;d<f;d++)c=a[d],t(c,h)>l&&(u.push(c),h=c);return h!==c&&u.push(c),u}function s(a,l,h,u,c){for(var d=u,f,p=l+1;p<h;p++){var m=e(a[p],a[l],a[h]);m>d&&(f=p,d=m)}d>u&&(f-l>1&&s(a,l,f,u,c),c.push(a[f]),h-f>1&&s(a,f,h,u,c))}function n(a,l){var h=a.length-1,u=[a[0]];return s(a,0,h,l,u),u.push(a[h]),u}function o(a,l,h){if(a.length<=2)return a;var u=l!==void 0?l*l:1;return a=h?a:i(a,u),a=n(a,u),a}r.exports=o,r.exports.default=o})()})(ed);var Wv=ed.exports;const qv=za(Wv),Xs=(r,t)=>t,dr=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}},Ya=r=>{let t=0,e=r.length-1;for(let i=0;i<r.length;i++)t+=(r[e][0]+r[i][0])*(r[e][1]-r[i][1]),e=i;return Math.abs(.5*t)},ja=(r,t,e)=>{let i=!1;for(let s=0,n=r.length-1;s<r.length;n=s++){const o=r[s][0],a=r[s][1],l=r[n][0],h=r[n][1];a>e!=h>e&&t<(l-o)*(e-a)/(h-a)+o&&(i=!i)}return i},Kv=(r,t=!0)=>{let e="M ";return r.forEach(([i,s],n)=>{n===0?e+=`${i},${s}`:e+=` L ${i},${s}`}),t&&(e+=" Z"),e},rd=(r,t=1)=>{const e=r.map(([i,s])=>({x:i,y:s}));return qv(e,t,!0).map(i=>[i.x,i.y])},Zv=(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))},Qv={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),u=t-i,c=e-s,d=l*u+h*c,f=h*u-l*c;return d*d/(n*n)+f*f/(o*o)<=1}};Xs(Ir.ELLIPSE,Qv);const Jv={area:r=>0,intersects:(r,t,e,i=2)=>{const[[s,n],[o,a]]=r.geometry.points,l=Math.abs((a-n)*t-(o-s)*e+o*n-a*s),h=Zv([s,n],[o,a]);return l/h<=i}};Xs(Ir.LINE,Jv);const t1={area:r=>{const{polygons:t}=r.geometry;return t.reduce((e,i)=>{const[s,...n]=i.rings,o=Ya(s.points),a=n.reduce((l,h)=>l+Ya(h.points),0);return e+o-a},0)},intersects:(r,t,e)=>{const{polygons:i}=r.geometry;for(const s of i){const[n,...o]=s.rings;if(ja(n.points,t,e)){let a=!1;for(const l of o)if(ja(l.points,t,e)){a=!0;break}if(!a)return!0}}return!1}},Gn=r=>{const t=r.reduce((e,i)=>[...e,...i.rings[0].points],[]);return dr(t)},es=r=>r.rings.map(e=>Kv(e.points)).join(" "),e1=r=>r.polygons.reduce((t,e)=>[...t,...e.rings.reduce((i,s)=>[...i,...s.points],[])],[]),r1=(r,t=1)=>{const e=r.geometry.polygons.map(s=>{const n=s.rings.map(a=>{const l=rd(a.points,t);return{...a,points:l}}),o=dr(n[0].points);return{...s,rings:n,bounds:o}}),i=Gn(e);return{...r,geometry:{...r.geometry,polygons:e,bounds:i}}};Xs(Ir.MULTIPOLYGON,t1);const i1={area:r=>{const t=r.geometry.points;return Ya(t)},intersects:(r,t,e)=>{const i=r.geometry.points;return ja(i,t,e)}},s1=(r,t=1)=>{const e=rd(r.geometry.points,t),i=dr(e);return{...r,geometry:{...r.geometry,bounds:i,points:e}}};Xs(Ir.POLYGON,i1);const n1={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};Xs(Ir.RECTANGLE,n1);const ae=" ";function o1(r){let t="";Array.isArray(r)||(r=[r]);for(let e=0;e<r.length;e++){const i=r[e];if(i.type===X.CLOSE_PATH)t+="z";else if(i.type===X.HORIZ_LINE_TO)t+=(i.relative?"h":"H")+i.x;else if(i.type===X.VERT_LINE_TO)t+=(i.relative?"v":"V")+i.y;else if(i.type===X.MOVE_TO)t+=(i.relative?"m":"M")+i.x+ae+i.y;else if(i.type===X.LINE_TO)t+=(i.relative?"l":"L")+i.x+ae+i.y;else if(i.type===X.CURVE_TO)t+=(i.relative?"c":"C")+i.x1+ae+i.y1+ae+i.x2+ae+i.y2+ae+i.x+ae+i.y;else if(i.type===X.SMOOTH_CURVE_TO)t+=(i.relative?"s":"S")+i.x2+ae+i.y2+ae+i.x+ae+i.y;else if(i.type===X.QUAD_TO)t+=(i.relative?"q":"Q")+i.x1+ae+i.y1+ae+i.x+ae+i.y;else if(i.type===X.SMOOTH_QUAD_TO)t+=(i.relative?"t":"T")+i.x+ae+i.y;else if(i.type===X.ARC)t+=(i.relative?"a":"A")+i.rX+ae+i.rY+ae+i.xRot+ae+ +i.lArcFlag+ae+ +i.sweepFlag+ae+i.x+ae+i.y;else throw new Error(`Unexpected command type "${i==null?void 0:i.type}" at index ${e}.`)}return t}function Wa([r,t],e){return[r*Math.cos(e)-t*Math.sin(e),r*Math.sin(e)+t*Math.cos(e)]}function tr(...r){for(let t=0;t<r.length;t++)if(typeof r[t]!="number")throw new Error(`assertNumbers arguments[${t}] is not a number. ${typeof r[t]} == typeof ${r[t]}`);return!0}const Kr=Math.PI;function qa(r,t,e){r.lArcFlag=r.lArcFlag===0?0:1,r.sweepFlag=r.sweepFlag===0?0:1;let{rX:i,rY:s}=r;const{x:n,y:o}=r;if(Math.abs(i)<1e-10||Math.abs(s)<1e-10){r.rX=0,r.rY=0,r.cX=(t+n)/2,r.cY=(e+o)/2,r.phi1=0,r.phi2=0;return}i=Math.abs(r.rX),s=Math.abs(r.rY);const a=r.xRot/180*Kr,[l,h]=Wa([(t-n)/2,(e-o)/2],-a),u=Math.pow(l,2)/Math.pow(i,2)+Math.pow(h,2)/Math.pow(s,2);1<u&&(i*=Math.sqrt(u),s*=Math.sqrt(u)),r.rX=i,r.rY=s;const c=Math.pow(i,2)*Math.pow(h,2)+Math.pow(s,2)*Math.pow(l,2),d=(r.lArcFlag!==r.sweepFlag?1:-1)*Math.sqrt(Math.max(0,(Math.pow(i,2)*Math.pow(s,2)-c)/c)),f=i*h/s*d,p=-s*l/i*d,m=Wa([f,p],a);r.cX=m[0]+(t+n)/2,r.cY=m[1]+(e+o)/2,r.phi1=Math.atan2((h-p)/s,(l-f)/i),r.phi2=Math.atan2((-h-p)/s,(-l-f)/i),r.sweepFlag===0&&r.phi2>r.phi1&&(r.phi2-=2*Kr),r.sweepFlag===1&&r.phi2<r.phi1&&(r.phi2+=2*Kr),r.phi1*=180/Kr,r.phi2*=180/Kr}function id(r,t,e){tr(r,t,e);const i=r*r+t*t-e*e;if(0>i)return[];if(i===0)return[[r*e/(r*r+t*t),t*e/(r*r+t*t)]];const s=Math.sqrt(i);return[[(r*e+t*s)/(r*r+t*t),(t*e-r*s)/(r*r+t*t)],[(r*e-t*s)/(r*r+t*t),(t*e+r*s)/(r*r+t*t)]]}const bi=Math.PI/180;function sd(r,t,e){return(1-e)*r+e*t}function nd(r,t,e,i){return r+Math.cos(i/180*Kr)*t+Math.sin(i/180*Kr)*e}function od(r,t,e,i){const n=t-r,o=e-t,a=i-e,l=3*n+3*a-6*o,h=(o-n)*6,u=3*n;return Math.abs(l)<1e-6?Math.abs(h)<1e-6?[]:[-u/h]:a1(h/l,u/l,1e-6)}function ad(r,t,e,i,s){const n=1-s,o=n*n*n,a=3*n*n*s,l=3*n*s*s,h=s*s*s;return r*o+t*a+e*l+i*h}function a1(r,t,e=1e-6){const i=r*r/4-t;if(i<-e)return[];if(i<=e)return[-r/2];const s=Math.sqrt(i);return[-(r/2)-s,-(r/2)+s]}function l1(r,t,e){r.cX||qa(r,t,e);const i=r.xRot/180*Kr;if(Math.abs(r.rX)<1e-10||Math.abs(r.rY)<1e-10)return[{relative:r.relative,type:X.CURVE_TO,x1:t+(r.x-t)/3,y1:e+(r.y-e)/3,x2:t+2*(r.x-t)/3,y2:e+2*(r.y-e)/3,x:r.x,y:r.y}];const s=Math.min(r.phi1,r.phi2),n=Math.max(r.phi1,r.phi2),o=n-s,a=Math.ceil(o/90),l=new Array(a);let h=t,u=e;const c=(d,f)=>{const[p,m]=Wa([d*r.rX,f*r.rY],i);return[r.cX+p,r.cY+m]};for(let d=0;d<a;d++){const f=sd(r.phi1,r.phi2,d/a),p=sd(r.phi1,r.phi2,(d+1)/a),m=p-f,_=4/3*Math.tan(m*bi/4),y=Math.cos(f*bi)-_*Math.sin(f*bi),v=Math.sin(f*bi)+_*Math.cos(f*bi),g=Math.cos(p*bi),x=Math.sin(p*bi),T=g+_*x,M=x-_*g,S=c(y,v),R=c(T,M),P=c(g,x),F={relative:r.relative,type:X.CURVE_TO,x:P[0],y:P[1],x1:S[0],y1:S[1],x2:R[0],y2:R[1]};r.relative&&(F.x1-=h,F.y1-=u,F.x2-=h,F.y2-=u,F.x-=h,F.y-=u),h=P[0],u=P[1],l[d]=F}return l}function $n(r,t,e){const i=t[0]-r[0],s=t[1]-r[1],n=e[0]-r[0],o=e[1]-r[1],a=i*o-s*n;if(!(Math.abs(a)<1e-10))return!1;const h=i*n+s*o,u=i*i+s*s,c=n*n+o*o;return 0<=h&&h<=c&&u<=c}function h1(r){if(r.length<=2)return r;const t=[],e=r.map(Qt.INFO((s,n,o)=>{const a="relative"in s&&s.relative;return["x"in s?s.x+(a?n:0):n,"y"in s?s.y+(a?o:0):o]}));let i=e[0];t.push(r[0]);for(let s=1;s<r.length;s++){const n=r[s],o=r[s+1];if(s<r.length-1&&o&&n.type&X.LINE_COMMANDS&&o.type&X.LINE_COMMANDS){const a=e[s+1];if($n(i,e[s],a)){"relative"in o&&o.relative&&("x"in o&&(o.x=a[0]-i[0]),"y"in o&&(o.y=a[1]-i[1]));continue}}t.push(n),i=e[s]}return t}function u1(r,t=!0){if(r.length<2)return r;const e=Qt.INFO((n,o,a)=>({...n,x:n.x??o,y:n.y??a,relative:n.relative??!1})),i=[];let s=[];for(const n of r){const o=e(n);o.type===X.MOVE_TO&&s.length>0&&(t?i.push(...Hn(s)):i.unshift(...Hn(s)),s=[]),s.push(o)}return s.length>0&&(t?i.push(...Hn(s)):i.unshift(...Hn(s))),i}function Hn(r){var s;const t=((s=r[r.length-1])==null?void 0:s.type)===X.CLOSE_PATH,e=t?r.length-2:r.length-1,i=[{type:X.MOVE_TO,relative:!1,x:r[e].x,y:r[e].y}];for(let n=e;n>0;n--){const o=r[n],a=r[n-1];if(o.relative)throw new Error("Relative command are not supported convert first with `toAbs()`");switch(o.type){case X.HORIZ_LINE_TO:i.push({type:X.HORIZ_LINE_TO,relative:!1,x:a.x});break;case X.VERT_LINE_TO:i.push({type:X.VERT_LINE_TO,relative:!1,y:a.y});break;case X.LINE_TO:case X.MOVE_TO:i.push({type:X.LINE_TO,relative:!1,x:a.x,y:a.y});break;case X.CURVE_TO:i.push({type:X.CURVE_TO,relative:!1,x:a.x,y:a.y,x1:o.x2,y1:o.y2,x2:o.x1,y2:o.y1});break;case X.SMOOTH_CURVE_TO:throw new Error("Unsupported command: S (smooth cubic bezier)");case X.SMOOTH_QUAD_TO:throw new Error("Unsupported command: T (smooth quadratic bezier)");case X.ARC:throw new Error("Unsupported command: A (arc)");case X.QUAD_TO:throw new Error("Unsupported command: Q (quadratic bezier)")}}return t&&i.push({type:X.CLOSE_PATH}),i}function c1(r=1e13){tr(r);function t(e){return Math.round(e*r)/r}return function(i){return"x1"in i&&typeof i.x1<"u"&&(i.x1=t(i.x1)),"y1"in i&&typeof i.y1<"u"&&(i.y1=t(i.y1)),"x2"in i&&typeof i.x2<"u"&&(i.x2=t(i.x2)),"y2"in i&&typeof i.y2<"u"&&(i.y2=t(i.y2)),"x"in i&&typeof i.x<"u"&&(i.x=t(i.x)),"y"in i&&typeof i.y<"u"&&(i.y=t(i.y)),"rX"in i&&typeof i.rX<"u"&&(i.rX=t(i.rX)),"rY"in i&&typeof i.rY<"u"&&(i.rY=t(i.rY)),i}}function ld(){return er((r,t,e)=>(r.relative&&(typeof r.x1<"u"&&(r.x1+=t),typeof r.y1<"u"&&(r.y1+=e),typeof r.x2<"u"&&(r.x2+=t),typeof r.y2<"u"&&(r.y2+=e),typeof r.x<"u"&&(r.x+=t),typeof r.y<"u"&&(r.y+=e),r.relative=!1),r))}function d1(){return er((r,t,e)=>(r.relative||(typeof r.x1<"u"&&(r.x1-=t),typeof r.y1<"u"&&(r.y1-=e),typeof r.x2<"u"&&(r.x2-=t),typeof r.y2<"u"&&(r.y2-=e),typeof r.x<"u"&&(r.x-=t),typeof r.y<"u"&&(r.y-=e),r.relative=!0),r))}function f1(r=!0,t=!0,e=!0,i=!0){return er((s,n,o,a,l)=>{if(isNaN(a)&&!(s.type&X.MOVE_TO))throw new Error("path must start with moveto");if(t&&s.type&X.HORIZ_LINE_TO&&(s.type=X.LINE_TO,s.y=s.relative?0:o),e&&s.type&X.VERT_LINE_TO&&(s.type=X.LINE_TO,s.x=s.relative?0:n),r&&s.type&X.CLOSE_PATH&&(s.type=X.LINE_TO,s.x=s.relative?a-n:a,s.y=s.relative?l-o:l),s.type&X.ARC&&(s.rX===0||s.rY===0)&&(s.type=X.LINE_TO,delete s.rX,delete s.rY,delete s.xRot,delete s.lArcFlag,delete s.sweepFlag),i&&s.type&X.QUAD_TO){const h=[n,o],u=s.relative?[n+s.x1,o+s.y1]:[s.x1,s.y1],c=s.relative?[n+s.x,o+s.y]:[s.x,s.y];$n(h,u,c)&&(s.type=X.LINE_TO,delete s.x1,delete s.y1)}if(i&&s.type&X.CURVE_TO){const h=[n,o],u=s.relative?[n+s.x1,o+s.y1]:[s.x1,s.y1],c=s.relative?[n+s.x2,o+s.y2]:[s.x2,s.y2],d=s.relative?[n+s.x,o+s.y]:[s.x,s.y];$n(h,u,d)&&$n(h,c,d)&&(s.type=X.LINE_TO,delete s.x1,delete s.y1,delete s.x2,delete s.y2)}return s})}function hd(){let r=NaN,t=NaN,e=NaN,i=NaN;return er((s,n,o)=>(s.type&X.SMOOTH_CURVE_TO&&(s.type=X.CURVE_TO,r=isNaN(r)?n:r,t=isNaN(t)?o:t,s.x1=s.relative?n-r:2*n-r,s.y1=s.relative?o-t:2*o-t),s.type&X.CURVE_TO?(r=s.relative?n+s.x2:s.x2,t=s.relative?o+s.y2:s.y2):(r=NaN,t=NaN),s.type&X.SMOOTH_QUAD_TO&&(s.type=X.QUAD_TO,e=isNaN(e)?n:e,i=isNaN(i)?o:i,s.x1=s.relative?n-e:2*n-e,s.y1=s.relative?o-i:2*o-i),s.type&X.QUAD_TO?(e=s.relative?n+s.x1:s.x1,i=s.relative?o+s.y1:s.y1):(e=NaN,i=NaN),s))}function ud(){let r=NaN,t=NaN;return er((e,i,s)=>{if(e.type&X.SMOOTH_QUAD_TO&&(e.type=X.QUAD_TO,r=isNaN(r)?i:r,t=isNaN(t)?s:t,e.x1=e.relative?i-r:2*i-r,e.y1=e.relative?s-t:2*s-t),e.type&X.QUAD_TO){r=e.relative?i+e.x1:e.x1,t=e.relative?s+e.y1:e.y1;const n=e.x1,o=e.y1;e.type=X.CURVE_TO,e.x1=((e.relative?0:i)+n*2)/3,e.y1=((e.relative?0:s)+o*2)/3,e.x2=(e.x+n*2)/3,e.y2=(e.y+o*2)/3}else r=NaN,t=NaN;return e})}function er(r){let t=0,e=0,i=NaN,s=NaN;return function(o){if(isNaN(i)&&!(o.type&X.MOVE_TO))throw new Error("path must start with moveto");const a=r(o,t,e,i,s);return o.type&X.CLOSE_PATH&&(t=i,e=s),"x"in o&&typeof o.x<"u"&&(t=o.relative?t+o.x:o.x),"y"in o&&typeof o.y<"u"&&(e=o.relative?e+o.y:o.y),o.type&X.MOVE_TO&&(i=t,s=e),a}}function p1(r=0){tr(r);let t=NaN,e=NaN,i=NaN,s=NaN;return er((n,o,a,l,h)=>{const u=Math.abs;let c=!1,d=0,f=0;if(n.type&X.SMOOTH_CURVE_TO&&(d=isNaN(t)?0:o-t,f=isNaN(e)?0:a-e),n.type&(X.CURVE_TO|X.SMOOTH_CURVE_TO)?(t=n.relative?o+n.x2:n.x2,e=n.relative?a+n.y2:n.y2):(t=NaN,e=NaN),n.type&X.SMOOTH_QUAD_TO?(i=isNaN(i)?o:2*o-i,s=isNaN(s)?a:2*a-s):n.type&X.QUAD_TO?(i=n.relative?o+n.x1:n.x1,s=n.relative?a+n.y1:n.y2):(i=NaN,s=NaN),n.type&X.LINE_COMMANDS||n.type&X.ARC&&(n.rX===0||n.rY===0||!n.lArcFlag)||n.type&X.CURVE_TO||n.type&X.SMOOTH_CURVE_TO||n.type&X.QUAD_TO||n.type&X.SMOOTH_QUAD_TO){const p=typeof n.x>"u"?0:n.relative?n.x:n.x-o,m=typeof n.y>"u"?0:n.relative?n.y:n.y-a;d=isNaN(i)?typeof n.x1>"u"?d:n.relative?n.x:n.x1-o:i-o,f=isNaN(s)?typeof n.y1>"u"?f:n.relative?n.y:n.y1-a:s-a;const _=typeof n.x2>"u"?0:n.relative?n.x:n.x2-o,y=typeof n.y2>"u"?0:n.relative?n.y:n.y2-a;u(p)<=r&&u(m)<=r&&u(d)<=r&&u(f)<=r&&u(_)<=r&&u(y)<=r&&(c=!0)}return n.type&X.CLOSE_PATH&&u(o-l)<=r&&u(a-h)<=r&&(c=!0),c?[]:n})}function Zr(r,t,e,i,s,n){return tr(r,t,e,i,s,n),er((o,a,l,h)=>{const u=o.x1,c=o.x2,d=o.relative&&!isNaN(h),f=typeof o.x<"u"?o.x:d?0:a,p=typeof o.y<"u"?o.y:d?0:l;o.type&X.HORIZ_LINE_TO&&t!==0&&(o.type=X.LINE_TO,o.y=o.relative?0:l),o.type&X.VERT_LINE_TO&&e!==0&&(o.type=X.LINE_TO,o.x=o.relative?0:a),typeof o.x<"u"&&(o.x=o.x*r+p*e+(d?0:s)),typeof o.y<"u"&&(o.y=f*t+o.y*i+(d?0:n)),typeof o.x1<"u"&&(o.x1=o.x1*r+o.y1*e+(d?0:s)),typeof o.y1<"u"&&(o.y1=u*t+o.y1*i+(d?0:n)),typeof o.x2<"u"&&(o.x2=o.x2*r+o.y2*e+(d?0:s)),typeof o.y2<"u"&&(o.y2=c*t+o.y2*i+(d?0:n));function m(y){return y*y}const _=r*i-t*e;if(typeof o.xRot<"u"&&(r!==1||t!==0||e!==0||i!==1))if(_===0)delete o.rX,delete o.rY,delete o.xRot,delete o.lArcFlag,delete o.sweepFlag,o.type=X.LINE_TO;else{const y=o.xRot*Math.PI/180,v=Math.sin(y),g=Math.cos(y),x=1/m(o.rX),T=1/m(o.rY),M=m(g)*x+m(v)*T,S=2*v*g*(x-T),R=m(v)*x+m(g)*T,P=M*i*i-S*t*i+R*t*t,F=S*(r*i+t*e)-2*(M*e*i+R*r*t),U=M*e*e-S*r*e+R*r*r,I=(Math.atan2(F,P-U)+Math.PI)%Math.PI/2,A=Math.sin(I),w=Math.cos(I);o.rX=Math.abs(_)/Math.sqrt(P*m(w)+F*A*w+U*m(A)),o.rY=Math.abs(_)/Math.sqrt(P*m(A)-F*A*w+U*m(w)),o.xRot=I*180/Math.PI}return typeof o.sweepFlag<"u"&&0>_&&(o.sweepFlag=+!o.sweepFlag),o})}function m1(r,t=0,e=0){tr(r,t,e);const i=Math.sin(r),s=Math.cos(r);return Zr(s,i,-i,s,t-t*s+e*i,e-t*i-e*s)}function g1(r,t=0){return tr(r,t),Zr(1,0,0,1,r,t)}function y1(r,t=r){return tr(r,t),Zr(r,0,0,t,0,0)}function _1(r){return tr(r),Zr(1,0,Math.tan(r),1,0,0)}function v1(r){return tr(r),Zr(1,Math.tan(r),0,1,0,0)}function x1(r=0){return tr(r),Zr(-1,0,0,1,r,0)}function b1(r=0){return tr(r),Zr(1,0,0,-1,0,r)}function E1(){return er((r,t,e)=>X.ARC===r.type?l1(r,r.relative?0:t,r.relative?0:e):r)}function w1(){return er((r,t,e)=>(r.relative&&(t=0,e=0),X.ARC===r.type&&qa(r,t,e),r))}function cd(){return r=>({...r})}function T1(){const r=cd(),t=ld(),e=ud(),i=hd(),s=er((n,o,a)=>{const l=i(e(t(r(n))));function h(c){c>s.maxX&&(s.maxX=c),c<s.minX&&(s.minX=c)}function u(c){c>s.maxY&&(s.maxY=c),c<s.minY&&(s.minY=c)}if(l.type&X.DRAWING_COMMANDS&&(h(o),u(a)),l.type&X.HORIZ_LINE_TO&&h(l.x),l.type&X.VERT_LINE_TO&&u(l.y),l.type&X.LINE_TO&&(h(l.x),u(l.y)),l.type&X.CURVE_TO){h(l.x),u(l.y);const c=od(o,l.x1,l.x2,l.x);for(const f of c)0<f&&1>f&&h(ad(o,l.x1,l.x2,l.x,f));const d=od(a,l.y1,l.y2,l.y);for(const f of d)0<f&&1>f&&u(ad(a,l.y1,l.y2,l.y,f))}if(l.type&X.ARC){h(l.x),u(l.y),qa(l,o,a);const c=l.xRot/180*Math.PI,d=Math.cos(c)*l.rX,f=Math.sin(c)*l.rX,p=-Math.sin(c)*l.rY,m=Math.cos(c)*l.rY,[_,y]=l.phi1<l.phi2?[l.phi1,l.phi2]:-180>l.phi2?[l.phi2+360,l.phi1+360]:[l.phi2,l.phi1],v=([T,M])=>{const R=Math.atan2(M,T)*180/Math.PI;return R<_?R+360:R},g=id(p,-d,0).map(v);for(const T of g)T>_&&T<y&&h(nd(l.cX,d,p,T));const x=id(m,-f,0).map(v);for(const T of x)T>_&&T<y&&u(nd(l.cY,f,m,T))}return n});return s.minX=1/0,s.maxX=-1/0,s.minY=1/0,s.maxY=-1/0,s}const Qt={ROUND:c1,TO_ABS:ld,TO_REL:d1,NORMALIZE_HVZ:f1,NORMALIZE_ST:hd,QT_TO_C:ud,INFO:er,SANITIZE:p1,MATRIX:Zr,ROTATE:m1,TRANSLATE:g1,SCALE:y1,SKEW_X:_1,SKEW_Y:v1,X_AXIS_SYMMETRY:x1,Y_AXIS_SYMMETRY:b1,A_TO_C:E1,ANNOTATE_ARCS:w1,CLONE:cd,CALCULATE_BOUNDS:T1,REVERSE_PATH:u1,REMOVE_COLLINEAR:h1};class dd{round(t){return this.transform(Qt.ROUND(t))}toAbs(){return this.transform(Qt.TO_ABS())}toRel(){return this.transform(Qt.TO_REL())}normalizeHVZ(t,e,i){return this.transform(Qt.NORMALIZE_HVZ(t,e,i))}normalizeST(){return this.transform(Qt.NORMALIZE_ST())}qtToC(){return this.transform(Qt.QT_TO_C())}aToC(){return this.transform(Qt.A_TO_C())}sanitize(t){return this.transform(Qt.SANITIZE(t))}translate(t,e){return this.transform(Qt.TRANSLATE(t,e))}scale(t,e){return this.transform(Qt.SCALE(t,e))}rotate(t,e,i){return this.transform(Qt.ROTATE(t,e,i))}matrix(t,e,i,s,n,o){return this.transform(Qt.MATRIX(t,e,i,s,n,o))}skewX(t){return this.transform(Qt.SKEW_X(t))}skewY(t){return this.transform(Qt.SKEW_Y(t))}xSymmetry(t){return this.transform(Qt.X_AXIS_SYMMETRY(t))}ySymmetry(t){return this.transform(Qt.Y_AXIS_SYMMETRY(t))}annotateArcs(){return this.transform(Qt.ANNOTATE_ARCS())}}const A1=r=>r===" "||r===" "||r==="\r"||r===`
3
+ `,fd=r=>48<=r.charCodeAt(0)&&r.charCodeAt(0)<=57;class S1 extends dd{constructor(){super();Ht(this,"curNumber","");Ht(this,"curCommandType",-1);Ht(this,"curCommandRelative",!1);Ht(this,"canParseCommandOrComma",!0);Ht(this,"curNumberHasExp",!1);Ht(this,"curNumberHasExpDigits",!1);Ht(this,"curNumberHasDecimal",!1);Ht(this,"curArgs",[])}finish(e=[]){if(this.parse(" ",e),this.curArgs.length!==0||!this.canParseCommandOrComma)throw new SyntaxError("Unterminated command at the path end.");return e}parse(e,i=[]){const s=n=>{i.push(n),this.curArgs.length=0,this.canParseCommandOrComma=!0};for(let n=0;n<e.length;n++){const o=e[n],a=this.curCommandType===X.ARC&&(this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber.length===1&&(this.curNumber==="0"||this.curNumber==="1"),l=fd(o)&&(this.curNumber==="0"&&o==="0"||a);if(fd(o)&&!l){this.curNumber+=o,this.curNumberHasExpDigits=this.curNumberHasExp;continue}if(o==="e"||o==="E"){this.curNumber+=o,this.curNumberHasExp=!0;continue}if((o==="-"||o==="+")&&this.curNumberHasExp&&!this.curNumberHasExpDigits){this.curNumber+=o;continue}if(o==="."&&!this.curNumberHasExp&&!this.curNumberHasDecimal&&!a){this.curNumber+=o,this.curNumberHasDecimal=!0;continue}if(this.curNumber&&this.curCommandType!==-1){const h=Number(this.curNumber);if(isNaN(h))throw new SyntaxError(`Invalid number ending at ${n}`);if(this.curCommandType===X.ARC){if(this.curArgs.length===0||this.curArgs.length===1){if(0>h)throw new SyntaxError(`Expected positive number, got "${h}" at index "${n}"`)}else if((this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber!=="0"&&this.curNumber!=="1")throw new SyntaxError(`Expected a flag, got "${this.curNumber}" at index "${n}"`)}this.curArgs.push(h),this.curArgs.length===C1[this.curCommandType]&&(X.HORIZ_LINE_TO===this.curCommandType?s({type:X.HORIZ_LINE_TO,relative:this.curCommandRelative,x:h}):X.VERT_LINE_TO===this.curCommandType?s({type:X.VERT_LINE_TO,relative:this.curCommandRelative,y:h}):this.curCommandType===X.MOVE_TO||this.curCommandType===X.LINE_TO||this.curCommandType===X.SMOOTH_QUAD_TO?(s({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),X.MOVE_TO===this.curCommandType&&(this.curCommandType=X.LINE_TO)):this.curCommandType===X.CURVE_TO?s({type:X.CURVE_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x2:this.curArgs[2],y2:this.curArgs[3],x:this.curArgs[4],y:this.curArgs[5]}):this.curCommandType===X.SMOOTH_CURVE_TO?s({type:X.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===X.QUAD_TO?s({type:X.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===X.ARC&&s({type:X.ARC,relative:this.curCommandRelative,rX:this.curArgs[0],rY:this.curArgs[1],xRot:this.curArgs[2],lArcFlag:this.curArgs[3],sweepFlag:this.curArgs[4],x:this.curArgs[5],y:this.curArgs[6]})),this.curNumber="",this.curNumberHasExpDigits=!1,this.curNumberHasExp=!1,this.curNumberHasDecimal=!1,this.canParseCommandOrComma=!0}if(!A1(o)){if(o===","&&this.canParseCommandOrComma){this.canParseCommandOrComma=!1;continue}if(o==="+"||o==="-"||o==="."){this.curNumber=o,this.curNumberHasDecimal=o===".";continue}if(l){this.curNumber=o,this.curNumberHasDecimal=!1;continue}if(this.curArgs.length!==0)throw new SyntaxError(`Unterminated command at index ${n}.`);if(!this.canParseCommandOrComma)throw new SyntaxError(`Unexpected character "${o}" at index ${n}. Command cannot follow comma`);if(this.canParseCommandOrComma=!1,o==="z"||o==="Z"){i.push({type:X.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1;continue}else if(o==="h"||o==="H")this.curCommandType=X.HORIZ_LINE_TO,this.curCommandRelative=o==="h";else if(o==="v"||o==="V")this.curCommandType=X.VERT_LINE_TO,this.curCommandRelative=o==="v";else if(o==="m"||o==="M")this.curCommandType=X.MOVE_TO,this.curCommandRelative=o==="m";else if(o==="l"||o==="L")this.curCommandType=X.LINE_TO,this.curCommandRelative=o==="l";else if(o==="c"||o==="C")this.curCommandType=X.CURVE_TO,this.curCommandRelative=o==="c";else if(o==="s"||o==="S")this.curCommandType=X.SMOOTH_CURVE_TO,this.curCommandRelative=o==="s";else if(o==="q"||o==="Q")this.curCommandType=X.QUAD_TO,this.curCommandRelative=o==="q";else if(o==="t"||o==="T")this.curCommandType=X.SMOOTH_QUAD_TO,this.curCommandRelative=o==="t";else if(o==="a"||o==="A")this.curCommandType=X.ARC,this.curCommandRelative=o==="a";else throw new SyntaxError(`Unexpected character "${o}" at index ${n}.`)}}return i}transform(e){return Object.create(this,{parse:{value(s,n=[]){const o=Object.getPrototypeOf(this).parse.call(this,s);for(const a of o){const l=e(a);Array.isArray(l)?n.push(...l):n.push(l)}return n}}})}}const Lt=class Lt extends dd{constructor(e){super();Ht(this,"commands");typeof e=="string"?this.commands=Lt.parse(e):this.commands=e}encode(){return Lt.encode(this.commands)}getBounds(){const e=Qt.CALCULATE_BOUNDS();return this.transform(e),e}transform(e){const i=[];for(const s of this.commands){const n=e(s);Array.isArray(n)?i.push(...n):i.push(n)}return this.commands=i,this}reverse(e=!0){return this.commands=Qt.REVERSE_PATH(this.commands,e),this}removeCollinear(){return this.commands=Qt.REMOVE_COLLINEAR(this.commands),this}static encode(e){return o1(e)}static parse(e){const i=new S1,s=[];return i.parse(e,s),i.finish(s),s}};Ht(Lt,"CLOSE_PATH",1),Ht(Lt,"MOVE_TO",2),Ht(Lt,"HORIZ_LINE_TO",4),Ht(Lt,"VERT_LINE_TO",8),Ht(Lt,"LINE_TO",16),Ht(Lt,"CURVE_TO",32),Ht(Lt,"SMOOTH_CURVE_TO",64),Ht(Lt,"QUAD_TO",128),Ht(Lt,"SMOOTH_QUAD_TO",256),Ht(Lt,"ARC",512),Ht(Lt,"LINE_COMMANDS",Lt.LINE_TO|Lt.HORIZ_LINE_TO|Lt.VERT_LINE_TO),Ht(Lt,"DRAWING_COMMANDS",Lt.HORIZ_LINE_TO|Lt.VERT_LINE_TO|Lt.LINE_TO|Lt.CURVE_TO|Lt.SMOOTH_CURVE_TO|Lt.QUAD_TO|Lt.SMOOTH_QUAD_TO|Lt.ARC);let X=Lt;const C1={[X.MOVE_TO]:2,[X.LINE_TO]:2,[X.HORIZ_LINE_TO]:1,[X.VERT_LINE_TO]:1,[X.CLOSE_PATH]:0,[X.QUAD_TO]:4,[X.SMOOTH_QUAD_TO]:2,[X.CURVE_TO]:6,[X.SMOOTH_CURVE_TO]:4,[X.ARC]:7},Te=[];for(let r=0;r<256;++r)Te.push((r+256).toString(16).slice(1));function I1(r,t=0){return(Te[r[t+0]]+Te[r[t+1]]+Te[r[t+2]]+Te[r[t+3]]+"-"+Te[r[t+4]]+Te[r[t+5]]+"-"+Te[r[t+6]]+Te[r[t+7]]+"-"+Te[r[t+8]]+Te[r[t+9]]+"-"+Te[r[t+10]]+Te[r[t+11]]+Te[r[t+12]]+Te[r[t+13]]+Te[r[t+14]]+Te[r[t+15]]).toLowerCase()}let Ka;const R1=new Uint8Array(16);function M1(){if(!Ka){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Ka=crypto.getRandomValues.bind(crypto)}return Ka(R1)}const pd={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function P1(r,t,e){var s;if(pd.randomUUID&&!r)return pd.randomUUID();r=r||{};const i=r.random??((s=r.rng)==null?void 0:s.call(r))??M1();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=i[6]&15|64,i[8]=i[8]&63|128,I1(i)}const O1=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:s,stroke:n,strokeWidth:o,strokeOpacity:a}=e;let l="";return i&&(l+=`fill:${i};`,l+=`fill-opacity:${s||"0.25"};`),n&&(l+=`stroke:${n};`,l+=`stroke-width:${o||"1"};`,l+=`stroke-opacity:${a||"1"};`),l}},Za=(r,t=0)=>{const{minX:e,minY:i,maxX:s,maxY:n}=r;return{x:e-t,y:i-t,w:s-e+2*t,h:n-i+2*t}},Qr=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,N1=r=>({}),md=r=>({grab:r[0]});function D1(r){let t,e,i,s;const n=r[8].default,o=Vc(n,r,r[7],md);return{c(){t=st("g"),o&&o.c(),E(t,"class","a9s-annotation selected")},m(a,l){lt(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&128)&&jc(o,n,a,a[7],e?Yc(n,a[7],l,N1):Wc(a[7]),md)},i(a){e||(Z(o,a),e=!0)},o(a){ht(o,a),e=!1},d(a){a&&ot(t),o&&o.d(a),i=!1,Ye(s)}}}function L1(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=Zi();let{shape:o}=t,{editor:a}=t,{transform:l}=t,{svgEl:h}=t,u,c,d;const f=_=>y=>{if(u=_,h){const{left:g,top:x}=h.getBoundingClientRect(),T=y.clientX-g,M=y.clientY-x;c=l.elementToImage(T,M)}else{const{offsetX:g,offsetY:x}=y;c=l.elementToImage(g,x)}d=o,y.target.setPointerCapture(y.pointerId),n("grab",y)},p=_=>{if(u){const[y,v]=l.elementToImage(_.offsetX,_.offsetY),g=[y-c[0],v-c[1]];e(3,o=a(d,u,g)),n("change",o)}},m=_=>{_.target.releasePointerCapture(_.pointerId),u=void 0,d=o,n("release",_)};return r.$$set=_=>{"shape"in _&&e(3,o=_.shape),"editor"in _&&e(4,a=_.editor),"transform"in _&&e(5,l=_.transform),"svgEl"in _&&e(6,h=_.svgEl),"$$scope"in _&&e(7,s=_.$$scope)},[f,p,m,o,a,l,h,s,i]}class Qa extends ie{constructor(t){super(),re(this,t,L1,D1,Yt,{shape:3,editor:4,transform:5,svgEl:6})}}function B1(r){let t,e,i,s,n,o,a,l,h=r[3]&&gd(r);return{c(){t=st("g"),e=st("circle"),h&&h.c(),s=st("circle"),E(e,"class","a9s-handle-buffer"),E(e,"cx",r[0]),E(e,"cy",r[1]),E(e,"r",i=r[5]+6/r[2]),E(s,"class",n=`a9s-handle-dot${r[3]?" selected":""}`),E(s,"cx",r[0]),E(s,"cy",r[1]),E(s,"r",r[5]),E(t,"class",o=`a9s-handle ${r[8].class||""}`.trim())},m(u,c){lt(u,t,c),Ct(t,e),h&&h.m(t,null),Ct(t,s),a||(l=[Ot(e,"pointerenter",r[11]),Ot(e,"pointerleave",r[12]),Ot(e,"pointerdown",r[13]),Ot(e,"pointerdown",r[6]),Ot(e,"pointerup",r[14]),Ot(e,"pointerup",r[7])],a=!0)},p(u,c){c&1&&E(e,"cx",u[0]),c&2&&E(e,"cy",u[1]),c&36&&i!==(i=u[5]+6/u[2])&&E(e,"r",i),u[3]?h?h.p(u,c):(h=gd(u),h.c(),h.m(t,s)):h&&(h.d(1),h=null),c&8&&n!==(n=`a9s-handle-dot${u[3]?" selected":""}`)&&E(s,"class",n),c&1&&E(s,"cx",u[0]),c&2&&E(s,"cy",u[1]),c&32&&E(s,"r",u[5]),c&256&&o!==(o=`a9s-handle ${u[8].class||""}`.trim())&&E(t,"class",o)},d(u){u&&ot(t),h&&h.d(),a=!1,Ye(l)}}}function F1(r){let t,e,i,s,n,o,a,l,h;return{c(){t=st("g"),e=st("circle"),s=st("circle"),o=st("circle"),E(e,"cx",r[0]),E(e,"cy",r[1]),E(e,"r",i=r[5]*10),E(e,"class","a9s-touch-halo"),qr(e,"touched",r[4]),E(s,"cx",r[0]),E(s,"cy",r[1]),E(s,"r",n=r[5]+10/r[2]),E(s,"class","a9s-handle-buffer"),E(o,"class","a9s-handle-dot"),E(o,"cx",r[0]),E(o,"cy",r[1]),E(o,"r",a=r[5]+2/r[2]),E(t,"class","a9s-touch-handle")},m(u,c){lt(u,t,c),Ct(t,e),Ct(t,s),Ct(t,o),l||(h=[Ot(s,"pointerdown",r[9]),Ot(s,"pointerup",r[10]),Ot(s,"pointerdown",r[6]),Ot(s,"pointerup",r[7])],l=!0)},p(u,c){c&1&&E(e,"cx",u[0]),c&2&&E(e,"cy",u[1]),c&32&&i!==(i=u[5]*10)&&E(e,"r",i),c&16&&qr(e,"touched",u[4]),c&1&&E(s,"cx",u[0]),c&2&&E(s,"cy",u[1]),c&36&&n!==(n=u[5]+10/u[2])&&E(s,"r",n),c&1&&E(o,"cx",u[0]),c&2&&E(o,"cy",u[1]),c&36&&a!==(a=u[5]+2/u[2])&&E(o,"r",a)},d(u){u&&ot(t),l=!1,Ye(h)}}}function gd(r){let t,e;return{c(){t=st("circle"),E(t,"class","a9s-handle-selected"),E(t,"cx",r[0]),E(t,"cy",r[1]),E(t,"r",e=r[5]+8/r[2])},m(i,s){lt(i,t,s)},p(i,s){s&1&&E(t,"cx",i[0]),s&2&&E(t,"cy",i[1]),s&36&&e!==(e=i[5]+8/i[2])&&E(t,"r",e)},d(i){i&&ot(t)}}}function k1(r){let t;function e(n,o){return Qr?F1:B1}let s=e()(r);return{c(){s.c(),t=Ge()},m(n,o){s.m(n,o),lt(n,t,o)},p(n,[o]){s.p(n,o)},i:zt,o:zt,d(n){n&&ot(t),s.d(n)}}}function U1(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t,{selected:a=void 0}=t,l=!1;const h=y=>{y.pointerType==="touch"&&e(4,l=!0)},u=()=>e(4,l=!1);function c(y){Oe.call(this,r,y)}function d(y){Oe.call(this,r,y)}function f(y){Oe.call(this,r,y)}function p(y){Oe.call(this,r,y)}function m(y){Oe.call(this,r,y)}function _(y){Oe.call(this,r,y)}return r.$$set=y=>{e(8,t=ka(ka({},t),qc(y))),"x"in y&&e(0,s=y.x),"y"in y&&e(1,n=y.y),"scale"in y&&e(2,o=y.scale),"selected"in y&&e(3,a=y.selected)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=4/o)},t=qc(t),[s,n,o,a,l,i,h,u,t,c,d,f,p,m,_]}class rs extends ie{constructor(t){super(),re(this,t,U1,k1,Yt,{x:0,y:1,scale:2,selected:3})}}function G1(r){let t,e,i,s,n,o,a;return{c(){t=st("g"),e=st("circle"),s=st("circle"),n=st("circle"),E(e,"class","a9s-polygon-midpoint-buffer svelte-12ykj76"),E(e,"cx",r[0]),E(e,"cy",r[1]),E(e,"r",i=1.75*r[2]),E(s,"class","a9s-polygon-midpoint-outer svelte-12ykj76"),E(s,"cx",r[0]),E(s,"cy",r[1]),E(s,"r",r[2]),E(n,"class","a9s-polygon-midpoint-inner svelte-12ykj76"),E(n,"cx",r[0]),E(n,"cy",r[1]),E(n,"r",r[2]),E(t,"class","a9s-polygon-midpoint svelte-12ykj76")},m(l,h){lt(l,t,h),Ct(t,e),Ct(t,s),Ct(t,n),o||(a=[Ot(e,"pointerdown",r[5]),Ot(e,"pointerdown",r[3])],o=!0)},p(l,h){h&1&&E(e,"cx",l[0]),h&2&&E(e,"cy",l[1]),h&4&&i!==(i=1.75*l[2])&&E(e,"r",i),h&1&&E(s,"cx",l[0]),h&2&&E(s,"cy",l[1]),h&4&&E(s,"r",l[2]),h&1&&E(n,"cx",l[0]),h&2&&E(n,"cy",l[1]),h&4&&E(n,"r",l[2])},d(l){l&&ot(t),o=!1,Ye(a)}}}function $1(r){let t;return{c(){t=st("circle"),E(t,"cx",r[0]),E(t,"cy",r[1]),E(t,"r",r[2])},m(e,i){lt(e,t,i)},p(e,i){i&1&&E(t,"cx",e[0]),i&2&&E(t,"cy",e[1]),i&4&&E(t,"r",e[2])},d(e){e&&ot(t)}}}function H1(r){let t;function e(n,o){return Qr?$1:G1}let s=e()(r);return{c(){s.c(),t=Ge()},m(n,o){s.m(n,o),lt(n,t,o)},p(n,[o]){s.p(n,o)},i:zt,o:zt,d(n){n&&ot(t),s.d(n)}}}function X1(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t;const a=h=>{h.pointerType};function l(h){Oe.call(this,r,h)}return r.$$set=h=>{"x"in h&&e(0,s=h.x),"y"in h&&e(1,n=h.y),"scale"in h&&e(4,o=h.scale)},r.$$.update=()=>{r.$$.dirty&16&&e(2,i=4/o)},[s,n,i,a,o,l]}class yd extends ie{constructor(t){super(),re(this,t,X1,H1,Yt,{x:0,y:1,scale:4})}}function Ja(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function _d(r,t,e){const i=r.slice();return i[28]=t[e],i[30]=e,i}function tl(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function el(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function vd(r){let t,e,i,s;return{c(){t=st("circle"),E(t,"cx",e=r[28][0]),E(t,"cy",i=r[28][1]),E(t,"r",s=Vs/r[3]),E(t,"class","svelte-1h2slbm")},m(n,o){lt(n,t,o)},p(n,o){o[0]&1088&&e!==(e=n[28][0])&&E(t,"cx",e),o[0]&1088&&i!==(i=n[28][1])&&E(t,"cy",i),o[0]&8&&s!==(s=Vs/n[3])&&E(t,"r",s)},d(n){n&&ot(t)}}}function xd(r){let t,e,i,s,n,o,a,l,h,u;return{c(){t=st("mask"),e=st("rect"),a=st("circle"),E(e,"x",i=r[9].x),E(e,"y",s=r[9].y),E(e,"width",n=r[9].w),E(e,"height",o=r[9].h),E(e,"class","svelte-1h2slbm"),E(a,"cx",l=r[28][0]),E(a,"cy",h=r[28][1]),E(a,"r",u=Vs/r[3]),E(a,"class","svelte-1h2slbm"),E(t,"id",`${r[19]}-inner`),E(t,"class","a9s-polygon-editor-mask svelte-1h2slbm")},m(c,d){lt(c,t,d),Ct(t,e),Ct(t,a)},p(c,d){d[0]&512&&i!==(i=c[9].x)&&E(e,"x",i),d[0]&512&&s!==(s=c[9].y)&&E(e,"y",s),d[0]&512&&n!==(n=c[9].w)&&E(e,"width",n),d[0]&512&&o!==(o=c[9].h)&&E(e,"height",o),d[0]&1088&&l!==(l=c[28][0])&&E(a,"cx",l),d[0]&1088&&h!==(h=c[28][1])&&E(a,"cy",h),d[0]&8&&u!==(u=Vs/c[3])&&E(a,"r",u)},d(c){c&&ot(t)}}}function bd(r){let t,e;return t=new rs({props:{class:"a9s-corner-handle",x:r[28][0],y:r[28][1],scale:r[3],selected:r[8].includes(r[30])}}),t.$on("pointerenter",r[11]),t.$on("pointerleave",r[12]),t.$on("pointerdown",r[15]),t.$on("pointerdown",function(){ee(r[27](`HANDLE-${r[30]}`))&&r[27](`HANDLE-${r[30]}`).apply(this,arguments)}),t.$on("pointerup",r[16](r[30])),{c(){Ut(t.$$.fragment)},m(i,s){Bt(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&32&&(n.x=r[28][0]),s[0]&32&&(n.y=r[28][1]),s[0]&8&&(n.scale=r[3]),s[0]&256&&(n.selected=r[8].includes(r[30])),t.$set(n)},i(i){e||(Z(t.$$.fragment,i),e=!0)},o(i){ht(t.$$.fragment,i),e=!1},d(i){Ft(t,i)}}}function Ed(r){let t,e;return t=new yd({props:{x:r[28][0],y:r[28][1],scale:r[3]}}),t.$on("pointerdown",function(){ee(r[18](r[6]))&&r[18](r[6]).apply(this,arguments)}),{c(){Ut(t.$$.fragment)},m(i,s){Bt(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&1088&&(n.x=r[28][0]),s[0]&1088&&(n.y=r[28][1]),s[0]&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(Z(t.$$.fragment,i),e=!0)},o(i){ht(t.$$.fragment,i),e=!1},d(i){Ft(t,i)}}}function V1(r){let t,e,i,s,n,o,a,l,h,u,c,d,f,p,m,_,y,v,g,x,T,M=r[6]!==void 0&&!r[7]&&vd(el(r)),S=r[6]!==void 0&&!r[7]&&xd(tl(r)),R=Ne(r[5].points),P=[];for(let I=0;I<R.length;I+=1)P[I]=bd(_d(r,R,I));const F=I=>ht(P[I],1,1,()=>{P[I]=null});let U=r[6]!==void 0&&!r[7]&&Ed(Ja(r));return{c(){t=st("defs"),e=st("mask"),i=st("rect"),l=st("polygon"),M&&M.c(),S&&S.c(),u=Le(),c=st("polygon"),f=Le(),p=st("polygon"),_=Le();for(let I=0;I<P.length;I+=1)P[I].c();y=Le(),U&&U.c(),v=Ge(),E(i,"x",s=r[9].x),E(i,"y",n=r[9].y),E(i,"width",o=r[9].w),E(i,"height",a=r[9].h),E(i,"class","svelte-1h2slbm"),E(l,"points",h=r[5].points.map(wd).join(" ")),E(l,"class","svelte-1h2slbm"),E(e,"id",`${r[19]}-outer`),E(e,"class","a9s-polygon-editor-mask svelte-1h2slbm"),E(c,"class","a9s-outer"),E(c,"mask",`url(#${r[19]}-outer)`),E(c,"points",d=r[5].points.map(Td).join(" ")),E(p,"class","a9s-inner a9s-shape-handle"),E(p,"mask",`url(#${r[19]}-inner)`),E(p,"style",r[1]),E(p,"points",m=r[5].points.map(Ad).join(" "))},m(I,A){lt(I,t,A),Ct(t,e),Ct(e,i),Ct(e,l),M&&M.m(e,null),S&&S.m(t,null),lt(I,u,A),lt(I,c,A),lt(I,f,A),lt(I,p,A),lt(I,_,A);for(let w=0;w<P.length;w+=1)P[w]&&P[w].m(I,A);lt(I,y,A),U&&U.m(I,A),lt(I,v,A),g=!0,x||(T=[Ot(c,"pointerup",r[14]),Ot(c,"pointerdown",function(){ee(r[27]("SHAPE"))&&r[27]("SHAPE").apply(this,arguments)}),Ot(p,"pointermove",r[13]),Ot(p,"pointerup",r[14]),Ot(p,"pointerdown",function(){ee(r[27]("SHAPE"))&&r[27]("SHAPE").apply(this,arguments)})],x=!0)},p(I,A){if(r=I,(!g||A[0]&512&&s!==(s=r[9].x))&&E(i,"x",s),(!g||A[0]&512&&n!==(n=r[9].y))&&E(i,"y",n),(!g||A[0]&512&&o!==(o=r[9].w))&&E(i,"width",o),(!g||A[0]&512&&a!==(a=r[9].h))&&E(i,"height",a),(!g||A[0]&32&&h!==(h=r[5].points.map(wd).join(" ")))&&E(l,"points",h),r[6]!==void 0&&!r[7]?M?M.p(el(r),A):(M=vd(el(r)),M.c(),M.m(e,null)):M&&(M.d(1),M=null),r[6]!==void 0&&!r[7]?S?S.p(tl(r),A):(S=xd(tl(r)),S.c(),S.m(t,null)):S&&(S.d(1),S=null),(!g||A[0]&32&&d!==(d=r[5].points.map(Td).join(" ")))&&E(c,"points",d),(!g||A[0]&2)&&E(p,"style",r[1]),(!g||A[0]&32&&m!==(m=r[5].points.map(Ad).join(" ")))&&E(p,"points",m),A[0]&134322472){R=Ne(r[5].points);let w;for(w=0;w<R.length;w+=1){const C=_d(r,R,w);P[w]?(P[w].p(C,A),Z(P[w],1)):(P[w]=bd(C),P[w].c(),Z(P[w],1),P[w].m(y.parentNode,y))}for(pe(),w=R.length;w<P.length;w+=1)F(w);me()}r[6]!==void 0&&!r[7]?U?(U.p(Ja(r),A),A[0]&192&&Z(U,1)):(U=Ed(Ja(r)),U.c(),Z(U,1),U.m(v.parentNode,v)):U&&(pe(),ht(U,1,1,()=>{U=null}),me())},i(I){if(!g){for(let A=0;A<R.length;A+=1)Z(P[A]);Z(U),g=!0}},o(I){P=P.filter(Boolean);for(let A=0;A<P.length;A+=1)ht(P[A]);ht(U),g=!1},d(I){I&&(ot(t),ot(u),ot(c),ot(f),ot(p),ot(_),ot(y),ot(v)),M&&M.d(),S&&S.d(),Wr(P,I),U&&U.d(I),x=!1,Ye(T)}}}function z1(r){let t,e;return t=new Qa({props:{shape:r[0],transform:r[2],editor:r[17],svgEl:r[4],$$slots:{default:[V1,({grab:i})=>({27:i}),({grab:i})=>[i?134217728:0]]},$$scope:{ctx:r}}}),t.$on("change",r[20]),t.$on("grab",r[21]),t.$on("release",r[22]),{c(){Ut(t.$$.fragment)},m(i,s){Bt(t,i,s),e=!0},p(i,s){const n={};s[0]&1&&(n.shape=i[0]),s[0]&4&&(n.transform=i[2]),s[0]&16&&(n.svgEl=i[4]),s[0]&134219754|s[1]&1&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(Z(t.$$.fragment,i),e=!0)},o(i){ht(t.$$.fragment,i),e=!1},d(i){Ft(t,i)}}}const Y1=250,j1=1e3,W1=12,Vs=4.5,wd=r=>r.join(","),Td=r=>r.join(","),Ad=r=>r.join(",");function q1(r,t,e){let i,s,n;const o=Zi();let{shape:a}=t,{computedStyle:l}=t,{transform:h}=t,{viewportScale:u=1}=t,{svgEl:c}=t,d,f=!1,p,m=[];const _=()=>e(7,f=!0),y=()=>e(7,f=!1),v=w=>{if(m.length>0||!s.some(H=>H.visible)){e(6,d=void 0);return}const[C,L]=h.elementToImage(w.offsetX,w.offsetY),O=H=>Math.pow(H[0]-C,2)+Math.pow(H[1]-L,2),B=i.points.reduce((H,k)=>O(k)<O(H)?k:H),V=s.filter(H=>H.visible).reduce((H,k)=>O(k.point)<O(H.point)?k:H),D=Math.pow(j1/u,2);O(B)<D||O(V.point)<D?e(6,d=s.indexOf(V)):e(6,d=void 0)},g=()=>{document.activeElement!==c&&c.focus()},x=()=>{e(8,m=[]),g()},T=w=>{e(7,f=!0),w.preventDefault(),w.stopPropagation(),p=performance.now()},M=w=>C=>{if(!p||Qr||performance.now()-p>Y1)return;const L=m.includes(w);C.metaKey||C.ctrlKey||C.shiftKey?L?e(8,m=m.filter(O=>O!==w)):e(8,m=[...m,w]):L&&m.length>1?e(8,m=[w]):L?e(8,m=[]):e(8,m=[w]),g()},S=(w,C,L)=>{g();let O;const B=w.geometry;m.length>1?O=B.points.map(([D,N],H)=>m.includes(H)?[D+L[0],N+L[1]]:[D,N]):C==="SHAPE"?O=B.points.map(([D,N])=>[D+L[0],N+L[1]]):O=B.points.map(([D,N],H)=>C===`HANDLE-${H}`?[D+L[0],N+L[1]]:[D,N]);const V=dr(O);return{...w,geometry:{points:O,bounds:V}}},R=w=>async C=>{C.stopPropagation();const L=[...i.points.slice(0,w+1),s[w].point,...i.points.slice(w+1)],O=dr(L);o("change",{...a,geometry:{points:L,bounds:O}}),await Jc();const B=[...document.querySelectorAll(".a9s-handle")][w+1];if(B!=null&&B.firstChild){const V=new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:C.clientX,clientY:C.clientY,pointerId:C.pointerId,pointerType:C.pointerType,isPrimary:C.isPrimary,buttons:C.buttons});B.firstChild.dispatchEvent(V)}},P=()=>{if(i.points.length-m.length<3)return;const w=i.points.filter((L,O)=>!m.includes(O)),C=dr(w);o("change",{...a,geometry:{points:w,bounds:C}}),e(8,m=[])};vi(()=>{if(Qr)return;const w=C=>{(C.key==="Delete"||C.key==="Backspace")&&(C.preventDefault(),P())};return c.addEventListener("pointermove",v),c.addEventListener("keydown",w),()=>{c.removeEventListener("pointermove",v),c.removeEventListener("keydown",w)}});const F=`polygon-mask-${Math.random().toString(36).substring(2,12)}`;function U(w){Oe.call(this,r,w)}function I(w){Oe.call(this,r,w)}function A(w){Oe.call(this,r,w)}return r.$$set=w=>{"shape"in w&&e(0,a=w.shape),"computedStyle"in w&&e(1,l=w.computedStyle),"transform"in w&&e(2,h=w.transform),"viewportScale"in w&&e(3,u=w.viewportScale),"svgEl"in w&&e(4,c=w.svgEl)},r.$$.update=()=>{r.$$.dirty[0]&1&&e(5,i=a.geometry),r.$$.dirty[0]&40&&e(10,s=Qr?[]:i.points.map((w,C)=>{const L=C===i.points.length-1?i.points[0]:i.points[C+1],O=(w[0]+L[0])/2,B=(w[1]+L[1])/2,D=Math.sqrt(Math.pow(L[0]-O,2)+Math.pow(L[1]-B,2))>W1/u;return{point:[O,B],visible:D}})),r.$$.dirty[0]&40&&e(9,n=Za(i.bounds,Vs/u))},[a,l,h,u,c,i,d,f,m,n,s,_,y,v,x,T,M,S,R,F,U,I,A]}class K1 extends ie{constructor(t){super(),re(this,t,q1,z1,Yt,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}function Z1(r){let t,e,i,s,n,o,a,l,h,u,c,d,f,p,m,_,y,v,g,x,T,M,S,R,P,F,U,I,A,w,C,L,O,B,V,D,N,H,k,z,Y,pt,_t,W,Et,nt,mt,vt,Mt,Dt,ve,Kt,et,Ke,_n;return nt=new rs({props:{class:"a9s-corner-handle-topleft",x:r[5].x,y:r[5].y,scale:r[3]}}),nt.$on("pointerdown",function(){ee(r[12]("TOP_LEFT"))&&r[12]("TOP_LEFT").apply(this,arguments)}),vt=new rs({props:{class:"a9s-corner-handle-topright",x:r[5].x+r[5].w,y:r[5].y,scale:r[3]}}),vt.$on("pointerdown",function(){ee(r[12]("TOP_RIGHT"))&&r[12]("TOP_RIGHT").apply(this,arguments)}),Dt=new rs({props:{class:"a9s-corner-handle-bottomright",x:r[5].x+r[5].w,y:r[5].y+r[5].h,scale:r[3]}}),Dt.$on("pointerdown",function(){ee(r[12]("BOTTOM_RIGHT"))&&r[12]("BOTTOM_RIGHT").apply(this,arguments)}),Kt=new rs({props:{class:"a9s-corner-handle-bottomleft",x:r[5].x,y:r[5].y+r[5].h,scale:r[3]}}),Kt.$on("pointerdown",function(){ee(r[12]("BOTTOM_LEFT"))&&r[12]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=st("defs"),e=st("mask"),i=st("rect"),l=st("rect"),f=Le(),p=st("rect"),g=Le(),x=st("rect"),P=Le(),F=st("rect"),w=Le(),C=st("rect"),V=Le(),D=st("rect"),z=Le(),Y=st("rect"),Et=Le(),Ut(nt.$$.fragment),mt=Le(),Ut(vt.$$.fragment),Mt=Le(),Ut(Dt.$$.fragment),ve=Le(),Ut(Kt.$$.fragment),E(i,"class","rect-mask-bg svelte-1njczvj"),E(i,"x",s=r[6].x),E(i,"y",n=r[6].y),E(i,"width",o=r[6].w),E(i,"height",a=r[6].h),E(l,"class","rect-mask-fg svelte-1njczvj"),E(l,"x",h=r[5].x),E(l,"y",u=r[5].y),E(l,"width",c=r[5].w),E(l,"height",d=r[5].h),E(e,"id",r[8]),E(e,"class","a9s-rectangle-editor-mask svelte-1njczvj"),E(p,"class","a9s-outer"),E(p,"mask",`url(#${r[8]})`),E(p,"x",m=r[5].x),E(p,"y",_=r[5].y),E(p,"width",y=r[5].w),E(p,"height",v=r[5].h),E(x,"class","a9s-inner a9s-shape-handle"),E(x,"style",r[1]),E(x,"x",T=r[5].x),E(x,"y",M=r[5].y),E(x,"width",S=r[5].w),E(x,"height",R=r[5].h),E(F,"class","a9s-edge-handle a9s-edge-handle-top"),E(F,"x",U=r[5].x),E(F,"y",I=r[5].y),E(F,"height",1),E(F,"width",A=r[5].w),E(C,"class","a9s-edge-handle a9s-edge-handle-right"),E(C,"x",L=r[5].x+r[5].w),E(C,"y",O=r[5].y),E(C,"height",B=r[5].h),E(C,"width",1),E(D,"class","a9s-edge-handle a9s-edge-handle-bottom"),E(D,"x",N=r[5].x),E(D,"y",H=r[5].y+r[5].h),E(D,"height",1),E(D,"width",k=r[5].w),E(Y,"class","a9s-edge-handle a9s-edge-handle-left"),E(Y,"x",pt=r[5].x),E(Y,"y",_t=r[5].y),E(Y,"height",W=r[5].h),E(Y,"width",1)},m(q,$){lt(q,t,$),Ct(t,e),Ct(e,i),Ct(e,l),lt(q,f,$),lt(q,p,$),lt(q,g,$),lt(q,x,$),lt(q,P,$),lt(q,F,$),lt(q,w,$),lt(q,C,$),lt(q,V,$),lt(q,D,$),lt(q,z,$),lt(q,Y,$),lt(q,Et,$),Bt(nt,q,$),lt(q,mt,$),Bt(vt,q,$),lt(q,Mt,$),Bt(Dt,q,$),lt(q,ve,$),Bt(Kt,q,$),et=!0,Ke||(_n=[Ot(p,"pointerdown",function(){ee(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),Ot(x,"pointerdown",function(){ee(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),Ot(F,"pointerdown",function(){ee(r[12]("TOP"))&&r[12]("TOP").apply(this,arguments)}),Ot(C,"pointerdown",function(){ee(r[12]("RIGHT"))&&r[12]("RIGHT").apply(this,arguments)}),Ot(D,"pointerdown",function(){ee(r[12]("BOTTOM"))&&r[12]("BOTTOM").apply(this,arguments)}),Ot(Y,"pointerdown",function(){ee(r[12]("LEFT"))&&r[12]("LEFT").apply(this,arguments)})],Ke=!0)},p(q,$){r=q,(!et||$&64&&s!==(s=r[6].x))&&E(i,"x",s),(!et||$&64&&n!==(n=r[6].y))&&E(i,"y",n),(!et||$&64&&o!==(o=r[6].w))&&E(i,"width",o),(!et||$&64&&a!==(a=r[6].h))&&E(i,"height",a),(!et||$&32&&h!==(h=r[5].x))&&E(l,"x",h),(!et||$&32&&u!==(u=r[5].y))&&E(l,"y",u),(!et||$&32&&c!==(c=r[5].w))&&E(l,"width",c),(!et||$&32&&d!==(d=r[5].h))&&E(l,"height",d),(!et||$&32&&m!==(m=r[5].x))&&E(p,"x",m),(!et||$&32&&_!==(_=r[5].y))&&E(p,"y",_),(!et||$&32&&y!==(y=r[5].w))&&E(p,"width",y),(!et||$&32&&v!==(v=r[5].h))&&E(p,"height",v),(!et||$&2)&&E(x,"style",r[1]),(!et||$&32&&T!==(T=r[5].x))&&E(x,"x",T),(!et||$&32&&M!==(M=r[5].y))&&E(x,"y",M),(!et||$&32&&S!==(S=r[5].w))&&E(x,"width",S),(!et||$&32&&R!==(R=r[5].h))&&E(x,"height",R),(!et||$&32&&U!==(U=r[5].x))&&E(F,"x",U),(!et||$&32&&I!==(I=r[5].y))&&E(F,"y",I),(!et||$&32&&A!==(A=r[5].w))&&E(F,"width",A),(!et||$&32&&L!==(L=r[5].x+r[5].w))&&E(C,"x",L),(!et||$&32&&O!==(O=r[5].y))&&E(C,"y",O),(!et||$&32&&B!==(B=r[5].h))&&E(C,"height",B),(!et||$&32&&N!==(N=r[5].x))&&E(D,"x",N),(!et||$&32&&H!==(H=r[5].y+r[5].h))&&E(D,"y",H),(!et||$&32&&k!==(k=r[5].w))&&E(D,"width",k),(!et||$&32&&pt!==(pt=r[5].x))&&E(Y,"x",pt),(!et||$&32&&_t!==(_t=r[5].y))&&E(Y,"y",_t),(!et||$&32&&W!==(W=r[5].h))&&E(Y,"height",W);const Ur={};$&32&&(Ur.x=r[5].x),$&32&&(Ur.y=r[5].y),$&8&&(Ur.scale=r[3]),nt.$set(Ur);const Gr={};$&32&&(Gr.x=r[5].x+r[5].w),$&32&&(Gr.y=r[5].y),$&8&&(Gr.scale=r[3]),vt.$set(Gr);const $r={};$&32&&($r.x=r[5].x+r[5].w),$&32&&($r.y=r[5].y+r[5].h),$&8&&($r.scale=r[3]),Dt.$set($r);const Hr={};$&32&&(Hr.x=r[5].x),$&32&&(Hr.y=r[5].y+r[5].h),$&8&&(Hr.scale=r[3]),Kt.$set(Hr)},i(q){et||(Z(nt.$$.fragment,q),Z(vt.$$.fragment,q),Z(Dt.$$.fragment,q),Z(Kt.$$.fragment,q),et=!0)},o(q){ht(nt.$$.fragment,q),ht(vt.$$.fragment,q),ht(Dt.$$.fragment,q),ht(Kt.$$.fragment,q),et=!1},d(q){q&&(ot(t),ot(f),ot(p),ot(g),ot(x),ot(P),ot(F),ot(w),ot(C),ot(V),ot(D),ot(z),ot(Y),ot(Et),ot(mt),ot(Mt),ot(ve)),Ft(nt,q),Ft(vt,q),Ft(Dt,q),Ft(Kt,q),Ke=!1,Ye(_n)}}}function Q1(r){let t,e;return t=new Qa({props:{shape:r[0],transform:r[2],editor:r[7],svgEl:r[4],$$slots:{default:[Z1,({grab:i})=>({12:i}),({grab:i})=>i?4096:0]},$$scope:{ctx:r}}}),t.$on("grab",r[9]),t.$on("change",r[10]),t.$on("release",r[11]),{c(){Ut(t.$$.fragment)},m(i,s){Bt(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&16&&(n.svgEl=i[4]),s&12394&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(Z(t.$$.fragment,i),e=!0)},o(i){ht(t.$$.fragment,i),e=!1},d(i){Ft(t,i)}}}function J1(r,t,e){let i,s,{shape:n}=t,{computedStyle:o}=t,{transform:a}=t,{viewportScale:l=1}=t,{svgEl:h}=t;const u=(m,_,y)=>{const v=m.geometry.bounds;let[g,x]=[v.minX,v.minY],[T,M]=[v.maxX,v.maxY];const[S,R]=y;if(_==="SHAPE")g+=S,T+=S,x+=R,M+=R;else{switch(_){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{x+=R;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{M+=R;break}}switch(_){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{g+=S;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{T+=S;break}}}const P=Math.min(g,T),F=Math.min(x,M),U=Math.abs(T-g),I=Math.abs(M-x);return{...m,geometry:{x:P,y:F,w:U,h:I,bounds:{minX:P,minY:F,maxX:P+U,maxY:F+I}}}},c=`rect-mask-${Math.random().toString(36).substring(2,12)}`;function d(m){Oe.call(this,r,m)}function f(m){Oe.call(this,r,m)}function p(m){Oe.call(this,r,m)}return r.$$set=m=>{"shape"in m&&e(0,n=m.shape),"computedStyle"in m&&e(1,o=m.computedStyle),"transform"in m&&e(2,a=m.transform),"viewportScale"in m&&e(3,l=m.viewportScale),"svgEl"in m&&e(4,h=m.svgEl)},r.$$.update=()=>{r.$$.dirty&1&&e(5,i=n.geometry),r.$$.dirty&40&&e(6,s=Za(i.bounds,2/l))},[n,o,a,l,h,i,s,u,c,d,f,p]}class tx extends ie{constructor(t){super(),re(this,t,J1,Q1,Yt,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4})}}var Sd=Object.prototype.hasOwnProperty;function rl(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--&&rl(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(Sd.call(r,e)&&++i&&!Sd.call(t,e)||!(e in t)||!rl(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}const ex=12,rx=(r,t)=>r.polygons.reduce((e,i,s)=>{const n=i.rings.reduce((o,a,l)=>{const h=a.points.map((u,c)=>{const d=c===a.points.length-1?a.points[0]:a.points[c+1],f=(u[0]+d[0])/2,p=(u[1]+d[1])/2,_=Math.sqrt(Math.pow(d[0]-f,2)+Math.pow(d[1]-p,2))>ex/t;return{point:[f,p],visible:_,elementIdx:s,ringIdx:l,pointIdx:c}});return[...o,...h]},[]);return[...e,...n]},[]);function il(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function Cd(r,t,e){const i=r.slice();return i[30]=t[e],i[32]=e,i}function Id(r,t,e){const i=r.slice();return i[33]=t[e],i[35]=e,i}function Rd(r,t,e){const i=r.slice();return i[29]=t[e],i[37]=e,i}function sl(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function nl(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function Md(r){let t,e,i,s;return{c(){t=st("circle"),E(t,"cx",e=r[29][0]),E(t,"cy",i=r[29][1]),E(t,"r",s=zs/r[3]),E(t,"class","svelte-1vxo6dc")},m(n,o){lt(n,t,o)},p(n,o){o[0]&1088&&e!==(e=n[29][0])&&E(t,"cx",e),o[0]&1088&&i!==(i=n[29][1])&&E(t,"cy",i),o[0]&8&&s!==(s=zs/n[3])&&E(t,"r",s)},d(n){n&&ot(t)}}}function Pd(r){let t,e,i,s,n,o,a,l,h,u;return{c(){t=st("mask"),e=st("rect"),a=st("circle"),E(e,"x",i=r[9].x),E(e,"y",s=r[9].y),E(e,"width",n=r[9].w),E(e,"height",o=r[9].h),E(e,"class","svelte-1vxo6dc"),E(a,"cx",l=r[29][0]),E(a,"cy",h=r[29][1]),E(a,"r",u=zs/r[3]),E(a,"class","svelte-1vxo6dc"),E(t,"id",`${r[18]}-${r[32]}-inner`),E(t,"class","a9s-multipolygon-editor-mask svelte-1vxo6dc")},m(c,d){lt(c,t,d),Ct(t,e),Ct(t,a)},p(c,d){d[0]&512&&i!==(i=c[9].x)&&E(e,"x",i),d[0]&512&&s!==(s=c[9].y)&&E(e,"y",s),d[0]&512&&n!==(n=c[9].w)&&E(e,"width",n),d[0]&512&&o!==(o=c[9].h)&&E(e,"height",o),d[0]&1088&&l!==(l=c[29][0])&&E(a,"cx",l),d[0]&1088&&h!==(h=c[29][1])&&E(a,"cy",h),d[0]&8&&u!==(u=zs/c[3])&&E(a,"r",u)},d(c){c&&ot(t)}}}function Od(r){let t,e;function i(...s){return r[19](r[32],r[35],r[37],...s)}return t=new rs({props:{class:"a9s-corner-handle",x:r[29][0],y:r[29][1],scale:r[3],selected:r[8].some(i)}}),t.$on("pointerenter",r[11]),t.$on("pointerleave",r[12]),t.$on("pointerdown",r[14]),t.$on("pointerdown",function(){ee(r[28](`HANDLE-${r[32]}-${r[35]}-${r[37]}`))&&r[28](`HANDLE-${r[32]}-${r[35]}-${r[37]}`).apply(this,arguments)}),t.$on("pointerup",r[15](r[32],r[35],r[37])),{c(){Ut(t.$$.fragment)},m(s,n){Bt(t,s,n),e=!0},p(s,n){r=s;const o={};n[0]&32&&(o.x=r[29][0]),n[0]&32&&(o.y=r[29][1]),n[0]&8&&(o.scale=r[3]),n[0]&256&&(o.selected=r[8].some(i)),t.$set(o)},i(s){e||(Z(t.$$.fragment,s),e=!0)},o(s){ht(t.$$.fragment,s),e=!1},d(s){Ft(t,s)}}}function Nd(r){let t,e,i=Ne(r[33].points),s=[];for(let o=0;o<i.length;o+=1)s[o]=Od(Rd(r,i,o));const n=o=>ht(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Ge()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);lt(o,t,a),e=!0},p(o,a){if(a[0]&268491048){i=Ne(o[33].points);let l;for(l=0;l<i.length;l+=1){const h=Rd(o,i,l);s[l]?(s[l].p(h,a),Z(s[l],1)):(s[l]=Od(h),s[l].c(),Z(s[l],1),s[l].m(t.parentNode,t))}for(pe(),l=i.length;l<s.length;l+=1)n(l);me()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)Z(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)ht(s[a]);e=!1},d(o){o&&ot(t),Wr(s,o)}}}function Dd(r){let t,e,i,s,n,o,a,l,h,u,c,d,f,p,m,_,y,v=r[6]!==void 0&&!r[7]&&Md(nl(r)),g=r[6]!==void 0&&!r[7]&&Pd(sl(r)),x=Ne(r[30].rings),T=[];for(let S=0;S<x.length;S+=1)T[S]=Nd(Id(r,x,S));const M=S=>ht(T[S],1,1,()=>{T[S]=null});return{c(){t=st("g"),e=st("defs"),i=st("mask"),s=st("rect"),h=st("path"),v&&v.c(),g&&g.c(),c=st("path"),f=st("path");for(let S=0;S<T.length;S+=1)T[S].c();E(s,"x",n=r[9].x),E(s,"y",o=r[9].y),E(s,"width",a=r[9].w),E(s,"height",l=r[9].h),E(s,"class","svelte-1vxo6dc"),E(h,"d",u=es(r[30])),E(h,"class","svelte-1vxo6dc"),E(i,"id",`${r[18]}-${r[32]}-outer`),E(i,"class","a9s-multipolygon-editor-mask svelte-1vxo6dc"),E(c,"class","a9s-outer"),E(c,"mask",`url(#${r[18]}-${r[32]}-outer)`),E(c,"fill-rule","evenodd"),E(c,"d",d=es(r[30])),E(f,"class","a9s-inner"),E(f,"mask",`url(#${r[18]}-${r[32]}-inner)`),E(f,"style",r[1]),E(f,"fill-rule","evenodd"),E(f,"d",p=es(r[30]))},m(S,R){lt(S,t,R),Ct(t,e),Ct(e,i),Ct(i,s),Ct(i,h),v&&v.m(i,null),g&&g.m(e,null),Ct(t,c),Ct(t,f);for(let P=0;P<T.length;P+=1)T[P]&&T[P].m(t,null);m=!0,_||(y=[Ot(c,"pointerup",r[13]),Ot(c,"pointerdown",function(){ee(r[28]("SHAPE"))&&r[28]("SHAPE").apply(this,arguments)}),Ot(f,"pointerup",r[13]),Ot(f,"pointerdown",function(){ee(r[28]("SHAPE"))&&r[28]("SHAPE").apply(this,arguments)})],_=!0)},p(S,R){if(r=S,(!m||R[0]&512&&n!==(n=r[9].x))&&E(s,"x",n),(!m||R[0]&512&&o!==(o=r[9].y))&&E(s,"y",o),(!m||R[0]&512&&a!==(a=r[9].w))&&E(s,"width",a),(!m||R[0]&512&&l!==(l=r[9].h))&&E(s,"height",l),(!m||R[0]&32&&u!==(u=es(r[30])))&&E(h,"d",u),r[6]!==void 0&&!r[7]?v?v.p(nl(r),R):(v=Md(nl(r)),v.c(),v.m(i,null)):v&&(v.d(1),v=null),r[6]!==void 0&&!r[7]?g?g.p(sl(r),R):(g=Pd(sl(r)),g.c(),g.m(e,null)):g&&(g.d(1),g=null),(!m||R[0]&32&&d!==(d=es(r[30])))&&E(c,"d",d),(!m||R[0]&2)&&E(f,"style",r[1]),(!m||R[0]&32&&p!==(p=es(r[30])))&&E(f,"d",p),R[0]&268491048){x=Ne(r[30].rings);let P;for(P=0;P<x.length;P+=1){const F=Id(r,x,P);T[P]?(T[P].p(F,R),Z(T[P],1)):(T[P]=Nd(F),T[P].c(),Z(T[P],1),T[P].m(t,null))}for(pe(),P=x.length;P<T.length;P+=1)M(P);me()}},i(S){if(!m){for(let R=0;R<x.length;R+=1)Z(T[R]);m=!0}},o(S){T=T.filter(Boolean);for(let R=0;R<T.length;R+=1)ht(T[R]);m=!1},d(S){S&&ot(t),v&&v.d(),g&&g.d(),Wr(T,S),_=!1,Ye(y)}}}function Ld(r){let t,e;return t=new yd({props:{x:r[29][0],y:r[29][1],scale:r[3]}}),t.$on("pointerdown",function(){ee(r[17](r[6]))&&r[17](r[6]).apply(this,arguments)}),{c(){Ut(t.$$.fragment)},m(i,s){Bt(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&1088&&(n.x=r[29][0]),s[0]&1088&&(n.y=r[29][1]),s[0]&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(Z(t.$$.fragment,i),e=!0)},o(i){ht(t.$$.fragment,i),e=!1},d(i){Ft(t,i)}}}function ix(r){let t,e,i,s=Ne(r[5].polygons),n=[];for(let l=0;l<s.length;l+=1)n[l]=Dd(Cd(r,s,l));const o=l=>ht(n[l],1,1,()=>{n[l]=null});let a=r[6]!==void 0&&!r[7]&&Ld(il(r));return{c(){for(let l=0;l<n.length;l+=1)n[l].c();t=Le(),a&&a.c(),e=Ge()},m(l,h){for(let u=0;u<n.length;u+=1)n[u]&&n[u].m(l,h);lt(l,t,h),a&&a.m(l,h),lt(l,e,h),i=!0},p(l,h){if(h[0]&268763114){s=Ne(l[5].polygons);let u;for(u=0;u<s.length;u+=1){const c=Cd(l,s,u);n[u]?(n[u].p(c,h),Z(n[u],1)):(n[u]=Dd(c),n[u].c(),Z(n[u],1),n[u].m(t.parentNode,t))}for(pe(),u=s.length;u<n.length;u+=1)o(u);me()}l[6]!==void 0&&!l[7]?a?(a.p(il(l),h),h[0]&192&&Z(a,1)):(a=Ld(il(l)),a.c(),Z(a,1),a.m(e.parentNode,e)):a&&(pe(),ht(a,1,1,()=>{a=null}),me())},i(l){if(!i){for(let h=0;h<s.length;h+=1)Z(n[h]);Z(a),i=!0}},o(l){n=n.filter(Boolean);for(let h=0;h<n.length;h+=1)ht(n[h]);ht(a),i=!1},d(l){l&&(ot(t),ot(e)),Wr(n,l),a&&a.d(l)}}}function sx(r){let t,e;return t=new Qa({props:{shape:r[0],transform:r[2],editor:r[16],svgEl:r[4],$$slots:{default:[ix,({grab:i})=>({28:i}),({grab:i})=>[i?268435456:0]]},$$scope:{ctx:r}}}),t.$on("change",r[20]),t.$on("grab",r[21]),t.$on("release",r[22]),{c(){Ut(t.$$.fragment)},m(i,s){Bt(t,i,s),e=!0},p(i,s){const n={};s[0]&1&&(n.shape=i[0]),s[0]&4&&(n.transform=i[2]),s[0]&16&&(n.svgEl=i[4]),s[0]&268437482|s[1]&128&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(Z(t.$$.fragment,i),e=!0)},o(i){ht(t.$$.fragment,i),e=!1},d(i){Ft(t,i)}}}const nx=250,ox=1e3,zs=4.5;function ax(r,t,e){let i,s,n;const o=Zi();let{shape:a}=t,{computedStyle:l}=t,{transform:h}=t,{viewportScale:u=1}=t,{svgEl:c}=t,d,f=!1,p,m=[];const _=()=>e(7,f=!0),y=()=>e(7,f=!1),v=C=>{if(m.length>0||!s.some(k=>k.visible)){e(6,d=void 0);return}const[L,O]=h.elementToImage(C.offsetX,C.offsetY),B=k=>Math.pow(k[0]-L,2)+Math.pow(k[1]-O,2),V=e1(i).reduce((k,z)=>B(z)<B(k)?z:k),D=s.filter(k=>k.visible).reduce((k,z)=>B(z.point)<B(k.point)?z:k),N=Math.pow(ox/u,2);B(V)<N||B(D.point)<N?e(6,d=s.indexOf(D)):e(6,d=void 0)},g=()=>{document.activeElement!==c&&c.focus()},x=()=>{e(8,m=[]),g()},T=C=>{e(7,f=!0),C.preventDefault(),C.stopPropagation(),p=performance.now()},M=(C,L,O)=>B=>{if(!p||Qr||performance.now()-p>nx)return;const V=N=>N.polygon===C&&N.ring===L&&N.point===O,D=m.some(V);B.metaKey||B.ctrlKey||B.shiftKey?D?e(8,m=m.filter(N=>!V(N))):e(8,m=[...m,{polygon:C,ring:L,point:O}]):D&&m.length>1?e(8,m=[{polygon:C,ring:L,point:O}]):D?e(8,m=[]):e(8,m=[{polygon:C,ring:L,point:O}]),g()},S=(C,L,O)=>{g();const B=C.geometry.polygons;let V;if(L==="SHAPE")V=B.map(D=>{const N=D.rings.map((k,z)=>({points:k.points.map((pt,_t)=>[pt[0]+O[0],pt[1]+O[1]])})),H=dr(N[0].points);return{rings:N,bounds:H}});else{const[D,N,H,k]=L.split("-").map(z=>parseInt(z));V=B.map((z,Y)=>{if(Y===N){const pt=z.rings.map((W,Et)=>Et===H?{points:W.points.map((mt,vt)=>vt===k?[mt[0]+O[0],mt[1]+O[1]]:mt)}:W),_t=dr(pt[0].points);return{rings:pt,bounds:_t}}else return z})}return{...C,geometry:{polygons:V,bounds:Gn(V)}}},R=C=>async L=>{L.stopPropagation();const O=s[C],B=i.polygons.map((D,N)=>{if(N===O.elementIdx){const H=D.rings.map((z,Y)=>Y===O.ringIdx?{points:[...z.points.slice(0,O.pointIdx+1),O.point,...z.points.slice(O.pointIdx+1)]}:z),k=dr(H[0].points);return{rings:H,bounds:k}}else return D});o("change",{...a,geometry:{polygons:B,bounds:Gn(B)}}),await Jc();const V=[...document.querySelectorAll(".a9s-handle")][C+1];if(V!=null&&V.firstChild){const D=new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:L.clientX,clientY:L.clientY,pointerId:L.pointerId,pointerType:L.pointerType,isPrimary:L.isPrimary,buttons:L.buttons});V.firstChild.dispatchEvent(D)}},P=()=>{const C=i.polygons.map((O,B)=>{if(m.some(D=>D.polygon===B)){const D=O.rings.map((H,k)=>{const z=m.filter(Y=>Y.polygon===B&&Y.ring===k);return z.length&&H.points.length-z.length>=3?{points:H.points.filter((pt,_t)=>!z.some(W=>W.point===_t))}:H}),N=dr(D[0].points);return{rings:D,bounds:N}}else return O});!rl(i.polygons,C)&&(o("change",{...a,geometry:{polygons:C,bounds:Gn(C)}}),e(8,m=[]))};vi(()=>{if(Qr)return;const C=L=>{(L.key==="Delete"||L.key==="Backspace")&&(L.preventDefault(),P())};return c.addEventListener("pointermove",v),c.addEventListener("keydown",C),()=>{c.removeEventListener("pointermove",v),c.removeEventListener("keydown",C)}});const F=`polygon-mask-${Math.random().toString(36).substring(2,12)}`,U=(C,L,O,{polygon:B,ring:V,point:D})=>B===C&&V===L&&D===O;function I(C){Oe.call(this,r,C)}function A(C){Oe.call(this,r,C)}function w(C){Oe.call(this,r,C)}return r.$$set=C=>{"shape"in C&&e(0,a=C.shape),"computedStyle"in C&&e(1,l=C.computedStyle),"transform"in C&&e(2,h=C.transform),"viewportScale"in C&&e(3,u=C.viewportScale),"svgEl"in C&&e(4,c=C.svgEl)},r.$$.update=()=>{r.$$.dirty[0]&1&&e(5,i=a.geometry),r.$$.dirty[0]&40&&e(10,s=Qr?[]:rx(i,u)),r.$$.dirty[0]&40&&e(9,n=Za(i.bounds,zs/u))},[a,l,h,u,c,i,d,f,m,n,s,_,y,x,T,M,S,R,F,U,I,A,w]}class lx extends ie{constructor(t){super(),re(this,t,ax,sx,Yt,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}Ir.RECTANGLE,Ir.POLYGON,Ir.MULTIPOLYGON;function hx(r,t,e){let i;const s=Zi();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:u}=t,c;return vi(()=>(e(6,c=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:u,svgEl:l.closest("svg")}})),c.$on("change",d=>{c.$$set({shape:d.detail}),s("change",d.detail)}),c.$on("grab",d=>s("grab",d.detail)),c.$on("release",d=>s("release",d.detail)),()=>{c.$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,u=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=O1(n,a)),r.$$.dirty&65&&n&&(c==null||c.$set({shape:n.target.selector})),r.$$.dirty&80&&c&&c.$set({transform:h}),r.$$.dirty&96&&c&&c.$set({viewportScale:u}),r.$$.dirty&192&&c&&i&&c.$set({computedStyle:i})},[n,o,a,l,h,u,c,i]}class ux extends ie{constructor(t){super(),re(this,t,hx,null,Yt,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1;var Ei=(r=>(r[r.WEBGL_LEGACY=0]="WEBGL_LEGACY",r[r.WEBGL=1]="WEBGL",r[r.WEBGL2=2]="WEBGL2",r))(Ei||{}),Bd=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.WEBGL=1]="WEBGL",r[r.CANVAS=2]="CANVAS",r))(Bd||{}),ol=(r=>(r[r.COLOR=16384]="COLOR",r[r.DEPTH=256]="DEPTH",r[r.STENCIL=1024]="STENCIL",r))(ol||{}),yt=(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))(yt||{}),fr=(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))(fr||{}),j=(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))(j||{}),is=(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))(is||{}),ft=(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))(ft||{}),J=(r=>(r[r.FLOAT=0]="FLOAT",r[r.INT=1]="INT",r[r.UINT=2]="UINT",r))(J||{}),Rr=(r=>(r[r.NEAREST=0]="NEAREST",r[r.LINEAR=1]="LINEAR",r))(Rr||{}),Jr=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(Jr||{}),pr=(r=>(r[r.OFF=0]="OFF",r[r.POW2=1]="POW2",r[r.ON=2]="ON",r[r.ON_MANUAL=3]="ON_MANUAL",r))(pr||{}),$e=(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))($e||{}),mr=(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))(mr||{}),al=(r=>(r[r.AUTO=0]="AUTO",r[r.MANUAL=1]="MANUAL",r))(al||{}),je=(r=>(r.LOW="lowp",r.MEDIUM="mediump",r.HIGH="highp",r))(je||{}),ce=(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))(ce||{}),le=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(le||{}),gr=(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))(gr||{});const tt={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 ll=/iPhone/i,Fd=/iPod/i,kd=/iPad/i,Ud=/\biOS-universal(?:.+)Mac\b/i,hl=/\bAndroid(?:.+)Mobile\b/i,Gd=/Android/i,ss=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Xn=/Silk/i,Mr=/Windows Phone/i,$d=/\bWindows(?:.+)ARM\b/i,Hd=/BlackBerry/i,Xd=/BB10/i,Vd=/Opera Mini/i,zd=/\b(CriOS|Chrome)(?:.+)Mobile/i,Yd=/Mobile(?:.+)Firefox\b/i,jd=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function cx(r){return function(t){return t.test(r)}}function Wd(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=cx(e),n={apple:{phone:s(ll)&&!s(Mr),ipod:s(Fd),tablet:!s(ll)&&(s(kd)||jd(t))&&!s(Mr),universal:s(Ud),device:(s(ll)||s(Fd)||s(kd)||s(Ud)||jd(t))&&!s(Mr)},amazon:{phone:s(ss),tablet:!s(ss)&&s(Xn),device:s(ss)||s(Xn)},android:{phone:!s(Mr)&&s(ss)||!s(Mr)&&s(hl),tablet:!s(Mr)&&!s(ss)&&!s(hl)&&(s(Xn)||s(Gd)),device:!s(Mr)&&(s(ss)||s(Xn)||s(hl)||s(Gd))||s(/\bokhttp\b/i)},windows:{phone:s(Mr),tablet:s($d),device:s(Mr)||s($d)},other:{blackberry:s(Hd),blackberry10:s(Xd),opera:s(Vd),firefox:s(Yd),chrome:s(zd),device:s(Hd)||s(Xd)||s(Vd)||s(Yd)||s(zd)},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 dx=Wd.default??Wd,Pr=dx(globalThis.navigator);tt.RETINA_PREFIX=/@([0-9\.]+)x/,tt.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var qd={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,u){this.fn=l,this.context=h,this.once=u||!1}function n(l,h,u,c,d){if(typeof u!="function")throw new TypeError("The listener must be a function");var f=new s(u,c||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=[],u,c;if(this._eventsCount===0)return h;for(c in u=this._events)t.call(u,c)&&h.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(u)):h},a.prototype.listeners=function(h){var u=e?e+h:h,c=this._events[u];if(!c)return[];if(c.fn)return[c.fn];for(var d=0,f=c.length,p=new Array(f);d<f;d++)p[d]=c[d].fn;return p},a.prototype.listenerCount=function(h){var u=e?e+h:h,c=this._events[u];return c?c.fn?1:c.length:0},a.prototype.emit=function(h,u,c,d,f,p){var m=e?e+h:h;if(!this._events[m])return!1;var _=this._events[m],y=arguments.length,v,g;if(_.fn){switch(_.once&&this.removeListener(h,_.fn,void 0,!0),y){case 1:return _.fn.call(_.context),!0;case 2:return _.fn.call(_.context,u),!0;case 3:return _.fn.call(_.context,u,c),!0;case 4:return _.fn.call(_.context,u,c,d),!0;case 5:return _.fn.call(_.context,u,c,d,f),!0;case 6:return _.fn.call(_.context,u,c,d,f,p),!0}for(g=1,v=new Array(y-1);g<y;g++)v[g-1]=arguments[g];_.fn.apply(_.context,v)}else{var x=_.length,T;for(g=0;g<x;g++)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,u);break;case 3:_[g].fn.call(_[g].context,u,c);break;case 4:_[g].fn.call(_[g].context,u,c,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,u,c){return n(this,h,u,c,!1)},a.prototype.once=function(h,u,c){return n(this,h,u,c,!0)},a.prototype.removeListener=function(h,u,c,d){var f=e?e+h:h;if(!this._events[f])return this;if(!u)return o(this,f),this;var p=this._events[f];if(p.fn)p.fn===u&&(!d||p.once)&&(!c||p.context===c)&&o(this,f);else{for(var m=0,_=[],y=p.length;m<y;m++)(p[m].fn!==u||d&&!p[m].once||c&&p[m].context!==c)&&_.push(p[m]);_.length?this._events[f]=_.length===1?_[0]:_:o(this,f)}return this},a.prototype.removeAllListeners=function(h){var u;return h?(u=e?e+h:h,this._events[u]&&o(this,u)):(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})(qd);var fx=qd.exports;const Ys=za(fx);var ul={exports:{}};ul.exports=Vn,ul.exports.default=Vn;function Vn(r,t,e){e=e||2;var i=t&&t.length,s=i?t[0]*e:r.length,n=Kd(r,0,s,e,!0),o=[];if(!n||n.next===n.prev)return o;var a,l,h,u,c,d,f;if(i&&(n=_x(r,t,n,e)),r.length>80*e){a=h=r[0],l=u=r[1];for(var p=e;p<s;p+=e)c=r[p],d=r[p+1],c<a&&(a=c),d<l&&(l=d),c>h&&(h=c),d>u&&(u=d);f=Math.max(h-a,u-l),f=f!==0?32767/f:0}return js(n,o,e,a,l,f,0),o}function Kd(r,t,e,i,s){var n,o;if(s===fl(r,t,e,i)>0)for(n=t;n<e;n+=i)o=Jd(n,r[n],r[n+1],o);else for(n=e-i;n>=t;n-=i)o=Jd(n,r[n],r[n+1],o);return o&&zn(o,o.next)&&(qs(o),o=o.next),o}function wi(r,t){if(!r)return r;t||(t=r);var e=r,i;do if(i=!1,!e.steiner&&(zn(e,e.next)||jt(e.prev,e,e.next)===0)){if(qs(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function js(r,t,e,i,s,n,o){if(r){!o&&n&&wx(r,i,s,n);for(var a=r,l,h;r.prev!==r.next;){if(l=r.prev,h=r.next,n?mx(r,i,s,n):px(r)){t.push(l.i/e|0),t.push(r.i/e|0),t.push(h.i/e|0),qs(r),r=h.next,a=h.next;continue}if(r=h,r===a){o?o===1?(r=gx(wi(r),t,e),js(r,t,e,i,s,n,2)):o===2&&yx(r,t,e,i,s,n):js(wi(r),t,e,i,s,n,1);break}}}}function px(r){var t=r.prev,e=r,i=r.next;if(jt(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,u=s<n?s<o?s:o:n<o?n:o,c=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>=u&&p.x<=d&&p.y>=c&&p.y<=f&&ns(s,a,n,l,o,h,p.x,p.y)&&jt(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function mx(r,t,e,i){var s=r.prev,n=r,o=r.next;if(jt(s,n,o)>=0)return!1;for(var a=s.x,l=n.x,h=o.x,u=s.y,c=n.y,d=o.y,f=a<l?a<h?a:h:l<h?l:h,p=u<c?u<d?u:d:c<d?c:d,m=a>l?a>h?a:h:l>h?l:h,_=u>c?u>d?u:d:c>d?c:d,y=cl(f,p,t,e,i),v=cl(m,_,t,e,i),g=r.prevZ,x=r.nextZ;g&&g.z>=y&&x&&x.z<=v;){if(g.x>=f&&g.x<=m&&g.y>=p&&g.y<=_&&g!==s&&g!==o&&ns(a,u,l,c,h,d,g.x,g.y)&&jt(g.prev,g,g.next)>=0||(g=g.prevZ,x.x>=f&&x.x<=m&&x.y>=p&&x.y<=_&&x!==s&&x!==o&&ns(a,u,l,c,h,d,x.x,x.y)&&jt(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;g&&g.z>=y;){if(g.x>=f&&g.x<=m&&g.y>=p&&g.y<=_&&g!==s&&g!==o&&ns(a,u,l,c,h,d,g.x,g.y)&&jt(g.prev,g,g.next)>=0)return!1;g=g.prevZ}for(;x&&x.z<=v;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=_&&x!==s&&x!==o&&ns(a,u,l,c,h,d,x.x,x.y)&&jt(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function gx(r,t,e){var i=r;do{var s=i.prev,n=i.next.next;!zn(s,n)&&Zd(s,i,i.next,n)&&Ws(s,n)&&Ws(n,s)&&(t.push(s.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),qs(i),qs(i.next),i=r=n),i=i.next}while(i!==r);return wi(i)}function yx(r,t,e,i,s,n){var o=r;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&Sx(o,a)){var l=Qd(o,a);o=wi(o,o.next),l=wi(l,l.next),js(o,t,e,i,s,n,0),js(l,t,e,i,s,n,0);return}a=a.next}o=o.next}while(o!==r)}function _x(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=Kd(r,a,l,i,!1),h===h.next&&(h.steiner=!0),s.push(Ax(h));for(s.sort(vx),n=0;n<s.length;n++)e=xx(s[n],e);return e}function vx(r,t){return r.x-t.x}function xx(r,t){var e=bx(r,t);if(!e)return t;var i=Qd(e,r);return wi(i,i.next),wi(e,e.next)}function bx(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,u=o.y,c=1/0,d;e=o;do i>=e.x&&e.x>=h&&i!==e.x&&ns(s<u?i:n,s,h,u,s<u?n:i,s,e.x,e.y)&&(d=Math.abs(s-e.y)/(i-e.x),Ws(e,r)&&(d<c||d===c&&(e.x>o.x||e.x===o.x&&Ex(o,e)))&&(o=e,c=d)),e=e.next;while(e!==l);return o}function Ex(r,t){return jt(r.prev,r,t.prev)<0&&jt(t.next,r,r.next)<0}function wx(r,t,e,i){var s=r;do s.z===0&&(s.z=cl(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,Tx(s)}function Tx(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 cl(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 Ax(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 ns(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 Sx(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!Cx(r,t)&&(Ws(r,t)&&Ws(t,r)&&Ix(r,t)&&(jt(r.prev,r,t.prev)||jt(r,t.prev,t))||zn(r,t)&&jt(r.prev,r,r.next)>0&&jt(t.prev,t,t.next)>0)}function jt(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function zn(r,t){return r.x===t.x&&r.y===t.y}function Zd(r,t,e,i){var s=jn(jt(r,t,e)),n=jn(jt(r,t,i)),o=jn(jt(e,i,r)),a=jn(jt(e,i,t));return!!(s!==n&&o!==a||s===0&&Yn(r,e,t)||n===0&&Yn(r,i,t)||o===0&&Yn(e,r,i)||a===0&&Yn(e,t,i))}function Yn(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 jn(r){return r>0?1:r<0?-1:0}function Cx(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&&Zd(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Ws(r,t){return jt(r.prev,r,r.next)<0?jt(r,t,r.next)>=0&&jt(r,r.prev,t)>=0:jt(r,t,r.prev)<0||jt(r,r.next,t)<0}function Ix(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 Qd(r,t){var e=new dl(r.i,r.x,r.y),i=new dl(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 Jd(r,t,e,i){var s=new dl(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 qs(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 dl(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}Vn.deviation=function(r,t,e,i){var s=t&&t.length,n=s?t[0]*e:r.length,o=Math.abs(fl(r,0,n,e));if(s)for(var a=0,l=t.length;a<l;a++){var h=t[a]*e,u=a<l-1?t[a+1]*e:r.length;o-=Math.abs(fl(r,h,u,e))}var c=0;for(a=0;a<i.length;a+=3){var d=i[a]*e,f=i[a+1]*e,p=i[a+2]*e;c+=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&&c===0?0:Math.abs((c-o)/o)};function fl(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}Vn.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 Rx=ul.exports;const Mx=za(Rx);var Wn={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */Wn.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,u=26,c=38,d=700,f=72,p=128,m="-",_=/^xn--/,y=/[^\x20-\x7E]/,v=/[\x2E\u3002\uFF0E\uFF61]/g,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,M=String.fromCharCode,S;function R(D){throw new RangeError(g[D])}function P(D,N){for(var H=D.length,k=[];H--;)k[H]=N(D[H]);return k}function F(D,N){var H=D.split("@"),k="";H.length>1&&(k=H[0]+"@",D=H[1]),D=D.replace(v,".");var z=D.split("."),Y=P(z,N).join(".");return k+Y}function U(D){for(var N=[],H=0,k=D.length,z,Y;H<k;)z=D.charCodeAt(H++),z>=55296&&z<=56319&&H<k?(Y=D.charCodeAt(H++),(Y&64512)==56320?N.push(((z&1023)<<10)+(Y&1023)+65536):(N.push(z),H--)):N.push(z);return N}function I(D){return P(D,function(N){var H="";return N>65535&&(N-=65536,H+=M(N>>>10&1023|55296),N=56320|N&1023),H+=M(N),H}).join("")}function A(D){return D-48<10?D-22:D-65<26?D-65:D-97<26?D-97:l}function w(D,N){return D+22+75*(D<26)-((N!=0)<<5)}function C(D,N,H){var k=0;for(D=H?T(D/d):D>>1,D+=T(D/N);D>x*u>>1;k+=l)D=T(D/x);return T(k+(x+1)*D/(D+c))}function L(D){var N=[],H=D.length,k,z=0,Y=p,pt=f,_t,W,Et,nt,mt,vt,Mt,Dt,ve;for(_t=D.lastIndexOf(m),_t<0&&(_t=0),W=0;W<_t;++W)D.charCodeAt(W)>=128&&R("not-basic"),N.push(D.charCodeAt(W));for(Et=_t>0?_t+1:0;Et<H;){for(nt=z,mt=1,vt=l;Et>=H&&R("invalid-input"),Mt=A(D.charCodeAt(Et++)),(Mt>=l||Mt>T((a-z)/mt))&&R("overflow"),z+=Mt*mt,Dt=vt<=pt?h:vt>=pt+u?u:vt-pt,!(Mt<Dt);vt+=l)ve=l-Dt,mt>T(a/ve)&&R("overflow"),mt*=ve;k=N.length+1,pt=C(z-nt,k,nt==0),T(z/k)>a-Y&&R("overflow"),Y+=T(z/k),z%=k,N.splice(z++,0,Y)}return I(N)}function O(D){var N,H,k,z,Y,pt,_t,W,Et,nt,mt,vt=[],Mt,Dt,ve,Kt;for(D=U(D),Mt=D.length,N=p,H=0,Y=f,pt=0;pt<Mt;++pt)mt=D[pt],mt<128&&vt.push(M(mt));for(k=z=vt.length,z&&vt.push(m);k<Mt;){for(_t=a,pt=0;pt<Mt;++pt)mt=D[pt],mt>=N&&mt<_t&&(_t=mt);for(Dt=k+1,_t-N>T((a-H)/Dt)&&R("overflow"),H+=(_t-N)*Dt,N=_t,pt=0;pt<Mt;++pt)if(mt=D[pt],mt<N&&++H>a&&R("overflow"),mt==N){for(W=H,Et=l;nt=Et<=Y?h:Et>=Y+u?u:Et-Y,!(W<nt);Et+=l)Kt=W-nt,ve=l-nt,vt.push(M(w(nt+Kt%ve,0))),W=T(Kt/ve);vt.push(M(w(W,0))),Y=C(H,Dt,k==z),H=0,++k}++H,++N}return vt.join("")}function B(D){return F(D,function(N){return _.test(N)?L(N.slice(4).toLowerCase()):N})}function V(D){return F(D,function(N){return y.test(N)?"xn--"+O(N):N})}if(o={version:"1.4.1",ucs2:{decode:U,encode:I},decode:L,encode:O,toASCII:V,toUnicode:B},i&&s)if(r.exports==i)s.exports=o;else for(S in o)o.hasOwnProperty(S)&&(i[S]=o[S]);else e.punycode=o})(Hs)}(Wn,Wn.exports);var Px=Wn.exports,os=TypeError;const Ox=jv(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var pl=typeof Map=="function"&&Map.prototype,ml=Object.getOwnPropertyDescriptor&&pl?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,qn=pl&&ml&&typeof ml.get=="function"?ml.get:null,tf=pl&&Map.prototype.forEach,gl=typeof Set=="function"&&Set.prototype,yl=Object.getOwnPropertyDescriptor&&gl?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Kn=gl&&yl&&typeof yl.get=="function"?yl.get:null,ef=gl&&Set.prototype.forEach,Nx=typeof WeakMap=="function"&&WeakMap.prototype,Ks=Nx?WeakMap.prototype.has:null,Dx=typeof WeakSet=="function"&&WeakSet.prototype,Zs=Dx?WeakSet.prototype.has:null,Lx=typeof WeakRef=="function"&&WeakRef.prototype,rf=Lx?WeakRef.prototype.deref:null,Bx=Boolean.prototype.valueOf,Fx=Object.prototype.toString,kx=Function.prototype.toString,Ux=String.prototype.match,_l=String.prototype.slice,ti=String.prototype.replace,Gx=String.prototype.toUpperCase,sf=String.prototype.toLowerCase,nf=RegExp.prototype.test,of=Array.prototype.concat,yr=Array.prototype.join,$x=Array.prototype.slice,af=Math.floor,vl=typeof BigInt=="function"?BigInt.prototype.valueOf:null,xl=Object.getOwnPropertySymbols,bl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,as=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Qs=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===as||!0)?Symbol.toStringTag:null,lf=Object.prototype.propertyIsEnumerable,hf=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function uf(r,t){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||nf.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var i=r<0?-af(-r):af(r);if(i!==r){var s=String(i),n=_l.call(t,s.length+1);return ti.call(s,e,"$&_")+"."+ti.call(ti.call(n,/([0-9]{3})/g,"$&_"),/_$/,"")}}return ti.call(t,e,"$&_")}var El=Ox,cf=El.custom,df=gf(cf)?cf:null,ff={__proto__:null,double:'"',single:"'"},Hx={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},Zn=function r(t,e,i,s){var n=e||{};if(Or(n,"quoteStyle")&&!Or(ff,n.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Or(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=Or(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(Or(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(Or(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 _f(t,n);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var l=String(t);return a?uf(t,l):l}if(typeof t=="bigint"){var h=String(t)+"n";return a?uf(t,h):h}var u=typeof n.depth>"u"?5:n.depth;if(typeof i>"u"&&(i=0),i>=u&&u>0&&typeof t=="object")return wl(t)?"[Array]":"[Object]";var c=ob(n,i);if(typeof s>"u")s=[];else if(yf(s,t)>=0)return"[Circular]";function d(A,w,C){if(w&&(s=$x.call(s),s.push(w)),C){var L={depth:n.depth};return Or(n,"quoteStyle")&&(L.quoteStyle=n.quoteStyle),r(A,L,i+1,s)}return r(A,n,i+1,s)}if(typeof t=="function"&&!mf(t)){var f=Zx(t),p=Qn(t,d);return"[Function"+(f?": "+f:" (anonymous)")+"]"+(p.length>0?" { "+yr.call(p,", ")+" }":"")}if(gf(t)){var m=as?ti.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):bl.call(t);return typeof t=="object"&&!as?Js(m):m}if(ib(t)){for(var _="<"+sf.call(String(t.nodeName)),y=t.attributes||[],v=0;v<y.length;v++)_+=" "+y[v].name+"="+pf(Xx(y[v].value),"double",n);return _+=">",t.childNodes&&t.childNodes.length&&(_+="..."),_+="</"+sf.call(String(t.nodeName))+">",_}if(wl(t)){if(t.length===0)return"[]";var g=Qn(t,d);return c&&!nb(g)?"["+Al(g,c)+"]":"[ "+yr.call(g,", ")+" ]"}if(zx(t)){var x=Qn(t,d);return!("cause"in Error.prototype)&&"cause"in t&&!lf.call(t,"cause")?"{ ["+String(t)+"] "+yr.call(of.call("[cause]: "+d(t.cause),x),", ")+" }":x.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+yr.call(x,", ")+" }"}if(typeof t=="object"&&o){if(df&&typeof t[df]=="function"&&El)return El(t,{depth:u-i});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(Qx(t)){var T=[];return tf&&tf.call(t,function(A,w){T.push(d(w,t,!0)+" => "+d(A,t))}),vf("Map",qn.call(t),T,c)}if(eb(t)){var M=[];return ef&&ef.call(t,function(A){M.push(d(A,t))}),vf("Set",Kn.call(t),M,c)}if(Jx(t))return Tl("WeakMap");if(rb(t))return Tl("WeakSet");if(tb(t))return Tl("WeakRef");if(jx(t))return Js(d(Number(t)));if(qx(t))return Js(d(vl.call(t)));if(Wx(t))return Js(Bx.call(t));if(Yx(t))return Js(d(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(typeof globalThis<"u"&&t===globalThis||typeof Hs<"u"&&t===Hs)return"{ [object globalThis] }";if(!Vx(t)&&!mf(t)){var S=Qn(t,d),R=hf?hf(t)===Object.prototype:t instanceof Object||t.constructor===Object,P=t instanceof Object?"":"null prototype",F=!R&&Qs&&Object(t)===t&&Qs in t?_l.call(ei(t),8,-1):P?"Object":"",U=R||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",I=U+(F||P?"["+yr.call(of.call([],F||[],P||[]),": ")+"] ":"");return S.length===0?I+"{}":c?I+"{"+Al(S,c)+"}":I+"{ "+yr.call(S,", ")+" }"}return String(t)};function pf(r,t,e){var i=e.quoteStyle||t,s=ff[i];return s+r+s}function Xx(r){return ti.call(String(r),/"/g,"&quot;")}function Ti(r){return!Qs||!(typeof r=="object"&&(Qs in r||typeof r[Qs]<"u"))}function wl(r){return ei(r)==="[object Array]"&&Ti(r)}function Vx(r){return ei(r)==="[object Date]"&&Ti(r)}function mf(r){return ei(r)==="[object RegExp]"&&Ti(r)}function zx(r){return ei(r)==="[object Error]"&&Ti(r)}function Yx(r){return ei(r)==="[object String]"&&Ti(r)}function jx(r){return ei(r)==="[object Number]"&&Ti(r)}function Wx(r){return ei(r)==="[object Boolean]"&&Ti(r)}function gf(r){if(as)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!bl)return!1;try{return bl.call(r),!0}catch{}return!1}function qx(r){if(!r||typeof r!="object"||!vl)return!1;try{return vl.call(r),!0}catch{}return!1}var Kx=Object.prototype.hasOwnProperty||function(r){return r in this};function Or(r,t){return Kx.call(r,t)}function ei(r){return Fx.call(r)}function Zx(r){if(r.name)return r.name;var t=Ux.call(kx.call(r),/^function\s*([\w$]+)/);return t?t[1]:null}function yf(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 Qx(r){if(!qn||!r||typeof r!="object")return!1;try{qn.call(r);try{Kn.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function Jx(r){if(!Ks||!r||typeof r!="object")return!1;try{Ks.call(r,Ks);try{Zs.call(r,Zs)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function tb(r){if(!rf||!r||typeof r!="object")return!1;try{return rf.call(r),!0}catch{}return!1}function eb(r){if(!Kn||!r||typeof r!="object")return!1;try{Kn.call(r);try{qn.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function rb(r){if(!Zs||!r||typeof r!="object")return!1;try{Zs.call(r,Zs);try{Ks.call(r,Ks)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function ib(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function _f(r,t){if(r.length>t.maxStringLength){var e=r.length-t.maxStringLength,i="... "+e+" more character"+(e>1?"s":"");return _f(_l.call(r,0,t.maxStringLength),t)+i}var s=Hx[t.quoteStyle||"single"];s.lastIndex=0;var n=ti.call(ti.call(r,s,"\\$1"),/[\x00-\x1f]/g,sb);return pf(n,"single",t)}function sb(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":"")+Gx.call(t.toString(16))}function Js(r){return"Object("+r+")"}function Tl(r){return r+" { ? }"}function vf(r,t,e,i){var s=i?Al(e,i):yr.call(e,", ");return r+" ("+t+") {"+s+"}"}function nb(r){for(var t=0;t<r.length;t++)if(yf(r[t],`
4
+ `)>=0)return!1;return!0}function ob(r,t){var e;if(r.indent===" ")e=" ";else if(typeof r.indent=="number"&&r.indent>0)e=yr.call(Array(r.indent+1)," ");else return null;return{base:e,prev:yr.call(Array(t+1),e)}}function Al(r,t){if(r.length===0)return"";var e=`
5
5
  `+t.prev+t.base;return e+yr.call(r,","+e)+`
6
- `+t.prev}function jn(r,t){var e=wl(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 xl=="function"?xl(r):[],o;if(os){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||os&&o["$"+l]instanceof Symbol||(ef.call(/[^\w$]/,l)?i.push(t(l,r)+": "+t(r[l],r)):i.push(l+": "+t(r[l],r))));if(typeof xl=="function")for(var h=0;h<n.length;h++)nf.call(r,n[h])&&i.push("["+t(n[h])+"]: "+t(r[n[h]],r));return i}var Vx=Wn,zx=ns,qn=function(r,t,e){for(var i=r,s;(s=i.next)!=null;i=s)if(s.key===t)return i.next=s.next,e||(s.next=r.next,r.next=s),s},Yx=function(r,t){if(r){var e=qn(r,t);return e&&e.value}},Wx=function(r,t,e){var i=qn(r,t);i?i.value=e:r.next={key:t,next:r.next,value:e}},jx=function(r,t){return r?!!qn(r,t):!1},qx=function(r,t){if(r)return qn(r,t,!0)},Kx=function(){var t,e={assert:function(i){if(!e.has(i))throw new zx("Side channel does not contain "+Vx(i))},delete:function(i){var s=t&&t.next,n=qx(t,i);return n&&s&&s===n&&(t=void 0),!!n},get:function(i){return Yx(t,i)},has:function(i){return jx(t,i)},set:function(i,s){t||(t={next:void 0}),Wx(t,i,s)}};return e},yf=Object,Zx=Error,Qx=EvalError,Jx=RangeError,tb=ReferenceError,eb=SyntaxError,rb=URIError,ib=Math.abs,sb=Math.floor,nb=Math.max,ob=Math.min,ab=Math.pow,lb=Math.round,hb=Number.isNaN||function(t){return t!==t},ub=hb,cb=function(t){return ub(t)||t===0?t:t<0?-1:1},db=Object.getOwnPropertyDescriptor,Kn=db;if(Kn)try{Kn([],"length")}catch{Kn=null}var _f=Kn,Zn=Object.defineProperty||!1;if(Zn)try{Zn({},"a",{value:1})}catch{Zn=!1}var fb=Zn,Sl,vf;function pb(){return vf||(vf=1,Sl=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(var n 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 o=Object.getOwnPropertySymbols(t);if(o.length!==1||o[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(t,e);if(a.value!==s||a.enumerable!==!0)return!1}return!0}),Sl}var Cl,xf;function mb(){if(xf)return Cl;xf=1;var r=typeof Symbol<"u"&&Symbol,t=pb();return Cl=function(){return typeof r!="function"||typeof Symbol!="function"||typeof r("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:t()},Cl}var Il,bf;function Ef(){return bf||(bf=1,Il=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),Il}var Rl,wf;function Tf(){if(wf)return Rl;wf=1;var r=yf;return Rl=r.getPrototypeOf||null,Rl}var gb="Function.prototype.bind called on incompatible ",yb=Object.prototype.toString,_b=Math.max,vb="[object Function]",Af=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},xb=function(t,e){for(var i=[],s=e,n=0;s<t.length;s+=1,n+=1)i[n]=t[s];return i},bb=function(r,t){for(var e="",i=0;i<r.length;i+=1)e+=r[i],i+1<r.length&&(e+=t);return e},Eb=function(t){var e=this;if(typeof e!="function"||yb.apply(e)!==vb)throw new TypeError(gb+e);for(var i=xb(arguments,1),s,n=function(){if(this instanceof s){var u=e.apply(this,Af(i,arguments));return Object(u)===u?u:this}return e.apply(t,Af(i,arguments))},o=_b(0,e.length-i.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(s=Function("binder","return function ("+bb(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},wb=Eb,Qn=Function.prototype.bind||wb,Ml=Function.prototype.call,Sf=Function.prototype.apply,Tb=typeof Reflect<"u"&&Reflect&&Reflect.apply,Ab=Qn,Sb=Sf,Cb=Ml,Ib=Tb,Rb=Ib||Ab.call(Cb,Sb),Mb=Qn,Pb=ns,Ob=Ml,Nb=Rb,Cf=function(t){if(t.length<1||typeof t[0]!="function")throw new Pb("a function is required");return Nb(Mb,Ob,t)},Pl,If;function Db(){if(If)return Pl;If=1;var r=Cf,t=_f,e;try{e=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var i=!!e&&t&&t(Object.prototype,"__proto__"),s=Object,n=s.getPrototypeOf;return Pl=i&&typeof i.get=="function"?r([i.get]):typeof n=="function"?function(a){return n(a==null?a:s(a))}:!1,Pl}var Ol,Rf;function Lb(){if(Rf)return Ol;Rf=1;var r=Ef(),t=Tf(),e=Db();return Ol=r?function(s){return r(s)}:t?function(s){if(!s||typeof s!="object"&&typeof s!="function")throw new TypeError("getProto: not an object");return t(s)}:e?function(s){return e(s)}:null,Ol}var Nl,Mf;function Bb(){if(Mf)return Nl;Mf=1;var r=Function.prototype.call,t=Object.prototype.hasOwnProperty,e=Qn;return Nl=e.call(r,t),Nl}var At,Fb=yf,kb=Zx,Ub=Qx,Gb=Jx,Hb=tb,as=eb,ls=ns,$b=rb,Xb=ib,Vb=sb,zb=nb,Yb=ob,Wb=ab,jb=lb,qb=cb,Pf=Function,Dl=function(r){try{return Pf('"use strict"; return ('+r+").constructor;")()}catch{}},Zs=_f,Kb=fb,Ll=function(){throw new ls},Zb=Zs?function(){try{return arguments.callee,Ll}catch{try{return Zs(arguments,"callee").get}catch{return Ll}}}():Ll,hs=mb()(),me=Lb(),Qb=Tf(),Jb=Ef(),Of=Sf,Qs=Ml,us={},tE=typeof Uint8Array>"u"||!me?At:me(Uint8Array),Ai={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?At:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?At:ArrayBuffer,"%ArrayIteratorPrototype%":hs&&me?me([][Symbol.iterator]()):At,"%AsyncFromSyncIteratorPrototype%":At,"%AsyncFunction%":us,"%AsyncGenerator%":us,"%AsyncGeneratorFunction%":us,"%AsyncIteratorPrototype%":us,"%Atomics%":typeof Atomics>"u"?At:Atomics,"%BigInt%":typeof BigInt>"u"?At:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?At:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?At:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?At:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":kb,"%eval%":eval,"%EvalError%":Ub,"%Float16Array%":typeof Float16Array>"u"?At:Float16Array,"%Float32Array%":typeof Float32Array>"u"?At:Float32Array,"%Float64Array%":typeof Float64Array>"u"?At:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?At:FinalizationRegistry,"%Function%":Pf,"%GeneratorFunction%":us,"%Int8Array%":typeof Int8Array>"u"?At:Int8Array,"%Int16Array%":typeof Int16Array>"u"?At:Int16Array,"%Int32Array%":typeof Int32Array>"u"?At:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":hs&&me?me(me([][Symbol.iterator]())):At,"%JSON%":typeof JSON=="object"?JSON:At,"%Map%":typeof Map>"u"?At:Map,"%MapIteratorPrototype%":typeof Map>"u"||!hs||!me?At:me(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Fb,"%Object.getOwnPropertyDescriptor%":Zs,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?At:Promise,"%Proxy%":typeof Proxy>"u"?At:Proxy,"%RangeError%":Gb,"%ReferenceError%":Hb,"%Reflect%":typeof Reflect>"u"?At:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?At:Set,"%SetIteratorPrototype%":typeof Set>"u"||!hs||!me?At:me(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?At:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":hs&&me?me(""[Symbol.iterator]()):At,"%Symbol%":hs?Symbol:At,"%SyntaxError%":as,"%ThrowTypeError%":Zb,"%TypedArray%":tE,"%TypeError%":ls,"%Uint8Array%":typeof Uint8Array>"u"?At:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?At:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?At:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?At:Uint32Array,"%URIError%":$b,"%WeakMap%":typeof WeakMap>"u"?At:WeakMap,"%WeakRef%":typeof WeakRef>"u"?At:WeakRef,"%WeakSet%":typeof WeakSet>"u"?At:WeakSet,"%Function.prototype.call%":Qs,"%Function.prototype.apply%":Of,"%Object.defineProperty%":Kb,"%Object.getPrototypeOf%":Qb,"%Math.abs%":Xb,"%Math.floor%":Vb,"%Math.max%":zb,"%Math.min%":Yb,"%Math.pow%":Wb,"%Math.round%":jb,"%Math.sign%":qb,"%Reflect.getPrototypeOf%":Jb};if(me)try{null.error}catch(r){var eE=me(me(r));Ai["%Error.prototype%"]=eE}var rE=function r(t){var e;if(t==="%AsyncFunction%")e=Dl("async function () {}");else if(t==="%GeneratorFunction%")e=Dl("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=Dl("async function* () {}");else if(t==="%AsyncGenerator%"){var i=r("%AsyncGeneratorFunction%");i&&(e=i.prototype)}else if(t==="%AsyncIteratorPrototype%"){var s=r("%AsyncGenerator%");s&&me&&(e=me(s.prototype))}return Ai[t]=e,e},Nf={__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"]},Js=Qn,Jn=Bb(),iE=Js.call(Qs,Array.prototype.concat),sE=Js.call(Of,Array.prototype.splice),Df=Js.call(Qs,String.prototype.replace),to=Js.call(Qs,String.prototype.slice),nE=Js.call(Qs,RegExp.prototype.exec),oE=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,aE=/\\(\\)?/g,lE=function(t){var e=to(t,0,1),i=to(t,-1);if(e==="%"&&i!=="%")throw new as("invalid intrinsic syntax, expected closing `%`");if(i==="%"&&e!=="%")throw new as("invalid intrinsic syntax, expected opening `%`");var s=[];return Df(t,oE,function(n,o,a,l){s[s.length]=a?Df(l,aE,"$1"):o||n}),s},hE=function(t,e){var i=t,s;if(Jn(Nf,i)&&(s=Nf[i],i="%"+s[0]+"%"),Jn(Ai,i)){var n=Ai[i];if(n===us&&(n=rE(i)),typeof n>"u"&&!e)throw new ls("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:s,name:i,value:n}}throw new as("intrinsic "+t+" does not exist!")},Bl=function(t,e){if(typeof t!="string"||t.length===0)throw new ls("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new ls('"allowMissing" argument must be a boolean');if(nE(/^%?[^%]*%?$/,t)===null)throw new as("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=lE(t),s=i.length>0?i[0]:"",n=hE("%"+s+"%",e),o=n.name,a=n.value,l=!1,h=n.alias;h&&(s=h[0],sE(i,iE([0,1],h)));for(var u=1,c=!0;u<i.length;u+=1){var d=i[u],f=to(d,0,1),p=to(d,-1);if((f==='"'||f==="'"||f==="`"||p==='"'||p==="'"||p==="`")&&f!==p)throw new as("property names with quotes must have matching quotes");if((d==="constructor"||!c)&&(l=!0),s+="."+d,o="%"+s+"%",Jn(Ai,o))a=Ai[o];else if(a!=null){if(!(d in a)){if(!e)throw new ls("base intrinsic for "+t+" exists, but the property is not available.");return}if(Zs&&u+1>=i.length){var m=Zs(a,d);c=!!m,c&&"get"in m&&!("originalValue"in m.get)?a=m.get:a=a[d]}else c=Jn(a,d),a=a[d];c&&!l&&(Ai[o]=a)}}return a},Lf=Bl,Bf=Cf,uE=Bf([Lf("%String.prototype.indexOf%")]),Ff=function(t,e){var i=Lf(t,!!e);return typeof i=="function"&&uE(t,".prototype.")>-1?Bf([i]):i},cE=Bl,tn=Ff,dE=Wn,fE=ns,kf=cE("%Map%",!0),pE=tn("Map.prototype.get",!0),mE=tn("Map.prototype.set",!0),gE=tn("Map.prototype.has",!0),yE=tn("Map.prototype.delete",!0),_E=tn("Map.prototype.size",!0),Uf=!!kf&&function(){var t,e={assert:function(i){if(!e.has(i))throw new fE("Side channel does not contain "+dE(i))},delete:function(i){if(t){var s=yE(t,i);return _E(t)===0&&(t=void 0),s}return!1},get:function(i){if(t)return pE(t,i)},has:function(i){return t?gE(t,i):!1},set:function(i,s){t||(t=new kf),mE(t,i,s)}};return e},vE=Bl,eo=Ff,xE=Wn,ro=Uf,bE=ns,cs=vE("%WeakMap%",!0),EE=eo("WeakMap.prototype.get",!0),wE=eo("WeakMap.prototype.set",!0),TE=eo("WeakMap.prototype.has",!0),AE=eo("WeakMap.prototype.delete",!0),SE=cs?function(){var t,e,i={assert:function(s){if(!i.has(s))throw new bE("Side channel does not contain "+xE(s))},delete:function(s){if(cs&&s&&(typeof s=="object"||typeof s=="function")){if(t)return AE(t,s)}else if(ro&&e)return e.delete(s);return!1},get:function(s){return cs&&s&&(typeof s=="object"||typeof s=="function")&&t?EE(t,s):e&&e.get(s)},has:function(s){return cs&&s&&(typeof s=="object"||typeof s=="function")&&t?TE(t,s):!!e&&e.has(s)},set:function(s,n){cs&&s&&(typeof s=="object"||typeof s=="function")?(t||(t=new cs),wE(t,s,n)):ro&&(e||(e=ro()),e.set(s,n))}};return i}:ro,CE=ns,IE=Wn,RE=Kx,ME=Uf,PE=SE,OE=PE||ME||RE,NE=function(){var t,e={assert:function(i){if(!e.has(i))throw new CE("Side channel does not contain "+IE(i))},delete:function(i){return!!t&&t.delete(i)},get:function(i){return t&&t.get(i)},has:function(i){return!!t&&t.has(i)},set:function(i,s){t||(t=OE()),t.set(i,s)}};return e},DE=String.prototype.replace,LE=/%20/g,Fl={RFC1738:"RFC1738",RFC3986:"RFC3986"},kl={default:Fl.RFC3986,formatters:{RFC1738:function(r){return DE.call(r,LE,"+")},RFC3986:function(r){return String(r)}},RFC1738:Fl.RFC1738,RFC3986:Fl.RFC3986},BE=kl,Ul=Object.prototype.hasOwnProperty,Si=Array.isArray,_r=function(){for(var r=[],t=0;t<256;++t)r.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return r}(),FE=function(t){for(;t.length>1;){var e=t.pop(),i=e.obj[e.prop];if(Si(i)){for(var s=[],n=0;n<i.length;++n)typeof i[n]<"u"&&s.push(i[n]);e.obj[e.prop]=s}}},Gf=function(t,e){for(var i=e&&e.plainObjects?{__proto__:null}:{},s=0;s<t.length;++s)typeof t[s]<"u"&&(i[s]=t[s]);return i},kE=function r(t,e,i){if(!e)return t;if(typeof e!="object"&&typeof e!="function"){if(Si(t))t.push(e);else if(t&&typeof t=="object")(i&&(i.plainObjects||i.allowPrototypes)||!Ul.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 Si(t)&&!Si(e)&&(s=Gf(t,i)),Si(t)&&Si(e)?(e.forEach(function(n,o){if(Ul.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 Ul.call(n,o)?n[o]=r(n[o],a,i):n[o]=a,n},s)},UE=function(t,e){return Object.keys(e).reduce(function(i,s){return i[s]=e[s],i},t)},GE=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}},Gl=1024,HE=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(f){return"%26%23"+parseInt(f.slice(2),16)+"%3B"});for(var a="",l=0;l<o.length;l+=Gl){for(var h=o.length>=Gl?o.slice(l,l+Gl):o,u=[],c=0;c<h.length;++c){var d=h.charCodeAt(c);if(d===45||d===46||d===95||d===126||d>=48&&d<=57||d>=65&&d<=90||d>=97&&d<=122||n===BE.RFC1738&&(d===40||d===41)){u[u.length]=h.charAt(c);continue}if(d<128){u[u.length]=_r[d];continue}if(d<2048){u[u.length]=_r[192|d>>6]+_r[128|d&63];continue}if(d<55296||d>=57344){u[u.length]=_r[224|d>>12]+_r[128|d>>6&63]+_r[128|d&63];continue}c+=1,d=65536+((d&1023)<<10|h.charCodeAt(c)&1023),u[u.length]=_r[240|d>>18]+_r[128|d>>12&63]+_r[128|d>>6&63]+_r[128|d&63]}a+=u.join("")}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],u=o[h];typeof u=="object"&&u!==null&&i.indexOf(u)===-1&&(e.push({obj:o,prop:h}),i.push(u))}return FE(e),t},XE=function(t){return Object.prototype.toString.call(t)==="[object RegExp]"},VE=function(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},zE=function(t,e){return[].concat(t,e)},YE=function(t,e){if(Si(t)){for(var i=[],s=0;s<t.length;s+=1)i.push(e(t[s]));return i}return e(t)},Hf={arrayToObject:Gf,assign:UE,combine:zE,compact:$E,decode:GE,encode:HE,isBuffer:VE,isRegExp:XE,maybeMap:YE,merge:kE},$f=NE,io=Hf,en=kl,WE=Object.prototype.hasOwnProperty,Xf={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},vr=Array.isArray,jE=Array.prototype.push,Vf=function(r,t){jE.apply(r,vr(t)?t:[t])},qE=Date.prototype.toISOString,zf=en.default,ue={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,commaRoundTrip:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:io.encode,encodeValuesOnly:!1,filter:void 0,format:zf,formatter:en.formatters[zf],indices:!1,serializeDate:function(t){return qE.call(t)},skipNulls:!1,strictNullHandling:!1},KE=function(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"},Hl={},ZE=function r(t,e,i,s,n,o,a,l,h,u,c,d,f,p,m,_,y,v){for(var g=t,x=v,E=0,R=!1;(x=x.get(Hl))!==void 0&&!R;){var S=x.get(t);if(E+=1,typeof S<"u"){if(S===E)throw new RangeError("Cyclic object value");R=!0}typeof x.get(Hl)>"u"&&(E=0)}if(typeof u=="function"?g=u(e,g):g instanceof Date?g=f(g):i==="comma"&&vr(g)&&(g=io.maybeMap(g,function(L){return L instanceof Date?f(L):L})),g===null){if(o)return h&&!_?h(e,ue.encoder,y,"key",p):e;g=""}if(KE(g)||io.isBuffer(g)){if(h){var M=_?e:h(e,ue.encoder,y,"key",p);return[m(M)+"="+m(h(g,ue.encoder,y,"value",p))]}return[m(e)+"="+m(String(g))]}var P=[];if(typeof g>"u")return P;var F;if(i==="comma"&&vr(g))_&&h&&(g=io.maybeMap(g,h)),F=[{value:g.length>0?g.join(",")||null:void 0}];else if(vr(u))F=u;else{var U=Object.keys(g);F=c?U.sort(c):U}var I=l?String(e).replace(/\./g,"%2E"):String(e),A=s&&vr(g)&&g.length===1?I+"[]":I;if(n&&vr(g)&&g.length===0)return A+"[]";for(var w=0;w<F.length;++w){var C=F[w],D=typeof C=="object"&&C&&typeof C.value<"u"?C.value:g[C];if(!(a&&D===null)){var N=d&&l?String(C).replace(/\./g,"%2E"):String(C),B=vr(g)?typeof i=="function"?i(A,N):A:A+(d?"."+N:"["+N+"]");v.set(t,E);var V=$f();V.set(Hl,v),Vf(P,r(D,B,i,s,n,o,a,l,i==="comma"&&_&&vr(g)?null:h,u,c,d,f,p,m,_,y,V))}}return P},QE=function(t){if(!t)return ue;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||ue.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=en.default;if(typeof t.format<"u"){if(!WE.call(en.formatters,t.format))throw new TypeError("Unknown format option provided.");i=t.format}var s=en.formatters[i],n=ue.filter;(typeof t.filter=="function"||vr(t.filter))&&(n=t.filter);var o;if(t.arrayFormat in Xf?o=t.arrayFormat:"indices"in t?o=t.indices?"indices":"repeat":o=ue.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:ue.allowDots:!!t.allowDots;return{addQueryPrefix:typeof t.addQueryPrefix=="boolean"?t.addQueryPrefix:ue.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:ue.allowEmptyArrays,arrayFormat:o,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:ue.charsetSentinel,commaRoundTrip:!!t.commaRoundTrip,delimiter:typeof t.delimiter>"u"?ue.delimiter:t.delimiter,encode:typeof t.encode=="boolean"?t.encode:ue.encode,encodeDotInKeys:typeof t.encodeDotInKeys=="boolean"?t.encodeDotInKeys:ue.encodeDotInKeys,encoder:typeof t.encoder=="function"?t.encoder:ue.encoder,encodeValuesOnly:typeof t.encodeValuesOnly=="boolean"?t.encodeValuesOnly:ue.encodeValuesOnly,filter:n,format:i,formatter:s,serializeDate:typeof t.serializeDate=="function"?t.serializeDate:ue.serializeDate,skipNulls:typeof t.skipNulls=="boolean"?t.skipNulls:ue.skipNulls,sort:typeof t.sort=="function"?t.sort:null,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:ue.strictNullHandling}},JE=function(r,t){var e=r,i=QE(t),s,n;typeof i.filter=="function"?(n=i.filter,e=n("",e)):vr(i.filter)&&(n=i.filter,s=n);var o=[];if(typeof e!="object"||e===null)return"";var a=Xf[i.arrayFormat],l=a==="comma"&&i.commaRoundTrip;s||(s=Object.keys(e)),i.sort&&s.sort(i.sort);for(var h=$f(),u=0;u<s.length;++u){var c=s[u],d=e[c];i.skipNulls&&d===null||Vf(o,ZE(d,c,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 f=o.join(i.delimiter),p=i.addQueryPrefix===!0?"?":"";return i.charsetSentinel&&(i.charset==="iso-8859-1"?p+="utf8=%26%2310003%3B&":p+="utf8=%E2%9C%93&"),f.length>0?p+f:""},Ci=Hf,$l=Object.prototype.hasOwnProperty,Yf=Array.isArray,Kt={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:Ci.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1,throwOnLimitExceeded:!1},tw=function(r){return r.replace(/&#(\d+);/g,function(t,e){return String.fromCharCode(parseInt(e,10))})},Wf=function(r,t,e){if(r&&typeof r=="string"&&t.comma&&r.indexOf(",")>-1)return r.split(",");if(t.throwOnLimitExceeded&&e>=t.arrayLimit)throw new RangeError("Array limit exceeded. Only "+t.arrayLimit+" element"+(t.arrayLimit===1?"":"s")+" allowed in an array.");return r},ew="utf8=%26%2310003%3B",rw="utf8=%E2%9C%93",iw=function(t,e){var i={__proto__:null},s=e.ignoreQueryPrefix?t.replace(/^\?/,""):t;s=s.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var n=e.parameterLimit===1/0?void 0:e.parameterLimit,o=s.split(e.delimiter,e.throwOnLimitExceeded?n+1:n);if(e.throwOnLimitExceeded&&o.length>n)throw new RangeError("Parameter limit exceeded. Only "+n+" parameter"+(n===1?"":"s")+" allowed.");var a=-1,l,h=e.charset;if(e.charsetSentinel)for(l=0;l<o.length;++l)o[l].indexOf("utf8=")===0&&(o[l]===rw?h="utf-8":o[l]===ew&&(h="iso-8859-1"),a=l,l=o.length);for(l=0;l<o.length;++l)if(l!==a){var u=o[l],c=u.indexOf("]="),d=c===-1?u.indexOf("="):c+1,f,p;d===-1?(f=e.decoder(u,Kt.decoder,h,"key"),p=e.strictNullHandling?null:""):(f=e.decoder(u.slice(0,d),Kt.decoder,h,"key"),p=Ci.maybeMap(Wf(u.slice(d+1),e,Yf(i[f])?i[f].length:0),function(_){return e.decoder(_,Kt.decoder,h,"value")})),p&&e.interpretNumericEntities&&h==="iso-8859-1"&&(p=tw(String(p))),u.indexOf("[]=")>-1&&(p=Yf(p)?[p]:p);var m=$l.call(i,f);m&&e.duplicates==="combine"?i[f]=Ci.combine(i[f],p):(!m||e.duplicates==="last")&&(i[f]=p)}return i},sw=function(r,t,e,i){var s=0;if(r.length>0&&r[r.length-1]==="[]"){var n=r.slice(0,-1).join("");s=Array.isArray(t)&&t[n]?t[n].length:0}for(var o=i?t:Wf(t,e,s),a=r.length-1;a>=0;--a){var l,h=r[a];if(h==="[]"&&e.parseArrays)l=e.allowEmptyArrays&&(o===""||e.strictNullHandling&&o===null)?[]:Ci.combine([],o);else{l=e.plainObjects?{__proto__:null}:{};var u=h.charAt(0)==="["&&h.charAt(h.length-1)==="]"?h.slice(1,-1):h,c=e.decodeDotInKeys?u.replace(/%2E/g,"."):u,d=parseInt(c,10);!e.parseArrays&&c===""?l={0:o}:!isNaN(d)&&h!==c&&String(d)===c&&d>=0&&e.parseArrays&&d<=e.arrayLimit?(l=[],l[d]=o):c!=="__proto__"&&(l[c]=o)}o=l}return o},nw=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,u=[];if(h){if(!i.plainObjects&&$l.call(Object.prototype,h)&&!i.allowPrototypes)return;u.push(h)}for(var c=0;i.depth>0&&(l=a.exec(n))!==null&&c<i.depth;){if(c+=1,!i.plainObjects&&$l.call(Object.prototype,l[1].slice(1,-1))&&!i.allowPrototypes)return;u.push(l[1])}if(l){if(i.strictDepth===!0)throw new RangeError("Input depth exceeded depth option of "+i.depth+" and strictDepth is true");u.push("["+n.slice(l.index)+"]")}return sw(u,e,i,s)}},ow=function(t){if(!t)return Kt;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");if(typeof t.throwOnLimitExceeded<"u"&&typeof t.throwOnLimitExceeded!="boolean")throw new TypeError("`throwOnLimitExceeded` option must be a boolean");var e=typeof t.charset>"u"?Kt.charset:t.charset,i=typeof t.duplicates>"u"?Kt.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:Kt.allowDots:!!t.allowDots;return{allowDots:s,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:Kt.allowEmptyArrays,allowPrototypes:typeof t.allowPrototypes=="boolean"?t.allowPrototypes:Kt.allowPrototypes,allowSparse:typeof t.allowSparse=="boolean"?t.allowSparse:Kt.allowSparse,arrayLimit:typeof t.arrayLimit=="number"?t.arrayLimit:Kt.arrayLimit,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Kt.charsetSentinel,comma:typeof t.comma=="boolean"?t.comma:Kt.comma,decodeDotInKeys:typeof t.decodeDotInKeys=="boolean"?t.decodeDotInKeys:Kt.decodeDotInKeys,decoder:typeof t.decoder=="function"?t.decoder:Kt.decoder,delimiter:typeof t.delimiter=="string"||Ci.isRegExp(t.delimiter)?t.delimiter:Kt.delimiter,depth:typeof t.depth=="number"||t.depth===!1?+t.depth:Kt.depth,duplicates:i,ignoreQueryPrefix:t.ignoreQueryPrefix===!0,interpretNumericEntities:typeof t.interpretNumericEntities=="boolean"?t.interpretNumericEntities:Kt.interpretNumericEntities,parameterLimit:typeof t.parameterLimit=="number"?t.parameterLimit:Kt.parameterLimit,parseArrays:t.parseArrays!==!1,plainObjects:typeof t.plainObjects=="boolean"?t.plainObjects:Kt.plainObjects,strictDepth:typeof t.strictDepth=="boolean"?!!t.strictDepth:Kt.strictDepth,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Kt.strictNullHandling,throwOnLimitExceeded:typeof t.throwOnLimitExceeded=="boolean"?t.throwOnLimitExceeded:!1}},aw=function(r,t){var e=ow(t);if(r===""||r===null||typeof r>"u")return e.plainObjects?{__proto__:null}:{};for(var i=typeof r=="string"?iw(r,e):r,s=e.plainObjects?{__proto__:null}:{},n=Object.keys(i),o=0;o<n.length;++o){var a=n[o],l=nw(a,i[a],e,typeof r=="string");s=Ci.merge(s,l,e)}return e.allowSparse===!0?s:Ci.compact(s)},lw=JE,hw=aw,uw=kl,cw={formats:uw,parse:hw,stringify:lw},dw=px;function Or(){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 fw=/^([a-z0-9.+-]+:)/i,pw=/:[0-9]*$/,mw=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,gw=["<",">",'"',"`"," ","\r",`
7
- `," "],yw=["{","}","|","\\","^","`"].concat(gw),Xl=["'"].concat(yw),jf=["%","/","?",";","#"].concat(Xl),qf=["/","?","#"],_w=255,Kf=/^[+a-z0-9A-Z_-]{0,63}$/,vw=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,xw={javascript:!0,"javascript:":!0},Vl={javascript:!0,"javascript:":!0},ds={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},zl=cw;function bw(r,t,e){if(r&&typeof r=="object"&&r instanceof Or)return r;var i=new Or;return i.parse(r,t,e),i}Or.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=mw.exec(a);if(l)return this.path=a,this.href=a,this.pathname=l[1],l[2]?(this.search=l[2],t?this.query=zl.parse(this.search.substr(1)):this.query=this.search.substr(1)):t&&(this.search="",this.query={}),this}var h=fw.exec(a);if(h){h=h[0];var u=h.toLowerCase();this.protocol=u,a=a.substr(h.length)}if(e||h||a.match(/^\/\/[^@/]+@[^@/]+/)){var c=a.substr(0,2)==="//";c&&!(h&&Vl[h])&&(a=a.substr(2),this.slashes=!0)}if(!Vl[h]&&(c||h&&!ds[h])){for(var d=-1,f=0;f<qf.length;f++){var p=a.indexOf(qf[f]);p!==-1&&(d===-1||p<d)&&(d=p)}var m,_;d===-1?_=a.lastIndexOf("@"):_=a.lastIndexOf("@",d),_!==-1&&(m=a.slice(0,_),a=a.slice(_+1),this.auth=decodeURIComponent(m)),d=-1;for(var f=0;f<jf.length;f++){var p=a.indexOf(jf[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,g=v.length;f<g;f++){var x=v[f];if(x&&!x.match(Kf)){for(var E="",R=0,S=x.length;R<S;R++)x.charCodeAt(R)>127?E+="x":E+=x[R];if(!E.match(Kf)){var M=v.slice(0,f),P=v.slice(f+1),F=x.match(vw);F&&(M.push(F[1]),P.unshift(F[2])),P.length&&(a="/"+P.join(".")+a),this.hostname=M.join(".");break}}}this.hostname.length>_w?this.hostname="":this.hostname=this.hostname.toLowerCase(),y||(this.hostname=dw.toASCII(this.hostname));var U=this.port?":"+this.port:"",I=this.hostname||"";this.host=I+U,this.href+=this.host,y&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),a[0]!=="/"&&(a="/"+a))}if(!xw[u])for(var f=0,g=Xl.length;f<g;f++){var A=Xl[f];if(a.indexOf(A)!==-1){var w=encodeURIComponent(A);w===A&&(w=escape(A)),a=a.split(A).join(w)}}var C=a.indexOf("#");C!==-1&&(this.hash=a.substr(C),a=a.slice(0,C));var D=a.indexOf("?");if(D!==-1?(this.search=a.substr(D),this.query=a.substr(D+1),t&&(this.query=zl.parse(this.query)),a=a.slice(0,D)):t&&(this.search="",this.query={}),a&&(this.pathname=a),ds[u]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var U=this.pathname||"",N=this.search||"";this.path=U+N}return this.href=this.format(),this},Or.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=zl.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var o=this.search||n&&"?"+n||"";return t&&t.substr(-1)!==":"&&(t+=":"),this.slashes||(!t||ds[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},Or.prototype.resolve=function(r){return this.resolveObject(bw(r,!1,!0)).format()},Or.prototype.resolveObject=function(r){if(typeof r=="string"){var t=new Or;t.parse(r,!1,!0),r=t}for(var e=new Or,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 ds[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(!ds[r.protocol]){for(var h=Object.keys(r),u=0;u<h.length;u++){var c=h[u];e[c]=r[c]}return e.href=e.format(),e}if(e.protocol=r.protocol,!r.host&&!Vl[r.protocol]){for(var g=(r.pathname||"").split("/");g.length&&!(r.host=g.shift()););r.host||(r.host=""),r.hostname||(r.hostname=""),g[0]!==""&&g.unshift(""),g.length<2&&g.unshift(""),e.pathname=g.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)==="/",_=m||p||e.host&&r.pathname,y=_,v=e.pathname&&e.pathname.split("/")||[],g=r.pathname&&r.pathname.split("/")||[],x=e.protocol&&!ds[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&&(g[0]===""?g[0]=r.host:g.unshift(r.host)),r.host=null),_=_&&(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=g;else if(g.length)v||(v=[]),v.pop(),v=v.concat(g),e.search=r.search,e.query=r.query;else if(r.search!=null){if(x){e.host=v.shift(),e.hostname=e.host;var E=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;E&&(e.auth=E.shift(),e.hostname=E.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 R=v.slice(-1)[0],S=(e.host||r.host||v.length>1)&&(R==="."||R==="..")||R==="",M=0,P=v.length;P>=0;P--)R=v[P],R==="."?v.splice(P,1):R===".."?(v.splice(P,1),M++):M&&(v.splice(P,1),M--);if(!_&&!y)for(;M--;M)v.unshift("..");_&&v[0]!==""&&(!v[0]||v[0].charAt(0)!=="/")&&v.unshift(""),S&&v.join("/").substr(-1)!=="/"&&v.push("");var F=v[0]===""||v[0]&&v[0].charAt(0)==="/";if(x){e.hostname=F?"":v.length?v.shift():"",e.host=e.hostname;var E=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;E&&(e.auth=E.shift(),e.hostname=E.shift(),e.host=e.hostname)}return _=_||e.host&&v.length,_&&!F&&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},Or.prototype.parseHost=function(){var r=this.host,t=pw.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 Zf={};function St(r,t,e=3){if(Zf[t])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${t}
6
+ `+t.prev}function Qn(r,t){var e=wl(r),i=[];if(e){i.length=r.length;for(var s=0;s<r.length;s++)i[s]=Or(r,s)?t(r[s],r):""}var n=typeof xl=="function"?xl(r):[],o;if(as){o={};for(var a=0;a<n.length;a++)o["$"+n[a]]=n[a]}for(var l in r)Or(r,l)&&(e&&String(Number(l))===l&&l<r.length||as&&o["$"+l]instanceof Symbol||(nf.call(/[^\w$]/,l)?i.push(t(l,r)+": "+t(r[l],r)):i.push(l+": "+t(r[l],r))));if(typeof xl=="function")for(var h=0;h<n.length;h++)lf.call(r,n[h])&&i.push("["+t(n[h])+"]: "+t(r[n[h]],r));return i}var ab=Zn,lb=os,Jn=function(r,t,e){for(var i=r,s;(s=i.next)!=null;i=s)if(s.key===t)return i.next=s.next,e||(s.next=r.next,r.next=s),s},hb=function(r,t){if(r){var e=Jn(r,t);return e&&e.value}},ub=function(r,t,e){var i=Jn(r,t);i?i.value=e:r.next={key:t,next:r.next,value:e}},cb=function(r,t){return r?!!Jn(r,t):!1},db=function(r,t){if(r)return Jn(r,t,!0)},fb=function(){var t,e={assert:function(i){if(!e.has(i))throw new lb("Side channel does not contain "+ab(i))},delete:function(i){var s=t&&t.next,n=db(t,i);return n&&s&&s===n&&(t=void 0),!!n},get:function(i){return hb(t,i)},has:function(i){return cb(t,i)},set:function(i,s){t||(t={next:void 0}),ub(t,i,s)}};return e},xf=Object,pb=Error,mb=EvalError,gb=RangeError,yb=ReferenceError,_b=SyntaxError,vb=URIError,xb=Math.abs,bb=Math.floor,Eb=Math.max,wb=Math.min,Tb=Math.pow,Ab=Math.round,Sb=Number.isNaN||function(t){return t!==t},Cb=Sb,Ib=function(t){return Cb(t)||t===0?t:t<0?-1:1},Rb=Object.getOwnPropertyDescriptor,to=Rb;if(to)try{to([],"length")}catch{to=null}var bf=to,eo=Object.defineProperty||!1;if(eo)try{eo({},"a",{value:1})}catch{eo=!1}var Mb=eo,Sl,Ef;function Pb(){return Ef||(Ef=1,Sl=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(var n 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 o=Object.getOwnPropertySymbols(t);if(o.length!==1||o[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(t,e);if(a.value!==s||a.enumerable!==!0)return!1}return!0}),Sl}var Cl,wf;function Ob(){if(wf)return Cl;wf=1;var r=typeof Symbol<"u"&&Symbol,t=Pb();return Cl=function(){return typeof r!="function"||typeof Symbol!="function"||typeof r("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:t()},Cl}var Il,Tf;function Af(){return Tf||(Tf=1,Il=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),Il}var Rl,Sf;function Cf(){if(Sf)return Rl;Sf=1;var r=xf;return Rl=r.getPrototypeOf||null,Rl}var Ml,If;function Nb(){if(If)return Ml;If=1;var r="Function.prototype.bind called on incompatible ",t=Object.prototype.toString,e=Math.max,i="[object Function]",s=function(l,h){for(var u=[],c=0;c<l.length;c+=1)u[c]=l[c];for(var d=0;d<h.length;d+=1)u[d+l.length]=h[d];return u},n=function(l,h){for(var u=[],c=h,d=0;c<l.length;c+=1,d+=1)u[d]=l[c];return u},o=function(a,l){for(var h="",u=0;u<a.length;u+=1)h+=a[u],u+1<a.length&&(h+=l);return h};return Ml=function(l){var h=this;if(typeof h!="function"||t.apply(h)!==i)throw new TypeError(r+h);for(var u=n(arguments,1),c,d=function(){if(this instanceof c){var y=h.apply(this,s(u,arguments));return Object(y)===y?y:this}return h.apply(l,s(u,arguments))},f=e(0,h.length-u.length),p=[],m=0;m<f;m++)p[m]="$"+m;if(c=Function("binder","return function ("+o(p,",")+"){ return binder.apply(this,arguments); }")(d),h.prototype){var _=function(){};_.prototype=h.prototype,c.prototype=new _,_.prototype=null}return c},Ml}var Pl,Rf;function ro(){if(Rf)return Pl;Rf=1;var r=Nb();return Pl=Function.prototype.bind||r,Pl}var Ol,Mf;function Nl(){return Mf||(Mf=1,Ol=Function.prototype.call),Ol}var Dl,Pf;function Of(){return Pf||(Pf=1,Dl=Function.prototype.apply),Dl}var Db=typeof Reflect<"u"&&Reflect&&Reflect.apply,Lb=ro(),Bb=Of(),Fb=Nl(),kb=Db,Ub=kb||Lb.call(Fb,Bb),Gb=ro(),$b=os,Hb=Nl(),Xb=Ub,Nf=function(t){if(t.length<1||typeof t[0]!="function")throw new $b("a function is required");return Xb(Gb,Hb,t)},Ll,Df;function Vb(){if(Df)return Ll;Df=1;var r=Nf,t=bf,e;try{e=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var i=!!e&&t&&t(Object.prototype,"__proto__"),s=Object,n=s.getPrototypeOf;return Ll=i&&typeof i.get=="function"?r([i.get]):typeof n=="function"?function(a){return n(a==null?a:s(a))}:!1,Ll}var Bl,Lf;function zb(){if(Lf)return Bl;Lf=1;var r=Af(),t=Cf(),e=Vb();return Bl=r?function(s){return r(s)}:t?function(s){if(!s||typeof s!="object"&&typeof s!="function")throw new TypeError("getProto: not an object");return t(s)}:e?function(s){return e(s)}:null,Bl}var Fl,Bf;function Yb(){if(Bf)return Fl;Bf=1;var r=Function.prototype.call,t=Object.prototype.hasOwnProperty,e=ro();return Fl=e.call(r,t),Fl}var At,jb=xf,Wb=pb,qb=mb,Kb=gb,Zb=yb,ls=_b,hs=os,Qb=vb,Jb=xb,tE=bb,eE=Eb,rE=wb,iE=Tb,sE=Ab,nE=Ib,Ff=Function,kl=function(r){try{return Ff('"use strict"; return ('+r+").constructor;")()}catch{}},tn=bf,oE=Mb,Ul=function(){throw new hs},aE=tn?function(){try{return arguments.callee,Ul}catch{try{return tn(arguments,"callee").get}catch{return Ul}}}():Ul,us=Ob()(),ge=zb(),lE=Cf(),hE=Af(),kf=Of(),en=Nl(),cs={},uE=typeof Uint8Array>"u"||!ge?At:ge(Uint8Array),Ai={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?At:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?At:ArrayBuffer,"%ArrayIteratorPrototype%":us&&ge?ge([][Symbol.iterator]()):At,"%AsyncFromSyncIteratorPrototype%":At,"%AsyncFunction%":cs,"%AsyncGenerator%":cs,"%AsyncGeneratorFunction%":cs,"%AsyncIteratorPrototype%":cs,"%Atomics%":typeof Atomics>"u"?At:Atomics,"%BigInt%":typeof BigInt>"u"?At:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?At:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?At:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?At:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Wb,"%eval%":eval,"%EvalError%":qb,"%Float16Array%":typeof Float16Array>"u"?At:Float16Array,"%Float32Array%":typeof Float32Array>"u"?At:Float32Array,"%Float64Array%":typeof Float64Array>"u"?At:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?At:FinalizationRegistry,"%Function%":Ff,"%GeneratorFunction%":cs,"%Int8Array%":typeof Int8Array>"u"?At:Int8Array,"%Int16Array%":typeof Int16Array>"u"?At:Int16Array,"%Int32Array%":typeof Int32Array>"u"?At:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":us&&ge?ge(ge([][Symbol.iterator]())):At,"%JSON%":typeof JSON=="object"?JSON:At,"%Map%":typeof Map>"u"?At:Map,"%MapIteratorPrototype%":typeof Map>"u"||!us||!ge?At:ge(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":jb,"%Object.getOwnPropertyDescriptor%":tn,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?At:Promise,"%Proxy%":typeof Proxy>"u"?At:Proxy,"%RangeError%":Kb,"%ReferenceError%":Zb,"%Reflect%":typeof Reflect>"u"?At:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?At:Set,"%SetIteratorPrototype%":typeof Set>"u"||!us||!ge?At:ge(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?At:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":us&&ge?ge(""[Symbol.iterator]()):At,"%Symbol%":us?Symbol:At,"%SyntaxError%":ls,"%ThrowTypeError%":aE,"%TypedArray%":uE,"%TypeError%":hs,"%Uint8Array%":typeof Uint8Array>"u"?At:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?At:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?At:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?At:Uint32Array,"%URIError%":Qb,"%WeakMap%":typeof WeakMap>"u"?At:WeakMap,"%WeakRef%":typeof WeakRef>"u"?At:WeakRef,"%WeakSet%":typeof WeakSet>"u"?At:WeakSet,"%Function.prototype.call%":en,"%Function.prototype.apply%":kf,"%Object.defineProperty%":oE,"%Object.getPrototypeOf%":lE,"%Math.abs%":Jb,"%Math.floor%":tE,"%Math.max%":eE,"%Math.min%":rE,"%Math.pow%":iE,"%Math.round%":sE,"%Math.sign%":nE,"%Reflect.getPrototypeOf%":hE};if(ge)try{null.error}catch(r){var cE=ge(ge(r));Ai["%Error.prototype%"]=cE}var dE=function r(t){var e;if(t==="%AsyncFunction%")e=kl("async function () {}");else if(t==="%GeneratorFunction%")e=kl("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=kl("async function* () {}");else if(t==="%AsyncGenerator%"){var i=r("%AsyncGeneratorFunction%");i&&(e=i.prototype)}else if(t==="%AsyncIteratorPrototype%"){var s=r("%AsyncGenerator%");s&&ge&&(e=ge(s.prototype))}return Ai[t]=e,e},Uf={__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"]},rn=ro(),io=Yb(),fE=rn.call(en,Array.prototype.concat),pE=rn.call(kf,Array.prototype.splice),Gf=rn.call(en,String.prototype.replace),so=rn.call(en,String.prototype.slice),mE=rn.call(en,RegExp.prototype.exec),gE=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,yE=/\\(\\)?/g,_E=function(t){var e=so(t,0,1),i=so(t,-1);if(e==="%"&&i!=="%")throw new ls("invalid intrinsic syntax, expected closing `%`");if(i==="%"&&e!=="%")throw new ls("invalid intrinsic syntax, expected opening `%`");var s=[];return Gf(t,gE,function(n,o,a,l){s[s.length]=a?Gf(l,yE,"$1"):o||n}),s},vE=function(t,e){var i=t,s;if(io(Uf,i)&&(s=Uf[i],i="%"+s[0]+"%"),io(Ai,i)){var n=Ai[i];if(n===cs&&(n=dE(i)),typeof n>"u"&&!e)throw new hs("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:s,name:i,value:n}}throw new ls("intrinsic "+t+" does not exist!")},Gl=function(t,e){if(typeof t!="string"||t.length===0)throw new hs("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new hs('"allowMissing" argument must be a boolean');if(mE(/^%?[^%]*%?$/,t)===null)throw new ls("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=_E(t),s=i.length>0?i[0]:"",n=vE("%"+s+"%",e),o=n.name,a=n.value,l=!1,h=n.alias;h&&(s=h[0],pE(i,fE([0,1],h)));for(var u=1,c=!0;u<i.length;u+=1){var d=i[u],f=so(d,0,1),p=so(d,-1);if((f==='"'||f==="'"||f==="`"||p==='"'||p==="'"||p==="`")&&f!==p)throw new ls("property names with quotes must have matching quotes");if((d==="constructor"||!c)&&(l=!0),s+="."+d,o="%"+s+"%",io(Ai,o))a=Ai[o];else if(a!=null){if(!(d in a)){if(!e)throw new hs("base intrinsic for "+t+" exists, but the property is not available.");return}if(tn&&u+1>=i.length){var m=tn(a,d);c=!!m,c&&"get"in m&&!("originalValue"in m.get)?a=m.get:a=a[d]}else c=io(a,d),a=a[d];c&&!l&&(Ai[o]=a)}}return a},$f=Gl,Hf=Nf,xE=Hf([$f("%String.prototype.indexOf%")]),Xf=function(t,e){var i=$f(t,!!e);return typeof i=="function"&&xE(t,".prototype.")>-1?Hf([i]):i},bE=Gl,sn=Xf,EE=Zn,wE=os,Vf=bE("%Map%",!0),TE=sn("Map.prototype.get",!0),AE=sn("Map.prototype.set",!0),SE=sn("Map.prototype.has",!0),CE=sn("Map.prototype.delete",!0),IE=sn("Map.prototype.size",!0),zf=!!Vf&&function(){var t,e={assert:function(i){if(!e.has(i))throw new wE("Side channel does not contain "+EE(i))},delete:function(i){if(t){var s=CE(t,i);return IE(t)===0&&(t=void 0),s}return!1},get:function(i){if(t)return TE(t,i)},has:function(i){return t?SE(t,i):!1},set:function(i,s){t||(t=new Vf),AE(t,i,s)}};return e},RE=Gl,no=Xf,ME=Zn,oo=zf,PE=os,ds=RE("%WeakMap%",!0),OE=no("WeakMap.prototype.get",!0),NE=no("WeakMap.prototype.set",!0),DE=no("WeakMap.prototype.has",!0),LE=no("WeakMap.prototype.delete",!0),BE=ds?function(){var t,e,i={assert:function(s){if(!i.has(s))throw new PE("Side channel does not contain "+ME(s))},delete:function(s){if(ds&&s&&(typeof s=="object"||typeof s=="function")){if(t)return LE(t,s)}else if(oo&&e)return e.delete(s);return!1},get:function(s){return ds&&s&&(typeof s=="object"||typeof s=="function")&&t?OE(t,s):e&&e.get(s)},has:function(s){return ds&&s&&(typeof s=="object"||typeof s=="function")&&t?DE(t,s):!!e&&e.has(s)},set:function(s,n){ds&&s&&(typeof s=="object"||typeof s=="function")?(t||(t=new ds),NE(t,s,n)):oo&&(e||(e=oo()),e.set(s,n))}};return i}:oo,FE=os,kE=Zn,UE=fb,GE=zf,$E=BE,HE=$E||GE||UE,XE=function(){var t,e={assert:function(i){if(!e.has(i))throw new FE("Side channel does not contain "+kE(i))},delete:function(i){return!!t&&t.delete(i)},get:function(i){return t&&t.get(i)},has:function(i){return!!t&&t.has(i)},set:function(i,s){t||(t=HE()),t.set(i,s)}};return e},VE=String.prototype.replace,zE=/%20/g,$l={RFC1738:"RFC1738",RFC3986:"RFC3986"},Hl={default:$l.RFC3986,formatters:{RFC1738:function(r){return VE.call(r,zE,"+")},RFC3986:function(r){return String(r)}},RFC1738:$l.RFC1738,RFC3986:$l.RFC3986},YE=Hl,Xl=Object.prototype.hasOwnProperty,Si=Array.isArray,_r=function(){for(var r=[],t=0;t<256;++t)r.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return r}(),jE=function(t){for(;t.length>1;){var e=t.pop(),i=e.obj[e.prop];if(Si(i)){for(var s=[],n=0;n<i.length;++n)typeof i[n]<"u"&&s.push(i[n]);e.obj[e.prop]=s}}},Yf=function(t,e){for(var i=e&&e.plainObjects?{__proto__:null}:{},s=0;s<t.length;++s)typeof t[s]<"u"&&(i[s]=t[s]);return i},WE=function r(t,e,i){if(!e)return t;if(typeof e!="object"&&typeof e!="function"){if(Si(t))t.push(e);else if(t&&typeof t=="object")(i&&(i.plainObjects||i.allowPrototypes)||!Xl.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 Si(t)&&!Si(e)&&(s=Yf(t,i)),Si(t)&&Si(e)?(e.forEach(function(n,o){if(Xl.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 Xl.call(n,o)?n[o]=r(n[o],a,i):n[o]=a,n},s)},qE=function(t,e){return Object.keys(e).reduce(function(i,s){return i[s]=e[s],i},t)},KE=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}},Vl=1024,ZE=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(f){return"%26%23"+parseInt(f.slice(2),16)+"%3B"});for(var a="",l=0;l<o.length;l+=Vl){for(var h=o.length>=Vl?o.slice(l,l+Vl):o,u=[],c=0;c<h.length;++c){var d=h.charCodeAt(c);if(d===45||d===46||d===95||d===126||d>=48&&d<=57||d>=65&&d<=90||d>=97&&d<=122||n===YE.RFC1738&&(d===40||d===41)){u[u.length]=h.charAt(c);continue}if(d<128){u[u.length]=_r[d];continue}if(d<2048){u[u.length]=_r[192|d>>6]+_r[128|d&63];continue}if(d<55296||d>=57344){u[u.length]=_r[224|d>>12]+_r[128|d>>6&63]+_r[128|d&63];continue}c+=1,d=65536+((d&1023)<<10|h.charCodeAt(c)&1023),u[u.length]=_r[240|d>>18]+_r[128|d>>12&63]+_r[128|d>>6&63]+_r[128|d&63]}a+=u.join("")}return a},QE=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],u=o[h];typeof u=="object"&&u!==null&&i.indexOf(u)===-1&&(e.push({obj:o,prop:h}),i.push(u))}return jE(e),t},JE=function(t){return Object.prototype.toString.call(t)==="[object RegExp]"},tw=function(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},ew=function(t,e){return[].concat(t,e)},rw=function(t,e){if(Si(t)){for(var i=[],s=0;s<t.length;s+=1)i.push(e(t[s]));return i}return e(t)},jf={arrayToObject:Yf,assign:qE,combine:ew,compact:QE,decode:KE,encode:ZE,isBuffer:tw,isRegExp:JE,maybeMap:rw,merge:WE},Wf=XE,ao=jf,nn=Hl,iw=Object.prototype.hasOwnProperty,qf={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},vr=Array.isArray,sw=Array.prototype.push,Kf=function(r,t){sw.apply(r,vr(t)?t:[t])},nw=Date.prototype.toISOString,Zf=nn.default,de={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,commaRoundTrip:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:ao.encode,encodeValuesOnly:!1,filter:void 0,format:Zf,formatter:nn.formatters[Zf],indices:!1,serializeDate:function(t){return nw.call(t)},skipNulls:!1,strictNullHandling:!1},ow=function(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"},zl={},aw=function r(t,e,i,s,n,o,a,l,h,u,c,d,f,p,m,_,y,v){for(var g=t,x=v,T=0,M=!1;(x=x.get(zl))!==void 0&&!M;){var S=x.get(t);if(T+=1,typeof S<"u"){if(S===T)throw new RangeError("Cyclic object value");M=!0}typeof x.get(zl)>"u"&&(T=0)}if(typeof u=="function"?g=u(e,g):g instanceof Date?g=f(g):i==="comma"&&vr(g)&&(g=ao.maybeMap(g,function(D){return D instanceof Date?f(D):D})),g===null){if(o)return h&&!_?h(e,de.encoder,y,"key",p):e;g=""}if(ow(g)||ao.isBuffer(g)){if(h){var R=_?e:h(e,de.encoder,y,"key",p);return[m(R)+"="+m(h(g,de.encoder,y,"value",p))]}return[m(e)+"="+m(String(g))]}var P=[];if(typeof g>"u")return P;var F;if(i==="comma"&&vr(g))_&&h&&(g=ao.maybeMap(g,h)),F=[{value:g.length>0?g.join(",")||null:void 0}];else if(vr(u))F=u;else{var U=Object.keys(g);F=c?U.sort(c):U}var I=l?String(e).replace(/\./g,"%2E"):String(e),A=s&&vr(g)&&g.length===1?I+"[]":I;if(n&&vr(g)&&g.length===0)return A+"[]";for(var w=0;w<F.length;++w){var C=F[w],L=typeof C=="object"&&C&&typeof C.value<"u"?C.value:g[C];if(!(a&&L===null)){var O=d&&l?String(C).replace(/\./g,"%2E"):String(C),B=vr(g)?typeof i=="function"?i(A,O):A:A+(d?"."+O:"["+O+"]");v.set(t,T);var V=Wf();V.set(zl,v),Kf(P,r(L,B,i,s,n,o,a,l,i==="comma"&&_&&vr(g)?null:h,u,c,d,f,p,m,_,y,V))}}return P},lw=function(t){if(!t)return de;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||de.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=nn.default;if(typeof t.format<"u"){if(!iw.call(nn.formatters,t.format))throw new TypeError("Unknown format option provided.");i=t.format}var s=nn.formatters[i],n=de.filter;(typeof t.filter=="function"||vr(t.filter))&&(n=t.filter);var o;if(t.arrayFormat in qf?o=t.arrayFormat:"indices"in t?o=t.indices?"indices":"repeat":o=de.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:de.allowDots:!!t.allowDots;return{addQueryPrefix:typeof t.addQueryPrefix=="boolean"?t.addQueryPrefix:de.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:de.allowEmptyArrays,arrayFormat:o,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:de.charsetSentinel,commaRoundTrip:!!t.commaRoundTrip,delimiter:typeof t.delimiter>"u"?de.delimiter:t.delimiter,encode:typeof t.encode=="boolean"?t.encode:de.encode,encodeDotInKeys:typeof t.encodeDotInKeys=="boolean"?t.encodeDotInKeys:de.encodeDotInKeys,encoder:typeof t.encoder=="function"?t.encoder:de.encoder,encodeValuesOnly:typeof t.encodeValuesOnly=="boolean"?t.encodeValuesOnly:de.encodeValuesOnly,filter:n,format:i,formatter:s,serializeDate:typeof t.serializeDate=="function"?t.serializeDate:de.serializeDate,skipNulls:typeof t.skipNulls=="boolean"?t.skipNulls:de.skipNulls,sort:typeof t.sort=="function"?t.sort:null,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:de.strictNullHandling}},hw=function(r,t){var e=r,i=lw(t),s,n;typeof i.filter=="function"?(n=i.filter,e=n("",e)):vr(i.filter)&&(n=i.filter,s=n);var o=[];if(typeof e!="object"||e===null)return"";var a=qf[i.arrayFormat],l=a==="comma"&&i.commaRoundTrip;s||(s=Object.keys(e)),i.sort&&s.sort(i.sort);for(var h=Wf(),u=0;u<s.length;++u){var c=s[u],d=e[c];i.skipNulls&&d===null||Kf(o,aw(d,c,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 f=o.join(i.delimiter),p=i.addQueryPrefix===!0?"?":"";return i.charsetSentinel&&(i.charset==="iso-8859-1"?p+="utf8=%26%2310003%3B&":p+="utf8=%E2%9C%93&"),f.length>0?p+f:""},Ci=jf,Yl=Object.prototype.hasOwnProperty,Qf=Array.isArray,Jt={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:Ci.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1,throwOnLimitExceeded:!1},uw=function(r){return r.replace(/&#(\d+);/g,function(t,e){return String.fromCharCode(parseInt(e,10))})},Jf=function(r,t,e){if(r&&typeof r=="string"&&t.comma&&r.indexOf(",")>-1)return r.split(",");if(t.throwOnLimitExceeded&&e>=t.arrayLimit)throw new RangeError("Array limit exceeded. Only "+t.arrayLimit+" element"+(t.arrayLimit===1?"":"s")+" allowed in an array.");return r},cw="utf8=%26%2310003%3B",dw="utf8=%E2%9C%93",fw=function(t,e){var i={__proto__:null},s=e.ignoreQueryPrefix?t.replace(/^\?/,""):t;s=s.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var n=e.parameterLimit===1/0?void 0:e.parameterLimit,o=s.split(e.delimiter,e.throwOnLimitExceeded?n+1:n);if(e.throwOnLimitExceeded&&o.length>n)throw new RangeError("Parameter limit exceeded. Only "+n+" parameter"+(n===1?"":"s")+" allowed.");var a=-1,l,h=e.charset;if(e.charsetSentinel)for(l=0;l<o.length;++l)o[l].indexOf("utf8=")===0&&(o[l]===dw?h="utf-8":o[l]===cw&&(h="iso-8859-1"),a=l,l=o.length);for(l=0;l<o.length;++l)if(l!==a){var u=o[l],c=u.indexOf("]="),d=c===-1?u.indexOf("="):c+1,f,p;d===-1?(f=e.decoder(u,Jt.decoder,h,"key"),p=e.strictNullHandling?null:""):(f=e.decoder(u.slice(0,d),Jt.decoder,h,"key"),p=Ci.maybeMap(Jf(u.slice(d+1),e,Qf(i[f])?i[f].length:0),function(_){return e.decoder(_,Jt.decoder,h,"value")})),p&&e.interpretNumericEntities&&h==="iso-8859-1"&&(p=uw(String(p))),u.indexOf("[]=")>-1&&(p=Qf(p)?[p]:p);var m=Yl.call(i,f);m&&e.duplicates==="combine"?i[f]=Ci.combine(i[f],p):(!m||e.duplicates==="last")&&(i[f]=p)}return i},pw=function(r,t,e,i){var s=0;if(r.length>0&&r[r.length-1]==="[]"){var n=r.slice(0,-1).join("");s=Array.isArray(t)&&t[n]?t[n].length:0}for(var o=i?t:Jf(t,e,s),a=r.length-1;a>=0;--a){var l,h=r[a];if(h==="[]"&&e.parseArrays)l=e.allowEmptyArrays&&(o===""||e.strictNullHandling&&o===null)?[]:Ci.combine([],o);else{l=e.plainObjects?{__proto__:null}:{};var u=h.charAt(0)==="["&&h.charAt(h.length-1)==="]"?h.slice(1,-1):h,c=e.decodeDotInKeys?u.replace(/%2E/g,"."):u,d=parseInt(c,10);!e.parseArrays&&c===""?l={0:o}:!isNaN(d)&&h!==c&&String(d)===c&&d>=0&&e.parseArrays&&d<=e.arrayLimit?(l=[],l[d]=o):c!=="__proto__"&&(l[c]=o)}o=l}return o},mw=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,u=[];if(h){if(!i.plainObjects&&Yl.call(Object.prototype,h)&&!i.allowPrototypes)return;u.push(h)}for(var c=0;i.depth>0&&(l=a.exec(n))!==null&&c<i.depth;){if(c+=1,!i.plainObjects&&Yl.call(Object.prototype,l[1].slice(1,-1))&&!i.allowPrototypes)return;u.push(l[1])}if(l){if(i.strictDepth===!0)throw new RangeError("Input depth exceeded depth option of "+i.depth+" and strictDepth is true");u.push("["+n.slice(l.index)+"]")}return pw(u,e,i,s)}},gw=function(t){if(!t)return Jt;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");if(typeof t.throwOnLimitExceeded<"u"&&typeof t.throwOnLimitExceeded!="boolean")throw new TypeError("`throwOnLimitExceeded` option must be a boolean");var e=typeof t.charset>"u"?Jt.charset:t.charset,i=typeof t.duplicates>"u"?Jt.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:Jt.allowDots:!!t.allowDots;return{allowDots:s,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:Jt.allowEmptyArrays,allowPrototypes:typeof t.allowPrototypes=="boolean"?t.allowPrototypes:Jt.allowPrototypes,allowSparse:typeof t.allowSparse=="boolean"?t.allowSparse:Jt.allowSparse,arrayLimit:typeof t.arrayLimit=="number"?t.arrayLimit:Jt.arrayLimit,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Jt.charsetSentinel,comma:typeof t.comma=="boolean"?t.comma:Jt.comma,decodeDotInKeys:typeof t.decodeDotInKeys=="boolean"?t.decodeDotInKeys:Jt.decodeDotInKeys,decoder:typeof t.decoder=="function"?t.decoder:Jt.decoder,delimiter:typeof t.delimiter=="string"||Ci.isRegExp(t.delimiter)?t.delimiter:Jt.delimiter,depth:typeof t.depth=="number"||t.depth===!1?+t.depth:Jt.depth,duplicates:i,ignoreQueryPrefix:t.ignoreQueryPrefix===!0,interpretNumericEntities:typeof t.interpretNumericEntities=="boolean"?t.interpretNumericEntities:Jt.interpretNumericEntities,parameterLimit:typeof t.parameterLimit=="number"?t.parameterLimit:Jt.parameterLimit,parseArrays:t.parseArrays!==!1,plainObjects:typeof t.plainObjects=="boolean"?t.plainObjects:Jt.plainObjects,strictDepth:typeof t.strictDepth=="boolean"?!!t.strictDepth:Jt.strictDepth,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Jt.strictNullHandling,throwOnLimitExceeded:typeof t.throwOnLimitExceeded=="boolean"?t.throwOnLimitExceeded:!1}},yw=function(r,t){var e=gw(t);if(r===""||r===null||typeof r>"u")return e.plainObjects?{__proto__:null}:{};for(var i=typeof r=="string"?fw(r,e):r,s=e.plainObjects?{__proto__:null}:{},n=Object.keys(i),o=0;o<n.length;++o){var a=n[o],l=mw(a,i[a],e,typeof r=="string");s=Ci.merge(s,l,e)}return e.allowSparse===!0?s:Ci.compact(s)},_w=hw,vw=yw,xw=Hl,bw={formats:xw,parse:vw,stringify:_w},Ew=Px;function Nr(){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 ww=/^([a-z0-9.+-]+:)/i,Tw=/:[0-9]*$/,Aw=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,Sw=["<",">",'"',"`"," ","\r",`
7
+ `," "],Cw=["{","}","|","\\","^","`"].concat(Sw),jl=["'"].concat(Cw),tp=["%","/","?",";","#"].concat(jl),ep=["/","?","#"],Iw=255,rp=/^[+a-z0-9A-Z_-]{0,63}$/,Rw=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Mw={javascript:!0,"javascript:":!0},Wl={javascript:!0,"javascript:":!0},fs={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},ql=bw;function Pw(r,t,e){if(r&&typeof r=="object"&&r instanceof Nr)return r;var i=new Nr;return i.parse(r,t,e),i}Nr.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=Aw.exec(a);if(l)return this.path=a,this.href=a,this.pathname=l[1],l[2]?(this.search=l[2],t?this.query=ql.parse(this.search.substr(1)):this.query=this.search.substr(1)):t&&(this.search="",this.query={}),this}var h=ww.exec(a);if(h){h=h[0];var u=h.toLowerCase();this.protocol=u,a=a.substr(h.length)}if(e||h||a.match(/^\/\/[^@/]+@[^@/]+/)){var c=a.substr(0,2)==="//";c&&!(h&&Wl[h])&&(a=a.substr(2),this.slashes=!0)}if(!Wl[h]&&(c||h&&!fs[h])){for(var d=-1,f=0;f<ep.length;f++){var p=a.indexOf(ep[f]);p!==-1&&(d===-1||p<d)&&(d=p)}var m,_;d===-1?_=a.lastIndexOf("@"):_=a.lastIndexOf("@",d),_!==-1&&(m=a.slice(0,_),a=a.slice(_+1),this.auth=decodeURIComponent(m)),d=-1;for(var f=0;f<tp.length;f++){var p=a.indexOf(tp[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,g=v.length;f<g;f++){var x=v[f];if(x&&!x.match(rp)){for(var T="",M=0,S=x.length;M<S;M++)x.charCodeAt(M)>127?T+="x":T+=x[M];if(!T.match(rp)){var R=v.slice(0,f),P=v.slice(f+1),F=x.match(Rw);F&&(R.push(F[1]),P.unshift(F[2])),P.length&&(a="/"+P.join(".")+a),this.hostname=R.join(".");break}}}this.hostname.length>Iw?this.hostname="":this.hostname=this.hostname.toLowerCase(),y||(this.hostname=Ew.toASCII(this.hostname));var U=this.port?":"+this.port:"",I=this.hostname||"";this.host=I+U,this.href+=this.host,y&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),a[0]!=="/"&&(a="/"+a))}if(!Mw[u])for(var f=0,g=jl.length;f<g;f++){var A=jl[f];if(a.indexOf(A)!==-1){var w=encodeURIComponent(A);w===A&&(w=escape(A)),a=a.split(A).join(w)}}var C=a.indexOf("#");C!==-1&&(this.hash=a.substr(C),a=a.slice(0,C));var L=a.indexOf("?");if(L!==-1?(this.search=a.substr(L),this.query=a.substr(L+1),t&&(this.query=ql.parse(this.query)),a=a.slice(0,L)):t&&(this.search="",this.query={}),a&&(this.pathname=a),fs[u]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var U=this.pathname||"",O=this.search||"";this.path=U+O}return this.href=this.format(),this},Nr.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=ql.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var o=this.search||n&&"?"+n||"";return t&&t.substr(-1)!==":"&&(t+=":"),this.slashes||(!t||fs[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},Nr.prototype.resolve=function(r){return this.resolveObject(Pw(r,!1,!0)).format()},Nr.prototype.resolveObject=function(r){if(typeof r=="string"){var t=new Nr;t.parse(r,!1,!0),r=t}for(var e=new Nr,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 fs[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(!fs[r.protocol]){for(var h=Object.keys(r),u=0;u<h.length;u++){var c=h[u];e[c]=r[c]}return e.href=e.format(),e}if(e.protocol=r.protocol,!r.host&&!Wl[r.protocol]){for(var g=(r.pathname||"").split("/");g.length&&!(r.host=g.shift()););r.host||(r.host=""),r.hostname||(r.hostname=""),g[0]!==""&&g.unshift(""),g.length<2&&g.unshift(""),e.pathname=g.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)==="/",_=m||p||e.host&&r.pathname,y=_,v=e.pathname&&e.pathname.split("/")||[],g=r.pathname&&r.pathname.split("/")||[],x=e.protocol&&!fs[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&&(g[0]===""?g[0]=r.host:g.unshift(r.host)),r.host=null),_=_&&(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=g;else if(g.length)v||(v=[]),v.pop(),v=v.concat(g),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 M=v.slice(-1)[0],S=(e.host||r.host||v.length>1)&&(M==="."||M==="..")||M==="",R=0,P=v.length;P>=0;P--)M=v[P],M==="."?v.splice(P,1):M===".."?(v.splice(P,1),R++):R&&(v.splice(P,1),R--);if(!_&&!y)for(;R--;R)v.unshift("..");_&&v[0]!==""&&(!v[0]||v[0].charAt(0)!=="/")&&v.unshift(""),S&&v.join("/").substr(-1)!=="/"&&v.push("");var F=v[0]===""||v[0]&&v[0].charAt(0)==="/";if(x){e.hostname=F?"":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 _=_||e.host&&v.length,_&&!F&&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},Nr.prototype.parseHost=function(){var r=this.host,t=Tw.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 ip={};function St(r,t,e=3){if(ip[t])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${t}
8
8
  Deprecated since v${r}`):(i=i.split(`
9
9
  `).splice(e).join(`
10
10
  `),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${t}
11
11
  Deprecated since v${r}`),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t}
12
- Deprecated since v${r}`),console.warn(i))),Zf[t]=!0}function rr(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function rn(r){return r.split("?")[0].split("#")[0]}function Ew(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ww(r,t,e){return r.replace(new RegExp(Ew(t),"g"),e)}function Tw(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}}}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 ge={toPosix(r){return ww(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){rr(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(rr(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=rn(this.toPosix(t??tt.ADAPTER.getBaseUrl())),s=rn(this.toPosix(e??this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?ge.join(s,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(rr(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=Tw(r),r.length>0&&i&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return rr(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(rr(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(rr(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){rr(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){rr(r),t&&rr(t),r=rn(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){rr(r),r=rn(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){rr(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=rn(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,u=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:u!==1&&(u=1):n!==-1&&(u=-1)}return n===-1||a===-1||u===0||u===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 Yl;async function Aw(){return Yl??(Yl=(async()=>{var n;const r=document.createElement("canvas").getContext("webgl");if(!r)return He.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 He.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]?He.PMA:He.UNPACK})()),Yl}let Wl;function Sw(){return typeof Wl>"u"&&(Wl=function(){var t;const r={stencil:!0,failIfMajorPerformanceCaveat:tt.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!tt.ADAPTER.getWebGLRenderingContext())return!1;const e=tt.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}}()),Wl}var Cw={grad:.9,turn:360,rad:360/(2*Math.PI)},Nr=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},ye=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},je=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},Qf=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},Jf=function(r){return{r:je(r.r,0,255),g:je(r.g,0,255),b:je(r.b,0,255),a:je(r.a)}},jl=function(r){return{r:ye(r.r),g:ye(r.g),b:ye(r.b),a:ye(r.a,3)}},Iw=/^#([0-9a-f]{3,8})$/i,so=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},tp=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}},ep=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}},rp=function(r){return{h:Qf(r.h),s:je(r.s,0,100),l:je(r.l,0,100),a:je(r.a)}},ip=function(r){return{h:ye(r.h),s:ye(r.s),l:ye(r.l),a:ye(r.a,3)}},sp=function(r){return ep((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},sn=function(r){return{h:(t=tp(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},Rw=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Mw=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Pw=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ow=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ql={string:[[function(r){var t=Iw.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?ye(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?ye(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=Pw.exec(r)||Ow.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:Jf({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=Rw.exec(r)||Mw.exec(r);if(!t)return null;var e,i,s=rp({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(Cw[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return sp(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 Nr(t)&&Nr(e)&&Nr(i)?Jf({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(!Nr(t)||!Nr(e)||!Nr(i))return null;var o=rp({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return sp(o)},"hsl"],[function(r){var t=r.h,e=r.s,i=r.v,s=r.a,n=s===void 0?1:s;if(!Nr(t)||!Nr(e)||!Nr(i))return null;var o=function(a){return{h:Qf(a.h),s:je(a.s,0,100),v:je(a.v,0,100),a:je(a.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return ep(o)},"hsv"]]},np=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]},Nw=function(r){return typeof r=="string"?np(r.trim(),ql.string):typeof r=="object"&&r!==null?np(r,ql.object):[null,void 0]},Kl=function(r,t){var e=sn(r);return{h:e.h,s:je(e.s+100*t,0,100),l:e.l,a:e.a}},Zl=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},op=function(r,t){var e=sn(r);return{h:e.h,s:e.s,l:je(e.l+100*t,0,100),a:e.a}},Ql=function(){function r(t){this.parsed=Nw(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 ye(Zl(this.rgba),2)},r.prototype.isDark=function(){return Zl(this.rgba)<.5},r.prototype.isLight=function(){return Zl(this.rgba)>=.5},r.prototype.toHex=function(){return t=jl(this.rgba),e=t.r,i=t.g,s=t.b,o=(n=t.a)<1?so(ye(255*n)):"","#"+so(e)+so(i)+so(s)+o;var t,e,i,s,n,o},r.prototype.toRgb=function(){return jl(this.rgba)},r.prototype.toRgbString=function(){return t=jl(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 ip(sn(this.rgba))},r.prototype.toHslString=function(){return t=ip(sn(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=tp(this.rgba),{h:ye(t.h),s:ye(t.s),v:ye(t.v),a:ye(t.a,3)};var t},r.prototype.invert=function(){return xr({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),xr(Kl(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),xr(Kl(this.rgba,-t))},r.prototype.grayscale=function(){return xr(Kl(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),xr(op(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),xr(op(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"?xr({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):ye(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=sn(this.rgba);return typeof t=="number"?xr({h:t,s:e.s,l:e.l,a:e.a}):ye(e.h)},r.prototype.isEqual=function(t){return this.toHex()===xr(t).toHex()},r}(),xr=function(r){return r instanceof Ql?r:new Ql(r)},ap=[],Dw=function(r){r.forEach(function(t){ap.indexOf(t)<0&&(t(Ql,ql),ap.push(t))})};function Lw(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 u=this.toRgb(),c=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=u,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<c&&(c=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"])}Dw([Lw]);const fs=class Ko{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 Ko)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]=Ko.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=Ko.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=xr(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)}};fs.shared=new fs,fs.temp=new fs,fs.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Ot=fs;function Bw(r){return St("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),Ot.shared.setValue(r).toHex()}function Fw(r){return St("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),Ot.shared.setValue(r).toNumber()}function kw(){const r=[],t=[];for(let i=0;i<32;i++)r[i]=i,t[i]=i;r[yt.NORMAL_NPM]=yt.NORMAL,r[yt.ADD_NPM]=yt.ADD,r[yt.SCREEN_NPM]=yt.SCREEN,t[yt.NORMAL]=yt.NORMAL_NPM,t[yt.ADD]=yt.ADD_NPM,t[yt.SCREEN]=yt.SCREEN_NPM;const e=[];return e.push(t),e.push(r),e}const lp=kw();function hp(r,t){return lp[t?1:0][r]}function Uw(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 up(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 no(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 cp(r){return!(r&r-1)&&!!r}function dp(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 ps(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 ri(r){return r===0?0:r<0?-1:1}let Gw=0;function Ii(){return++Gw}const Jl=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}};Jl.EMPTY=new Jl(0,0,0,0);let fp=Jl;const pp={},br=Object.create(null),ii=Object.create(null);class Hw{constructor(t,e,i){this._canvas=tt.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||tt.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 mp(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 gp(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 $w(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&&mp(s,t,o);)++o;if(o===e)return fp.EMPTY;for(;mp(s,t,l);)--l;for(;gp(s,t,n,o,l);)++n;for(;gp(s,t,a,o,l);)--a;return++a,++l,new fp(n,o,a,l)}function Xw(r){const t=$w(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 Vw(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 Dr(r,t=1){var i;const e=(i=tt.RETINA_PREFIX)==null?void 0:i.exec(r);return e?parseFloat(e[1]):t}var Q=(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))(Q||{});const th=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},yp=(r,t)=>th(r).priority??t,ht={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(th).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(th).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)=>yp(n,e)-yp(s,e)))},i=>{const s=t.indexOf(i.ref);s!==-1&&t.splice(s,1)})}};class eh{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 zw=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
13
- `);function Yw(r){let t="";for(let e=0;e<r;++e)e>0&&(t+=`
14
- else `),e<r-1&&(t+=`if(test == ${e}.0){}`);return t}function Ww(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=zw.replace(/%forloop%/gi,Yw(r));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))r=r/2|0;else break}return r}const rh=0,ih=1,sh=2,nh=3,oh=4,ah=5;class Er{constructor(){this.data=0,this.blendMode=yt.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<rh)}set blend(t){!!(this.data&1<<rh)!==t&&(this.data^=1<<rh)}get offsets(){return!!(this.data&1<<ih)}set offsets(t){!!(this.data&1<<ih)!==t&&(this.data^=1<<ih)}get culling(){return!!(this.data&1<<sh)}set culling(t){!!(this.data&1<<sh)!==t&&(this.data^=1<<sh)}get depthTest(){return!!(this.data&1<<nh)}set depthTest(t){!!(this.data&1<<nh)!==t&&(this.data^=1<<nh)}get depthMask(){return!!(this.data&1<<ah)}set depthMask(t){!!(this.data&1<<ah)!==t&&(this.data^=1<<ah)}get clockwiseFrontFace(){return!!(this.data&1<<oh)}set clockwiseFrontFace(t){!!(this.data&1<<oh)!==t&&(this.data^=1<<oh)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==yt.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new Er;return t.depthTest=!1,t.blend=!0,t}}Er.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const lh=[];function _p(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=lh.length-1;i>=0;--i){const s=lh[i];if(s.test&&s.test(r,e))return new s(r,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class ir{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:u}=this;this._aliasCount++;for(let c=0,d=u.length;c<d;c++)u[c][h](t,e,i,s,n,o,a,l);return u===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(ir.prototype,{dispatch:{value:ir.prototype.emit},run:{value:ir.prototype.emit}});class nn{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new ir("setRealSize"),this.onUpdate=new ir("update"),this.onError=new ir("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 oo extends nn{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===He.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 jw={scaleMode:Ir.NEAREST,alphaMode:He.NPM},hh=class Ss extends Xs{constructor(t=null,e=null){super(),e=Object.assign({},Ss.defaultOptions,e);const{alphaMode:i,mipmap:s,anisotropicLevel:n,scaleMode:o,width:a,height:l,wrapMode:h,format:u,type:c,target:d,resolution:f,resourceOptions:p}=e;t&&!(t instanceof nn)&&(t=_p(t,p),t.internal=!0),this.resolution=f||tt.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=u,this.type=c,this.target=d,this.alphaMode=i,this.uid=Ii(),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=cp(this.realWidth)&&cp(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 ii[this.cacheId],delete br[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),Ss.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=tt.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}_${Ii()}`}n=t._pixiId}let o=ii[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in BaseTextureCache.`);return o||(o=new Ss(t,e),o.cacheId=n,Ss.addToCache(o,n)),o}static fromBuffer(t,e,i,s){t=t||new Float32Array(e*i*4);const n=new oo(t,{width:e,height:i,...s==null?void 0:s.resourceOptions});let o,a;return t instanceof Float32Array?(o=z.RGBA,a=ft.FLOAT):t instanceof Int32Array?(o=z.RGBA_INTEGER,a=ft.INT):t instanceof Uint32Array?(o=z.RGBA_INTEGER,a=ft.UNSIGNED_INT):t instanceof Int16Array?(o=z.RGBA_INTEGER,a=ft.SHORT):t instanceof Uint16Array?(o=z.RGBA_INTEGER,a=ft.UNSIGNED_SHORT):t instanceof Int8Array?(o=z.RGBA,a=ft.BYTE):(o=z.RGBA,a=ft.UNSIGNED_BYTE),n.internal=!0,new Ss(n,Object.assign({},jw,{type:a,format:o},s))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),ii[e]&&ii[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),ii[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=ii[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete ii[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)delete ii[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}};hh.defaultOptions={mipmap:pr.POW2,anisotropicLevel:0,scaleMode:Ir.LINEAR,wrapMode:Jr.CLAMP,alphaMode:He.UNPACK,target:rs.TEXTURE_2D,format:z.RGBA,type:ft.UNSIGNED_BYTE},hh._globalBatch=0;let vt=hh;class uh{constructor(){this.texArray=null,this.blend=0,this.type=fr.TRIANGLES,this.start=0,this.size=0,this.data=null}}let qw=0;class te{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=qw++,this.disposeRunner=new ir("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?gr.ELEMENT_ARRAY_BUFFER:gr.ARRAY_BUFFER}get index(){return this.type===gr.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new te(t)}}class ao{constructor(t,e=0,i=!1,s=ft.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 ao(t,e,i,s,n)}}const Kw={Float32Array,Uint32Array,Int32Array,Uint8Array};function Zw(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],u=r[l],c=up(u);s[c]||(s[c]=new Kw[c](n)),o=s[c];for(let d=0;d<u.length;d++){const f=(d/h|0)*i+a,p=d%h;o[f+p]=u[d]}a+=h}return new Float32Array(n)}const vp={5126:4,5123:2,5121:1};let Qw=0;const Jw={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class si{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=Qw++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new ir("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 te||(e instanceof Array&&(e=new Float32Array(e)),e=new te(e));const h=t.split("|");if(h.length>1){for(let c=0;c<h.length;c++)this.addAttribute(h[c],e,i,s,n);return this}let u=this.buffers.indexOf(e);return u===-1&&(this.buffers.push(e),u=this.buffers.length-1),this.attributes[t]=new ao(u,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 te||(t instanceof Array&&(t=new Uint16Array(t)),t=new te(t)),t.type=gr.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 te;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*vp[n.type]/4),n.buffer=0}for(i.data=Zw(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 si;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new te(this.buffers[e].data.slice(0));for(const e in this.attributes){const i=this.attributes[e];t.attributes[e]=new ao(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=gr.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new si,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 Jw[up(o.buffers[a].data)](s[a]),e.buffers[a]=new te(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=gr.ELEMENT_ARRAY_BUFFER;let a=0,l=0,h=0,u=0;for(let c=0;c<o.buffers.length;c++)if(o.buffers[c]!==o.indexBuffer){u=c;break}for(const c in o.attributes){const d=o.attributes[c];(d.buffer|0)===u&&(l+=d.size*vp[d.type]/4)}for(let c=0;c<t.length;c++){const d=t[c].indexBuffer.data;for(let f=0;f<d.length;f++)e.indexBuffer.data[f+h]+=a;a+=t[c].buffers[u].data.length/l,h+=d.length}}return e}}class xp extends si{constructor(t=!1){super(),this._buffer=new te(null,t,!1),this._indexBuffer=new te(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,ft.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,ft.FLOAT).addAttribute("aColor",this._buffer,4,!0,ft.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,ft.FLOAT).addIndex(this._indexBuffer)}}const lo=Math.PI*2,tT=180/Math.PI,eT=Math.PI/180;var Ae=(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))(Ae||{});class It{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new It(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}}It.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const ho=[new It,new It,new It,new It];class Et{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=Ae.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 Et(0,0,0,0)}clone(){return new Et(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 M=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=M)return!1;const P=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>P}const i=this.left,s=this.right,n=this.top,o=this.bottom;if(s<=i||o<=n)return!1;const a=ho[0].set(t.left,t.top),l=ho[1].set(t.left,t.bottom),h=ho[2].set(t.right,t.top),u=ho[3].set(t.right,t.bottom);if(h.x<=a.x||l.y<=a.y)return!1;const c=Math.sign(e.a*e.d-e.b*e.c);if(c===0||(e.apply(a,a),e.apply(l,l),e.apply(h,h),e.apply(u,u),Math.max(a.x,l.x,h.x,u.x)<=i||Math.min(a.x,l.x,h.x,u.x)>=s||Math.max(a.y,l.y,h.y,u.y)<=n||Math.min(a.y,l.y,h.y,u.y)>=o))return!1;const d=c*(l.y-a.y),f=c*(a.x-l.x),p=d*i+f*n,m=d*s+f*n,_=d*i+f*o,y=d*s+f*o;if(Math.max(p,m,_,y)<=d*a.x+f*a.y||Math.min(p,m,_,y)>=d*u.x+f*u.y)return!1;const v=c*(a.y-h.y),g=c*(h.x-a.x),x=v*i+g*n,E=v*s+g*n,R=v*i+g*o,S=v*s+g*o;return!(Math.max(x,E,R,S)<=v*a.x+g*a.y||Math.min(x,E,R,S)>=v*u.x+g*u.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}}Et.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class uo{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.radius=i,this.type=Ae.CIRC}clone(){return new uo(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 Et(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}uo.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class co{constructor(t=0,e=0,i=0,s=0){this.x=t,this.y=e,this.width=i,this.height=s,this.type=Ae.ELIP}clone(){return new co(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 Et(this.x-this.width,this.y-this.height,this.width,this.height)}}co.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Ri{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=Ae.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new Ri(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],u=this.points[o*2+1];l>e!=u>e&&t<(h-a)*((e-l)/(u-l))+a&&(i=!i)}return i}}Ri.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((r,t)=>`${r}, ${t}`,"")}]`};class fo{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=Ae.RREC}clone(){return new fo(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}}fo.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class Ut{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 It;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 It;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(lo-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 Ut;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 Ut}static get TEMP_MATRIX(){return new Ut}}Ut.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 Mi=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Pi=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Oi=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Ni=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],ch=[],bp=[],po=Math.sign;function rT(){for(let r=0;r<16;r++){const t=[];ch.push(t);for(let e=0;e<16;e++){const i=po(Mi[r]*Mi[e]+Oi[r]*Pi[e]),s=po(Pi[r]*Mi[e]+Ni[r]*Pi[e]),n=po(Mi[r]*Oi[e]+Oi[r]*Ni[e]),o=po(Pi[r]*Oi[e]+Ni[r]*Ni[e]);for(let a=0;a<16;a++)if(Mi[a]===i&&Pi[a]===s&&Oi[a]===n&&Ni[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new Ut;t.set(Mi[r],Pi[r],Oi[r],Ni[r],0,0),bp.push(t)}}rT();const Yt={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=>Mi[r],uY:r=>Pi[r],vX:r=>Oi[r],vY:r=>Ni[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>ch[r][t],sub:(r,t)=>ch[r][Yt.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?Yt.S:Yt.N:Math.abs(t)*2<=Math.abs(r)?r>0?Yt.E:Yt.W:t>0?r>0?Yt.SE:Yt.SW:r>0?Yt.NE:Yt.NW,matrixAppendRotationInv:(r,t,e=0,i=0)=>{const s=bp[Yt.inv(t)];s.tx=e,s.ty=i,r.append(s)}};class Lr{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 Lr(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))}}Lr.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const dh=class{constructor(){this.worldTransform=new Ut,this.localTransform=new Ut,this.position=new Lr(this.onChange,this,0,0),this.scale=new Lr(this.onChange,this,1,1),this.pivot=new Lr(this.onChange,this,0,0),this.skew=new Lr(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())}};dh.IDENTITY=new dh;let fh=dh;fh.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 iT=`varying vec2 vTextureCoord;
12
+ Deprecated since v${r}`),console.warn(i))),ip[t]=!0}function rr(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function on(r){return r.split("?")[0].split("#")[0]}function Ow(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Nw(r,t,e){return r.replace(new RegExp(Ow(t),"g"),e)}function Dw(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}}}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 ye={toPosix(r){return Nw(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){rr(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(rr(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=on(this.toPosix(t??tt.ADAPTER.getBaseUrl())),s=on(this.toPosix(e??this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?ye.join(s,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(rr(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=Dw(r),r.length>0&&i&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return rr(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(rr(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(rr(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){rr(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){rr(r),t&&rr(t),r=on(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){rr(r),r=on(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){rr(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=on(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,u=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:u!==1&&(u=1):n!==-1&&(u=-1)}return n===-1||a===-1||u===0||u===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 Kl;async function Lw(){return Kl??(Kl=(async()=>{var n;const r=document.createElement("canvas").getContext("webgl");if(!r)return $e.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 $e.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]?$e.PMA:$e.UNPACK})()),Kl}let Zl;function Bw(){return typeof Zl>"u"&&(Zl=function(){var t;const r={stencil:!0,failIfMajorPerformanceCaveat:tt.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!tt.ADAPTER.getWebGLRenderingContext())return!1;const e=tt.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}}()),Zl}var Fw={grad:.9,turn:360,rad:360/(2*Math.PI)},Dr=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},_e=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},We=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},sp=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},np=function(r){return{r:We(r.r,0,255),g:We(r.g,0,255),b:We(r.b,0,255),a:We(r.a)}},Ql=function(r){return{r:_e(r.r),g:_e(r.g),b:_e(r.b),a:_e(r.a,3)}},kw=/^#([0-9a-f]{3,8})$/i,lo=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},op=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}},ap=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}},lp=function(r){return{h:sp(r.h),s:We(r.s,0,100),l:We(r.l,0,100),a:We(r.a)}},hp=function(r){return{h:_e(r.h),s:_e(r.s),l:_e(r.l),a:_e(r.a,3)}},up=function(r){return ap((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},an=function(r){return{h:(t=op(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},Uw=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Gw=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,$w=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Hw=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Jl={string:[[function(r){var t=kw.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?_e(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?_e(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=$w.exec(r)||Hw.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:np({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=Uw.exec(r)||Gw.exec(r);if(!t)return null;var e,i,s=lp({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(Fw[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return up(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 Dr(t)&&Dr(e)&&Dr(i)?np({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(!Dr(t)||!Dr(e)||!Dr(i))return null;var o=lp({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return up(o)},"hsl"],[function(r){var t=r.h,e=r.s,i=r.v,s=r.a,n=s===void 0?1:s;if(!Dr(t)||!Dr(e)||!Dr(i))return null;var o=function(a){return{h:sp(a.h),s:We(a.s,0,100),v:We(a.v,0,100),a:We(a.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return ap(o)},"hsv"]]},cp=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]},Xw=function(r){return typeof r=="string"?cp(r.trim(),Jl.string):typeof r=="object"&&r!==null?cp(r,Jl.object):[null,void 0]},th=function(r,t){var e=an(r);return{h:e.h,s:We(e.s+100*t,0,100),l:e.l,a:e.a}},eh=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},dp=function(r,t){var e=an(r);return{h:e.h,s:e.s,l:We(e.l+100*t,0,100),a:e.a}},rh=function(){function r(t){this.parsed=Xw(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 _e(eh(this.rgba),2)},r.prototype.isDark=function(){return eh(this.rgba)<.5},r.prototype.isLight=function(){return eh(this.rgba)>=.5},r.prototype.toHex=function(){return t=Ql(this.rgba),e=t.r,i=t.g,s=t.b,o=(n=t.a)<1?lo(_e(255*n)):"","#"+lo(e)+lo(i)+lo(s)+o;var t,e,i,s,n,o},r.prototype.toRgb=function(){return Ql(this.rgba)},r.prototype.toRgbString=function(){return t=Ql(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 hp(an(this.rgba))},r.prototype.toHslString=function(){return t=hp(an(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=op(this.rgba),{h:_e(t.h),s:_e(t.s),v:_e(t.v),a:_e(t.a,3)};var t},r.prototype.invert=function(){return xr({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),xr(th(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),xr(th(this.rgba,-t))},r.prototype.grayscale=function(){return xr(th(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),xr(dp(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),xr(dp(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"?xr({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):_e(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=an(this.rgba);return typeof t=="number"?xr({h:t,s:e.s,l:e.l,a:e.a}):_e(e.h)},r.prototype.isEqual=function(t){return this.toHex()===xr(t).toHex()},r}(),xr=function(r){return r instanceof rh?r:new rh(r)},fp=[],Vw=function(r){r.forEach(function(t){fp.indexOf(t)<0&&(t(rh,Jl),fp.push(t))})};function zw(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 u=this.toRgb(),c=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=u,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<c&&(c=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"])}Vw([zw]);const ps=class Jo{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 Jo)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]=Jo.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=Jo.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=xr(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)}};ps.shared=new ps,ps.temp=new ps,ps.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Nt=ps;function Yw(r){return St("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),Nt.shared.setValue(r).toHex()}function jw(r){return St("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),Nt.shared.setValue(r).toNumber()}function Ww(){const r=[],t=[];for(let i=0;i<32;i++)r[i]=i,t[i]=i;r[yt.NORMAL_NPM]=yt.NORMAL,r[yt.ADD_NPM]=yt.ADD,r[yt.SCREEN_NPM]=yt.SCREEN,t[yt.NORMAL]=yt.NORMAL_NPM,t[yt.ADD]=yt.ADD_NPM,t[yt.SCREEN]=yt.SCREEN_NPM;const e=[];return e.push(t),e.push(r),e}const pp=Ww();function mp(r,t){return pp[t?1:0][r]}function qw(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 gp(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 ho(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 yp(r){return!(r&r-1)&&!!r}function _p(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 ms(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 ri(r){return r===0?0:r<0?-1:1}let Kw=0;function Ii(){return++Kw}const ih=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}};ih.EMPTY=new ih(0,0,0,0);let vp=ih;const xp={},br=Object.create(null),ii=Object.create(null);class Zw{constructor(t,e,i){this._canvas=tt.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||tt.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 bp(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 Ep(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 Qw(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&&bp(s,t,o);)++o;if(o===e)return vp.EMPTY;for(;bp(s,t,l);)--l;for(;Ep(s,t,n,o,l);)++n;for(;Ep(s,t,a,o,l);)--a;return++a,++l,new vp(n,o,a,l)}function Jw(r){const t=Qw(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 tT(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 Lr(r,t=1){var i;const e=(i=tt.RETINA_PREFIX)==null?void 0:i.exec(r);return e?parseFloat(e[1]):t}var Q=(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))(Q||{});const sh=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},wp=(r,t)=>sh(r).priority??t,ut={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(sh).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(sh).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)=>wp(n,e)-wp(s,e)))},i=>{const s=t.indexOf(i.ref);s!==-1&&t.splice(s,1)})}};class nh{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 eT=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
13
+ `);function rT(r){let t="";for(let e=0;e<r;++e)e>0&&(t+=`
14
+ else `),e<r-1&&(t+=`if(test == ${e}.0){}`);return t}function iT(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=eT.replace(/%forloop%/gi,rT(r));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))r=r/2|0;else break}return r}const oh=0,ah=1,lh=2,hh=3,uh=4,ch=5;class Er{constructor(){this.data=0,this.blendMode=yt.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<oh)}set blend(t){!!(this.data&1<<oh)!==t&&(this.data^=1<<oh)}get offsets(){return!!(this.data&1<<ah)}set offsets(t){!!(this.data&1<<ah)!==t&&(this.data^=1<<ah)}get culling(){return!!(this.data&1<<lh)}set culling(t){!!(this.data&1<<lh)!==t&&(this.data^=1<<lh)}get depthTest(){return!!(this.data&1<<hh)}set depthTest(t){!!(this.data&1<<hh)!==t&&(this.data^=1<<hh)}get depthMask(){return!!(this.data&1<<ch)}set depthMask(t){!!(this.data&1<<ch)!==t&&(this.data^=1<<ch)}get clockwiseFrontFace(){return!!(this.data&1<<uh)}set clockwiseFrontFace(t){!!(this.data&1<<uh)!==t&&(this.data^=1<<uh)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==yt.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new Er;return t.depthTest=!1,t.blend=!0,t}}Er.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const dh=[];function Tp(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=dh.length-1;i>=0;--i){const s=dh[i];if(s.test&&s.test(r,e))return new s(r,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class ir{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:u}=this;this._aliasCount++;for(let c=0,d=u.length;c<d;c++)u[c][h](t,e,i,s,n,o,a,l);return u===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(ir.prototype,{dispatch:{value:ir.prototype.emit},run:{value:ir.prototype.emit}});class ln{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new ir("setRealSize"),this.onUpdate=new ir("update"),this.onError=new ir("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 uo extends ln{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===$e.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 sT={scaleMode:Rr.NEAREST,alphaMode:$e.NPM},fh=class Is extends Ys{constructor(t=null,e=null){super(),e=Object.assign({},Is.defaultOptions,e);const{alphaMode:i,mipmap:s,anisotropicLevel:n,scaleMode:o,width:a,height:l,wrapMode:h,format:u,type:c,target:d,resolution:f,resourceOptions:p}=e;t&&!(t instanceof ln)&&(t=Tp(t,p),t.internal=!0),this.resolution=f||tt.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=u,this.type=c,this.target=d,this.alphaMode=i,this.uid=Ii(),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=yp(this.realWidth)&&yp(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 ii[this.cacheId],delete br[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),Is.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=tt.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}_${Ii()}`}n=t._pixiId}let o=ii[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in BaseTextureCache.`);return o||(o=new Is(t,e),o.cacheId=n,Is.addToCache(o,n)),o}static fromBuffer(t,e,i,s){t=t||new Float32Array(e*i*4);const n=new uo(t,{width:e,height:i,...s==null?void 0:s.resourceOptions});let o,a;return t instanceof Float32Array?(o=j.RGBA,a=ft.FLOAT):t instanceof Int32Array?(o=j.RGBA_INTEGER,a=ft.INT):t instanceof Uint32Array?(o=j.RGBA_INTEGER,a=ft.UNSIGNED_INT):t instanceof Int16Array?(o=j.RGBA_INTEGER,a=ft.SHORT):t instanceof Uint16Array?(o=j.RGBA_INTEGER,a=ft.UNSIGNED_SHORT):t instanceof Int8Array?(o=j.RGBA,a=ft.BYTE):(o=j.RGBA,a=ft.UNSIGNED_BYTE),n.internal=!0,new Is(n,Object.assign({},sT,{type:a,format:o},s))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),ii[e]&&ii[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),ii[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=ii[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete ii[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)delete ii[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}};fh.defaultOptions={mipmap:pr.POW2,anisotropicLevel:0,scaleMode:Rr.LINEAR,wrapMode:Jr.CLAMP,alphaMode:$e.UNPACK,target:is.TEXTURE_2D,format:j.RGBA,type:ft.UNSIGNED_BYTE},fh._globalBatch=0;let bt=fh;class ph{constructor(){this.texArray=null,this.blend=0,this.type=fr.TRIANGLES,this.start=0,this.size=0,this.data=null}}let nT=0;class se{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=nT++,this.disposeRunner=new ir("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?gr.ELEMENT_ARRAY_BUFFER:gr.ARRAY_BUFFER}get index(){return this.type===gr.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new se(t)}}class co{constructor(t,e=0,i=!1,s=ft.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 co(t,e,i,s,n)}}const oT={Float32Array,Uint32Array,Int32Array,Uint8Array};function aT(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],u=r[l],c=gp(u);s[c]||(s[c]=new oT[c](n)),o=s[c];for(let d=0;d<u.length;d++){const f=(d/h|0)*i+a,p=d%h;o[f+p]=u[d]}a+=h}return new Float32Array(n)}const Ap={5126:4,5123:2,5121:1};let lT=0;const hT={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class si{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=lT++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new ir("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 se||(e instanceof Array&&(e=new Float32Array(e)),e=new se(e));const h=t.split("|");if(h.length>1){for(let c=0;c<h.length;c++)this.addAttribute(h[c],e,i,s,n);return this}let u=this.buffers.indexOf(e);return u===-1&&(this.buffers.push(e),u=this.buffers.length-1),this.attributes[t]=new co(u,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 se||(t instanceof Array&&(t=new Uint16Array(t)),t=new se(t)),t.type=gr.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 se;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*Ap[n.type]/4),n.buffer=0}for(i.data=aT(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 si;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new se(this.buffers[e].data.slice(0));for(const e in this.attributes){const i=this.attributes[e];t.attributes[e]=new co(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=gr.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new si,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 hT[gp(o.buffers[a].data)](s[a]),e.buffers[a]=new se(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=gr.ELEMENT_ARRAY_BUFFER;let a=0,l=0,h=0,u=0;for(let c=0;c<o.buffers.length;c++)if(o.buffers[c]!==o.indexBuffer){u=c;break}for(const c in o.attributes){const d=o.attributes[c];(d.buffer|0)===u&&(l+=d.size*Ap[d.type]/4)}for(let c=0;c<t.length;c++){const d=t[c].indexBuffer.data;for(let f=0;f<d.length;f++)e.indexBuffer.data[f+h]+=a;a+=t[c].buffers[u].data.length/l,h+=d.length}}return e}}class Sp extends si{constructor(t=!1){super(),this._buffer=new se(null,t,!1),this._indexBuffer=new se(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,ft.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,ft.FLOAT).addAttribute("aColor",this._buffer,4,!0,ft.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,ft.FLOAT).addIndex(this._indexBuffer)}}const fo=Math.PI*2,uT=180/Math.PI,cT=Math.PI/180;var Ae=(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))(Ae||{});class It{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new It(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}}It.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const po=[new It,new It,new It,new It];class wt{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=Ae.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 wt(0,0,0,0)}clone(){return new wt(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 R=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=R)return!1;const P=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>P}const i=this.left,s=this.right,n=this.top,o=this.bottom;if(s<=i||o<=n)return!1;const a=po[0].set(t.left,t.top),l=po[1].set(t.left,t.bottom),h=po[2].set(t.right,t.top),u=po[3].set(t.right,t.bottom);if(h.x<=a.x||l.y<=a.y)return!1;const c=Math.sign(e.a*e.d-e.b*e.c);if(c===0||(e.apply(a,a),e.apply(l,l),e.apply(h,h),e.apply(u,u),Math.max(a.x,l.x,h.x,u.x)<=i||Math.min(a.x,l.x,h.x,u.x)>=s||Math.max(a.y,l.y,h.y,u.y)<=n||Math.min(a.y,l.y,h.y,u.y)>=o))return!1;const d=c*(l.y-a.y),f=c*(a.x-l.x),p=d*i+f*n,m=d*s+f*n,_=d*i+f*o,y=d*s+f*o;if(Math.max(p,m,_,y)<=d*a.x+f*a.y||Math.min(p,m,_,y)>=d*u.x+f*u.y)return!1;const v=c*(a.y-h.y),g=c*(h.x-a.x),x=v*i+g*n,T=v*s+g*n,M=v*i+g*o,S=v*s+g*o;return!(Math.max(x,T,M,S)<=v*a.x+g*a.y||Math.min(x,T,M,S)>=v*u.x+g*u.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}}wt.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class mo{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.radius=i,this.type=Ae.CIRC}clone(){return new mo(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 wt(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}mo.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class go{constructor(t=0,e=0,i=0,s=0){this.x=t,this.y=e,this.width=i,this.height=s,this.type=Ae.ELIP}clone(){return new go(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 wt(this.x-this.width,this.y-this.height,this.width,this.height)}}go.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Ri{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=Ae.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new Ri(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],u=this.points[o*2+1];l>e!=u>e&&t<(h-a)*((e-l)/(u-l))+a&&(i=!i)}return i}}Ri.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((r,t)=>`${r}, ${t}`,"")}]`};class yo{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=Ae.RREC}clone(){return new yo(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}}yo.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class Gt{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 It;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 It;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(fo-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 Gt;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 Gt}static get TEMP_MATRIX(){return new Gt}}Gt.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 Mi=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Pi=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Oi=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Ni=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],mh=[],Cp=[],_o=Math.sign;function dT(){for(let r=0;r<16;r++){const t=[];mh.push(t);for(let e=0;e<16;e++){const i=_o(Mi[r]*Mi[e]+Oi[r]*Pi[e]),s=_o(Pi[r]*Mi[e]+Ni[r]*Pi[e]),n=_o(Mi[r]*Oi[e]+Oi[r]*Ni[e]),o=_o(Pi[r]*Oi[e]+Ni[r]*Ni[e]);for(let a=0;a<16;a++)if(Mi[a]===i&&Pi[a]===s&&Oi[a]===n&&Ni[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new Gt;t.set(Mi[r],Pi[r],Oi[r],Ni[r],0,0),Cp.push(t)}}dT();const Wt={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=>Mi[r],uY:r=>Pi[r],vX:r=>Oi[r],vY:r=>Ni[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>mh[r][t],sub:(r,t)=>mh[r][Wt.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?Wt.S:Wt.N:Math.abs(t)*2<=Math.abs(r)?r>0?Wt.E:Wt.W:t>0?r>0?Wt.SE:Wt.SW:r>0?Wt.NE:Wt.NW,matrixAppendRotationInv:(r,t,e=0,i=0)=>{const s=Cp[Wt.inv(t)];s.tx=e,s.ty=i,r.append(s)}};class Br{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 Br(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))}}Br.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const gh=class{constructor(){this.worldTransform=new Gt,this.localTransform=new Gt,this.position=new Br(this.onChange,this,0,0),this.scale=new Br(this.onChange,this,1,1),this.pivot=new Br(this.onChange,this,0,0),this.skew=new Br(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())}};gh.IDENTITY=new gh;let yh=gh;yh.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 fT=`varying vec2 vTextureCoord;
15
15
 
16
16
  uniform sampler2D uSampler;
17
17
 
18
18
  void main(void){
19
19
  gl_FragColor *= texture2D(uSampler, vTextureCoord);
20
- }`,sT=`attribute vec2 aVertexPosition;
20
+ }`,pT=`attribute vec2 aVertexPosition;
21
21
  attribute vec2 aTextureCoord;
22
22
 
23
23
  uniform mat3 projectionMatrix;
@@ -28,7 +28,7 @@ void main(void){
28
28
  gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
29
29
  vTextureCoord = aTextureCoord;
30
30
  }
31
- `;function Ep(r,t,e){const i=r.createShader(t);return r.shaderSource(i,e),r.compileShader(i),i}function ph(r){const t=new Array(r);for(let e=0;e<t.length;e++)t[e]=!1;return t}function wp(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 ph(2*t);case"bvec3":return ph(3*t);case"bvec4":return ph(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 ms=[{test:r=>r.type==="float"&&r.size===1&&!r.isArray,code:r=>`
31
+ `;function Ip(r,t,e){const i=r.createShader(t);return r.shaderSource(i,e),r.compileShader(i),i}function _h(r){const t=new Array(r);for(let e=0;e<t.length;e++)t[e]=!1;return t}function Rp(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 _h(2*t);case"bvec3":return _h(3*t);case"bvec4":return _h(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 gs=[{test:r=>r.type==="float"&&r.size===1&&!r.isArray,code:r=>`
32
32
  if(uv["${r}"] !== ud["${r}"].value)
33
33
  {
34
34
  ud["${r}"].value = uv["${r}"]
@@ -148,7 +148,7 @@ void main(void){
148
148
  cv[3] = v[3];
149
149
 
150
150
  gl.uniform4f(ud["${r}"].location, v[0], v[1], v[2], v[3])
151
- }`}],nT={float:`
151
+ }`}],mT={float:`
152
152
  if (cv !== v)
153
153
  {
154
154
  cu.value = v;
@@ -284,7 +284,7 @@ void main(void){
284
284
  cu.value = v;
285
285
 
286
286
  gl.uniform1i(location, v);
287
- }`},oT={float:"gl.uniform1fv(location, v)",vec2:"gl.uniform2fv(location, v)",vec3:"gl.uniform3fv(location, v)",vec4:"gl.uniform4fv(location, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat2:"gl.uniformMatrix2fv(location, false, v)",int:"gl.uniform1iv(location, v)",ivec2:"gl.uniform2iv(location, v)",ivec3:"gl.uniform3iv(location, v)",ivec4:"gl.uniform4iv(location, v)",uint:"gl.uniform1uiv(location, v)",uvec2:"gl.uniform2uiv(location, v)",uvec3:"gl.uniform3uiv(location, v)",uvec4:"gl.uniform4uiv(location, v)",bool:"gl.uniform1iv(location, v)",bvec2:"gl.uniform2iv(location, v)",bvec3:"gl.uniform3iv(location, v)",bvec4:"gl.uniform4iv(location, v)",sampler2D:"gl.uniform1iv(location, v)",samplerCube:"gl.uniform1iv(location, v)",sampler2DArray:"gl.uniform1iv(location, v)"};function aT(r,t){var i;const e=[`
287
+ }`},gT={float:"gl.uniform1fv(location, v)",vec2:"gl.uniform2fv(location, v)",vec3:"gl.uniform3fv(location, v)",vec4:"gl.uniform4fv(location, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat2:"gl.uniformMatrix2fv(location, false, v)",int:"gl.uniform1iv(location, v)",ivec2:"gl.uniform2iv(location, v)",ivec3:"gl.uniform3iv(location, v)",ivec4:"gl.uniform4iv(location, v)",uint:"gl.uniform1uiv(location, v)",uvec2:"gl.uniform2uiv(location, v)",uvec3:"gl.uniform3uiv(location, v)",uvec4:"gl.uniform4uiv(location, v)",bool:"gl.uniform1iv(location, v)",bvec2:"gl.uniform2iv(location, v)",bvec3:"gl.uniform3iv(location, v)",bvec4:"gl.uniform4iv(location, v)",sampler2D:"gl.uniform1iv(location, v)",samplerCube:"gl.uniform1iv(location, v)",sampler2DArray:"gl.uniform1iv(location, v)"};function yT(r,t){var i;const e=[`
288
288
  var v = null;
289
289
  var cv = null;
290
290
  var cu = null;
@@ -294,18 +294,18 @@ void main(void){
294
294
  renderer.shader.syncUniformBufferGroup(uv.${s}, '${s}');
295
295
  `):e.push(`
296
296
  renderer.shader.syncUniformGroup(uv.${s}, syncData);
297
- `));continue}const o=r.uniforms[s];let a=!1;for(let l=0;l<ms.length;l++)if(ms[l].test(n,o)){e.push(ms[l].code(s,o)),a=!0;break}if(!a){const l=(n.size===1&&!n.isArray?nT:oT)[n.type].replace("location",`ud["${s}"].location`);e.push(`
297
+ `));continue}const o=r.uniforms[s];let a=!1;for(let l=0;l<gs.length;l++)if(gs[l].test(n,o)){e.push(gs[l].code(s,o)),a=!0;break}if(!a){const l=(n.size===1&&!n.isArray?mT:gT)[n.type].replace("location",`ud["${s}"].location`);e.push(`
298
298
  cu = ud["${s}"];
299
299
  cv = cu.value;
300
300
  v = uv["${s}"];
301
301
  ${l};`)}}return new Function("ud","uv","renderer","syncData",e.join(`
302
- `))}const Tp={};let gs=Tp;function lT(){if(gs===Tp||gs!=null&&gs.isContextLost()){const r=tt.ADAPTER.createCanvas();let t;tt.PREFER_ENV>=Ei.WEBGL2&&(t=r.getContext("webgl2",{})),t||(t=r.getContext("webgl",{})||r.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),gs=t}return gs}let mo;function hT(){if(!mo){mo=We.MEDIUM;const r=lT();if(r&&r.getShaderPrecisionFormat){const t=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT);t&&(mo=t.precision?We.HIGH:We.MEDIUM)}}return mo}function Ap(r,t){const e=r.getShaderSource(t).split(`
302
+ `))}const Mp={};let ys=Mp;function _T(){if(ys===Mp||ys!=null&&ys.isContextLost()){const r=tt.ADAPTER.createCanvas();let t;tt.PREFER_ENV>=Ei.WEBGL2&&(t=r.getContext("webgl2",{})),t||(t=r.getContext("webgl",{})||r.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),ys=t}return ys}let vo;function vT(){if(!vo){vo=je.MEDIUM;const r=_T();if(r&&r.getShaderPrecisionFormat){const t=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT);t&&(vo=t.precision?je.HIGH:je.MEDIUM)}}return vo}function Pp(r,t){const e=r.getShaderSource(t).split(`
303
303
  `).map((h,u)=>`${u}: ${h}`),i=r.getShaderInfoLog(t),s=i.split(`
304
304
  `),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(`
305
- `);a[0]=l,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function uT(r,t,e,i){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||Ap(r,e),r.getShaderParameter(i,r.COMPILE_STATUS)||Ap(r,i),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}const cT={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 Sp(r){return cT[r]}let go=null;const Cp={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 Ip(r,t){if(!go){const e=Object.keys(Cp);go={};for(let i=0;i<e.length;++i){const s=e[i];go[r[s]]=Cp[s]}}return go[t]}function Rp(r,t,e){if(r.substring(0,9)!=="precision"){let i=t;return t===We.HIGH&&e!==We.HIGH&&(i=We.MEDIUM),`precision ${i} float;
306
- ${r}`}else if(e!==We.HIGH&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}let on;function dT(){if(typeof on=="boolean")return on;try{on=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{on=!1}return on}let fT=0;const yo={},mh=class Cs{constructor(t,e,i="pixi-shader",s={}){this.extra={},this.id=fT++,this.vertexSrc=t||Cs.defaultVertexSrc,this.fragmentSrc=e||Cs.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,"-"),yo[i]?(yo[i]++,i+=`-${yo[i]}`):yo[i]=1,this.vertexSrc=`#define SHADER_NAME ${i}
305
+ `);a[0]=l,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function xT(r,t,e,i){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||Pp(r,e),r.getShaderParameter(i,r.COMPILE_STATUS)||Pp(r,i),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}const bT={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 Op(r){return bT[r]}let xo=null;const Np={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 Dp(r,t){if(!xo){const e=Object.keys(Np);xo={};for(let i=0;i<e.length;++i){const s=e[i];xo[r[s]]=Np[s]}}return xo[t]}function Lp(r,t,e){if(r.substring(0,9)!=="precision"){let i=t;return t===je.HIGH&&e!==je.HIGH&&(i=je.MEDIUM),`precision ${i} float;
306
+ ${r}`}else if(e!==je.HIGH&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}let hn;function ET(){if(typeof hn=="boolean")return hn;try{hn=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{hn=!1}return hn}let wT=0;const bo={},vh=class Rs{constructor(t,e,i="pixi-shader",s={}){this.extra={},this.id=wT++,this.vertexSrc=t||Rs.defaultVertexSrc,this.fragmentSrc=e||Rs.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,"-"),bo[i]?(bo[i]++,i+=`-${bo[i]}`):bo[i]=1,this.vertexSrc=`#define SHADER_NAME ${i}
307
307
  ${this.vertexSrc}`,this.fragmentSrc=`#define SHADER_NAME ${i}
308
- ${this.fragmentSrc}`,this.vertexSrc=Rp(this.vertexSrc,Cs.defaultVertexPrecision,We.HIGH),this.fragmentSrc=Rp(this.fragmentSrc,Cs.defaultFragmentPrecision,hT())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return sT}static get defaultFragmentSrc(){return iT}static from(t,e,i){const s=t+e;let n=pp[s];return n||(pp[s]=n=new Cs(t,e,i)),n}};mh.defaultVertexPrecision=We.HIGH,mh.defaultFragmentPrecision=Mr.apple.device?We.HIGH:We.MEDIUM;let Br=mh,pT=0;class sr{constructor(t,e,i){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=pT++,this.static=!!e,this.ubo=!!i,t instanceof te?(this.buffer=t,this.buffer.type=gr.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new te(new Float32Array(1)),this.buffer.type=gr.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 sr(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 sr(t,e,i)}static uboFrom(t,e){return new sr(t,e??!0,!0)}}class wr{constructor(t,e){this.uniformBindCount=0,this.program=t,e?e instanceof sr?this.uniformGroup=e:this.uniformGroup=new sr(e):this.uniformGroup=new sr({}),this.disposeRunner=new ir("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=Br.from(t,e);return new wr(s,i)}}class mT{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]=sr.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 Br(this.vertexSrc,s)}const e={tint:new Float32Array([1,1,1,1]),translationMatrix:new Ut,default:this.defaultGroupCache[t]};return new wr(this.programCache[t],e)}generateSampleSrc(t){let e="";e+=`
308
+ ${this.fragmentSrc}`,this.vertexSrc=Lp(this.vertexSrc,Rs.defaultVertexPrecision,je.HIGH),this.fragmentSrc=Lp(this.fragmentSrc,Rs.defaultFragmentPrecision,vT())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return pT}static get defaultFragmentSrc(){return fT}static from(t,e,i){const s=t+e;let n=xp[s];return n||(xp[s]=n=new Rs(t,e,i)),n}};vh.defaultVertexPrecision=je.HIGH,vh.defaultFragmentPrecision=Pr.apple.device?je.HIGH:je.MEDIUM;let Fr=vh,TT=0;class sr{constructor(t,e,i){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=TT++,this.static=!!e,this.ubo=!!i,t instanceof se?(this.buffer=t,this.buffer.type=gr.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new se(new Float32Array(1)),this.buffer.type=gr.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 sr(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 sr(t,e,i)}static uboFrom(t,e){return new sr(t,e??!0,!0)}}class wr{constructor(t,e){this.uniformBindCount=0,this.program=t,e?e instanceof sr?this.uniformGroup=e:this.uniformGroup=new sr(e):this.uniformGroup=new sr({}),this.disposeRunner=new ir("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=Fr.from(t,e);return new wr(s,i)}}class AT{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]=sr.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 Fr(this.vertexSrc,s)}const e={tint:new Float32Array([1,1,1,1]),translationMatrix:new Gt,default:this.defaultGroupCache[t]};return new wr(this.programCache[t],e)}generateSampleSrc(t){let e="";e+=`
309
309
  `,e+=`
310
310
  `;for(let i=0;i<t;i++)i>0&&(e+=`
311
311
  else `),i<t-1&&(e+=`if(vTextureId < ${i}.5)`),e+=`
@@ -313,7 +313,7 @@ else `),i<t-1&&(e+=`if(vTextureId < ${i}.5)`),e+=`
313
313
  color = texture2D(uSamplers[${i}], vTextureCoord);`,e+=`
314
314
  }`;return e+=`
315
315
  `,e+=`
316
- `,e}}class gh{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 gT(){return!Mr.apple.device}function yT(r){let t=!0;const e=tt.ADAPTER.getNavigator();if(Mr.tablet||Mr.phone){if(Mr.apple.device){const i=e.userAgent.match(/OS (\d+)_(\d+)?/);i&&parseInt(i[1],10)<11&&(t=!1)}if(Mr.android.device){const i=e.userAgent.match(/Android\s([0-9.]*)/);i&&parseInt(i[1],10)<7&&(t=!1)}}return t?r:4}class _o{constructor(t){this.renderer=t}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(t){}}var _T=`varying vec2 vTextureCoord;
316
+ `,e}}class xh{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 ST(){return!Pr.apple.device}function CT(r){let t=!0;const e=tt.ADAPTER.getNavigator();if(Pr.tablet||Pr.phone){if(Pr.apple.device){const i=e.userAgent.match(/OS (\d+)_(\d+)?/);i&&parseInt(i[1],10)<11&&(t=!1)}if(Pr.android.device){const i=e.userAgent.match(/Android\s([0-9.]*)/);i&&parseInt(i[1],10)<7&&(t=!1)}}return t?r:4}class Eo{constructor(t){this.renderer=t}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(t){}}var IT=`varying vec2 vTextureCoord;
317
317
  varying vec4 vColor;
318
318
  varying float vTextureId;
319
319
  uniform sampler2D uSamplers[%count%];
@@ -323,7 +323,7 @@ void main(void){
323
323
  %forloop%
324
324
  gl_FragColor = color * vColor;
325
325
  }
326
- `,vT=`precision highp float;
326
+ `,RT=`precision highp float;
327
327
  attribute vec2 aVertexPosition;
328
328
  attribute vec2 aTextureCoord;
329
329
  attribute vec4 aColor;
@@ -344,14 +344,14 @@ void main(void){
344
344
  vTextureId = aTextureId;
345
345
  vColor = aColor * tint;
346
346
  }
347
- `;const an=class ur extends _o{constructor(t){super(t),this.setShaderGenerator(),this.geometryClass=xp,this.vertexSize=6,this.state=Er.for2d(),this.size=ur.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??yT(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??gT(),this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return St("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return vT}static get defaultFragmentTemplate(){return _T}setShaderGenerator({vertex:t=ur.defaultVertexSrc,fragment:e=ur.defaultFragmentTemplate}={}){this.shaderGenerator=new mT(t,e)}contextChange(){const t=this.renderer.gl;tt.PREFER_ENV===Ei.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),ur.defaultMaxTextures),this.maxTextures=Ww(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}=ur,i=this.size/4,s=Math.floor(i/this.maxTextures)+1;for(;t.length<i;)t.push(new uh);for(;e.length<s;)e.push(new gh);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=ur._textureArrayPool,s=this.renderer.batch,n=this._tempBoundTextures,o=this.renderer.textureGC.count;let a=++vt._globalBatch,l=0,h=i[0],u=0;s.copyBoundTextures(n,e);for(let c=0;c<this._bufferSize;++c){const d=t[c];t[c]=null,d._batchEnabled!==a&&(h.count>=e&&(s.boundArray(h,n,a,e),this.buildDrawCalls(h,u,c),u=c,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,u,this._bufferSize),++l,++a);for(let c=0;c<n.length;c++)n[c]=null;vt._globalBatch=a}buildDrawCalls(t,e,i){const{_bufferedElements:s,_attributeBuffer:n,_indexBuffer:o,vertexSize:a}=this,l=ur._drawCallPool;let h=this._dcIndex,u=this._aIndex,c=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,_=lp[m.alphaMode?1:0][p.blendMode];s[f]=null,e<f&&d.blend!==_&&(d.size=c-d.start,e=f,d=l[++h],d.texArray=t,d.start=c),this.packInterleavedGeometry(p,n,o,u,c),u+=p.vertexData.length/2*a,c+=p.indices.length,d.blend=_}e<i&&(d.size=c-d.start,++h),this._dcIndex=h,this._aIndex=u,this._iIndex=c}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;ur.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=ur._drawCallPool;let n=null;for(let o=0;o<t;o++){const{texArray:a,type:l,size:h,start:u,blend:c}=s[o];n!==a&&(n=a,this.bindAndClearTexArray(a)),this.state.blendMode=c,i.set(this.state),e.drawElements(l,h,e.UNSIGNED_SHORT,u*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),ur.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=no(Math.ceil(t/8)),i=dp(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 eh(s*this.vertexSize*4)),n}getIndexBuffer(t){const e=no(Math.ceil(t/12)),i=dp(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,u=t.indices,c=t.vertexData,d=t._texture.baseTexture._batchLocation,f=Math.min(t.worldAlpha,1),p=Ot.shared.setValue(t._tintRGB).toPremultiplied(f,t._texture.baseTexture.alphaMode>0);for(let m=0;m<c.length;m+=2)a[s++]=c[m],a[s++]=c[m+1],a[s++]=h[m],a[s++]=h[m+1],o[s++]=p,a[s++]=d;for(let m=0;m<u.length;m++)i[n++]=l+u[m]}};an.defaultBatchSize=4096,an.extension={name:"batch",type:Q.RendererPlugin},an._drawCallPool=[],an._textureArrayPool=[];let Di=an;ht.add(Di);var xT=`varying vec2 vTextureCoord;
347
+ `;const un=class ur extends Eo{constructor(t){super(t),this.setShaderGenerator(),this.geometryClass=Sp,this.vertexSize=6,this.state=Er.for2d(),this.size=ur.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??CT(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??ST(),this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return St("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return RT}static get defaultFragmentTemplate(){return IT}setShaderGenerator({vertex:t=ur.defaultVertexSrc,fragment:e=ur.defaultFragmentTemplate}={}){this.shaderGenerator=new AT(t,e)}contextChange(){const t=this.renderer.gl;tt.PREFER_ENV===Ei.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),ur.defaultMaxTextures),this.maxTextures=iT(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}=ur,i=this.size/4,s=Math.floor(i/this.maxTextures)+1;for(;t.length<i;)t.push(new ph);for(;e.length<s;)e.push(new xh);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=ur._textureArrayPool,s=this.renderer.batch,n=this._tempBoundTextures,o=this.renderer.textureGC.count;let a=++bt._globalBatch,l=0,h=i[0],u=0;s.copyBoundTextures(n,e);for(let c=0;c<this._bufferSize;++c){const d=t[c];t[c]=null,d._batchEnabled!==a&&(h.count>=e&&(s.boundArray(h,n,a,e),this.buildDrawCalls(h,u,c),u=c,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,u,this._bufferSize),++l,++a);for(let c=0;c<n.length;c++)n[c]=null;bt._globalBatch=a}buildDrawCalls(t,e,i){const{_bufferedElements:s,_attributeBuffer:n,_indexBuffer:o,vertexSize:a}=this,l=ur._drawCallPool;let h=this._dcIndex,u=this._aIndex,c=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,_=pp[m.alphaMode?1:0][p.blendMode];s[f]=null,e<f&&d.blend!==_&&(d.size=c-d.start,e=f,d=l[++h],d.texArray=t,d.start=c),this.packInterleavedGeometry(p,n,o,u,c),u+=p.vertexData.length/2*a,c+=p.indices.length,d.blend=_}e<i&&(d.size=c-d.start,++h),this._dcIndex=h,this._aIndex=u,this._iIndex=c}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;ur.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=ur._drawCallPool;let n=null;for(let o=0;o<t;o++){const{texArray:a,type:l,size:h,start:u,blend:c}=s[o];n!==a&&(n=a,this.bindAndClearTexArray(a)),this.state.blendMode=c,i.set(this.state),e.drawElements(l,h,e.UNSIGNED_SHORT,u*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),ur.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=ho(Math.ceil(t/8)),i=_p(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 nh(s*this.vertexSize*4)),n}getIndexBuffer(t){const e=ho(Math.ceil(t/12)),i=_p(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,u=t.indices,c=t.vertexData,d=t._texture.baseTexture._batchLocation,f=Math.min(t.worldAlpha,1),p=Nt.shared.setValue(t._tintRGB).toPremultiplied(f,t._texture.baseTexture.alphaMode>0);for(let m=0;m<c.length;m+=2)a[s++]=c[m],a[s++]=c[m+1],a[s++]=h[m],a[s++]=h[m+1],o[s++]=p,a[s++]=d;for(let m=0;m<u.length;m++)i[n++]=l+u[m]}};un.defaultBatchSize=4096,un.extension={name:"batch",type:Q.RendererPlugin},un._drawCallPool=[],un._textureArrayPool=[];let Di=un;ut.add(Di);var MT=`varying vec2 vTextureCoord;
348
348
 
349
349
  uniform sampler2D uSampler;
350
350
 
351
351
  void main(void){
352
352
  gl_FragColor = texture2D(uSampler, vTextureCoord);
353
353
  }
354
- `,bT=`attribute vec2 aVertexPosition;
354
+ `,PT=`attribute vec2 aVertexPosition;
355
355
 
356
356
  uniform mat3 projectionMatrix;
357
357
 
@@ -377,7 +377,7 @@ void main(void)
377
377
  gl_Position = filterVertexPosition();
378
378
  vTextureCoord = filterTextureCoord();
379
379
  }
380
- `;const yh=class gn extends wr{constructor(t,e,i){const s=Br.from(t||gn.defaultVertexSrc,e||gn.defaultFragmentSrc);super(s,i),this.padding=0,this.resolution=gn.defaultResolution,this.multisample=gn.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new Er}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 bT}static get defaultFragmentSrc(){return xT}};yh.defaultResolution=1,yh.defaultMultisample=ae.NONE;let Be=yh;class vo{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new Ot(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(){}}vo.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},vo.extension={type:[Q.RendererSystem,Q.CanvasRendererSystem],name:"background"},ht.add(vo);class Mp{constructor(t){this.renderer=t,this.emptyRenderer=new _o(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 u=n[h],c=u._batchLocation;if(c>=0&&c<s&&e[c]===u){o[h]=c;continue}for(;l<s;){const d=e[l];if(d&&d._batchEnabled===i&&d._batchLocation===l){l++;continue}o[h]=l,u._batchLocation=l,e[l]=u;break}}}destroy(){this.renderer=null}}Mp.extension={type:Q.RendererSystem,name:"batch"},ht.add(Mp);let Pp=0;class xo{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=Pp++}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=Pp++,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(tt.PREFER_ENV>=Ei.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")}}xo.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},xo.extension={type:Q.RendererSystem,name:"context"},ht.add(xo);class _h{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 ir("disposeFramebuffer"),this.multisample=ae.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new vt(null,{scaleMode:Ir.NEAREST,resolution:1,mipmap:pr.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new vt(null,{scaleMode:Ir.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:pr.OFF,format:z.DEPTH_COMPONENT,type:ft.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 Op extends vt{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=ae.NONE),super(null,t),this.mipmap=pr.OFF,this.valid=!0,this._clear=new Ot([0,0,0,0]),this.framebuffer=new _h(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 Fr extends nn{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=Vw(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===He.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 Np extends Fr{constructor(t,e){if(e=e||{},typeof t=="string"){const i=new Image;Fr.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??tt.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===He.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 vh{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=Yt.add(i,Yt.NW),this.x0=l+o*Yt.uX(i),this.y0=h+a*Yt.uY(i),i=Yt.add(i,2),this.x1=l+o*Yt.uX(i),this.y1=h+a*Yt.uY(i),i=Yt.add(i,2),this.x2=l+o*Yt.uX(i),this.y2=h+a*Yt.uY(i),i=Yt.add(i,2),this.x3=l+o*Yt.uX(i),this.y3=h+a*Yt.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}}vh.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 Dp=new vh;function bo(r){r.destroy=function(){},r.on=function(){},r.once=function(){},r.emit=function(){}}class ut extends Xs{constructor(t,e,i,s,n,o,a){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new Et(0,0,1,1)),t instanceof ut&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=s,this.valid=!1,this.destroyed=!1,this._uvs=Dp,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 It(o.x,o.y):new It(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&&br[e.url]&&ut.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,ut.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 ut(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===Dp&&(this._uvs=new vh),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},i=tt.STRICT_TEXTURE_CACHE){const s=typeof t=="string";let n=null;if(s)n=t;else if(t instanceof vt){if(!t.cacheId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${a}-${Ii()}`,vt.addToCache(t,t.cacheId)}n=t.cacheId}else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${Ii()}`}n=t._pixiId}let o=br[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!o&&!(t instanceof vt)?(e.resolution||(e.resolution=Dr(t)),o=new ut(new vt(t,e)),o.baseTexture.cacheId=n,vt.addToCache(o.baseTexture,n),ut.addToCache(o,n)):!o&&t instanceof vt&&(o=new ut(t),ut.addToCache(o,n)),o}static fromURL(t,e){const i=Object.assign({autoLoad:!1},e==null?void 0:e.resourceOptions),s=ut.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 ut(vt.fromBuffer(t,e,i,s))}static fromLoader(t,e,i,s){const n=new vt(t,Object.assign({scaleMode:vt.defaultOptions.scaleMode,resolution:Dr(e)},s)),{resource:o}=n;o instanceof Np&&(o.url=e);const a=new ut(n);return i||(i=e),vt.addToCache(a.baseTexture,i),ut.addToCache(a,i),i!==e&&(vt.addToCache(a.baseTexture,e),ut.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),br[e]&&br[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),br[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=br[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete br[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)br[t.textureCacheIds[e]]===t&&delete br[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}`,u=`Y: ${i} + ${n} = ${i+n} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${h} ${l} ${u}`)}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 ut._EMPTY||(ut._EMPTY=new ut(new vt),bo(ut._EMPTY),bo(ut._EMPTY.baseTexture)),ut._EMPTY}static get WHITE(){if(!ut._WHITE){const t=tt.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),ut._WHITE=new ut(vt.from(t)),bo(ut._WHITE),bo(ut._WHITE.baseTexture)}return ut._WHITE}}class Li extends ut{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 Li(new Op(t))}}class Lp{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,i=ae.NONE){const s=new Op(Object.assign({width:t,height:e,resolution:1,multisample:i},this.textureOptions));return new Li(s)}getOptimalTexture(t,e,i=1,s=ae.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=no(t),e=no(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||ae.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}}}Lp.SCREEN_KEY=-1;class ET extends si{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class Bp extends si{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 te(this.vertices),this.uvBuffer=new te(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 wT{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=ae.NONE,this.sourceFrame=new Et,this.destinationFrame=new Et,this.bindingSourceFrame=new Et,this.bindingDestinationFrame=new Et,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const Eo=[new It,new It,new It,new It],xh=new Ut;class Fp{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new Lp,this.statePool=[],this.quad=new ET,this.quadUv=new Bp,this.tempRect=new Et,this.activeState={},this.globalUniforms=new sr({outputFrame:new Et,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 wT,o=i.renderTexture;let a,l;if(o.current){const _=o.current;a=_.resolution,l=_.multisample}else a=i.resolution,l=i.multisample;let h=e[0].resolution||a,u=e[0].multisample??l,c=e[0].padding,d=e[0].autoFit,f=e[0].legacy??!0;for(let _=1;_<e.length;_++){const y=e[_];h=Math.min(h,y.resolution||a),u=Math.min(u,y.multisample??l),c=this.useMaxPadding?Math.max(c,y.padding):c+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=u,n.legacy=f,n.target=t,n.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),n.sourceFrame.pad(c);const p=this.tempRect.copyFrom(o.sourceFrame);i.projection.transform&&this.transformAABB(xh.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,u),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,mr.BLEND,e),this.returnFilterTexture(e.renderTexture);else{let h=e.renderTexture,u=this.getOptimalFilterTexture(h.width,h.height,e.resolution);u.filterFrame=h.filterFrame;let c=0;for(c=0;c<i.length-1;++c){c===1&&e.multisample>1&&(u=this.getOptimalFilterTexture(h.width,h.height,e.resolution),u.filterFrame=h.filterFrame),i[c].apply(this,h,u,mr.CLEAR,e);const d=h;h=u,u=d}i[c].apply(this,h,l.renderTexture,mr.BLEND,e),c>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(h),this.returnFilterTexture(u)}e.clear(),this.statePool.push(e)}bindAndClear(t,e=mr.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===mr.CLEAR||e===mr.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(fr.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(fr.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(Ut.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=ae.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||ae.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=Eo[0],s=Eo[1],n=Eo[2],o=Eo[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),u=Math.max(i.y,s.y,n.y,o.y);e.x=a,e.y=l,e.width=h-a,e.height=u-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?xh.copyFrom(n):xh.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)}}}Fp.extension={type:Q.RendererSystem,name:"filter"},ht.add(Fp);class TT{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=ae.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const AT=new Et;class kp{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new _h(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 Et,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let e=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;tt.PREFER_ENV===Ei.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=ol.COLOR|ol.DEPTH){const{gl:o}=this;o.clearColor(t,e,i,s),o.clear(n)}initFramebuffer(t){const{gl:e}=this,i=new TT(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],u=h.parentTextureArray||h;this.renderer.texture.bind(u,0),l===0&&s.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,s.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,u._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,u._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=ae.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=ae.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 u=s.colorTextures[0];if(!u)return;l.blitFramebuffer||(l.blitFramebuffer=new _h(s.width,s.height),l.blitFramebuffer.addColorTexture(0,u)),t=l.blitFramebuffer,t.colorTextures[0]!==u&&(t.colorTextures[0]=u,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=AT,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 Et}destroy(){this.renderer=null}}kp.extension={type:Q.RendererSystem,name:"framebuffer"},ht.add(kp);const bh={5126:4,5123:2,5121:1};class Up{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;tt.PREFER_ENV===Ei.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 u=h[l];if(u)return h[a.id]=u,u;const c=t.buffers,d=t.attributes,f={},p={};for(const m in c)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*bh[d[m].type];for(const m in d){const _=d[m],y=_.size;_.stride===void 0&&(f[_.buffer]===y*bh[_.type]?_.stride=0:_.stride=f[_.buffer]),_.start===void 0&&(_.start=p[_.buffer],p[_.buffer]+=y*bh[_.type])}u=s.createVertexArray(),s.bindVertexArray(u);for(let m=0;m<c.length;m++){const _=c[m];o.bind(_),i&&_._glBuffers[n].refCount++}return this.activateVao(t,a),h[a.id]=u,h[l]=u,s.bindVertexArray(null),o.unbind(gr.ARRAY_BUFFER),u}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 u=a[h],c=o[u.buffer],d=c._glBuffers[s];if(e.attributeData[h]){l!==d&&(n.bind(c),l=d);const f=e.attributeData[h].location;if(i.enableVertexAttribArray(f),i.vertexAttribPointer(f,u.size,u.type||i.FLOAT,u.normalized,u.stride,u.start),u.instance)if(this.hasInstance)i.vertexAttribDivisor(f,u.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}}Up.extension={type:Q.RendererSystem,name:"geometry"},ht.add(Up);const Gp=new Ut;class Hp{constructor(t,e){this._texture=t,this.mapCoord=new Ut,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&&(Gp.set(s.width/n.width,0,0,s.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(Gp));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 ST=`varying vec2 vMaskCoord;
380
+ `;const bh=class vn extends wr{constructor(t,e,i){const s=Fr.from(t||vn.defaultVertexSrc,e||vn.defaultFragmentSrc);super(s,i),this.padding=0,this.resolution=vn.defaultResolution,this.multisample=vn.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new Er}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 PT}static get defaultFragmentSrc(){return MT}};bh.defaultResolution=1,bh.defaultMultisample=le.NONE;let Be=bh;class wo{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new Nt(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(){}}wo.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},wo.extension={type:[Q.RendererSystem,Q.CanvasRendererSystem],name:"background"},ut.add(wo);class Bp{constructor(t){this.renderer=t,this.emptyRenderer=new Eo(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 u=n[h],c=u._batchLocation;if(c>=0&&c<s&&e[c]===u){o[h]=c;continue}for(;l<s;){const d=e[l];if(d&&d._batchEnabled===i&&d._batchLocation===l){l++;continue}o[h]=l,u._batchLocation=l,e[l]=u;break}}}destroy(){this.renderer=null}}Bp.extension={type:Q.RendererSystem,name:"batch"},ut.add(Bp);let Fp=0;class To{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=Fp++}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=Fp++,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(tt.PREFER_ENV>=Ei.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")}}To.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},To.extension={type:Q.RendererSystem,name:"context"},ut.add(To);class Eh{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 ir("disposeFramebuffer"),this.multisample=le.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new bt(null,{scaleMode:Rr.NEAREST,resolution:1,mipmap:pr.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new bt(null,{scaleMode:Rr.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:pr.OFF,format:j.DEPTH_COMPONENT,type:ft.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 kp extends bt{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=le.NONE),super(null,t),this.mipmap=pr.OFF,this.valid=!0,this._clear=new Nt([0,0,0,0]),this.framebuffer=new Eh(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 kr extends ln{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=tT(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===$e.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 Up extends kr{constructor(t,e){if(e=e||{},typeof t=="string"){const i=new Image;kr.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??tt.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===$e.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 wh{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=Wt.add(i,Wt.NW),this.x0=l+o*Wt.uX(i),this.y0=h+a*Wt.uY(i),i=Wt.add(i,2),this.x1=l+o*Wt.uX(i),this.y1=h+a*Wt.uY(i),i=Wt.add(i,2),this.x2=l+o*Wt.uX(i),this.y2=h+a*Wt.uY(i),i=Wt.add(i,2),this.x3=l+o*Wt.uX(i),this.y3=h+a*Wt.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}}wh.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 Gp=new wh;function Ao(r){r.destroy=function(){},r.on=function(){},r.once=function(){},r.emit=function(){}}class ct extends Ys{constructor(t,e,i,s,n,o,a){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new wt(0,0,1,1)),t instanceof ct&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=s,this.valid=!1,this.destroyed=!1,this._uvs=Gp,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 It(o.x,o.y):new It(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&&br[e.url]&&ct.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,ct.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 ct(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===Gp&&(this._uvs=new wh),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},i=tt.STRICT_TEXTURE_CACHE){const s=typeof t=="string";let n=null;if(s)n=t;else if(t instanceof bt){if(!t.cacheId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${a}-${Ii()}`,bt.addToCache(t,t.cacheId)}n=t.cacheId}else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${Ii()}`}n=t._pixiId}let o=br[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!o&&!(t instanceof bt)?(e.resolution||(e.resolution=Lr(t)),o=new ct(new bt(t,e)),o.baseTexture.cacheId=n,bt.addToCache(o.baseTexture,n),ct.addToCache(o,n)):!o&&t instanceof bt&&(o=new ct(t),ct.addToCache(o,n)),o}static fromURL(t,e){const i=Object.assign({autoLoad:!1},e==null?void 0:e.resourceOptions),s=ct.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 ct(bt.fromBuffer(t,e,i,s))}static fromLoader(t,e,i,s){const n=new bt(t,Object.assign({scaleMode:bt.defaultOptions.scaleMode,resolution:Lr(e)},s)),{resource:o}=n;o instanceof Up&&(o.url=e);const a=new ct(n);return i||(i=e),bt.addToCache(a.baseTexture,i),ct.addToCache(a,i),i!==e&&(bt.addToCache(a.baseTexture,e),ct.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),br[e]&&br[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),br[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=br[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete br[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)br[t.textureCacheIds[e]]===t&&delete br[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}`,u=`Y: ${i} + ${n} = ${i+n} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${h} ${l} ${u}`)}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 ct._EMPTY||(ct._EMPTY=new ct(new bt),Ao(ct._EMPTY),Ao(ct._EMPTY.baseTexture)),ct._EMPTY}static get WHITE(){if(!ct._WHITE){const t=tt.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),ct._WHITE=new ct(bt.from(t)),Ao(ct._WHITE),Ao(ct._WHITE.baseTexture)}return ct._WHITE}}class Li extends ct{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 Li(new kp(t))}}class $p{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,i=le.NONE){const s=new kp(Object.assign({width:t,height:e,resolution:1,multisample:i},this.textureOptions));return new Li(s)}getOptimalTexture(t,e,i=1,s=le.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=ho(t),e=ho(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||le.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}}}$p.SCREEN_KEY=-1;class OT extends si{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class Hp extends si{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 se(this.vertices),this.uvBuffer=new se(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 NT{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=le.NONE,this.sourceFrame=new wt,this.destinationFrame=new wt,this.bindingSourceFrame=new wt,this.bindingDestinationFrame=new wt,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const So=[new It,new It,new It,new It],Th=new Gt;class Xp{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new $p,this.statePool=[],this.quad=new OT,this.quadUv=new Hp,this.tempRect=new wt,this.activeState={},this.globalUniforms=new sr({outputFrame:new wt,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 NT,o=i.renderTexture;let a,l;if(o.current){const _=o.current;a=_.resolution,l=_.multisample}else a=i.resolution,l=i.multisample;let h=e[0].resolution||a,u=e[0].multisample??l,c=e[0].padding,d=e[0].autoFit,f=e[0].legacy??!0;for(let _=1;_<e.length;_++){const y=e[_];h=Math.min(h,y.resolution||a),u=Math.min(u,y.multisample??l),c=this.useMaxPadding?Math.max(c,y.padding):c+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=u,n.legacy=f,n.target=t,n.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),n.sourceFrame.pad(c);const p=this.tempRect.copyFrom(o.sourceFrame);i.projection.transform&&this.transformAABB(Th.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,u),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,mr.BLEND,e),this.returnFilterTexture(e.renderTexture);else{let h=e.renderTexture,u=this.getOptimalFilterTexture(h.width,h.height,e.resolution);u.filterFrame=h.filterFrame;let c=0;for(c=0;c<i.length-1;++c){c===1&&e.multisample>1&&(u=this.getOptimalFilterTexture(h.width,h.height,e.resolution),u.filterFrame=h.filterFrame),i[c].apply(this,h,u,mr.CLEAR,e);const d=h;h=u,u=d}i[c].apply(this,h,l.renderTexture,mr.BLEND,e),c>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(h),this.returnFilterTexture(u)}e.clear(),this.statePool.push(e)}bindAndClear(t,e=mr.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===mr.CLEAR||e===mr.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(fr.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(fr.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(Gt.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=le.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||le.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=So[0],s=So[1],n=So[2],o=So[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),u=Math.max(i.y,s.y,n.y,o.y);e.x=a,e.y=l,e.width=h-a,e.height=u-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?Th.copyFrom(n):Th.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)}}}Xp.extension={type:Q.RendererSystem,name:"filter"},ut.add(Xp);class DT{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=le.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const LT=new wt;class Vp{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new Eh(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 wt,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let e=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;tt.PREFER_ENV===Ei.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=ol.COLOR|ol.DEPTH){const{gl:o}=this;o.clearColor(t,e,i,s),o.clear(n)}initFramebuffer(t){const{gl:e}=this,i=new DT(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],u=h.parentTextureArray||h;this.renderer.texture.bind(u,0),l===0&&s.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,s.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,u._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,u._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=le.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=le.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 u=s.colorTextures[0];if(!u)return;l.blitFramebuffer||(l.blitFramebuffer=new Eh(s.width,s.height),l.blitFramebuffer.addColorTexture(0,u)),t=l.blitFramebuffer,t.colorTextures[0]!==u&&(t.colorTextures[0]=u,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=LT,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 wt}destroy(){this.renderer=null}}Vp.extension={type:Q.RendererSystem,name:"framebuffer"},ut.add(Vp);const Ah={5126:4,5123:2,5121:1};class zp{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;tt.PREFER_ENV===Ei.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 u=h[l];if(u)return h[a.id]=u,u;const c=t.buffers,d=t.attributes,f={},p={};for(const m in c)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*Ah[d[m].type];for(const m in d){const _=d[m],y=_.size;_.stride===void 0&&(f[_.buffer]===y*Ah[_.type]?_.stride=0:_.stride=f[_.buffer]),_.start===void 0&&(_.start=p[_.buffer],p[_.buffer]+=y*Ah[_.type])}u=s.createVertexArray(),s.bindVertexArray(u);for(let m=0;m<c.length;m++){const _=c[m];o.bind(_),i&&_._glBuffers[n].refCount++}return this.activateVao(t,a),h[a.id]=u,h[l]=u,s.bindVertexArray(null),o.unbind(gr.ARRAY_BUFFER),u}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 u=a[h],c=o[u.buffer],d=c._glBuffers[s];if(e.attributeData[h]){l!==d&&(n.bind(c),l=d);const f=e.attributeData[h].location;if(i.enableVertexAttribArray(f),i.vertexAttribPointer(f,u.size,u.type||i.FLOAT,u.normalized,u.stride,u.start),u.instance)if(this.hasInstance)i.vertexAttribDivisor(f,u.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}}zp.extension={type:Q.RendererSystem,name:"geometry"},ut.add(zp);const Yp=new Gt;class jp{constructor(t,e){this._texture=t,this.mapCoord=new Gt,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&&(Yp.set(s.width/n.width,0,0,s.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(Yp));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 BT=`varying vec2 vMaskCoord;
381
381
  varying vec2 vTextureCoord;
382
382
 
383
383
  uniform sampler2D uSampler;
@@ -402,7 +402,7 @@ void main(void)
402
402
 
403
403
  gl_FragColor = original;
404
404
  }
405
- `,CT=`attribute vec2 aVertexPosition;
405
+ `,FT=`attribute vec2 aVertexPosition;
406
406
  attribute vec2 aTextureCoord;
407
407
 
408
408
  uniform mat3 projectionMatrix;
@@ -418,7 +418,7 @@ void main(void)
418
418
  vTextureCoord = aTextureCoord;
419
419
  vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;
420
420
  }
421
- `;class IT extends Be{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||CT,e||ST,i),this.maskSprite=s,this.maskMatrix=new Ut}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 Hp(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 RT{constructor(t=null){this.type=he.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=Be.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=he.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 $p{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 RT;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!==he.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case he.SCISSOR:this.renderer.scissor.push(i);break;case he.STENCIL:this.renderer.stencil.push(i);break;case he.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case he.COLOR:this.pushColorMask(i);break}i.type===he.SPRITE&&this.maskStack.push(i)}pop(t){const e=this.maskStack.pop();if(!(!e||e._target!==t)){if(e.enabled)switch(e.type){case he.SCISSOR:this.renderer.scissor.pop(e);break;case he.STENCIL:this.renderer.stencil.pop(e.maskObject);break;case he.SPRITE:this.popSpriteMask(e);break;case he.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===he.SPRITE&&i._filters&&(i._filters[0].maskSprite=i.maskObject)}}}detect(t){const e=t.maskObject;e?e.isSprite?t.type=he.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=he.SCISSOR:t.type=he.STENCIL:t.type=he.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 IT])),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}}$p.extension={type:Q.RendererSystem,name:"mask"},ht.add($p);class Xp{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 Vp=new Ut,zp=[],Yp=class Zo extends Xp{constructor(t){super(t),this.glConst=tt.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,zp.pop()??new Et);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()||Zo.isMatrixRotated(e.worldTransform)||Zo.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){Zo.isMatrixRotated(n)||(n=n?Vp.copyFrom(n):Vp.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&&zp.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)}};Yp.extension={type:Q.RendererSystem,name:"scissor"};let MT=Yp;ht.add(MT);class Wp extends Xp{constructor(t){super(t),this.glConst=tt.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)}}Wp.extension={type:Q.RendererSystem,name:"stencil"},ht.add(Wp);class jp{constructor(t){this.renderer=t,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get(){return St("7.0.0","renderer.plugins.extract has moved to renderer.extract"),t.extract}},prepare:{enumerable:!1,get(){return St("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),t.prepare}},interaction:{enumerable:!1,get(){return St("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}}jp.extension={type:[Q.RendererSystem,Q.CanvasRendererSystem],name:"_plugin"},ht.add(jp);class qp{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new Ut,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}}qp.extension={type:Q.RendererSystem,name:"projection"},ht.add(qp);const PT=new fh,Kp=new Et;class Zp{constructor(t){this.renderer=t,this._tempMatrix=new Ut}generateTexture(t,e){const{region:i,...s}=e||{},n=(i==null?void 0:i.copyTo(Kp))||t.getLocalBounds(Kp,!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=Li.create(s);this._tempMatrix.tx=-n.x,this._tempMatrix.ty=-n.y;const l=t.transform;return t.transform=PT,this.renderer.render(t,{renderTexture:a,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=l,a}destroy(){}}Zp.extension={type:[Q.RendererSystem,Q.CanvasRendererSystem],name:"textureGenerator"},ht.add(Zp);const Bi=new Et,ln=new Et;class Qp{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new Et,this.destinationFrame=new Et,this.viewportFrame=new Et}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||(Bi.width=t.frame.width,Bi.height=t.frame.height,e=Bi),i||(ln.x=t.frame.x,ln.y=t.frame.y,ln.width=e.width,ln.height=e.height,i=ln),o=n.framebuffer):(a=s.resolution,e||(Bi.width=s._view.screen.width,Bi.height=s._view.screen.height,e=Bi),i||(i=Bi,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=Ot.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:u,height:c}=this.viewportFrame;l=Math.round(l),h=Math.round(h),u=Math.round(u),c=Math.round(c),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(l,h,u,c)}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}}Qp.extension={type:Q.RendererSystem,name:"renderTexture"},ht.add(Qp);class OT{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 NT(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=Ip(t,n.type),a={type:o,name:n.name,size:Sp(o),location:t.getAttribLocation(r,n.name)};e[n.name]=a}return e}function DT(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=Ip(t,n.type);e[o]={name:o,index:s,type:l,size:n.size,isArray:a,value:wp(l,n.size)}}return e}function LT(r,t){var a;const e=Ep(r,r.VERTEX_SHADER,t.vertexSrc),i=Ep(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)||uT(r,s,e,i),t.attributeData=NT(s,r),t.uniformData=DT(s,r),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertexSrc)){const l=Object.keys(t.attributeData);l.sort((h,u)=>h>u?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:wp(h.type,h.size)}}return new OT(s,o)}function BT(r,t,e,i,s){e.buffer.update(s)}const FT={float:`
421
+ `;class kT extends Be{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||FT,e||BT,i),this.maskSprite=s,this.maskMatrix=new Gt}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 jp(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 UT{constructor(t=null){this.type=ce.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=Be.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=ce.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 Wp{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 UT;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!==ce.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case ce.SCISSOR:this.renderer.scissor.push(i);break;case ce.STENCIL:this.renderer.stencil.push(i);break;case ce.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case ce.COLOR:this.pushColorMask(i);break}i.type===ce.SPRITE&&this.maskStack.push(i)}pop(t){const e=this.maskStack.pop();if(!(!e||e._target!==t)){if(e.enabled)switch(e.type){case ce.SCISSOR:this.renderer.scissor.pop(e);break;case ce.STENCIL:this.renderer.stencil.pop(e.maskObject);break;case ce.SPRITE:this.popSpriteMask(e);break;case ce.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===ce.SPRITE&&i._filters&&(i._filters[0].maskSprite=i.maskObject)}}}detect(t){const e=t.maskObject;e?e.isSprite?t.type=ce.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=ce.SCISSOR:t.type=ce.STENCIL:t.type=ce.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 kT])),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}}Wp.extension={type:Q.RendererSystem,name:"mask"},ut.add(Wp);class qp{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 Kp=new Gt,Zp=[],Qp=class ta extends qp{constructor(t){super(t),this.glConst=tt.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,Zp.pop()??new wt);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()||ta.isMatrixRotated(e.worldTransform)||ta.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){ta.isMatrixRotated(n)||(n=n?Kp.copyFrom(n):Kp.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&&Zp.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)}};Qp.extension={type:Q.RendererSystem,name:"scissor"};let GT=Qp;ut.add(GT);class Jp extends qp{constructor(t){super(t),this.glConst=tt.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)}}Jp.extension={type:Q.RendererSystem,name:"stencil"},ut.add(Jp);class tm{constructor(t){this.renderer=t,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get(){return St("7.0.0","renderer.plugins.extract has moved to renderer.extract"),t.extract}},prepare:{enumerable:!1,get(){return St("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),t.prepare}},interaction:{enumerable:!1,get(){return St("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}}tm.extension={type:[Q.RendererSystem,Q.CanvasRendererSystem],name:"_plugin"},ut.add(tm);class em{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new Gt,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}}em.extension={type:Q.RendererSystem,name:"projection"},ut.add(em);const $T=new yh,rm=new wt;class im{constructor(t){this.renderer=t,this._tempMatrix=new Gt}generateTexture(t,e){const{region:i,...s}=e||{},n=(i==null?void 0:i.copyTo(rm))||t.getLocalBounds(rm,!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=Li.create(s);this._tempMatrix.tx=-n.x,this._tempMatrix.ty=-n.y;const l=t.transform;return t.transform=$T,this.renderer.render(t,{renderTexture:a,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=l,a}destroy(){}}im.extension={type:[Q.RendererSystem,Q.CanvasRendererSystem],name:"textureGenerator"},ut.add(im);const Bi=new wt,cn=new wt;class sm{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new wt,this.destinationFrame=new wt,this.viewportFrame=new wt}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||(Bi.width=t.frame.width,Bi.height=t.frame.height,e=Bi),i||(cn.x=t.frame.x,cn.y=t.frame.y,cn.width=e.width,cn.height=e.height,i=cn),o=n.framebuffer):(a=s.resolution,e||(Bi.width=s._view.screen.width,Bi.height=s._view.screen.height,e=Bi),i||(i=Bi,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=Nt.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:u,height:c}=this.viewportFrame;l=Math.round(l),h=Math.round(h),u=Math.round(u),c=Math.round(c),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(l,h,u,c)}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}}sm.extension={type:Q.RendererSystem,name:"renderTexture"},ut.add(sm);class HT{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 XT(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=Dp(t,n.type),a={type:o,name:n.name,size:Op(o),location:t.getAttribLocation(r,n.name)};e[n.name]=a}return e}function VT(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=Dp(t,n.type);e[o]={name:o,index:s,type:l,size:n.size,isArray:a,value:Rp(l,n.size)}}return e}function zT(r,t){var a;const e=Ip(r,r.VERTEX_SHADER,t.vertexSrc),i=Ip(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)||xT(r,s,e,i),t.attributeData=XT(s,r),t.uniformData=VT(s,r),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertexSrc)){const l=Object.keys(t.attributeData);l.sort((h,u)=>h>u?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:Rp(h.type,h.size)}}return new HT(s,o)}function YT(r,t,e,i,s){e.buffer.update(s)}const jT={float:`
422
422
  data[offset] = v;
423
423
  `,vec2:`
424
424
  data[offset] = v[0];
@@ -456,7 +456,7 @@ void main(void)
456
456
  {
457
457
  data[offset + i] = v[i];
458
458
  }
459
- `},Jp={float:4,vec2:8,vec3:12,vec4:16,int:4,ivec2:8,ivec3:12,ivec4:16,uint:4,uvec2:8,uvec3:12,uvec4:16,bool:4,bvec2:8,bvec3:12,bvec4:16,mat2:16*2,mat3:16*3,mat4:16*4};function kT(r){const t=r.map(n=>({data:n,offset:0,dataLen:0,dirty:0}));let e=0,i=0,s=0;for(let n=0;n<t.length;n++){const o=t[n];if(e=Jp[o.data.type],o.data.size>1&&(e=Math.max(e,16)*o.data.size),o.dataLen=e,i%e!==0&&i<16){const a=i%e%16;i+=a,s+=a}i+e>16?(s=Math.ceil(s/16)*16,o.offset=s,s+=e,i=e):(o.offset=s,i+=e,s+=e)}return s=Math.ceil(s/16)*16,{uboElements:t,size:s}}function UT(r,t){const e=[];for(const i in r)t[i]&&e.push(t[i]);return e.sort((i,s)=>i.index-s.index),e}function GT(r,t){if(!r.autoManage)return{size:0,syncFunc:BT};const e=UT(r.uniforms,t),{uboElements:i,size:s}=kT(e),n=[`
459
+ `},nm={float:4,vec2:8,vec3:12,vec4:16,int:4,ivec2:8,ivec3:12,ivec4:16,uint:4,uvec2:8,uvec3:12,uvec4:16,bool:4,bvec2:8,bvec3:12,bvec4:16,mat2:16*2,mat3:16*3,mat4:16*4};function WT(r){const t=r.map(n=>({data:n,offset:0,dataLen:0,dirty:0}));let e=0,i=0,s=0;for(let n=0;n<t.length;n++){const o=t[n];if(e=nm[o.data.type],o.data.size>1&&(e=Math.max(e,16)*o.data.size),o.dataLen=e,i%e!==0&&i<16){const a=i%e%16;i+=a,s+=a}i+e>16?(s=Math.ceil(s/16)*16,o.offset=s,s+=e,i=e):(o.offset=s,i+=e,s+=e)}return s=Math.ceil(s/16)*16,{uboElements:t,size:s}}function qT(r,t){const e=[];for(const i in r)t[i]&&e.push(t[i]);return e.sort((i,s)=>i.index-s.index),e}function KT(r,t){if(!r.autoManage)return{size:0,syncFunc:YT};const e=qT(r.uniforms,t),{uboElements:i,size:s}=WT(e),n=[`
460
460
  var v = null;
461
461
  var v2 = null;
462
462
  var cv = null;
@@ -464,7 +464,7 @@ void main(void)
464
464
  var gl = renderer.gl
465
465
  var index = 0;
466
466
  var data = buffer.data;
467
- `];for(let o=0;o<i.length;o++){const a=i[o],l=r.uniforms[a.data.name],h=a.data.name;let u=!1;for(let c=0;c<ms.length;c++){const d=ms[c];if(d.codeUbo&&d.test(a.data,l)){n.push(`offset = ${a.offset/4};`,ms[c].codeUbo(a.data.name,l)),u=!0;break}}if(!u)if(a.data.size>1){const c=Sp(a.data.type),d=Math.max(Jp[a.data.type]/16,1),f=c/d,p=(4-f%4)%4;n.push(`
467
+ `];for(let o=0;o<i.length;o++){const a=i[o],l=r.uniforms[a.data.name],h=a.data.name;let u=!1;for(let c=0;c<gs.length;c++){const d=gs[c];if(d.codeUbo&&d.test(a.data,l)){n.push(`offset = ${a.offset/4};`,gs[c].codeUbo(a.data.name,l)),u=!0;break}}if(!u)if(a.data.size>1){const c=Op(a.data.type),d=Math.max(nm[a.data.type]/16,1),f=c/d,p=(4-f%4)%4;n.push(`
468
468
  cv = ud.${h}.value;
469
469
  v = uv.${h};
470
470
  offset = ${a.offset/4};
@@ -480,7 +480,7 @@ void main(void)
480
480
  offset += ${p};
481
481
  }
482
482
 
483
- `)}else{const c=FT[a.data.type];n.push(`
483
+ `)}else{const c=jT[a.data.type];n.push(`
484
484
  cv = ud.${h}.value;
485
485
  v = uv.${h};
486
486
  offset = ${a.offset/4};
@@ -488,7 +488,7 @@ void main(void)
488
488
  `)}}return n.push(`
489
489
  renderer.buffer.update(buffer);
490
490
  `),{size:s,syncFunc:new Function("ud","uv","renderer","syncData","buffer",n.join(`
491
- `))}}let HT=0;const wo={textureCount:0,uboCount:0};class tm{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=HT++}systemCheck(){if(!dT())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||(wo.textureCount=0,wo.uboCount=0,this.syncUniformGroup(t.uniformGroup,wo)),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]=aT(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,wo,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]=GT(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=LT(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}}tm.extension={type:Q.RendererSystem,name:"shader"},ht.add(tm);class To{constructor(t){this.renderer=t}run(t){const{renderer:e}=this;e.runners.init.emit(e.options),t.hello&&console.log(`PixiJS 7.4.3 - ${e.rendererLogId} - https://pixijs.com`),e.resize(e.screen.width,e.screen.height)}destroy(){}}To.defaultOptions={hello:!1},To.extension={type:[Q.RendererSystem,Q.CanvasRendererSystem],name:"startup"},ht.add(To);function $T(r,t=[]){return t[yt.NORMAL]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.ADD]=[r.ONE,r.ONE],t[yt.MULTIPLY]=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.SCREEN]=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.OVERLAY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.DARKEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.LIGHTEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.COLOR_DODGE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.COLOR_BURN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.HARD_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.SOFT_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.DIFFERENCE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.EXCLUSION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.HUE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.SATURATION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.COLOR]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.LUMINOSITY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.NONE]=[0,0],t[yt.NORMAL_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.ADD_NPM]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t[yt.SCREEN_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.SRC_IN]=[r.DST_ALPHA,r.ZERO],t[yt.SRC_OUT]=[r.ONE_MINUS_DST_ALPHA,r.ZERO],t[yt.SRC_ATOP]=[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[yt.DST_OVER]=[r.ONE_MINUS_DST_ALPHA,r.ONE],t[yt.DST_IN]=[r.ZERO,r.SRC_ALPHA],t[yt.DST_OUT]=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],t[yt.DST_ATOP]=[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],t[yt.XOR]=[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[yt.SUBTRACT]=[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD],t}const XT=0,VT=1,zT=2,YT=3,WT=4,jT=5,em=class iu{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=yt.NONE,this._blendEq=!1,this.map=[],this.map[XT]=this.setBlend,this.map[VT]=this.setOffset,this.map[zT]=this.setCullFace,this.map[YT]=this.setDepthTest,this.map[WT]=this.setFrontFace,this.map[jT]=this.setDepthMask,this.checks=[],this.defaultState=new Er,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=$T(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(iu.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(iu.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}};em.extension={type:Q.RendererSystem,name:"state"};let qT=em;ht.add(qT);class KT extends Xs{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 ir(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 hn=class Qo{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=Qo.defaultMaxIdle,this.checkCountMax=Qo.defaultCheckCountMax,this.mode=Qo.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==al.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}};hn.defaultMode=al.AUTO,hn.defaultMaxIdle=60*60,hn.defaultCheckCountMax=60*10,hn.extension={type:Q.RendererSystem,name:"textureGC"};let Fi=hn;ht.add(Fi);class Eh{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=ft.UNSIGNED_BYTE,this.internalFormat=z.RGBA,this.samplerType=0}}function ZT(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[r.RGB]:J.FLOAT,[r.RGBA]:J.FLOAT,[r.ALPHA]:J.FLOAT,[r.LUMINANCE]:J.FLOAT,[r.LUMINANCE_ALPHA]:J.FLOAT,[r.R8]:J.FLOAT,[r.R8_SNORM]:J.FLOAT,[r.RG8]:J.FLOAT,[r.RG8_SNORM]:J.FLOAT,[r.RGB8]:J.FLOAT,[r.RGB8_SNORM]:J.FLOAT,[r.RGB565]:J.FLOAT,[r.RGBA4]:J.FLOAT,[r.RGB5_A1]:J.FLOAT,[r.RGBA8]:J.FLOAT,[r.RGBA8_SNORM]:J.FLOAT,[r.RGB10_A2]:J.FLOAT,[r.RGB10_A2UI]:J.FLOAT,[r.SRGB8]:J.FLOAT,[r.SRGB8_ALPHA8]:J.FLOAT,[r.R16F]:J.FLOAT,[r.RG16F]:J.FLOAT,[r.RGB16F]:J.FLOAT,[r.RGBA16F]:J.FLOAT,[r.R32F]:J.FLOAT,[r.RG32F]:J.FLOAT,[r.RGB32F]:J.FLOAT,[r.RGBA32F]:J.FLOAT,[r.R11F_G11F_B10F]:J.FLOAT,[r.RGB9_E5]:J.FLOAT,[r.R8I]:J.INT,[r.R8UI]:J.UINT,[r.R16I]:J.INT,[r.R16UI]:J.UINT,[r.R32I]:J.INT,[r.R32UI]:J.UINT,[r.RG8I]:J.INT,[r.RG8UI]:J.UINT,[r.RG16I]:J.INT,[r.RG16UI]:J.UINT,[r.RG32I]:J.INT,[r.RG32UI]:J.UINT,[r.RGB8I]:J.INT,[r.RGB8UI]:J.UINT,[r.RGB16I]:J.INT,[r.RGB16UI]:J.UINT,[r.RGB32I]:J.INT,[r.RGB32UI]:J.UINT,[r.RGBA8I]:J.INT,[r.RGBA8UI]:J.UINT,[r.RGBA16I]:J.INT,[r.RGBA16UI]:J.UINT,[r.RGBA32I]:J.INT,[r.RGBA32UI]:J.UINT,[r.DEPTH_COMPONENT16]:J.FLOAT,[r.DEPTH_COMPONENT24]:J.FLOAT,[r.DEPTH_COMPONENT32F]:J.FLOAT,[r.DEPTH_STENCIL]:J.FLOAT,[r.DEPTH24_STENCIL8]:J.FLOAT,[r.DEPTH32F_STENCIL8]:J.FLOAT}:t={[r.RGB]:J.FLOAT,[r.RGBA]:J.FLOAT,[r.ALPHA]:J.FLOAT,[r.LUMINANCE]:J.FLOAT,[r.LUMINANCE_ALPHA]:J.FLOAT,[r.DEPTH_STENCIL]:J.FLOAT},t}function QT(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[ft.UNSIGNED_BYTE]:{[z.RGBA]:r.RGBA8,[z.RGB]:r.RGB8,[z.RG]:r.RG8,[z.RED]:r.R8,[z.RGBA_INTEGER]:r.RGBA8UI,[z.RGB_INTEGER]:r.RGB8UI,[z.RG_INTEGER]:r.RG8UI,[z.RED_INTEGER]:r.R8UI,[z.ALPHA]:r.ALPHA,[z.LUMINANCE]:r.LUMINANCE,[z.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[ft.BYTE]:{[z.RGBA]:r.RGBA8_SNORM,[z.RGB]:r.RGB8_SNORM,[z.RG]:r.RG8_SNORM,[z.RED]:r.R8_SNORM,[z.RGBA_INTEGER]:r.RGBA8I,[z.RGB_INTEGER]:r.RGB8I,[z.RG_INTEGER]:r.RG8I,[z.RED_INTEGER]:r.R8I},[ft.UNSIGNED_SHORT]:{[z.RGBA_INTEGER]:r.RGBA16UI,[z.RGB_INTEGER]:r.RGB16UI,[z.RG_INTEGER]:r.RG16UI,[z.RED_INTEGER]:r.R16UI,[z.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[ft.SHORT]:{[z.RGBA_INTEGER]:r.RGBA16I,[z.RGB_INTEGER]:r.RGB16I,[z.RG_INTEGER]:r.RG16I,[z.RED_INTEGER]:r.R16I},[ft.UNSIGNED_INT]:{[z.RGBA_INTEGER]:r.RGBA32UI,[z.RGB_INTEGER]:r.RGB32UI,[z.RG_INTEGER]:r.RG32UI,[z.RED_INTEGER]:r.R32UI,[z.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[ft.INT]:{[z.RGBA_INTEGER]:r.RGBA32I,[z.RGB_INTEGER]:r.RGB32I,[z.RG_INTEGER]:r.RG32I,[z.RED_INTEGER]:r.R32I},[ft.FLOAT]:{[z.RGBA]:r.RGBA32F,[z.RGB]:r.RGB32F,[z.RG]:r.RG32F,[z.RED]:r.R32F,[z.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[ft.HALF_FLOAT]:{[z.RGBA]:r.RGBA16F,[z.RGB]:r.RGB16F,[z.RG]:r.RG16F,[z.RED]:r.R16F},[ft.UNSIGNED_SHORT_5_6_5]:{[z.RGB]:r.RGB565},[ft.UNSIGNED_SHORT_4_4_4_4]:{[z.RGBA]:r.RGBA4},[ft.UNSIGNED_SHORT_5_5_5_1]:{[z.RGBA]:r.RGB5_A1},[ft.UNSIGNED_INT_2_10_10_10_REV]:{[z.RGBA]:r.RGB10_A2,[z.RGBA_INTEGER]:r.RGB10_A2UI},[ft.UNSIGNED_INT_10F_11F_11F_REV]:{[z.RGB]:r.R11F_G11F_B10F},[ft.UNSIGNED_INT_5_9_9_9_REV]:{[z.RGB]:r.RGB9_E5},[ft.UNSIGNED_INT_24_8]:{[z.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[ft.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[z.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:t={[ft.UNSIGNED_BYTE]:{[z.RGBA]:r.RGBA,[z.RGB]:r.RGB,[z.ALPHA]:r.ALPHA,[z.LUMINANCE]:r.LUMINANCE,[z.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[ft.UNSIGNED_SHORT_5_6_5]:{[z.RGB]:r.RGB},[ft.UNSIGNED_SHORT_4_4_4_4]:{[z.RGBA]:r.RGBA},[ft.UNSIGNED_SHORT_5_5_5_1]:{[z.RGBA]:r.RGBA}},t}class rm{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new vt,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=QT(t),this.samplerTypes=ZT(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 Eh(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 Eh(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!==J.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(t){const e=new Eh(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]??J.FLOAT,this.webGLVersion===2&&t.type===ft.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!==J.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&&ps(this.managedTextures,s,1)}}updateTextureStyle(t){var i;const e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===pr.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=Jr.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!==pr.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===Ir.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const s=this.renderer.context.extensions.anisotropicFiltering;if(s&&t.anisotropicLevel>0&&t.scaleMode===Ir.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===Ir.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===Ir.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}rm.extension={type:Q.RendererSystem,name:"texture"},ht.add(rm);class im{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}}im.extension={type:Q.RendererSystem,name:"transformFeedback"},ht.add(im);class Ao{constructor(t){this.renderer=t}init(t){this.screen=new Et(0,0,t.width,t.height),this.element=t.view||tt.ADAPTER.createCanvas(),this.resolution=t.resolution||tt.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}}Ao.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},Ao.extension={type:[Q.RendererSystem,Q.CanvasRendererSystem],name:"_view"},ht.add(Ao),tt.PREFER_ENV=Ei.WEBGL2,tt.STRICT_TEXTURE_CACHE=!1,tt.RENDER_OPTIONS={...xo.defaultOptions,...vo.defaultOptions,...Ao.defaultOptions,...To.defaultOptions},Object.defineProperties(tt,{WRAP_MODE:{get(){return vt.defaultOptions.wrapMode},set(r){St("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),vt.defaultOptions.wrapMode=r}},SCALE_MODE:{get(){return vt.defaultOptions.scaleMode},set(r){St("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),vt.defaultOptions.scaleMode=r}},MIPMAP_TEXTURES:{get(){return vt.defaultOptions.mipmap},set(r){St("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),vt.defaultOptions.mipmap=r}},ANISOTROPIC_LEVEL:{get(){return vt.defaultOptions.anisotropicLevel},set(r){St("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),vt.defaultOptions.anisotropicLevel=r}},FILTER_RESOLUTION:{get(){return St("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),Be.defaultResolution},set(r){Be.defaultResolution=r}},FILTER_MULTISAMPLE:{get(){return St("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),Be.defaultMultisample},set(r){Be.defaultMultisample=r}},SPRITE_MAX_TEXTURES:{get(){return Di.defaultMaxTextures},set(r){St("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),Di.defaultMaxTextures=r}},SPRITE_BATCH_SIZE:{get(){return Di.defaultBatchSize},set(r){St("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),Di.defaultBatchSize=r}},CAN_UPLOAD_SAME_BUFFER:{get(){return Di.canUploadSameBuffer},set(r){St("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),Di.canUploadSameBuffer=r}},GC_MODE:{get(){return Fi.defaultMode},set(r){St("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),Fi.defaultMode=r}},GC_MAX_IDLE:{get(){return Fi.defaultMaxIdle},set(r){St("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),Fi.defaultMaxIdle=r}},GC_MAX_CHECK_COUNT:{get(){return Fi.defaultCheckCountMax},set(r){St("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),Fi.defaultCheckCountMax=r}},PRECISION_VERTEX:{get(){return Br.defaultVertexPrecision},set(r){St("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),Br.defaultVertexPrecision=r}},PRECISION_FRAGMENT:{get(){return Br.defaultFragmentPrecision},set(r){St("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),Br.defaultFragmentPrecision=r}}});var ki=(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))(ki||{});class wh{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 sm=class Ve{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 wh(null,null,1/0),this.deltaMS=1/Ve.targetFPMS,this.elapsedMS=1/Ve.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=ki.NORMAL){return this._addListener(new wh(t,e,i))}addOnce(t,e,i=ki.NORMAL){return this._addListener(new wh(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*Ve.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,Ve.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(!Ve._shared){const t=Ve._shared=new Ve;t.autoStart=!0,t._protected=!0}return Ve._shared}static get system(){if(!Ve._system){const t=Ve._system=new Ve;t.autoStart=!0,t._protected=!0}return Ve._system}};sm.targetFPMS=.06;let Xe=sm;Object.defineProperties(tt,{TARGET_FPMS:{get(){return Xe.targetFPMS},set(r){St("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),Xe.targetFPMS=r}}});class nm{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,ki.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?Xe.shared:new Xe,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}nm.extension=Q.Application,ht.add(nm);const om=[];ht.handleByList(Q.Renderer,om);function am(r){for(const t of om)if(t.test(r))return new t(r);throw new Error("Unable to auto-detect a suitable renderer.")}var JT=`attribute vec2 aVertexPosition;
491
+ `))}}let ZT=0;const Co={textureCount:0,uboCount:0};class om{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=ZT++}systemCheck(){if(!ET())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||(Co.textureCount=0,Co.uboCount=0,this.syncUniformGroup(t.uniformGroup,Co)),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]=yT(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,Co,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]=KT(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=zT(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}}om.extension={type:Q.RendererSystem,name:"shader"},ut.add(om);class Io{constructor(t){this.renderer=t}run(t){const{renderer:e}=this;e.runners.init.emit(e.options),t.hello&&console.log(`PixiJS 7.4.3 - ${e.rendererLogId} - https://pixijs.com`),e.resize(e.screen.width,e.screen.height)}destroy(){}}Io.defaultOptions={hello:!1},Io.extension={type:[Q.RendererSystem,Q.CanvasRendererSystem],name:"startup"},ut.add(Io);function QT(r,t=[]){return t[yt.NORMAL]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.ADD]=[r.ONE,r.ONE],t[yt.MULTIPLY]=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.SCREEN]=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.OVERLAY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.DARKEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.LIGHTEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.COLOR_DODGE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.COLOR_BURN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.HARD_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.SOFT_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.DIFFERENCE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.EXCLUSION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.HUE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.SATURATION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.COLOR]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.LUMINOSITY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.NONE]=[0,0],t[yt.NORMAL_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.ADD_NPM]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t[yt.SCREEN_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[yt.SRC_IN]=[r.DST_ALPHA,r.ZERO],t[yt.SRC_OUT]=[r.ONE_MINUS_DST_ALPHA,r.ZERO],t[yt.SRC_ATOP]=[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[yt.DST_OVER]=[r.ONE_MINUS_DST_ALPHA,r.ONE],t[yt.DST_IN]=[r.ZERO,r.SRC_ALPHA],t[yt.DST_OUT]=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],t[yt.DST_ATOP]=[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],t[yt.XOR]=[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[yt.SUBTRACT]=[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD],t}const JT=0,tA=1,eA=2,rA=3,iA=4,sA=5,am=class au{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=yt.NONE,this._blendEq=!1,this.map=[],this.map[JT]=this.setBlend,this.map[tA]=this.setOffset,this.map[eA]=this.setCullFace,this.map[rA]=this.setDepthTest,this.map[iA]=this.setFrontFace,this.map[sA]=this.setDepthMask,this.checks=[],this.defaultState=new Er,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=QT(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(au.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(au.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}};am.extension={type:Q.RendererSystem,name:"state"};let nA=am;ut.add(nA);class oA extends Ys{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 ir(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 dn=class ea{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=ea.defaultMaxIdle,this.checkCountMax=ea.defaultCheckCountMax,this.mode=ea.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==al.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}};dn.defaultMode=al.AUTO,dn.defaultMaxIdle=60*60,dn.defaultCheckCountMax=60*10,dn.extension={type:Q.RendererSystem,name:"textureGC"};let Fi=dn;ut.add(Fi);class Sh{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=ft.UNSIGNED_BYTE,this.internalFormat=j.RGBA,this.samplerType=0}}function aA(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[r.RGB]:J.FLOAT,[r.RGBA]:J.FLOAT,[r.ALPHA]:J.FLOAT,[r.LUMINANCE]:J.FLOAT,[r.LUMINANCE_ALPHA]:J.FLOAT,[r.R8]:J.FLOAT,[r.R8_SNORM]:J.FLOAT,[r.RG8]:J.FLOAT,[r.RG8_SNORM]:J.FLOAT,[r.RGB8]:J.FLOAT,[r.RGB8_SNORM]:J.FLOAT,[r.RGB565]:J.FLOAT,[r.RGBA4]:J.FLOAT,[r.RGB5_A1]:J.FLOAT,[r.RGBA8]:J.FLOAT,[r.RGBA8_SNORM]:J.FLOAT,[r.RGB10_A2]:J.FLOAT,[r.RGB10_A2UI]:J.FLOAT,[r.SRGB8]:J.FLOAT,[r.SRGB8_ALPHA8]:J.FLOAT,[r.R16F]:J.FLOAT,[r.RG16F]:J.FLOAT,[r.RGB16F]:J.FLOAT,[r.RGBA16F]:J.FLOAT,[r.R32F]:J.FLOAT,[r.RG32F]:J.FLOAT,[r.RGB32F]:J.FLOAT,[r.RGBA32F]:J.FLOAT,[r.R11F_G11F_B10F]:J.FLOAT,[r.RGB9_E5]:J.FLOAT,[r.R8I]:J.INT,[r.R8UI]:J.UINT,[r.R16I]:J.INT,[r.R16UI]:J.UINT,[r.R32I]:J.INT,[r.R32UI]:J.UINT,[r.RG8I]:J.INT,[r.RG8UI]:J.UINT,[r.RG16I]:J.INT,[r.RG16UI]:J.UINT,[r.RG32I]:J.INT,[r.RG32UI]:J.UINT,[r.RGB8I]:J.INT,[r.RGB8UI]:J.UINT,[r.RGB16I]:J.INT,[r.RGB16UI]:J.UINT,[r.RGB32I]:J.INT,[r.RGB32UI]:J.UINT,[r.RGBA8I]:J.INT,[r.RGBA8UI]:J.UINT,[r.RGBA16I]:J.INT,[r.RGBA16UI]:J.UINT,[r.RGBA32I]:J.INT,[r.RGBA32UI]:J.UINT,[r.DEPTH_COMPONENT16]:J.FLOAT,[r.DEPTH_COMPONENT24]:J.FLOAT,[r.DEPTH_COMPONENT32F]:J.FLOAT,[r.DEPTH_STENCIL]:J.FLOAT,[r.DEPTH24_STENCIL8]:J.FLOAT,[r.DEPTH32F_STENCIL8]:J.FLOAT}:t={[r.RGB]:J.FLOAT,[r.RGBA]:J.FLOAT,[r.ALPHA]:J.FLOAT,[r.LUMINANCE]:J.FLOAT,[r.LUMINANCE_ALPHA]:J.FLOAT,[r.DEPTH_STENCIL]:J.FLOAT},t}function lA(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[ft.UNSIGNED_BYTE]:{[j.RGBA]:r.RGBA8,[j.RGB]:r.RGB8,[j.RG]:r.RG8,[j.RED]:r.R8,[j.RGBA_INTEGER]:r.RGBA8UI,[j.RGB_INTEGER]:r.RGB8UI,[j.RG_INTEGER]:r.RG8UI,[j.RED_INTEGER]:r.R8UI,[j.ALPHA]:r.ALPHA,[j.LUMINANCE]:r.LUMINANCE,[j.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[ft.BYTE]:{[j.RGBA]:r.RGBA8_SNORM,[j.RGB]:r.RGB8_SNORM,[j.RG]:r.RG8_SNORM,[j.RED]:r.R8_SNORM,[j.RGBA_INTEGER]:r.RGBA8I,[j.RGB_INTEGER]:r.RGB8I,[j.RG_INTEGER]:r.RG8I,[j.RED_INTEGER]:r.R8I},[ft.UNSIGNED_SHORT]:{[j.RGBA_INTEGER]:r.RGBA16UI,[j.RGB_INTEGER]:r.RGB16UI,[j.RG_INTEGER]:r.RG16UI,[j.RED_INTEGER]:r.R16UI,[j.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[ft.SHORT]:{[j.RGBA_INTEGER]:r.RGBA16I,[j.RGB_INTEGER]:r.RGB16I,[j.RG_INTEGER]:r.RG16I,[j.RED_INTEGER]:r.R16I},[ft.UNSIGNED_INT]:{[j.RGBA_INTEGER]:r.RGBA32UI,[j.RGB_INTEGER]:r.RGB32UI,[j.RG_INTEGER]:r.RG32UI,[j.RED_INTEGER]:r.R32UI,[j.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[ft.INT]:{[j.RGBA_INTEGER]:r.RGBA32I,[j.RGB_INTEGER]:r.RGB32I,[j.RG_INTEGER]:r.RG32I,[j.RED_INTEGER]:r.R32I},[ft.FLOAT]:{[j.RGBA]:r.RGBA32F,[j.RGB]:r.RGB32F,[j.RG]:r.RG32F,[j.RED]:r.R32F,[j.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[ft.HALF_FLOAT]:{[j.RGBA]:r.RGBA16F,[j.RGB]:r.RGB16F,[j.RG]:r.RG16F,[j.RED]:r.R16F},[ft.UNSIGNED_SHORT_5_6_5]:{[j.RGB]:r.RGB565},[ft.UNSIGNED_SHORT_4_4_4_4]:{[j.RGBA]:r.RGBA4},[ft.UNSIGNED_SHORT_5_5_5_1]:{[j.RGBA]:r.RGB5_A1},[ft.UNSIGNED_INT_2_10_10_10_REV]:{[j.RGBA]:r.RGB10_A2,[j.RGBA_INTEGER]:r.RGB10_A2UI},[ft.UNSIGNED_INT_10F_11F_11F_REV]:{[j.RGB]:r.R11F_G11F_B10F},[ft.UNSIGNED_INT_5_9_9_9_REV]:{[j.RGB]:r.RGB9_E5},[ft.UNSIGNED_INT_24_8]:{[j.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[ft.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[j.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:t={[ft.UNSIGNED_BYTE]:{[j.RGBA]:r.RGBA,[j.RGB]:r.RGB,[j.ALPHA]:r.ALPHA,[j.LUMINANCE]:r.LUMINANCE,[j.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[ft.UNSIGNED_SHORT_5_6_5]:{[j.RGB]:r.RGB},[ft.UNSIGNED_SHORT_4_4_4_4]:{[j.RGBA]:r.RGBA},[ft.UNSIGNED_SHORT_5_5_5_1]:{[j.RGBA]:r.RGBA}},t}class lm{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new bt,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=lA(t),this.samplerTypes=aA(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 Sh(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 Sh(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!==J.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(t){const e=new Sh(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]??J.FLOAT,this.webGLVersion===2&&t.type===ft.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!==J.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&&ms(this.managedTextures,s,1)}}updateTextureStyle(t){var i;const e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===pr.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=Jr.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!==pr.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===Rr.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const s=this.renderer.context.extensions.anisotropicFiltering;if(s&&t.anisotropicLevel>0&&t.scaleMode===Rr.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===Rr.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===Rr.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}lm.extension={type:Q.RendererSystem,name:"texture"},ut.add(lm);class hm{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}}hm.extension={type:Q.RendererSystem,name:"transformFeedback"},ut.add(hm);class Ro{constructor(t){this.renderer=t}init(t){this.screen=new wt(0,0,t.width,t.height),this.element=t.view||tt.ADAPTER.createCanvas(),this.resolution=t.resolution||tt.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}}Ro.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},Ro.extension={type:[Q.RendererSystem,Q.CanvasRendererSystem],name:"_view"},ut.add(Ro),tt.PREFER_ENV=Ei.WEBGL2,tt.STRICT_TEXTURE_CACHE=!1,tt.RENDER_OPTIONS={...To.defaultOptions,...wo.defaultOptions,...Ro.defaultOptions,...Io.defaultOptions},Object.defineProperties(tt,{WRAP_MODE:{get(){return bt.defaultOptions.wrapMode},set(r){St("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),bt.defaultOptions.wrapMode=r}},SCALE_MODE:{get(){return bt.defaultOptions.scaleMode},set(r){St("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),bt.defaultOptions.scaleMode=r}},MIPMAP_TEXTURES:{get(){return bt.defaultOptions.mipmap},set(r){St("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),bt.defaultOptions.mipmap=r}},ANISOTROPIC_LEVEL:{get(){return bt.defaultOptions.anisotropicLevel},set(r){St("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),bt.defaultOptions.anisotropicLevel=r}},FILTER_RESOLUTION:{get(){return St("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),Be.defaultResolution},set(r){Be.defaultResolution=r}},FILTER_MULTISAMPLE:{get(){return St("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),Be.defaultMultisample},set(r){Be.defaultMultisample=r}},SPRITE_MAX_TEXTURES:{get(){return Di.defaultMaxTextures},set(r){St("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),Di.defaultMaxTextures=r}},SPRITE_BATCH_SIZE:{get(){return Di.defaultBatchSize},set(r){St("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),Di.defaultBatchSize=r}},CAN_UPLOAD_SAME_BUFFER:{get(){return Di.canUploadSameBuffer},set(r){St("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),Di.canUploadSameBuffer=r}},GC_MODE:{get(){return Fi.defaultMode},set(r){St("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),Fi.defaultMode=r}},GC_MAX_IDLE:{get(){return Fi.defaultMaxIdle},set(r){St("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),Fi.defaultMaxIdle=r}},GC_MAX_CHECK_COUNT:{get(){return Fi.defaultCheckCountMax},set(r){St("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),Fi.defaultCheckCountMax=r}},PRECISION_VERTEX:{get(){return Fr.defaultVertexPrecision},set(r){St("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),Fr.defaultVertexPrecision=r}},PRECISION_FRAGMENT:{get(){return Fr.defaultFragmentPrecision},set(r){St("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),Fr.defaultFragmentPrecision=r}}});var ki=(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))(ki||{});class Ch{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 um=class Ve{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 Ch(null,null,1/0),this.deltaMS=1/Ve.targetFPMS,this.elapsedMS=1/Ve.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=ki.NORMAL){return this._addListener(new Ch(t,e,i))}addOnce(t,e,i=ki.NORMAL){return this._addListener(new Ch(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*Ve.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,Ve.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(!Ve._shared){const t=Ve._shared=new Ve;t.autoStart=!0,t._protected=!0}return Ve._shared}static get system(){if(!Ve._system){const t=Ve._system=new Ve;t.autoStart=!0,t._protected=!0}return Ve._system}};um.targetFPMS=.06;let Xe=um;Object.defineProperties(tt,{TARGET_FPMS:{get(){return Xe.targetFPMS},set(r){St("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),Xe.targetFPMS=r}}});class cm{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,ki.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?Xe.shared:new Xe,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}cm.extension=Q.Application,ut.add(cm);const dm=[];ut.handleByList(Q.Renderer,dm);function fm(r){for(const t of dm)if(t.test(r))return new t(r);throw new Error("Unable to auto-detect a suitable renderer.")}var hA=`attribute vec2 aVertexPosition;
492
492
  attribute vec2 aTextureCoord;
493
493
 
494
494
  uniform mat3 projectionMatrix;
@@ -499,7 +499,7 @@ void main(void)
499
499
  {
500
500
  gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
501
501
  vTextureCoord = aTextureCoord;
502
- }`,tA=`attribute vec2 aVertexPosition;
502
+ }`,uA=`attribute vec2 aVertexPosition;
503
503
 
504
504
  uniform mat3 projectionMatrix;
505
505
 
@@ -525,7 +525,7 @@ void main(void)
525
525
  gl_Position = filterVertexPosition();
526
526
  vTextureCoord = filterTextureCoord();
527
527
  }
528
- `;const eA=JT,lm=tA;class hm{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>=ae.HIGH?this.multisample=ae.HIGH:e>=ae.MEDIUM?this.multisample=ae.MEDIUM:e>=ae.LOW?this.multisample=ae.LOW:this.multisample=ae.NONE}destroy(){}}hm.extension={type:Q.RendererSystem,name:"_multisample"},ht.add(hm);class rA{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class um{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 rA(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}um.extension={type:Q.RendererSystem,name:"buffer"},ht.add(um);class cm{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}}cm.extension={type:Q.RendererSystem,name:"objectRenderer"},ht.add(cm);const So=class su extends KT{constructor(t){super(),this.type=Nd.WEBGL,t=Object.assign({},tt.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new sr({projectionMatrix:new Ut},!0);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:su.__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&&(St("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=su.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t!=null&&t.forceCanvas?!1:Sw()}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 St("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return St("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return St("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return St("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){St("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return St("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){St("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return St("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)}};So.extension={type:Q.Renderer,priority:1},So.__plugins={},So.__systems={};let Th=So;ht.handleByMap(Q.RendererPlugin,Th.__plugins),ht.handleByMap(Q.RendererSystem,Th.__systems),ht.add(Th);class dm extends nn{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 vt;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 nn?this.addResourceAt(t[i],i):this.addResourceAt(_p(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 iA extends dm{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=rs.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 sA extends Fr{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const fm=class yn extends dm{constructor(t,e){const{width:i,height:s,autoLoad:n,linkBaseTexture:o}=e||{};if(t&&t.length!==yn.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:s});for(let a=0;a<yn.SIDES;a++)this.items[a].target=rs.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=rs.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=rs.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<yn.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===yn.SIDES}};fm.SIDES=6;let nA=fm;class ys extends Fr{constructor(t,e){e=e||{};let i,s,n;typeof t=="string"?(i=ys.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 tt.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===He.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 ys._EMPTY=ys._EMPTY??tt.ADAPTER.createCanvas(0,0),ys._EMPTY}}const Ah=class Jo extends Fr{constructor(t,e){e=e||{},super(tt.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)},Jo.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;Fr.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_${Ii()}`,o.getContext("2d").drawImage(t,0,0,e,i,0,0,s,n),this._resolve(),this._resolve=null}}static getSize(t){const e=Jo.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"&&Jo.SVG_XML.test(t)}};Ah.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,Ah.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let Sh=Ah;class oA extends Fr{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}}const Ch=class nu extends Fr{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];Fr.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(),u=h.slice(h.lastIndexOf(".")+1);l=l||nu.MIME_TYPES[u]||`video/${u}`}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=Xe.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&&(Xe.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||(Xe.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Xe.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||nu.TYPES.includes(e)}};Ch.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],Ch.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let pm=Ch;lh.push(ys,Np,sA,pm,oA,Sh,oo,nA,iA);class Co{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?Et.EMPTY:(t=t||new Et(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,u=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,u),this.maxY=Math.max(this.maxY,u)}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,u=t.tx,c=t.ty;let d=this.minX,f=this.minY,p=this.maxX,m=this.maxY,_=o*e+l*i+u,y=a*e+h*i+c;d=_<d?_:d,f=y<f?y:f,p=_>p?_:p,m=y>m?y:m,_=o*s+l*i+u,y=a*s+h*i+c,d=_<d?_:d,f=y<f?y:f,p=_>p?_:p,m=y>m?y:m,_=o*e+l*n+u,y=a*e+h*n+c,d=_<d?_:d,f=y<f?y:f,p=_>p?_:p,m=y>m?y:m,_=o*s+l*n+u,y=a*s+h*n+c,d=_<d?_:d,f=y<f?y:f,p=_>p?_: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],u=t[l+1];s=h<s?h:s,n=u<n?u:n,o=h>o?h:o,a=u>a?u: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,u=t.d,c=t.tx,d=t.ty;let f=this.minX,p=this.minY,m=this.maxX,_=this.maxY;for(let y=i;y<s;y+=2){const v=e[y],g=e[y+1],x=a*v+h*g+c,E=u*g+l*v+d;f=Math.min(f,x-n),m=Math.max(m,x+n),p=Math.min(p,E-o),_=Math.max(_,E+o)}this.minX=f,this.minY=p,this.maxX=m,this.maxY=_}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,u=this.maxY;this.minX=i<a?i:a,this.minY=s<l?s:l,this.maxX=n>h?n:h,this.maxY=o>u?o:u}}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,u=this.maxY;this.minX=i<a?i:a,this.minY=s<l?s:l,this.maxX=n>h?n:h,this.maxY=o>u?o:u}}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 Wt extends Xs{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new fh,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 Co,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(Wt.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 Et),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new Et),t=this._localBoundsRect),this._localBounds||(this._localBounds=new Co);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 aA),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*tT}set angle(t){this.transform.rotation=t*eT}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 aA extends Wt{constructor(){super(...arguments),this.sortDirty=null}}Wt.prototype.displayObjectUpdateTransform=Wt.prototype.updateTransform;const lA=new Ut;function hA(r,t){return r.zIndex===t.zIndex?r._lastSortedIndex-t._lastSortedIndex:r.zIndex-t.zIndex}const mm=class ou extends Wt{constructor(){super(),this.children=[],this.sortableChildren=ou.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);ps(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,ps(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,ps(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(hA),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!==ou.prototype._render&&(i=this.getBounds(!0));const n=t.projection.transform;if(n&&(s?(s=lA.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!==he.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}};mm.defaultSortableChildren=!1;let nr=mm;nr.prototype.containerUpdateTransform=nr.prototype.updateTransform,Object.defineProperties(tt,{SORTABLE_CHILDREN:{get(){return nr.defaultSortableChildren},set(r){St("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),nr.defaultSortableChildren=r}}});const un=new It,uA=new Uint16Array([0,1,2,0,2,3]);class _s extends nr{constructor(t){super(),this._anchor=new Lr(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 Ot(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=yt.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||ut.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=uA,this.pluginName="batch",this.isSprite=!0,this._roundPixels=tt.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=ri(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=ri(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,u=t.trim,c=t.orig,d=this._anchor;let f=0,p=0,m=0,_=0;if(u?(p=u.x-d._x*c.width,f=p+u.width,_=u.y-d._y*c.height,m=_+u.height):(p=-d._x*c.width,f=p+c.width,_=-d._y*c.height,m=_+c.height),h[0]=i*p+n*_+a,h[1]=o*_+s*p+l,h[2]=i*f+n*_+a,h[3]=o*_+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=tt.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,u=n.tx,c=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+u,e[1]=h*p+a*d+c,e[2]=o*f+l*p+u,e[3]=h*p+a*f+c,e[4]=o*f+l*m+u,e[5]=h*m+a*f+c,e[6]=o*d+l*m+u,e[7]=h*m+a*d+c,this._roundPixels){const _=tt.RESOLUTION;for(let y=0;y<e.length;++y)e[y]=Math.round(e[y]*_)/_}}_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 Co),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 Et),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,un);const e=this._texture.orig.width,i=this._texture.orig.height,s=-e*this.anchor.x;let n=0;return un.x>=s&&un.x<s+e&&(n=-i*this.anchor.y,un.y>=n&&un.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 ut?t:ut.from(t,e);return new _s(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=ri(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=ri(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||ut.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const gm=new Ut;Wt.prototype._cacheAsBitmap=!1,Wt.prototype._cacheData=null,Wt.prototype._cacheAsBitmapResolution=null,Wt.prototype._cacheAsBitmapMultisample=null;class cA{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(Wt.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 cA),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)}}}),Wt.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))},Wt.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 Et,!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=Li.create({width:e.width,height:e.height,resolution:i,multisample:this.cacheAsBitmapMultisample??r.multisample}),h=`cacheAsBitmap_${Ii()}`;this._cacheData.textureCacheId=h,vt.addToCache(l.baseTexture,h),ut.addToCache(l,h);const u=this.transform.localTransform.copyTo(gm).invert().translate(-e.x,-e.y);this.render=this._cacheData.originalRender,r.render(this,{renderTexture:l,clear:!0,transform:u,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 c=new _s(l);c.transform.worldTransform=this.transform.worldTransform,c.anchor.x=-(e.x/e.width),c.anchor.y=-(e.y/e.height),c.alpha=t,c._bounds=this._bounds,this._cacheData.sprite=c,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=c.containsPoint.bind(c)},Wt.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))},Wt.prototype._initCachedDisplayObjectCanvas=function(r){var u;if((u=this._cacheData)!=null&&u.sprite)return;const t=this.getLocalBounds(new Et,!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=Li.create({width:t.width,height:t.height,resolution:n}),a=`cacheAsBitmap_${Ii()}`;this._cacheData.textureCacheId=a,vt.addToCache(o.baseTexture,a),ut.addToCache(o,a);const l=gm;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 _s(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)},Wt.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},Wt.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},Wt.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,vt.removeFromCache(this._cacheData.textureCacheId),ut.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},Wt.prototype._cacheAsBitmapDestroy=function(r){this.cacheAsBitmap=!1,this.destroy(r)},Wt.prototype.name=null,nr.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},Wt.prototype.getGlobalPosition=function(r=new It,t=!1){return this.parent?this.parent.toGlobal(this.position,r,t):(r.x=this.position.x,r.y=this.position.y),r};var dA=`varying vec2 vTextureCoord;
528
+ `;const cA=hA,pm=uA;class mm{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>=le.HIGH?this.multisample=le.HIGH:e>=le.MEDIUM?this.multisample=le.MEDIUM:e>=le.LOW?this.multisample=le.LOW:this.multisample=le.NONE}destroy(){}}mm.extension={type:Q.RendererSystem,name:"_multisample"},ut.add(mm);class dA{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class gm{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 dA(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}gm.extension={type:Q.RendererSystem,name:"buffer"},ut.add(gm);class ym{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}}ym.extension={type:Q.RendererSystem,name:"objectRenderer"},ut.add(ym);const Mo=class lu extends oA{constructor(t){super(),this.type=Bd.WEBGL,t=Object.assign({},tt.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new sr({projectionMatrix:new Gt},!0);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:lu.__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&&(St("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=lu.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t!=null&&t.forceCanvas?!1:Bw()}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 St("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return St("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return St("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return St("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){St("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return St("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){St("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return St("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)}};Mo.extension={type:Q.Renderer,priority:1},Mo.__plugins={},Mo.__systems={};let Ih=Mo;ut.handleByMap(Q.RendererPlugin,Ih.__plugins),ut.handleByMap(Q.RendererSystem,Ih.__systems),ut.add(Ih);class _m extends ln{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 bt;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 ln?this.addResourceAt(t[i],i):this.addResourceAt(Tp(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 fA extends _m{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=is.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 pA extends kr{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const vm=class xn extends _m{constructor(t,e){const{width:i,height:s,autoLoad:n,linkBaseTexture:o}=e||{};if(t&&t.length!==xn.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:s});for(let a=0;a<xn.SIDES;a++)this.items[a].target=is.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=is.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=is.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<xn.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===xn.SIDES}};vm.SIDES=6;let mA=vm;class _s extends kr{constructor(t,e){e=e||{};let i,s,n;typeof t=="string"?(i=_s.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 tt.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===$e.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 _s._EMPTY=_s._EMPTY??tt.ADAPTER.createCanvas(0,0),_s._EMPTY}}const Rh=class ra extends kr{constructor(t,e){e=e||{},super(tt.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)},ra.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;kr.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_${Ii()}`,o.getContext("2d").drawImage(t,0,0,e,i,0,0,s,n),this._resolve(),this._resolve=null}}static getSize(t){const e=ra.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"&&ra.SVG_XML.test(t)}};Rh.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,Rh.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let Mh=Rh;class gA extends kr{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}}const Ph=class hu extends kr{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];kr.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(),u=h.slice(h.lastIndexOf(".")+1);l=l||hu.MIME_TYPES[u]||`video/${u}`}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=Xe.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&&(Xe.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||(Xe.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Xe.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||hu.TYPES.includes(e)}};Ph.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],Ph.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let xm=Ph;dh.push(_s,Up,pA,xm,gA,Mh,uo,mA,fA);class Po{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?wt.EMPTY:(t=t||new wt(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,u=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,u),this.maxY=Math.max(this.maxY,u)}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,u=t.tx,c=t.ty;let d=this.minX,f=this.minY,p=this.maxX,m=this.maxY,_=o*e+l*i+u,y=a*e+h*i+c;d=_<d?_:d,f=y<f?y:f,p=_>p?_:p,m=y>m?y:m,_=o*s+l*i+u,y=a*s+h*i+c,d=_<d?_:d,f=y<f?y:f,p=_>p?_:p,m=y>m?y:m,_=o*e+l*n+u,y=a*e+h*n+c,d=_<d?_:d,f=y<f?y:f,p=_>p?_:p,m=y>m?y:m,_=o*s+l*n+u,y=a*s+h*n+c,d=_<d?_:d,f=y<f?y:f,p=_>p?_: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],u=t[l+1];s=h<s?h:s,n=u<n?u:n,o=h>o?h:o,a=u>a?u: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,u=t.d,c=t.tx,d=t.ty;let f=this.minX,p=this.minY,m=this.maxX,_=this.maxY;for(let y=i;y<s;y+=2){const v=e[y],g=e[y+1],x=a*v+h*g+c,T=u*g+l*v+d;f=Math.min(f,x-n),m=Math.max(m,x+n),p=Math.min(p,T-o),_=Math.max(_,T+o)}this.minX=f,this.minY=p,this.maxX=m,this.maxY=_}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,u=this.maxY;this.minX=i<a?i:a,this.minY=s<l?s:l,this.maxX=n>h?n:h,this.maxY=o>u?o:u}}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,u=this.maxY;this.minX=i<a?i:a,this.minY=s<l?s:l,this.maxX=n>h?n:h,this.maxY=o>u?o:u}}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 qt extends Ys{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new yh,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 Po,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(qt.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 wt),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new wt),t=this._localBoundsRect),this._localBounds||(this._localBounds=new Po);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 yA),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*uT}set angle(t){this.transform.rotation=t*cT}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 yA extends qt{constructor(){super(...arguments),this.sortDirty=null}}qt.prototype.displayObjectUpdateTransform=qt.prototype.updateTransform;const _A=new Gt;function vA(r,t){return r.zIndex===t.zIndex?r._lastSortedIndex-t._lastSortedIndex:r.zIndex-t.zIndex}const bm=class uu extends qt{constructor(){super(),this.children=[],this.sortableChildren=uu.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);ms(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,ms(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,ms(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(vA),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!==uu.prototype._render&&(i=this.getBounds(!0));const n=t.projection.transform;if(n&&(s?(s=_A.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!==ce.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}};bm.defaultSortableChildren=!1;let nr=bm;nr.prototype.containerUpdateTransform=nr.prototype.updateTransform,Object.defineProperties(tt,{SORTABLE_CHILDREN:{get(){return nr.defaultSortableChildren},set(r){St("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),nr.defaultSortableChildren=r}}});const fn=new It,xA=new Uint16Array([0,1,2,0,2,3]);class vs extends nr{constructor(t){super(),this._anchor=new Br(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 Nt(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=yt.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||ct.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=xA,this.pluginName="batch",this.isSprite=!0,this._roundPixels=tt.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=ri(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=ri(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,u=t.trim,c=t.orig,d=this._anchor;let f=0,p=0,m=0,_=0;if(u?(p=u.x-d._x*c.width,f=p+u.width,_=u.y-d._y*c.height,m=_+u.height):(p=-d._x*c.width,f=p+c.width,_=-d._y*c.height,m=_+c.height),h[0]=i*p+n*_+a,h[1]=o*_+s*p+l,h[2]=i*f+n*_+a,h[3]=o*_+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=tt.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,u=n.tx,c=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+u,e[1]=h*p+a*d+c,e[2]=o*f+l*p+u,e[3]=h*p+a*f+c,e[4]=o*f+l*m+u,e[5]=h*m+a*f+c,e[6]=o*d+l*m+u,e[7]=h*m+a*d+c,this._roundPixels){const _=tt.RESOLUTION;for(let y=0;y<e.length;++y)e[y]=Math.round(e[y]*_)/_}}_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 Po),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 wt),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,fn);const e=this._texture.orig.width,i=this._texture.orig.height,s=-e*this.anchor.x;let n=0;return fn.x>=s&&fn.x<s+e&&(n=-i*this.anchor.y,fn.y>=n&&fn.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 ct?t:ct.from(t,e);return new vs(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=ri(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=ri(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||ct.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const Em=new Gt;qt.prototype._cacheAsBitmap=!1,qt.prototype._cacheData=null,qt.prototype._cacheAsBitmapResolution=null,qt.prototype._cacheAsBitmapMultisample=null;class bA{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(qt.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 bA),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)}}}),qt.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))},qt.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 wt,!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=Li.create({width:e.width,height:e.height,resolution:i,multisample:this.cacheAsBitmapMultisample??r.multisample}),h=`cacheAsBitmap_${Ii()}`;this._cacheData.textureCacheId=h,bt.addToCache(l.baseTexture,h),ct.addToCache(l,h);const u=this.transform.localTransform.copyTo(Em).invert().translate(-e.x,-e.y);this.render=this._cacheData.originalRender,r.render(this,{renderTexture:l,clear:!0,transform:u,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 c=new vs(l);c.transform.worldTransform=this.transform.worldTransform,c.anchor.x=-(e.x/e.width),c.anchor.y=-(e.y/e.height),c.alpha=t,c._bounds=this._bounds,this._cacheData.sprite=c,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=c.containsPoint.bind(c)},qt.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))},qt.prototype._initCachedDisplayObjectCanvas=function(r){var u;if((u=this._cacheData)!=null&&u.sprite)return;const t=this.getLocalBounds(new wt,!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=Li.create({width:t.width,height:t.height,resolution:n}),a=`cacheAsBitmap_${Ii()}`;this._cacheData.textureCacheId=a,bt.addToCache(o.baseTexture,a),ct.addToCache(o,a);const l=Em;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 vs(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)},qt.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},qt.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},qt.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,bt.removeFromCache(this._cacheData.textureCacheId),ct.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},qt.prototype._cacheAsBitmapDestroy=function(r){this.cacheAsBitmap=!1,this.destroy(r)},qt.prototype.name=null,nr.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},qt.prototype.getGlobalPosition=function(r=new It,t=!1){return this.parent?this.parent.toGlobal(this.position,r,t):(r.x=this.position.x,r.y=this.position.y),r};var EA=`varying vec2 vTextureCoord;
529
529
 
530
530
  uniform sampler2D uSampler;
531
531
  uniform float uAlpha;
@@ -534,9 +534,9 @@ void main(void)
534
534
  {
535
535
  gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha;
536
536
  }
537
- `;class fA extends Be{constructor(t=1){super(eA,dA,{uAlpha:1}),this.alpha=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}const pA={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]},mA=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(`
538
- `);function gA(r){const t=pA[r],e=t.length;let i=mA,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+=`
539
- `}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}const yA=`
537
+ `;class wA extends Be{constructor(t=1){super(cA,EA,{uAlpha:1}),this.alpha=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}const TA={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]},AA=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(`
538
+ `);function SA(r){const t=TA[r],e=t.length;let i=AA,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+=`
539
+ `}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}const CA=`
540
540
  attribute vec2 aVertexPosition;
541
541
 
542
542
  uniform mat3 projectionMatrix;
@@ -566,8 +566,8 @@ void main(void)
566
566
 
567
567
  vec2 textureCoord = filterTextureCoord();
568
568
  %blur%
569
- }`;function _A(r,t){const e=Math.ceil(r/2);let i=yA,s="",n;t?n="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":n="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(let o=0;o<r;o++){let a=n.replace("%index%",o.toString());a=a.replace("%sampleIndex%",`${o-(e-1)}.0`),s+=a,s+=`
570
- `}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}class Ih extends Be{constructor(t,e=8,i=4,s=Be.defaultResolution,n=5){const o=_A(n,t),a=gA(n);super(o,a),this.horizontal=t,this.resolution=s,this._quality=0,this.quality=i,this.blur=e}apply(t,e,i,s){if(i?this.horizontal?this.uniforms.strength=1/i.width*(i.width/e.width):this.uniforms.strength=1/i.height*(i.height/e.height):this.horizontal?this.uniforms.strength=1/t.renderer.width*(t.renderer.width/e.width):this.uniforms.strength=1/t.renderer.height*(t.renderer.height/e.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)t.applyFilter(this,e,i,s);else{const n=t.getFilterTexture(),o=t.renderer;let a=e,l=n;this.state.blend=!1,t.applyFilter(this,a,l,mr.CLEAR);for(let h=1;h<this.passes-1;h++){t.bindAndClear(a,mr.BLIT),this.uniforms.uSampler=l;const u=l;l=a,a=u,o.shader.bind(this),o.geometry.draw(5)}this.state.blend=!0,t.applyFilter(this,l,i,s),t.returnFilterTexture(n)}}get blur(){return this.strength}set blur(t){this.padding=1+Math.abs(t)*2,this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}}class vA extends Be{constructor(t=8,e=4,i=Be.defaultResolution,s=5){super(),this._repeatEdgePixels=!1,this.blurXFilter=new Ih(!0,t,e,i,s),this.blurYFilter=new Ih(!1,t,e,i,s),this.resolution=i,this.quality=e,this.blur=t,this.repeatEdgePixels=!1}apply(t,e,i,s){const n=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(n&&o){const a=t.getFilterTexture();this.blurXFilter.apply(t,e,a,mr.CLEAR),this.blurYFilter.apply(t,a,i,s),t.returnFilterTexture(a)}else o?this.blurYFilter.apply(t,e,i,s):this.blurXFilter.apply(t,e,i,s)}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.strength),Math.abs(this.blurYFilter.strength))*2}get blur(){return this.blurXFilter.blur}set blur(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get blurX(){return this.blurXFilter.blur}set blurX(t){this.blurXFilter.blur=t,this.updatePadding()}get blurY(){return this.blurYFilter.blur}set blurY(t){this.blurYFilter.blur=t,this.updatePadding()}get blendMode(){return this.blurYFilter.blendMode}set blendMode(t){this.blurYFilter.blendMode=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}var xA=`varying vec2 vTextureCoord;
569
+ }`;function IA(r,t){const e=Math.ceil(r/2);let i=CA,s="",n;t?n="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":n="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(let o=0;o<r;o++){let a=n.replace("%index%",o.toString());a=a.replace("%sampleIndex%",`${o-(e-1)}.0`),s+=a,s+=`
570
+ `}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}class Oh extends Be{constructor(t,e=8,i=4,s=Be.defaultResolution,n=5){const o=IA(n,t),a=SA(n);super(o,a),this.horizontal=t,this.resolution=s,this._quality=0,this.quality=i,this.blur=e}apply(t,e,i,s){if(i?this.horizontal?this.uniforms.strength=1/i.width*(i.width/e.width):this.uniforms.strength=1/i.height*(i.height/e.height):this.horizontal?this.uniforms.strength=1/t.renderer.width*(t.renderer.width/e.width):this.uniforms.strength=1/t.renderer.height*(t.renderer.height/e.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)t.applyFilter(this,e,i,s);else{const n=t.getFilterTexture(),o=t.renderer;let a=e,l=n;this.state.blend=!1,t.applyFilter(this,a,l,mr.CLEAR);for(let h=1;h<this.passes-1;h++){t.bindAndClear(a,mr.BLIT),this.uniforms.uSampler=l;const u=l;l=a,a=u,o.shader.bind(this),o.geometry.draw(5)}this.state.blend=!0,t.applyFilter(this,l,i,s),t.returnFilterTexture(n)}}get blur(){return this.strength}set blur(t){this.padding=1+Math.abs(t)*2,this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}}class RA extends Be{constructor(t=8,e=4,i=Be.defaultResolution,s=5){super(),this._repeatEdgePixels=!1,this.blurXFilter=new Oh(!0,t,e,i,s),this.blurYFilter=new Oh(!1,t,e,i,s),this.resolution=i,this.quality=e,this.blur=t,this.repeatEdgePixels=!1}apply(t,e,i,s){const n=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(n&&o){const a=t.getFilterTexture();this.blurXFilter.apply(t,e,a,mr.CLEAR),this.blurYFilter.apply(t,a,i,s),t.returnFilterTexture(a)}else o?this.blurYFilter.apply(t,e,i,s):this.blurXFilter.apply(t,e,i,s)}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.strength),Math.abs(this.blurYFilter.strength))*2}get blur(){return this.blurXFilter.blur}set blur(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get blurX(){return this.blurXFilter.blur}set blurX(t){this.blurXFilter.blur=t,this.updatePadding()}get blurY(){return this.blurYFilter.blur}set blurY(t){this.blurYFilter.blur=t,this.updatePadding()}get blendMode(){return this.blurYFilter.blendMode}set blendMode(t){this.blurYFilter.blendMode=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}var MA=`varying vec2 vTextureCoord;
571
571
  uniform sampler2D uSampler;
572
572
  uniform float m[20];
573
573
  uniform float uAlpha;
@@ -619,7 +619,7 @@ void main(void)
619
619
 
620
620
  gl_FragColor = vec4(rgb, result.a);
621
621
  }
622
- `;class Rh extends Be{constructor(){const t={m:new Float32Array([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]),uAlpha:1};super(lm,xA,t),this.alpha=1}_loadMatrix(t,e=!1){let i=t;e&&(this._multiply(i,this.uniforms.m,t),i=this._colorMatrix(i)),this.uniforms.m=i}_multiply(t,e,i){return t[0]=e[0]*i[0]+e[1]*i[5]+e[2]*i[10]+e[3]*i[15],t[1]=e[0]*i[1]+e[1]*i[6]+e[2]*i[11]+e[3]*i[16],t[2]=e[0]*i[2]+e[1]*i[7]+e[2]*i[12]+e[3]*i[17],t[3]=e[0]*i[3]+e[1]*i[8]+e[2]*i[13]+e[3]*i[18],t[4]=e[0]*i[4]+e[1]*i[9]+e[2]*i[14]+e[3]*i[19]+e[4],t[5]=e[5]*i[0]+e[6]*i[5]+e[7]*i[10]+e[8]*i[15],t[6]=e[5]*i[1]+e[6]*i[6]+e[7]*i[11]+e[8]*i[16],t[7]=e[5]*i[2]+e[6]*i[7]+e[7]*i[12]+e[8]*i[17],t[8]=e[5]*i[3]+e[6]*i[8]+e[7]*i[13]+e[8]*i[18],t[9]=e[5]*i[4]+e[6]*i[9]+e[7]*i[14]+e[8]*i[19]+e[9],t[10]=e[10]*i[0]+e[11]*i[5]+e[12]*i[10]+e[13]*i[15],t[11]=e[10]*i[1]+e[11]*i[6]+e[12]*i[11]+e[13]*i[16],t[12]=e[10]*i[2]+e[11]*i[7]+e[12]*i[12]+e[13]*i[17],t[13]=e[10]*i[3]+e[11]*i[8]+e[12]*i[13]+e[13]*i[18],t[14]=e[10]*i[4]+e[11]*i[9]+e[12]*i[14]+e[13]*i[19]+e[14],t[15]=e[15]*i[0]+e[16]*i[5]+e[17]*i[10]+e[18]*i[15],t[16]=e[15]*i[1]+e[16]*i[6]+e[17]*i[11]+e[18]*i[16],t[17]=e[15]*i[2]+e[16]*i[7]+e[17]*i[12]+e[18]*i[17],t[18]=e[15]*i[3]+e[16]*i[8]+e[17]*i[13]+e[18]*i[18],t[19]=e[15]*i[4]+e[16]*i[9]+e[17]*i[14]+e[18]*i[19]+e[19],t}_colorMatrix(t){const e=new Float32Array(t);return e[4]/=255,e[9]/=255,e[14]/=255,e[19]/=255,e}brightness(t,e){const i=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}tint(t,e){const[i,s,n]=Ot.shared.setValue(t).toArray(),o=[i,0,0,0,0,0,s,0,0,0,0,0,n,0,0,0,0,0,1,0];this._loadMatrix(o,e)}greyscale(t,e){const i=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}blackAndWhite(t){const e=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(e,t)}hue(t,e){t=(t||0)/180*Math.PI;const i=Math.cos(t),s=Math.sin(t),n=Math.sqrt,o=1/3,a=n(o),l=i+(1-i)*o,h=o*(1-i)-a*s,u=o*(1-i)+a*s,c=o*(1-i)+a*s,d=i+o*(1-i),f=o*(1-i)-a*s,p=o*(1-i)-a*s,m=o*(1-i)+a*s,_=i+o*(1-i),y=[l,h,u,0,0,c,d,f,0,0,p,m,_,0,0,0,0,0,1,0];this._loadMatrix(y,e)}contrast(t,e){const i=(t||0)+1,s=-.5*(i-1),n=[i,0,0,0,s,0,i,0,0,s,0,0,i,0,s,0,0,0,1,0];this._loadMatrix(n,e)}saturate(t=0,e){const i=t*2/3+1,s=(i-1)*-.5,n=[i,s,s,0,0,s,i,s,0,0,s,s,i,0,0,0,0,0,1,0];this._loadMatrix(n,e)}desaturate(){this.saturate(-1)}negative(t){const e=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(e,t)}sepia(t){const e=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(e,t)}technicolor(t){const e=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(e,t)}polaroid(t){const e=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(e,t)}toBGR(t){const e=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)}kodachrome(t){const e=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(e,t)}browni(t){const e=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(e,t)}vintage(t){const e=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(e,t)}colorTone(t,e,i,s,n){t=t||.2,e=e||.15,i=i||16770432,s=s||3375104;const o=Ot.shared,[a,l,h]=o.setValue(i).toArray(),[u,c,d]=o.setValue(s).toArray(),f=[.3,.59,.11,0,0,a,l,h,t,0,u,c,d,e,0,a-u,l-c,h-d,0,0];this._loadMatrix(f,n)}night(t,e){t=t||.1;const i=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(i,e)}predator(t,e){const i=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(i,e)}lsd(t){const e=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(e,t)}reset(){const t=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(t,!1)}get matrix(){return this.uniforms.m}set matrix(t){this.uniforms.m=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}Rh.prototype.grayscale=Rh.prototype.greyscale;var bA=`varying vec2 vFilterCoord;
622
+ `;class Nh extends Be{constructor(){const t={m:new Float32Array([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]),uAlpha:1};super(pm,MA,t),this.alpha=1}_loadMatrix(t,e=!1){let i=t;e&&(this._multiply(i,this.uniforms.m,t),i=this._colorMatrix(i)),this.uniforms.m=i}_multiply(t,e,i){return t[0]=e[0]*i[0]+e[1]*i[5]+e[2]*i[10]+e[3]*i[15],t[1]=e[0]*i[1]+e[1]*i[6]+e[2]*i[11]+e[3]*i[16],t[2]=e[0]*i[2]+e[1]*i[7]+e[2]*i[12]+e[3]*i[17],t[3]=e[0]*i[3]+e[1]*i[8]+e[2]*i[13]+e[3]*i[18],t[4]=e[0]*i[4]+e[1]*i[9]+e[2]*i[14]+e[3]*i[19]+e[4],t[5]=e[5]*i[0]+e[6]*i[5]+e[7]*i[10]+e[8]*i[15],t[6]=e[5]*i[1]+e[6]*i[6]+e[7]*i[11]+e[8]*i[16],t[7]=e[5]*i[2]+e[6]*i[7]+e[7]*i[12]+e[8]*i[17],t[8]=e[5]*i[3]+e[6]*i[8]+e[7]*i[13]+e[8]*i[18],t[9]=e[5]*i[4]+e[6]*i[9]+e[7]*i[14]+e[8]*i[19]+e[9],t[10]=e[10]*i[0]+e[11]*i[5]+e[12]*i[10]+e[13]*i[15],t[11]=e[10]*i[1]+e[11]*i[6]+e[12]*i[11]+e[13]*i[16],t[12]=e[10]*i[2]+e[11]*i[7]+e[12]*i[12]+e[13]*i[17],t[13]=e[10]*i[3]+e[11]*i[8]+e[12]*i[13]+e[13]*i[18],t[14]=e[10]*i[4]+e[11]*i[9]+e[12]*i[14]+e[13]*i[19]+e[14],t[15]=e[15]*i[0]+e[16]*i[5]+e[17]*i[10]+e[18]*i[15],t[16]=e[15]*i[1]+e[16]*i[6]+e[17]*i[11]+e[18]*i[16],t[17]=e[15]*i[2]+e[16]*i[7]+e[17]*i[12]+e[18]*i[17],t[18]=e[15]*i[3]+e[16]*i[8]+e[17]*i[13]+e[18]*i[18],t[19]=e[15]*i[4]+e[16]*i[9]+e[17]*i[14]+e[18]*i[19]+e[19],t}_colorMatrix(t){const e=new Float32Array(t);return e[4]/=255,e[9]/=255,e[14]/=255,e[19]/=255,e}brightness(t,e){const i=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}tint(t,e){const[i,s,n]=Nt.shared.setValue(t).toArray(),o=[i,0,0,0,0,0,s,0,0,0,0,0,n,0,0,0,0,0,1,0];this._loadMatrix(o,e)}greyscale(t,e){const i=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}blackAndWhite(t){const e=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(e,t)}hue(t,e){t=(t||0)/180*Math.PI;const i=Math.cos(t),s=Math.sin(t),n=Math.sqrt,o=1/3,a=n(o),l=i+(1-i)*o,h=o*(1-i)-a*s,u=o*(1-i)+a*s,c=o*(1-i)+a*s,d=i+o*(1-i),f=o*(1-i)-a*s,p=o*(1-i)-a*s,m=o*(1-i)+a*s,_=i+o*(1-i),y=[l,h,u,0,0,c,d,f,0,0,p,m,_,0,0,0,0,0,1,0];this._loadMatrix(y,e)}contrast(t,e){const i=(t||0)+1,s=-.5*(i-1),n=[i,0,0,0,s,0,i,0,0,s,0,0,i,0,s,0,0,0,1,0];this._loadMatrix(n,e)}saturate(t=0,e){const i=t*2/3+1,s=(i-1)*-.5,n=[i,s,s,0,0,s,i,s,0,0,s,s,i,0,0,0,0,0,1,0];this._loadMatrix(n,e)}desaturate(){this.saturate(-1)}negative(t){const e=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(e,t)}sepia(t){const e=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(e,t)}technicolor(t){const e=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(e,t)}polaroid(t){const e=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(e,t)}toBGR(t){const e=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)}kodachrome(t){const e=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(e,t)}browni(t){const e=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(e,t)}vintage(t){const e=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(e,t)}colorTone(t,e,i,s,n){t=t||.2,e=e||.15,i=i||16770432,s=s||3375104;const o=Nt.shared,[a,l,h]=o.setValue(i).toArray(),[u,c,d]=o.setValue(s).toArray(),f=[.3,.59,.11,0,0,a,l,h,t,0,u,c,d,e,0,a-u,l-c,h-d,0,0];this._loadMatrix(f,n)}night(t,e){t=t||.1;const i=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(i,e)}predator(t,e){const i=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(i,e)}lsd(t){const e=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(e,t)}reset(){const t=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(t,!1)}get matrix(){return this.uniforms.m}set matrix(t){this.uniforms.m=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}Nh.prototype.grayscale=Nh.prototype.greyscale;var PA=`varying vec2 vFilterCoord;
623
623
  varying vec2 vTextureCoord;
624
624
 
625
625
  uniform vec2 scale;
@@ -639,7 +639,7 @@ void main(void)
639
639
 
640
640
  gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw));
641
641
  }
642
- `,EA=`attribute vec2 aVertexPosition;
642
+ `,OA=`attribute vec2 aVertexPosition;
643
643
 
644
644
  uniform mat3 projectionMatrix;
645
645
  uniform mat3 filterMatrix;
@@ -668,7 +668,7 @@ void main(void)
668
668
  vTextureCoord = filterTextureCoord();
669
669
  vFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0) ).xy;
670
670
  }
671
- `;class wA extends Be{constructor(t,e){const i=new Ut;t.renderable=!1,super(EA,bA,{mapSampler:t._texture,filterMatrix:i,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])}),this.maskSprite=t,this.maskMatrix=i,e==null&&(e=20),this.scale=new It(e,e)}apply(t,e,i,s){this.uniforms.filterMatrix=t.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;const n=this.maskSprite.worldTransform,o=Math.sqrt(n.a*n.a+n.b*n.b),a=Math.sqrt(n.c*n.c+n.d*n.d);o!==0&&a!==0&&(this.uniforms.rotation[0]=n.a/o,this.uniforms.rotation[1]=n.b/o,this.uniforms.rotation[2]=n.c/a,this.uniforms.rotation[3]=n.d/a),t.applyFilter(this,e,i,s)}get map(){return this.uniforms.mapSampler}set map(t){this.uniforms.mapSampler=t}}var TA=`varying vec2 v_rgbNW;
671
+ `;class NA extends Be{constructor(t,e){const i=new Gt;t.renderable=!1,super(OA,PA,{mapSampler:t._texture,filterMatrix:i,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])}),this.maskSprite=t,this.maskMatrix=i,e==null&&(e=20),this.scale=new It(e,e)}apply(t,e,i,s){this.uniforms.filterMatrix=t.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;const n=this.maskSprite.worldTransform,o=Math.sqrt(n.a*n.a+n.b*n.b),a=Math.sqrt(n.c*n.c+n.d*n.d);o!==0&&a!==0&&(this.uniforms.rotation[0]=n.a/o,this.uniforms.rotation[1]=n.b/o,this.uniforms.rotation[2]=n.c/a,this.uniforms.rotation[3]=n.d/a),t.applyFilter(this,e,i,s)}get map(){return this.uniforms.mapSampler}set map(t){this.uniforms.mapSampler=t}}var DA=`varying vec2 v_rgbNW;
672
672
  varying vec2 v_rgbNE;
673
673
  varying vec2 v_rgbSW;
674
674
  varying vec2 v_rgbSE;
@@ -789,7 +789,7 @@ void main() {
789
789
 
790
790
  gl_FragColor = color;
791
791
  }
792
- `,AA=`
792
+ `,LA=`
793
793
  attribute vec2 aVertexPosition;
794
794
 
795
795
  uniform mat3 projectionMatrix;
@@ -831,7 +831,7 @@ void main(void) {
831
831
 
832
832
  texcoords(vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);
833
833
  }
834
- `;class SA extends Be{constructor(){super(AA,TA)}}var CA=`precision highp float;
834
+ `;class BA extends Be{constructor(){super(LA,DA)}}var FA=`precision highp float;
835
835
 
836
836
  varying vec2 vTextureCoord;
837
837
  varying vec4 vColor;
@@ -865,8 +865,8 @@ void main()
865
865
 
866
866
  gl_FragColor = color;
867
867
  }
868
- `;class IA extends Be{constructor(t=.5,e=Math.random()){super(lm,CA,{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 ym={AlphaFilter:fA,BlurFilter:vA,BlurFilterPass:Ih,ColorMatrixFilter:Rh,DisplacementFilter:wA,FXAAFilter:SA,NoiseFilter:IA};Object.entries(ym).forEach(([r,t])=>{Object.defineProperty(ym,r,{get(){return St("7.1.0",`filters.${r} has moved to ${r}`),t}})});class RA{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||(Xe.system.add(this.tickerUpdate,this,ki.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(Xe.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 ni=new RA;class cn{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=cn.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new It,this.page=new It,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 Io extends cn{constructor(){super(...arguments),this.client=new It,this.movement=new It,this.offset=new It,this.global=new It,this.screen=new It}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,u,c,d,f,p,m){throw new Error("Method not implemented.")}}class or extends Io{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 vs extends Io{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}vs.DOM_DELTA_PIXEL=0,vs.DOM_DELTA_LINE=1,vs.DOM_DELTA_PAGE=2;const MA=2048,PA=new It,Mh=new It;class OA{constructor(t){this.dispatch=new Xs,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){ni.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",s=this[i](this.rootTarget,this.rootTarget.eventMode,PA.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<MA&&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")&&(ni.pauseUpdate=!1),t.interactiveChildren&&t.children){const u=t.children;for(let c=u.length-1;c>=0;c--){const d=u[c],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")&&(ni.pauseUpdate=!1),t.interactiveChildren&&t.children){const l=t.children;for(let h=l.length-1;h>=0;h--){const u=l[h],c=this.hitTestRecursive(u,this._isInteractive(e)?e:u.eventMode,i,s,n);if(c){if(c.length>0&&!c[c.length-1].parent)continue;const d=t.isInteractive();return(c.length>0||d)&&c.push(t),c}}}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,Mh),!t.hitArea.contains(Mh.x,Mh.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 or)){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 or)){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 u=t.type==="mousemove"?"mouseout":"pointerout",c=this.createPointerEvent(t,u,n);if(this.dispatchEvent(c,"pointerout"),i&&this.dispatchEvent(c,"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(c)}if(n!==e.target){const u=t.type==="mousemove"?"mouseover":"pointerover",c=this.clonePointerEvent(e,u);this.dispatchEvent(c,"pointerover"),i&&this.dispatchEvent(c,"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(c)}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 or)){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 or)){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 or)){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 or)){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 vs)){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(or);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(vs);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(or);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 or&&e instanceof or&&(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 Io&&e instanceof Io&&(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 NA=1,DA={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Ph=class au{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new OA(null),ni.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new or(null),this.rootWheelEvent=new vs(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...au.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,au._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,ni.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,ni.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;ni.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;ni.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():{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=NA),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=DA[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}};Ph.extension={name:"events",type:[Q.RendererSystem,Q.CanvasRendererSystem]},Ph.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Oh=Ph;ht.add(Oh);function _m(r){return r==="dynamic"||r==="static"}const LA={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??_m(Oh.defaultEventMode)},set interactive(r){St("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??Oh.defaultEventMode},set eventMode(r){this._internalInteractive=_m(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 cn))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}};Wt.mixin(LA);const BA={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};Wt.mixin(BA);const FA=9,Ro=100,kA=0,UA=0,vm=2,xm=1,GA=-1e3,HA=-1e3,$A=2;class bm{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,(Mr.tablet||Mr.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${Ro}px`,e.style.height=`${Ro}px`,e.style.position="absolute",e.style.top=`${kA}px`,e.style.left=`${UA}px`,e.style.zIndex=vm.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=`${xm}px`,t.style.height=`${xm}px`,t.style.position="absolute",t.style.top=`${GA}px`,t.style.left=`${HA}px`,t.style.zIndex=$A.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(Mr.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,u=n/a*l;let c=this.div;c.style.left=`${e}px`,c.style.top=`${i}px`,c.style.width=`${o}px`,c.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,ps(this.children,d,1),this.div.removeChild(f._accessibleDiv),this.pool.push(f._accessibleDiv),f._accessibleDiv=null,d--;else{c=f._accessibleDiv;let p=f.hitArea;const m=f.worldTransform;f.hitArea?(c.style.left=`${(m.tx+p.x*m.a)*h}px`,c.style.top=`${(m.ty+p.y*m.d)*u}px`,c.style.width=`${p.width*m.a*h}px`,c.style.height=`${p.height*m.d*u}px`):(p=f.getBounds(),this.capHitArea(p),c.style.left=`${p.x*h}px`,c.style.top=`${p.y*u}px`,c.style.width=`${p.width*h}px`,c.style.height=`${p.height*u}px`,c.title!==f.accessibleTitle&&f.accessibleTitle!==null&&(c.title=f.accessibleTitle),c.getAttribute("aria-label")!==f.accessibleHint&&f.accessibleHint!==null&&c.setAttribute("aria-label",f.accessibleHint)),(f.accessibleTitle!==c.title||f.tabIndex!==c.tabIndex)&&(c.title=f.accessibleTitle,c.tabIndex=f.tabIndex,this.debug&&this.updateDebugHTML(c))}}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=`${Ro}px`,e.style.height=`${Ro}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=vm.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 cn(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===FA&&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}}bm.extension={name:"accessibility",type:[Q.RendererPlugin,Q.CanvasRendererPlugin]},ht.add(bm);const Em=class lu{constructor(t){this.stage=new nr,t=Object.assign({forceCanvas:!1},t),this.renderer=am(t),lu._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=lu._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}};Em._plugins=[];let XA=Em;ht.handleByList(Q.Application,XA._plugins);class wm{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}}wm.extension=Q.Application,ht.add(wm);const Tm={loader:Q.LoadParser,resolver:Q.ResolveParser,cache:Q.CacheParser,detection:Q.DetectionParser};ht.handle(Q.Asset,r=>{const t=r.ref;Object.entries(Tm).filter(([e])=>!!t[e]).forEach(([e,i])=>ht.add(Object.assign(t[e],{extension:t[e].extension??i})))},r=>{const t=r.ref;Object.keys(Tm).filter(e=>!!t[e]).forEach(e=>ht.remove(t[e]))});class VA{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 xs(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 oi(r,t){const e=r.split("?")[0],i=ge.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const ar=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(i=>typeof i=="string"||e?t(i):i):r),Nh=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r};function Am(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?Am(r.replace(i[e],a),t,e+1,i,s):s.push(r.replace(i[e],a))}}function zA(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)}),Am(r,s,0,e,i)}else i.push(r);return i}const Mo=r=>!Array.isArray(r);class YA{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=ar(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=>{const l=s?s[a]:e;this._cache.has(a)&&this._cache.get(a)!==l&&console.warn("[Cache] already has key:",a),this._cache.set(a,s[a])}),e instanceof ut){const a=e;i.forEach(l=>{a.baseTexture!==ut.EMPTY.baseTexture&&vt.addToCache(a.baseTexture,l),ut.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 Ui=new YA;class WA{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=Mo(t),o=ar(t,h=>({alias:[h],src:h})),a=o.length,l=o.map(async h=>{const u=ge.toAbsolute(h.src);if(!s[h.src])try{this.promiseCache[u]||(this.promiseCache[u]=this._getLoadPromiseAndParser(u,h)),s[h.src]=await this.promiseCache[u].promise,e&&e(++i/a)}catch(c){throw delete this.promiseCache[u],delete s[h.src],new Error(`[Loader.load] Failed to load ${u}.
869
- ${c}`)}});return await Promise.all(l),n?s[o[0].src]:s}async unload(t){const e=ar(t,i=>({alias:[i],src:i})).map(async i=>{var o,a;const s=ge.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 lr=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(lr||{});const jA=".json",qA="application/json",KA={extension:{type:Q.LoadParser,priority:lr.Low},name:"loadJson",test(r){return xs(r,qA)||oi(r,jA)},async load(r){return await(await tt.ADAPTER.fetch(r)).json()}};ht.add(KA);const ZA=".txt",QA="text/plain",JA={name:"loadTxt",extension:{type:Q.LoadParser,priority:lr.Low},test(r){return xs(r,QA)||oi(r,ZA)},async load(r){return await(await tt.ADAPTER.fetch(r)).text()}};ht.add(JA);const tS=["normal","bold","100","200","300","400","500","600","700","800","900"],eS=[".ttf",".otf",".woff",".woff2"],rS=["font/ttf","font/otf","font/woff","font/woff2"],iS=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function sS(r){const t=ge.extname(r),e=ge.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(iS)){i=!1;break}let s=e.join(" ");return i||(s=`"${s.replace(/[\\"]/g,"\\$&")}"`),s}const nS=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function oS(r){return nS.test(r)?r:encodeURI(r)}const aS={extension:{type:Q.LoadParser,priority:lr.Low},name:"loadWebFont",test(r){return xs(r,rS)||oi(r,eS)},async load(r,t){var i,s,n;const e=tt.ADAPTER.getFontFaceSet();if(e){const o=[],a=((i=t.data)==null?void 0:i.family)??sS(r),l=((n=(s=t.data)==null?void 0:s.weights)==null?void 0:n.filter(u=>tS.includes(u)))??["normal"],h=t.data??{};for(let u=0;u<l.length;u++){const c=l[u],d=new FontFace(a,`url(${oS(r)})`,{...h,weight:c});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=>tt.ADAPTER.getFontFaceSet().delete(t))}};ht.add(aS);const lS=`(function() {
868
+ `;class kA extends Be{constructor(t=.5,e=Math.random()){super(pm,FA,{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 wm={AlphaFilter:wA,BlurFilter:RA,BlurFilterPass:Oh,ColorMatrixFilter:Nh,DisplacementFilter:NA,FXAAFilter:BA,NoiseFilter:kA};Object.entries(wm).forEach(([r,t])=>{Object.defineProperty(wm,r,{get(){return St("7.1.0",`filters.${r} has moved to ${r}`),t}})});class UA{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||(Xe.system.add(this.tickerUpdate,this,ki.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(Xe.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 ni=new UA;class pn{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=pn.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new It,this.page=new It,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 Oo extends pn{constructor(){super(...arguments),this.client=new It,this.movement=new It,this.offset=new It,this.global=new It,this.screen=new It}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,u,c,d,f,p,m){throw new Error("Method not implemented.")}}class or extends Oo{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 xs extends Oo{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}xs.DOM_DELTA_PIXEL=0,xs.DOM_DELTA_LINE=1,xs.DOM_DELTA_PAGE=2;const GA=2048,$A=new It,Dh=new It;class HA{constructor(t){this.dispatch=new Ys,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){ni.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",s=this[i](this.rootTarget,this.rootTarget.eventMode,$A.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<GA&&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")&&(ni.pauseUpdate=!1),t.interactiveChildren&&t.children){const u=t.children;for(let c=u.length-1;c>=0;c--){const d=u[c],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")&&(ni.pauseUpdate=!1),t.interactiveChildren&&t.children){const l=t.children;for(let h=l.length-1;h>=0;h--){const u=l[h],c=this.hitTestRecursive(u,this._isInteractive(e)?e:u.eventMode,i,s,n);if(c){if(c.length>0&&!c[c.length-1].parent)continue;const d=t.isInteractive();return(c.length>0||d)&&c.push(t),c}}}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,Dh),!t.hitArea.contains(Dh.x,Dh.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 or)){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 or)){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 u=t.type==="mousemove"?"mouseout":"pointerout",c=this.createPointerEvent(t,u,n);if(this.dispatchEvent(c,"pointerout"),i&&this.dispatchEvent(c,"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(c)}if(n!==e.target){const u=t.type==="mousemove"?"mouseover":"pointerover",c=this.clonePointerEvent(e,u);this.dispatchEvent(c,"pointerover"),i&&this.dispatchEvent(c,"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(c)}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 or)){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 or)){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 or)){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 or)){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 xs)){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(or);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(xs);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(or);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 or&&e instanceof or&&(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 Oo&&e instanceof Oo&&(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 XA=1,VA={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Lh=class cu{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new HA(null),ni.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new or(null),this.rootWheelEvent=new xs(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...cu.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,cu._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,ni.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,ni.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;ni.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;ni.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():{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=XA),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=VA[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}};Lh.extension={name:"events",type:[Q.RendererSystem,Q.CanvasRendererSystem]},Lh.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Bh=Lh;ut.add(Bh);function Tm(r){return r==="dynamic"||r==="static"}const zA={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??Tm(Bh.defaultEventMode)},set interactive(r){St("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??Bh.defaultEventMode},set eventMode(r){this._internalInteractive=Tm(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 pn))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}};qt.mixin(zA);const YA={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};qt.mixin(YA);const jA=9,No=100,WA=0,qA=0,Am=2,Sm=1,KA=-1e3,ZA=-1e3,QA=2;class Cm{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,(Pr.tablet||Pr.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${No}px`,e.style.height=`${No}px`,e.style.position="absolute",e.style.top=`${WA}px`,e.style.left=`${qA}px`,e.style.zIndex=Am.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=`${Sm}px`,t.style.height=`${Sm}px`,t.style.position="absolute",t.style.top=`${KA}px`,t.style.left=`${ZA}px`,t.style.zIndex=QA.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(Pr.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,u=n/a*l;let c=this.div;c.style.left=`${e}px`,c.style.top=`${i}px`,c.style.width=`${o}px`,c.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,ms(this.children,d,1),this.div.removeChild(f._accessibleDiv),this.pool.push(f._accessibleDiv),f._accessibleDiv=null,d--;else{c=f._accessibleDiv;let p=f.hitArea;const m=f.worldTransform;f.hitArea?(c.style.left=`${(m.tx+p.x*m.a)*h}px`,c.style.top=`${(m.ty+p.y*m.d)*u}px`,c.style.width=`${p.width*m.a*h}px`,c.style.height=`${p.height*m.d*u}px`):(p=f.getBounds(),this.capHitArea(p),c.style.left=`${p.x*h}px`,c.style.top=`${p.y*u}px`,c.style.width=`${p.width*h}px`,c.style.height=`${p.height*u}px`,c.title!==f.accessibleTitle&&f.accessibleTitle!==null&&(c.title=f.accessibleTitle),c.getAttribute("aria-label")!==f.accessibleHint&&f.accessibleHint!==null&&c.setAttribute("aria-label",f.accessibleHint)),(f.accessibleTitle!==c.title||f.tabIndex!==c.tabIndex)&&(c.title=f.accessibleTitle,c.tabIndex=f.tabIndex,this.debug&&this.updateDebugHTML(c))}}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=`${No}px`,e.style.height=`${No}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=Am.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 pn(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===jA&&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}}Cm.extension={name:"accessibility",type:[Q.RendererPlugin,Q.CanvasRendererPlugin]},ut.add(Cm);const Im=class du{constructor(t){this.stage=new nr,t=Object.assign({forceCanvas:!1},t),this.renderer=fm(t),du._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=du._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}};Im._plugins=[];let JA=Im;ut.handleByList(Q.Application,JA._plugins);class Rm{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}}Rm.extension=Q.Application,ut.add(Rm);const Mm={loader:Q.LoadParser,resolver:Q.ResolveParser,cache:Q.CacheParser,detection:Q.DetectionParser};ut.handle(Q.Asset,r=>{const t=r.ref;Object.entries(Mm).filter(([e])=>!!t[e]).forEach(([e,i])=>ut.add(Object.assign(t[e],{extension:t[e].extension??i})))},r=>{const t=r.ref;Object.keys(Mm).filter(e=>!!t[e]).forEach(e=>ut.remove(t[e]))});class tS{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 bs(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 oi(r,t){const e=r.split("?")[0],i=ye.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const ar=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(i=>typeof i=="string"||e?t(i):i):r),Fh=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r};function Pm(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?Pm(r.replace(i[e],a),t,e+1,i,s):s.push(r.replace(i[e],a))}}function eS(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)}),Pm(r,s,0,e,i)}else i.push(r);return i}const Do=r=>!Array.isArray(r);class rS{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=ar(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=>{const l=s?s[a]:e;this._cache.has(a)&&this._cache.get(a)!==l&&console.warn("[Cache] already has key:",a),this._cache.set(a,s[a])}),e instanceof ct){const a=e;i.forEach(l=>{a.baseTexture!==ct.EMPTY.baseTexture&&bt.addToCache(a.baseTexture,l),ct.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 Ui=new rS;class iS{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=Do(t),o=ar(t,h=>({alias:[h],src:h})),a=o.length,l=o.map(async h=>{const u=ye.toAbsolute(h.src);if(!s[h.src])try{this.promiseCache[u]||(this.promiseCache[u]=this._getLoadPromiseAndParser(u,h)),s[h.src]=await this.promiseCache[u].promise,e&&e(++i/a)}catch(c){throw delete this.promiseCache[u],delete s[h.src],new Error(`[Loader.load] Failed to load ${u}.
869
+ ${c}`)}});return await Promise.all(l),n?s[o[0].src]:s}async unload(t){const e=ar(t,i=>({alias:[i],src:i})).map(async i=>{var o,a;const s=ye.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 lr=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(lr||{});const sS=".json",nS="application/json",oS={extension:{type:Q.LoadParser,priority:lr.Low},name:"loadJson",test(r){return bs(r,nS)||oi(r,sS)},async load(r){return await(await tt.ADAPTER.fetch(r)).json()}};ut.add(oS);const aS=".txt",lS="text/plain",hS={name:"loadTxt",extension:{type:Q.LoadParser,priority:lr.Low},test(r){return bs(r,lS)||oi(r,aS)},async load(r){return await(await tt.ADAPTER.fetch(r)).text()}};ut.add(hS);const uS=["normal","bold","100","200","300","400","500","600","700","800","900"],cS=[".ttf",".otf",".woff",".woff2"],dS=["font/ttf","font/otf","font/woff","font/woff2"],fS=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function pS(r){const t=ye.extname(r),e=ye.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(fS)){i=!1;break}let s=e.join(" ");return i||(s=`"${s.replace(/[\\"]/g,"\\$&")}"`),s}const mS=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function gS(r){return mS.test(r)?r:encodeURI(r)}const yS={extension:{type:Q.LoadParser,priority:lr.Low},name:"loadWebFont",test(r){return bs(r,dS)||oi(r,cS)},async load(r,t){var i,s,n;const e=tt.ADAPTER.getFontFaceSet();if(e){const o=[],a=((i=t.data)==null?void 0:i.family)??pS(r),l=((n=(s=t.data)==null?void 0:s.weights)==null?void 0:n.filter(u=>uS.includes(u)))??["normal"],h=t.data??{};for(let u=0;u<l.length;u++){const c=l[u],d=new FontFace(a,`url(${gS(r)})`,{...h,weight:c});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=>tt.ADAPTER.getFontFaceSet().delete(t))}};ut.add(yS);const _S=`(function() {
870
870
  "use strict";
871
871
  const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
872
872
  async function checkImageBitmap() {
@@ -883,7 +883,7 @@ ${c}`)}});return await Promise.all(l),n?s[o[0].src]:s}async unload(t){const e=ar
883
883
  self.postMessage(result);
884
884
  });
885
885
  })();
886
- `;let bs=null,Dh=class{constructor(){bs||(bs=URL.createObjectURL(new Blob([lS],{type:"application/javascript"}))),this.worker=new Worker(bs)}};Dh.revokeObjectURL=function(){bs&&(URL.revokeObjectURL(bs),bs=null)};const hS=`(function() {
886
+ `;let Es=null,kh=class{constructor(){Es||(Es=URL.createObjectURL(new Blob([_S],{type:"application/javascript"}))),this.worker=new Worker(Es)}};kh.revokeObjectURL=function(){Es&&(URL.revokeObjectURL(Es),Es=null)};const vS=`(function() {
887
887
  "use strict";
888
888
  async function loadImageBitmap(url) {
889
889
  const response = await fetch(url);
@@ -909,8 +909,8 @@ ${c}`)}});return await Promise.all(l),n?s[o[0].src]:s}async unload(t){const e=ar
909
909
  }
910
910
  };
911
911
  })();
912
- `;let Es=null;class Sm{constructor(){Es||(Es=URL.createObjectURL(new Blob([hS],{type:"application/javascript"}))),this.worker=new Worker(Es)}}Sm.revokeObjectURL=function(){Es&&(URL.revokeObjectURL(Es),Es=null)};let Cm=0,Lh;class uS{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 Dh;e.addEventListener("message",i=>{e.terminate(),Dh.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){Lh===void 0&&(Lh=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<Lh&&(this._createdWorkers++,t=new Sm().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[Cm]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Cm++,id:i})}}const Im=new uS;function dn(r,t,e){r.resource.internal=!0;const i=new ut(r),s=()=>{delete t.promiseCache[e],Ui.has(e)&&Ui.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 cS=[".jpeg",".jpg",".png",".webp",".avif"],dS=["image/jpeg","image/png","image/webp","image/avif"];async function fS(r){const t=await tt.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 Po={name:"loadTextures",extension:{type:Q.LoadParser,priority:lr.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return xs(r,dS)||oi(r,cS)},async load(r,t,e){var a;const i=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let s;i?this.config.preferWorkers&&await Im.isImageBitmapSupported()?s=await Im.loadImageBitmap(r):s=await fS(r):s=await new Promise((l,h)=>{const u=new Image;u.crossOrigin=this.config.crossOrigin,u.src=r,u.complete?l(u):(u.onload=()=>l(u),u.onerror=c=>h(c))});const n={...t.data};n.resolution??(n.resolution=Dr(r)),i&&((a=n.resourceOptions)==null?void 0:a.ownsImageBitmap)===void 0&&(n.resourceOptions={...n.resourceOptions},n.resourceOptions.ownsImageBitmap=!0);const o=new vt(s,n);return o.resource.src=r,dn(o,e,r)},unload(r){r.destroy(!0)}};ht.add(Po);const pS=".svg",mS="image/svg+xml",gS={extension:{type:Q.LoadParser,priority:lr.High},name:"loadSVG",test(r){return xs(r,mS)||oi(r,pS)},async testParse(r){return Sh.test(r)},async parse(r,t,e){var n;const i=new Sh(r,(n=t==null?void 0:t.data)==null?void 0:n.resourceOptions);await i.load();const s=new vt(i,{resolution:Dr(r),...t==null?void 0:t.data});return s.resource.src=t.src,dn(s,e,t.src)},async load(r,t){return(await tt.ADAPTER.fetch(r)).text()},unload:Po.unload};ht.add(gS);const yS=[".mp4",".m4v",".webm",".ogv"],_S=["video/mp4","video/webm","video/ogg"],vS={name:"loadVideo",extension:{type:Q.LoadParser,priority:lr.High},config:{defaultAutoPlay:!0,defaultUpdateFPS:0,defaultLoop:!1,defaultMuted:!1,defaultPlaysinline:!0},test(r){return xs(r,_S)||oi(r,yS)},async load(r,t,e){var o;let i;const s=await(await tt.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 pm(n,a);await l.load();const h=new vt(l,{alphaMode:await Aw(),resolution:Dr(r),...t==null?void 0:t.data});h.resource.src=r,i=dn(h,e,r),i.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(n)})}catch(a){throw URL.revokeObjectURL(n),a}return i},unload(r){r.destroy(!0)}};ht.add(vS);class xS{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 ar(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"?(St("7.2.0",`Assets.add now uses an object instead of individual parameters.
913
- 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`)},ar(o).forEach(l=>{const{src:h,srcs:u}=l;let{data:c,format:d,loadParser:f}=l;const p=ar(h||u).map(y=>typeof y=="string"?zA(y):Array.isArray(y)?y:[y]),m=this.getAlias(l);Array.isArray(m)?m.forEach(a):a(m);const _=[];p.forEach(y=>{y.forEach(v=>{let g={};if(typeof v!="object"){g.src=v;for(let x=0;x<this._parsers.length;x++){const E=this._parsers[x];if(E.test(v)){g=E.parse(v);break}}}else c=v.data??c,d=v.format??d,f=v.loadParser??f,g={...g,...v};if(!m)throw new Error(`[Resolver] alias is undefined for this asset: ${g.src}`);g=this.buildResolvedAsset(g,{aliases:m,data:c,format:d,loadParser:f}),_.push(g)})}),m.forEach(y=>{this._assetMap[y]=_})})}resolveBundle(t){const e=Mo(t);t=ar(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=Mo(t);t=ar(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 u=n.filter(c=>c[l]?c[l]===h:!1);u.length&&(n=u)})}),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=ge.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??ge.extname(t.src).slice(1),t.srcs=t.src,t.name=t.alias,t}}class bS{constructor(){this._detections=[],this._initialized=!1,this.resolver=new xS,this.loader=new WA,this.cache=Ui,this._backgroundLoader=new VA(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=Mo(t),s=ar(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)},u=o.map(c=>{const d=s[c];return l+=Object.keys(d).length,this._mapLoadToResolve(d,h).then(f=>{n[c]=f})});return await Promise.all(u),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 Ui.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=Ui.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],u=[a.src];a.alias&&u.push(...a.alias),o[s[l]]=h,Ui.set(u,h)}),o}async unload(t){this._initialized||await this.init();const e=ar(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=ar(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=>{Ui.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 Po.config.preferWorkers}set preferWorkers(t){St("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 Oo=new bS;ht.handleByList(Q.LoadParser,Oo.loader.parsers).handleByList(Q.ResolveParser,Oo.resolver.parsers).handleByList(Q.CacheParser,Oo.cache.parsers).handleByList(Q.DetectionParser,Oo.detections);const ES={extension:Q.CacheParser,test:r=>Array.isArray(r)&&r.every(t=>t instanceof ut),getCacheableAssets:(r,t)=>{const e={};return r.forEach(i=>{t.forEach((s,n)=>{e[i+(n===0?"":n+1)]=s})}),e}};ht.add(ES);async function Rm(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 wS={extension:{type:Q.DetectionParser,priority:1},test:async()=>Rm("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")};ht.add(wS);const TS={extension:{type:Q.DetectionParser,priority:0},test:async()=>Rm("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};ht.add(TS);const Mm=["png","jpg","jpeg"],AS={extension:{type:Q.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...Mm],remove:async r=>r.filter(t=>!Mm.includes(t))};ht.add(AS);const SS="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Bh(r){return SS?!1:document.createElement("video").canPlayType(r)!==""}const CS={extension:{type:Q.DetectionParser,priority:0},test:async()=>Bh("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")};ht.add(CS);const IS={extension:{type:Q.DetectionParser,priority:0},test:async()=>Bh("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")};ht.add(IS);const RS={extension:{type:Q.DetectionParser,priority:0},test:async()=>Bh("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")};ht.add(RS);const MS={extension:Q.ResolveParser,test:Po.test,parse:r=>{var t;return{resolution:parseFloat(((t=tt.RETINA_PREFIX.exec(r))==null?void 0:t[1])??"1"),format:ge.extname(r).slice(1),src:r}}};ht.add(MS);var Se=(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))(Se||{});const No={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 Tr,ws;function Pm(){ws={bptc:Tr.getExtension("EXT_texture_compression_bptc"),astc:Tr.getExtension("WEBGL_compressed_texture_astc"),etc:Tr.getExtension("WEBGL_compressed_texture_etc"),s3tc:Tr.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:Tr.getExtension("WEBGL_compressed_texture_s3tc_srgb"),pvrtc:Tr.getExtension("WEBGL_compressed_texture_pvrtc")||Tr.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:Tr.getExtension("WEBGL_compressed_texture_etc1"),atc:Tr.getExtension("WEBGL_compressed_texture_atc")}}const PS={extension:{type:Q.DetectionParser,priority:2},test:async()=>{const r=tt.ADAPTER.createCanvas().getContext("webgl");return r?(Tr=r,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async r=>{ws||Pm();const t=[];for(const e in ws)ws[e]&&t.push(e);return[...t,...r]},remove:async r=>(ws||Pm(),r.filter(t=>!(t in ws)))};ht.add(PS);class OS extends oo{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 eh(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 eh(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class Gi extends OS{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=Gi._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||Gi._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:u}=this._levelBuffers[n];s.compressedTexImage2D(s.TEXTURE_2D,a,this.format,l,h,0,u)}return!0}onBlobLoaded(){this._levelBuffers=Gi._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,u=o,c=a,d=u+s-1&~(s-1),f=c+n-1&~(n-1),p=d*f*No[e];for(let m=0;m<i;m++)l[m]={levelID:m,levelWidth:i>1?u:d,levelHeight:i>1?c:f,levelBuffer:new Uint8Array(t.buffer,h,p)},h+=p,u=u>>1||1,c=c>>1||1,d=u+s-1&~(s-1),f=c+n-1&~(n-1),p=d*f*No[e];return l}}const Fh=4,Do=124,NS=32,Om=20,DS=542327876,Lo={HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},LS={FOURCC:2},Bo={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3},BS=1,FS=2,kS=4,US=64,GS=512,HS=131072,$S=827611204,XS=861165636,VS=894720068,zS=808540228,YS=4,WS={[$S]:Se.COMPRESSED_RGBA_S3TC_DXT1_EXT,[XS]:Se.COMPRESSED_RGBA_S3TC_DXT3_EXT,[VS]:Se.COMPRESSED_RGBA_S3TC_DXT5_EXT},jS={70:Se.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:Se.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:Se.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:Se.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:Se.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:Se.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:Se.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:Se.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:Se.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,96:Se.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,95:Se.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,98:Se.COMPRESSED_RGBA_BPTC_UNORM_EXT,99:Se.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT};function qS(r){const t=new Uint32Array(r);if(t[0]!==DS)throw new Error("Invalid DDS file magic word");const e=new Uint32Array(r,0,Do/Uint32Array.BYTES_PER_ELEMENT),i=e[Lo.HEIGHT],s=e[Lo.WIDTH],n=e[Lo.MIPMAP_COUNT],o=new Uint32Array(r,Lo.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,NS/Uint32Array.BYTES_PER_ELEMENT),a=o[BS];if(a&kS){const l=o[LS.FOURCC];if(l!==zS){const v=WS[l],g=Fh+Do,x=new Uint8Array(r,g);return[new Gi(x,{format:v,width:s,height:i,levels:n})]}const h=Fh+Do,u=new Uint32Array(t.buffer,h,Om/Uint32Array.BYTES_PER_ELEMENT),c=u[Bo.DXGI_FORMAT],d=u[Bo.RESOURCE_DIMENSION],f=u[Bo.MISC_FLAG],p=u[Bo.ARRAY_SIZE],m=jS[c];if(m===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${c}`);if(f===YS)throw new Error("DDSParser does not support cubemap textures");if(d===6)throw new Error("DDSParser does not supported 3D texture data");const _=new Array,y=Fh+Do+Om;if(p===1)_.push(new Uint8Array(r,y));else{const v=No[m];let g=0,x=s,E=i;for(let S=0;S<n;S++){const M=Math.max(1,x+3&-4),P=Math.max(1,E+3&-4),F=M*P*v;g+=F,x=x>>>1,E=E>>>1}let R=y;for(let S=0;S<p;S++)_.push(new Uint8Array(r,R,g)),R+=g}return _.map(v=>new Gi(v,{format:m,width:s,height:i,levels:n}))}throw a&US?new Error("DDSParser does not support uncompressed texture data."):a&GS?new Error("DDSParser does not supported YUV uncompressed texture data."):a&HS?new Error("DDSParser does not support single-channel (lumninance) texture data!"):a&FS?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 Nm=[171,75,84,88,32,49,49,187,13,10,26,10],KS=67305985,hr={ENDIANNESS:12,GL_TYPE:16,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,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},kh=64,Dm={[ft.UNSIGNED_BYTE]:1,[ft.UNSIGNED_SHORT]:2,[ft.INT]:4,[ft.UNSIGNED_INT]:4,[ft.FLOAT]:4,[ft.HALF_FLOAT]:8},ZS={[z.RGBA]:4,[z.RGB]:3,[z.RG]:2,[z.RED]:1,[z.LUMINANCE]:1,[z.LUMINANCE_ALPHA]:2,[z.ALPHA]:1},QS={[ft.UNSIGNED_SHORT_4_4_4_4]:2,[ft.UNSIGNED_SHORT_5_5_5_1]:2,[ft.UNSIGNED_SHORT_5_6_5]:2};function JS(r,t,e=!1){const i=new DataView(t);if(!tC(r,i))return null;const s=i.getUint32(hr.ENDIANNESS,!0)===KS,n=i.getUint32(hr.GL_TYPE,s),o=i.getUint32(hr.GL_FORMAT,s),a=i.getUint32(hr.GL_INTERNAL_FORMAT,s),l=i.getUint32(hr.PIXEL_WIDTH,s),h=i.getUint32(hr.PIXEL_HEIGHT,s)||1,u=i.getUint32(hr.PIXEL_DEPTH,s)||1,c=i.getUint32(hr.NUMBER_OF_ARRAY_ELEMENTS,s)||1,d=i.getUint32(hr.NUMBER_OF_FACES,s),f=i.getUint32(hr.NUMBER_OF_MIPMAP_LEVELS,s),p=i.getUint32(hr.BYTES_OF_KEY_VALUE_DATA,s);if(h===0||u!==1)throw new Error("Only 2D textures are supported");if(d!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(c!==1)throw new Error("WebGL does not support array textures");const m=4,_=4,y=l+3&-4,v=h+3&-4,g=new Array(c);let x=l*h;n===0&&(x=y*v);let E;if(n!==0?Dm[n]?E=Dm[n]*ZS[o]:E=QS[n]:E=No[a],E===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const R=e?rC(i,p,s):null;let S=x*E,M=l,P=h,F=y,U=v,I=kh+p;for(let A=0;A<f;A++){const w=i.getUint32(I,s);let C=I+4;for(let D=0;D<c;D++){let N=g[D];N||(N=g[D]=new Array(f)),N[A]={levelID:A,levelWidth:f>1||n!==0?M:F,levelHeight:f>1||n!==0?P:U,levelBuffer:new Uint8Array(t,C,S)},C+=S}I+=w+4,I=I%4!==0?I+4-I%4:I,M=M>>1||1,P=P>>1||1,F=M+m-1&-4,U=P+_-1&-4,S=F*U*E}return n!==0?{uncompressed:g.map(A=>{let w=A[0].levelBuffer,C=!1;return n===ft.FLOAT?w=new Float32Array(A[0].levelBuffer.buffer,A[0].levelBuffer.byteOffset,A[0].levelBuffer.byteLength/4):n===ft.UNSIGNED_INT?(C=!0,w=new Uint32Array(A[0].levelBuffer.buffer,A[0].levelBuffer.byteOffset,A[0].levelBuffer.byteLength/4)):n===ft.INT&&(C=!0,w=new Int32Array(A[0].levelBuffer.buffer,A[0].levelBuffer.byteOffset,A[0].levelBuffer.byteLength/4)),{resource:new oo(w,{width:A[0].levelWidth,height:A[0].levelHeight}),type:n,format:C?eC(o):o}}),kvData:R}:{compressed:g.map(A=>new Gi(null,{format:a,width:l,height:h,levels:f,levelBuffers:A})),kvData:R}}function tC(r,t){for(let e=0;e<Nm.length;e++)if(t.getUint8(e)!==Nm[e])return console.error(`${r} is not a valid *.ktx file!`),!1;return!0}function eC(r){switch(r){case z.RGBA:return z.RGBA_INTEGER;case z.RGB:return z.RGB_INTEGER;case z.RG:return z.RG_INTEGER;case z.RED:return z.RED_INTEGER;default:return r}}function rC(r,t,e){const i=new Map;let s=0;for(;s<t;){const n=r.getUint32(kh+s,e),o=kh+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)),u=new DataView(r.buffer,o+l+1,n-l-1);i.set(h,u),s+=4+n+a}return i}const iC={extension:{type:Q.LoadParser,priority:lr.High},name:"loadDDS",test(r){return oi(r,".dds")},async load(r,t,e){const i=await(await tt.ADAPTER.fetch(r)).arrayBuffer(),s=qS(i).map(n=>{const o=new vt(n,{mipmap:pr.OFF,alphaMode:He.NO_PREMULTIPLIED_ALPHA,resolution:Dr(r),...t.data});return dn(o,e,r)});return s.length===1?s[0]:s},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};ht.add(iC);const sC={extension:{type:Q.LoadParser,priority:lr.High},name:"loadKTX",test(r){return oi(r,".ktx")},async load(r,t,e){const i=await(await tt.ADAPTER.fetch(r)).arrayBuffer(),{compressed:s,uncompressed:n,kvData:o}=JS(r,i),a=s??n,l={mipmap:pr.OFF,alphaMode:He.NO_PREMULTIPLIED_ALPHA,resolution:Dr(r),...t.data},h=a.map(u=>{a===n&&Object.assign(l,{type:u.type,format:u.format});const c=u.resource??u,d=new vt(c,l);return d.ktxKeyValueData=o,dn(d,e,r)});return h.length===1?h[0]:h},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};ht.add(sC);const nC=["s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"],oC={extension:Q.ResolveParser,test:r=>{const t=ge.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(nC.includes(n))return{resolution:parseFloat(((i=tt.RETINA_PREFIX.exec(r))==null?void 0:i[1])??"1"),format:n,src:r}}return{resolution:parseFloat(((s=tt.RETINA_PREFIX.exec(r))==null?void 0:s[1])??"1"),format:e,src:r}}};ht.add(oC);const Fo=new Et,aC=4,Lm=class _n{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&&_n._flipY(i,s,n),a&&_n._unpremultiplyAlpha(i);const l=new Hw(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&&_n._flipY(i,s,n),a&&_n._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 Li?a=t:(a=i.generateTexture(t,{region:e,resolution:i.resolution,multisample:i.multisample}),l=!0,e&&(Fo.width=e.width,Fo.height=e.height,e=Fo)));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===z.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=Fo,e.width=i.width/s,e.height=i.height/s),n=!0,o=this._rendererPremultipliedAlpha,i.renderTexture.bind();const u=Math.max(Math.round(e.width*s),1),c=Math.max(Math.round(e.height*s),1),d=new Uint8Array(aC*u*c);return h.readPixels(Math.round(e.x*s),Math.round(e.y*s),u,c,h.RGBA,h.UNSIGNED_BYTE,d),l&&(a==null||a.destroy(!0)),{pixels:d,width:u,height:c,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}}}};Lm.extension={name:"extract",type:Q.RendererSystem};let lC=Lm;ht.add(lC);const ko={build(r){const t=r.points;let e,i,s,n,o,a;if(r.type===Ae.CIRC){const p=r.shape;e=p.x,i=p.y,o=a=p.radius,s=n=0}else if(r.type===Ae.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,_=p.height/2;e=p.x+m,i=p.y+_,o=a=Math.max(0,Math.min(p.radius,Math.min(m,_))),s=m-o,n=_-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 u=0,c=l*4+(s?2:0)+2,d=c,f=h;{const p=s+o,m=n,_=e+p,y=e-p,v=i+m;if(t[u++]=_,t[u++]=v,t[--c]=v,t[--c]=y,n){const g=i-m;t[d++]=y,t[d++]=g,t[--f]=g,t[--f]=_}}for(let p=1;p<l;p++){const m=Math.PI/2*(p/l),_=s+Math.cos(m)*o,y=n+Math.sin(m)*a,v=e+_,g=e-_,x=i+y,E=i-y;t[u++]=v,t[u++]=x,t[--c]=x,t[--c]=g,t[d++]=g,t[d++]=E,t[--f]=E,t[--f]=v}{const p=s,m=n+a,_=e+p,y=e-p,v=i+m,g=i-m;t[u++]=_,t[u++]=v,t[--f]=g,t[--f]=_,s&&(t[u++]=y,t[u++]=v,t[--f]=g,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!==Ae.RREC){const u=r.shape;a=u.x,l=u.y}else{const u=r.shape;a=u.x+u.width/2,l=u.y+u.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 u=2;u<e.length;u+=2)i.push(e[u],e[u+1]),s.push(n++,o,n);s.push(o+1,o,n)}};function Bm(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 Fm={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){Bm(e,!1);const o=[];for(let h=0;h<i.length;h++){const u=i[h];Bm(u.points,!0),o.push(e.length/2),e=e.concat(u.points)}const a=fx(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])}}},hC={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)}},uC={build(r){ko.build(r)},triangulate(r,t){ko.triangulate(r,t)}};var qe=(r=>(r.MITER="miter",r.BEVEL="bevel",r.ROUND="round",r))(qe||{}),ai=(r=>(r.BUTT="butt",r.ROUND="round",r.SQUARE="square",r))(ai||{});const Ts={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 km{static curveTo(t,e,i,s,n,o){const a=o[o.length-2],l=o[o.length-1]-e,h=a-t,u=s-e,c=i-t,d=Math.abs(l*c-h*u);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=u*u+c*c,m=l*u+h*c,_=n*Math.sqrt(f)/d,y=n*Math.sqrt(p)/d,v=_*m/f,g=y*m/p,x=_*c+y*h,E=_*u+y*l,R=h*(y+v),S=l*(y+v),M=c*(_+g),P=u*(_+g),F=Math.atan2(S-E,R-x),U=Math.atan2(P-E,M-x);return{cx:x+t,cy:E+e,radius:n,startAngle:F,endAngle:U,anticlockwise:h*u>c*l}}static arc(t,e,i,s,n,o,a,l,h){const u=a-o,c=Ts._segmentsCount(Math.abs(u)*n,Math.ceil(Math.abs(u)/lo)*40),d=u/(c*2),f=d*2,p=Math.cos(d),m=Math.sin(d),_=c-1,y=_%1/_;for(let v=0;v<=_;++v){const g=v+y*v,x=d+o+f*g,E=Math.cos(x),R=-Math.sin(x);h.push((p*E+m*R)*n+i,(p*-R+m*E)*n+s)}}}class cC{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 Uh{static curveLength(t,e,i,s,n,o,a,l){let h=0,u=0,c=0,d=0,f=0,p=0,m=0,_=0,y=0,v=0,g=0,x=t,E=e;for(let R=1;R<=10;++R)u=R/10,c=u*u,d=c*u,f=1-u,p=f*f,m=p*f,_=m*t+3*p*u*i+3*f*c*n+d*a,y=m*e+3*p*u*s+3*f*c*o+d*l,v=x-_,g=E-y,x=_,E=y,h+=Math.sqrt(v*v+g*g);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 u=Ts._segmentsCount(Uh.curveLength(l,h,t,e,i,s,n,o));let c=0,d=0,f=0,p=0,m=0;a.push(l,h);for(let _=1,y=0;_<=u;++_)y=_/u,c=1-y,d=c*c,f=d*c,p=y*y,m=p*y,a.push(f*l+3*d*y*t+3*c*p*i+m*n,f*h+3*d*y*e+3*c*p*s+m*o)}}function Um(r,t,e,i,s,n,o,a){const l=r-e*s,h=t-i*s,u=r+e*n,c=t+i*n;let d,f;o?(d=i,f=-e):(d=-i,f=e);const p=l+d,m=h+f,_=u+d,y=c+f;return a.push(p,m,_,y),2}function Hi(r,t,e,i,s,n,o,a){const l=e-r,h=i-t;let u=Math.atan2(l,h),c=Math.atan2(s-r,n-t);a&&u<c?u+=Math.PI*2:!a&&u>c&&(c+=Math.PI*2);let d=u;const f=c-u,p=Math.abs(f),m=Math.sqrt(l*l+h*h),_=(15*p*Math.sqrt(m)/Math.PI>>0)+1,y=f/_;if(d+=y,a){o.push(r,t,e,i);for(let v=1,g=d;v<_;v++,g+=y)o.push(r,t,r+Math.sin(g)*m,t+Math.cos(g)*m);o.push(r,t,s,n)}else{o.push(e,i,r,t);for(let v=1,g=d;v<_;v++,g+=y)o.push(r+Math.sin(g)*m,t+Math.cos(g)*m,r,t);o.push(s,n,r,t)}return _*2}function dC(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 It(i[0],i[1]),a=new It(i[i.length-2],i[i.length-1]),l=e.type!==Ae.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 N=(o.x+a.x)*.5,B=(a.y+o.y)*.5;i.unshift(N,B),i.push(N,B)}const u=t.points,c=i.length/2;let d=i.length;const f=u.length/2,p=n.width/2,m=p*p,_=n.miterLimit*n.miterLimit;let y=i[0],v=i[1],g=i[2],x=i[3],E=0,R=0,S=-(v-x),M=y-g,P=0,F=0,U=Math.sqrt(S*S+M*M);S/=U,M/=U,S*=p,M*=p;const I=n.alignment,A=(1-I)*2,w=I*2;l||(n.cap===ai.ROUND?d+=Hi(y-S*(A-w)*.5,v-M*(A-w)*.5,y-S*A,v-M*A,y+S*w,v+M*w,u,!0)+2:n.cap===ai.SQUARE&&(d+=Um(y,v,S,M,A,w,!0,u))),u.push(y-S*A,v-M*A,y+S*w,v+M*w);for(let N=1;N<c-1;++N){y=i[(N-1)*2],v=i[(N-1)*2+1],g=i[N*2],x=i[N*2+1],E=i[(N+1)*2],R=i[(N+1)*2+1],S=-(v-x),M=y-g,U=Math.sqrt(S*S+M*M),S/=U,M/=U,S*=p,M*=p,P=-(x-R),F=g-E,U=Math.sqrt(P*P+F*F),P/=U,F/=U,P*=p,F*=p;const B=g-y,V=v-x,L=g-E,O=R-x,k=B*L+V*O,X=V*L-O*B,Y=X<0;if(Math.abs(X)<.001*Math.abs(k)){u.push(g-S*A,x-M*A,g+S*w,x+M*w),k>=0&&(n.join===qe.ROUND?d+=Hi(g,x,g-S*A,x-M*A,g-P*A,x-F*A,u,!1)+4:d+=2,u.push(g-P*w,x-F*w,g+P*A,x+F*A));continue}const q=(-S+y)*(-M+x)-(-S+g)*(-M+v),pt=(-P+E)*(-F+x)-(-P+g)*(-F+R),_t=(B*pt-L*q)/X,W=(O*q-V*pt)/X,bt=(_t-g)*(_t-g)+(W-x)*(W-x),dt=g+(_t-g)*A,mt=x+(W-x)*A,xt=g-(_t-g)*w,Mt=x-(W-x)*w,Nt=Math.min(B*B+V*V,L*L+O*O),_e=Y?A:w,jt=Nt+_e*_e*m,et=bt<=jt;let Ke=n.join;if(Ke===qe.MITER&&bt/m>_&&(Ke=qe.BEVEL),et)switch(Ke){case qe.MITER:{u.push(dt,mt,xt,Mt);break}case qe.BEVEL:{Y?u.push(dt,mt,g+S*w,x+M*w,dt,mt,g+P*w,x+F*w):u.push(g-S*A,x-M*A,xt,Mt,g-P*A,x-F*A,xt,Mt),d+=2;break}case qe.ROUND:{Y?(u.push(dt,mt,g+S*w,x+M*w),d+=Hi(g,x,g+S*w,x+M*w,g+P*w,x+F*w,u,!0)+4,u.push(dt,mt,g+P*w,x+F*w)):(u.push(g-S*A,x-M*A,xt,Mt),d+=Hi(g,x,g-S*A,x-M*A,g-P*A,x-F*A,u,!1)+4,u.push(g-P*A,x-F*A,xt,Mt));break}}else{switch(u.push(g-S*A,x-M*A,g+S*w,x+M*w),Ke){case qe.MITER:{Y?u.push(xt,Mt,xt,Mt):u.push(dt,mt,dt,mt),d+=2;break}case qe.ROUND:{Y?d+=Hi(g,x,g+S*w,x+M*w,g+P*w,x+F*w,u,!0)+2:d+=Hi(g,x,g-S*A,x-M*A,g-P*A,x-F*A,u,!1)+2;break}}u.push(g-P*A,x-F*A,g+P*w,x+F*w),d+=2}}y=i[(c-2)*2],v=i[(c-2)*2+1],g=i[(c-1)*2],x=i[(c-1)*2+1],S=-(v-x),M=y-g,U=Math.sqrt(S*S+M*M),S/=U,M/=U,S*=p,M*=p,u.push(g-S*A,x-M*A,g+S*w,x+M*w),l||(n.cap===ai.ROUND?d+=Hi(g-S*(A-w)*.5,x-M*(A-w)*.5,g-S*A,x-M*A,g+S*w,x+M*w,u,!1)+2:n.cap===ai.SQUARE&&(d+=Um(g,x,S,M,A,w,!1,u)));const C=t.indices,D=Ts.epsilon*Ts.epsilon;for(let N=f;N<d+f-2;++N)y=u[N*2],v=u[N*2+1],g=u[(N+1)*2],x=u[(N+1)*2+1],E=u[(N+2)*2],R=u[(N+2)*2+1],!(Math.abs(y*(x-R)+g*(R-v)+E*(v-x))<D)&&C.push(N,N+1,N+2)}function fC(r,t){let e=0;const i=r.shape,s=r.points||i.points,n=i.type!==Ae.POLY||i.closeStroke;if(s.length===0)return;const o=t.points,a=t.indices,l=s.length/2,h=o.length/2;let u=h;for(o.push(s[0],s[1]),e=1;e<l;e++)o.push(s[e*2],s[e*2+1]),a.push(u,u+1),u++;n&&a.push(u,h)}function Gm(r,t){r.lineStyle.native?fC(r,t):dC(r,t)}class Gh{static curveLength(t,e,i,s,n,o){const a=t-2*i+n,l=e-2*s+o,h=2*i-2*t,u=2*s-2*e,c=4*(a*a+l*l),d=4*(a*h+l*u),f=h*h+u*u,p=2*Math.sqrt(c+d+f),m=Math.sqrt(c),_=2*c*m,y=2*Math.sqrt(f),v=d/m;return(_*p+m*d*(p-y)+(4*f*c-d*d)*Math.log((2*m+v+p)/(v+y)))/(4*_)}static curveTo(t,e,i,s,n){const o=n[n.length-2],a=n[n.length-1],l=Ts._segmentsCount(Gh.curveLength(o,a,t,e,i,s));let h=0,u=0;for(let c=1;c<=l;++c){const d=c/l;h=o+(t-o)*d,u=a+(e-a)*d,n.push(h+(t+(i-t)*d-h)*d,u+(e+(s-e)*d-u)*d)}}}const Hh={[Ae.POLY]:Fm,[Ae.CIRC]:ko,[Ae.ELIP]:ko,[Ae.RECT]:hC,[Ae.RREC]:uC},Hm=[],Uo=[];class Go{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 Go(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 As=new It,$m=class Ng extends xp{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 Co,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(),Uo.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e.reset(),Hm.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 Go(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 Go(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,As):As.copyFrom(t),s.shape.contains(As.x,As.y))){let n=!1;if(s.holes){for(let o=0;o<s.holes.length;o++)if(s.holes[o].shape.contains(As.x,As.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],u=h.fillStyle,c=h.lineStyle;Hh[h.type].build(h),h.matrix&&this.transformPoints(h.points,h.matrix),(u.visible||c.visible)&&this.processHoles(h.holes);for(let d=0;d<2;d++){const f=d===0?u:c;if(!f.visible)continue;const p=f.texture.baseTexture,m=this.indices.length,_=this.points.length/2;p.wrapMode=Jr.REPEAT,d===0?this.processFill(h):this.processLine(h);const y=this.points.length/2-_;y!==0&&(i&&!this._compareStyles(s,f)&&(i.end(m,_),i=null),i||(i=Hm.pop()||new cC,i.begin(f,m,_),this.batches.push(i),s=f),this.addUvs(this.points,t,f.texture,_,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<Ng.BATCHABLE_SIZE*2}buildDrawCalls(){let t=++vt._globalBatch;for(let c=0;c<this.drawCalls.length;c++)this.drawCalls[c].texArray.clear(),Uo.push(this.drawCalls[c]);this.drawCalls.length=0;const e=this.colors,i=this.textureIds;let s=Uo.pop();s||(s=new uh,s.texArray=new gh),s.texArray.count=0,s.start=0,s.size=0,s.type=fr.TRIANGLES;let n=0,o=null,a=0,l=!1,h=fr.TRIANGLES,u=0;this.drawCalls.push(s);for(let c=0;c<this.batches.length;c++){const d=this.batches[c],f=8,p=d.style,m=p.texture.baseTexture;l!==!!p.native&&(l=!!p.native,h=l?fr.LINES:fr.TRIANGLES,o=null,n=f,t++),o!==m&&(o=m,m._batchEnabled!==t&&(n===f&&(t++,n=0,s.size>0&&(s=Uo.pop(),s||(s=new uh,s.texArray=new gh),this.drawCalls.push(s)),s.start=u,s.size=0,s.texArray.count=0,s.type=h),m.touched=1,m._batchEnabled=t,m._batchLocation=n,m.wrapMode=Jr.REPEAT,s.texArray.elements[s.texArray.count++]=m,n++)),s.size+=d.size,u+=d.size,a=m._batchLocation,this.addColors(e,p.color,p.alpha,d.attribSize,d.attribStart),this.addTextureIds(i,a,d.attribSize,d.attribStart)}vt._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?Fm.triangulate(t,this):Hh[t.type].triangulate(t,this)}processLine(t){Gm(t,this);for(let e=0;e<t.holes.length;e++)Gm(t.holes[e],this)}processHoles(t){for(let e=0;e<t.length;e++){const i=t[e];Hh[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=Ot.shared.setValue(e).toLittleEndianNumber(),a=Ot.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 c=t[(s+a)*2],d=t[(s+a)*2+1];if(o){const f=o.a*c+o.c*d+o.tx;d=o.b*c+o.d*d+o.ty,c=f}a++,e.push(c/h.width,d/h.height)}const u=i.baseTexture;(h.width<u.width||h.height<u.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,u=l.height/n.height;let c=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));c-=f,d-=p;for(let m=i;m<a;m+=2)t[m]=(t[m]+c)*h,t[m+1]=(t[m+1]+d)*u}};$m.BATCHABLE_SIZE=100;let pC=$m;class Ho{constructor(){this.color=16777215,this.alpha=1,this.texture=ut.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new Ho;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=ut.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class $h extends Ho{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=ai.BUTT,this.join=qe.MITER,this.miterLimit=10}clone(){const t=new $h;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=ai.BUTT,this.join=qe.MITER,this.miterLimit=10}}const Xh={},Vh=class ta extends nr{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 Ho,this._lineStyle=new $h,this._matrix=null,this._holeMode=!1,this.state=Er.for2d(),this._geometry=t||new pC,this._geometry.refCount++,this._transformID=-1,this._tintColor=new Ot(16777215),this.blendMode=yt.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new ta(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:ut.WHITE,color:t!=null&&t.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:ai.BUTT,join:qe.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 Ri,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new Ri,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),Gh.curveTo(t,e,i,s,n),this}bezierCurveTo(t,e,i,s,n,o){return this._initCurve(),Uh.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=km.curveTo(t,e,i,s,n,o);if(a){const{cx:l,cy:h,radius:u,startAngle:c,endAngle:d,anticlockwise:f}=a;this.arc(l,h,u,c,d,f)}return this}arc(t,e,i,s,n,o=!1){if(s===n)return this;if(!o&&n<=s?n+=lo:o&&s<=n&&(s+=lo),n-s===0)return this;const a=t+Math.cos(s)*i,l=e+Math.sin(s)*i,h=this._geometry.closePointEps;let u=this.currentPath?this.currentPath.points:null;if(u){const c=Math.abs(u[u.length-2]-a),d=Math.abs(u[u.length-1]-l);c<h&&d<h||u.push(a,l)}else this.moveTo(a,l),u=this.currentPath.points;return km.arc(a,l,t,e,i,s,n,o,u),this}beginFill(t=0,e){return this.beginTextureFill({texture:ut.WHITE,color:t,alpha:e})}normalizeColor(t){const e=Ot.shared.setValue(t.color??0);t.color=e.toNumber(),t.alpha??(t.alpha=e.alpha)}beginTextureFill(t){const e={texture:ut.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 Et(t,e,i,s))}drawRoundedRect(t,e,i,s,n){return this.drawShape(new fo(t,e,i,s,n))}drawCircle(t,e,i){return this.drawShape(new uo(t,e,i))}drawEllipse(t,e,i,s){return this.drawShape(new co(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 Ri(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===Ae.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),u={vertexData:a,blendMode:e,indices:h,uvs:l,_batchRGB:Ot.shared.setValue(o).toRgbArray(),_tintRGB:o,_texture:n.style.texture,alpha:n.style.alpha,worldAlpha:1};this.batches[s]=u}}_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,Ot.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(!Xh[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 Ut,default:sr.from({uSamplers:n},!0)},a=t.plugins[i]._shader.program;Xh[i]=new wr(a,o)}e=Xh[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,ta._TEMP_POINT),this._geometry.containsPoint(ta._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=Ot.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,u=this.vertexData;let c=0;for(let d=0;d<h.length;d+=2){const f=h[d],p=h[d+1];u[c++]=i*f+n*p+a,u[c++]=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)}};Vh.curves=Ts,Vh._TEMP_POINT=new It;let fn=Vh;class mC{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 zh=new It,Xm=new Ri,Vm=class Dg extends nr{constructor(t,e,i,s=fr.TRIANGLES){super(),this.geometry=t,this.shader=e,this.state=i||Er.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=tt.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===fr.TRIANGLES&&e.length<Dg.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,u=s.ty,c=this.vertexData;for(let d=0;d<c.length/2;d++){const f=e[d*2],p=e[d*2+1];c[d*2]=n*f+a*p+h,c[d*2+1]=o*f+l*p+u}if(this._roundPixels){const d=tt.RESOLUTION;for(let f=0;f<c.length;++f)c[f]=Math.round(c[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 mC(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,zh);const e=this.geometry.getBuffer("aVertexPosition").data,i=Xm.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,u=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[u],i[5]=e[u+1],Xm.contains(zh.x,zh.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}};Vm.BATCHABLE_SIZE=100;let zm=Vm;class gC extends si{constructor(t,e,i){super();const s=new te(t),n=new te(e,!0),o=new te(i,!0,!0);this.addAttribute("aVertexPosition",s,2,!1,ft.FLOAT).addAttribute("aTextureCoord",n,2,!1,ft.FLOAT).addIndex(o),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var yC=`varying vec2 vTextureCoord;
912
+ `;let ws=null;class Om{constructor(){ws||(ws=URL.createObjectURL(new Blob([vS],{type:"application/javascript"}))),this.worker=new Worker(ws)}}Om.revokeObjectURL=function(){ws&&(URL.revokeObjectURL(ws),ws=null)};let Nm=0,Uh;class xS{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 kh;e.addEventListener("message",i=>{e.terminate(),kh.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){Uh===void 0&&(Uh=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<Uh&&(this._createdWorkers++,t=new Om().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[Nm]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Nm++,id:i})}}const Dm=new xS;function mn(r,t,e){r.resource.internal=!0;const i=new ct(r),s=()=>{delete t.promiseCache[e],Ui.has(e)&&Ui.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 bS=[".jpeg",".jpg",".png",".webp",".avif"],ES=["image/jpeg","image/png","image/webp","image/avif"];async function wS(r){const t=await tt.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 Lo={name:"loadTextures",extension:{type:Q.LoadParser,priority:lr.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return bs(r,ES)||oi(r,bS)},async load(r,t,e){var a;const i=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let s;i?this.config.preferWorkers&&await Dm.isImageBitmapSupported()?s=await Dm.loadImageBitmap(r):s=await wS(r):s=await new Promise((l,h)=>{const u=new Image;u.crossOrigin=this.config.crossOrigin,u.src=r,u.complete?l(u):(u.onload=()=>l(u),u.onerror=c=>h(c))});const n={...t.data};n.resolution??(n.resolution=Lr(r)),i&&((a=n.resourceOptions)==null?void 0:a.ownsImageBitmap)===void 0&&(n.resourceOptions={...n.resourceOptions},n.resourceOptions.ownsImageBitmap=!0);const o=new bt(s,n);return o.resource.src=r,mn(o,e,r)},unload(r){r.destroy(!0)}};ut.add(Lo);const TS=".svg",AS="image/svg+xml",SS={extension:{type:Q.LoadParser,priority:lr.High},name:"loadSVG",test(r){return bs(r,AS)||oi(r,TS)},async testParse(r){return Mh.test(r)},async parse(r,t,e){var n;const i=new Mh(r,(n=t==null?void 0:t.data)==null?void 0:n.resourceOptions);await i.load();const s=new bt(i,{resolution:Lr(r),...t==null?void 0:t.data});return s.resource.src=t.src,mn(s,e,t.src)},async load(r,t){return(await tt.ADAPTER.fetch(r)).text()},unload:Lo.unload};ut.add(SS);const CS=[".mp4",".m4v",".webm",".ogv"],IS=["video/mp4","video/webm","video/ogg"],RS={name:"loadVideo",extension:{type:Q.LoadParser,priority:lr.High},config:{defaultAutoPlay:!0,defaultUpdateFPS:0,defaultLoop:!1,defaultMuted:!1,defaultPlaysinline:!0},test(r){return bs(r,IS)||oi(r,CS)},async load(r,t,e){var o;let i;const s=await(await tt.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 xm(n,a);await l.load();const h=new bt(l,{alphaMode:await Lw(),resolution:Lr(r),...t==null?void 0:t.data});h.resource.src=r,i=mn(h,e,r),i.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(n)})}catch(a){throw URL.revokeObjectURL(n),a}return i},unload(r){r.destroy(!0)}};ut.add(RS);class MS{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 ar(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"?(St("7.2.0",`Assets.add now uses an object instead of individual parameters.
913
+ 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`)},ar(o).forEach(l=>{const{src:h,srcs:u}=l;let{data:c,format:d,loadParser:f}=l;const p=ar(h||u).map(y=>typeof y=="string"?eS(y):Array.isArray(y)?y:[y]),m=this.getAlias(l);Array.isArray(m)?m.forEach(a):a(m);const _=[];p.forEach(y=>{y.forEach(v=>{let g={};if(typeof v!="object"){g.src=v;for(let x=0;x<this._parsers.length;x++){const T=this._parsers[x];if(T.test(v)){g=T.parse(v);break}}}else c=v.data??c,d=v.format??d,f=v.loadParser??f,g={...g,...v};if(!m)throw new Error(`[Resolver] alias is undefined for this asset: ${g.src}`);g=this.buildResolvedAsset(g,{aliases:m,data:c,format:d,loadParser:f}),_.push(g)})}),m.forEach(y=>{this._assetMap[y]=_})})}resolveBundle(t){const e=Do(t);t=ar(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=Do(t);t=ar(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 u=n.filter(c=>c[l]?c[l]===h:!1);u.length&&(n=u)})}),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=ye.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??ye.extname(t.src).slice(1),t.srcs=t.src,t.name=t.alias,t}}class PS{constructor(){this._detections=[],this._initialized=!1,this.resolver=new MS,this.loader=new iS,this.cache=Ui,this._backgroundLoader=new tS(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=Do(t),s=ar(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)},u=o.map(c=>{const d=s[c];return l+=Object.keys(d).length,this._mapLoadToResolve(d,h).then(f=>{n[c]=f})});return await Promise.all(u),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 Ui.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=Ui.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],u=[a.src];a.alias&&u.push(...a.alias),o[s[l]]=h,Ui.set(u,h)}),o}async unload(t){this._initialized||await this.init();const e=ar(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=ar(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=>{Ui.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 Lo.config.preferWorkers}set preferWorkers(t){St("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 Bo=new PS;ut.handleByList(Q.LoadParser,Bo.loader.parsers).handleByList(Q.ResolveParser,Bo.resolver.parsers).handleByList(Q.CacheParser,Bo.cache.parsers).handleByList(Q.DetectionParser,Bo.detections);const OS={extension:Q.CacheParser,test:r=>Array.isArray(r)&&r.every(t=>t instanceof ct),getCacheableAssets:(r,t)=>{const e={};return r.forEach(i=>{t.forEach((s,n)=>{e[i+(n===0?"":n+1)]=s})}),e}};ut.add(OS);async function Lm(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 NS={extension:{type:Q.DetectionParser,priority:1},test:async()=>Lm("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")};ut.add(NS);const DS={extension:{type:Q.DetectionParser,priority:0},test:async()=>Lm("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};ut.add(DS);const Bm=["png","jpg","jpeg"],LS={extension:{type:Q.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...Bm],remove:async r=>r.filter(t=>!Bm.includes(t))};ut.add(LS);const BS="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Gh(r){return BS?!1:document.createElement("video").canPlayType(r)!==""}const FS={extension:{type:Q.DetectionParser,priority:0},test:async()=>Gh("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")};ut.add(FS);const kS={extension:{type:Q.DetectionParser,priority:0},test:async()=>Gh("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")};ut.add(kS);const US={extension:{type:Q.DetectionParser,priority:0},test:async()=>Gh("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")};ut.add(US);const GS={extension:Q.ResolveParser,test:Lo.test,parse:r=>{var t;return{resolution:parseFloat(((t=tt.RETINA_PREFIX.exec(r))==null?void 0:t[1])??"1"),format:ye.extname(r).slice(1),src:r}}};ut.add(GS);var Se=(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))(Se||{});const Fo={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 Tr,Ts;function Fm(){Ts={bptc:Tr.getExtension("EXT_texture_compression_bptc"),astc:Tr.getExtension("WEBGL_compressed_texture_astc"),etc:Tr.getExtension("WEBGL_compressed_texture_etc"),s3tc:Tr.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:Tr.getExtension("WEBGL_compressed_texture_s3tc_srgb"),pvrtc:Tr.getExtension("WEBGL_compressed_texture_pvrtc")||Tr.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:Tr.getExtension("WEBGL_compressed_texture_etc1"),atc:Tr.getExtension("WEBGL_compressed_texture_atc")}}const $S={extension:{type:Q.DetectionParser,priority:2},test:async()=>{const r=tt.ADAPTER.createCanvas().getContext("webgl");return r?(Tr=r,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async r=>{Ts||Fm();const t=[];for(const e in Ts)Ts[e]&&t.push(e);return[...t,...r]},remove:async r=>(Ts||Fm(),r.filter(t=>!(t in Ts)))};ut.add($S);class HS extends uo{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 nh(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 nh(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class Gi extends HS{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=Gi._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||Gi._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:u}=this._levelBuffers[n];s.compressedTexImage2D(s.TEXTURE_2D,a,this.format,l,h,0,u)}return!0}onBlobLoaded(){this._levelBuffers=Gi._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,u=o,c=a,d=u+s-1&~(s-1),f=c+n-1&~(n-1),p=d*f*Fo[e];for(let m=0;m<i;m++)l[m]={levelID:m,levelWidth:i>1?u:d,levelHeight:i>1?c:f,levelBuffer:new Uint8Array(t.buffer,h,p)},h+=p,u=u>>1||1,c=c>>1||1,d=u+s-1&~(s-1),f=c+n-1&~(n-1),p=d*f*Fo[e];return l}}const $h=4,ko=124,XS=32,km=20,VS=542327876,Uo={HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},zS={FOURCC:2},Go={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3},YS=1,jS=2,WS=4,qS=64,KS=512,ZS=131072,QS=827611204,JS=861165636,tC=894720068,eC=808540228,rC=4,iC={[QS]:Se.COMPRESSED_RGBA_S3TC_DXT1_EXT,[JS]:Se.COMPRESSED_RGBA_S3TC_DXT3_EXT,[tC]:Se.COMPRESSED_RGBA_S3TC_DXT5_EXT},sC={70:Se.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:Se.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:Se.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:Se.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:Se.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:Se.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:Se.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:Se.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:Se.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,96:Se.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,95:Se.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,98:Se.COMPRESSED_RGBA_BPTC_UNORM_EXT,99:Se.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT};function nC(r){const t=new Uint32Array(r);if(t[0]!==VS)throw new Error("Invalid DDS file magic word");const e=new Uint32Array(r,0,ko/Uint32Array.BYTES_PER_ELEMENT),i=e[Uo.HEIGHT],s=e[Uo.WIDTH],n=e[Uo.MIPMAP_COUNT],o=new Uint32Array(r,Uo.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,XS/Uint32Array.BYTES_PER_ELEMENT),a=o[YS];if(a&WS){const l=o[zS.FOURCC];if(l!==eC){const v=iC[l],g=$h+ko,x=new Uint8Array(r,g);return[new Gi(x,{format:v,width:s,height:i,levels:n})]}const h=$h+ko,u=new Uint32Array(t.buffer,h,km/Uint32Array.BYTES_PER_ELEMENT),c=u[Go.DXGI_FORMAT],d=u[Go.RESOURCE_DIMENSION],f=u[Go.MISC_FLAG],p=u[Go.ARRAY_SIZE],m=sC[c];if(m===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${c}`);if(f===rC)throw new Error("DDSParser does not support cubemap textures");if(d===6)throw new Error("DDSParser does not supported 3D texture data");const _=new Array,y=$h+ko+km;if(p===1)_.push(new Uint8Array(r,y));else{const v=Fo[m];let g=0,x=s,T=i;for(let S=0;S<n;S++){const R=Math.max(1,x+3&-4),P=Math.max(1,T+3&-4),F=R*P*v;g+=F,x=x>>>1,T=T>>>1}let M=y;for(let S=0;S<p;S++)_.push(new Uint8Array(r,M,g)),M+=g}return _.map(v=>new Gi(v,{format:m,width:s,height:i,levels:n}))}throw a&qS?new Error("DDSParser does not support uncompressed texture data."):a&KS?new Error("DDSParser does not supported YUV uncompressed texture data."):a&ZS?new Error("DDSParser does not support single-channel (lumninance) texture data!"):a&jS?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 Um=[171,75,84,88,32,49,49,187,13,10,26,10],oC=67305985,hr={ENDIANNESS:12,GL_TYPE:16,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,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},Hh=64,Gm={[ft.UNSIGNED_BYTE]:1,[ft.UNSIGNED_SHORT]:2,[ft.INT]:4,[ft.UNSIGNED_INT]:4,[ft.FLOAT]:4,[ft.HALF_FLOAT]:8},aC={[j.RGBA]:4,[j.RGB]:3,[j.RG]:2,[j.RED]:1,[j.LUMINANCE]:1,[j.LUMINANCE_ALPHA]:2,[j.ALPHA]:1},lC={[ft.UNSIGNED_SHORT_4_4_4_4]:2,[ft.UNSIGNED_SHORT_5_5_5_1]:2,[ft.UNSIGNED_SHORT_5_6_5]:2};function hC(r,t,e=!1){const i=new DataView(t);if(!uC(r,i))return null;const s=i.getUint32(hr.ENDIANNESS,!0)===oC,n=i.getUint32(hr.GL_TYPE,s),o=i.getUint32(hr.GL_FORMAT,s),a=i.getUint32(hr.GL_INTERNAL_FORMAT,s),l=i.getUint32(hr.PIXEL_WIDTH,s),h=i.getUint32(hr.PIXEL_HEIGHT,s)||1,u=i.getUint32(hr.PIXEL_DEPTH,s)||1,c=i.getUint32(hr.NUMBER_OF_ARRAY_ELEMENTS,s)||1,d=i.getUint32(hr.NUMBER_OF_FACES,s),f=i.getUint32(hr.NUMBER_OF_MIPMAP_LEVELS,s),p=i.getUint32(hr.BYTES_OF_KEY_VALUE_DATA,s);if(h===0||u!==1)throw new Error("Only 2D textures are supported");if(d!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(c!==1)throw new Error("WebGL does not support array textures");const m=4,_=4,y=l+3&-4,v=h+3&-4,g=new Array(c);let x=l*h;n===0&&(x=y*v);let T;if(n!==0?Gm[n]?T=Gm[n]*aC[o]:T=lC[n]:T=Fo[a],T===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const M=e?dC(i,p,s):null;let S=x*T,R=l,P=h,F=y,U=v,I=Hh+p;for(let A=0;A<f;A++){const w=i.getUint32(I,s);let C=I+4;for(let L=0;L<c;L++){let O=g[L];O||(O=g[L]=new Array(f)),O[A]={levelID:A,levelWidth:f>1||n!==0?R:F,levelHeight:f>1||n!==0?P:U,levelBuffer:new Uint8Array(t,C,S)},C+=S}I+=w+4,I=I%4!==0?I+4-I%4:I,R=R>>1||1,P=P>>1||1,F=R+m-1&-4,U=P+_-1&-4,S=F*U*T}return n!==0?{uncompressed:g.map(A=>{let w=A[0].levelBuffer,C=!1;return n===ft.FLOAT?w=new Float32Array(A[0].levelBuffer.buffer,A[0].levelBuffer.byteOffset,A[0].levelBuffer.byteLength/4):n===ft.UNSIGNED_INT?(C=!0,w=new Uint32Array(A[0].levelBuffer.buffer,A[0].levelBuffer.byteOffset,A[0].levelBuffer.byteLength/4)):n===ft.INT&&(C=!0,w=new Int32Array(A[0].levelBuffer.buffer,A[0].levelBuffer.byteOffset,A[0].levelBuffer.byteLength/4)),{resource:new uo(w,{width:A[0].levelWidth,height:A[0].levelHeight}),type:n,format:C?cC(o):o}}),kvData:M}:{compressed:g.map(A=>new Gi(null,{format:a,width:l,height:h,levels:f,levelBuffers:A})),kvData:M}}function uC(r,t){for(let e=0;e<Um.length;e++)if(t.getUint8(e)!==Um[e])return console.error(`${r} is not a valid *.ktx file!`),!1;return!0}function cC(r){switch(r){case j.RGBA:return j.RGBA_INTEGER;case j.RGB:return j.RGB_INTEGER;case j.RG:return j.RG_INTEGER;case j.RED:return j.RED_INTEGER;default:return r}}function dC(r,t,e){const i=new Map;let s=0;for(;s<t;){const n=r.getUint32(Hh+s,e),o=Hh+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)),u=new DataView(r.buffer,o+l+1,n-l-1);i.set(h,u),s+=4+n+a}return i}const fC={extension:{type:Q.LoadParser,priority:lr.High},name:"loadDDS",test(r){return oi(r,".dds")},async load(r,t,e){const i=await(await tt.ADAPTER.fetch(r)).arrayBuffer(),s=nC(i).map(n=>{const o=new bt(n,{mipmap:pr.OFF,alphaMode:$e.NO_PREMULTIPLIED_ALPHA,resolution:Lr(r),...t.data});return mn(o,e,r)});return s.length===1?s[0]:s},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};ut.add(fC);const pC={extension:{type:Q.LoadParser,priority:lr.High},name:"loadKTX",test(r){return oi(r,".ktx")},async load(r,t,e){const i=await(await tt.ADAPTER.fetch(r)).arrayBuffer(),{compressed:s,uncompressed:n,kvData:o}=hC(r,i),a=s??n,l={mipmap:pr.OFF,alphaMode:$e.NO_PREMULTIPLIED_ALPHA,resolution:Lr(r),...t.data},h=a.map(u=>{a===n&&Object.assign(l,{type:u.type,format:u.format});const c=u.resource??u,d=new bt(c,l);return d.ktxKeyValueData=o,mn(d,e,r)});return h.length===1?h[0]:h},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};ut.add(pC);const mC=["s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"],gC={extension:Q.ResolveParser,test:r=>{const t=ye.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(mC.includes(n))return{resolution:parseFloat(((i=tt.RETINA_PREFIX.exec(r))==null?void 0:i[1])??"1"),format:n,src:r}}return{resolution:parseFloat(((s=tt.RETINA_PREFIX.exec(r))==null?void 0:s[1])??"1"),format:e,src:r}}};ut.add(gC);const $o=new wt,yC=4,$m=class bn{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&&bn._flipY(i,s,n),a&&bn._unpremultiplyAlpha(i);const l=new Zw(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&&bn._flipY(i,s,n),a&&bn._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 Li?a=t:(a=i.generateTexture(t,{region:e,resolution:i.resolution,multisample:i.multisample}),l=!0,e&&($o.width=e.width,$o.height=e.height,e=$o)));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===j.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=$o,e.width=i.width/s,e.height=i.height/s),n=!0,o=this._rendererPremultipliedAlpha,i.renderTexture.bind();const u=Math.max(Math.round(e.width*s),1),c=Math.max(Math.round(e.height*s),1),d=new Uint8Array(yC*u*c);return h.readPixels(Math.round(e.x*s),Math.round(e.y*s),u,c,h.RGBA,h.UNSIGNED_BYTE,d),l&&(a==null||a.destroy(!0)),{pixels:d,width:u,height:c,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}}}};$m.extension={name:"extract",type:Q.RendererSystem};let _C=$m;ut.add(_C);const Ho={build(r){const t=r.points;let e,i,s,n,o,a;if(r.type===Ae.CIRC){const p=r.shape;e=p.x,i=p.y,o=a=p.radius,s=n=0}else if(r.type===Ae.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,_=p.height/2;e=p.x+m,i=p.y+_,o=a=Math.max(0,Math.min(p.radius,Math.min(m,_))),s=m-o,n=_-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 u=0,c=l*4+(s?2:0)+2,d=c,f=h;{const p=s+o,m=n,_=e+p,y=e-p,v=i+m;if(t[u++]=_,t[u++]=v,t[--c]=v,t[--c]=y,n){const g=i-m;t[d++]=y,t[d++]=g,t[--f]=g,t[--f]=_}}for(let p=1;p<l;p++){const m=Math.PI/2*(p/l),_=s+Math.cos(m)*o,y=n+Math.sin(m)*a,v=e+_,g=e-_,x=i+y,T=i-y;t[u++]=v,t[u++]=x,t[--c]=x,t[--c]=g,t[d++]=g,t[d++]=T,t[--f]=T,t[--f]=v}{const p=s,m=n+a,_=e+p,y=e-p,v=i+m,g=i-m;t[u++]=_,t[u++]=v,t[--f]=g,t[--f]=_,s&&(t[u++]=y,t[u++]=v,t[--f]=g,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!==Ae.RREC){const u=r.shape;a=u.x,l=u.y}else{const u=r.shape;a=u.x+u.width/2,l=u.y+u.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 u=2;u<e.length;u+=2)i.push(e[u],e[u+1]),s.push(n++,o,n);s.push(o+1,o,n)}};function Hm(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 Xm={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){Hm(e,!1);const o=[];for(let h=0;h<i.length;h++){const u=i[h];Hm(u.points,!0),o.push(e.length/2),e=e.concat(u.points)}const a=Mx(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])}}},vC={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)}},xC={build(r){Ho.build(r)},triangulate(r,t){Ho.triangulate(r,t)}};var qe=(r=>(r.MITER="miter",r.BEVEL="bevel",r.ROUND="round",r))(qe||{}),ai=(r=>(r.BUTT="butt",r.ROUND="round",r.SQUARE="square",r))(ai||{});const As={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 Vm{static curveTo(t,e,i,s,n,o){const a=o[o.length-2],l=o[o.length-1]-e,h=a-t,u=s-e,c=i-t,d=Math.abs(l*c-h*u);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=u*u+c*c,m=l*u+h*c,_=n*Math.sqrt(f)/d,y=n*Math.sqrt(p)/d,v=_*m/f,g=y*m/p,x=_*c+y*h,T=_*u+y*l,M=h*(y+v),S=l*(y+v),R=c*(_+g),P=u*(_+g),F=Math.atan2(S-T,M-x),U=Math.atan2(P-T,R-x);return{cx:x+t,cy:T+e,radius:n,startAngle:F,endAngle:U,anticlockwise:h*u>c*l}}static arc(t,e,i,s,n,o,a,l,h){const u=a-o,c=As._segmentsCount(Math.abs(u)*n,Math.ceil(Math.abs(u)/fo)*40),d=u/(c*2),f=d*2,p=Math.cos(d),m=Math.sin(d),_=c-1,y=_%1/_;for(let v=0;v<=_;++v){const g=v+y*v,x=d+o+f*g,T=Math.cos(x),M=-Math.sin(x);h.push((p*T+m*M)*n+i,(p*-M+m*T)*n+s)}}}class bC{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 Xh{static curveLength(t,e,i,s,n,o,a,l){let h=0,u=0,c=0,d=0,f=0,p=0,m=0,_=0,y=0,v=0,g=0,x=t,T=e;for(let M=1;M<=10;++M)u=M/10,c=u*u,d=c*u,f=1-u,p=f*f,m=p*f,_=m*t+3*p*u*i+3*f*c*n+d*a,y=m*e+3*p*u*s+3*f*c*o+d*l,v=x-_,g=T-y,x=_,T=y,h+=Math.sqrt(v*v+g*g);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 u=As._segmentsCount(Xh.curveLength(l,h,t,e,i,s,n,o));let c=0,d=0,f=0,p=0,m=0;a.push(l,h);for(let _=1,y=0;_<=u;++_)y=_/u,c=1-y,d=c*c,f=d*c,p=y*y,m=p*y,a.push(f*l+3*d*y*t+3*c*p*i+m*n,f*h+3*d*y*e+3*c*p*s+m*o)}}function zm(r,t,e,i,s,n,o,a){const l=r-e*s,h=t-i*s,u=r+e*n,c=t+i*n;let d,f;o?(d=i,f=-e):(d=-i,f=e);const p=l+d,m=h+f,_=u+d,y=c+f;return a.push(p,m,_,y),2}function $i(r,t,e,i,s,n,o,a){const l=e-r,h=i-t;let u=Math.atan2(l,h),c=Math.atan2(s-r,n-t);a&&u<c?u+=Math.PI*2:!a&&u>c&&(c+=Math.PI*2);let d=u;const f=c-u,p=Math.abs(f),m=Math.sqrt(l*l+h*h),_=(15*p*Math.sqrt(m)/Math.PI>>0)+1,y=f/_;if(d+=y,a){o.push(r,t,e,i);for(let v=1,g=d;v<_;v++,g+=y)o.push(r,t,r+Math.sin(g)*m,t+Math.cos(g)*m);o.push(r,t,s,n)}else{o.push(e,i,r,t);for(let v=1,g=d;v<_;v++,g+=y)o.push(r+Math.sin(g)*m,t+Math.cos(g)*m,r,t);o.push(s,n,r,t)}return _*2}function EC(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 It(i[0],i[1]),a=new It(i[i.length-2],i[i.length-1]),l=e.type!==Ae.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 O=(o.x+a.x)*.5,B=(a.y+o.y)*.5;i.unshift(O,B),i.push(O,B)}const u=t.points,c=i.length/2;let d=i.length;const f=u.length/2,p=n.width/2,m=p*p,_=n.miterLimit*n.miterLimit;let y=i[0],v=i[1],g=i[2],x=i[3],T=0,M=0,S=-(v-x),R=y-g,P=0,F=0,U=Math.sqrt(S*S+R*R);S/=U,R/=U,S*=p,R*=p;const I=n.alignment,A=(1-I)*2,w=I*2;l||(n.cap===ai.ROUND?d+=$i(y-S*(A-w)*.5,v-R*(A-w)*.5,y-S*A,v-R*A,y+S*w,v+R*w,u,!0)+2:n.cap===ai.SQUARE&&(d+=zm(y,v,S,R,A,w,!0,u))),u.push(y-S*A,v-R*A,y+S*w,v+R*w);for(let O=1;O<c-1;++O){y=i[(O-1)*2],v=i[(O-1)*2+1],g=i[O*2],x=i[O*2+1],T=i[(O+1)*2],M=i[(O+1)*2+1],S=-(v-x),R=y-g,U=Math.sqrt(S*S+R*R),S/=U,R/=U,S*=p,R*=p,P=-(x-M),F=g-T,U=Math.sqrt(P*P+F*F),P/=U,F/=U,P*=p,F*=p;const B=g-y,V=v-x,D=g-T,N=M-x,H=B*D+V*N,k=V*D-N*B,z=k<0;if(Math.abs(k)<.001*Math.abs(H)){u.push(g-S*A,x-R*A,g+S*w,x+R*w),H>=0&&(n.join===qe.ROUND?d+=$i(g,x,g-S*A,x-R*A,g-P*A,x-F*A,u,!1)+4:d+=2,u.push(g-P*w,x-F*w,g+P*A,x+F*A));continue}const Y=(-S+y)*(-R+x)-(-S+g)*(-R+v),pt=(-P+T)*(-F+x)-(-P+g)*(-F+M),_t=(B*pt-D*Y)/k,W=(N*Y-V*pt)/k,Et=(_t-g)*(_t-g)+(W-x)*(W-x),nt=g+(_t-g)*A,mt=x+(W-x)*A,vt=g-(_t-g)*w,Mt=x-(W-x)*w,Dt=Math.min(B*B+V*V,D*D+N*N),ve=z?A:w,Kt=Dt+ve*ve*m,et=Et<=Kt;let Ke=n.join;if(Ke===qe.MITER&&Et/m>_&&(Ke=qe.BEVEL),et)switch(Ke){case qe.MITER:{u.push(nt,mt,vt,Mt);break}case qe.BEVEL:{z?u.push(nt,mt,g+S*w,x+R*w,nt,mt,g+P*w,x+F*w):u.push(g-S*A,x-R*A,vt,Mt,g-P*A,x-F*A,vt,Mt),d+=2;break}case qe.ROUND:{z?(u.push(nt,mt,g+S*w,x+R*w),d+=$i(g,x,g+S*w,x+R*w,g+P*w,x+F*w,u,!0)+4,u.push(nt,mt,g+P*w,x+F*w)):(u.push(g-S*A,x-R*A,vt,Mt),d+=$i(g,x,g-S*A,x-R*A,g-P*A,x-F*A,u,!1)+4,u.push(g-P*A,x-F*A,vt,Mt));break}}else{switch(u.push(g-S*A,x-R*A,g+S*w,x+R*w),Ke){case qe.MITER:{z?u.push(vt,Mt,vt,Mt):u.push(nt,mt,nt,mt),d+=2;break}case qe.ROUND:{z?d+=$i(g,x,g+S*w,x+R*w,g+P*w,x+F*w,u,!0)+2:d+=$i(g,x,g-S*A,x-R*A,g-P*A,x-F*A,u,!1)+2;break}}u.push(g-P*A,x-F*A,g+P*w,x+F*w),d+=2}}y=i[(c-2)*2],v=i[(c-2)*2+1],g=i[(c-1)*2],x=i[(c-1)*2+1],S=-(v-x),R=y-g,U=Math.sqrt(S*S+R*R),S/=U,R/=U,S*=p,R*=p,u.push(g-S*A,x-R*A,g+S*w,x+R*w),l||(n.cap===ai.ROUND?d+=$i(g-S*(A-w)*.5,x-R*(A-w)*.5,g-S*A,x-R*A,g+S*w,x+R*w,u,!1)+2:n.cap===ai.SQUARE&&(d+=zm(g,x,S,R,A,w,!1,u)));const C=t.indices,L=As.epsilon*As.epsilon;for(let O=f;O<d+f-2;++O)y=u[O*2],v=u[O*2+1],g=u[(O+1)*2],x=u[(O+1)*2+1],T=u[(O+2)*2],M=u[(O+2)*2+1],!(Math.abs(y*(x-M)+g*(M-v)+T*(v-x))<L)&&C.push(O,O+1,O+2)}function wC(r,t){let e=0;const i=r.shape,s=r.points||i.points,n=i.type!==Ae.POLY||i.closeStroke;if(s.length===0)return;const o=t.points,a=t.indices,l=s.length/2,h=o.length/2;let u=h;for(o.push(s[0],s[1]),e=1;e<l;e++)o.push(s[e*2],s[e*2+1]),a.push(u,u+1),u++;n&&a.push(u,h)}function Ym(r,t){r.lineStyle.native?wC(r,t):EC(r,t)}class Vh{static curveLength(t,e,i,s,n,o){const a=t-2*i+n,l=e-2*s+o,h=2*i-2*t,u=2*s-2*e,c=4*(a*a+l*l),d=4*(a*h+l*u),f=h*h+u*u,p=2*Math.sqrt(c+d+f),m=Math.sqrt(c),_=2*c*m,y=2*Math.sqrt(f),v=d/m;return(_*p+m*d*(p-y)+(4*f*c-d*d)*Math.log((2*m+v+p)/(v+y)))/(4*_)}static curveTo(t,e,i,s,n){const o=n[n.length-2],a=n[n.length-1],l=As._segmentsCount(Vh.curveLength(o,a,t,e,i,s));let h=0,u=0;for(let c=1;c<=l;++c){const d=c/l;h=o+(t-o)*d,u=a+(e-a)*d,n.push(h+(t+(i-t)*d-h)*d,u+(e+(s-e)*d-u)*d)}}}const zh={[Ae.POLY]:Xm,[Ae.CIRC]:Ho,[Ae.ELIP]:Ho,[Ae.RECT]:vC,[Ae.RREC]:xC},jm=[],Xo=[];class Vo{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 Vo(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 Ss=new It,Wm=class Ug extends Sp{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 Po,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(),Xo.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e.reset(),jm.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 Vo(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 Vo(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,Ss):Ss.copyFrom(t),s.shape.contains(Ss.x,Ss.y))){let n=!1;if(s.holes){for(let o=0;o<s.holes.length;o++)if(s.holes[o].shape.contains(Ss.x,Ss.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],u=h.fillStyle,c=h.lineStyle;zh[h.type].build(h),h.matrix&&this.transformPoints(h.points,h.matrix),(u.visible||c.visible)&&this.processHoles(h.holes);for(let d=0;d<2;d++){const f=d===0?u:c;if(!f.visible)continue;const p=f.texture.baseTexture,m=this.indices.length,_=this.points.length/2;p.wrapMode=Jr.REPEAT,d===0?this.processFill(h):this.processLine(h);const y=this.points.length/2-_;y!==0&&(i&&!this._compareStyles(s,f)&&(i.end(m,_),i=null),i||(i=jm.pop()||new bC,i.begin(f,m,_),this.batches.push(i),s=f),this.addUvs(this.points,t,f.texture,_,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<Ug.BATCHABLE_SIZE*2}buildDrawCalls(){let t=++bt._globalBatch;for(let c=0;c<this.drawCalls.length;c++)this.drawCalls[c].texArray.clear(),Xo.push(this.drawCalls[c]);this.drawCalls.length=0;const e=this.colors,i=this.textureIds;let s=Xo.pop();s||(s=new ph,s.texArray=new xh),s.texArray.count=0,s.start=0,s.size=0,s.type=fr.TRIANGLES;let n=0,o=null,a=0,l=!1,h=fr.TRIANGLES,u=0;this.drawCalls.push(s);for(let c=0;c<this.batches.length;c++){const d=this.batches[c],f=8,p=d.style,m=p.texture.baseTexture;l!==!!p.native&&(l=!!p.native,h=l?fr.LINES:fr.TRIANGLES,o=null,n=f,t++),o!==m&&(o=m,m._batchEnabled!==t&&(n===f&&(t++,n=0,s.size>0&&(s=Xo.pop(),s||(s=new ph,s.texArray=new xh),this.drawCalls.push(s)),s.start=u,s.size=0,s.texArray.count=0,s.type=h),m.touched=1,m._batchEnabled=t,m._batchLocation=n,m.wrapMode=Jr.REPEAT,s.texArray.elements[s.texArray.count++]=m,n++)),s.size+=d.size,u+=d.size,a=m._batchLocation,this.addColors(e,p.color,p.alpha,d.attribSize,d.attribStart),this.addTextureIds(i,a,d.attribSize,d.attribStart)}bt._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?Xm.triangulate(t,this):zh[t.type].triangulate(t,this)}processLine(t){Ym(t,this);for(let e=0;e<t.holes.length;e++)Ym(t.holes[e],this)}processHoles(t){for(let e=0;e<t.length;e++){const i=t[e];zh[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=Nt.shared.setValue(e).toLittleEndianNumber(),a=Nt.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 c=t[(s+a)*2],d=t[(s+a)*2+1];if(o){const f=o.a*c+o.c*d+o.tx;d=o.b*c+o.d*d+o.ty,c=f}a++,e.push(c/h.width,d/h.height)}const u=i.baseTexture;(h.width<u.width||h.height<u.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,u=l.height/n.height;let c=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));c-=f,d-=p;for(let m=i;m<a;m+=2)t[m]=(t[m]+c)*h,t[m+1]=(t[m+1]+d)*u}};Wm.BATCHABLE_SIZE=100;let TC=Wm;class zo{constructor(){this.color=16777215,this.alpha=1,this.texture=ct.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new zo;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=ct.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class Yh extends zo{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=ai.BUTT,this.join=qe.MITER,this.miterLimit=10}clone(){const t=new Yh;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=ai.BUTT,this.join=qe.MITER,this.miterLimit=10}}const jh={},Wh=class ia extends nr{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 zo,this._lineStyle=new Yh,this._matrix=null,this._holeMode=!1,this.state=Er.for2d(),this._geometry=t||new TC,this._geometry.refCount++,this._transformID=-1,this._tintColor=new Nt(16777215),this.blendMode=yt.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new ia(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:ct.WHITE,color:t!=null&&t.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:ai.BUTT,join:qe.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 Ri,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new Ri,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),Vh.curveTo(t,e,i,s,n),this}bezierCurveTo(t,e,i,s,n,o){return this._initCurve(),Xh.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=Vm.curveTo(t,e,i,s,n,o);if(a){const{cx:l,cy:h,radius:u,startAngle:c,endAngle:d,anticlockwise:f}=a;this.arc(l,h,u,c,d,f)}return this}arc(t,e,i,s,n,o=!1){if(s===n)return this;if(!o&&n<=s?n+=fo:o&&s<=n&&(s+=fo),n-s===0)return this;const a=t+Math.cos(s)*i,l=e+Math.sin(s)*i,h=this._geometry.closePointEps;let u=this.currentPath?this.currentPath.points:null;if(u){const c=Math.abs(u[u.length-2]-a),d=Math.abs(u[u.length-1]-l);c<h&&d<h||u.push(a,l)}else this.moveTo(a,l),u=this.currentPath.points;return Vm.arc(a,l,t,e,i,s,n,o,u),this}beginFill(t=0,e){return this.beginTextureFill({texture:ct.WHITE,color:t,alpha:e})}normalizeColor(t){const e=Nt.shared.setValue(t.color??0);t.color=e.toNumber(),t.alpha??(t.alpha=e.alpha)}beginTextureFill(t){const e={texture:ct.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 wt(t,e,i,s))}drawRoundedRect(t,e,i,s,n){return this.drawShape(new yo(t,e,i,s,n))}drawCircle(t,e,i){return this.drawShape(new mo(t,e,i))}drawEllipse(t,e,i,s){return this.drawShape(new go(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 Ri(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===Ae.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),u={vertexData:a,blendMode:e,indices:h,uvs:l,_batchRGB:Nt.shared.setValue(o).toRgbArray(),_tintRGB:o,_texture:n.style.texture,alpha:n.style.alpha,worldAlpha:1};this.batches[s]=u}}_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,Nt.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(!jh[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 Gt,default:sr.from({uSamplers:n},!0)},a=t.plugins[i]._shader.program;jh[i]=new wr(a,o)}e=jh[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,ia._TEMP_POINT),this._geometry.containsPoint(ia._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=Nt.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,u=this.vertexData;let c=0;for(let d=0;d<h.length;d+=2){const f=h[d],p=h[d+1];u[c++]=i*f+n*p+a,u[c++]=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)}};Wh.curves=As,Wh._TEMP_POINT=new It;let gn=Wh;class AC{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 qh=new It,qm=new Ri,Km=class Gg extends nr{constructor(t,e,i,s=fr.TRIANGLES){super(),this.geometry=t,this.shader=e,this.state=i||Er.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=tt.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===fr.TRIANGLES&&e.length<Gg.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,u=s.ty,c=this.vertexData;for(let d=0;d<c.length/2;d++){const f=e[d*2],p=e[d*2+1];c[d*2]=n*f+a*p+h,c[d*2+1]=o*f+l*p+u}if(this._roundPixels){const d=tt.RESOLUTION;for(let f=0;f<c.length;++f)c[f]=Math.round(c[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 AC(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,qh);const e=this.geometry.getBuffer("aVertexPosition").data,i=qm.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,u=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[u],i[5]=e[u+1],qm.contains(qh.x,qh.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}};Km.BATCHABLE_SIZE=100;let Zm=Km;class SC extends si{constructor(t,e,i){super();const s=new se(t),n=new se(e,!0),o=new se(i,!0,!0);this.addAttribute("aVertexPosition",s,2,!1,ft.FLOAT).addAttribute("aTextureCoord",n,2,!1,ft.FLOAT).addIndex(o),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var CC=`varying vec2 vTextureCoord;
914
914
  uniform vec4 uColor;
915
915
 
916
916
  uniform sampler2D uSampler;
@@ -919,7 +919,7 @@ void main(void)
919
919
  {
920
920
  gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor;
921
921
  }
922
- `,_C=`attribute vec2 aVertexPosition;
922
+ `,IC=`attribute vec2 aVertexPosition;
923
923
  attribute vec2 aTextureCoord;
924
924
 
925
925
  uniform mat3 projectionMatrix;
@@ -934,7 +934,7 @@ void main(void)
934
934
 
935
935
  vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;
936
936
  }
937
- `;class Ym extends wr{constructor(t,e){const i={uSampler:t,alpha:1,uTextureMatrix:Ut.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||Br.from(_C,yC),i),this._colorDirty=!1,this.uvMatrix=new Hp(t),this.batchable=e.program===void 0,this.pluginName=e.pluginName,this._tintColor=new Ot(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;Ot.shared.setValue(this._tintColor).premultiply(this._alpha,t).toArray(this.uniforms.uColor)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class Wm{constructor(t,e,i){this.geometry=new si,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||ft.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 te(Uw(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 te(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 te(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===ft.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===ft.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===ft.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===ft.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 vC=`varying vec2 vTextureCoord;
937
+ `;class Qm extends wr{constructor(t,e){const i={uSampler:t,alpha:1,uTextureMatrix:Gt.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||Fr.from(IC,CC),i),this._colorDirty=!1,this.uvMatrix=new jp(t),this.batchable=e.program===void 0,this.pluginName=e.pluginName,this._tintColor=new Nt(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;Nt.shared.setValue(this._tintColor).premultiply(this._alpha,t).toArray(this.uniforms.uColor)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class Jm{constructor(t,e,i){this.geometry=new si,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||ft.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 se(qw(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 se(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 se(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===ft.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===ft.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===ft.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===ft.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 RC=`varying vec2 vTextureCoord;
938
938
  varying vec4 vColor;
939
939
 
940
940
  uniform sampler2D uSampler;
@@ -942,7 +942,7 @@ uniform sampler2D uSampler;
942
942
  void main(void){
943
943
  vec4 color = texture2D(uSampler, vTextureCoord) * vColor;
944
944
  gl_FragColor = color;
945
- }`,xC=`attribute vec2 aVertexPosition;
945
+ }`,MC=`attribute vec2 aVertexPosition;
946
946
  attribute vec2 aTextureCoord;
947
947
  attribute vec4 aColor;
948
948
 
@@ -967,8 +967,8 @@ void main(void){
967
967
  vTextureCoord = aTextureCoord;
968
968
  vColor = aColor * uColor;
969
969
  }
970
- `;class jm extends _o{constructor(t){super(t),this.shader=null,this.properties=null,this.tempMatrix=new Ut,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:ft.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=wr.from(xC,vC,{}),this.state=Er.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=hp(t.blendMode,h),n.state.set(this.state);const u=n.gl,c=t.worldTransform.copyTo(this.tempMatrix);c.prepend(n.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=c.toArray(!0),this.shader.uniforms.uColor=Ot.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 _=a[p];_.uploadDynamic(e,f,m);const y=t._bufferUpdateIDs[p]||0;d=d||_._updateID<y,d&&(_._updateID=t._updateID,_.uploadStatic(e,f,m)),n.geometry.bind(_.geometry),u.drawElements(u.TRIANGLES,m*6,u.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 Wm(this.properties,n,s));return e}_generateOneMoreBuffer(t){const e=t._batchSize,i=t._properties;return new Wm(this.properties,i,e)}uploadVertices(t,e,i,s,n,o){let a=0,l=0,h=0,u=0;for(let c=0;c<i;++c){const d=t[e+c],f=d._texture,p=d.scale.x,m=d.scale.y,_=f.trim,y=f.orig;_?(l=_.x-d.anchor.x*y.width,a=l+_.width,u=_.y-d.anchor.y*y.height,h=u+_.height):(a=y.width*(1-d.anchor.x),l=y.width*-d.anchor.x,h=y.height*(1-d.anchor.y),u=y.height*-d.anchor.y),s[o]=l*p,s[o+1]=u*m,s[o+n]=a*p,s[o+n+1]=u*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=Ot.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}}jm.extension={name:"particle",type:Q.RendererPlugin},ht.add(jm);var $o=(r=>(r[r.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",r[r.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",r))($o||{});const Xo={willReadFrequently:!0},Ar=class ct{static get experimentalLetterSpacingSupported(){let t=ct._experimentalLetterSpacingSupported;if(t!==void 0){const e=tt.ADAPTER.getCanvasRenderingContext2D().prototype;t=ct._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=ct._canvas){i=i??e.wordWrap;const n=e.toFontString(),o=ct.measureFont(n);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const a=s.getContext("2d",Xo);a.font=n;const l=(i?ct.wordWrap(t,e,s):t).split(/(?:\r\n|\r|\n)/),h=new Array(l.length);let u=0;for(let p=0;p<l.length;p++){const m=ct._measureText(l[p],e.letterSpacing,a);h[p]=m,u=Math.max(u,m)}let c=u+e.strokeThickness;e.dropShadow&&(c+=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 ct(t,e,c,f,l,h,d+e.leading,u,o)}static _measureText(t,e,i){let s=!1;ct.experimentalLetterSpacingSupported&&(ct.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+=(ct.graphemeSegmenter(t).length-1)*e),n}static wordWrap(t,e,i=ct._canvas){const s=i.getContext("2d",Xo);let n=0,o="",a="";const l=Object.create(null),{letterSpacing:h,whiteSpace:u}=e,c=ct.collapseSpaces(u),d=ct.collapseNewlines(u);let f=!c;const p=e.wordWrapWidth+h,m=ct.tokenize(t);for(let _=0;_<m.length;_++){let y=m[_];if(ct.isNewline(y)){if(!d){a+=ct.addLine(o),f=!c,o="",n=0;continue}y=" "}if(c){const g=ct.isBreakingSpace(y),x=ct.isBreakingSpace(o[o.length-1]);if(g&&x)continue}const v=ct.getFromCache(y,h,l,s);if(v>p)if(o!==""&&(a+=ct.addLine(o),o="",n=0),ct.canBreakWords(y,e.breakWords)){const g=ct.wordWrapSplit(y);for(let x=0;x<g.length;x++){let E=g[x],R=E,S=1;for(;g[x+S];){const P=g[x+S];if(!ct.canBreakChars(R,P,y,x,e.breakWords))E+=P;else break;R=P,S++}x+=S-1;const M=ct.getFromCache(E,h,l,s);M+n>p&&(a+=ct.addLine(o),f=!1,o="",n=0),o+=E,n+=M}}else{o.length>0&&(a+=ct.addLine(o),o="",n=0);const g=_===m.length-1;a+=ct.addLine(y,!g),f=!1,o="",n=0}else v+n>p&&(f=!1,a+=ct.addLine(o),o="",n=0),(o.length>0||!ct.isBreakingSpace(y)||f)&&(o+=y,n+=v)}return a+=ct.addLine(o,!1),a}static addLine(t,e=!0){return t=ct.trimRight(t),t=e?`${t}
971
- `:t,t}static getFromCache(t,e,i,s){let n=i[t];return typeof n!="number"&&(n=ct._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(!ct.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:ct._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:ct._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(ct.isBreakingSpace(n,o)||ct.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 ct.graphemeSegmenter(t)}static measureFont(t){if(ct._fonts[t])return ct._fonts[t];const e={ascent:0,descent:0,fontSize:0},i=ct._canvas,s=ct._context;s.font=t;const n=ct.METRICS_STRING+ct.BASELINE_SYMBOL,o=Math.ceil(s.measureText(n).width);let a=Math.ceil(s.measureText(ct.BASELINE_SYMBOL).width);const l=Math.ceil(ct.HEIGHT_MULTIPLIER*a);if(a=a*ct.BASELINE_MULTIPLIER|0,o===0||l===0)return ct._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,u=h.length,c=o*4;let d=0,f=0,p=!1;for(d=0;d<a;++d){for(let m=0;m<c;m+=4)if(h[f+m]!==255){p=!0;break}if(!p)f+=c;else break}for(e.ascent=a-d,f=u-c,p=!1,d=l;d>a;--d){for(let m=0;m<c;m+=4)if(h[f+m]!==255){p=!0;break}if(!p)f-=c;else break}return e.descent=d-a,e.fontSize=e.ascent+e.descent,ct._fonts[t]=e,e}static clearMetrics(t=""){t?delete ct._fonts[t]:ct._fonts={}}static get _canvas(){var t;if(!ct.__canvas){let e;try{const i=new OffscreenCanvas(0,0);if((t=i.getContext("2d",Xo))!=null&&t.measureText)return ct.__canvas=i,i;e=tt.ADAPTER.createCanvas()}catch{e=tt.ADAPTER.createCanvas()}e.width=e.height=10,ct.__canvas=e}return ct.__canvas}static get _context(){return ct.__context||(ct.__context=ct._canvas.getContext("2d",Xo)),ct.__context}};Ar.METRICS_STRING="|ÉqÅ",Ar.BASELINE_SYMBOL="M",Ar.BASELINE_MULTIPLIER=1.4,Ar.HEIGHT_MULTIPLIER=2,Ar.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]})(),Ar.experimentalLetterSpacing=!1,Ar._fonts={},Ar._newlines=[10,13],Ar._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let li=Ar;const bC=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],qm=class vn{constructor(t){this.styleID=0,this.reset(),Wh(this,t,t)}clone(){const t={};return Wh(t,this,vn.defaultStyle),new vn(t)}reset(){Wh(this,vn.defaultStyle,vn.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=Yh(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=Yh(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){EC(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=Yh(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)&&!bC.includes(s)&&(s=`"${s}"`),e[i]=s}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};qm.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:$o.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 hi=qm;function Yh(r){const t=Ot.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 EC(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 Wh(r,t,e){for(const i in e)Array.isArray(t[i])?r[i]=t[i].slice():r[i]=t[i]}const wC={texture:!0,children:!1,baseTexture:!0},Km=class hu extends _s{constructor(t,e,i){let s=!1;i||(i=tt.ADAPTER.createCanvas(),s=!0),i.width=3,i.height=3;const n=ut.from(i);n.orig=new Et,n.trim=new Et,super(n),this._ownCanvas=s,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=hu.defaultResolution??tt.RESOLUTION,this._autoResolution=hu.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 li.experimentalLetterSpacing}static set experimentalLetterSpacing(t){St("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),li.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=li.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,u=s.maxLineWidth,c=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 _=e.dropShadow&&m===0,y=_?Math.ceil(Math.max(1,o)+e.padding*2):0,v=y*this._resolution;if(_){i.fillStyle="black",i.strokeStyle="black";const x=e.dropShadowColor,E=e.dropShadowBlur*this._resolution,R=e.dropShadowDistance*this._resolution;i.shadowColor=Ot.shared.setValue(x).setAlpha(e.dropShadowAlpha).toRgbaString(),i.shadowBlur=E,i.shadowOffsetX=Math.cos(e.dropShadowAngle)*R,i.shadowOffsetY=Math.sin(e.dropShadowAngle)*R+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 g=(l-c.fontSize)/2;l-c.fontSize<0&&(g=0);for(let x=0;x<a.length;x++)d=e.strokeThickness/2,f=e.strokeThickness/2+x*l+c.ascent+g,e.align==="right"?d+=u-h[x]:e.align==="center"&&(d+=(u-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(li.experimentalLetterSpacingSupported&&(li.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=li.graphemeSegmenter(t);let h=this.context.measureText(t).width,u=0;for(let c=0;c<l.length;++c){const d=l[c];s?this.context.strokeText(d,a,i):this.context.fillText(d,a,i);let f="";for(let p=c+1;p<l.length;++p)f+=l[p];u=this.context.measureText(f).width,a+=h-u+n,h=u}}updateTexture(){const t=this.canvas;if(this._style.trim){const o=Xw(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,u=s.slice(),c=t.fillGradientStops.slice();if(!c.length){const d=u.length+1;for(let f=1;f<d;++f)c.push(f/d)}if(u.unshift(s[0]),c.unshift(0),u.push(s[s.length-1]),c.push(1),t.fillGradientType===$o.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 _=m;f>0&&p>m&&(_=(m+p)/2);const y=m+d,v=i.lineHeight*(f+1);let g=y;f+1<e.length&&v<y&&(g=(y+v)/2);const x=(g-_)/h;for(let E=0;E<u.length;E++){let R=0;typeof c[E]=="number"?R=c[E]:R=E/u.length;let S=Math.min(1,Math.max(0,_/h+R*x));S=Number(S.toFixed(5)),n.addColorStop(S,u[E])}}}else{n=this.context.createLinearGradient(a,h/2,l+a,h/2);const d=u.length+1;let f=1;for(let p=0;p<u.length;p++){let m;typeof c[p]=="number"?m=c[p]:m=f/d,n.addColorStop(m,u[p]),f++}}return n}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},wC,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=ri(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=ri(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 hi?this._style=t:this._style=new hi(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)}};Km.defaultAutoResolution=!0;let Zm=Km;class TC{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function AC(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 ut){const n=r._textures[s].baseTexture;t.includes(n)||(t.push(n),e=!0)}}return e}function SC(r,t){if(r.baseTexture instanceof vt){const e=r.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function CC(r,t){if(r._texture&&r._texture instanceof ut){const e=r._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function IC(r,t){return t instanceof Zm?(t.updateText(!0),!0):!1}function RC(r,t){if(t instanceof hi){const e=t.toFontString();return li.measureFont(e),!0}return!1}function MC(r,t){if(r instanceof Zm){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 PC(r,t){return r instanceof hi?(t.includes(r)||t.push(r),!0):!1}const Qm=class Lg{constructor(t){this.limiter=new TC(Lg.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(MC),this.registerFindHook(PC),this.registerFindHook(AC),this.registerFindHook(SC),this.registerFindHook(CC),this.registerUploadHook(IC),this.registerUploadHook(RC)}upload(t){return new Promise(e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,Xe.system.addOnce(this.tick,this,ki.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)Xe.system.addOnce(this.tick,this,ki.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 nr)for(let e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&Xe.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}};Qm.uploadsPerFrame=4;let jh=Qm;Object.defineProperties(tt,{UPLOADS_PER_FRAME:{get(){return jh.uploadsPerFrame},set(r){St("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),jh.uploadsPerFrame=r}}});function Jm(r,t){return t instanceof vt?(t._glTextures[r.CONTEXT_UID]||r.texture.bind(t),!0):!1}function OC(r,t){if(!(t instanceof fn))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&&Jm(r,n.baseTexture)}return e.batchable||r.geometry.bind(e,t._resolveDirectShader(r)),!0}function NC(r,t){return r instanceof fn?(t.push(r),!0):!1}class tg extends jh{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(NC),this.registerUploadHook(Jm),this.registerUploadHook(OC)}}tg.extension={name:"prepare",type:Q.RendererSystem},ht.add(tg);var DC=`#version 300 es
970
+ `;class tg extends Eo{constructor(t){super(t),this.shader=null,this.properties=null,this.tempMatrix=new Gt,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:ft.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=wr.from(MC,RC,{}),this.state=Er.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=mp(t.blendMode,h),n.state.set(this.state);const u=n.gl,c=t.worldTransform.copyTo(this.tempMatrix);c.prepend(n.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=c.toArray(!0),this.shader.uniforms.uColor=Nt.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 _=a[p];_.uploadDynamic(e,f,m);const y=t._bufferUpdateIDs[p]||0;d=d||_._updateID<y,d&&(_._updateID=t._updateID,_.uploadStatic(e,f,m)),n.geometry.bind(_.geometry),u.drawElements(u.TRIANGLES,m*6,u.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 Jm(this.properties,n,s));return e}_generateOneMoreBuffer(t){const e=t._batchSize,i=t._properties;return new Jm(this.properties,i,e)}uploadVertices(t,e,i,s,n,o){let a=0,l=0,h=0,u=0;for(let c=0;c<i;++c){const d=t[e+c],f=d._texture,p=d.scale.x,m=d.scale.y,_=f.trim,y=f.orig;_?(l=_.x-d.anchor.x*y.width,a=l+_.width,u=_.y-d.anchor.y*y.height,h=u+_.height):(a=y.width*(1-d.anchor.x),l=y.width*-d.anchor.x,h=y.height*(1-d.anchor.y),u=y.height*-d.anchor.y),s[o]=l*p,s[o+1]=u*m,s[o+n]=a*p,s[o+n+1]=u*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=Nt.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}}tg.extension={name:"particle",type:Q.RendererPlugin},ut.add(tg);var Yo=(r=>(r[r.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",r[r.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",r))(Yo||{});const jo={willReadFrequently:!0},Ar=class dt{static get experimentalLetterSpacingSupported(){let t=dt._experimentalLetterSpacingSupported;if(t!==void 0){const e=tt.ADAPTER.getCanvasRenderingContext2D().prototype;t=dt._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=dt._canvas){i=i??e.wordWrap;const n=e.toFontString(),o=dt.measureFont(n);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const a=s.getContext("2d",jo);a.font=n;const l=(i?dt.wordWrap(t,e,s):t).split(/(?:\r\n|\r|\n)/),h=new Array(l.length);let u=0;for(let p=0;p<l.length;p++){const m=dt._measureText(l[p],e.letterSpacing,a);h[p]=m,u=Math.max(u,m)}let c=u+e.strokeThickness;e.dropShadow&&(c+=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 dt(t,e,c,f,l,h,d+e.leading,u,o)}static _measureText(t,e,i){let s=!1;dt.experimentalLetterSpacingSupported&&(dt.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+=(dt.graphemeSegmenter(t).length-1)*e),n}static wordWrap(t,e,i=dt._canvas){const s=i.getContext("2d",jo);let n=0,o="",a="";const l=Object.create(null),{letterSpacing:h,whiteSpace:u}=e,c=dt.collapseSpaces(u),d=dt.collapseNewlines(u);let f=!c;const p=e.wordWrapWidth+h,m=dt.tokenize(t);for(let _=0;_<m.length;_++){let y=m[_];if(dt.isNewline(y)){if(!d){a+=dt.addLine(o),f=!c,o="",n=0;continue}y=" "}if(c){const g=dt.isBreakingSpace(y),x=dt.isBreakingSpace(o[o.length-1]);if(g&&x)continue}const v=dt.getFromCache(y,h,l,s);if(v>p)if(o!==""&&(a+=dt.addLine(o),o="",n=0),dt.canBreakWords(y,e.breakWords)){const g=dt.wordWrapSplit(y);for(let x=0;x<g.length;x++){let T=g[x],M=T,S=1;for(;g[x+S];){const P=g[x+S];if(!dt.canBreakChars(M,P,y,x,e.breakWords))T+=P;else break;M=P,S++}x+=S-1;const R=dt.getFromCache(T,h,l,s);R+n>p&&(a+=dt.addLine(o),f=!1,o="",n=0),o+=T,n+=R}}else{o.length>0&&(a+=dt.addLine(o),o="",n=0);const g=_===m.length-1;a+=dt.addLine(y,!g),f=!1,o="",n=0}else v+n>p&&(f=!1,a+=dt.addLine(o),o="",n=0),(o.length>0||!dt.isBreakingSpace(y)||f)&&(o+=y,n+=v)}return a+=dt.addLine(o,!1),a}static addLine(t,e=!0){return t=dt.trimRight(t),t=e?`${t}
971
+ `:t,t}static getFromCache(t,e,i,s){let n=i[t];return typeof n!="number"&&(n=dt._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(!dt.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:dt._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:dt._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(dt.isBreakingSpace(n,o)||dt.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 dt.graphemeSegmenter(t)}static measureFont(t){if(dt._fonts[t])return dt._fonts[t];const e={ascent:0,descent:0,fontSize:0},i=dt._canvas,s=dt._context;s.font=t;const n=dt.METRICS_STRING+dt.BASELINE_SYMBOL,o=Math.ceil(s.measureText(n).width);let a=Math.ceil(s.measureText(dt.BASELINE_SYMBOL).width);const l=Math.ceil(dt.HEIGHT_MULTIPLIER*a);if(a=a*dt.BASELINE_MULTIPLIER|0,o===0||l===0)return dt._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,u=h.length,c=o*4;let d=0,f=0,p=!1;for(d=0;d<a;++d){for(let m=0;m<c;m+=4)if(h[f+m]!==255){p=!0;break}if(!p)f+=c;else break}for(e.ascent=a-d,f=u-c,p=!1,d=l;d>a;--d){for(let m=0;m<c;m+=4)if(h[f+m]!==255){p=!0;break}if(!p)f-=c;else break}return e.descent=d-a,e.fontSize=e.ascent+e.descent,dt._fonts[t]=e,e}static clearMetrics(t=""){t?delete dt._fonts[t]:dt._fonts={}}static get _canvas(){var t;if(!dt.__canvas){let e;try{const i=new OffscreenCanvas(0,0);if((t=i.getContext("2d",jo))!=null&&t.measureText)return dt.__canvas=i,i;e=tt.ADAPTER.createCanvas()}catch{e=tt.ADAPTER.createCanvas()}e.width=e.height=10,dt.__canvas=e}return dt.__canvas}static get _context(){return dt.__context||(dt.__context=dt._canvas.getContext("2d",jo)),dt.__context}};Ar.METRICS_STRING="|ÉqÅ",Ar.BASELINE_SYMBOL="M",Ar.BASELINE_MULTIPLIER=1.4,Ar.HEIGHT_MULTIPLIER=2,Ar.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]})(),Ar.experimentalLetterSpacing=!1,Ar._fonts={},Ar._newlines=[10,13],Ar._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let li=Ar;const PC=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],eg=class En{constructor(t){this.styleID=0,this.reset(),Zh(this,t,t)}clone(){const t={};return Zh(t,this,En.defaultStyle),new En(t)}reset(){Zh(this,En.defaultStyle,En.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=Kh(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=Kh(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){OC(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=Kh(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)&&!PC.includes(s)&&(s=`"${s}"`),e[i]=s}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};eg.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:Yo.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 hi=eg;function Kh(r){const t=Nt.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 OC(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 Zh(r,t,e){for(const i in e)Array.isArray(t[i])?r[i]=t[i].slice():r[i]=t[i]}const NC={texture:!0,children:!1,baseTexture:!0},rg=class fu extends vs{constructor(t,e,i){let s=!1;i||(i=tt.ADAPTER.createCanvas(),s=!0),i.width=3,i.height=3;const n=ct.from(i);n.orig=new wt,n.trim=new wt,super(n),this._ownCanvas=s,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=fu.defaultResolution??tt.RESOLUTION,this._autoResolution=fu.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 li.experimentalLetterSpacing}static set experimentalLetterSpacing(t){St("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),li.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=li.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,u=s.maxLineWidth,c=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 _=e.dropShadow&&m===0,y=_?Math.ceil(Math.max(1,o)+e.padding*2):0,v=y*this._resolution;if(_){i.fillStyle="black",i.strokeStyle="black";const x=e.dropShadowColor,T=e.dropShadowBlur*this._resolution,M=e.dropShadowDistance*this._resolution;i.shadowColor=Nt.shared.setValue(x).setAlpha(e.dropShadowAlpha).toRgbaString(),i.shadowBlur=T,i.shadowOffsetX=Math.cos(e.dropShadowAngle)*M,i.shadowOffsetY=Math.sin(e.dropShadowAngle)*M+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 g=(l-c.fontSize)/2;l-c.fontSize<0&&(g=0);for(let x=0;x<a.length;x++)d=e.strokeThickness/2,f=e.strokeThickness/2+x*l+c.ascent+g,e.align==="right"?d+=u-h[x]:e.align==="center"&&(d+=(u-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(li.experimentalLetterSpacingSupported&&(li.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=li.graphemeSegmenter(t);let h=this.context.measureText(t).width,u=0;for(let c=0;c<l.length;++c){const d=l[c];s?this.context.strokeText(d,a,i):this.context.fillText(d,a,i);let f="";for(let p=c+1;p<l.length;++p)f+=l[p];u=this.context.measureText(f).width,a+=h-u+n,h=u}}updateTexture(){const t=this.canvas;if(this._style.trim){const o=Jw(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,u=s.slice(),c=t.fillGradientStops.slice();if(!c.length){const d=u.length+1;for(let f=1;f<d;++f)c.push(f/d)}if(u.unshift(s[0]),c.unshift(0),u.push(s[s.length-1]),c.push(1),t.fillGradientType===Yo.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 _=m;f>0&&p>m&&(_=(m+p)/2);const y=m+d,v=i.lineHeight*(f+1);let g=y;f+1<e.length&&v<y&&(g=(y+v)/2);const x=(g-_)/h;for(let T=0;T<u.length;T++){let M=0;typeof c[T]=="number"?M=c[T]:M=T/u.length;let S=Math.min(1,Math.max(0,_/h+M*x));S=Number(S.toFixed(5)),n.addColorStop(S,u[T])}}}else{n=this.context.createLinearGradient(a,h/2,l+a,h/2);const d=u.length+1;let f=1;for(let p=0;p<u.length;p++){let m;typeof c[p]=="number"?m=c[p]:m=f/d,n.addColorStop(m,u[p]),f++}}return n}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},NC,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=ri(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=ri(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 hi?this._style=t:this._style=new hi(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)}};rg.defaultAutoResolution=!0;let ig=rg;class DC{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function LC(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 ct){const n=r._textures[s].baseTexture;t.includes(n)||(t.push(n),e=!0)}}return e}function BC(r,t){if(r.baseTexture instanceof bt){const e=r.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function FC(r,t){if(r._texture&&r._texture instanceof ct){const e=r._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function kC(r,t){return t instanceof ig?(t.updateText(!0),!0):!1}function UC(r,t){if(t instanceof hi){const e=t.toFontString();return li.measureFont(e),!0}return!1}function GC(r,t){if(r instanceof ig){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 $C(r,t){return r instanceof hi?(t.includes(r)||t.push(r),!0):!1}const sg=class $g{constructor(t){this.limiter=new DC($g.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(GC),this.registerFindHook($C),this.registerFindHook(LC),this.registerFindHook(BC),this.registerFindHook(FC),this.registerUploadHook(kC),this.registerUploadHook(UC)}upload(t){return new Promise(e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,Xe.system.addOnce(this.tick,this,ki.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)Xe.system.addOnce(this.tick,this,ki.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 nr)for(let e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&Xe.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}};sg.uploadsPerFrame=4;let Qh=sg;Object.defineProperties(tt,{UPLOADS_PER_FRAME:{get(){return Qh.uploadsPerFrame},set(r){St("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),Qh.uploadsPerFrame=r}}});function ng(r,t){return t instanceof bt?(t._glTextures[r.CONTEXT_UID]||r.texture.bind(t),!0):!1}function HC(r,t){if(!(t instanceof gn))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&&ng(r,n.baseTexture)}return e.batchable||r.geometry.bind(e,t._resolveDirectShader(r)),!0}function XC(r,t){return r instanceof gn?(t.push(r),!0):!1}class og extends Qh{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(XC),this.registerUploadHook(ng),this.registerUploadHook(HC)}}og.extension={name:"prepare",type:Q.RendererSystem},ut.add(og);var VC=`#version 300 es
972
972
  #define SHADER_NAME Tiling-Sprite-100
973
973
 
974
974
  precision lowp float;
@@ -994,7 +994,7 @@ void main(void)
994
994
 
995
995
  fragmentColor = texSample * uColor;
996
996
  }
997
- `,LC=`#version 300 es
997
+ `,zC=`#version 300 es
998
998
  #define SHADER_NAME Tiling-Sprite-300
999
999
 
1000
1000
  precision lowp float;
@@ -1014,7 +1014,7 @@ void main(void)
1014
1014
 
1015
1015
  vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
1016
1016
  }
1017
- `,BC=`#version 100
1017
+ `,YC=`#version 100
1018
1018
  #ifdef GL_EXT_shader_texture_lod
1019
1019
  #extension GL_EXT_shader_texture_lod : enable
1020
1020
  #endif
@@ -1047,7 +1047,7 @@ void main(void)
1047
1047
 
1048
1048
  gl_FragColor = texSample * uColor;
1049
1049
  }
1050
- `,eg=`#version 100
1050
+ `,ag=`#version 100
1051
1051
  #define SHADER_NAME Tiling-Sprite-100
1052
1052
 
1053
1053
  precision lowp float;
@@ -1067,7 +1067,7 @@ void main(void)
1067
1067
 
1068
1068
  vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
1069
1069
  }
1070
- `,FC=`#version 100
1070
+ `,jC=`#version 100
1071
1071
  #define SHADER_NAME Tiling-Sprite-Simple-100
1072
1072
 
1073
1073
  precision lowp float;
@@ -1082,7 +1082,7 @@ void main(void)
1082
1082
  vec4 texSample = texture2D(uSampler, vTextureCoord);
1083
1083
  gl_FragColor = texSample * uColor;
1084
1084
  }
1085
- `;const Vo=new Ut;class rg extends _o{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new Bp,this.state=Er.for2d()}contextChange(){const t=this.renderer,e={globals:t.globalUniforms};this.simpleShader=wr.from(eg,FC,e),this.shader=t.context.webGLVersion>1?wr.from(LC,DC,e):wr.from(eg,BC,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,u=t.tileTransform.localTransform,c=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!==Jr.CLAMP:l.wrapMode===Jr.CLAMP&&(l.wrapMode=Jr.REPEAT));const f=d?this.simpleShader:this.shader,p=a.width,m=a.height,_=t._width,y=t._height;Vo.set(u.a*p/_,u.b*p/y,u.c*m/_,u.d*m/y,u.tx/_,u.ty/y),Vo.invert(),d?Vo.prepend(c.mapCoord):(f.uniforms.uMapCoord=c.mapCoord.toArray(!0),f.uniforms.uClampFrame=c.uClampFrame,f.uniforms.uClampOffset=c.uClampOffset),f.uniforms.uTransform=Vo.toArray(!0),f.uniforms.uColor=Ot.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=hp(t.blendMode,h),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}rg.extension={name:"tilingSprite",type:Q.RendererPlugin},ht.add(rg);const ig=class xn{constructor(t,e,i){this.linkedSheets=[],(t instanceof vt||t instanceof ut)&&(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 ut?s:null,this.baseTexture=s instanceof vt?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=Dr(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<=xn.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=xn.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,u=new Et(0,0,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution);n.rotated?a=new Et(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 Et(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 Et(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 ut(this.baseTexture,a,u,l,n.rotated?2:0,n.anchor,n.borders),ut.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*xn.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*xn.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=[]}};ig.BATCH_SIZE=1e3;let sg=ig;const kC=["jpg","png","jpeg","avif","webp","s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"];function ng(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=ge.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{Object.assign(i,ng([`${s}/${t.data.meta.related_multi_packs[o]}`],n,!0))})}return i}const UC={extension:Q.Asset,cache:{test:r=>r instanceof sg,getCacheableAssets:(r,t)=>ng(r,t,!1)},resolver:{test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&kC.includes(i)},parse:r=>{var e;const t=r.split(".");return{resolution:parseFloat(((e=tt.RETINA_PREFIX.exec(r))==null?void 0:e[1])??"1"),format:t[t.length-2],src:r}}},loader:{name:"spritesheetLoader",extension:{type:Q.LoadParser,priority:lr.Normal},async testParse(r,t){return ge.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var u,c;const{texture:i,imageFilename:s,cachePrefix:n}=(t==null?void 0:t.data)??{};let o=ge.dirname(t.src);o&&o.lastIndexOf("/")!==o.length-1&&(o+="/");let a;if(i&&i.baseTexture)a=i;else{const d=Nh(o+(s??r.meta.image),t.src);a=(await e.load([d]))[d]}const l=new sg({texture:a.baseTexture,data:r,resolutionFilename:t.src,cachePrefix:n});await l.parse();const h=(u=r==null?void 0:r.meta)==null?void 0:u.related_multi_packs;if(Array.isArray(h)){const d=[];for(const p of h){if(typeof p!="string")continue;let m=o+p;(c=t.data)!=null&&c.ignoreMultiPack||(m=Nh(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)}}};ht.add(UC);class zo{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class Yo{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 u=a[h].split("="),c=u[0],d=u[1].replace(/"/gm,""),f=parseFloat(d),p=isNaN(f)?d:f;l[c]=p}i[o].push(l)}const s=new zo;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 qh{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 zo,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 u=o[h];e.char.push({id:parseInt(u.getAttribute("id"),10),page:parseInt(u.getAttribute("page"),10)||0,x:parseInt(u.getAttribute("x"),10),y:parseInt(u.getAttribute("y"),10),width:parseInt(u.getAttribute("width"),10),height:parseInt(u.getAttribute("height"),10),xoffset:parseInt(u.getAttribute("xoffset"),10),yoffset:parseInt(u.getAttribute("yoffset"),10),xadvance:parseInt(u.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 Kh{static test(t){return typeof t=="string"&&t.includes("<font>")?qh.test(tt.ADAPTER.parseXML(t)):!1}static parse(t){return qh.parse(tt.ADAPTER.parseXML(t))}}const Zh=[Yo,qh,Kh];function GC(r){for(let t=0;t<Zh.length;t++)if(Zh[t].test(r))return Zh[t];return null}function HC(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,u=r.width/i-l-h*2,c=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===$o.LINEAR_VERTICAL){a=t.createLinearGradient(u/2,h,u/2,c+h);let p=0;const m=(n.fontProperties.fontSize+e.strokeThickness)/c;for(let _=0;_<s.length;_++){const y=n.lineHeight*_;for(let v=0;v<d.length;v++){let g=0;typeof f[v]=="number"?g=f[v]:g=v/d.length;const x=y/c+g*m;let E=Math.max(p,x);E=Math.min(E,1),a.addColorStop(E,d[v]),p=E}}}else{a=t.createLinearGradient(h,c/2,u+h,c/2);const p=d.length+1;let m=1;for(let _=0;_<d.length;_++){let y;typeof f[_]=="number"?y=f[_]:y=m/p,a.addColorStop(y,d[_]),m++}}return a}function $C(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,u=-(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=HC(r,t,o,n,[a],e),t.strokeStyle=o.stroke,o.dropShadow){const c=o.dropShadowColor,d=o.dropShadowBlur*n,f=o.dropShadowDistance*n;t.shadowColor=Ot.shared.setValue(c).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,u+e.lineHeight-l.descent),o.fill&&t.fillText(a,h,u+e.lineHeight-l.descent),t.setTransform(1,0,0,1,0,0),t.fillStyle="rgba(0, 0, 0, 0)"}function Wo(r){return r.codePointAt?r.codePointAt(0):r.charCodeAt(0)}function og(r){return Array.from?Array.from(r):r.split("")}function XC(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(...og(s))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const ui=class Sr{constructor(t,e,i){var u;const[s]=t.info,[n]=t.common,[o]=t.page,[a]=t.distanceField,l=Dr(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 c=0;c<t.page.length;c++){const{id:d,file:f}=t.page[c];h[d]=e instanceof Array?e[c]:e[f],a!=null&&a.fieldType&&a.fieldType!=="none"&&(h[d].baseTexture.alphaMode=He.NO_PREMULTIPLIED_ALPHA,h[d].baseTexture.mipmap=pr.OFF)}for(let c=0;c<t.char.length;c++){const{id:d,page:f}=t.char[c];let{x:p,y:m,width:_,height:y,xoffset:v,yoffset:g,xadvance:x}=t.char[c];p/=l,m/=l,_/=l,y/=l,v/=l,g/=l,x/=l;const E=new Et(p+h[f].frame.x/l,m+h[f].frame.y/l,_,y);this.chars[d]={xOffset:v,yOffset:g,xAdvance:x,kerning:{},texture:new ut(h[f].baseTexture,E),page:f}}for(let c=0;c<t.kerning.length;c++){let{first:d,second:f,amount:p}=t.kerning[c];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=((u=a==null?void 0:a.fieldType)==null?void 0:u.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 zo)s=t;else{const o=GC(t);if(!o)throw new Error("Unrecognized data format for font.");s=o.parse(t)}e instanceof ut&&(e=[e]);const n=new Sr(s,e,i);return Sr.available[n.font]=n,n}static uninstall(t){const e=Sr.available[t];if(!e)throw new Error(`No font found named '${t}'`);e.destroy(),delete Sr.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({},Sr.defaultOptions,i),u=XC(s),c=e instanceof hi?e:new hi(e),d=a,f=new zo;f.info[0]={face:c.fontFamily,size:c.fontSize},f.common[0]={lineHeight:c.fontSize};let p=0,m=0,_,y,v,g=0;const x=[];for(let R=0;R<u.length;R++){_||(_=tt.ADAPTER.createCanvas(),_.width=a,_.height=l,y=_.getContext("2d"),v=new vt(_,{resolution:o,...h}),x.push(new ut(v)),f.page.push({id:x.length-1,file:""}));const S=u[R],M=li.measureText(S,c,!1,_),P=M.width,F=Math.ceil(M.height),U=Math.ceil((c.fontStyle==="italic"?2:1)*P);if(m>=l-F*o){if(m===0)throw new Error(`[BitmapFont] textureHeight ${l}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${S}')`);--R,_=null,y=null,v=null,m=0,p=0,g=0;continue}if(g=Math.max(F+M.fontProperties.descent,g),U*o+p>=d){if(p===0)throw new Error(`[BitmapFont] textureWidth ${a}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${S}')`);--R,m+=g*o,m=Math.ceil(m),p=0,g=0;continue}$C(_,y,M,p,m,o,c);const I=Wo(M.text);f.char.push({id:I,page:x.length-1,x:p/o,y:m/o,width:U,height:F,xoffset:0,yoffset:0,xadvance:P-(c.dropShadow?c.dropShadowDistance:0)-(c.stroke?c.strokeThickness:0)}),p+=(U+2*n)*o,p=Math.ceil(p)}if(!(i!=null&&i.skipKerning))for(let R=0,S=u.length;R<S;R++){const M=u[R];for(let P=0;P<S;P++){const F=u[P],U=y.measureText(M).width,I=y.measureText(F).width,A=y.measureText(M+F).width-(U+I);A&&f.kerning.push({first:Wo(M),second:Wo(F),amount:A})}}const E=new Sr(f,x,!0);return Sr.available[t]!==void 0&&Sr.uninstall(t),Sr.available[t]=E,E}};ui.ALPHA=[["a","z"],["A","Z"]," "],ui.NUMERIC=[["0","9"]],ui.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],ui.ASCII=[[" ","~"]],ui.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:ui.ALPHANUMERIC},ui.available={};let ci=ui;var VC=`// Pixi texture info\r
1085
+ `;const Wo=new Gt;class lg extends Eo{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new Hp,this.state=Er.for2d()}contextChange(){const t=this.renderer,e={globals:t.globalUniforms};this.simpleShader=wr.from(ag,jC,e),this.shader=t.context.webGLVersion>1?wr.from(zC,VC,e):wr.from(ag,YC,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,u=t.tileTransform.localTransform,c=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!==Jr.CLAMP:l.wrapMode===Jr.CLAMP&&(l.wrapMode=Jr.REPEAT));const f=d?this.simpleShader:this.shader,p=a.width,m=a.height,_=t._width,y=t._height;Wo.set(u.a*p/_,u.b*p/y,u.c*m/_,u.d*m/y,u.tx/_,u.ty/y),Wo.invert(),d?Wo.prepend(c.mapCoord):(f.uniforms.uMapCoord=c.mapCoord.toArray(!0),f.uniforms.uClampFrame=c.uClampFrame,f.uniforms.uClampOffset=c.uClampOffset),f.uniforms.uTransform=Wo.toArray(!0),f.uniforms.uColor=Nt.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=mp(t.blendMode,h),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}lg.extension={name:"tilingSprite",type:Q.RendererPlugin},ut.add(lg);const hg=class wn{constructor(t,e,i){this.linkedSheets=[],(t instanceof bt||t instanceof ct)&&(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 ct?s:null,this.baseTexture=s instanceof bt?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=Lr(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<=wn.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=wn.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,u=new wt(0,0,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution);n.rotated?a=new wt(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 wt(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 wt(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 ct(this.baseTexture,a,u,l,n.rotated?2:0,n.anchor,n.borders),ct.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*wn.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*wn.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=[]}};hg.BATCH_SIZE=1e3;let ug=hg;const WC=["jpg","png","jpeg","avif","webp","s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"];function cg(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=ye.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{Object.assign(i,cg([`${s}/${t.data.meta.related_multi_packs[o]}`],n,!0))})}return i}const qC={extension:Q.Asset,cache:{test:r=>r instanceof ug,getCacheableAssets:(r,t)=>cg(r,t,!1)},resolver:{test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&WC.includes(i)},parse:r=>{var e;const t=r.split(".");return{resolution:parseFloat(((e=tt.RETINA_PREFIX.exec(r))==null?void 0:e[1])??"1"),format:t[t.length-2],src:r}}},loader:{name:"spritesheetLoader",extension:{type:Q.LoadParser,priority:lr.Normal},async testParse(r,t){return ye.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var u,c;const{texture:i,imageFilename:s,cachePrefix:n}=(t==null?void 0:t.data)??{};let o=ye.dirname(t.src);o&&o.lastIndexOf("/")!==o.length-1&&(o+="/");let a;if(i&&i.baseTexture)a=i;else{const d=Fh(o+(s??r.meta.image),t.src);a=(await e.load([d]))[d]}const l=new ug({texture:a.baseTexture,data:r,resolutionFilename:t.src,cachePrefix:n});await l.parse();const h=(u=r==null?void 0:r.meta)==null?void 0:u.related_multi_packs;if(Array.isArray(h)){const d=[];for(const p of h){if(typeof p!="string")continue;let m=o+p;(c=t.data)!=null&&c.ignoreMultiPack||(m=Fh(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)}}};ut.add(qC);class qo{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class Ko{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 u=a[h].split("="),c=u[0],d=u[1].replace(/"/gm,""),f=parseFloat(d),p=isNaN(f)?d:f;l[c]=p}i[o].push(l)}const s=new qo;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 Jh{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 qo,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 u=o[h];e.char.push({id:parseInt(u.getAttribute("id"),10),page:parseInt(u.getAttribute("page"),10)||0,x:parseInt(u.getAttribute("x"),10),y:parseInt(u.getAttribute("y"),10),width:parseInt(u.getAttribute("width"),10),height:parseInt(u.getAttribute("height"),10),xoffset:parseInt(u.getAttribute("xoffset"),10),yoffset:parseInt(u.getAttribute("yoffset"),10),xadvance:parseInt(u.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 tu{static test(t){return typeof t=="string"&&t.includes("<font>")?Jh.test(tt.ADAPTER.parseXML(t)):!1}static parse(t){return Jh.parse(tt.ADAPTER.parseXML(t))}}const eu=[Ko,Jh,tu];function KC(r){for(let t=0;t<eu.length;t++)if(eu[t].test(r))return eu[t];return null}function ZC(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,u=r.width/i-l-h*2,c=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===Yo.LINEAR_VERTICAL){a=t.createLinearGradient(u/2,h,u/2,c+h);let p=0;const m=(n.fontProperties.fontSize+e.strokeThickness)/c;for(let _=0;_<s.length;_++){const y=n.lineHeight*_;for(let v=0;v<d.length;v++){let g=0;typeof f[v]=="number"?g=f[v]:g=v/d.length;const x=y/c+g*m;let T=Math.max(p,x);T=Math.min(T,1),a.addColorStop(T,d[v]),p=T}}}else{a=t.createLinearGradient(h,c/2,u+h,c/2);const p=d.length+1;let m=1;for(let _=0;_<d.length;_++){let y;typeof f[_]=="number"?y=f[_]:y=m/p,a.addColorStop(y,d[_]),m++}}return a}function QC(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,u=-(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=ZC(r,t,o,n,[a],e),t.strokeStyle=o.stroke,o.dropShadow){const c=o.dropShadowColor,d=o.dropShadowBlur*n,f=o.dropShadowDistance*n;t.shadowColor=Nt.shared.setValue(c).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,u+e.lineHeight-l.descent),o.fill&&t.fillText(a,h,u+e.lineHeight-l.descent),t.setTransform(1,0,0,1,0,0),t.fillStyle="rgba(0, 0, 0, 0)"}function Zo(r){return r.codePointAt?r.codePointAt(0):r.charCodeAt(0)}function dg(r){return Array.from?Array.from(r):r.split("")}function JC(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(...dg(s))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const ui=class Sr{constructor(t,e,i){var u;const[s]=t.info,[n]=t.common,[o]=t.page,[a]=t.distanceField,l=Lr(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 c=0;c<t.page.length;c++){const{id:d,file:f}=t.page[c];h[d]=e instanceof Array?e[c]:e[f],a!=null&&a.fieldType&&a.fieldType!=="none"&&(h[d].baseTexture.alphaMode=$e.NO_PREMULTIPLIED_ALPHA,h[d].baseTexture.mipmap=pr.OFF)}for(let c=0;c<t.char.length;c++){const{id:d,page:f}=t.char[c];let{x:p,y:m,width:_,height:y,xoffset:v,yoffset:g,xadvance:x}=t.char[c];p/=l,m/=l,_/=l,y/=l,v/=l,g/=l,x/=l;const T=new wt(p+h[f].frame.x/l,m+h[f].frame.y/l,_,y);this.chars[d]={xOffset:v,yOffset:g,xAdvance:x,kerning:{},texture:new ct(h[f].baseTexture,T),page:f}}for(let c=0;c<t.kerning.length;c++){let{first:d,second:f,amount:p}=t.kerning[c];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=((u=a==null?void 0:a.fieldType)==null?void 0:u.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 qo)s=t;else{const o=KC(t);if(!o)throw new Error("Unrecognized data format for font.");s=o.parse(t)}e instanceof ct&&(e=[e]);const n=new Sr(s,e,i);return Sr.available[n.font]=n,n}static uninstall(t){const e=Sr.available[t];if(!e)throw new Error(`No font found named '${t}'`);e.destroy(),delete Sr.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({},Sr.defaultOptions,i),u=JC(s),c=e instanceof hi?e:new hi(e),d=a,f=new qo;f.info[0]={face:c.fontFamily,size:c.fontSize},f.common[0]={lineHeight:c.fontSize};let p=0,m=0,_,y,v,g=0;const x=[];for(let M=0;M<u.length;M++){_||(_=tt.ADAPTER.createCanvas(),_.width=a,_.height=l,y=_.getContext("2d"),v=new bt(_,{resolution:o,...h}),x.push(new ct(v)),f.page.push({id:x.length-1,file:""}));const S=u[M],R=li.measureText(S,c,!1,_),P=R.width,F=Math.ceil(R.height),U=Math.ceil((c.fontStyle==="italic"?2:1)*P);if(m>=l-F*o){if(m===0)throw new Error(`[BitmapFont] textureHeight ${l}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${S}')`);--M,_=null,y=null,v=null,m=0,p=0,g=0;continue}if(g=Math.max(F+R.fontProperties.descent,g),U*o+p>=d){if(p===0)throw new Error(`[BitmapFont] textureWidth ${a}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${S}')`);--M,m+=g*o,m=Math.ceil(m),p=0,g=0;continue}QC(_,y,R,p,m,o,c);const I=Zo(R.text);f.char.push({id:I,page:x.length-1,x:p/o,y:m/o,width:U,height:F,xoffset:0,yoffset:0,xadvance:P-(c.dropShadow?c.dropShadowDistance:0)-(c.stroke?c.strokeThickness:0)}),p+=(U+2*n)*o,p=Math.ceil(p)}if(!(i!=null&&i.skipKerning))for(let M=0,S=u.length;M<S;M++){const R=u[M];for(let P=0;P<S;P++){const F=u[P],U=y.measureText(R).width,I=y.measureText(F).width,A=y.measureText(R+F).width-(U+I);A&&f.kerning.push({first:Zo(R),second:Zo(F),amount:A})}}const T=new Sr(f,x,!0);return Sr.available[t]!==void 0&&Sr.uninstall(t),Sr.available[t]=T,T}};ui.ALPHA=[["a","z"],["A","Z"]," "],ui.NUMERIC=[["0","9"]],ui.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],ui.ASCII=[[" ","~"]],ui.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:ui.ALPHANUMERIC},ui.available={};let ci=ui;var t2=`// Pixi texture info\r
1086
1086
  varying vec2 vTextureCoord;\r
1087
1087
  uniform sampler2D uSampler;\r
1088
1088
  \r
@@ -1120,7 +1120,7 @@ void main(void) {\r
1120
1120
  // NPM Textures, NPM outputs\r
1121
1121
  gl_FragColor = vec4(uColor.rgb, coverage);\r
1122
1122
  }\r
1123
- `,zC=`// Mesh material default fragment\r
1123
+ `,e2=`// Mesh material default fragment\r
1124
1124
  attribute vec2 aVertexPosition;\r
1125
1125
  attribute vec2 aTextureCoord;\r
1126
1126
  \r
@@ -1136,15 +1136,15 @@ void main(void)\r
1136
1136
  \r
1137
1137
  vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\r
1138
1138
  }\r
1139
- `;const ag=[],lg=[],hg=[],YC=class Bg extends nr{constructor(t,e={}){super();const{align:i,tint:s,maxWidth:n,letterSpacing:o,fontName:a,fontSize:l}=Object.assign({},Bg.styleDefaults,e);if(!ci.available[a])throw new Error(`Missing BitmapFont "${a}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=i,this._tintColor=new Ot(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 Lr(()=>{this.dirty=!0},this,0,0),this._roundPixels=tt.ROUND_PIXELS,this.dirty=!0,this._resolution=tt.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){var U;const t=ci.available[this._fontName],e=this.fontSize,i=e/t.size,s=new It,n=[],o=[],a=[],l=this._text.replace(/(?:\r\n|\r)/g,`
1140
- `)||" ",h=og(l),u=this._maxWidth*t.size/e,c=t.distanceFieldType==="none"?ag:lg;let d=null,f=0,p=0,m=0,_=-1,y=0,v=0,g=0,x=0;for(let I=0;I<h.length;I++){const A=h[I],w=Wo(A);if(/(?:\s)/.test(A)&&(_=I,y=f,x++),A==="\r"||A===`
1141
- `){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 C=t.chars[w];if(!C)continue;d&&C.kerning[d]&&(s.x+=C.kerning[d]);const D=hg.pop()||{texture:ut.EMPTY,line:0,charCode:0,prevSpaces:0,position:new It};D.texture=C.texture,D.line=m,D.charCode=w,D.position.x=Math.round(s.x+C.xOffset+this._letterSpacing/2),D.position.y=Math.round(s.y+C.yOffset),D.prevSpaces=x,n.push(D),f=D.position.x+Math.max(C.xAdvance-C.xOffset,C.texture.orig.width),s.x+=C.xAdvance+this._letterSpacing,g=Math.max(g,C.yOffset+C.texture.height),d=w,_!==-1&&u>0&&s.x>u&&(++v,ps(n,1+_-v,1+I-_),I=_,_=-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 E=h[h.length-1];E!=="\r"&&E!==`
1142
- `&&(/(?:\s)/.test(E)&&(f=y),o.push(f),p=Math.max(p,f),a.push(-1));const R=[];for(let I=0;I<=m;I++){let A=0;this._align==="right"?A=p-o[I]:this._align==="center"?A=(p-o[I])/2:this._align==="justify"&&(A=a[I]<0?0:(p-o[I])/a[I]),R.push(A)}const S=n.length,M={},P=[],F=this._activePagesMeshData;c.push(...F);for(let I=0;I<S;I++){const A=n[I].texture,w=A.baseTexture.uid;if(!M[w]){let C=c.pop();if(!C){const N=new gC;let B,V;t.distanceFieldType==="none"?(B=new Ym(ut.EMPTY),V=yt.NORMAL):(B=new Ym(ut.EMPTY,{program:Br.from(zC,VC),uniforms:{uFWidth:0}}),V=yt.NORMAL_NPM);const L=new zm(N,B);L.blendMode=V,C={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:L,vertices:null,uvs:null,indices:null}}C.index=0,C.indexCount=0,C.vertexCount=0,C.uvsCount=0,C.total=0;const{_textureCache:D}=this;D[w]=D[w]||new ut(A.baseTexture),C.mesh.texture=D[w],C.mesh.tint=this._tintColor.value,P.push(C),M[w]=C}M[w].total++}for(let I=0;I<F.length;I++)P.includes(F[I])||this.removeChild(F[I].mesh);for(let I=0;I<P.length;I++)P[I].mesh.parent!==this&&this.addChild(P[I].mesh);this._activePagesMeshData=P;for(const I in M){const A=M[I],w=A.total;if(!(((U=A.indices)==null?void 0:U.length)>6*w)||A.vertices.length<zm.BATCHABLE_SIZE*2)A.vertices=new Float32Array(4*2*w),A.uvs=new Float32Array(4*2*w),A.indices=new Uint16Array(6*w);else{const C=A.total,D=A.vertices;for(let N=C*4*2;N<D.length;N++)D[N]=0}A.mesh.size=6*w}for(let I=0;I<S;I++){const A=n[I];let w=A.position.x+R[A.line]*(this._align==="justify"?A.prevSpaces:1);this._roundPixels&&(w=Math.round(w));const C=w*i,D=A.position.y*i,N=A.texture,B=M[N.baseTexture.uid],V=N.frame,L=N._uvs,O=B.index++;B.indices[O*6+0]=0+O*4,B.indices[O*6+1]=1+O*4,B.indices[O*6+2]=2+O*4,B.indices[O*6+3]=0+O*4,B.indices[O*6+4]=2+O*4,B.indices[O*6+5]=3+O*4,B.vertices[O*8+0]=C,B.vertices[O*8+1]=D,B.vertices[O*8+2]=C+V.width*i,B.vertices[O*8+3]=D,B.vertices[O*8+4]=C+V.width*i,B.vertices[O*8+5]=D+V.height*i,B.vertices[O*8+6]=C,B.vertices[O*8+7]=D+V.height*i,B.uvs[O*8+0]=L.x0,B.uvs[O*8+1]=L.y0,B.uvs[O*8+2]=L.x1,B.uvs[O*8+3]=L.y1,B.uvs[O*8+4]=L.x2,B.uvs[O*8+5]=L.y2,B.uvs[O*8+6]=L.x3,B.uvs[O*8+7]=L.y3}this._textWidth=p*i,this._textHeight=(s.y+t.lineHeight)*i;for(const I in M){const A=M[I];if(this.anchor.x!==0||this.anchor.y!==0){let N=0;const B=this._textWidth*this.anchor.x,V=this._textHeight*this.anchor.y;for(let L=0;L<A.total;L++)A.vertices[N++]-=B,A.vertices[N++]-=V,A.vertices[N++]-=B,A.vertices[N++]-=V,A.vertices[N++]-=B,A.vertices[N++]-=V,A.vertices[N++]-=B,A.vertices[N++]-=V}this._maxLineHeight=g*i;const w=A.mesh.geometry.getBuffer("aVertexPosition"),C=A.mesh.geometry.getBuffer("aTextureCoord"),D=A.mesh.geometry.getIndex();w.data=A.vertices,C.data=A.uvs,D.data=A.indices,w.update(),C.update(),D.update()}for(let I=0;I<n.length;I++)hg.push(n[I]);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}=ci.available[this._fontName];if(i!=="none"){const{a:n,b:o,c:a,d:l}=this.worldTransform,h=Math.sqrt(n*n+o*o),u=Math.sqrt(a*a+l*l),c=(Math.abs(h)+Math.abs(u))/2,d=this.fontSize/s,f=t._view.resolution;for(const p of this._activePagesMeshData)p.mesh.shader.uniforms.uFWidth=c*e*d*f}super._render(t)}getLocalBounds(){return this.validate(),super.getLocalBounds()}validate(){const t=ci.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(!ci.available[t])throw new Error(`Missing BitmapFont "${t}"`);this._fontName!==t&&(this._fontName=t,this.dirty=!0)}get fontSize(){return this._fontSize??ci.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=ci.available[this._fontName].distanceFieldType==="none"?ag:lg;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=ut.EMPTY});for(const s in e)e[s].destroy(),delete e[s];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(t)}};YC.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};const WC=[".xml",".fnt"],jC={extension:{type:Q.LoadParser,priority:lr.Normal},name:"loadBitmapFont",test(r){return WC.includes(ge.extname(r).toLowerCase())},async testParse(r){return Yo.test(r)||Kh.test(r)},async parse(r,t,e){const i=Yo.test(r)?Yo.parse(r):Kh.parse(r),{src:s}=t,{page:n}=i,o=[];for(let h=0;h<n.length;++h){const u=n[h].file;let c=ge.join(ge.dirname(s),u);c=Nh(c,s),o.push(c)}const a=await e.load(o),l=o.map(h=>a[h]);return ci.install(i,l,!0)},async load(r,t){return(await tt.ADAPTER.fetch(r)).text()},unload(r){r.destroy()}};ht.add(jC);const Qh=class Is extends hi{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(t){return new Is(Object.keys(Is.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 Is.availableFonts[t.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(t,e={}){const{availableFonts:i}=Is;if(i[t]){const s=i[t];return this._fonts.push(s),s.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return tt.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:ge.basename(t,ge.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}
1139
+ `;const fg=[],pg=[],mg=[],r2=class Hg extends nr{constructor(t,e={}){super();const{align:i,tint:s,maxWidth:n,letterSpacing:o,fontName:a,fontSize:l}=Object.assign({},Hg.styleDefaults,e);if(!ci.available[a])throw new Error(`Missing BitmapFont "${a}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=i,this._tintColor=new Nt(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 Br(()=>{this.dirty=!0},this,0,0),this._roundPixels=tt.ROUND_PIXELS,this.dirty=!0,this._resolution=tt.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){var U;const t=ci.available[this._fontName],e=this.fontSize,i=e/t.size,s=new It,n=[],o=[],a=[],l=this._text.replace(/(?:\r\n|\r)/g,`
1140
+ `)||" ",h=dg(l),u=this._maxWidth*t.size/e,c=t.distanceFieldType==="none"?fg:pg;let d=null,f=0,p=0,m=0,_=-1,y=0,v=0,g=0,x=0;for(let I=0;I<h.length;I++){const A=h[I],w=Zo(A);if(/(?:\s)/.test(A)&&(_=I,y=f,x++),A==="\r"||A===`
1141
+ `){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 C=t.chars[w];if(!C)continue;d&&C.kerning[d]&&(s.x+=C.kerning[d]);const L=mg.pop()||{texture:ct.EMPTY,line:0,charCode:0,prevSpaces:0,position:new It};L.texture=C.texture,L.line=m,L.charCode=w,L.position.x=Math.round(s.x+C.xOffset+this._letterSpacing/2),L.position.y=Math.round(s.y+C.yOffset),L.prevSpaces=x,n.push(L),f=L.position.x+Math.max(C.xAdvance-C.xOffset,C.texture.orig.width),s.x+=C.xAdvance+this._letterSpacing,g=Math.max(g,C.yOffset+C.texture.height),d=w,_!==-1&&u>0&&s.x>u&&(++v,ms(n,1+_-v,1+I-_),I=_,_=-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!==`
1142
+ `&&(/(?:\s)/.test(T)&&(f=y),o.push(f),p=Math.max(p,f),a.push(-1));const M=[];for(let I=0;I<=m;I++){let A=0;this._align==="right"?A=p-o[I]:this._align==="center"?A=(p-o[I])/2:this._align==="justify"&&(A=a[I]<0?0:(p-o[I])/a[I]),M.push(A)}const S=n.length,R={},P=[],F=this._activePagesMeshData;c.push(...F);for(let I=0;I<S;I++){const A=n[I].texture,w=A.baseTexture.uid;if(!R[w]){let C=c.pop();if(!C){const O=new SC;let B,V;t.distanceFieldType==="none"?(B=new Qm(ct.EMPTY),V=yt.NORMAL):(B=new Qm(ct.EMPTY,{program:Fr.from(e2,t2),uniforms:{uFWidth:0}}),V=yt.NORMAL_NPM);const D=new Zm(O,B);D.blendMode=V,C={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:D,vertices:null,uvs:null,indices:null}}C.index=0,C.indexCount=0,C.vertexCount=0,C.uvsCount=0,C.total=0;const{_textureCache:L}=this;L[w]=L[w]||new ct(A.baseTexture),C.mesh.texture=L[w],C.mesh.tint=this._tintColor.value,P.push(C),R[w]=C}R[w].total++}for(let I=0;I<F.length;I++)P.includes(F[I])||this.removeChild(F[I].mesh);for(let I=0;I<P.length;I++)P[I].mesh.parent!==this&&this.addChild(P[I].mesh);this._activePagesMeshData=P;for(const I in R){const A=R[I],w=A.total;if(!(((U=A.indices)==null?void 0:U.length)>6*w)||A.vertices.length<Zm.BATCHABLE_SIZE*2)A.vertices=new Float32Array(4*2*w),A.uvs=new Float32Array(4*2*w),A.indices=new Uint16Array(6*w);else{const C=A.total,L=A.vertices;for(let O=C*4*2;O<L.length;O++)L[O]=0}A.mesh.size=6*w}for(let I=0;I<S;I++){const A=n[I];let w=A.position.x+M[A.line]*(this._align==="justify"?A.prevSpaces:1);this._roundPixels&&(w=Math.round(w));const C=w*i,L=A.position.y*i,O=A.texture,B=R[O.baseTexture.uid],V=O.frame,D=O._uvs,N=B.index++;B.indices[N*6+0]=0+N*4,B.indices[N*6+1]=1+N*4,B.indices[N*6+2]=2+N*4,B.indices[N*6+3]=0+N*4,B.indices[N*6+4]=2+N*4,B.indices[N*6+5]=3+N*4,B.vertices[N*8+0]=C,B.vertices[N*8+1]=L,B.vertices[N*8+2]=C+V.width*i,B.vertices[N*8+3]=L,B.vertices[N*8+4]=C+V.width*i,B.vertices[N*8+5]=L+V.height*i,B.vertices[N*8+6]=C,B.vertices[N*8+7]=L+V.height*i,B.uvs[N*8+0]=D.x0,B.uvs[N*8+1]=D.y0,B.uvs[N*8+2]=D.x1,B.uvs[N*8+3]=D.y1,B.uvs[N*8+4]=D.x2,B.uvs[N*8+5]=D.y2,B.uvs[N*8+6]=D.x3,B.uvs[N*8+7]=D.y3}this._textWidth=p*i,this._textHeight=(s.y+t.lineHeight)*i;for(const I in R){const A=R[I];if(this.anchor.x!==0||this.anchor.y!==0){let O=0;const B=this._textWidth*this.anchor.x,V=this._textHeight*this.anchor.y;for(let D=0;D<A.total;D++)A.vertices[O++]-=B,A.vertices[O++]-=V,A.vertices[O++]-=B,A.vertices[O++]-=V,A.vertices[O++]-=B,A.vertices[O++]-=V,A.vertices[O++]-=B,A.vertices[O++]-=V}this._maxLineHeight=g*i;const w=A.mesh.geometry.getBuffer("aVertexPosition"),C=A.mesh.geometry.getBuffer("aTextureCoord"),L=A.mesh.geometry.getIndex();w.data=A.vertices,C.data=A.uvs,L.data=A.indices,w.update(),C.update(),L.update()}for(let I=0;I<n.length;I++)mg.push(n[I]);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}=ci.available[this._fontName];if(i!=="none"){const{a:n,b:o,c:a,d:l}=this.worldTransform,h=Math.sqrt(n*n+o*o),u=Math.sqrt(a*a+l*l),c=(Math.abs(h)+Math.abs(u))/2,d=this.fontSize/s,f=t._view.resolution;for(const p of this._activePagesMeshData)p.mesh.shader.uniforms.uFWidth=c*e*d*f}super._render(t)}getLocalBounds(){return this.validate(),super.getLocalBounds()}validate(){const t=ci.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(!ci.available[t])throw new Error(`Missing BitmapFont "${t}"`);this._fontName!==t&&(this._fontName=t,this.dirty=!0)}get fontSize(){return this._fontSize??ci.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=ci.available[this._fontName].distanceFieldType==="none"?fg:pg;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=ct.EMPTY});for(const s in e)e[s].destroy(),delete e[s];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(t)}};r2.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};const i2=[".xml",".fnt"],s2={extension:{type:Q.LoadParser,priority:lr.Normal},name:"loadBitmapFont",test(r){return i2.includes(ye.extname(r).toLowerCase())},async testParse(r){return Ko.test(r)||tu.test(r)},async parse(r,t,e){const i=Ko.test(r)?Ko.parse(r):tu.parse(r),{src:s}=t,{page:n}=i,o=[];for(let h=0;h<n.length;++h){const u=n[h].file;let c=ye.join(ye.dirname(s),u);c=Fh(c,s),o.push(c)}const a=await e.load(o),l=o.map(h=>a[h]);return ci.install(i,l,!0)},async load(r,t){return(await tt.ADAPTER.fetch(r)).text()},unload(r){r.destroy()}};ut.add(s2);const ru=class Ms extends hi{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(t){return new Ms(Object.keys(Ms.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 Ms.availableFonts[t.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(t,e={}){const{availableFonts:i}=Ms;if(i[t]){const s=i[t];return this._fonts.push(s),s.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return tt.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:ye.basename(t,ye.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}
1143
1143
  @font-face {
1144
1144
  font-family: "${e.family}";
1145
1145
  src: url('${e.dataSrc}');
1146
1146
  font-weight: ${e.weight};
1147
1147
  font-style: ${e.style};
1148
1148
  font-display: ${e.display};
1149
- }`,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=Fw(t)),typeof t=="number"?Bw(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,Is.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}=tt.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}};Qh.availableFonts={},Qh.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 Jh=Qh;const jo=class Rs extends _s{constructor(t="",e={}){super(ut.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=ut.from(i,{scaleMode:tt.SCALE_MODE,resourceOptions:{autoLoad:!1}});s.orig=new Et,s.trim=new Et,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"),u=document.createElementNS(o,"style");l.setAttribute("width","10000"),l.setAttribute("height","10000"),l.style.overflow="hidden",a.appendChild(l),this.maxWidth=Rs.defaultMaxWidth,this.maxHeight=Rs.defaultMaxHeight,this._domElement=h,this._styleElement=u,this._svgRoot=a,this._foreignObject=l,this._foreignObject.appendChild(u),this._foreignObject.appendChild(h),this._image=i,this._loadImage=new Image,this._autoResolution=Rs.defaultAutoResolution,this._resolution=Rs.defaultResolution??tt.RESOLUTION,this.text=t,this.style=e}measureText(t){var u,c;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:(u=this._style)==null?void 0:u.toCSS(s)}),this._styleElement.textContent=(c=this._style)==null?void 0:c.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({},Rs.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=ri(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=ri(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 Jh?(this.ownsStyle=!1,this._style=t):t instanceof hi?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=Jh.from(t)):(this.ownsStyle=!0,this._style=new Jh(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(/&nbsp;/gi,"&#160;")}};jo.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},jo.defaultMaxWidth=2024,jo.defaultMaxHeight=2024,jo.defaultAutoResolution=!0;const qC=16777215,KC=.25,ZC=16777215,QC=1,JC=1.5;let di=!1,pn;const tu=r=>{const t={tint:r!=null&&r.fill?new Ot(r.fill).toNumber():qC,alpha:(r==null?void 0:r.fillOpacity)!==void 0?Math.min(r.fillOpacity,1):String(r==null?void 0:r.fill).toLowerCase().startsWith("rgba(")?new Ot(r==null?void 0:r.fill).alpha:KC},e={tint:r!=null&&r.stroke?new Ot(r.stroke).toNumber():ZC,alpha:(r==null?void 0:r.strokeOpacity)!==void 0?Math.min(r.strokeOpacity,1):String(r==null?void 0:r.stroke).toLowerCase().startsWith("rgba(")?new Ot(r==null?void 0:r.stroke).alpha:QC,lineWidth:(r==null?void 0:r.strokeWidth)===void 0?JC:r.strokeWidth};return{fillStyle:t,strokeStyle:e}},qo=r=>(t,e,i)=>{const{fillStyle:s,strokeStyle:n}=tu(i),o=new fn;o.beginFill(16777215),r(e,o),o.endFill(),o.tint=s.tint,o.alpha=s.alpha,t.addChild(o);const a=new fn,l=n.lineWidth===1?1:n.lineWidth/pn;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}},t2=qo((r,t)=>{const{x:e,y:i,w:s,h:n}=r.geometry;t.drawRect(e,i,s,n)}),e2=qo((r,t)=>{const{cx:e,cy:i,rx:s,ry:n}=r.geometry;t.drawEllipse(e,i,s,n)}),r2=qo((r,t)=>{const e=r.geometry.points.reduce((i,s)=>[...i,...s],[]);t.drawPolygon(e)}),i2=qo((r,t)=>{const e=i=>i.points.reduce((s,n)=>[...s,...n],[]);r.geometry.polygons.forEach(i=>{const[s,...n]=i.rings;t.drawPolygon(e(s)),n.forEach(o=>{t.beginHole(),t.drawPolygon(e(o)),t.endHole()})})}),ug=r=>{const t=r.viewport.getContainerSize().x;return r.viewport.getZoom(!0)*t/r.world.getContentFactor()},cg=(r,t,e,i)=>()=>{const s=r.viewport.viewportToImageRectangle(r.viewport.getBounds(!0)),n=ug(r);(n!==pn||!di)&&(di=!0,e.forEach(({stroke:d,strokeWidth:f})=>{const{lineStyle:p}=d.geometry.graphicsData[0];f>1?(di=n===pn,p.width=f/n,p.native=!1,d.geometry.invalidate()):f===1&&!p.native&&(p.width=1,p.native=!0,d.geometry.invalidate())})),pn=n;const o=r.viewport.getFlip();let a=Math.PI*r.viewport.getRotation(!0)/180;a<0&&(a+=2*Math.PI),a>2*Math.PI&&(a-=2*Math.PI);const l=o?r.viewport._containerInnerSize.x+s.x*n:-s.x*n,h=-s.y*n;let u,c;a>0&&a<=Math.PI/2?(u=s.height*n,c=0):a>Math.PI/2&&a<=Math.PI?(u=s.width*n,c=s.height*n):a>Math.PI&&a<=Math.PI*1.5?(u=0,c=s.width*n):(u=0,c=0),t.position.x=u+l*Math.cos(a)-h*Math.sin(a),t.position.y=c+l*Math.sin(a)+h*Math.cos(a),t.scale.set(o?-n:n,n),t.rotation=a,i.render(t)},s2=(r,t)=>{const e=new fn,i=am({width:t.width,height:t.height,backgroundAlpha:0,view:t,antialias:!0,resolution:2}),s=new Map;let n=new Set,o,a;pn=ug(r);const l=(g,x)=>{di=!1;const{selector:E}=g.target,R=typeof a=="function"?a(g,x):a;let S;E.type===Tt.RECTANGLE?S=t2(e,E,R):E.type===Tt.POLYGON?S=r2(e,E,R):E.type===Tt.ELLIPSE?S=e2(e,E,R):E.type===Tt.MULTIPOLYGLON?S=i2(e,E,R):console.warn(`Unsupported shape type: ${E.type}`),S&&s.set(g.id,{annotation:g,...S})},h=g=>{const x=s.get(g.id);x&&(s.delete(g.id),x.fill.destroy(),x.stroke.destroy())},u=(g,x,E)=>{di=!1;const R=s.get(g.id);if(R&&(s.delete(g.id),R.fill.destroy(),R.stroke.destroy(),l(x,E),n.has(x.id))){const{fill:S,stroke:M}=s.get(x.id);e.removeChild(S),e.removeChild(M)}},c=(g,x)=>{const E=s.get(g);E&&(s.delete(g),E.fill.destroy(),E.stroke.destroy(),l(E.annotation,x))},d=(g,x)=>{i.resize(g,x),i.render(e)},f=g=>{di=!1;const{children:x}=e;s.forEach(({fill:E,stroke:R,annotation:S})=>{const M=g?n.has(S.id)||g(S):!0;M&&!x.includes(E)?(e.addChild(E),e.addChild(R)):!M&&x.includes(E)&&(e.removeChild(E),e.removeChild(R))}),i.render(e)},p=g=>{const x=new Set(g.selected.map(S=>S.id)),E=g.selected.filter(({id:S})=>!n.has(S)),R=[...n].filter(S=>!x.has(S));E.forEach(({id:S,editable:M})=>{if(M){const P=s.get(S);P&&(e.removeChild(P.fill),e.removeChild(P.stroke))}else c(S,{selected:!0,hovered:S===o})}),R.forEach(S=>c(S,{hovered:S===o})),n=x,i.render(e)},m=g=>{o!==g&&(o&&!n.has(o)&&c(o,{selected:n.has(o)}),g&&c(g,{selected:n.has(g),hovered:!0}),o=g,i.render(e))},_=g=>{if(typeof g=="function")s.forEach(({annotation:x,fill:E,stroke:R,strokeWidth:S},M)=>{S>1&&(di=!1);const P={selected:n.has(x.id),hovered:o===x.id},{fillStyle:F,strokeStyle:U}=tu(g(x,P));E.tint=F.tint,E.alpha=F.alpha,R.tint=U.tint||16777215,R.alpha=U.alpha,s.set(x.id,{annotation:x,fill:E,stroke:R,strokeWidth:U.lineWidth})});else{const{fillStyle:x,strokeStyle:E}=tu(g);E.lineWidth>1&&(di=!1),s.forEach(({annotation:R,fill:S,stroke:M,strokeWidth:P},F)=>{S.tint=x.tint,S.alpha=x.alpha,M.tint=E.tint||16777215,M.alpha=E.alpha,s.set(R.id,{annotation:R,fill:S,stroke:M,strokeWidth:E.lineWidth})})}a=g,i.render(e),cg(r,e,s,i)()},y=g=>{g?t.classList.remove("hidden"):t.classList.add("hidden")};return{addAnnotation:l,destroy:()=>i.destroy(),redraw:cg(r,e,s,i),removeAnnotation:h,resize:d,setFilter:f,setHovered:m,setSelected:p,setStyle:_,setVisible:y,updateAnnotation:u}};function n2(r,t,e){let i,s,{filter:n}=t,{state:o}=t,{style:a}=t,{viewer:l}=t,{visible:h=!0}=t;const{store:u,hover:c,selection:d,viewport:f}=o;Nn(r,c,R=>e(11,i=R)),Nn(r,d,R=>e(8,s=R));const p=Ki();let m,_;const y=R=>{const S=new ve.Point(R.x,R.y),{x:M,y:P}=l.viewport.pointFromPixel(S);return l.viewport.viewportToImageCoordinates(M,P)},v=R=>{const{x:S,y:M}=R.position;_={x:S,y:M}},g=R=>S=>{const{x:M,y:P}=y(new ve.Point(S.offsetX,S.offsetY)),F=u.getAt(M,P,n);F?(R.classList.add("hover"),i!==F.id&&(c.set(F.id),m.setHovered(F.id))):(R.classList.remove("hover"),i&&(c.set(void 0),m.setHovered(void 0)))},x=R=>{if(!_)return;const S=R.originalEvent,{x:M,y:P}=R.position,F=M-_.x,U=P-_.y;if(Math.sqrt(F*F+U*U)<5){const{x:A,y:w}=y(R.position),C=u.getAt(A,w,n);C?p("click",{originalEvent:S,annotation:C}):p("click",{originalEvent:S})}_=void 0};let E;return vi(()=>{var D;const{offsetWidth:R,offsetHeight:S}=l.canvas,M=document.createElement("canvas");M.width=R,M.height=S,M.className="a9s-gl-canvas",(D=l.element.querySelector(".openseadragon-canvas"))==null||D.appendChild(M),e(7,m=s2(l,M));const P=g(M);M.addEventListener("pointermove",P);const F=new ResizeObserver(N=>{try{const{width:B,height:V}=N[0].contentRect;M.width=B,M.height=V,m.resize(B,V)}catch{console.warn("WebGL canvas already disposed")}});F.observe(M);const U=()=>{const N=l.viewport.getBounds();E=l.viewport.viewportToImageRectangle(N);const{x:B,y:V,width:L,height:O}=E,k=u.getIntersecting(B,V,L,O);f.set(k.map(X=>X.id))};l.addHandler("canvas-press",v),l.addHandler("canvas-release",x),l.addHandler("update-viewport",m.redraw),l.addHandler("animation-finish",U);const I=N=>N.filter(B=>ze(B)),A=N=>ze(N.oldValue)&&ze(N.newValue),w=N=>{const{selector:B}=N.target;if(B.type===Tt.POLYGON){const V=$v(B);return{...N,target:{...N.target,selector:{...V}}}}else if(B.type===Tt.MULTIPOLYGLON){const V=Gv(B);return{...N,target:{...N.target,selector:{...V}}}}else return N},C=N=>{const{created:B,updated:V,deleted:L}=N.changes;if((B||[]).filter(k=>ze(k)).map(w).forEach(k=>m.addAnnotation(k)),I(L||[]).forEach(k=>m.removeAnnotation(k)),(V||[]).filter(k=>A(k)).map(({oldValue:k,newValue:X})=>({oldValue:k,newValue:w(X)})).forEach(({oldValue:k,newValue:X})=>m.updateAnnotation(k,X)),E){const{x:k,y:X,width:Y,height:q}=E,pt=u.getIntersecting(k,X,Y,q);f.set(pt.map(_t=>_t.id))}else f.set(u.all().map(k=>k.id));m.redraw()};return u.observe(C),()=>{var N;M.removeEventListener("pointermove",P),F.disconnect(),l.removeHandler("canvas-press",v),l.removeHandler("canvas-release",x),l.removeHandler("update-viewport",m.redraw),l.removeHandler("animation-finish",U),u.unobserve(C),m.destroy(),(N=M.parentNode)==null||N.removeChild(M)}}),r.$$set=R=>{"filter"in R&&e(2,n=R.filter),"state"in R&&e(3,o=R.state),"style"in R&&e(4,a=R.style),"viewer"in R&&e(5,l=R.viewer),"visible"in R&&e(6,h=R.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))},[c,d,n,o,a,l,h,m,s]}class o2 extends se{constructor(t){super(),ie(this,t,n2,null,qt,{filter:2,state:3,style:4,viewer:5,visible:6})}}const dg=(r,t,e,i)=>{if(!i)return r;if(t.shiftKey||t.ctrlKey||t.metaKey){const n=(e.selected||[]).map(o=>o.id);return n.includes(r)?n.filter(o=>o!==r):[...n,r]}else return r},a2=r=>({transform:r&2,scale:r&1}),fg=r=>({transform:r[1],scale:r[0]});function l2(r){let t;const e=r[4].default,i=Hc(e,r,r[3],fg);return{c(){i&&i.c()},m(s,n){i&&i.m(s,n),t=!0},p(s,[n]){i&&i.p&&(!t||n&11)&&Vc(i,e,s,s[3],t?Xc(e,s[3],n,a2):zc(s[3]),fg)},i(s){t||(K(i,s),t=!0)},o(s){lt(i,s),t=!1},d(s){i&&i.d(s)}}}function h2(r,t,e){let{$$slots:i={},$$scope:s}=t,{viewer:n}=t,o=1,a;const l=()=>{const h=n.viewport.getContainerSize().x,u=n.viewport.getZoom(!0),c=n.viewport.getFlip(),d=n.viewport.pixelFromPoint(new ve.Point(0,0),!0);c&&(d.x=h-d.x);const f=u*h/n.world.getContentFactor(),p=c?-f:f,m=n.viewport.getRotation(!0);e(1,a=`translate(${d.x}, ${d.y}) scale(${p}, ${f}) rotate(${m})`),e(0,o=u*h/n.world.getContentFactor())};return vi(()=>(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 eu extends se{constructor(t){super(),ie(this,t,h2,l2,qt,{viewer:2})}}function u2(r,t,e){const i=Ki();let{drawingMode:s}=t,{opts:n}=t,{target:o}=t,{tool:a}=t,{transform:l}=t,{viewer:h}=t,{viewportScale:u}=t,c;return vi(()=>{const d=o.closest("svg"),f=[],p=(m,_,y)=>{if(d==null||d.addEventListener(m,_,y),f.push(()=>d==null?void 0:d.removeEventListener(m,_,y)),m==="pointerup"||m==="dblclick"){const v=x=>{const{originalEvent:E}=x;_(E)},g=m==="pointerup"?"canvas-click":"canvas-double-click";h.addHandler(g,v),f.push(()=>h.removeHandler(g,v))}else if(m==="pointermove"){const v=g=>{const{originalEvent:x}=g;_(x)};h.addHandler("canvas-drag",v),f.push(()=>h.removeHandler("canvas-drag",v))}};return e(7,c=new a({target:o,props:{addEventListener:p,drawingMode:s,opts:n,transform:l,viewportScale:u,svgEl:d}})),c.$on("create",m=>i("create",m.detail)),()=>{f.forEach(m=>m()),c.$destroy()}}),r.$$set=d=>{"drawingMode"in d&&e(0,s=d.drawingMode),"opts"in d&&e(1,n=d.opts),"target"in d&&e(2,o=d.target),"tool"in d&&e(3,a=d.tool),"transform"in d&&e(4,l=d.transform),"viewer"in d&&e(5,h=d.viewer),"viewportScale"in d&&e(6,u=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&144&&c&&c.$set({transform:l}),r.$$.dirty&192&&c&&c.$set({viewportScale:u})},[s,n,o,a,l,h,u,c]}class c2 extends se{constructor(t){super(),ie(this,t,u2,null,qt,{drawingMode:0,opts:1,target:2,tool:3,transform:4,viewer:5,viewportScale:6})}}const{Boolean:d2}=ka;function pg(r,t,e){const i=r.slice();i[36]=t[e];const s=i[17](i[36].target.selector);return i[37]=s,i}function f2(r){let t=`${r[2]}-${r[7]}`,e,i,s=mg(r);return{c(){s.c(),e=Ge()},m(n,o){s.m(n,o),at(n,e,o),i=!0},p(n,o){o[0]&132&&qt(t,t=`${n[2]}-${n[7]}`)?(fe(),lt(s,1,1,Qt),pe(),s=mg(n),s.c(),K(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(K(s),i=!0)},o(n){lt(s),i=!1},d(n){n&&nt(e),s.d(n)}}}function p2(r){let t,e,i=Pe(r[9].filter(r[27])),s=[];for(let o=0;o<i.length;o+=1)s[o]=_g(pg(r,i,o));const n=o=>lt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Ge()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);at(o,t,a),e=!0},p(o,a){if(a[0]&193282|a[1]&16){i=Pe(o[9].filter(o[27]));let l;for(l=0;l<i.length;l+=1){const h=pg(o,i,l);s[l]?(s[l].p(h,a),K(s[l],1)):(s[l]=_g(h),s[l].c(),K(s[l],1),s[l].m(t.parentNode,t))}for(fe(),l=i.length;l<s.length;l+=1)n(l);pe()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)K(s[a]);e=!0}},o(o){s=s.filter(d2);for(let a=0;a<s.length;a+=1)lt(s[a]);e=!1},d(o){o&&nt(t),Wr(s,o)}}}function mg(r){let t,e;return t=new c2({props:{target:r[8],tool:r[10],drawingMode:r[4],transform:{elementToImage:r[12]},viewer:r[3],viewportScale:r[35],opts:r[5]}}),t.$on("create",r[16]),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s[0]&256&&(n.target=i[8]),s[0]&1024&&(n.tool=i[10]),s[0]&16&&(n.drawingMode=i[4]),s[0]&8&&(n.viewer=i[3]),s[1]&16&&(n.viewportScale=i[35]),s[0]&32&&(n.opts=i[5]),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function gg(r){let t=r[36].id,e,i,s=yg(r);return{c(){s.c(),e=Ge()},m(n,o){s.m(n,o),at(n,e,o),i=!0},p(n,o){o[0]&512&&qt(t,t=n[36].id)?(fe(),lt(s,1,1,Qt),pe(),s=yg(n),s.c(),K(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(K(s),i=!0)},o(n){lt(s),i=!1},d(n){n&&nt(e),s.d(n)}}}function yg(r){let t,e;return t=new W1({props:{target:r[8],editor:r[17](r[36].target.selector),annotation:r[36],style:r[1],transform:{elementToImage:r[12]},viewportScale:r[35]}}),t.$on("grab",r[13]),t.$on("change",function(){Jt(r[15](r[36]))&&r[15](r[36]).apply(this,arguments)}),t.$on("release",r[14]),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&256&&(n.target=r[8]),s[0]&512&&(n.editor=r[17](r[36].target.selector)),s[0]&512&&(n.annotation=r[36]),s[0]&2&&(n.style=r[1]),s[1]&16&&(n.viewportScale=r[35]),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function _g(r){let t,e,i=r[37]&&gg(r);return{c(){i&&i.c(),t=Ge()},m(s,n){i&&i.m(s,n),at(s,t,n),e=!0},p(s,n){s[37]?i?(i.p(s,n),n[0]&512&&K(i,1)):(i=gg(s),i.c(),K(i,1),i.m(t.parentNode,t)):i&&(fe(),lt(i,1,1,()=>{i=null}),pe())},i(s){e||(K(i),e=!0)},o(s){lt(i),e=!1},d(s){s&&nt(t),i&&i.d(s)}}}function m2(r){let t,e,i,s,n,o;const a=[p2,f2],l=[];function h(u,c){var d;return u[8]&&((d=u[9])==null?void 0:d.length)===1?0:u[8]&&u[10]&&u[0]?1:-1}return~(i=h(r))&&(s=l[i]=a[i](r)),{c(){t=st("svg"),e=st("g"),s&&s.c(),T(e,"transform",n=r[34]),T(e,"class","svelte-1ye6tpl"),T(t,"tabindex",0),T(t,"class","a9s-annotationlayer a9s-osd-drawinglayer svelte-1ye6tpl"),jr(t,"drawing",r[0]),jr(t,"editing",r[9]),jr(t,"hover",r[6])},m(u,c){at(u,t,c),Ct(t,e),~i&&l[i].m(e,null),r[28](e),o=!0},p(u,c){let d=i;i=h(u),i===d?~i&&l[i].p(u,c):(s&&(fe(),lt(l[d],1,1,()=>{l[d]=null}),pe()),~i?(s=l[i],s?s.p(u,c):(s=l[i]=a[i](u),s.c()),K(s,1),s.m(e,null)):s=null),(!o||c[1]&8&&n!==(n=u[34]))&&T(e,"transform",n),(!o||c[0]&1)&&jr(t,"drawing",u[0]),(!o||c[0]&512)&&jr(t,"editing",u[9]),(!o||c[0]&64)&&jr(t,"hover",u[6])},i(u){o||(K(s),o=!0)},o(u){lt(s),o=!1},d(u){u&&nt(t),~i&&l[i].d(),r[28](null)}}}function g2(r){let t,e;return t=new eu({props:{viewer:r[3],$$slots:{default:[m2,({transform:i,scale:s})=>({34:i,35:s}),({transform:i,scale:s})=>[0,(i?8:0)|(s?16:0)]]},$$scope:{ctx:r}}}),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s[0]&8&&(n.viewer=i[3]),s[0]&2047|s[1]&536&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function y2(r,t,e){let i,s,n,o,{drawingEnabled:a}=t,{filter:l}=t,{multiSelect:h}=t,{preferredDrawingMode:u}=t,{state:c}=t,{style:d=void 0}=t,{toolName:f=Rn()[0]}=t,{user:p}=t,{viewer:m}=t,_=!1,y=0;const v=()=>e(7,y+=1),g=()=>f,x=()=>a;let E;const{store:R,selection:S,hover:M}=c;Nn(r,S,O=>e(26,o=O));let P,F,U;const I=O=>{R.unobserve(P);const k=O.filter(({editable:X})=>X).map(({id:X})=>X);k.length>0?(e(9,F=k.map(X=>R.getAnnotation(X))),P=X=>{const{updated:Y}=X.changes;e(9,F=(Y||[]).map(q=>q.newValue))},R.observe(P,{annotations:k}),m.forceRedraw()):e(9,F=void 0)},A=(O,k)=>{const{x:X,y:Y}=m.viewport.viewerElementToImageCoordinates(new ve.Point(O,k));return[X,Y]},w=O=>{m.setMouseNavEnabled(!1),U=O.timeStamp},C=O=>{if(m.setMouseNavEnabled(!0),performance.now()-(U||0)<300){const{offsetX:X,offsetY:Y}=O.detail,[q,pt]=A(X,Y),_t=R.getAt(q,pt);if(_t&&(!l||l(_t))&&!F.find(bt=>bt.id===_t.id)){M.set(_t.id);const bt=dg(_t.id,O.detail,S,h);S.userSelect(bt)}}},D=O=>k=>{var pt;const{target:X}=O,Y=10*60*1e3,q=((pt=X.creator)==null?void 0:pt.id)!==p.id||!X.created||new Date().getTime()-X.created.getTime()>Y;R.updateTarget({...X,selector:k.detail,created:q?X.created:new Date,updated:q?new Date:void 0,updatedBy:q?p:void 0})},N=O=>{const k=p1(),X={id:k,bodies:[],target:{annotation:k,selector:O.detail,creator:p,created:new Date}};R.addAnnotation(X),S.setSelected(X.id),m.setMouseNavEnabled(!0)},B=O=>dc(O);vi(()=>{const O=k=>{if(o.selected.length===0)return;const{offsetX:X,offsetY:Y}=k,q=m.viewport.pointFromPixel(new ve.Point(X,Y)),{x:pt,y:_t}=m.viewport.viewportToImageCoordinates(q.x,q.y);e(6,_=!!R.getAt(pt,_t,l))};return m.element.addEventListener("pointermove",O),()=>{var k;(k=m.element)==null||k.removeEventListener("pointermove",O)}});const V=O=>ze(O);function L(O){Dn[O?"unshift":"push"](()=>{E=O,e(8,E)})}return r.$$set=O=>{"drawingEnabled"in O&&e(0,a=O.drawingEnabled),"filter"in O&&e(18,l=O.filter),"multiSelect"in O&&e(19,h=O.multiSelect),"preferredDrawingMode"in O&&e(20,u=O.preferredDrawingMode),"state"in O&&e(21,c=O.state),"style"in O&&e(1,d=O.style),"toolName"in O&&e(2,f=O.toolName),"user"in O&&e(22,p=O.user),"viewer"in O&&e(3,m=O.viewer)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(10,{tool:i,opts:s}=Mn(f)||{tool:void 0,opts:void 0},i,(e(5,s),e(2,f))),r.$$.dirty[0]&1048608&&e(4,n=(s==null?void 0:s.drawingMode)||u),r.$$.dirty[0]&25&&(a&&n==="drag"?m.setMouseNavEnabled(!1):m.setMouseNavEnabled(!0)),r.$$.dirty[0]&1&&a&&S.clear(),r.$$.dirty[0]&67108889&&o.selected.length===0&&n==="drag"&&a&&m.setMouseNavEnabled(!1),r.$$.dirty[0]&67108864&&I(o.selected)},[a,d,f,m,n,s,_,y,E,F,i,S,A,w,C,D,N,B,l,h,u,c,p,v,g,x,o,V,L]}class _2 extends se{constructor(t){super(),ie(this,t,y2,g2,qt,{drawingEnabled:0,filter:18,multiSelect:19,preferredDrawingMode:20,state:21,style:1,toolName:2,user:22,viewer:3,cancelDrawing:23,getDrawingTool:24,isDrawingEnabled:25},null,[-1,-1])}get cancelDrawing(){return this.$$.ctx[23]}get getDrawingTool(){return this.$$.ctx[24]}get isDrawingEnabled(){return this.$$.ctx[25]}}function v2(r){let t,e,i,s,n,o,a,l=r[2].appearance.label+"",h,u,c,d;return{c(){t=st("g"),e=st("rect"),a=st("text"),h=Ua(l),T(e,"class","a9s-presence-label-bg svelte-1rehw2p"),T(e,"x",r[0]),T(e,"y",i=r[1]-18/r[3]),T(e,"height",s=18/r[3]),T(e,"fill",n=r[2].appearance.color),T(e,"stroke",o=r[2].appearance.color),T(a,"font-size",u=12/r[3]),T(a,"x",c=r[0]+Math.round(5/r[3])),T(a,"y",d=r[1]-5/r[3]),T(a,"class","svelte-1rehw2p"),T(t,"class","a9s-presence-label")},m(f,p){at(f,t,p),Ct(t,e),Ct(t,a),Ct(a,h),r[6](t)},p(f,[p]){p&1&&T(e,"x",f[0]),p&10&&i!==(i=f[1]-18/f[3])&&T(e,"y",i),p&8&&s!==(s=18/f[3])&&T(e,"height",s),p&4&&n!==(n=f[2].appearance.color)&&T(e,"fill",n),p&4&&o!==(o=f[2].appearance.color)&&T(e,"stroke",o),p&4&&l!==(l=f[2].appearance.label+"")&&Sv(h,l),p&8&&u!==(u=12/f[3])&&T(a,"font-size",u),p&9&&c!==(c=f[0]+Math.round(5/f[3]))&&T(a,"x",c),p&10&&d!==(d=f[1]-5/f[3])&&T(a,"y",d)},i:Qt,o:Qt,d(f){f&&nt(t),r[6](null)}}}function x2(r,t,e){let{x:i}=t,{y:s}=t,{user:n}=t,{scale:o}=t,{hAlign:a=null}=t,l;const h=c=>{const d=l.querySelector("text"),f=l.querySelector("rect"),p=d.getBBox().width+10/c;a==="CENTER"&&l.setAttribute("style",`transform: translateX(-${p/2}px)`),f.setAttribute("width",`${p}`)};function u(c){Dn[c?"unshift":"push"](()=>{l=c,e(4,l)})}return r.$$set=c=>{"x"in c&&e(0,i=c.x),"y"in c&&e(1,s=c.y),"user"in c&&e(2,n=c.user),"scale"in c&&e(3,o=c.scale),"hAlign"in c&&e(5,a=c.hAlign)},r.$$.update=()=>{r.$$.dirty&24&&l&&h(o)},[i,s,n,o,l,a,u]}class vg extends se{constructor(t){super(),ie(this,t,x2,v2,qt,{x:0,y:1,user:2,scale:3,hAlign:5})}}function b2(r){let t,e,i,s,n,o;return e=new vg({props:{scale:r[1],user:r[0],x:r[3][0],y:r[3][1],hAlign:"CENTER"}}),{c(){t=st("g"),Ht(e.$$.fragment),i=st("polygon"),T(i,"class","a9s-presence-shape a9s-presence-polygon svelte-fgq4n0"),T(i,"stroke",s=r[0].appearance.color),T(i,"fill","transparent"),T(i,"points",n=r[2].points.map(xg).join(" ")),T(t,"class","a9s-presence-overlay")},m(a,l){at(a,t,l),Ft(e,t,null),Ct(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))&&T(i,"stroke",s),(!o||l&4&&n!==(n=a[2].points.map(xg).join(" ")))&&T(i,"points",n)},i(a){o||(K(e.$$.fragment,a),o=!0)},o(a){lt(e.$$.fragment,a),o=!1},d(a){a&&nt(t),kt(e)}}}const xg=r=>r.join(",");function E2(r,t,e){let i,s,{annotation:n}=t,{user:o}=t,{scale:a}=t;const l=h=>{let[u,...c]=h.points;return c.forEach(([d,f])=>{f<u[1]&&(u=[d,f])}),u};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 w2 extends se{constructor(t){super(),ie(this,t,E2,b2,qt,{annotation:4,user:0,scale:1})}}function T2(r){let t,e,i,s,n,o,a,l,h;return e=new vg({props:{scale:r[1],user:r[0],x:r[2].x,y:r[2].y}}),{c(){t=st("g"),Ht(e.$$.fragment),i=st("rect"),T(i,"class","a9s-presence-shape a9s-presence-rectangle svelte-gze948"),T(i,"stroke",s=r[0].appearance.color),T(i,"fill","transparent"),T(i,"x",n=r[2].x),T(i,"y",o=r[2].y),T(i,"width",a=r[2].w),T(i,"height",l=r[2].h),T(t,"class","a9s-presence-overlay")},m(u,c){at(u,t,c),Ft(e,t,null),Ct(t,i),h=!0},p(u,[c]){const d={};c&2&&(d.scale=u[1]),c&1&&(d.user=u[0]),c&4&&(d.x=u[2].x),c&4&&(d.y=u[2].y),e.$set(d),(!h||c&1&&s!==(s=u[0].appearance.color))&&T(i,"stroke",s),(!h||c&4&&n!==(n=u[2].x))&&T(i,"x",n),(!h||c&4&&o!==(o=u[2].y))&&T(i,"y",o),(!h||c&4&&a!==(a=u[2].w))&&T(i,"width",a),(!h||c&4&&l!==(l=u[2].h))&&T(i,"height",l)},i(u){h||(K(e.$$.fragment,u),h=!0)},o(u){lt(e.$$.fragment,u),h=!1},d(u){u&&nt(t),kt(e)}}}function A2(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 S2 extends se{constructor(t){super(),ie(this,t,A2,T2,qt,{annotation:3,user:0,scale:1})}}const{Boolean:C2}=ka;function bg(r,t,e){const i=r.slice();return i[8]=t[e],i}function Eg(r){let t,e;return t=new eu({props:{viewer:r[0],$$slots:{default:[M2,({transform:i,scale:s})=>({6:i,7:s}),({transform:i,scale:s})=>(i?64:0)|(s?128:0)]},$$scope:{ctx:r}}}),{c(){Ht(t.$$.fragment)},m(i,s){Ft(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||(K(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function wg(r){let t,e,i=Pe(r[2]),s=[];for(let o=0;o<i.length;o+=1)s[o]=Tg(bg(r,i,o));const n=o=>lt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Ge()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);at(o,t,a),e=!0},p(o,a){if(a&132){i=Pe(o[2]);let l;for(l=0;l<i.length;l+=1){const h=bg(o,i,l);s[l]?(s[l].p(h,a),K(s[l],1)):(s[l]=Tg(h),s[l].c(),K(s[l],1),s[l].m(t.parentNode,t))}for(fe(),l=i.length;l<s.length;l+=1)n(l);pe()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)K(s[a]);e=!0}},o(o){s=s.filter(C2);for(let a=0;a<s.length;a+=1)lt(s[a]);e=!1},d(o){o&&nt(t),Wr(s,o)}}}function I2(r){let t,e;return t=new w2({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){Ht(t.$$.fragment)},m(i,s){Ft(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||(K(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function R2(r){let t,e;return t=new S2({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){Ht(t.$$.fragment)},m(i,s){Ft(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||(K(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function Tg(r){let t,e,i,s;const n=[R2,I2],o=[];function a(l,h){return l[8].annotation.target.selector.type===Tt.RECTANGLE?0:l[8].annotation.target.selector.type===Tt.POLYGON?1:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Ge()},m(l,h){~t&&o[t].m(l,h),at(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(fe(),lt(o[u],1,1,()=>{o[u]=null}),pe()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),K(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(K(e),s=!0)},o(l){lt(e),s=!1},d(l){l&&nt(i),~t&&o[t].d(l)}}}function M2(r){let t,e,i,s,n=r[2].length>0&&wg(r);return{c(){t=st("svg"),e=st("g"),n&&n.c(),T(e,"transform",i=r[6]),T(t,"class","a9s-osd-presencelayer svelte-1krwc4m")},m(o,a){at(o,t,a),Ct(t,e),n&&n.m(e,null),s=!0},p(o,a){o[2].length>0?n?(n.p(o,a),a&4&&K(n,1)):(n=wg(o),n.c(),K(n,1),n.m(e,null)):n&&(fe(),lt(n,1,1,()=>{n=null}),pe()),(!s||a&64&&i!==(i=o[6]))&&T(e,"transform",i)},i(o){s||(K(n),s=!0)},o(o){lt(n),s=!1},d(o){o&&nt(t),n&&n.d()}}}function P2(r){let t=!!r[1],e,i,s=t&&Eg(r);return{c(){s&&s.c(),e=Ge()},m(n,o){s&&s.m(n,o),at(n,e,o),i=!0},p(n,[o]){o&2&&(t=!!n[1]),t?s?(s.p(n,o),o&2&&K(s,1)):(s=Eg(n),s.c(),K(s,1),s.m(e.parentNode,e)):s&&(fe(),lt(s,1,1,()=>{s=null}),pe())},i(n){i||(K(s),i=!0)},o(n){lt(s),i=!1},d(n){n&&nt(e),s&&s.d(n)}}}function O2(r,t,e){let{store:i}=t,{viewer:s}=t,{provider:n}=t,o=[],a;const l=(h,u)=>{e(2,o=[...o.filter(({selectedBy:c})=>c.presenceKey!==h.presenceKey),...(u||[]).map(c=>({annotation:i.getAnnotation(c),selectedBy:h}))].filter(({annotation:c})=>(c||console.warn("Selection event on unknown annotation"),!!c))),a&&i.unobserve(a),a=c=>{const{deleted:d,updated:f}=c.changes,p=new Set((d||[]).map(_=>_.id)),m=o.filter(({annotation:_})=>!p.has(_.id)).map(_=>{const y=(f||[]).find(v=>v.oldValue.id===_.annotation.id);return y?{selectedBy:_.selectedBy,annotation:y.newValue}:_});e(2,o=m)},i.observe(a,{annotations:o.map(c=>c.annotation.id)})};return Iv(()=>{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 N2 extends se{constructor(t){super(),ie(this,t,O2,P2,qt,{store:3,viewer:0,provider:1})}}function D2(r){let t,e,i,s,n;return{c(){t=st("rect"),T(t,"x",e=r[0].x),T(t,"y",i=r[0].y),T(t,"width",s=r[0].w),T(t,"height",n=r[0].h)},m(o,a){at(o,t,a)},p(o,[a]){a&1&&e!==(e=o[0].x)&&T(t,"x",e),a&1&&i!==(i=o[0].y)&&T(t,"y",i),a&1&&s!==(s=o[0].w)&&T(t,"width",s),a&1&&n!==(n=o[0].h)&&T(t,"height",n)},i:Qt,o:Qt,d(o){o&&nt(t)}}}function L2(r,t,e){let i,{annotation:s}=t;return r.$$set=n=>{"annotation"in n&&e(1,s=n.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=s.target.selector.geometry)},[i,s]}class B2 extends se{constructor(t){super(),ie(this,t,L2,D2,qt,{annotation:1})}}function F2(r){let t,e;return{c(){t=st("polygon"),T(t,"points",e=r[0].points.map(Ag).join(" "))},m(i,s){at(i,t,s)},p(i,[s]){s&1&&e!==(e=i[0].points.map(Ag).join(" "))&&T(t,"points",e)},i:Qt,o:Qt,d(i){i&&nt(t)}}}const Ag=r=>r.join(",");function k2(r,t,e){let i,{annotation:s}=t;return r.$$set=n=>{"annotation"in n&&e(1,s=n.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=s.target.selector.geometry)},[i,s]}class U2 extends se{constructor(t){super(),ie(this,t,k2,F2,qt,{annotation:1})}}function Sg(r,t,e){const i=r.slice();return i[2]=t[e],i}function Cg(r){let t,e;return{c(){t=st("path"),e=st("path"),T(t,"fill-rule","evenodd"),T(t,"d",Ze(r[2])),T(e,"class","a9s-inner"),T(e,"fill-rule","evenodd"),T(e,"d",Ze(r[2]))},m(i,s){at(i,t,s),at(i,e,s)},p:Qt,d(i){i&&(nt(t),nt(e))}}}function G2(r){let t,e=Pe(r[0]),i=[];for(let s=0;s<e.length;s+=1)i[s]=Cg(Sg(r,e,s));return{c(){t=st("g");for(let s=0;s<i.length;s+=1)i[s].c()},m(s,n){at(s,t,n);for(let o=0;o<i.length;o+=1)i[o]&&i[o].m(t,null)},p(s,[n]){if(n&1){e=Pe(s[0]);let o;for(o=0;o<e.length;o+=1){const a=Sg(s,e,o);i[o]?i[o].p(a,n):(i[o]=Cg(a),i[o].c(),i[o].m(t,null))}for(;o<i.length;o+=1)i[o].d(1);i.length=e.length}},i:Qt,o:Qt,d(s){s&&nt(t),Wr(i,s)}}}function H2(r,t,e){let{annotation:i}=t;const{polygons:s}=i.target.selector.geometry;return r.$$set=n=>{"annotation"in n&&e(1,i=n.annotation)},[s,i]}class $2 extends se{constructor(t){super(),ie(this,t,H2,G2,qt,{annotation:1})}}function X2(r){let t,e,i,s,n;return{c(){t=st("ellipse"),T(t,"cx",e=r[0].cx),T(t,"cy",i=r[0].cy),T(t,"rx",s=r[0].rx),T(t,"ry",n=r[0].ry)},m(o,a){at(o,t,a)},p(o,[a]){a&1&&e!==(e=o[0].cx)&&T(t,"cx",e),a&1&&i!==(i=o[0].cy)&&T(t,"cy",i),a&1&&s!==(s=o[0].rx)&&T(t,"rx",s),a&1&&n!==(n=o[0].ry)&&T(t,"ry",n)},i:Qt,o:Qt,d(o){o&&nt(t)}}}function V2(r,t,e){let i,{annotation:s}=t;return r.$$set=n=>{"annotation"in n&&e(1,s=n.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=s.target.selector.geometry)},[i,s]}class z2 extends se{constructor(t){super(),ie(this,t,V2,X2,qt,{annotation:1})}}const{Boolean:Y2}=ka;function Ig(r,t,e){const i=r.slice();return i[10]=t[e],i}function Rg(r){let t,e;return t=new eu({props:{viewer:r[0],$$slots:{default:[Z2,({transform:i})=>({9:i}),({transform:i})=>i?512:0]},$$scope:{ctx:r}}}),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s&1&&(n.viewer=i[0]),s&8710&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function W2(r){let t,e;return t=new z2({props:{annotation:r[10]}}),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s&2&&(n.annotation=i[10]),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function j2(r){let t,e;return t=new $2({props:{annotation:r[10]}}),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s&2&&(n.annotation=i[10]),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function q2(r){let t,e;return t=new U2({props:{annotation:r[10]}}),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s&2&&(n.annotation=i[10]),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function K2(r){let t,e;return t=new B2({props:{annotation:r[10]}}),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s&2&&(n.annotation=i[10]),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function Mg(r){let t,e,i,s;const n=[K2,q2,j2,W2],o=[];function a(l,h){return l[10].target.selector.type===Tt.RECTANGLE?0:l[10].target.selector.type===Tt.POLYGON?1:l[10].target.selector.type===Tt.MULTIPOLYGLON?2:l[10].target.selector.type===Tt.ELLIPSE?3:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Ge()},m(l,h){~t&&o[t].m(l,h),at(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(fe(),lt(o[u],1,1,()=>{o[u]=null}),pe()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),K(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(K(e),s=!0)},o(l){lt(e),s=!1},d(l){l&&nt(i),~t&&o[t].d(l)}}}function Z2(r){let t,e,i,s,n,o,a,l,h,u,c,d,f,p,m=Pe(r[1].filter(r[6])),_=[];for(let v=0;v<m.length;v+=1)_[v]=Mg(Ig(r,m,v));const y=v=>lt(_[v],1,1,()=>{_[v]=null});return{c(){var v,g,x,E;t=st("svg"),e=st("g"),i=st("rect"),l=st("rect");for(let R=0;R<_.length;R+=1)_[R].c();T(i,"class","a9s-union-bg svelte-1p8m4b9"),T(i,"x",s=(v=r[2])==null?void 0:v.minX),T(i,"y",n=(g=r[2])==null?void 0:g.minY),T(i,"width",o=r[2]?r[2].maxX-r[2].minX:0),T(i,"height",a=r[2]?r[2].maxY-r[2].minY:0),T(l,"class","a9s-union-fg svelte-1p8m4b9"),T(l,"x",h=(x=r[2])==null?void 0:x.minX),T(l,"y",u=(E=r[2])==null?void 0:E.minY),T(l,"width",c=r[2]?r[2].maxX-r[2].minX:0),T(l,"height",d=r[2]?r[2].maxY-r[2].minY:0),T(e,"transform",f=r[9]),T(t,"class","a9s-osd-selectionlayer svelte-1p8m4b9")},m(v,g){at(v,t,g),Ct(t,e),Ct(e,i),Ct(e,l);for(let x=0;x<_.length;x+=1)_[x]&&_[x].m(e,null);p=!0},p(v,g){var x,E,R,S;if((!p||g&4&&s!==(s=(x=v[2])==null?void 0:x.minX))&&T(i,"x",s),(!p||g&4&&n!==(n=(E=v[2])==null?void 0:E.minY))&&T(i,"y",n),(!p||g&4&&o!==(o=v[2]?v[2].maxX-v[2].minX:0))&&T(i,"width",o),(!p||g&4&&a!==(a=v[2]?v[2].maxY-v[2].minY:0))&&T(i,"height",a),(!p||g&4&&h!==(h=(R=v[2])==null?void 0:R.minX))&&T(l,"x",h),(!p||g&4&&u!==(u=(S=v[2])==null?void 0:S.minY))&&T(l,"y",u),(!p||g&4&&c!==(c=v[2]?v[2].maxX-v[2].minX:0))&&T(l,"width",c),(!p||g&4&&d!==(d=v[2]?v[2].maxY-v[2].minY:0))&&T(l,"height",d),g&2){m=Pe(v[1].filter(v[6]));let M;for(M=0;M<m.length;M+=1){const P=Ig(v,m,M);_[M]?(_[M].p(P,g),K(_[M],1)):(_[M]=Mg(P),_[M].c(),K(_[M],1),_[M].m(e,null))}for(fe(),M=m.length;M<_.length;M+=1)y(M);pe()}(!p||g&512&&f!==(f=v[9]))&&T(e,"transform",f)},i(v){if(!p){for(let g=0;g<m.length;g+=1)K(_[g]);p=!0}},o(v){_=_.filter(Y2);for(let g=0;g<_.length;g+=1)lt(_[g]);p=!1},d(v){v&&nt(t),Wr(_,v)}}}function Q2(r){let t=!!r[2],e,i,s=t&&Rg(r);return{c(){s&&s.c(),e=Ge()},m(n,o){s&&s.m(n,o),at(n,e,o),i=!0},p(n,[o]){o&4&&(t=!!n[2]),t?s?(s.p(n,o),o&4&&K(s,1)):(s=Rg(n),s.c(),K(s,1),s.m(e.parentNode,e)):s&&(fe(),lt(s,1,1,()=>{s=null}),pe())},i(n){i||(K(s),i=!0)},o(n){lt(s),i=!1},d(n){n&&nt(e),s&&s.d(n)}}}function J2(r,t,e){let i,s,n,{state:o}=t,{viewer:a}=t;const{store:l}=o,{selection:h}=o;Nn(r,h,d=>e(5,n=d));const u=d=>{let f=-1/0,p=-1/0,m=1/0,_=1/0;for(let y of d.filter(v=>ze(v))){const{bounds:v}=y.target.selector.geometry;v.maxX>f&&(f=v.maxX),v.maxY>p&&(p=v.maxY),v.minX<m&&(m=v.minX),v.minY<_&&(_=v.minY)}return a.forceRedraw(),{maxX:f,maxY:p,minX:m,minY:_}},c=d=>ze(d);return r.$$set=d=>{"state"in d&&e(4,o=d.state),"viewer"in d&&e(0,a=d.viewer)},r.$$.update=()=>{r.$$.dirty&32&&e(1,i=n.selected.map(({id:d})=>l.getAnnotation(d))),r.$$.dirty&2&&e(2,s=i.length>1?u(i):void 0)},[a,i,s,h,o,n,c]}class tI extends se{constructor(t){super(),ie(this,t,J2,Q2,qt,{state:4,viewer:0})}}const Pg=(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=Dc(a);r.element.setAttribute("data-theme",l)}})}):r.element.setAttribute("data-theme",t)},Og=(r,t,e)=>(i,s={})=>{const n=typeof i=="string"?i:i.id,o=t.getAnnotation(n);if(!o||!ze(o))return;const a=r.container.getBoundingClientRect(),{padding:l}=s;let[h,u,c,d]=l?Array.isArray(l)?l:[l,l,l,l]:[0,0,0,0];h=h/a.height,u=u/a.width,c=c/a.height,d=d/a.width;const{minX:f,minY:p,maxX:m,maxY:_}=o.target.selector.geometry.bounds,y=m-f,v=_-p,g=f-d*y,x=p-h*v,E=y+(u+d)*y,R=v+(h+c)*v,S=r.viewport.imageToViewportRectangle(g,x,E,R);r.viewport[e](S,s.immediately)},eI=(r,t)=>Og(r,t,"fitBounds"),rI=(r,t)=>Og(r,t,"fitBoundsWithConstraints"),iI=(r,t={})=>{const e=Bc(t,{drawingEnabled:!1,drawingMode:Cr?"drag":"click",userSelectAction:ea.EDIT,theme:"light"}),i=Nc(e),{hover:s,selection:n,store:o}=i,a=Zg(o,e.initialHistory),l=Qg(i,a,e.adapter,e.autoSave);let h=oy(),u=e.drawingEnabled,c=e.drawingMode,d=e.modalSelect;const f=kc(a,r.element),p=new o2({target:r.element,props:{state:i,viewer:r,style:e.style,filter:void 0}}),m=new N2({target:r.element.querySelector(".openseadragon-canvas"),props:{provider:void 0,store:o,viewer:r}}),_=new _2({target:r.element.querySelector(".openseadragon-canvas"),props:{drawingEnabled:!!u,filter:void 0,multiSelect:e.multiSelect,preferredDrawingMode:c,state:i,style:e.style,user:h,viewer:r}}),y=new tI({target:r.element.querySelector(".openseadragon-canvas"),props:{state:i,viewer:r}});p.$on("click",O=>{const{originalEvent:k,annotation:X}=O.detail,Y=q=>dg(q.id,k,n,e.multiSelect);d?n.isEmpty()&&X&&n.userSelect(Y(X),k):X&&!(c==="click"&&u)?n.userSelect(Y(X),k):n.isEmpty()||n.clear()}),r.element.addEventListener("pointerdown",O=>{if(s.current){const k=o.getAnnotation(s.current);l.emit("clickAnnotation",k,O)}}),Pg(r,e.theme);const v=ty(i,a,e.adapter),g=()=>_.cancelDrawing(),x=()=>{p.$destroy(),m.$destroy(),_.$destroy(),y.$destroy(),f.destroy(),a.destroy()},E=eI(r,o),R=rI(r,o),S=()=>_.getDrawingTool(),M=()=>h,P=()=>_.isDrawingEnabled(),F=(O,k,X)=>yc(O,k,X),U=(O,k)=>fc(O,k),I=O=>{if(!Mn(O))throw`No drawing tool named ${O}`;_.$set({toolName:O})},A=O=>{u=O,_.$set({drawingEnabled:O})},w=O=>{p.$set({filter:O}),_.$set({filter:O})},C=O=>d=O,D=O=>{p.$set({style:O}),_.$set({style:O})},N=O=>m.$set({provider:O}),B=O=>Pg(r,O),V=O=>{h=O,_.$set({user:O})},L=O=>p.$set({visible:O});return{...v,cancelDrawing:g,destroy:x,fitBounds:E,fitBoundsWithConstraints:R,getDrawingTool:S,getUser:M,isDrawingEnabled:P,listDrawingTools:Rn,on:l.on,off:l.off,registerDrawingTool:F,registerShapeEditor:U,setDrawingEnabled:A,setDrawingTool:I,setFilter:w,setModalSelect:C,setPresenceProvider:N,setStyle:D,setTheme:B,setUser:V,setVisible:L,state:i,viewer:r}};Zt.ShapeType=Tt,Zt.UserSelectAction=ea,Zt.W3CImageFormat=Y_,Zt.chainStyles=B_,Zt.computeStyle=L_,Zt.createBody=$g,Zt.createImageAnnotator=Ev,Zt.createOSDAnnotator=iI,Zt.defaultColorProvider=ly,Object.defineProperty(Zt,Symbol.toStringTag,{value:"Module"})});
1149
+ }`,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=jw(t)),typeof t=="number"?Yw(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,Ms.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}=tt.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}};ru.availableFonts={},ru.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 iu=ru;const Qo=class Ps extends vs{constructor(t="",e={}){super(ct.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=ct.from(i,{scaleMode:tt.SCALE_MODE,resourceOptions:{autoLoad:!1}});s.orig=new wt,s.trim=new wt,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"),u=document.createElementNS(o,"style");l.setAttribute("width","10000"),l.setAttribute("height","10000"),l.style.overflow="hidden",a.appendChild(l),this.maxWidth=Ps.defaultMaxWidth,this.maxHeight=Ps.defaultMaxHeight,this._domElement=h,this._styleElement=u,this._svgRoot=a,this._foreignObject=l,this._foreignObject.appendChild(u),this._foreignObject.appendChild(h),this._image=i,this._loadImage=new Image,this._autoResolution=Ps.defaultAutoResolution,this._resolution=Ps.defaultResolution??tt.RESOLUTION,this.text=t,this.style=e}measureText(t){var u,c;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:(u=this._style)==null?void 0:u.toCSS(s)}),this._styleElement.textContent=(c=this._style)==null?void 0:c.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({},Ps.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=ri(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=ri(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 iu?(this.ownsStyle=!1,this._style=t):t instanceof hi?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=iu.from(t)):(this.ownsStyle=!0,this._style=new iu(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(/&nbsp;/gi,"&#160;")}};Qo.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},Qo.defaultMaxWidth=2024,Qo.defaultMaxHeight=2024,Qo.defaultAutoResolution=!0;const n2=16777215,o2=.25,a2=16777215,l2=1,h2=1.5;let di=!1,Cs;const su=r=>{const t={tint:r!=null&&r.fill?new Nt(r.fill).toNumber():n2,alpha:(r==null?void 0:r.fillOpacity)!==void 0?Math.min(r.fillOpacity,1):String(r==null?void 0:r.fill).toLowerCase().startsWith("rgba(")?new Nt(r==null?void 0:r.fill).alpha:o2},e={tint:r!=null&&r.stroke?new Nt(r.stroke).toNumber():a2,alpha:(r==null?void 0:r.strokeOpacity)!==void 0?Math.min(r.strokeOpacity,1):String(r==null?void 0:r.stroke).toLowerCase().startsWith("rgba(")?new Nt(r==null?void 0:r.stroke).alpha:l2,lineWidth:(r==null?void 0:r.strokeWidth)===void 0?h2:r.strokeWidth};return{fillStyle:t,strokeStyle:e}},yn=r=>(t,e,i)=>{const{fillStyle:s,strokeStyle:n}=su(i),o=new gn;o.beginFill(16777215),r(e,o),o.endFill(),o.tint=s.tint,o.alpha=s.alpha,t.addChild(o);const a=new gn,l=n.lineWidth===1?1:n.lineWidth/Cs;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}},u2=yn((r,t)=>{const{x:e,y:i,w:s,h:n}=r.geometry;t.drawRect(e,i,s,n)}),c2=yn((r,t)=>{const{cx:e,cy:i,rx:s,ry:n}=r.geometry;t.drawEllipse(e,i,s,n)}),d2=yn((r,t)=>{const[[e,i],[s,n]]=r.geometry.points;t.moveTo(e,i),t.lineTo(s,n),t.closePath()}),f2=yn((r,t)=>{const e=r.geometry.points.reduce((i,s)=>[...i,...s],[]);t.drawPolygon(e)}),p2=yn((r,t)=>{const e=i=>i.points.reduce((s,n)=>[...s,...n],[]);r.geometry.polygons.forEach(i=>{const[s,...n]=i.rings;t.drawPolygon(e(s)),n.forEach(o=>{t.beginHole(),t.drawPolygon(e(o)),t.endHole()})})}),gg=r=>{const t=r.viewport.getContainerSize().x;return r.viewport.getZoom(!0)*t/r.world.getContentFactor()},yg=(r,t,e,i)=>()=>{const s=r.viewport.viewportToImageRectangle(r.viewport.getBounds(!0)),n=gg(r);(n!==Cs||!di)&&(di=!0,e.forEach(({stroke:d,strokeWidth:f})=>{const{lineStyle:p}=d.geometry.graphicsData[0];f>1?(di=n===Cs,p.width=f/n,p.native=!1,d.geometry.invalidate()):f===1&&!p.native&&(p.width=1,p.native=!0,d.geometry.invalidate())})),Cs=n;const o=r.viewport.getFlip();let a=Math.PI*r.viewport.getRotation(!0)/180;a<0&&(a+=2*Math.PI),a>2*Math.PI&&(a-=2*Math.PI);const l=o?r.viewport._containerInnerSize.x+s.x*n:-s.x*n,h=-s.y*n;let u,c;a>0&&a<=Math.PI/2?(u=s.height*n,c=0):a>Math.PI/2&&a<=Math.PI?(u=s.width*n,c=s.height*n):a>Math.PI&&a<=Math.PI*1.5?(u=0,c=s.width*n):(u=0,c=0),t.position.x=u+l*Math.cos(a)-h*Math.sin(a),t.position.y=c+l*Math.sin(a)+h*Math.cos(a),t.scale.set(o?-n:n,n),t.rotation=a,i.render(t)},m2=(r,t)=>{const e=new gn,i=fm({width:t.width,height:t.height,backgroundAlpha:0,view:t,antialias:!0,resolution:2}),s=new Map;let n=new Set,o,a;Cs=gg(r);const l=(g,x)=>{di=!1;const T=s.get(g.id);T&&(T.fill.destroy(),T.stroke.destroy());const{selector:M}=g.target,S=typeof a=="function"?a(g,x):a;let R;M.type===xt.RECTANGLE?R=u2(e,M,S):M.type===xt.POLYGON?R=f2(e,M,S):M.type===xt.ELLIPSE?R=c2(e,M,S):M.type===xt.MULTIPOLYGON?R=p2(e,M,S):M.type===xt.LINE?R=d2(e,M,S):console.warn(`Unsupported shape type: ${M.type}`),R&&s.set(g.id,{annotation:g,...R})},h=g=>{const x=s.get(g.id);x&&(s.delete(g.id),x.fill.destroy(),x.stroke.destroy())},u=(g,x,T)=>{di=!1;const M=s.get(g.id);if(M&&(s.delete(g.id),M.fill.destroy(),M.stroke.destroy(),l(x,T),n.has(x.id))){const{fill:S,stroke:R}=s.get(x.id);e.removeChild(S),e.removeChild(R)}},c=(g,x)=>{const T=s.get(g);T&&(s.delete(g),T.fill.destroy(),T.stroke.destroy(),l(T.annotation,x))},d=(g,x)=>{i.resize(g,x),i.render(e)},f=g=>{di=!1;const{children:x}=e;s.forEach(({fill:T,stroke:M,annotation:S})=>{const R=g?n.has(S.id)||g(S):!0;R&&!x.includes(T)?(e.addChild(T),e.addChild(M)):!R&&x.includes(T)&&(e.removeChild(T),e.removeChild(M))}),i.render(e)},p=g=>{const x=new Set(g.selected.map(S=>S.id)),T=g.selected.filter(({id:S})=>!n.has(S)),M=[...n].filter(S=>!x.has(S));T.forEach(({id:S,editable:R})=>{if(R){const P=s.get(S);P&&(e.removeChild(P.fill),e.removeChild(P.stroke))}else c(S,{selected:!0,hovered:S===o})}),M.forEach(S=>c(S,{hovered:S===o})),n=x,i.render(e)},m=g=>{o!==g&&(o&&!n.has(o)&&c(o,{selected:n.has(o)}),g&&c(g,{selected:n.has(g),hovered:!0}),o=g,i.render(e))},_=g=>{if(typeof g=="function")s.forEach(({annotation:x,fill:T,stroke:M,strokeWidth:S},R)=>{S>1&&(di=!1);const P={selected:n.has(x.id),hovered:o===x.id},{fillStyle:F,strokeStyle:U}=su(g(x,P));T.tint=F.tint,T.alpha=F.alpha,M.tint=U.tint||16777215,M.alpha=U.alpha,s.set(x.id,{annotation:x,fill:T,stroke:M,strokeWidth:U.lineWidth})});else{const{fillStyle:x,strokeStyle:T}=su(g);T.lineWidth>1&&(di=!1),s.forEach(({annotation:M,fill:S,stroke:R,strokeWidth:P},F)=>{S.tint=x.tint,S.alpha=x.alpha,R.tint=T.tint||16777215,R.alpha=T.alpha,s.set(M.id,{annotation:M,fill:S,stroke:R,strokeWidth:T.lineWidth})})}a=g,i.render(e),yg(r,e,s,i)()},y=g=>{g?t.classList.remove("hidden"):t.classList.add("hidden")};return{addAnnotation:l,destroy:()=>i.destroy(),getScale:()=>Cs,redraw:yg(r,e,s,i),removeAnnotation:h,resize:d,setFilter:f,setHovered:m,setSelected:p,setStyle:_,setVisible:y,updateAnnotation:u}};function g2(r,t,e){let i,s,{filter:n}=t,{state:o}=t,{style:a}=t,{viewer:l}=t,{visible:h=!0}=t;const{store:u,hover:c,selection:d,viewport:f}=o;Fn(r,c,S=>e(11,i=S)),Fn(r,d,S=>e(8,s=S));const p=Zi();let m,_;const y=S=>{const R=new xe.Point(S.x,S.y),{x:P,y:F}=l.viewport.pointFromPixel(R);return l.viewport.viewportToImageCoordinates(P,F)},v=()=>2/m.getScale(),g=S=>{const{x:R,y:P}=S.position;_={x:R,y:P}},x=S=>R=>{const{x:P,y:F}=y(new xe.Point(R.offsetX,R.offsetY)),U=v(),I=u.getAt(P,F,n,U);I?(S.classList.add("hover"),i!==I.id&&(c.set(I.id),m.setHovered(I.id))):(S.classList.remove("hover"),i&&(c.set(void 0),m.setHovered(void 0)))},T=S=>{if(!_)return;const R=S.originalEvent,{x:P,y:F}=S.position,U=P-_.x,I=F-_.y;if(Math.sqrt(U*U+I*I)<5){const{x:w,y:C}=y(S.position),L=v(),O=u.getAt(w,C,n,L);O?p("click",{originalEvent:R,annotation:O}):p("click",{originalEvent:R})}_=void 0};let M;return vi(()=>{var O;const{offsetWidth:S,offsetHeight:R}=l.canvas,P=document.createElement("canvas");P.width=S,P.height=R,P.className="a9s-gl-canvas",(O=l.element.querySelector(".openseadragon-canvas"))==null||O.appendChild(P),e(7,m=m2(l,P));const F=x(P);P.addEventListener("pointermove",F);const U=new ResizeObserver(B=>{try{const{width:V,height:D}=B[0].contentRect;P.width=V,P.height=D,m.resize(V,D)}catch{console.warn("WebGL canvas already disposed")}});U.observe(P);const I=()=>{const B=l.viewport.getBounds();M=l.viewport.viewportToImageRectangle(B);const{x:V,y:D,width:N,height:H}=M,k=u.getIntersecting(V,D,N,H);f.set(k.map(z=>z.id))};l.addHandler("canvas-press",g),l.addHandler("canvas-release",T),l.addHandler("update-viewport",m.redraw),l.addHandler("animation-finish",I);const A=B=>B.filter(V=>ze(V)),w=B=>ze(B.oldValue)&&ze(B.newValue),C=B=>{const{selector:V}=B.target;if(V.type===xt.POLYGON){const D=s1(V);return{...B,target:{...B.target,selector:{...D}}}}else if(V.type===xt.MULTIPOLYGON){const D=r1(V);return{...B,target:{...B.target,selector:{...D}}}}else return B},L=B=>{const{created:V,updated:D,deleted:N}=B.changes,H=(V||[]).filter(k=>ze(k)).map(C);if(A(N||[]).forEach(k=>m.removeAnnotation(k)),H.forEach(k=>m.addAnnotation(k)),(D||[]).filter(k=>w(k)).map(({oldValue:k,newValue:z})=>({oldValue:k,newValue:C(z)})).forEach(({oldValue:k,newValue:z})=>m.updateAnnotation(k,z)),M){const{x:k,y:z,width:Y,height:pt}=M,_t=u.getIntersecting(k,z,Y,pt);f.set(_t.map(W=>W.id))}else f.set(u.all().map(k=>k.id));m.redraw()};return u.observe(L),()=>{var B;P.removeEventListener("pointermove",F),U.disconnect(),l.removeHandler("canvas-press",g),l.removeHandler("canvas-release",T),l.removeHandler("update-viewport",m.redraw),l.removeHandler("animation-finish",I),u.unobserve(L),m.destroy(),(B=P.parentNode)==null||B.removeChild(P)}}),r.$$set=S=>{"filter"in S&&e(2,n=S.filter),"state"in S&&e(3,o=S.state),"style"in S&&e(4,a=S.style),"viewer"in S&&e(5,l=S.viewer),"visible"in S&&e(6,h=S.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))},[c,d,n,o,a,l,h,m,s]}class y2 extends ie{constructor(t){super(),re(this,t,g2,null,Yt,{filter:2,state:3,style:4,viewer:5,visible:6})}}const _g=(r,t,e,i)=>{if(!i)return r;if(t.shiftKey||t.ctrlKey||t.metaKey){const n=(e.selected||[]).map(o=>o.id);return n.includes(r)?n.filter(o=>o!==r):[...n,r]}else return r},_2=r=>({transform:r&2,scale:r&1}),vg=r=>({transform:r[1],scale:r[0]});function v2(r){let t;const e=r[4].default,i=Vc(e,r,r[3],vg);return{c(){i&&i.c()},m(s,n){i&&i.m(s,n),t=!0},p(s,[n]){i&&i.p&&(!t||n&11)&&jc(i,e,s,s[3],t?Yc(e,s[3],n,_2):Wc(s[3]),vg)},i(s){t||(Z(i,s),t=!0)},o(s){ht(i,s),t=!1},d(s){i&&i.d(s)}}}function x2(r,t,e){let{$$slots:i={},$$scope:s}=t,{viewer:n}=t,o=1,a;const l=()=>{const h=n.viewport.getContainerSize().x,u=n.viewport.getZoom(!0),c=n.viewport.getFlip(),d=n.viewport.pixelFromPoint(new xe.Point(0,0),!0);c&&(d.x=h-d.x);const f=u*h/n.world.getContentFactor(),p=c?-f:f,m=n.viewport.getRotation(!0);e(1,a=`translate(${d.x}, ${d.y}) scale(${p}, ${f}) rotate(${m})`),e(0,o=u*h/n.world.getContentFactor())};return vi(()=>(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 nu extends ie{constructor(t){super(),re(this,t,x2,v2,Yt,{viewer:2})}}function b2(r,t,e){const i=Zi();let{drawingMode:s}=t,{opts:n}=t,{target:o}=t,{tool:a}=t,{transform:l}=t,{viewer:h}=t,{viewportScale:u}=t,c;return vi(()=>{const d=o.closest("svg"),f=[],p=(m,_,y)=>{if(d==null||d.addEventListener(m,_,y),f.push(()=>d==null?void 0:d.removeEventListener(m,_,y)),m==="pointerup"||m==="dblclick"){const v=x=>{const{originalEvent:T}=x;_(T)},g=m==="pointerup"?"canvas-click":"canvas-double-click";h.addHandler(g,v),f.push(()=>h.removeHandler(g,v))}else if(m==="pointermove"){const v=g=>{const{originalEvent:x}=g;_(x)};h.addHandler("canvas-drag",v),f.push(()=>h.removeHandler("canvas-drag",v))}};return e(7,c=new a({target:o,props:{addEventListener:p,drawingMode:s,opts:n,transform:l,viewportScale:u,svgEl:d}})),c.$on("create",m=>i("create",m.detail)),()=>{f.forEach(m=>m()),c.$destroy()}}),r.$$set=d=>{"drawingMode"in d&&e(0,s=d.drawingMode),"opts"in d&&e(1,n=d.opts),"target"in d&&e(2,o=d.target),"tool"in d&&e(3,a=d.tool),"transform"in d&&e(4,l=d.transform),"viewer"in d&&e(5,h=d.viewer),"viewportScale"in d&&e(6,u=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&144&&c&&c.$set({transform:l}),r.$$.dirty&192&&c&&c.$set({viewportScale:u})},[s,n,o,a,l,h,u,c]}class E2 extends ie{constructor(t){super(),re(this,t,b2,null,Yt,{drawingMode:0,opts:1,target:2,tool:3,transform:4,viewer:5,viewportScale:6})}}const{Boolean:w2}=Ua;function xg(r,t,e){const i=r.slice();i[38]=t[e];const s=i[17](i[38].target.selector);return i[39]=s,i}function T2(r){let t=`${r[2]}-${r[7]}`,e,i,s=bg(r);return{c(){s.c(),e=Ge()},m(n,o){s.m(n,o),lt(n,e,o),i=!0},p(n,o){o[0]&132&&Yt(t,t=`${n[2]}-${n[7]}`)?(pe(),ht(s,1,1,zt),me(),s=bg(n),s.c(),Z(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(Z(s),i=!0)},o(n){ht(s),i=!1},d(n){n&&ot(e),s.d(n)}}}function A2(r){let t,e,i=Ne(r[9].filter(r[27])),s=[];for(let o=0;o<i.length;o+=1)s[o]=Tg(xg(r,i,o));const n=o=>ht(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Ge()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);lt(o,t,a),e=!0},p(o,a){if(a[0]&193282|a[1]&64){i=Ne(o[9].filter(o[27]));let l;for(l=0;l<i.length;l+=1){const h=xg(o,i,l);s[l]?(s[l].p(h,a),Z(s[l],1)):(s[l]=Tg(h),s[l].c(),Z(s[l],1),s[l].m(t.parentNode,t))}for(pe(),l=i.length;l<s.length;l+=1)n(l);me()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)Z(s[a]);e=!0}},o(o){s=s.filter(w2);for(let a=0;a<s.length;a+=1)ht(s[a]);e=!1},d(o){o&&ot(t),Wr(s,o)}}}function bg(r){let t,e;return t=new E2({props:{target:r[8],tool:r[10],drawingMode:r[4],transform:{elementToImage:r[12]},viewer:r[3],viewportScale:r[37],opts:r[5]}}),t.$on("create",r[16]),{c(){Ut(t.$$.fragment)},m(i,s){Bt(t,i,s),e=!0},p(i,s){const n={};s[0]&256&&(n.target=i[8]),s[0]&1024&&(n.tool=i[10]),s[0]&16&&(n.drawingMode=i[4]),s[0]&8&&(n.viewer=i[3]),s[1]&64&&(n.viewportScale=i[37]),s[0]&32&&(n.opts=i[5]),t.$set(n)},i(i){e||(Z(t.$$.fragment,i),e=!0)},o(i){ht(t.$$.fragment,i),e=!1},d(i){Ft(t,i)}}}function Eg(r){let t=r[38].id,e,i,s=wg(r);return{c(){s.c(),e=Ge()},m(n,o){s.m(n,o),lt(n,e,o),i=!0},p(n,o){o[0]&512&&Yt(t,t=n[38].id)?(pe(),ht(s,1,1,zt),me(),s=wg(n),s.c(),Z(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(Z(s),i=!0)},o(n){ht(s),i=!1},d(n){n&&ot(e),s.d(n)}}}function wg(r){let t,e;return t=new ux({props:{target:r[8],editor:r[17](r[38].target.selector),annotation:r[38],style:r[1],transform:{elementToImage:r[12]},viewportScale:r[37]}}),t.$on("grab",r[13]),t.$on("change",function(){ee(r[15](r[38]))&&r[15](r[38]).apply(this,arguments)}),t.$on("release",r[14]),{c(){Ut(t.$$.fragment)},m(i,s){Bt(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&256&&(n.target=r[8]),s[0]&512&&(n.editor=r[17](r[38].target.selector)),s[0]&512&&(n.annotation=r[38]),s[0]&2&&(n.style=r[1]),s[1]&64&&(n.viewportScale=r[37]),t.$set(n)},i(i){e||(Z(t.$$.fragment,i),e=!0)},o(i){ht(t.$$.fragment,i),e=!1},d(i){Ft(t,i)}}}function Tg(r){let t,e,i=r[39]&&Eg(r);return{c(){i&&i.c(),t=Ge()},m(s,n){i&&i.m(s,n),lt(s,t,n),e=!0},p(s,n){s[39]?i?(i.p(s,n),n[0]&512&&Z(i,1)):(i=Eg(s),i.c(),Z(i,1),i.m(t.parentNode,t)):i&&(pe(),ht(i,1,1,()=>{i=null}),me())},i(s){e||(Z(i),e=!0)},o(s){ht(i),e=!1},d(s){s&&ot(t),i&&i.d(s)}}}function S2(r){let t,e,i,s,n,o;const a=[A2,T2],l=[];function h(u,c){var d;return u[8]&&((d=u[9])==null?void 0:d.length)===1?0:u[8]&&u[10]&&u[0]?1:-1}return~(i=h(r))&&(s=l[i]=a[i](r)),{c(){t=st("svg"),e=st("g"),s&&s.c(),E(e,"transform",n=r[36]),E(e,"class","svelte-g4ws1v"),E(t,"tabindex",0),E(t,"class","a9s-annotationlayer a9s-osd-drawinglayer svelte-g4ws1v"),qr(t,"drawing",r[0]),qr(t,"editing",r[9]),qr(t,"hover",r[6])},m(u,c){lt(u,t,c),Ct(t,e),~i&&l[i].m(e,null),r[28](e),o=!0},p(u,c){let d=i;i=h(u),i===d?~i&&l[i].p(u,c):(s&&(pe(),ht(l[d],1,1,()=>{l[d]=null}),me()),~i?(s=l[i],s?s.p(u,c):(s=l[i]=a[i](u),s.c()),Z(s,1),s.m(e,null)):s=null),(!o||c[1]&32&&n!==(n=u[36]))&&E(e,"transform",n),(!o||c[0]&1)&&qr(t,"drawing",u[0]),(!o||c[0]&512)&&qr(t,"editing",u[9]),(!o||c[0]&64)&&qr(t,"hover",u[6])},i(u){o||(Z(s),o=!0)},o(u){ht(s),o=!1},d(u){u&&ot(t),~i&&l[i].d(),r[28](null)}}}function C2(r){let t,e;return t=new nu({props:{viewer:r[3],$$slots:{default:[S2,({transform:i,scale:s})=>({36:i,37:s}),({transform:i,scale:s})=>[0,(i?32:0)|(s?64:0)]]},$$scope:{ctx:r}}}),{c(){Ut(t.$$.fragment)},m(i,s){Bt(t,i,s),e=!0},p(i,s){const n={};s[0]&8&&(n.viewer=i[3]),s[0]&2047|s[1]&2144&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(Z(t.$$.fragment,i),e=!0)},o(i){ht(t.$$.fragment,i),e=!1},d(i){Ft(t,i)}}}function I2(r,t,e){let i,s,n,o,{drawingEnabled:a}=t,{filter:l}=t,{multiSelect:h}=t,{preferredDrawingMode:u}=t,{state:c}=t,{style:d=void 0}=t,{toolName:f=Nn()[0]}=t,{user:p}=t,{viewer:m}=t,_=!1,y=0;const v=()=>e(7,y+=1),g=()=>f,x=()=>a;let T;const{store:M,selection:S,hover:R}=c;Fn(r,S,k=>e(26,o=k));let P,F,U;const I=k=>{M.unobserve(P);const z=k.filter(({editable:Y})=>Y).map(({id:Y})=>Y);z.length>0?(e(9,F=z.map(Y=>M.getAnnotation(Y))),P=Y=>{const{updated:pt}=Y.changes;e(9,F=(pt||[]).map(_t=>_t.newValue))},M.observe(P,{annotations:z}),m.forceRedraw()):e(9,F=void 0)},A=(k,z)=>{const{x:Y,y:pt}=m.viewport.viewerElementToImageCoordinates(new xe.Point(k,z));return[Y,pt]},w=()=>{const k=m.viewport.getContainerSize().x;return m.viewport.getZoom(!0)*k/m.world.getContentFactor()},C=()=>2/w(),L=k=>{m.setMouseNavEnabled(!1),U=k.timeStamp},O=k=>{if(m.setMouseNavEnabled(!0),performance.now()-(U||0)<300){const{offsetX:Y,offsetY:pt}=k.detail,[_t,W]=A(Y,pt),Et=C(),nt=M.getAt(_t,W,void 0,Et);if(nt&&(!l||l(nt))&&!F.find(vt=>vt.id===nt.id)){R.set(nt.id);const vt=_g(nt.id,k.detail,S,h);S.userSelect(vt)}}},B=k=>z=>{var W;const{target:Y}=k,pt=10*60*1e3,_t=((W=Y.creator)==null?void 0:W.id)!==p.id||!Y.created||new Date().getTime()-Y.created.getTime()>pt;M.updateTarget({...Y,selector:z.detail,created:_t?Y.created:new Date,updated:_t?new Date:void 0,updatedBy:_t?p:void 0})},V=k=>{const z=P1(),Y={id:z,bodies:[],target:{annotation:z,selector:k.detail,creator:p,created:new Date}};M.addAnnotation(Y),S.setSelected(Y.id),m.setMouseNavEnabled(!0)},D=k=>mc(k);vi(()=>{const k=z=>{if(o.selected.length===0)return;const{offsetX:Y,offsetY:pt}=z,_t=m.viewport.pointFromPixel(new xe.Point(Y,pt)),{x:W,y:Et}=m.viewport.viewportToImageCoordinates(_t.x,_t.y),nt=C();e(6,_=!!M.getAt(W,Et,l,nt))};return m.element.addEventListener("pointermove",k),()=>{var z;(z=m.element)==null||z.removeEventListener("pointermove",k)}});const N=k=>ze(k);function H(k){kn[k?"unshift":"push"](()=>{T=k,e(8,T)})}return r.$$set=k=>{"drawingEnabled"in k&&e(0,a=k.drawingEnabled),"filter"in k&&e(18,l=k.filter),"multiSelect"in k&&e(19,h=k.multiSelect),"preferredDrawingMode"in k&&e(20,u=k.preferredDrawingMode),"state"in k&&e(21,c=k.state),"style"in k&&e(1,d=k.style),"toolName"in k&&e(2,f=k.toolName),"user"in k&&e(22,p=k.user),"viewer"in k&&e(3,m=k.viewer)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(10,{tool:i,opts:s}=Dn(f)||{tool:void 0,opts:void 0},i,(e(5,s),e(2,f))),r.$$.dirty[0]&1048608&&e(4,n=(s==null?void 0:s.drawingMode)||u),r.$$.dirty[0]&25&&(a&&n==="drag"?m.setMouseNavEnabled(!1):m.setMouseNavEnabled(!0)),r.$$.dirty[0]&1&&a&&S.clear(),r.$$.dirty[0]&67108889&&o.selected.length===0&&n==="drag"&&a&&m.setMouseNavEnabled(!1),r.$$.dirty[0]&67108864&&I(o.selected)},[a,d,f,m,n,s,_,y,T,F,i,S,A,L,O,B,V,D,l,h,u,c,p,v,g,x,o,N,H]}class R2 extends ie{constructor(t){super(),re(this,t,I2,C2,Yt,{drawingEnabled:0,filter:18,multiSelect:19,preferredDrawingMode:20,state:21,style:1,toolName:2,user:22,viewer:3,cancelDrawing:23,getDrawingTool:24,isDrawingEnabled:25},null,[-1,-1])}get cancelDrawing(){return this.$$.ctx[23]}get getDrawingTool(){return this.$$.ctx[24]}get isDrawingEnabled(){return this.$$.ctx[25]}}function M2(r){let t,e,i,s,n,o,a,l=r[2].appearance.label+"",h,u,c,d;return{c(){t=st("g"),e=st("rect"),a=st("text"),h=Ga(l),E(e,"class","a9s-presence-label-bg svelte-1rehw2p"),E(e,"x",r[0]),E(e,"y",i=r[1]-18/r[3]),E(e,"height",s=18/r[3]),E(e,"fill",n=r[2].appearance.color),E(e,"stroke",o=r[2].appearance.color),E(a,"font-size",u=12/r[3]),E(a,"x",c=r[0]+Math.round(5/r[3])),E(a,"y",d=r[1]-5/r[3]),E(a,"class","svelte-1rehw2p"),E(t,"class","a9s-presence-label")},m(f,p){lt(f,t,p),Ct(t,e),Ct(t,a),Ct(a,h),r[6](t)},p(f,[p]){p&1&&E(e,"x",f[0]),p&10&&i!==(i=f[1]-18/f[3])&&E(e,"y",i),p&8&&s!==(s=18/f[3])&&E(e,"height",s),p&4&&n!==(n=f[2].appearance.color)&&E(e,"fill",n),p&4&&o!==(o=f[2].appearance.color)&&E(e,"stroke",o),p&4&&l!==(l=f[2].appearance.label+"")&&Gv(h,l),p&8&&u!==(u=12/f[3])&&E(a,"font-size",u),p&9&&c!==(c=f[0]+Math.round(5/f[3]))&&E(a,"x",c),p&10&&d!==(d=f[1]-5/f[3])&&E(a,"y",d)},i:zt,o:zt,d(f){f&&ot(t),r[6](null)}}}function P2(r,t,e){let{x:i}=t,{y:s}=t,{user:n}=t,{scale:o}=t,{hAlign:a=null}=t,l;const h=c=>{const d=l.querySelector("text"),f=l.querySelector("rect"),p=d.getBBox().width+10/c;a==="CENTER"&&l.setAttribute("style",`transform: translateX(-${p/2}px)`),f.setAttribute("width",`${p}`)};function u(c){kn[c?"unshift":"push"](()=>{l=c,e(4,l)})}return r.$$set=c=>{"x"in c&&e(0,i=c.x),"y"in c&&e(1,s=c.y),"user"in c&&e(2,n=c.user),"scale"in c&&e(3,o=c.scale),"hAlign"in c&&e(5,a=c.hAlign)},r.$$.update=()=>{r.$$.dirty&24&&l&&h(o)},[i,s,n,o,l,a,u]}class Ag extends ie{constructor(t){super(),re(this,t,P2,M2,Yt,{x:0,y:1,user:2,scale:3,hAlign:5})}}function O2(r){let t,e,i,s,n,o;return e=new Ag({props:{scale:r[1],user:r[0],x:r[3][0],y:r[3][1],hAlign:"CENTER"}}),{c(){t=st("g"),Ut(e.$$.fragment),i=st("polygon"),E(i,"class","a9s-presence-shape a9s-presence-polygon svelte-fgq4n0"),E(i,"stroke",s=r[0].appearance.color),E(i,"fill","transparent"),E(i,"points",n=r[2].points.map(Sg).join(" ")),E(t,"class","a9s-presence-overlay")},m(a,l){lt(a,t,l),Bt(e,t,null),Ct(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))&&E(i,"stroke",s),(!o||l&4&&n!==(n=a[2].points.map(Sg).join(" ")))&&E(i,"points",n)},i(a){o||(Z(e.$$.fragment,a),o=!0)},o(a){ht(e.$$.fragment,a),o=!1},d(a){a&&ot(t),Ft(e)}}}const Sg=r=>r.join(",");function N2(r,t,e){let i,s,{annotation:n}=t,{user:o}=t,{scale:a}=t;const l=h=>{let[u,...c]=h.points;return c.forEach(([d,f])=>{f<u[1]&&(u=[d,f])}),u};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 D2 extends ie{constructor(t){super(),re(this,t,N2,O2,Yt,{annotation:4,user:0,scale:1})}}function L2(r){let t,e,i,s,n,o,a,l,h;return e=new Ag({props:{scale:r[1],user:r[0],x:r[2].x,y:r[2].y}}),{c(){t=st("g"),Ut(e.$$.fragment),i=st("rect"),E(i,"class","a9s-presence-shape a9s-presence-rectangle svelte-gze948"),E(i,"stroke",s=r[0].appearance.color),E(i,"fill","transparent"),E(i,"x",n=r[2].x),E(i,"y",o=r[2].y),E(i,"width",a=r[2].w),E(i,"height",l=r[2].h),E(t,"class","a9s-presence-overlay")},m(u,c){lt(u,t,c),Bt(e,t,null),Ct(t,i),h=!0},p(u,[c]){const d={};c&2&&(d.scale=u[1]),c&1&&(d.user=u[0]),c&4&&(d.x=u[2].x),c&4&&(d.y=u[2].y),e.$set(d),(!h||c&1&&s!==(s=u[0].appearance.color))&&E(i,"stroke",s),(!h||c&4&&n!==(n=u[2].x))&&E(i,"x",n),(!h||c&4&&o!==(o=u[2].y))&&E(i,"y",o),(!h||c&4&&a!==(a=u[2].w))&&E(i,"width",a),(!h||c&4&&l!==(l=u[2].h))&&E(i,"height",l)},i(u){h||(Z(e.$$.fragment,u),h=!0)},o(u){ht(e.$$.fragment,u),h=!1},d(u){u&&ot(t),Ft(e)}}}function B2(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 F2 extends ie{constructor(t){super(),re(this,t,B2,L2,Yt,{annotation:3,user:0,scale:1})}}const{Boolean:k2}=Ua;function Cg(r,t,e){const i=r.slice();return i[8]=t[e],i}function Ig(r){let t,e;return t=new nu({props:{viewer:r[0],$$slots:{default:[$2,({transform:i,scale:s})=>({6:i,7:s}),({transform:i,scale:s})=>(i?64:0)|(s?128:0)]},$$scope:{ctx:r}}}),{c(){Ut(t.$$.fragment)},m(i,s){Bt(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||(Z(t.$$.fragment,i),e=!0)},o(i){ht(t.$$.fragment,i),e=!1},d(i){Ft(t,i)}}}function Rg(r){let t,e,i=Ne(r[2]),s=[];for(let o=0;o<i.length;o+=1)s[o]=Mg(Cg(r,i,o));const n=o=>ht(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Ge()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);lt(o,t,a),e=!0},p(o,a){if(a&132){i=Ne(o[2]);let l;for(l=0;l<i.length;l+=1){const h=Cg(o,i,l);s[l]?(s[l].p(h,a),Z(s[l],1)):(s[l]=Mg(h),s[l].c(),Z(s[l],1),s[l].m(t.parentNode,t))}for(pe(),l=i.length;l<s.length;l+=1)n(l);me()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)Z(s[a]);e=!0}},o(o){s=s.filter(k2);for(let a=0;a<s.length;a+=1)ht(s[a]);e=!1},d(o){o&&ot(t),Wr(s,o)}}}function U2(r){let t,e;return t=new D2({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){Ut(t.$$.fragment)},m(i,s){Bt(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||(Z(t.$$.fragment,i),e=!0)},o(i){ht(t.$$.fragment,i),e=!1},d(i){Ft(t,i)}}}function G2(r){let t,e;return t=new F2({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){Ut(t.$$.fragment)},m(i,s){Bt(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||(Z(t.$$.fragment,i),e=!0)},o(i){ht(t.$$.fragment,i),e=!1},d(i){Ft(t,i)}}}function Mg(r){let t,e,i,s;const n=[G2,U2],o=[];function a(l,h){return l[8].annotation.target.selector.type===xt.RECTANGLE?0:l[8].annotation.target.selector.type===xt.POLYGON?1:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Ge()},m(l,h){~t&&o[t].m(l,h),lt(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(pe(),ht(o[u],1,1,()=>{o[u]=null}),me()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),Z(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(Z(e),s=!0)},o(l){ht(e),s=!1},d(l){l&&ot(i),~t&&o[t].d(l)}}}function $2(r){let t,e,i,s,n=r[2].length>0&&Rg(r);return{c(){t=st("svg"),e=st("g"),n&&n.c(),E(e,"transform",i=r[6]),E(t,"class","a9s-osd-presencelayer svelte-1krwc4m")},m(o,a){lt(o,t,a),Ct(t,e),n&&n.m(e,null),s=!0},p(o,a){o[2].length>0?n?(n.p(o,a),a&4&&Z(n,1)):(n=Rg(o),n.c(),Z(n,1),n.m(e,null)):n&&(pe(),ht(n,1,1,()=>{n=null}),me()),(!s||a&64&&i!==(i=o[6]))&&E(e,"transform",i)},i(o){s||(Z(n),s=!0)},o(o){ht(n),s=!1},d(o){o&&ot(t),n&&n.d()}}}function H2(r){let t=!!r[1],e,i,s=t&&Ig(r);return{c(){s&&s.c(),e=Ge()},m(n,o){s&&s.m(n,o),lt(n,e,o),i=!0},p(n,[o]){o&2&&(t=!!n[1]),t?s?(s.p(n,o),o&2&&Z(s,1)):(s=Ig(n),s.c(),Z(s,1),s.m(e.parentNode,e)):s&&(pe(),ht(s,1,1,()=>{s=null}),me())},i(n){i||(Z(s),i=!0)},o(n){ht(s),i=!1},d(n){n&&ot(e),s&&s.d(n)}}}function X2(r,t,e){let{store:i}=t,{viewer:s}=t,{provider:n}=t,o=[],a;const l=(h,u)=>{e(2,o=[...o.filter(({selectedBy:c})=>c.presenceKey!==h.presenceKey),...(u||[]).map(c=>({annotation:i.getAnnotation(c),selectedBy:h}))].filter(({annotation:c})=>(c||console.warn("Selection event on unknown annotation"),!!c))),a&&i.unobserve(a),a=c=>{const{deleted:d,updated:f}=c.changes,p=new Set((d||[]).map(_=>_.id)),m=o.filter(({annotation:_})=>!p.has(_.id)).map(_=>{const y=(f||[]).find(v=>v.oldValue.id===_.annotation.id);return y?{selectedBy:_.selectedBy,annotation:y.newValue}:_});e(2,o=m)},i.observe(a,{annotations:o.map(c=>c.annotation.id)})};return Hv(()=>{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 V2 extends ie{constructor(t){super(),re(this,t,X2,H2,Yt,{store:3,viewer:0,provider:1})}}function z2(r){let t,e,i,s,n;return{c(){t=st("rect"),E(t,"x",e=r[0].x),E(t,"y",i=r[0].y),E(t,"width",s=r[0].w),E(t,"height",n=r[0].h)},m(o,a){lt(o,t,a)},p(o,[a]){a&1&&e!==(e=o[0].x)&&E(t,"x",e),a&1&&i!==(i=o[0].y)&&E(t,"y",i),a&1&&s!==(s=o[0].w)&&E(t,"width",s),a&1&&n!==(n=o[0].h)&&E(t,"height",n)},i:zt,o:zt,d(o){o&&ot(t)}}}function Y2(r,t,e){let i,{annotation:s}=t;return r.$$set=n=>{"annotation"in n&&e(1,s=n.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=s.target.selector.geometry)},[i,s]}class j2 extends ie{constructor(t){super(),re(this,t,Y2,z2,Yt,{annotation:1})}}function W2(r){let t,e;return{c(){t=st("polygon"),E(t,"points",e=r[0].points.map(Pg).join(" "))},m(i,s){lt(i,t,s)},p(i,[s]){s&1&&e!==(e=i[0].points.map(Pg).join(" "))&&E(t,"points",e)},i:zt,o:zt,d(i){i&&ot(t)}}}const Pg=r=>r.join(",");function q2(r,t,e){let i,{annotation:s}=t;return r.$$set=n=>{"annotation"in n&&e(1,s=n.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=s.target.selector.geometry)},[i,s]}class K2 extends ie{constructor(t){super(),re(this,t,q2,W2,Yt,{annotation:1})}}function Og(r,t,e){const i=r.slice();return i[2]=t[e],i}function Ng(r){let t,e;return{c(){t=st("path"),e=st("path"),E(t,"fill-rule","evenodd"),E(t,"d",Ze(r[2])),E(e,"class","a9s-inner"),E(e,"fill-rule","evenodd"),E(e,"d",Ze(r[2]))},m(i,s){lt(i,t,s),lt(i,e,s)},p:zt,d(i){i&&(ot(t),ot(e))}}}function Z2(r){let t,e=Ne(r[0]),i=[];for(let s=0;s<e.length;s+=1)i[s]=Ng(Og(r,e,s));return{c(){t=st("g");for(let s=0;s<i.length;s+=1)i[s].c()},m(s,n){lt(s,t,n);for(let o=0;o<i.length;o+=1)i[o]&&i[o].m(t,null)},p(s,[n]){if(n&1){e=Ne(s[0]);let o;for(o=0;o<e.length;o+=1){const a=Og(s,e,o);i[o]?i[o].p(a,n):(i[o]=Ng(a),i[o].c(),i[o].m(t,null))}for(;o<i.length;o+=1)i[o].d(1);i.length=e.length}},i:zt,o:zt,d(s){s&&ot(t),Wr(i,s)}}}function Q2(r,t,e){let{annotation:i}=t;const{polygons:s}=i.target.selector.geometry;return r.$$set=n=>{"annotation"in n&&e(1,i=n.annotation)},[s,i]}class J2 extends ie{constructor(t){super(),re(this,t,Q2,Z2,Yt,{annotation:1})}}function tI(r){let t,e,i,s,n;return{c(){t=st("ellipse"),E(t,"cx",e=r[0].cx),E(t,"cy",i=r[0].cy),E(t,"rx",s=r[0].rx),E(t,"ry",n=r[0].ry)},m(o,a){lt(o,t,a)},p(o,[a]){a&1&&e!==(e=o[0].cx)&&E(t,"cx",e),a&1&&i!==(i=o[0].cy)&&E(t,"cy",i),a&1&&s!==(s=o[0].rx)&&E(t,"rx",s),a&1&&n!==(n=o[0].ry)&&E(t,"ry",n)},i:zt,o:zt,d(o){o&&ot(t)}}}function eI(r,t,e){let i,{annotation:s}=t;return r.$$set=n=>{"annotation"in n&&e(1,s=n.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=s.target.selector.geometry)},[i,s]}class rI extends ie{constructor(t){super(),re(this,t,eI,tI,Yt,{annotation:1})}}function iI(r){let t,e,i,s,n;return{c(){t=st("line"),E(t,"x1",e=r[0].points[0][0]),E(t,"y1",i=r[0].points[0][1]),E(t,"x2",s=r[0].points[1][0]),E(t,"y2",n=r[0].points[1][1])},m(o,a){lt(o,t,a)},p(o,[a]){a&1&&e!==(e=o[0].points[0][0])&&E(t,"x1",e),a&1&&i!==(i=o[0].points[0][1])&&E(t,"y1",i),a&1&&s!==(s=o[0].points[1][0])&&E(t,"x2",s),a&1&&n!==(n=o[0].points[1][1])&&E(t,"y2",n)},i:zt,o:zt,d(o){o&&ot(t)}}}function sI(r,t,e){let i,{annotation:s}=t;return r.$$set=n=>{"annotation"in n&&e(1,s=n.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=s.target.selector.geometry)},[i,s]}class nI extends ie{constructor(t){super(),re(this,t,sI,iI,Yt,{annotation:1})}}const{Boolean:oI}=Ua;function Dg(r,t,e){const i=r.slice();return i[10]=t[e],i}function Lg(r){let t,e;return t=new nu({props:{viewer:r[0],$$slots:{default:[dI,({transform:i})=>({9:i}),({transform:i})=>i?512:0]},$$scope:{ctx:r}}}),{c(){Ut(t.$$.fragment)},m(i,s){Bt(t,i,s),e=!0},p(i,s){const n={};s&1&&(n.viewer=i[0]),s&8710&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(Z(t.$$.fragment,i),e=!0)},o(i){ht(t.$$.fragment,i),e=!1},d(i){Ft(t,i)}}}function aI(r){let t,e;return t=new nI({props:{annotation:r[10]}}),{c(){Ut(t.$$.fragment)},m(i,s){Bt(t,i,s),e=!0},p(i,s){const n={};s&2&&(n.annotation=i[10]),t.$set(n)},i(i){e||(Z(t.$$.fragment,i),e=!0)},o(i){ht(t.$$.fragment,i),e=!1},d(i){Ft(t,i)}}}function lI(r){let t,e;return t=new rI({props:{annotation:r[10]}}),{c(){Ut(t.$$.fragment)},m(i,s){Bt(t,i,s),e=!0},p(i,s){const n={};s&2&&(n.annotation=i[10]),t.$set(n)},i(i){e||(Z(t.$$.fragment,i),e=!0)},o(i){ht(t.$$.fragment,i),e=!1},d(i){Ft(t,i)}}}function hI(r){let t,e;return t=new J2({props:{annotation:r[10]}}),{c(){Ut(t.$$.fragment)},m(i,s){Bt(t,i,s),e=!0},p(i,s){const n={};s&2&&(n.annotation=i[10]),t.$set(n)},i(i){e||(Z(t.$$.fragment,i),e=!0)},o(i){ht(t.$$.fragment,i),e=!1},d(i){Ft(t,i)}}}function uI(r){let t,e;return t=new K2({props:{annotation:r[10]}}),{c(){Ut(t.$$.fragment)},m(i,s){Bt(t,i,s),e=!0},p(i,s){const n={};s&2&&(n.annotation=i[10]),t.$set(n)},i(i){e||(Z(t.$$.fragment,i),e=!0)},o(i){ht(t.$$.fragment,i),e=!1},d(i){Ft(t,i)}}}function cI(r){let t,e;return t=new j2({props:{annotation:r[10]}}),{c(){Ut(t.$$.fragment)},m(i,s){Bt(t,i,s),e=!0},p(i,s){const n={};s&2&&(n.annotation=i[10]),t.$set(n)},i(i){e||(Z(t.$$.fragment,i),e=!0)},o(i){ht(t.$$.fragment,i),e=!1},d(i){Ft(t,i)}}}function Bg(r){let t,e,i,s;const n=[cI,uI,hI,lI,aI],o=[];function a(l,h){return l[10].target.selector.type===xt.RECTANGLE?0:l[10].target.selector.type===xt.POLYGON?1:l[10].target.selector.type===xt.MULTIPOLYGON?2:l[10].target.selector.type===xt.ELLIPSE?3:l[10].target.selector.type===xt.LINE?4:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Ge()},m(l,h){~t&&o[t].m(l,h),lt(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(pe(),ht(o[u],1,1,()=>{o[u]=null}),me()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),Z(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(Z(e),s=!0)},o(l){ht(e),s=!1},d(l){l&&ot(i),~t&&o[t].d(l)}}}function dI(r){let t,e,i,s,n,o,a,l,h,u,c,d,f,p,m=Ne(r[1].filter(r[6])),_=[];for(let v=0;v<m.length;v+=1)_[v]=Bg(Dg(r,m,v));const y=v=>ht(_[v],1,1,()=>{_[v]=null});return{c(){var v,g,x,T;t=st("svg"),e=st("g"),i=st("rect"),l=st("rect");for(let M=0;M<_.length;M+=1)_[M].c();E(i,"class","a9s-union-bg svelte-jwrce3"),E(i,"x",s=(v=r[2])==null?void 0:v.minX),E(i,"y",n=(g=r[2])==null?void 0:g.minY),E(i,"width",o=r[2]?r[2].maxX-r[2].minX:0),E(i,"height",a=r[2]?r[2].maxY-r[2].minY:0),E(l,"class","a9s-union-fg svelte-jwrce3"),E(l,"x",h=(x=r[2])==null?void 0:x.minX),E(l,"y",u=(T=r[2])==null?void 0:T.minY),E(l,"width",c=r[2]?r[2].maxX-r[2].minX:0),E(l,"height",d=r[2]?r[2].maxY-r[2].minY:0),E(e,"transform",f=r[9]),E(t,"class","a9s-osd-selectionlayer svelte-jwrce3")},m(v,g){lt(v,t,g),Ct(t,e),Ct(e,i),Ct(e,l);for(let x=0;x<_.length;x+=1)_[x]&&_[x].m(e,null);p=!0},p(v,g){var x,T,M,S;if((!p||g&4&&s!==(s=(x=v[2])==null?void 0:x.minX))&&E(i,"x",s),(!p||g&4&&n!==(n=(T=v[2])==null?void 0:T.minY))&&E(i,"y",n),(!p||g&4&&o!==(o=v[2]?v[2].maxX-v[2].minX:0))&&E(i,"width",o),(!p||g&4&&a!==(a=v[2]?v[2].maxY-v[2].minY:0))&&E(i,"height",a),(!p||g&4&&h!==(h=(M=v[2])==null?void 0:M.minX))&&E(l,"x",h),(!p||g&4&&u!==(u=(S=v[2])==null?void 0:S.minY))&&E(l,"y",u),(!p||g&4&&c!==(c=v[2]?v[2].maxX-v[2].minX:0))&&E(l,"width",c),(!p||g&4&&d!==(d=v[2]?v[2].maxY-v[2].minY:0))&&E(l,"height",d),g&2){m=Ne(v[1].filter(v[6]));let R;for(R=0;R<m.length;R+=1){const P=Dg(v,m,R);_[R]?(_[R].p(P,g),Z(_[R],1)):(_[R]=Bg(P),_[R].c(),Z(_[R],1),_[R].m(e,null))}for(pe(),R=m.length;R<_.length;R+=1)y(R);me()}(!p||g&512&&f!==(f=v[9]))&&E(e,"transform",f)},i(v){if(!p){for(let g=0;g<m.length;g+=1)Z(_[g]);p=!0}},o(v){_=_.filter(oI);for(let g=0;g<_.length;g+=1)ht(_[g]);p=!1},d(v){v&&ot(t),Wr(_,v)}}}function fI(r){let t=!!r[2],e,i,s=t&&Lg(r);return{c(){s&&s.c(),e=Ge()},m(n,o){s&&s.m(n,o),lt(n,e,o),i=!0},p(n,[o]){o&4&&(t=!!n[2]),t?s?(s.p(n,o),o&4&&Z(s,1)):(s=Lg(n),s.c(),Z(s,1),s.m(e.parentNode,e)):s&&(pe(),ht(s,1,1,()=>{s=null}),me())},i(n){i||(Z(s),i=!0)},o(n){ht(s),i=!1},d(n){n&&ot(e),s&&s.d(n)}}}function pI(r,t,e){let i,s,n,{state:o}=t,{viewer:a}=t;const{store:l}=o,{selection:h}=o;Fn(r,h,d=>e(5,n=d));const u=d=>{let f=-1/0,p=-1/0,m=1/0,_=1/0;for(let y of d.filter(v=>ze(v))){const{bounds:v}=y.target.selector.geometry;v.maxX>f&&(f=v.maxX),v.maxY>p&&(p=v.maxY),v.minX<m&&(m=v.minX),v.minY<_&&(_=v.minY)}return a.forceRedraw(),{maxX:f,maxY:p,minX:m,minY:_}},c=d=>ze(d);return r.$$set=d=>{"state"in d&&e(4,o=d.state),"viewer"in d&&e(0,a=d.viewer)},r.$$.update=()=>{r.$$.dirty&32&&e(1,i=n.selected.map(({id:d})=>l.getAnnotation(d))),r.$$.dirty&2&&e(2,s=i.length>1?u(i):void 0)},[a,i,s,h,o,n,c]}class mI extends ie{constructor(t){super(),re(this,t,pI,fI,Yt,{state:4,viewer:0})}}const Fg=(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=Fc(a);r.element.setAttribute("data-theme",l)}})}):r.element.setAttribute("data-theme",t)},kg=(r,t,e)=>(i,s={})=>{const n=typeof i=="string"?i:i.id,o=t.getAnnotation(n);if(!o||!ze(o))return;const a=r.container.getBoundingClientRect(),{padding:l}=s;let[h,u,c,d]=l?Array.isArray(l)?l:[l,l,l,l]:[0,0,0,0];h=h/a.height,u=u/a.width,c=c/a.height,d=d/a.width;const{minX:f,minY:p,maxX:m,maxY:_}=o.target.selector.geometry.bounds,y=m-f,v=_-p,g=f-d*y,x=p-h*v,T=y+(u+d)*y,M=v+(h+c)*v,S=r.viewport.imageToViewportRectangle(g,x,T,M);r.viewport[e](S,s.immediately)},gI=(r,t)=>kg(r,t,"fitBounds"),yI=(r,t)=>kg(r,t,"fitBoundsWithConstraints"),_I=(r,t={})=>{const e=Uc(t,{drawingEnabled:!1,drawingMode:Cr?"drag":"click",userSelectAction:sa.EDIT,theme:"light"}),i=Bc(e),{hover:s,selection:n,store:o}=i,a=iy(o,e.initialHistory),l=sy(i,a,e.adapter,e.autoSave);let h=dy(),u=e.drawingEnabled,c=e.drawingMode,d=e.modalSelect;const f=$c(a,r.element),p=new y2({target:r.element,props:{state:i,viewer:r,style:e.style,filter:void 0}}),m=new V2({target:r.element.querySelector(".openseadragon-canvas"),props:{provider:void 0,store:o,viewer:r}}),_=new R2({target:r.element.querySelector(".openseadragon-canvas"),props:{drawingEnabled:!!u,filter:void 0,multiSelect:e.multiSelect,preferredDrawingMode:c,state:i,style:e.style,user:h,viewer:r}}),y=new mI({target:r.element.querySelector(".openseadragon-canvas"),props:{state:i,viewer:r}});p.$on("click",N=>{const{originalEvent:H,annotation:k}=N.detail,z=Y=>_g(Y.id,H,n,e.multiSelect);d?n.isEmpty()&&k&&n.userSelect(z(k),H):k&&!(c==="click"&&u)?n.userSelect(z(k),H):n.isEmpty()||n.clear()}),r.element.addEventListener("pointerdown",N=>{if(s.current){const H=o.getAnnotation(s.current);l.emit("clickAnnotation",H,N)}}),Fg(r,e.theme);const v=oy(i,a,e.adapter),g=()=>_.cancelDrawing(),x=()=>{p.$destroy(),m.$destroy(),_.$destroy(),y.$destroy(),f.destroy(),a.destroy()},T=gI(r,o),M=yI(r,o),S=()=>_.getDrawingTool(),R=()=>h,P=()=>_.isDrawingEnabled(),F=(N,H,k)=>xc(N,H,k),U=(N,H)=>gc(N,H),I=N=>{if(!Dn(N))throw`No drawing tool named ${N}`;_.$set({toolName:N})},A=N=>{u=N,_.$set({drawingEnabled:N})},w=N=>{p.$set({filter:N}),_.$set({filter:N})},C=N=>d=N,L=N=>{p.$set({style:N}),_.$set({style:N})},O=N=>m.$set({provider:N}),B=N=>Fg(r,N),V=N=>{h=N,_.$set({user:N})},D=N=>p.$set({visible:N});return{...v,cancelDrawing:g,destroy:x,fitBounds:T,fitBoundsWithConstraints:M,getDrawingTool:S,getUser:R,isDrawingEnabled:P,listDrawingTools:Nn,on:l.on,off:l.off,registerDrawingTool:F,registerShapeEditor:U,setDrawingEnabled:A,setDrawingTool:I,setFilter:w,setModalSelect:C,setPresenceProvider:O,setStyle:L,setTheme:B,setUser:V,setVisible:D,state:i,viewer:r}};te.ShapeType=xt,te.UserSelectAction=sa,te.W3CImageFormat=r0,te.chainStyles=Y_,te.computeStyle=z_,te.createBody=Wg,te.createImageAnnotator=Bv,te.createOSDAnnotator=_I,te.defaultColorProvider=py,Object.defineProperty(te,Symbol.toStringTag,{value:"Module"})});
1150
1150
  //# sourceMappingURL=annotorious-openseadragon.js.map