vendor: 5,794 bytes, line 1
1function Km(n,e){for(var t=0;t<e.length;t++){const i=e[t];if(typeof i!="string"&&!Array.isArray(i)){for(const r in i)if(r!=="default"&&!(r in n)){const s=Object.getOwnPropertyDescriptor(i,r);s&&Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:()=>i[r]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}var FP=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Xh(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function NP(n){if(Object.prototype.hasOwnProperty.call(n,"__esModule"))return n;var e=n.default;if(typeof e=="function"){var t=function i(){var r=!1;try{r=this instanceof i}catch{}return r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(i){var r=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:function(){return n[i]}})}),t}var Ia={exports:{}},qr={};var Iu;function Jm(){if(Iu)return qr;Iu=1;var n=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(i,r,s){var o=null;if(s!==void 0&&(o=""+s),r.key!==void 0&&(o=""+r.key),"key"in r){s={};for(var a in r)a!=="key"&&(s[a]=r[a])}else s=r;return r=s.ref,{$$typeof:n,type:i,key:o,ref:r!==void 0?r:null,props:s}}return qr.Fragment=e,qr.jsx=t,qr.jsxs=t,qr}var Mu;function Qm(){return Mu||(Mu=1,Ia.exports=Jm()),Ia.exports}var Ei=Qm(),Ma={exports:{}},Oe={};var Du;function ev(){if(Du)return Oe;Du=1;var n=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),o=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),u=Symbol.for("react.lazy"),c=Symbol.for("react.activity"),d=Symbol.iterator;function f(b){return b===null||typeof b!="object"?null:(b=d&&b[d]||b["@@iterator"],typeof b=="function"?b:null)}var p={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,v={};function m(b,H,X){this.props=b,this.context=H,this.refs=v,this.updater=X||p}m.prototype.isReactComponent={},m.prototype.setState=function(b,H){if(typeof b!="object"&&typeof b!="function"&&b!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,b,H,"setState")},m.prototype.forceUpdate=function(b){this.updater.enqueueForceUpdate(this,b,"forceUpdate")};function x(){}x.prototype=m.prototype;function y(b,H,X){this.props=b,this.context=H,this.refs=v,this.updater=X||p}var E=y.prototype=new x;E.constructor=y,g(E,m.prototype),E.isPureReactComponent=!0;var R=Array.isArray;function P(){}var S={H:null,A:null,T:null,S:null},L=Object.prototype.hasOwnProperty;function k(b,H,X){var $=X.ref;return{$$typeof:n,type:b,key:H,ref:$!==void 0?$:null,props:X}}function W(b,H){return k(b.type,H,b.props)}function j(b){return typeof b=="object"&&b!==null&&b.$$typeof===n}function V(b){var H={"=":"=0",":":"=2"};return"$"+b.replace(/[=:]/g,function(X){return H[X]})}var N=/\/+/g;function D(b,H){return typeof b=="object"&&b!==null&&b.key!=null?V(""+b.key):H.toString(36)}function A(b){switch(b.status){case"fulfilled":return b.value;case"rejected":throw b.reason;default:switch(typeof b.status=="string"?b.then(P,P):(b.status="pending",b.then(function(H){b.status==="pending"&&(b.status="fulfilled",b.value=H)},function(H){b.status==="pending"&&(b.status="rejected",b.reason=H)})),b.status){case"fulfilled":return b.value;case"rejected":throw b.reason}}throw b}function O(b,H,X,$,re){var se=typeof b;(se==="undefined"||se==="boolean")&&(b=null);var ce=!1;if(b===null)ce=!0;else switch(se){case"bigint":case"string":case"number":ce=!0;break;case"object":switch(b.$$typeof){case n:case e:ce=!0;break;case u:return ce=b._init,O(ce(b._payload),H,X,$,re)}}if(ce)return re=re(b),ce=$===""?"."+D(b,0):$,R(re)?(X="",ce!=null&&(X=ce.replace(N,"$&/")+"/"),O(re,H,X,"",function(de){return de})):re!=null&&(j(re)&&(re=W(re,X+(re.key==null||b&&b.key===re.key?"":(""+re.key).replace(N,"$&/")+"/")+ce)),H.push(re)),1;ce=0;var ie=$===""?".":$+":";if(R(b))for(var ge=0;ge<b.length;ge++)$=b[ge],se=ie+D($,ge),ce+=O($,H,X,se,re);else if(ge=f(b),typeof ge=="function")for(b=ge.call(b),ge=0;!($=b.next()).done;)$=$.value,se=ie+D($,ge++),ce+=O($,H,X,se,re);else if(se==="object"){if(typeof b.then=="function")return O(A(b),H,X,$,re);throw H=String(b),Error("Objects are not valid as a React child (found: "+(H==="[object Object]"?"object with keys {"+Object.keys(b).join(", ")+"}":H)+"). If you meant to render a collection of children, use an array instead.")}return ce}function B(b,H,X){if(b==null)return b;var $=[],re=0;return O(b,$,"","",function(se){return H.call(X,se,re++)}),$}function G(b){if(b._status===-1){var H=b._result;H=H(),H.then(function(X){(b._status===0||b._status===-1)&&(b._status=1,b._result=X)},function(X){(b._status===0||b._status===-1)&&(b._status=2,b._result=X)}),b._status===-1&&(b._status=0,b._result=H)}if(b._status===1)return b._result.default;throw b._result}var Y=typeof reportError=="function"?reportError:function(b){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var H=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof b=="object"&&b!==null&&typeof b.message=="string"?String(b.message):String(b),error:b});if(!window.dispatchEvent(H))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",b);return}console.error(b)}
vendor: 6,833 bytes, line 1
1,z={map:B,forEach:function(b,H,X){B(b,function(){H.apply(this,arguments)},X)},count:function(b){var H=0;return B(b,function(){H++}),H},toArray:function(b){return B(b,function(H){return H})||[]},only:function(b){if(!j(b))throw Error("React.Children.only expected to receive a single React element child.");return b}};return Oe.Activity=c,Oe.Children=z,Oe.Component=m,Oe.Fragment=t,Oe.Profiler=r,Oe.PureComponent=y,Oe.StrictMode=i,Oe.Suspense=l,Oe.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=S,Oe.__COMPILER_RUNTIME={__proto__:null,c:function(b){return S.H.useMemoCache(b)}},Oe.cache=function(b){return function(){return b.apply(null,arguments)}},Oe.cacheSignal=function(){return null},Oe.cloneElement=function(b,H,X){if(b==null)throw Error("The argument must be a React element, but you passed "+b+".");var $=g({},b.props),re=b.key;if(H!=null)for(se in H.key!==void 0&&(re=""+H.key),H)!L.call(H,se)||se==="key"||se==="__self"||se==="__source"||se==="ref"&&H.ref===void 0||($[se]=H[se]);var se=arguments.length-2;if(se===1)$.children=X;else if(1<se){for(var ce=Array(se),ie=0;ie<se;ie++)ce[ie]=arguments[ie+2];$.children=ce}return k(b.type,re,$)},Oe.createContext=function(b){return b={$$typeof:o,_currentValue:b,_currentValue2:b,_threadCount:0,Provider:null,Consumer:null},b.Provider=b,b.Consumer={$$typeof:s,_context:b},b},Oe.createElement=function(b,H,X){var $,re={},se=null;if(H!=null)for($ in H.key!==void 0&&(se=""+H.key),H)L.call(H,$)&&$!=="key"&&$!=="__self"&&$!=="__source"&&(re[$]=H[$]);var ce=arguments.length-2;if(ce===1)re.children=X;else if(1<ce){for(var ie=Array(ce),ge=0;ge<ce;ge++)ie[ge]=arguments[ge+2];re.children=ie}if(b&&b.defaultProps)for($ in ce=b.defaultProps,ce)re[$]===void 0&&(re[$]=ce[$]);return k(b,se,re)},Oe.createRef=function(){return{current:null}},Oe.forwardRef=function(b){return{$$typeof:a,render:b}},Oe.isValidElement=j,Oe.lazy=function(b){return{$$typeof:u,_payload:{_status:-1,_result:b},_init:G}},Oe.memo=function(b,H){return{$$typeof:h,type:b,compare:H===void 0?null:H}},Oe.startTransition=function(b){var H=S.T,X={};S.T=X;try{var $=b(),re=S.S;re!==null&&re(X,$),typeof $=="object"&&$!==null&&typeof $.then=="function"&&$.then(P,Y)}catch(se){Y(se)}finally{H!==null&&X.types!==null&&(H.types=X.types),S.T=H}},Oe.unstable_useCacheRefresh=function(){return S.H.useCacheRefresh()},Oe.use=function(b){return S.H.use(b)},Oe.useActionState=function(b,H,X){return S.H.useActionState(b,H,X)},Oe.useCallback=function(b,H){return S.H.useCallback(b,H)},Oe.useContext=function(b){return S.H.useContext(b)},Oe.useDebugValue=function(){},Oe.useDeferredValue=function(b,H){return S.H.useDeferredValue(b,H)},Oe.useEffect=function(b,H){return S.H.useEffect(b,H)},Oe.useEffectEvent=function(b){return S.H.useEffectEvent(b)},Oe.useId=function(){return S.H.useId()},Oe.useImperativeHandle=function(b,H,X){return S.H.useImperativeHandle(b,H,X)},Oe.useInsertionEffect=function(b,H){return S.H.useInsertionEffect(b,H)},Oe.useLayoutEffect=function(b,H){return S.H.useLayoutEffect(b,H)},Oe.useMemo=function(b,H){return S.H.useMemo(b,H)},Oe.useOptimistic=function(b,H){return S.H.useOptimistic(b,H)},Oe.useReducer=function(b,H,X){return S.H.useReducer(b,H,X)},Oe.useRef=function(b){return S.H.useRef(b)},Oe.useState=function(b){return S.H.useState(b)},Oe.useSyncExternalStore=function(b,H,X){return S.H.useSyncExternalStore(b,H,X)},Oe.useTransition=function(){return S.H.useTransition()},Oe.version="19.2.7",Oe}var Ou;function dp(){return Ou||(Ou=1,Ma.exports=ev()),Ma.exports}var le=dp();const tv=Xh(le),fp=Km({__proto__:null,default:tv},[le]);var Da={exports:{}},Ct={};var Lu;function iv(){if(Lu)return Ct;Lu=1;var n=dp();function e(l){var h="https://react.dev/errors/"+l;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var u=2;u<arguments.length;u++)h+="&args[]="+encodeURIComponent(arguments[u])}return"Minified React error #"+l+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function t(){}var i={d:{f:t,r:function(){throw Error(e(522))},D:t,C:t,L:t,m:t,X:t,S:t,M:t},p:0,findDOMNode:null},r=Symbol.for("react.portal");function s(l,h,u){var c=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:r,key:c==null?null:""+c,children:l,containerInfo:h,implementation:u}}var o=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function a(l,h){if(l==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return Ct.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,Ct.createPortal=function(l,h){var u=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(e(299));return s(l,h,null,u)},Ct.flushSync=function(l){var h=o.T,u=i.p;try{if(o.T=null,i.p=2,l)return l()}finally{o.T=h,i.p=u,i.d.f()}},Ct.preconnect=function(l,h){typeof l=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,i.d.C(l,h))},Ct.prefetchDNS=function(l){typeof l=="string"&&i.d.D(l)},Ct.preinit=function(l,h){if(typeof l=="string"&&h&&typeof h.as=="string"){var u=h.as,c=a(u,h.crossOrigin),d=typeof h.integrity=="string"?h.integrity:void 0,f=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;u==="style"?i.d.S(l,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:c,integrity:d,fetchPriority:f}):u==="script"&&i.d.X(l,{crossOrigin:c,integrity:d,fetchPriority:f,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},Ct.preinitModule=function(l,h){if(typeof l=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var u=a(h.as,h.crossOrigin);i.d.M(l,{crossOrigin:u,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&i.d.M(l)},Ct.preload=function(l,h){if(typeof l=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var u=h.as,c=a(u,h.crossOrigin);i.d.L(l,u,{crossOrigin:c,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},Ct.preloadModule=function(l,h){if(typeof l=="string")if(h){var u=a(h.as,h.crossOrigin);i.d.m(l,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:u,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else i.d.m(l)},Ct.requestFormReset=function(l){i.d.r(l)},Ct.unstable_batchedUpdates=function(l,h){return l(h)},Ct.useFormState=function(l,h,u){return o.H.useFormState(l,h,u)}
1,Ct.useFormStatus=function(){return o.H.useHostTransitionStatus()},Ct.version="19.2.7",Ct}var Bu;function nv(){if(Bu)return Da.exports;Bu=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),Da.exports=iv(),Da.exports}var Wh=nv();const kP=Xh(Wh);var rv=Object.defineProperty,sv=(n,e,t)=>e in n?rv(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Fu=(n,e,t)=>sv(n,typeof e!="symbol"?e+"":e,t);function Gn(){}function Vl(n,e){for(const t in e)n[t]=e[t];return n}function pp(n){return n()}function Nu(){return Object.create(null)}function ii(n){n.forEach(pp)}function ut(n){return typeof n=="function"}function Fr(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function ov(n){return Object.keys(n).length===0}function av(n,e,t,i){if(n){const r=gp(n,e,t,i);return n[0](r)}}function gp(n,e,t,i){return n[1]&&i?Vl(t.ctx.slice(),n[1](i(e))):t.ctx}function lv(n,e,t,i){if(n[2]&&i){const r=n[2](i(t));if(e.dirty===void 0)return r;if(typeof r=="object"){const s=[],o=Math.max(e.dirty.length,r.length);for(let a=0;a<o;a+=1)s[a]=e.dirty[a]|r[a];return s}return e.dirty|r}return e.dirty}function hv(n,e,t,i,r,s){if(r){const o=gp(e,t,i,s);n.p(o,r)}}function uv(n){if(n.ctx.length>32){const e=[],t=n.ctx.length/32;for(let i=0;i<t;i++)e[i]=-1;return e}return-1}function ku(n){const e={};for(const t in n)t[0]!=="$"&&(e[t]=n[t]);return e}function Uu(n){return n??""}function Ke(n,e){n.appendChild(e)}function Ne(n,e,t){n.insertBefore(e,t||null)}function Be(n){n.parentNode&&n.parentNode.removeChild(n)}function ha(n,e){for(let t=0;t<n.length;t+=1)n[t]&&n[t].d(e)}function Ie(n){return document.createElementNS("http://www.w3.org/2000/svg",n)}function mp(n){return document.createTextNode(n)}function Lt(){return mp(" ")}function Os(){return mp("")}function We(n,e,t,i){return n.addEventListener(e,t,i),()=>n.removeEventListener(e,t,i)}function U(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function cv(n){return Array.from(n.childNodes)}function Hu(n,e,t){n.classList.toggle(e,!!t)}function dv(n,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:i})}let ms;function cs(n){ms=n}function vp(){if(!ms)throw new Error("Function called outside component initialization");return ms}function Yh(n){vp().$$.on_mount.push(n)}function qh(){const n=vp();return(e,t,{cancelable:i=!1}={})=>{const r=n.$$.callbacks[e];if(r){const s=dv(e,t,{cancelable:i});return r.slice().forEach(o=>{o.call(n,s)}),!s.defaultPrevented}return!0}}function xt(n,e){const t=n.$$.callbacks[e.type];t&&t.slice().forEach(i=>i.call(this,e))}const sr=[],Gu=[];let yr=[];const zu=[],yp=Promise.resolve();let jl=!1;function xp(){jl||(jl=!0,yp.then(wp))}function _p(){return xp(),yp}function Xl(n){yr.push(n)}const Oa=new Set;let Zn=0;function wp(){if(Zn!==0)return;const n=ms;do{try{for(;Zn<sr.length;){const e=sr[Zn];Zn++,cs(e),fv(e.$$)}}catch(e){throw sr.length=0,Zn=0,e}for(cs(null),sr.length=0,Zn=0;Gu.length;)Gu.pop()();for(let e=0;e<yr.length;e+=1){const t=yr[e];Oa.has(t)||(Oa.add(t),t())}yr.length=0}while(sr.length);for(;zu.length;)zu.pop()();jl=!1,Oa.clear(),cs(n)}function fv(n){if(n.fragment!==null){n.update(),ii(n.before_update);const e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(Xl)}}function pv(n){const e=[],t=[];yr.forEach(i=>n.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),yr=e}const yo=new Set;let Dn;function Cr(){Dn={r:0,c:[],p:Dn}}function Ir(){Dn.r||ii(Dn.c),Dn=Dn.p}function je(n,e){n&&n.i&&(yo.delete(n),n.i(e))}function Qe(n,e,t,i){if(n&&n.o){if(yo.has(n))return;yo.add(n),Dn.c.push(()=>{yo.delete(n),i&&(t&&n.d(1),i())}),n.o(e)}else i&&i()}function hn(n){return n?.length!==void 0?n:Array.from(n)}function Zt(n){n&&n.c()}function Vt(n,e,t){const{fragment:i,after_update:r}=n.$$;i&&i.m(e,t),Xl(()=>{const s=n.$$.on_mount.map(pp).filter(ut);n.$$.on_destroy?n.$$.on_destroy.push(...s):ii(s),n.$$.on_mount=[]}),r.forEach(Xl)}function jt(n,e){const t=n.$$;t.fragment!==null&&(pv(t.after_update),ii(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}
1function gv(n,e){n.$$.dirty[0]===-1&&(sr.push(n),xp(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<<e%31}function Nr(n,e,t,i,r,s,o=null,a=[-1]){const l=ms;cs(n);const h=n.$$={fragment:null,ctx:[],props:s,update:Gn,not_equal:r,bound:Nu(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(l?l.$$.context:[])),callbacks:Nu(),dirty:a,skip_bound:!1,root:e.target||l.$$.root};o&&o(h.root);let u=!1;if(h.ctx=t?t(n,e.props||{},(c,d,...f)=>{const p=f.length?f[0]:d;return h.ctx&&r(h.ctx[c],h.ctx[c]=p)&&(!h.skip_bound&&h.bound[c]&&h.bound[c](p),u&&gv(n,c)),d}):[],h.update(),u=!0,ii(h.before_update),h.fragment=i?i(h.ctx):!1,e.target){if(e.hydrate){const c=cv(e.target);h.fragment&&h.fragment.l(c),c.forEach(Be)}else h.fragment&&h.fragment.c();e.intro&&je(n.$$.fragment),Vt(n,e.target,e.anchor),wp()}cs(l)}class kr{constructor(){Fu(this,"$$"),Fu(this,"$$set")}$destroy(){jt(this,1),this.$destroy=Gn}$on(e,t){if(!ut(t))return Gn;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}$set(e){this.$$set&&!ov(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const mv="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(mv);var Si=(n=>(n.ELLIPSE="ELLIPSE",n.MULTIPOLYGON="MULTIPOLYGON",n.POLYGON="POLYGON",n.POLYLINE="POLYLINE",n.RECTANGLE="RECTANGLE",n.LINE="LINE",n))(Si||{}),vv={exports:{}};(function(n){(function(){function e(a,l){var h=a.x-l.x,u=a.y-l.y;return h*h+u*u}function t(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],e(c,h)>l&&(u.push(c),h=c);return h!==c&&u.push(c),u}function r(a,l,h,u,c){for(var d=u,f,p=l+1;p<h;p++){var g=t(a[p],a[l],a[h]);g>d&&(f=p,d=g)}d>u&&(f-l>1&&r(a,l,f,u,c),c.push(a[f]),h-f>1&&r(a,f,h,u,c))}function s(a,l){var h=a.length-1,u=[a[0]];return r(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=s(a,u),a}n.exports=o,n.exports.default=o})()})(vv);const Ur=(n,e)=>e,Bi=n=>{let e=1/0,t=1/0,i=-1/0,r=-1/0;return n.forEach(([s,o])=>{e=Math.min(e,s),t=Math.min(t,o),i=Math.max(i,s),r=Math.max(r,o)}),{minX:e,minY:t,maxX:i,maxY:r}},Bo=n=>{let e=0,t=n.length-1;for(let i=0;i<n.length;i++)e+=(n[t][0]+n[i][0])*(n[t][1]-n[i][1]),t=i;return Math.abs(.5*e)},Fo=(n,e,t)=>{let i=!1;for(let r=0,s=n.length-1;r<n.length;s=r++){const o=n[r][0],a=n[r][1],l=n[s][0],h=n[s][1];a>t!=h>t&&e<(l-o)*(t-a)/(h-a)+o&&(i=!i)}return i},yv=(n,e=!0)=>{let t="M ";return n.forEach(([i,r],s)=>{s===0?t+=`${i},${r}`:t+=` L ${i},${r}`}),e&&(t+=" Z"),t},xv=(n,e)=>{const t=Math.abs(e[0]-n[0]),i=Math.abs(e[1]-n[1]);return Math.sqrt(Math.pow(t,2)+Math.pow(i,2))},_v={area:n=>Math.PI*n.geometry.rx*n.geometry.ry,intersects:(n,e,t)=>{const{cx:i,cy:r,rx:s,ry:o}=n.geometry,a=0,l=Math.cos(a),h=Math.sin(a),u=e-i,c=t-r,d=l*u+h*c,f=h*u-l*c;return d*d/(s*s)+f*f/(o*o)<=1}};Ur(Si.ELLIPSE,_v);const wv={area:n=>0,intersects:(n,e,t,i=2)=>{const[[r,s],[o,a]]=n.geometry.points,l=Math.abs((a-s)*e-(o-r)*t+o*s-a*r),h=xv([r,s],[o,a]);return l/h<=i}};Ur(Si.LINE,wv);const Tv={area:n=>{const{polygons:e}=n.geometry;return e.reduce((t,i)=>{const[r,...s]=i.rings,o=Bo(r.points),a=s.reduce((l,h)=>l+Bo(h.points),0);return t+o-a},0)},intersects:(n,e,t)=>{const{polygons:i}=n.geometry;for(const r of i){const[s,...o]=r.rings;if(Fo(s.points,e,t)){let a=!1;for(const l of o)if(Fo(l.points,e,t)){a=!0;break}if(!a)return!0}}return!1}},La=n=>{const e=n.reduce((t,i)=>[...t,...i.rings[0].points],[]);return Bi(e)},Kn=n=>n.rings.map(e=>yv(e.points)).join(" "),Ev=n=>n.polygons.reduce((e,t)=>[...e,...t.rings.reduce((i,r)=>[...i,...r.points],[])],[]);Ur(Si.MULTIPOLYGON,Tv);const bv={area:n=>{const e=n.geometry.points;return Bo(e)},intersects:(n,e,t)=>{const i=n.geometry.points;return Fo(i,e,t)}};Ur(Si.POLYGON,bv);const Sv={area:n=>{const e=n.geometry;if(!e.closed||e.points.length<3)return 0;const t=Vu(e.points,e.closed);return Bo(t)},intersects:(n,e,t,i=2)=>{const r=n.geometry;if(r.closed){const s=Vu(r.points,r.closed);return Fo(s,e,t)}else return Av(r,[e,t],i)}},Vu=(n,e=!1)=>{const t=[];for(let i=0;i<n.length;i++){const r=n[i],s=n[(i+1)%n.length];if(t.push(r.point),(i<n.length-1||e)&&(r.type==="CURVE"||s.type=="CURVE")){const o=Tp(r.point,r.type==="CURVE"&&r.outHandle||r.point,s.type==="CURVE"&&s.inHandle||s.point,s.point,10);t.push(...o.slice(1))}}return t},Tp=(n,e,t,i,r=10)=>{const s=[];for(let o=0;o<=r;o++){const a=o/r,l=Math.pow(1-a,3)*n[0]+3*Math.pow(1-a,2)*a*e[0]+3*(1-a)*Math.pow(a,2)*t[0]+Math.pow(a,3)*i[0],h=Math.pow(1-a,3)*n[1]+3*Math.pow(1-a,2)*a*e[1]+3*(1-a)*Math.pow(a,2)*t[1]+Math.pow(a,3)*i[1];s.push([l,h])}return s},Av=(n,e,t)=>{for(let i=0;i<n.points.length-1;i++){const r=n.points[i],s=n.points[i+1];if(r.type==="CURVE"||s.type==="CURVE"){const o=Tp(r.point,r.type==="CURVE"&&r.outHandle||r.point,s.type==="CURVE"&&s.inHandle||s.point,s.point,20);for(let a=0;a<o.length-1;a++)if(ju(e,o[a],o[a+1])<=t)return!0}else if(ju(e,r.point,s.point)<=t)return!0}return!1},ju=(n,e,t)=>{const[i,r]=n,[s,o]=e,[a,l]=t,h=a-s,u=l-o,c=Math.sqrt(h*h+u*u);
1if(c===0)return Math.sqrt((i-s)*(i-s)+(r-o)*(r-o));const d=((i-s)*h+(r-o)*u)/(c*c);return d<=0?Math.sqrt((i-s)*(i-s)+(r-o)*(r-o)):d>=1?Math.sqrt((i-a)*(i-a)+(r-l)*(r-l)):Math.abs((l-o)*i-(a-s)*r+a*o-l*s)/c};Ur(Si.POLYLINE,Sv);const Rv={area:n=>n.geometry.w*n.geometry.h,intersects:(n,e,t)=>{const i=n.geometry;if(i.rot){const r=i.x+i.w/2,s=i.y+i.h/2,o=e-r,a=t-s,l=Math.cos(i.rot),h=Math.sin(i.rot),u=o*l+a*h,c=-o*h+a*l;return u>=-i.w/2&&u<=i.w/2&&c>=-i.h/2&&c<=i.h/2}else return e>=i.x&&e<=i.x+i.w&&t>=i.y&&t<=i.y+i.h}};Ur(Si.RECTANGLE,Rv);const Pv=[];for(let n=0;n<256;++n)Pv.push((n+256).toString(16).slice(1));globalThis.nanostoresGlobal||(globalThis.nanostoresGlobal={epoch:0});const Cv=[];for(let n=0;n<256;++n)Cv.push((n+256).toString(16).slice(1));let Iv="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",Mv=(n=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(n|=0));for(;n--;)e+=Iv[t[n]&63];return e};globalThis.ANNOTORIOUS_PRESENCE_KEY||(globalThis.ANNOTORIOUS_PRESENCE_KEY=Mv());const Dv=(n,e)=>{const{left:t,top:i,width:r,height:s}=n.getBoundingClientRect();return[(e.clientX-t)*(n.clientWidth/r),(e.clientY-i)*(n.clientHeight/s)]},$h=(n,e=0)=>{const{minX:t,minY:i,maxX:r,maxY:s}=n;return{x:t-e,y:i-e,w:r-t+2*e,h:s-i+2*e}},on=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,Ov=n=>({}),Xu=n=>({grab:n[0]});function Lv(n){let e,t,i,r;const s=n[8].default,o=av(s,n,n[7],Xu);return{c(){e=Ie("g"),o&&o.c(),U(e,"class","a9s-annotation selected")},m(a,l){Ne(a,e,l),o&&o.m(e,null),t=!0,i||(r=[We(e,"pointerup",n[2]),We(e,"pointermove",n[1])],i=!0)},p(a,[l]){o&&o.p&&(!t||l&128)&&hv(o,s,a,a[7],t?lv(s,a[7],l,Ov):uv(a[7]),Xu)},i(a){t||(je(o,a),t=!0)},o(a){Qe(o,a),t=!1},d(a){a&&Be(e),o&&o.d(a),i=!1,ii(r)}}}function Bv(n,e,t){let{$$slots:i={},$$scope:r}=e;const s=qh();let{shape:o}=e,{editor:a}=e,{transform:l}=e,{svgEl:h}=e,u,c,d;const f=v=>m=>{if(u=v,h){const[x,y]=Dv(h,m);c=l.elementToImage(x,y)}else{const{offsetX:x,offsetY:y}=m;c=l.elementToImage(x,y)}d=o,m.target.setPointerCapture(m.pointerId),s("grab",m)},p=v=>{if(u){const[m,x]=l.elementToImage(v.offsetX,v.offsetY),y=[m-c[0],x-c[1]];t(3,o=a(d,u,y)),s("change",o)}},g=v=>{v.target.releasePointerCapture(v.pointerId),u=void 0,d=o,s("release",v)};return n.$$set=v=>{"shape"in v&&t(3,o=v.shape),"editor"in v&&t(4,a=v.editor),"transform"in v&&t(5,l=v.transform),"svgEl"in v&&t(6,h=v.svgEl),"$$scope"in v&&t(7,r=v.$$scope)},[f,p,g,o,a,l,h,r,i]}let Zh=class extends kr{constructor(e){super(),Nr(this,e,Bv,Lv,Fr,{shape:3,editor:4,transform:5,svgEl:6})}};function Fv(n){let e,t,i,r,s,o,a,l,h=n[3]&&Wu(n);return{c(){e=Ie("g"),t=Ie("circle"),h&&h.c(),r=Ie("circle"),U(t,"class","a9s-handle-buffer svelte-qtyc7s"),U(t,"cx",n[0]),U(t,"cy",n[1]),U(t,"r",i=n[5]+6/n[2]),U(t,"role","button"),U(t,"tabindex","0"),U(r,"class",s=Uu(`a9s-handle-dot${n[3]?" selected":""}`)+" svelte-qtyc7s"),U(r,"cx",n[0]),U(r,"cy",n[1]),U(r,"r",n[5]),U(e,"class",o=`a9s-handle ${n[8].class||""}`.trim())},m(u,c){Ne(u,e,c),Ke(e,t),h&&h.m(e,null),Ke(e,r),a||(l=[We(t,"dblclick",n[12]),We(t,"pointerenter",n[13]),We(t,"pointerleave",n[14]),We(t,"pointerdown",n[15]),We(t,"pointerdown",n[6]),We(t,"pointerup",n[16]),We(t,"pointerup",n[7])],a=!0)},p(u,c){c&1&&U(t,"cx",u[0]),c&2&&U(t,"cy",u[1]),c&36&&i!==(i=u[5]+6/u[2])&&U(t,"r",i),u[3]?h?h.p(u,c):(h=Wu(u),h.c(),h.m(e,r)):h&&(h.d(1),h=null),c&8&&s!==(s=Uu(`a9s-handle-dot${u[3]?" selected":""}`)+" svelte-qtyc7s")&&U(r,"class",s),c&1&&U(r,"cx",u[0]),c&2&&U(r,"cy",u[1]),c&32&&U(r,"r",u[5]),c&256&&o!==(o=`a9s-handle ${u[8].class||""}`.trim())&&U(e,"class",o)},d(u){u&&Be(e),h&&h.d(),a=!1,ii(l)}}}function Nv(n){let e,t,i,r,s,o,a,l,h;return{c(){e=Ie("g"),t=Ie("circle"),r=Ie("circle"),o=Ie("circle"),U(t,"cx",n[0]),U(t,"cy",n[1]),U(t,"r",i=n[5]*10),U(t,"class","a9s-touch-halo"),Hu(t,"touched",n[4]),U(r,"cx",n[0]),U(r,"cy",n[1]),U(r,"r",s=n[5]+10/n[2]),U(r,"class","a9s-handle-buffer svelte-qtyc7s"),U(r,"role","button"),U(r,"tabindex","0"),U(o,"class","a9s-handle-dot"),U(o,"cx",n[0]),U(o,"cy",n[1]),U(o,"r",a=n[5]+2/n[2]),U(e,"class","a9s-touch-handle")},m(u,c){Ne(u,e,c),Ke(e,t),Ke(e,r),Ke(e,o),l||(h=[We(r,"dblclick",n[9]),We(r,"pointerdown",n[10]),We(r,"pointerdown",n[6]),We(r,"pointerup",n[11]),We(r,"pointerup",n[7])],l=!0)},p(u,c){c&1&&U(t,"cx",u[0]),c&2&&U(t,"cy",u[1]),c&32&&i!==(i=u[5]*10)&&U(t,"r",i),c&16&&Hu(t,"touched",u[4]),c&1&&U(r,"cx",u[0]),c&2&&U(r,"cy",u[1]),c&36&&s!==(s=u[5]+10/u[2])&&U(r,"r",s),c&1&&U(o,"cx",u[0]),c&2&&U(o,"cy",u[1]),c&36&&a!==(a=u[5]+2/u[2])&&U(o,"r",a)},d(u){u&&Be(e),l=!1,ii(h)}}}function Wu(n){let e,t;return{c(){e=Ie("circle"),U(e,"class","a9s-handle-selected"),U(e,"cx",n[0]),U(e,"cy",n[1]),U(e,"r",t=n[5]+8/n[2])},m(i,r){Ne(i,e,r)},p(i,r){r&1&&U(e,"cx",i[0]),r&2&&U(e,"cy",i[1]),r&36&&t!==(t=i[5]+8/i[2])&&U(e,"r",t)},d(i){i&&Be(e)}}}function kv(n){let e;function t(r,s){return on?Nv:Fv}let i=t()(n);return{c(){i.c(),e=Os()},m(r,s){i.m(r,s),Ne(r,e,s)},p(r,[s]){i.p(r,s)},i:Gn,o:Gn,d(r){r&&Be(e),i.d(r)}}}function Uv(n,e,t){let i,{x:r}=e,{y:s}=e,{scale:o}=e,{selected:a=void 0}=e,l=!1;const h=y=>{y.pointerType==="touch"&&t(4,l=!0)},u=()=>t(4,l=!1);function c(y){xt.call(this,n,y)}function d(y){xt.call(this,n,y)}function f(y){xt.call(this,n,y)}function p(y){xt.call(this,n,y)}function g(y){xt.call(this,n,y)}function v(y){xt.call(this,n,y)}function m(y){xt.call(this,n,y)}function x(y){xt.call(this,n,y)}return n.$$set=y=>{t(8,e=Vl(Vl({},e),ku(y))),"x"in y&&t(0,r=y.x),"y"in y&&t(1,s=y.y),"scale"in y&&t(2,o=y.scale),"selected"in y&&t(3,a=y.selected)},n.$$.update=()=>{n.$$.dirty&4&&t(5,i=4/o)},e=ku(e),[r,s,o,a,l,i,h,u,e,c,d,f,p,g,v,m,x]}let Cn=class extends kr{constructor(e){super(),Nr(this,e,Uv,kv,Fr,{x:0,y:1,scale:2,selected:3})}};function Hv(n){let e,t,i,r,s,o,a;return{c(){e=Ie("g"),t=Ie("circle"),r=Ie("circle"),s=Ie("circle"),U(t,"class","a9s-polygon-midpoint-buffer svelte-12ykj76"),U(t,"cx",n[0]),U(t,"cy",n[1]),U(t,"r",i=1.75*n[2]),U(r,"class","a9s-polygon-midpoint-outer svelte-12ykj76"),U(r,"cx",n[0]),U(r,"cy",n[1]),U(r,"r",n[2]),U(s,"class","a9s-polygon-midpoint-inner svelte-12ykj76"),U(s,"cx",n[0]),U(s,"cy",n[1]),U(s,"r",n[2]),U(e,"class","a9s-polygon-midpoint svelte-12ykj76")},m(l,h){Ne(l,e,h),Ke(e,t),Ke(e,r),Ke(e,s),o||(a=[We(t,"pointerdown",n[5]),We(t,"pointerdown",n[3])],o=!0)},p(l,h){h&1&&U(t,"cx",l[0]),h&2&&U(t,"cy",l[1]),h&4&&i!==(i=1.75*l[2])&&U(t,"r",i),h&1&&U(r,"cx",l[0]),h&2&&U(r,"cy",l[1]),h&4&&U(r,"r",l[2]),h&1&&U(s,"cx",l[0]),h&2&&U(s,"cy",l[1]),h&4&&U(s,"r",l[2])},d(l){l&&Be(e),o=!1,ii(a)}}}function Gv(n){let e;return{c(){e=Ie("circle"),U(e,"cx",n[0]),U(e,"cy",n[1]),U(e,"r",n[2])},m(t,i){Ne(t,e,i)},p(t,i){i&1&&U(e,"cx",t[0]),i&2&&U(e,"cy",t[1]),i&4&&U(e,"r",t[2])},d(t){t&&Be(e)}}}function zv(n){let e;function t(r,s){return on?Gv:Hv}let i=t()(n);return{c(){i.c(),e=Os()},m(r,s){i.m(r,s),Ne(r,e,s)},p(r,[s]){i.p(r,s)},i:Gn,o:Gn,d(r){r&&Be(e),i.d(r)}}}function Vv(n,e,t){let i,{x:r}=e,{y:s}=e,{scale:o}=e;const a=h=>{h.pointerType};function l(h){xt.call(this,n,h)}return n.$$set=h=>{"x"in h&&t(0,r=h.x),"y"in h&&t(1,s=h.y),"scale"in h&&t(4,o=h.scale)}
1,n.$$.update=()=>{n.$$.dirty&16&&t(2,i=4/o)},[r,s,i,a,o,l]}let Ep=class extends kr{constructor(e){super(),Nr(this,e,Vv,zv,Fr,{x:0,y:1,scale:4})}};function Ba(n){const e=n.slice(),t=e[10][e[6]];return e[28]=t.point,e}function Yu(n,e,t){const i=n.slice();return i[28]=e[t],i[30]=t,i}function Fa(n){const e=n.slice(),t=e[10][e[6]];return e[28]=t.point,e}function Na(n){const e=n.slice(),t=e[10][e[6]];return e[28]=t.point,e}function qu(n){let e,t,i,r;return{c(){e=Ie("circle"),U(e,"cx",t=n[28][0]),U(e,"cy",i=n[28][1]),U(e,"r",r=vs/n[3]),U(e,"class","svelte-1h2slbm")},m(s,o){Ne(s,e,o)},p(s,o){o[0]&1088&&t!==(t=s[28][0])&&U(e,"cx",t),o[0]&1088&&i!==(i=s[28][1])&&U(e,"cy",i),o[0]&8&&r!==(r=vs/s[3])&&U(e,"r",r)},d(s){s&&Be(e)}}}function $u(n){let e,t,i,r,s,o,a,l,h,u;return{c(){e=Ie("mask"),t=Ie("rect"),a=Ie("circle"),U(t,"x",i=n[9].x),U(t,"y",r=n[9].y),U(t,"width",s=n[9].w),U(t,"height",o=n[9].h),U(t,"class","svelte-1h2slbm"),U(a,"cx",l=n[28][0]),U(a,"cy",h=n[28][1]),U(a,"r",u=vs/n[3]),U(a,"class","svelte-1h2slbm"),U(e,"id",`${n[19]}-inner`),U(e,"class","a9s-polygon-editor-mask svelte-1h2slbm")},m(c,d){Ne(c,e,d),Ke(e,t),Ke(e,a)},p(c,d){d[0]&512&&i!==(i=c[9].x)&&U(t,"x",i),d[0]&512&&r!==(r=c[9].y)&&U(t,"y",r),d[0]&512&&s!==(s=c[9].w)&&U(t,"width",s),d[0]&512&&o!==(o=c[9].h)&&U(t,"height",o),d[0]&1088&&l!==(l=c[28][0])&&U(a,"cx",l),d[0]&1088&&h!==(h=c[28][1])&&U(a,"cy",h),d[0]&8&&u!==(u=vs/c[3])&&U(a,"r",u)},d(c){c&&Be(e)}}}function Zu(n){let e,t;return e=new Cn({props:{class:"a9s-corner-handle",x:n[28][0],y:n[28][1],scale:n[3],selected:n[8].includes(n[30])}}),e.$on("pointerenter",n[11]),e.$on("pointerleave",n[12]),e.$on("pointerdown",n[15]),e.$on("pointerdown",function(){ut(n[27](`HANDLE-${n[30]}`))&&n[27](`HANDLE-${n[30]}`).apply(this,arguments)}),e.$on("pointerup",n[16](n[30])),{c(){Zt(e.$$.fragment)},m(i,r){Vt(e,i,r),t=!0},p(i,r){n=i;const s={};r[0]&32&&(s.x=n[28][0]),r[0]&32&&(s.y=n[28][1]),r[0]&8&&(s.scale=n[3]),r[0]&256&&(s.selected=n[8].includes(n[30])),e.$set(s)},i(i){t||(je(e.$$.fragment,i),t=!0)},o(i){Qe(e.$$.fragment,i),t=!1},d(i){jt(e,i)}}}function Ku(n){let e,t;return e=new Ep({props:{x:n[28][0],y:n[28][1],scale:n[3]}}),e.$on("pointerdown",function(){ut(n[18](n[6]))&&n[18](n[6]).apply(this,arguments)}),{c(){Zt(e.$$.fragment)},m(i,r){Vt(e,i,r),t=!0},p(i,r){n=i;const s={};r[0]&1088&&(s.x=n[28][0]),r[0]&1088&&(s.y=n[28][1]),r[0]&8&&(s.scale=n[3]),e.$set(s)},i(i){t||(je(e.$$.fragment,i),t=!0)},o(i){Qe(e.$$.fragment,i),t=!1},d(i){jt(e,i)}}}function jv(n){let e,t,i,r,s,o,a,l,h,u,c,d,f,p,g,v,m,x,y,E,R,P=n[6]!==void 0&&!n[7]&&qu(Na(n)),S=n[6]!==void 0&&!n[7]&&$u(Fa(n)),L=hn(n[5].points),k=[];for(let V=0;V<L.length;V+=1)k[V]=Zu(Yu(n,L,V));const W=V=>Qe(k[V],1,1,()=>{k[V]=null});let j=n[6]!==void 0&&!n[7]&&Ku(Ba(n));return{c(){e=Ie("defs"),t=Ie("mask"),i=Ie("rect"),l=Ie("polygon"),P&&P.c(),S&&S.c(),u=Lt(),c=Ie("polygon"),f=Lt(),p=Ie("polygon"),v=Lt();for(let V=0;V<k.length;V+=1)k[V].c();m=Lt(),j&&j.c(),x=Os(),U(i,"x",r=n[9].x),U(i,"y",s=n[9].y),U(i,"width",o=n[9].w),U(i,"height",a=n[9].h),U(i,"class","svelte-1h2slbm"),U(l,"points",h=n[5].points.map(Ju).join(" ")),U(l,"class","svelte-1h2slbm"),U(t,"id",`${n[19]}-outer`),U(t,"class","a9s-polygon-editor-mask svelte-1h2slbm"),U(c,"class","a9s-outer"),U(c,"mask",`url(#${n[19]}-outer)`),U(c,"points",d=n[5].points.map(Qu).join(" ")),U(p,"class","a9s-inner a9s-shape-handle"),U(p,"mask",`url(#${n[19]}-inner)`),U(p,"style",n[1]),U(p,"points",g=n[5].points.map(ec).join(" "))},m(V,N){Ne(V,e,N),Ke(e,t),Ke(t,i),Ke(t,l),P&&P.m(t,null),S&&S.m(e,null),Ne(V,u,N),Ne(V,c,N),Ne(V,f,N),Ne(V,p,N),Ne(V,v,N);for(let D=0;D<k.length;D+=1)k[D]&&k[D].m(V,N);Ne(V,m,N),j&&j.m(V,N),Ne(V,x,N),y=!0,E||(R=[We(c,"pointerup",n[14]),We(c,"pointerdown",function(){ut(n[27]("SHAPE"))&&n[27]("SHAPE").apply(this,arguments)}),We(p,"pointermove",n[13]),We(p,"pointerup",n[14]),We(p,"pointerdown",function(){ut(n[27]("SHAPE"))&&n[27]("SHAPE").apply(this,arguments)})],E=!0)},p(V,N){if(n=V,(!y||N[0]&512&&r!==(r=n[9].x))&&U(i,"x",r),(!y||N[0]&512&&s!==(s=n[9].y))&&U(i,"y",s),(!y||N[0]&512&&o!==(o=n[9].w))&&U(i,"width",o),(!y||N[0]&512&&a!==(a=n[9].h))&&U(i,"height",a),(!y||N[0]&32&&h!==(h=n[5].points.map(Ju).join(" ")))&&U(l,"points",h),n[6]!==void 0&&!n[7]?P?P.p(Na(n),N):(P=qu(Na(n)),P.c(),P.m(t,null)):P&&(P.d(1),P=null),n[6]!==void 0&&!n[7]?S?S.p(Fa(n),N):(S=$u(Fa(n)),S.c(),S.m(e,null)):S&&(S.d(1),S=null),(!y||N[0]&32&&d!==(d=n[5].points.map(Qu).join(" ")))&&U(c,"points",d),(!y||N[0]&2)&&U(p,"style",n[1]),(!y||N[0]&32&&g!==(g=n[5].points.map(ec).join(" ")))&&U(p,"points",g),N[0]&134322472){L=hn(n[5].points);let D;for(D=0;D<L.length;D+=1){const A=Yu(n,L,D);k[D]?(k[D].p(A,N),je(k[D],1)):(k[D]=Zu(A),k[D].c(),je(k[D],1),k[D].m(m.parentNode,m))}for(Cr(),D=L.length;D<k.length;D+=1)W(D);Ir()}n[6]!==void 0&&!n[7]?j?(j.p(Ba(n),N),N[0]&192&&je(j,1)):(j=Ku(Ba(n)),j.c(),je(j,1),j.m(x.parentNode,x)):j&&(Cr(),Qe(j,1,1,()=>{j=null}),Ir())},i(V){if(!y){for(let N=0;N<L.length;N+=1)je(k[N]);je(j),y=!0}}
1,o(V){k=k.filter(Boolean);for(let N=0;N<k.length;N+=1)Qe(k[N]);Qe(j),y=!1},d(V){V&&(Be(e),Be(u),Be(c),Be(f),Be(p),Be(v),Be(m),Be(x)),P&&P.d(),S&&S.d(),ha(k,V),j&&j.d(V),E=!1,ii(R)}}}function Xv(n){let e,t;return e=new Zh({props:{shape:n[0],transform:n[2],editor:n[17],svgEl:n[4],$$slots:{default:[jv,({grab:i})=>({27:i}),({grab:i})=>[i?134217728:0]]},$$scope:{ctx:n}}}),e.$on("change",n[20]),e.$on("grab",n[21]),e.$on("release",n[22]),{c(){Zt(e.$$.fragment)},m(i,r){Vt(e,i,r),t=!0},p(i,r){const s={};r[0]&1&&(s.shape=i[0]),r[0]&4&&(s.transform=i[2]),r[0]&16&&(s.svgEl=i[4]),r[0]&134219754|r[1]&1&&(s.$$scope={dirty:r,ctx:i}),e.$set(s)},i(i){t||(je(e.$$.fragment,i),t=!0)},o(i){Qe(e.$$.fragment,i),t=!1},d(i){jt(e,i)}}}const Wv=250,Yv=1e3,qv=12,vs=4.5,Ju=n=>n.join(","),Qu=n=>n.join(","),ec=n=>n.join(",");function $v(n,e,t){let i,r,s;const o=qh();let{shape:a}=e,{computedStyle:l}=e,{transform:h}=e,{viewportScale:u=1}=e,{svgEl:c}=e,d,f=!1,p,g=[];const v=()=>t(7,f=!0),m=()=>t(7,f=!1),x=D=>{if(g.length>0||!r.some(b=>b.visible)){t(6,d=void 0);return}const[A,O]=h.elementToImage(D.offsetX,D.offsetY),B=b=>Math.pow(b[0]-A,2)+Math.pow(b[1]-O,2),G=i.points.reduce((b,H)=>B(H)<B(b)?H:b),Y=r.filter(b=>b.visible).reduce((b,H)=>B(H.point)<B(b.point)?H:b),z=Math.pow(Yv/u,2);B(G)<z||B(Y.point)<z?t(6,d=r.indexOf(Y)):t(6,d=void 0)},y=()=>{document.activeElement!==c&&c.focus()},E=()=>{t(8,g=[]),y()},R=D=>{t(7,f=!0),D.preventDefault(),D.stopPropagation(),p=performance.now()},P=D=>A=>{if(!p||on||performance.now()-p>Wv)return;const O=g.includes(D);A.metaKey||A.ctrlKey||A.shiftKey?O?t(8,g=g.filter(B=>B!==D)):t(8,g=[...g,D]):O&&g.length>1?t(8,g=[D]):O?t(8,g=[]):t(8,g=[D]),y()},S=(D,A,O)=>{y();let B;const G=D.geometry;g.length>1?B=G.points.map(([z,b],H)=>g.includes(H)?[z+O[0],b+O[1]]:[z,b]):A==="SHAPE"?B=G.points.map(([z,b])=>[z+O[0],b+O[1]]):B=G.points.map(([z,b],H)=>A===`HANDLE-${H}`?[z+O[0],b+O[1]]:[z,b]);const Y=Bi(B);return{...D,geometry:{points:B,bounds:Y}}},L=D=>async A=>{A.stopPropagation();const O=[...i.points.slice(0,D+1),r[D].point,...i.points.slice(D+1)],B=Bi(O);o("change",{...a,geometry:{points:O,bounds:B}}),await _p();const G=[...document.querySelectorAll(".a9s-handle")][D+1];if(G!=null&&G.firstChild){const Y=new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:A.clientX,clientY:A.clientY,pointerId:A.pointerId,pointerType:A.pointerType,isPrimary:A.isPrimary,buttons:A.buttons});G.firstChild.dispatchEvent(Y)}},k=()=>{if(i.points.length-g.length<3)return;const D=i.points.filter((O,B)=>!g.includes(B)),A=Bi(D);o("change",{...a,geometry:{points:D,bounds:A}}),t(8,g=[])};Yh(()=>
1{if(on)return;const D=A=>{(A.key==="Delete"||A.key==="Backspace")&&(A.preventDefault(),k())};return c.addEventListener("pointermove",x),c.addEventListener("keydown",D),()=>{c.removeEventListener("pointermove",x),c.removeEventListener("keydown",D)}});const W=`polygon-mask-${Math.random().toString(36).substring(2,12)}`;function j(D){xt.call(this,n,D)}function V(D){xt.call(this,n,D)}function N(D){xt.call(this,n,D)}return n.$$set=D=>{"shape"in D&&t(0,a=D.shape),"computedStyle"in D&&t(1,l=D.computedStyle),"transform"in D&&t(2,h=D.transform),"viewportScale"in D&&t(3,u=D.viewportScale),"svgEl"in D&&t(4,c=D.svgEl)},n.$$.update=()=>{n.$$.dirty[0]&1&&t(5,i=a.geometry),n.$$.dirty[0]&40&&t(10,r=on?[]:i.points.map((D,A)=>{const O=A===i.points.length-1?i.points[0]:i.points[A+1],B=(D[0]+O[0])/2,G=(D[1]+O[1])/2,Y=Math.sqrt(Math.pow(O[0]-B,2)+Math.pow(O[1]-G,2))>qv/u;return{point:[B,G],visible:Y}})),n.$$.dirty[0]&40&&t(9,s=$h(i.bounds,vs/u))},[a,l,h,u,c,i,d,f,g,s,r,v,m,x,E,R,P,S,L,W,j,V,N]}let Zv=class extends kr{constructor(e){super(),Nr(this,e,$v,Xv,Fr,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}};const bp=(n,e,t)=>{const[i,r]=n,[s,o]=e,a=Math.cos(t),l=Math.sin(t),h=i-s,u=r-o;return[s+h*a-u*l,o+h*l+u*a]},Kv=(n,e,t,i,r=0)=>{const s=[[n,e],[n+t,e],[n+t,e+i],[n,e+i]],o=[n+t/2,e+i/2];return s.map(a=>bp(a,o,r))},tc=(n,e)=>{const{x:t,y:i,w:r,h:s,rot:o=0}=n,a=[t+r/2,i+s/2];let l=[t+r/2,i-e];return bp(l,a,o)},Jv=(n,e,t)=>{const i=Math.cos(t),r=Math.sin(t);return[n*i+e*r,-n*r+e*i]},Qv=(n,e,t)=>{const i=n[0]-t[0],r=n[1]-t[1],s=Math.atan2(r,i),o=e[0]-t[0],a=e[1]-t[1];return Math.atan2(a,o)-s},ey=(n,e=10)=>{const t=e*Math.PI/180;return Math.round(n/t)*t};function ty(n){let e,t,i,r,s,o,a,l,h,u,c,d,f,p,g,v,m,x,y,E,R,P,S,L,k,W,j,V,N,D,A,O,B,G,Y,z,b,H,X,$,re,se,ce,ie,ge,de,Te,me,De,it,Je,ht,w,I,q,K,ae,he,J,ye,ee,Ve,Re;return P=new Cn({props:{class:"a9s-rotation-handle",x:n[7][0],y:n[7][1],scale:n[3]}}),P.$on("pointerdown",function(){ut(n[16]("ROTATION"))&&n[16]("ROTATION").apply(this,arguments)}),I=new Cn({props:{class:"a9s-corner-handle-topleft",x:n[6][0][0],y:n[6][0][1],scale:n[3]}}),I.$on("pointerdown",function(){ut(n[16]("TOP_LEFT"))&&n[16]("TOP_LEFT").apply(this,arguments)}),K=new Cn({props:{class:"a9s-corner-handle-topright",x:n[6][1][0],y:n[6][1][1],scale:n[3]}}),K.$on("pointerdown",function(){ut(n[16]("TOP_RIGHT"))&&n[16]("TOP_RIGHT").apply(this,arguments)}),he=new Cn({props:{class:"a9s-corner-handle-bottomright",x:n[6][2][0],y:n[6][2][1],scale:n[3]}}),he.$on("pointerdown",function(){ut(n[16]("BOTTOM_RIGHT"))&&n[16]("BOTTOM_RIGHT").apply(this,arguments)}),ye=new Cn({props:{class:"a9s-corner-handle-bottomleft",x:n[6][3][0],y:n[6][3][1],scale:n[3]}}),ye.$on("pointerdown",function(){ut(n[16]("BOTTOM_LEFT"))&&n[16]("BOTTOM_LEFT").apply(this,arguments)}),{c(){e=Ie("defs"),t=Ie("mask"),i=Ie("rect"),l=Ie("polygon"),u=Lt(),c=Ie("g"),d=Ie("line"),m=Ie("line"),Zt(P.$$.fragment),S=Lt(),L=Ie("g"),k=Ie("polygon"),j=Ie("polygon"),N=Lt(),D=Ie("line"),Y=Lt(),z=Ie("line"),re=Lt(),se=Ie("line"),Te=Lt(),me=Ie("line"),w=Lt(),Zt(I.$$.fragment),q=Lt(),Zt(K.$$.fragment),ae=Lt(),Zt(he.$$.fragment),J=Lt(),Zt(ye.$$.fragment),U(i,"class","rect-mask-bg svelte-1bwhzbc"),U(i,"x",r=n[5].x),U(i,"y",s=n[5].y),U(i,"width",o=n[5].w),U(i,"height",a=n[5].h),U(l,"class","rect-mask-fg svelte-1bwhzbc"),U(l,"points",h=n[6].map(ic).join(" ")),U(t,"id",n[9]),U(t,"class","a9s-rectangle-editor-mask svelte-1bwhzbc"),U(d,"class","a9s-rotation-handle-line-bg"),U(d,"x1",f=n[6][0][0]+(n[6][1][0]-n[6][0][0])/2),U(d,"y1",p=n[6][0][1]+(n[6][1][1]-n[6][0][1])/2),U(d,"x2",g=n[7][0]),U(d,"y2",v=n[7][1]),U(d,"pointer-events","none"),U(m,"class","a9s-rotation-handle-line-fg"),U(m,"x1",x=n[6][0][0]+(n[6][1][0]-n[6][0][0])/2),U(m,"y1",y=n[6][0][1]+(n[6][1][1]-n[6][0][1])/2),U(m,"x2",E=n[7][0]),U(m,"y2",R=n[7][1]),U(m,"pointer-events","none"),U(c,"class","a9s-rotation-handle-group"),U(k,"class","a9s-outer"),U(k,"mask",`url(#${n[9]})`),U(k,"points",W=n[6].map(nc).join(" ")),U(j,"class","a9s-inner a9s-shape-handle"),U(j,"style",n[1]),U(j,"points",V=n[6].map(rc).join(" ")),U(D,"class","a9s-edge-handle a9s-edge-handle-top"),U(D,"x1",A=n[6][0][0]),U(D,"y1",O=n[6][0][1]),U(D,"x2",B=n[6][1][0]),U(D,"y2",G=n[6][1][1]),U(z,"class","a9s-edge-handle a9s-edge-handle-right"),U(z,"x1",b=n[6][1][0]),U(z,"y1",H=n[6][1][1]),U(z,"x2",X=n[6][2][0]),U(z,"y2",$=n[6][2][1]),U(se,"class","a9s-edge-handle a9s-edge-handle-bottom"),U(se,"x1",ce=n[6][2][0]),U(se,"y1",ie=n[6][2][1]),U(se,"x2",ge=n[6][3][0]),U(se,"y2",de=n[6][3][1]),U(me,"class","a9s-edge-handle a9s-edge-handle-left"),U(me,"x1",De=n[6][3][0]),U(me,"y1",it=n[6][3][1]),U(me,"x2",Je=n[6][0][0]),U(me,"y2",ht=n[6][0][1])},m(Q,_){Ne(Q,e,_),Ke(e,t),Ke(t,i),Ke(t,l),Ne(Q,u,_),Ne(Q,c,_),Ke(c,d),Ke(c,m),Vt(P,c,null),Ne(Q,S,_),Ne(Q,L,_),Ke(L,k),Ke(L,j),Ne(Q,N,_),Ne(Q,D,_),Ne(Q,Y,_),Ne(Q,z,_),Ne(Q,re,_),Ne(Q,se,_),Ne(Q,Te,_),Ne(Q,me,_),Ne(Q,w,_),Vt(I,Q,_),Ne(Q,q,_),Vt(K,Q,_),Ne(Q,ae,_),Vt(he,Q,_),Ne(Q,J,_),Vt(ye,Q,_),ee=!0,Ve||(Re=[We(k,"pointerdown",function(){ut(n[16]("SHAPE"))&&n[16]("SHAPE").apply(this,arguments)}),We(j,"pointerdown",function(){ut(n[16]("SHAPE"))&&n[16]("SHAPE").apply(this,arguments)}),We(D,"pointerdown",function(){ut(n[16]("TOP"))&&n[16]("TOP").apply(this,arguments)}),We(z,"pointerdown",function(){ut(n[16]("RIGHT"))&&n[16]("RIGHT").apply(this,arguments)}),We(se,"pointerdown",function(){ut(n[16]("BOTTOM"))&&n[16]("BOTTOM").apply(this,arguments)}),We(me,"pointerdown",function(){ut(n[16]("LEFT"))&&n[16]("LEFT").apply(this,arguments)})],Ve=!0)},p(Q,_){n=Q,(!ee||_&32&&r!==(r=n[5].x))&&U(i,"x",r),(!ee||_&32&&s!==(s=n[5].y))&&U(i,"y",s),(!ee||_&32&&o!==(o=n[5].w))&&U(i,"width",o),(!ee||_&32&&a!==(a=n[5].h))&&U(i,"height",a),(!ee||_&64&&h!==(h=n[6].map(ic).join(" ")))&&U(l,"points",h),(!ee||_&64&&f!==(f=n[6][0][0]+(n[6][1][0]-n[6][0][0])/2))&&U(d,"x1",f),(!ee||_&64&&p!==(p=n[6][0][1]+(n[6][1][1]-n[6][0][1])/2))&&U(d,"y1",p),(!ee||_&128&&g!==(g=n[7][0]))&&U(d,"x2",g),(!ee||_&128&&v!==(v=n[7][1]))&&U(d,"y2",v),(!ee||_&64&&x!==(x=n[6][0][0]+(n[6][1][0]-n[6][0][0])/2))&&U(m,"x1",x),(!ee||_&64&&y!==(y=n[6][0][1]+(n[6][1][1]-n[6][0][1])/2))&&U(m,"y1",y),(!ee||_&128&&E!==(E=n[7][0]))&&U(m,"x2",E),(!ee||_&128&&R!==(R=n[7][1]))&&U(m,"y2",R);const T={};_&128&&(T.x=n[7][0]),_&128&&(T.y=n[7][1]),_&8&&(T.scale=n[3]),P.$set(T),(!ee||_&64&&W!==(W=n[6].map(nc).join(" ")))&&U(k,"points",W),(!ee||_&2)&&U(j,"style",n[1]),(!ee||_&64&&V!==(V=n[6].map(rc).join(" ")))&&U(j,"points",V),(!ee||_&64&&A!==(A=n[6][0][0]))&&U(D,"x1",A),(!ee||_&64&&O!==(O=n[6][0][1]))&&U(D,"y1",O),(!ee||_&64&&B!==(B=n[6][1][0]))&&U(D,"x2",B),(!ee||_&64&&G!==(G=n[6][1][1]))&&U(D,"y2",G),(!ee||_&64&&b!==(b=n[6][1][0]))&&U(z,"x1",b),(!ee||_&64&&H!==(H=n[6][1][1]))&&U(z,"y1",H),(!ee||_&64&&X!==(X=n[6][2][0]))&&U(z,"x2",X),(!ee||_&64&&$!==($=n[6][2][1]))&&U(z,"y2",$),(!ee||_&64&&ce!==(ce=n[6][2][0]))&&U(se,"x1",ce),
1(!ee||_&64&&ie!==(ie=n[6][2][1]))&&U(se,"y1",ie),(!ee||_&64&&ge!==(ge=n[6][3][0]))&&U(se,"x2",ge),(!ee||_&64&&de!==(de=n[6][3][1]))&&U(se,"y2",de),(!ee||_&64&&De!==(De=n[6][3][0]))&&U(me,"x1",De),(!ee||_&64&&it!==(it=n[6][3][1]))&&U(me,"y1",it),(!ee||_&64&&Je!==(Je=n[6][0][0]))&&U(me,"x2",Je),(!ee||_&64&&ht!==(ht=n[6][0][1]))&&U(me,"y2",ht);const M={};_&64&&(M.x=n[6][0][0]),_&64&&(M.y=n[6][0][1]),_&8&&(M.scale=n[3]),I.$set(M);const F={};_&64&&(F.x=n[6][1][0]),_&64&&(F.y=n[6][1][1]),_&8&&(F.scale=n[3]),K.$set(F);const Z={};_&64&&(Z.x=n[6][2][0]),_&64&&(Z.y=n[6][2][1]),_&8&&(Z.scale=n[3]),he.$set(Z);const ne={};_&64&&(ne.x=n[6][3][0]),_&64&&(ne.y=n[6][3][1]),_&8&&(ne.scale=n[3]),ye.$set(ne)},i(Q){ee||(je(P.$$.fragment,Q),je(I.$$.fragment,Q),je(K.$$.fragment,Q),je(he.$$.fragment,Q),je(ye.$$.fragment,Q),ee=!0)},o(Q){Qe(P.$$.fragment,Q),Qe(I.$$.fragment,Q),Qe(K.$$.fragment,Q),Qe(he.$$.fragment,Q),Qe(ye.$$.fragment,Q),ee=!1},d(Q){Q&&(Be(e),Be(u),Be(c),Be(S),Be(L),Be(N),Be(D),Be(Y),Be(z),Be(re),Be(se),Be(Te),Be(me),Be(w),Be(q),Be(ae),Be(J)),jt(P),jt(I,Q),jt(K,Q),jt(he,Q),jt(ye,Q),Ve=!1,ii(Re)}}}function iy(n){let e,t;return e=new Zh({props:{shape:n[0],transform:n[2],editor:n[8],svgEl:n[4],$$slots:{default:[ty,({grab:i})=>({16:i}),({grab:i})=>i?65536:0]},$$scope:{ctx:n}}}),e.$on("grab",n[12]),e.$on("change",n[13]),e.$on("release",n[14]),{c(){Zt(e.$$.fragment)},m(i,r){Vt(e,i,r),t=!0},p(i,[r]){const s={};r&1&&(s.shape=i[0]),r&4&&(s.transform=i[2]),r&16&&(s.svgEl=i[4]),r&196842&&(s.$$scope={dirty:r,ctx:i}),e.$set(s)},i(i){t||(je(e.$$.fragment,i),t=!0)},o(i){Qe(e.$$.fragment,i),t=!1},d(i){jt(e,i)}}}const ic=n=>`${n[0]},${n[1]}`,nc=n=>`${n[0]},${n[1]}`,rc=n=>`${n[0]},${n[1]}`;function ny(n,e,t){let i,r,s,o,a,{shape:l}=e,{computedStyle:h}=e,{transform:u}=e,{viewportScale:c=1}=e,{svgEl:d}=e,f=!1;const p=(y,E,R)=>{let{x:P,y:S,w:L,h:k,rot:W=0}=y.geometry;const[j,V]=R;if(E==="ROTATION"){const D=tc(y.geometry,i),A=D[0]+j,O=D[1]+V,B=[P+L/2,S+k/2];W+=Qv([D[0],D[1]],[A,O],B),f&&(W=ey(W));const G=2*Math.PI;W=(W%G+G)%G}else if(E==="SHAPE")P+=j,S+=V;else{let D=0,A=0,O=L,B=k;const[G,Y]=W!==0?Jv(j,V,W):[j,V];switch(E){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":A+=Y;break;case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":B+=Y;break}switch(E){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":D+=G;break;case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":O+=G;break}const z=(D+O)/2,b=(A+B)/2;L=Math.abs(O-D),k=Math.abs(B-A);const H=[P+y.geometry.w/2,S+y.geometry.h/2],X=[z-y.geometry.w/2,b-y.geometry.h/2],$=Math.cos(W),re=Math.sin(W),se=H[0]+X[0]*$-X[1]*re,ce=H[1]+X[0]*re+X[1]*$;P=se-L/2,S=ce-k/2}const N=Bi(s);return{...y,geometry:{x:P,y:S,w:L,h:k,rot:W,bounds:N}}};Yh(()=>{const y=R=>{R.key==="Shift"&&(f=!0)},E=R=>{R.key==="Shift"&&(f=!1)};return window.addEventListener("keydown",y),window.addEventListener("keyup",E),()=>{window.removeEventListener("keydown",y),window.removeEventListener("keyup",E)}});const g=`rect-mask-${Math.random().toString(36).substring(2,12)}`;function v(y){xt.call(this,n,y)}function m(y){xt.call(this,n,y)}function x(y){xt.call(this,n,y)}return n.$$set=y=>{"shape"in y&&t(0,l=y.shape),"computedStyle"in y&&t(1,h=y.computedStyle),"transform"in y&&t(2,u=y.transform),"viewportScale"in y&&t(3,c=y.viewportScale),"svgEl"in y&&t(4,d=y.svgEl)},n.$$.update=()=>{n.$$.dirty&8&&t(11,i=20/c),n.$$.dirty&1&&t(10,r=l.geometry),n.$$.dirty&1024&&t(6,s=Kv(r.x,r.y,r.w,r.h,r.rot)),n.$$.dirty&3072&&t(7,o=tc(r,i)),n.$$.dirty&1032&&t(5,a=$h(r.bounds,5/c))},[l,h,u,c,d,a,s,o,p,g,r,i,v,m,x]}class ry extends kr{constructor(e){super(),Nr(this,e,ny,iy,Fr,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4})}}var sc=Object.prototype.hasOwnProperty;function Wl(n,e){var t,i;if(n===e)return!0;if(n&&e&&(t=n.constructor)===e.constructor){if(t===Date)return n.getTime()===e.getTime();if(t===RegExp)return n.toString()===e.toString();if(t===Array){if((i=n.length)===e.length)for(;i--&&Wl(n[i],e[i]););return i===-1}if(!t||typeof n=="object"){i=0;for(t in n)if(sc.call(n,t)&&++i&&!sc.call(e,t)||!(t in e)||!Wl(n[t],e[t]))return!1;return Object.keys(e).length===i}}return n!==n&&e!==e}const sy=12,oy=(n,e)=>n.polygons.reduce((t,i,r)=>{const s=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,g=Math.sqrt(Math.pow(d[0]-f,2)+Math.pow(d[1]-p,2))>sy/e;return{point:[f,p],visible:g,elementIdx:r,ringIdx:l,pointIdx:c}});return[...o,...h]},[]);return[...t,...s]},[]);function ka(n){const e=n.slice(),t=e[10][e[6]];return e[29]=t.point,e}function oc(n,e,t){const i=n.slice();return i[30]=e[t],i[32]=t,i}function ac(n,e,t){const i=n.slice();return i[33]=e[t],i[35]=t,i}function lc(n,e,t){const i=n.slice();return i[29]=e[t],i[37]=t,i}function Ua(n){const e=n.slice(),t=e[10][e[6]];return e[29]=t.point,e}function Ha(n){const e=n.slice(),t=e[10][e[6]];return e[29]=t.point,e}function hc(n){let e,t,i,r;return{c(){e=Ie("circle"),U(e,"cx",t=n[29][0]),U(e,"cy",i=n[29][1]),U(e,"r",r=ys/n[3]),U(e,"class","svelte-1vxo6dc")},m(s,o){Ne(s,e,o)},p(s,o){o[0]&1088&&t!==(t=s[29][0])&&U(e,"cx",t),o[0]&1088&&i!==(i=s[29][1])&&U(e,"cy",i),o[0]&8&&r!==(r=ys/s[3])&&U(e,"r",r)},d(s){s&&Be(e)}}}function uc(n){let e,t,i,r,s,o,a,l,h,u;
1return{c(){e=Ie("mask"),t=Ie("rect"),a=Ie("circle"),U(t,"x",i=n[9].x),U(t,"y",r=n[9].y),U(t,"width",s=n[9].w),U(t,"height",o=n[9].h),U(t,"class","svelte-1vxo6dc"),U(a,"cx",l=n[29][0]),U(a,"cy",h=n[29][1]),U(a,"r",u=ys/n[3]),U(a,"class","svelte-1vxo6dc"),U(e,"id",`${n[18]}-${n[32]}-inner`),U(e,"class","a9s-multipolygon-editor-mask svelte-1vxo6dc")},m(c,d){Ne(c,e,d),Ke(e,t),Ke(e,a)},p(c,d){d[0]&512&&i!==(i=c[9].x)&&U(t,"x",i),d[0]&512&&r!==(r=c[9].y)&&U(t,"y",r),d[0]&512&&s!==(s=c[9].w)&&U(t,"width",s),d[0]&512&&o!==(o=c[9].h)&&U(t,"height",o),d[0]&1088&&l!==(l=c[29][0])&&U(a,"cx",l),d[0]&1088&&h!==(h=c[29][1])&&U(a,"cy",h),d[0]&8&&u!==(u=ys/c[3])&&U(a,"r",u)},d(c){c&&Be(e)}}}function cc(n){let e,t;function i(...r){return n[19](n[32],n[35],n[37],...r)}return e=new Cn({props:{class:"a9s-corner-handle",x:n[29][0],y:n[29][1],scale:n[3],selected:n[8].some(i)}}),e.$on("pointerenter",n[11]),e.$on("pointerleave",n[12]),e.$on("pointerdown",n[14]),e.$on("pointerdown",function(){ut(n[28](`HANDLE-${n[32]}-${n[35]}-${n[37]}`))&&n[28](`HANDLE-${n[32]}-${n[35]}-${n[37]}`).apply(this,arguments)}),e.$on("pointerup",n[15](n[32],n[35],n[37])),{c(){Zt(e.$$.fragment)},m(r,s){Vt(e,r,s),t=!0},p(r,s){n=r;const o={};s[0]&32&&(o.x=n[29][0]),s[0]&32&&(o.y=n[29][1]),s[0]&8&&(o.scale=n[3]),s[0]&256&&(o.selected=n[8].some(i)),e.$set(o)},i(r){t||(je(e.$$.fragment,r),t=!0)},o(r){Qe(e.$$.fragment,r),t=!1},d(r){jt(e,r)}}}function dc(n){let e,t,i=hn(n[33].points),r=[];for(let o=0;o<i.length;o+=1)r[o]=cc(lc(n,i,o));const s=o=>Qe(r[o],1,1,()=>{r[o]=null});return{c(){for(let o=0;o<r.length;o+=1)r[o].c();e=Os()},m(o,a){for(let l=0;l<r.length;l+=1)r[l]&&r[l].m(o,a);Ne(o,e,a),t=!0},p(o,a){if(a[0]&268491048){i=hn(o[33].points);let l;for(l=0;l<i.length;l+=1){const h=lc(o,i,l);r[l]?(r[l].p(h,a),je(r[l],1)):(r[l]=cc(h),r[l].c(),je(r[l],1),r[l].m(e.parentNode,e))}for(Cr(),l=i.length;l<r.length;l+=1)s(l);Ir()}},i(o){if(!t){for(let a=0;a<i.length;a+=1)je(r[a]);t=!0}},o(o){r=r.filter(Boolean);for(let a=0;a<r.length;a+=1)Qe(r[a]);t=!1},d(o){o&&Be(e),ha(r,o)}}}function fc(n){let e,t,i,r,s,o,a,l,h,u,c,d,f,p,g,v,m,x=n[6]!==void 0&&!n[7]&&hc(Ha(n)),y=n[6]!==void 0&&!n[7]&&uc(Ua(n)),E=hn(n[30].rings),R=[];for(let S=0;S<E.length;S+=1)R[S]=dc(ac(n,E,S));const P=S=>Qe(R[S],1,1,()=>{R[S]=null});return{c(){e=Ie("g"),t=Ie("defs"),i=Ie("mask"),r=Ie("rect"),h=Ie("path"),x&&x.c(),y&&y.c(),c=Ie("path"),f=Ie("path");for(let S=0;S<R.length;S+=1)R[S].c();U(r,"x",s=n[9].x),U(r,"y",o=n[9].y),U(r,"width",a=n[9].w),U(r,"height",l=n[9].h),U(r,"class","svelte-1vxo6dc"),U(h,"d",u=Kn(n[30])),U(h,"class","svelte-1vxo6dc"),U(i,"id",`${n[18]}-${n[32]}-outer`),U(i,"class","a9s-multipolygon-editor-mask svelte-1vxo6dc"),U(c,"class","a9s-outer"),U(c,"mask",`url(#${n[18]}-${n[32]}-outer)`),U(c,"fill-rule","evenodd"),U(c,"d",d=Kn(n[30])),U(f,"class","a9s-inner"),U(f,"mask",`url(#${n[18]}-${n[32]}-inner)`),U(f,"style",n[1]),U(f,"fill-rule","evenodd"),U(f,"d",p=Kn(n[30]))},m(S,L){Ne(S,e,L),Ke(e,t),Ke(t,i),Ke(i,r),Ke(i,h),x&&x.m(i,null),y&&y.m(t,null),Ke(e,c),Ke(e,f);for(let k=0;k<R.length;k+=1)R[k]&&R[k].m(e,null);g=!0,v||(m=[We(c,"pointerup",n[13]),We(c,"pointerdown",function(){ut(n[28]("SHAPE"))&&n[28]("SHAPE").apply(this,arguments)}),We(f,"pointerup",n[13]),We(f,"pointerdown",function(){ut(n[28]("SHAPE"))&&n[28]("SHAPE").apply(this,arguments)})],v=!0)},p(S,L){if(n=S,(!g||L[0]&512&&s!==(s=n[9].x))&&U(r,"x",s),(!g||L[0]&512&&o!==(o=n[9].y))&&U(r,"y",o),(!g||L[0]&512&&a!==(a=n[9].w))&&U(r,"width",a),(!g||L[0]&512&&l!==(l=n[9].h))&&U(r,"height",l),(!g||L[0]&32&&u!==(u=Kn(n[30])))&&U(h,"d",u),n[6]!==void 0&&!n[7]?x?x.p(Ha(n),L):(x=hc(Ha(n)),x.c(),x.m(i,null)):x&&(x.d(1),x=null),n[6]!==void 0&&!n[7]?y?y.p(Ua(n),L):(y=uc(Ua(n)),y.c(),y.m(t,null)):y&&(y.d(1),y=null),(!g||L[0]&32&&d!==(d=Kn(n[30])))&&U(c,"d",d),(!g||L[0]&2)&&U(f,"style",n[1]),(!g||L[0]&32&&p!==(p=Kn(n[30])))&&U(f,"d",p),L[0]&268491048){E=hn(n[30].rings);let k;for(k=0;k<E.length;k+=1){const W=ac(n,E,k);
1R[k]?(R[k].p(W,L),je(R[k],1)):(R[k]=dc(W),R[k].c(),je(R[k],1),R[k].m(e,null))}for(Cr(),k=E.length;k<R.length;k+=1)P(k);Ir()}},i(S){if(!g){for(let L=0;L<E.length;L+=1)je(R[L]);g=!0}},o(S){R=R.filter(Boolean);for(let L=0;L<R.length;L+=1)Qe(R[L]);g=!1},d(S){S&&Be(e),x&&x.d(),y&&y.d(),ha(R,S),v=!1,ii(m)}}}function pc(n){let e,t;return e=new Ep({props:{x:n[29][0],y:n[29][1],scale:n[3]}}),e.$on("pointerdown",function(){ut(n[17](n[6]))&&n[17](n[6]).apply(this,arguments)}),{c(){Zt(e.$$.fragment)},m(i,r){Vt(e,i,r),t=!0},p(i,r){n=i;const s={};r[0]&1088&&(s.x=n[29][0]),r[0]&1088&&(s.y=n[29][1]),r[0]&8&&(s.scale=n[3]),e.$set(s)},i(i){t||(je(e.$$.fragment,i),t=!0)},o(i){Qe(e.$$.fragment,i),t=!1},d(i){jt(e,i)}}}function ay(n){let e,t,i,r=hn(n[5].polygons),s=[];for(let l=0;l<r.length;l+=1)s[l]=fc(oc(n,r,l));const o=l=>Qe(s[l],1,1,()=>{s[l]=null});let a=n[6]!==void 0&&!n[7]&&pc(ka(n));return{c(){for(let l=0;l<s.length;l+=1)s[l].c();e=Lt(),a&&a.c(),t=Os()},m(l,h){for(let u=0;u<s.length;u+=1)s[u]&&s[u].m(l,h);Ne(l,e,h),a&&a.m(l,h),Ne(l,t,h),i=!0},p(l,h){if(h[0]&268763114){r=hn(l[5].polygons);let u;for(u=0;
1u<r.length;u+=1){const c=oc(l,r,u);s[u]?(s[u].p(c,h),je(s[u],1)):(s[u]=fc(c),s[u].c(),je(s[u],1),s[u].m(e.parentNode,e))}for(Cr(),u=r.length;u<s.length;u+=1)o(u);Ir()}l[6]!==void 0&&!l[7]?a?(a.p(ka(l),h),h[0]&192&&je(a,1)):(a=pc(ka(l)),a.c(),je(a,1),a.m(t.parentNode,t)):a&&(Cr(),Qe(a,1,1,()=>{a=null}),Ir())},i(l){if(!i){for(let h=0;h<r.length;h+=1)je(s[h]);je(a),i=!0}},o(l){s=s.filter(Boolean);for(let h=0;h<s.length;h+=1)Qe(s[h]);Qe(a),i=!1},d(l){l&&(Be(e),Be(t)),ha(s,l),a&&a.d(l)}}}function ly(n){let e,t;return e=new Zh({props:{shape:n[0],transform:n[2],editor:n[16],svgEl:n[4],$$slots:{default:[ay,({grab:i})=>({28:i}),({grab:i})=>[i?268435456:0]]},$$scope:{ctx:n}}}),e.$on("change",n[20]),e.$on("grab",n[21]),e.$on("release",n[22]),{c(){Zt(e.$$.fragment)},m(i,r){Vt(e,i,r),t=!0},p(i,r){const s={};r[0]&1&&(s.shape=i[0]),r[0]&4&&(s.transform=i[2]),r[0]&16&&(s.svgEl=i[4]),r[0]&268437482|r[1]&128&&(s.$$scope={dirty:r,ctx:i}),e.$set(s)},i(i){t||(je(e.$$.fragment,i),t=!0)},o(i){Qe(e.$$.fragment,i),t=!1},d(i){jt(e,i)}}}const hy=250,uy=1e3,ys=4.5;function cy(n,e,t){let i,r,s;const o=qh();let{shape:a}=e,{computedStyle:l}=e,{transform:h}=e,{viewportScale:u=1}=e,{svgEl:c}=e,d,f=!1,p,g=[];const v=()=>t(7,f=!0),m=()=>t(7,f=!1),x=A=>{if(g.length>0||!r.some(H=>H.visible)){t(6,d=void 0);return}const[O,B]=h.elementToImage(A.offsetX,A.offsetY),G=H=>Math.pow(H[0]-O,2)+Math.pow(H[1]-B,2),Y=Ev(i).reduce((H,X)=>G(X)<G(H)?X:H),z=r.filter(H=>H.visible).reduce((H,X)=>G(X.point)<G(H.point)?X:H),b=Math.pow(uy/u,2);G(Y)<b||G(z.point)<b?t(6,d=r.indexOf(z)):t(6,d=void 0)},y=()=>{document.activeElement!==c&&c.focus()},E=()=>{t(8,g=[]),y()},R=A=>{t(7,f=!0),A.preventDefault(),A.stopPropagation(),p=performance.now()},P=(A,O,B)=>G=>{if(!p||on||performance.now()-p>hy)return;const Y=b=>b.polygon===A&&b.ring===O&&b.point===B,z=g.some(Y);G.metaKey||G.ctrlKey||G.shiftKey?z?t(8,g=g.filter(b=>!Y(b))):t(8,g=[...g,{polygon:A,ring:O,point:B}]):z&&g.length>1?t(8,g=[{polygon:A,ring:O,point:B}]):z?t(8,g=[]):t(8,g=[{polygon:A,ring:O,point:B}]),y()},S=(A,O,B)=>{y();const G=A.geometry.polygons;let Y;if(O==="SHAPE")Y=G.map(z=>{const b=z.rings.map((X,$)=>({points:X.points.map((re,se)=>[re[0]+B[0],re[1]+B[1]])})),H=Bi(b[0].points);return{rings:b,bounds:H}});else{const[z,b,H,X]=O.split("-").map($=>parseInt($));Y=G.map(($,re)=>{if(re===b){const se=$.rings.map((ie,ge)=>ge===H?{points:ie.points.map((de,Te)=>Te===X?[de[0]+B[0],de[1]+B[1]]:de)}:ie),ce=Bi(se[0].points);return{rings:se,bounds:ce}}else return $})}return{...A,geometry:{polygons:Y,bounds:La(Y)}}},L=A=>async O=>{O.stopPropagation();const B=r[A],G=i.polygons.map((z,b)=>{if(b===B.elementIdx){const H=z.rings.map(($,re)=>re===B.ringIdx?{points:[...$.points.slice(0,B.pointIdx+1),B.point,...$.points.slice(B.pointIdx+1)]}:$),X=Bi(H[0].points);return{rings:H,bounds:X}}else return z});o("change",{...a,geometry:{polygons:G,bounds:La(G)}}),await _p();const Y=[...document.querySelectorAll(".a9s-handle")][A+1];if(Y!=null&&Y.firstChild){const z=new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:O.clientX,clientY:O.clientY,pointerId:O.pointerId,pointerType:O.pointerType,isPrimary:O.isPrimary,buttons:O.buttons});Y.firstChild.dispatchEvent(z)}},k=()=>{const A=i.polygons.map((O,B)=>{if(g.some(G=>G.polygon===B)){const G=O.rings.map((z,b)=>{const H=g.filter(X=>X.polygon===B&&X.ring===b);return H.length&&z.points.length-H.length>=3?{points:z.points.filter((X,$)=>!H.some(re=>re.point===$))}:z}),Y=Bi(G[0].points);return{rings:G,bounds:Y}}else return O});!Wl(i.polygons,A)&&(o("change",{...a,geometry:{polygons:A,bounds:La(A)}}),t(8,g=[]))};Yh(()=>
1{if(on)return;const A=O=>{(O.key==="Delete"||O.key==="Backspace")&&(O.preventDefault(),k())};return c.addEventListener("pointermove",x),c.addEventListener("keydown",A),()=>{c.removeEventListener("pointermove",x),c.removeEventListener("keydown",A)}});const W=`polygon-mask-${Math.random().toString(36).substring(2,12)}`,j=(A,O,B,{polygon:G,ring:Y,point:z})=>G===A&&Y===O&&z===B;function V(A){xt.call(this,n,A)}function N(A){xt.call(this,n,A)}function D(A){xt.call(this,n,A)}return n.$$set=A=>{"shape"in A&&t(0,a=A.shape),"computedStyle"in A&&t(1,l=A.computedStyle),"transform"in A&&t(2,h=A.transform),"viewportScale"in A&&t(3,u=A.viewportScale),"svgEl"in A&&t(4,c=A.svgEl)},n.$$.update=()=>{n.$$.dirty[0]&1&&t(5,i=a.geometry),n.$$.dirty[0]&40&&t(10,r=on?[]:oy(i,u)),n.$$.dirty[0]&40&&t(9,s=$h(i.bounds,ys/u))},[a,l,h,u,c,i,d,f,g,s,r,v,m,E,R,P,S,L,W,j,V,N,D]}let dy=class extends kr{constructor(e){super(),Nr(this,e,cy,ly,Fr,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}};Si.RECTANGLE,Si.POLYGON,Si.MULTIPOLYGON;typeof navigator>"u"||navigator.userAgent.indexOf("Mac OS X");var xo={exports:{}},fy=xo.exports,gc;function py(){return gc||(gc=1,(function(n){function e(t){return new e.Viewer(t)}(function(t){t.version={versionStr:"5.0.1",major:parseInt("5",10),minor:parseInt("0",10),revision:parseInt("1",10)};var i={"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object AsyncFunction]":"function","[object Promise]":"promise","[object Array]":"array","[object Date]":"date","[object RegExp]":"regexp","[object Object]":"object"},r=Object.prototype.toString,s=Object.prototype.hasOwnProperty;t.isFunction=function(o){return t.type(o)==="function"},t.isArray=Array.isArray||function(o){return t.type(o)==="array"},t.isWindow=function(o){return o&&typeof o=="object"&&"setInterval"in o},t.type=function(o){return o==null?String(o):i[r.call(o)]||"object"},t.isPlainObject=function(o){if(!o||e.type(o)!=="object"||o.nodeType||t.isWindow(o)||o.constructor&&!s.call(o,"constructor")&&!s.call(o.constructor.prototype,"isPrototypeOf"))return!1;var a;for(var l in o)a=l;return a===void 0||s.call(o,a)},t.isEmptyObject=function(o){for(var a in o)return!1;return!0},t.freezeObject=function(o){return Object.freeze?t.freezeObject=Object.freeze:t.freezeObject=function(a){return a},t.freezeObject(o)},t.supportsCanvas=(function(){var o=document.createElement("canvas");return!!(t.isFunction(o.getContext)&&o.getContext("2d"))})(),t.isCanvasTainted=function(o){var a=!1;try{o.getContext("2d").getImageData(0,0,1,1)}catch{a=!0}return a},t.supportsAddEventListener=(function(){return!!(document.documentElement.addEventListener&&document.addEventListener)})(),t.supportsRemoveEventListener=(function(){return!!(document.documentElement.removeEventListener&&document.removeEventListener)})(),t.supportsEventListenerOptions=(function(){var o=0;if(t.supportsAddEventListener)try{var a={get capture(){return o++,!1},get once(){return o++,!1},get passive(){return o++,!1}};window.addEventListener("test",null,a),window.removeEventListener("test",null,a)}catch{o=0}return o>=3})(),t.getCurrentPixelDensityRatio=function(){if(t.supportsCanvas){var o=document.createElement("canvas").getContext("2d"),a=window.devicePixelRatio||1,l=o.webkitBackingStorePixelRatio||o.mozBackingStorePixelRatio||o.msBackingStorePixelRatio||o.oBackingStorePixelRatio||o.backingStorePixelRatio||1;return Math.max(a,1)/l}else return 1},t.pixelDensityRatio=t.getCurrentPixelDensityRatio()})(e),(function(t){t.extend=function(){var l,h,u,c,d,f,p=arguments[0]||{},g=arguments.length,v=!1,m=1;for(typeof p=="boolean"&&(v=p,p=arguments[1]||{},m=2),typeof p!="object"&&!e.isFunction(p)&&(p={}),g===m&&(p=this,--m);m<g;m++)if(l=arguments[m],l!==null||l!==void 0)for(h in l){var x=Object.getOwnPropertyDescriptor(l,h);if(x!==void 0){if(x.get||x.set){Object.defineProperty(p,h,x);continue}c=x.value}else{t.console.warn('Could not copy inherited property "'+h+'".');continue}p!==c&&(v&&c&&(e.isPlainObject(c)||(d=e.isArray(c)))?(u=p[h],d?(d=!1,f=u&&e.isArray(u)?u:[]):f=u&&e.isPlainObject(u)?u:{},p[h]=e.extend(v,f,c)):c!==void 0&&(p[h]=c))}return p};var i=function(){if(typeof navigator!="object")return!1;var l=navigator.userAgent;return typeof l!="string"?!1:l.indexOf("iPhone")!==-1||l.indexOf("iPad")!==-1||l.indexOf("iPod")!==-1};t.extend(t,{DEFAULT_SETTINGS:{xmlPath:null,tileSources:null,tileHost:null,initialPage:0,crossOriginPolicy:!1,ajaxWithCredentials:!1,loadTilesWithAjax:!1,ajaxHeaders:{},splitHashDataForPost:!1,panHorizontal:!0,panVertical:!0,constrainDuringPan:!1,wrapHorizontal:!1,wrapVertical:!1,visibilityRatio:.5,minPixelRatio:.5,defaultZoomLevel:0,minZoomLevel:null,maxZoomLevel:null,homeFillsViewer:!1,clickTimeThreshold:300,clickDistThreshold:5,dblClickTimeThreshold:300,dblClickDistThreshold:20,springStiffness:6.5,animationTime:1.2,gestureSettingsMouse:{dragToPan:!0,scrollToZoom:!0,clickToZoom:!0,dblClickToZoom:!1,dblClickDragToZoom:!1,pinchToZoom:!1,zoomToRefPoint:!0,flickEnabled:!1,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},gestureSettingsTouch:{dragToPan:!0,scrollToZoom:!1,clickToZoom:!1,dblClickToZoom:!0,dblClickDragToZoom:!0,pinchToZoom:!0,zoomToRefPoint:!0,flickEnabled:!0,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},gestureSettingsPen:{dragToPan:!0,scrollToZoom:!1,clickToZoom:!0,dblClickToZoom:!1,dblClickDragToZoom:!1,pinchToZoom:!1,zoomToRefPoint:!0,flickEnabled:!1,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},gestureSettingsUnknown:{dragToPan:!0,scrollToZoom:!1,clickToZoom:!1,dblClickToZoom:!0,dblClickDragToZoom:!1,pinchToZoom:!0,zoomToRefPoint:!0,flickEnabled:!0,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},zoomPerClick:2,zoomPerScroll:1.2,zoomPerDblClickDrag:1.2,zoomPerSecond:1,blendTime:0,alwaysBlend:!1,autoHideControls:!0,immediateRender:!1,minZoomImageRatio:.9,maxZoomPixelRatio:1.1,smoothTileEdgesMinZoom:1.1,iOSDevice:i(),pixelsPerWheelLine:40,pixelsPerArrowPress:40,autoResize:!0,preserveImageSizeOnResize:!1,minScrollDeltaT
vendor: 7,964 bytes, line 1
1ime:50,rotationIncrement:90,maxTilesPerFrame:1,showSequenceControl:!0,sequenceControlAnchor:null,preserveViewport:!1,preserveOverlays:!1,navPrevNextWrap:!1,showNavigationControl:!0,navigationControlAnchor:null,showZoomControl:!0,showHomeControl:!0,showFullPageControl:!0,showRotationControl:!1,showFlipControl:!1,controlsFadeDelay:2e3,controlsFadeLength:1500,mouseNavEnabled:!0,showNavigator:!1,navigatorElement:null,navigatorId:null,navigatorPosition:null,navigatorSizeRatio:.2,navigatorMaintainSizeRatio:!1,navigatorTop:null,navigatorLeft:null,navigatorHeight:null,navigatorWidth:null,navigatorAutoResize:!0,navigatorAutoFade:!0,navigatorRotate:!0,navigatorBackground:"#000",navigatorOpacity:.8,navigatorBorderColor:"#555",navigatorDisplayRegionColor:"#900",degrees:0,flipped:!1,overlayPreserveContentDirection:!0,opacity:1,compositeOperation:null,drawer:["webgl","canvas","html"],drawerOptions:{webgl:{},canvas:{},html:{},custom:{}},preload:!1,imageSmoothingEnabled:!0,placeholderFillStyle:null,subPixelRoundingForTransparency:null,showReferenceStrip:!1,referenceStripScroll:"horizontal",referenceStripElement:null,referenceStripHeight:null,referenceStripWidth:null,referenceStripPosition:"BOTTOM_LEFT",referenceStripSizeRatio:.2,collectionRows:3,collectionColumns:0,collectionLayout:"horizontal",collectionMode:!1,collectionTileSize:800,collectionTileMargin:80,imageLoaderLimit:0,maxImageCacheCount:200,timeout:3e4,tileRetryMax:0,tileRetryDelay:2500,prefixUrl:"/images/",navImages:{zoomIn:{REST:"zoomin_rest.png",GROUP:"zoomin_grouphover.png",HOVER:"zoomin_hover.png",DOWN:"zoomin_pressed.png"},zoomOut:{REST:"zoomout_rest.png",GROUP:"zoomout_grouphover.png",HOVER:"zoomout_hover.png",DOWN:"zoomout_pressed.png"},home:{REST:"home_rest.png",GROUP:"home_grouphover.png",HOVER:"home_hover.png",DOWN:"home_pressed.png"},fullpage:{REST:"fullpage_rest.png",GROUP:"fullpage_grouphover.png",HOVER:"fullpage_hover.png",DOWN:"fullpage_pressed.png"},rotateleft:{REST:"rotateleft_rest.png",GROUP:"rotateleft_grouphover.png",HOVER:"rotateleft_hover.png",DOWN:"rotateleft_pressed.png"},rotateright:{REST:"rotateright_rest.png",GROUP:"rotateright_grouphover.png",HOVER:"rotateright_hover.png",DOWN:"rotateright_pressed.png"},flip:{REST:"flip_rest.png",GROUP:"flip_grouphover.png",HOVER:"flip_hover.png",DOWN:"flip_pressed.png"},previous:{REST:"previous_rest.png",GROUP:"previous_grouphover.png",HOVER:"previous_hover.png",DOWN:"previous_pressed.png"},next:{REST:"next_rest.png",GROUP:"next_grouphover.png",HOVER:"next_hover.png",DOWN:"next_pressed.png"}},debugMode:!1,debugGridColor:["#437AB2","#1B9E77","#D95F02","#7570B3","#E7298A","#66A61E","#E6AB02","#A6761D","#666666"],silenceMultiImageWarnings:!1},delegate:function(l,h){return function(){var u=arguments;return u===void 0&&(u=[]),h.apply(l,u)}},BROWSERS:{UNKNOWN:0,IE:1,FIREFOX:2,SAFARI:3,CHROME:4,OPERA:5,EDGE:6,CHROMEEDGE:7},SUBPIXEL_ROUNDING_OCCURRENCES:{NEVER:0,ONLY_AT_REST:1,ALWAYS:2},_viewers:new Map,getViewer:function(l){return t._viewers.get(this.getElement(l))},getElement:function(l){return typeof l=="string"&&(l=document.getElementById(l)),l},getElementPosition:function(l){var h=new t.Point,u,c;for(l=t.getElement(l),u=t.getElementStyle(l).position==="fixed",c=a(l,u);c;)h.x+=l.offsetLeft,h.y+=l.offsetTop,u&&(h=h.plus(t.getPageScroll())),l=c,u=t.getElementStyle(l).position==="fixed",c=a(l,u);return h},getElementOffset:function(l){l=t.getElement(l);var h=l&&l.ownerDocument,u,c,d={top:0,left:0};return h?(u=h.documentElement,typeof l.getBoundingClientRect<"u"&&(d=l.getBoundingClientRect()),c=h===h.window?h:h.nodeType===9?h.defaultView||h.parentWindow:!1,new t.Point(d.left+(c.pageXOffset||u.scrollLeft)-(u.clientLeft||0),d.top+(c.pageYOffset||u.scrollTop)-(u.clientTop||0))):new t.Point},getElementSize:function(l){return l=t.getElement(l),new t.Point(l.clientWidth,l.clientHeight)},getElementStyle:document.documentElement.currentStyle?function(l){return l=t.getElement(l),l.currentStyle}:function(l){return l=t.getElement(l),window.getComputedStyle(l,"")},getCssPropertyWithVendorPrefix:function(l){var h={};return t.getCssPropertyWithVendorPrefix=function(u){if(h[u]!==void 0)return h[u];var c=document.createElement("div").style,d=null;if(c[u]!==void 0)d=u;else for(var f=["Webkit","Moz","MS","O","webkit","moz","ms","o"],p=t.capitalizeFirstLetter(u),g=0;g<f.length;g++){var v=f[g]+p;if(c[v]!==void 0){d=v;break}}return h[u]=d,d},t.getCssPropertyWithVendorPrefix(l)},capitalizeFirstLetter:function(l){return l.charAt(0).toUpperCase()+l.slice(1)},positiveModulo:function(l,h){var u=l%h;return u<0&&(u+=h),u},pointInElement:function(l,h){l=t.getElement(l);var u=t.getElementOffset(l),c=t.getElementSize(l);return h.x>=u.x&&h.x<u.x+c.x&&h.y<u.y+c.y&&h.y>=u.y},getMousePosition:function(l){if(typeof l.pageX=="number")t.getMousePosition=function(h){var u=new t.Point;return u.x=h.pageX,u.y=h.pageY,u};else if(typeof l.clientX=="number")t.getMousePosition=function(h){var u=new t.Point;return u.x=h.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,u.y=h.clientY+document.body.scrollTop+document.documentElement.scrollTop,u};else throw new Error("Unknown event mouse position, no known technique.");return t.getMousePosition(l)},getPageScroll:function(){var l=document.documentElement||{},h=document.body||{};if(typeof window.pageXOffset=="number")t.getPageScroll=function(){return new t.Point(window.pageXOffset,window.pageYOffset)};else if(h.scrollLeft||h.scrollTop)t.getPageScroll=function(){return new t.Point(document.body.scrollLeft,document.body.scrollTop)};else if(l.scrollLeft||l.scrollTop)t.getPageScroll=function(){return new t.Point(document.documentElement.scrollLeft,document.documentElement.scrollTop)};else return new t.Point(0,0);return t.getPageScroll()},setPageScroll:function(l){if(typeof window.scrollTo<"u")t.setPageScroll=function(c){window.scrollTo(c.x,c.y)};else{var h=t.getPageScroll();if(h.x===l.x&&h.y===l.y)return;document.body.scrollLeft=l.x,document.body.scrollTop=l.y;var u=t.getPageScroll();if(u.x!==h.x&&u.y!==h.y){t.setPageScroll=function(c){document.body.scrollLeft=c.x,document.body.scrollTop=c.y};return}if(document.documentElement.scrollLeft=l.x,document.documentElement.scrollTop=l.y,u=t.getPageScroll(),u.x!==h.x&&u.y!==h.y){t.setPageScroll=function(c){document.documentElement.scrollLeft=c.x,document.documentElement.scrollTop=c.y};return}t.setPageScroll=function(c){}}t.setPageScroll(l)},getWindowSize:function(){var l=document.documentElement||{},h=document.body||{};if(typeof window.innerWidth=="number")t.getWindowSize=function(){return new t.Point(window.innerWidth,window.innerHeight)};else if(l.clientWidth||l.clientHeight)t.getWindowSize=function(){return new t.Point(document.documentElement.clientWidth,document.documentElement.clientHeight)};else if(h.clientWidth||h.clientHeight)t.getWindowSize=function(){return new t.Point(document.body.clientWidth,document.body.clientHeight)};else throw new Error("Unknown window size, no known technique.");return t.getWindowSize()},makeCenteredNode:function(l){l=t.getElement(l);var h=[t.makeNeutralElement("div"),t.makeNeutralElement("div"),t.makeNeutralElement("div")];return t.extend(h[0].style,{display:"table",height:"100%",width:"100%"}),t.extend(h[1].style,{display:"table-row"}),t.extend(h[2].style,{display:"table-cell",verticalAlign:"middle",textAlign:"center"}),h[0].appendChild(h[1]),h[1].appendChild(h[2]),h[2].appendChild(l),h[0]},makeNeutralElement:function(l){var h=document.createElement(l),u=h.style;return u.background="transparent none",u.border="none",u.margin="0px",u.padding="0px",u.position="static",h},now:function(){return Date.now?t.now=Date.now:t.now=function(){return new Date().getTime()},t.now()},makeTransparentImage:function(l){var h=t.makeNeutralElement("img");return h.src=l,h},setElementOpacity:function(l,h,u){var c,d;l=t.getElement(l),u&&!t.Browser.alpha&&(h=Math.round(h)),t.Browser.opacity?l.style.opacity=h<1?h:"":h<1?(c=Math.round(100*h),d="alph
1a(opacity="+c+")",l.style.filter=d):l.style.filter=""},setElementTouchActionNone:function(l){l=t.getElement(l),typeof l.style.touchAction<"u"?l.style.touchAction="none":typeof l.style.msTouchAction<"u"&&(l.style.msTouchAction="none")},setElementPointerEvents:function(l,h){l=t.getElement(l),typeof l.style<"u"&&typeof l.style.pointerEvents<"u"&&(l.style.pointerEvents=h)},setElementPointerEventsNone:function(l){t.setElementPointerEvents(l,"none")},addClass:function(l,h){l=t.getElement(l),l.className?(" "+l.className+" ").indexOf(" "+h+" ")===-1&&(l.className+=" "+h):l.className=h},indexOf:function(l,h,u){return Array.prototype.indexOf?this.indexOf=function(c,d,f){return c.indexOf(d,f)}:this.indexOf=function(c,d,f){var p,g=f||0,v;if(!c)throw new TypeError;if(v=c.length,v===0||g>=v)return-1;for(g<0&&(g=v-Math.abs(g)),p=g;p<v;p++)if(c[p]===d)return p;return-1},this.indexOf(l,h,u)},removeClass:function(l,h){var u,c=[],d;for(l=t.getElement(l),u=l.className.split(/\s+/),d=0;d<u.length;d++)u[d]&&u[d]!==h&&c.push(u[d]);l.className=c.join(" ")},normalizeEventListenerOptions:function(l){var h;return typeof l<"u"?typeof l=="boolean"?h=t.supportsEventListenerOptions?{capture:l}:l:h=t.supportsEventListenerOptions?l:typeof l.capture<"u"?l.capture:!1:h=t.supportsEventListenerOptions?{capture:!1}:!1,h},addEvent:(function(){if(t.supportsAddEventListener)return function(l,h,u,c){c=t.normalizeEventListenerOptions(c),l=t.getElement(l),l.addEventListener(h,u,c)};if(document.documentElement.attachEvent&&document.attachEvent)return function(l,h,u){l=t.getElement(l),l.attachEvent("on"+h,u)};throw new Error("No known event model.")})(),removeEvent:(function(){if(t.supportsRemoveEventListener)return function(l,h,u,c){c=t.normalizeEventListenerOptions(c),l=t.getElement(l),l.removeEventListener(h,u,c)};if(document.documentElement.detachEvent&&document.detachEvent)return function(l,h,u){l=t.getElement(l),l.detachEvent("on"+h,u)};throw new Error("No known event model.")})(),cancelEvent:function(l){l.preventDefault()},eventIsCanceled:function(l){return l.defaultPrevented},stopEvent:function(l){l.stopPropagation()},createCallback:function(l,h){console.error("The createCallback function is deprecated and will be removed in future versions. Please use alternativeFunction instead.");var u=[],c;for(c=2;c<arguments.length;c++)u.push(arguments[c]);return function(){var d=u.concat([]),f;for(f=0;f<arguments.length;f++)d.push(arguments[f]);return h.apply(l,d)}},getUrlParameter:function(l){var h=o[l];return h||null},getUrlProtocol:function(l){var h=l.match(/^([a-z]+:)\/\//i);return h===null?window.location.protocol:h[1].toLowerCase()},createAjaxRequest:function(){if(window.XMLHttpRequest)return t.createAjaxRequest=function(){return new XMLHttpRequest},new XMLHttpRequest;throw new Error("Browser doesn't support XMLHttpRequest.")},makeAjaxRequest:function(l,h,u){var c,d,f,p;t.isPlainObject(l)&&(h=l.success,u=l.error,c=l.withCredentials,d=l.headers,f=l.responseType||null,p=l.postData||null,l=l.url);var g=t.getUrlProtocol(l),v=t.createAjaxRequest();if(!t.isFunction(h))throw new Error("makeAjaxRequest requires a success callback");v.onreadystatechange=function(){v.readyState===4&&(v.onreadystatechange=function(){},v.status>=200&&v.status<300||v.status===0&&g!=="http:"&&g!=="https:"?h(v):t.isFunction(u)?u(v):t.console.error("AJAX request returned %d: %s",v.status,l))};var m=p?"POST":"GET";try{if(v.open(m,l,!0),f&&(v.responseType=f),d)for(var x in d)Object.prototype.hasOwnProperty.call(d,x)&&d[x]&&v.setRequestHeader(x,d[x]);c&&(v.withCredentials=!0),v.send(p)}catch(y){t.console.error("%s while making AJAX request: %s",y.name,y.message),v.onreadystatechange=function(){},t.isFunction(u)&&u(v,y)}return v},jsonp:function(l){var h,u=l.url,c=document.head||document.getElementsByTagName("head")[0]||document.documentElement,d=l.callbackName||"openseadragon"+t.now(),f=window[d],p="$1"+d+"$2",g=l.param||"callback",v=l.callback;u=u.replace(/(=)\?(&|$)|\?\?/i,p),u+=(/\?/.test(u)?"&":"?")+g+"="+d,window[d]=function(m){if(f)window[d]=f;else try{delete window[d]}catch{}v&&t.isFunction(v)&&v(m)},h=document.createElement("script"),(l.async!==void 0||l.async!==!1)&&(h.async="async"),l.scriptCharset&&(h.charset=l.scriptCharset),h.src=u,h.onload=h.onreadystatechange=function(m,x){(x||!h.readyState||/loaded|complete/.test(h.readyState))&&(h.onload=h.onreadystatechange=null,c&&h.parentNode&&c.removeChild(h),h=void 0)},c.insertBefore(h,c.firstChild)},createFromDZI:function(){throw"OpenSeadragon.createFromDZI is deprecated, use Viewer.open."},parseXml:function(l){if(window.DOMParser)t.parseXml=function(h){var u=null,c;return c=new DOMParser,u=c.parseFromString(h,"text/xml"),u};else throw new Error("Browser doesn't support XML DOM.");return t.parseXml(l)},parseJSON:function(l){return t.parseJSON=window.JSON.parse,t.parseJSON(l)},imageFormatSupported:function(l){return l=l||"",!!s[l.toLowerCase()]},setImageFormatsSupported:function(l){t.extend(s,l)}});var r=function(l){};t.console=window.console||{log:r,debug:r,info:r,warn:r,error:r,assert:r}
vendor: 6,331 bytes, line 1
1,t.Browser={vendor:t.BROWSERS.UNKNOWN,version:0,alpha:!0};var s={avif:!0,bmp:!1,jpeg:!0,jpg:!0,png:!0,tif:!1,wdp:!1,webp:!0},o={};(function(){var l=navigator.appVersion,h=navigator.userAgent,u;switch(navigator.appName){case"Microsoft Internet Explorer":window.attachEvent&&window.ActiveXObject&&(t.Browser.vendor=t.BROWSERS.IE,t.Browser.version=parseFloat(h.substring(h.indexOf("MSIE")+5,h.indexOf(";",h.indexOf("MSIE")))));break;case"Netscape":window.addEventListener&&(h.indexOf("Edge")>=0?(t.Browser.vendor=t.BROWSERS.EDGE,t.Browser.version=parseFloat(h.substring(h.indexOf("Edge")+5))):h.indexOf("Edg")>=0?(t.Browser.vendor=t.BROWSERS.CHROMEEDGE,t.Browser.version=parseFloat(h.substring(h.indexOf("Edg")+4))):h.indexOf("Firefox")>=0?(t.Browser.vendor=t.BROWSERS.FIREFOX,t.Browser.version=parseFloat(h.substring(h.indexOf("Firefox")+8))):h.indexOf("Safari")>=0?(t.Browser.vendor=h.indexOf("Chrome")>=0?t.BROWSERS.CHROME:t.BROWSERS.SAFARI,t.Browser.version=parseFloat(h.substring(h.substring(0,h.indexOf("Safari")).lastIndexOf("/")+1,h.indexOf("Safari")))):(u=new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})"),u.exec(h)!==null&&(t.Browser.vendor=t.BROWSERS.IE,t.Browser.version=parseFloat(RegExp.$1))));break;case"Opera":t.Browser.vendor=t.BROWSERS.OPERA,t.Browser.version=parseFloat(l);break}var c=window.location.search.substring(1),d=c.split("&"),f,p,g;for(g=0;g<d.length;g++)if(f=d[g],p=f.indexOf("="),p>0){var v=f.substring(0,p),m=f.substring(p+1);try{o[v]=decodeURIComponent(m)}catch{t.console.error("Ignoring malformed URL parameter: %s=%s",v,m)}}t.Browser.alpha=!(t.Browser.vendor===t.BROWSERS.CHROME&&t.Browser.version<2),t.Browser.opacity=!0,t.Browser.vendor===t.BROWSERS.IE&&t.console.error("Internet Explorer is not supported by OpenSeadragon")})(),(function(l){var h=l.requestAnimationFrame||l.mozRequestAnimationFrame||l.webkitRequestAnimationFrame||l.msRequestAnimationFrame,u=l.cancelAnimationFrame||l.mozCancelAnimationFrame||l.webkitCancelAnimationFrame||l.msCancelAnimationFrame;if(h&&u)t.requestAnimationFrame=function(){return h.apply(l,arguments)},t.cancelAnimationFrame=function(){return u.apply(l,arguments)};else{var c=[],d=[],f=0,p;t.requestAnimationFrame=function(g){return c.push([++f,g]),p||(p=setInterval(function(){if(c.length){var v=t.now(),m=d;for(d=c,c=m;d.length;)d.shift()[1](v)}else clearInterval(p),p=void 0},1e3/50)),f},t.cancelAnimationFrame=function(g){var v,m;for(v=0,m=c.length;v<m;v+=1)if(c[v][0]===g){c.splice(v,1);return}for(v=0,m=d.length;v<m;v+=1)if(d[v][0]===g){d.splice(v,1);return}}}})(window);function a(l,h){return h&&l!==document.body?document.body:l.offsetParent}})(e),(function(t,i){n.exports?n.exports=i():t.OpenSeadragon=i()})(fy,function(){return e}),(function(t){class i{constructor(s){s||(s=[0,0,0,0,0,0,0,0,0]),this.values=s}static makeIdentity(){return new i([1,0,0,0,1,0,0,0,1])}static makeTranslation(s,o){return new i([1,0,0,0,1,0,s,o,1])}static makeRotation(s){var o=Math.cos(s),a=Math.sin(s);return new i([o,-a,0,a,o,0,0,0,1])}static makeScaling(s,o){return new i([s,0,0,0,o,0,0,0,1])}multiply(s){let o=this.values,a=s.values;var l=o[0],h=o[1],u=o[2],c=o[3],d=o[4],f=o[5],p=o[6],g=o[7],v=o[8],m=a[0],x=a[1],y=a[2],E=a[3],R=a[4],P=a[5],S=a[6],L=a[7],k=a[8];return new i([m*l+x*c+y*p,m*h+x*d+y*g,m*u+x*f+y*v,E*l+R*c+P*p,E*h+R*d+P*g,E*u+R*f+P*v,S*l+L*c+k*p,S*h+L*d+k*g,S*u+L*f+k*v])}}t.Mat3=i})(e),(function(t){var i={supportsFullScreen:!1,isFullScreen:function(){return!1},getFullScreenElement:function(){return null},requestFullScreen:function(){},exitFullScreen:function(){},cancelFullScreen:function(){},fullScreenEventName:"",fullScreenErrorEventName:""};document.exitFullscreen?(i.supportsFullScreen=!0,i.getFullScreenElement=function(){return document.fullscreenElement},i.requestFullScreen=function(r){return r.requestFullscreen().catch(function(s){t.console.error("Fullscreen request failed: ",s)})},i.exitFullScreen=function(){document.exitFullscreen().catch(function(r){t.console.error("Error while exiting fullscreen: ",r)})},i.fullScreenEventName="fullscreenchange",i.fullScreenErrorEventName="fullscreenerror"):document.msExitFullscreen?(i.supportsFullScreen=!0,i.getFullScreenElement=function(){return document.msFullscreenElement},i.requestFullScreen=function(r){return r.msRequestFullscreen()},i.exitFullScreen=function(){document.msExitFullscreen()},i.fullScreenEventName="MSFullscreenChange",i.fullScreenErrorEventName="MSFullscreenError"):document.webkitExitFullscreen?(i.supportsFullScreen=!0,i.getFullScreenElement=function(){return document.webkitFullscreenElement},i.requestFullScreen=function(r){return r.webkitRequestFullscreen()},i.exitFullScreen=function(){document.webkitExitFullscreen()},i.fullScreenEventName="webkitfullscreenchange",i.fullScreenErrorEventName="webkitfullscreenerror"):document.webkitCancelFullScreen?(i.supportsFullScreen=!0,i.getFullScreenElement=function(){return document.webkitCurrentFullScreenElement},i.requestFullScreen=function(r){return r.webkitRequestFullScreen()},i.exitFullScreen=function(){document.webkitCancelFullScreen()},i.fullScreenEventName="webkitfullscreenchange",i.fullScreenErrorEventName="webkitfullscreenerror"):document.mozCancelFullScreen&&(i.supportsFullScreen=!0,i.getFullScreenElement=function(){return document.mozFullScreenElement},i.requestFullScreen=function(r){return r.mozRequestFullScreen()},i.exitFullScreen=function(){document.mozCancelFullScreen()},i.fullScreenEventName="mozfullscreenchange",i.fullScreenErrorEventName="mozfullscreenerror"),i.isFullScreen=function(){return i.getFullScreenElement()!==null},i.cancelFullScreen=function(){t.console.error("cancelFullScreen is deprecated. Use exitFullScreen instead."),i.exitFullScreen()},t.extend(t,i)})(e),(function(t){t.EventSource=function(){this.events={},this._rejectedEventList={}},t.EventSource.prototype={addOnceHandler:function(i,r,s,o,a){var l=this;o=o||1;var h=0,u=function(c){return h++,h===o&&l.removeHandler(i,u),r(c)};return this.addHandler(i,u,s,a)},addHandler:function(i,r,s,o){if(Object.prototype.hasOwnProperty.call(this._rejectedEventList,i))return t.console.error(`Error adding handler for ${i}. ${this._rejectedEventList[i]}`),!1;var a=this.events[i];if(a||(this.events[i]=a=[]),r&&t.isFunction(r)){var l=a.length,h={handler:r,userData:s||null,priority:o||0};for(a[l]=h;l>0&&a[l-1].priority<a[l].priority;
vendor: 4,505 bytes, line 1
1)a[l]=a[l-1],a[l-1]=h,l--}return!0},removeHandler:function(i,r){var s=this.events[i],o=[],a;if(s&&t.isArray(s)){for(a=0;a<s.length;a++)s[a].handler!==r&&o.push(s[a]);this.events[i]=o}},numberOfHandlers:function(i){var r=this.events[i];return r?r.length:0},removeAllHandlers:function(i){if(i)this.events[i]=[];else for(var r in this.events)this.events[r]=[]},getHandler:function(i){var r=this.events[i];return!r||!r.length?null:(r=r.length===1?[r[0]]:Array.apply(null,r),function(s,o){var a,l=r.length;for(a=0;a<l;a++)r[a]&&(o.eventSource=s,o.userData=r[a].userData,r[a].handler(o))})},raiseEvent:function(i,r){if(Object.prototype.hasOwnProperty.call(this._rejectedEventList,i))return t.console.error(`Error adding handler for ${i}. ${this._rejectedEventList[i]}`),!1;var s=this.getHandler(i);return s&&s(this,r||{}),!0},rejectEventHandler(i,r=""){this._rejectedEventList[i]=r},allowEventHandler(i){delete this._rejectedEventList[i]}}})(e),(function(t){var i={};t.MouseTracker=function(_){var T=arguments;t.isPlainObject(_)||(_={element:T[0],clickTimeThreshold:T[1],clickDistThreshold:T[2]}),this.hash=Math.random(),this.element=t.getElement(_.element),this.clickTimeThreshold=_.clickTimeThreshold||t.DEFAULT_SETTINGS.clickTimeThreshold,this.clickDistThreshold=_.clickDistThreshold||t.DEFAULT_SETTINGS.clickDistThreshold,this.dblClickTimeThreshold=_.dblClickTimeThreshold||t.DEFAULT_SETTINGS.dblClickTimeThreshold,this.dblClickDistThreshold=_.dblClickDistThreshold||t.DEFAULT_SETTINGS.dblClickDistThreshold,this.userData=_.userData||null,this.stopDelay=_.stopDelay||50,this.preProcessEventHandler=_.preProcessEventHandler||null,this.contextMenuHandler=_.contextMenuHandler||null,this.enterHandler=_.enterHandler||null,this.leaveHandler=_.leaveHandler||null,this.exitHandler=_.exitHandler||null,this.overHandler=_.overHandler||null,this.outHandler=_.outHandler||null,this.pressHandler=_.pressHandler||null,this.nonPrimaryPressHandler=_.nonPrimaryPressHandler||null,this.releaseHandler=_.releaseHandler||null,this.nonPrimaryReleaseHandler=_.nonPrimaryReleaseHandler||null,this.moveHandler=_.moveHandler||null,this.scrollHandler=_.scrollHandler||null,this.clickHandler=_.clickHandler||null,this.dblClickHandler=_.dblClickHandler||null,this.dragHandler=_.dragHandler||null,this.dragEndHandler=_.dragEndHandler||null,this.pinchHandler=_.pinchHandler||null,this.stopHandler=_.stopHandler||null,this.keyDownHandler=_.keyDownHandler||null,this.keyUpHandler=_.keyUpHandler||null,this.keyHandler=_.keyHandler||null,this.focusHandler=_.focusHandler||null,this.blurHandler=_.blurHandler||null;var M=this;i[this.hash]={click:function(F){y(M,F)},dblclick:function(F){E(M,F)},keydown:function(F){R(M,F)},keyup:function(F){P(M,F)},keypress:function(F){S(M,F)},focus:function(F){L(M,F)},blur:function(F){k(M,F)},contextmenu:function(F){W(M,F)},wheel:function(F){j(M,F)},mousewheel:function(F){V(M,F)},DOMMouseScroll:function(F){V(M,F)},MozMousePixelScroll:function(F){V(M,F)},losecapture:function(F){D(M,F)},mouseenter:function(F){X(M,F)},mouseleave:function(F){$(M,F)},mouseover:function(F){re(M,F)},mouseout:function(F){se(M,F)},mousedown:function(F){ce(M,F)},mouseup:function(F){ie(M,F)},mousemove:function(F){Te(M,F)},touchstart:function(F){A(M,F)},touchend:function(F){O(M,F)},touchmove:function(F){B(M,F)},touchcancel:function(F){G(M,F)},gesturestart:function(F){Y(M,F)},gesturechange:function(F){z(M,F)},gotpointercapture:function(F){b(M,F)},lostpointercapture:function(F){H(M,F)},pointerenter:function(F){X(M,F)},pointerleave:function(F){$(M,F)},pointerover:function(F){re(M,F)},pointerout:function(F){se(M,F)},pointerdown:function(F){ce(M,F)},pointerup:function(F){ie(M,F)},pointermove:function(F){Te(M,F)},pointercancel:function(F){it(M,F)},pointerupcaptured:function(F){ge(M,F)},pointermovecaptured:function(F){me(M,F)},tracking:!1,activePointersLists:[],lastClickPos:null,dblClickTimeOut:null,pinchGPoints:[],lastPinchDist:0,currentPinchDist:0,lastPinchCenter:null,currentPinchCenter:null,sentDragEvent:!1},this.hasGestureHandlers=!!(this.pressHandler||this.nonPrimaryPressHandler||this.releaseHandler||this.nonPrimaryReleaseHandler||this.clickHandler||this.dblClickHandler||this.dragHandler||this.dragEndHandler||this.pinchHandler),this.hasScrollHandler=!!this.scrollHandler,t.MouseTracker.havePointerEvents&&t.setElementPointerEvents(this.element,"auto"),this.exitHandler&&t.console.error("MouseTracker.exitHandler is deprecated. Use MouseTracker.leaveHandler instead."),_.startDisabled||this.setTracking(!0)}
1,t.MouseTracker.prototype={destroy:function(){l(this),this.element=null,i[this.hash]=null,delete i[this.hash]},isTracking:function(){return i[this.hash].tracking},setTracking:function(_){return _?a(this):l(this),this},getActivePointersListByType:function(_){var T=i[this.hash],M,F=T?T.activePointersLists.length:0,Z;for(M=0;M<F;M++)if(T.activePointersLists[M].type===_)return T.activePointersLists[M];return Z=new t.MouseTracker.GesturePointList(_),T&&T.activePointersLists.push(Z),Z},getActivePointerCount:function(){var _=i[this.hash],T,M=_.activePointersLists.length,F=0;for(T=0;T<M;T++)F+=_.activePointersLists[T].getLength();return F},preProcessEventHandler:function(){},contextMenuHandler:function(){},enterHandler:function(){},leaveHandler:function(){},exitHandler:function(){},overHandler:function(){},outHandler:function(){},pressHandler:function(){},nonPrimaryPressHandler:function(){},releaseHandler:function(){},nonPrimaryReleaseHandler:function(){},moveHandler:function(){},scrollHandler:function(){},clickHandler:function(){},dblClickHandler:function(){},dragHandler:function(){},dragEndHandler:function(){},pinchHandler:function(){},stopHandler:function(){},keyDownHandler:function(){},keyUpHandler:function(){},keyHandler:function(){},focusHandler:function(){},blurHandler:function(){}};var r=(function(){try{return window.self!==window.top}catch{return!0}})();function s(_){try{return _.addEventListener&&_.removeEventListener}catch{return!1}}t.MouseTracker.gesturePointVelocityTracker=(function(){var _=[],T=0,M=0,F=function(qe,Pe){return qe.hash.toString()+Pe.type+Pe.id.toString()},Z=function(){var qe,Pe=_.length,Gt,vt,$n=t.now(),Ru,Pu,Cu;for(Ru=$n-M,M=$n,qe=0;qe<Pe;qe++)Gt=_[qe],vt=Gt.gPoint,vt.direction=Math.atan2(vt.currentPos.y-Gt.lastPos.y,vt.currentPos.x-Gt.lastPos.x),Pu=Gt.lastPos.distanceTo(vt.currentPos),Gt.lastPos=vt.currentPos,Cu=1e3*Pu/(Ru+1),vt.speed=.75*Cu+.25*vt.speed},ne=function(qe,Pe){var Gt=F(qe,Pe);_.push({guid:Gt,gPoint:Pe,lastPos:Pe.currentPos}),_.length===1&&(M=t.now(),T=window.setInterval(Z,50))},be=function(qe,Pe){var Gt=F(qe,Pe),vt,$n=_.length;for(vt=0;vt<$n;vt++)if(_[vt].guid===Gt){_.splice(vt,1),$n--,$n===0&&window.clearInterval(T);break}};return{addPoint:ne,removePoint:be}})(),t.MouseTracker.captureElement=document,t.MouseTracker.wheelEventName="onw
1heel"in document.createElement("div")?"wheel":document.onmousewheel!==void 0?"mousewheel":"DOMMouseScroll",t.MouseTracker.subscribeEvents=["click","dblclick","keydown","keyup","keypress","focus","blur","contextmenu",t.MouseTracker.wheelEventName],t.MouseTracker.wheelEventName==="DOMMouseScroll"&&t.MouseTracker.subscribeEvents.push("MozMousePixelScroll"),window.PointerEvent?(t.MouseTracker.havePointerEvents=!0,t.MouseTracker.subscribeEvents.push("pointerenter","pointerleave","pointerover","pointerout","pointerdown","pointerup","pointermove","pointercancel"),t.MouseTracker.havePointerCapture=(function(){var _=document.createElement("div");return t.isFunction(_.setPointerCapture)&&t.isFunction(_.releasePointerCapture)})(),t.MouseTracker.havePointerCapture&&t.MouseTracker.subscribeEvents.push("gotpointercapture","lostpointercapture")):(t.MouseTracker.havePointerEvents=!1,t.MouseTracker.subscribeEvents.push("mouseenter","mouseleave","mouseover","mouseout","mousedown","mouseup","mousemove"),t.MouseTracker.mousePointerId="legacy-mouse",t.MouseTracker.havePointerCapture=(function(){var _=document.createElement("div");return t.isFunction(_.setCapture)&&t.isFunction(_.releaseCapture)})(),t.MouseTracker.havePointerCapture&&t.MouseTracker.subscribeEvents.push("losecapture"),"ontouchstart"in window&&t.MouseTracker.subscribeEvents.push("touchstart","touchend","touchmove","touchcancel"),"ongesturestart"in window&&t.MouseTracker.subscribeEvents.push("gesturestart","gesturechange")),t.MouseTracker.GesturePointList=function(_){this._gPoints=[],this.type=_,this.buttons=0,this.contacts=0,this.clicks=0,this.captureCount=0},t.MouseTracker.GesturePointList.prototype={getLength:function(){return this._gPoints.length},asArray:function(){return this._gPoints},add:function(_){return this._gPoints.push(_)},removeById:function(_){var T,M=this._gPoints.length;for(T=0;T<M;T++)if(this._gPoints[T].id===_){this._gPoints.splice(T,1);break}return this._gPoints.length},getByIndex:function(_){return _<this._gPoints.length?this._gPoints[_]:null},getById:function(_){var T,M=this._gPoints.length;for(T=0;T<M;T++)if(this._gPoints[T].id===_)return this._gPoints[T];return null},getPrimary:function(_){var T,M=this._gPoints.length;for(T=0;T<M;T++)if(this._gPoints[T].isPrimary)return this._gPoints[T];return null},addContact:function(){++this.contacts,this.contacts>1&&(this.type==="mouse"||this.type==="pen")&&(t.console.warn("GesturePointList.addContact() Implausible contacts value"),this.contacts=1)},removeContact:function(){--this.contacts,this.contacts<0&&(this.contacts=0)}};function o(_){var T=i[_.hash],M,F,Z,ne,be,qe=T.activePointersLists.length;for(M=0;M<qe;M++)if(Z=T.activePointersLists[M],Z.getLength()>0){for(be=[],ne=Z.asArray(),F=0;F<ne.length;
vendor: 25,213 bytes, line 1
1F++)be.push(ne[F]);for(F=0;F<be.length;F++)ht(_,Z,be[F])}for(M=0;M<qe;M++)T.activePointersLists.pop();T.sentDragEvent=!1}function a(_){var T=i[_.hash],M,F;if(!T.tracking){for(F=0;F<t.MouseTracker.subscribeEvents.length;F++)M=t.MouseTracker.subscribeEvents[F],t.addEvent(_.element,M,T[M],M===t.MouseTracker.wheelEventName?{passive:!1,capture:!1}:!1);o(_),T.tracking=!0}}function l(_){var T=i[_.hash],M,F;if(T.tracking){for(F=0;F<t.MouseTracker.subscribeEvents.length;F++)M=t.MouseTracker.subscribeEvents[F],t.removeEvent(_.element,M,T[M],!1);o(_),T.tracking=!1}}function h(_,T){var M=i[_.hash];if(T==="pointerevent")return{upName:"pointerup",upHandler:M.pointerupcaptured,moveName:"pointermove",moveHandler:M.pointermovecaptured};if(T==="mouse")return{upName:"pointerup",upHandler:M.pointerupcaptured,moveName:"pointermove",moveHandler:M.pointermovecaptured};if(T==="touch")return{upName:"touchend",upHandler:M.touchendcaptured,moveName:"touchmove",moveHandler:M.touchmovecaptured};throw new Error("MouseTracker.getCaptureEventParams: Unknown pointer type.")}function u(_,T){var M;if(t.MouseTracker.havePointerCapture)if(t.MouseTracker.havePointerEvents)try{_.element.setPointerCapture(T.id)}catch{t.console.warn("setPointerCapture() called on invalid pointer ID");return}else _.element.setCapture(!0);else M=h(_,t.MouseTracker.havePointerEvents?"pointerevent":T.type),r&&s(window.top)&&t.addEvent(window.top,M.upName,M.upHandler,!0),t.addEvent(t.MouseTracker.captureElement,M.upName,M.upHandler,!0),t.addEvent(t.MouseTracker.captureElement,M.moveName,M.moveHandler,!0);q(_,T,!0)}function c(_,T){var M,F,Z;if(t.MouseTracker.havePointerCapture)if(t.MouseTracker.havePointerEvents){if(F=_.getActivePointersListByType(T.type),Z=F.getById(T.id),!Z||!Z.captured)return;try{_.element.releasePointerCapture(T.id)}catch{}}else _.element.releaseCapture();else M=h(_,t.MouseTracker.havePointerEvents?"pointerevent":T.type),r&&s(window.top)&&t.removeEvent(window.top,M.upName,M.upHandler,!0),t.removeEvent(t.MouseTracker.captureElement,M.moveName,M.moveHandler,!0),t.removeEvent(t.MouseTracker.captureElement,M.upName,M.upHandler,!0);q(_,T,!1)}function d(_){return t.MouseTracker.havePointerEvents?_.pointerId:t.MouseTracker.mousePointerId}function f(_){return t.MouseTracker.havePointerEvents&&_.pointerType?_.pointerType:"mouse"}function p(_){return t.MouseTracker.havePointerEvents?_.isPrimary:!0}function g(_){return t.getMousePosition(_)}function v(_,T){return m(g(_),T)}function m(_,T){var M=t.getElementOffset(T);return _.minus(M)}function x(_,T){return new t.Point((_.x+T.x)/2,(_.y+T.y)/2)}function y(_,T){var M={originalEvent:T,eventType:"click",pointerType:"mouse",isEmulated:!1};I(_,M),M.preventDefault&&!M.defaultPrevented&&t.cancelEvent(T),M.stopPropagation&&t.stopEvent(T)}function E(_,T){var M={originalEvent:T,eventType:"dblclick",pointerType:"mouse",isEmulated:!1};I(_,M),M.preventDefault&&!M.defaultPrevented&&t.cancelEvent(T),M.stopPropagation&&t.stopEvent(T)}function R(_,T){var M=null,F={originalEvent:T,eventType:"keydown",pointerType:"",isEmulated:!1};I(_,F),_.keyDownHandler&&!F.preventGesture&&!F.defaultPrevented&&(M={eventSource:_,keyCode:T.keyCode?T.keyCode:T.charCode,ctrl:T.ctrlKey,shift:T.shiftKey,alt:T.altKey,meta:T.metaKey,originalEvent:T,preventDefault:F.preventDefault||F.defaultPrevented,userData:_.userData},_.keyDownHandler(M)),(M&&M.preventDefault||F.preventDefault&&!F.defaultPrevented)&&t.cancelEvent(T),F.stopPropagation&&t.stopEvent(T)}function P(_,T){var M=null,F={originalEvent:T,eventType:"keyup",pointerType:"",isEmulated:!1};I(_,F),_.keyUpHandler&&!F.preventGesture&&!F.defaultPrevented&&(M={eventSource:_,keyCode:T.keyCode?T.keyCode:T.charCode,ctrl:T.ctrlKey,shift:T.shiftKey,alt:T.altKey,meta:T.metaKey,originalEvent:T,preventDefault:F.preventDefault||F.defaultPrevented,userData:_.userData},_.keyUpHandler(M)),(M&&M.preventDefault||F.preventDefault&&!F.defaultPrevented)&&t.cancelEvent(T),F.stopPropagation&&t.stopEvent(T)}function S(_,T){var M=null,F={originalEvent:T,eventType:"keypress",pointerType:"",isEmulated:!1};I(_,F),_.keyHandler&&!F.preventGesture&&!F.defaultPrevented&&(M={eventSource:_,keyCode:T.keyCode?T.keyCode:T.charCode,ctrl:T.ctrlKey,shift:T.shiftKey,alt:T.altKey,meta:T.metaKey,originalEvent:T,preventDefault:F.preventDefault||F.defaultPrevented,userData:_.userData},_.keyHandler(M)),(M&&M.preventDefault||F.preventDefault&&!F.defaultPrevented)&&t.cancelEvent(T),F.stopPropagation&&t.stopEvent(T)}function L(_,T){var M={originalEvent:T,eventType:"focus",pointerType:"",isEmulated:!1};I(_,M),_.focusHandler&&!M.preventGesture&&_.focusHandler({eventSource:_,originalEvent:T,userData:_.userData})}function k(_,T){var M={originalEvent:T,eventType:"blur",pointerType:"",isEmulated:!1};I(_,M),_.blurHandler&&!M.preventGesture&&_.blurHandler({eventSource:_,originalEvent:T,userData:_.userData})}function W(_,T){var M=null,F={originalEvent:T,eventType:"contextmenu",pointerType:"mouse",isEmulated:!1};I(_,F),_.contextMenuHandler&&!F.preventGesture&&!F.defaultPrevented&&(M={eventSource:_,position:m(g(T),_.element),originalEvent:F.originalEvent,preventDefault:F.preventDefault||F.defaultPrevented,userData:_.userData},_.contextMenuHandler(M)),(M&&M.preventDefault||F.preventDefault&&!F.defaultPrevented)&&t.cancelEvent(T),F.stopPropagation&&t.stopEvent(T)}function j(_,T){N(_,T,T)}function V(_,T){var M={target:T.target||T.srcElement,type:"wheel",shiftKey:T.shiftKey||!1,clientX:T.clientX,clientY:T.clientY,pageX:T.pageX?T.pageX:T.clientX,pageY:T.pageY?T.pageY:T.clientY,deltaMode:T.type==="MozMousePixelScroll"?0:1,deltaX:0,deltaZ:0};t.MouseTracker.wheelEventName==="mousewheel"?M.deltaY=-T.wheelDelta/t.DEFAULT_SETTINGS.pixelsPerWheelLine:M.deltaY=T.detail,N(_,M,T)}function N(_,T,M){var F=0,Z,ne=null;F=T.deltaY?T.deltaY<0?1:-1:0,Z={originalEvent:T,eventType:"wheel",pointerType:"mouse",isEmulated:T!==M},I(_,Z),_.scrollHandler&&!Z.preventGesture&&!Z.defaultPrevented&&(ne={eventSource:_,pointerType:"mouse",position:v(T,_.element),scroll:F,shift:T.shiftKey,isTouchEvent:!1,originalEvent:M,preventDefault:Z.preventDefault||Z.defaultPrevented,userData:_.userData},_.scrollHandler(ne)),Z.stopPropagation&&t.stopEvent(M),(ne&&ne.preventDefault||Z.preventDefault&&!Z.defaultPrevented)&&t.cancelEvent(M)}function D(_,T){var M={id:t.MouseTracker.mousePointerId,type:"mouse"},F={originalEvent:T,eventType:"lostpointercapture",pointerType:"mouse",isEmulated:!1};I(_,F),T.target===_.element&&q(_,M,!1),F.stopPropagation&&t.stopEvent(T)}function A(_,T){var M,F,Z=T.changedTouches.length,ne,be=_.getActivePointersListByType("touch");M=t.now(),be.getLength()>T.touches.length-Z&&t.console.warn("Tracked touch contact count doesn't match event.touches.length");var qe={originalEvent:T,eventType:"pointerdown",pointerType:"touch",isEmulated:!1};for(I(_,qe),F=0;F<Z;F++)ne={id:T.changedTouches[F].identifier,type:"touch",isPrimary:be.getLength()===0,currentPos:g(T.changedTouches[F]),currentTime:M},K(_,qe,ne),ye(_,qe,ne,0),q(_,ne,!0);qe.preventDefault&&!qe.defaultPrevented&&t.cancelEvent(T),qe.stopPropagation&&t.stopEvent(T)}function O(_,T){var M,F,Z=T.changedTouches.length,ne;M=t.now();var be={originalEvent:T,eventType:"pointerup",pointerType:"touch",isEmulated:!1};for(I(_,be),F=0;F<Z;F++)ne={id:T.changedTouches[F].identifier,type:"touch",currentPos:g(T.changedTouches[F]),currentTime:M},ee(_,be,ne,0),q(_,ne,!1),ae(_,be,ne);be.preventDefault&&!be.defaultPrevented&&t.cancelEvent(T),be.stopPropagation&&t.stopEvent(T)}function B(_,T){var M,F,Z=T.changedTouches.length,ne;M=t.now();var be={originalEvent:T,eventType:"pointermove",pointerType:"touch",isEmulated:!1};for(I(_,be),F=0;F<Z;F++)ne={id:T.changedTouches[F].identifier,type:"touch",currentPos:g(T.changedTouches[F]),currentTime:M},Ve(_,be,ne);be.preventDefault&&!be.defaultPrevented&&t.cancelEvent(T),be.stopPropagation&&t.stopEvent(T)}function G(_,T){var M=T.changedTouches.length,F,Z,ne={originalEvent:T,eventType:"pointercancel",pointerType:"touch",isEmulated:!1};for(I(_,ne),F=0;F<M;F++)Z={id:T.changedTouches[F].identifier,type:"touch"},Re(_,ne,Z);ne.stopPropagation&&t.stopEvent(T)}function Y(_,T){return t.eventIsCanceled(T)||T.preventDefault(),!1}function z(_,T){return t.eventIsCanceled(T)||T.preventDefault(),!1}function b(_,T){var M={originalEvent:T,eventType:"gotpointercapture",pointerType:f(T),isEmulated:!1};I(_,M),T.target===_.element&&q(_,{id:T.pointerId,type:f(T)},!0),M.stopPropagation&&t.stopEvent(T)}function H(_,T){var M={originalEvent:T,eventType:"lostpointercapture",pointerType:f(T),isEmulated:!1};I(_,M),T.target===_.element&&q(_,{id:T.pointerId,type:f(T)},!1),M.stopPropagation&&t.stopEvent(T)}function X(_,T){var M={id:d(T),type:f(T),isPrimary:p(T),currentPos:g(T),currentTime:t.now()},F={originalEvent:T,eventType:"pointerenter",pointerType:M.type,isEmulated:!1};I(_,F),K(_,F,M)}function $(_,T){var M={id:d(T),type:f(T),isPrimary:p(T),currentPos:g(T),currentTime:t.now()},F={originalEvent:T,eventType:"pointerleave",pointerType:M.type,isEmulated:!1};I(_,F),ae(_,F,M)}function re(_,T){var M={id:d(T),type:f(T),isPrimary:p(T),currentPos:g(T),currentTime:t.now()},F={originalEvent:T,eventType:"pointerover",pointerType:M.type,isEmulated:!1};I(_,F),he(_,F,M),F.preventDefault&&!F.defaultPrevented&&t.cancelEvent(T),F.stopPropagation&&t.stopEvent(T)}function se(_,T){var M={id:d(T),type:f(T),isPrimary:p(T),currentPos:g(T),currentTime:t.now()},F={originalEvent:T,eventType:"pointerout",pointerType:M.type,isEmulated:!1};I(_,F),J(_,F,M),F.preventDefault&&!F.defaultPrevented&&t.cancelEvent(T),F.stopPropagation&&t.stopEvent(T)}function ce(_,T){var M={id:d(T),type:f(T),isPrimary:p(T),currentPos:g(T),currentTime:t.now()},F=t.MouseTracker.havePointerEvents&&M.type==="touch",Z={originalEvent:T,eventType:"pointerdown",pointerType:M.type,isEmulated:!1};I(_,Z),ye(_,Z,M,T.button),Z.preventDefault&&!Z.defaultPrevented&&t.cancelEvent(T),Z.stopPropagation&&t.stopEvent(T),Z.shouldCapture&&(F?q(_,M,!0):u(_,M))}function ie(_,T){de(_,T)}function ge(_,T){var M=_.getActivePointersListByType(f(T));M.getById(T.pointerId)&&de(_,T),t.stopEvent(T)}function de(_,T){var M;M={id:d(T),type:f(T),isPrimary:p(T),currentPos:g(T),currentTime:t.now()};var F={originalEvent:T,eventType:"pointerup",pointerType:M.type,isEmulated:!1};I(_,F),ee(_,F,M,T.button),F.preventDefault&&!F.defaultPrevented&&t.cancelEvent(T),F.stopPropagation&&t.stopEvent(T),F.shouldReleaseCapture&&(T.target===_.element?c(_,M):q(_,M,!1))}function Te(_,T){De(_,T)}function me(_,T){var M=_.getActivePointersListByType(f(T));M.getById(T.pointerId)&&De(_,T),t.stopEvent(T)}function De(_,T){var M={id:d(T),type:f(T),isPrimary:p(T),currentPos:g(T),currentTime:t.now()},F={originalEvent:T,eventType:"pointermove",pointerType:M.type,isEmulated:!1};I(_,F),Ve(_,F,M),F.preventDefault&&!F.defaultPrevented&&t.cancelEvent(T),F.stopPropagation&&t.stopEvent(T)}function it(_,T){var M={id:T.pointerId,type:f(T)},F={originalEvent:T,eventType:"pointercancel",pointerType:M.type,isEmulated:!1};I(_,F),Re(_,F,M),F.stopPropagation&&t.stopEvent(T)}function Je(_,T){return T.speed=0,T.direction=0,T.contactPos=T.currentPos,T.contactTime=T.currentTime,T.lastPos=T.currentPos,T.lastTime=T.currentTime,_.add(T)}function ht(_,T,M){var F,Z=T.getById(M.id);return Z?(Z.captured&&(t.console.warn("stopTrackingPointer() called on captured pointer"),c(_,Z)),T.removeContact(),F=T.removeById(M.id)):F=T.getLength(),F}function w(_,T){switch(T.eventType){case"pointermove":T.isStoppable=!0,T.isCancelable=!0,T.preventDefault=!1,T.preventGesture=!_.hasGestureHandlers,T.stopPropagation=!1;break;case"pointerover":case"pointerout":case"contextmenu":case"keydown":case"keyup":case"keypress":T.isStoppable=!0,T.isCancelable=!0,T.preventDefault=!1,T.preventGesture=!1,T.stopPropagation=!1;break;case"pointerdown":T.isStoppable=!0,T.isCancelable=!0,T.preventDefault=!1,T.preventGesture=!_.hasGestureHandlers,T.stopPropagation=!1;break;case"pointerup":T.isStoppable=!0,T.isCancelable=!0,T.preventDefault=!1,T.preventGesture=!_.hasGestureHandlers,T.stopPropagation=!1;break;case"wheel":T.isStoppable=!0,T.isCancelable=!0,T.preventDefault=!1,T.preventGesture=!_.hasScrollHandler,T.stopPropagation=!1;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":T.isStoppable=!0,T.isCancelable=!1,T.preventDefault=!1,T.preventGesture=!1,T.stopPropagation=!1;break;case"click":T.isStoppable=!0,T.isCancelable=!0,T.preventDefault=!!_.clickHandler,T.preventGesture=!1,T.stopPropagation=!1;break;case"dblclick":T.isStoppable=!0,T.isCancelable=!0,T.preventDefault=!!_.dblClickHandler,T.preventGesture=!1,T.stopPropagation=!1;break;default:T.isStoppable=!1,T.isCancelable=!1,T.preventDefault=!1,T.preventGesture=!1,T.stopPropagation=!1;break}}function I(_,T){T.eventSource=_,T.eventPhase=T.originalEvent&&typeof T.originalEvent.eventPhase<"u"?T.originalEvent.eventPhase:0,T.defaultPrevented=t.eventIsCanceled(T.originalEvent),T.shouldCapture=!1,T.shouldReleaseCapture=!1,T.userData=_.userData,w(_,T),_.preProcessEventHandler&&_.preProcessEventHandler(T)}function q(_,T,M){var F=_.getActivePointersListByType(T.type),Z=F.getById(T.id);Z?M&&!Z.captured?(Z.captured=!0,F.captureCount++):!M&&Z.captured&&(Z.captured=!1,F.captureCount--,F.captureCount<0&&(F.captureCount=0,t.console.warn("updatePointerCaptured() - pointsList.captureCount went negative"))):t.console.warn("updatePointerCaptured() called on untracked pointer")}function K(_,T,M){var F=_.getActivePointersListByType(M.type),Z;Z=F.getById(M.id),Z?(Z.insideElement=!0,Z.lastPos=Z.currentPos,Z.lastTime=Z.currentTime,Z.currentPos=M.currentPos,Z.currentTime=M.currentTime,M=Z):(M.captured=!1,M.insideElementPressed=!1,M.insideElement=!0,Je(F,M)),_.enterHandler&&_.enterHandler({eventSource:_,pointerType:M.type,position:m(M.currentPos,_.element),buttons:F.buttons,pointers:_.getActivePointerCount(),insideElementPressed:M.insideElementPressed,buttonDownAny:F.buttons!==0,isTouchEvent:M.type==="touch",originalEvent:T.originalEvent,userData:_.userData})}function ae(_,T,M){var F=_.getActivePointersListByType(M.type),Z,ne;Z=F.getById(M.id),Z?(Z.captured?(Z.insideElement=!1,Z.lastPos=Z.currentPos,Z.lastTime=Z.currentTime,Z.currentPos=M.currentPos,Z.currentTime=M.currentTime):ht(_,F,Z),M=Z):(M.captured=!1,M.insideElementPressed=!1),(_.leaveHandler||_.exitHandler)&&(ne={eventSource:_,pointerType:M.type,position:M.currentPos&&m(M.currentPos,_.element),buttons:F.buttons,pointers:_.getActivePointerCount(),insideElementPressed:M.insideElementPressed,buttonDownAny:F.buttons!==0,isTouchEvent:M.type==="touch",originalEvent:T.originalEvent,userData:_.userData},_.leaveHandler&&_.leaveHandler(ne),_.exitHandler&&_.exitHandler(ne))}function he(_,T,M){var F,Z;F=_.getActivePointersListByType(M.type),Z=F.getById(M.id),Z?M=Z:(M.captured=!1,M.insideElementPressed=!1),_.overHandler&&_.overHandler({eventSource:_,pointerType:M.type,position:m(M.currentPos,_.element),buttons:F.buttons,pointers:_.getActivePointerCount(),insideElementPressed:M.insideElementPressed,buttonDownAny:F.buttons!==0,isTouchEvent:M.type==="touch",originalEvent:T.originalEvent,userData:_.userData})}function J(_,T,M){var F,Z;F=_.getActivePointersListByType(M.type),Z=F.getById(M.id),Z?M=Z:(M.captured=!1,M.insideElementPressed=!1),_.outHandler&&_.outHandler({eventSource:_,pointerType:M.type,position:M.currentPos&&m(M.currentPos,_.element),buttons:F.buttons,pointers:_.getActivePointerCount(),insideElementPressed:M.insideElementPressed,buttonDownAny:F.buttons!==0,isTouchEvent:M.type==="touch",originalEvent:T.originalEvent,userData:_.userData})}function ye(_,T,M,F){var Z=i[_.hash],ne=_.getActivePointersListByType(M.type),be;if(typeof T.originalEvent.buttons<"u"?ne.buttons=T.originalEvent.buttons:F===0?ne.buttons|=1:F===1?ne.buttons|=4:F===2?ne.buttons|=2:F===3?ne.buttons|=8:F===4?ne.buttons|=16:F===5&&(ne.buttons|=32),F!==0){T.shouldCapture=!1,T.shouldReleaseCapture=!1,_.nonPrimaryPressHandler&&!T.preventGesture&&!T.defaultPrevented&&(T.preventDefault=!0,_.nonPrimaryPressHandler({eventSource:_,pointerType:M.type,position:m(M.currentPos,_.element),button:F,buttons:ne.buttons,isTouchEvent:M.type==="touch",originalEvent:T.originalEvent,userData:_.userData}));return}be=ne.getById(M.id),be?(be.insideElementPressed=!0,be.insideElement=!0,be.originalTarget=T.originalEvent.target,be.contactPos=M.currentPos,be.contactTime=M.currentTime,be.lastPos=be.currentPos,be.lastTime=be.currentTime,be.currentPos=M.currentPos,be.currentTime=M.currentTime,M=be):(M.captured=!1,M.insideElementPressed=!0,M.insideElement=!0,M.originalTarget=T.originalEvent.target,Je(ne,M)),ne.addContact(),!T.preventGesture&&!T.defaultPrevented?(T.shouldCapture=!0,T.shouldReleaseCapture=!1,T.preventDefault=!0,(_.dragHandler||_.dragEndHandler||_.pinchHandler)&&t.MouseTracker.gesturePointVelocityTracker.addPoint(_,M),ne.contacts===1?_.pressHandler&&!T.preventGesture&&_.pressHandler({eventSource:_,pointerType:M.type,position:m(M.contactPos,_.element),buttons:ne.buttons,isTouchEvent:M.type==="touch",originalEvent:T.originalEvent,userData:_.userData}):ne.contacts===2&&_.pinchHandler&&M.type==="touch"&&(Z.pinchGPoints=ne.asArray(),Z.lastPinchDist=Z.currentPinchDist=Z.pinchGPoints[0].currentPos.distanceTo(Z.pinchGPoints[1].currentPos),Z.lastPinchCenter=Z.currentPinchCenter=x(Z.pinchGPoints[0].currentPos,Z.pinchGPoints[1].currentPos))):(T.shouldCapture=!1,T.shouldReleaseCapture=!1)}function ee(_,T,M,F){var Z=i[_.hash],ne=_.getActivePointersListByType(M.type),be,qe,Pe,Gt=!1,vt;if(typeof T.originalEvent.buttons<"u"?ne.buttons=T.originalEvent.buttons:F===0?ne.buttons^=-2:F===1?ne.buttons^=-5:F===2?ne.buttons^=-3:F===3?ne.buttons^=-9:F===4?ne.buttons^=-17:F===5&&(ne.buttons^=-33),T.shouldCapture=!1,F!==0){T.shouldReleaseCapture=!1,_.nonPrimaryReleaseHandler&&!T.preventGesture&&!T.defaultPrevented&&(T.preventDefault=!0,_.nonPrimaryReleaseHandler({eventSource:_,pointerType:M.type,position:m(M.currentPos,_.element),button:F,buttons:ne.buttons,isTouchEvent:M.type==="touch",originalEvent:T.originalEvent,userData:_.userData}));return}Pe=ne.getById(M.id),Pe?(ne.removeContact(),Pe.captured&&(Gt=!0),Pe.lastPos=Pe.currentPos,Pe.lastTime=Pe.currentTime,Pe.currentPos=M.currentPos,Pe.currentTime=M.currentTime,Pe.insideElement||ht(_,ne,Pe),be=Pe.currentPos,qe=Pe.currentTime):(M.captured=!1,M.insideElementPressed=!1,M.insideElement=!0,Je(ne,M),Pe=M),!T.preventGesture&&!T.defaultPrevented&&(Gt?(T.shouldReleaseCapture=!0,T.preventDefault=!0,(_.dragHandler||_.dragEndHandler||_.pinchHandler)&&t.MouseTracker.gesturePointVelocityTracker.removePoint(_,Pe),ne.contacts===0?(_.releaseHandler&&be&&_.releaseHandler({eventSource:_,pointerType:Pe.type,position:m(be,_.element),buttons:ne.buttons,insideElementPressed:Pe.insideElementPressed,insideElementReleased:Pe.insideElement,isTouchEvent:Pe.type==="touch",originalEvent:T.originalEvent,userData:_.userData}),_.dragEndHandler&&Z.sentDragEvent&&_.dragEndHandler({eventSource:_,pointerType:Pe.type,position:m(Pe.currentPos,_.element),speed:Pe.speed,direction:Pe.direction,shift:T.originalEvent.shiftKey,isTouchEvent:Pe.type==="touch",originalEvent:T.originalEvent,userData:_.userData}),Z.sentDragEvent=!1,(_.clickHandler||_.dblClickHandler)&&Pe.insideElement&&(vt=qe-Pe.contactTime<=_.clickTimeThreshold&&Pe.contactPos.distanceTo(be)<=_.clickDistThreshold,_.clickHandler&&_.clickHandler({eventSource:_,pointerType:Pe.type,position:m(Pe.currentPos,_.element),quick:vt,shift:T.originalEvent.shiftKey,isTouchEvent:Pe.type==="touch",originalEvent:T.originalEvent,originalTarget:Pe.originalTarget,userData:_.userData}),_.dblClickHandler&&vt&&(ne.clicks++,ne.clicks===1?(Z.lastClickPos=be,Z.dblClickTimeOut=setTimeout(function(){ne.clicks=0},_.dblClickTimeThreshold)):ne.clicks===2&&(clearTimeout(Z.dblClickTimeOut),ne.clicks=0,Z.lastClickPos.distanceTo(be)<=_.dblClickDistThreshold&&_.dblClickHandler({eventSource:_,pointerType:Pe.type,position:m(Pe.currentPos,_.element),shift:T.originalEvent.shiftKey,isTouchEvent:Pe.type==="touch",originalEvent:T.originalEvent,userData:_.userData}),Z.lastClickPos=null)))):ne.contacts===2&&_.pinchHandler&&Pe.type==="touch"&&(Z.pinchGPoints=ne.asArray(),Z.lastPinchDist=Z.currentPinchDist=Z.pinchGPoints[0].currentPos.distanceTo(Z.pinchGPoints[1].currentPos),Z.lastPinchCenter=Z.currentPinchCenter=x(Z.pinchGPoints[0].currentPos,Z.pinchGPoints[1].currentPos))):(T.shouldReleaseCapture=!1,_.releaseHandler&&be&&(_.releaseHandler({eventSource:_,pointerType:Pe.type,position:m(be,_.element),buttons:ne.buttons,insideElementPressed:Pe.insideElementPressed,insideElementReleased:Pe.insideElement,isTouchEvent:Pe.type==="touch",originalEvent:T.originalEvent,userData:_.userData}),T.preventDefault=!0)))}function Ve(_,T,M){var F=i[_.hash],Z=_.getActivePointersListByType(M.type),ne,be,qe;if(typeof T.originalEvent.buttons<"u"&&(Z.buttons=T.originalEvent.buttons),ne=Z.getById(M.id),ne)ne.lastPos=ne.currentPos,ne.lastTime=ne.currentTime,ne.currentPos=M.currentPos,ne.currentTime=M.currentTime;else return;T.shouldCapture=!1,T.shouldReleaseCapture=!1,_.stopHandler&&M.type==="mouse"&&(clearTimeout(_.stopTimeOut),_.stopTimeOut=setTimeout(function(){Q(_,T.originalEvent,M.type)},_.stopDelay)),Z.contacts===0?_.moveHandler&&_.moveHandler({eventSource:_,pointerType:M.type,position:m(M.currentPos,_.element),buttons:Z.buttons,isTouchEvent:M.type==="touch",originalEvent:T.originalEvent,userData:_.userData}):Z.contacts===1?(_.moveHandler&&(ne=Z.asArray()[0],_.moveHandler({eventSource:_,pointerType:ne.type,position:m(ne.currentPos,_.element),buttons:Z.buttons,isTouchEvent:ne.type==="touch",originalEvent:T.originalEvent,userData:_.userData})),_.dragHandler&&!T.preventGesture&&!T.defaultPrevented&&(ne=Z.asArray()[0],qe=ne.currentPos.minus(ne.lastPos),_.dragHandler({eventSource:_,pointerType:ne.type,position:m(ne.currentPos,_.element),buttons:Z.buttons,delta:qe,speed:ne.speed,direction:ne.direction,shift:T.originalEvent.shiftKey,isTouchEvent:ne.type==="touch",originalEvent:T.originalEvent,userData:_.userData}),T.preventDefault=!0,F.sentDragEvent=!0)):Z.contacts===2&&(_.moveHandler&&(be=Z.asArray(),_.moveHandler({eventSource:_,pointerType:be[0].type,position:m(x(be[0].currentPos,be[1].currentPos),_.element),buttons:Z.buttons,isTouchEvent:be[0].type==="touch",originalEvent:T.originalEvent,userData:_.userData})),_.pinchHandler&&M.type==="touch"&&!T.preventGesture&&!T.defaultPrevented&&(qe=F.pinchGPoints[0].currentPos.distanceTo(F.pinchGPoints[1].currentPos),qe!==F.currentPinchDist&&(F.lastPinchDist=F.currentPinchDist,F.currentPinchDist=qe,F.lastPinchCenter=F.currentPinchCenter,F.currentPinchCenter=x(F.pinchGPoints[0].currentPos,F.pinchGPoints[1].currentPos),_.pinchHandler({eventSource:_,pointerType:"touch",gesturePoints:F.pinchGPoints,lastCenter:m(F.lastPinchCenter,_.element),center:m(F.currentPinchCenter,_.element),lastDistance:F.lastPinchDist,distance:F.currentPinchDist,shift:T.originalEvent.shiftKey,originalEvent:T.originalEvent,userData:_.userData}),T.preventDefault=!0)))}function Re(_,T,M){var F=_.getActivePointersListByType(M.type),Z;Z=F.getById(M.id),Z&&ht(_,F,Z)}function Q(_,T,M){_.stopHandler&&_.stopHandler({eventSource:_,pointerType:M,position:v(T,_.element),buttons:_.getActivePointersListByType(M).buttons,isTouchEvent:M==="touch",originalEvent:T,userData:_.userData})}})(e),(function(t){t.ControlAnchor={NONE:0,TOP_LEFT:1,TOP_RIGHT:2,BOTTOM_RIGHT:3,BOTTOM_LEFT:4,ABSOLUTE:5},t.Control=function(i,r,s){var o=i.parentNode;typeof r=="number"&&(t.console.error("Passing an anchor directly into the OpenSeadragon.Control constructor is deprecated; please use an options object instead. Support for this deprecated variant is scheduled for removal in December 2013"),r={anchor:r}),r.attachToViewer=typeof r.attachToViewer>"u"?!0:r.attachToViewer,this.autoFade=typeof r.autoFade>"u"?!0:r.autoFade,this.element=i,this.anchor=r.anchor,this.container=s,this.anchor===t.ControlAnchor.ABSOLUTE?(this.wrapper=t.makeNeutralElement("div"),this.wrapper.style.position="absolute",this.wrapper.style.top=typeof r.top=="number"?r.top+"px":r.top,this.wrapper.style.left=typeof r.left=="number"?r.left+"px":r.left,this.wrapper.style.height=typeof r.height=="number"?r.height+"px":r.height,this.wrapper.style.width=typeof r.width=="number"?r.width+"px":r.width,this.wrapper.style.margin="0px",this.wrapper.style.padding="0px",this.element.style.position="relative",this.element.style.top="0px",this.element.style.left="0px",this.element.style.height="100%",this.element.style.width="100%"):(this.wrapper=t.makeNeutralElement("div"),this.wrapper.style.display="inline-block",this.anchor===t.ControlAnchor.NONE&&(this.wrapper.style.width=this.wrapper.style.height="100%")),this.wrapper.appendChild(this.element),r.attachToViewer?this.anchor===t.ControlAnchor.TOP_RIGHT||this.anchor===t.ControlAnchor.BOTTOM_RIGHT?this.container.insertBefore(this.wrapper,this.container.firstChild):this.container.appendChild(this.wrapper):o.appendChild(this.wrapper)},t.Control.prototype={destroy:function(){this.wrapper.removeChild(this.element),this.anchor!==t.ControlAnchor.NONE&&this.container.removeChild(this.wrapper)},isVisible:function(){return this.wrapper.style.display!=="none"},setVisible:function(i){this.wrapper.style.display=i?this.anchor===t.ControlAnchor.ABSOLUTE?"block":"inl
1ine-block":"none"},setOpacity:function(i){t.setElementOpacity(this.wrapper,i,!0)}}})(e),(function(t){t.ControlDock=function(r){var s=["topleft","topright","bottomright","bottomleft"],o,a;for(t.extend(!0,this,{id:"controldock-"+t.now()+"-"+Math.floor(Math.random()*1e6),container:t.makeNeutralElement("div"),controls:[]},r),this.container.onsubmit=function(){return!1},this.element&&(this.element=t.getElement(this.element),this.element.appendChild(this.container),t.getElementStyle(this.element).position==="static"&&(this.element.style.position="relative"),this.container.style.width="100%",this.container.style.height="100%"),a=0;a<s.length;a++)o=s[a],this.controls[o]=t.makeNeutralElement("div"),this.controls[o].style.position="absolute",o.match("left")&&(this.controls[o].style.left="0px"),o.match("right")&&(this.controls[o].style.right="0px"),o.match("top")&&(this.controls[o].style.top="0px"),o.match("bottom")&&(this.controls[o].style.bottom="0px");this.container.appendChild(this.controls.topleft),this.container.appendChild(this.controls.topright),this.container.appendChild(this.controls.bottomright),this.container.appendChild(this.controls.bottomleft)},t.ControlDock.prototype={addControl:function(r,s){r=t.getElement(r);var o=null;if(!(i(this,r)>=0)){switch(s.anchor){case t.ControlAnchor.TOP_RIGHT:o=this.controls.topright,r.style.position="relative",r.style.paddingRight="0px",r.style.paddingTop="0px";break;case t.ControlAnchor.BOTTOM_RIGHT:o=this.controls.bottomright,r.style.position="relative",r.style.paddingRight="0px",r.style.paddingBottom="0px";break;case t.ControlAnchor.BOTTOM_LEFT:o=this.controls.bottomleft,r.style.position="relative",r.style.paddingLeft="0px",r.style.paddingBottom="0px";break;case t.ControlAnchor.TOP_LEFT:o=this.controls.topleft,r.style.position="relative",r.style.paddingLeft="0px",r.style.paddingTop="0px";break;case t.ControlAnchor.ABSOLUTE:o=this.container,r.style.margin="0px",r.style.padding="0px";break;default:case t.ControlAnchor.NONE:o=this.container,r.style.margin="0px",r.style.padding="0px";break}this.controls.push(new t.Control(r,s,o)),r.style.display="inline-block"}},removeControl:function(r){r=t.getElement(r);var s=i(this,r);return s>=0&&(this.controls[s].destroy(),this.controls.splice(s,1)),this},clearControls:function(){for(;this.controls.length>0;)this.controls.pop().destroy();return this},areControlsEnabled:function(){var r;for(r=this.controls.length-1;r>=0;r--)if(this.controls[r].isVisible())return!0;return!1},setControlsEnabled:function(r){var s;for(s=this.controls.length-1;s>=0;s--)this.controls[s].setVisible(r);return this}};function i(r,s){var o=r.controls,a;for(a=o.length-1;a>=0;a--)if(o[a].element===s)return a;return-1}})(e),(function(t){t.Placement=t.freezeObject({CENTER:0,TOP_LEFT:1,TOP:2,TOP_RIGHT:3,RIGHT:4,BOTTOM_RIGHT:5,BOTTOM:6,BOTTOM_LEFT:7,LEFT:8,properties:{0:{isLeft:!1,isHorizontallyCentered:!0,isRight:!1,isTop:!1,isVerticallyCentered:!0,isBottom:!1},1:{isLeft:!0,isHorizontallyCentered:!1,isRight:!1,isTop:!0,isVerticallyCentered:!1,isBottom:!1},2:{isLeft:!1,isHorizontallyCentered:!0,isRight:!1,isTop:!0,isVerticallyCentered:!1,isBottom:!1},3:{isLeft:!1,isHorizontallyCentered:!1,isRight:!0,isTop:!0,isVerticallyCentered:!1,isBottom:!1},4:{isLeft:!1,isHorizontallyCentered:!1,isRight:!0,isTop:!1,isVerticallyCentered:!0,isBottom:!1},5:{isLeft:!1,isHorizontallyCentered:!1,isRight:!0,isTop:!1,isVerticallyCentered:!1,isBottom:!0},6:{isLeft:!1,isHorizontallyCentered:!0,isRight:!1,isTop:!1,isVerticallyCentered:!1,isBottom:!0},7:{isLeft:!0,isHorizontallyCentered:!1,isRight:!1,isTop:!1,isVerticallyCentered:!1,isBottom:!0},8:{isLeft:!0,isHorizontallyCentered:!1,isRight:!1,isTop:!1,isVerticallyCentered:!0,isBottom:!1}}})})(e),(function(t){var i={},r=1;t.Viewer=function(w){var I=arguments,q=this,K;t.isPlainObject(w)||(w={id:I[0],xmlPath:I.length>1?I[1]:void 0,prefixUrl:I.length>2?I[2]:void 0,controls:I.length>3?I[3]:void 0,overlays:I.length>4?I[4]:void 0}),w.config&&(t.extend(!0,w,w.config),delete w.config);let ae=["useCanvas"];if(w.drawerOptions=Object.assign({},ae.reduce((J,ye)=>(J[ye]=w[ye],delete w[ye],J),{}),w.drawerOptions),t.extend(!0,this,{id:w.id,hash:w.hash||r++,initialPage:0,element:null,container:null,canvas:null,overlays:[],overlaysContainer:null,previousBody:[],customControls:[],source:null,drawer:null,world:null,viewport:null,navigator:null,collectionViewport:null,collectionDrawer:null,navImages:null,buttonGroup:null,profiler:null},t.DEFAULT_SETTINGS,w),typeof this.hash>"u")throw new Error("A hash must be defined, either by specifying options.id or options.hash.");typeof i[this.hash]<"u"&&t.console.warn("Hash "+this.hash+" has already been used."),i[this.hash]={fsBoundsDelta:new t.Point(1,1),prevContainerSize:null,animating:!1,forceRedraw:!1,needsResize:!1,forceResize:!1,mouseInside:!1,group:null,zooming:!1,zoomFactor:null,lastZoomTime:null,fullPage:!1,onfullscreenchange:null,lastClickTime:null,draggingToZoom:!1},this._sequenceIndex=0,this._firstOpen=!0,this._updateRequestId=null,this._loadQueue=[],this.currentOverlays=[],this._updatePixelDensityRatioBind=null,this._lastScrollTime=t.now(),t.EventSource.call(this),this.addHandler("open-failed",function(J){var ye=t.getString("Errors.OpenFailed",J.eventSource,J.message);q._showMessage(ye)}),t.ControlDock.call(this,w),this.xmlPath&&(this.tileSources=[this.xmlPath]),this.element=this.element||document.getElementById(this.id),this.canvas=t.makeNeutralElement("div"),this.canvas.className="openseadragon-canvas",(function(J){J.width="100%",J.height="100%",J.overflow="hidden",J.position="absolute",J.top="0px",J.left="0px"})(this.canvas.style),t.setElementTouchActionNone(this.canvas),w.tabIndex!==""&&(this.canvas.tabIndex=w.tabIndex===void 0?0:w.tabIndex),this.container.className="openseadragon-container",(function(J){J.width="100%",J.height="100%",J.position="relative",J.overflow="hidden",J.left="0px",J.top="0px",J.textAlign="left"})(this.container.style),t.setElementTouchActionNone(this.container),this.container.insertBefore(this.canvas,this.container.firstChild),this.element.appendChild(this.container),this.bodyWidth=document.body.style.width,this.bodyHeight=document.body.style.height,this.bodyOverflow=document.body.style.overflow,this.docOverflow=document.documentElement.style.overflow,this.innerTracker=new t.MouseTracker({userData:"Viewer.innerTracker",element:this.canvas,startDisabled:!this.mouseNavEnabled,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,dblClickTimeThreshold:this.dblClickTimeThreshold,dblClickDistThreshold:this.dblClickDistThreshold,contextMenuHandler:t.delegate(this,v),keyD
vendor: 10,879 bytes, line 1
1ownHandler:t.delegate(this,m),keyHandler:t.delegate(this,x),clickHandler:t.delegate(this,y),dblClickHandler:t.delegate(this,E),dragHandler:t.delegate(this,R),dragEndHandler:t.delegate(this,P),enterHandler:t.delegate(this,S),leaveHandler:t.delegate(this,L),pressHandler:t.delegate(this,k),releaseHandler:t.delegate(this,W),nonPrimaryPressHandler:t.delegate(this,j),nonPrimaryReleaseHandler:t.delegate(this,V),scrollHandler:t.delegate(this,O),pinchHandler:t.delegate(this,N),focusHandler:t.delegate(this,D),blurHandler:t.delegate(this,A)}),this.outerTracker=new t.MouseTracker({userData:"Viewer.outerTracker",element:this.container,startDisabled:!this.mouseNavEnabled,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,dblClickTimeThreshold:this.dblClickTimeThreshold,dblClickDistThreshold:this.dblClickDistThreshold,enterHandler:t.delegate(this,B),leaveHandler:t.delegate(this,G)}),this.toolbar&&(this.toolbar=new t.ControlDock({element:this.toolbar})),this.bindStandardControls(),i[this.hash].prevContainerSize=s(this.container),window.ResizeObserver?(this._autoResizePolling=!1,this._resizeObserver=new ResizeObserver(function(){i[q.hash].needsResize=!0}),this._resizeObserver.observe(this.container,{})):this._autoResizePolling=!0,this.world=new t.World({viewer:this}),this.world.addHandler("add-item",function(J){q.source=q.world.getItemAt(0).source,i[q.hash].forceRedraw=!0,q._updateRequestId||(q._updateRequestId=h(q,Y))}),this.world.addHandler("remove-item",function(J){q.world.getItemCount()?q.source=q.world.getItemAt(0).source:q.source=null,i[q.hash].forceRedraw=!0}),this.world.addHandler("metrics-change",function(J){q.viewport&&q.viewport._setContentBounds(q.world.getHomeBounds(),q.world.getContentFactor())}),this.world.addHandler("item-index-change",function(J){q.source=q.world.getItemAt(0).source}),this.viewport=new t.Viewport({containerSize:i[this.hash].prevContainerSize,springStiffness:this.springStiffness,animationTime:this.animationTime,minZoomImageRatio:this.minZoomImageRatio,maxZoomPixelRatio:this.maxZoomPixelRatio,visibilityRatio:this.visibilityRatio,wrapHorizontal:this.wrapHorizontal,wrapVertical:this.wrapVertical,defaultZoomLevel:this.defaultZoomLevel,minZoomLevel:this.minZoomLevel,maxZoomLevel:this.maxZoomLevel,viewer:this,degrees:this.degrees,flipped:this.flipped,overlayPreserveContentDirection:this.overlayPreserveContentDirection,navigatorRotate:this.navigatorRotate,homeFillsViewer:this.homeFillsViewer,margins:this.viewportMargins,silenceMultiImageWarnings:this.silenceMultiImageWarnings}),this.viewport._setContentBounds(this.world.getHomeBounds(),this.world.getContentFactor()),this.imageLoader=new t.ImageLoader({jobLimit:this.imageLoaderLimit,timeout:w.timeout,tileRetryMax:this.tileRetryMax,tileRetryDelay:this.tileRetryDelay}),this.tileCache=new t.TileCache({maxImageCacheCount:this.maxImageCacheCount}),Object.prototype.hasOwnProperty.call(this.drawerOptions,"useCanvas")&&(t.console.error('useCanvas is deprecated, use the "drawer" option to indicate preferred drawer(s)'),this.drawerOptions.useCanvas||(this.drawer=t.HTMLDrawer),delete this.drawerOptions.useCanvas);let he=Array.isArray(this.drawer)?this.drawer:[this.drawer];he.length===0&&(he=[t.DEFAULT_SETTINGS.drawer].flat(),t.console.warn("No valid drawers were selected. Using the default value.")),this.drawer=null;for(const J of he)if(this.requestDrawer(J,{mainDrawer:!0,redrawImmediately:!1}))break;if(!this.drawer)throw t.console.error("No drawer could be created!"),"Error with creating the selected drawer(s)";for(this.drawer.setImageSmoothingEnabled(this.imageSmoothingEnabled),this.overlaysContainer=t.makeNeutralElement("div"),this.canvas.appendChild(this.overlaysContainer),this.drawer.canRotate()||(this.rotateLeft&&(K=this.buttonGroup.buttons.indexOf(this.rotateLeft),this.buttonGroup.buttons.splice(K,1),this.buttonGroup.element.removeChild(this.rotateLeft.element)),this.rotateRight&&(K=this.buttonGroup.buttons.indexOf(this.rotateRight),this.buttonGroup.buttons.splice(K,1),this.buttonGroup.element.removeChild(this.rotateRight.element))),this._addUpdatePixelDensityRatioEvent(),this.showNavigator&&(this.navigator=new t.Navigator({element:this.navigatorElement,id:this.navigatorId,position:this.navigatorPosition,sizeRatio:this.navigatorSizeRatio,maintainSizeRatio:this.navigatorMaintainSizeRatio,top:this.navigatorTop,left:this.navigatorLeft,width:this.navigatorWidth,height:this.navigatorHeight,autoResize:this.navigatorAutoResize,autoFade:this.navigatorAutoFade,prefixUrl:this.prefixUrl,viewer:this,navigatorRotate:this.navigatorRotate,background:this.navigatorBackground,opacity:this.navigatorOpacity,borderColor:this.navigatorBorderColor,displayRegionColor:this.navigatorDisplayRegionColor,crossOriginPolicy:this.crossOriginPolicy,animationTime:this.animationTime,drawer:this.drawer.getType(),loadTilesWithAjax:this.loadTilesWithAjax,ajaxHeaders:this.ajaxHeaders,ajaxWithCredentials:this.ajaxWithCredentials})),this.sequenceMode&&this.bindSequenceControls(),this.tileSources&&this.open(this.tileSources),K=0;K<this.customControls.length;K++)this.addControl(this.customControls[K].id,{anchor:this.customControls[K].anchor});t.requestAnimationFrame(function(){c(q)}),t._viewers.set(this.element,this)},t.extend(t.Viewer.prototype,t.EventSource.prototype,t.ControlDock.prototype,{isOpen:function(){return!!this.world.getItemCount()},openDzi:function(w){return t.console.error("[Viewer.openDzi] this function is deprecated; use Viewer.open() instead."),this.open(w)},openTileSource:function(w){return t.console.error("[Viewer.openTileSource] this function is deprecated; use Viewer.open() instead."),this.open(w)},get buttons(){return t.console.warn("Viewer.buttons is deprecated; Please use Viewer.buttonGroup"),this.buttonGroup},open:function(w,I){var q=this;if(this.close(),!w)return this;if(this.sequenceMode&&t.isArray(w))return this.referenceStrip&&(this.referenceStrip.destroy(),this.referenceStrip=null),typeof I<"u"&&!isNaN(I)&&(this.initialPage=I),this.tileSources=w,this._sequenceIndex=Math.max(0,Math.min(this.tileSources.length-1,this.initialPage)),this.tileSources.length&&(this.open(this.tileSources[this._sequenceIndex]),this.showReferenceStrip&&this.addReferenceStrip()),this._updateSequenceButtons(this._sequenceIndex),this;if(t.isArray(w)||(w=[w]),!w.length)return this;this._opening=!0;for(var K=w.length,ae=0,he=0,J,ye=function(){if(ae+he===K)if(ae){(q._firstOpen||!q.preserveViewport)&&(q.viewport.goHome(!0),q.viewport.update()),q._firstOpen=!1;var Re=w[0];if(Re.tileSource&&(Re=Re.tileSource),q.overlays&&!q.preserveOverlays)for(var Q=0;Q<q.overlays.length;Q++)q.currentOverlays[Q]=a(q,q.overlays[Q]);q._drawOverlays(),q._opening=!1,q.raiseEvent("open",{source:Re})}else q._opening=!1,q.raiseEvent("open-failed",J)},ee=function(Re){(!t.isPlainObject(Re)||!Re.tileSource)&&(Re={tileSource:Re}),Re.index!==void 0&&(t.console.error("[Viewer.open] setting indexes here is not supported; use addTiledImage instead"),delete Re.index),Re.collectionImmediately===void 0&&(Re.collectionImmediately=!0);var Q=Re.success;Re.success=function(T){if(ae++,Re.tileSource.overlays)for(var M=0;M<Re.tileSource.overlays.length;M++)q.addOverlay(Re.tileSource.overlays[M]);Q&&Q(T),ye()};var _=Re.error;Re.error=function(T){he++,J||(J=T),_&&_(T),ye()},q.addTiledImage(Re)},Ve=0;Ve<w.length;Ve++)ee(w[Ve]);return this},close:function(){return i[this.hash]?(this._opening=!1,this.navigator&&this.navigator.close(),this.preserveOverlays||(this.clearOverlays(),this.overlaysContainer.innerHTML=""),i[this.hash].animating=!1,this.world.removeAll(),this.imageLoader.clear(),this.raiseEvent("close"),this):this},destroy:function(){if(i[this.hash]){if(this.raiseEvent("before-destroy"),this._removeUpdatePixelDensityRatioEvent(),this.close(),this.clearOverlays(),this.overlaysContainer.innerHTML="",this._resizeObserver&&this._resizeObserver.disconnect(),this.referenceStrip&&(this.referenceStrip.destroy(),this.referenceStrip=null),this._updateRequestId!==null&&(t.cancelAnimationFrame(this._updateRequestId),this._updateRequestId=null),this.drawer&&this.drawer.destroy(),this.navigator&&(this.navigator.destroy(),i[this.navigator.hash]=null,delete i[this.navigator.hash],this.navigator=null),this.buttonGroup)this.buttonGroup.destroy();else if(this.customButtons)for(;this.customButtons.length;)this.customButtons.pop().destroy();if(this.paging&&this.paging.destroy(),this.element)for(;this.element.firstChild;)this.element.removeChild(this.element.firstChild);this.container.onsubmit=null,this.clearControls(),this.innerTracker&&this.innerTracker.destroy(),this.outerTracker&&this.outerTracker.destroy(),i[this.hash]=null,delete i[this.hash],this.canvas=null,this.container=null,t._viewers.delete(this.element),this.element=null,this.raiseEvent("destroy"),this.removeAllHandlers()}},requestDrawer(w,I){const q={mainDrawer:!0,redrawImmediately:!0,drawerOptions:null};I=t.extend(!0,q,I);const K=I.mainDrawer,ae=I.redrawImmediately,he=I.drawerOptions,J=this.drawer;let ye=null;if(w&&w.prototype instanceof t.DrawerBase?(ye=w,w="custom"):typeof w=="string"&&(ye=t.determineDrawer(w)),ye||t.console.warn("Unsupported drawer! Drawer must be an existing string type, or a class that extends OpenSeadragon.DrawerBase."),ye&&ye.isSupported()){J&&K&&J.destroy();const ee=new ye({viewer:this,viewport:this.viewport,element:this.canvas,debugGridColor:this.debugGridColor,options:he||this.drawerOptions[w]});return K&&(this.drawer=ee,ae&&this.forceRedraw()),ee}return!1},isMouseNavEnabled:function(){return this.innerTracker.isTracking()},setMouseNavEnabled:function(w){return this.innerTracker.setTracking(w),this.outerTracker.setTracking(w),this.raiseEvent("mouse-enabled",{enabled:w}),this},areControlsEnabled:function(){var w=this.controls.length,I;for(I=0;I<this.controls.length;I++)w=w&&this.controls[I].isVisible();return w},setControlsEnabled:function(w){return w?f(this):c(this),this.raiseEvent("controls-enabled",{enabled:w}),this},setDebugMode:function(w){for(var I=0;I<this.world.getItemCount();I++)this.world.getItemAt(I).debugMode=w;this.debugMode=w,this.forceRedraw()},setAjaxHeaders:function(w,I){if(w===null&&(w={}),!t.isPlainObject(w)){console.error("[Viewer.setAjaxHeaders] Ignoring invalid headers, must be a plain object");return}if(I===void 0&&(I=!0),this.ajaxHeaders=w,I){for(var q=0;q<this.world.getItemCount();q++)this.world.getItemAt(q)._updateAjaxHeaders(!0);if(this.navigator&&this.navigator.setAjaxHeaders(this.ajaxHeaders,!0),this.referenceStrip&&this.referenceStrip.miniViewers)for(var K in this.referenceStrip.miniViewers)this.referenceStrip.miniViewers[K].setAjaxHeaders(this.ajaxHeaders,!0)}},addButton:function(w){this.buttonGroup.addButton(w)},isFullPage:function(){return i[this.hash]&&i[this.hash].fullPage},setFullPage:function(w){var I=document.body,q=I.style,K=document.documentElement.style,ae
vendor: 4,661 bytes, line 1
1=this,he,J;if(w===this.isFullPage())return this;var ye={fullPage:w,preventDefaultAction:!1};if(this.raiseEvent("pre-full-page",ye),ye.preventDefaultAction)return this;if(w&&this.element){for(this.elementSize=t.getElementSize(this.element),this.pageScroll=t.getPageScroll(),this.elementMargin=this.element.style.margin,this.element.style.margin="0",this.elementPadding=this.element.style.padding,this.element.style.padding="0",this.bodyMargin=q.margin,this.docMargin=K.margin,q.margin="0",K.margin="0",this.bodyPadding=q.padding,this.docPadding=K.padding,q.padding="0",K.padding="0",this.bodyWidth=q.width,this.docWidth=K.width,q.width="100%",K.width="100%",this.bodyHeight=q.height,this.docHeight=K.height,q.height="100%",K.height="100%",this.bodyDisplay=q.display,q.display="block",this.previousBody=[],i[this.hash].prevElementParent=this.element.parentNode,i[this.hash].prevNextSibling=this.element.nextSibling,i[this.hash].prevElementWidth=this.element.style.width,i[this.hash].prevElementHeight=this.element.style.height,he=I.childNodes.length,J=0;J<he;J++)this.previousBody.push(I.childNodes[0]),I.removeChild(I.childNodes[0]);this.toolbar&&this.toolbar.element&&(this.toolbar.parentNode=this.toolbar.element.parentNode,this.toolbar.nextSibling=this.toolbar.element.nextSibling,I.appendChild(this.toolbar.element),t.addClass(this.toolbar.element,"fullpage")),t.addClass(this.element,"fullpage"),I.appendChild(this.element),this.element.style.height="100vh",this.element.style.width="100vw",this.toolbar&&this.toolbar.element&&(this.element.style.height=t.getElementSize(this.element).y-t.getElementSize(this.toolbar.element).y+"px"),i[this.hash].fullPage=!0,t.delegate(this,B)({})}else{for(this.element.style.margin=this.elementMargin,this.element.style.padding=this.elementPadding,q.margin=this.bodyMargin,K.margin=this.docMargin,q.padding=this.bodyPadding,K.padding=this.docPadding,q.width=this.bodyWidth,K.width=this.docWidth,q.height=this.bodyHeight,K.height=this.docHeight,q.display=this.bodyDisplay,I.removeChild(this.element),he=this.previousBody.length,J=0;J<he;J++)I.appendChild(this.previousBody.shift());t.removeClass(this.element,"fullpage"),i[this.hash].prevElementParent.insertBefore(this.element,i[this.hash].prevNextSibling),this.toolbar&&this.toolbar.element&&(I.removeChild(this.toolbar.element),t.removeClass(this.toolbar.element,"fullpage"),this.toolbar.parentNode.insertBefore(this.toolbar.element,this.toolbar.nextSibling),delete this.toolbar.parentNode,delete this.toolbar.nextSibling),this.element.style.width=i[this.hash].prevElementWidth,this.element.style.height=i[this.hash].prevElementHeight;var ee=0,Ve=function(){t.setPageScroll(ae.pageScroll);var Re=t.getPageScroll();ee++,ee<10&&(Re.x!==ae.pageScroll.x||Re.y!==ae.pageScroll.y)&&t.requestAnimationFrame(Ve)};t.requestAnimationFrame(Ve),i[this.hash].fullPage=!1,t.delegate(this,G)({})}return this.navigator&&this.viewport&&this.navigator.update(this.viewport),this.raiseEvent("full-page",{fullPage:w}),this},setFullScreen:function(w){var I=this;if(!t.supportsFullScreen)return this.setFullPage(w);if(t.isFullScreen()===w)return this;var q={fullScreen:w,preventDefaultAction:!1};if(this.raiseEvent("pre-full-screen",q),q.preventDefaultAction)return this;if(w){if(this.setFullPage(!0),!this.isFullPage())return this;this.fullPageStyleWidth=this.element.style.width,this.fullPageStyleHeight=this.element.style.height,this.element.style.width="100%",this.element.style.height="100%";var K=function(){var ae=t.isFullScreen();ae||(t.removeEvent(document,t.fullScreenEventName,K),t.removeEvent(document,t.fullScreenErrorEventName,K),I.setFullPage(!1),I.isFullPage()&&(I.element.style.width=I.fullPageStyleWidth,I.element.style.height=I.fullPageStyleHeight)),I.navigator&&I.viewport&&setTimeout(function(){I.navigator.update(I.viewport)}),I.raiseEvent("full-screen",{fullScreen:ae})};t.addEvent(document,t.fullScreenEventName,K),t.addEvent(document,t.fullScreenErrorEventName,K),t.requestFullScreen(document.body)}else t.exitFullScreen();return this},isVisible:function(){return this.container.style.visibility!=="hidden"},isFullScreen:function(){return t.isFullScreen()&&this.isFullPage()},setVisible:function(w){return this.container.style.visibility=w?"":"hidden",this.raiseEvent("visible",{visible:w}),this},addTiledImage:function(w){t.console.assert(w,"[Viewer.addTiledImage] options is required"),t.console.assert(w.tileSource,"[Viewer.addTiledImage] options.tileSource is required"),t.console.assert(!w.replace||w.index>-1&&w.index<this.world.getItemCount(),"[Viewer.addTiledImage] if options.replace is used, options.index must be a valid index in Viewer.world");var I=this;
vendor: 4,110 bytes, line 1
1w.replace&&(w.replaceItem=I.world.getItemAt(w.index)),this._hideMessage(),w.placeholderFillStyle===void 0&&(w.placeholderFillStyle=this.placeholderFillStyle),w.opacity===void 0&&(w.opacity=this.opacity),w.preload===void 0&&(w.preload=this.preload),w.compositeOperation===void 0&&(w.compositeOperation=this.compositeOperation),w.crossOriginPolicy===void 0&&(w.crossOriginPolicy=w.tileSource.crossOriginPolicy!==void 0?w.tileSource.crossOriginPolicy:this.crossOriginPolicy),w.ajaxWithCredentials===void 0&&(w.ajaxWithCredentials=this.ajaxWithCredentials),w.loadTilesWithAjax===void 0&&(w.loadTilesWithAjax=this.loadTilesWithAjax),t.isPlainObject(w.ajaxHeaders)||(w.ajaxHeaders={});var q={options:w};function K(J){for(var ye=0;ye<I._loadQueue.length;ye++)if(I._loadQueue[ye]===q){I._loadQueue.splice(ye,1);break}I._loadQueue.length===0&&ae(q),I.raiseEvent("add-item-failed",J),w.error&&w.error(J)}function ae(J){I.collectionMode&&(I.world.arrange({immediately:J.options.collectionImmediately,rows:I.collectionRows,columns:I.collectionColumns,layout:I.collectionLayout,tileSize:I.collectionTileSize,tileMargin:I.collectionTileMargin}),I.world.setAutoRefigureSizes(!0))}if(t.isArray(w.tileSource)){setTimeout(function(){K({message:"[Viewer.addTiledImage] Sequences can not be added; add them one at a time instead.",source:w.tileSource,options:w})});return}this._loadQueue.push(q);function he(){for(var J,ye,ee;I._loadQueue.length&&(J=I._loadQueue[0],!!J.tileSource);){if(I._loadQueue.splice(0,1),J.options.replace){var Ve=I.world.getIndexOfItem(J.options.replaceItem);Ve!==-1&&(J.options.index=Ve),I.world.removeItem(J.options.replaceItem)}ye=new t.TiledImage({viewer:I,source:J.tileSource,viewport:I.viewport,drawer:I.drawer,tileCache:I.tileCache,imageLoader:I.imageLoader,x:J.options.x,y:J.options.y,width:J.options.width,height:J.options.height,fitBounds:J.options.fitBounds,fitBoundsPlacement:J.options.fitBoundsPlacement,clip:J.options.clip,placeholderFillStyle:J.options.placeholderFillStyle,opacity:J.options.opacity,preload:J.options.preload,degrees:J.options.degrees,flipped:J.options.flipped,compositeOperation:J.options.compositeOperation,springStiffness:I.springStiffness,animationTime:I.animationTime,minZoomImageRatio:I.minZoomImageRatio,wrapHorizontal:I.wrapHorizontal,wrapVertical:I.wrapVertical,maxTilesPerFrame:I.maxTilesPerFrame,immediateRender:I.immediateRender,blendTime:I.blendTime,alwaysBlend:I.alwaysBlend,minPixelRatio:I.minPixelRatio,smoothTileEdgesMinZoom:I.smoothTileEdgesMinZoom,iOSDevice:I.iOSDevice,crossOriginPolicy:J.options.crossOriginPolicy,ajaxWithCredentials:J.options.ajaxWithCredentials,loadTilesWithAjax:J.options.loadTilesWithAjax,ajaxHeaders:J.options.ajaxHeaders,debugMode:I.debugMode,subPixelRoundingForTransparency:I.subPixelRoundingForTransparency}),I.collectionMode&&I.world.setAutoRefigureSizes(!1),I.navigator&&(ee=t.extend({},J.options,{replace:!1,originalTiledImage:ye,tileSource:J.tileSource}),I.navigator.addTiledImage(ee)),I.world.addItem(ye,{index:J.options.index}),I._loadQueue.length===0&&ae(J),I.world.getItemCount()===1&&!I.preserveViewport&&I.viewport.goHome(!0),J.options.success&&J.options.success({item:ye})}}o(this,w.tileSource,w,function(J){q.tileSource=J,he()},function(J){J.options=w,K(J),he()})},addSimpleImage:function(w){t.console.assert(w,"[Viewer.addSimpleImage] options is required"),t.console.assert(w.url,"[Viewer.addSimpleImage] options.url is required");var I=t.extend({},w,{tileSource:{type:"image",url:w.url}});delete I.url,this.addTiledImage(I)},addLayer:function(w){var I=this;t.console.error("[Viewer.addLayer] this function is deprecated; use Viewer.addTiledImage() instead.");var q=t.extend({},w,{success:function(K){I.raiseEvent("add-layer",{options:w,drawer:K.item})},error:function(K){I.raiseEvent("add-layer-failed",K)}});return this.addTiledImage(q),this},getLayerAtLevel:function(w){return t.console.error("[Viewer.getLayerAtLevel] this function is deprecated; use World.getItemAt() instead."),this.world.getItemAt(w)},getLevelOfLayer:function(w){return t.console.error("[Viewer.getLevelOfLayer] this function is deprecated;
1 use World.getIndexOfItem() instead."),this.world.getIndexOfItem(w)},getLayersCount:function(){return t.console.error("[Viewer.getLayersCount] this function is deprecated; use World.getItemCount() instead."),this.world.getItemCount()},setLayerLevel:function(w,I){return t.console.error("[Viewer.setLayerLevel] this function is deprecated; use World.setItemIndex() instead."),this.world.setItemIndex(w,I)},removeLayer:function(w){return t.console.error("[Viewer.removeLayer] this function is deprecated; use World.removeItem() instead."),this.world.removeItem(w)},forceRedraw:function(){return i[this.hash].forceRedraw=!0,this},forceResize:function(){i[this.hash].needsResize=!0,i[this.hash].forceResize=!0},bindSequenceControls:function(){var w=t.delegate(this,p),I=t.delegate(this,g),q=t.delegate(this,this.goToNextPage),K=t.delegate(this,this.goToPreviousPage),ae=this.navImages,he=!0;return this.showSequenceControl&&((this.previousButton||this.nextButton)&&(he=!1),this.previousButton=new t.Button({element:this.previousButton?t.getElement(this.previousButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.PreviousPage"),srcRest:X(this.prefixUrl,ae.previous.REST),srcGroup:X(this.prefixUrl,ae.previous.GROUP),srcHover:X(this.prefixUrl,ae.previous.HOVER),srcDown:X(this.prefixUrl,ae.previous.DOWN),onRelease:K,onFocus:w,onBlur:I}),this.nextButton=new t.Button({element:this.nextButton?t.getElement(this.nextButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.NextPage"),srcRest:X(this.prefixUrl,ae.next.REST),srcGroup:X(this.prefixUrl,ae.next.GROUP),srcHover:X(this.prefixUrl,ae.next.HOVER),srcDown:X(this.prefixUrl,ae.next.DOWN),onRelease:q,onFocus:w,onBlur:I}),this.navPrevNextWrap||this.previousButton.disable(),(!this.tileSources||!this.tileSources.length)&&this.nextButton.disable(),he&&(this.paging=new t.ButtonGroup({buttons:[this.previousButton,this.nextButton],clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold}),this.pagingControl=this.paging.element,this.toolbar?this.toolbar.addControl(this.pagingControl,{anchor:t.ControlAnchor.BOTTOM_RIGHT}):this.addControl(this.pagingControl,{anchor:this.sequenceControlAnchor||t.ControlAnchor.TOP_LEFT}))),this},bindStandardControls:function(){var w=t.delegate(this,$),I=t.delegate(this,se),q=t.delegate(this,ge),K=t.delegate(this,re),ae=t.delegate(this,de),he=t.delegate(this,me),J=t.delegate(this,De),ye=t.delegate(this,it),ee=t.delegate(this,Je),Ve=t.delegate(this,ht),Re=t.delegate(this,p),Q=t.delegate(this,g),_=this.navImages,T=[],M=!0;return this.showNavigationControl&&((this.zoomInButton||this.zoomOutButton||this.homeButton||this.fullPageButton||this.rotateLeftButton||this.rotateRightButton||this.flipButton)&&(M=!1),this.showZoomControl&&(T.push(this.zoomInButton=new t.Button({element:this.zoomInButton?t.getElement(this.zoomInButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.ZoomIn"),srcRest:X(this.prefixUrl,_.zoomIn.REST),srcGroup:X(this.prefixUrl,_.zoomIn.GROUP),srcHover:X(this.prefixUrl,_.zoomIn.HOVER),srcDown:X(this.prefixUrl,_.zoomIn.DOWN),onPress:w,onRelease:I,onClick:q,onEnter:w,onExit:I,onFocus:Re,onBlur:Q})),T.push(this.zoomOutButton=new t.Button({element:this.zoomOutButton?t.getElement(this.zoomOutButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.ZoomOut"),srcRest:X(this.prefixUrl,_.zoomOut.REST),srcGroup:X(this.prefixUrl,_.zoomOut.GROUP),srcHover:X(this.prefixUrl,_.zoomOut.HOVER),srcDown:X(this.prefixUrl,_.zoomOut.DOWN),onPress:K,onRelease:I,onClick:ae,onEnter:K,onExit:I,onFocus:Re,onBlur:Q}))),this.showHomeControl&&T.push(this.homeButton=new t.Button({element:this.homeButton?t.getElement(this.homeButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.Home"),srcRest:X(this.prefixUrl,_.home.REST),srcGroup:X(this.prefixUrl,_.home.GROUP),srcHover:X(this.prefixUrl,_.home.HOVER),srcDown:X(this.prefixUrl,_.home.DOWN),onRelease:he,onFocus:Re,onBlur:Q}
vendor: 58,908 bytes, line 1
1)),this.showFullPageControl&&T.push(this.fullPageButton=new t.Button({element:this.fullPageButton?t.getElement(this.fullPageButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.FullPage"),srcRest:X(this.prefixUrl,_.fullpage.REST),srcGroup:X(this.prefixUrl,_.fullpage.GROUP),srcHover:X(this.prefixUrl,_.fullpage.HOVER),srcDown:X(this.prefixUrl,_.fullpage.DOWN),onRelease:J,onFocus:Re,onBlur:Q})),this.showRotationControl&&(T.push(this.rotateLeftButton=new t.Button({element:this.rotateLeftButton?t.getElement(this.rotateLeftButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.RotateLeft"),srcRest:X(this.prefixUrl,_.rotateleft.REST),srcGroup:X(this.prefixUrl,_.rotateleft.GROUP),srcHover:X(this.prefixUrl,_.rotateleft.HOVER),srcDown:X(this.prefixUrl,_.rotateleft.DOWN),onRelease:ye,onFocus:Re,onBlur:Q})),T.push(this.rotateRightButton=new t.Button({element:this.rotateRightButton?t.getElement(this.rotateRightButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.RotateRight"),srcRest:X(this.prefixUrl,_.rotateright.REST),srcGroup:X(this.prefixUrl,_.rotateright.GROUP),srcHover:X(this.prefixUrl,_.rotateright.HOVER),srcDown:X(this.prefixUrl,_.rotateright.DOWN),onRelease:ee,onFocus:Re,onBlur:Q}))),this.showFlipControl&&T.push(this.flipButton=new t.Button({element:this.flipButton?t.getElement(this.flipButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.Flip"),srcRest:X(this.prefixUrl,_.flip.REST),srcGroup:X(this.prefixUrl,_.flip.GROUP),srcHover:X(this.prefixUrl,_.flip.HOVER),srcDown:X(this.prefixUrl,_.flip.DOWN),onRelease:Ve,onFocus:Re,onBlur:Q})),M?(this.buttonGroup=new t.ButtonGroup({buttons:T,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold}),this.navControl=this.buttonGroup.element,this.addHandler("open",t.delegate(this,Te)),this.toolbar?this.toolbar.addControl(this.navControl,{anchor:this.navigationControlAnchor||t.ControlAnchor.TOP_LEFT}):this.addControl(this.navControl,{anchor:this.navigationControlAnchor||t.ControlAnchor.TOP_LEFT})):this.customButtons=T),this},currentPage:function(){return this._sequenceIndex},goToPage:function(w){return this.tileSources&&w>=0&&w<this.tileSources.length&&(this._sequenceIndex=w,this._updateSequenceButtons(w),this.open(this.tileSources[w]),this.referenceStrip&&this.referenceStrip.setFocus(w),this.raiseEvent("page",{page:w})),this},addOverlay:function(w,I,q,K){var ae;if(t.isPlainObject(w)?ae=w:ae={element:w,location:I,placement:q,onDraw:K},w=t.getElement(ae.element),l(this.currentOverlays,w)>=0)return this;var he=a(this,ae);return this.currentOverlays.push(he),he.drawHTML(this.overlaysContainer,this.viewport),this.raiseEvent("add-overlay",{element:w,location:ae.location,placement:ae.placement}),this},updateOverlay:function(w,I,q){var K;return w=t.getElement(w),K=l(this.currentOverlays,w),K>=0&&(this.currentOverlays[K].update(I,q),i[this.hash].forceRedraw=!0,this.raiseEvent("update-overlay",{element:w,location:I,placement:q})),this},removeOverlay:function(w){var I;return w=t.getElement(w),I=l(this.currentOverlays,w),I>=0&&(this.currentOverlays[I].destroy(),this.currentOverlays.splice(I,1),i[this.hash].forceRedraw=!0,this.raiseEvent("remove-overlay",{element:w})),this},clearOverlays:function(){for(;this.currentOverlays.length>0;)this.currentOverlays.pop().destroy();return i[this.hash].forceRedraw=!0,this.raiseEvent("clear-overlay",{}),this},getOverlayById:function(w){var I;return w=t.getElement(w),I=l(this.currentOverlays,w),I>=0?this.currentOverlays[I]:null},_updateSequenceButtons:function(w){this.nextButton&&(!this.tileSources||this.tileSources.length-1===w?this.navPrevNextWrap||this.nextButton.disable():this.nextButton.enable()),this.previousButton&&(w>0?this.previousButton.enable():this.navPrevNextWrap||this.previousButton.disable())},_showMessage:function(w){this._hideMessage();var I=t.makeNeutralElement("div");I.appendChild(document.createTextNode(w)),this.messageDiv=t.makeCenteredNode(I),t.addClass(this.messageDiv,"openseadragon-message"),this.container.appendChild(this.messageDiv)},_hideMessage:function(){var w=this.messageDiv;w&&(w.parentNode.removeChild(w),delete this.messageDiv)},gestureSettingsByDeviceType:function(w){switch(w){case"mouse":return this.gestureSettingsMouse;case"touch":return this.gestureSettingsTouch;case"pen":return this.gestureSettingsPen;default:return this.gestureSettingsUnknown}},_drawOverlays:function(){var w,I=this.currentOverlays.length;for(w=0;w<I;w++)this.currentOverlays[w].drawHTML(this.overlaysContainer,this.viewport)},_cancelPendingImages:function(){this._loadQueue=[]},removeReferenceStrip:function(){this.showReferenceStrip=!1,this.referenceStrip&&(this.referenceStrip.destroy(),this.referenceStrip=null)},addReferenceStrip:function(){if(this.showReferenceStrip=!0,this.sequenceMode){if(this.referenceStrip)return;this.tileSources.length&&this.tileSources.length>1&&(this.referenceStrip=new t.ReferenceStrip({id:this.referenceStripElement,position:this.referenceStripPosition,sizeRatio:this.referenceStripSizeRatio,scroll:this.referenceStripScroll,height:this.referenceStripHeight,width:this.referenceStripWidth,tileSources:this.tileSources,prefixUrl:this.prefixUrl,viewer:this}),this.referenceStrip.setFocus(this._sequenceIndex))}else t.console.warn('Attempting to display a reference strip while "sequenceMode" is off.')},_addUpdatePixelDensityRatioEvent:function(){this._updatePixelDensityRatioBind=this._updatePixelDensityRatio.bind(this),t.addEvent(window,"resize",this._updatePixelDensityRatioBind)},_removeUpdatePixelDensityRatioEvent:function(){t.removeEvent(window,"resize",this._updatePixelDensityRatioBind)},_updatePixelDensityRatio:function(){var w=t.pixelDensityRatio,I=t.getCurrentPixelDensityRatio();w!==I&&(t.pixelDensityRatio=I,this.forceResize())},goToPreviousPage:function(){var w=this._sequenceIndex-1;this.navPrevNextWrap&&w<0&&(w+=this.tileSources.length),this.goToPage(w)},goToNextPage:function(){var w=this._sequenceIndex+1;this.navPrevNextWrap&&w>=this.tileSources.length&&(w=0),this.goToPage(w)},isAnimating:function(){return i[this.hash].animating}});function s(w){return w=t.getElement(w),new t.Point(w.clientWidth===0?1:w.clientWidth,w.clientHeight===0?1:w.clientHeight)}function o(w,I,q,K,ae){var he=w;if(t.type(I)==="string"){if(I.match(/^\s*<.*>\s*$/))I=t.parseXml(I);else if(I.match(/^\s*[{[].*[}\]]\s*$/))try{var J=t.parseJSON(I);I=J}catch{}}function ye(ee,Ve){ee.ready?K(ee):(ee.addHandler("ready",function(){K(ee)}),ee.addHandler("open-failed",function(Re){ae({message:Re.message,source:Ve})}))}setTimeout(function(){if(t.type(I)==="string")I=new t.TileSource({url:I,crossOriginPolicy:q.crossOriginPolicy!==void 0?q.crossOriginPolicy:w.crossOriginPolicy,ajaxWithCredentials:w.ajaxWithCredentials,ajaxHeaders:q.ajaxHeaders?q.ajaxHeaders:w.ajaxHeaders,splitHashDataForPost:w.splitHashDataForPost,success:function(Q){K(Q.tileSource)}}),I.addHandler("open-failed",function(Q){ae(Q)});else if(t.isPlainObject(I)||I.nodeType)if(I.crossOriginPolicy===void 0&&(q.crossOriginPolicy!==void 0||w.crossOriginPolicy!==void 0)&&(I.crossOriginPolicy=q.crossOriginPolicy!==void 0?q.crossOriginPolicy:w.crossOriginPolicy),I.ajaxWithCredentials===void 0&&(I.ajaxWithCredentials=w.ajaxWithCredentials),t.isFunction(I.getTileUrl)){var ee=new t.TileSource(I);ee.getTileUrl=I.getTileUrl,K(ee)}else{var Ve=t.TileSource.determineType(he,I);if(!Ve){ae({message:"Unable to load TileSource",source:I});return}var Re=Ve.prototype.configure.apply(he,[I]);ye(new Ve(Re),I)}else ye(I,I)})}function a(w,I){if(I instanceof t.Overlay)return I;var q=null;if(I.element)q=t.getElement(I.element);else{var K=I.id?I.id:"openseadragon-overlay-"+Math.floor(Math.random()*1e7);q=t.getElement(I.id),q||(q=document.createElement("a"),q.href="#/overlay/"+K),q.id=K,t.addClass(q,I.className?I.className:"openseadragon-overlay")}var ae=I.location,he=I.width,J=I.height;if(!ae){var ye=I.x,ee=I.y;if(I.px!==void 0){var Ve=w.viewport.imageToViewportRectangle(new t.Rect(I.px,I.py,he||0,J||0));ye=Ve.x,ee=Ve.y,he=he!==void 0?Ve.width:void 0,J=J!==void 0?Ve.height:void 0}ae=new t.Point(ye,ee)}var Re=I.placement;return Re&&t.type(Re)==="string"&&(Re=t.Placement[I.placement.toUpperCase()]),new t.Overlay({element:q,location:ae,placement:Re,onDraw:I.onDraw,checkResize:I.checkResize,width:he,height:J,rotationMode:I.rotationMode})}function l(w,I){var q;for(q=w.length-1;q>=0;q--)if(w[q].element===I)return q;return-1}function h(w,I){return t.requestAnimationFrame(function(){I(w)})}function u(w){t.requestAnimationFrame(function(){d(w)})}function c(w){w.autoHideControls&&(w.controlsShouldFade=!0,w.controlsFadeBeginTime=t.now()+w.controlsFadeDelay,window.setTimeout(function(){u(w)},w.controlsFadeDelay))}function d(w){var I,q,K,ae;if(w.controlsShouldFade){for(I=t.now(),q=I-w.controlsFadeBeginTime,K=1-q/w.controlsFadeLength,K=Math.min(1,K),K=Math.max(0,K),ae=w.controls.length-1;ae>=0;ae--)w.controls[ae].autoFade&&w.controls[ae].setOpacity(K);K>0&&u(w)}}function f(w){var I;for(w.controlsShouldFade=!1,I=w.controls.length-1;I>=0;I--)w.controls[I].setOpacity(1)}function p(){f(this)}function g(){c(this)}function v(w){var I={tracker:w.eventSource,position:w.position,originalEvent:w.originalEvent,preventDefault:w.preventDefault};this.raiseEvent("canvas-contextmenu",I),w.preventDefault=I.preventDefault}function m(w){var I={originalEvent:w.originalEvent,preventDefaultAction:!1,preventVerticalPan:w.preventVerticalPan||!this.panVertical,preventHorizontalPan:w.preventHorizontalPan||!this.panHorizontal};if(this.raiseEvent("canvas-key",I),!I.preventDefaultAction&&!w.ctrl&&!w.alt&&!w.meta)switch(w.keyCode){case 38:I.preventVerticalPan||(w.shift?this.viewport.zoomBy(1.1):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(0,-this.pixelsPerArrowPress))),this.viewport.applyConstraints()),w.preventDefault=!0;break;case 40:I.preventVerticalPan||(w.shift?this.viewport.zoomBy(.9):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(0,this.pixelsPerArrowPress))),this.viewport.applyConstraints()),w.preventDefault=!0;break;case 37:I.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(-this.pixelsPerArrowPress,0))),this.viewport.applyConstraints()),w.preventDefault=!0;break;case 39:I.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(this.pixelsPerArrowPress,0))),this.viewport.applyConstraints()),w.preventDefault=!0;break;case 187:this.viewport.zoomBy(1.1),this.viewport.applyConstraints(),w.preventDefault=!0;break;case 189:this.viewport.zoomBy(.9),this.viewport.applyConstraints(),w.preventDefault=!0;break;case 48:this.viewport.goHome(),this.viewport.applyConstraints(),w.preventDefault=!0;break;case 87:I.preventVerticalPan||(w.shift?this.viewport.zoomBy(1.1):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(0,-40))),this.viewport.applyConstraints()),w.preventDefault=!0;break;case 83:I.preventVerticalPan||(w.shift?this.viewport.zoomBy(.9):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(0,40))),this.viewport.applyConstraints()),w.preventDefault=!0;break;case 65:I.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(-40,0))),this.viewport.applyConstraints()),w.preventDefault=!0;break;case 68:I.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(40,0))),this.viewport.applyConstraints()),w.preventDefault=!0;break;case 82:w.shift?this.viewport.flipped?this.viewport.setRotation(this.viewport.getRotation()+this.rotationIncrement):this.viewport.setRotation(this.viewport.getRotation()-this.rotationIncrement):this.viewport.flipped?this.viewport.setRotation(this.viewport.getRotation()-this.rotationIncrement):this.viewport.setRotation(this.viewport.getRotation()+this.rotationIncrement),this.viewport.applyConstraints(),w.preventDefault=!0;break;case 70:this.viewport.toggleFlip(),w.preventDefault=!0;break;case 74:this.goToPreviousPage();break;case 75:this.goToNextPage();break;default:w.preventDefault=!1;break}else w.preventDefault=!1}function x(w){var I={originalEvent:w.originalEvent};this.raiseEvent("canvas-key-press",I)}function y(w){var I,q=document.activeElement===this.canvas;q||this.canvas.focus(),this.viewport.flipped&&(w.position.x=this.viewport.getContainerSize().x-w.position.x);var K={tracker:w.eventSource,position:w.position,quick:w.quick,shift:w.shift,originalEvent:w.originalEvent,originalTarget:w.originalTarget,preventDefaultAction:!1};this.raiseEvent("canvas-click",K),!K.preventDefaultAction&&this.viewport&&w.quick&&(I=this.gestureSettingsByDeviceType(w.pointerType),I.clickToZoom===!0&&(this.viewport.zoomBy(w.shift?1/this.zoomPerClick:this.zoomPerClick,I.zoomToRefPoint?this.viewport.pointFromPixel(w.position,!0):null),this.viewport.applyConstraints()),I.dblClickDragToZoom&&(i[this.hash].draggingToZoom===!0?(i[this.hash].lastClickTime=null,i[this.hash].draggingToZoom=!1):i[this.hash].lastClickTime=t.now()))}function E(w){var I,q={tracker:w.eventSource,position:w.position,shift:w.shift,originalEvent:w.originalEvent,preventDefaultAction:!1};this.raiseEvent("canvas-double-click",q),!q.preventDefaultAction&&this.viewport&&(I=this.gestureSettingsByDeviceType(w.pointerType),I.dblClickToZoom&&(this.viewport.zoomBy(w.shift?1/this.zoomPerClick:this.zoomPerClick,I.zoomToRefPoint?this.viewport.pointFromPixel(w.position,!0):null),this.viewport.applyConstraints()))}function R(w){var I,q={tracker:w.eventSource,pointerType:w.pointerType,position:w.position,delta:w.delta,speed:w.speed,direction:w.direction,shift:w.shift,originalEvent:w.originalEvent,preventDefaultAction:!1};if(this.raiseEvent("canvas-drag",q),I=this.gestureSettingsByDeviceType(w.pointerType),!q.preventDefaultAction&&this.viewport){if(I.dblClickDragToZoom&&i[this.hash].draggingToZoom){var K=Math.pow(this.zoomPerDblClickDrag,w.delta.y/50);this.viewport.zoomBy(K)}else if(I.dragToPan&&!i[this.hash].draggingToZoom){if(this.panHorizontal||(w.delta.x=0),this.panVertical||(w.delta.y=0),this.viewport.flipped&&(w.delta.x=-w.delta.x),this.constrainDuringPan){var ae=this.viewport.deltaPointsFromPixels(w.delta.negate());this.viewport.centerSpringX.target.value+=ae.x,this.viewport.centerSpringY.target.value+=ae.y;var he=this.viewport.getConstrainedBounds();this.viewport.centerSpringX.target.value-=ae.x,this.viewport.centerSpringY.target.value-=ae.y,he.xConstrained&&(w.delta.x=0),he.yConstrained&&(w.delta.y=0)}this.viewport.panBy(this.viewport.deltaPointsFromPixels(w.delta.negate()),I.flickEnabled&&!this.constrainDuringPan)}}}function P(w){var I,q={tracker:w.eventSource,pointerType:w.pointerType,position:w.position,speed:w.speed,direction:w.direction,shift:w.shift,originalEvent:w.originalEvent,preventDefaultAction:!1};if(this.raiseEvent("canvas-drag-end",q),I=this.gestureSettingsByDeviceType(w.pointerType),!q.preventDefaultAction&&this.viewport){if(!i[this.hash].draggingToZoom&&I.dragToPan&&I.flickEnabled&&w.speed>=I.flickMinSpeed){var K=0;this.panHorizontal&&(K=I.flickMomentum*w.speed*Math.cos(w.direction));var ae=0;this.panVertical&&(ae=I.flickMomentum*w.speed*Math.sin(w.direction));var he=this.viewport.pixelFromPoint(this.viewport.getCenter(!0)),J=this.viewport.pointFromPixel(new t.Point(he.x-K,he.y-ae));this.viewport.panTo(J,!1)}this.viewport.applyConstraints()}I.dblClickDragToZoom&&i[this.hash].draggingToZoom===!0&&(i[this.hash].draggingToZoom=!1)}function S(w){this.raiseEvent("canvas-enter",{tracker:w.eventSource,pointerType:w.pointerType,position:w.position,buttons:w.buttons,pointers:w.pointers,insideElementPressed:w.insideElementPressed,buttonDownAny:w.buttonDownAny,originalEvent:w.originalEvent})}function L(w){this.raiseEvent("canvas-exit",{tracker:w.eventSource,pointerType:w.pointerType,position:w.position,buttons:w.buttons,pointers:w.pointers,insideElementPressed:w.insideElementPressed,buttonDownAny:w.buttonDownAny,originalEvent:w.originalEvent})}function k(w){var I;if(this.raiseEvent("canvas-press",{tracker:w.eventSource,pointerType:w.pointerType,position:w.position,insideElementPressed:w.insideElementPressed,insideElementReleased:w.insideElementReleased,originalEvent:w.originalEvent}),I=this.gestureSettingsByDeviceType(w.pointerType),I.dblClickDragToZoom){var q=i[this.hash].lastClickTime,K=t.now();if(q===null)return;K-q<this.dblClickTimeThreshold&&(i[this.hash].draggingToZoom=!0),i[this.hash].lastClickTime=null}}function W(w){this.raiseEvent("canvas-release",{tracker:w.eventSource,pointerType:w.pointerType,position:w.position,insideElementPressed:w.insideElementPressed,insideElementReleased:w.insideElementReleased,originalEvent:w.originalEvent})}function j(w){this.raiseEvent("canvas-nonprimary-press",{tracker:w.eventSource,position:w.position,pointerType:w.pointerType,button:w.button,buttons:w.buttons,originalEvent:w.originalEvent})}function V(w){this.raiseEvent("canvas-nonprimary-release",{tracker:w.eventSource,position:w.position,pointerType:w.pointerType,button:w.button,buttons:w.buttons,originalEvent:w.originalEvent})}function N(w){var I,q,K,ae,he={tracker:w.eventSource,pointerType:w.pointerType,gesturePoints:w.gesturePoints,lastCenter:w.lastCenter,center:w.center,lastDistance:w.lastDistance,distance:w.distance,shift:w.shift,originalEvent:w.originalEvent,preventDefaultPanAction:!1,preventDefaultZoomAction:!1,preventDefaultRotateAction:!1};if(this.raiseEvent("canvas-pinch",he),this.viewport&&(I=this.gestureSettingsByDeviceType(w.pointerType),I.pinchToZoom&&(!he.preventDefaultPanAction||!he.preventDefaultZoomAction)&&(q=this.viewport.pointFromPixel(w.center,!0),I.zoomToRefPoint&&!he.preventDefaultPanAction&&(K=this.viewport.pointFromPixel(w.lastCenter,!0),ae=K.minus(q),this.panHorizontal||(ae.x=0),this.panVertical||(ae.y=0),this.viewport.panBy(ae,!0)),he.preventDefaultZoomAction||this.viewport.zoomBy(w.distance/w.lastDistance,q,!0),this.viewport.applyConstraints()),I.pinchRotate&&!he.preventDefaultRotateAction)){var J=Math.atan2(w.gesturePoints[0].currentPos.y-w.gesturePoints[1].currentPos.y,w.gesturePoints[0].currentPos.x-w.gesturePoints[1].currentPos.x),ye=Math.atan2(w.gesturePoints[0].lastPos.y-w.gesturePoints[1].lastPos.y,w.gesturePoints[0].lastPos.x-w.gesturePoints[1].lastPos.x);q=this.viewport.pointFromPixel(w.center,!0),this.viewport.rotateTo(this.viewport.getRotation(!0)+(J-ye)*(180/Math.PI),q,!0)}}function D(w){this.raiseEvent("canvas-focus",{tracker:w.eventSource,originalEvent:w.originalEvent})}function A(w){this.raiseEvent("canvas-blur",{tracker:w.eventSource,originalEvent:w.originalEvent})}function O(w){var I,q,K,ae,he;ae=t.now(),he=ae-this._lastScrollTime,he>this.minScrollDeltaTime?(this._lastScrollTime=ae,I={tracker:w.eventSource,position:w.position,scroll:w.scroll,shift:w.shift,originalEvent:w.originalEvent,preventDefaultAction:!1,preventDefault:!0},this.raiseEvent("canvas-scroll",I),!I.preventDefaultAction&&this.viewport&&(this.viewport.flipped&&(w.position.x=this.viewport.getContainerSize().x-w.position.x),q=this.gestureSettingsByDeviceType(w.pointerType),q.scrollToZoom&&(K=Math.pow(this.zoomPerScroll,w.scroll),this.viewport.zoomBy(K,q.zoomToRefPoint?this.viewport.pointFromPixel(w.position,!0):null),this.viewport.applyConstraints())),w.preventDefault=I.preventDefault):w.preventDefault=!0}function B(w){i[this.hash].mouseInside=!0,f(this),this.raiseEvent("container-enter",{tracker:w.eventSource,pointerType:w.pointerType,position:w.position,buttons:w.buttons,pointers:w.pointers,insideElementPressed:w.insideElementPressed,buttonDownAny:w.buttonDownAny,originalEvent:w.originalEvent})}function G(w){w.pointers<1&&(i[this.hash].mouseInside=!1,i[this.hash].animating||c(this)),this.raiseEvent("container-exit",{tracker:w.eventSource,pointerType:w.pointerType,position:w.position,buttons:w.buttons,pointers:w.pointers,insideElementPressed:w.insideElementPressed,buttonDownAny:w.buttonDownAny,originalEvent:w.originalEvent})}function Y(w){b(w),w.isOpen()?w._updateRequestId=h(w,Y):w._updateRequestId=!1}function z(w,I){var q=w.viewport,K=q.getZoom(),ae=q.getCenter();q.resize(I,w.preserveImageSizeOnResize),q.panTo(ae,!0);var he;if(w.preserveImageSizeOnResize)he=i[w.hash].prevContainerSize.x/I.x;else{var J=new t.Point(0,0),ye=new t.Point(i[w.hash].prevContainerSize.x,i[w.hash].prevContainerSize.y).distanceTo(J),ee=new t.Point(I.x,I.y).distanceTo(J);he=ee/ye*i[w.hash].prevContainerSize.x/I.x}q.zoomTo(K*he,null,!0),i[w.hash].prevContainerSize=I,i[w.hash].forceRedraw=!0,i[w.hash].needsResize=!1,i[w.hash].forceResize=!1}function b(w){if(!(w._opening||!i[w.hash])){if(w.autoResize||i[w.hash].forceResize){var I;if(w._autoResizePolling){I=s(w.container);var q=i[w.hash].prevContainerSize;I.equals(q)||(i[w.hash].needsResize=!0)}i[w.hash].needsResize&&z(w,I||s(w.container))}var K=w.viewport.update(),ae=w.world.update(K)||K;K&&w.raiseEvent("viewport-change"),w.referenceStrip&&(ae=w.referenceStrip.update(w.viewport)||ae);var he=i[w.hash].animating;!he&&ae&&(w.raiseEvent("animation-start"),f(w));var J=he&&!ae;J&&(i[w.hash].animating=!1),(ae||J||i[w.hash].forceRedraw||w.world.needsDraw())&&(H(w),w._drawOverlays(),w.navigator&&w.navigator.update(w.viewport),i[w.hash].forceRedraw=!1,ae&&w.raiseEvent("animation")),J&&(w.raiseEvent("animation-finish"),i[w.hash].mouseInside||c(w)),i[w.hash].animating=ae}}function H(w){w.imageLoader.clear(),w.world.draw(),w.raiseEvent("update-viewport",{})}function X(w,I){return w?w+I:I}function $(){i[this.hash].lastZoomTime=t.now(),i[this.hash].zoomFactor=this.zoomPerSecond,i[this.hash].zooming=!0,ce(this)}function re(){i[this.hash].lastZoomTime=t.now(),i[this.hash].zoomFactor=1/this.zoomPerSecond,i[this.hash].zooming=!0,ce(this)}function se(){i[this.hash].zooming=!1}function ce(w){t.requestAnimationFrame(t.delegate(w,ie))}function ie(){var w,I,q;i[this.hash].zooming&&this.viewport&&(w=t.now(),I=w-i[this.hash].lastZoomTime,q=Math.pow(i[this.hash].zoomFactor,I/1e3),this.viewport.zoomBy(q),this.viewport.applyConstraints(),i[this.hash].lastZoomTime=w,ce(this))}function ge(){this.viewport&&(i[this.hash].zooming=!1,this.viewport.zoomBy(this.zoomPerClick/1),this.viewport.applyConstraints())}function de(){this.viewport&&(i[this.hash].zooming=!1,this.viewport.zoomBy(1/this.zoomPerClick),this.viewport.applyConstraints())}function Te(){this.buttonGroup&&(this.buttonGroup.emulateEnter(),this.buttonGroup.emulateLeave())}function me(){this.viewport&&this.viewport.goHome()}function De(){this.isFullPage()&&!t.isFullScreen()?this.setFullPage(!1):this.setFullScreen(!this.isFullPage()),this.buttonGroup&&this.buttonGroup.emulateLeave(),this.fullPageButton.element.focus(),this.viewport&&this.viewport.applyConstraints()}function it(){if(this.viewport){var w=this.viewport.getRotation();this.viewport.flipped?w+=this.rotationIncrement:w-=this.rotationIncrement,this.viewport.setRotation(w)}}function Je(){if(this.viewport){var w=this.viewport.getRotation();this.viewport.flipped?w-=this.rotationIncrement:w+=this.rotationIncrement,this.viewport.setRotation(w)}}function ht(){this.viewport.toggleFlip()}t.determineDrawer=function(w){for(let I in e){const q=e[I],K=q.prototype;if(K&&K instanceof e.DrawerBase&&t.isFunction(K.getType)&&K.getType.call(q)===w)return q}return null}})(e),(function(t){t.Navigator=function(h){var u=h.viewer,c=this,d,f;h.element||h.id?(h.element?(h.id&&t.console.warn("Given option.id for Navigator was ignored since option.element was provided and is being used instead."),h.element.id?h.id=h.element.id:h.id="navigator-"+t.now(),this.element=h.element):this.element=document.getElementById(h.id),h.controlOptions={anchor:t.ControlAnchor.NONE,attachToViewer:!1,autoFade:!1}):(h.id="navigator-"+t.now(),this.element=t.makeNeutralElement("div"),h.controlOptions={anchor:t.ControlAnchor.TOP_RIGHT,attachToViewer:!0,autoFade:h.autoFade},h.position&&(h.position==="BOTTOM_RIGHT"?h.controlOptions.anchor=t.ControlAnchor.BOTTOM_RIGHT:h.position==="BOTTOM_LEFT"?h.controlOptions.anchor=t.ControlAnchor.BOTTOM_LEFT:h.position==="TOP_RIGHT"?h.controlOptions.anchor=t.ControlAnchor.TOP_RIGHT:h.position==="TOP_LEFT"?h.controlOptions.anchor=t.ControlAnchor.TOP_LEFT:h.position==="ABSOLUTE"&&(h.controlOptions.anchor=t.ControlAnchor.ABSOLUTE,h.controlOptions.top=h.top,h.controlOptions.left=h.left,h.controlOptions.height=h.height,h.controlOptions.width=h.width))),this.element.id=h.id,this.element.className+=" navigator",h=t.extend(!0,{sizeRatio:t.DEFAULT_SETTINGS.navigatorSizeRatio},h,{element:this.element,tabIndex:-1,showNavigator:!1,mouseNavEnabled:!1,showNavigationControl:!1,showSequenceControl:!1,immediateRender:!0,blendTime:0,animationTime:h.animationTime,autoResize:!1,minZoomImageRatio:1,background:h.background,opacity:h.opacity,borderColor:h.borderColor,displayRegionColor:h.displayRegionColor}),h.minPixelRatio=this.minPixelRatio=u.minPixelRatio,t.setElementTouchActionNone(this.element),this.borderWidth=2,this.fudge=new t.Point(1,1),this.totalBorderWidths=new t.Point(this.borderWidth*2,this.borderWidth*2).minus(this.fudge),h.controlOptions.anchor!==t.ControlAnchor.NONE&&(function(v,m){v.margin="0px",v.border=m+"px solid "+h.borderColor,v.padding="0px",v.background=h.background,v.opacity=h.opacity,v.overflow="hidden"})(this.element.style,this.borderWidth),this.displayRegion=t.makeNeutralElement("div"),this.displayRegion.id=this.element.id+"-displayregion",this.displayRegion.className="displayregion",(function(v,m){v.position="relative",v.top="0px",v.left="0px",v.fontSize="0px",v.overflow="hidden",v.border=m+"px solid "+h.displayRegionColor,v.margin="0px",v.padding="0px",v.background="transparent",v.float="left",v.cssFloat="left",v.zIndex=999999999,v.cursor="default",v.boxSizing="content-box"})(this.displayRegion.style,this.borderWidth),t.setElementPointerEventsNone(this.displayRegion),t.setElementTouchActionNone(this.displayRegion),this.displayRegionContainer=t.makeNeutralElement("div"),this.displayRegionContainer.id=this.element.id+"-displayregioncontainer",this.displayRegionContainer.className="displayregioncontainer",this.displayRegionContainer.style.width="100%",this.displayRegionContainer.style.height="100%",t.setElementPointerEventsNone(this.displayRegionContainer),t.setElementTouchActionNone(this.displayRegionContainer),u.addControl(this.element,h.controlOptions),this._resizeWithViewer=h.controlOptions.anchor!==t.ControlAnchor.ABSOLUTE&&h.controlOptions.anchor!==t.ControlAnchor.NONE,h.width&&h.height?(this.setWidth(h.width),this.setHeight(h.height)):this._resizeWithViewer&&(d=t.getElementSize(u.element),this.element.style.height=Math.round(d.y*h.sizeRatio)+"px",this.element.style.width=Math.round(d.x*h.sizeRatio)+"px",this.oldViewerSize=d,f=t.getElementSize(this.element),this.elementArea=f.x*f.y),this.oldContainerSize=new t.Point(0,0),t.Viewer.apply(this,[h]),this.displayRegionContainer.appendChild(this.displayRegion),this.element.getElementsByTagName("div")[0].appendChild(this.displayRegionContainer);function p(v,m){a(c.displayRegionContainer,v),a(c.displayRegion,-v),c.viewport.setRotation(v,m)}if(h.navigatorRotate){var g=h.viewer.viewport?h.viewer.viewport.getRotation():h.viewer.degrees||0;p(g,!0),h.viewer.addHandler("rotate",function(v){p(v.degrees,v.immediately)})}this.innerTracker.destroy(),this.innerTracker=new t.MouseTracker({userData:"Navigator.innerTracker",element:this.element,dragHandler:t.delegate(this,r),clickHandler:t.delegate(this,i),releaseHandler:t.delegate(this,s),scrollHandler:t.delegate(this,o),preProcessEventHandler:function(v){v.eventType==="wheel"&&(v.preventDefault=!0)}}),this.outerTracker.userData="Navigator.outerTracker",t.setElementPointerEventsNone(this.canvas),t.setElementPointerEventsNone(this.container),this.addHandler("reset-size",function(){c.viewport&&c.viewport.goHome(!0)}),u.world.addHandler("item-index-change",function(v){window.setTimeout(function(){var m=c.world.getItemAt(v.previousIndex);c.world.setItemIndex(m,v.newIndex)},1)}),u.world.addHandler("remove-item",function(v){var m=v.item,x=c._getMatchingItem(m);x&&c.world.removeItem(x)}),this.update(u.viewport)},t.extend(t.Navigator.prototype,t.EventSource.prototype,t.Viewer.prototype,{updateSize:function(){if(this.viewport){var h=new t.Point(this.container.clientWidth===0?1:this.container.clientWidth,this.container.clientHeight===0?1:this.container.clientHeight);h.equals(this.oldContainerSize)||(this.viewport.resize(h,!0),this.viewport.goHome(!0),this.oldContainerSize=h,this.world.update(),this.world.draw(),this.update(this.viewer.viewport))}},setWidth:function(h){this.width=h,this.element.style.width=typeof h=="number"?h+"px":h,this._resizeWithViewer=!1,this.updateSize()},setHeight:function(h){this.height=h,this.element.style.height=typeof h=="number"?h+"px":h,this._resizeWithViewer=!1,this.updateSize()},setFlip:function(h){return this.viewport.setFlip(h),this.setDisplayTransform(this.viewer.viewport.getFlip()?"scale(-1,1)":"scale(1,1)"),this},setDisplayTransform:function(h){l(this.canvas,h),l(this.element,h)},update:function(h){var u,c,d,f,p,g;if(h||(h=this.viewer.viewport),u=t.getElementSize(this.viewer.element),this._resizeWithViewer&&u.x&&u.y&&!u.equals(this.oldViewerSize)&&(this.oldViewerSize=u,this.maintainSizeRatio||!this.elementArea?(c=u.x*this.sizeRatio,d=u.y*this.sizeRatio):(c=Math.sqrt(this.elementArea*(u.x/u.y)),d=this.elementArea/c),this.element.style.width=Math.round(c)+"px",this.element.style.height=Math.round(d)+"px",this.elementArea||(this.elementArea=c*d),this.updateSize()),h&&this.viewport){if(f=h.getBoundsNoRotate(!0),p=this.viewport.pixelFromPointNoRotate(f.getTopLeft(),!1),g=this.viewport.pixelFromPointNoRotate(f.getBottomRight(),!1).minus(this.totalBorderWidths),!this.navigatorRotate){var v=h.getRotation(!0);a(this.displayRegion,-v)}var m=this.displayRegion.style;m.display=this.world.getItemCount()?"block":"none",m.top=p.y.toFixed(2)+"px",m.left=p.x.toFixed(2)+"px";var x=g.x-p.x,y=g.y-p.y;m.width=Math.round(Math.max(x,0))+"px",m.height=Math.round(Math.max(y,0))+"px"}},addTiledImage:function(h){var u=this,c=h.originalTiledImage;delete h.original;var d=t.extend({},h,{success:function(f){var p=f.item;p._originalForNavigator=c,u._matchBounds(p,c,!0),u._matchOpacity(p,c),u._matchCompositeOperation(p,c);function g(){u._matchBounds(p,c)}function v(){u._matchOpacity(p,c)}function m(){u._matchCompositeOperation(p,c)}c.addHandler("bounds-change",g),c.addHandler("clip-change",g),c.addHandler("opacity-change",v),c.addHandler("composite-operation-change",m)}});return t.Viewer.prototype.addTiledImage.apply(this,[d])},destroy:function(){return t.Viewer.prototype.destroy.apply(this)},_getMatchingItem:function(h){for(var u=this.world.getItemCount(),c,d=0;d<u;d++)if(c=this.world.getItemAt(d),c._originalForNavigator===h)return c;return null},_matchBounds:function(h,u,c){var d=u.getBoundsNoRotate();h.setPosition(d.getTopLeft(),c),h.setWidth(d.width,c),h.setRotation(u.getRotation(),c),h.setClip(u.getClip()),h.setFlip(u.getFlip())},_matchOpacity:function(h,u){h.setOpacity(u.opacity)},_matchCompositeOperation:function(h,u){h.setCompositeOperation(u.compositeOperation)}});function i(h){var u={tracker:h.eventSource,position:h.position,quick:h.quick,shift:h.shift,originalEvent:h.originalEvent,preventDefaultAction:!1};if(this.viewer.raiseEvent("navigator-click",u),!u.preventDefaultAction&&h.quick&&this.viewer.viewport&&(this.panVertical||this.panHorizontal)){this.viewer.viewport.flipped&&(h.position.x=this.viewport.getContainerSize().x-h.position.x);var c=this.viewport.pointFromPixel(h.position);this.panVertical?this.panHorizontal||(c.x=this.viewer.viewport.getCenter(!0).x):c.y=this.viewer.viewport.getCenter(!0).y,this.viewer.viewport.panTo(c),this.viewer.viewport.applyConstraints()}}function r(h){var u={tracker:h.eventSource,position:h.position,delta:h.delta,speed:h.speed,direction:h.direction,shift:h.shift,originalEvent:h.originalEvent,preventDefaultAction:!1};this.viewer.raiseEvent("navigator-drag",u),!u.preventDefaultAction&&this.viewer.viewport&&(this.panHorizontal||(h.delta.x=0),this.panVertical||(h.delta.y=0),this.viewer.viewport.flipped&&(h.delta.x=-h.delta.x),this.viewer.viewport.panBy(this.viewport.deltaPointsFromPixels(h.delta)),this.viewer.constrainDuringPan&&this.viewer.viewport.applyConstraints())}function s(h){h.insideElementPressed&&this.viewer.viewport&&this.viewer.viewport.applyConstraints()}function o(h){var u={tracker:h.eventSource,position:h.position,scroll:h.scroll,shift:h.shift,originalEvent:h.originalEvent,preventDefault:h.preventDefault};this.viewer.raiseEvent("navigator-scroll",u),h.preventDefault=u.preventDefault}function a(h,u){l(h,"rotate("+u+"deg)")}function l(h,u){h.style.webkitTransform=u,h.style.mozTransform=u,h.style.msTransform=u,h.style.oTransform=u,h.style.transform=u}})(e),(function(t){var i={Errors:{Dzc:"Sorry, we don't support Deep Zoom Collections!",Dzi:"Hmm, this doesn't appear to be a valid Deep Zoom Image.",Xml:"Hmm, this doesn't appear to be a valid Deep Zoom Image.",ImageFormat:"Sorry, we don't support {0}-based Deep Zoom Images.",Security:"It looks like a security restriction stopped us from loading this Deep Zoom Image.",Status:"This space unintentionally left blank ({0} {1}).",OpenFailed:"Unable to open {0}: {1}"},Tooltips:{FullPage:"Toggle full page",Home:"Go home",ZoomIn:"Zoom in",ZoomOut:"Zoom out",NextPage:"Next page",PreviousPage:"Previous page",RotateLeft:"Rotate left",RotateRight:"Rotate right",Flip:"Flip Horizontally"}};t.extend(t,{getString:function(r){var s=r.split("."),o=null,a=arguments,l=i,h;for(h=0;h<s.length-1;h++)l=l[s[h]]||{};return o=l[s[h]],typeof o!="string"&&(t.console.error("Untranslated source string:",r),o=""),o.replace(/\{\d+\}/g,function(u){var c=parseInt(u.match(/\d+/),10)+1;return c<a.length?a[c]:""})},setString:function(r,s){var o=r.split("."),a=i,l;for(l=0;l<o.length-1;l++)a[o[l]]||(a[o[l]]={}),a=a[o[l]];a[o[l]]=s}})})(e),(function(t){t.Point=function(i,r){this.x=typeof i=="number"?i:0,this.y=typeof r=="number"?r:0},t.Point.prototype={clone:function(){return new t.Point(this.x,this.y)},plus:function(i){return new t.Point(this.x+i.x,this.y+i.y)},minus:function(i){return new t.Point(this.x-i.x,this.y-i.y)},times:function(i){return new t.Point(this.x*i,this.y*i)},divide:function(i){return new t.Point(this.x/i,this.y/i)},negate:function(){return new t.Point(-this.x,-this.y)},distanceTo:function(i){return Math.sqrt(Math.pow(this.x-i.x,2)+Math.pow(this.y-i.y,2))},squaredDistanceTo:function(i){return Math.pow(this.x-i.x,2)+Math.pow(this.y-i.y,2)},apply:function(i){return new t.Point(i(this.x),i(this.y))},equals:function(i){return i instanceof t.Point&&this.x===i.x&&this.y===i.y},rotate:function(i,r){r=r||new t.Point(0,0);var s,o;if(i%90===0){var a=t.positiveModulo(i,360);switch(a){case 0:s=1,o=0;break;case 90:s=0,o=1;break;case 180:s=-1,o=0;break;case 270:s=0,o=-1;break}}else{var l=i*Math.PI/180;s=Math.cos(l),o=Math.sin(l)}var h=s*(this.x-r.x)-o*(this.y-r.y)+r.x,u=o*(this.x-r.x)+s*(this.y-r.y)+r.y;return new t.Point(h,u)},toString:function(){return"("+Math.round(this.x*100)/100+","+Math.round(this.y*100)/100+")"}}})(e),(function(t){t.TileSource=function(r,s,o,a,l,h){var u=this,c=arguments,d,f;if(t.isPlainObject(r)?d=r:d={width:c[0],height:c[1],tileSize:c[2],tileOverlap:c[3],minLevel:c[4],maxLevel:c[5]},t.EventSource.call(this),t.extend(!0,this,d),!this.success){for(f=0;f<arguments.length;f++)if(t.isFunction(arguments[f])){this.success=arguments[f];break}}this.success&&this.addHandler("ready",function(p){u.success(p)}),t.type(arguments[0])==="string"&&(this.url=arguments[0]),this.url?(this.aspectRatio=1,this.dimensions=new t.Point(10,10),this._tileWidth=0,this._tileHeight=0,this.tileOverlap=0,this.minLevel=0,this.maxLevel=0,this.ready=!1,this.getImageInfo(this.url)):(this.ready=!0,this.aspectRatio=d.width&&d.height?d.width/d.height:1,this.dimensions=new t.Point(d.width,d.height),this.tileSize?(this._tileWidth=this._tileHeight=this.tileSize,delete this.tileSize):(this.tileWidth?(this._tileWidth=this.tileWidth,delete this.tileWidth):this._tileWidth=0,this.tileHeight?(this._tileHeight=this.tileHeight,delete this.tileHeight):this._tileHeight=0),this.tileOverlap=d.tileOverlap?d.tileOverlap:0,this.minLevel=d.minLevel?d.minLevel:0,this.maxLevel=d.maxLevel!==void 0&&d.maxLevel!==null?d.maxLevel:d.width&&d.height?Math.ceil(Math.log(Math.max(d.width,d.height))/Math.log(2)):0,this.success&&t.isFunction(this.success)&&this.success(this))},t.TileSource.prototype={getTileSize:function(r){return t.console.error("[TileSource.getTileSize] is deprecated. Use TileSource.getTileWidth() and TileSource.getTileHeight() instead"),this._tileWidth},getTileWidth:function(r){return this._tileWidth?this._tileWidth:this.getTileSize(r)},getTileHeight:function(r){return this._tileHeight?this._tileHeight:this.getTileSize(r)},setMaxLevel:function(r){this.maxLevel=r,this._memoizeLevelScale()},getLevelScale:function(r){return this._memoizeLevelScale(),this.getLevelScale(r)},_memoizeLevelScale:function(){var r={},s;for(s=0;s<=this.maxLevel;s++)r[s]=1/Math.pow(2,this.maxLevel-s);this.getLevelScale=function(o){return r[o]}},getNumTiles:function(r){var s=this.getLevelScale(r),o=Math.ceil(s*this.dimensions.x/this.getTileWidth(r)),a=Math.ceil(s*this.dimensions.y/this.getTileHeight(r));return new t.Point(o,a)},getPixelRatio:function(r){var s=this.dimensions.times(this.getLevelScale(r)),o=1/s.x*t.pixelDensityRatio,a=1/s.y*t.pixelDensityRatio;return new t.Point(o,a)},getClosestLevel:function(){var r,s;for(r=this.minLevel+1;r<=this.maxLevel&&(s=this.getNumTiles(r),!(s.x>1||s.y>1));r++);return r-1},getTileAtPoint:function(r,s){var o=s.x>=0&&s.x<=1&&s.y>=0&&s.y<=1/this.aspectRatio;t.console.assert(o,"[TileSource.getTileAtPoint] must be called with a valid point.");var a=this.dimensions.x*this.getLevelScale(r),l=s.x*a,h=s.y*a,u=Math.floor(l/this.getTileWidth(r)),c=Math.floor(h/this.getTileHeight(r));s.x>=1&&(u=this.getNumTiles(r).x-1);var d=1e-15;return s.y>=1/this.aspectRatio-d&&(c=this.getNumTiles(r).y-1),new t.Point(u,c)},getTileBounds:function(r,s,o,a){var l=this.dimensions.times(this.getLevelScale(r)),h=this.getTileWidth(r),u=this.getTileHeight(r),c=s===0?0:h*s-this.tileOverlap,d=o===0?0:u*o-this.tileOverlap,f=h+(s===0?1:2)*this.tileOverlap,p=u+(o===0?1:2)*this.tileOverlap,g=1/l.x;return f=Math.min(f,l.x-c),p=Math.min(p,l.y-d),a?new t.Rect(0,0,f,p):new t.Rect(c*g,d*g,f*g,p*g)},getImageInfo:function(r){var s=this,o,a,l,h,u,c,d;r&&(u=r.split("/"),c=u[u.length-1],d=c.lastIndexOf("."),d>-1&&(u[u.length-1]=c.slice(0,d)));var f=null;if(this.splitHashDataForPost){var p=r.indexOf("#");p!==-1&&(f=r.substring(p+1),r=r.substr(0,p))}a=function(g){typeof g=="string"&&(g=t.parseXml(g));var v=t.TileSource.determineType(s,g,r);if(!v){s.raiseEvent("open-failed",{message:"Unable to load TileSource",source:r});return}h=v.prototype.configure.apply(s,[g,r,f]),h.ajaxWithCredentials===void 0&&(h.ajaxWithCredentials=s.ajaxWithCredentials),l=new v(h),s.ready=!0,s.raiseEvent("ready",{tileSource:l})},r.match(/\.js$/)?(o=r.split("/").pop().replace(".js",""),t.jsonp({url:r,async:!1,callbackName:o,callback:a})):t.makeAjaxRequest({url:r,postData:f,withCredentials:this.ajaxWithCredentials,headers:this.ajaxHeaders,success:function(g){var v=i(g);a(v)},error:function(g,v){var m;try{m="HTTP "+g.status+" attempting to load TileSource: "+r}catch{var x;typeof v>"u"||!v.toString?x="Unknown error":x=v.toString(),m=x+" attempting to load TileSource: "+r}t.console.error(m),s.raiseEvent("open-failed",{message:m,source:r,postData:f})}})},supports:function(r,s){return!1},configure:function(r,s,o){throw new Error("Method not implemented.")},getTileUrl:function(r,s,o){throw new Error("Method not implemented.")},getTilePostData:function(r,s,o){return null},getTileAjaxHeaders:function(r,s,o){return{}},getTileHashKey:function(r,s,o,a,l,h){function u(c){return l?c+"+"+JSON.stringify(l):c}return u(typeof a!="string"?r+"/"+s+"_"+o:a)},tileExists:function(r,s,o){var a=this.getNumTiles(r);return r>=this.minLevel&&r<=this.maxLevel&&s>=0&&o>=0&&s<a.x&&o<a.y},hasTransparency:function(r,s,o,a){return!!r||s.match(".png")},downloadTileStart:function(r){var s=r.userData,o=new Image;s.image=o,s.request=null;var a=function(l){if(!o){r.finish(null,s.request,"Image load failed: undefined Image instance.");return}o.onload=o.onerror=o.onabort=null,r.finish(l?null:o,s.request,l)};o.onload=function(){a()},o.onabort=o.onerror=function(){a("Image load aborted.")},r.loadWithAjax?s.request=t.makeAjaxRequest({url:r.src,withCredentials:r.ajaxWithCredentials,headers:r.ajaxHeaders,responseType:"arraybuffer",postData:r.postData,success:function(l){var h;try{h=new window.Blob([l.response])}catch(d){var u=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;if(d.name==="TypeError"&&u){var c=new u;c.append(l.response),h=c.getBlob()}}h.size===0?a("Empty image response."):o.src=(window.URL||window.webkitURL).createObjectURL(h)},error:function(l){a("Image load aborted - XHR error")}}):(r.crossOriginPolicy!==!1&&(o.crossOrigin=r.crossOriginPolicy),o.src=r.src)},downloadTileAbort:function(r){r.userData.request&&r.userData.request.abort();var s=r.userData.image;r.userData.image&&(s.onload=s.onerror=s.onabort=null)},createTileCache:function(r,s,o){r._data=s},destroyTileCache:function(r){r._data=null,r._renderedContext=null},getTileCacheData:function(r){return r._data},getTileCacheDataAsImage:function(r){return r._data},getTileCacheDataAsContext2D:function(r){if(!r._renderedContext){var s=document.createElement("canvas");s.width=r._data.width,s.height=r._data.height,r._renderedContext=s.getContext("2d"),r._renderedContext.drawImage(r._data,0,0),r._data=null}return r._renderedContext}},t.extend(!0,t.TileSource.prototype,t.EventSource.prototype);function i(r){var s=r.responseText,o=r.status,a,l;if(r){if(r.status!==200&&r.status!==0)throw o=r.status,a=o===404?"Not Found":r.statusText,new Error(t.getString("Errors.Status",o,a))}else throw new Error(t.getString("Errors.Security"));if(s.match(/^\s*<.*/))try{l=r.responseXML&&r.responseXML.documentElement?r.responseXML:t.parseXml(s)}catch{l=r.responseText}else if(s.match(/\s*[{[].*/))try{l=t.parseJSON(s)}catch{l=s}else l=s;return l}t.TileSource.determineType=function(r,s,o){var a;for(a in e)if(a.match(/.+TileSource$/)&&t.isFunction(e[a])&&t.isFunction(e[a].prototype.supports)&&e[a].prototype.supports.call(r,s,o))return e[a];return t.console.error("No TileSource was able to open %s %s",o,s),null}})(e),(function(t){t.DziTileSource=function(s,o,a,l,h,u,c,d,f){var p,g,v,m;if(t.isPlainObject(s)?m=s:m={width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4],fileFormat:arguments[5],displayRects:arguments[6],minLevel:arguments[7],maxLevel:arguments[8]},this._levelRects={},this.tilesUrl=m.tilesUrl,this.fileFormat=m.fileFormat,this.displayRects=m.displayRects,this.displayRects)for(p=this.displayRects.length-1;p>=0;p--)for(g=this.displayRects[p],v=g.minLevel;v<=g.maxLevel;v++)this._levelRects[v]||(this._levelRects[v]=[]),this._levelRects[v].push(g);t.TileSource.apply(this,[m])},t.extend(t.DziTileSource.prototype,t.TileSource.prototype,{supports:function(s,o){var a;return s.Image?a=s.Image.xmlns:s.documentElement&&(s.documentElement.localName==="Image"||s.documentElement.tagName==="Image")&&(a=s.documentElement.namespaceURI),a=(a||"").toLowerCase(),a.indexOf("schemas.microsoft.com/deepzoom/2008")!==-1||a.indexOf("schemas.microsoft.com/deepzoom/2009")!==-1},configure:function(s,o,a){var l;return t.isPlainObject(s)?l=r(this,s):l=i(this,s),o&&!l.tilesUrl&&(l.tilesUrl=o.replace(/([^/]+?)(\.(dzi|xml|js)?(\?[^/]*)?)?\/?$/,"$1_files/"),o.search(/\.(dzi|xml|js)\?/)!==-1?l.queryParams=o.match(/\?.*/):l.queryParams=""),l},getTileUrl:function(s,o,a){return[this.tilesUrl,s,"/",o,"_",a,".",this.fileFormat,this.queryParams].join("")},tileExists:function(s,o,a){var l=this._levelRects[s],h,u,c,d,f,p,g;if(this.minLevel&&s<this.minLevel||this.maxLevel&&s>this.maxLevel)return!1;if(!l||!l.length)return!0;for(g=l.length-1;g>=0;g--)if(h=l[g],!(s<h.minLevel||s>h.maxLevel)&&(u=this.getLevelScale(s),c=h.x*u,d=h.y*u,f=c+h.width*u,p=d+h.height*u,c=Math.floor(c/this._tileWidth),d=Math.floor(d/this._tileWidth),f=Math.ceil(f/this._tileWidth),p=Math.ceil(p/this._tileWidth),c<=o&&o<f&&d<=a&&a<p))return!0;return!1}});function i(s,o){if(!o||!o.documentElement)throw new Error(t.getString("Errors.Xml"));var a=o.documentElement,l=a.localName||a.tagName,h=o.documentElement.namespaceURI,u=null,c=[],d,f,p,g,v;if(l==="Image")try{if(g=a.getElementsByTagName("Size")[0],g===void 0&&(g=a.getElementsByTagNameNS(h,"Size")[0]),u={Image:{xmlns:"http://schemas.microsoft.com/deepzoom/2008",Url:a.getAttribute("Url"),Format:a.getAttribute("Format"),DisplayRect:null,Overlap:parseInt(a.getAttribute("Overlap"),10),TileSize:parseInt(a.getAttribute("TileSize"),10),Size:{Height:parseInt(g.getAttribute("Height"),10),Width:parseInt(g.getAttribute("Width"),10)}}},!t.imageFormatSupported(u.Image.Format))throw new Error(t.getString("Errors.ImageFormat",u.Image.Format.toUpperCase()));for(d=a.getElementsByTagName("DisplayRect"),d===void 0&&(d=a.getElementsByTagNameNS(h,"DisplayRect")[0]),v=0;v<d.length;v++)f=d[v],p=f.getElementsByTagName("Rect")[0],p===void 0&&(p=f.getElementsByTagNameNS(h,"Rect")[0]),c.push({Rect:{X:parseInt(p.getAttribute("X"),10),Y:parseInt(p.getAttribute("Y"),10),Width:parseInt(p.getAttribute("Width"),10),Height:parseInt(p.getAttribute("Height"),10),MinLevel:parseInt(f.getAttribute("MinLevel"),10),MaxLevel:parseInt(f.getAttribute("MaxLevel"),10)}});return c.length&&(u.Image.DisplayRect=c),r(s,u)}catch(y){throw y instanceof Error?y:new Error(t.getString("Errors.Dzi"))}else{if(l==="Collection")throw new Error(t.getString("Errors.Dzc"));if(l==="Error"){var m=a.getElementsByTagName("Message")[0],x=m.firstChild.nodeValue;throw new Error(x)}}throw new Error(t.getString("Errors.Dzi"))}function r(s,o){var a=o.Image,l=a.Url,h=a.Format,u=a.Size,c=a.DisplayRect||[],d=parseInt(u.Width,10),f=parseInt(u.Height,10),p=parseInt(a.TileSize,10),g=parseInt(a.Overlap,10),v=[],m,x;for(x=0;x<c.length;x++)m=c[x].Rect,v.push(new t.DisplayRect(parseInt(m.X,10),parseInt(m.Y,10),parseInt(m.Width,10),parseInt(m.Height,10),parseInt(m.MinLevel,10),parseInt(m.MaxLevel,10)));return t.extend(!0,{width:d,height:f,tileSize:p,tileOverlap:g,minLevel:null,maxLevel:null,tilesUrl:l,fileFormat:h,displayRects:v},o)}})(e),(function(t){t.IIIFTileSource=function(a){if(t.extend(!0,this,a),this._id=this["@id"]||this.id||this.identifier||null,!(this.height&&this.width&&this._id))throw new Error("IIIF required parameters (width, height, or id) not provided.");if(a.tileSizePerScaleFactor={},this.tileFormat=this.tileFormat||"jpg",this.version=a.version,this.tile_width&&this.tile_height)a.tileWidth=this.tile_width,a.tileHeight=this.tile_height;else if(this.tile_width)a.tileSize=this.tile_width;else if(this.tile_height)a.tileSize=this.tile_height;else if(this.tiles)if(this.tiles.length===1)a.tileWidth=this.tiles[0].width,a.tileHeight=this.tiles[0].height||this.tiles[0].width,this.scale_factors=this.tiles[0].scaleFactors;else{this.scale_factors=[];for(var l=0;l<this.tiles.length;l++)for(var h=0;h<this.tiles[l].scaleFactors.length;h++){var u=this.tiles[l].scaleFactors[h];this.scale_factors.push(u),a.tileSizePerScaleFactor[u]={width:this.tiles[l].width,height:this.tiles[l].height||this.tiles[l].width}}}else if(i(a)){for(var c=Math.min(this.height,this.width),d=[256,512,1024],f=[],p=0;p<d.length;p++)d[p]<=c&&f.push(d[p]);f.length>0?a.tileSize=Math.max.apply(null,f):a.tileSize=c}else this.sizes&&this.sizes.length>0?(this.emulateLegacyImagePyramid=!0,a.levels=r(this),t.extend(!0,a,{width:a.levels[a.levels.length-1].width,height:a.levels[a.levels.length-1].height,tileSize:Math.max(a.height,a.width),tileOverlap:0,minLevel:0,maxLevel:a.levels.length-1}),this.levels=a.levels):t.console.error("Nothing in the info.json to construct image pyramids from");if(!a.maxLevel&&!this.emulateLegacyImagePyramid)if(!this.scale_factors)a.maxLevel=Number(Math.round(Math.log(Math.max(this.width,this.height),2)));else{var g=Math.max.apply(null,this.scale_factors);a.maxLevel=Math.round(Math.log(g)*Math.LOG2E)}if(this.sizes){var v=this.sizes.length;(v===a.maxLevel||v===a.maxLevel+1)&&(this.levelSizes=this.sizes.slice().sort((m,x)=>m.width-x.width),v===a.maxLevel&&this.levelSizes.push({width:this.width,height:this.height}))}t.TileSource.apply(this,[a])},t.extend(t.IIIFTileSource.prototype,t.TileSource.prototype,{supports:function(a,l){return a.protocol&&a.protocol==="http://iiif.io/api/image"||a["@context"]&&(a["@context"]==="http://library.stanford.edu/iiif/image-api/1.1/context.json"||a["@context"]==="http://iiif.io/api/image/1/context.json")||a.profile&&a.profile.indexOf("http://library.stanford.edu/iiif/image-api/compliance.html")===0||a.identifier&&a.width&&a.height?!0:!!(a.documentElement&&a.documentElement.tagName==="info"&&a.documentElement.namespaceURI==="http://library.stanford.edu/iiif/image-api/ns/")},configure:function(a,l,h){if(t.isPlainObject(a)){if(!a["@context"])a["@context"]="http://iiif.io/api/image/1.0/context.json",a["@id"]=l.replace("/info.json",""),a.version=1;else{var c=a["@context"];if(Array.isArray(c)){for(var d=0;d<c.length;d++)if(typeof c[d]=="string"&&(/^http:\/\/iiif\.io\/api\/image\/[1-3]\/context\.json$/.test(c[d])||c[d]==="http://library.stanford.edu/iiif/image-api/1.1/context.json")){c=c[d];break}}switch(c){case"http://iiif.io/api/image/1/context.json":case"http://library.stanford.edu/iiif/image-api/1.1/context.json":a.version=1;break;case"http://iiif.io/api/image/2/context.json":a.version=2;break;case"http://iiif.io/api/image/3/context.json":a.version=3;break;default:t.console.error("Data has a @context property which contains no known IIIF context URI.")}}if(a.preferredFormats){for(var f=0;f<a.preferredFormats.length;f++)if(e.imageFormatSupported(a.preferredFormats[f])){a.tileFormat=a.preferredFormats[f];break}}return a}else{var u=s(a);return u["@context"]="http://iiif.io/api/image/1.0/context.json",u["@id"]=l.replace("/info.xml",""),u.version=1,u}},getTileWidth:function(a){if(this.emulateLegacyImagePyramid)return t.TileSource.prototype.getTileWidth.call(this,a);var l=Math.pow(2,this.maxLevel-a);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[l]?this.tileSizePerScaleFactor[l].width:this._tileWidth},getTileHeight:function(a){if(this.emulateLegacyImagePyramid)return t.TileSource.prototype.getTileHeight.call(this,a);var l=Math.pow(2,this.maxLevel-a);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[l]?this.tileSizePerScaleFactor[l].height:this._tileHeight},getLevelScale:function(a){if(this.emulateLegacyImagePyramid){var l=NaN;return this.levels.length>0&&a>=this.minLevel&&a<=this.maxLevel&&(l=this.levels[a].width/this.levels[this.maxLevel].width),l}return t.TileSource.prototype.getLevelScale.call(this,a)},getNumTiles:function(a){if(this.emulateLegacyImagePyramid){var l=this.getLevelScale(a);return l?new t.Point(1,1):new t.Point(0,0)}if(this.levelSizes){var h=this.levelSizes[a],u=Math.ceil(h.width/this.getTileWidth(a)),c=Math.ceil(h.height/this.getTileHeight(a));return new t.Point(u,c)}else return t.TileSource.prototype.getNumTiles.call(this,a)},getTileAtPoint:function(a,l){if(this.emulateLegacyImagePyramid)return new t.Point(0,0);if(this.levelSizes){var h=l.x>=0&&l.x<=1&&l.y>=0&&l.y<=1/this.aspectRatio;t.console.assert(h,"[TileSource.getTileAtPoint] must be called with a valid point.");var u=this.levelSizes[a].width,c=l.x*u,d=l.y*u,f=Math.floor(c/this.getTileWidth(a)),p=Math.floor(d/this.getTileHeight(a));l.x>=1&&(f=this.getNumTiles(a).x-1);var g=1e-15;return l.y>=1/this.aspectRatio-g&&(p=this.getNumTiles(a).y-1),new t.Point(f,p)}return t.TileSource.prototype.getTileAtPoint.call(this,a,l)},getTileUrl:function(a,l,h){if(this.emulateLegacyImagePyramid){var u=null;return this.levels.length>0&&a>=this.minLevel&&a<=this.maxLevel&&(u=this.levels[a].url),u}var c="0",d=Math.pow(.5,this.maxLevel-a),f,p,g,v,m,x,y,E,R,P,S,L,k,W,j,V;return this.levelSizes?(f=this.levelSizes[a].width,p=this.levelSizes[a].height):(f=Math.ceil(this.width*d),p=Math.ceil(this.height*d)),g=this.getTileWidth(a),v=this.getTileHeight(a),m=Math.round(g/d),x=Math.round(v/d),this.version===1?j="native."+this.tileFormat:j="default."+this.tileFormat,f<g&&p<v?(this.version===2&&f===this.width?L="full":this.version===3&&f===this.width&&p===this.height?L="max":this.version===3?L=f+","+p:L=f+",",y="full"):(E=l*m,R=h*x,P=Math.min(m,this.width-E),S=Math.min(x,this.height-R),l===0&&h===0&&P===this.width&&S===this.height?y="full":y=[E,R,P,S].join(","),k=Math.min(g,f-l*g),W=Math.min(v,p-h*v),this.version===2&&k===this.width?L="full":this.version===3&&k===this.width&&W===this.height?L="max":this.version===3?L=k+","+W:L=k+","),V=[this._id,y,L,c,j].join("/"),V},__testonly__:{canBeTiled:i,constructLevels:r}});function i(a){var l=["http://library.stanford.edu/iiif/image-api/compliance.html#level0","http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0","http://iiif.io/api/image/2/level0.json","level0","https://iiif.io/api/image/3/level0.json"],h=Array.isArray(a.profile)?a.profile[0]:a.profile,u=l.indexOf(h)!==-1,c=!1;return a.version===2&&a.profile.length>1&&a.profile[1].supports&&(c=a.profile[1].supports.indexOf("sizeByW")!==-1),a.version===3&&a.extraFeatures&&(c=a.extraFeatures.indexOf("sizeByWh")!==-1),!u||c}function r(a){for(var l=[],h=0;h<a.sizes.length;h++)l.push({url:a._id+"/full/"+a.sizes[h].width+","+(a.version===3?a.sizes[h].height:"")+"/0/default."+a.tileFormat,width:a.sizes[h].width,height:a.sizes[h].height});return l.sort(function(u,c){return u.width-c.width})}function s(a){if(!a||!a.documentElement)throw new Error(t.getString("Errors.Xml"));var l=a.documentElement,h=l.tagName,u=null;if(h==="info")try{return u={},o(l,u),u}catch(c){throw c instanceof Error?c:new Error(t.getString("Errors.IIIF"))}throw new Error(t.getString("Errors.IIIF"))}function o(a,l,h){var u,c;if(a.nodeType===3&&h)c=a.nodeValue.trim(),c.match(/^\d*$/)&&(c=Number(c)),l[h]?(t.isArray(l[h])||(l[h]=[l[h]]),l[h].push(c)):l[h]=c;else if(a.nodeType===1)for(u=0;u<a.childNodes.length;u++)o(a.childNodes[u],l,a.nodeName)}})(e),(function(t){t.OsmTileSource=function(i,r,s,o,a){var l;t.isPlainObject(i)?l=i:l={width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4]},(!l.width||!l.height)&&(l.width=65572864,l.height=65572864),l.tileSize||(l.tileSize=256,l.tileOverlap=0),l.tilesUrl||(l.tilesUrl="http://tile.openstreetmap.org/"),l.minLevel=8,t.TileSource.apply(this,[l])},t.extend(t.OsmTileSource.prototype,t.TileSource.prototype,{supports:function(i,r){return i.type&&i.type==="openstreetmaps"},configure:function(i,r,s){return i},getTileUrl:function(i,r,s){return this.tilesUrl+(i-8)+"/"+r+"/"+s+".png"}})})(e),(function(t){t.TmsTileSource=function(i,r,s,o,a){var l;t.isPlainObject(i)?l=i:l={width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4]};var h=Math.ceil(l.width/256)*256,u=Math.ceil(l.height/256)*256,c;h>u?c=h/256:c=u/256,l.maxLevel=Math.ceil(Math.log(c)/Math.log(2))-1,l.tileSize=256,l.width=h,l.height=u,t.TileSource.apply(this,[l])},t.extend(t.TmsTileSource.prototype,t.TileSource.prototype,{supports:function(i,r){return i.type&&i.type==="tiledmapservice"},configure:function(i,r,s){return i},getTileUrl:function(i,r,s){var o=this.getNumTiles(i).y-1;return this.tilesUrl+i+"/"+r+"/"+(o-s)+".png"}})})(e),(function(t){t.ZoomifyTileSource=function(i){typeof i.tileSize>"u"&&(i.tileSize=256),typeof i.fileFormat>"u"&&(i.fileFormat="jpg",this.fileFormat=i.fileFormat);var r={x:i.width,y:i.height};for(i.imageSizes=[{x:i.width,y:i.height}],i.gridSize=[this._getGridSize(i.width,i.height,i.tileSize)];parseInt(r.x,10)>i.tileSize||parseInt(r.y,10)>i.tileSize;)r.x=Math.floor(r.x/2),r.y=Math.floor(r.y/2),i.imageSizes.push({x:r.x,y:r.y}),i.gridSize.push(this._getGridSize(r.x,r.y,i.tileSize));i.imageSizes.reverse(),i.gridSize.reverse(),i.minLevel=0,i.maxLevel=i.gridSize.length-1,e.TileSource.apply(this,[i])},t.extend(t.ZoomifyTileSource.prototype,t.TileSource.prototype,{_getGridSize:function(i,r,s){return{x:Math.ceil(i/s),y:Math.ceil(r/s)}},_calculateAbsoluteTileNumber:function(i,r,s){for(var o=0,a={},l=0;l<i;l++)a=this.gridSize[l],o+=a.x*a.y;return a=this.gridSize[i],o+=a.x*s+r,o},supports:function(i,r){return i.type&&i.type==="zoomifytileservice"},configure:function(i,r,s){return i},getTileUrl:function(i,r,s){var o=0,a=this._calculateAbsoluteTileNumber(i,r,s);return o=Math.floor(a/256),this.tilesUrl+"TileGroup"+o+"/"+i+"-"+r+"-"+s+"."+this.fileFormat}})})(e),(function(t){t.LegacyTileSource=function(o){var a,l,h;t.isArray(o)&&(a={type:"legacy-image-pyramid",levels:o}),a.levels=i(a.levels),a.levels.length>0?(l=a.levels[a.levels.length-1].width,h=a.levels[a.levels.length-1].height):(l=0,h=0,t.console.error("No supported image formats found")),t.extend(!0,a,{width:l,height:h,tileSize:Math.max(h,l),tileOverlap:0,minLevel:0,maxLevel:a.levels.length>0?a.levels.length-1:0}),t.TileSource.apply(this,[a]),this.levels=a.levels},t.extend(t.LegacyTileSource.prototype,t.TileSource.prototype,{supports:function(o,a){return o.type&&o.type==="legacy-image-pyramid"||o.documentElement&&o.documentElement.getAttribute("type")==="legacy-image-pyramid"},configure:function(o,a,l){var h;return t.isPlainObject(o)?h=s(this,o):h=r(this,o),h},getLevelScale:function(o){var a=NaN;return this.levels.length>0&&o>=this.minLevel&&o<=this.maxLevel&&(a=this.levels[o].width/this.levels[this.maxLevel].width),a},getNumTiles:function(o){var a=this.getLevelScale(o);return a?new t.Point(1,1):new t.Point(0,0)},getTileUrl:function(o,a,l){var h=null;return this.levels.length>0&&o>=this.minLevel&&o<=this.maxLevel&&(h=this.levels[o].url),h}});function i(o){var a=[],l,h;for(h=0;h<o.length;h++)l=o[h],l.height&&l.width&&l.url?a.push({url:l.url,width:Number(l.width),height:Number(l.height)}):t.console.error("Unsupported image format: %s",l.url?l.url:"<no URL>");return a.sort(function(u,c){return u.height-c.height})}function r(o,a){if(!a||!a.documentElement)throw new Error(t.getString("Errors.Xml"));var l=a.documentElement,h=l.tagName,u=null,c=[],d,f;if(h==="image")try{for(u={type:l.getAttribute("type"),levels:[]},c=l.getElementsByTagName("level"),f=0;f<c.length;f++)d=c[f],u.levels.push({url:d.getAttribute("url"),width:parseInt(d.getAttribute("width"),10),height:parseInt(d.getAttribute("height"),10)});return s(o,u)}catch(p){throw p instanceof Error?p:new Error("Unknown error parsing Legacy Image Pyramid XML.")}else{if(h==="collection")throw new Error("Legacy Image Pyramid Collections not yet supported.");
vendor: 8,291 bytes, line 1
1if(h==="error")throw new Error("Error: "+a)}throw new Error("Unknown element "+h)}function s(o,a){return a.levels}})(e),(function(t){t.ImageTileSource=function(i){i=t.extend({buildPyramid:!0,crossOriginPolicy:!1,ajaxWithCredentials:!1},i),t.TileSource.apply(this,[i])},t.extend(t.ImageTileSource.prototype,t.TileSource.prototype,{supports:function(i,r){return i.type&&i.type==="image"},configure:function(i,r,s){return i},getImageInfo:function(i){var r=this._image=new Image,s=this;this.crossOriginPolicy&&(r.crossOrigin=this.crossOriginPolicy),this.ajaxWithCredentials&&(r.useCredentials=this.ajaxWithCredentials),t.addEvent(r,"load",function(){s.width=r.naturalWidth,s.height=r.naturalHeight,s.aspectRatio=s.width/s.height,s.dimensions=new t.Point(s.width,s.height),s._tileWidth=s.width,s._tileHeight=s.height,s.tileOverlap=0,s.minLevel=0,s.levels=s._buildLevels(),s.maxLevel=s.levels.length-1,s.ready=!0,s.raiseEvent("ready",{tileSource:s})}),t.addEvent(r,"error",function(){s.raiseEvent("open-failed",{message:"Error loading image at "+i,source:i})}),r.src=i},getLevelScale:function(i){var r=NaN;return i>=this.minLevel&&i<=this.maxLevel&&(r=this.levels[i].width/this.levels[this.maxLevel].width),r},getNumTiles:function(i){var r=this.getLevelScale(i);return r?new t.Point(1,1):new t.Point(0,0)},getTileUrl:function(i,r,s){var o=null;return i>=this.minLevel&&i<=this.maxLevel&&(o=this.levels[i].url),o},getContext2D:function(i,r,s){var o=null;return i>=this.minLevel&&i<=this.maxLevel&&(o=this.levels[i].context2D),o},destroy:function(i){this._freeupCanvasMemory(i)},_buildLevels:function(){var i=[{url:this._image.src,width:this._image.naturalWidth,height:this._image.naturalHeight}];if(!this.buildPyramid||!t.supportsCanvas)return delete this._image,i;var r=this._image.naturalWidth,s=this._image.naturalHeight,o=document.createElement("canvas"),a=o.getContext("2d");if(o.width=r,o.height=s,a.drawImage(this._image,0,0,r,s),i[0].context2D=a,delete this._image,t.isCanvasTainted(o))return i;for(;r>=2&&s>=2;){r=Math.floor(r/2),s=Math.floor(s/2);var l=document.createElement("canvas"),h=l.getContext("2d");l.width=r,l.height=s,h.drawImage(o,0,0,r,s),i.splice(0,0,{context2D:h,width:r,height:s}),o=l,a=h}return i},_freeupCanvasMemory:function(i){for(var r=0;r<this.levels.length;r++)this.levels[r].context2D&&(this.levels[r].context2D.canvas.height=0,this.levels[r].context2D.canvas.width=0,i&&i.raiseEvent("image-unloaded",{context2D:this.levels[r].context2D}))}})})(e),(function(t){t.TileSourceCollection=function(i,r,s,o){t.console.error("TileSourceCollection is deprecated; use World instead")}})(e),(function(t){t.ButtonState={REST:0,GROUP:1,HOVER:2,DOWN:3},t.Button=function(h){var u=this;t.EventSource.call(this),t.extend(!0,this,{tooltip:null,srcRest:null,srcGroup:null,srcHover:null,srcDown:null,clickTimeThreshold:t.DEFAULT_SETTINGS.clickTimeThreshold,clickDistThreshold:t.DEFAULT_SETTINGS.clickDistThreshold,fadeDelay:0,fadeLength:2e3,onPress:null,onRelease:null,onClick:null,onEnter:null,onExit:null,onFocus:null,onBlur:null,userData:null},h),this.element=h.element||t.makeNeutralElement("div"),h.element||(this.imgRest=t.makeTransparentImage(this.srcRest),this.imgGroup=t.makeTransparentImage(this.srcGroup),this.imgHover=t.makeTransparentImage(this.srcHover),this.imgDown=t.makeTransparentImage(this.srcDown),this.imgRest.alt=this.imgGroup.alt=this.imgHover.alt=this.imgDown.alt=this.tooltip,t.setElementPointerEventsNone(this.imgRest),t.setElementPointerEventsNone(this.imgGroup),t.setElementPointerEventsNone(this.imgHover),t.setElementPointerEventsNone(this.imgDown),this.element.style.position="relative",t.setElementTouchActionNone(this.element),this.imgGroup.style.position=this.imgHover.style.position=this.imgDown.style.position="absolute",this.imgGroup.style.top=this.imgHover.style.top=this.imgDown.style.top="0px",this.imgGroup.style.left=this.imgHover.style.left=this.imgDown.style.left="0px",this.imgHover.style.visibility=this.imgDown.style.visibility="hidden",this.element.appendChild(this.imgRest),this.element.appendChild(this.imgGroup),this.element.appendChild(this.imgHover),this.element.appendChild(this.imgDown)),this.addHandler("press",this.onPress),this.addHandler("release",this.onRelease),this.addHandler("click",this.onClick),this.addHandler("enter",this.onEnter),this.addHandler("exit",this.onExit),this.addHandler("focus",this.onFocus),this.addHandler("blur",this.onBlur),this.currentState=t.ButtonState.GROUP,this.fadeBeginTime=null,this.shouldFade=!1,this.element.style.display="inline-block",this.element.style.position="relative",this.element.title=this.tooltip,this.tracker=new t.MouseTracker({userData:"Button.tracker",element:this.element,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,enterHandler:function(c){c.insideElementPressed?(a(u,t.ButtonState.DOWN),u.raiseEvent("enter",{originalEvent:c.originalEvent})):c.buttonDownAny||a(u,t.ButtonState.HOVER)},focusHandler:function(c){u.tracker.enterHandler(c),u.raiseEvent("focus",{originalEvent:c.originalEvent})},leaveHandler:function(c){l(u,t.ButtonState.GROUP),c.insideElementPressed&&u.raiseEvent("exit",{originalEvent:c.originalEvent})},blurHandler:function(c){u.tracker.leaveHandler(c),u.raiseEvent("blur",{originalEvent:c.originalEvent})},pressHandler:function(c){a(u,t.ButtonState.DOWN),u.raiseEvent("press",{originalEvent:c.originalEvent})},releaseHandler:function(c){c.insideElementPressed&&c.insideElementReleased?(l(u,t.ButtonState.HOVER),u.raiseEvent("release",{originalEvent:c.originalEvent})):c.insideElementPressed?l(u,t.ButtonState.GROUP):a(u,t.ButtonState.HOVER)},clickHandler:function(c){c.quick&&u.raiseEvent("click",{originalEvent:c.originalEvent})},keyHandler:function(c){c.keyCode===13?(u.raiseEvent("click",{originalEvent:c.originalEvent}),u.raiseEvent("release",{originalEvent:c.originalEvent}),c.preventDefault=!0):c.preventDefault=!1}}),l(this,t.ButtonState.REST)},t.extend(t.Button.prototype,t.EventSource.prototype,{notifyGroupEnter:function(){a(this,t.ButtonState.GROUP)},notifyGroupExit:function(){l(this,t.ButtonState.REST)},disable:function(){this.notifyGroupExit(),this.element.disabled=!0,this.tracker.setTracking(!1),t.setElementOpacity(this.element,.2,!0)},enable:function(){this.element.disabled=!1,this.tracker.setTracking(!0),t.setElementOpacity(this.element,1,!0),this.notifyGroupEnter()},destroy:function(){this.imgRest&&(this.element.removeChild(this.imgRest),this.imgRest=null),this.imgGroup&&(this.element.removeChild(this.imgGroup),this.imgGroup=null),this.imgHover&&(this.element.removeChild(this.imgHover),this.imgHover=null),this.imgDown&&(this.element.removeChild(this.imgDown),this.imgDown=null),this.removeAllHandlers(),this.tracker.destroy(),this.element=null}});function i(h){t.requestAnimationFrame(function(){r(h)})}function r(h){var u,c,d;h.shouldFade&&(u=t.now(),c=u-h.fadeBeginTime,d=1-c/h.fadeLength,d=Math.min(1,d),d=Math.max(0,d),h.imgGroup&&t.setElementOpacity(h.imgGroup,d,!0),d>0&&i(h))}function s(h){h.shouldFade=!0,h.fadeBeginTime=t.now()+h.fadeDelay,window.setTimeout(function(){i(h)},h.fadeDelay)}function o(h){h.shouldFade=!1,h.imgGroup&&t.setElementOpacity(h.imgGroup,1,!0)}function a(h,u){h.element.disabled||(u>=t.ButtonState.GROUP&&h.currentState===t.ButtonState.REST&&(o(h),h.currentState=t.ButtonState.GROUP),u>=t.ButtonState.HOVER&&h.currentState===t.ButtonState.GROUP&&(h.imgHover&&(h.imgHover.style.visibility=""),h.currentState=t.ButtonState.HOVER),u>=t.ButtonState.DOWN&&h.currentState===t.ButtonState.HOVER&&(h.imgDown&&(h.imgDown.style.visibility=""),h.currentState=t.ButtonState.DOWN))}function l(h,u){h.element.disabled||(u<=t.ButtonState.HOVER&&h.currentState===t.ButtonState.DOWN&&(h.imgDown&&(h.imgDown.style.visibility="hidden"),h.currentState=t.ButtonState.HOVER),u<=t.ButtonState.GROUP&&h.currentState===t.ButtonState.HOVER&&(h.imgHover&&(h.imgHover.style.visibility="hidden"),h.currentState=t.ButtonState.GROUP),u<=t.ButtonState.REST&&h.currentState===t.ButtonState.GROUP&&(s(h),h.currentState=t.ButtonState.REST))}})(e),(function(t){t.ButtonGroup=function(i){t.extend(!0,this,{buttons:[],clickTimeThreshold:t.DEFAULT_SETTINGS.clickTimeThreshold,clickDistThreshold:t.DEFAULT_SETTINGS.clickDistThreshold,labelText:""},i);var r=this.buttons.concat([]),s=this,o;
vendor: 14,674 bytes, line 1
1if(this.element=i.element||t.makeNeutralElement("div"),!i.group)for(this.element.style.display="inline-block",o=0;o<r.length;o++)this.element.appendChild(r[o].element);t.setElementTouchActionNone(this.element),this.tracker=new t.MouseTracker({userData:"ButtonGroup.tracker",element:this.element,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,enterHandler:function(a){var l;for(l=0;l<s.buttons.length;l++)s.buttons[l].notifyGroupEnter()},leaveHandler:function(a){var l;if(!a.insideElementPressed)for(l=0;l<s.buttons.length;l++)s.buttons[l].notifyGroupExit()}})},t.ButtonGroup.prototype={addButton:function(i){this.buttons.push(i),this.element.appendChild(i.element)},emulateEnter:function(){this.tracker.enterHandler({eventSource:this.tracker})},emulateLeave:function(){this.tracker.leaveHandler({eventSource:this.tracker})},destroy:function(){for(;this.buttons.length;){var i=this.buttons.pop();this.element.removeChild(i.element),i.destroy()}this.tracker.destroy(),this.element=null}}})(e),(function(t){t.Rect=function(i,r,s,o,a){this.x=typeof i=="number"?i:0,this.y=typeof r=="number"?r:0,this.width=typeof s=="number"?s:0,this.height=typeof o=="number"?o:0,this.degrees=typeof a=="number"?a:0,this.degrees=t.positiveModulo(this.degrees,360);var l,h;this.degrees>=270?(l=this.getTopRight(),this.x=l.x,this.y=l.y,h=this.height,this.height=this.width,this.width=h,this.degrees-=270):this.degrees>=180?(l=this.getBottomRight(),this.x=l.x,this.y=l.y,this.degrees-=180):this.degrees>=90&&(l=this.getBottomLeft(),this.x=l.x,this.y=l.y,h=this.height,this.height=this.width,this.width=h,this.degrees-=90)},t.Rect.fromSummits=function(i,r,s){var o=i.distanceTo(r),a=i.distanceTo(s),l=r.minus(i),h=Math.atan(l.y/l.x);return l.x<0?h+=Math.PI:l.y<0&&(h+=2*Math.PI),new t.Rect(i.x,i.y,o,a,h/Math.PI*180)},t.Rect.prototype={clone:function(){return new t.Rect(this.x,this.y,this.width,this.height,this.degrees)},getAspectRatio:function(){return this.width/this.height},getTopLeft:function(){return new t.Point(this.x,this.y)},getBottomRight:function(){return new t.Point(this.x+this.width,this.y+this.height).rotate(this.degrees,this.getTopLeft())},getTopRight:function(){return new t.Point(this.x+this.width,this.y).rotate(this.degrees,this.getTopLeft())},getBottomLeft:function(){return new t.Point(this.x,this.y+this.height).rotate(this.degrees,this.getTopLeft())},getCenter:function(){return new t.Point(this.x+this.width/2,this.y+this.height/2).rotate(this.degrees,this.getTopLeft())},getSize:function(){return new t.Point(this.width,this.height)},equals:function(i){return i instanceof t.Rect&&this.x===i.x&&this.y===i.y&&this.width===i.width&&this.height===i.height&&this.degrees===i.degrees},times:function(i){return new t.Rect(this.x*i,this.y*i,this.width*i,this.height*i,this.degrees)},translate:function(i){return new t.Rect(this.x+i.x,this.y+i.y,this.width,this.height,this.degrees)},union:function(i){var r=this.getBoundingBox(),s=i.getBoundingBox(),o=Math.min(r.x,s.x),a=Math.min(r.y,s.y),l=Math.max(r.x+r.width,s.x+s.width),h=Math.max(r.y+r.height,s.y+s.height);return new t.Rect(o,a,l-o,h-a)},intersection:function(i){var r=1e-10,s=[],o=this.getTopLeft();i.containsPoint(o,r)&&s.push(o);var a=this.getTopRight();i.containsPoint(a,r)&&s.push(a);var l=this.getBottomLeft();i.containsPoint(l,r)&&s.push(l);var h=this.getBottomRight();i.containsPoint(h,r)&&s.push(h);var u=i.getTopLeft();this.containsPoint(u,r)&&s.push(u);var c=i.getTopRight();this.containsPoint(c,r)&&s.push(c);var d=i.getBottomLeft();this.containsPoint(d,r)&&s.push(d);var f=i.getBottomRight();this.containsPoint(f,r)&&s.push(f);for(var p=this._getSegments(),g=i._getSegments(),v=0;v<p.length;v++)for(var m=p[v],x=0;x<g.length;x++){var y=g[x],E=R(m[0],m[1],y[0],y[1]);E&&s.push(E)}function R(V,N,D,A){var O=N.minus(V),B=A.minus(D),G=-B.x*O.y+O.x*B.y;if(G===0)return null;var Y=(O.x*(V.y-D.y)-O.y*(V.x-D.x))/G,z=(B.x*(V.y-D.y)-B.y*(V.x-D.x))/G;return-r<=Y&&Y<=1-r&&-r<=z&&z<=1-r?new t.Point(V.x+z*O.x,V.y+z*O.y):null}if(s.length===0)return null;for(var P=s[0].x,S=s[0].x,L=s[0].y,k=s[0].y,W=1;W<s.length;W++){var j=s[W];j.x<P&&(P=j.x),j.x>S&&(S=j.x),j.y<L&&(L=j.y),j.y>k&&(k=j.y)}return new t.Rect(P,L,S-P,k-L)},_getSegments:function(){var i=this.getTopLeft(),r=this.getTopRight(),s=this.getBottomLeft(),o=this.getBottomRight();return[[i,r],[r,o],[o,s],[s,i]]},rotate:function(i,r){if(i=t.positiveModulo(i,360),i===0)return this.clone();r=r||this.getCenter();var s=this.getTopLeft().rotate(i,r),o=this.getTopRight().rotate(i,r),a=o.minus(s);a=a.apply(function(h){var u=1e-15;return Math.abs(h)<u?0:h});var l=Math.atan(a.y/a.x);return a.x<0?l+=Math.PI:a.y<0&&(l+=2*Math.PI),new t.Rect(s.x,s.y,this.width,this.height,l/Math.PI*180)},getBoundingBox:function(){if(this.degrees===0)return this.clone();var i=this.getTopLeft(),r=this.getTopRight(),s=this.getBottomLeft(),o=this.getBottomRight(),a=Math.min(i.x,r.x,s.x,o.x),l=Math.max(i.x,r.x,s.x,o.x),h=Math.min(i.y,r.y,s.y,o.y),u=Math.max(i.y,r.y,s.y,o.y);return new t.Rect(a,h,l-a,u-h)},getIntegerBoundingBox:function(){var i=this.getBoundingBox(),r=Math.floor(i.x),s=Math.floor(i.y),o=Math.ceil(i.width+i.x-r),a=Math.ceil(i.height+i.y-s);return new t.Rect(r,s,o,a)},containsPoint:function(i,r){r=r||0;var s=this.getTopLeft(),o=this.getTopRight(),a=this.getBottomLeft(),l=o.minus(s),h=a.minus(s);return(i.x-s.x)*l.x+(i.y-s.y)*l.y>=-r&&(i.x-o.x)*l.x+(i.y-o.y)*l.y<=r&&(i.x-s.x)*h.x+(i.y-s.y)*h.y>=-r&&(i.x-a.x)*h.x+(i.y-a.y)*h.y<=r},toString:function(){return"["+Math.round(this.x*100)/100+", "+Math.round(this.y*100)/100+", "+Math.round(this.width*100)/100+"x"+Math.round(this.height*100)/100+", "+Math.round(this.degrees*100)/100+"deg]"}}})(e),(function(t){var i={};t.ReferenceStrip=function(d){var f=this,p=d.viewer,g=t.getElementSize(p.element),v,m,x;for(d.id||(d.id="referencestrip-"+t.now(),this.element=t.makeNeutralElement("div"),this.element.id=d.id,this.element.className="referencestrip"),d=t.extend(!0,{sizeRatio:t.DEFAULT_SETTINGS.referenceStripSizeRatio,position:t.DEFAULT_SETTINGS.referenceStripPosition,scroll:t.DEFAULT_SETTINGS.referenceStripScroll,clickTimeThreshold:t.DEFAULT_SETTINGS.clickTimeThreshold},d,{element:this.element}),t.extend(this,d),i[this.id]={animating:!1},this.minPixelRatio=this.viewer.minPixelRatio,this.element.tabIndex=0,m=this.element.style,m.marginTop="0px",m.marginRight="0px",m.marginBottom="0px",m.marginLeft="0px",m.left="0px",m.bottom="0px",m.border="0px",m.background="#000",m.position="relative",t.setElementTouchActionNone(this.element),t.setElementOpacity(this.element,.8),this.viewer=p,this.tracker=new t.MouseTracker({userData:"ReferenceStrip.tracker",element:this.element,clickHandler:t.delegate(this,r),dragHandler:t.delegate(this,s),scrollHandler:t.delegate(this,o),enterHandler:t.delegate(this,l),leaveHandler:t.delegate(this,h),keyDownHandler:t.delegate(this,u),keyHandler:t.delegate(this,c),preProcessEventHandler:function(y){y.eventType==="wheel"&&(y.preventDefault=!0)}}),d.width&&d.height?(this.element.style.width=d.width+"px",this.element.style.height=d.height+"px",p.addControl(this.element,{anchor:t.ControlAnchor.BOTTOM_LEFT})):d.scroll==="horizontal"?(this.element.style.width=g.x*d.sizeRatio*p.tileSources.length+12*p.tileSources.length+"px",this.element.style.height=g.y*d.sizeRatio+"px",p.addControl(this.element,{anchor:t.ControlAnchor.BOTTOM_LEFT})):(this.element.style.height=g.y*d.sizeRatio*p.tileSources.length+12*p.tileSources.length+"px",this.element.style.width=g.x*d.sizeRatio+"px",p.addControl(this.element,{anchor:t.ControlAnchor.TOP_LEFT})),this.panelWidth=g.x*this.sizeRatio+8,this.panelHeight=g.y*this.sizeRatio+8,this.panels=[],this.miniViewers={},x=0;x<p.tileSources.length;x++)v=t.makeNeutralElement("div"),v.id=this.element.id+"-"+x,v.style.width=f.panelWidth+"px",v.style.height=f.panelHeight+"px",v.style.display="inline",v.style.float="left",v.style.cssFloat="left",v.style.padding="2px",t.setElementTouchActionNone(v),t.setElementPointerEventsNone(v),this.element.appendChild(v),v.activePanel=!1,this.panels.push(v);a(this,this.scroll==="vertical"?g.y:g.x,0),this.setFocus(0)},t.ReferenceStrip.prototype={setFocus:function(d){var f=this.element.querySelector("#"+this.element.id+"-"+d),p=t.getElementSize(this.viewer.canvas),g=Number(this.element.style.width.replace("px","")),v=Number(this.element.style.height.replace("px","")),m=-Number(this.element.style.marginLeft.replace("px","")),x=-Number(this.element.style.marginTop.replace("px","")),y;this.currentSelected!==f&&(this.currentSelected&&(this.currentSelected.style.background="#000"),this.currentSelected=f,this.currentSelected.style.background="#999",this.scroll==="horizontal"?(y=Number(d)*(this.panelWidth+3),y>m+p.x-this.panelWidth?(y=Math.min(y,g-p.x),this.element.style.marginLeft=-y+"px",a(this,p.x,-y)):y<m&&(y=Math.max(0,y-p.x/2),this.element.style.marginLeft=-y+"px",a(this,p.x,-y))):(y=Number(d)*(this.panelHeight+3),y>x+p.y-this.panelHeight?(y=Math.min(y,v-p.y),this.element.style.marginTop=-y+"px",a(this,p.y,-y)):y<x&&(y=Math.max(0,y-p.y/2),this.element.style.marginTop=-y+"px",a(this,p.y,-y))),this.currentPage=d,l.call(this,{eventSource:this.tracker}))},update:function(){return!!i[this.id].animating},destroy:function(){if(this.miniViewers)for(var d in this.miniViewers)this.miniViewers[d].destroy();this.tracker.destroy(),this.element&&this.viewer.removeControl(this.element)}};function r(d){if(d.quick){var f;this.scroll==="horizontal"?f=Math.floor(d.position.x/(this.panelWidth+4)):f=Math.floor(d.position.y/this.panelHeight),this.viewer.goToPage(f)}this.element.focus()}function s(d){if(this.dragging=!0,this.element){var f=Number(this.element.style.marginLeft.replace("px","")),p=Number(this.element.style.marginTop.replace("px","")),g=Number(this.element.style.width.replace("px","")),v=Number(this.element.style.height.replace("px","")),m=t.getElementSize(this.viewer.canvas);this.scroll==="horizontal"?-d.delta.x>0?f>-(g-m.x)&&(this.element.style.marginLeft=f+d.delta.x*2+"px",a(this,m.x,f+d.delta.x*2)):-d.delta.x<0&&f<0&&(this.element.style.marginLeft=f+d.delta.x*2+"px",a(this,m.x,f+d.delta.x*2)):-d.delta.y>0?p>-(v-m.y)&&(this.element.style.marginTop=p+d.delta.y*2+"px",a(this,m.y,p+d.delta.y*2)):-d.delta.y<0&&p<0&&(this.element.style.marginTop=p+d.delta.y*2+"px",a(this,m.y,p+d.delta.y*2))}}function o(d){if(this.element){var f=Number(this.element.style.marginLeft.replace("px","")),p=Number(this.element.style.marginTop.replace("px","")),g=Number(this.element.style.width.replace("px","")),v=Number(this.element.style.height.replace("px","")),m=t.getElementSize(this.viewer.canvas);this.scroll==="horizontal"?d.scroll>0?f>-(g-m.x)&&(this.element.style.marginLeft=f-d.scroll*60+"px",a(this,m.x,f-d.scroll*60)):d.scroll<0&&f<0&&(this.element.style.marginLeft=f-d.scroll*60+"px",a(this,m.x,f-d.scroll*60)):d.scroll<0?p>m.y-v&&(this.element.style.marginTop=p+d.scroll*60+"px",a(this,m.y,p+d.scroll*60)):d.scroll>0&&p<0&&(this.element.style.marginTop=p+d.scroll*60+"px",a(this,m.y,p+d.scroll*60)),d.preventDefault=!0}}function a(d,f,p){var g,v,m,x,y,E;for(d.scroll==="horizontal"?g=d.panelWidth:g=d.panelHeight,v=Math.ceil(f/g)+5,m=Math.ceil((Math.abs(p)+f)/g)+1,v=m-v,v=v<0?0:v,y=v;y<m&&y<d.panels.length;y++)if(E=d.panels[y],!E.activePanel){var R,P=d.viewer.tileSources[y];P.referenceStripThumbnailUrl?R={type:"image",url:P.referenceStripThumbnailUrl}:R=P,x=new t.Viewer({id:E.id,tileSources:[R],element:E,navigatorSizeRatio:d.sizeRatio,showNavigator:!1,mouseNavEnabled:!1,showNavigationControl:!1,showSequenceControl:!1,immediateRender:!0,blendTime:0,animationTime:0,loadTilesWithAjax:d.viewer.loadTilesWithAjax,ajaxHeaders:d.viewer.ajaxHeaders,drawer:"canvas"}),t.setElementPointerEventsNone(x.canvas),t.setElementPointerEventsNone(x.container),x.innerTracker.setTracking(!1),x.outerTracker.setTracking(!1),d.miniViewers[E.id]=x,E.activePanel=!0}}function l(d){var f=d.eventSource.element;this.scroll==="horizontal"?f.style.marginBottom="0px":f.style.marginLeft="0px"}function h(d){var f=d.eventSource.element;this.scroll==="horizontal"?f.style.marginBottom="-"+t.getElementSize(f).y/2+"px":f.style.marginLeft="-"+t.getElementSize(f).x/2+"px"}function u(d){if(!d.ctrl&&!d.alt&&!d.meta)switch(d.keyCode){case 38:o.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;case 40:o.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 37:o.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 39:o.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;default:d.preventDefault=!1;break}else d.preventDefault=!1}function c(d){if(!d.ctrl&&!d.alt&&!d.meta)switch(d.keyCode){case 61:o.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;case 45:o.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 48:case 119:case 87:o.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;case 115:case 83:o.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 97:o.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),d.preventDefault=!0;break;case 100:o.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),d.preventDefault=!0;break;default:d.preventDefault=!1;break}else d.preventDefault=!1}})(e),(function(t){t.DisplayRect=function(i,r,s,o,a,l){t.Rect.apply(this,[i,r,s,o]),this.minLevel=a,this.maxLevel=l},t.extend(t.DisplayRect.prototype,t.Rect.prototype)})(e),(function(t){t.Spring=function(r){var s=arguments;typeof r!="object"&&(r={initial:s.length&&typeof s[0]=="number"?s[0]:void 0,springStiffness:s.length>1?s[1].springStiffness:5,animationTime:s.length>1?s[1].animationTime:1.5}),t.console.assert(typeof r.springStiffness=="number"&&r.springStiffness!==0,"[OpenSeadragon.Spring] options.springStiffness must be a non-zero number"),t.console.assert(typeof r.animationTime=="number"&&r.animationTime>=0,"[OpenSeadragon.Spring] options.animationTime must be a number greater than or equal to 0"),r.exponential&&(this._exponential=!0,delete r.exponential),t.extend(!0,this,r),this.current={value:typeof this.initial=="number"?this.initial:this._exponential?0:1,time:t.now()},t.console.assert(!this._exponential||this.current.value!==0,"[OpenSeadragon.Spring] value must be non-zero for exponential springs"),this.start={value:this.current.value,time:this.current.time},this.target={value:this.current.value,time:this.current.time}
vendor: 5,147 bytes, line 1
1,this._exponential&&(this.start._logValue=Math.log(this.start.value),this.target._logValue=Math.log(this.target.value),this.current._logValue=Math.log(this.current.value))},t.Spring.prototype={resetTo:function(r){t.console.assert(!this._exponential||r!==0,"[OpenSeadragon.Spring.resetTo] target must be non-zero for exponential springs"),this.start.value=this.target.value=this.current.value=r,this.start.time=this.target.time=this.current.time=t.now(),this._exponential&&(this.start._logValue=Math.log(this.start.value),this.target._logValue=Math.log(this.target.value),this.current._logValue=Math.log(this.current.value))},springTo:function(r){t.console.assert(!this._exponential||r!==0,"[OpenSeadragon.Spring.springTo] target must be non-zero for exponential springs"),this.start.value=this.current.value,this.start.time=this.current.time,this.target.value=r,this.target.time=this.start.time+1e3*this.animationTime,this._exponential&&(this.start._logValue=Math.log(this.start.value),this.target._logValue=Math.log(this.target.value))},shiftBy:function(r){this.start.value+=r,this.target.value+=r,this._exponential&&(t.console.assert(this.target.value!==0&&this.start.value!==0,"[OpenSeadragon.Spring.shiftBy] spring value must be non-zero for exponential springs"),this.start._logValue=Math.log(this.start.value),this.target._logValue=Math.log(this.target.value))},setExponential:function(r){this._exponential=r,this._exponential&&(t.console.assert(this.current.value!==0&&this.target.value!==0&&this.start.value!==0,"[OpenSeadragon.Spring.setExponential] spring value must be non-zero for exponential springs"),this.start._logValue=Math.log(this.start.value),this.target._logValue=Math.log(this.target.value),this.current._logValue=Math.log(this.current.value))},update:function(){this.current.time=t.now();let r,s;if(this._exponential?(r=this.start._logValue,s=this.target._logValue):(r=this.start.value,s=this.target.value),this.current.time>=this.target.time)this.current.value=this.target.value;else{let o=r+(s-r)*i(this.springStiffness,(this.current.time-this.start.time)/(this.target.time-this.start.time));this._exponential?this.current.value=Math.exp(o):this.current.value=o}return this.current.value!==this.target.value},isAtTargetValue:function(){return this.current.value===this.target.value}};function i(r,s){return(1-Math.exp(r*-s))/(1-Math.exp(-r))}})(e),(function(t){t.ImageJob=function(r){t.extend(!0,this,{timeout:t.DEFAULT_SETTINGS.timeout,jobId:null,tries:0},r),this.data=null,this.userData={},this.errorMsg=null},t.ImageJob.prototype={start:function(){this.tries++;var r=this,s=this.abort;this.jobId=window.setTimeout(function(){r.finish(null,null,"Image load exceeded timeout ("+r.timeout+" ms)")},this.timeout),this.abort=function(){r.source.downloadTileAbort(r),typeof s=="function"&&s()},this.source.downloadTileStart(this)},finish:function(r,s,o){this.data=r,this.request=s,this.errorMsg=o,this.jobId&&window.clearTimeout(this.jobId),this.callback(this)}},t.ImageLoader=function(r){t.extend(!0,this,{jobLimit:t.DEFAULT_SETTINGS.imageLoaderLimit,timeout:t.DEFAULT_SETTINGS.timeout,jobQueue:[],failedTiles:[],jobsInProgress:0},r)},t.ImageLoader.prototype={addJob:function(r){if(!r.source){t.console.error("ImageLoader.prototype.addJob() requires [options.source]. TileSource since new API defines how images are fetched. Creating a dummy TileSource.");var s=t.TileSource.prototype;r.source={downloadTileStart:s.downloadTileStart,downloadTileAbort:s.downloadTileAbort}}var o=this,a=function(u){i(o,u,r.callback)},l={src:r.src,tile:r.tile||{},source:r.source,loadWithAjax:r.loadWithAjax,ajaxHeaders:r.loadWithAjax?r.ajaxHeaders:null,crossOriginPolicy:r.crossOriginPolicy,ajaxWithCredentials:r.ajaxWithCredentials,postData:r.postData,callback:a,abort:r.abort,timeout:this.timeout},h=new t.ImageJob(l);!this.jobLimit||this.jobsInProgress<this.jobLimit?(h.start(),this.jobsInProgress++):this.jobQueue.push(h)},clear:function(){for(var r=0;r<this.jobQueue.length;r++){var s=this.jobQueue[r];typeof s.abort=="function"&&s.abort()}this.jobQueue=[]}};function i(r,s,o){s.errorMsg!==""&&(s.data===null||s.data===void 0)&&s.tries<1+r.tileRetryMax&&r.failedTiles.push(s);var a;r.jobsInProgress--,(!r.jobLimit||r.jobsInProgress<r.jobLimit)&&r.jobQueue.length>0&&(a=r.jobQueue.shift(),a.start(),r.jobsInProgress++),r.tileRetryMax>0&&r.jobQueue.length===0&&(!r.jobLimit||r.jobsInProgress<r.jobLimit)&&r.failedTiles.length>0&&(a=r.failedTiles.shift(),setTimeout(function(){a.start()},r.tileRetryDelay),r.jobsInProgress++),o(s.data,s.errorMsg,s.request)}})(e),(function(t){t.Tile=function(i,r,s,o,a,l,h,u,c,d,f,p){this.level=i,this.x=r,this.y=s,this.bounds=o,this.positionedBounds=new e.Rect(o.x,o.y,o.width,o.height),this.sourceBounds=d,this.exists=a,this._url=l,this.postData=f,this.context2D=h,this.loadWithAjax=u,this.ajaxHeaders=c,p===void 0&&(t.console.warn("Tile constructor needs 'cacheKey' variable: creation tile cache in Tile class is deprecated. TileSource.prototype.getTileHashKey will be used."),p=t.TileSource.prototype.getTileHashKey(i,r,s,l,c,f)),this.cacheKey=p,this.loaded=!1,this.loading=!1,this.element=null,this.img
vendor: 8,471 bytes, line 1
1Element=null,this.style=null,this.position=null,this.size=null,this.flipped=!1,this.blendStart=null,this.opacity=null,this.squaredDistance=null,this.visibility=null,this.hasTransparency=!1,this.beingDrawn=!1,this.lastTouchTime=0,this.isRightMost=!1,this.isBottomMost=!1},t.Tile.prototype={toString:function(){return this.level+"/"+this.x+"_"+this.y},_hasTransparencyChannel:function(){return console.warn("Tile.prototype._hasTransparencyChannel() has been deprecated and will be removed in the future. Use TileSource.prototype.hasTransparency() instead."),!!this.context2D||this.getUrl().match(".png")},get image(){return t.console.error("[Tile.image] property has been deprecated. Use [Tile.prototype.getImage] instead."),this.getImage()},get url(){return t.console.error("[Tile.url] property has been deprecated. Use [Tile.prototype.getUrl] instead."),this.getUrl()},getImage:function(){return this.cacheImageRecord.getImage()},getUrl:function(){return typeof this._url=="function"?this._url():this._url},getCanvasContext:function(){return this.context2D||this.cacheImageRecord&&this.cacheImageRecord.getRenderedContext()},getScaleForEdgeSmoothing:function(){var i;if(this.cacheImageRecord)i=this.cacheImageRecord.getRenderedContext();else if(this.context2D)i=this.context2D;else return t.console.warn("[Tile.drawCanvas] attempting to get tile scale %s when tile's not cached",this.toString()),1;return i.canvas.width/(this.size.x*t.pixelDensityRatio)},getTranslationForEdgeSmoothing:function(i,r,s){var o=Math.max(1,Math.ceil((s.x-r.x)/2)),a=Math.max(1,Math.ceil((s.y-r.y)/2));return new t.Point(o,a).minus(this.position.times(t.pixelDensityRatio).times(i||1).apply(function(l){return l%1}))},unload:function(){this.imgElement&&this.imgElement.parentNode&&this.imgElement.parentNode.removeChild(this.imgElement),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.element=null,this.imgElement=null,this.loaded=!1,this.loading=!1}}})(e),(function(t){t.OverlayPlacement=t.Placement,t.OverlayRotationMode=t.freezeObject({NO_ROTATION:1,EXACT:2,BOUNDING_BOX:3}),t.Overlay=function(i,r,s){var o;t.isPlainObject(i)?o=i:o={element:i,location:r,placement:s},this.elementWrapper=document.createElement("div"),this.element=o.element,this.elementWrapper.appendChild(this.element),this.element.id?this.elementWrapper.id="overlay-wrapper-"+this.element.id:this.elementWrapper.id="overlay-wrapper",this.style=this.elementWrapper.style,this._init(o)},t.Overlay.prototype={_init:function(i){this.location=i.location,this.placement=i.placement===void 0?t.Placement.TOP_LEFT:i.placement,this.onDraw=i.onDraw,this.checkResize=i.checkResize===void 0?!0:i.checkResize,this.width=i.width===void 0?null:i.width,this.height=i.height===void 0?null:i.height,this.rotationMode=i.rotationMode||t.OverlayRotationMode.EXACT,this.location instanceof t.Rect&&(this.width=this.location.width,this.height=this.location.height,this.location=this.location.getTopLeft(),this.placement=t.Placement.TOP_LEFT),this.scales=this.width!==null&&this.height!==null,this.bounds=new t.Rect(this.location.x,this.location.y,this.width,this.height),this.position=this.location},adjust:function(i,r){var s=t.Placement.properties[this.placement];s&&(s.isHorizontallyCentered?i.x-=r.x/2:s.isRight&&(i.x-=r.x),s.isVerticallyCentered?i.y-=r.y/2:s.isBottom&&(i.y-=r.y))},destroy:function(){var i=this.elementWrapper,r=this.style;i.parentNode&&(i.parentNode.removeChild(i),i.prevElementParent&&(r.display="none",document.body.appendChild(i))),this.onDraw=null,r.top="",r.left="",r.position="",this.width!==null&&(r.width=""),this.height!==null&&(r.height="");var s=t.getCssPropertyWithVendorPrefix("transformOrigin"),o=t.getCssPropertyWithVendorPrefix("transform");s&&o&&(r[s]="",r[o]="")},drawHTML:function(i,r){var s=this.elementWrapper;s.parentNode!==i&&(s.prevElementParent=s.parentNode,s.prevNextSibling=s.nextSibling,i.appendChild(s),this.style.position="absolute",this.size=t.getElementSize(this.elementWrapper));var o=this._getOverlayPositionAndSize(r),a=o.position,l=this.size=o.size,h="";r.overlayPreserveContentDirection&&(h=r.flipped?" scaleX(-1)":" scaleX(1)");var u=r.flipped?-o.rotate:o.rotate,c=r.flipped?" scaleX(-1)":"";if(this.onDraw)this.onDraw(a,l,this.element);else{var d=this.style,f=this.element.style;f.display="block",d.left=a.x+"px",d.top=a.y+"px",this.width!==null&&(f.width=l.x+"px"),this.height!==null&&(f.height=l.y+"px");var p=t.getCssPropertyWithVendorPrefix("transformOrigin"),g=t.getCssPropertyWithVendorPrefix("transform");p&&g&&(u&&!r.flipped?(f[g]="",d[p]=this._getTransformOrigin(),d[g]="rotate("+u+"deg)"):!u&&r.flipped?(f[g]=h,d[p]=this._getTransformOrigin(),d[g]=c):u&&r.flipped?(f[g]=h,d[p]=this._getTransformOrigin(),d[g]="rotate("+u+"deg)"+c):(f[g]="",d[p]="",d[g]="")),d.display="flex"}},_getOverlayPositionAndSize:function(i){var r=i.pixelFromPoint(this.location,!0),s=this._getSizeInPixels(i);this.adjust(r,s);var o=0;if(i.getRotation(!0)&&this.rotationMode!==t.OverlayRotationMode.NO_ROTATION)if(this.rotationMode===t.OverlayRotationMode.BOUNDING_BOX&&this.width!==null&&this.height!==null){var a=new t.Rect(r.x,r.y,s.x,s.y),l=this._getBoundingBox(a,i.getRotation(!0));r=l.getTopLeft(),s=l.getSize()}else o=i.getRotation(!0);return i.flipped&&(r.x=i.getContainerSize().x-r.x),{position:r,size:s,rotate:o}},_getSizeInPixels:function(i){var r=this.size.x,s=this.size.y;if(this.width!==null||this.height!==null){var o=i.deltaPixelsFromPointsNoRotate(new t.Point(this.width||0,this.height||0),!0);this.width!==null&&(r=o.x),this.height!==null&&(s=o.y)}if(this.checkResize&&(this.width===null||this.height===null)){var a=this.size=t.getElementSize(this.elementWrapper);this.width===null&&(r=a.x),this.height===null&&(s=a.y)}return new t.Point(r,s)},_getBoundingBox:function(i,r){var s=this._getPlacementPoint(i);return i.rotate(r,s).getBoundingBox()},_getPlacementPoint:function(i){var r=new t.Point(i.x,i.y),s=t.Placement.properties[this.placement];return s&&(s.isHorizontallyCentered?r.x+=i.width/2:s.isRight&&(r.x+=i.width),s.isVerticallyCentered?r.y+=i.height/2:s.isBottom&&(r.y+=i.height)),r},_getTransformOrigin:function(){var i="",r=t.Placement.properties[this.placement];return r&&(r.isLeft?i="left":r.isRight&&(i="right"),r.isTop?i+=" top":r.isBottom&&(i+=" bottom")),i},update:function(i,r){var s=t.isPlainObject(i)?i:{location:i,placement:r};this._init({location:s.location||this.location,placement:s.placement!==void 0?s.placement:this.placement,onDraw:s.onDraw||this.onDraw,checkResize:s.checkResize||this.checkResize,width:s.width!==void 0?s.width:this.width,height:s.height!==void 0?s.height:this.height,rotationMode:s.rotationMode||this.rotationMode})},getBounds:function(i){t.console.assert(i,"A viewport must now be passed to Overlay.getBounds.");var r=this.width,s=this.height;if(r===null||s===null){var o=i.deltaPointsFromPixelsNoRotate(this.size,!0);r===null&&(r=o.x),s===null&&(s=o.y)}var a=this.location.clone();return this.adjust(a,new t.Point(r,s)),this._adjustBoundsForRotation(i,new t.Rect(a.x,a.y,r,s))},_adjustBoundsForRotation:function(i,r){if(!i||i.getRotation(!0)===0||this.rotationMode===t.OverlayRotationMode.EXACT)return r;if(this.rotationMode===t.OverlayRotationMode.BOUNDING_BOX){if(this.width===null||this.height===null)return r;var s=this._getOverlayPositionAndSize(i);return i.viewerElementToViewportRectangle(new t.Rect(s.position.x,s.position.y,s.size.x,s.size.y))}return r.rotate(-i.getRotation(!0),this._getPlacementPoint(r))}}})(e),(function(t){const i=t;i.DrawerBase=class{constructor(s){t.console.assert(s.viewer,"[Drawer] options.viewer is required"),t.console.assert(s.viewport,"[Drawer] options.viewport is required"),t.console.assert(s.element,"[Drawer] options.element is required"),this.viewer=s.viewer,this.viewport=s.viewport,this.debugGridColor=typeof s.debugGridColor=="string"?[s.debugGridColor]:s.debugGridColor||t.DEFAULT_SETTINGS.debugGridColor,this.options=s.options||{},this.container=t.getElement(s.element),this._renderingTarget=this._createDrawingElement(),this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.position="absolute",this.canvas.style.left="0",t.setElementOpacity(this.canvas,this.viewer.opacity,!0),t.setElementPointerEventsNone(this.canvas),t.setElementTouchActionNone(this.canvas),this.container.style.textAlign="left",this.container.appendChild(this.canvas),this._checkForAPIOverrides()}get canvas(){return this._renderingTarget}
vendor: 5,596 bytes, line 1
1get element(){return t.console.error("Drawer.element is deprecated. Use Drawer.container instead."),this.container}getType(){t.console.error("Drawer.getType must be implemented by child class")}static isSupported(){t.console.error("Drawer.isSupported must be implemented by child class")}_createDrawingElement(){return t.console.error("Drawer._createDrawingElement must be implemented by child class"),null}draw(s){t.console.error("Drawer.draw must be implemented by child class")}canRotate(){t.console.error("Drawer.canRotate must be implemented by child class")}destroy(){t.console.error("Drawer.destroy must be implemented by child class")}minimumOverlapRequired(s){return!1}setImageSmoothingEnabled(s){t.console.error("Drawer.setImageSmoothingEnabled must be implemented by child class")}drawDebuggingRect(s){t.console.warn("[drawer].drawDebuggingRect is not implemented by this drawer")}clear(){t.console.warn("[drawer].clear() is deprecated. The drawer is responsible for clearing itself as needed before drawing tiles.")}_checkForAPIOverrides(){if(this._createDrawingElement===t.DrawerBase.prototype._createDrawingElement)throw new Error("[drawer]._createDrawingElement must be implemented by child class");if(this.draw===t.DrawerBase.prototype.draw)throw new Error("[drawer].draw must be implemented by child class");if(this.canRotate===t.DrawerBase.prototype.canRotate)throw new Error("[drawer].canRotate must be implemented by child class");if(this.destroy===t.DrawerBase.prototype.destroy)throw new Error("[drawer].destroy must be implemented by child class");if(this.setImageSmoothingEnabled===t.DrawerBase.prototype.setImageSmoothingEnabled)throw new Error("[drawer].setImageSmoothingEnabled must be implemented by child class")}viewportToDrawerRectangle(s){var o=this.viewport.pixelFromPointNoRotate(s.getTopLeft(),!0),a=this.viewport.deltaPixelsFromPointsNoRotate(s.getSize(),!0);return new t.Rect(o.x*t.pixelDensityRatio,o.y*t.pixelDensityRatio,a.x*t.pixelDensityRatio,a.y*t.pixelDensityRatio)}viewportCoordToDrawerCoord(s){var o=this.viewport.pixelFromPointNoRotate(s,!0);return new t.Point(o.x*t.pixelDensityRatio,o.y*t.pixelDensityRatio)}_calculateCanvasSize(){var s=t.pixelDensityRatio,o=this.viewport.getContainerSize();return new i.Point(Math.round(o.x*s),Math.round(o.y*s))}_raiseTiledImageDrawnEvent(s,o){this.viewer&&this.viewer.raiseEvent("tiled-image-drawn",{tiledImage:s,tiles:o})}_raiseDrawerErrorEvent(s,o){this.viewer&&this.viewer.raiseEvent("drawer-error",{tiledImage:s,drawer:this,error:o})}}})(e),(function(t){const i=t;class r extends i.DrawerBase{constructor(o){super(o),this.viewer.rejectEventHandler("tile-drawing","The HTMLDrawer does not raise the tile-drawing event"),this.viewer.allowEventHandler("tile-drawn")}static isSupported(){return!0}getType(){return"html"}minimumOverlapRequired(o){return!0}_createDrawingElement(){return t.makeNeutralElement("div")}draw(o){var a=this;this._prepareNewFrame(),o.forEach(function(l){l.opacity!==0&&a._drawTiles(l)})}canRotate(){return!1}destroy(){this.container.removeChild(this.canvas)}setImageSmoothingEnabled(){}_prepareNewFrame(){this.canvas.innerHTML=""}_drawTiles(o){var a=o.getTilesToDraw().map(u=>u.tile);if(!(o.opacity===0||a.length===0&&!o.placeholderFillStyle))for(var l=a.length-1;l>=0;l--){var h=a[l];this._drawTile(h),this.viewer&&this.viewer.raiseEvent("tile-drawn",{tiledImage:o,tile:h})}}_drawTile(o){t.console.assert(o,"[Drawer._drawTile] tile is required");let a=this.canvas;if(!o.cacheImageRecord){t.console.warn("[Drawer._drawTileToHTML] attempting to draw tile %s when it's not cached",o.toString());return}if(!o.loaded){t.console.warn("Attempting to draw tile %s when it's not yet loaded.",o.toString());return}if(!o.element){var l=o.getImage();if(!l)return;o.element=t.makeNeutralElement("div"),o.imgElement=l.cloneNode(),o.imgElement.style.msInterpolationMode="nearest-neighbor",o.imgElement.style.width="100%",o.imgElement.style.height="100%",o.style=o.element.style,o.style.position="absolute"}o.element.parentNode!==a&&a.appendChild(o.element),o.imgElement.parentNode!==o.element&&o.element.appendChild(o.imgElement),o.style.top=o.position.y+"px",o.style.left=o.position.x+"px",o.style.height=o.size.y+"px",o.style.width=o.size.x+"px",o.flipped&&(o.style.transform="scaleX(-1)"),t.setElementOpacity(o.element,o.opacity)}}t.HTMLDrawer=r})(e),(function(t){const i=t;class r extends i.DrawerBase{constructor(u){super(u),this.context=this.canvas.getContext("2d"),this.sketchCanvas=null,this.sketchContext=null,this._imageSmoothingEnabled=!0,this.viewer.allowEventHandler("tile-drawn"),this.viewer.allowEventHandler("tile-drawing")}static isSupported(){return t.supportsCanvas}getType(){return"canvas"}_createDrawingElement(){let u=t.makeNeutralElement("canvas"),c=this._calculateCanvasSize();return u.width=c.x,u.height=c.y,u}draw(u){this._prepareNewFrame(),this.viewer.viewport.getFlip()!==this._viewportFlipped&&this._flip();for(const c of u)c.opacity!==0&&this._drawTiles(c)}canRotate(){return!0}destroy(){this.canvas.width=1,this.canvas.height=1,this.sketchCanvas=null,this.sketchContext=null,this.container.removeChild(this.canvas)}minimumOverlapRequired(u){return!0}setImageSmoothingEnabled(u){this._imageSmoothingEnabled=!!u,this._updateImageSmoothingEnabled(this.context),this.viewer.forceRedraw()}drawDebuggingRect(u){var c=this.context;c.save(),c.lineWidth=2*t.pixelDensityRatio,c.strokeStyle=this.debugGridColor[0],c.fillStyle=this.debugGridColor[0],c.strokeRect(u.x*t.pixelDensityRatio,u.y*t.pixelDensityRatio,u.width*t.pixelDensityRatio,u.height*t.pixelDensityRatio),c.restore(
vendor: 86,133 bytes, lines 1-74
1)}get _viewportFlipped(){return this.context.getTransform().a<0}_raiseTileDrawingEvent(u,c,d,f){this.viewer.raiseEvent("tile-drawing",{tiledImage:u,context:c,tile:d,rendered:f})}_prepareNewFrame(){var u=this._calculateCanvasSize();if((this.canvas.width!==u.x||this.canvas.height!==u.y)&&(this.canvas.width=u.x,this.canvas.height=u.y,this._updateImageSmoothingEnabled(this.context),this.sketchCanvas!==null)){var c=this._calculateSketchCanvasSize();this.sketchCanvas.width=c.x,this.sketchCanvas.height=c.y,this._updateImageSmoothingEnabled(this.sketchContext)}this._clear()}_clear(u,c){var d=this._getContext(u);if(c)d.clearRect(c.x,c.y,c.width,c.height);else{var f=d.canvas;d.clearRect(0,0,f.width,f.height)}}_drawTiles(u){var c=u.getTilesToDraw().map(V=>V.tile);if(!(u.opacity===0||c.length===0&&!u.placeholderFillStyle)){var d=c[0],f;d&&(f=u.opacity<1||u.compositeOperation&&u.compositeOperation!=="source-over"||!u._isBottomItem()&&u.source.hasTransparency(d.context2D,d.getUrl(),d.ajaxHeaders,d.postData));var p,g,v=this.viewport.getZoom(!0),m=u.viewportToImageZoom(v);c.length>1&&m>u.smoothTileEdgesMinZoom&&!u.iOSDevice&&u.getRotation(!0)%360===0&&(f=!0,p=d.getScaleForEdgeSmoothing(),g=d.getTranslationForEdgeSmoothing(p,this._getCanvasSize(!1),this._getCanvasSize(!0)));var x;f&&(p||(x=this.viewport.viewportToViewerElementRectangle(u.getClippedBounds(!0)).getIntegerBoundingBox(),x=x.times(t.pixelDensityRatio)),this._clear(!0,x)),p||this._setRotations(u,f);var y=!1;if(u._clip){this._saveContext(f);var E=u.imageToViewportRectangle(u._clip,!0);E=E.rotate(-u.getRotation(!0),u._getRotationPoint(!0));var R=this.viewportToDrawerRectangle(E);p&&(R=R.times(p)),g&&(R=R.translate(g)),this._setClip(R,f),y=!0}if(u._croppingPolygons){var P=this;y||this._saveContext(f);try{var S=u._croppingPolygons.map(function(V){return V.map(function(N){var D=u.imageToViewportCoordinates(N.x,N.y,!0).rotate(-u.getRotation(!0),u._getRotationPoint(!0)),A=P.viewportCoordToDrawerCoord(D);return p&&(A=A.times(p)),g&&(A=A.plus(g)),A})});this._clipWithPolygons(S,f)}catch(V){t.console.error(V)}y=!0}if(u._hasOpaqueTile=!1,u.placeholderFillStyle&&u._hasOpaqueTile===!1){let V=this.viewportToDrawerRectangle(u.getBoundsNoRotate(!0));p&&(V=V.times(p)),g&&(V=V.translate(g));let N=null;typeof u.placeholderFillStyle=="function"?N=u.placeholderFillStyle(u,this.context):N=u.placeholderFillStyle,this._drawRectangle(V,N,f)}var L=l(u.subPixelRoundingForTransparency),k=!1;if(L===t.SUBPIXEL_ROUNDING_OCCURRENCES.ALWAYS)k=!0;else if(L===t.SUBPIXEL_ROUNDING_OCCURRENCES.ONLY_AT_REST){var W=this.viewer&&this.viewer.isAnimating();k=!W}for(var j=0;j<c.length;j++)d=c[j],this._drawTile(d,u,f,p,g,k,u.source),this.viewer&&this.viewer.raiseEvent("tile-drawn",{tiledImage:u,tile:d});y&&this._restoreContext(f),p||(u.getRotation(!0)%360!==0&&this._restoreRotationChanges(f),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(f)),f&&(p&&this._setRotations(u),this.blendSketch({opacity:u.opacity,scale:p,translate:g,compositeOperation:u.compositeOperation,bounds:x}),p&&(u.getRotation(!0)%360!==0&&this._restoreRotationChanges(!1),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(!1))),this._drawDebugInfo(u,c),this._raiseTiledImageDrawnEvent(u,c)}}_drawDebugInfo(u,c){if(u.debugMode)for(var d=c.length-1;d>=0;d--){var f=c[d];try{this._drawDebugInfoOnTile(f,c.length,d,u)}catch(p){t.console.error(p)}}}_clipWithPolygons(u,c){var d=this._getContext(c);d.beginPath();for(const f of u)for(const[p,g]of f.entries())d[p===0?"moveTo":"lineTo"](g.x,g.y);d.clip()}_drawTile(u,c,d,f,p,g,v){t.console.assert(u,"[Drawer._drawTile] tile is required"),t.console.assert(c,"[Drawer._drawTile] drawingHandler is required");var m=this._getContext(d);f=f||1,this._drawTileToCanvas(u,m,c,f,p,g,v)}_drawTileToCanvas(u,c,d,f,p,g,v){var m=u.position.times(t.pixelDensityRatio),x=u.size.times(t.pixelDensityRatio),y;if(!u.context2D&&!u.cacheImageRecord){t.console.warn("[Drawer._drawTileToCanvas] attempting to draw tile %s when it's not cached",u.toString());return}if(y=u.getCanvasContext(),!u.loaded||!y){t.console.warn("Attempting to draw tile %s when it's not yet loaded.",u.toString());return}c.save(),typeof f=="number"&&f!==1&&(m=m.times(f),x=x.times(f)),p instanceof t.Point&&(m=m.plus(p)),c.globalAlpha===1&&u.hasTransparency&&(g&&(m.x=Math.round(m.x),m.y=Math.round(m.y),x.x=Math.round(x.x),x.y=Math.round(x.y)),c.clearRect(m.x,m.y,x.x,x.y)),this._raiseTileDrawingEvent(d,c,u,y);var E,R;u.sourceBounds?(E=Math.min(u.sourceBounds.width,y.canvas.width),R=Math.min(u.sourceBounds.height,y.canvas.height)):(E=y.canvas.width,R=y.canvas.height),c.translate(m.x+x.x/2,0),u.flipped&&c.scale(-1,1),c.drawImage(y.canvas,0,0,E,R,-x.x/2,m.y,x.x,x.y),c.restore()}_getContext(u){var c=this.context;if(u){if(this.sketchCanvas===null){this.sketchCanvas=document.createElement("canvas");var d=this._calculateSketchCanvasSize();if(this.sketchCanvas.width=d.x,this.sketchCanvas.height=d.y,this.sketchContext=this.sketchCanvas.getContext("2d"),this.viewport.getRotation()===0){var f=this;this.viewer.addHandler("rotate",function p(){if(f.viewport.getRotation()!==0){f.viewer.removeHandler("rotate",p);var g=f._calculateSketchCanvasSize();f.sketchCanvas.width=g.x,f.sketchCanvas.height=g.y}})}this._updateImageSmoothingEnabled(this.sketchContext)}c=this.sketchContext}return c}_saveContext(u){this._getContext(u).save()}_restoreContext(u){this._getContext(u).restore()}_setClip(u,c){var d=this._getContext(c);d.beginPath(),d.rect(u.x,u.y,u.width,u.height),d.clip()}_drawRectangle(u,c,d){var f=this._getContext(d);f.save(),f.fillStyle=c,f.fillRect(u.x,u.y,u.width,u.height),f.restore()}blendSketch(u,c,d,f){var p=u;t.isPlainObject(p)||(p={opacity:u,scale:c,translate:d,compositeOperation:f}),u=p.opacity,f=p.compositeOperation;var g=p.bounds;if(this.context.save(),this.context.globalAlpha=u,f&&(this.context.globalCompositeOperation=f),g)g.x<0&&(g.width+=g.x,g.x=0),g.x+g.width>this.canvas.width&&(g.width=this.canvas.width-g.x),g.y<0&&(g.height+=g.y,g.y=0),g.y+g.height>this.canvas.height&&(g.height=this.canvas.height-g.y),this.context.drawImage(this.sketchCanvas,g.x,g.y,g.width,g.height,g.x,g.y,g.width,g.height);else{c=p.scale||1,d=p.translate;var v=d instanceof t.Point?d:new t.Point(0,0),m=0,x=0;if(d){var y=this.sketchCanvas.width-this.canvas.width,E=this.sketchCanvas.height-this.canvas.height;m=Math.round(y/2),x=Math.round(E/2)}this.context.drawImage(this.sketchCanvas,v.x-m*c,v.y-x*c,(this.canvas.width+2*m)*c,(this.canvas.height+2*x)*c,-m,-x,this.canvas.width+2*m,this.canvas.height+2*x)}this.context.restore()}_drawDebugInfoOnTile(u,c,d,f){var p=this.viewer.world.getIndexOfItem(f)%this.debugGridColor.length,g=this.context;g.save(),g.lineWidth=2*t.pixelDensityRatio,g.font="small-caps bold "+13*t.pixelDensityRatio+"px arial",g.strokeStyle=this.debugGridColor[p],g.fillStyle=this.debugGridColor[p],this._setRotations(f),this._viewportFlipped&&this._flip({point:u.position.plus(u.size.divide(2))}),g.strokeRect(u.position.x*t.pixelDensityRatio,u.position.y*t.pixelDensityRatio,u.size.x*t.pixelDensityRatio,u.size.y*t.pixelDensityRatio);var v=(u.position.x+u.size.x/2)*t.pixelDensityRatio,m=(u.position.y+u.size.y/2)*t.pixelDensityRatio;g.translate(v,m);const x=this.viewport.getRotation(!0);g.rotate(Math.PI/180*-x),g.translate(-v,-m),u.x===0&&u.y===0&&(g.fillText("Zoom: "+this.viewport.getZoom(),u.position.x*t.pixelDensityRatio,(u.position.y-30)*t.pixelDensityRatio),g.fillText("Pan: "+this.viewport.getBounds().toString(),u.position.x*t.pixelDensityRatio,(u.position.y-20)*t.pixelDensityRatio)),g.fillText("Level: "+u.level,(u.position.x+10)*t.pixelDensityRatio,(u.position.y+20)*t.pixelDensityRatio),g.fillText("Column: "+u.x,(u.position.x+10)*t.pixelDensityRatio,(u.position.y+30)*t.pixelDensityRatio),g.fillText("Row: "+u.y,(u.position.x+10)*t.pixelDensityRatio,(u.position.y+40)*t.pixelDensityRatio),g.fillText("Order: "+d+" of "+c,(u.position.x+10)*t.pixelDensityRatio,(u.position.y+50)*t.pixelDensityRatio),g.fillText("Size: "+u.size.toString(),(u.position.x+10)*t.pixelDensityRatio,(u.position.y+60)*t.pixelDensityRatio),g.fillText("Position: "+u.position.toString(),(u.position.x+10)*t.pixelDensityRatio,(u.position.y+70)*t.pixelDensityRatio),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(),f.getRotation(!0)%360!==0&&this._restoreRotationChanges(),g.restore()}_updateImageSmoothingEnabled(u){u.msImageSmoothingEnabled=this._imageSmoothingEnabled,u.imageSmoothingEnabled=this._imageSmoothingEnabled}_getCanvasSize(u){var c=this._getContext(u).canvas;return new t.Point(c.width,c.height)}_getCanvasCenter(){return new t.Point(this.canvas.width/2,this.canvas.height/2)}_setRotations(u,c=!1){var d=!1;this.viewport.getRotation(!0)%360!==0&&(this._offsetForRotation({degrees:this.viewport.getRotation(!0),useSketch:c,saveContext:d}),d=!1),u.getRotation(!0)%360!==0&&this._offsetForRotation({degrees:u.getRotation(!0),point:this.viewport.pixelFromPointNoRotate(u._getRotationPoint(!0),!0),useSketch:c,saveContext:d})}_offsetForRotation(u){var c=u.point?u.point.times(t.pixelDensityRatio):this._getCanvasCenter(),d=this._getContext(u.useSketch);d.save(),d.translate(c.x,c.y),d.rotate(Math.PI/180*u.degrees),d.translate(-c.x,-c.y)}_flip(u){u=u||{};var c=u.point?u.point.times(t.pixelDensityRatio):this._getCanvasCenter(),d=this._getContext(u.useSketch);d.translate(c.x,0),d.scale(-1,1),d.translate(-c.x,0)}_restoreRotationChanges(u){var c=this._getContext(u);c.restore()}_calculateCanvasSize(){var u=t.pixelDensityRatio,c=this.viewport.getContainerSize();return{x:Math.round(c.x*u),y:Math.round(c.y*u)}}_calculateSketchCanvasSize(){var u=this._calculateCanvasSize();if(this.viewport.getRotation()===0)return u;var c=Math.ceil(Math.sqrt(u.x*u.x+u.y*u.y));return{x:c,y:c}}}t.CanvasDrawer=r;var s=t.SUBPIXEL_ROUNDING_OCCURRENCES.NEVER;function o(h){return h!==t.SUBPIXEL_ROUNDING_OCCURRENCES.ALWAYS&&h!==t.SUBPIXEL_ROUNDING_OCCURRENCES.ONLY_AT_REST&&h!==t.SUBPIXEL_ROUNDING_OCCURRENCES.NEVER}function a(h){return o(h)?s:h}function l(h){if(typeof h=="number")return a(h);if(!h||!t.Browser)return s;var u=h[t.Browser.vendor];return o(u)&&(u=h["*"]),a(u)}})(e),(function(t){const i=t;i.WebGLDrawer=class extends i.DrawerBase{constructor(s){super(s),this._destroyed=!1,this._TextureMap=new Map,this._TileMap=new Map,this._gl=null,this._firstPass=null,this._secondPass=null,this._glFrameBuffer=null,this._renderToTexture=null,this._glFramebufferToCanvasTransform=null,this._outputCanvas=null,this._outputContext=null,this._clippingCanvas=null,this._clippingContext=null,this._renderingCanvas=null,this._backupCanvasDrawer=null,this._imageSmoothingEnabled=!0,this._boundToTileReady=o=>this._tileReadyHandler(o),this._boundToImageUnloaded=o=>this._imageUnloadedHandler(o),this.viewer.addHandler("tile-ready",this._boundToTileReady),this.viewer.addHandler("image-unloaded",this._boundToImageUnloaded),this.viewer.rejectEventHandler("tile-drawn","The WebGLDrawer does not raise the tile-drawn event"),this.viewer.rejectEventHandler("tile-drawing","The WebGLDrawer does not raise the tile-drawing event"),this._setupCanvases(),this._setupRenderer(),this.context=this._outputContext}destroy(){if(this._destroyed)return;let s=this._gl;var o=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS);for(let l=0;l<o;++l)s.activeTexture(s.TEXTURE0+l),s.bindTexture(s.TEXTURE_2D,null),s.bindTexture(s.TEXTURE_CUBE_MAP,null);s.bindBuffer(s.ARRAY_BUFFER,null),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,null),s.bindRenderbuffer(s.RENDERBUFFER,null),s.bindFramebuffer(s.FRAMEBUFFER,null),this._unloadTextures(),s.deleteBuffer(this._secondPass.bufferOutputPosition),s.deleteFramebuffer(this._glFrameBuffer),this._renderingCanvas.width=this._renderingCanvas.height=1,this._clippingCanvas.width=this._clippingCanvas.height=1,this._outputCanvas.width=this._outputCanvas.height=1,this._renderingCanvas=null,this._clippingCanvas=this._clippingContext=null,this._outputCanvas=this._outputContext=null;let a=s.getExtension("WEBGL_lose_context");a&&a.loseContext(),this.viewer.removeHandler("tile-ready",this._boundToTileReady),this.viewer.removeHandler("image-unloaded",this._boundToImageUnloaded),this.viewer.removeHandler("resize",this._resizeHandler),this._gl=null,this._backupCanvasDrawer&&(this._backupCanvasDrawer.destroy(),this._backupCanvasDrawer=null),this.container.removeChild(this.canvas),this.viewer.drawer===this&&(this.viewer.drawer=null),this._destroyed=!0}canRotate(){return!0}static isSupported(){let s=document.createElement("canvas"),o=t.isFunction(s.getContext)&&s.getContext("webgl"),a=o&&o.getExtension("WEBGL_lose_context");return a&&a.loseContext(),!!o}getType(){return"webgl"}minimumOverlapRequired(s){return s.isTainted()}_createDrawingElement(){let s=t.makeNeutralElement("canvas"),o=this._calculateCanvasSize();return s.width=o.x,s.height=o.y,s}_getBackupCanvasDrawer(){return this._backupCanvasDrawer||(this._backupCanvasDrawer=this.viewer.requestDrawer("canvas",{mainDrawer:!1}),this._backupCanvasDrawer.canvas.style.setProperty("visibility","hidden")),this._backupCanvasDrawer}draw(s){let o=this._gl;const a=this.viewport.getBoundsNoRotateWithMargins(!0);let l={bounds:a,center:new i.Point(a.x+a.width/2,a.y+a.height/2),rotation:this.viewport.getRotation(!0)*Math.PI/180},h=this.viewport.flipped?-1:1,u=t.Mat3.makeTranslation(-l.center.x,-l.center.y),c=t.Mat3.makeScaling(2/l.bounds.width*h,-2/l.bounds.height),d=t.Mat3.makeRotation(-l.rotation),f=c.multiply(d).multiply(u);o.bindFramebuffer(o.FRAMEBUFFER,null),o.clear(o.COLOR_BUFFER_BIT),this._outputContext.clearRect(0,0,this._outputCanvas.width,this._outputCanvas.height);let p=!1;s.forEach((g,v)=>{if(g.isTainted()){p&&(this._outputContext.drawImage(this._renderingCanvas,0,0),o.bindFramebuffer(o.FRAMEBUFFER,null),o.clear(o.COLOR_BUFFER_BIT),p=!1);const m=this._getBackupCanvasDrawer();m.draw([g]),this._outputContext.drawImage(m.canvas,0,0)}else{let m=g.getTilesToDraw();if(g.placeholderFillStyle&&g._hasOpaqueTile===!1&&this._drawPlaceholder(g),m.length===0||g.getOpacity()===0)return;let x=m[0],y=g.compositeOperation||this.viewer.compositeOperation||g._clip||g._croppingPolygons||g.debugMode,E=y||g.opacity<1||x.hasTransparency;y&&(p&&this._outputContext.drawImage(this._renderingCanvas,0,0),o.bindFramebuffer(o.FRAMEBUFFER,null),o.clear(o.COLOR_BUFFER_BIT)),o.useProgram(this._firstPass.shaderProgram),E?(o.bindFramebuffer(o.FRAMEBUFFER,this._glFrameBuffer),o.clear(o.COLOR_BUFFER_BIT)):o.bindFramebuffer(o.FRAMEBUFFER,null);let R=f,P=g.getRotation(!0);if(P%360!==0){let V=t.Mat3.makeRotation(-P*Math.PI/180),N=g.getBoundsNoRotate(!0).getCenter(),D=t.Mat3.makeTranslation(N.x,N.y),A=t.Mat3.makeTranslation(-N.x,-N.y),O=D.multiply(V).multiply(A);R=f.multiply(O)}let S=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);if(S<=0)throw new Error(`WegGL error: bad value for gl parameter MAX_TEXTURE_IMAGE_UNITS (${S}). This could happen 2 if too many contexts have been created and not released, or there is another problem with the graphics card.`);let L=new Float32Array(S*12),k=new Array(S),W=new Array(S),j=new Array(S);for(let V=0;V<m.length;V++){let N=m[V].tile,D=V%S,A=D+1,O=N.getCanvasContext(),B=O?this._TextureMap.get(O.canvas):null;if(B||(this._tileReadyHandler({tile:N,tiledImage:g}),B=O?this._TextureMap.get(O.canvas):null),B&&this._getTileData(N,g,B,R,D,L,k,W,j),A===S||V===m.length-1){for(let G=0;G<=A;G++)o.activeTexture(o.TEXTURE0+G),o.bindTexture(o.TEXTURE_2D,k[G]);o.bindBuffer(o.ARRAY_BUFFER,this._firstPass.bufferTexturePosition),o.bufferData(o.ARRAY_BUFFER,L,o.DYNAMIC_DRAW),W.forEach((G,Y)=>{o.uniformMatrix3fv(this._firstPass.uTransformMatrices[Y],!1,G)}),o.uniform1fv(this._firstPass.uOpacities,new Float32Array(j)),o.bindBuffer(o.ARRAY_BUFFER,this._firstPass.bufferOutputPosition),o.vertexAttribPointer(this._firstPass.aOutputPosition,2,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,this._firstPass.bufferTexturePosition),o.vertexAttribPointer(this._firstPass.aTexturePosition,2,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,this._firstPass.bufferIndex),o.vertexAttribPointer(this._firstPass.aIndex,1,o.FLOAT,!1,0,0),o.drawArrays(o.TRIANGLES,0,6*A)}}E&&(o.useProgram(this._secondPass.shaderProgram),o.bindFramebuffer(o.FRAMEBUFFER,null),o.activeTexture(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,this._renderToTexture),this._gl.uniform1f(this._secondPass.uOpacityMultiplier,g.opacity),o.bindBuffer(o.ARRAY_BUFFER,this._secondPass.bufferTexturePosition),o.vertexAttribPointer(this._secondPass.aTexturePosition,2,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,this._secondPass.bufferOutputPosition),o.vertexAttribPointer(this._secondPass.aOutputPosition,2,o.FLOAT,!1,0,0),o.drawArrays(o.TRIANGLES,0,6)),p=!0,y&&(this._applyContext2dPipeline(g,m,v),p=!1,o.bindFramebuffer(o.FRAMEBUFFER,null),o.clear(o.COLOR_BUFFER_BIT)),v===0&&this._raiseTiledImageDrawnEvent(g,m.map(V=>V.tile))}}),p&&this._outputContext.drawImage(this._renderingCanvas,0,0)}setImageSmoothingEnabled(s){this._imageSmoothingEnabled!==s&&(this._imageSmoothingEnabled=s,this._unloadTextures(),this.viewer.world.draw())}drawDebuggingRect(s){let o=this._outputContext;o.save(),o.lineWidth=2*t.pixelDensityRatio,o.strokeStyle=this.debugGridColor[0],o.fillStyle=this.debugGridColor[0],o.strokeRect(s.x*t.pixelDensityRatio,s.y*t.pixelDensityRatio,s.width*t.pixelDensityRatio,s.height*t.pixelDensityRatio),o.restore()}_getTextureDataFromTile(s){return s.getCanvasContext().canvas}_applyContext2dPipeline(s,o,a){if(this._outputContext.save(),this._outputContext.globalCompositeOperation=a===0?null:s.compositeOperation||this.viewer.compositeOperation,s._croppingPolygons||s._clip?(this._renderToClippingCanvas(s),this._outputContext.drawImage(this._clippingCanvas,0,0)):this._outputContext.drawImage(this._renderingCanvas,0,0),this._outputContext.restore(),s.debugMode){const l=this.viewer.viewport.getFlip();l&&this._flip(),this._drawDebugInfo(o,s,l),l&&this._flip()}}_getTileData(s,o,a,l,h,u,c,d,f){let p=a.texture,g=a.position;u.set(g,h*12);let v=this._calculateOverlapFraction(s,o),m=s.positionedBounds.width*v.x,x=s.positionedBounds.height*v.y,y=s.positionedBounds.x+(s.x===0?0:m),E=s.positionedBounds.y+(s.y===0?0:x),R=s.positionedBounds.x+s.positionedBounds.width-(s.isRightMost?0:m),P=s.positionedBounds.y+s.positionedBounds.height-(s.isBottomMost?0:x),S=R-y,L=P-E,k=new t.Mat3([S,0,0,0,L,0,y,E,1]);if(s.flipped){let j=t.Mat3.makeTranslation(.5,0),V=t.Mat3.makeTranslation(-.5,0),N=j.multiply(t.Mat3.makeScaling(-1,1)).multiply(V);k=k.multiply(N)}let W=l.multiply(k);f[h]=s.opacity,c[h]=p,d[h]=W.values}_textureFilter(){return this._imageSmoothingEnabled?this._gl.LINEAR:this._gl.NEAREST}_setupRenderer(){let s=this._gl;s||t.console.error("_setupCanvases must be called before _setupRenderer"),this._unitQuad=this._makeQuadVertexBuffer(0,1,0,1),this._makeFirstPassShaderProgram(),this._makeSecondPassShaderProgram(),this._renderToTexture=s.createTexture(),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,this._renderToTexture),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,this._renderingCanvas.width,this._renderingCanvas.height,0,s.RGBA,s.UNSIGNED_BYTE,null),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,this._textureFilter()),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),this._glFrameBuffer=s.createFramebuffer(),s.bindFramebuffer(s.FRAMEBUFFER,this._glFrameBuffer),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,this._renderToTexture,0),s.enable(s.BLEND),s.blendFunc(s.ONE,s.ONE_MINUS_SRC_ALPHA)}_makeFirstPassShaderProgram(){let s=this._glNumTextures=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),o=()=>[...Array(s).keys()].map(p=>`uniform mat3 u_matrix_${p};`).join(` 3`),a=()=>[...Array(s).keys()].map(p=>`${p>0?"else ":""}if(int(a_index) == ${p}) { transform_matrix = u_matrix_${p}; }`).join(` 4`);const l=` 5 attribute vec2 a_output_position; 6 attribute vec2 a_texture_position; 7 attribute float a_index; 8 9 ${o()} // create a uniform mat3 for each potential tile to draw 10 11 varying vec2 v_texture_position; 12 varying float v_image_index; 13 14 void main() { 15 16 mat3 transform_matrix; // value will be set by the if/elses in makeConditional() 17 18 ${a()} 19 20 gl_Position = vec4(transform_matrix * vec3(a_output_position, 1), 1); 21 22 v_texture_position = a_texture_position; 23 v_image_index = a_index; 24 } 25 `,h=` 26 precision mediump float; 27 28 // our textures 29 uniform sampler2D u_images[${s}]; 30 // our opacities 31 uniform float u_opacities[${s}]; 32 33 // the varyings passed in from the vertex shader. 34 varying vec2 v_texture_position; 35 varying float v_image_index; 36 37 void main() { 38 // can't index directly with a variable, need to use a loop iterator hack 39 for(int i = 0; i < ${s}; ++i){ 40 if(i == int(v_image_index)){ 41 gl_FragColor = texture2D(u_images[i], v_texture_position) * u_opacities[i]; 42 } 43 } 44 } 45 `;let u=this._gl,c=this.constructor.initShaderProgram(u,l,h);u.useProgram(c),this._firstPass={shaderProgram:c,aOutputPosition:u.getAttribLocation(c,"a_output_position"),aTexturePosition:u.getAttribLocation(c,"a_texture_position"),aIndex:u.getAttribLocation(c,"a_index"),uTransformMatrices:[...Array(this._glNumTextures).keys()].map(p=>u.getUniformLocation(c,`u_matrix_${p}`)),uImages:u.getUniformLocation(c,"u_images"),uOpacities:u.getUniformLocation(c,"u_opacities"),bufferOutputPosition:u.createBuffer(),bufferTexturePosition:u.createBuffer(),bufferIndex:u.createBuffer()},u.uniform1iv(this._firstPass.uImages,[...Array(s).keys()]);let d=new Float32Array(s*12);for(let p=0;p<s;++p)d.set(Float32Array.from(this._unitQuad),p*12);u.bindBuffer(u.ARRAY_BUFFER,this._firstPass.bufferOutputPosition),u.bufferData(u.ARRAY_BUFFER,d,u.STATIC_DRAW),u.enableVertexAttribArray(this._firstPass.aOutputPosition),u.bindBuffer(u.ARRAY_BUFFER,this._firstPass.bufferTexturePosition),u.enableVertexAttribArray(this._firstPass.aTexturePosition),u.bindBuffer(u.ARRAY_BUFFER,this._firstPass.bufferIndex);let f=[...Array(this._glNumTextures).keys()].map(p=>Array(6).fill(p)).flat();u.bufferData(u.ARRAY_BUFFER,new Float32Array(f),u.STATIC_DRAW),u.enableVertexAttribArray(this._firstPass.aIndex)}_makeSecondPassShaderProgram(){const s=` 46 attribute vec2 a_output_position; 47 attribute vec2 a_texture_position; 48 49 uniform mat3 u_matrix; 50 51 varying vec2 v_texture_position; 52 53 void main() { 54 gl_Position = vec4(u_matrix * vec3(a_output_position, 1), 1); 55 56 v_texture_position = a_texture_position; 57 } 58 `,o=` 59 precision mediump float; 60 61 // our texture 62 uniform sampler2D u_image; 63 64 // the texCoords passed in from the vertex shader. 65 varying vec2 v_texture_position; 66 67 // the opacity multiplier for the image 68 uniform float u_opacity_multiplier; 69 70 void main() { 71 gl_FragColor = texture2D(u_image, v_texture_position); 72 gl_FragColor *= u_opacity_multiplier; 73 } 74 `;let a=this._gl,l=this.constructor.initShaderProgram(a,s,o);a.useProgram(l),this._secondPass={shaderProgram:l,aOutputPosition:a.getAttribLocation(l,"a_output_position"),aTexturePosition:a.getAttribLocation(l,"a_texture_position"),uMatrix:a.getUniformLocation(l,"u_matrix"),uImage:a.getUniformLocation(l,"u_image"),uOpacityMultiplier:a.getUniformLocation(l,"u_opacity_multiplier"),bufferOutputPosition:a.createBuffer(),bufferTexturePosition:a.createBuffer()},a.bindBuffer(a.ARRAY_BUFFER,this._secondPass.bufferOutputPosition),a.bufferData(a.ARRAY_BUFFER,this._unitQuad,a.STATIC_DRAW),a.enableVertexAttribArray(this._secondPass.aOutputPosition),a.bindBuffer(a.ARRAY_BUFFER,this._secondPass.bufferTexturePosition),a.bufferData(a.ARRAY_BUFFER,this._unitQuad,a.DYNAMIC_DRAW),a.enableVertexAttribArray(this._secondPass.aTexturePosition);let h=t.Mat3.makeScaling(2,2).multiply(t.Mat3.makeTranslation(-.5,-.5));a.uniformMatrix3fv(this._secondPass.uMatrix,!1,h.values)}_resizeRenderer(){let s=this._gl,o=this._renderingCanvas.width,a=this._renderingCanvas.height;s.viewport(0,0,o,a),s.deleteTexture(this._renderToTexture),this._renderToTexture=s.createTexture(),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,this._renderToTexture),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,o,a,0,s.RGBA,s.UNSIGNED_BYTE,null),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,this._textureFilter()),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.bindFramebuffer(s.FRAMEBUFFER,this._glFrameBuffer),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,this._renderToTexture,0)}_setupCanvases(){let s=this;this._outputCanvas=this.canvas,this._outputContext=this._outputCanvas.getContext("2d"),this._renderingCanvas=document.createElement("canvas"),this._clippingCanvas=document.createElement("canvas"),this._clippingContext=this._clippingCanvas.getContext("2d"),this._renderingCanvas.width=this._clippingCanvas.width=this._outputCanvas.width,this._renderingCanvas.height=this._clippingCanvas.height=this._outputCanvas.height,this._gl=this._renderingCanvas.getContext("webgl"),this._resizeHandler=function(){s._outputCanvas!==s.viewer.drawer.canvas&&(s._outputCanvas.style.width=s.viewer.drawer.canvas.clientWidth+"px",s._outputCanvas.style.height=s.viewer.drawer.canvas.clientHeight+"px");let o=s._calculateCanvasSize();(s._outputCanvas.width!==o.x||s._outputCanvas.height!==o.y)&&(s._outputCanvas.width=o.x,s._outputCanvas.height=o.y),s._renderingCanvas.style.width=s._outputCanvas.clientWidth+"px",s._renderingCanvas.style.height=s._outputCanvas.clientHeight+"px",s._renderingCanvas.width=s._clippingCanvas.width=s._outputCanvas.width,s._renderingCanvas.height=s._clippingCanvas.height=s._outputCanvas.height,s._resizeRenderer()},this.viewer.addHandler("resize",this._resizeHandler)}_makeQuadVertexBuffer(s,o,a,l){return new Float32Array([s,l,o,l,s,a,s,a,o,l,o,a])}_tileReadyHandler(s){let o=s.tile,a=s.tiledImage;if(a.isTainted())return;let l=o.getCanvasContext(),h=l&&l.canvas;if(!h||t.isCanvasTainted(h)){a.isTainted()||(a.setTainted(!0),t.console.warn("WebGL cannot be used to draw this TiledImage because it has tainted data. Does crossOriginPolicy need to be set?"),this._raiseDrawerErrorEvent(a,"Tainted data cannot be used by the WebGLDrawer. Falling back to CanvasDrawer for this TiledImage."));return}if(!this._TextureMap.get(h)){let c=this._gl,d=c.createTexture(),f,p=a.source.tileOverlap,g,v;if(o.sourceBounds?(g=Math.min(o.sourceBounds.width,h.width)/h.width,v=Math.min(o.sourceBounds.height,h.height)/h.height):(g=1,v=1),p>0){let x=this._calculateOverlapFraction(o,a),y=(o.x===0?0:x.x)*g,E=(o.y===0?0:x.y)*v,R=(o.isRightMost?1:1-x.x)*g,P=(o.isBottomMost?1:1-x.y)*v;f=this._makeQuadVertexBuffer(y,R,E,P)}else g===1&&v===1?f=this._unitQuad:f=this._makeQuadVertexBuffer(0,g,0,v);let m={texture:d,position:f};this._TextureMap.set(h,m),c.activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,d),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,this._textureFilter()),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,this._textureFilter()),this._uploadImageData(l)}}_calculateOverlapFraction(s,o){let a=o.source.tileOverlap,l=s.sourceBounds.width,h=s.sourceBounds.height,u=(s.x===0?0:a)+(s.isRightMost?0:a),c=(s.y===0?0:a)+(s.isBottomMost?0:a),d=a/(l+u),f=a/(h+c);return{x:d,y:f}}_unloadTextures(){Array.from(this._TextureMap.keys()).forEach(o=>{this._cleanupImageData(o)})}_uploadImageData(s){let o=this._gl,a=s.canvas;try{if(!a)throw s;o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,a)}catch(l){t.console.error("Error uploading image data to WebGL",l)}}_imageUnloadedHandler(s){let o=s.context2D.canvas;this._cleanupImageData(o)}_cleanupImageData(s){let o=this._TextureMap.get(s);this._TextureMap.delete(s),o&&this._gl.deleteTexture(o.texture)}_setClip(){}_renderToClippingCanvas(s){if(this._clippingContext.clearRect(0,0,this._clippingCanvas.width,this._clippingCanvas.height),this._clippingContext.save(),this.viewer.viewport.getFlip()){const o=new t.Point(this.canvas.width/2,this.canvas.height/2);this._clippingContext.translate(o.x,0),this._clippingContext.scale(-1,1),this._clippingContext.translate(-o.x,0)}if(s._clip){let a=[{x:s._clip.x,y:s._clip.y},{x:s._clip.x+s._clip.width,y:s._clip.y},{x:s._clip.x+s._clip.width,y:s._clip.y+s._clip.height},{x:s._clip.x,y:s._clip.y+s._clip.height}].map(l=>{let h=s.imageToViewportCoordinates(l.x,l.y,!0).rotate(this.viewer.viewport.getRotation(!0),this.viewer.viewport.getCenter(!0));return this.viewportCoordToDrawerCoord(h)});this._clippingContext.beginPath(),a.forEach((l,h)=>{this._clippingContext[h===0?"moveTo":"lineTo"](l.x,l.y)}),this._clippingContext.clip(),this._setClip()}if(s._croppingPolygons){let o=s._croppingPolygons.map(a=>a.map(l=>{let h=s.imageToViewportCoordinates(l.x,l.y,!0).rotate(this.viewer.viewport.getRotation(!0),this.viewer.viewport.getCenter(!0));return this.viewportCoordToDrawerCoord(h)}));this._clippingContext.beginPath(),o.forEach(a=>{a.forEach((l,h)=>{this._clippingContext[h===0?"moveTo":"lineTo"](l.x,l.y)})}),this._clippingContext.clip()}if(this.viewer.viewport.getFlip()){const o=new t.Point(this.canvas.width/2,this.canvas.height/2);this._clippingContext.translate(o.x,0),this._clippingContext.scale(-1,1),this._clippingContext.translate(-o.x,0)}this._clippingContext.drawImage(this._renderingCanvas,0,0),this._clippingContext.restore()}_setRotations(s){var o=!1;this.viewport.getRotation(!0)%360!==0&&(this._offsetForRotation({degrees:this.viewport.getRotation(!0),saveContext:o}),o=!1),s.getRotation(!0)%360!==0&&this._offsetForRotation({degrees:s.getRotation(!0),point:this.viewport.pixelFromPointNoRotate(s._getRotationPoint(!0),!0),saveContext:o})}_offsetForRotation(s){var o=s.point?s.point.times(t.pixelDensityRatio):this._getCanvasCenter(),a=this._outputContext;a.save(),a.translate(o.x,o.y),a.rotate(Math.PI/180*s.degrees),a.translate(-o.x,-o.y)}_flip(s){s=s||{};var o=s.point?s.point.times(t.pixelDensityRatio):this._getCanvasCenter(),a=this._outputContext;a.translate(o.x,0),a.scale(-1,1),a.translate(-o.x,0)}_drawDebugInfo(s,o,a){for(var l=s.length-1;l>=0;l--){var h=s[l].tile;try{this._drawDebugInfoOnTile(h,s.length,l,o,a)}catch(u){t.console.error(u)}}}_drawDebugInfoOnTile(s,o,a,l,h){var u=this.viewer.world.getIndexOfItem(l)%this.debugGridColor.length,c=this.context;c.save(),c.lineWidth=2*t.pixelDensityRatio,c.font="small-caps bold "+13*t.pixelDensityRatio+"px arial",c.strokeStyle=this.debugGridColor[u],c.fillStyle=this.debugGridColor[u],this._setRotations(l),h&&this._flip({point:s.position.plus(s.size.divide(2))}),c.strokeRect(s.position.x*t.pixelDensityRatio,s.position.y*t.pixelDensityRatio,s.size.x*t.pixelDensityRatio,s.size.y*t.pixelDensityRatio);var d=(s.position.x+s.size.x/2)*t.pixelDensityRatio,f=(s.position.y+s.size.y/2)*t.pixelDensityRatio;c.translate(d,f);const p=this.viewport.getRotation(!0);c.rotate(Math.PI/180*-p),c.translate(-d,-f),s.x===0&&s.y===0&&(c.fillText("Zoom: "+this.viewport.getZoom(),s.position.x*t.pixelDensityRatio,(s.position.y-30)*t.pixelDensityRatio),c.fillText("Pan: "+this.viewport.getBounds().toString(),s.position.x*t.pixelDensityRatio,(s.position.y-20)*t.pixelDensityRatio)),c.fillText("Level: "+s.level,(s.position.x+10)*t.pixelDensityRatio,(s.position.y+20)*t.pixelDensityRatio),c.fillText("Column: "+s.x,(s.position.x+10)*t.pixelDensityRatio,(s.position.y+30)*t.pixelDensityRatio),c.fillText("Row: "+s.y,(s.position.x+10)*t.pixelDensityRatio,(s.position.y+40)*t.pixelDensityRatio),c.fillText("Order: "+a+" of "+o,(s.position.x+10)*t.pixelDensityRatio,(s.position.y+50)*t.pixelDensityRatio),c.fillText("Size: "+s.size.toString(),(s.position.x+10)*t.pixelDensityRatio,(s.position.y+60)*t.pixelDensityRatio),c.fillText("Position: "+s.position.toString(),(s.position.x+10)*t.pixelDensityRatio,(s.position.y+70)*t.pixelDensityRatio),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(),l.getRotation(!0)%360!==0&&this._restoreRotationChanges(),c.restore()}_drawPlaceholder(s){const o=s.getBounds(!0),a=this.viewportToDrawerRectangle(s.getBounds(!0)),l=this._outputContext;let h;typeof s.placeholderFillStyle=="function"?h=s.placeholderFillStyle(s,l):h=s.placeholderFillStyle,this._offsetForRotation({degrees:this.viewer.viewport.getRotation(!0)}),l.fillStyle=h,l.translate(a.x,a.y),l.rotate(Math.PI/180*o.degrees),l.translate(-a.x,-a.y),l.fillRect(a.x,a.y,a.width,a.height),this._restoreRotationChanges()}_getCanvasCenter(){return new t.Point(this.canvas.width/2,this.canvas.height/2)}_restoreRotationChanges(){var s=this._outputContext;s.restore()}static initShaderProgram(s,o,a){function l(d,f,p){const g=d.createShader(f);return d.shaderSource(g,p),d.compileShader(g),d.getShaderParameter(g,d.COMPILE_STATUS)?g:(t.console.error(`An error occurred compiling the shaders: ${d.getShaderInfoLog(g)}`),d.deleteShader(g),null)}const h=l(s,s.VERTEX_SHADER,o),u=l(s,s.FRAGMENT_SHADER,a),c=s.createProgram();return s.attachShader(c,h),s.attachShader(c,u),s.linkProgram(c),s.getProgramParameter(c,s.LINK_STATUS)?c:(t.console.error(`Unable to initialize the shader program: ${s.getProgramInfoLog(c)}`),null)}}})(e),(function(t){t.Viewport=function(i){var r=arguments;r.length&&r[0]instanceof t.Point&&(i={containerSize:r[0],contentSize:r[1],config:r[2]}),i.config&&(t.extend(!0,i,i.config),delete i.config),this._margins=t.extend({left:0,top:0,right:0,bottom:0},i.margins||{}),delete i.margins,i.initialDegrees=i.degrees,delete i.degrees,t.extend(!0,this,{containerSize:null,contentSize:null,zoomPoint:null,rotationPivot:null,viewer:null,springStiffness:t.DEFAULT_SETTINGS.springStiffness,animationTime:t.DEFAULT_SETTINGS.animationTime,minZoomImageRatio:t.DEFAULT_SETTINGS.minZoomImageRatio,maxZoomPixelRatio:t.DEFAULT_SETTINGS.maxZoomPixelRatio,visibilityRatio:t.DEFAULT_SETTINGS.visibilityRatio,wrapHorizontal:t.DEFAULT_SETTINGS.wrapHorizontal,wrapVertical:t.DEFAULT_SETTINGS.wrapVertical,defaultZoomLevel:t.DEFAULT_SETTINGS.defaultZoomLevel,minZoomLevel:t.DEFAULT_SETTINGS.minZoomLevel,maxZoomLevel:t.DEFAULT_SETTINGS.maxZoomLevel,initialDegrees:t.DEFAULT_SETTINGS.degrees,flipped:t.DEFAULT_SETTINGS.flipped,homeFillsViewer:t.DEFAULT_SETTINGS.homeFillsViewer,silenceMultiImageWarnings:t.DEFAULT_SETTINGS.silenceMultiImageWarnings},i),this._updateContainerInnerSize(),this.centerSpringX=new t.Spring({initial:0,springStiffness:this.springStiffness,animationTime:this.animationTime}),this.centerSpringY=new t.Spring({initial:0,springStiffness:this.springStiffness,animationTime:this.animationTime}),this.zoomSpring=new t.Spring({exponential:!0,initial:1,springStiffness:this.springStiffness,animationTime:this.animationTime}),this.degreesSpring=new t.Spring({initial:i.initialDegrees,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._oldCenterX=this.centerSpringX.current.value,this._oldCenterY=this.centerSpringY.current.value,this._oldZoom=this.zoomSpring.current.value,this._oldDegrees=this.degreesSpring.current.value,this._setContentBounds(new t.Rect(0,0,1,1),1),this.goHome(!0),this.update()},t.Viewport.prototype={get degrees(){return t.console.warn("Accessing [Viewport.degrees] is deprecated. Use viewport.getRotation instead."),this.getRotation()},set degrees(i){t.console.warn("Setting [Viewport.degrees] is deprecated. Use viewport.rotateTo, viewport.rotateBy, or viewport.setRotation instead."),this.rotateTo(i)},resetContentSize:function(i){return t.console.assert(i,"[Viewport.resetContentSize] contentSize is required"),t.console.assert(i instanceof t.Point,"[Viewport.resetContentSize] contentSize must be an OpenSeadragon.Point"),t.console.assert(i.x>0,"[Viewport.resetContentSize] contentSize.x must be greater than 0"),t.console.assert(i.y>0,"[Viewport.resetContentSize] contentSize.y must be greater than 0"),this._setContentBounds(new t.Rect(0,0,1,i.y/i.x),i.x),this},setHomeBounds:function(i,r){t.console.error("[Viewport.setHomeBounds] this function is deprecated; The content bounds should not be set manually."),this._setContentBounds(i,r)},_setContentBounds:function(i,r){t.console.assert(i,"[Viewport._setContentBounds] bounds is required"),t.console.assert(i instanceof t.Rect,"[Viewport._setContentBounds] bounds must be an OpenSeadragon.Rect"),t.console.assert(i.width>0,"[Viewport._setContentBounds] bounds.width must be greater than 0"),t.console.assert(i.height>0,"[Viewport._setContentBounds] bounds.height must be greater than 0"),this._contentBoundsNoRotate=i.clone(),this._contentSizeNoRotate=this._contentBoundsNoRotate.getSize().times(r),this._contentBounds=i.rotate(this.getRotation()).getBoundingBox(),this._contentSize=this._contentBounds.getSize().times(r),this._contentAspectRatio=this._contentSize.x/this._contentSize.y,this.viewer&&this.viewer.raiseEvent("reset-size",{contentSize:this._contentSizeNoRotate.clone(),contentFactor:r,homeBounds:this._contentBoundsNoRotate.clone(),contentBounds:this._contentBounds.clone()})},getHomeZoom:function(){if(this.defaultZoomLevel)return this.defaultZoomLevel;var i=this._contentAspectRatio/this.getAspectRatio(),r;return this.homeFillsViewer?r=i>=1?i:1:r=i>=1?1:i,r/this._contentBounds.width},getHomeBounds:function(){return this.getHomeBoundsNoRotate().rotate(-this.getRotation())},getHomeBoundsNoRotate:function(){var i=this._contentBounds.getCenter(),r=1/this.getHomeZoom(),s=r/this.getAspectRatio();return new t.Rect(i.x-r/2,i.y-s/2,r,s)},goHome:function(i){return this.viewer&&this.viewer.raiseEvent("home",{immediately:i}),this.fitBounds(this.getHomeBounds(),i)},getMinZoom:function(){var i=this.getHomeZoom(),r=this.minZoomLevel?this.minZoomLevel:this.minZoomImageRatio*i;return r},getMaxZoom:function(){var i=this.maxZoomLevel;return i||(i=this._contentSize.x*this.maxZoomPixelRatio/this._containerInnerSize.x,i/=this._contentBounds.width),Math.max(i,this.getHomeZoom())},getAspectRatio:function(){return this._containerInnerSize.x/this._containerInnerSize.y},getContainerSize:function(){return new t.Point(this.containerSize.x,this.containerSize.y)},getMargins:function(){return t.extend({},this._margins)},setMargins:function(i){t.console.assert(t.type(i)==="object","[Viewport.setMargins] margins must be an object"),this._margins=t.extend({left:0,top:0,right:0,bottom:0},i),this._updateContainerInnerSize(),this.viewer&&this.viewer.forceRedraw()},getBounds:function(i){return this.getBoundsNoRotate(i).rotate(-this.getRotation(i))},getBoundsNoRotate:function(i){var r=this.getCenter(i),s=1/this.getZoom(i),o=s/this.getAspectRatio();return new t.Rect(r.x-s/2,r.y-o/2,s,o)},getBoundsWithMargins:function(i){return this.getBoundsNoRotateWithMargins(i).rotate(-this.getRotation(i),this.getCenter(i))},getBoundsNoRotateWithMargins:function(i){var r=this.getBoundsNoRotate(i),s=this._containerInnerSize.x*this.getZoom(i);return r.x-=this._margins.left/s,r.y-=this._margins.top/s,r.width+=(this._margins.left+this._margins.right)/s,r.height+=(this._margins.top+this._margins.bottom)/s,r},getCenter:function(i){var r=new t.Point(this.centerSpringX.current.value,this.centerSpringY.current.value),s=new t.Point(this.centerSpringX.target.value,this.centerSpringY.target.value),o,a,l,h,u,c,d,f;return i?r:this.zoomPoint?(o=this.pixelFromPoint(this.zoomPoint,!0),a=this.getZoom(),l=1/a,h=l/this.getAspectRatio(),u=new t.Rect(r.x-l/2,r.y-h/2,l,h),c=this._pixelFromPoint(this.zoomPoint,u),d=c.minus(o).rotate(-this.getRotation(!0)),f=d.divide(this._containerInnerSize.x*a),s.plus(f)):s},getZoom:function(i){return i?this.zoomSpring.current.value:this.zoomSpring.target.value},_applyZoomConstraints:function(i){return Math.max(Math.min(i,this.getMaxZoom()),this.getMinZoom())},_applyBoundaryConstraints:function(i){var r=this.viewportToViewerElementRectangle(i).getBoundingBox(),s=this.viewportToViewerElementRectangle(this._contentBoundsNoRotate).getBoundingBox(),o=!1,a=!1;if(!this.wrapHorizontal){var l=r.x+r.width,h=s.x+s.width,u,c,d;r.width>s.width?u=this.visibilityRatio*s.width:u=this.visibilityRatio*r.width,c=s.x-l+u,d=h-r.x-u,u>s.width?(r.x+=(c+d)/2,o=!0):d<0?(r.x+=d,o=!0):c>0&&(r.x+=c,o=!0)}if(!this.wrapVertical){var f=r.y+r.height,p=s.y+s.height,g,v,m;r.height>s.height?g=this.visibilityRatio*s.height:g=this.visibilityRatio*r.height,v=s.y-f+g,m=p-r.y-g,g>s.height?(r.y+=(v+m)/2,a=!0):m<0?(r.y+=m,a=!0):v>0&&(r.y+=v,a=!0)}var x=o||a,y=x?this.viewerElementToViewportRectangle(r):i.clone();return y.xConstrained=o,y.yConstrained=a,y.constraintApplied=x,y},_raiseConstraintsEvent:function(i){this.viewer&&this.viewer.raiseEvent("constrain",{immediately:i})},applyConstraints:function(i){var r=this.getZoom(),s=this._applyZoomConstraints(r);r!==s&&this.zoomTo(s,this.zoomPoint,i);var o=this.getConstrainedBounds(!1);return o.constraintApplied&&(this.fitBounds(o,i),this._raiseConstraintsEvent(i)),this},ensureVisible:function(i){return this.applyConstraints(i)},_fitBounds:function(i,r){r=r||{};var s=r.immediately||!1,o=r.constraints||!1,a=this.getAspectRatio(),l=i.getCenter(),h=new t.Rect(i.x,i.y,i.width,i.height,i.degrees+this.getRotation()).getBoundingBox();h.getAspectRatio()>=a?h.height=h.width/a:h.width=h.height*a,h.x=l.x-h.width/2,h.y=l.y-h.height/2;var u=1/h.width;if(s)return this.panTo(l,!0),this.zoomTo(u,null,!0),o&&this.applyConstraints(!0),this;var c=this.getCenter(!0),d=this.getZoom(!0);this.panTo(c,!0),this.zoomTo(d,null,!0);var f=this.getBounds(),p=this.getZoom();if(p===0||Math.abs(u/p-1)<1e-8)return this.zoomTo(u,null,!0),this.panTo(l,s),o&&this.applyConstraints(!1),this;if(o){this.panTo(l,!1),u=this._applyZoomConstraints(u),this.zoomTo(u,null,!1);var g=this.getConstrainedBounds();this.panTo(c,!0),this.zoomTo(d,null,!0),this.fitBounds(g)}else{var v=h.rotate(-this.getRotation()),m=v.getTopLeft().times(u).minus(f.getTopLeft().times(p)).divide(u-p);this.zoomTo(u,m,s)}return this},fitBounds:function(i,r){return this._fitBounds(i,{immediately:r,constraints:!1})},fitBoundsWithConstraints:function(i,r){return this._fitBounds(i,{immediately:r,constraints:!0})},fitVertically:function(i){var r=new t.Rect(this._contentBounds.x+this._contentBounds.width/2,this._contentBounds.y,0,this._contentBounds.height);return this.fitBounds(r,i)},fitHorizontally:function(i){var r=new t.Rect(this._contentBounds.x,this._contentBounds.y+this._contentBounds.height/2,this._contentBounds.width,0);return this.fitBounds(r,i)},getConstrainedBounds:function(i){var r,s;return r=this.getBounds(i),s=this._applyBoundaryConstraints(r),s},panBy:function(i,r){var s=new t.Point(this.centerSpringX.target.value,this.centerSpringY.target.value);return this.panTo(s.plus(i),r)},panTo:function(i,r){return r?(this.centerSpringX.resetTo(i.x),this.centerSpringY.resetTo(i.y)):(this.centerSpringX.springTo(i.x),this.centerSpringY.springTo(i.y)),this.viewer&&this.viewer.raiseEvent("pan",{center:i,immediately:r}),this},zoomBy:function(i,r,s){return this.zoomTo(this.zoomSpring.target.value*i,r,s)},zoomTo:function(i,r,s){var o=this;return this.zoomPoint=r instanceof t.Point&&!isNaN(r.x)&&!isNaN(r.y)?r:null,s?this._adjustCenterSpringsForZoomPoint(function(){o.zoomSpring.resetTo(i)}):this.zoomSpring.springTo(i),this.viewer&&this.viewer.raiseEvent("zoom",{zoom:i,refPoint:r,immediately:s}),this},setRotation:function(i,r){return this.rotateTo(i,null,r)},getRotation:function(i){return i?this.degreesSpring.current.value:this.degreesSpring.target.value},setRotationWithPivot:function(i,r,s){return this.rotateTo(i,r,s)},rotateTo:function(i,r,s){if(!this.viewer||!this.viewer.drawer.canRotate())return this;if(this.degreesSpring.target.value===i&&this.degreesSpring.isAtTargetValue())return this;if(this.rotationPivot=r instanceof t.Point&&!isNaN(r.x)&&!isNaN(r.y)?r:null,s)if(this.rotationPivot){var o=i-this._oldDegrees;if(!o)return this.rotationPivot=null,this;this._rotateAboutPivot(i)}else this.degreesSpring.resetTo(i);else{var a=t.positiveModulo(this.degreesSpring.current.value,360),l=t.positiveModulo(i,360),h=l-a;h>180?l-=360:h<-180&&(l+=360);var u=a-l;this.degreesSpring.resetTo(i+u),this.degreesSpring.springTo(i)}return this._setContentBounds(this.viewer.world.getHomeBounds(),this.viewer.world.getContentFactor()),this.viewer.forceRedraw(),this.viewer.raiseEvent("rotate",{degrees:i,immediately:!!s,pivot:this.rotationPivot||this.getCenter()}),this},rotateBy:function(i,r,s){return this.rotateTo(this.degreesSpring.target.value+i,r,s)},resize:function(i,r){var s=this.getBoundsNoRotate(),o=s,a;this.containerSize.x=i.x,this.containerSize.y=i.y,this._updateContainerInnerSize(),r&&(a=i.x/this.containerSize.x,o.width=s.width*a,o.height=o.width/this.getAspectRatio()),this.viewer&&this.viewer.raiseEvent("resize",{newContainerSize:i,maintain:r});var l=this.fitBounds(o,!0);return this.viewer&&this.viewer.raiseEvent("after-resize",{newContainerSize:i,maintain:r}),l},_updateContainerInnerSize:function(){this._containerInnerSize=new t.Point(Math.max(1,this.containerSize.x-(this._margins.left+this._margins.right)),Math.max(1,this.containerSize.y-(this._margins.top+this._margins.bottom)))},update:function(){var i=this;this._adjustCenterSpringsForZoomPoint(function(){i.zoomSpring.update()}),this.degreesSpring.isAtTargetValue()&&(this.rotationPivot=null),this.centerSpringX.update(),this.centerSpringY.update(),this.rotationPivot?this._rotateAboutPivot(!0):this.degreesSpring.update();var r=this.centerSpringX.current.value!==this._oldCenterX||this.centerSpringY.current.value!==this._oldCenterY||this.zoomSpring.current.value!==this._oldZoom||this.degreesSpring.current.value!==this._oldDegrees;this._oldCenterX=this.centerSpringX.current.value,this._oldCenterY=this.centerSpringY.current.value,this._oldZoom=this.zoomSpring.current.value,this._oldDegrees=this.degreesSpring.current.value;var s=r||!this.zoomSpring.isAtTargetValue()||!this.centerSpringX.isAtTargetValue()||!this.centerSpringY.isAtTargetValue()||!this.degreesSpring.isAtTargetValue();return s},_rotateAboutPivot:function(i){var r=i===!0,s=this.rotationPivot.minus(this.getCenter());this.centerSpringX.shiftBy(s.x),this.centerSpringY.shiftBy(s.y),r?this.degreesSpring.update():this.degreesSpring.resetTo(i);var o=this.degreesSpring.current.value-this._oldDegrees,a=s.rotate(o*-1).times(-1);this.centerSpringX.shiftBy(a.x),this.centerSpringY.shiftBy(a.y)},_adjustCenterSpringsForZoomPoint:function(i){if(this.zoomPoint){var r=this.pixelFromPoint(this.zoomPoint,!0);i();var s=this.pixelFromPoint(this.zoomPoint,!0),o=s.minus(r),a=this.deltaPointsFromPixels(o,!0);this.centerSpringX.shiftBy(a.x),this.centerSpringY.shiftBy(a.y),this.zoomSpring.isAtTargetValue()&&(this.zoomPoint=null)}else i()},deltaPixelsFromPointsNoRotate:function(i,r){return i.times(this._containerInnerSize.x*this.getZoom(r))},deltaPixelsFromPoints:function(i,r){return this.deltaPixelsFromPointsNoRotate(i.rotate(this.getRotation(r)),r)},deltaPointsFromPixelsNoRotate:function(i,r){return i.divide(this._containerInnerSize.x*this.getZoom(r))},deltaPointsFromPixels:function(i,r){return this.deltaPointsFromPixelsNoRotate(i,r).rotate(-this.getRotation(r))},pixelFromPointNoRotate:function(i,r){return this._pixelFromPointNoRotate(i,this.getBoundsNoRotate(r))},pixelFromPoint:function(i,r){return this._pixelFromPoint(i,this.getBoundsNoRotate(r))},_pixelFromPointNoRotate:function(i,r){return i.minus(r.getTopLeft()).times(this._containerInnerSize.x/r.width).plus(new t.Point(this._margins.left,this._margins.top))},_pixelFromPoint:function(i,r){return this._pixelFromPointNoRotate(i.rotate(this.getRotation(!0),this.getCenter(!0)),r)},pointFromPixelNoRotate:function(i,r){var s=this.getBoundsNoRotate(r);return i.minus(new t.Point(this._margins.left,this._margins.top)).divide(this._containerInnerSize.x/s.width).plus(s.getTopLeft())},pointFromPixel:function(i,r){return this.pointFromPixelNoRotate(i,r).rotate(-this.getRotation(r),this.getCenter(r))},_viewportToImageDelta:function(i,r){var s=this._contentBoundsNoRotate.width;return new t.Point(i*this._contentSizeNoRotate.x/s,r*this._contentSizeNoRotate.x/s)},viewportToImageCoordinates:function(i,r){if(i instanceof t.Point)return this.viewportToImageCoordinates(i.x,i.y);if(this.viewer){var s=this.viewer.world.getItemCount();if(s>1)this.silenceMultiImageWarnings||t.console.error("[Viewport.viewportToImageCoordinates] is not accurate with multi-image; use TiledImage.viewportToImageCoordinates instead.");else if(s===1){var o=this.viewer.world.getItemAt(0);return o.viewportToImageCoordinates(i,r,!0)}}return this._viewportToImageDelta(i-this._contentBoundsNoRotate.x,r-this._contentBoundsNoRotate.y)},_imageToViewportDelta:function(i,r){var s=this._contentBoundsNoRotate.width;return new t.Point(i/this._contentSizeNoRotate.x*s,r/this._contentSizeNoRotate.x*s)},imageToViewportCoordinates:function(i,r){if(i instanceof t.Point)return this.imageToViewportCoordinates(i.x,i.y);if(this.viewer){var s=this.viewer.world.getItemCount();if(s>1)this.silenceMultiImageWarnings||t.console.error("[Viewport.imageToViewportCoordinates] is not accurate with multi-image; use TiledImage.imageToViewportCoordinates instead.");else if(s===1){var o=this.viewer.world.getItemAt(0);return o.imageToViewportCoordinates(i,r,!0)}}var a=this._imageToViewportDelta(i,r);return a.x+=this._contentBoundsNoRotate.x,a.y+=this._contentBoundsNoRotate.y,a},imageToViewportRectangle:function(i,r,s,o){var a=i;if(a instanceof t.Rect||(a=new t.Rect(i,r,s,o)),this.viewer){var l=this.viewer.world.getItemCount();if(l>1)this.silenceMultiImageWarnings||t.console.error("[Viewport.imageToViewportRectangle] is not accurate with multi-image; use TiledImage.imageToViewportRectangle instead.");else if(l===1){var h=this.viewer.world.getItemAt(0);return h.imageToViewportRectangle(i,r,s,o,!0)}}var u=this.imageToViewportCoordinates(a.x,a.y),c=this._imageToViewportDelta(a.width,a.height);return new t.Rect(u.x,u.y,c.x,c.y,a.degrees)},viewportToImageRectangle:function(i,r,s,o){var a=i;if(a instanceof t.Rect||(a=new t.Rect(i,r,s,o)),this.viewer){var l=this.viewer.world.getItemCount();if(l>1)this.silenceMultiImageWarnings||t.console.error("[Viewport.viewportToImageRectangle] is not accurate with multi-image; use TiledImage.viewportToImageRectangle instead.");else if(l===1){var h=this.viewer.world.getItemAt(0);return h.viewportToImageRectangle(i,r,s,o,!0)}}var u=this.viewportToImageCoordinates(a.x,a.y),c=this._viewportToImageDelta(a.width,a.height);return new t.Rect(u.x,u.y,c.x,c.y,a.degrees)},viewerElementToImageCoordinates:function(i){var r=this.pointFromPixel(i,!0);return this.viewportToImageCoordinates(r)},imageToViewerElementCoordinates:function(i){var r=this.imageToViewportCoordinates(i);return this.pixelFromPoint(r,!0)},windowToImageCoordinates:function(i){t.console.assert(this.viewer,"[Viewport.windowToImageCoordinates] the viewport must have a viewer.");var r=i.minus(t.getElementPosition(this.viewer.element));return this.viewerElementToImageCoordinates(r)},imageToWindowCoordinates:function(i){t.console.assert(this.viewer,"[Viewport.imageToWindowCoordinates] the viewport must have a viewer.");var r=this.imageToViewerElementCoordinates(i);return r.plus(t.getElementPosition(this.viewer.element))},viewerElementToViewportCoordinates:function(i){return this.pointFromPixel(i,!0)},viewportToViewerElementCoordinates:function(i){return this.pixelFromPoint(i,!0)},viewerElementToViewportRectangle:function(i){return t.Rect.fromSummits(this.pointFromPixel(i.getTopLeft(),!0),this.pointFromPixel(i.getTopRight(),!0),this.pointFromPixel(i.getBottomLeft(),!0))},viewportToViewerElementRectangle:function(i){return t.Rect.fromSummits(this.pixelFromPoint(i.getTopLeft(),!0),this.pixelFromPoint(i.getTopRight(),!0),this.pixelFromPoint(i.getBottomLeft(),!0))},windowToViewportCoordinates:function(i){t.console.assert(this.viewer,"[Viewport.windowToViewportCoordinates] the viewport must have a viewer.");var r=i.minus(t.getElementPosition(this.viewer.element));return this.viewerElementToViewportCoordinates(r)},viewportToWindowCoordinates:function(i){t.console.assert(this.viewer,"[Viewport.viewportToWindowCoordinates] the viewport must have a viewer.");var r=this.viewportToViewerElementCoordinates(i);return r.plus(t.getElementPosition(this.viewer.element))},viewportToImageZoom:function(i){if(this.viewer){var r=this.viewer.world.getItemCount();if(r>1)this.silenceMultiImageWarnings||t.console.error("[Viewport.viewportToImageZoom] is not accurate with multi-image.");else if(r===1){var s=this.viewer.world.getItemAt(0);return s.viewportToImageZoom(i)}}var o=this._contentSizeNoRotate.x,a=this._containerInnerSize.x,l=this._contentBoundsNoRotate.width,h=a/o*l;return i*h},imageToViewportZoom:function(i){if(this.viewer){var r=this.viewer.world.getItemCount();if(r>1)this.silenceMultiImageWarnings||t.console.error("[Viewport.imageToViewportZoom] is not accurate with multi-image. Instead, use [TiledImage.imageToViewportZoom] for the specific image of interest");else if(r===1){var s=this.viewer.world.getItemAt(0);return s.imageToViewportZoom(i)}}var o=this._contentSizeNoRotate.x,a=this._containerInnerSize.x,l=this._contentBoundsNoRotate.width,h=o/a/l;return i*h},toggleFlip:function(){return this.setFlip(!this.getFlip()),this},getFlip:function(){return this.flipped},setFlip:function(i){return this.flipped===i?this:(this.flipped=i,this.viewer.navigator&&this.viewer.navigator.setFlip(this.getFlip()),this.viewer.forceRedraw(),this.viewer.raiseEvent("flip",{flipped:i}),this)},getMaxZoomPixelRatio:function(){return this.maxZoomPixelRatio},setMaxZoomPixelRatio:function(i,r=!0,s=!1){t.console.assert(!isNaN(i),"[Viewport.setMaxZoomPixelRatio] ratio must be a number"),!isNaN(i)&&(this.maxZoomPixelRatio=i,r&&this.getZoom()>this.getMaxZoom()&&this.applyConstraints(s))}}})(e),(function(t){t.TiledImage=function(i){this._initialized=!1,t.console.assert(i.tileCache,"[TiledImage] options.tileCache is required"),t.console.assert(i.drawer,"[TiledImage] options.drawer is required"),t.console.assert(i.viewer,"[TiledImage] options.viewer is required"),t.console.assert(i.imageLoader,"[TiledImage] options.imageLoader is required"),t.console.assert(i.source,"[TiledImage] options.source is required"),t.console.assert(!i.clip||i.clip instanceof t.Rect,"[TiledImage] options.clip must be an OpenSeadragon.Rect if present"),t.EventSource.call(this),this._tileCache=i.tileCache,delete i.tileCache,this._drawer=i.drawer,delete i.drawer,this._imageLoader=i.imageLoader,delete i.imageLoader,i.clip instanceof t.Rect&&(this._clip=i.clip.clone()),delete i.clip;var r=i.x||0;delete i.x;var s=i.y||0;delete i.y,this.normHeight=i.source.dimensions.y/i.source.dimensions.x,this.contentAspectX=i.source.dimensions.x/i.source.dimensions.y;var o=1;i.width?(o=i.width,delete i.width,i.height&&(t.console.error("specifying both width and height to a tiledImage is not supported"),delete i.height)):i.height&&(o=i.height/this.normHeight,delete i.height);var a=i.fitBounds;delete i.fitBounds;var l=i.fitBoundsPlacement||e.Placement.CENTER;delete i.fitBoundsPlacement;var h=i.degrees||0;delete i.degrees;var u=i.ajaxHeaders;delete i.ajaxHeaders,t.extend(!0,this,{viewer:null,tilesMatrix:{},coverage:{},loadingCoverage:{},lastDrawn:[],lastResetTime:0,_needsDraw:!0,_needsUpdate:!0,_hasOpaqueTile:!1,_tilesLoading:0,_tilesToDraw:[],_lastDrawn:[],_isBlending:!1,_wasBlending:!1,_isTainted:!1,springStiffness:t.DEFAULT_SETTINGS.springStiffness,animationTime:t.DEFAULT_SETTINGS.animationTime,minZoomImageRatio:t.DEFAULT_SETTINGS.minZoomImageRatio,wrapHorizontal:t.DEFAULT_SETTINGS.wrapHorizontal,wrapVertical:t.DEFAULT_SETTINGS.wrapVertical,immediateRender:t.DEFAULT_SETTINGS.immediateRender,blendTime:t.DEFAULT_SETTINGS.blendTime,alwaysBlend:t.DEFAULT_SETTINGS.alwaysBlend,minPixelRatio:t.DEFAULT_SETTINGS.minPixelRatio,smoothTileEdgesMinZoom:t.DEFAULT_SETTINGS.smoothTileEdgesMinZoom,iOSDevice:t.DEFAULT_SETTINGS.iOSDevice,debugMode:t.DEFAULT_SETTINGS.debugMode,crossOriginPolicy:t.DEFAULT_SETTINGS.crossOriginPolicy,ajaxWithCredentials:t.DEFAULT_SETTINGS.ajaxWithCredentials,placeholderFillStyle:t.DEFAULT_SETTINGS.placeholderFillStyle,opacity:t.DEFAULT_SETTINGS.opacity,preload:t.DEFAULT_SETTINGS.preload,compositeOperation:t.DEFAULT_SETTINGS.compositeOperation,subPixelRoundingForTransparency:t.DEFAULT_SETTINGS.subPixelRoundingForTransparency,maxTilesPerFrame:t.DEFAULT_SETTINGS.maxTilesPerFrame},i),this._preload=this.preload,delete this.preload,this._fullyLoaded=!1,this._xSpring=new t.Spring({initial:r,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._ySpring=new t.Spring({initial:s,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._scaleSpring=new t.Spring({initial:o,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._degreesSpring=new t.Spring({initial:h,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._updateForScale(),a&&this.fitBounds(a,l,!0),this._ownAjaxHeaders={},this.setAjaxHeaders(u,!1),this._initialized=!0},t.extend(t.TiledImage.prototype,t.EventSource.prototype,{needsDraw:function(){return this._needsDraw},redraw:function(){this._needsDraw=!0},getFullyLoaded:function(){return this._fullyLoaded},_setFullyLoaded:function(i){i!==this._fullyLoaded&&(this._fullyLoaded=i,this.raiseEvent("fully-loaded-change",{fullyLoaded:this._fullyLoaded}))},reset:function(){this._tileCache.clearTilesFor(this),this.lastResetTime=t.now(),this._needsDraw=!0},update:function(i){let r=this._xSpring.update(),s=this._ySpring.update(),o=this._scaleSpring.update(),a=this._degreesSpring.update(),l=r||s||o||a||this._needsUpdate;if(l||i||!this._fullyLoaded){let h=this._updateLevelsForViewport();this._setFullyLoaded(h)}return this._needsUpdate=!1,l?(this._updateForScale(),this._raiseBoundsChange(),this._needsDraw=!0,!0):!1},setDrawn:function(){return this._needsDraw=this._isBlending||this._wasBlending,this._needsDraw},setTainted(i){this._isTainted=i},isTainted(){return this._isTainted},destroy:function(){this.reset(),this.source.destroy&&this.source.destroy(this.viewer)},getBounds:function(i){return this.getBoundsNoRotate(i).rotate(this.getRotation(i),this._getRotationPoint(i))},getBoundsNoRotate:function(i){return i?new t.Rect(this._xSpring.current.value,this._ySpring.current.value,this._worldWidthCurrent,this._worldHeightCurrent):new t.Rect(this._xSpring.target.value,this._ySpring.target.value,this._worldWidthTarget,this._worldHeightTarget)},getWorldBounds:function(){return t.console.error("[TiledImage.getWorldBounds] is deprecated; use TiledImage.getBounds instead"),this.getBounds()},getClippedBounds:function(i){var r=this.getBoundsNoRotate(i);if(this._clip){var s=i?this._worldWidthCurrent:this._worldWidthTarget,o=s/this.source.dimensions.x,a=this._clip.times(o);r=new t.Rect(r.x+a.x,r.y+a.y,a.width,a.height)}return r.rotate(this.getRotation(i),this._getRotationPoint(i))},getTileBounds:function(i,r,s){var o=this.source.getNumTiles(i),a=(o.x+r%o.x)%o.x,l=(o.y+s%o.y)%o.y,h=this.source.getTileBounds(i,a,l);return this.getFlip()&&(h.x=Math.max(0,1-h.x-h.width)),h.x+=(r-a)/o.x,h.y+=this._worldHeightCurrent/this._worldWidthCurrent*((s-l)/o.y),h},getContentSize:function(){return new t.Point(this.source.dimensions.x,this.source.dimensions.y)},getSizeInWindowCoordinates:function(){var i=this.imageToWindowCoordinates(new t.Point(0,0)),r=this.imageToWindowCoordinates(this.getContentSize());return new t.Point(r.x-i.x,r.y-i.y)},_viewportToImageDelta:function(i,r,s){var o=s?this._scaleSpring.current.value:this._scaleSpring.target.value;return new t.Point(i*(this.source.dimensions.x/o),r*(this.source.dimensions.y*this.contentAspectX/o))},viewportToImageCoordinates:function(i,r,s){var o;return i instanceof t.Point?(s=r,o=i):o=new t.Point(i,r),o=o.rotate(-this.getRotation(s),this._getRotationPoint(s)),s?this._viewportToImageDelta(o.x-this._xSpring.current.value,o.y-this._ySpring.current.value):this._viewportToImageDelta(o.x-this._xSpring.target.value,o.y-this._ySpring.target.value)},_imageToViewportDelta:function(i,r,s){var o=s?this._scaleSpring.current.value:this._scaleSpring.target.value;return new t.Point(i/this.source.dimensions.x*o,r/this.source.dimensions.y/this.contentAspectX*o)},imageToViewportCoordinates:function(i,r,s){i instanceof t.Point&&(s=r,r=i.y,i=i.x);var o=this._imageToViewportDelta(i,r,s);return s?(o.x+=this._xSpring.current.value,o.y+=this._ySpring.current.value):(o.x+=this._xSpring.target.value,o.y+=this._ySpring.target.value),o.rotate(this.getRotation(s),this._getRotationPoint(s))},imageToViewportRectangle:function(i,r,s,o,a){var l=i;l instanceof t.Rect?a=r:l=new t.Rect(i,r,s,o);var h=this.imageToViewportCoordinates(l.getTopLeft(),a),u=this._imageToViewportDelta(l.width,l.height,a);return new t.Rect(h.x,h.y,u.x,u.y,l.degrees+this.getRotation(a))},viewportToImageRectangle:function(i,r,s,o,a){var l=i;i instanceof t.Rect?a=r:l=new t.Rect(i,r,s,o);var h=this.viewportToImageCoordinates(l.getTopLeft(),a),u=this._viewportToImageDelta(l.width,l.height,a);return new t.Rect(h.x,h.y,u.x,u.y,l.degrees-this.getRotation(a))},viewerElementToImageCoordinates:function(i){var r=this.viewport.pointFromPixel(i,!0);return this.viewportToImageCoordinates(r)},imageToViewerElementCoordinates:function(i){var r=this.imageToViewportCoordinates(i);return this.viewport.pixelFromPoint(r,!0)},windowToImageCoordinates:function(i){var r=i.minus(e.getElementPosition(this.viewer.element));return this.viewerElementToImageCoordinates(r)},imageToWindowCoordinates:function(i){var r=this.imageToViewerElementCoordinates(i);return r.plus(e.getElementPosition(this.viewer.element))},_viewportToTiledImageRectangle:function(i){var r=this._scaleSpring.current.value;return i=i.rotate(-this.getRotation(!0),this._getRotationPoint(!0)),new t.Rect((i.x-this._xSpring.current.value)/r,(i.y-this._ySpring.current.value)/r,i.width/r,i.height/r,i.degrees)},viewportToImageZoom:function(i){var r=this._scaleSpring.current.value*this.viewport._containerInnerSize.x/this.source.dimensions.x;return r*i},imageToViewportZoom:function(i){var r=this._scaleSpring.current.value*this.viewport._containerInnerSize.x/this.source.dimensions.x;return i/r},setPosition:function(i,r){var s=this._xSpring.target.value===i.x&&this._ySpring.target.value===i.y;if(r){if(s&&this._xSpring.current.value===i.x&&this._ySpring.current.value===i.y)return;this._xSpring.resetTo(i.x),this._ySpring.resetTo(i.y),this._needsDraw=!0,this._needsUpdate=!0}else{if(s)return;this._xSpring.springTo(i.x),this._ySpring.springTo(i.y),this._needsDraw=!0,this._needsUpdate=!0}s||this._raiseBoundsChange()},setWidth:function(i,r){this._setScale(i,r)},setHeight:function(i,r){this._setScale(i/this.normHeight,r)},setCroppingPolygons:function(i){var r=function(o){return o instanceof t.Point||typeof o.x=="number"&&typeof o.y=="number"},s=function(o){return o.map(function(a){try{if(r(a))return{x:a.x,y:a.y};throw new Error}catch{throw new Error("A Provided cropping polygon point is not supported")}})};try{if(!t.isArray(i))throw new Error("Provided cropping polygon is not an array");this._croppingPolygons=i.map(function(o){return s(o)}),this._needsDraw=!0}catch(o){t.console.error("[TiledImage.setCroppingPolygons] Cropping polygon format not supported"),t.console.error(o),this.resetCroppingPolygons()}},resetCroppingPolygons:function(){this._croppingPolygons=null,this._needsDraw=!0},fitBounds:function(i,r,s){r=r||t.Placement.CENTER;var o=t.Placement.properties[r],a=this.contentAspectX,l=0,h=0,u=1,c=1;if(this._clip&&(a=this._clip.getAspectRatio(),u=this._clip.width/this.source.dimensions.x,c=this._clip.height/this.source.dimensions.y,i.getAspectRatio()>a?(l=this._clip.x/this._clip.height*i.height,h=this._clip.y/this._clip.height*i.height):(l=this._clip.x/this._clip.width*i.width,h=this._clip.y/this._clip.width*i.width)),i.getAspectRatio()>a){var d=i.height/c,f=0;o.isHorizontallyCentered?f=(i.width-i.height*a)/2:o.isRight&&(f=i.width-i.height*a),this.setPosition(new t.Point(i.x-l+f,i.y-h),s),this.setHeight(d,s)}else{var p=i.width/u,g=0;o.isVerticallyCentered?g=(i.height-i.width/a)/2:o.isBottom&&(g=i.height-i.width/a),this.setPosition(new t.Point(i.x-l,i.y-h+g),s),this.setWidth(p,s)}},getClip:function(){return this._clip?this._clip.clone():null},setClip:function(i){t.console.assert(!i||i instanceof t.Rect,"[TiledImage.setClip] newClip must be an OpenSeadragon.Rect or null"),i instanceof t.Rect?this._clip=i.clone():this._clip=null,this._needsUpdate=!0,this._needsDraw=!0,this.raiseEvent("clip-change")},getFlip:function(){return this.flipped},setFlip:function(i){this.flipped=i},get flipped(){return this._flipped},set flipped(i){let r=this._flipped!==!!i;this._flipped=!!i,r&&(this.update(!0),this._needsDraw=!0,this._raiseBoundsChange())},get wrapHorizontal(){return this._wrapHorizontal},set wrapHorizontal(i){let r=this._wrapHorizontal!==!!i;this._wrapHorizontal=!!i,this._initialized&&r&&(this.update(!0),this._needsDraw=!0)},get wrapVertical(){return this._wrapVertical},set wrapVertical(i){let r=this._wrapVertical!==!!i;this._wrapVertical=!!i,this._initialized&&r&&(this.update(!0),this._needsDraw=!0)},get debugMode(){return this._debugMode},set debugMode(i){this._debugMode=!!i,this._needsDraw=!0},getOpacity:function(){return this.opacity},setOpacity:function(i){this.opacity=i},get opacity(){return this._opacity},set opacity(i){i!==this.opacity&&(this._opacity=i,this._needsDraw=!0,this.raiseEvent("opacity-change",{opacity:this.opacity}))},getPreload:function(){return this._preload},setPreload:function(i){this._preload=!!i,this._needsDraw=!0},getRotation:function(i){return i?this._degreesSpring.current.value:this._degreesSpring.target.value},setRotation:function(i,r){this._degreesSpring.target.value===i&&this._degreesSpring.isAtTargetValue()||(r?this._degreesSpring.resetTo(i):this._degreesSpring.springTo(i),this._needsDraw=!0,this._needsUpdate=!0,this._raiseBoundsChange())},getDrawArea:function(){if(this._opacity===0&&!this._preload)return!1;var i=this._viewportToTiledImageRectangle(this.viewport.getBoundsWithMargins(!0));if(!this.wrapHorizontal&&!this.wrapVertical){var r=this._viewportToTiledImageRectangle(this.getClippedBounds(!0));i=i.intersection(r)}return i},getTilesToDraw:function(){let i=this._tilesToDraw.flat();return this._updateTilesInViewport(i),i=this._tilesToDraw.flat(),i.forEach(r=>{r.tile.beingDrawn=!0}),this._lastDrawn=i,i},_getRotationPoint:function(i){return this.getBoundsNoRotate(i).getCenter()},get compositeOperation(){return this._compositeOperation},set compositeOperation(i){i!==this._compositeOperation&&(this._compositeOperation=i,this._needsDraw=!0,this.raiseEvent("composite-operation-change",{compositeOperation:this._compositeOperation}))},getCompositeOperation:function(){return this._compositeOperation},setCompositeOperation:function(i){this.compositeOperation=i},setAjaxHeaders:function(i,r){if(i===null&&(i={}),!t.isPlainObject(i)){console.error("[TiledImage.setAjaxHeaders] Ignoring invalid headers, must be a plain object");return}this._ownAjaxHeaders=i,this._updateAjaxHeaders(r)},_updateAjaxHeaders:function(i){if(i===void 0&&(i=!0),t.isPlainObject(this.viewer.ajaxHeaders)?this.ajaxHeaders=t.extend({},this.viewer.ajaxHeaders,this._ownAjaxHeaders):this.ajaxHeaders=this._ownAjaxHeaders,i){var r,s,o,a;for(var l in this.tilesMatrix){r=this.source.getNumTiles(l);for(var h in this.tilesMatrix[l]){s=(r.x+h%r.x)%r.x;for(var u in this.tilesMatrix[l][h])if(o=(r.y+u%r.y)%r.y,a=this.tilesMatrix[l][h][u],a.loadWithAjax=this.loadTilesWithAjax,a.loadWithAjax){var c=this.source.getTileAjaxHeaders(l,s,o);a.ajaxHeaders=t.extend({},this.ajaxHeaders,c)}else a.ajaxHeaders=null}}for(var d=0;d<this._imageLoader.jobQueue.length;d++){var f=this._imageLoader.jobQueue[d];f.loadWithAjax=f.tile.loadWithAjax,f.ajaxHeaders=f.tile.loadWithAjax?f.tile.ajaxHeaders:null}}},_setScale:function(i,r){var s=this._scaleSpring.target.value===i;if(r){if(s&&this._scaleSpring.current.value===i)return;this._scaleSpring.resetTo(i),this._updateForScale(),this._needsDraw=!0,this._needsUpdate=!0}else{if(s)return;this._scaleSpring.springTo(i),this._updateForScale(),this._needsDraw=!0,this._needsUpdate=!0}s||this._raiseBoundsChange()},_updateForScale:function(){this._worldWidthTarget=this._scaleSpring.target.value,this._worldHeightTarget=this.normHeight*this._scaleSpring.target.value,this._worldWidthCurrent=this._scaleSpring.current.value,this._worldHeightCurrent=this.normHeight*this._scaleSpring.current.value},_raiseBoundsChange:function(){this.raiseEvent("bounds-change")},_isBottomItem:function(){return this.viewer.world.getItemAt(0)===this},_getLevelsInterval:function(){var i=Math.max(this.source.minLevel,Math.floor(Math.log(this.minZoomImageRatio)/Math.log(2))),r=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(0),!0).x*this._scaleSpring.current.value,s=Math.min(Math.abs(this.source.maxLevel),Math.abs(Math.floor(Math.log(r/this.minPixelRatio)/Math.log(2))));return s=Math.max(s,this.source.minLevel||0),i=Math.min(i,s),{lowestLevel:i,highestLevel:s}},_updateLevelsForViewport:function(){var i=this._getLevelsInterval(),r=i.lowestLevel,s=i.highestLevel,o=[],a=this.getDrawArea(),l=t.now();if(this._lastDrawn.forEach(R=>{R.tile.beingDrawn=!1}),this._tilesToDraw=[],this._tilesLoading=0,this.loadingCoverage={},!a)return this._needsDraw=!1,this._fullyLoaded;var h=new Array(s-r+1);for(let R=0,P=s;P>=r;P--,R++)h[R]=P;for(let R=s+1;R<=this.source.maxLevel;R++){var u=this.tilesMatrix[R]&&this.tilesMatrix[R][0]&&this.tilesMatrix[R][0][0];if(u&&u.isBottomMost&&u.isRightMost&&u.loaded){h.push(R);break}}let c=!1;for(let R=0;R<h.length;R++){let P=h[R];var d=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(P),!0).x*this._scaleSpring.current.value;if(R===h.length-1||d>=this.minPixelRatio)c=!0;else if(!c)continue;var f=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(P),!1).x*this._scaleSpring.current.value,p=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(Math.max(this.source.getClosestLevel(),0)),!1).x*this._scaleSpring.current.value,g=this.immediateRender?1:p,v=Math.min(1,(d-.5)/.5),m=g/Math.abs(g-f),x=this._updateLevel(P,v,m,a,l,o);o=x.bestTiles;var y=x.updatedTiles.filter(S=>S.loaded),E=(function(S,L,k){return function(W){return{tile:W,level:S,levelOpacity:L,currentTime:k}}})(P,v,l);if(this._tilesToDraw[P]=y.map(E),this._providesCoverage(this.coverage,P))break}return o&&o.length>0?(o.forEach(function(R){R&&!R.context2D&&this._loadTile(R,l)},this),this._needsDraw=!0,!1):this._tilesLoading===0},_updateTilesInViewport:function(i){let r=t.now(),s=this;this._tilesLoading=0,this._wasBlending=this._isBlending,this._isBlending=!1,this.loadingCoverage={};let o=i.length?i[0].level:0;if(!this.getDrawArea())return;function l(u){let c=u.tile;if(c&&c.loaded){let d=s._blendTile(c,c.x,c.y,u.level,u.levelOpacity,r,o);s._isBlending=s._isBlending||d,s._needsDraw=s._needsDraw||d||s._wasBlending}}let h=0;for(let u=0;u<i.length;u++){let c=i[u];l(c),this._providesCoverage(this.coverage,c.level)&&(h=Math.max(h,c.level))}if(h>0)for(let u in this._tilesToDraw)u<h&&delete this._tilesToDraw[u]},_blendTile:function(i,r,s,o,a,l,h){let u=1e3*this.blendTime,c,d;return i.blendStart||(i.blendStart=l),c=l-i.blendStart,d=u?Math.min(1,c/u):1,o===h&&(d=1,c=u),this.alwaysBlend&&(d*=a),i.opacity=d,d===1&&(this._setCoverage(this.coverage,o,r,s,!0),this._hasOpaqueTile=!0),c<u},_updateLevel:function(i,r,s,o,a,l){var h=o.getBoundingBox().getTopLeft(),u=o.getBoundingBox().getBottomRight();this.viewer&&this.viewer.raiseEvent("update-level",{tiledImage:this,havedrawn:!0,level:i,opacity:r,visibility:s,drawArea:o,topleft:h,bottomright:u,currenttime:a,best:l}),this._resetCoverage(this.coverage,i),this._resetCoverage(this.loadingCoverage,i);var c=this._getCornerTiles(i,h,u),d=c.topLeft,f=c.bottomRight,p=this.source.getNumTiles(i),g=this.viewport.pixelFromPoint(this.viewport.getCenter());this.getFlip()&&(f.x+=1,this.wrapHorizontal||(f.x=Math.min(f.x,p.x-1)));for(var v=Math.max(0,(f.x-d.x)*(f.y-d.y)),m=new Array(v),x=0,y=d.x;y<=f.x;y++)for(var E=d.y;E<=f.y;E++){var R;if(this.getFlip()){var P=(p.x+y%p.x)%p.x;R=y+p.x-P-P-1}else R=y;if(o.intersection(this.getTileBounds(i,R,E))!==null){var S=this._updateTile(R,E,i,s,g,p,a,l);l=S.bestTiles,m[x]=S.tile,x+=1}}return{bestTiles:l,updatedTiles:m}},_positionTile:function(i,r,s,o,a){var l=i.bounds.getTopLeft();l.x*=this._scaleSpring.current.value,l.y*=this._scaleSpring.current.value,l.x+=this._xSpring.current.value,l.y+=this._ySpring.current.value;var h=i.bounds.getSize();h.x*=this._scaleSpring.current.value,h.y*=this._scaleSpring.current.value,i.positionedBounds.x=l.x,i.positionedBounds.y=l.y,i.positionedBounds.width=h.x,i.positionedBounds.height=h.y;var u=s.pixelFromPointNoRotate(l,!0),c=s.pixelFromPointNoRotate(l,!1),d=s.deltaPixelsFromPointsNoRotate(h,!0),f=s.deltaPixelsFromPointsNoRotate(h,!1),p=c.plus(f.divide(2)),g=o.squaredDistanceTo(p);this.viewer.drawer.minimumOverlapRequired(this)&&(r||(d=d.plus(new t.Point(1,1))),i.isRightMost&&this.wrapHorizontal&&(d.x+=.75),i.isBottomMost&&this.wrapVertical&&(d.y+=.75)),i.position=u,i.size=d,i.squaredDistance=g,i.visibility=a},_updateTile:function(i,r,s,o,a,l,h,u){var c=this._getTile(i,r,s,h,l);this.viewer&&this.viewer.raiseEvent("update-tile",{tiledImage:this,tile:c}),this._setCoverage(this.coverage,s,i,r,!1);var d=c.loaded||c.loading||this._isCovered(this.loadingCoverage,s,i,r);if(this._setCoverage(this.loadingCoverage,s,i,r,d),!c.exists)return{bestTiles:u,tile:c};if(c.loaded&&c.opacity===1&&this._setCoverage(this.coverage,s,i,r,!0),this._positionTile(c,this.source.tileOverlap,this.viewport,a,o),!c.loaded)if(c.context2D)this._setTileLoaded(c);else{var f=this._tileCache.getImageRecord(c.cacheKey);f&&this._setTileLoaded(c,f.getData())}return c.loading?this._tilesLoading++:d||(u=this._compareTiles(u,c,this.maxTilesPerFrame)),{bestTiles:u,tile:c}},_getCornerTiles:function(i,r,s){var o,a;this.wrapHorizontal?(o=t.positiveModulo(r.x,1),a=t.positiveModulo(s.x,1)):(o=Math.max(0,r.x),a=Math.min(1,s.x));var l,h,u=1/this.source.aspectRatio;this.wrapVertical?(l=t.positiveModulo(r.y,u),h=t.positiveModulo(s.y,u)):(l=Math.max(0,r.y),h=Math.min(u,s.y));var c=this.source.getTileAtPoint(i,new t.Point(o,l)),d=this.source.getTileAtPoint(i,new t.Point(a,h)),f=this.source.getNumTiles(i);return this.wrapHorizontal&&(c.x+=f.x*Math.floor(r.x),d.x+=f.x*Math.floor(s.x)),this.wrapVertical&&(c.y+=f.y*Math.floor(r.y/u),d.y+=f.y*Math.floor(s.y/u)),{topLeft:c,bottomRight:d}},_getTile:function(i,r,s,o,a){var l,h,u,c,d,f,p,g,v,m,x=this.tilesMatrix,y=this.source;return x[s]||(x[s]={}),x[s][i]||(x[s][i]={}),(!x[s][i][r]||!x[s][i][r].flipped!=!this.flipped)&&(l=(a.x+i%a.x)%a.x,h=(a.y+r%a.y)%a.y,u=this.getTileBounds(s,i,r),c=y.getTileBounds(s,l,h,!0),d=y.tileExists(s,l,h),f=y.getTileUrl(s,l,h),p=y.getTilePostData(s,l,h),this.loadTilesWithAjax?(g=y.getTileAjaxHeaders(s,l,h),t.isPlainObject(this.ajaxHeaders)&&(g=t.extend({},this.ajaxHeaders,g))):g=null,v=y.getContext2D?y.getContext2D(s,l,h):void 0,m=new t.Tile(s,i,r,u,d,f,v,this.loadTilesWithAjax,g,c,p,y.getTileHashKey(s,l,h,f,g,p)),this.getFlip()?l===0&&(m.isRightMost=!0):l===a.x-1&&(m.isRightMost=!0),h===a.y-1&&(m.isBottomMost=!0),m.flipped=this.flipped,x[s][i][r]=m),m=x[s][i][r],m.lastTouchTime=o,m},_loadTile:function(i,r){var s=this;i.loading=!0,this._imageLoader.addJob({src:i.getUrl(),tile:i,source:this.source,postData:i.postData,loadWithAjax:i.loadWithAjax,ajaxHeaders:i.ajaxHeaders,crossOriginPolicy:this.crossOriginPolicy,ajaxWithCredentials:this.ajaxWithCredentials,callback:function(o,a,l){s._onTileLoad(i,r,o,a,l)},abort:function(){i.loading=!1}})},_onTileLoad:function(i,r,s,o,a){if(s)i.exists=!0;else{t.console.error("Tile %s failed to load: %s - error: %s",i,i.getUrl(),o),this.viewer.raiseEvent("tile-load-failed",{tile:i,tiledImage:this,time:r,message:o,tileRequest:a}),i.loading=!1,i.exists=!1;return}if(r<this.lastResetTime){t.console.warn("Ignoring tile %s loaded before reset: %s",i,i.getUrl()),i.loading=!1;return}var l=this,h=function(){var u=l.source,c=u.getClosestLevel();l._setTileLoaded(i,s,c,a)};h()},_setTileLoaded:function(i,r,s,o){var a=0,l=!1,h=this;function u(){return l&&t.console.error("Event 'tile-loaded' argument getCompletionCallback must be called synchronously. Its return value should be called asynchronously."),a++,c}function c(){a--,a===0&&(i.loading=!1,i.loaded=!0,i.hasTransparency=h.source.hasTransparency(i.context2D,i.getUrl(),i.ajaxHeaders,i.postData),i.context2D||h._tileCache.cacheTile({data:r,tile:i,cutoff:s,tiledImage:h}),h.viewer.raiseEvent("tile-ready",{tile:i,tiledImage:h,tileRequest:o}),h._needsDraw=!0)}var d=u();this.viewer.raiseEvent("tile-loaded",{tile:i,tiledImage:this,tileRequest:o,get image(){return t.console.error("[tile-loaded] event 'image' has been deprecated. Use 'data' property instead."),r},data:r,getCompletionCallback:u}),l=!0,d()},_compareTiles:function(i,r,s){return i?(i.push(r),this._sortTiles(i),i.length>s&&i.pop(),i):[r]},_sortTiles:function(i){i.sort(function(r,s){return r===null?1:s===null?-1:r.visibility===s.visibility?r.squaredDistance-s.squaredDistance:s.visibility-r.visibility})},_providesCoverage:function(i,r,s,o){var a,l,h,u;if(!i[r])return!1;if(s===void 0||o===void 0){a=i[r];for(h in a)if(Object.prototype.hasOwnProperty.call(a,h)){l=a[h];for(u in l)if(Object.prototype.hasOwnProperty.call(l,u)&&!l[u])return!1}return!0}return i[r][s]===void 0||i[r][s][o]===void 0||i[r][s][o]===!0},_isCovered:function(i,r,s,o){return s===void 0||o===void 0?this._providesCoverage(i,r+1):this._providesCoverage(i,r+1,2*s,2*o)&&this._providesCoverage(i,r+1,2*s,2*o+1)&&this._providesCoverage(i,r+1,2*s+1,2*o)&&this._providesCoverage(i,r+1,2*s+1,2*o+1)},_setCoverage:function(i,r,s,o,a){if(!i[r]){t.console.warn("Setting coverage for a tile before its level's coverage has been reset: %s",r);return}i[r][s]||(i[r][s]={}),i[r][s][o]=a},_resetCoverage:function(i,r){i[r]={}}})})(e),(function(t){var i=function(s){t.console.assert(s,"[TileCache.cacheTile] options is required"),t.console.assert(s.tile,"[TileCache.cacheTile] options.tile is required"),t.console.assert(s.tiledImage,"[TileCache.cacheTile] options.tiledImage is required"),this.tile=s.tile,this.tiledImage=s.tiledImage},r=function(s){t.console.assert(s,"[ImageRecord] options is required"),t.console.assert(s.data,"[ImageRecord] options.data is required"),this._tiles=[],s.create.apply(null,[this,s.data,s.ownerTile]),this._destroyImplementation=s.destroy.bind(null,this),this.getImage=s.getImage.bind(null,this),this.getData=s.getData.bind(null,this),this.getRenderedContext=s.getRenderedContext.bind(null,this)};r.prototype={destroy:function(){this._destroyImplementation(),this._tiles=null},addTile:function(s){t.console.assert(s,"[ImageRecord.addTile] tile is required"),this._tiles.push(s)},removeTile:function(s){for(var o=0;o<this._tiles.length;o++)if(this._tiles[o]===s){this._tiles.splice(o,1);return}t.console.warn("[ImageRecord.removeTile] trying to remove unknown tile",s)},getTileCount:function(){return this._tiles.length}},t.TileCache=function(s){s=s||{},this._maxImageCacheCount=s.maxImageCacheCount||t.DEFAULT_SETTINGS.maxImageCacheCount,this._tilesLoaded=[],this._imagesLoaded=[],this._imagesLoadedCount=0},t.TileCache.prototype={numTilesLoaded:function(){return this._tilesLoaded.length},cacheTile:function(s){t.console.assert(s,"[TileCache.cacheTile] options is required"),t.console.assert(s.tile,"[TileCache.cacheTile] options.tile is required"),t.console.assert(s.tile.cacheKey,"[TileCache.cacheTile] options.tile.cacheKey is required"),t.console.assert(s.tiledImage,"[TileCache.cacheTile] options.tiledImage is required");var o=s.cutoff||0,a=this._tilesLoaded.length,l=this._imagesLoaded[s.tile.cacheKey];if(l||(s.data||(t.console.error("[TileCache.cacheTile] options.image was renamed to options.data. '.image' attribute has been deprecated and will be removed in the future."),s.data=s.image),t.console.assert(s.data,"[TileCache.cacheTile] options.data is required to create an ImageRecord"),l=this._imagesLoaded[s.tile.cacheKey]=new r({data:s.data,ownerTile:s.tile,create:s.tiledImage.source.createTileCache,destroy:s.tiledImage.source.destroyTileCache,getImage:s.tiledImage.source.getTileCacheDataAsImage,getData:s.tiledImage.source.getTileCacheData,getRenderedContext:s.tiledImage.source.getTileCacheDataAsContext2D}),this._imagesLoadedCount++),l.addTile(s.tile),s.tile.cacheImageRecord=l,this._imagesLoadedCount>this._maxImageCacheCount){for(var h=null,u=-1,c=null,d,f,p,g,v,m,x=this._tilesLoaded.length-1;x>=0;x--)if(m=this._tilesLoaded[x],d=m.tile,!(d.level<=o||d.beingDrawn)){if(!h){h=d,u=x,c=m;continue}g=d.lastTouchTime,f=h.lastTouchTime,v=d.level,p=h.level,(g<f||g===f&&v>p)&&(h=d,u=x,c=m)}h&&u>=0&&(this._unloadTile(c),a=u)}this._tilesLoaded[a]=new i({tile:s.tile,tiledImage:s.tiledImage})},clearTilesFor:function(s){t.console.assert(s,"[TileCache.clearTilesFor] tiledImage is required");for(var o,a=0;a<this._tilesLoaded.length;++a)o=this._tilesLoaded[a],o.tiledImage===s&&(this._unloadTile(o),this._tilesLoaded.splice(a,1),a--)},getImageRecord:function(s){return t.console.assert(s,"[TileCache.getImageRecord] cacheKey is required"),this._imagesLoaded[s]},_unloadTile:function(s){t.console.assert(s,"[TileCache._unloadTile] tileRecord is required");var o=s.tile,a=s.tiledImage;let l=o.getCanvasContext&&o.getCanvasContext();o.unload(),o.cacheImageRecord=null;var h=this._imagesLoaded[o.cacheKey];h&&(h.removeTile(o),h.getTileCount()||(h.destroy(),delete this._imagesLoaded[o.cacheKey],this._imagesLoadedCount--,l&&(l.canvas.width=0,l.canvas.height=0,a.viewer.raiseEvent("image-unloaded",{context2D:l,tile:o}))),a.viewer.raiseEvent("tile-unloaded",{tile:o,tiledImage:a}))}}})(e),(function(t){t.World=function(i){var r=this;t.console.assert(i.viewer,"[World] options.viewer is required"),t.EventSource.call(this),this.viewer=i.viewer,this._items=[],this._needsDraw=!1,this._autoRefigureSizes=!0,this._needsSizesFigured=!1,this._delegatedFigureSizes=function(s){r._autoRefigureSizes?r._figureSizes():r._needsSizesFigured=!0},this._figureSizes()},t.extend(t.World.prototype,t.EventSource.prototype,{addItem:function(i,r){if(t.console.assert(i,"[World.addItem] item is required"),t.console.assert(i instanceof t.TiledImage,"[World.addItem] only TiledImages supported at this time"),r=r||{},r.index!==void 0){var s=Math.max(0,Math.min(this._items.length,r.index));this._items.splice(s,0,i)}else this._items.push(i);this._autoRefigureSizes?this._figureSizes():this._needsSizesFigured=!0,this._needsDraw=!0,i.addHandler("bounds-change",this._delegatedFigureSizes),i.addHandler("clip-change",this._delegatedFigureSizes),this.raiseEvent("add-item",{item:i})},getItemAt:function(i){return t.console.assert(i!==void 0,"[World.getItemAt] index is required"),this._items[i]},getIndexOfItem:function(i){return t.console.assert(i,"[World.getIndexOfItem] item is required"),t.indexOf(this._items,i)},getItemCount:function(){return this._items.length},setItemIndex:function(i,r){t.console.assert(i,"[World.setItemIndex] item is required"),t.console.assert(r!==void 0,"[World.setItemIndex] index is required");var s=this.getIndexOfItem(i);if(r>=this._items.length)throw new Error("Index bigger than number of layers.");r===s||s===-1||(this._items.splice(s,1),this._items.splice(r,0,i),this._needsDraw=!0,this.raiseEvent("item-index-change",{item:i,previousIndex:s,newIndex:r}))},removeItem:function(i){t.console.assert(i,"[World.removeItem] item is required");var r=t.indexOf(this._items,i);r!==-1&&(i.removeHandler("bounds-change",this._delegatedFigureSizes),i.removeHandler("clip-change",this._delegatedFigureSizes),i.destroy(),this._items.splice(r,1),this._figureSizes(),this._needsDraw=!0,this._raiseRemoveItem(i))},removeAll:function(){this.viewer._cancelPendingImages();var i,r;for(r=0;r<this._items.length;r++)i=this._items[r],i.removeHandler("bounds-change",this._delegatedFigureSizes),i.removeHandler("clip-change",this._delegatedFigureSizes),i.destroy();var s=this._items;for(this._items=[],this._figureSizes(),this._needsDraw=!0,r=0;r<s.length;r++)i=s[r],this._raiseRemoveItem(i)},resetItems:function(){for(var i=0;i<this._items.length;i++)this._items[i].reset()},update:function(i){for(var r=!1,s=0;s<this._items.length;s++)r=this._items[s].update(i)||r;return r},draw:function(){this.viewer.drawer.draw(this._items),this._needsDraw=!1,this._items.forEach(i=>{this._needsDraw=i.setDrawn()||this._needsDraw})},needsDraw:function(){for(var i=0;i<this._items.length;i++)if(this._items[i].needsDraw())return!0;return this._needsDraw},getHomeBounds:function(){return this._homeBounds.clone()},getContentFactor:function(){return this._contentFactor},setAutoRefigureSizes:function(i){this._autoRefigureSizes=i,i&this._needsSizesFigured&&(this._figureSizes(),this._needsSizesFigured=!1)},arrange:function(i){i=i||{};var r=i.immediately||!1,s=i.layout||t.DEFAULT_SETTINGS.collectionLayout,o=i.rows||t.DEFAULT_SETTINGS.collectionRows,a=i.columns||t.DEFAULT_SETTINGS.collectionColumns,l=i.tileSize||t.DEFAULT_SETTINGS.collectionTileSize,h=i.tileMargin||t.DEFAULT_SETTINGS.collectionTileMargin,u=l+h,c;!i.rows&&a?c=a:c=Math.ceil(this._items.length/o);var d=0,f=0,p,g,v,m,x;this.setAutoRefigureSizes(!1);for(var y=0;y<this._items.length;y++)y&&y%c===0&&(s==="horizontal"?(f+=u,d=0):(d+=u,f=0)),p=this._items[y],g=p.getBounds(),g.width>g.height?v=l:v=l*(g.width/g.height),m=v*(g.height/g.width),x=new t.Point(d+(l-v)/2,f+(l-m)/2),p.setPosition(x,r),p.setWidth(v,r),s==="horizontal"?d+=u:f+=u;this.setAutoRefigureSizes(!0)},_figureSizes:function(){var i=this._homeBounds?this._homeBounds.clone():null,r=this._contentSize?this._contentSize.clone():null,
74s=this._contentFactor||0;if(!this._items.length)this._homeBounds=new t.Rect(0,0,1,1),this._contentSize=new t.Point(1,1),this._contentFactor=1;else{var o=this._items[0],a=o.getBounds();this._contentFactor=o.getContentSize().x/a.width;for(var l=o.getClippedBounds().getBoundingBox(),h=l.x,u=l.y,c=l.x+l.width,d=l.y+l.height,f=1;f<this._items.length;f++)o=this._items[f],a=o.getBounds(),this._contentFactor=Math.max(this._contentFactor,o.getContentSize().x/a.width),l=o.getClippedBounds().getBoundingBox(),h=Math.min(h,l.x),u=Math.min(u,l.y),c=Math.max(c,l.x+l.width),d=Math.max(d,l.y+l.height);this._homeBounds=new t.Rect(h,u,c-h,d-u),this._contentSize=new t.Point(this._homeBounds.width*this._contentFactor,this._homeBounds.height*this._contentFactor)}(this._contentFactor!==s||!this._homeBounds.equals(i)||!this._contentSize.equals(r))&&this.raiseEvent("metrics-change",{})},_raiseRemoveItem:function(i){this.raiseEvent("remove-item",{item:i})}})})(e)})(xo)),xo.exports}var Sp=py();const zi=Xh(Sp);var mc=Object.prototype.hasOwnProperty;function Mr(n,e){var t,i;if(n===e)return!0;if(n&&e&&(t=n.constructor)===e.constructor){if(t===Date)return n.getTime()===e.getTime();if(t===RegExp)return n.toString()===e.toString();if(t===Array){if((i=n.length)===e.length)for(;i--&&Mr(n[i],e[i]););return i===-1}if(!t||typeof n=="object"){i=0;for(t in n)if(mc.call(n,t)&&++i&&!mc.call(e,t)||!(t in e)||!Mr(n[t],e[t]))return!1;return Object.keys(e).length===i}}return n!==n&&e!==e}const Ls=le.createContext({anno:void 0,setAnno:void 0,annotations:[],selection:{selected:[]}}),gy=(n,e)=>{const{event:t,...i}=n,{event:r,...s}=e;return Mr(i,s)?t?.timeStamp===r?.timeStamp:!1},WP=le.forwardRef((n,e)=>{const[t,i]=le.useState(null),[r,s]=le.useState([]),[o,a]=le.useState({selected:[],previous:[]}),l=le.useRef([]);return le.useImperativeHandle(e,()=>t),le.useEffect(()=>{if(t){const{selection:h,store:u}=t.state;u.all().length>0&&s(u.all());const c=()=>s(()=>u.all());u.observe(c);let d;const f=h.subscribe(({selected:p,...g})=>{d&&u.unobserve(d);const v=(p||[]).map(({id:m,editable:x})=>({annotation:u.getAnnotation(m),editable:x}));a(m=>{const x={selected:v,previous:m.selected,...g};return gy(m,x)?m:(l.current=m.selected,x)}),d=m=>{const{updated:x}=m.changes;a(y=>({...y,selected:y.selected.map(({annotation:E,editable:R})=>{const P=x.find(S=>S.oldValue.id===E.id);return P?{annotation:P.newValue,editable:R}:{annotation:E,editable:R}})}))},u.observe(d,{annotations:p.map(({id:m})=>m)})});return()=>{u.unobserve(c),f()}}},[t]),Ei.jsx(Ls.Provider,{value:{anno:t,setAnno:i,annotations:r,selection:o},children:n.children})}),Ap=()=>{const{anno:n}=le.useContext(Ls);return n},my=()=>{const{annotations:n}=le.useContext(Ls);return n},YP=n=>my(),vy=()=>{const{selection:n}=le.useContext(Ls);return n},qP=()=>{const n=Ap(),[e,t]=le.useState();return le.useEffect(()=>{if(!n)return;const{hover:i,store:r}=n.state,s=i.subscribe(o=>{if(o){const a=r.getAnnotation(o);t(a)}else t(void 0)});return()=>{s()}},[n]),e};var yy=typeof document<"u",xy=function(){},No=yy?le.useLayoutEffect:xy;const _y={...fp},wy=_y.useInsertionEffect,Ty=wy||(n=>n());function Ey(n){const e=le.useRef(()=>{});return Ty(()=>{e.current=n}),le.useCallback(function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];return e.current==null?void 0:e.current(...i)},[])}function ua(){return typeof window<"u"}function Hr(n){return Rp(n)?(n.nodeName||"").toLowerCase():"#document"}function Ht(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function Wi(n){var e;return(e=(Rp(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function Rp(n){return ua()?n instanceof Node||n instanceof Ht(n).Node:!1}function kt(n){return ua()?n instanceof Element||n instanceof Ht(n).Element:!1}function gn(n){return ua()?n instanceof HTMLElement||n instanceof Ht(n).HTMLElement:!1}function vc(n){return!ua()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof Ht(n).ShadowRoot}function ca(n){const{overflow:e,overflowX:t,overflowY:i,display:r}=fi(n);return/auto|scroll|overlay|hidden|clip/.test(e+i+t)&&r!=="inline"&&r!=="contents"}function by(n){return/^(table|td|th)$/.test(Hr(n))}function da(n){try{if(n.matches(":popover-open"))return!0}catch{}try{return n.matches(":modal")}catch{return!1}}const Sy=/transform|translate|scale|rotate|perspective|filter/,Ay=/paint|layout|strict|content/,_n=n=>!!n&&n!=="none";let Ga;
74function Kh(n){const e=kt(n)?fi(n):n;return _n(e.transform)||_n(e.translate)||_n(e.scale)||_n(e.rotate)||_n(e.perspective)||!Jh()&&(_n(e.backdropFilter)||_n(e.filter))||Sy.test(e.willChange||"")||Ay.test(e.contain||"")}function Ry(n){let e=zn(n);for(;gn(e)&&!xs(e);){if(Kh(e))return e;if(da(e))return null;e=zn(e)}return null}function Jh(){return Ga==null&&(Ga=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Ga}function xs(n){return/^(html|body|#document)$/.test(Hr(n))}function fi(n){return Ht(n).getComputedStyle(n)}function fa(n){return kt(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function zn(n){if(Hr(n)==="html")return n;const e=n.assignedSlot||n.parentNode||vc(n)&&n.host||Wi(n);return vc(e)?e.host:e}function Pp(n){const e=zn(n);return xs(e)?(n.ownerDocument||n).body:gn(e)&&ca(e)?e:Pp(e)}function _s(n,e,t){var i;e===void 0&&(e=[]),t===void 0&&(t=!0);const r=Pp(n),s=r===((i=n.ownerDocument)==null?void 0:i.body),o=Ht(r);if(s){const a=Yl(o);return e.concat(o,o.visualViewport||[],ca(r)?r:[],a&&t?_s(a):[])}else return e.concat(r,_s(r,[],t))}function Yl(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}const Vi=Math.min,Ai=Math.max,ko=Math.round,Ws=Math.floor,Gi=n=>({x:n,y:n}),Py={left:"right",right:"left",bottom:"top",top:"bottom"};function Cp(n,e,t){return Ai(n,Vi(e,t))}function Gr(n,e){return typeof n=="function"?n(e):n}function un(n){return n.split("-")[0]}function Bs(n){return n.split("-")[1]}function Ip(n){return n==="x"?"y":"x"}function Qh(n){return n==="y"?"height":"width"}function Fi(n){const e=n[0];return e==="t"||e==="b"?"y":"x"}function eu(n){return Ip(Fi(n))}function Cy(n,e,t){t===void 0&&(t=!1);const i=Bs(n),r=eu(n),s=Qh(r);let o=r==="x"?i===(t?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=Uo(o)),[o,Uo(o)]}function Iy(n){const e=Uo(n);return[ql(n),e,ql(e)]}function ql(n){return n.includes("start")?n.replace("start","end"):n.replace("end","start")}const yc=["left","right"],xc=["right","left"],My=["top","bottom"],Dy=["bottom","top"];function Oy(n,e,t){switch(n){case"top":case"bottom":return t?e?xc:yc:e?yc:xc;case"left":case"right":return e?My:Dy;default:return[]}}function Ly(n,e,t,i){const r=Bs(n);let s=Oy(un(n),t==="start",i);return r&&(s=s.map(o=>o+"-"+r),e&&(s=s.concat(s.map(ql)))),s}function Uo(n){const e=un(n);return Py[e]+n.slice(e.length)}function By(n){var e,t,i,r;return{top:(e=n.top)!=null?e:0,right:(t=n.right)!=null?t:0,bottom:(i=n.bottom)!=null?i:0,left:(r=n.left)!=null?r:0}}function tu(n){return typeof n!="number"?By(n):{top:n,right:n,bottom:n,left:n}}function an(n){const{x:e,y:t,width:i,height:r}=n;return{width:i,height:r,top:t,left:e,right:e+i,bottom:t+r,x:e,y:t}}function _c(n,e,t){let{reference:i,floating:r}=n;const s=Fi(e),o=eu(e),a=Qh(o),l=un(e),h=s==="y",u=i.x+i.width/2-r.width/2,c=i.y+i.height/2-r.height/2,d=i[a]/2-r[a]/2;let f;switch(l){case"top":f={x:u,y:i.y-r.height};break;case"bottom":f={x:u,y:i.y+i.height};break;case"right":f={x:i.x+i.width,y:c};break;case"left":f={x:i.x-r.width,y:c};break;default:f={x:i.x,y:i.y}}const p=Bs(e);return p&&(f[o]+=d*(p==="end"?1:-1)*(t&&h?-1:1)),f}async function Fy(n,e){var t;e===void 0&&(e={});const{x:i,y:r,platform:s,rects:o,elements:a,strategy:l}=n,{boundary:h="clippingAncestors",rootBoundary:u="viewport",elementContext:c="floating",altBoundary:d=!1,padding:f=0}=Gr(e,n),p=tu(f),g=a[d?c==="floating"?"reference":"floating":c],v=an(await s.getClippingRect({element:(t=await(s.isElement==null?void 0:s.isElement(g)))==null||t?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:h,rootBoundary:u,strategy:l})),m=c==="floating"?{x:i,y:r,width:o.floating.width,height:o.floating.height}:o.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),y=await(s.isElement==null?void 0:s.isElement(x))&&await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1},E=an(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:m,offsetParent:x,strategy:l}):m);return{top:(v.top-E.top+p.top)/y.y,bottom:(E.bottom-v.bottom+p.bottom)/y.y,left:(v.left-E.left+p.left)/y.x,right:(E.right-v.right+p.right)/y.x}}const Ny=50,ky=async(n,e,t)=>{const{placement:i="bottom",strategy:r="absolute",middleware:s=[],platform:o}=t,a=o.detectOverflow?o:{...o,detectOverflow:Fy},l=await(o.isRTL==null?void 0:o.isRTL(e));let h=await o.getElementRects({reference:n,floating:e,strategy:r}),{x:u,y:c}=_c(h,i,l),d=i,f=0;const p={};for(let g=0;g<s.length;g++){const v=s[g];
74if(!v)continue;const{name:m,fn:x}=v,{x:y,y:E,data:R,reset:P}=await x({x:u,y:c,initialPlacement:i,placement:d,strategy:r,middlewareData:p,rects:h,platform:a,elements:{reference:n,floating:e}});u=y??u,c=E??c,p[m]={...p[m],...R},P&&f<Ny&&(f++,typeof P=="object"&&(P.placement&&(d=P.placement),P.rects&&(h=P.rects===!0?await o.getElementRects({reference:n,floating:e,strategy:r}):P.rects),{x:u,y:c}=_c(h,d,l)),g=-1)}return{x:u,y:c,placement:d,strategy:r,middlewareData:p}},Uy=n=>({name:"arrow",options:n,async fn(e){const{x:t,y:i,placement:r,rects:s,platform:o,elements:a,middlewareData:l}=e,{element:h,padding:u=0}=Gr(n,e)||{};if(h==null)return{};const c=tu(u),d={x:t,y:i},f=eu(r),p=Qh(f),g=await o.getDimensions(h),v=f==="y",m=v?"top":"left",x=v?"bottom":"right",y=v?"clientHeight":"clientWidth",E=s.reference[p]+s.reference[f]-d[f]-s.floating[p],R=d[f]-s.reference[f],P=await(o.getOffsetParent==null?void 0:o.getOffsetParent(h));let S=P?P[y]:0;(!S||!await(o.isElement==null?void 0:o.isElement(P)))&&(S=a.floating[y]||s.floating[p]);const L=E/2-R/2,k=S/2-g[p]/2-1,W=Vi(c[m],k),j=Vi(c[x],k),V=S-g[p]-j,N=S/2-g[p]/2+L,D=Cp(W,N,V),A=!l.arrow&&Bs(r)!=null&&N!==D&&s.reference[p]/2-(N<W?W:j)-g[p]/2<0,O=A?N<W?N-W:N-V:0;return{[f]:d[f]+O,data:{[f]:D,centerOffset:N-D-O,...A&&{alignmentOffset:O}},reset:A}}}),Hy=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,i;const{placement:r,middlewareData:s,rects:o,initialPlacement:a,platform:l,elements:h}=e,{mainAxis:u=!0,crossAxis:c=!0,fallbackPlacements:d,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...v}=Gr(n,e);if((t=s.arrow)!=null&&t.alignmentOffset)return{};const m=un(r),x=Fi(a),y=un(a)===a,E=await(l.isRTL==null?void 0:l.isRTL(h.floating)),R=d||(y||!g?[Uo(a)]:Iy(a)),P=p!=="none";!d&&P&&R.push(...Ly(a,g,p,E));const S=[a,...R],L=await l.detectOverflow(e,v),k=[];let W=((i=s.flip)==null?void 0:i.overflows)||[];if(u&&k.push(L[m]),c){const D=Cy(r,o,E);k.push(L[D[0]],L[D[1]])}if(W=[...W,{placement:r,overflows:k}],!k.every(D=>D<=0)){var j,V;const D=(((j=s.flip)==null?void 0:j.index)||0)+1,A=S[D];if(A&&(!(c==="alignment"&&x!==Fi(A))||W.every(B=>Fi(B.placement)===x?B.overflows[0]>0:!0)))return{data:{index:D,overflows:W},reset:{placement:A}};let O=(V=W.filter(B=>B.overflows[0]<=0).sort((B,G)=>B.overflows[1]-G.overflows[1])[0])==null?void 0:V.placement;if(!O)switch(f){case"bestFit":{var N;const B=(N=W.filter(G=>{if(P){const Y=Fi(G.placement);return Y===x||Y==="y"}return!0}).map(G=>[G.placement,G.overflows.filter(Y=>Y>0).reduce((Y,z)=>Y+z,0)]).sort((G,Y)=>G[1]-Y[1])[0])==null?void 0:N[0];B&&(O=B);break}case"initialPlacement":O=a;break}if(r!==O)return{reset:{placement:O}}}return{}}}};function Mp(n){const e=Vi(...n.map(s=>s.left)),t=Vi(...n.map(s=>s.top)),i=Ai(...n.map(s=>s.right)),r=Ai(...n.map(s=>s.bottom));return{x:e,y:t,width:i-e,height:r-t}}function Gy(n){const e=n.slice().sort((r,s)=>r.y-s.y),t=[];let i=null;for(let r=0;r<e.length;r++){const s=e[r];!i||s.y-i.y>i.height/2?t.push([s]):t[t.length-1].push(s),i=s}return t.map(r=>an(Mp(r)))}const zy=function(n){return n===void 0&&(n={}),{name:"inline",options:n,async fn(e){const{placement:t,elements:i,rects:r,platform:s,strategy:o}=e,{padding:a=2,x:l,y:h}=Gr(n,e),u=Array.from(await(s.getClientRects==null?void 0:s.getClientRects(i.reference))||[]);if(!u.length)return{};const c=Gy(u),d=an(Mp(u)),f=tu(a);function p(){if(c.length===2&&(c[0].left>c[1].right||c[1].left>c[0].right)&&l!=null&&h!=null)return c.find(v=>l>v.left-f.left&&l<v.right+f.right&&h>v.top-f.top&&h<v.bottom+f.bottom)||d;if(c.length>=2){if(Fi(t)==="y"){const P=c[0],S=c[c.length-1],L=un(t)==="top",k=P.top,W=S.bottom,j=L?P.left:S.left,V=L?P.right:S.right;return an({x:j,y:k,width:V-j,height:W-k})}const v=un(t)==="left",m=Ai(...c.map(P=>P.right)),x=Vi(...c.map(P=>P.left)),y=c.filter(P=>v?P.left===x:P.right===m),E=y[0].top,R=y[y.length-1].bottom;return an({x,y:E,width:m-x,height:R-E})}return d}const g=await s.getElementRects({reference:{getBoundingClientRect:p},floating:i.floating,strategy:o});return r.reference.x!==g.reference.x||r.reference.y!==g.reference.y||r.reference.width!==g.reference.width||r.reference.height!==g.reference.height?{reset:{rects:g}}:{}}}},Vy=new Set(["left","top"]);async function jy(n,e){const{placement:t,platform:i,elements:r}=n,s=await(i.isRTL==null?void 0:i.isRTL(r.floating)),o=un(t),a=Bs(t),l=Fi(t)==="y",h=Vy.has(o)?-1:1,u=s&&l?-1:1,c=Gr(e,n);let{mainAxis:d,crossAxis:f,alignmentAxis:p}=typeof c=="number"?{mainAxis:c,crossAxis:0,alignmentAxis:null}
74:{mainAxis:c.mainAxis||0,crossAxis:c.crossAxis||0,alignmentAxis:c.alignmentAxis};return a&&typeof p=="number"&&(f=a==="end"?p*-1:p),l?{x:f*u,y:d*h}:{x:d*h,y:f*u}}const Xy=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,i;const{x:r,y:s,placement:o,middlewareData:a}=e,l=await jy(e,n);return o===((t=a.offset)==null?void 0:t.placement)&&(i=a.arrow)!=null&&i.alignmentOffset?{}:{x:r+l.x,y:s+l.y,data:{...l,placement:o}}}}},Wy=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){const{x:t,y:i,placement:r,platform:s}=e,{mainAxis:o=!0,crossAxis:a=!1,limiter:l={fn:x=>{let{x:y,y:E}=x;return{x:y,y:E}}},...h}=Gr(n,e),u={x:t,y:i},c=await s.detectOverflow(e,h),d=Fi(r),f=Ip(d);let p=u[f],g=u[d];const v=(x,y)=>Cp(y+c[x==="y"?"top":"left"],y,y-c[x==="y"?"bottom":"right"]);o&&(p=v(f,p)),a&&(g=v(d,g));const m=l.fn({...e,[f]:p,[d]:g});return{...m,data:{x:m.x-t,y:m.y-i,enabled:{[f]:o,[d]:a}}}}}};function Dp(n){const e=fi(n);let t=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const r=gn(n),s=r?n.offsetWidth:t,o=r?n.offsetHeight:i,a=ko(t)!==s||ko(i)!==o;return a&&(t=s,i=o),{width:t,height:i,$:a}}function iu(n){return kt(n)?n:n.contextElement}function xr(n){const e=iu(n);if(!gn(e))return Gi(1);const t=e.getBoundingClientRect(),{width:i,height:r,$:s}=Dp(e);let o=(s?ko(t.width):t.width)/i,a=(s?ko(t.height):t.height)/r;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const Yy=Gi(0);function Op(n){const e=Ht(n);
74return!Jh()||!e.visualViewport?Yy:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function qy(n,e,t){return e===void 0&&(e=!1),!!t&&e&&t===Ht(n)}function Vn(n,e,t,i){e===void 0&&(e=!1),t===void 0&&(t=!1);const r=n.getBoundingClientRect(),s=iu(n);let o=Gi(1);e&&(i?kt(i)&&(o=xr(i)):o=xr(n));const a=qy(s,t,i)?Op(s):Gi(0);let l=(r.left+a.x)/o.x,h=(r.top+a.y)/o.y,u=r.width/o.x,c=r.height/o.y;if(s&&i){const d=Ht(s),f=kt(i)?Ht(i):i;let p=d,g=Yl(p);for(;g&&f!==p;){const v=xr(g),m=g.getBoundingClientRect(),x=fi(g),y=m.left+(g.clientLeft+parseFloat(x.paddingLeft))*v.x,E=m.top+(g.clientTop+parseFloat(x.paddingTop))*v.y;l*=v.x,h*=v.y,u*=v.x,c*=v.y,l+=y,h+=E,p=Ht(g),g=Yl(p)}}return an({width:u,height:c,x:l,y:h})}function pa(n,e){const t=fa(n).scrollLeft;return e?e.left+t:Vn(Wi(n)).left+t}function Lp(n,e){const t=n.getBoundingClientRect(),i=t.left+e.scrollLeft-pa(n,t),r=t.top+e.scrollTop;return{x:i,y:r}}function $y(n){let{elements:e,rect:t,offsetParent:i,strategy:r}=n;const s=r==="fixed",o=Wi(i),a=e?da(e.floating):!1;if(i===o||a&&s)return t;let l={scrollLeft:0,scrollTop:0},h=Gi(1);const u=Gi(0),c=gn(i);if((c||!s)&&((Hr(i)!=="body"||ca(o))&&(l=fa(i)),c)){const f=Vn(i);h=xr(i),u.x=f.x+i.clientLeft,u.y=f.y+i.clientTop}const d=o&&!c&&!s?Lp(o,l):Gi(0);return{width:t.width*h.x,height:t.height*h.y,x:t.x*h.x-l.scrollLeft*h.x+u.x+d.x,y:t.y*h.y-l.scrollTop*h.y+u.y+d.y}}function Zy(n){return n.getClientRects?Array.from(n.getClientRects()):[]}function Ky(n){const e=fa(n),t=n.ownerDocument.body,i=Ai(n.scrollWidth,n.clientWidth,t.scrollWidth,t.clientWidth),r=Ai(n.scrollHeight,n.clientHeight,t.scrollHeight,t.clientHeight);let s=-e.scrollLeft+pa(n);const o=-e.scrollTop;return fi(t).direction==="rtl"&&(s+=Ai(n.clientWidth,t.clientWidth)-i),{width:i,height:r,x:s,y:o}}const Jy=25;function Qy(n,e,t){t===void 0&&(t="viewport");const i=t==="layoutViewport",r=Ht(n),s=Wi(n),o=r.visualViewport;let a=s.clientWidth,l=s.clientHeight,h=0,u=0;if(o){const c=!Jh()||e==="fixed";i?c||(h=-o.offsetLeft,u=-o.offsetTop):(a=o.width,l=o.height,c&&(h=o.offsetLeft,u=o.offsetTop))}if(pa(s)<=0){const c=s.ownerDocument,d=c.body,f=getComputedStyle(d),p=c.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,g=Math.abs(s.clientWidth-d.clientWidth-p),v=getComputedStyle(s).scrollbarGutter==="stable both-edges"?g/2:g;v<=Jy&&(a-=v)}return{width:a,height:l,x:h,y:u}}function ex(n,e){const t=Vn(n,!0,e==="fixed"),i=t.top+n.clientTop,r=t.left+n.clientLeft,s=xr(n),o=n.clientWidth*s.x,a=n.clientHeight*s.y,l=r*s.x,h=i*s.y;return{width:o,height:a,x:l,y:h}}function wc(n,e,t){let i;if(e==="viewport"||e==="layoutViewport")i=Qy(n,t,e);else if(e==="document")i=Ky(Wi(n));else if(kt(e))i=ex(e,t);else{const r=Op(n);i={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return an(i)}function tx(n,e){const t=e.get(n);if(t)return t;let i=_s(n,[],!1).filter(a=>kt(a)&&Hr(a)!=="body"),r=null;const s=fi(n).position==="fixed";let o=s?zn(n):n;for(;kt(o)&&!xs(o);){const a=fi(o),l=Kh(o),h=r?r.position:s?"fixed":"";!l&&(h==="fixed"||h==="absolute"&&a.position==="static")?i=i.filter(u=>u!==o):r=a,o=zn(o)}return e.set(n,i),i}function ix(n){let{element:e,boundary:t,rootBoundary:i,strategy:r}=n;const s=[...t==="clippingAncestors"?da(e)?[]:tx(e,this._c):[].concat(t),i],o=wc(e,s[0],r);let a=o.top,l=o.right,h=o.bottom,u=o.left;for(let c=1;c<s.length;c++){const d=wc(e,s[c],r);a=Ai(d.top,a),l=Vi(d.right,l),h=Vi(d.bottom,h),u=Ai(d.left,u)}return{width:l-u,height:h-a,x:u,y:a}}function nx(n){const{width:e,height:t}=Dp(n);return{width:e,height:t}}function rx(n,e,t){const i=gn(e),r=Wi(e),s=t==="fixed",o=Vn(n,!0,s,e);let a={scrollLeft:0,scrollTop:0};const l=Gi(0);if((i||!s)&&((Hr(e)!=="body"||ca(r))&&(a=fa(e)),i)){const d=Vn(e,!0,s,e);l.x=d.x+e.clientLeft,l.y=d.y+e.clientTop}!i&&r&&(l.x=pa(r));const h=r&&!i&&!s?Lp(r,a):Gi(0),u=o.left+a.scrollLeft-l.x-h.x,c=o.top+a.scrollTop-l.y-h.y;return{x:u,y:c,width:o.width,height:o.height}}function za(n){return fi(n).position==="static"}function Tc(n,e){if(!gn(n)||fi(n).position==="fixed")return null;if(e)return e(n);let t=n.offsetParent;return Wi(n)===t&&(t=t.ownerDocument.body),t}function Bp(n,e){const t=Ht(n);if(da(n))return t;if(!gn(n)){let r=zn(n);for(;r&&!xs(r);){if(kt(r)&&!za(r))return r;r=zn(r)}return t}let i=Tc(n,e);for(;i&&by(i)&&za(i);)i=Tc(i,e);return i&&xs(i)&&za(i)&&!Kh(i)?t:i||Ry(n)||t}const sx=async function(n){const e=this.getOffsetParent||Bp,t=this.getDimensions,i=await t(n.floating);return{reference:rx(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function ox(n){return fi(n).direction==="rtl"}const ax={convertOffsetParentRelativeRectToViewportRelativeRect:$y,getDocumentElement:Wi,getClippingRect:ix,getOffsetParent:Bp,getElementRects:sx,getClientRects:Zy,getDimensions:nx,getScale:xr,isElement:kt,isRTL:ox};function Fp(n,e){return n.x===e.x&&n.y===e.y&&n.width===e.width&&n.height===e.height}function lx(n,e,t){let i=null,r;const s=Wi(n);function o(){var u;clearTimeout(r),(u=i)==null||u.disconnect(),i=null}function a(u,c){u===void 0&&(u=!1),c===void 0&&(c=1),o();const d=n.getBoundingClientRect(),{left:f,top:p,width:g,height:v}=d;if(u||e(),!g||!v)return;const m=Ws(p),x=Ws(s.clientWidth-(f+g)),y=Ws(s.clientHeight-(p+v)),E=Ws(f),R={rootMargin:-m+"px "+-x+"px "+-y+"px "+-E+"px",threshold:Ai(0,Vi(1,c))||1};let P=!0;function S(L){const k=L[0].intersectionRatio;if(!Fp(d,n.getBoundingClientRect()))return a();if(k!==c){if(!P)return a();k?a(!1,k):r=setTimeout(()=>{a(!1,1e-7)},1e3)}P=!1}try{i=new IntersectionObserver(S,{...R,root:s.ownerDocument})}catch{i=new IntersectionObserver(S,R)}i.observe(n)}const l=Ht(n),h=()=>a(t);return l.addEventListener("resize",h),a(!0),()=>{l.removeEventListener("resize",h),o()}}function hx(n,e,t,i){i===void 0&&(i={});const{ancestorScroll:r=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=i,h=iu(n),u=r||s?[...h?_s(h):[],...e?_s(e):[]]:[];u.forEach(m=>{r&&m.addEventListener("scroll",t),s&&m.addEventListener("resize",t)});const c=h&&a?lx(h,t,s):null;let d=-1,f=null;o&&(f=new ResizeObserver(m=>{let[x]=m;x&&x.target===h&&f&&e&&(f.unobserve(e),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var y;(y=f)==null||y.observe(e)})),t()}),h&&!l&&f.observe(h),e&&f.observe(e));let p,g=l?Vn(n):null;l&&v();function v(){const m=Vn(n);g&&!Fp(g,m)&&t(),g=m,p=requestAnimationFrame(v)}return t(),()=>{var m;u.forEach(x=>{r&&x.removeEventListener("scroll",t),s&&x.removeEventListener("resize",t)}),c?.(),(m=f)==null||m.disconnect(),f=null,l&&cancelAnimationFrame(p)}}const ux=Xy,cx=Wy,dx=Hy,Ec=Uy,fx=zy,px=(n,e,t)=>{const i=new Map,r=t??{},s={...ax,...r.platform,_c:i};return ky(n,e,{...r,platform:s})};var gx=typeof document<"u",mx=function(){},_o=gx?le.useLayoutEffect:mx;function Ho(n,e){if(n===e)return!0;
74if(typeof n!=typeof e)return!1;if(typeof n=="function"&&n.toString()===e.toString())return!0;let t,i,r;if(n&&e&&typeof n=="object"){if(Array.isArray(n)){if(t=n.length,t!==e.length)return!1;for(i=t;i--!==0;)if(!Ho(n[i],e[i]))return!1;return!0}if(r=Object.keys(n),t=r.length,t!==Object.keys(e).length)return!1;for(i=t;i--!==0;)if(!{}.hasOwnProperty.call(e,r[i]))return!1;for(i=t;i--!==0;){const s=r[i];if(!(s==="_owner"&&n.$$typeof)&&!Ho(n[s],e[s]))return!1}return!0}return n!==n&&e!==e}function Np(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function bc(n,e){const t=Np(n);return Math.round(e*t)/t}function Va(n){const e=le.useRef(n);return _o(()=>{e.current=n}),e}function vx(n){n===void 0&&(n={});const{placement:e="bottom",strategy:t="absolute",middleware:i=[],platform:r,elements:{reference:s,floating:o}={},transform:a=!0,whileElementsMounted:l,open:h}=n,[u,c]=le.useState({x:0,y:0,strategy:t,placement:e,middlewareData:{},isPositioned:!1}),[d,f]=le.useState(i);Ho(d,i)||f(i);const[p,g]=le.useState(null),[v,m]=le.useState(null),x=le.useCallback(G=>{G!==P.current&&(P.current=G,g(G))},[]),y=le.useCallback(G=>{G!==S.current&&(S.current=G,m(G))},[]),E=s||p,R=o||v,P=le.useRef(null),S=le.useRef(null),L=le.useRef(u),k=l!=null,W=Va(l),j=Va(r),V=Va(h),N=le.useCallback(()=>{if(!P.current||!S.current)return;const G={placement:e,strategy:t,middleware:d};j.current&&(G.platform=j.current),px(P.current,S.current,G).then(Y=>{const z={...Y,isPositioned:V.current!==!1};D.current&&!Ho(L.current,z)&&(L.current=z,Wh.flushSync(()=>{c(z)}))})},[d,e,t,j,V]);_o(()=>{h===!1&&L.current.isPositioned&&(L.current.isPositioned=!1,c(G=>({...G,isPositioned:!1})))},[h]);const D=le.useRef(!1);_o(()=>(D.current=!0,()=>{D.current=!1}),[]),_o(()=>{if(E&&(P.current=E),R&&(S.current=R),E&&R){if(W.current)return W.current(E,R,N);N()}},[E,R,N,W,k]);const A=le.useMemo(()=>({reference:P,floating:S,setReference:x,setFloating:y}),[x,y]),O=le.useMemo(()=>({reference:E,floating:R}),[E,R]),B=le.useMemo(()=>{const G={position:t,left:0,top:0};if(!O.floating)return G;const Y=bc(O.floating,u.x),z=bc(O.floating,u.y);return a?{...G,transform:"translate("+Y+"px, "+z+"px)",...Np(O.floating)>=1.5&&{willChange:"transform"}}:{position:t,left:Y,top:z}},[t,a,O.floating,u.x,u.y]);return le.useMemo(()=>({...u,update:N,refs:A,elements:O,floatingStyles:B}),[u,N,A,O,B])}const yx=n=>{function e(t){return{}.hasOwnProperty.call(t,"current")}return{name:"arrow",options:n,fn(t){const{element:i,padding:r}=typeof n=="function"?n(t):n;return i&&e(i)?i.current!=null?Ec({element:i.current,padding:r}).fn(t):{}:i?Ec({element:i,padding:r}).fn(t):{}}}},xx=(n,e)=>{const t=ux(n);return{name:t.name,fn:t.fn,options:[n,e]}},_x=(n,e)=>{const t=cx(n);return{name:t.name,fn:t.fn,options:[n,e]}},wx=(n,e)=>{const t=dx(n);return{name:t.name,fn:t.fn,options:[n,e]}},Tx=(n,e)=>{const t=fx(n);return{name:t.name,fn:t.fn,options:[n,e]}},Ex=(n,e)=>{const t=yx(n);return{name:t.name,fn:t.fn,options:[n,e]}},bx={...fp};let Sc=!1,Sx=0;const Ac=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+Sx++;function Ax(){const[n,e]=le.useState(()=>Sc?Ac():void 0);return No(()=>{n==null&&e(Ac())},[]),le.useEffect(()=>{Sc=!0},[]),n}const Rx=bx.useId,kp=Rx||Ax,Px=le.forwardRef(function(n,e){const{context:{placement:t,elements:{floating:i},middlewareData:{arrow:r,shift:s}},width:o=14,height:a=7,tipRadius:l=0,strokeWidth:h=0,staticOffset:u,stroke:c,d,style:{transform:f,...p}={},...g}=n,v=kp(),[m,x]=le.useState(!1);if(No(()=>{i&&fi(i).direction==="rtl"&&x(!0)},[i]),!i)return null;const[y,E]=t.split("-"),R=y==="top"||y==="bottom";let P=u;(R&&s!=null&&s.x||!R&&s!=null&&s.y)&&(P=null);const S=h*2,L=S/2,k=o/2*(l/-8+1),W=a/2*l/4,j=!!d,V=P&&E==="end"?"bottom":"top";let N=P&&E==="end"?"right":"left";P&&m&&(N=E==="end"?"left":"right");const D=r?.x!=null?P||r.x:"",A=r?.y!=null?P||r.y:"",O=d||"M0,0"+(" H"+o)+(" L"+(o-k)+","+(a-W))+(" Q"+o/2+","+a+" "+k+","+(a-W))+" Z",B={top:j?"rotate(180deg)":"",left:j?"rotate(90deg)":"rotate(-90deg)",bottom:j?"":"rotate(180deg)",right:j?"rotate(-90deg)":"rotate(90deg)"}[y];return Ei.jsxs("svg",{...g,"aria-hidden":!0,ref:e,width:j?o:o+S,height:o,viewBox:"0 0 "+o+" "+(a>o?a:o),style:{position:"absolute",pointerEvents:"none",[N]:D,[V]:A,[y]:R||j?"100%":"calc(100% - "+S/2+"px)",transform:[B,f].filter(G=>!!G).join(" "),...p},children:[S>0&&Ei.jsx("path",{clipPath:"url(#"+v+")",fill:"none",stroke:c,strokeWidth:S+(d?0:1),d:O}),Ei.jsx("path",{stroke:S&&!d?g.fill:"none",d:O}),Ei.jsx("clipPath",{id:v,children:Ei.jsx("rect",{x:-L,y:L*(j?-1:1),width:o+S,height:o})})]})});function Cx(){const n=new Map;return{emit(e,t){var i;
74(i=n.get(e))==null||i.forEach(r=>r(t))},on(e,t){n.has(e)||n.set(e,new Set),n.get(e).add(t)},off(e,t){var i;(i=n.get(e))==null||i.delete(t)}}}const Ix=le.createContext(null),Mx=le.createContext(null),Dx=()=>{var n;return((n=le.useContext(Ix))==null?void 0:n.id)||null},Ox=()=>le.useContext(Mx);function Lx(n){const{open:e=!1,onOpenChange:t,elements:i}=n,r=kp(),s=le.useRef({}),[o]=le.useState(()=>Cx()),a=Dx()!=null,[l,h]=le.useState(i.reference),u=Ey((f,p,g)=>{s.current.openEvent=f?p:void 0,o.emit("openchange",{open:f,event:p,reason:g,nested:a}),t?.(f,p,g)}),c=le.useMemo(()=>({setPositionReference:h}),[]),d=le.useMemo(()=>({reference:l||i.reference||null,floating:i.floating||null,domReference:i.reference}),[l,i.reference,i.floating]);return le.useMemo(()=>({dataRef:s,open:e,onOpenChange:u,elements:d,events:o,floatingId:r,refs:c}),[e,u,d,o,r,c])}function Bx(n){var e,t;let{elements:i,...r}=n===void 0?{}:n;const{nodeId:s}=r,o=Lx({...r,elements:{reference:(e=i?.reference)!=null?e:null,floating:(t=i?.floating)!=null?t:null}}),a=r.rootContext||o,l=a.elements,[h,u]=le.useState(null),[c,d]=le.useState(null),f=l?.domReference||h,p=le.useRef(null),g=Ox();No(()=>{f&&(p.current=f)},[f]);const v=vx({...r,elements:{...l,...c&&{reference:c}}}),m=le.useCallback(P=>{const S=kt(P)?{getBoundingClientRect:()=>P.getBoundingClientRect(),getClientRects:()=>P.getClientRects(),contextElement:P}:P;d(S),v.refs.setReference(S)},[v.refs]),x=le.useCallback(P=>{(kt(P)||P===null)&&(p.current=P,u(P)),(kt(v.refs.reference.current)||v.refs.reference.current===null||P!==null&&!kt(P))&&v.refs.setReference(P)},[v.refs]),y=le.useMemo(()=>({...v.refs,setReference:x,setPositionReference:m,domReference:p}),[v.refs,x,m]),E=le.useMemo(()=>({...v.elements,domReference:f}),[v.elements,f]),R=le.useMemo(()=>({...v,...a,refs:y,elements:E,nodeId:s}),[v,y,E,s,a]);return No(()=>{a.dataRef.current.floatingContext=R;const P=g?.nodesRef.current.find(S=>S.id===s);P&&(P.context=R)}),le.useMemo(()=>({...v,context:R,refs:y,elements:E}),[v,y,E,R])}const Fx=n=>({length:1,item:e=>e===0?n:void 0,[Symbol.iterator]:function*(){for(let e=0;e<this.length;e++)yield this.item(e)}}),Nx=new Uint8Array(16);function kx(){return crypto.getRandomValues(Nx)}const bt=[];for(let n=0;n<256;++n)bt.push((n+256).toString(16).slice(1));function Ux(n,e=0){return(bt[n[e+0]]+bt[n[e+1]]+bt[n[e+2]]+bt[n[e+3]]+"-"+bt[n[e+4]]+bt[n[e+5]]+"-"+bt[n[e+6]]+bt[n[e+7]]+"-"+bt[n[e+8]]+bt[n[e+9]]+"-"+bt[n[e+10]]+bt[n[e+11]]+bt[n[e+12]]+bt[n[e+13]]+bt[n[e+14]]+bt[n[e+15]]).toLowerCase()}function Rc(n,e,t){return crypto.randomUUID?crypto.randomUUID():Hx(n)}function Hx(n,e,t){var i;n=n||{};const r=n.random??((i=n.rng)==null?void 0:i.call(n))??kx();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,Ux(r)}globalThis.nanostoresGlobal||(globalThis.nanostoresGlobal={epoch:0});const Gx=[];for(let n=0;n<256;++n)Gx.push((n+256).toString(16).slice(1));let zx="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",Vx=n=>crypto.getRandomValues(new Uint8Array(n)),jx=(n,e,t)=>{let i=256-256%n.length;if(i===256){let s=n.length-1;return(o=e)=>{if(!o)return"";let a="";for(;;){let l=t(o),h=o;for(;h--;)if(a+=n[l[h]&s],a.length>=o)return a}}}let r=Math.ceil(1.6*256*e/i);return(s=e)=>{if(!s)return"";let o="";for(;;){let a=t(r),l=r;for(;l--;)if(a[l]<i&&(o+=n[a[l]%n.length],o.length>=s))return o}}},Xx=(n,e=21)=>jx(n,e|0,Vx),Wx=(n=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(n|=0));for(;n--;)e+=zx[t[n]&63];return e};const Yx=()=>({isGuest:!0,id:Xx("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()});globalThis.ANNOTORIOUS_PRESENCE_KEY||(globalThis.ANNOTORIOUS_PRESENCE_KEY=Wx());var qx=Object.defineProperty,$x=(n,e,t)=>e in n?qx(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Pc=(n,e,t)=>$x(n,typeof e!="symbol"?e+"":e,t),Cc=Object.prototype.hasOwnProperty;function Fn(n,e){var t,i;if(n===e)return!0;if(n&&e&&(t=n.constructor)===e.constructor){if(t===Date)return n.getTime()===e.getTime();if(t===RegExp)return n.toString()===e.toString();if(t===Array){if((i=n.length)===e.length)for(;i--&&Fn(n[i],e[i]););return i===-1}if(!t||typeof n=="object"){i=0;for(t in n)if(Cc.call(n,t)&&++i&&!Cc.call(e,t)||!(t in e)||!Fn(n[t],e[t]))return!1;return Object.keys(e).length===i}}return n!==n&&e!==e}globalThis.nanostoresGlobal||(globalThis.nanostoresGlobal={epoch:0});var Up=(n=>
74(n.EDIT="EDIT",n.SELECT="SELECT",n.NONE="NONE",n))(Up||{});const Zx=[];for(let n=0;n<256;++n)Zx.push((n+256).toString(16).slice(1));const ja=n=>{const e=t=>{const i={...t};return t.created&&typeof t.created=="string"&&(i.created=new Date(t.created)),t.updated&&typeof t.updated=="string"&&(i.updated=new Date(t.updated)),i};return{...n,bodies:(n.bodies||[]).map(e),target:e(n.target)}},Kx=(n,e)=>{const t=new Set(n.bodies.map(i=>i.id));return e.bodies.filter(i=>!t.has(i.id))},Jx=(n,e)=>{const t=new Set(e.bodies.map(i=>i.id));return n.bodies.filter(i=>!t.has(i.id))},Qx=(n,e)=>e.bodies.map(t=>{const i=n.bodies.find(r=>r.id===t.id);return{newBody:t,oldBody:i&&!Fn(i,t)?i:void 0}}).filter(({oldBody:t})=>t).map(({oldBody:t,newBody:i})=>({oldBody:t,newBody:i})),e0=(n,e)=>!Fn(n.target,e.target),t0=(n,e)=>{const t=Kx(n,e),i=Jx(n,e),r=Qx(n,e);return{oldValue:n,newValue:e,bodiesCreated:t.length>0?t:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:r.length>0?r:void 0,targetUpdated:e0(n,e)?{oldTarget:n.target,newTarget:e.target}:void 0}};var tn=(n=>(n.LOCAL="LOCAL",n.REMOTE="REMOTE",n.SILENT="SILENT",n))(tn||{});const i0=(n,e)=>{const t=new Set((n.created||[]).map(c=>c.id)),i=new Set((n.updated||[]).map(({newValue:c})=>c.id)),r=new Set((e.created||[]).map(c=>c.id)),s=new Set((e.deleted||[]).map(c=>c.id)),o=new Set((e.updated||[]).map(({oldValue:c})=>c.id)),a=new Set((e.updated||[]).filter(({oldValue:c})=>t.has(c.id)||i.has(c.id)).map(({oldValue:c})=>c.id)),l=[...(n.created||[]).filter(c=>!s.has(c.id)).map(c=>o.has(c.id)?e.updated.find(({oldValue:d})=>d.id===c.id).newValue:c),...e.created||[]],h=[...(n.deleted||[]).filter(c=>!r.has(c.id)),...(e.deleted||[]).filter(c=>!t.has(c.id))],u=[...(n.updated||[]).filter(({newValue:c})=>!s.has(c.id)).map(c=>{const{oldValue:d,newValue:f}=c;if(o.has(f.id)){const p=e.updated.find(g=>g.oldValue.id===f.id).newValue;return t0(d,p)}else return c}),...(e.updated||[]).filter(({oldValue:c})=>!a.has(c.id))];return{created:l,deleted:h,updated:u}};let n0=()=>({emit(n,...e){for(let t=this.events[n]||[],i=0,r=t.length;i<r;i++)t[i](...e)},events:{},on(n,e){var t;return((t=this.events)[n]||(t[n]=[])).push(e),()=>{var i;this.events[n]=(i=this.events[n])==null?void 0:i.filter(r=>e!==r)}}});const r0=250,s0=(n,e)=>{const t=n0(),i=e?.changes||[];let r=e?e.pointer:-1,s=!1,o=0;const a=p=>{if(!s){const{changes:g}=p,v=performance.now();if(v-o>r0)i.splice(r+1),i.push(g),r=i.length-1;else{const m=i.length-1;i[m]=i0(i[m],g)}o=v}s=!1};n.observe(a,{origin:tn.LOCAL});const l=p=>p&&p.length>0&&n.bulkDeleteAnnotations(p),h=p=>p&&p.length>0&&n.bulkUpsertAnnotations(p),u=p=>p&&p.length>0&&n.bulkUpdateAnnotations(p.map(({oldValue:g})=>g)),c=p=>p&&p.length>0&&n.bulkUpdateAnnotations(p.map(({newValue:g})=>g)),d=p=>p&&p.length>0&&n.bulkUpsertAnnotations(p),f=p=>p&&p.length>0&&n.bulkDeleteAnnotations(p);return{canRedo:()=>i.length-1>r,canUndo:()=>r>-1,destroy:()=>n.unobserve(a),getHistory:()=>({changes:[...i],pointer:r}),on:(p,g)=>t.on(p,g),redo:()=>{if(i.length-1>r){s=!0;const{created:p,updated:g,deleted:v}=i[r+1];h(p),c(g),f(v),t.emit("redo",i[r+1]),r+=1}},undo:()=>{if(r>-1){s=!0;const{created:p,updated:g,deleted:v}=i[r];l(p),u(g),d(v),t.emit("undo",i[r]),r-=1}}}},o0=(n,e,t,i)=>{const{hover:r,selection:s,store:o,viewport:a}=n,l=new Map;let h=[],u,c;const d=(m,x)=>{l.has(m)?l.get(m).push(x):l.set(m,[x])},f=(m,x)=>{const y=l.get(m);if(y){const E=y.indexOf(x);E!==-1&&y.splice(E,1)}},p=(m,x,y)=>{l.has(m)&&setTimeout(()=>{l.get(m).forEach(E=>{if(t){const R=Array.isArray(x)?x.map(S=>t.serialize(S)):t.serialize(x),P=y?y instanceof PointerEvent?y:t.serialize(y):void 0;E(R,P)}else E(x,y)})},1)},g=()=>{const{selected:m}=s,x=(m||[]).map(({id:y})=>o.getAnnotation(y));x.forEach(y=>{const E=h.find(R=>R.id===y.id);(!E||!Fn(E,y))&&p("updateAnnotation",y,E)}),h=h.map(y=>x.find(({id:E})=>E===y.id)||y)};s.subscribe(({selected:m})=>{if(!(h.length===0&&m.length===0)){if(h.length===0&&m.length>0)h=m.map(({id:x})=>o.getAnnotation(x));else if(h.length>0&&m.length===0)h.forEach(x=>{const y=o.getAnnotation(x.id);y&&!Fn(y,x)&&p("updateAnnotation",y,x)}),h=[];else{const x=new Set(h.map(E=>E.id)),y=new Set(m.map(({id:E})=>E));h.filter(E=>
74!y.has(E.id)).forEach(E=>{const R=o.getAnnotation(E.id);R&&!Fn(R,E)&&p("updateAnnotation",R,E)}),h=[...h.filter(E=>y.has(E.id)),...m.filter(({id:E})=>!x.has(E)).map(({id:E})=>o.getAnnotation(E))]}p("selectionChanged",h)}}),r.subscribe(m=>{!u&&m?p("mouseEnterAnnotation",o.getAnnotation(m)):u&&!m?p("mouseLeaveAnnotation",o.getAnnotation(u)):u&&m&&(p("mouseLeaveAnnotation",o.getAnnotation(u)),p("mouseEnterAnnotation",o.getAnnotation(m))),u=m}),a?.subscribe(m=>p("viewportIntersect",m.map(x=>o.getAnnotation(x)))),o.observe(m=>{i&&(c&&clearTimeout(c),c=setTimeout(g,1e3));const{created:x,deleted:y}=m.changes;(x||[]).forEach(E=>p("createAnnotation",E)),(y||[]).forEach(E=>p("deleteAnnotation",E)),(m.changes.updated||[]).filter(E=>[...E.bodiesCreated||[],...E.bodiesDeleted||[],...E.bodiesUpdated||[]].length>0).forEach(({oldValue:E,newValue:R})=>{const P=h.find(S=>S.id===E.id)||E;h=h.map(S=>S.id===E.id?R:S),p("updateAnnotation",R,P)})},{origin:tn.LOCAL}),o.observe(m=>{if(h){const x=new Set(h.map(E=>E.id)),y=(m.changes.updated||[]).filter(({newValue:E})=>x.has(E.id)).map(({newValue:E})=>E);y.length>0&&(h=h.map(E=>y.find(R=>R.id===E.id)||E))}},{origin:tn.REMOTE});const v=m=>x=>{const{updated:y}=x;m?(y||[]).forEach(E=>p("updateAnnotation",E.oldValue,E.newValue)):(y||[]).forEach(E=>p("updateAnnotation",E.newValue,E.oldValue))};return e.on("undo",v(!0)),e.on("redo",v(!1)),{on:d,off:f,emit:p}},a0=n=>e=>e.reduce((t,i)=>{const{parsed:r,error:s}=n.parse(i);return s?{parsed:t.parsed,failed:[...t.failed,i]}:r?{parsed:[...t.parsed,r],failed:t.failed}:{...t}},{parsed:[],failed:[]}),l0=(n,e,t)=>{const{store:i,selection:r}=n,s=m=>{if(t){const{parsed:x,error:y}=t.parse(m);x?i.addAnnotation(x,tn.REMOTE):console.error(y)}else i.addAnnotation(ja(m),tn.REMOTE)},o=()=>r.clear(),a=()=>i.clear(),l=m=>{const x=i.getAnnotation(m);return t&&x?t.serialize(x):x},h=()=>t?i.all().map(t.serialize):i.all(),u=()=>{var m;const x=(((m=r.selected)==null?void 0:m.map(y=>y.id))||[]).map(y=>i.getAnnotation(y)).filter(Boolean);return t?x.map(t.serialize):x},c=(m,x=!0)=>fetch(m).then(y=>y.json()).then(y=>(f(y,x),y)),d=m=>{if(typeof m=="string"){const x=i.getAnnotation(m);if(i.deleteAnnotation(m),x)return t?t.serialize(x):x}else{const x=t?t.parse(m).parsed:m;if(x)return i.deleteAnnotation(x),m}},f=(m,x=!0)=>{const y=x?i.syncAnnotations:i.bulkUpsertAnnotations;if(t){const E=t.parseAll||a0(t),{parsed:R,failed:P}=E(m);P.length>0&&console.warn(`Discarded ${P.length} invalid annotations`,P),y(R,tn.REMOTE)}else y(m.map(ja),tn.REMOTE)},p=(m,x)=>{m?r.setSelected(m,x):r.clear()},g=m=>{r.setUserSelectAction(m)},v=m=>{if(t){const x=t.parse(m).parsed,y=t.serialize(i.getAnnotation(x.id));return i.updateAnnotation(x),y}else{const x=i.getAnnotation(m.id);return i.updateAnnotation(ja(m)),x}};return{addAnnotation:s,cancelSelected:o,canRedo:e.canRedo,canUndo:e.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getHistory:e.getHistory,getSelected:u,loadAnnotations:c,redo:e.redo,removeAnnotation:d,setAnnotations:f,setSelected:p,setUserSelectAction:g,undo:e.undo,updateAnnotation:v}};let h0="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",u0=n=>crypto.getRandomValues(new Uint8Array(n)),c0=(n,e,t)=>{let i=256-256%n.length;if(i===256){let s=n.length-1;return(o=e)=>{if(!o)return"";let a="";for(;;){let l=t(o),h=o;for(;h--;)if(a+=n[l[h]&s],a.length>=o)return a}}}let r=Math.ceil(1.6*256*e/i);return(s=e)=>{if(!s)return"";let o="";for(;;){let a=t(r),l=r;for(;l--;)if(a[l]<i&&(o+=n[a[l]%n.length],o.length>=s))return o}}},d0=(n,e=21)=>c0(n,e|0,u0),f0=(n=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(n|=0));for(;n--;)e+=h0[t[n]&63];return e};const p0=()=>({isGuest:!0,id:d0("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()});globalThis.ANNOTORIOUS_PRESENCE_KEY||(globalThis.ANNOTORIOUS_PRESENCE_KEY=f0());var g0=Object.defineProperty,m0=(n,e,t)=>e in n?g0(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Ic=(n,e,t)=>m0(n,typeof e!="symbol"?e+"":e,t);function pi(){}function $l(n,e){for(const t in e)n[t]=e[t];return n}function Hp(n){return n()}function Mc(){return Object.create(null)}
vendor: 4,276 bytes, line 74
74function ni(n){n.forEach(Hp)}function ct(n){return typeof n=="function"}function mn(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function v0(n){return Object.keys(n).length===0}function y0(n,e,t,i){if(n){const r=Gp(n,e,t,i);return n[0](r)}}function Gp(n,e,t,i){return n[1]&&i?$l(t.ctx.slice(),n[1](i(e))):t.ctx}function x0(n,e,t,i){if(n[2]&&i){const r=n[2](i(t));if(e.dirty===void 0)return r;if(typeof r=="object"){const s=[],o=Math.max(e.dirty.length,r.length);for(let a=0;a<o;a+=1)s[a]=e.dirty[a]|r[a];return s}return e.dirty|r}return e.dirty}function _0(n,e,t,i,r,s){if(r){const o=Gp(e,t,i,s);n.p(o,r)}}function w0(n){if(n.ctx.length>32){const e=[],t=n.ctx.length/32;for(let i=0;i<t;i++)e[i]=-1;return e}return-1}function Dc(n){const e={};for(const t in n)t[0]!=="$"&&(e[t]=n[t]);return e}function Oc(n){return n??""}function Ge(n,e){n.appendChild(e)}function Ae(n,e,t){n.insertBefore(e,t||null)}function Se(n){n.parentNode&&n.parentNode.removeChild(n)}function ga(n,e){for(let t=0;t<n.length;t+=1)n[t]&&n[t].d(e)}function ve(n){return document.createElementNS("http://www.w3.org/2000/svg",n)}function zp(n){return document.createTextNode(n)}function Bt(){return zp(" ")}function zr(){return zp("")}function Ye(n,e,t,i){return n.addEventListener(e,t,i),()=>n.removeEventListener(e,t,i)}function C(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function T0(n){return Array.from(n.childNodes)}function Lc(n,e,t){n.classList.toggle(e,!!t)}function E0(n,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:i})}let ws;function ds(n){ws=n}function Vp(){if(!ws)throw new Error("Function called outside component initialization");return ws}function Fs(n){Vp().$$.on_mount.push(n)}function Ns(){const n=Vp();return(e,t,{cancelable:i=!1}={})=>{const r=n.$$.callbacks[e];if(r){const s=E0(e,t,{cancelable:i});return r.slice().forEach(o=>{o.call(n,s)}),!s.defaultPrevented}return!0}}function _t(n,e){const t=n.$$.callbacks[e.type];t&&t.slice().forEach(i=>i.call(this,e))}const or=[],Bc=[];let _r=[];const Fc=[],jp=Promise.resolve();let Zl=!1;function Xp(){Zl||(Zl=!0,jp.then(Yp))}function Wp(){return Xp(),jp}function Kl(n){_r.push(n)}const Xa=new Set;let Jn=0;function Yp(){if(Jn!==0)return;const n=ws;do{try{for(;Jn<or.length;){const e=or[Jn];Jn++,ds(e),b0(e.$$)}}catch(e){throw or.length=0,Jn=0,e}for(ds(null),or.length=0,Jn=0;Bc.length;)Bc.pop()();for(let e=0;e<_r.length;e+=1){const t=_r[e];Xa.has(t)||(Xa.add(t),t())}_r.length=0}while(or.length);for(;Fc.length;)Fc.pop()();Zl=!1,Xa.clear(),ds(n)}function b0(n){if(n.fragment!==null){n.update(),ni(n.before_update);const e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(Kl)}}function S0(n){const e=[],t=[];_r.forEach(i=>n.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),_r=e}const wo=new Set;let On;function Dr(){On={r:0,c:[],p:On}}function Or(){On.r||ni(On.c),On=On.p}function Xe(n,e){n&&n.i&&(wo.delete(n),n.i(e))}function et(n,e,t,i){if(n&&n.o){if(wo.has(n))return;wo.add(n),On.c.push(()=>{wo.delete(n),i&&(t&&n.d(1),i())}),n.o(e)}else i&&i()}function cn(n){return n?.length!==void 0?n:Array.from(n)}function Kt(n){n&&n.c()}function Xt(n,e,t){const{fragment:i,after_update:r}=n.$$;i&&i.m(e,t),Kl(()=>{const s=n.$$.on_mount.map(Hp).filter(ct);n.$$.on_destroy?n.$$.on_destroy.push(...s):ni(s),n.$$.on_mount=[]}),r.forEach(Kl)}function Wt(n,e){const t=n.$$;t.fragment!==null&&(S0(t.after_update),ni(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function A0(n,e){n.$$.dirty[0]===-1&&(or.push(n),Xp(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<<e%31}function vn(n,e,t,i,r,s,o=null,a=[-1]){const l=ws;ds(n);const h=n.$$={fragment:null,ctx:[],props:s,update:pi,not_equal:r,bound:Mc(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(l?l.$$.context:[])),callbacks:Mc(),dirty:a,skip_bound:!1,root:e.target||l.$$.root};o&&o(h.root);let u=!1;if(h.ctx=t?t(n,e.props||{},(c,d,...f)=>{const p=f.length?f[0]:d;return h.ctx&&r(h.ctx[c],h.ctx[c]=p)&&(!h.skip_bound&&h.bound[c]&&h.bound[c](p),u&&A0(n,c)),d}):[],h.update(),u=!0,ni(h.before_update),h.fragment=i?i(h.ctx):!1,e.target){if(e.hydrate){const c=T0(e.target);
74h.fragment&&h.fragment.l(c),c.forEach(Se)}else h.fragment&&h.fragment.c();e.intro&&Xe(n.$$.fragment),Xt(n,e.target,e.anchor),Yp()}ds(l)}class yn{constructor(){Ic(this,"$$"),Ic(this,"$$set")}$destroy(){Wt(this,1),this.$destroy=pi}$on(e,t){if(!ct(t))return pi;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}$set(e){this.$$set&&!v0(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const R0="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(R0);var $e=(n=>(n.ELLIPSE="ELLIPSE",n.MULTIPOLYGON="MULTIPOLYGON",n.POLYGON="POLYGON",n.POLYLINE="POLYLINE",n.RECTANGLE="RECTANGLE",n.LINE="LINE",n))($e||{}),P0={exports:{}};(function(n){(function(){function e(a,l){var h=a.x-l.x,u=a.y-l.y;return h*h+u*u}function t(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],e(c,h)>l&&(u.push(c),h=c);return h!==c&&u.push(c),u}function r(a,l,h,u,c){for(var d=u,f,p=l+1;p<h;p++){var g=t(a[p],a[l],a[h]);g>d&&(f=p,d=g)}d>u&&(f-l>1&&r(a,l,f,u,c),c.push(a[f]),h-f>1&&r(a,f,h,u,c))}function s(a,l){var h=a.length-1,u=[a[0]];return r(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=s(a,u),a}n.exports=o,n.exports.default=o})()})(P0);const nu={},Vr=(n,e)=>nu[n]=e,Jl=n=>nu[n.type].area(n),C0=(n,e,t,i)=>nu[n.type].intersects(n,e,t,i),Jt=n=>{let e=1/0,t=1/0,i=-1/0,r=-1/0;return n.forEach(([s,o])=>{e=Math.min(e,s),t=Math.min(t,o),i=Math.max(i,s),r=Math.max(r,o)}),{minX:e,minY:t,maxX:i,maxY:r}},Go=n=>{let e=0,t=n.length-1;for(let i=0;i<n.length;i++)e+=(n[t][0]+n[i][0])*(n[t][1]-n[i][1]),t=i;return Math.abs(.5*e)},zo=(n,e,t)=>{let i=!1;for(let r=0,s=n.length-1;r<n.length;s=r++){const o=n[r][0],a=n[r][1],l=n[s][0],h=n[s][1];a>t!=h>t&&e<(l-o)*(t-a)/(h-a)+o&&(i=!i)}return i},I0=(n,e=!0)=>{let t="M ";return n.forEach(([i,r],s)=>{s===0?t+=`${i},${r}`:t+=` L ${i},${r}`}),e&&(t+=" Z"),t},To=(n,e)=>{const t=Math.abs(e[0]-n[0]),i=Math.abs(e[1]-n[1]);return Math.sqrt(Math.pow(t,2)+Math.pow(i,2))},M0={area:n=>Math.PI*n.geometry.rx*n.geometry.ry,intersects:(n,e,t)=>{const{cx:i,cy:r,rx:s,ry:o}=n.geometry,a=0,l=Math.cos(a),h=Math.sin(a),u=e-i,c=t-r,d=l*u+h*c,f=h*u-l*c;return d*d/(s*s)+f*f/(o*o)<=1}};Vr($e.ELLIPSE,M0);const D0={area:n=>0,intersects:(n,e,t,i=2)=>{const[[r,s],[o,a]]=n.geometry.points,l=Math.abs((a-s)*e-(o-r)*t+o*s-a*r),h=To([r,s],[o,a]);return l/h<=i}};Vr($e.LINE,D0);const O0={area:n=>{const{polygons:e}=n.geometry;return e.reduce((t,i)=>{const[r,...s]=i.rings,o=Go(r.points),a=s.reduce((l,h)=>l+Go(h.points),0);return t+o-a},0)},intersects:(n,e,t)=>{const{polygons:i}=n.geometry;for(const r of i){const[s,...o]=r.rings;if(zo(s.points,e,t)){let a=!1;for(const l of o)if(zo(l.points,e,t)){a=!0;break}if(!a)return!0}}return!1}},Wa=n=>{const e=n.reduce((t,i)=>[...t,...i.rings[0].points],[]);return Jt(e)},Ki=n=>n.rings.map(e=>I0(e.points)).join(" "),L0=n=>n.polygons.reduce((e,t)=>[...e,...t.rings.reduce((i,r)=>[...i,...r.points],[])],[]);Vr($e.MULTIPOLYGON,O0);const B0={area:n=>{const e=n.geometry.points;return Go(e)},intersects:(n,e,t)=>{const i=n.geometry.points;return zo(i,e,t)}};Vr($e.POLYGON,B0);const F0={area:n=>{const e=n.geometry;if(!e.closed||e.points.length<3)return 0;const t=Nc(e.points,e.closed);return Go(t)},intersects:(n,e,t,i=2)=>{const r=n.geometry;if(r.closed){const s=Nc(r.points,r.closed);return zo(s,e,t)}else return N0(r,[e,t],i)}},Nc=(n,e=!1)=>{const t=[];for(let i=0;i<n.length;i++){const r=n[i],s=n[(i+1)%n.length];if(t.push(r.point),(i<n.length-1||e)&&(r.type==="CURVE"||s.type=="CURVE")){const o=qp(r.point,r.type==="CURVE"&&r.outHandle||r.point,s.type==="CURVE"&&s.inHandle||s.point,s.point,10);t.push(...o.slice(1))}}return t},qp=(n,e,t,i,r=10)=>{const s=[];for(let o=0;o<=r;o++){const a=o/r,l=Math.pow(1-a,3)*n[0]+3*Math.pow(1-a,2)*a*e[0]+3*(1-a)*Math.pow(a,2)*t[0]+Math.pow(a,3)*i[0],h=Math.pow(1-a,3)*n[1]+3*Math.pow(1-a,2)*a*e[1]+3*(1-a)*Math.pow(a,2)*t[1]+Math.pow(a,3)*i[1];s.push([l,h])}return s},N0=(n,e,t)=>{for(let i=0;i<n.points.length-1;i++){const r=n.points[i],s=n.points[i+1];if(r.type==="CURVE"||s.type==="CURVE"){const o=qp(r.point,r.type==="CURVE"&&r.outHandle||r.point,s.type==="CURVE"&&s.inHandle||s.point,s.point,20);for(let a=0;a<o.length-1;a++)if(kc(e,o[a],o[a+1])<=t)return!0}else if(kc(e,r.point,s.point)<=t)return!0}return!1},kc=(n,e,t)=>{const[i,r]=n,[s,o]=e,[a,l]=t,h=a-s,u=l-o,c=Math.sqrt(h*h+u*u);
74if(c===0)return Math.sqrt((i-s)*(i-s)+(r-o)*(r-o));const d=((i-s)*h+(r-o)*u)/(c*c);return d<=0?Math.sqrt((i-s)*(i-s)+(r-o)*(r-o)):d>=1?Math.sqrt((i-a)*(i-a)+(r-l)*(r-l)):Math.abs((l-o)*i-(a-s)*r+a*o-l*s)/c},k0=n=>{if(!n.points||n.points.length===0)return"";const e=[],t=n.points[0];e.push(`M ${t.point[0]} ${t.point[1]}`);for(let i=1;i<n.points.length;i++){const r=n.points[i],s=n.points[i-1];if(r.type==="CURVE"||s.type==="CURVE"){const o=s.type==="CURVE"&&s.outHandle||s.point,a=r.type==="CURVE"&&r.inHandle||r.point,l=r.point;e.push(`C ${o[0]} ${o[1]} ${a[0]} ${a[1]} ${l[0]} ${l[1]}`)}else e.push(`L ${r.point[0]} ${r.point[1]}`)}if(n.closed){const i=n.points[n.points.length-1],r=n.points[0];if(i.type==="CURVE"||r.type==="CURVE"){const s=i.outHandle||i.point,o=r.inHandle||r.point,a=r.point;e.push(`C ${s[0]} ${s[1]} ${o[0]} ${o[1]} ${a[0]} ${a[1]}`)}e.push("Z")}return e.join(" ")};Vr($e.POLYLINE,F0);const U0={area:n=>n.geometry.w*n.geometry.h,intersects:(n,e,t)=>{const i=n.geometry;if(i.rot){const r=i.x+i.w/2,s=i.y+i.h/2,o=e-r,a=t-s,l=Math.cos(i.rot),h=Math.sin(i.rot),u=o*l+a*h,c=-o*h+a*l;return u>=-i.w/2&&u<=i.w/2&&c>=-i.h/2&&c<=i.h/2}else return e>=i.x&&e<=i.x+i.w&&t>=i.y&&t<=i.y+i.h}};Vr($e.RECTANGLE,U0);const nn=n=>Eo(n.target),Eo=n=>{var e,t;return n?.annotation!==void 0&&((t=(e=n?.selector)==null?void 0:e.geometry)==null?void 0:t.bounds)!==void 0},H0=[];for(let n=0;n<256;++n)H0.push((n+256).toString(16).slice(1));var Uc=Object.prototype.hasOwnProperty;function Ts(n,e){var t,i;if(n===e)return!0;if(n&&e&&(t=n.constructor)===e.constructor){if(t===Date)return n.getTime()===e.getTime();if(t===RegExp)return n.toString()===e.toString();if(t===Array){if((i=n.length)===e.length)for(;i--&&Ts(n[i],e[i]););return i===-1}if(!t||typeof n=="object"){i=0;for(t in n)if(Uc.call(n,t)&&++i&&!Uc.call(e,t)||!(t in e)||!Ts(n[t],e[t]))return!1;return Object.keys(e).length===i}}return n!==n&&e!==e}let $t=[],ts=0;const Ql=4,G0=globalThis.nanostoresGlobal||(globalThis.nanostoresGlobal={epoch:0});let z0=()=>{let n,e;for(;ts<$t.length;){e=ts,ts+=Ql;try{$t[e]($t[e+1].value,$t[e+2],$t[e+3])}catch(t){n=t}}if($t.length=ts=0,n)throw n};const ru=n=>{let e=[],t={eq:Object.is,get(){return t.lc||t.listen(()=>{})(),t.value},init:n,lc:0,listen(i){return t.lc=e.push(i),()=>{for(let s=ts;s<$t.length;)$t[s]===i&&$t[s+1]===t?$t.splice(s,Ql):s+=Ql;let r=e.indexOf(i);~r&&(e.splice(r,1),--t.lc||t.off())}},notify(i,r){G0.epoch++;let s=!$t.length&&!0;for(let o of e)$t.push(o,t,i,r);s&&z0()},off(){},set(i){let r=t.value;t.eq(r,i)||(t.value=i,t.notify(r))},subscribe(i){let r=t.listen(i);return i(t.value),r},value:n};return t},V0=n=>{const e=ru(null);return n.observe(({changes:t})=>{const i=e.get();if(i){(t.deleted||[]).some(s=>s.id===i)&&e.set(null);const r=(t.updated||[]).find(({oldValue:s})=>s.id===i);r&&e.set(r.newValue.id)}}),{get current(){return e.get()},subscribe:e.subscribe.bind(e),set:e.set.bind(e)}};var su=(n=>
74(n.EDIT="EDIT",n.SELECT="SELECT",n.NONE="NONE",n))(su||{});const Ya={selected:[]},j0=(n,e,t)=>{const i=ru(Ya);let r=e;const s=()=>{Ts(i.get(),Ya)||i.set(Ya)},o=()=>{var f;return((f=i.get().selected)==null?void 0:f.length)===0},a=f=>{if(o())return!1;const p=typeof f=="string"?f:f.id;return i.get().selected.some(g=>g.id===p)},l=(f,p)=>{let g;if(Array.isArray(f)){if(g=f.map(m=>n.getAnnotation(m)).filter(Boolean),g.length<f.length){console.warn("Invalid selection: "+f.filter(m=>!g.some(x=>x.id===m)));return}}else{const m=n.getAnnotation(f);if(!m){console.warn("Invalid selection: "+f);return}g=[m]}const v=g.reduce((m,x)=>{const y=d(x);return y==="EDIT"?[...m,{id:x.id,editable:!0}]:y==="SELECT"?[...m,{id:x.id}]:m},[]);i.set({selected:v,event:p})},h=(f,p)=>{const g=Array.isArray(f)?f:[f],v=g.map(m=>n.getAnnotation(m)).filter(m=>!!m);i.set({selected:v.map(m=>{const x=p===void 0?d(m)==="EDIT":p;return{id:m.id,editable:x}})}),v.length!==g.length&&console.warn("Invalid selection",f)},u=f=>{if(o())return!1;const{selected:p}=i.get();p.some(({id:g})=>f.includes(g))&&i.set({selected:p.filter(({id:g})=>!f.includes(g))})},c=f=>{r=f,h(i.get().selected.map(({id:p})=>p))},d=f=>X0(f,r,t);return n.observe(({changes:f})=>u((f.deleted||[]).map(p=>p.id))),{get event(){const f=i.get();return f?f.event:null},get selected(){const f=i.get();return f?[...f.selected]:null},get userSelectAction(){return r},clear:s,evalSelectAction:d,isEmpty:o,isSelected:a,setSelected:h,setUserSelectAction:c,subscribe:i.subscribe.bind(i),userSelect:l}},X0=(n,e,t)=>{const i=t?t.serialize(n):n;return typeof e=="function"?e(i):e||"EDIT"},St=[];for(let n=0;n<256;++n)St.push((n+256).toString(16).slice(1));function W0(n,e=0){return(St[n[e+0]]+St[n[e+1]]+St[n[e+2]]+St[n[e+3]]+"-"+St[n[e+4]]+St[n[e+5]]+"-"+St[n[e+6]]+St[n[e+7]]+"-"+St[n[e+8]]+St[n[e+9]]+"-"+St[n[e+10]]+St[n[e+11]]+St[n[e+12]]+St[n[e+13]]+St[n[e+14]]+St[n[e+15]]).toLowerCase()}const Y0=new Uint8Array(16);function q0(){return crypto.getRandomValues(Y0)}function $0(n,e,t){return crypto.randomUUID?crypto.randomUUID():Z0(n)}function Z0(n,e,t){var i;n=n||{};const r=n.random??((i=n.rng)==null?void 0:i.call(n))??q0();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,W0(r)}const K0=(n,e)=>{const t=new Set(n.bodies.map(i=>i.id));return e.bodies.filter(i=>!t.has(i.id))},J0=(n,e)=>{const t=new Set(e.bodies.map(i=>i.id));return n.bodies.filter(i=>!t.has(i.id))},Q0=(n,e)=>e.bodies.map(t=>{const i=n.bodies.find(r=>r.id===t.id);return{newBody:t,oldBody:i&&!Ts(i,t)?i:void 0}}).filter(({oldBody:t})=>t).map(({oldBody:t,newBody:i})=>({oldBody:t,newBody:i})),e_=(n,e)=>!Ts(n.target,e.target),t_=(n,e)=>{const t=K0(n,e),i=J0(n,e),r=Q0(n,e);return{oldValue:n,newValue:e,bodiesCreated:t.length>0?t:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:r.length>0?r:void 0,targetUpdated:e_(n,e)?{oldTarget:n.target,newTarget:e.target}:void 0}};var gt=(n=>(n.LOCAL="LOCAL",n.REMOTE="REMOTE",n.SILENT="SILENT",n))(gt||{});const i_=(n,e)=>{var t,i;const{changes:r,origin:s}=e;if(!(n.options.origin?n.options.origin===s:s!=="SILENT"))return!1;if(n.options.ignore){const{ignore:o}=n.options,a=l=>l&&l.length>0;if(!(a(r.created)||a(r.deleted))){const l=(t=r.updated)==null?void 0:t.some(u=>a(u.bodiesCreated)||a(u.bodiesDeleted)||a(u.bodiesUpdated)),h=(i=r.updated)==null?void 0:i.some(u=>u.targetUpdated);if(o==="BODY_ONLY"&&l&&!h||o==="TARGET_ONLY"&&h&&!l)return!1}}if(n.options.annotations){const o=new Set([...(r.created||[]).map(a=>a.id),...(r.deleted||[]).map(a=>a.id),...(r.updated||[]).map(({oldValue:a})=>a.id)]);return!!(Array.isArray(n.options.annotations)?n.options.annotations:[n.options.annotations]).find(a=>o.has(a))}else return!0},qa=n=>{const e=n.id===void 0?$0():n.id;return{...n,id:e,bodies:n.bodies===void 0?[]:n.bodies.map(t=>({...t,annotation:e})),target:{...n.target,annotation:e}}},n_=n=>n.id!==void 0,r_=()=>{const n=new Map,e=new Map,t=[],i=(A,O={})=>{t.push({onChange:A,options:O})},r=A=>{const O=t.findIndex(B=>B.onChange==A);O>-1&&t.splice(O,1)},s=(A,O)=>{const B={origin:A,changes:{created:O.created||[],updated:O.updated||[],deleted:O.deleted||[]},state:[...n.values()]};t.forEach(G=>{i_(G,B)&&G.onChange(B)})},o=A=>
74{n.set(A.id,A),A.bodies.forEach(O=>e.set(O.id,A.id))},a=(A,O=gt.LOCAL)=>{if(A.id&&n.get(A.id))throw Error(`Cannot add annotation ${A.id} - exists already`);{const B=qa(A);o(B),s(O,{created:[B]})}},l=(A,O)=>{const B=qa(typeof A=="string"?O:A),G=typeof A=="string"?A:A.id,Y=G&&n.get(G);if(Y){const z=t_(Y,B);return G===B.id?n.set(G,B):(n.delete(G),n.set(B.id,B)),Y.bodies.forEach(b=>e.delete(b.id)),B.bodies.forEach(b=>e.set(b.id,B.id)),z}else console.warn(`Cannot update annotation ${G} - does not exist`)},h=(A,O=gt.LOCAL,B=gt.LOCAL)=>{const G=n_(O)?B:O,Y=l(A,O);Y&&s(G,{updated:[Y]})},u=(A,O=gt.LOCAL)=>{n.get(A.id)?h(A,O):a(A,O)},c=(A,O=gt.LOCAL)=>{const B=A.reduce((G,Y)=>{const z=l(Y);return z?[...G,z]:G},[]);B.length>0&&s(O,{updated:B})},d=A=>A.map(qa).reduce((O,B)=>n.get(B.id)?{...O,toUpdate:[...O.toUpdate,B]}:{...O,toAdd:[...O.toAdd,B]},{toAdd:[],toUpdate:[]}),f=(A,O=gt.LOCAL)=>{const{toAdd:B,toUpdate:G}=d(A),Y=G.map(z=>l(z,O)).filter(Boolean);B.forEach(o),s(O,{created:B,updated:Y})},p=(A,O=gt.LOCAL)=>{const B=n.get(A.annotation);if(B){const G={...B,bodies:[...B.bodies,A]};n.set(B.id,G),e.set(A.id,G.id),s(O,{updated:[{oldValue:B,newValue:G,bodiesCreated:[A]}]})}else console.warn(`Attempt to add body to missing annotation: ${A.annotation}`)},g=()=>[...n.values()],v=(A=gt.LOCAL)=>{const O=[...n.values()];n.clear(),e.clear(),s(A,{deleted:O})},m=(A,O=gt.LOCAL)=>{const{toAdd:B,toUpdate:G}=d(A),Y=new Set([...B,...G].map(H=>H.id)),z=[...n.keys()].filter(H=>!Y.has(H)).map(H=>y(H)).filter(Boolean),b=G.map(H=>l(H)).filter(Boolean);B.forEach(o),s(O,{created:B,updated:b,deleted:z})},x=(A,O=!0,B=gt.LOCAL)=>{O?m(A,B):f(A,B)},y=A=>{const O=typeof A=="string"?A:A.id,B=n.get(O);if(B)return n.delete(O),B.bodies.forEach(G=>e.delete(G.id)),B;console.warn(`Attempt to delete missing annotation: ${O}`)},E=(A,O=gt.LOCAL)=>{const B=y(A);B&&s(O,{deleted:[B]})},R=(A,O=gt.LOCAL)=>{const B=A.reduce((G,Y)=>{const z=y(Y);return z?[...G,z]:G},[]);B.length>0&&s(O,{deleted:B})},P=A=>{const O=n.get(A.annotation);if(O){const B=O.bodies.find(G=>G.id===A.id);if(B){e.delete(B.id);const G={...O,bodies:O.bodies.filter(Y=>Y.id!==A.id)};return n.set(O.id,G),{oldValue:O,newValue:G,bodiesDeleted:[B]}}else console.warn(`Attempt to delete missing body ${A.id} from annotation ${A.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${A.annotation}`)},S=(A,O=gt.LOCAL)=>{const B=P(A);B&&s(O,{updated:[B]})},L=(A,O=gt.LOCAL)=>{const B=A.map(G=>P(G)).filter(Boolean);B.length>0&&s(O,{updated:B})},k=A=>{const O=n.get(A);return O?{...O}:void 0},W=A=>{const O=e.get(A);if(O){const B=k(O).bodies.find(G=>G.id===A);if(B)return B;console.error(`Store integrity error: body ${A} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${A}`)},j=(A,O)=>{if(A.annotation!==O.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const B=n.get(A.annotation);if(B){const G=B.bodies.find(z=>z.id===A.id),Y={...B,bodies:B.bodies.map(z=>z.id===G.id?O:z)};return n.set(B.id,Y),G.id!==O.id&&(e.delete(G.id),e.set(O.id,Y.id)),{oldValue:B,newValue:Y,bodiesUpdated:[{oldBody:G,newBody:O}]}}else console.warn(`Attempt to add body to missing annotation ${A.annotation}`)},V=(A,O,B=gt.LOCAL)=>{const G=j(A,O);G&&s(B,{updated:[G]})},N=(A,O=gt.LOCAL)=>{const B=A.map(G=>j({id:G.id,annotation:G.annotation},G)).filter(Boolean);s(O,{updated:B})},D=A=>{const O=n.get(A.annotation);if(O){const B={...O,target:{...O.target,...A}};return n.set(O.id,B),{oldValue:O,newValue:B,targetUpdated:{oldTarget:O.target,newTarget:A}}}else console.warn(`Attempt to update target on missing annotation: ${A.annotation}`)};return{addAnnotation:a,addBody:p,all:g,bulkAddAnnotations:x,bulkDeleteAnnotations:R,bulkDeleteBodies:L,bulkUpdateAnnotations:c,bulkUpdateBodies:N,bulkUpdateTargets:(A,O=gt.LOCAL)=>{const B=A.map(G=>D(G)).filter(Boolean);B.length>0&&s(O,{updated:B})},bulkUpsertAnnotations:f,clear:v,deleteAnnotation:E,deleteBody:S,getAnnotation:k,getBody:W,observe:i,syncAnnotations:m,unobserve:r,updateAnnotation:h,updateBody:V,updateTarget:(A,O=gt.LO
74CAL)=>{const B=D(A);B&&s(O,{updated:[B]})},upsertAnnotation:u}},s_=()=>{const n=ru([]);return{subscribe:n.subscribe.bind(n),set:n.set.bind(n)}};let o_="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",a_=(n=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(n|=0));for(;n--;)e+=o_[t[n]&63];return e};globalThis.ANNOTORIOUS_PRESENCE_KEY||(globalThis.ANNOTORIOUS_PRESENCE_KEY=a_());const $p=(n,e)=>{const{left:t,top:i,width:r,height:s}=n.getBoundingClientRect();return[(e.clientX-t)*(n.clientWidth/r),(e.clientY-i)*(n.clientHeight/s)]},ma=(n,e=0)=>{const{minX:t,minY:i,maxX:r,maxY:s}=n;return{x:t-e,y:i-e,w:r-t+2*e,h:s-i+2*e}},ti=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,l_=n=>({}),Hc=n=>({grab:n[0]});function h_(n){let e,t,i,r;const s=n[8].default,o=y0(s,n,n[7],Hc);return{c(){e=ve("g"),o&&o.c(),C(e,"class","a9s-annotation selected")},m(a,l){Ae(a,e,l),o&&o.m(e,null),t=!0,i||(r=[Ye(e,"pointerup",n[2]),Ye(e,"pointermove",n[1])],i=!0)},p(a,[l]){o&&o.p&&(!t||l&128)&&_0(o,s,a,a[7],t?x0(s,a[7],l,l_):w0(a[7]),Hc)},i(a){t||(Xe(o,a),t=!0)},o(a){et(o,a),t=!1},d(a){a&&Se(e),o&&o.d(a),i=!1,ni(r)}}}function u_(n,e,t){let{$$slots:i={},$$scope:r}=e;const s=Ns();let{shape:o}=e,{editor:a}=e,{transform:l}=e,{svgEl:h}=e,u,c,d;const f=v=>m=>{if(u=v,h){const[x,y]=$p(h,m);c=l.elementToImage(x,y)}else{const{offsetX:x,offsetY:y}=m;c=l.elementToImage(x,y)}d=o,m.target.setPointerCapture(m.pointerId),s("grab",m)},p=v=>{if(u){const[m,x]=l.elementToImage(v.offsetX,v.offsetY),y=[m-c[0],x-c[1]];t(3,o=a(d,u,y)),s("change",o)}},g=v=>{v.target.releasePointerCapture(v.pointerId),u=void 0,d=o,s("release",v)};return n.$$set=v=>{"shape"in v&&t(3,o=v.shape),"editor"in v&&t(4,a=v.editor),"transform"in v&&t(5,l=v.transform),"svgEl"in v&&t(6,h=v.svgEl),"$$scope"in v&&t(7,r=v.$$scope)},[f,p,g,o,a,l,h,r,i]}class ou extends yn{constructor(e){super(),vn(this,e,u_,h_,mn,{shape:3,editor:4,transform:5,svgEl:6})}}function c_(n){let e,t,i,r,s,o,a,l,h=n[3]&&Gc(n);return{c(){e=ve("g"),t=ve("circle"),h&&h.c(),r=ve("circle"),C(t,"class","a9s-handle-buffer svelte-qtyc7s"),C(t,"cx",n[0]),C(t,"cy",n[1]),C(t,"r",i=n[5]+6/n[2]),C(t,"role","button"),C(t,"tabindex","0"),C(r,"class",s=Oc(`a9s-handle-dot${n[3]?" selected":""}`)+" svelte-qtyc7s"),C(r,"cx",n[0]),C(r,"cy",n[1]),C(r,"r",n[5]),C(e,"class",o=`a9s-handle ${n[8].class||""}`.trim())},m(u,c){Ae(u,e,c),Ge(e,t),h&&h.m(e,null),Ge(e,r),a||(l=[Ye(t,"dblclick",n[12]),Ye(t,"pointerenter",n[13]),Ye(t,"pointerleave",n[14]),Ye(t,"pointerdown",n[15]),Ye(t,"pointerdown",n[6]),Ye(t,"pointerup",n[16]),Ye(t,"pointerup",n[7])],a=!0)},p(u,c){c&1&&C(t,"cx",u[0]),c&2&&C(t,"cy",u[1]),c&36&&i!==(i=u[5]+6/u[2])&&C(t,"r",i),u[3]?h?h.p(u,c):(h=Gc(u),h.c(),h.m(e,r)):h&&(h.d(1),h=null),c&8&&s!==(s=Oc(`a9s-handle-dot${u[3]?" selected":""}`)+" svelte-qtyc7s")&&C(r,"class",s),c&1&&C(r,"cx",u[0]),c&2&&C(r,"cy",u[1]),c&32&&C(r,"r",u[5]),c&256&&o!==(o=`a9s-handle ${u[8].class||""}`.trim())&&C(e,"class",o)},d(u){u&&Se(e),h&&h.d(),a=!1,ni(l)}}}function d_(n){let e,t,i,r,s,o,a,l,h;return{c(){e=ve("g"),t=ve("circle"),r=ve("circle"),o=ve("circle"),C(t,"cx",n[0]),C(t,"cy",n[1]),C(t,"r",i=n[5]*10),C(t,"class","a9s-touch-halo"),Lc(t,"touched",n[4]),C(r,"cx",n[0]),C(r,"cy",n[1]),C(r,"r",s=n[5]+10/n[2]),C(r,"class","a9s-handle-buffer svelte-qtyc7s"),C(r,"role","button"),C(r,"tabindex","0"),C(o,"class","a9s-handle-dot"),C(o,"cx",n[0]),C(o,"cy",n[1]),C(o,"r",a=n[5]+2/n[2]),C(e,"class","a9s-touch-handle")},m(u,c){Ae(u,e,c),Ge(e,t),Ge(e,r),Ge(e,o),l||(h=[Ye(r,"dblclick",n[9]),Ye(r,"pointerdown",n[10]),Ye(r,"pointerdown",n[6]),Ye(r,"pointerup",n[11]),Ye(r,"pointerup",n[7])],l=!0)},p(u,c){c&1&&C(t,"cx",u[0]),c&2&&C(t,"cy",u[1]),c&32&&i!==(i=u[5]*10)&&C(t,"r",i),c&16&&Lc(t,"touched",u[4]),c&1&&C(r,"cx",u[0]),c&2&&C(r,"cy",u[1]),c&36&&s!==(s=u[5]+10/u[2])&&C(r,"r",s),c&1&&C(o,"cx",u[0]),c&2&&C(o,"cy",u[1]),c&36&&a!==(a=u[5]+2/u[2])&&C(o,"r",a)},d(u){u&&Se(e),l=!1,ni(h)}}}function Gc(n){let e,t;return{c(){e=ve("circle"),C(e,"class","a9s-handle-selected"),C(e,"cx",n[0]),C(e,"cy",n[1]),C(e,"r",t=n[5]+8/n[2])},m(i,r){Ae(i,e,r)},p(i,r){r&1&&C(e,"cx",i[0]),r&2&&C(e,"cy",i[1]),r&36&&t!==(t=i[5]+8/i[2])&&C(e,"r",t)},d(i){i&&Se(e)}}}function f_(n){let e;function t(r,s){return ti?d_:c_}let i=t()(n);return{c(){i.c(),e=zr()},m(r,s){i.m(r,s),Ae(r,e,s)},p(r,[s]){i.p(r,s)},i:pi,o:pi,d(r){r&&Se(e),i.d(r)}}}function p_(n,e,t){let i,{x:r}=e,{y:s}=e,{scale:o}=e,{selected:a=void 0}=e,l=!1;const h=y=>{y.pointerType==="touch"&&t(4,l=!0)},u=()=>t(4,l=!1);function c(y){_t.call(this,n,y)}function d(y){_t.call(this,n,y)}function f(y){_t.call(this,n,y)}function p(y){_t.call(this,n,y)}function g(y){_t.call(this,n,y)}function v(y){_t.call(this,n,y)}function m(y){_t.call(this,n,y)}function x(y){_t.call(this,n,y)}return n.$$set=y=>{t(8,e=$l($l({},e),Dc(y))),"x"in y&&t(0,r=y.x),"y"in y&&t(1,s=y.y),"scale"in y&&t(2,o=y.scale),"selected"in y&&t(3,a=y.selected)},n.$$.update=()=>{n.$$.dirty&4&&t(5,i=4/o)},e=Dc(e),[r,s,o,a,l,i,h,u,e,c,d,f,p,g,v,m,x]}class In extends yn{constructor(e){super(),vn(this,e,p_,f_,mn,{x:0,y:1,scale:2,selected:3})}}function g_(n){let e,t,i,r,s,o,a;return{c(){e=ve("g"),t=ve("circle"),r=ve("circle"),s=ve("circle"),C(t,"class","a9s-polygon-midpoint-buffer svelte-12ykj76"),C(t,"cx",n[0]),C(t,"cy",n[1]),C(t,"r",i=1.75*n[2]),C(r,"class","a9s-polygon-midpoint-outer svelte-12ykj76"),C(r,"cx",n[0]),C(r,"cy",n[1]),C(r,"r",n[2]),C(s,"class","a9s-polygon-midpoint-inner svelte-12ykj76"),C(s,"cx",n[0]),C(s,"cy",n[1]),C(s,"r",n[2]),C(e,"class","a9s-polygon-midpoint svelte-12ykj76")},m(l,h){Ae(l,e,h),Ge(e,t),Ge(e,r),Ge(e,s),o||(a=[Ye(t,"pointerdown",n[5]),Ye(t,"pointerdown",n[3])],o=!0)},p(l,h){h&1&&C(t,"cx",l[0]),h&2&&C(t,"cy",l[1]),h&4&&i!==(i=1.75*l[2])&&C(t,"r",i),h&1&&C(r,"cx",l[0]),h&2&&C(r,"cy",l[1]),h&4&&C(r,"r",l[2]),h&1&&C(s,"cx",l[0]),h&2&&C(s,"cy",l[1]),h&4&&C(s,"r",l[2])},d(l){l&&Se(e),o=!1,ni(a)}}}function m_(n){let e;return{c(){e=ve("circle"),C(e,"cx",n[0]),C(e,"cy",n[1]),C(e,"r",n[2])},m(t,i){Ae(t,e,i)},p(t,i){i&1&&C(e,"cx",t[0]),i&2&&C(e,"cy",t[1]),i&4&&C(e,"r",t[2])},d(t){t&&Se(e)}}}function v_(n){let e;function t(r,s){return ti?m_:g_}let i=t()(n);return{c(){i.c(),e=zr()},m(r,s){i.m(r,s),Ae(r,e,s)},p(r,[s]){i.p(r,s)},i:pi,o:pi,d(r){r&&Se(e),i.d(r)}}}function y_(n,e,t){let i,{x:r}=e,{y:s}=e,{scale:o}=e;const a=h=>{h.pointerType};function l(h){_t.call(this,n,h)}return n.$$set=h=>{"x"in h&&t(0,r=h.x),"y"in h&&t(1,s=h.y),"scale"in h&&t(4,o=h.scale)}
74,n.$$.update=()=>{n.$$.dirty&16&&t(2,i=4/o)},[r,s,i,a,o,l]}class Zp extends yn{constructor(e){super(),vn(this,e,y_,v_,mn,{x:0,y:1,scale:4})}}function $a(n){const e=n.slice(),t=e[10][e[6]];return e[28]=t.point,e}function zc(n,e,t){const i=n.slice();return i[28]=e[t],i[30]=t,i}function Za(n){const e=n.slice(),t=e[10][e[6]];return e[28]=t.point,e}function Ka(n){const e=n.slice(),t=e[10][e[6]];return e[28]=t.point,e}function Vc(n){let e,t,i,r;return{c(){e=ve("circle"),C(e,"cx",t=n[28][0]),C(e,"cy",i=n[28][1]),C(e,"r",r=Es/n[3]),C(e,"class","svelte-1h2slbm")},m(s,o){Ae(s,e,o)},p(s,o){o[0]&1088&&t!==(t=s[28][0])&&C(e,"cx",t),o[0]&1088&&i!==(i=s[28][1])&&C(e,"cy",i),o[0]&8&&r!==(r=Es/s[3])&&C(e,"r",r)},d(s){s&&Se(e)}}}function jc(n){let e,t,i,r,s,o,a,l,h,u;return{c(){e=ve("mask"),t=ve("rect"),a=ve("circle"),C(t,"x",i=n[9].x),C(t,"y",r=n[9].y),C(t,"width",s=n[9].w),C(t,"height",o=n[9].h),C(t,"class","svelte-1h2slbm"),C(a,"cx",l=n[28][0]),C(a,"cy",h=n[28][1]),C(a,"r",u=Es/n[3]),C(a,"class","svelte-1h2slbm"),C(e,"id",`${n[19]}-inner`),C(e,"class","a9s-polygon-editor-mask svelte-1h2slbm")},m(c,d){Ae(c,e,d),Ge(e,t),Ge(e,a)},p(c,d){d[0]&512&&i!==(i=c[9].x)&&C(t,"x",i),d[0]&512&&r!==(r=c[9].y)&&C(t,"y",r),d[0]&512&&s!==(s=c[9].w)&&C(t,"width",s),d[0]&512&&o!==(o=c[9].h)&&C(t,"height",o),d[0]&1088&&l!==(l=c[28][0])&&C(a,"cx",l),d[0]&1088&&h!==(h=c[28][1])&&C(a,"cy",h),d[0]&8&&u!==(u=Es/c[3])&&C(a,"r",u)},d(c){c&&Se(e)}}}function Xc(n){let e,t;return e=new In({props:{class:"a9s-corner-handle",x:n[28][0],y:n[28][1],scale:n[3],selected:n[8].includes(n[30])}}),e.$on("pointerenter",n[11]),e.$on("pointerleave",n[12]),e.$on("pointerdown",n[15]),e.$on("pointerdown",function(){ct(n[27](`HANDLE-${n[30]}`))&&n[27](`HANDLE-${n[30]}`).apply(this,arguments)}),e.$on("pointerup",n[16](n[30])),{c(){Kt(e.$$.fragment)},m(i,r){Xt(e,i,r),t=!0},p(i,r){n=i;const s={};r[0]&32&&(s.x=n[28][0]),r[0]&32&&(s.y=n[28][1]),r[0]&8&&(s.scale=n[3]),r[0]&256&&(s.selected=n[8].includes(n[30])),e.$set(s)},i(i){t||(Xe(e.$$.fragment,i),t=!0)},o(i){et(e.$$.fragment,i),t=!1},d(i){Wt(e,i)}}}function Wc(n){let e,t;return e=new Zp({props:{x:n[28][0],y:n[28][1],scale:n[3]}}),e.$on("pointerdown",function(){ct(n[18](n[6]))&&n[18](n[6]).apply(this,arguments)}),{c(){Kt(e.$$.fragment)},m(i,r){Xt(e,i,r),t=!0},p(i,r){n=i;const s={};r[0]&1088&&(s.x=n[28][0]),r[0]&1088&&(s.y=n[28][1]),r[0]&8&&(s.scale=n[3]),e.$set(s)},i(i){t||(Xe(e.$$.fragment,i),t=!0)},o(i){et(e.$$.fragment,i),t=!1},d(i){Wt(e,i)}}}function x_(n){let e,t,i,r,s,o,a,l,h,u,c,d,f,p,g,v,m,x,y,E,R,P=n[6]!==void 0&&!n[7]&&Vc(Ka(n)),S=n[6]!==void 0&&!n[7]&&jc(Za(n)),L=cn(n[5].points),k=[];for(let V=0;V<L.length;V+=1)k[V]=Xc(zc(n,L,V));const W=V=>et(k[V],1,1,()=>{k[V]=null});let j=n[6]!==void 0&&!n[7]&&Wc($a(n));return{c(){e=ve("defs"),t=ve("mask"),i=ve("rect"),l=ve("polygon"),P&&P.c(),S&&S.c(),u=Bt(),c=ve("polygon"),f=Bt(),p=ve("polygon"),v=Bt();for(let V=0;V<k.length;V+=1)k[V].c();m=Bt(),j&&j.c(),x=zr(),C(i,"x",r=n[9].x),C(i,"y",s=n[9].y),C(i,"width",o=n[9].w),C(i,"height",a=n[9].h),C(i,"class","svelte-1h2slbm"),C(l,"points",h=n[5].points.map(Yc).join(" ")),C(l,"class","svelte-1h2slbm"),C(t,"id",`${n[19]}-outer`),C(t,"class","a9s-polygon-editor-mask svelte-1h2slbm"),C(c,"class","a9s-outer"),C(c,"mask",`url(#${n[19]}-outer)`),C(c,"points",d=n[5].points.map(qc).join(" ")),C(p,"class","a9s-inner a9s-shape-handle"),C(p,"mask",`url(#${n[19]}-inner)`),C(p,"style",n[1]),C(p,"points",g=n[5].points.map($c).join(" "))},m(V,N){Ae(V,e,N),Ge(e,t),Ge(t,i),Ge(t,l),P&&P.m(t,null),S&&S.m(e,null),Ae(V,u,N),Ae(V,c,N),Ae(V,f,N),Ae(V,p,N),Ae(V,v,N);for(let D=0;D<k.length;D+=1)k[D]&&k[D].m(V,N);Ae(V,m,N),j&&j.m(V,N),Ae(V,x,N),y=!0,E||(R=[Ye(c,"pointerup",n[14]),Ye(c,"pointerdown",function(){ct(n[27]("SHAPE"))&&n[27]("SHAPE").apply(this,arguments)}),Ye(p,"pointermove",n[13]),Ye(p,"pointerup",n[14]),Ye(p,"pointerdown",function(){ct(n[27]("SHAPE"))&&n[27]("SHAPE").apply(this,arguments)})],E=!0)},p(V,N){if(n=V,(!y||N[0]&512&&r!==(r=n[9].x))&&C(i,"x",r),(!y||N[0]&512&&s!==(s=n[9].y))&&C(i,"y",s),(!y||N[0]&512&&o!==(o=n[9].w))&&C(i,"width",o),(!y||N[0]&512&&a!==(a=n[9].h))&&C(i,"height",a),(!y||N[0]&32&&h!==(h=n[5].points.map(Yc).join(" ")))&&C(l,"points",h),n[6]!==void 0&&!n[7]?P?P.p(Ka(n),N):(P=Vc(Ka(n)),P.c(),P.m(t,null)):P&&(P.d(1),P=null),n[6]!==void 0&&!n[7]?S?S.p(Za(n),N):(S=jc(Za(n)),S.c(),S.m(e,null)):S&&(S.d(1),S=null),(!y||N[0]&32&&d!==(d=n[5].points.map(qc).join(" ")))&&C(c,"points",d),(!y||N[0]&2)&&C(p,"style",n[1]),(!y||N[0]&32&&g!==(g=n[5].points.map($c).join(" ")))&&C(p,"points",g),N[0]&134322472){L=cn(n[5].points);let D;for(D=0;D<L.length;D+=1){const A=zc(n,L,D);k[D]?(k[D].p(A,N),Xe(k[D],1)):(k[D]=Xc(A),k[D].c(),Xe(k[D],1),k[D].m(m.parentNode,m))}for(Dr(),D=L.length;D<k.length;D+=1)W(D);Or()}n[6]!==void 0&&!n[7]?j?(j.p($a(n),N),N[0]&192&&Xe(j,1)):(j=Wc($a(n)),j.c(),Xe(j,1),j.m(x.parentNode,x)):j&&(Dr(),et(j,1,1,()=>{j=null}),Or())},i(V){if(!y){for(let N=0;N<L.length;N+=1)Xe(k[N]);Xe(j),y=!0}}
74,o(V){k=k.filter(Boolean);for(let N=0;N<k.length;N+=1)et(k[N]);et(j),y=!1},d(V){V&&(Se(e),Se(u),Se(c),Se(f),Se(p),Se(v),Se(m),Se(x)),P&&P.d(),S&&S.d(),ga(k,V),j&&j.d(V),E=!1,ni(R)}}}function __(n){let e,t;return e=new ou({props:{shape:n[0],transform:n[2],editor:n[17],svgEl:n[4],$$slots:{default:[x_,({grab:i})=>({27:i}),({grab:i})=>[i?134217728:0]]},$$scope:{ctx:n}}}),e.$on("change",n[20]),e.$on("grab",n[21]),e.$on("release",n[22]),{c(){Kt(e.$$.fragment)},m(i,r){Xt(e,i,r),t=!0},p(i,r){const s={};r[0]&1&&(s.shape=i[0]),r[0]&4&&(s.transform=i[2]),r[0]&16&&(s.svgEl=i[4]),r[0]&134219754|r[1]&1&&(s.$$scope={dirty:r,ctx:i}),e.$set(s)},i(i){t||(Xe(e.$$.fragment,i),t=!0)},o(i){et(e.$$.fragment,i),t=!1},d(i){Wt(e,i)}}}const w_=250,T_=1e3,E_=12,Es=4.5,Yc=n=>n.join(","),qc=n=>n.join(","),$c=n=>n.join(",");function b_(n,e,t){let i,r,s;const o=Ns();let{shape:a}=e,{computedStyle:l}=e,{transform:h}=e,{viewportScale:u=1}=e,{svgEl:c}=e,d,f=!1,p,g=[];const v=()=>t(7,f=!0),m=()=>t(7,f=!1),x=D=>{if(g.length>0||!r.some(b=>b.visible)){t(6,d=void 0);return}const[A,O]=h.elementToImage(D.offsetX,D.offsetY),B=b=>Math.pow(b[0]-A,2)+Math.pow(b[1]-O,2),G=i.points.reduce((b,H)=>B(H)<B(b)?H:b),Y=r.filter(b=>b.visible).reduce((b,H)=>B(H.point)<B(b.point)?H:b),z=Math.pow(T_/u,2);B(G)<z||B(Y.point)<z?t(6,d=r.indexOf(Y)):t(6,d=void 0)},y=()=>{document.activeElement!==c&&c.focus()},E=()=>{t(8,g=[]),y()},R=D=>{t(7,f=!0),D.preventDefault(),D.stopPropagation(),p=performance.now()},P=D=>A=>{if(!p||ti||performance.now()-p>w_)return;const O=g.includes(D);A.metaKey||A.ctrlKey||A.shiftKey?O?t(8,g=g.filter(B=>B!==D)):t(8,g=[...g,D]):O&&g.length>1?t(8,g=[D]):O?t(8,g=[]):t(8,g=[D]),y()},S=(D,A,O)=>{y();let B;const G=D.geometry;g.length>1?B=G.points.map(([z,b],H)=>g.includes(H)?[z+O[0],b+O[1]]:[z,b]):A==="SHAPE"?B=G.points.map(([z,b])=>[z+O[0],b+O[1]]):B=G.points.map(([z,b],H)=>A===`HANDLE-${H}`?[z+O[0],b+O[1]]:[z,b]);const Y=Jt(B);return{...D,geometry:{points:B,bounds:Y}}},L=D=>async A=>{A.stopPropagation();const O=[...i.points.slice(0,D+1),r[D].point,...i.points.slice(D+1)],B=Jt(O);o("change",{...a,geometry:{points:O,bounds:B}}),await Wp();const G=[...document.querySelectorAll(".a9s-handle")][D+1];if(G!=null&&G.firstChild){const Y=new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:A.clientX,clientY:A.clientY,pointerId:A.pointerId,pointerType:A.pointerType,isPrimary:A.isPrimary,buttons:A.buttons});G.firstChild.dispatchEvent(Y)}},k=()=>{if(i.points.length-g.length<3)return;const D=i.points.filter((O,B)=>!g.includes(B)),A=Jt(D);o("change",{...a,geometry:{points:D,bounds:A}}),t(8,g=[])};Fs(()=>{if(ti)return;const D=A=>{(A.key==="Delete"||A.key==="Backspace")&&(A.preventDefault(),k())};return c.addEventListener("pointermove",x),c.addEventListener("keydown",D),()=>{c.removeEventListener("pointermove",x),c.removeEventListener("keydown",D)}});const W=`polygon-mask-${Math.random().toString(36).substring(2,12)}`;function j(D){_t.call(this,n,D)}function V(D){_t.call(this,n,D)}function N(D){_t.call(this,n,D)}return n.$$set=D=>{"shape"in D&&t(0,a=D.shape),"computedStyle"in D&&t(1,l=D.computedStyle),"transform"in D&&t(2,h=D.transform),"viewportScale"in D&&t(3,u=D.viewportScale),"svgEl"in D&&t(4,c=D.svgEl)},n.$$.update=()=>{n.$$.dirty[0]&1&&t(5,i=a.geometry),n.$$.dirty[0]&40&&t(10,r=ti?[]:i.points.map((D,A)=>{const O=A===i.points.length-1?i.points[0]:i.points[A+1],B=(D[0]+O[0])/2,G=(D[1]+O[1])/2,Y=Math.sqrt(Math.pow(O[0]-B,2)+Math.pow(O[1]-G,2))>E_/u;return{point:[B,G],visible:Y}})),n.$$.dirty[0]&40&&t(9,s=ma(i.bounds,Es/u))},[a,l,h,u,c,i,d,f,g,s,r,v,m,x,E,R,P,S,L,W,j,V,N]}class S_ extends yn{constructor(e){super(),vn(this,e,b_,__,mn,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}const Kp=(n,e,t)=>{const[i,r]=n,[s,o]=e,a=Math.cos(t),l=Math.sin(t),h=i-s,u=r-o;return[s+h*a-u*l,o+h*l+u*a]},A_=(n,e,t,i,r=0)=>{const s=[[n,e],[n+t,e],[n+t,e+i],[n,e+i]],o=[n+t/2,e+i/2];return s.map(a=>Kp(a,o,r))},Zc=(n,e)=>{const{x:t,y:i,w:r,h:s,rot:o=0}=n,a=[t+r/2,i+s/2];let l=[t+r/2,i-e];return Kp(l,a,o)},R_=(n,e,t)=>{const i=Math.cos(t),r=Math.sin(t);return[n*i+e*r,-n*r+e*i]},P_=(n,e,t)=>{const i=n[0]-t[0],r=n[1]-t[1],s=Math.atan2(r,i),o=e[0]-t[0],a=e[1]-t[1];return Math.atan2(a,o)-s},C_=(n,e=10)=>{const t=e*Math.PI/180;return Math.round(n/t)*t};function I_(n){let e,t,i,r,s,o,a,l,h,u,c,d,f,p,g,v,m,x,y,E,R,P,S,L,k,W,j,V,N,D,A,O,B,G,Y,z,b,H,X,$,re,se,ce,ie,ge,de,Te,me,De,it,Je,ht,w,I,q,K,ae,he,J,ye,ee,Ve,Re;return P=new In({props:{class:"a9s-rotation-handle",x:n[7][0],y:n[7][1],scale:n[3]}}),P.$on("pointerdown",function(){ct(n[16]("ROTATION"))&&n[16]("ROTATION").apply(this,arguments)}),I=new In({props:{class:"a9s-corner-handle-topleft",x:n[6][0][0],y:n[6][0][1],scale:n[3]}}),I.$on("pointerdown",function(){ct(n[16]("TOP_LEFT"))&&n[16]("TOP_LEFT").apply(this,arguments)}),K=new In({props:{class:"a9s-corner-handle-topright",x:n[6][1][0],y:n[6][1][1],scale:n[3]}}),K.$on("pointerdown",function(){ct(n[16]("TOP_RIGHT"))&&n[16]("TOP_RIGHT").apply(this,arguments)}),he=new In({props:{class:"a9s-corner-handle-bottomright",x:n[6][2][0],y:n[6][2][1],scale:n[3]}}),he.$on("pointerdown",function(){ct(n[16]("BOTTOM_RIGHT"))&&n[16]("BOTTOM_RIGHT").apply(this,arguments)}),ye=new In({props:{class:"a9s-corner-handle-bottomleft",x:n[6][3][0],y:n[6][3][1],scale:n[3]}}),ye.$on("pointerdown",function(){ct(n[16]("BOTTOM_LEFT"))&&n[16]("BOTTOM_LEFT").apply(this,arguments)}),{c(){e=ve("defs"),t=ve("mask"),i=ve("rect"),l=ve("polygon"),u=Bt(),c=ve("g"),d=ve("line"),m=ve("line"),Kt(P.$$.fragment),S=Bt(),L=ve("g"),k=ve("polygon"),j=ve("polygon"),N=Bt(),D=ve("line"),Y=Bt(),z=ve("line"),re=Bt(),se=ve("line"),Te=Bt(),me=ve("line"),w=Bt(),Kt(I.$$.fragment),q=Bt(),Kt(K.$$.fragment),ae=Bt(),Kt(he.$$.fragment),J=Bt(),Kt(ye.$$.fragment),C(i,"class","rect-mask-bg svelte-1bwhzbc"),C(i,"x",r=n[5].x),C(i,"y",s=n[5].y),C(i,"width",o=n[5].w),C(i,"height",a=n[5].h),C(l,"class","rect-mask-fg svelte-1bwhzbc"),C(l,"points",h=n[6].map(Kc).join(" ")),C(t,"id",n[9]),C(t,"class","a9s-rectangle-editor-mask svelte-1bwhzbc"),C(d,"class","a9s-rotation-handle-line-bg"),C(d,"x1",f=n[6][0][0]+(n[6][1][0]-n[6][0][0])/2),C(d,"y1",p=n[6][0][1]+(n[6][1][1]-n[6][0][1])/2),C(d,"x2",g=n[7][
740]),C(d,"y2",v=n[7][1]),C(d,"pointer-events","none"),C(m,"class","a9s-rotation-handle-line-fg"),C(m,"x1",x=n[6][0][0]+(n[6][1][0]-n[6][0][0])/2),C(m,"y1",y=n[6][0][1]+(n[6][1][1]-n[6][0][1])/2),C(m,"x2",E=n[7][0]),C(m,"y2",R=n[7][1]),C(m,"pointer-events","none"),C(c,"class","a9s-rotation-handle-group"),C(k,"class","a9s-outer"),C(k,"mask",`url(#${n[9]})`),C(k,"points",W=n[6].map(Jc).join(" ")),C(j,"class","a9s-inner a9s-shape-handle"),C(j,"style",n[1]),C(j,"points",V=n[6].map(Qc).join(" ")),C(D,"class","a9s-edge-handle a9s-edge-handle-top"),C(D,"x1",A=n[6][0][0]),C(D,"y1",O=n[6][0][1]),C(D,"x2",B=n[6][1][0]),C(D,"y2",G=n[6][1][1]),C(z,"class","a9s-edge-handle a9s-edge-handle-right"),C(z,"x1",b=n[6][1][0]),C(z,"y1",H=n[6][1][1]),C(z,"x2",X=n[6][2][0]),C(z,"y2",$=n[6][2][1]),C(se,"class","a9s-edge-handle a9s-edge-handle-bottom"),C(se,"x1",ce=n[6][2][0]),C(se,"y1",ie=n[6][2][1]),C(se,"x2",ge=n[6][3][0]),C(se,"y2",de=n[6][3][1]),C(me,"class","a9s-edge-handle a9s-edge-handle-left"),C(me,"x1",De=n[6][3][0]),C(me,"y1",it=n[6][3][1]),C(me,"x2",Je=n[6][0][0]),C(me,"y2",ht=n[6][0][1])},m(Q,_){Ae(Q,e,_),Ge(e,t),Ge(t,i),Ge(t,l),Ae(Q,u,_),Ae(Q,c,_),Ge(c,d),Ge(c,m),Xt(P,c,null),Ae(Q,S,_),Ae(Q,L,_),Ge(L,k),Ge(L,j),Ae(Q,N,_),Ae(Q,D,_),Ae(Q,Y,_),Ae(Q,z,_),Ae(Q,re,_),Ae(Q,se,_),Ae(Q,Te,_),Ae(Q,me,_),Ae(Q,w,_),Xt(I,Q,_),Ae(Q,q,_),Xt(K,Q,_),Ae(Q,ae,_),Xt(he,Q,_),Ae(Q,J,_),Xt(ye,Q,_),ee=!0,Ve||(Re=[Ye(k,"pointerdown",function(){ct(n[16]("SHAPE"))&&n[16]("SHAPE").apply(this,arguments)}),Ye(j,"pointerdown",function(){ct(n[16]("SHAPE"))&&n[16]("SHAPE").apply(this,arguments)}),Ye(D,"pointerdown",function(){ct(n[16]("TOP"))&&n[16]("TOP").apply(this,arguments)}),Ye(z,"pointerdown",function(){ct(n[16]("RIGHT"))&&n[16]("RIGHT").apply(this,arguments)}),Ye(se,"pointerdown",function(){ct(n[16]("BOTTOM"))&&n[16]("BOTTOM").apply(this,arguments)}),Ye(me,"pointerdown",function(){ct(n[16]("LEFT"))&&n[16]("LEFT").apply(this,arguments)})],Ve=!0)},p(Q,_){n=Q,(!ee||_&32&&r!==(r=n[5].x))&&C(i,"x",r),(!ee||_&32&&s!==(s=n[5].y))&&C(i,"y",s),(!ee||_&32&&o!==(o=n[5].w))&&C(i,"width",o),(!ee||_&32&&a!==(a=n[5].h))&&C(i,"height",a),(!ee||_&64&&h!==(h=n[6].map(Kc).join(" ")))&&C(l,"points",h),(!ee||_&64&&f!==(f=n[6][0][0]+(n[6][1][0]-n[6][0][0])/2))&&C(d,"x1",f),(!ee||_&64&&p!==(p=n[6][0][1]+(n[6][1][1]-n[6][0][1])/2))&&C(d,"y1",p),(!ee||_&128&&g!==(g=n[7][0]))&&C(d,"x2",g),(!ee||_&128&&v!==(v=n[7][1]))&&C(d,"y2",v),(!ee||_&64&&x!==(x=n[6][0][0]+(n[6][1][0]-n[6][0][0])/2))&&C(m,"x1",x),(!ee||_&64&&y!==(y=n[6][0][1]+(n[6][1][1]-n[6][0][1])/2))&&C(m,"y1",y),(!ee||_&128&&E!==(E=n[7][0]))&&C(m,"x2",E),(!ee||_&128&&R!==(R=n[7][1]))&&C(m,"y2",R);const T={};_&128&&(T.x=n[7][0]),_&128&&(T.y=n[7][1]),_&8&&(T.scale=n[3]),P.$set(T),(!ee||_&64&&W!==(W=n[6].map(Jc).join(" ")))&&C(k,"points",W),(!ee||_&2)&&C(j,"style",n[1]),(!ee||_&64&&V!==(V=n[6].map(Qc).join(" ")))&&C(j,"points",V),(!ee||_&64&&A!==(A=n[6][0][0]))&&C(D,"x1",A),(!ee||_&64&&O!==(O=n[6][0][1]))&&C(D,"y1",O),(!ee||_&64&&B!==(B=n[6][1][0]))&&C(D,"x2",B),(!ee||_&64&&G!==(G=n[6][1][1]))&&C(D,"y2",G),(!ee||_&64&&b!==(b=n[6][1][0]))&&C(z,"x1",b),(!ee||_&64&&H!==(H=n[6][1][1]))&&C(z,"y1",H),(!ee||_&64&&X!==(X=n[6][2][0]))&&C(z,"x2",X),(!ee||_&64&&$!==($=n[6][2][1]))&&C(z,"y2",$),(!ee||_&64&&ce!==(ce=n[6][2][0]))&&C(se,"x1",ce),(!ee||_&64&&ie!==(ie=n[6][2][1]))&&C(se,"y1",ie),(!ee||_&64&&ge!==(ge=n[6][3][0]))&&C(se,"x2",ge),(!ee||_&64&&de!==(de=n[6][3][1]))&&C(se,"y2",de),(!ee||_&64&&De!==(De=n[6][3][0]))&&C(me,"x1",De),(!ee||_&64&&it!==(it=n[6][3][1]))&&C(me,"y1",it),(!ee||_&64&&Je!==(Je=n[6][0][0]))&&C(me,"x2",Je),(!ee||_&64&&ht!==(ht=n[6][0][1]))&&C(me,"y2",ht);const M={};_&64&&(M.x=n[6][0][0]),_&64&&(M.y=n[6][0][1]),_&8&&(M.scale=n[3]),I.$set(M);const F={};_&64&&(F.x=n[6][1][0]),_&64&&(F.y=n[6][1][1]),_&8&&(F.scale=n[3]),K.$set(F);const Z={};_&64&&(Z.x=n[6][2][0]),_&64&&(Z.y=n[6][2][1]),_&8&&(Z.scale=n[3]),he.$set(Z);const ne={};_&64&&(ne.x=n[6][3][0]),_&64&&(ne.y=n[6][3][1]),_&8&&(ne.scale=n[3]),ye.$set(ne)},i(Q){ee||(Xe(P.$$.fragment,Q),Xe(I.$$.fragment,Q),Xe(K.$$.fragment,Q),Xe(he.$$.fragment,Q),Xe(ye.$$.fragment,Q),ee=!0)},o(Q){et(P.$$.fragment,Q),et(I.$$.fragment,Q),et(K.$$.fragment,Q),et(he.$$.fragment,Q),et(ye.$$.fragment,Q),ee=!1},d(Q){Q&&(Se(e),Se(u),Se(c),Se(S),Se(L),Se(N),Se(D),Se(Y),Se(z),Se(re),Se(se),Se(Te),Se(me),Se(w),Se(q),Se(ae),Se(J)),Wt(P),Wt(I,Q),Wt(K,Q),Wt(he,Q),Wt(ye,Q),Ve=!1,ni(Re)}}}function M_(n){let e,t;return e=new ou({props:{shape:n[0],transform:n[2],editor:n[8],svgEl:n[4],$$slots:{default:[I_,({grab:i})=>({16:i}),({grab:i})=>i?65536:0]},$$scope:{ctx:n}}}),e.$on("grab",n[12]),e.$on("change",n[13]),e.$on("release",n[14]),{c(){Kt(e.$$.fragment)},m(i,r){Xt(e,i,r),t=!0},p(i,[r]){const s={};r&1&&(s.shape=i[0]),r&4&&(s.transform=i[2]),r&16&&(s.svgEl=i[4]),r&196842&&(s.$$scope={dirty:r,ctx:i}),e.$set(s)},i(i){t||(Xe(e.$$.fragment,i),t=!0)},o(i){et(e.$$.fragment,i),t=!1}
74,d(i){Wt(e,i)}}}const Kc=n=>`${n[0]},${n[1]}`,Jc=n=>`${n[0]},${n[1]}`,Qc=n=>`${n[0]},${n[1]}`;function D_(n,e,t){let i,r,s,o,a,{shape:l}=e,{computedStyle:h}=e,{transform:u}=e,{viewportScale:c=1}=e,{svgEl:d}=e,f=!1;const p=(y,E,R)=>{let{x:P,y:S,w:L,h:k,rot:W=0}=y.geometry;const[j,V]=R;if(E==="ROTATION"){const D=Zc(y.geometry,i),A=D[0]+j,O=D[1]+V,B=[P+L/2,S+k/2];W+=P_([D[0],D[1]],[A,O],B),f&&(W=C_(W));const G=2*Math.PI;W=(W%G+G)%G}else if(E==="SHAPE")P+=j,S+=V;else{let D=0,A=0,O=L,B=k;const[G,Y]=W!==0?R_(j,V,W):[j,V];switch(E){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":A+=Y;break;case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":B+=Y;break}switch(E){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":D+=G;break;case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":O+=G;break}const z=(D+O)/2,b=(A+B)/2;L=Math.abs(O-D),k=Math.abs(B-A);const H=[P+y.geometry.w/2,S+y.geometry.h/2],X=[z-y.geometry.w/2,b-y.geometry.h/2],$=Math.cos(W),re=Math.sin(W),se=H[0]+X[0]*$-X[1]*re,ce=H[1]+X[0]*re+X[1]*$;P=se-L/2,S=ce-k/2}const N=Jt(s);return{...y,geometry:{x:P,y:S,w:L,h:k,rot:W,bounds:N}}};Fs(()=>{const y=R=>{R.key==="Shift"&&(f=!0)},E=R=>{R.key==="Shift"&&(f=!1)};return window.addEventListener("keydown",y),window.addEventListener("keyup",E),()=>{window.removeEventListener("keydown",y),window.removeEventListener("keyup",E)}});const g=`rect-mask-${Math.random().toString(36).substring(2,12)}`;function v(y){_t.call(this,n,y)}function m(y){_t.call(this,n,y)}function x(y){_t.call(this,n,y)}return n.$$set=y=>{"shape"in y&&t(0,l=y.shape),"computedStyle"in y&&t(1,h=y.computedStyle),"transform"in y&&t(2,u=y.transform),"viewportScale"in y&&t(3,c=y.viewportScale),"svgEl"in y&&t(4,d=y.svgEl)},n.$$.update=()=>{n.$$.dirty&8&&t(11,i=20/c),n.$$.dirty&1&&t(10,r=l.geometry),n.$$.dirty&1024&&t(6,s=A_(r.x,r.y,r.w,r.h,r.rot)),n.$$.dirty&3072&&t(7,o=Zc(r,i)),n.$$.dirty&1032&&t(5,a=ma(r.bounds,5/c))},[l,h,u,c,d,a,s,o,p,g,r,i,v,m,x]}class O_ extends yn{constructor(e){super(),vn(this,e,D_,M_,mn,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4})}}var ed=Object.prototype.hasOwnProperty;function eh(n,e){var t,i;if(n===e)return!0;if(n&&e&&(t=n.constructor)===e.constructor){if(t===Date)return n.getTime()===e.getTime();if(t===RegExp)return n.toString()===e.toString();if(t===Array){if((i=n.length)===e.length)for(;i--&&eh(n[i],e[i]););return i===-1}if(!t||typeof n=="object"){i=0;for(t in n)if(ed.call(n,t)&&++i&&!ed.call(e,t)||!(t in e)||!eh(n[t],e[t]))return!1;return Object.keys(e).length===i}}return n!==n&&e!==e}const L_=12,B_=(n,e)=>n.polygons.reduce((t,i,r)=>{const s=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,g=Math.sqrt(Math.pow(d[0]-f,2)+Math.pow(d[1]-p,2))>L_/e;return{point:[f,p],visible:g,elementIdx:r,ringIdx:l,pointIdx:c}});return[...o,...h]},[]);return[...t,...s]},[]);function Ja(n){const e=n.slice(),t=e[10][e[6]];return e[29]=t.point,e}function td(n,e,t){const i=n.slice();return i[30]=e[t],i[32]=t,i}function id(n,e,t){const i=n.slice();return i[33]=e[t],i[35]=t,i}function nd(n,e,t){const i=n.slice();return i[29]=e[t],i[37]=t,i}function Qa(n){const e=n.slice(),t=e[10][e[6]];return e[29]=t.point,e}function el(n){const e=n.slice(),t=e[10][e[6]];return e[29]=t.point,e}function rd(n){let e,t,i,r;return{c(){e=ve("circle"),C(e,"cx",t=n[29][0]),C(e,"cy",i=n[29][1]),C(e,"r",r=bs/n[3]),C(e,"class","svelte-1vxo6dc")},m(s,o){Ae(s,e,o)},p(s,o){o[0]&1088&&t!==(t=s[29][0])&&C(e,"cx",t),o[0]&1088&&i!==(i=s[29][1])&&C(e,"cy",i),o[0]&8&&r!==(r=bs/s[3])&&C(e,"r",r)},d(s){s&&Se(e)}}}function sd(n){let e,t,i,r,s,o,a,l,h,u;return{c(){e=ve("mask"),t=ve("rect"),a=ve("circle"),C(t,"x",i=n[9].x),C(t,"y",r=n[9].y),C(t,"width",s=n[9].w),C(t,"height",o=n[9].h),C(t,"class","svelte-1vxo6dc"),C(a,"cx",l=n[29][0]),C(a,"cy",h=n[29][1]),C(a,"r",u=bs/n[3]),C(a,"class","svelte-1vxo6dc"),C(e,"id",`${n[18]}-${n[32]}-inner`),C(e,"class","a9s-multipolygon-editor-mask svelte-1vxo6dc")},m(c,d){Ae(c,e,d),Ge(e,t),Ge(e,a)},p(c,d){d[0]&512&&i!==(i=c[9].x)&&C(t,"x",i),d[0]&512&&r!==(r=c[9].y)&&C(t,"y",r),d[0]&512&&s!==(s=c[9].w)&&C(t,"width",s),d[0]&512&&o!==(o=c[9].h)&&C(t,"height",o),d[0]&1088&&l!==(l=c[29][0])&&C(a,"cx",l),d[0]&1088&&h!==(h=c[29][1])&&C(a,"cy",h),d[0]&8&&u!==(u=bs/c[3])&&C(a,"r",u)},d(c){c&&Se(e)}}}function od(n){let e,t;function i(...r){return n[19](n[32],n[35],n[37],...r)}return e=new In({props:{class:"a9s-corner-handle",x:n[29][0],y:n[29][1],scale:n[3],selected:n[8].some(i)}}),e.$on("pointerenter",n[11]),e.$on("pointerleave",n[12]),e.$on("pointerdown",n[14]),e.$on("pointerdown",function(){ct(n[28](`HANDLE-${n[32]}-${n[35]}-${n[37]}`))&&n[28](`HANDLE-${n[32]}-${n[35]}-${n[37]}`).apply(this,arguments)}),e.$on("pointerup",n[15](n[32],n[35],n[37])),{c(){Kt(e.$$.fragment)},m(r,s){Xt(e,r,s),t=!0},p(r,s){n=r;const o={};
74s[0]&32&&(o.x=n[29][0]),s[0]&32&&(o.y=n[29][1]),s[0]&8&&(o.scale=n[3]),s[0]&256&&(o.selected=n[8].some(i)),e.$set(o)},i(r){t||(Xe(e.$$.fragment,r),t=!0)},o(r){et(e.$$.fragment,r),t=!1},d(r){Wt(e,r)}}}function ad(n){let e,t,i=cn(n[33].points),r=[];for(let o=0;o<i.length;o+=1)r[o]=od(nd(n,i,o));const s=o=>et(r[o],1,1,()=>{r[o]=null});return{c(){for(let o=0;o<r.length;o+=1)r[o].c();e=zr()},m(o,a){for(let l=0;l<r.length;l+=1)r[l]&&r[l].m(o,a);Ae(o,e,a),t=!0},p(o,a){if(a[0]&268491048){i=cn(o[33].points);let l;for(l=0;l<i.length;l+=1){const h=nd(o,i,l);r[l]?(r[l].p(h,a),Xe(r[l],1)):(r[l]=od(h),r[l].c(),Xe(r[l],1),r[l].m(e.parentNode,e))}for(Dr(),l=i.length;l<r.length;l+=1)s(l);Or()}},i(o){if(!t){for(let a=0;a<i.length;a+=1)Xe(r[a]);t=!0}},o(o){r=r.filter(Boolean);for(let a=0;a<r.length;a+=1)et(r[a]);t=!1},d(o){o&&Se(e),ga(r,o)}}}function ld(n){let e,t,i,r,s,o,a,l,h,u,c,d,f,p,g,v,m,x=n[6]!==void 0&&!n[7]&&rd(el(n)),y=n[6]!==void 0&&!n[7]&&sd(Qa(n)),E=cn(n[30].rings),R=[];for(let S=0;S<E.length;S+=1)R[S]=ad(id(n,E,S));const P=S=>et(R[S],1,1,()=>{R[S]=null});return{c(){e=ve("g"),t=ve("defs"),i=ve("mask"),r=ve("rect"),h=ve("path"),x&&x.c(),y&&y.c(),c=ve("path"),f=ve("path");for(let S=0;S<R.length;S+=1)R[S].c();C(r,"x",s=n[9].x),C(r,"y",o=n[9].y),C(r,"width",a=n[9].w),C(r,"height",l=n[9].h),C(r,"class","svelte-1vxo6dc"),C(h,"d",u=Ki(n[30])),C(h,"class","svelte-1vxo6dc"),C(i,"id",`${n[18]}-${n[32]}-outer`),C(i,"class","a9s-multipolygon-editor-mask svelte-1vxo6dc"),C(c,"class","a9s-outer"),C(c,"mask",`url(#${n[18]}-${n[32]}-outer)`),C(c,"fill-rule","evenodd"),C(c,"d",d=Ki(n[30])),C(f,"class","a9s-inner"),C(f,"mask",`url(#${n[18]}-${n[32]}-inner)`),C(f,"style",n[1]),C(f,"fill-rule","evenodd"),C(f,"d",p=Ki(n[30]))},m(S,L){Ae(S,e,L),Ge(e,t),Ge(t,i),Ge(i,r),Ge(i,h),x&&x.m(i,null),y&&y.m(t,null),Ge(e,c),Ge(e,f);for(let k=0;k<R.length;k+=1)R[k]&&R[k].m(e,null);g=!0,v||(m=[Ye(c,"pointerup",n[13]),Ye(c,"pointerdown",function(){ct(n[28]("SHAPE"))&&n[28]("SHAPE").apply(this,arguments)}),Ye(f,"pointerup",n[13]),Ye(f,"pointerdown",function(){ct(n[28]("SHAPE"))&&n[28]("SHAPE").apply(this,arguments)})],v=!0)},p(S,L){if(n=S,(!g||L[0]&512&&s!==(s=n[9].x))&&C(r,"x",s),(!g||L[0]&512&&o!==(o=n[9].y))&&C(r,"y",o),(!g||L[0]&512&&a!==(a=n[9].w))&&C(r,"width",a),(!g||L[0]&512&&l!==(l=n[9].h))&&C(r,"height",l),(!g||L[0]&32&&u!==(u=Ki(n[30])))&&C(h,"d",u),n[6]!==void 0&&!n[7]?x?x.p(el(n),L):(x=rd(el(n)),x.c(),x.m(i,null)):x&&(x.d(1),x=null),n[6]!==void 0&&!n[7]?y?y.p(Qa(n),L):(y=sd(Qa(n)),y.c(),y.m(t,null)):y&&(y.d(1),y=null),(!g||L[0]&32&&d!==(d=Ki(n[30])))&&C(c,"d",d),(!g||L[0]&2)&&C(f,"style",n[1]),(!g||L[0]&32&&p!==(p=Ki(n[30])))&&C(f,"d",p),L[0]&268491048){E=cn(n[30].rings);let k;for(k=0;k<E.length;k+=1){const W=id(n,E,k);R[k]?(R[k].p(W,L),Xe(R[k],1)):(R[k]=ad(W),R[k].c(),Xe(R[k],1),R[k].m(e,null))}for(Dr(),k=E.length;k<R.length;k+=1)P(k);Or()}},i(S){if(!g){for(let L=0;L<E.length;L+=1)Xe(R[L]);g=!0}},o(S){R=R.filter(Boolean);for(let L=0;L<R.length;L+=1)et(R[L]);g=!1},d(S){S&&Se(e),x&&x.d(),y&&y.d(),ga(R,S),v=!1,ni(m)}}}function hd(n){let e,t;return e=new Zp({props:{x:n[29][0],y:n[29][1],scale:n[3]}}),e.$on("pointerdown",function(){ct(n[17](n[6]))&&n[17](n[6]).apply(this,arguments)}),{c(){Kt(e.$$.fragment)},m(i,r){Xt(e,i,r),t=!0},p(i,r){n=i;const s={};r[0]&1088&&(s.x=n[29][0]),r[0]&1088&&(s.y=n[29][1]),r[0]&8&&(s.scale=n[3]),e.$set(s)},i(i){t||(Xe(e.$$.fragment,i),t=!0)},o(i){et(e.$$.fragment,i),t=!1},d(i){Wt(e,i)}}}function F_(n){let e,t,i,r=cn(n[5].polygons),s=[];for(let l=0;l<r.length;l+=1)s[l]=ld(td(n,r,l));const o=l=>et(s[l],1,1,()=>{s[l]=null});let a=n[6]!==void 0&&!n[7]&&hd(Ja(n));return{c(){for(let l=0;l<s.length;l+=1)s[l].c();e=Bt(),a&&a.c(),t=zr()},m(l,h){for(let u=0;u<s.length;u+=1)s[u]&&s[u].m(l,h);Ae(l,e,h),a&&a.m(l,h),Ae(l,t,h),i=!0},p(l,h){if(h[0]&268763114){r=cn(l[5].polygons);let u;for(u=0;
74u<r.length;u+=1){const c=td(l,r,u);s[u]?(s[u].p(c,h),Xe(s[u],1)):(s[u]=ld(c),s[u].c(),Xe(s[u],1),s[u].m(e.parentNode,e))}for(Dr(),u=r.length;u<s.length;u+=1)o(u);Or()}l[6]!==void 0&&!l[7]?a?(a.p(Ja(l),h),h[0]&192&&Xe(a,1)):(a=hd(Ja(l)),a.c(),Xe(a,1),a.m(t.parentNode,t)):a&&(Dr(),et(a,1,1,()=>{a=null}),Or())},i(l){if(!i){for(let h=0;h<r.length;h+=1)Xe(s[h]);Xe(a),i=!0}},o(l){s=s.filter(Boolean);for(let h=0;h<s.length;h+=1)et(s[h]);et(a),i=!1},d(l){l&&(Se(e),Se(t)),ga(s,l),a&&a.d(l)}}}function N_(n){let e,t;return e=new ou({props:{shape:n[0],transform:n[2],editor:n[16],svgEl:n[4],$$slots:{default:[F_,({grab:i})=>({28:i}),({grab:i})=>[i?268435456:0]]},$$scope:{ctx:n}}}),e.$on("change",n[20]),e.$on("grab",n[21]),e.$on("release",n[22]),{c(){Kt(e.$$.fragment)},m(i,r){Xt(e,i,r),t=!0},p(i,r){const s={};r[0]&1&&(s.shape=i[0]),r[0]&4&&(s.transform=i[2]),r[0]&16&&(s.svgEl=i[4]),r[0]&268437482|r[1]&128&&(s.$$scope={dirty:r,ctx:i}),e.$set(s)},i(i){t||(Xe(e.$$.fragment,i),t=!0)},o(i){et(e.$$.fragment,i),t=!1},d(i){Wt(e,i)}}}const k_=250,U_=1e3,bs=4.5;function H_(n,e,t){let i,r,s;const o=Ns();let{shape:a}=e,{computedStyle:l}=e,{transform:h}=e,{viewportScale:u=1}=e,{svgEl:c}=e,d,f=!1,p,g=[];const v=()=>t(7,f=!0),m=()=>t(7,f=!1),x=A=>{if(g.length>0||!r.some(H=>H.visible)){t(6,d=void 0);return}const[O,B]=h.elementToImage(A.offsetX,A.offsetY),G=H=>Math.pow(H[0]-O,2)+Math.pow(H[1]-B,2),Y=L0(i).reduce((H,X)=>G(X)<G(H)?X:H),z=r.filter(H=>H.visible).reduce((H,X)=>G(X.point)<G(H.point)?X:H),b=Math.pow(U_/u,2);G(Y)<b||G(z.point)<b?t(6,d=r.indexOf(z)):t(6,d=void 0)},y=()=>{document.activeElement!==c&&c.focus()},E=()=>{t(8,g=[]),y()},R=A=>{t(7,f=!0),A.preventDefault(),A.stopPropagation(),p=performance.now()},P=(A,O,B)=>G=>{if(!p||ti||performance.now()-p>k_)return;const Y=b=>b.polygon===A&&b.ring===O&&b.point===B,z=g.some(Y);G.metaKey||G.ctrlKey||G.shiftKey?z?t(8,g=g.filter(b=>!Y(b))):t(8,g=[...g,{polygon:A,ring:O,point:B}]):z&&g.length>1?t(8,g=[{polygon:A,ring:O,point:B}]):z?t(8,g=[]):t(8,g=[{polygon:A,ring:O,point:B}]),y()},S=(A,O,B)=>{y();const G=A.geometry.polygons;let Y;if(O==="SHAPE")Y=G.map(z=>{const b=z.rings.map((X,$)=>({points:X.points.map((re,se)=>[re[0]+B[0],re[1]+B[1]])})),H=Jt(b[0].points);return{rings:b,bounds:H}});else{const[z,b,H,X]=O.split("-").map($=>parseInt($));Y=G.map(($,re)=>{if(re===b){const se=$.rings.map((ie,ge)=>ge===H?{points:ie.points.map((de,Te)=>Te===X?[de[0]+B[0],de[1]+B[1]]:de)}:ie),ce=Jt(se[0].points);return{rings:se,bounds:ce}}else return $})}return{...A,geometry:{polygons:Y,bounds:Wa(Y)}}},L=A=>async O=>{O.stopPropagation();const B=r[A],G=i.polygons.map((z,b)=>{if(b===B.elementIdx){const H=z.rings.map(($,re)=>re===B.ringIdx?{points:[...$.points.slice(0,B.pointIdx+1),B.point,...$.points.slice(B.pointIdx+1)]}:$),X=Jt(H[0].points);return{rings:H,bounds:X}}else return z});o("change",{...a,geometry:{polygons:G,bounds:Wa(G)}}),await Wp();const Y=[...document.querySelectorAll(".a9s-handle")][A+1];if(Y!=null&&Y.firstChild){const z=new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:O.clientX,clientY:O.clientY,pointerId:O.pointerId,pointerType:O.pointerType,isPrimary:O.isPrimary,buttons:O.buttons});Y.firstChild.dispatchEvent(z)}},k=()=>{const A=i.polygons.map((O,B)=>{if(g.some(G=>G.polygon===B)){const G=O.rings.map((z,b)=>{const H=g.filter(X=>X.polygon===B&&X.ring===b);return H.length&&z.points.length-H.length>=3?{points:z.points.filter((X,$)=>!H.some(re=>re.point===$))}:z}),Y=Jt(G[0].points);return{rings:G,bounds:Y}}else return O});!eh(i.polygons,A)&&(o("change",{...a,geometry:{polygons:A,bounds:Wa(A)}}),t(8,g=[]))};Fs(()=>{if(ti)return;const A=O=>{(O.key==="Delete"||O.key==="Backspace")&&(O.preventDefault(),k())};return c.addEventListener("pointermove",x),c.addEventListener("keydown",A),()=>{c.removeEventListener("pointermove",x),c.removeEventListener("keydown",A)}});const W=`polygon-mask-${Math.random().toString(36).substring(2,12)}`,j=(A,O,B,{polygon:G,ring:Y,point:z})=>G===A&&Y===O&&z===B;function V(A){_t.call(this,n,A)}function N(A){_t.call(this,n,A)}function D(A){_t.call(this,n,A)}return n.$$set=A=>{"shape"in A&&t(0,a=A.shape),"computedStyle"in A&&t(1,l=A.computedStyle),"transform"in A&&t(2,h=A.transform),"viewportScale"in A&&t(3,u=A.viewportScale),"svgEl"in A&&t(4,c=A.svgEl)},n.$$.update=()=>{n.$$.dirty[0]&1&&t(5,i=a.geometry),n.$$.dirty[0]&40&&t(10,r=ti?[]:B_(i,u)),n.$$.dirty[0]&40&&t(9,s=ma(i.bounds,bs/u))},[a,l,h,u,c,i,d,f,g,s,r,v,m,E,R,P,S,L,W,j,V,N,D]}class G_ extends yn{constructor(e){super(),vn(this,e,H_,N_,mn,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}const Jp=new Map([[$e.RECTANGLE,O_],[$e.POLYGON,S_],[$e.MULTIPOLYGON,G_]]),Qp=n=>Jp.get(n.type),z_=(n,e)=>Jp.set(n,e);function ud(n){let e,t,i,r,s,o,a,l,h,u;return{c(){e=ve("defs"),t=ve("mask"),i=ve("rect"),l=ve("rect"),h=ve("rect"),u=ve("rect"),C(i,"class","rect-mask-bg svelte-1a76qe7"),C(i,"x",r=n[1]-n[5]),C(i,"y",s=n[2]-n[5]),C(i,"width",o=n[3]+2*n[5]),C(i,"height",a=n[4]+2*n[5]),C(l,"class","rect-mask-fg svelte-1a76qe7"),C(l,"x",n[1]),C(l,"y",n[2]),C(l,"width",n[3]),C(l,"height",n[4]),C(t,"id",n[6]),C(t,"class","a9s-rubberband-rectangle-mask svelte-1a76qe7"),C(h,"class","a9s-outer"),C(h,"mask",`url(#${n[6]})`),C(h,"x",n[1]),C(h,"y",n[2]),C(h,"width",n[3]),C(h,"height",n[4]),C(u,"class","a9s-inner"),C(u,"x",n[1]),C(u,"y",n[2]),C(u,"width",n[3]),C(u,"height",n[4])},m(c,d){Ae(c,e,d),Ge(e,t),Ge(t,i),Ge(t,l),Ae(c,h,d),Ae(c,u,d)},p(c,d){d&34&&r!==(r=c[1]-c[5])&&C(i,"x",r),d&36&&s!==(s=c[2]-c[5])&&C(i,"y",s),d&40&&o!==(o=c[3]+2*c[5])&&C(i,"width",o),d&48&&a!==(a=c[4]+2*c[5])&&C(i,"height",a),d&2&&C(l,"x",c[1]),d&4&&C(l,"y",c[2]),d&8&&C(l,"width",c[3]),d&16&&C(l,"height",c[4]),d&2&&C(h,"x",c[1]),d&4&&C(
74h,"y",c[2]),d&8&&C(h,"width",c[3]),d&16&&C(h,"height",c[4]),d&2&&C(u,"x",c[1]),d&4&&C(u,"y",c[2]),d&8&&C(u,"width",c[3]),d&16&&C(u,"height",c[4])},d(c){c&&(Se(e),Se(h),Se(u))}}}function V_(n){let e,t=n[0]&&ud(n);return{c(){e=ve("g"),t&&t.c(),C(e,"class","a9s-annotation a9s-rubberband")},m(i,r){Ae(i,e,r),t&&t.m(e,null)},p(i,[r]){i[0]?t?t.p(i,r):(t=ud(i),t.c(),t.m(e,null)):t&&(t.d(1),t=null)},i:pi,o:pi,d(i){i&&Se(e),t&&t.d()}}}function j_(n,e,t){let i;const r=Ns();let{addEventListener:s}=e,{drawingMode:o}=e,{transform:a}=e,{viewportScale:l=1}=e,h,u,c,d,f,p,g;const v=R=>{const P=R;h=performance.now(),o==="drag"&&(t(0,u=a.elementToImage(P.offsetX,P.offsetY)),c=u,t(1,d=u[0]),t(2,f=u[1]),t(3,p=1),t(4,g=1))},m=R=>{const P=R;u&&(c=a.elementToImage(P.offsetX,P.offsetY),t(1,d=Math.min(c[0],u[0])),t(2,f=Math.min(c[1],u[1])),t(3,p=Math.abs(c[0]-u[0])),t(4,g=Math.abs(c[1]-u[1])))},x=R=>{const P=R,S=performance.now()-h;if(o==="click"){if(S>300)return;u?y():(t(0,u=a.elementToImage(P.offsetX,P.offsetY)),c=u,t(1,d=u[0]),t(2,f=u[1]),t(3,p=1),t(4,g=1))}else u&&(S>300||p*g>
74100?(P.stopPropagation(),y()):(t(0,u=void 0),c=void 0))},y=()=>{if(p*g>15){const R={type:$e.RECTANGLE,geometry:{bounds:{minX:d,minY:f,maxX:d+p,maxY:f+g},rot:0,x:d,y:f,w:p,h:g}};r("create",R)}t(0,u=void 0),c=void 0};Fs(()=>{s("pointerdown",v),s("pointermove",m),s("pointerup",x,!0)});const E=`rect-mask-${Math.random().toString(36).substring(2,12)}`;return n.$$set=R=>{"addEventListener"in R&&t(7,s=R.addEventListener),"drawingMode"in R&&t(8,o=R.drawingMode),"transform"in R&&t(9,a=R.transform),"viewportScale"in R&&t(10,l=R.viewportScale)},n.$$.update=()=>{n.$$.dirty&1024&&t(5,i=2/l)},[u,d,f,p,g,i,E,s,o,a,l]}class X_ extends yn{constructor(e){super(),vn(this,e,j_,V_,mn,{addEventListener:7,drawingMode:8,transform:9,viewportScale:10})}}function tl(n){const e=n.slice(),t=e[2].map(i=>i.join(",")).join(" ");return e[19]=t,e}function cd(n){let e,t,i,r,s,o,a,l,h,u,c,d,f,p,g=n[1]&&dd(n);return{c(){e=ve("defs"),t=ve("mask"),i=ve("rect"),l=ve("polygon"),u=ve("polygon"),d=ve("polygon"),g&&g.c(),p=zr(),C(i,"x",r=n[3].x),C(i,"y",s=n[3].y),C(i,"width",o=n[3].w),C(i,"height",a=n[3].h),C(i,"class","svelte-18wrg3t"),C(l,"points",h=n[19]),C(l,"class","svelte-18wrg3t"),C(t,"id",n[5]),C(t,"class","a9s-rubberband-polygon-mask svelte-18wrg3t"),C(u,"class","a9s-outer"),C(u,"mask",`url(#${n[5]})`),C(u,"points",c=n[19]),C(d,"class","a9s-inner"),C(d,"points",f=n[19])},m(v,m){Ae(v,e,m),Ge(e,t),Ge(t,i),Ge(t,l),Ae(v,u,m),Ae(v,d,m),g&&g.m
74(v,m),Ae(v,p,m)},p(v,m){m&8&&r!==(r=v[3].x)&&C(i,"x",r),m&8&&s!==(s=v[3].y)&&C(i,"y",s),m&8&&o!==(o=v[3].w)&&C(i,"width",o),m&8&&a!==(a=v[3].h)&&C(i,"height",a),m&4&&h!==(h=v[19])&&C(l,"points",h),m&4&&c!==(c=v[19])&&C(u,"points",c),m&4&&f!==(f=v[19])&&C(d,"points",f),v[1]?g?g.p(v,m):(g=dd(v),g.c(),g.m(p.parentNode,p)):g&&(g.d(1),g=null)},d(v){v&&(Se(e),Se(u),Se(d),Se(p)),g&&g.d(v)}}}function dd(n){let e,t,i;return{c(){e=ve("circle"),C(e,"class","a9s-handle svelte-18wrg3t"),C(e,"cx",t=n[0][0][0]),C(e,"cy",i=n[0][0][1]),C(e,"r",n[4])},m(r,s){Ae(r,e,s)},p(r,s){s&1&&t!==(t=r[0][0][0])&&C(e,"cx",t),s&1&&i!==(i=r[0][0][1])&&C(e,"cy",i),s&16&&C(e,"r",r[4])},d(r){r&&Se(e)}}}function W_(n){let e,t=n[3]&&cd(tl(n));return{c(){e=ve("g"),t&&t.c(),C(e,"class","a9s-annotation a9s-rubberband")},m(i,r){Ae(i,e,r),t&&t.m(e,null)},p(i,[r]){i[3]?t?t.p(tl(i),r):(t=cd(tl(i)),t.c(),t.m(e,null)):t&&(t.d(1),t=null)},i:pi,o:pi,d(i){i&&Se(e),t&&t.d()}}}const Y_=20,q_=1500;function $_(n,e,t){let i,r,s;const o=Ns();let{addEventListener:a}=e,{drawingMode:l}=e,{transform:h}=e,{viewportScale:u=1}=e,c,d=[],f,p,g=!1;const v=P=>{const S=P,{timeStamp:L,offsetX:k,offsetY:W}=S;if(c={timeStamp:L,offsetX:k,offsetY:W},l==="drag"&&d.length===0){const j=h.elementToImage(S.offsetX,S.offsetY);d.push(j),t(10,f=j)}},m=P=>{const S=P;if(p&&clearTimeout(p),d.length>0){if(t(10,f=h.elementToImage(S.offsetX,S.offsetY)),d.length>2){const L=To(f,d[0])*u;t(1,g=L<Y_)}S.pointerType==="touch"&&(p=setTimeout(()=>{y()},q_))}},x=P=>{const S=P;if(p&&clearTimeout(p),l==="click"){const L=S.timeStamp-c.timeStamp,k=To([c.offsetX,c.offsetY],[S.offsetX,S.offsetY]);if(L>300||k>15)return;if(g)E();else if(d.length===0){const W=h.elementToImage(S.offsetX,S.offsetY);d.push(W),t(10,f=W)}else f&&d.push(f)}else{if(!f)return;if(d.length===1&&To(d[0],f)<=4){t(0,d=[]),t(10,f=void 0);return}S.stopImmediatePropagation(),g?E():d.push(f)}},y=()=>{if(!f)return;const P=d.slice(0,-1);if(P.length<3)return;const S={type:$e.POLYGON,geometry:{bounds:Jt(d),points:P}};Jl(S)>4&&(t(0,d=[]),t(10,f=void 0),o("create",S))},E=()=>{const P={type:$e.POLYGON,geometry:{bounds:Jt(d),points:[...d]}};t(0,d=[]),t(10,f=void 0),o("create",P)};Fs(()=>{a("pointerdown",v,!0),a("pointermove",m),a("pointerup",x,!0),a("dblclick",y,!0)});const R=`polygon-mask-${Math.random().toString(36).substring(2,12)}`;return n.$$set=P=>{"addEventListener"in P&&t(6,a=P.addEventListener),"drawingMode"in P&&t(7,l=P.drawingMode),"transform"in P&&t(8,h=P.transform),"viewportScale"in P&&t(9,u=P.viewportScale)},n.$$.update=()=>{n.$$.dirty&512&&t(4,i=4/u),n.$$.dirty&1027&&t(2,r=f?g?d:[...d,f]:[]),n.$$.dirty&516&&t(3,s=r.length>0?ma(Jt(r),2/u):void 0)},[d,g,r,s,i,R,a,l,h,u,f]}class Z_ extends yn{constructor(e){super(),vn(this,e,$_,W_,mn,{addEventListener:6,drawingMode:7,transform:8,viewportScale:9})}}const au=new Map([["rectangle",{tool:X_}],["polygon",{tool:Z_}]]),eg=()=>[...au.keys()],tg=n=>au.get(n),K_=(n,e,t={})=>au.set(n,{tool:e,opts:t});function ig(n,e,t=0,i=n.length-1,r=J_){for(;i>t;){if(i-t>600){const l=i-t+1,h=e-t+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(t,Math.floor(e-h*c/l+d)),p=Math.min(i,Math.floor(e+(l-h)*c/l+d));ig(n,e,f,p,r)}const s=n[e];let o=t,a=i;for($r(n,t,e),r(n[i],s)>0&&$r(n,t,i);o<a;){for($r(n,o,a),o++,a--;r(n[o],s)<0;)o++;for(;r(n[a],s)>0;)a--}r(n[t],s)===0?$r(n,t,a):(a++,$r(n,a,i)),a<=e&&(t=a+1),e<=a&&(i=a-1)}}function $r(n,e,t){const i=n[e];n[e]=n[t],n[t]=i}function J_(n,e){return n<e?-1:n>e?1:0}class Q_{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data;const i=[];if(!qs(e,t))return i;const r=this.toBBox,s=[];for(;t;){for(let o=0;o<t.children.length;o++){const a=t.children[o],l=t.leaf?r(a):a;qs(e,l)&&(t.leaf?i.push(a):nl(e,l)?this._all(a,i):s.push(a))}t=s.pop()}return i}collides(e){let t=this.data;if(!qs(e,t))return!1;const i=[];for(;t;){for(let r=0;r<t.children.length;r++){const s=t.children[r],o=t.leaf?this.toBBox(s):s;
vendor: 5,017 bytes, line 74
74if(qs(e,o)){if(t.leaf||nl(e,o))return!0;i.push(s)}}t=i.pop()}return!1}load(e){if(!(e&&e.length))return this;if(e.length<this._minEntries){for(let i=0;i<e.length;i++)this.insert(e[i]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(!this.data.children.length)this.data=t;else if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){const i=this.data;this.data=t,t=i}this._insert(t,this.data.height-t.height-1,!0)}return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=ar([]),this}remove(e,t){if(!e)return this;let i=this.data;const r=this.toBBox(e),s=[],o=[];let a,l,h;for(;i||s.length;){if(i||(i=s.pop(),l=s[s.length-1],a=o.pop(),h=!0),i.leaf){const u=ew(e,i.children,t);if(u!==-1)return i.children.splice(u,1),s.push(i),this._condense(s),this}!h&&!i.leaf&&nl(i,r)?(s.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(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){const i=[];for(;e;)e.leaf?t.push(...e.children):i.push(...e.children),e=i.pop();return t}_build(e,t,i,r){const s=i-t+1;let o=this._maxEntries,a;if(s<=o)return a=ar(e.slice(t,i+1)),Qn(a,this.toBBox),a;r||(r=Math.ceil(Math.log(s)/Math.log(o)),o=Math.ceil(s/Math.pow(o,r-1))),a=ar([]),a.leaf=!1,a.height=r;const l=Math.ceil(s/o),h=l*Math.ceil(Math.sqrt(o));fd(e,t,i,h,this.compareMinX);for(let u=t;u<=i;u+=h){const c=Math.min(u+h-1,i);fd(e,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(e,d,f,r-1))}}return Qn(a,this.toBBox),a}_chooseSubtree(e,t,i,r){for(;r.push(t),!(t.leaf||r.length-1===i);){let s=1/0,o=1/0,a;for(let l=0;l<t.children.length;l++){const h=t.children[l],u=il(h),c=nw(e,h)-u;c<o?(o=c,s=u<s?u:s,a=h):c===o&&u<s&&(s=u,a=h)}t=a||t.children[0]}return t}_insert(e,t,i){const r=i?e:this.toBBox(e),s=[],o=this._chooseSubtree(r,this.data,t,s);for(o.children.push(e),ns(o,r);t>=0&&s[t].children.length>this._maxEntries;)this._split(s,t),t--;this._adjustParentBBoxes(r,s,t)}_split(e,t){const i=e[t],r=i.children.length,s=this._minEntries;this._chooseSplitAxis(i,s,r);const o=this._chooseSplitIndex(i,s,r),a=ar(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,Qn(i,this.toBBox),Qn(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(i,a)}_splitRoot(e,t){this.data=ar([e,t]),this.data.height=e.height+1,this.data.leaf=!1,Qn(this.data,this.toBBox)}_chooseSplitIndex(e,t,i){let r,s=1/0,o=1/0;for(let a=t;a<=i-t;a++){const l=is(e,0,a,this.toBBox),h=is(e,a,i,this.toBBox),u=rw(l,h),c=il(l)+il(h);u<s?(s=u,r=a,o=c<o?c:o):u===s&&c<o&&(o=c,r=a)}return r||i-t}_chooseSplitAxis(e,t,i){const r=e.leaf?this.compareMinX:tw,s=e.leaf?this.compareMinY:iw,o=this._allDistMargin(e,t,i,r),a=this._allDistMargin(e,t,i,s);o<a&&e.children.sort(r)}_allDistMargin(e,t,i,r){e.children.sort(r);const s=this.toBBox,o=is(e,0,t,s),a=is(e,i-t,i,s);let l=Ys(o)+Ys(a);for(let h=t;h<i-t;h++){const u=e.children[h];ns(o,e.leaf?s(u):u),l+=Ys(o)}for(let h=i-t-1;h>=t;h--){const u=e.children[h];ns(a,e.leaf?s(u):u),l+=Ys(a)}return l}_adjustParentBBoxes(e,t,i){for(let r=i;r>=0;r--)ns(t[r],e)}_condense(e){for(let t=e.length-1,i;t>=0;t--)e[t].children.length===0?t>0?(i=e[t-1].children,i.splice(i.indexOf(e[t]),1)):this.clear():Qn(e[t],this.toBBox)}}function ew(n,e,t){if(!t)return e.indexOf(n);for(let i=0;i<e.length;i++)if(t(n,e[i]))return i;return-1}function Qn(n,e){is(n,0,n.children.length,e,n)}function is(n,e,t,i,r){r||(r=ar(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(let s=e;s<t;s++){const o=n.children[s];ns(r,n.leaf?i(o):o)}return r}function ns(n,e){return n.minX=Math.min(n.minX,e.minX),n.minY=Math.min(n.minY,e.minY),n.maxX=Math.max(n.maxX,e.maxX),n.maxY=Math.max(n.maxY,e.maxY),n}function tw(n,e){return n.minX-e.minX}function iw(n,e){return n.minY-e.minY}function il(n){return(n.maxX-n.minX)*(n.maxY-n.minY)}function Ys(n){return n.maxX-n.minX+(n.maxY-n.minY)}function nw(n,e){return(Math.max(e.maxX,n.maxX)-Math.min(e.minX,n.minX))*(Math.max(e.maxY,n.maxY)-Math.min(e.minY,n.minY))}function rw(n,e){const t=Math.max(n.minX,e.minX),i=Math.max(n.minY,e.minY),r=Math.min(n.maxX,e.maxX),s=Math.min(n.maxY,e.maxY);return Math.max(0,r-t)*Math.max(0,s-i)}function nl(n,e){return n.minX<=e.minX&&n.minY<=e.minY&&e.maxX<=n.maxX&&e.maxY<=n.maxY}function qs(n,e){return e.minX<=n.maxX&&e.minY<=n.maxY&&e.maxX>=n.minX&&e.maxY>=n.minY}function ar(n){return{children:n,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function fd(n,e,t,i,r){const s=[e,t];for(;s.length;){if(t=s.pop(),e=s.pop(),t-e<=i)continue;const o=e+Math.ceil((t-e)/i/2)*i;ig(n,o,e,t,r),s.push(e,o,o,t)}}const sw=()=>{const n=new Q_,e=new Map,t=()=>[...e.values()],i=()=>{n.clear(),e.clear()},r=o=>{if(!Eo(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};n.insert(c),e.set(o.annotation,c)},s=o=>
74{if(!Eo(o))return;const a=e.get(o.annotation);a&&n.remove(a),e.delete(o.annotation)};return{all:t,clear:i,getAt:(o,a,l=0)=>{const h=n.search({minX:o-l,minY:a-l,maxX:o+l,maxY:a+l}).map(u=>u.target).filter(({selector:u})=>C0(u,o,a,l));return h.length>0?(h.sort((u,c)=>Jl(u.selector)-Jl(c.selector)),h):[]},getIntersecting:(o,a,l,h)=>n.search({minX:o,minY:a,maxX:o+l,maxY:a+h}).map(u=>u.target),insert:r,remove:s,set:(o,a=!0)=>{a&&i();const l=o.reduce((h,u)=>{if(Eo(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=>e.set(h.target.annotation,h)),n.load(l)},size:()=>n.all().length,update:(o,a)=>{s(o),r(a)}}},ow=n=>{const e=r_(),t=sw(),i=j0(e,n.userSelectAction,n.adapter),r=V0(e),s=s_();e.observe(({changes:a})=>{t.set((a.created||[]).map(l=>l.target),!1),(a.deleted||[]).forEach(l=>t.remove(l.target)),(a.updated||[]).forEach(({oldValue:l,newValue:h})=>t.update(l.target,h.target))});function o(a,l,h,u,c=!1){const d=t.getAt(a,l,u);if(h){const f=d.map(p=>e.getAnnotation(p.annotation)).filter(Boolean).filter(h);return c?f:f[0]}else{if(c)return d.map(f=>e.getAnnotation(f.annotation)).filter(Boolean);{const f=d[0];return f?e.getAnnotation(f.annotation):void 0}}}return{store:{...e,getAt:o,getIntersecting:(a,l,h,u)=>t.getIntersecting(a,l,h,u).map(c=>e.getAnnotation(c.annotation)).filter(Boolean)},selection:i,hover:r,viewport:s}},aw=n=>{let e,t;if(n.nodeName==="CANVAS")e=n,t=e.getContext("2d",{willReadFrequently:!0});else{const r=n;e=document.createElement("canvas"),e.width=r.width,e.height=r.height,t=e.getContext("2d",{willReadFrequently:!0}),t.drawImage(r,0,0,r.width,r.height)}let i=0;for(let r=1;r<10;r++)for(let s=1;s<10;s++){const o=Math.round(s*e.width/10),a=Math.round(r*e.height/10),l=t.getImageData(o,a,1,1).data,h=(.299*l[0]+.587*l[1]+.114*l[2])/255;i+=h}return i/81},lw=n=>{const e=aw(n),t=e>.6?"dark":"light";return console.log(`[Annotorious] Image brightness: ${e.toFixed(1)}. Setting ${t} theme.`),t},hw=(n,e)=>({...n,drawingEnabled:n.drawingEnabled===void 0?e.drawingEnabled:n.drawingEnabled,drawingMode:n.drawingMode||e.drawingMode,userSelectAction:n.userSelectAction||e.userSelectAction,theme:n.theme||e.theme}),pd=typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1,uw=(n,e)=>{const t=e||document,i=o=>{const a=o;a.key==="z"&&a.ctrlKey?n.undo():a.key==="y"&&a.ctrlKey&&n.redo()},r=o=>{const a=o;a.key==="z"&&a.metaKey&&(a.shiftKey?n.redo():n.undo())},s=()=>{pd?t.removeEventListener("keydown",r):t.removeEventListener("keydown",i)};return pd?t.addEventListener("keydown",r):t.addEventListener("keydown",i),{destroy:s}};function ft(){}function cw(n,e){for(const t in e)n[t]=e[t];return n}function ng(n){return n()}function gd(){return Object.create(null)}function ks(n){n.forEach(ng)}function lu(n){return typeof n=="function"}function Et(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function dw(n){return Object.keys(n).length===0}function fw(n,...e){if(n==null){for(const i of e)i(void 0);return ft}const t=n.subscribe(...e);return t.unsubscribe?()=>t.unsubscribe():t}function Ss(n,e,t){n.$$.on_destroy.push(fw(e,t))}function pw(n,e,t,i){if(n){const r=rg(n,e,t,i);return n[0](r)}}function rg(n,e,t,i){return n[1]&&i?cw(t.ctx.slice(),n[1](i(e))):t.ctx}function gw(n,e,t,i){if(n[2]&&i){const r=n[2](i(t));if(e.dirty===void 0)return r;if(typeof r=="object"){const s=[],o=Math.max(e.dirty.length,r.length);for(let a=0;a<o;a+=1)s[a]=e.dirty[a]|r[a];return s}return e.dirty|r}return e.dirty}function mw(n,e,t,i,r,s){if(r){const o=rg(e,t,i,s);n.p(o,r)}}function vw(n){if(n.ctx.length>32){const e=[],t=n.ctx.length/32;for(let i=0;i<t;i++)e[i]=-1;return e}return-1}const hu=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function Ri(n,e){n.appendChild(e)}function at(n,e,t){n.insertBefore(e,t||null)}function nt(n){n.parentNode&&n.parentNode.removeChild(n)}function va(n,e){for(let t=0;t<n.length;t+=1)n[t]&&n[t].d(e)}function ot(n){return document.createElementNS("http://www.w3.org/2000/svg",n)}function sg(n){return document.createTextNode(n)}function Yi(){return sg("")}function yw(n,e,t,i){return n.addEventListener(e,t,i),()=>n.removeEventListener(e,t,i)}function te(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function xw(n){return Array.from(n.childNodes)}function _w(n,e){e=""+e,n.data!==e&&(n.data=e)}function er(n,e,t){n.classList.toggle(e,!!t)}
74function ww(n,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:i})}let As;function fs(n){As=n}function uu(){if(!As)throw new Error("Function called outside component initialization");return As}function Us(n){uu().$$.on_mount.push(n)}function Tw(n){uu().$$.on_destroy.push(n)}function cu(){const n=uu();return(e,t,{cancelable:i=!1}={})=>{const r=n.$$.callbacks[e];if(r){const s=ww(e,t,{cancelable:i});return r.slice().forEach(o=>{o.call(n,s)}),!s.defaultPrevented}return!0}}const lr=[],Vo=[];let wr=[];const md=[],Ew=Promise.resolve();let th=!1;function bw(){th||(th=!0,Ew.then(og))}function ih(n){wr.push(n)}const rl=new Set;let tr=0;function og(){if(tr!==0)return;const n=As;do{try{for(;tr<lr.length;){const e=lr[tr];tr++,fs(e),Sw(e.$$)}}catch(e){throw lr.length=0,tr=0,e}for(fs(null),lr.length=0,tr=0;Vo.length;)Vo.pop()();for(let e=0;e<wr.length;e+=1){const t=wr[e];rl.has(t)||(rl.add(t),t())}wr.length=0}while(lr.length);for(;md.length;)md.pop()();th=!1,rl.clear(),fs(n)}function Sw(n){if(n.fragment!==null){n.update(),ks(n.before_update);const e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(ih)}}function Aw(n){const e=[],t=[];wr.forEach(i=>n.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),wr=e}const bo=new Set;let Ln;function ri(){Ln={r:0,c:[],p:Ln}}function si(){Ln.r||ks(Ln.c),Ln=Ln.p}function Me(n,e){n&&n.i&&(bo.delete(n),n.i(e))}function ke(n,e,t,i){if(n&&n.o){if(bo.has(n))return;bo.add(n),Ln.c.push(()=>{bo.delete(n),i&&(t&&n.d(1),i())}),n.o(e)}else i&&i()}function dn(n){return n?.length!==void 0?n:Array.from(n)}function Nt(n){n&&n.c()}function It(n,e,t){const{fragment:i,after_update:r}=n.$$;i&&i.m(e,t),ih(()=>{const s=n.$$.on_mount.map(ng).filter(lu);n.$$.on_destroy?n.$$.on_destroy.push(...s):ks(s),n.$$.on_mount=[]}),r.forEach(ih)}function Mt(n,e){const t=n.$$;t.fragment!==null&&(Aw(t.after_update),ks(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Rw(n,e){n.$$.dirty[0]===-1&&(lr.push(n),bw(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<<e%31}function Dt(n,e,t,i,r,s,o=null,a=[-1]){const l=As;fs(n);const h=n.$$={fragment:null,ctx:[],props:s,update:ft,not_equal:r,bound:gd(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(l?l.$$.context:[])),callbacks:gd(),dirty:a,skip_bound:!1,root:e.target||l.$$.root};o&&o(h.root);let u=!1;if(h.ctx=t?t(n,e.props||{},(c,d,...f)=>{const p=f.length?f[0]:d;return h.ctx&&r(h.ctx[c],h.ctx[c]=p)&&(!h.skip_bound&&h.bound[c]&&h.bound[c](p),u&&Rw(n,c)),d}):[],h.update(),u=!0,ks(h.before_update),h.fragment=i?i(h.ctx):!1,e.target){if(e.hydrate){const c=xw(e.target);h.fragment&&h.fragment.l(c),c.forEach(nt)}else h.fragment&&h.fragment.c();e.intro&&Me(n.$$.fragment),It(n,e.target,e.anchor),og()}fs(l)}class Ot{constructor(){Pc(this,"$$"),Pc(this,"$$set")}$destroy(){Mt(this,1),this.$destroy=ft}$on(e,t){if(!lu(t))return ft;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}$set(e){this.$$set&&!dw(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Pw="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Pw);var Pi=(n=>(n.ELLIPSE="ELLIPSE",n.MULTIPOLYGON="MULTIPOLYGON",n.POLYGON="POLYGON",n.POLYLINE="POLYLINE",n.RECTANGLE="RECTANGLE",n.LINE="LINE",n))(Pi||{}),sl=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function du(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function Cw(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var t=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(i){var r=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:function(){return n[i]}})}),t}var ag={exports:{}};(function(n){(function(){function e(a,l){var h=a.x-l.x,u=a.y-l.y;return h*h+u*u}function t(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],e(c,h)>l&&(u.push(c),h=c);return h!==c&&u.push(c),u}function r(a,l,h,u,c){for(var d=u,f,p=l+1;p<h;p++){var g=t(a[p],a[l],a[h]);g>d&&(f=p,d=g)}d>u&&(f-l>1&&r(a,l,f,u,c),c.push(a[f]),h-f>1&&r(a,f,h,u,c))}function s(a,l){var h=a.length-1,u=[a[0]];return r(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=s(a,u),a}n.exports=o,n.exports.default=o})()})(ag);var Iw=ag.exports;const Mw=du(Iw),jr=(n,e)=>e,fu=n=>{let e=1/0,t=1/0,i=-1/0,r=-1/0;
74return n.forEach(([s,o])=>{e=Math.min(e,s),t=Math.min(t,o),i=Math.max(i,s),r=Math.max(r,o)}),{minX:e,minY:t,maxX:i,maxY:r}},jo=n=>{let e=0,t=n.length-1;for(let i=0;i<n.length;i++)e+=(n[t][0]+n[i][0])*(n[t][1]-n[i][1]),t=i;return Math.abs(.5*e)},Xo=(n,e,t)=>{let i=!1;for(let r=0,s=n.length-1;r<n.length;s=r++){const o=n[r][0],a=n[r][1],l=n[s][0],h=n[s][1];a>t!=h>t&&e<(l-o)*(t-a)/(h-a)+o&&(i=!i)}return i},lg=(n,e=1)=>{const t=n.map(([i,r])=>({x:i,y:r}));return Mw(t,e,!0).map(i=>[i.x,i.y])},Dw=(n,e)=>{const t=Math.abs(e[0]-n[0]),i=Math.abs(e[1]-n[1]);return Math.sqrt(Math.pow(t,2)+Math.pow(i,2))},Ow={area:n=>Math.PI*n.geometry.rx*n.geometry.ry,intersects:(n,e,t)=>{const{cx:i,cy:r,rx:s,ry:o}=n.geometry,a=0,l=Math.cos(a),h=Math.sin(a),u=e-i,c=t-r,d=l*u+h*c,f=h*u-l*c;return d*d/(s*s)+f*f/(o*o)<=1}};jr(Pi.ELLIPSE,Ow);const Lw={area:n=>0,intersects:(n,e,t,i=2)=>{const[[r,s],[o,a]]=n.geometry.points,l=Math.abs((a-s)*e-(o-r)*t+o*s-a*r),h=Dw([r,s],[o,a]);return l/h<=i}};jr(Pi.LINE,Lw);const Bw={area:n=>{const{polygons:e}=n.geometry;return e.reduce((t,i)=>{const[r,...s]=i.rings,o=jo(r.points),a=s.reduce((l,h)=>l+jo(h.points),0);return t+o-a},0)},intersects:(n,e,t)=>{const{polygons:i}=n.geometry;for(const r of i){const[s,...o]=r.rings;if(Xo(s.points,e,t)){let a=!1;for(const l of o)if(Xo(l.points,e,t)){a=!0;break}if(!a)return!0}}return!1}},Fw=n=>{const e=n.reduce((t,i)=>[...t,...i.rings[0].points],[]);return fu(e)},Nw=(n,e=1)=>{const t=n.geometry.polygons.map(r=>{const s=r.rings.map(a=>{const l=lg(a.points,e);return{...a,points:l}}),o=fu(s[0].points);return{...r,rings:s,bounds:o}}),i=Fw(t);return{...n,geometry:{...n.geometry,polygons:t,bounds:i}}};jr(Pi.MULTIPOLYGON,Bw);const kw={area:n=>{const e=n.geometry.points;return jo(e)},intersects:(n,e,t)=>{const i=n.geometry.points;return Xo(i,e,t)}},Uw=(n,e=1)=>{const t=lg(n.geometry.points,e),i=fu(t);return{...n,geometry:{...n.geometry,bounds:i,points:t}}};jr(Pi.POLYGON,kw);const Hw={area:n=>{const e=n.geometry;if(!e.closed||e.points.length<3)return 0;const t=vd(e.points,e.closed);return jo(t)},intersects:(n,e,t,i=2)=>{const r=n.geometry;if(r.closed){const s=vd(r.points,r.closed);return Xo(s,e,t)}else return Gw(r,[e,t],i)}},vd=(n,e=!1)=>{const t=[];for(let i=0;i<n.length;i++){const r=n[i],s=n[(i+1)%n.length];if(t.push(r.point),(i<n.length-1||e)&&(r.type==="CURVE"||s.type=="CURVE")){const o=hg(r.point,r.type==="CURVE"&&r.outHandle||r.point,s.type==="CURVE"&&s.inHandle||s.point,s.point,10);t.push(...o.slice(1))}}return t},hg=(n,e,t,i,r=10)=>{const s=[];for(let o=0;o<=r;o++){const a=o/r,l=Math.pow(1-a,3)*n[0]+3*Math.pow(1-a,2)*a*e[0]+3*(1-a)*Math.pow(a,2)*t[0]+Math.pow(a,3)*i[0],h=Math.pow(1-a,3)*n[1]+3*Math.pow(1-a,2)*a*e[1]+3*(1-a)*Math.pow(a,2)*t[1]+Math.pow(a,3)*i[1];s.push([l,h])}return s},Gw=(n,e,t)=>{for(let i=0;i<n.points.length-1;i++){const r=n.points[i],s=n.points[i+1];if(r.type==="CURVE"||s.type==="CURVE"){const o=hg(r.point,r.type==="CURVE"&&r.outHandle||r.point,s.type==="CURVE"&&s.inHandle||s.point,s.point,20);for(let a=0;a<o.length-1;a++)if(yd(e,o[a],o[a+1])<=t)return!0}else if(yd(e,r.point,s.point)<=t)return!0}return!1},yd=(n,e,t)=>{const[i,r]=n,[s,o]=e,[a,l]=t,h=a-s,u=l-o,c=Math.sqrt(h*h+u*u);if(c===0)return Math.sqrt((i-s)*(i-s)+(r-o)*(r-o));const d=((i-s)*h+(r-o)*u)/(c*c);return d<=0?Math.sqrt((i-s)*(i-s)+(r-o)*(r-o)):d>=1?Math.sqrt((i-a)*(i-a)+(r-l)*(r-l)):Math.abs((l-o)*i-(a-s)*r+a*o-l*s)/c};jr(Pi.POLYLINE,Hw);const zw={area:n=>n.geometry.w*n.geometry.h,intersects:(n,e,t)=>{const i=n.geometry;if(i.rot){const r=i.x+i.w/2,s=i.y+i.h/2,o=e-r,a=t-s,l=Math.cos(i.rot),h=Math.sin(i.rot),u=o*l+a*h,c=-o*h+a*l;return u>=-i.w/2&&u<=i.w/2&&c>=-i.h/2&&c<=i.h/2}else return e>=i.x&&e<=i.x+i.w&&t>=i.y&&t<=i.y+i.h}};jr(Pi.RECTANGLE,zw);const At=[];for(let n=0;n<256;++n)At.push((n+256).toString(16).slice(1));function Vw(n,e=0){return(At[n[e+0]]+At[n[e+1]]+At[n[e+2]]+At[n[e+3]]+"-"+At[n[e+4]]+At[n[e+5]]+"-"+At[n[e+6]]+At[n[e+7]]+"-"+At[n[e+8]]+At[n[e+9]]+"-"+At[n[e+10]]+At[n[e+11]]+At[n[e+12]]+At[n[e+13]]+At[n[e+14]]+At[n[e+15]]).toLowerCase()}const jw=new Uint8Array(16);function Xw(){return crypto.getRandomValues(jw)}function Ww(n,e,t){return crypto.randomUUID?crypto.randomUUID():Yw(n)}function Yw(n,e,t){var i;n=n||{};const r=n.random??((i=n.rng)==null?void 0:i.call(n))??Xw();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,Vw(r)}const qw=(n,e,t)=>{const i=typeof e=="function"?e(n,t):e;if(i){const{fill:r,fillOpacity:s,stroke:o,strokeWidth:a,strokeOpacity:l}=i;let h="";return r&&(h+=`fill:${r};`),s||s===0?h+=`fill-opacity:${s};`:r&&(h+="fill-opacity:0.25;"),o&&(h+=`stroke:${o};`,h+=`stroke-width:${a||"1"};`,h+=`stroke-opacity:${l||"1"};`),h}};Pi.RECTANGLE,Pi.POLYGON,Pi.MULTIPOLYGON;function $w(n,e,t){let i;const r=cu();let{annotation:s}=e,{editor:o}=e,{style:a}=e,{target:l}=e,{transform:h}=e,{viewportScale:u}=e,c;return Us(()=>(t(6,c=new o({target:l,props:{shape:s.target.selector,computedStyle:i,transform:h,viewportScale:u,svgEl:l.closest("svg")}})),c.$on("change",d=>{c.$$set({shape:d.detail}),r("change",d.detail)}),c.$on("grab",d=>r("grab",d.detail)),c.$on("release",d=>r("release",d.detail)),()=>{c.$destroy()})),n.$$set=d=>{"annotation"in d&&t(0,s=d.annotation),"editor"in d&&t(1,o=d.editor),"style"in d&&t(2,a=d.style),"target"in d&&t(3,l=d.target),"transform"in d&&t(4,h=d.transform),"viewportScale"in d&&t(5,u=d.viewportScale)},n.$$.update=()=>{n.$$.dirty&5&&t(7,i=qw(s,a,{selected:!0,hovered:!0})),n.$$.dirty&65&&s&&c?.$set({shape:s.target.selector}),n.$$.dirty&80&&c&&c.$set({transform:h}),n.$$.dirty&96&&c&&c.$set({viewportScale:u}),n.$$.dirty&192&&c&&i&&c.$set({computedStyle:i})},[s,o,a,l,h,u,c,i]}class Zw extends Ot{constructor(e){super(),Dt(this,e,$w,null,Et,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}typeof navigator>"u"||navigator.userAgent.indexOf("Mac OS X");var Yn=(n=>(n[n.WEBGL_LEGACY=0]="WEBGL_LEGACY",n[n.WEBGL=1]="WEBGL",n[n.WEBGL2=2]="WEBGL2",n))(Yn||{}),ug=(n=>(n[n.UNKNOWN=0]="UNKNOWN",n[n.WEBGL=1]="WEBGL",n[n.CANVAS=2]="CANVAS",n))(ug||{}),nh=(n=>(n[n.COLOR=16384]="COLOR",n[n.DEPTH=256]="DEPTH",n[n.STENCIL=1024]="STENCIL",n))(nh||{}),Ce=(n=>(n[n.NORMAL=0]="NORMAL",n[n.ADD=1]="ADD",n[n.MULTIPLY=2]="MULTIPLY",n[n.SCREEN=3]="SCREEN",n[n.OVERLAY=4]="OVERLAY",n[n.DARKEN=5]="DARKEN",n[n.LIGHTEN=6]="LIGHTEN",n[n.COLOR_DODGE=7]="COLOR_DODGE",n[n.COLOR_BURN=8]="COLOR_BURN",n[n.HARD_LIGHT=9]="HARD_LIGHT",n[n.SOFT_LIGHT=10]="SOFT_LIGHT",n[n.DIFFERENCE=11]="DIFFERENCE",n[n.EXCLUSION=12]="EXCLUSION",n[n.HUE=13]="HUE",n[n.SATURATION=14]="SATURATION",n[n.COLOR=15]="COLOR",n[n.LUMINOSITY=16]="LUMINOSITY",n[n.NORMAL_NPM=17]="NORMAL_NPM",n[n.ADD_NPM=18]="ADD_NPM",
74n[n.SCREEN_NPM=19]="SCREEN_NPM",n[n.NONE=20]="NONE",n[n.SRC_OVER=0]="SRC_OVER",n[n.SRC_IN=21]="SRC_IN",n[n.SRC_OUT=22]="SRC_OUT",n[n.SRC_ATOP=23]="SRC_ATOP",n[n.DST_OVER=24]="DST_OVER",n[n.DST_IN=25]="DST_IN",n[n.DST_OUT=26]="DST_OUT",n[n.DST_ATOP=27]="DST_ATOP",n[n.ERASE=26]="ERASE",n[n.SUBTRACT=28]="SUBTRACT",n[n.XOR=29]="XOR",n))(Ce||{}),bi=(n=>(n[n.POINTS=0]="POINTS",n[n.LINES=1]="LINES",n[n.LINE_LOOP=2]="LINE_LOOP",n[n.LINE_STRIP=3]="LINE_STRIP",n[n.TRIANGLES=4]="TRIANGLES",n[n.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",n[n.TRIANGLE_FAN=6]="TRIANGLE_FAN",n))(bi||{}),oe=(n=>(n[n.RGBA=6408]="RGBA",n[n.RGB=6407]="RGB",n[n.RG=33319]="RG",n[n.RED=6403]="RED",n[n.RGBA_INTEGER=36249]="RGBA_INTEGER",n[n.RGB_INTEGER=36248]="RGB_INTEGER",n[n.RG_INTEGER=33320]="RG_INTEGER",n[n.RED_INTEGER=36244]="RED_INTEGER",n[n.ALPHA=6406]="ALPHA",n[n.LUMINANCE=6409]="LUMINANCE",n[n.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",n[n.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",n[n.DEPTH_STENCIL=34041]="DEPTH_STENCIL",n))(oe||{}),Tr=(n=>(n[n.TEXTURE_2D=3553]="TEXTURE_2D",n[n.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",n[n.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",n[n.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",n[n.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",n[n.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",n[n.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",n[n.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",n[n.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",n))(Tr||{}),Ee=(n=>(n[n.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",n[n.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",n[n.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",n[n.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",n[n.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",n[n.UNSIGNED_INT=5125]="UNSIGNED_INT",n[n.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",n[n.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",n[n.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",n[n.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",n[n.BYTE=5120]="BYTE",n[n.SHORT=5122]="SHORT",n[n.INT=5124]="INT",n[n.FLOAT=5126]="FLOAT",n[n.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",n[n.HALF_FLOAT=36193]="HALF_FLOAT",n))(Ee||{}),fe=(n=>(n[n.FLOAT=0]="FLOAT",n[n.INT=1]="INT",n[n.UINT=2]="UINT",n))(fe||{}),Ni=(n=>(n[n.NEAREST=0]="NEAREST",n[n.LINEAR=1]="LINEAR",n))(Ni||{}),ln=(n=>(n[n.CLAMP=33071]="CLAMP",n[n.REPEAT=10497]="REPEAT",n[n.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",n))(ln||{}),Mi=(n=>(n[n.OFF=0]="OFF",n[n.POW2=1]="POW2",n[n.ON=2]="ON",n[n.ON_MANUAL=3]="ON_MANUAL",n))(Mi||{}),Ut=(n=>(n[n.NPM=0]="NPM",n[n.UNPACK=1]="UNPACK",n[n.PMA=2]="PMA",n[n.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",n[n.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",n[n.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",n))(Ut||{}),Ti=(n=>(n[n.NO=0]="NO",n[n.YES=1]="YES",n[n.AUTO=2]="AUTO",n[n.BLEND=0]="BLEND",n[n.CLEAR=1]="CLEAR",n[n.BLIT=2]="BLIT",n))(Ti||{}),pu=(n=>(n[n.AUTO=0]="AUTO",n[n.MANUAL=1]="MANUAL",n))(pu||{}),Qt=(n=>(n.LOW="lowp",n.MEDIUM="mediump",n.HIGH="highp",n))(Qt||{}),mt=(n=>(n[n.NONE=0]="NONE",n[n.SCISSOR=1]="SCISSOR",n[n.STENCIL=2]="STENCIL",n[n.SPRITE=3]="SPRITE",n[n.COLOR=4]="COLOR",n))(mt||{}),pt=(n=>(n[n.NONE=0]="NONE",n[n.LOW=2]="LOW",n[n.MEDIUM=4]="MEDIUM",n[n.HIGH=8]="HIGH",n))(pt||{}),Ci=(n=>(n[n.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",n[n.ARRAY_BUFFER=34962]="ARRAY_BUFFER",n[n.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",n))(Ci||{});const Kw={createCanvas:(n,e)=>{const t=document.createElement("canvas");return t.width=n,t.height=e,t},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(n,e)=>fetch(n,e),parseXML:n=>new DOMParser().parseFromString(n,"text/xml")},pe={ADAPTER:Kw,RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var ol=/iPhone/i,xd=/iPod/i,_d=/iPad/i,wd=/\biOS-universal(?:.+)Mac\b/i,al=/\bAndroid(?:.+)Mobile\b/i,Td=/Android/i,ir=/(?:SD4930UR|\bSilk(?:.
vendor: 4,132 bytes, line 74
74+)Mobile\b)/i,$s=/Silk/i,Oi=/Windows Phone/i,Ed=/\bWindows(?:.+)ARM\b/i,bd=/BlackBerry/i,Sd=/BB10/i,Ad=/Opera Mini/i,Rd=/\b(CriOS|Chrome)(?:.+)Mobile/i,Pd=/Mobile(?:.+)Firefox\b/i,Cd=function(n){return typeof n<"u"&&n.platform==="MacIntel"&&typeof n.maxTouchPoints=="number"&&n.maxTouchPoints>1&&typeof MSStream>"u"};function Jw(n){return function(e){return e.test(n)}}function Id(n){var e={userAgent:"",platform:"",maxTouchPoints:0};!n&&typeof navigator<"u"?e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof n=="string"?e.userAgent=n:n&&n.userAgent&&(e={userAgent:n.userAgent,platform:n.platform,maxTouchPoints:n.maxTouchPoints||0});var t=e.userAgent,i=t.split("[FBAN");typeof i[1]<"u"&&(t=i[0]),i=t.split("Twitter"),typeof i[1]<"u"&&(t=i[0]);var r=Jw(t),s={apple:{phone:r(ol)&&!r(Oi),ipod:r(xd),tablet:!r(ol)&&(r(_d)||Cd(e))&&!r(Oi),universal:r(wd),device:(r(ol)||r(xd)||r(_d)||r(wd)||Cd(e))&&!r(Oi)},amazon:{phone:r(ir),tablet:!r(ir)&&r($s),device:r(ir)||r($s)},android:{phone:!r(Oi)&&r(ir)||!r(Oi)&&r(al),tablet:!r(Oi)&&!r(ir)&&!r(al)&&(r($s)||r(Td)),device:!r(Oi)&&(r(ir)||r($s)||r(al)||r(Td))||r(/\bokhttp\b/i)},windows:{phone:r(Oi),tablet:r(Ed),device:r(Oi)||r(Ed)},other:{blackberry:r(bd),blackberry10:r(Sd),opera:r(Ad),firefox:r(Pd),chrome:r(Rd),device:r(bd)||r(Sd)||r(Ad)||r(Pd)||r(Rd)},any:!1,phone:!1,tablet:!1};return s.any=s.apple.device||s.android.device||s.windows.device||s.other.device,s.phone=s.apple.phone||s.android.phone||s.windows.phone,s.tablet=s.apple.tablet||s.android.tablet||s.windows.tablet,s}const Qw=Id.default??Id,ki=Qw(globalThis.navigator);pe.RETINA_PREFIX=/@([0-9\.]+)x/;pe.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var cg={exports:{}};(function(n){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function r(l,h,u){this.fn=l,this.context=h,this.once=u||!1}function s(l,h,u,c,d){if(typeof u!="function")throw new TypeError("The listener must be a function");var f=new r(u,c||l,d),p=t?t+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 l=[],h,u;if(this._eventsCount===0)return l;for(u in h=this._events)e.call(h,u)&&l.push(t?u.slice(1):u);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(h)):l},a.prototype.listeners=function(l){var h=t?t+l:l,u=this._events[h];if(!u)return[];if(u.fn)return[u.fn];for(var c=0,d=u.length,f=new Array(d);c<d;c++)f[c]=u[c].fn;return f},a.prototype.listenerCount=function(l){var h=t?t+l:l,u=this._events[h];return u?u.fn?1:u.length:0},a.prototype.emit=function(l,h,u,c,d,f){var p=t?t+l:l;if(!this._events[p])return!1;var g=this._events[p],v=arguments.length,m,x;if(g.fn){switch(g.once&&this.removeListener(l,g.fn,void 0,!0),v){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,h),!0;case 3:return g.fn.call(g.context,h,u),!0;case 4:return g.fn.call(g.context,h,u,c),!0;case 5:return g.fn.call(g.context,h,u,c,d),!0;case 6:return g.fn.call(g.context,h,u,c,d,f),!0}for(x=1,m=new Array(v-1);x<v;x++)m[x-1]=arguments[x];g.fn.apply(g.context,m)}else{var y=g.length,E;for(x=0;x<y;x++)switch(g[x].once&&this.removeListener(l,g[x].fn,void 0,!0),v){case 1:g[x].fn.call(g[x].context);break;case 2:g[x].fn.call(g[x].context,h);break;case 3:g[x].fn.call(g[x].context,h,u);break;case 4:g[x].fn.call(g[x].context,h,u,c);break;default:if(!m)for(E=1,m=new Array(v-1);E<v;E++)m[E-1]=arguments[E];g[x].fn.apply(g[x].context,m)}}return!0},a.prototype.on=function(l,h,u){return s(this,l,h,u,!1)},a.prototype.once=function(l,h,u){return s(this,l,h,u,!0)},a.prototype.removeListener=function(l,h,u,c){var d=t?t+l:l;if(!this._events[d])return this;if(!h)return o(this,d),this;var f=this._events[d];if(f.fn)f.fn===h&&(!c||f.once)&&(!u||f.context===u)&&o(this,d);else{for(var p=0,g=[],v=f.length;p<v;p++)(f[p].fn!==h||c&&!f[p].once||u&&f[p].context!==u)&&g.push(f[p]
vendor: 5,497 bytes, line 74
74);g.length?this._events[d]=g.length===1?g[0]:g:o(this,d)}return this},a.prototype.removeAllListeners=function(l){var h;return l?(h=t?t+l:l,this._events[h]&&o(this,h)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,n.exports=a})(cg);var eT=cg.exports;const Hs=du(eT);var gu={exports:{}};gu.exports=ya;gu.exports.default=ya;function ya(n,e,t){t=t||2;var i=e&&e.length,r=i?e[0]*t:n.length,s=dg(n,0,r,t,!0),o=[];if(!s||s.next===s.prev)return o;var a,l,h,u,c,d,f;if(i&&(s=sT(n,e,s,t)),n.length>80*t){a=h=n[0],l=u=n[1];for(var p=t;p<r;p+=t)c=n[p],d=n[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 Rs(s,o,t,a,l,f,0),o}function dg(n,e,t,i,r){var s,o;if(r===oh(n,e,t,i)>0)for(s=e;s<t;s+=i)o=Md(s,n[s],n[s+1],o);else for(s=t-i;s>=e;s-=i)o=Md(s,n[s],n[s+1],o);return o&&xa(o,o.next)&&(Cs(o),o=o.next),o}function jn(n,e){if(!n)return n;e||(e=n);var t=n,i;do if(i=!1,!t.steiner&&(xa(t,t.next)||st(t.prev,t,t.next)===0)){if(Cs(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Rs(n,e,t,i,r,s,o){if(n){!o&&s&&uT(n,i,r,s);for(var a=n,l,h;n.prev!==n.next;){if(l=n.prev,h=n.next,s?iT(n,i,r,s):tT(n)){e.push(l.i/t|0),e.push(n.i/t|0),e.push(h.i/t|0),Cs(n),n=h.next,a=h.next;continue}if(n=h,n===a){o?o===1?(n=nT(jn(n),e,t),Rs(n,e,t,i,r,s,2)):o===2&&rT(n,e,t,i,r,s):Rs(jn(n),e,t,i,r,s,1);break}}}}function tT(n){var e=n.prev,t=n,i=n.next;if(st(e,t,i)>=0)return!1;for(var r=e.x,s=t.x,o=i.x,a=e.y,l=t.y,h=i.y,u=r<s?r<o?r:o:s<o?s:o,c=a<l?a<h?a:h:l<h?l:h,d=r>s?r>o?r:o:s>o?s:o,f=a>l?a>h?a:h:l>h?l:h,p=i.next;p!==e;){if(p.x>=u&&p.x<=d&&p.y>=c&&p.y<=f&&mr(r,a,s,l,o,h,p.x,p.y)&&st(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function iT(n,e,t,i){var r=n.prev,s=n,o=n.next;if(st(r,s,o)>=0)return!1;for(var a=r.x,l=s.x,h=o.x,u=r.y,c=s.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,g=a>l?a>h?a:h:l>h?l:h,v=u>c?u>d?u:d:c>d?c:d,m=rh(f,p,e,t,i),x=rh(g,v,e,t,i),y=n.prevZ,E=n.nextZ;y&&y.z>=m&&E&&E.z<=x;){if(y.x>=f&&y.x<=g&&y.y>=p&&y.y<=v&&y!==r&&y!==o&&mr(a,u,l,c,h,d,y.x,y.y)&&st(y.prev,y,y.next)>=0||(y=y.prevZ,E.x>=f&&E.x<=g&&E.y>=p&&E.y<=v&&E!==r&&E!==o&&mr(a,u,l,c,h,d,E.x,E.y)&&st(E.prev,E,E.next)>=0))return!1;E=E.nextZ}for(;y&&y.z>=m;){if(y.x>=f&&y.x<=g&&y.y>=p&&y.y<=v&&y!==r&&y!==o&&mr(a,u,l,c,h,d,y.x,y.y)&&st(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;E&&E.z<=x;){if(E.x>=f&&E.x<=g&&E.y>=p&&E.y<=v&&E!==r&&E!==o&&mr(a,u,l,c,h,d,E.x,E.y)&&st(E.prev,E,E.next)>=0)return!1;E=E.nextZ}return!0}function nT(n,e,t){var i=n;do{var r=i.prev,s=i.next.next;!xa(r,s)&&fg(r,i,i.next,s)&&Ps(r,s)&&Ps(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),Cs(i),Cs(i.next),i=n=s),i=i.next}while(i!==n);return jn(i)}function rT(n,e,t,i,r,s){var o=n;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&fT(o,a)){var l=pg(o,a);o=jn(o,o.next),l=jn(l,l.next),Rs(o,e,t,i,r,s,0),Rs(l,e,t,i,r,s,0);return}a=a.next}o=o.next}while(o!==n)}function sT(n,e,t,i){var r=[],s,o,a,l,h;for(s=0,o=e.length;s<o;s++)a=e[s]*i,l=s<o-1?e[s+1]*i:n.length,h=dg(n,a,l,i,!1),h===h.next&&(h.steiner=!0),r.push(dT(h));for(r.sort(oT),s=0;s<r.length;s++)t=aT(r[s],t);return t}function oT(n,e){return n.x-e.x}function aT(n,e){var t=lT(n,e);if(!t)return e;var i=pg(t,n);return jn(i,i.next),jn(t,t.next)}function lT(n,e){var t=e,i=n.x,r=n.y,s=-1/0,o;do{if(r<=t.y&&r>=t.next.y&&t.next.y!==t.y){var a=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(a<=i&&a>s&&(s=a,o=t.x<t.next.x?t:t.next,a===i))return o}t=t.next}while(t!==e);if(!o)return null;var l=o,h=o.x,u=o.y,c=1/0,d;t=o;do i>=t.x&&t.x>=h&&i!==t.x&&mr(r<u?i:s,r,h,u,r<u?s:i,r,t.x,t.y)&&(d=Math.abs(r-t.y)/(i-t.x),Ps(t,n)&&(d<c||d===c&&(t.x>o.x||t.x===o.x&&hT(o,t)))&&(o=t,c=d)),t=t.next;while(t!==l);return o}function hT(n,e){return st(n.prev,n,e.prev)<0&&st(e.next,n,n.next)<0}function uT(n,e,t,i){var r=n;do r.z===0&&(r.z=rh(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,cT(r)}function cT(n){var e,t,i,r,s,o,a,l,h=1;do{for(t=n,n=null,s=null,o=0;t;){for(o++,i=t,a=0,e=0;e<h&&(a++,i=i.nextZ,!!i);e++);for(l=h;a>0||l>0&&i;)a!==0&&(l===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,a--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,h*=2}while(o>1);return n}function rh(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function dT(n){var e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function mr(n,e,t,i,r,s,o,a){return(r-o)*(e-a)>=(n-o)*(s-a)&&(n-o)*(i-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(r-o)*(i-a)}function fT(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!pT(n,e)&&(Ps(n,e)&&Ps(e,n)&&gT(n,e)&&(st(n.prev,n,e.prev)||st(n,e.prev,e))||xa(n,e)&&st(n.prev,n,n.next)>0&&st(e.prev,e,e.next)>0)}function st(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function xa(n,e){return n.x===e.x&&n.y===e.y}function fg(n,e,t,i){var r=Ks(st(n,e,t)),s=Ks(st(n,e,i)),o=Ks(st(t,i,n)),a=Ks(st(t,i,e));return!!(r!==s&&o!==a||r===0&&Zs(n,t,e)||s===0&&Zs(n,i,e)||o===0&&Zs(t,n,i)||a===0&&Zs(t,e,i))}function Zs(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function Ks(n){return n>0?1:n<0?-1:0}function pT(n,e){var t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&fg(t,t.next,n,e))return!0;t=t.next}
vendor: 4,329 bytes, line 74
74while(t!==n);return!1}function Ps(n,e){return st(n.prev,n,n.next)<0?st(n,e,n.next)>=0&&st(n,n.prev,e)>=0:st(n,e,n.prev)<0||st(n,n.next,e)<0}function gT(n,e){var t=n,i=!1,r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function pg(n,e){var t=new sh(n.i,n.x,n.y),i=new sh(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function Md(n,e,t,i){var r=new sh(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Cs(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function sh(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}ya.deviation=function(n,e,t,i){var r=e&&e.length,s=r?e[0]*t:n.length,o=Math.abs(oh(n,0,s,t));if(r)for(var a=0,l=e.length;a<l;a++){var h=e[a]*t,u=a<l-1?e[a+1]*t:n.length;o-=Math.abs(oh(n,h,u,t))}var c=0;for(a=0;a<i.length;a+=3){var d=i[a]*t,f=i[a+1]*t,p=i[a+2]*t;c+=Math.abs((n[d]-n[p])*(n[f+1]-n[d+1])-(n[d]-n[f])*(n[p+1]-n[d+1]))}return o===0&&c===0?0:Math.abs((c-o)/o)};function oh(n,e,t,i){for(var r=0,s=e,o=t-i;s<t;s+=i)r+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return r}ya.flatten=function(n){for(var e=n[0][0].length,t={vertices:[],holes:[],dimensions:e},i=0,r=0;r<n.length;r++){for(var s=0;s<n[r].length;s++)for(var o=0;o<e;o++)t.vertices.push(n[r][s][o]);r>0&&(i+=n[r-1].length,t.holes.push(i))}return t};var mT=gu.exports;const vT=du(mT);var Wo={exports:{}};Wo.exports;(function(n,e){(function(t){var i=e&&!e.nodeType&&e,r=n&&!n.nodeType&&n,s=typeof sl=="object"&&sl;(s.global===s||s.window===s||s.self===s)&&(t=s);var o,a=2147483647,l=36,h=1,u=26,c=38,d=700,f=72,p=128,g="-",v=/^xn--/,m=/[^\x20-\x7E]/,x=/[\x2E\u3002\uFF0E\uFF61]/g,y={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},E=l-h,R=Math.floor,P=String.fromCharCode,S;function L(z){throw new RangeError(y[z])}function k(z,b){for(var H=z.length,X=[];H--;)X[H]=b(z[H]);return X}function W(z,b){var H=z.split("@"),X="";H.length>1&&(X=H[0]+"@",z=H[1]),z=z.replace(x,".");var $=z.split("."),re=k($,b).join(".");return X+re}function j(z){for(var b=[],H=0,X=z.length,$,re;H<X;)$=z.charCodeAt(H++),$>=55296&&$<=56319&&H<X?(re=z.charCodeAt(H++),(re&64512)==56320?b.push((($&1023)<<10)+(re&1023)+65536):(b.push($),H--)):b.push($);return b}function V(z){return k(z,function(b){var H="";return b>65535&&(b-=65536,H+=P(b>>>10&1023|55296),b=56320|b&1023),H+=P(b),H}).join("")}function N(z){return z-48<10?z-22:z-65<26?z-65:z-97<26?z-97:l}function D(z,b){return z+22+75*(z<26)-((b!=0)<<5)}function A(z,b,H){var X=0;for(z=H?R(z/d):z>>1,z+=R(z/b);z>E*u>>1;X+=l)z=R(z/E);return R(X+(E+1)*z/(z+c))}function O(z){var b=[],H=z.length,X,$=0,re=p,se=f,ce,ie,ge,de,Te,me,De,it,Je;for(ce=z.lastIndexOf(g),ce<0&&(ce=0),ie=0;ie<ce;++ie)z.charCodeAt(ie)>=128&&L("not-basic"),b.push(z.charCodeAt(ie));for(ge=ce>0?ce+1:0;ge<H;){for(de=$,Te=1,me=l;ge>=H&&L("invalid-input"),De=N(z.charCodeAt(ge++)),(De>=l||De>R((a-$)/Te))&&L("overflow"),$+=De*Te,it=me<=se?h:me>=se+u?u:me-se,!(De<it);me+=l)Je=l-it,Te>R(a/Je)&&L("overflow"),Te*=Je;X=b.length+1,se=A($-de,X,de==0),R($/X)>a-re&&L("overflow"),re+=R($/X),$%=X,b.splice($++,0,re)}return V(b)}function B(z){var b,H,X,$,re,se,ce,ie,ge,de,Te,me=[],De,it,Je,ht;for(z=j(z),De=z.length,b=p,H=0,re=f,se=0;se<De;++se)Te=z[se],Te<128&&me.push(P(Te));for(X=$=me.length,$&&me.push(g);X<De;){for(ce=a,se=0;se<De;++se)Te=z[se],Te>=b&&Te<ce&&(ce=Te);for(it=X+1,ce-b>R((a-H)/it)&&L("overflow"),H+=(ce-b)*it,b=ce,se=0;se<De;++se)if(Te=z[se],Te<b&&++H>a&&L("overflow"),Te==b){for(ie=H,ge=l;de=ge<=re?h:ge>=re+u?u:ge-re,!(ie<de);ge+=l)ht=ie-de,Je=l-de,me.push(P(D(de+ht%Je,0))),ie=R(ht/Je);me.push(P(D(ie,0))),re=A(H,it,X==$),H=0,++X}++H,++b}return me.join("")}function G(z){return W(z,function(b){return v.test(b)?O(b.slice(4).toLowerCase()):b})}function Y(z){return W(z,function(b){return m.test(b)?"xn--"+B(b):b})}if(o={version:"1.4.1",ucs2:{decode:j,encode:V},decode:O,encode:B,toASCII:Y,toUnicode:G},i&&r)if(n.exports==i)r.exports=o;else for(S in o)o.hasOwnProperty(S)&&(i[S]=o[S]);else t.punycode=o})(sl)}
74)(Wo,Wo.exports);Wo.exports;var gg=TypeError;const yT={},xT=Object.freeze(Object.defineProperty({__proto__:null,default:yT},Symbol.toStringTag,{value:"Module"})),_T=Cw(xT);var mg=typeof Map=="function"&&Map.prototype,ll=Object.getOwnPropertyDescriptor&&mg?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null;mg&&ll&&typeof ll.get=="function"&&ll.get;var vg=typeof Set=="function"&&Set.prototype,hl=Object.getOwnPropertyDescriptor&&vg?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null;vg&&hl&&typeof hl.get=="function"&&hl.get;var Dd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,wT=typeof Symbol=="function"&&typeof Symbol.iterator=="object",TT=_T,Od=TT.custom;ET(Od);function ET(n){if(wT)return n&&typeof n=="object"&&n instanceof Symbol;if(typeof n=="symbol")return!0;if(!n||typeof n!="object"||!Dd)return!1;try{return Dd.call(n),!0}catch{}return!1}var yg=Object,bT=Error,ST=EvalError,AT=RangeError,RT=ReferenceError,PT=SyntaxError,CT=URIError,IT=Math.abs,MT=Math.floor,DT=Math.max,OT=Math.min,LT=Math.pow,BT=Math.round,FT=Number.isNaN||function(n){return n!==n},NT=FT,kT=function(n){return NT(n)||n===0?n:n<0?-1:1},UT=Object.getOwnPropertyDescriptor,So=UT;if(So)try{So([],"length")}catch{So=null}var xg=So,Ao=Object.defineProperty||!1;if(Ao)try{Ao({},"a",{value:1})}catch{Ao=!1}var HT=Ao,Ld,Bd;function GT(){return Bd||(Bd=1,Ld=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var n={},e=Symbol("test"),t=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(t)!=="[object Symbol]")return!1;var i=42;n[e]=i;for(var r in n)return!1;if(typeof Object.keys=="function"&&Object.keys(n).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(n).length!==0)return!1;var s=Object.getOwnPropertySymbols(n);if(s.length!==1||s[0]!==e||!Object.prototype.propertyIsEnumerable.call(n,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var o=Object.getOwnPropertyDescriptor(n,e);if(o.value!==i||o.enumerable!==!0)return!1}return!0}),Ld}var ul,Fd;function zT(){if(Fd)return ul;Fd=1;var n=typeof Symbol<"u"&&Symbol,e=GT();return ul=function(){return typeof n!="function"||typeof Symbol!="function"||typeof n("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:e()},ul}var Nd,kd;function _g(){return kd||(kd=1,Nd=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),Nd}var cl,Ud;function wg(){if(Ud)return cl;Ud=1;var n=yg;return cl=n.getPrototypeOf||null,cl}var VT="Function.prototype.bind called on incompatible ",jT=Object.prototype.toString,XT=Math.max,WT="[object Function]",Hd=function(n,e){for(var t=[],i=0;i<n.length;i+=1)t[i]=n[i];for(var r=0;r<e.length;r+=1)t[r+n.length]=e[r];return t},YT=function(n,e){for(var t=[],i=e,r=0;i<n.length;i+=1,r+=1)t[r]=n[i];return t},qT=function(n,e){for(var t="",i=0;i<n.length;i+=1)t+=n[i],i+1<n.length&&(t+=e);return t},$T=function(n){var e=this;if(typeof e!="function"||jT.apply(e)!==WT)throw new TypeError(VT+e);for(var t=YT(arguments,1),i,r=function(){if(this instanceof i){var h=e.apply(this,Hd(t,arguments));return Object(h)===h?h:this}return e.apply(n,Hd(t,arguments))},s=XT(0,e.length-t.length),o=[],a=0;a<s;a++)o[a]="$"+a;if(i=Function("binder","return function ("+qT(o,",")+"){ return binder.apply(this,arguments); }")(r),e.prototype){var l=function(){};l.prototype=e.prototype,i.prototype=new l,l.prototype=null}return i},ZT=$T,_a=Function.prototype.bind||ZT,mu=Function.prototype.call,Gd,zd;function Tg(){return zd||(zd=1,Gd=Function.prototype.apply),Gd}var KT=typeof Reflect<"u"&&Reflect&&Reflect.apply,JT=_a,QT=Tg(),eE=mu,tE=KT,iE=tE||JT.call(eE,QT),nE=_a,rE=gg,sE=mu,oE=iE,Eg=function(n){if(n.length<1||typeof n[0]!="function")throw new rE("a function is required");return oE(nE,sE,n)},dl,Vd;function aE(){if(Vd)return dl;Vd=1;var n=Eg,e=xg,t;try{t=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var i=!!t&&e&&e(Object.prototype,"__proto__"),r=Object,s=r.getPrototypeOf;return dl=i&&typeof i.get=="function"?n([i.get]):typeof s=="function"?(function(o){return s(o==null?o:r(o))}):!1,dl}var fl,jd;function lE(){if(jd)return fl;jd=1;var n=_g(),e=wg(),t=aE();return fl=n?function(i){return n(i)}:e?function(i){if(!i||typeof i!="object"&&typeof i!="function")throw new TypeError("getProto: not an object");return e(i)}:t?function(i){return t(i)}:null,fl}var pl,Xd;function hE(){if(Xd)return pl;Xd=1;var n=Function.prototype.call,e=Object.prototype.hasOwnProperty,t=_a;return pl=t.call(n,e),pl}var He,uE=yg,cE=bT,dE=ST,fE=AT,pE=RT,Lr=PT,Er=gg,gE=CT,mE=IT,vE=MT,yE=DT,xE=OT,_E=LT,wE=BT,TE=kT,bg=Function,gl=function(n){try{return bg('"use strict"; return ('+n+").constructor;")()}catch{}},Is=xg,EE=HT,ml=function(){throw new Er},bE=Is?(function(){try{return arguments.callee,ml}catch{try{return Is(arguments,"callee").get}catch{return ml}}})():ml,nr=zT()(),yt=lE(),SE=wg(),AE=_g(),Sg=Tg(),Gs=mu,hr={},RE=typeof Uint8Array>"u"||!yt?He:yt(Uint8Array),Nn={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?He:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?He:ArrayBuffer,"%ArrayIteratorPrototype%":nr&&yt?yt([][Symbol.iterator]()):He,"%AsyncFromSyncIteratorPrototype%":He,"%AsyncFunction%":hr,"%AsyncGenerator%":hr,"%AsyncGeneratorFunction%":hr,"%AsyncIteratorPrototype%":hr,"%Atomics%":typeof Atomics>"u"?He:Atomics,"%BigInt%":typeof BigInt>"u"?He:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?He:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?He:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?He:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":cE,"%eval%":eval,"%EvalError%":dE,"%Float16Array%":typeof Float16Array>"u"?He:Float16Array,"%Float32Array%":typeof Float32Array>"u"?He:Float32Array,"%Float64Array%":typeof Float64Array>"u"?He:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?He:FinalizationRegistry,"%Function%":bg,"%GeneratorFunction%":hr,"%Int8Array%":typeof Int8Array>"u"?He:Int8Array,"%Int16Array%":typeof Int16Array>"u"?He:Int16Array,"%Int32Array%":typeof Int32Array>
vendor: 5,513 bytes, line 74
74"u"?He:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":nr&&yt?yt(yt([][Symbol.iterator]())):He,"%JSON%":typeof JSON=="object"?JSON:He,"%Map%":typeof Map>"u"?He:Map,"%MapIteratorPrototype%":typeof Map>"u"||!nr||!yt?He:yt(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":uE,"%Object.getOwnPropertyDescriptor%":Is,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?He:Promise,"%Proxy%":typeof Proxy>"u"?He:Proxy,"%RangeError%":fE,"%ReferenceError%":pE,"%Reflect%":typeof Reflect>"u"?He:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?He:Set,"%SetIteratorPrototype%":typeof Set>"u"||!nr||!yt?He:yt(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?He:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":nr&&yt?yt(""[Symbol.iterator]()):He,"%Symbol%":nr?Symbol:He,"%SyntaxError%":Lr,"%ThrowTypeError%":bE,"%TypedArray%":RE,"%TypeError%":Er,"%Uint8Array%":typeof Uint8Array>"u"?He:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?He:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?He:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?He:Uint32Array,"%URIError%":gE,"%WeakMap%":typeof WeakMap>"u"?He:WeakMap,"%WeakRef%":typeof WeakRef>"u"?He:WeakRef,"%WeakSet%":typeof WeakSet>"u"?He:WeakSet,"%Function.prototype.call%":Gs,"%Function.prototype.apply%":Sg,"%Object.defineProperty%":EE,"%Object.getPrototypeOf%":SE,"%Math.abs%":mE,"%Math.floor%":vE,"%Math.max%":yE,"%Math.min%":xE,"%Math.pow%":_E,"%Math.round%":wE,"%Math.sign%":TE,"%Reflect.getPrototypeOf%":AE};if(yt)try{null.error}catch(n){var PE=yt(yt(n));Nn["%Error.prototype%"]=PE}var CE=function n(e){var t;if(e==="%AsyncFunction%")t=gl("async function () {}");else if(e==="%GeneratorFunction%")t=gl("function* () {}");else if(e==="%AsyncGeneratorFunction%")t=gl("async function* () {}");else if(e==="%AsyncGenerator%"){var i=n("%AsyncGeneratorFunction%");i&&(t=i.prototype)}else if(e==="%AsyncIteratorPrototype%"){var r=n("%AsyncGenerator%");r&&yt&&(t=yt(r.prototype))}return Nn[e]=t,t},Wd={__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"]},zs=_a,Yo=hE(),IE=zs.call(Gs,Array.prototype.concat),ME=zs.call(Sg,Array.prototype.splice),Yd=zs.call(Gs,String.prototype.replace),qo=zs.call(Gs,String.prototype.slice),DE=zs.call(Gs,RegExp.prototype.exec),OE=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,LE=/\\(\\)?/g,BE=function(n){var e=qo(n,0,1),t=qo(n,-1);if(e==="%"&&t!=="%")throw new Lr("invalid intrinsic syntax, expected closing `%`");if(t==="%"&&e!=="%")throw new Lr("invalid intrinsic syntax, expected opening `%`");var i=[];return Yd(n,OE,function(r,s,o,a){i[i.length]=o?Yd(a,LE,"$1"):s||r}),i},FE=function(n,e){var t=n,i;if(Yo(Wd,t)&&(i=Wd[t],t="%"+i[0]+"%"),Yo(Nn,t)){var r=Nn[t];if(r===hr&&(r=CE(t)),typeof r>"u"&&!e)throw new Er("intrinsic "+n+" exists, but is not available. Please file an issue!");return{alias:i,name:t,value:r}}throw new Lr("intrinsic "+n+" does not exist!")}
74,vu=function(n,e){if(typeof n!="string"||n.length===0)throw new Er("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new Er('"allowMissing" argument must be a boolean');if(DE(/^%?[^%]*%?$/,n)===null)throw new Lr("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var t=BE(n),i=t.length>0?t[0]:"",r=FE("%"+i+"%",e),s=r.name,o=r.value,a=!1,l=r.alias;l&&(i=l[0],ME(t,IE([0,1],l)));for(var h=1,u=!0;h<t.length;h+=1){var c=t[h],d=qo(c,0,1),f=qo(c,-1);if((d==='"'||d==="'"||d==="`"||f==='"'||f==="'"||f==="`")&&d!==f)throw new Lr("property names with quotes must have matching quotes");if((c==="constructor"||!u)&&(a=!0),i+="."+c,s="%"+i+"%",Yo(Nn,s))o=Nn[s];else if(o!=null){if(!(c in o)){if(!e)throw new Er("base intrinsic for "+n+" exists, but the property is not available.");return}if(Is&&h+1>=t.length){var p=Is(o,c);u=!!p,u&&"get"in p&&!("originalValue"in p.get)?o=p.get:o=o[c]}else u=Yo(o,c),o=o[c];u&&!a&&(Nn[s]=o)}}return o},Ag=vu,Rg=Eg,NE=Rg([Ag("%String.prototype.indexOf%")]),Pg=function(n,e){var t=Ag(n,!!e);return typeof t=="function"&&NE(n,".prototype.")>-1?Rg([t]):t},kE=vu,Vs=Pg;kE("%Map%",!0);Vs("Map.prototype.get",!0);Vs("Map.prototype.set",!0);Vs("Map.prototype.has",!0);Vs("Map.prototype.delete",!0);Vs("Map.prototype.size",!0);var UE=vu,wa=Pg;UE("%WeakMap%",!0);wa("WeakMap.prototype.get",!0);wa("WeakMap.prototype.set",!0);wa("WeakMap.prototype.has",!0);wa("WeakMap.prototype.delete",!0);(function(){for(var n=[],e=0;e<256;++e)n[n.length]="%"+((e<16?"0":"")+e.toString(16)).toUpperCase();return n})();const qd={};function Ue(n,e,t=3){if(qd[e])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${e} 75Deprecated since v${n}`):(i=i.split(` 76`).splice(t).join(` 77`),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${e} 78Deprecated since v${n}`),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${e} 79Deprecated since v${n}`),console.warn(i))),qd[e]=!0}function oi(n){if(typeof n!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(n)}`)}function Zr(n){return n.split("?")[0].split("#")[0]}function HE(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function GE(n,e,t){return n.replace(new RegExp(HE(e),"g"),t)}function zE(n,e){let t="",i=0,r=-1,s=0,o=-1;for(let a=0;a<=n.length;++a){if(a<n.length)o=n.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(r===a-1||s===1))if(r!==a-1&&s===2){if(t.length<2||i!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){const l=t.lastIndexOf("/");if(l!==t.length-1){l===-1?(t="",i=0):(t=t.slice(0,l),i=t.length-1-t.lastIndexOf("/")),r=a,s=0;continue}}else if(t.length===2||t.length===1){t="",i=0,r=a,s=0;continue}}}else t.length>0?t+=`/${n.slice(r+1,a)}`:t=n.slice(r+1,a),i=a-r-1;r=a,s=0}else o===46&&s!==-1?++s:s=-1}return t}const Tt={toPosix(n){return GE(n,"\\","/")},isUrl(n){return/^https?:/.test(this.toPosix(n))},isDataUrl(n){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(n)},isBlobUrl(n){return n.startsWith("blob:")},hasProtocol(n){return/^[^/:]+:/.test(this.toPosix(n))},getProtocol(n){oi(n),n=this.toPosix(n);const e=/^file:\/\/\//.exec(n);if(e)return e[0];const t=/^[^/:]+:\/{0,2}/.exec(n);return t?t[0]:""},toAbsolute(n,e,t){if(oi(n),this.isDataUrl(n)||this.isBlobUrl(n))return n;const i=Zr(this.toPosix(e??pe.ADAPTER.getBaseUrl())),r=Zr(this.toPosix(t??this.rootname(i)));return n=this.toPosix(n),n.startsWith("/")?Tt.join(r,n.slice(1)):this.isAbsolute(n)?n:this.join(i,n)},normalize(n){if(oi(n),n.length===0)return".";if(this.isDataUrl(n)||this.isBlobUrl(n))return n;n=this.toPosix(n);let e="";const t=n.startsWith("/");this.hasProtocol(n)&&(e=this.rootname(n),n=n.slice(e.length));const i=n.endsWith("/");return n=zE(n),n.length>0&&i&&(n+="/"),t?`/${n}`:e+n},isAbsolute(n){return oi(n),n=this.toPosix(n),this.hasProtocol(n)?!0:n.startsWith("/")},join(...n){if(n.length===0)return".";let e;for(let t=0;t<n.length;++t){const i=n[t];if(oi(i),i.length>0)if(e===void 0)e=i;else{const r=n[t-1]??"";this.joinExtensions.includes(this.extname(r).toLowerCase())?e+=`/../${i}`:e+=`/${i}`}}return e===void 0?".":this.normalize(e)},dirname(n){if(oi(n),n.length===0)return".";n=this.toPosix(n);let e=n.charCodeAt(0);const t=e===47;let i=-1,r=!0;const s=this.getProtocol(n),o=n;n=n.slice(s.length);for(let a=n.length-1;a>=1;--a)if(e=n.charCodeAt(a),e===47){if(!r){i=a;break}}else r=!1;return i===-1?t?"/":this.isUrl(o)?s+n:s:t&&i===1?"//":s+n.slice(0,i)},rootname(n){oi(n),n=this.toPosix(n);let e="";if(n.startsWith("/")?e="/":e=this.getProtocol(n),this.isUrl(n)){const t=n.indexOf("/",e.length);t!==-1?e=n.slice(0,t):e=n,e.endsWith("/")||(e+="/")}return e}
vendor: 5,362 bytes, line 79
79,basename(n,e){oi(n),e&&oi(e),n=Zr(this.toPosix(n));let t=0,i=-1,r=!0,s;if(e!==void 0&&e.length>0&&e.length<=n.length){if(e.length===n.length&&e===n)return"";let o=e.length-1,a=-1;for(s=n.length-1;s>=0;--s){const l=n.charCodeAt(s);if(l===47){if(!r){t=s+1;break}}else a===-1&&(r=!1,a=s+1),o>=0&&(l===e.charCodeAt(o)?--o===-1&&(i=s):(o=-1,i=a))}return t===i?i=a:i===-1&&(i=n.length),n.slice(t,i)}for(s=n.length-1;s>=0;--s)if(n.charCodeAt(s)===47){if(!r){t=s+1;break}}else i===-1&&(r=!1,i=s+1);return i===-1?"":n.slice(t,i)},extname(n){oi(n),n=Zr(this.toPosix(n));let e=-1,t=0,i=-1,r=!0,s=0;for(let o=n.length-1;o>=0;--o){const a=n.charCodeAt(o);if(a===47){if(!r){t=o+1;break}continue}i===-1&&(r=!1,i=o+1),a===46?e===-1?e=o:s!==1&&(s=1):e!==-1&&(s=-1)}return e===-1||i===-1||s===0||s===1&&e===i-1&&e===t+1?"":n.slice(e,i)},parse(n){oi(n);const e={root:"",dir:"",base:"",ext:"",name:""};if(n.length===0)return e;n=Zr(this.toPosix(n));let t=n.charCodeAt(0);const i=this.isAbsolute(n);let r;e.root=this.rootname(n),i||this.hasProtocol(n)?r=1:r=0;let s=-1,o=0,a=-1,l=!0,h=n.length-1,u=0;for(;h>=r;--h){if(t=n.charCodeAt(h),t===47){if(!l){o=h+1;break}continue}a===-1&&(l=!1,a=h+1),t===46?s===-1?s=h:u!==1&&(u=1):s!==-1&&(u=-1)}return s===-1||a===-1||u===0||u===1&&s===a-1&&s===o+1?a!==-1&&(o===0&&i?e.base=e.name=n.slice(1,a):e.base=e.name=n.slice(o,a)):(o===0&&i?(e.name=n.slice(1,s),e.base=n.slice(1,a)):(e.name=n.slice(o,s),e.base=n.slice(o,a)),e.ext=n.slice(s,a)),e.dir=this.dirname(n),e},sep:"/",delimiter:":",joinExtensions:[".html"]};let vl;async function VE(){return vl??(vl=(async()=>{var n;const e=document.createElement("canvas").getContext("webgl");if(!e)return Ut.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 Ut.UNPACK;const i=e.createTexture();e.bindTexture(e.TEXTURE_2D,i);const r=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,r),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,i,0),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t);const s=new Uint8Array(4);return e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,s),e.deleteFramebuffer(r),e.deleteTexture(i),(n=e.getExtension("WEBGL_lose_context"))==null||n.loseContext(),s[0]<=s[3]?Ut.PMA:Ut.UNPACK})()),vl}let yl;function jE(){return typeof yl>"u"&&(yl=(function(){var n;const e={stencil:!0,failIfMajorPerformanceCaveat:pe.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!pe.ADAPTER.getWebGLRenderingContext())return!1;const t=pe.ADAPTER.createCanvas();let i=t.getContext("webgl",e)||t.getContext("experimental-webgl",e);const r=!!((n=i?.getContextAttributes())!=null&&n.stencil);if(i){const s=i.getExtension("WEBGL_lose_context");s&&s.loseContext()}return i=null,r}catch{return!1}})()),yl}var XE={grad:.9,turn:360,rad:360/(2*Math.PI)},Li=function(n){return typeof n=="string"?n.length>0:typeof n=="number"},wt=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=Math.pow(10,e)),Math.round(t*n)/t+0},ei=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),n>t?t:n>e?n:e},Cg=function(n){return(n=isFinite(n)?n%360:0)>0?n:n+360},$d=function(n){return{r:ei(n.r,0,255),g:ei(n.g,0,255),b:ei(n.b,0,255),a:ei(n.a)}},xl=function(n){return{r:wt(n.r),g:wt(n.g),b:wt(n.b),a:wt(n.a,3)}},WE=/^#([0-9a-f]{3,8})$/i,Js=function(n){var e=n.toString(16);return e.length<2?"0"+e:e},Ig=function(n){var e=n.r,t=n.g,i=n.b,r=n.a,s=Math.max(e,t,i),o=s-Math.min(e,t,i),a=o?s===e?(t-i)/o:s===t?2+(i-e)/o:4+(e-t)/o:0;return{h:60*(a<0?a+6:a),s:s?o/s*100:0,v:s/255*100,a:r}},Mg=function(n){var e=n.h,t=n.s,i=n.v,r=n.a;e=e/360*6,t/=100,i/=100;var s=Math.floor(e),o=i*(1-t),a=i*(1-(e-s)*t),l=i*(1-(1-e+s)*t),h=s%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:r}},Zd=function(n){return{h:Cg(n.h),s:ei(n.s,0,100),l:ei(n.l,0,100),a:ei(n.a)}},Kd=function(n){return{h:wt(n.h),s:wt(n.s),l:wt(n.l),a:wt(n.a,3)}},Jd=function(n){return Mg((t=(e=n).s,{h:e.h,s:(t*=((i=e.l)<50?i:100-i)/100)>0?2*t/(i+t)*100:0,v:i+t,a:e.a}));var e,t,i},ps=function(n){return{h:(e=Ig(n)).h,s:(r=(200-(t=e.s))*(i=e.v)/100)>0&&r<200?t*i/100/(r<=100?r:200-r)*100:0,l:r/2,a:e.a};var e,t,i,r},YE=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,qE=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,$E=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\
vendor: 6,874 bytes, line 79
79s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ZE=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ah={string:[[function(n){var e=WE.exec(n);return e?(n=e[1]).length<=4?{r:parseInt(n[0]+n[0],16),g:parseInt(n[1]+n[1],16),b:parseInt(n[2]+n[2],16),a:n.length===4?wt(parseInt(n[3]+n[3],16)/255,2):1}:n.length===6||n.length===8?{r:parseInt(n.substr(0,2),16),g:parseInt(n.substr(2,2),16),b:parseInt(n.substr(4,2),16),a:n.length===8?wt(parseInt(n.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(n){var e=$E.exec(n)||ZE.exec(n);return e?e[2]!==e[4]||e[4]!==e[6]?null:$d({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(n){var e=YE.exec(n)||qE.exec(n);if(!e)return null;var t,i,r=Zd({h:(t=e[1],i=e[2],i===void 0&&(i="deg"),Number(t)*(XE[i]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return Jd(r)},"hsl"]],object:[[function(n){var e=n.r,t=n.g,i=n.b,r=n.a,s=r===void 0?1:r;return Li(e)&&Li(t)&&Li(i)?$d({r:Number(e),g:Number(t),b:Number(i),a:Number(s)}):null},"rgb"],[function(n){var e=n.h,t=n.s,i=n.l,r=n.a,s=r===void 0?1:r;if(!Li(e)||!Li(t)||!Li(i))return null;var o=Zd({h:Number(e),s:Number(t),l:Number(i),a:Number(s)});return Jd(o)},"hsl"],[function(n){var e=n.h,t=n.s,i=n.v,r=n.a,s=r===void 0?1:r;if(!Li(e)||!Li(t)||!Li(i))return null;var o=(function(a){return{h:Cg(a.h),s:ei(a.s,0,100),v:ei(a.v,0,100),a:ei(a.a)}})({h:Number(e),s:Number(t),v:Number(i),a:Number(s)});return Mg(o)},"hsv"]]},Qd=function(n,e){for(var t=0;t<e.length;t++){var i=e[t][0](n);if(i)return[i,e[t][1]]}return[null,void 0]},KE=function(n){return typeof n=="string"?Qd(n.trim(),ah.string):typeof n=="object"&&n!==null?Qd(n,ah.object):[null,void 0]},_l=function(n,e){var t=ps(n);return{h:t.h,s:ei(t.s+100*e,0,100),l:t.l,a:t.a}},wl=function(n){return(299*n.r+587*n.g+114*n.b)/1e3/255},ef=function(n,e){var t=ps(n);return{h:t.h,s:t.s,l:ei(t.l+100*e,0,100),a:t.a}},lh=(function(){function n(e){this.parsed=KE(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return n.prototype.isValid=function(){return this.parsed!==null},n.prototype.brightness=function(){return wt(wl(this.rgba),2)},n.prototype.isDark=function(){return wl(this.rgba)<.5},n.prototype.isLight=function(){return wl(this.rgba)>=.5},n.prototype.toHex=function(){return e=xl(this.rgba),t=e.r,i=e.g,r=e.b,o=(s=e.a)<1?Js(wt(255*s)):"","#"+Js(t)+Js(i)+Js(r)+o;var e,t,i,r,s,o},n.prototype.toRgb=function(){return xl(this.rgba)},n.prototype.toRgbString=function(){return e=xl(this.rgba),t=e.r,i=e.g,r=e.b,(s=e.a)<1?"rgba("+t+", "+i+", "+r+", "+s+")":"rgb("+t+", "+i+", "+r+")";var e,t,i,r,s},n.prototype.toHsl=function(){return Kd(ps(this.rgba))},n.prototype.toHslString=function(){return e=Kd(ps(this.rgba)),t=e.h,i=e.s,r=e.l,(s=e.a)<1?"hsla("+t+", "+i+"%, "+r+"%, "+s+")":"hsl("+t+", "+i+"%, "+r+"%)";var e,t,i,r,s},n.prototype.toHsv=function(){return e=Ig(this.rgba),{h:wt(e.h),s:wt(e.s),v:wt(e.v),a:wt(e.a,3)};var e},n.prototype.invert=function(){return vi({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},n.prototype.saturate=function(e){return e===void 0&&(e=.1),vi(_l(this.rgba,e))},n.prototype.desaturate=function(e){return e===void 0&&(e=.1),vi(_l(this.rgba,-e))},n.prototype.grayscale=function(){return vi(_l(this.rgba,-1))},n.prototype.lighten=function(e){return e===void 0&&(e=.1),vi(ef(this.rgba,e))},n.prototype.darken=function(e){return e===void 0&&(e=.1),vi(ef(this.rgba,-e))},n.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},n.prototype.alpha=function(e){return typeof e=="number"?vi({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):wt(this.rgba.a,3);var t},n.prototype.hue=function(e){var t=ps(this.rgba);return typeof e=="number"?vi({h:e,s:t.s,l:t.l,a:t.a}):wt(t.h)},n.prototype.isEqual=function(e){return this.toHex()===vi(e).toHex()},n})(),vi=function(n){return n instanceof lh?n:new lh(n)},tf=[],JE=function(n){n.forEach(function(e){tf.indexOf(e)<0&&(e(lh,ah),tf.push(e))})};function QE(n,e){var t={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",s
vendor: 38,715 bytes, lines 79-95
79andybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var r in t)i[t[r]]=r;var s={};n.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(!s.length)for(var f in t)s[f]=new n(t[f]).toRgb();for(var p in t){var g=(a=u,l=s[p],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));g<c&&(c=g,d=p)}return d}},e.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":t[a];return l?new n(l).toRgb():null},"name"])}JE([QE]);const ur=class Ro{constructor(e=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=e}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(e){return this.value=e,this}set value(e){if(e instanceof Ro)this._value=this.cloneSource(e._value),this._int=e._int,this._components.set(e._components);else{if(e===null)throw new Error("Cannot set PIXI.Color#value to null");(this._value===null||!this.isSourceEqual(this._value,e))&&(this.normalize(e),this._value=this.cloneSource(e))}}get value(){return this._value}cloneSource(e){return typeof e=="string"||typeof e=="number"||e instanceof Number||e===null?e:Array.isArray(e)||ArrayBuffer.isView(e)?e.slice(0):typeof e=="object"&&e!==null?{...e}:e}isSourceEqual(e,t){const i=typeof e;if(i!==typeof t)return!1;if(i==="number"||i==="string"||e instanceof Number)return e===t;if(Array.isArray(e)&&Array.isArray(t)||ArrayBuffer.isView(e)&&ArrayBuffer.isView(t))return e.length!==t.length?!1:e.every((r,s)=>r===t[s]);if(e!==null&&t!==null){const r=Object.keys(e),s=Object.keys(t);return r.length!==s.length?!1:r.every(o=>e[o]===t[o])}return e===t}toRgba(){const[e,t,i,r]=this._components;return{r:e,g:t,b:i,a:r}}toRgb(){const[e,t,i]=this._components;return{r:e,g:t,b:i}}toRgbaString(){const[e,t,i]=this.toUint8RgbArray();return`rgba(${e},${t},${i},${this.alpha})`}toUint8RgbArray(e){const[t,i,r]=this._components;return e=e??[],e[0]=Math.round(t*255),e[1]=Math.round(i*255),e[2]=Math.round(r*255),e}toRgbArray(e){e=e??[];const[t,i,r]=this._components;return e[0]=t,e[1]=i,e[2]=r,e}toNumber(){return this._int}toLittleEndianNumber(){const e=this._int;return(e>>16)+(e&65280)+((e&255)<<16)}multiply(e){const[t,i,r,s]=Ro.temp.setValue(e)._components;return this._components[0]*=t,this._components[1]*=i,this._components[2]*=r,this._components[3]*=s,this.refreshInt(),this._value=null,this}premultiply(e,t=!0){return t&&(this._components[0]*=e,this._components[1]*=e,this._components[2]*=e),this._components[3]=e,this.refreshInt(),this._value=null,this}toPremultiplied(e,t=!0){if(e===1)return(255<<24)+this._int;if(e===0)return t?0:this._int;let i=this._int>>16&255,r=this._int>>8&255,s=this._int&255;return t&&(i=i*e+.5|0,r=r*e+.5|0,s=s*e+.5|0),(e*255<<24)+(i<<16)+(r<<8)+s}toHex(){const e=this._int.toString(16);return`#${"000000".substring(0,6-e.length)+e}`}toHexa(){const e=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-e.length)+e}setAlpha(e){return this._components[3]=this._clamp(e),this}round(e){const[t,i,r]=this._components;return this._components[0]=Math.round(t*e)/e,this._components[1]=Math.round(i*e)/e,this._components[2]=Math.round(r*e)/e,this.refreshInt(),this._value=null,this}toArray(e){e=e??[];const[t,i,r,s]=this._components;return e[0]=t,e[1]=i,e[2]=r,e[3]=s,e}normalize(e){let t,i,r,s;if((typeof e=="number"||e instanceof Number)&&e>=0&&e<=16777215){const o=e;t=(o>>16&255)/255,i=(o>>8&255)/255,r=(o&255)/255,s=1}else if((Array.isArray(e)||e instanceof Float32Array)&&e.length>=3&&e.length<=4)e=this._clamp(e),[t,i,r,s=1]=e;else if((e instanceof Uint8Array||e instanceof Uint8ClampedArray)&&e.length>=3&&e.length<=4)e=this._clamp(e,0,255),[t,i,r,s=255]=e,t/=255,i/=255,r/=255,s/=255;else if(typeof e=="string"||typeof e=="object"){if(typeof e=="string"){const a=Ro.HEX_PATTERN.exec(e);a&&(e=`#${a[2]}`)}const o=vi(e);o.isValid()&&({r:t,g:i,b:r,a:s}=o.rgba,t/=255,i/=255,r/=255)}if(t!==void 0)this._components[0]=t,this._components[1]=i,this._components[2]=r,this._components[3]=s,this.refreshInt();else throw new Error(`Unable to convert color ${e}`)}refreshInt(){this._clamp(this._components);const[e,t,i]=this._components;this._int=(e*255<<16)+(t*255<<8)+(i*255|0)}_clamp(e,t=0,i=1){return typeof e=="number"?Math.min(Math.max(e,t),i):(e.forEach((r,s)=>{e[s]=Math.min(Math.max(r,t),i)}),e)}};ur.shared=new ur,ur.temp=new ur,ur.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Ze=ur;function eb(n){return Ue("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),Ze.shared.setValue(n).toHex()}function tb(n){return Ue("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),Ze.shared.setValue(n).toNumber()}function ib(){const n=[],e=[];for(let i=0;i<32;i++)n[i]=i,e[i]=i;n[Ce.NORMAL_NPM]=Ce.NORMAL,n[Ce.ADD_NPM]=Ce.ADD,n[Ce.SCREEN_NPM]=Ce.SCREEN,e[Ce.NORMAL]=Ce.NORMAL_NPM,e[Ce.ADD]=Ce.ADD_NPM,e[Ce.SCREEN]=Ce.SCREEN_NPM;const t=[];return t.push(e),t.push(n),t}const Dg=ib();function Og(n,e){return Dg[e?1:0][n]}function nb(n,e=null){const t=n*6;if(e=e||new Uint16Array(t),e.length!==t)throw new Error(`Out buffer length is incorrect, got ${e.length} and expected ${t}`);for(let i=0,r=0;i<t;i+=6,r+=4)e[i+0]=r+0,e[i+1]=r+1,e[i+2]=r+2,e[i+3]=r+0,e[i+4]=r+2,e[i+5]=r+3;return e}function Lg(n){if(n.BYTES_PER_ELEMENT===4)return n instanceof Float32Array?"Float32Array":n instanceof Uint32Array?"Uint32Array":"Int32Array";if(n.BYTES_PER_ELEMENT===2){if(n instanceof Uint16Array)return"Uint16Array"}else if(n.BYTES_PER_ELEMENT===1&&n instanceof Uint8Array)return"Uint8Array";return null}function $o(n){return n+=n===0?1:0,--n,n|=n>>>1,n|=n>>>2,n|=n>>>4,n|=n>>>8,n|=n>>>16,n+1}function nf(n){return!(n&n-1)&&!!n}function rf(n){let e=(n>65535?1:0)<<4;n>>>=e;let t=(n>255?1:0)<<3;return n>>>=t,e|=t,t=(n>15?1:0)<<2,n>>>=t,e|=t,t=(n>3?1:0)<<1,n>>>=t,e|=t,e|n>>1}function br(n,e,t){const i=n.length;let r;if(e>=i||t===0)return;t=e+t>i?i-e:t;const s=i-t;for(r=e;r<s;++r)n[r]=n[r+t];n.length=s}function rn(n){return n===0?0:n<0?-1:1}let rb=0;function Xn(){return++rb}const hh=class{constructor(n,e,t,i){this.left=n,this.top=e,this.right=t,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}};hh.EMPTY=new hh(0,0,0,0);let sf=hh;const of={},yi=Object.create(null),qi=Object.create(null);class sb{constructor(e,t,i){this._canvas=pe.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||pe.RESOLUTION,this.resize(e,t)}clear(){this._checkDestroyed(),this._context.setTransform(1,0,0,1,0,0),this._context.clearRect(0,0,this._canvas.width,this._canvas.height)}resize(e,t){this._checkDestroyed(),this._canvas.width=Math.round(e*this.resolution),this._canvas.height=Math.round(t*this.resolution)}destroy(){this._context=null,this._canvas=null}get width(){return this._checkDestroyed(),this._canvas.width}set width(e){this._checkDestroyed(),this._canvas.width=Math.round(e)}get height(){return this._checkDestroyed(),this._canvas.height}set height(e){this._checkDestroyed(),this._canvas.height=Math.round(e)}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 af(n,e,t){for(let i=0,r=4*t*e;i<e;++i,r+=4)if(n[r+3]!==0)return!1;return!0}function lf(n,e,t,i,r){const s=4*e;for(let o=i,a=i*s+4*t;o<=r;++o,a+=s)if(n[a+3]!==0)return!1;return!0}function ob(n){const{width:e,height:t}=n,i=n.getContext("2d",{willReadFrequently:!0});if(i===null)throw new TypeError("Failed to get canvas 2D context");const r=i.getImageData(0,0,e,t).data;let s=0,o=0,a=e-1,l=t-1;for(;o<t&&af(r,e,o);)++o;if(o===t)return sf.EMPTY;for(;af(r,e,l);)--l;for(;lf(r,e,s,o,l);)++s;for(;lf(r,e,a,o,l);)--a;return++a,++l,new sf(s,o,a,l)}function ab(n){const e=ob(n),{width:t,height:i}=e;let r=null;if(!e.isEmpty()){const s=n.getContext("2d");if(s===null)throw new TypeError("Failed to get canvas 2D context");r=s.getImageData(e.left,e.top,t,i)}return{width:t,height:i,data:r}}function lb(n,e=globalThis.location){if(n.startsWith("data:"))return"";e=e||globalThis.location;const t=new URL(n,document.baseURI);return t.hostname!==e.hostname||t.port!==e.port||t.protocol!==e.protocol?"anonymous":""}function ji(n,e=1){var t;const i=(t=pe.RETINA_PREFIX)==null?void 0:t.exec(n);return i?parseFloat(i[1]):e}var ue=(n=>(n.Renderer="renderer",n.Application="application",n.RendererSystem="renderer-webgl-system",n.RendererPlugin="renderer-webgl-plugin",n.CanvasRendererSystem="renderer-canvas-system",n.CanvasRendererPlugin="renderer-canvas-plugin",n.Asset="asset",n.LoadParser="load-parser",n.ResolveParser="resolve-parser",n.CacheParser="cache-parser",n.DetectionParser="detection-parser",n))(ue||{});const uh=n=>{if(typeof n=="function"||typeof n=="object"&&n.extension){if(!n.extension)throw new Error("Extension class must have an extension object");n={...typeof n.extension!="object"?{type:n.extension}:n.extension,ref:n}}if(typeof n=="object")n={...n};else throw new Error("Invalid extension type");return typeof n.type=="string"&&(n.type=[n.type]),n},hf=(n,e)=>uh(n).priority??e,_e={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...n){return n.map(uh).forEach(e=>{e.type.forEach(t=>{var i,r;return(r=(i=this._removeHandlers)[t])==null?void 0:r.call(i,e)})}),this},add(...n){return n.map(uh).forEach(e=>{e.type.forEach(t=>{var i,r;const s=this._addHandlers,o=this._queue;s[t]?(i=s[t])==null||i.call(s,e):(o[t]=o[t]||[],(r=o[t])==null||r.push(e))})}),this},handle(n,e,t){var i;const r=this._addHandlers,s=this._removeHandlers;if(r[n]||s[n])throw new Error(`Extension type ${n} already has a handler`);r[n]=e,s[n]=t;const o=this._queue;return o[n]&&((i=o[n])==null||i.forEach(a=>e(a)),delete o[n]),this},handleByMap(n,e){return this.handle(n,t=>{t.name&&(e[t.name]=t.ref)},t=>{t.name&&delete e[t.name]})},handleByList(n,e,t=-1){return this.handle(n,i=>{e.includes(i.ref)||(e.push(i.ref),e.sort((r,s)=>hf(s,t)-hf(r,t)))},i=>{const r=e.indexOf(i.ref);r!==-1&&e.splice(r,1)})}};class ch{constructor(e){typeof e=="number"?this.rawBinaryData=new ArrayBuffer(e):e instanceof Uint8Array?this.rawBinaryData=e.buffer:this.rawBinaryData=e,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(e){return this[`${e}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(e){switch(e){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${e} isn't a valid view type`)}}}const hb=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` 80`);function ub(n){let e="";for(let t=0;t<n;++t)t>0&&(e+=` 81else `),t<n-1&&(e+=`if(test == ${t}.0){}`);return e}function cb(n,e){if(n===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const t=e.createShader(e.FRAGMENT_SHADER);for(;;){const i=hb.replace(/%forloop%/gi,ub(n));if(e.shaderSource(t,i),e.compileShader(t),!e.getShaderParameter(t,e.COMPILE_STATUS))n=n/2|0;else break}return n}const Tl=0,El=1,bl=2,Sl=3,Al=4,Rl=5;class Di{constructor(){this.data=0,this.blendMode=Ce.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Tl)}set blend(e){!!(this.data&1<<Tl)!==e&&(this.data^=1<<Tl)}get offsets(){return!!(this.data&1<<El)}set offsets(e){!!(this.data&1<<El)!==e&&(this.data^=1<<El)}get culling(){return!!(this.data&1<<bl)}set culling(e){!!(this.data&1<<bl)!==e&&(this.data^=1<<bl)}get depthTest(){return!!(this.data&1<<Sl)}set depthTest(e){!!(this.data&1<<Sl)!==e&&(this.data^=1<<Sl)}get depthMask(){return!!(this.data&1<<Rl)}set depthMask(e){!!(this.data&1<<Rl)!==e&&(this.data^=1<<Rl)}get clockwiseFrontFace(){return!!(this.data&1<<Al)}set clockwiseFrontFace(e){!!(this.data&1<<Al)!==e&&(this.data^=1<<Al)}get blendMode(){return this._blendMode}set blendMode(e){this.blend=e!==Ce.NONE,this._blendMode=e}get polygonOffset(){return this._polygonOffset}set polygonOffset(e){this.offsets=!!e,this._polygonOffset=e}static for2d(){const e=new Di;return e.depthTest=!1,e.blend=!0,e}}Di.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 Bg(n,e){if(!n)return null;let t="";if(typeof n=="string"){const i=/\.(\w{3,4})(?:$|\?|#)/i.exec(n);i&&(t=i[1].toLowerCase())}for(let i=dh.length-1;i>=0;--i){const r=dh[i];if(r.test&&r.test(n,t))return new r(n,e)}throw new Error("Unrecognized source type to auto-detect Resource")}class ci{constructor(e){this.items=[],this._name=e,this._aliasCount=0}emit(e,t,i,r,s,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](e,t,i,r,s,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(e){return e[this._name]&&(this.ensureNonAliasedItems(),this.remove(e),this.items.push(e)),this}remove(e){const t=this.items.indexOf(e);return t!==-1&&(this.ensureNonAliasedItems(),this.items.splice(t,1)),this}contains(e){return this.items.includes(e)}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(ci.prototype,{dispatch:{value:ci.prototype.emit},run:{value:ci.prototype.emit}});class Ms{constructor(e=0,t=0){this._width=e,this._height=t,this.destroyed=!1,this.internal=!1,this.onResize=new ci("setRealSize"),this.onUpdate=new ci("update"),this.onError=new ci("onError")}bind(e){this.onResize.add(e),this.onUpdate.add(e),this.onError.add(e),(this._width||this._height)&&this.onResize.emit(this._width,this._height)}unbind(e){this.onResize.remove(e),this.onUpdate.remove(e),this.onError.remove(e)}resize(e,t){(e!==this._width||t!==this._height)&&(this._width=e,this._height=t,this.onResize.emit(e,t))}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(e,t,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(e,t){return!1}}class Ta extends Ms{constructor(e,t){const{width:i,height:r}=t||{};if(!i||!r)throw new Error("BufferResource width or height invalid");super(i,r),this.data=e,this.unpackAlignment=t.unpackAlignment??4}upload(e,t,i){const r=e.gl;r.pixelStorei(r.UNPACK_ALIGNMENT,this.unpackAlignment),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.alphaMode===Ut.UNPACK);const s=t.realWidth,o=t.realHeight;return i.width===s&&i.height===o?r.texSubImage2D(t.target,0,0,0,s,o,t.format,i.type,this.data):(i.width=s,i.height=o,r.texImage2D(t.target,0,i.internalFormat,s,o,0,t.format,i.type,this.data)),!0}dispose(){this.data=null}static test(e){return e===null||e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array}}const db={scaleMode:Ni.NEAREST,alphaMode:Ut.NPM},fh=class cr extends Hs{constructor(e=null,t=null){super(),t=Object.assign({},cr.defaultOptions,t);const{alphaMode:i,mipmap:r,anisotropicLevel:s,scaleMode:o,width:a,height:l,wrapMode:h,format:u,type:c,target:d,resolution:f,resourceOptions:p}=t;e&&!(e instanceof Ms)&&(e=Bg(e,p),e.internal=!0),this.resolution=f||pe.RESOLUTION,this.width=Math.round((a||0)*this.resolution)/this.resolution,this.height=Math.round((l||0)*this.resolution)/this.resolution,this._mipmap=r,this.anisotropicLevel=s,this._wrapMode=h,this._scaleMode=o,this.format=u,this.type=c,this.target=d,this.alphaMode=i,this.uid=Xn(),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(e)}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(e){this._mipmap!==e&&(this._mipmap=e,this.dirtyStyleId++)}get scaleMode(){return this._scaleMode}set scaleMode(e){this._scaleMode!==e&&(this._scaleMode=e,this.dirtyStyleId++)}get wrapMode(){return this._wrapMode}set wrapMode(e){this._wrapMode!==e&&(this._wrapMode=e,this.dirtyStyleId++)}setStyle(e,t){let i;return e!==void 0&&e!==this.scaleMode&&(this.scaleMode=e,i=!0),t!==void 0&&t!==this.mipmap&&(this.mipmap=t,i=!0),i&&this.dirtyStyleId++,this}setSize(e,t,i){return i=i||this.resolution,this.setRealSize(e*i,t*i,i)}setRealSize(e,t,i){return this.resolution=i||this.resolution,this.width=Math.round(e)/this.resolution,this.height=Math.round(t)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=nf(this.realWidth)&&nf(this.realHeight)}setResolution(e){const t=this.resolution;return t===e?this:(this.resolution=e,this.valid&&(this.width=Math.round(this.width*t)/e,this.height=Math.round(this.height*t)/e,this.emit("update",this)),this._refreshPOT(),this)}setResource(e){if(this.resource===e)return this;if(this.resource)throw new Error("Resource can be set only once");return e.bind(this),this.resource=e,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(e){this.emit("error",this,e)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete qi[this.cacheId],delete yi[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),cr.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(e,t,i=pe.STRICT_TEXTURE_CACHE){const r=typeof e=="string";let s=null;if(r)s=e;else{if(!e._pixiId){const a=t?.pixiIdPrefix||"pixiid";e._pixiId=`${a}_${Xn()}`}s=e._pixiId}let o=qi[s];if(r&&i&&!o)throw new Error(`The cacheId "${s}" does not exist in BaseTextureCache.`);return o||(o=new cr(e,t),o.cacheId=s,cr.addToCache(o,s)),o}static fromBuffer(e,t,i,r){e=e||new Float32Array(t*i*4);const s=new Ta(e,{width:t,height:i,...r?.resourceOptions});let o,a;return e instanceof Float32Array?(o=oe.RGBA,a=Ee.FLOAT):e instanceof Int32Array?(o=oe.RGBA_INTEGER,a=Ee.INT):e instanceof Uint32Array?(o=oe.RGBA_INTEGER,a=Ee.UNSIGNED_INT):e instanceof Int16Array?(o=oe.RGBA_INTEGER,a=Ee.SHORT):e instanceof Uint16Array?(o=oe.RGBA_INTEGER,a=Ee.UNSIGNED_SHORT):e instanceof Int8Array?(o=oe.RGBA,a=Ee.BYTE):(o=oe.RGBA,a=Ee.UNSIGNED_BYTE),s.internal=!0,new cr(s,Object.assign({},db,{type:a,format:o},r))}static addToCache(e,t){t&&(e.textureCacheIds.includes(t)||e.textureCacheIds.push(t),qi[t]&&qi[t]!==e&&console.warn(`BaseTexture added to the cache with an id [${t}] that already had an entry`),qi[t]=e)}static removeFromCache(e){if(typeof e=="string"){const t=qi[e];if(t){const i=t.textureCacheIds.indexOf(e);return i>-1&&t.textureCacheIds.splice(i,1),delete qi[e],t}}else if(e!=null&&e.textureCacheIds){for(let t=0;t<e.textureCacheIds.length;++t)delete qi[e.textureCacheIds[t]];return e.textureCacheIds.length=0,e}return null}};fh.defaultOptions={mipmap:Mi.POW2,anisotropicLevel:0,scaleMode:Ni.LINEAR,wrapMode:ln.CLAMP,alphaMode:Ut.UNPACK,target:Tr.TEXTURE_2D,format:oe.RGBA,type:Ee.UNSIGNED_BYTE},fh._globalBatch=0;let Le=fh;class ph{constructor(){this.texArray=null,this.blend=0,this.type=bi.TRIANGLES,this.start=0,this.size=0,this.data=null}}let fb=0;class dt{constructor(e,t=!0,i=!1){this.data=e||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=i,this.static=t,this.id=fb++,this.disposeRunner=new ci("disposeBuffer")}update(e){e instanceof Array&&(e=new Float32Array(e)),this.data=e||this.data,this._updateID++}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.data=null}set index(e){this.type=e?Ci.ELEMENT_ARRAY_BUFFER:Ci.ARRAY_BUFFER}get index(){return this.type===Ci.ELEMENT_ARRAY_BUFFER}static from(e){return e instanceof Array&&(e=new Float32Array(e)),new dt(e)}}class Zo{constructor(e,t=0,i=!1,r=Ee.FLOAT,s,o,a,l=1){this.buffer=e,this.size=t,this.normalized=i,this.type=r,this.stride=s,this.start=o,this.instance=a,this.divisor=l}destroy(){this.buffer=null}static from(e,t,i,r,s){return new Zo(e,t,i,r,s)}}const pb={Float32Array,Uint32Array,Int32Array,Uint8Array};function gb(n,e){let t=0,i=0;const r={};for(let l=0;l<n.length;l++)i+=e[l],t+=n[l].length;const s=new ArrayBuffer(t*4);let o=null,a=0;for(let l=0;l<n.length;l++){const h=e[l],u=n[l],c=Lg(u);r[c]||(r[c]=new pb[c](s)),o=r[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(s)}const uf={5126:4,5123:2,5121:1};let mb=0;const vb={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class fn{constructor(e=[],t={}){this.buffers=e,this.indexBuffer=null,this.attributes=t,this.glVertexArrayObjects={},this.id=mb++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new ci("disposeGeometry"),this.refCount=0}addAttribute(e,t,i=0,r=!1,s,o,a,l=!1){if(!t)throw new Error("You must pass a buffer when creating an attribute");t instanceof dt||(t instanceof Array&&(t=new Float32Array(t)),t=new dt(t));const h=e.split("|");if(h.length>1){for(let c=0;c<h.length;c++)this.addAttribute(h[c],t,i,r,s);return this}let u=this.buffers.indexOf(t);return u===-1&&(this.buffers.push(t),u=this.buffers.length-1),this.attributes[e]=new Zo(u,i,r,s,o,a,l),this.instanced=this.instanced||l,this}getAttribute(e){return this.attributes[e]}getBuffer(e){return this.buffers[this.getAttribute(e).buffer]}addIndex(e){return e instanceof dt||(e instanceof Array&&(e=new Uint16Array(e)),e=new dt(e)),e.type=Ci.ELEMENT_ARRAY_BUFFER,this.indexBuffer=e,this.buffers.includes(e)||this.buffers.push(e),this}getIndex(){return this.indexBuffer}interleave(){if(this.buffers.length===1||this.buffers.length===2&&this.indexBuffer)return this;const e=[],t=[],i=new dt;let r;for(r in this.attributes){const s=this.attributes[r],o=this.buffers[s.buffer];e.push(o.data),t.push(s.size*uf[s.type]/4),s.buffer=0}for(i.data=gb(e,t),r=0;r<this.buffers.length;r++)this.buffers[r]!==this.indexBuffer&&this.buffers[r].destroy();return this.buffers=[i],this.indexBuffer&&this.buffers.push(this.indexBuffer),this}getSize(){for(const e in this.attributes){const t=this.attributes[e];return this.buffers[t.buffer].data.length/(t.stride/4||t.size)}return 0}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.buffers=null,this.indexBuffer=null,this.attributes=null}clone(){const e=new fn;for(let t=0;t<this.buffers.length;t++)e.buffers[t]=new dt(this.buffers[t].data.slice(0));for(const t in this.attributes){const i=this.attributes[t];e.attributes[t]=new Zo(i.buffer,i.size,i.normalized,i.type,i.stride,i.start,i.instance)}return this.indexBuffer&&(e.indexBuffer=e.buffers[this.buffers.indexOf(this.indexBuffer)],e.indexBuffer.type=Ci.ELEMENT_ARRAY_BUFFER),e}static merge(e){const t=new fn,i=[],r=[],s=[];let o;for(let a=0;a<e.length;a++){o=e[a];for(let l=0;l<o.buffers.length;l++)r[l]=r[l]||0,r[l]+=o.buffers[l].data.length,s[l]=0}for(let a=0;a<o.buffers.length;a++)i[a]=new vb[Lg(o.buffers[a].data)](r[a]),t.buffers[a]=new dt(i[a]);for(let a=0;a<e.length;a++){o=e[a];for(let l=0;l<o.buffers.length;l++)i[l].set(o.buffers[l].data,s[l]),s[l]+=o.buffers[l].data.length}if(t.attributes=o.attributes,o.indexBuffer){t.indexBuffer=t.buffers[o.buffers.indexOf(o.indexBuffer)],t.indexBuffer.type=Ci.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*uf[d.type]/4)}for(let c=0;c<e.length;c++){const d=e[c].indexBuffer.data;for(let f=0;f<d.length;f++)t.indexBuffer.data[f+h]+=a;a+=e[c].buffers[u].data.length/l,h+=d.length}}return t}}class Fg extends fn{constructor(e=!1){super(),this._buffer=new dt(null,e,!1),this._indexBuffer=new dt(null,e,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,Ee.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,Ee.FLOAT).addAttribute("aColor",this._buffer,4,!0,Ee.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,Ee.FLOAT).addIndex(this._indexBuffer)}}const Ko=Math.PI*2,yb=180/Math.PI,xb=Math.PI/180;var Pt=(n=>(n[n.POLY=0]="POLY",n[n.RECT=1]="RECT",n[n.CIRC=2]="CIRC",n[n.ELIP=3]="ELIP",n[n.RREC=4]="RREC",n))(Pt||{});class ze{constructor(e=0,t=0){this.x=0,this.y=0,this.x=e,this.y=t}clone(){return new ze(this.x,this.y)}copyFrom(e){return this.set(e.x,e.y),this}copyTo(e){return e.set(this.x,this.y),e}equals(e){return e.x===this.x&&e.y===this.y}set(e=0,t=e){return this.x=e,this.y=t,this}}ze.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const Qs=[new ze,new ze,new ze,new ze];class Fe{constructor(e=0,t=0,i=0,r=0){this.x=Number(e),this.y=Number(t),this.width=Number(i),this.height=Number(r),this.type=Pt.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 Fe(0,0,0,0)}clone(){return new Fe(this.x,this.y,this.width,this.height)}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}copyTo(e){return e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e}contains(e,t){return this.width<=0||this.height<=0?!1:e>=this.x&&e<this.x+this.width&&t>=this.y&&t<this.y+this.height}intersects(e,t){if(!t){const L=this.x<e.x?e.x:this.x;if((this.right>e.right?e.right:this.right)<=L)return!1;const k=this.y<e.y?e.y:this.y;return(this.bottom>e.bottom?e.bottom:this.bottom)>k}const i=this.left,r=this.right,s=this.top,o=this.bottom;if(r<=i||o<=s)return!1;const a=Qs[0].set(e.left,e.top),l=Qs[1].set(e.left,e.bottom),h=Qs[2].set(e.right,e.top),u=Qs[3].set(e.right,e.bottom);if(h.x<=a.x||l.y<=a.y)return!1;const c=Math.sign(t.a*t.d-t.b*t.c);if(c===0||(t.apply(a,a),t.apply(l,l),t.apply(h,h),t.apply(u,u),Math.max(a.x,l.x,h.x,u.x)<=i||Math.min(a.x,l.x,h.x,u.x)>=r||Math.max(a.y,l.y,h.y,u.y)<=s||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*s,g=d*r+f*s,v=d*i+f*o,m=d*r+f*o;if(Math.max(p,g,v,m)<=d*a.x+f*a.y||Math.min(p,g,v,m)>=d*u.x+f*u.y)return!1;const x=c*(a.y-h.y),y=c*(h.x-a.x),E=x*i+y*s,R=x*r+y*s,P=x*i+y*o,S=x*r+y*o;return!(Math.max(E,R,P,S)<=x*a.x+y*a.y||Math.min(E,R,P,S)>=x*u.x+y*u.y)}pad(e=0,t=e){return this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2,this}fit(e){const t=Math.max(this.x,e.x),i=Math.min(this.x+this.width,e.x+e.width),r=Math.max(this.y,e.y),s=Math.min(this.y+this.height,e.y+e.height);return this.x=t,this.width=Math.max(i-t,0),this.y=r,this.height=Math.max(s-r,0),this}ceil(e=1,t=.001){const i=Math.ceil((this.x+this.width-t)*e)/e,r=Math.ceil((this.y+this.height-t)*e)/e;return this.x=Math.floor((this.x+t)*e)/e,this.y=Math.floor((this.y+t)*e)/e,this.width=i-this.x,this.height=r-this.y,this}enlarge(e){const t=Math.min(this.x,e.x),i=Math.max(this.x+this.width,e.x+e.width),r=Math.min(this.y,e.y),s=Math.max(this.y+this.height,e.y+e.height);return this.x=t,this.width=i-t,this.y=r,this.height=s-r,this}}Fe.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Ea{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.radius=i,this.type=Pt.CIRC}clone(){return new Ea(this.x,this.y,this.radius)}contains(e,t){if(this.radius<=0)return!1;const i=this.radius*this.radius;let r=this.x-e,s=this.y-t;return r*=r,s*=s,r+s<=i}getBounds(){return new Fe(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}Ea.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class ba{constructor(e=0,t=0,i=0,r=0){this.x=e,this.y=t,this.width=i,this.height=r,this.type=Pt.ELIP}clone(){return new ba(this.x,this.y,this.width,this.height)}contains(e,t){if(this.width<=0||this.height<=0)return!1;let i=(e-this.x)/this.width,r=(t-this.y)/this.height;return i*=i,r*=r,i+r<=1}getBounds(){return new Fe(this.x-this.width,this.y-this.height,this.width,this.height)}}ba.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class kn{constructor(...e){let t=Array.isArray(e[0])?e[0]:e;if(typeof t[0]!="number"){const i=[];for(let r=0,s=t.length;r<s;r++)i.push(t[r].x,t[r].y);t=i}this.points=t,this.type=Pt.POLY,this.closeStroke=!0}clone(){const e=this.points.slice(),t=new kn(e);return t.closeStroke=this.closeStroke,t}contains(e,t){let i=!1;const r=this.points.length/2;for(let s=0,o=r-1;s<r;o=s++){const a=this.points[s*2],l=this.points[s*2+1],h=this.points[o*2],u=this.points[o*2+1];l>t!=u>t&&e<(h-a)*((t-l)/(u-l))+a&&(i=!i)}return i}}kn.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((n,e)=>`${n}, ${e}`,"")}]`};class Sa{constructor(e=0,t=0,i=0,r=0,s=20){this.x=e,this.y=t,this.width=i,this.height=r,this.radius=s,this.type=Pt.RREC}clone(){return new Sa(this.x,this.y,this.width,this.height,this.radius)}contains(e,t){if(this.width<=0||this.height<=0)return!1;if(e>=this.x&&e<=this.x+this.width&&t>=this.y&&t<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(t>=this.y+i&&t<=this.y+this.height-i||e>=this.x+i&&e<=this.x+this.width-i)return!0;let r=e-(this.x+i),s=t-(this.y+i);const o=i*i;if(r*r+s*s<=o||(r=e-(this.x+this.width-i),r*r+s*s<=o)||(s=t-(this.y+this.height-i),r*r+s*s<=o)||(r=e-(this.x+i),r*r+s*s<=o))return!0}return!1}}Sa.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class tt{constructor(e=1,t=0,i=0,r=1,s=0,o=0){this.array=null,this.a=e,this.b=t,this.c=i,this.d=r,this.tx=s,this.ty=o}fromArray(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]}set(e,t,i,r,s,o){return this.a=e,this.b=t,this.c=i,this.d=r,this.tx=s,this.ty=o,this}toArray(e,t){this.array||(this.array=new Float32Array(9));const i=t||this.array;return e?(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(e,t){t=t||new ze;const i=e.x,r=e.y;return t.x=this.a*i+this.c*r+this.tx,t.y=this.b*i+this.d*r+this.ty,t}applyInverse(e,t){t=t||new ze;const i=1/(this.a*this.d+this.c*-this.b),r=e.x,s=e.y;return t.x=this.d*i*r+-this.c*i*s+(this.ty*this.c-this.tx*this.d)*i,t.y=this.a*i*s+-this.b*i*r+(-this.ty*this.a+this.tx*this.b)*i,t}translate(e,t){return this.tx+=e,this.ty+=t,this}scale(e,t){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this}rotate(e){const t=Math.cos(e),i=Math.sin(e),r=this.a,s=this.c,o=this.tx;return this.a=r*t-this.b*i,this.b=r*i+this.b*t,this.c=s*t-this.d*i,this.d=s*i+this.d*t,this.tx=o*t-this.ty*i,this.ty=o*i+this.ty*t,this}append(e){const t=this.a,i=this.b,r=this.c,s=this.d;return this.a=e.a*t+e.b*r,this.b=e.a*i+e.b*s,this.c=e.c*t+e.d*r,this.d=e.c*i+e.d*s,this.tx=e.tx*t+e.ty*r+this.tx,this.ty=e.tx*i+e.ty*s+this.ty,this}setTransform(e,t,i,r,s,o,a,l,h){return this.a=Math.cos(a+h)*s,this.b=Math.sin(a+h)*s,this.c=-Math.sin(a-l)*o,this.d=Math.cos(a-l)*o,this.tx=e-(i*this.a+r*this.c),this.ty=t-(i*this.b+r*this.d),this}prepend(e){const t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){const i=this.a,r=this.c;this.a=i*e.a+this.b*e.c,this.b=i*e.b+this.b*e.d,this.c=r*e.a+this.d*e.c,this.d=r*e.b+this.d*e.d}return this.tx=t*e.a+this.ty*e.c+e.tx,this.ty=t*e.b+this.ty*e.d+e.ty,this}decompose(e){const t=this.a,i=this.b,r=this.c,s=this.d,o=e.pivot,a=-Math.atan2(-r,s),l=Math.atan2(i,t),h=Math.abs(a+l);return h<1e-5||Math.abs(Ko-h)<1e-5?(e.rotation=l,e.skew.x=e.skew.y=0):(e.rotation=0,e.skew.x=a,e.skew.y=l),e.scale.x=Math.sqrt(t*t+i*i),e.scale.y=Math.sqrt(r*r+s*s),e.position.x=this.tx+(o.x*t+o.y*r),e.position.y=this.ty+(o.x*i+o.y*s),e}invert(){const e=this.a,t=this.b,i=this.c,r=this.d,s=this.tx,o=e*r-t*i;return this.a=r/o,this.b=-t/o,this.c=-i/o,this.d=e/o,this.tx=(i*this.ty-r*s)/o,this.ty=-(e*this.ty-t*s)/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 e=new tt;return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}static get IDENTITY(){return new tt}static get TEMP_MATRIX(){return new tt}}tt.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 En=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],bn=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Sn=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],An=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],gh=[],Ng=[],eo=Math.sign;function _b(){for(let n=0;n<16;n++){const e=[];gh.push(e);for(let t=0;t<16;t++){const i=eo(En[n]*En[t]+Sn[n]*bn[t]),r=eo(bn[n]*En[t]+An[n]*bn[t]),s=eo(En[n]*Sn[t]+Sn[n]*An[t]),o=eo(bn[n]*Sn[t]+An[n]*An[t]);for(let a=0;a<16;a++)if(En[a]===i&&bn[a]===r&&Sn[a]===s&&An[a]===o){e.push(a);break}}}for(let n=0;n<16;n++){const e=new tt;e.set(En[n],bn[n],Sn[n],An[n],0,0),Ng.push(e)}}_b();const rt={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:n=>En[n],uY:n=>bn[n],vX:n=>Sn[n],vY:n=>An[n],inv:n=>n&8?n&15:-n&7,add:(n,e)=>gh[n][e],sub:(n,e)=>gh[n][rt.inv(e)],rotate180:n=>n^4,isVertical:n=>(n&3)===2,byDirection:(n,e)=>Math.abs(n)*2<=Math.abs(e)?e>=0?rt.S:rt.N:Math.abs(e)*2<=Math.abs(n)?n>0?rt.E:rt.W:e>0?n>0?rt.SE:rt.SW:n>0?rt.NE:rt.NW,matrixAppendRotationInv:(n,e,t=0,i=0)=>{const r=Ng[rt.inv(e)];r.tx=t,r.ty=i,n.append(r)}};class Ui{constructor(e,t,i=0,r=0){this._x=i,this._y=r,this.cb=e,this.scope=t}clone(e=this.cb,t=this.scope){return new Ui(e,t,this._x,this._y)}set(e=0,t=e){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this.cb.call(this.scope)),this}copyFrom(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this.cb.call(this.scope)),this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return e.x===this._x&&e.y===this._y}get x(){return this._x}set x(e){this._x!==e&&(this._x=e,this.cb.call(this.scope))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this.cb.call(this.scope))}}Ui.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const mh=class{constructor(){this.worldTransform=new tt,this.localTransform=new tt,this.position=new Ui(this.onChange,this,0,0),this.scale=new Ui(this.onChange,this,1,1),this.pivot=new Ui(this.onChange,this,0,0),this.skew=new Ui(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 n=this.localTransform;this._localID!==this._currentLocalID&&(n.a=this._cx*this.scale.x,n.b=this._sx*this.scale.x,n.c=this._cy*this.scale.y,n.d=this._sy*this.scale.y,n.tx=this.position.x-(this.pivot.x*n.a+this.pivot.y*n.c),n.ty=this.position.y-(this.pivot.x*n.b+this.pivot.y*n.d),this._currentLocalID=this._localID,this._parentID=-1)}updateTransform(n){const e=this.localTransform;if(this._localID!==this._currentLocalID&&(e.a=this._cx*this.scale.x,e.b=this._sx*this.scale.x,e.c=this._cy*this.scale.y,e.d=this._sy*this.scale.y,e.tx=this.position.x-(this.pivot.x*e.a+this.pivot.y*e.c),e.ty=this.position.y-(this.pivot.x*e.b+this.pivot.y*e.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==n._worldID){const t=n.worldTransform,i=this.worldTransform;i.a=e.a*t.a+e.b*t.c,i.b=e.a*t.b+e.b*t.d,i.c=e.c*t.a+e.d*t.c,i.d=e.c*t.b+e.d*t.d,i.tx=e.tx*t.a+e.ty*t.c+t.tx,i.ty=e.tx*t.b+e.ty*t.d+t.ty,this._parentID=n._worldID,this._worldID++}}setFromMatrix(n){n.decompose(this),this._localID++}get rotation(){return this._rotation}set rotation(n){this._rotation!==n&&(this._rotation=n,this.updateSkew())}};mh.IDENTITY=new mh;let yu=mh;yu.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 wb=`varying vec2 vTextureCoord; 82 83uniform sampler2D uSampler; 84 85void main(void){ 86 gl_FragColor *= texture2D(uSampler, vTextureCoord); 87}`,Tb=`attribute vec2 aVertexPosition; 88attribute vec2 aTextureCoord; 89 90uniform mat3 projectionMatrix; 91 92varying vec2 vTextureCoord; 93 94void main(void){ 95 gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0
95)).xy, 0.0, 1.0); 96 vTextureCoord = aTextureCoord; 97} 98`;function cf(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}function Pl(n){const e=new Array(n);for(let t=0;t<e.length;t++)e[t]=!1;return e}function kg(n,e){switch(n){case"float":return 0;case"vec2":return new Float32Array(2*e);case"vec3":return new Float32Array(3*e);case"vec4":return new Float32Array(4*e);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*e);case"ivec3":return new Int32Array(3*e);case"ivec4":return new Int32Array(4*e);case"uvec2":return new Uint32Array(2*e);case"uvec3":return new Uint32Array(3*e);case"uvec4":return new Uint32Array(4*e);case"bool":return!1;case"bvec2":return Pl(2*e);case"bvec3":return Pl(3*e);case"bvec4":return Pl(4*e);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 Sr=[{test:n=>n.type==="float"&&n.size===1&&!n.isArray,code:n=>` 99 if(uv["${n}"] !== ud["${n}"].value) 100 { 101 ud["${n}"].value = uv["${n}"] 102 gl.uniform1f(ud["${n}"].location, uv["${n}"]) 103 } 104 `},{test:(n,e)=>(n.type==="sampler2D"||n.type==="samplerCube"||n.type==="sampler2DArray")&&n.size===1&&!n.isArray&&(e==null||e.castToBaseTexture!==void 0),code:n=>`t = syncData.textureCount++; 105 106 renderer.texture.bind(uv["${n}"], t); 107 108 if(ud["${n}"].value !== t) 109 { 110 ud["${n}"].value = t; 111 gl.uniform1i(ud["${n}"].location, t); 112; // eslint-disable-line max-len 113 }`},{test:(n,e)=>n.type==="mat3"&&n.size===1&&!n.isArray&&e.a!==void 0,code:n=>` 114 gl.uniformMatrix3fv(ud["${n}"].location, false, uv["${n}"].toArray(true)); 115 `,codeUbo:n=>` 116 var ${n}_matrix = uv.${n}.toArray(true); 117 118 data[offset] = ${n}_matrix[0]; 119 data[offset+1] = ${n}_matrix[1]; 120 data[offset+2] = ${n}_matrix[2]; 121 122 data[offset + 4] = ${n}_matrix[3]; 123 data[offset + 5] = ${n}_matrix[4]; 124 data[offset + 6] = ${n}_matrix[5]; 125 126 data[offset + 8] = ${n}_matrix[6]; 127 data[offset + 9] = ${n}_matrix[7]; 128 data[offset + 10] = ${n}_matrix[8]; 129 `},{test:(n,e)=>n.type==="vec2"&&n.size===1&&!n.isArray&&e.x!==void 0,code:n=>` 130 cv = ud["${n}"].value; 131 v = uv["${n}"]; 132 133 if(cv[0] !== v.x || cv[1] !== v.y) 134 { 135 cv[0] = v.x; 136 cv[1] = v.y; 137 gl.uniform2f(ud["${n}"].location, v.x, v.y); 138 }`,codeUbo:n=>` 139 v = uv.${n}; 140 141 data[offset] = v.x; 142 data[offset+1] = v.y; 143 `},{test:n=>n.type==="vec2"&&n.size===1&&!n.isArray,code:n=>` 144 cv = ud["${n}"].value; 145 v = uv["${n}"]; 146 147 if(cv[0] !== v[0] || cv[1] !== v[1]) 148 { 149 cv[0] = v[0]; 150 cv[1] = v[1]; 151 gl.uniform2f(ud["${n}"].location, v[0], v[1]); 152 } 153 `},{test:(n,e)=>n.type==="vec4"&&n.size===1&&!n.isArray&&e.width!==void 0,code:n=>` 154 cv = ud["${n}"].value; 155 v = uv["${n}"]; 156 157 if(cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) 158 { 159 cv[0] = v.x; 160 cv[1] = v.y; 161 cv[2] = v.width; 162 cv[3] = v.height; 163 gl.uniform4f(ud["${n}"].location, v.x, v.y, v.width, v.height) 164 }`,codeUbo:n=>` 165 v = uv.${n}; 166 167 data[offset] = v.x; 168 data[offset+1] = v.y; 169 data[offset+2] = v.width; 170 data[offset+3] = v.height; 171 `},{test:(n,e)=>n.type==="vec4"&&n.size===1&&!n.isArray&&e.red!==void 0,code:n=>` 172 cv = ud["${n}"].value; 173 v = uv["${n}"]; 174 175 if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) 176 { 177 cv[0] = v.red; 178 cv[1] = v.green; 179 cv[2] = v.blue; 180 cv[3] = v.alpha; 181 gl.uniform4f(ud["${n}"].location, v.red, v.green, v.blue, v.alpha) 182 }`,codeUbo:n=>
vendor: 13,440 bytes, lines 182-408
182` 183 v = uv.${n}; 184 185 data[offset] = v.red; 186 data[offset+1] = v.green; 187 data[offset+2] = v.blue; 188 data[offset+3] = v.alpha; 189 `},{test:(n,e)=>n.type==="vec3"&&n.size===1&&!n.isArray&&e.red!==void 0,code:n=>` 190 cv = ud["${n}"].value; 191 v = uv["${n}"]; 192 193 if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.a) 194 { 195 cv[0] = v.red; 196 cv[1] = v.green; 197 cv[2] = v.blue; 198 199 gl.uniform3f(ud["${n}"].location, v.red, v.green, v.blue) 200 }`,codeUbo:n=>` 201 v = uv.${n}; 202 203 data[offset] = v.red; 204 data[offset+1] = v.green; 205 data[offset+2] = v.blue; 206 `},{test:n=>n.type==="vec4"&&n.size===1&&!n.isArray,code:n=>` 207 cv = ud["${n}"].value; 208 v = uv["${n}"]; 209 210 if(cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) 211 { 212 cv[0] = v[0]; 213 cv[1] = v[1]; 214 cv[2] = v[2]; 215 cv[3] = v[3]; 216 217 gl.uniform4f(ud["${n}"].location, v[0], v[1], v[2], v[3]) 218 }`}],Eb={float:` 219 if (cv !== v) 220 { 221 cu.value = v; 222 gl.uniform1f(location, v); 223 }`,vec2:` 224 if (cv[0] !== v[0] || cv[1] !== v[1]) 225 { 226 cv[0] = v[0]; 227 cv[1] = v[1]; 228 229 gl.uniform2f(location, v[0], v[1]) 230 }`,vec3:` 231 if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) 232 { 233 cv[0] = v[0]; 234 cv[1] = v[1]; 235 cv[2] = v[2]; 236 237 gl.uniform3f(location, v[0], v[1], v[2]) 238 }`,vec4:` 239 if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) 240 { 241 cv[0] = v[0]; 242 cv[1] = v[1]; 243 cv[2] = v[2]; 244 cv[3] = v[3]; 245 246 gl.uniform4f(location, v[0], v[1], v[2], v[3]); 247 }`,int:` 248 if (cv !== v) 249 { 250 cu.value = v; 251 252 gl.uniform1i(location, v); 253 }`,ivec2:` 254 if (cv[0] !== v[0] || cv[1] !== v[1]) 255 { 256 cv[0] = v[0]; 257 cv[1] = v[1]; 258 259 gl.uniform2i(location, v[0], v[1]); 260 }`,ivec3:` 261 if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) 262 { 263 cv[0] = v[0]; 264 cv[1] = v[1]; 265 cv[2] = v[2]; 266 267 gl.uniform3i(location, v[0], v[1], v[2]); 268 }`,ivec4:` 269 if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) 270 { 271 cv[0] = v[0]; 272 cv[1] = v[1]; 273 cv[2] = v[2]; 274 cv[3] = v[3]; 275 276 gl.uniform4i(location, v[0], v[1], v[2], v[3]); 277 }`,uint:` 278 if (cv !== v) 279 { 280 cu.value = v; 281 282 gl.uniform1ui(location, v); 283 }`,uvec2:` 284 if (cv[0] !== v[0] || cv[1] !== v[1]) 285 { 286 cv[0] = v[0]; 287 cv[1] = v[1]; 288 289 gl.uniform2ui(location, v[0], v[1]); 290 }`,uvec3:` 291 if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) 292 { 293 cv[0] = v[0]; 294 cv[1] = v[1]; 295 cv[2] = v[2]; 296 297 gl.uniform3ui(location, v[0], v[1], v[2]); 298 }`,uvec4:` 299 if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) 300 { 301 cv[0] = v[0]; 302 cv[1] = v[1]; 303 cv[2] = v[2]; 304 cv[3] = v[3]; 305 306 gl.uniform4ui(location, v[0], v[1], v[2], v[3]); 307 }`,bool:` 308 if (cv !== v) 309 { 310 cu.value = v; 311 gl.uniform1i(location, v); 312 }`,bvec2:` 313 if (cv[0] != v[0] || cv[1] != v[1]) 314 { 315 cv[0] = v[0]; 316 cv[1] = v[1]; 317 318 gl.uniform2i(location, v[0], v[1]); 319 }`,bvec3:` 320 if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) 321 { 322 cv[0] = v[0]; 323 cv[1] = v[1]; 324 cv[2] = v[2]; 325 326 gl.uniform3i(location, v[0], v[1], v[2]); 327 }`,bvec4:` 328 if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) 329 { 330 cv[0] = v[0]; 331 cv[1] = v[1]; 332 cv[2] = v[2]; 333 cv[3] = v[3]; 334 335 gl.uniform4i(location, v[0], v[1], v[2], v[3]); 336 }`,mat2:"gl.uniformMatrix2fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",sampler2D:` 337 if (cv !== v) 338 { 339 cu.value = v; 340 341 gl.uniform1i(location, v); 342 }`,samplerCube:` 343 if (cv !== v) 344 { 345 cu.value = v; 346 347 gl.uniform1i(location, v); 348 }`,sampler2DArray:` 349 if (cv !== v) 350 { 351 cu.value = v; 352 353 gl.uniform1i(location, v); 354 }`},bb={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 Sb(n,e){var t;const i=[` 355 var v = null; 356 var cv = null; 357 var cu = null; 358 var t = 0; 359 var gl = renderer.gl; 360 `];for(const r in n.uniforms){const s=e[r];if(!s){((t=n.uniforms[r])==null?void 0:t.group)===!0&&(n.uniforms[r].ubo?i.push(` 361 renderer.shader.syncUniformBufferGroup(uv.${r}, '${r}'); 362 `):i.push(` 363 renderer.shader.syncUniformGroup(uv.${r}, syncData); 364 `));continue}const o=n.uniforms[r];let a=!1;for(let l=0;l<Sr.length;l++)if(Sr[l].test(s,o)){i.push(Sr[l].code(r,o)),a=!0;break}if(!a){const l=(s.size===1&&!s.isArray?Eb:bb)[s.type].replace("location",`ud["${r}"].location`);i.push(` 365 cu = ud["${r}"]; 366 cv = cu.value; 367 v = uv["${r}"]; 368 ${l};`)}}return new Function("ud","uv","renderer","syncData",i.join(` 369`))}const Ug={};let Kr=Ug;function Ab(){if(Kr===Ug||Kr!=null&&Kr.isContextLost()){const n=pe.ADAPTER.createCanvas();let e;pe.PREFER_ENV>=Yn.WEBGL2&&(e=n.getContext("webgl2",{})),e||(e=n.getContext("webgl",{})||n.getContext("experimental-webgl",{}),e?e.getExtension("WEBGL_draw_buffers"):e=null),Kr=e}return Kr}let to;function Rb(){if(!to){to=Qt.MEDIUM;const n=Ab();if(n&&n.getShaderPrecisionFormat){const e=n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT);e&&(to=e.precision?Qt.HIGH:Qt.MEDIUM)}}return to}function df(n,e){const t=n.getShaderSource(e).split(` 370`).map((h,u)=>`${u}: ${h}`),i=n.getShaderInfoLog(e),r=i.split(` 371`),s={},o=r.map(h=>parseFloat(h.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(h=>h&&!s[h]?(s[h]=!0,!0):!1),a=[""];o.forEach(h=>{t[h-1]=`%c${t[h-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const l=t.join(` 372`);a[0]=l,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function Pb(n,e,t,i){n.getProgramParameter(e,n.LINK_STATUS)||(n.getShaderParameter(t,n.COMPILE_STATUS)||df(n,t),n.getShaderParameter(i,n.COMPILE_STATUS)||df(n,i),console.error("PixiJS Error: Could not initialize shader."),n.getProgramInfoLog(e)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",n.getProgramInfoLog(e)))}const Cb={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 Hg(n){return Cb[n]}let io=null;const ff={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 Gg(n,e){if(!io){const t=Object.keys(ff);io={};for(let i=0;i<t.length;++i){const r=t[i];io[n[r]]=ff[r]}}return io[e]}function pf(n,e,t){if(n.substring(0,9)!=="precision"){let i=e;return e===Qt.HIGH&&t!==Qt.HIGH&&(i=Qt.MEDIUM),`precision ${i} float; 373${n}`}else if(t!==Qt.HIGH&&n.substring(0,15)==="precision highp")return n.replace("precision highp","precision mediump");return n}let Jr;function Ib(){if(typeof Jr=="boolean")return Jr;try{Jr=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{Jr=!1}return Jr}let Mb=0;const no={},vh=class dr{constructor(e,t,i="pixi-shader",r={}){this.extra={},this.id=Mb++,this.vertexSrc=e||dr.defaultVertexSrc,this.fragmentSrc=t||dr.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.extra=r,this.vertexSrc.substring(0,8)!=="#version"&&(i=i.replace(/\s+/g,"-"),no[i]?(no[i]++,i+=`-${no[i]}`):no[i]=1,this.vertexSrc=`#define SHADER_NAME ${i} 374${this.vertexSrc}`,this.fragmentSrc=`#define SHADER_NAME ${i} 375${this.fragmentSrc}`,this.vertexSrc=pf(this.vertexSrc,dr.defaultVertexPrecision,Qt.HIGH),this.fragmentSrc=pf(this.fragmentSrc,dr.defaultFragmentPrecision,Rb())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return Tb}static get defaultFragmentSrc(){return wb}static from(e,t,i){const r=e+t;let s=of[r];return s||(of[r]=s=new dr(e,t,i)),s}};vh.defaultVertexPrecision=Qt.HIGH,vh.defaultFragmentPrecision=ki.apple.device?Qt.HIGH:Qt.MEDIUM;let Hi=vh,Db=0;class di{constructor(e,t,i){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=Db++,this.static=!!t,this.ubo=!!i,e instanceof dt?(this.buffer=e,this.buffer.type=Ci.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=e,this.ubo&&(this.buffer=new dt(new Float32Array(1)),this.buffer.type=Ci.UNIFORM_BUFFER,this.autoManage=!0))}update(){this.dirtyId++,!this.autoManage&&this.buffer&&this.buffer.update()}add(e,t,i){if(!this.ubo)this.uniforms[e]=new di(t,i);else throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them")}static from(e,t,i){return new di(e,t,i)}static uboFrom(e,t){return new di(e,t??!0,!0)}}class Ii{constructor(e,t){this.uniformBindCount=0,this.program=e,t?t instanceof di?this.uniformGroup=t:this.uniformGroup=new di(t):this.uniformGroup=new di({}),this.disposeRunner=new ci("disposeShader")}checkUniformExists(e,t){if(t.uniforms[e])return!0;for(const i in t.uniforms){const r=t.uniforms[i];if(r.group===!0&&this.checkUniformExists(e,r))return!0}return!1}destroy(){this.uniformGroup=null,this.disposeRunner.emit(this),this.disposeRunner.destroy()}get uniforms(){return this.uniformGroup.uniforms}static from(e,t,i){const r=Hi.from(e,t);return new Ii(r,i)}}class Ob{constructor(e,t){if(this.vertexSrc=e,this.fragTemplate=t,this.programCache={},this.defaultGroupCache={},!t.includes("%count%"))throw new Error('Fragment template must contain "%count%".');if(!t.includes("%forloop%"))throw new Error('Fragment template must contain "%forloop%".')}generateShader(e){if(!this.programCache[e]){const i=new Int32Array(e);for(let s=0;s<e;s++)i[s]=s;this.defaultGroupCache[e]=di.from({uSamplers:i},!0);let r=this.fragTemplate;r=r.replace(/%count%/gi,`${e}`),r=r.replace(/%forloop%/gi,this.generateSampleSrc(e)),this.programCache[e]=new Hi(this.vertexSrc,r)}const t={tint:new Float32Array([1,1,1,1]),translationMatrix:new tt,default:this.defaultGroupCache[e]};return new Ii(this.programCache[e],t)}generateSampleSrc(e){let t="";t+=` 376`,t+=` 377`;for(let i=0;i<e;i++)i>0&&(t+=` 378else `),i<e-1&&(t+=`if(vTextureId < ${i}.5)`),t+=` 379{`,t+=` 380 color = texture2D(uSamplers[${i}], vTextureCoord);`,t+=` 381}`;return t+=` 382`,t+=` 383`,t}}class yh{constructor(){this.elements=[],this.ids=[],this.count=0}clear(){for(let e=0;e<this.count;e++)this.elements[e]=null;this.count=0}}function Lb(){return!ki.apple.device}function Bb(n){let e=!0;const t=pe.ADAPTER.getNavigator();if(ki.tablet||ki.phone){if(ki.apple.device){const i=t.userAgent.match(/OS (\d+)_(\d+)?/);i&&parseInt(i[1],10)<11&&(e=!1)}if(ki.android.device){const i=t.userAgent.match(/Android\s([0-9.]*)/);i&&parseInt(i[1],10)<7&&(e=!1)}}return e?n:4}class Aa{constructor(e){this.renderer=e}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(e){}}var Fb=`varying vec2 vTextureCoord; 384varying vec4 vColor; 385varying float vTextureId; 386uniform sampler2D uSamplers[%count%]; 387 388void main(void){ 389 vec4 color; 390 %forloop% 391 gl_FragColor = color * vColor; 392} 393`,Nb=`precision highp float; 394attribute vec2 aVertexPosition; 395attribute vec2 aTextureCoord; 396attribute vec4 aColor; 397attribute float aTextureId; 398 399uniform mat3 projectionMatrix; 400uniform mat3 translationMatrix; 401uniform vec4 tint; 402 403varying vec2 vTextureCoord; 404varying vec4 vColor; 405varying float vTextureId; 406 407void main(void){ 408 gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0
408)).xy, 0.0, 1.0); 409 410 vTextureCoord = aTextureCoord; 411 vTextureId = aTextureId; 412 vColor = aColor * tint; 413} 414`;const rs=class li extends Aa{constructor(e){super(e),this.setShaderGenerator(),this.geometryClass=Fg,this.vertexSize=6,this.state=Di.for2d(),this.size=li.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),e.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??Bb(32),this._defaultMaxTextures}static set defaultMaxTextures(e){this._defaultMaxTextures=e}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??Lb(),this._canUploadSameBuffer}static set canUploadSameBuffer(e){this._canUploadSameBuffer=e}get MAX_TEXTURES(){return Ue("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return Nb}static get defaultFragmentTemplate(){return Fb}setShaderGenerator({vertex:e=li.defaultVertexSrc,fragment:t=li.defaultFragmentTemplate}={}){this.shaderGenerator=new Ob(e,t)}contextChange(){const e=this.renderer.gl;pe.PREFER_ENV===Yn.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),li.defaultMaxTextures),this.maxTextures=cb(this.maxTextures,e)),this._shader=this.shaderGenerator.generateShader(this.maxTextures);for(let t=0;t<this._packedGeometryPoolSize;t++)this._packedGeometries[t]=new this.geometryClass;this.initFlushBuffers()}initFlushBuffers(){const{_drawCallPool:e,_textureArrayPool:t}=li,i=this.size/4,r=Math.floor(i/this.maxTextures)+1;for(;e.length<i;)e.push(new ph);for(;t.length<r;)t.push(new yh);for(let s=0;s<this.maxTextures;s++)this._tempBoundTextures[s]=null}onPrerender(){this._flushId=0}render(e){e._texture.valid&&(this._vertexCount+e.vertexData.length/2>this.size&&this.flush(),this._vertexCount+=e.vertexData.length/2,this._indexCount+=e.indices.length,this._bufferedTextures[this._bufferSize]=e._texture.baseTexture,this._bufferedElements[this._bufferSize++]=e)}buildTexturesAndDrawCalls(){const{_bufferedTextures:e,maxTextures:t}=this,i=li._textureArrayPool,r=this.renderer.batch,s=this._tempBoundTextures,o=this.renderer.textureGC.count;let a=++Le._globalBatch,l=0,h=i[0],u=0;r.copyBoundTextures(s,t);for(let c=0;c<this._bufferSize;++c){const d=e[c];e[c]=null,d._batchEnabled!==a&&(h.count>=t&&(r.boundArray(h,s,a,t),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&&(r.boundArray(h,s,a,t),this.buildDrawCalls(h,u,this._bufferSize),++l,++a);for(let c=0;c<s.length;c++)s[c]=null;Le._globalBatch=a}buildDrawCalls(e,t,i){const{_bufferedElements:r,_attributeBuffer:s,_indexBuffer:o,vertexSize:a}=this,l=li._drawCallPool;let h=this._dcIndex,u=this._aIndex,c=this._iIndex,d=l[h];d.start=this._iIndex,d.texArray=e;for(let f=t;f<i;++f){const p=r[f],g=p._texture.baseTexture,v=Dg[g.alphaMode?1:0][p.blendMode];r[f]=null,t<f&&d.blend!==v&&(d.size=c-d.start,t=f,d=l[++h],d.texArray=e,d.start=c),this.packInterleavedGeometry(p,s,o,u,c),u+=p.vertexData.length/2*a,c+=p.indices.length,d.blend=v}t<i&&(d.size=c-d.start,++h),this._dcIndex=h,this._aIndex=u,this._iIndex=c}bindAndClearTexArray(e){const t=this.renderer.texture;for(let i=0;i<e.count;i++)t.bind(e.elements[i],e.ids[i]),e.elements[i]=null;e.count=0}updateGeometry(){const{_packedGeometries:e,_attributeBuffer:t,_indexBuffer:i}=this;li.canUploadSameBuffer?(e[this._flushId]._buffer.update(t.rawBinaryData),e[this._flushId]._indexBuffer.update(i),this.renderer.geometry.updateBuffers()):(this._packedGeometryPoolSize<=this._flushId&&(this._packedGeometryPoolSize++,e[this._flushId]=new this.geometryClass),e[this._flushId]._buffer.update(t.rawBinaryData),e[this._flushId]._indexBuffer.update(i),this.renderer.geometry.bind(e[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)}drawBatches(){const e=this._dcIndex,{gl:t,state:i}=this.renderer,r=li._drawCallPool;let s=null;for(let o=0;o<e;o++){const{texArray:a,type:l,size:h,start:u,blend:c}=r[o];s!==a&&(s=a,this.bindAndClearTexArray(a)),this.state.blendMode=c,i.set(this.state),t.drawElements(l,h,t.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),li.canUploadSameBuffer&&this.renderer.geometry.bind(this._packedGeometries[this._flushId])}stop(){this.flush()}destroy(){for(let e=0;e<this._packedGeometryPoolSize;e++)this._packedGeometries[e]&&this._packedGeometries[e].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(e){const t=$o(Math.ceil(e/8)),i=rf(t),r=t*8;this._aBuffers.length<=i&&(this._iBuffers.length=i+1);let s=this._aBuffers[r];return s||(this._aBuffers[r]=s=new ch(r*this.vertexSize*4)),s}getIndexBuffer(e){const t=$o(Math.ceil(e/12)),i=rf(t),r=t*12;this._iBuffers.length<=i&&(this._iBuffers.length=i+1);let s=this._iBuffers[i];return s||(this._iBuffers[i]=s=new Uint16Array(r)),s}packInterleavedGeometry(e,t,i,r,s){const{uint32View:o,float32View:a}=t,l=r/this.vertexSize,h=e.uvs,u=e.indices,c=e.vertexData,d=e._texture.baseTexture._batchLocation,f=Math.min(e.worldAlpha,1),p=Ze.shared.setValue(e._tintRGB).toPremultiplied(f,e._texture.baseTexture.alphaMode>0);for(let g=0;g<c.length;g+=2)a[r++]=c[g],a[r++]=c[g+1],a[r++]=h[g],a[r++]=h[g+1],o[r++]=p,a[r++]=d;for(let g=0;g<u.length;g++)i[s++]=l+u[g]}};rs.defaultBatchSize=4096,rs.extension={name:"batch",type:ue.RendererPlugin},rs._drawCallPool=[],rs._textureArrayPool=[];let Rn=rs;_e.add(Rn);var kb=`varying vec2 vTextureCoord; 415 416uniform sampler2D uSampler; 417 418void main(void){ 419 gl_FragColor = texture2D(uSampler, vTextureCoord); 420} 421`,Ub=`attribute vec2 aVertexPosition; 422 423uniform mat3 projectionMatrix; 424 425varying vec2 vTextureCoord; 426 427uniform vec4 inputSize; 428uniform vec4 outputFrame; 429 430vec4 filterVertexPosition( void ) 431{ 432 vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; 433
434 return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); 435} 436 437vec2 filterTextureCoord( void ) 438{ 439 return aVertexPosition * (outputFrame.zw * inputSize.zw); 440} 441 442void main(void) 443{ 444 gl_Position = filterVertexPosition(); 445 vTextureCoord = filterTextureCoord(); 446} 447`;const xh=class ss extends Ii{constructor(e,t,i){const r=Hi.from(e||ss.defaultVertexSrc,t||ss.defaultFragmentSrc);super(r,i),this.padding=0,this.resolution=ss.defaultResolution,this.multisample=ss.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new Di}apply(e,t,i,r,s){e.applyFilter(this,t,i,r)}get blendMode(){return this.state.blendMode}set blendMode(e){this.state.blendMode=e}get resolution(){return this._resolution}set resolution(e){this._resolution=e}static get defaultVertexSrc(){return Ub}static get defaultFragmentSrc(){return kb}};xh.defaultResolution=1,xh.defaultMultisample=pt.NONE;let Ft=xh;class Jo{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new Ze(0),this.alpha=1}init(e){this.clearBeforeRender=e.clearBeforeRender;const{backgroundColor:t,background:i,backgroundAlpha:r}=e,s=i??t;s!==void 0&&(this.color=s),this.alpha=r}get color(){return this._backgroundColor.value}set color(e){this._backgroundColor.setValue(e)}get alpha(){return this._backgroundColor.alpha}set alpha(e){this._backgroundColor.setAlpha(e)}get backgroundColor(){return this._backgroundColor}destroy(){}}Jo.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},Jo.extension={type:[ue.RendererSystem,ue.CanvasRendererSystem],name:"background"};_e.add(Jo);class zg{constructor(e){this.renderer=e,this.emptyRenderer=new Aa(e),this.currentRenderer=this.emptyRenderer}setObjectRenderer(e){this.currentRenderer!==e&&(this.currentRenderer.stop(),this.currentRenderer=e,this.currentRenderer.start())}flush(){this.setObjectRenderer(this.emptyRenderer)}reset(){this.setObjectRenderer(this.emptyRenderer)}copyBoundTextures(e,t){const{boundTextures:i}=this.renderer.texture;for(let r=t-1;r>=0;--r)e[r]=i[r]||null,e[r]&&(e[r]._batchLocation=r)}boundArray(e,t,i,r){const{elements:s,ids:o,count:a}=e;let l=0;for(let h=0;h<a;h++){const u=s[h],c=u._batchLocation;if(c>=0&&c<r&&t[c]===u){o[h]=c;continue}for(;l<r;){const d=t[l];if(d&&d._batchEnabled===i&&d._batchLocation===l){l++;continue}o[h]=l,u._batchLocation=l,t[l]=u;break}}}destroy(){this.renderer=null}}zg.extension={type:ue.RendererSystem,name:"batch"};_e.add(zg);let gf=0;class Qo{constructor(e){this.renderer=e,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(e){this.gl=e,this.renderer.gl=e,this.renderer.CONTEXT_UID=gf++}init(e){if(e.context)this.initFromContext(e.context);else{const t=this.renderer.background.alpha<1,i=e.premultipliedAlpha;this.preserveDrawingBuffer=e.preserveDrawingBuffer,this.useContextAlpha=e.useContextAlpha,this.powerPreference=e.powerPreference,this.initFromOptions({alpha:t,premultipliedAlpha:i,antialias:e.antialias,stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:e.powerPreference})}}initFromContext(e){this.gl=e,this.validateContext(e),this.renderer.gl=e,this.renderer.CONTEXT_UID=gf++,this.renderer.runners.contextChange.emit(e);const t=this.renderer.view;t.addEventListener!==void 0&&(t.addEventListener("webglcontextlost",this.handleContextLost,!1),t.addEventListener("webglcontextrestored",this.handleContextRestored,!1))}initFromOptions(e){const t=this.createContext(this.renderer.view,e);this.initFromContext(t)}createContext(e,t){let i;if(pe.PREFER_ENV>=Yn.WEBGL2&&(i=e.getContext("webgl2",t)),i)this.webGLVersion=2;else if(this.webGLVersion=1,i=e.getContext("webgl",t)||e.getContext("experimental-webgl",t),!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:e}=this,t={loseContext:e.getExtension("WEBGL_lose_context"),anisotropicFiltering:e.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),s3tc:e.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:e.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:e.getExtension("WEBGL_compressed_texture_etc"),etc1:e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:e.getExtension("WEBGL_compressed_texture_atc"),astc:e.getExtension("WEBGL_compressed_texture_astc"),bptc:e.getExtension("EXT_texture_compression_bptc")};this.webGLVersion===1?Object.assign(this.extensions,t,{drawBuffers:e.getExtension("WEBGL_draw_buffers"),depthTexture:e.getExtension("WEBGL_depth_texture"),vertexArrayObject:e.getExtension("OES_vertex_array_object")||e.getExtension("MOZ_OES_vertex_array_object")||e.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:e.getExtension("OES_element_index_uint"),floatTexture:e.getExtension("OES_texture_float"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),textureHalfFloat:e.getExtension("OES_texture_half_float"),textureHalfFloatLinear:e.getExtension("OES_texture_half_float_linear")}):this.webGLVersion===2&&Object.assign(this.extensions,t,{colorBufferFloat:e.getExtension("EXT_color_buffer_float")})}handleContextLost(e){e.preventDefault(),setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext&&this.extensions.loseContext.restoreContext()},0)}handleContextRestored(){this.renderer.runners.contextChange.emit(this.gl)}destroy(){const e=this.renderer.view;this.renderer=null,e.removeEventListener!==void 0&&(e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored)),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()}postrender(){this.renderer.objectRenderer.renderingToScreen&&this.gl.flush()}validateContext(e){const t=e.getContextAttributes(),i="WebGL2RenderingContext"in globalThis&&e instanceof globalThis.WebGL2RenderingContext;i&&(this.webGLVersion=2),t&&!t.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const r=i||!!e.getExtension("OES_element_index_uint");this.supports.uint32Indices=r,r||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}Qo.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},Qo.extension={type:ue.RendererSystem,name:"context"};_e.add(Qo);class _h{constructor(e,t){if(this.width=Math.round(e),this.height=Math.round(t),!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 ci("disposeFramebuffer"),this.multisample=pt.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(e=0,t){return this.colorTextures[e]=t||new Le(null,{scaleMode:Ni.NEAREST,resolution:1,mipmap:Mi.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(e){return this.depthTexture=e||new Le(null,{scaleMode:Ni.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:Mi.OFF,format:oe.DEPTH_COMPONENT,type:Ee.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(e,t){if(e=Math.round(e),t=Math.round(t),!e||!t)throw new Error("Framebuffer width and height must not be zero");if(!(e===this.width&&t===this.height)){this.width=e,this.height=t,this.dirtyId++,this.dirtySize++;for(let i=0;i<this.colorTextures.length;i++){const r=this.colorTextures[i],s=r.resolution;r.setSize(e/s,t/s)}if(this.depthTexture){const i=this.depthTexture.resolution;this.depthTexture.setSize(e/i,t/i)}}}dispose(){this.disposeRunner.emit(this,!1)}destroyDepthTexture(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)}}class Vg extends Le{constructor(e={}){if(typeof e=="number"){const t=arguments[0],i=arguments[1],r=arguments[2],s=arguments[3];e={width:t,height:i,scaleMode:r,resolution:s}}e.width=e.width??100,e.height=e.height??100,e.multisample??(e.multisample=pt.NONE),super(null,e),this.mipmap=Mi.OFF,this.valid=!0,this._clear=new Ze([0,0,0,0]),this.framebuffer=new _h(this.realWidth,this.realHeight).addColorTexture(0,this),this.framebuffer.multisample=e.multisample,this.maskStack=[],this.filterStack=[{}]}set clearColor(e){this._clear.setValue(e)}get clearColor(){return this._clear.value}get clear(){return this._clear}get multisample(){return this.framebuffer.multisample}set multisample(e){this.framebuffer.multisample=e}resize(e,t){this.framebuffer.resize(e*this.resolution,t*this.resolution),this.setRealSize(this.framebuffer.width,this.framebuffer.he
vendor: 18,418 bytes, line 447
447ight)}dispose(){this.framebuffer.dispose(),super.dispose()}destroy(){super.destroy(),this.framebuffer.destroyDepthTexture(),this.framebuffer=null}}class Xi extends Ms{constructor(e){const t=e,i=t.naturalWidth||t.videoWidth||t.displayWidth||t.width,r=t.naturalHeight||t.videoHeight||t.displayHeight||t.height;super(i,r),this.source=e,this.noSubImage=!1}static crossOrigin(e,t,i){i===void 0&&!t.startsWith("data:")?e.crossOrigin=lb(t):i!==!1&&(e.crossOrigin=typeof i=="string"?i:"anonymous")}upload(e,t,i,r){const s=e.gl,o=t.realWidth,a=t.realHeight;if(r=r||this.source,typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement){if(!r.complete||r.naturalWidth===0)return!1}else if(typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement&&r.readyState<=1)return!1;return s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.alphaMode===Ut.UNPACK),!this.noSubImage&&t.target===s.TEXTURE_2D&&i.width===o&&i.height===a?s.texSubImage2D(s.TEXTURE_2D,0,0,0,t.format,i.type,r):(i.width=o,i.height=a,s.texImage2D(t.target,0,i.internalFormat,t.format,i.type,r)),!0}update(){if(this.destroyed)return;const e=this.source,t=e.naturalWidth||e.videoWidth||e.width,i=e.naturalHeight||e.videoHeight||e.height;this.resize(t,i),super.update()}dispose(){this.source=null}}class jg extends Xi{constructor(e,t){if(t=t||{},typeof e=="string"){const i=new Image;Xi.crossOrigin(i,e,t.crossorigin),i.src=e,e=i}super(e),!e.complete&&this._width&&this._height&&(this._width=0,this._height=0),this.url=e.src,this._process=null,this.preserveBitmap=!1,this.createBitmap=(t.createBitmap??pe.CREATE_IMAGE_BITMAP)&&!!globalThis.createImageBitmap,this.alphaMode=typeof t.alphaMode=="number"?t.alphaMode:null,this.bitmap=null,this._load=null,t.autoLoad!==!1&&this.load()}load(e){return this._load?this._load:(e!==void 0&&(this.createBitmap=e),this._load=new Promise((t,i)=>{const r=this.source;this.url=r.src;const s=()=>{this.destroyed||(r.onload=null,r.onerror=null,this.update(),this._load=null,this.createBitmap?t(this.process()):t(this))};r.complete&&r.src?s():(r.onload=s,r.onerror=o=>{i(o),this.onError.emit(o)})}),this._load)}process(){const e=this.source;if(this._process!==null)return this._process;if(this.bitmap!==null||!globalThis.createImageBitmap)return Promise.resolve(this);const t=globalThis.createImageBitmap,i=!e.crossOrigin||e.crossOrigin==="anonymous";return this._process=fetch(e.src,{mode:i?"cors":"no-cors"}).then(r=>r.blob()).then(r=>t(r,0,0,e.width,e.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Ut.UNPACK?"premultiply":"none"})).then(r=>this.destroyed?Promise.reject():(this.bitmap=r,this.update(),this._process=null,Promise.resolve(this))),this._process}upload(e,t,i){if(typeof this.alphaMode=="number"&&(t.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(e,t,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(e,t,i,this.bitmap),!this.preserveBitmap){let r=!0;const s=t._glTextures;for(const o in s){const a=s[o];if(a!==i&&a.dirtyId!==t.dirtyId){r=!1;break}}r&&(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(e){return typeof HTMLImageElement<"u"&&(typeof e=="string"||e instanceof HTMLImageElement)}}class xu{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(e,t,i){const r=t.width,s=t.height;if(i){const o=e.width/2/r,a=e.height/2/s,l=e.x/r+o,h=e.y/s+a;i=rt.add(i,rt.NW),this.x0=l+o*rt.uX(i),this.y0=h+a*rt.uY(i),i=rt.add(i,2),this.x1=l+o*rt.uX(i),this.y1=h+a*rt.uY(i),i=rt.add(i,2),this.x2=l+o*rt.uX(i),this.y2=h+a*rt.uY(i),i=rt.add(i,2),this.x3=l+o*rt.uX(i),this.y3=h+a*rt.uY(i)}else this.x0=e.x/r,this.y0=e.y/s,this.x1=(e.x+e.width)/r,this.y1=e.y/s,this.x2=(e.x+e.width)/r,this.y2=(e.y+e.height)/s,this.x3=e.x/r,this.y3=(e.y+e.height)/s;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}}xu.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 mf=new xu;function ro(n){n.destroy=function(){},n.on=function(){},n.once=function(){},n.emit=function(){}}class xe extends Hs{constructor(e,t,i,r,s,o,a){if(super(),this.noFrame=!1,t||(this.noFrame=!0,t=new Fe(0,0,1,1)),e instanceof xe&&(e=e.baseTexture),this.baseTexture=e,this._frame=t,this.trim=r,this.valid=!1,this.destroyed=!1,this._uvs=mf,this.uvMatrix=null,this.orig=i||t,this._rotate=Number(s||0),s===!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 ze(o.x,o.y):new ze(0,0),this.defaultBorders=a,this._updateID=0,this.textureCacheIds=[],e.valid?this.noFrame?e.valid&&this.onBaseTextureUpdated(e):this.frame=t:e.once("loaded",this.onBaseTextureUpdated,this),this.noFrame&&e.on("update",this.onBaseTextureUpdated,this)}update(){this.baseTexture.resource&&this.baseTexture.resource.update()}onBaseTextureUpdated(e){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=e.width,this._frame.height=e.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)}destroy(e){if(this.baseTexture){if(e){const{resource:t}=this.baseTexture;t!=null&&t.url&&yi[t.url]&&xe.removeFromCache(t.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,xe.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}clone(){var e;const t=this._frame.clone(),i=this._frame===this.orig?t:this.orig.clone(),r=new xe(this.baseTexture,!this.noFrame&&t,i,(e=this.trim)==null?void 0:e.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(r._frame=t),r}updateUvs(){this._uvs===mf&&(this._uvs=new xu),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(e,t={},i=pe.STRICT_TEXTURE_CACHE){const r=typeof e=="string";let s=null;if(r)s=e;else if(e instanceof Le){if(!e.cacheId){const a=t?.pixiIdPrefix||"pixiid";e.cacheId=`${a}-${Xn()}`,Le.addToCache(e,e.cacheId)}s=e.cacheId}else{if(!e._pixiId){const a=t?.pixiIdPrefix||"pixiid";e._pixiId=`${a}_${Xn()}`}s=e._pixiId}let o=yi[s];if(r&&i&&!o)throw new Error(`The cacheId "${s}" does not exist in TextureCache.`);return!o&&!(e instanceof Le)?(t.resolution||(t.resolution=ji(e)),o=new xe(new Le(e,t)),o.baseTexture.cacheId=s,Le.addToCache(o.baseTexture,s),xe.addToCache(o,s)):!o&&e instanceof Le&&(o=new xe(e),xe.addToCache(o,s)),o}static fromURL(e,t){const i=Object.assign({autoLoad:!1},t?.resourceOptions),r=xe.from(e,Object.assign({resourceOptions:i},t),!1),s=r.baseTexture.resource;return r.baseTexture.valid?Promise.resolve(r):s.load().then(()=>Promise.resolve(r))}static fromBuffer(e,t,i,r){return new xe(Le.fromBuffer(e,t,i,r))}static fromLoader(e,t,i,r){const s=new Le(e,Object.assign({scaleMode:Le.defaultOptions.scaleMode,resolution:ji(t)},r)),{resource:o}=s;o instanceof jg&&(o.url=t);const a=new xe(s);return i||(i=t),Le.addToCache(a.baseTexture,i),xe.addToCache(a,i),i!==t&&(Le.addToCache(a.baseTexture,t),xe.addToCache(a,t)),a.baseTexture.valid?Promise.resolve(a):new Promise(l=>{a.baseTexture.once("loaded",()=>l(a))})}static addToCache(e,t){t&&(e.textureCacheIds.includes(t)||e.textureCacheIds.push(t),yi[t]&&yi[t]!==e&&console.warn(`Texture added to the cache with an id [${t}] that already had an entry`),yi[t]=e)}static removeFromCache(e){if(typeof e=="string"){const t=yi[e];if(t){const i=t.textureCacheIds.indexOf(e);return i>-1&&t.textureCacheIds.splice(i,1),delete yi[e],t}}else if(e!=null&&e.textureCacheIds){for(let t=0;t<e.textureCacheIds.length;++t)yi[e.textureCacheIds[t]]===e&&delete yi[e.textureCacheIds[t]];return e.textureCacheIds.length=0,e}return null}get resolution(){return this.baseTexture.resolution}get frame(){return this._frame}set frame(e){this._frame=e,this.noFrame=!1;const{x:t,y:i,width:r,height:s}=e,o=t+r>this.baseTexture.width,a=i+s>this.baseTexture.height;if(o||a){const l=o&&a?"and":"or",h=`X: ${t} + ${r} = ${t+r} > ${this.baseTexture.width}`,u=`Y: ${i} + ${s} = ${i+s} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${h} ${l} ${u}`)}this.valid=r&&s&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=e),this.valid&&this.updateUvs()}get rotate(){return this._rotate}set rotate(e){this._rotate=e,this.valid&&this.updateUvs()}get width(){return this.orig.width}get height(){return this.orig.height}castToBaseTexture(){return this.baseTexture}static get EMPTY(){return xe._EMPTY||(xe._EMPTY=new xe(new Le),ro(xe._EMPTY),ro(xe._EMPTY.baseTexture)),xe._EMPTY}static get WHITE(){if(!xe._WHITE){const e=pe.ADAPTER.createCanvas(16,16),t=e.getContext("2d");e.width=16,e.height=16,t.fillStyle="white",t.fillRect(0,0,16,16),xe._WHITE=new xe(Le.from(e)),ro(xe._WHITE),ro(xe._WHITE.baseTexture)}return xe._WHITE}}class qn extends xe{constructor(e,t){super(e,t),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(e){this.framebuffer.multisample=e}resize(e,t,i=!0){const r=this.baseTexture.resolution,s=Math.round(e*r)/r,o=Math.round(t*r)/r;this.valid=s>0&&o>0,this._frame.width=this.orig.width=s,this._frame.height=this.orig.height=o,i&&this.baseTexture.resize(s,o),this.updateUvs()}setResolution(e){const{baseTexture:t}=this;t.resolution!==e&&(t.setResolution(e),this.resize(t.width,t.height,!1))}static create(e){return new qn(new Vg(e))}}class Xg{constructor(e){this.texturePool={},this.textureOptions=e||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(e,t,i=pt.NONE){const r=new Vg(Object.assign({width:e,height:t,resolution:1,multisample:i},this.textureOptions));return new qn(r)}getOptimalTexture(e,t,i=1,r=pt.NONE){let s;e=Math.max(Math.ceil(e*i-1e-6),1),t=Math.max(Math.ceil(t*i-1e-6),1),!this.enableFullScreen||e!==this._pixelsWidth||t!==this._pixelsHeight?(e=$o(e),t=$o(t),s=((e&65535)<<16|t&65535)>>>0,r>1&&(s+=r*4294967296)):s=r>1?-r:-1,this.texturePool[s]||(this.texturePool[s]=[]);let o=this.texturePool[s].pop();return o||(o=this.createTexture(e,t,r)),o.filterPoolKey=s,o.setResolution(i),o}getFilterTexture(e,t,i){const r=this.getOptimalTexture(e.width,e.height,t||e.resolution,i||pt.NONE);return r.filterFrame=e.filterFrame,r}returnTexture(e){const t=e.filterPoolKey;e.filterFrame=null,this.texturePool[t].push(e)}returnFilterTexture(e){this.returnTexture(e)}clear(e){if(e=e!==!1,e)for(const t in this.texturePool){const i=this.texturePool[t];if(i)for(let r=0;r<i.length;r++)i[r].destroy(!0)}this.texturePool={}}setScreenSize(e){if(!(e.width===this._pixelsWidth&&e.height===this._pixelsHeight)){this.enableFullScreen=e.width>0&&e.height>0;for(const t in this.texturePool){if(!(Number(t)<0))continue;const i=this.texturePool[t];if(i)for(let r=0;r<i.length;r++)i[r].destroy(!0);this.texturePool[t]=[]}this._pixelsWidth=e.width,this._pixelsHeight=e.height}}}Xg.SCREEN_KEY=-1;class Hb extends fn{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class Wg extends fn{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 dt(this.vertices),this.uvBuffer=new dt(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(e,t){let i=0,r=0;return this.uvs[0]=i,this.uvs[1]=r,this.uvs[2]=i+t.width/e.width,this.uvs[3]=r,this.uvs[4]=i+t.width/e.width,this.uvs[5]=r+t.height/e.height,this.uvs[6]=i,this.uvs[7]=r+t.height/e.height,i=t.x,r=t.y,this.vertices[0]=i,this.vertices[1]=r,this.vertices[2]=i+t.width,this.vertices[3]=r,this.vertices[4]=i+t.width,this.vertices[5]=r+t.height,this.vertices[6]=i,this.vertices[7]=r+t.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}class Gb{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=pt.NONE,this.sourceFrame=new Fe,this.destinationFrame=new Fe,this.bindingSourceFrame=new Fe,this.bindingDestinationFrame=new Fe,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const so=[new ze,new ze,new ze,new ze],Cl=new tt;class Yg{constructor(e){this.renderer=e,this.defaultFilterStack=[{}],this.texturePool=new Xg,this.statePool=[],this.quad=new Hb,this.quadUv=new Wg,this.tempRect=new Fe,this.activeState={},this.globalUniforms=new di({outputFrame:new Fe,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(e,t){const i=this.renderer,r=this.defaultFilterStack,s=this.statePool.pop()||new Gb,o=i.renderTexture;let a,l;if(o.current){const v=o.current;a=v.resolution,l=v.multisample}else a=i.resolution,l=i.multisample;let h=t[0].resolution||a,u=t[0].multisample??l,c=t[0].padding,d=t[0].autoFit,f=t[0].legacy??!0;for(let v=1;v<t.length;v++){const m=t[v];h=Math.min(h,m.resolution||a),u=Math.min(u,m.multisample??l),c=this.useMaxPadding?Math.max(c,m.padding):c+m.padding,d=d&&m.autoFit,f=f||(m.legacy??!0)}r.length===1&&(this.defaultFilterStack[0].renderTexture=o.current),r.push(s),s.resolution=h,s.multisample=u,s.legacy=f,s.target=e,s.sourceFrame.copyFrom(e.filterArea||e.getBounds(!0)),s.sourceFrame.pad(c);const p=this.tempRect.copyFrom(o.sourceFrame);i.projection.transform&&this.transformAABB(Cl.copyFrom(i.projection.transform).invert(),p),d?(s.sourceFrame.fit(p),(s.sourceFrame.width<=0||s.sourceFrame.height<=0)&&(s.sourceFrame.width=0,s.sourceFrame.height=0)):s.sourceFrame.intersects(p)||(s.sourceFrame.width=0,s.sourceFrame.height=0),this.roundFrame(s.sourceFrame,o.current?o.current.resolution:i.resolution,o.sourceFrame,o.destinationFrame,i.projection.transform),s.renderTexture=this.getOptimalFilterTexture(s.sourceFrame.width,s.sourceFrame.height,h,u),s.filters=t,s.destinationFrame.width=s.renderTexture.width,s.destinationFrame.height=s.renderTexture.height;const g=this.tempRect;g.x=0,g.y=0,g.width=s.sourceFrame.width,g.height=s.sourceFrame.height,s.renderTexture.filterFrame=s.sourceFrame,s.bindingSourceFrame.copyFrom(o.sourceFrame),s.bindingDestinationFrame.copyFrom(o.destinationFrame),s.transform=i.projection.transform,i.projection.transform=null,o.bind(s.renderTexture,s.sourceFrame,g),i.framebuffer.clear(0,0,0,0)}pop(){const e=this.defaultFilterStack,t=e.pop(),i=t.filters;this.activeState=t;const r=this.globalUniforms.uniforms;r.outputFrame=t.sourceFrame,r.resolution=t.resolution;const s=r.inputSize,o=r.inputPixel,a=r.inputClamp;if(s[0]=t.destinationFrame.width,s[1]=t.destinationFrame.height,s[2]=1/s[0],s[3]=1/s[1],o[0]=Math.round(s[0]*t.resolution),o[1]=Math.round(s[1]*t.resolution),o[2]=1/o[0],o[3]=1/o[1],a[0]=.5*o[2],a[1]=.5*o[3],a[2]=t.sourceFrame.width*s[2]-.5*o[2],a[3]=t.sourceFrame.height*s[3]-.5*o[3],t.legacy){const h=r.filterArea;h[0]=t.destinationFrame.width,h[1]=t.destinationFrame.height,h[2]=t.sourceFrame.x,h[3]=t.sourceFrame.y,r.filterClamp=r.inputClamp}this.globalUniforms.update();const l=e[e.length-1];if(this.renderer.framebuffer.blit(),i.length===1)i[0].apply(this,t.renderTexture,l.renderTexture,Ti.BLEND,t),this.returnFilterTexture(t.renderTexture);else{let h=t.renderTexture,u=this.getOptimalFilterTexture(h.width,h.height,t.resolution);u.filterFrame=h.filterFrame;let c=0;for(c=0;c<i.length-1;++c){c===1&&t.multisample>1&&(u=this.getOptimalFilterTexture(h.width,h.height,t.resolution),u.filterFrame=h.filterFrame),i[c].apply(this,h,u,Ti.CLEAR,t);const d=h;h=u,u=d}i[c].apply(this,h,l.renderTexture,Ti.BLEND,t),c>1&&t.multisample>1&&this.returnFilterTexture(t.renderTexture),this.returnFilterTexture(h),this.returnFilterTexture(u)}t.clear(),this.statePool.push(t)}bindAndClear(e,t=Ti.CLEAR){const{renderTexture:i,state:r}=this.renderer;if(e===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,e?.filterFrame){const o=this.tempRect;o.x=0,o.y=0,o.width=e.filterFrame.width,o.height=e.filterFrame.height,i.bind(e,e.filterFrame,o)}else e!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?i.bind(e):this.renderer.renderTexture.bind(e,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const s=r.stateId&1||this.forceClear;(t===Ti.CLEAR||t===Ti.BLIT&&s)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(e,t,i,r){const s=this.renderer;s.state.set(e.state),this.bindAndClear(i,r),e.uniforms.uSampler=t,e.uniforms.filterGlobals=this.globalUniforms,s.shader.bind(e),e.legacy=!!e.program.attributeData.aTextureCoord,e.legacy?(this.quadUv.map(t._frame,t.filterFrame),s.geometry.bind(this.quadUv),s.geometry.draw(bi.TRIANGLES)):(s.geometry.bind(this.quad),s.geometry.draw(bi.TRIANGLE_STRIP))}calculateSpriteMatrix(e,t){const{sourceFrame:i,destinationFrame:r}=this.activeState,{orig:s}=t._texture,o=e.set(r.width,0,0,r.height,i.x,i.y),a=t.worldTransform.copyTo(tt.TEMP_MATRIX);return a.invert(),o.prepend(a),o.scale(1/s.width,1/s.height),o.translate(t.anchor.x,t.anchor.y),o}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(e,t,i=1,r=pt.NONE){return this.texturePool.getOptimalTexture(e,t,i,r)}getFilterTexture(e,t,i){if(typeof e=="number"){const s=e;e=t,t=s}e=e||this.activeState.renderTexture;const r=this.texturePool.getOptimalTexture(e.width,e.height,t||e.resolution,i||pt.NONE);return r.filterFrame=e.filterFrame,r}returnFilterTexture(e){this.texturePool.returnTexture(e)}emptyPool(){this.texturePool.clear(!0)}
vendor: 14,092 bytes, line 447
447resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(e,t){const i=so[0],r=so[1],s=so[2],o=so[3];i.set(t.left,t.top),r.set(t.left,t.bottom),s.set(t.right,t.top),o.set(t.right,t.bottom),e.apply(i,i),e.apply(r,r),e.apply(s,s),e.apply(o,o);const a=Math.min(i.x,r.x,s.x,o.x),l=Math.min(i.y,r.y,s.y,o.y),h=Math.max(i.x,r.x,s.x,o.x),u=Math.max(i.y,r.y,s.y,o.y);t.x=a,t.y=l,t.width=h-a,t.height=u-l}roundFrame(e,t,i,r,s){if(!(e.width<=0||e.height<=0||i.width<=0||i.height<=0)){if(s){const{a:o,b:a,c:l,d:h}=s;if((Math.abs(a)>1e-4||Math.abs(l)>1e-4)&&(Math.abs(o)>1e-4||Math.abs(h)>1e-4))return}s=s?Cl.copyFrom(s):Cl.identity(),s.translate(-i.x,-i.y).scale(r.width/i.width,r.height/i.height).translate(r.x,r.y),this.transformAABB(s,e),e.ceil(t),this.transformAABB(s.invert(),e)}}}Yg.extension={type:ue.RendererSystem,name:"filter"};_e.add(Yg);class zb{constructor(e){this.framebuffer=e,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=pt.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const Vb=new Fe;class qg{constructor(e){this.renderer=e,this.managedFramebuffers=[],this.unknownFramebuffer=new _h(10,10),this.msaaSamples=null}contextChange(){this.disposeAll(!0);const e=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new Fe,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let t=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;pe.PREFER_ENV===Yn.WEBGL_LEGACY&&(t=null,i=null),t?e.drawBuffers=r=>t.drawBuffersWEBGL(r):(this.hasMRT=!1,e.drawBuffers=()=>{}),i||(this.writeDepthTexture=!1)}else this.msaaSamples=e.getInternalformatParameter(e.RENDERBUFFER,e.RGBA8,e.SAMPLES)}bind(e,t,i=0){const{gl:r}=this;if(e){const s=e.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(e);this.current!==e&&(this.current=e,r.bindFramebuffer(r.FRAMEBUFFER,s.framebuffer)),s.mipLevel!==i&&(e.dirtyId++,e.dirtyFormat++,s.mipLevel=i),s.dirtyId!==e.dirtyId&&(s.dirtyId=e.dirtyId,s.dirtyFormat!==e.dirtyFormat?(s.dirtyFormat=e.dirtyFormat,s.dirtySize=e.dirtySize,this.updateFramebuffer(e,i)):s.dirtySize!==e.dirtySize&&(s.dirtySize=e.dirtySize,this.resizeFramebuffer(e)));for(let o=0;o<e.colorTextures.length;o++){const a=e.colorTextures[o];this.renderer.texture.unbind(a.parentTextureArray||a)}if(e.depthTexture&&this.renderer.texture.unbind(e.depthTexture),t){const o=t.width>>i,a=t.height>>i,l=o/t.width;this.setViewport(t.x*l,t.y*l,o,a)}else{const o=e.width>>i,a=e.height>>i;this.setViewport(0,0,o,a)}}else this.current&&(this.current=null,r.bindFramebuffer(r.FRAMEBUFFER,null)),t?this.setViewport(t.x,t.y,t.width,t.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)}setViewport(e,t,i,r){const s=this.viewport;e=Math.round(e),t=Math.round(t),i=Math.round(i),r=Math.round(r),(s.width!==i||s.height!==r||s.x!==e||s.y!==t)&&(s.x=e,s.y=t,s.width=i,s.height=r,this.gl.viewport(e,t,i,r))}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(e,t,i,r,s=nh.COLOR|nh.DEPTH){const{gl:o}=this;o.clearColor(e,t,i,r),o.clear(s)}initFramebuffer(e){const{gl:t}=this,i=new zb(t.createFramebuffer());return i.multisample=this.detectSamples(e.multisample),e.glFramebuffers[this.CONTEXT_UID]=i,this.managedFramebuffers.push(e),e.disposeRunner.add(this),i}resizeFramebuffer(e){const{gl:t}=this,i=e.glFramebuffers[this.CONTEXT_UID];if(i.stencil){t.bindRenderbuffer(t.RENDERBUFFER,i.stencil);let o;this.renderer.context.webGLVersion===1?o=t.DEPTH_STENCIL:e.depth&&e.stencil?o=t.DEPTH24_STENCIL8:e.depth?o=t.DEPTH_COMPONENT24:o=t.STENCIL_INDEX8,i.msaaBuffer?t.renderbufferStorageMultisample(t.RENDERBUFFER,i.multisample,o,e.width,e.height):t.renderbufferStorage(t.RENDERBUFFER,o,e.width,e.height)}const r=e.colorTextures;let s=r.length;t.drawBuffers||(s=Math.min(s,1));for(let o=0;o<s;o++){const a=r[o],l=a.parentTextureArray||a;this.renderer.texture.bind(l,0),o===0&&i.msaaBuffer&&(t.bindRenderbuffer(t.RENDERBUFFER,i.msaaBuffer),t.renderbufferStorageMultisample(t.RENDERBUFFER,i.multisample,l._glTextures[this.CONTEXT_UID].internalFormat,e.width,e.height))}e.depthTexture&&this.writeDepthTexture&&this.renderer.texture.bind(e.depthTexture,0)}updateFramebuffer(e,t){const{gl:i}=this,r=e.glFramebuffers[this.CONTEXT_UID],s=e.colorTextures;let o=s.length;i.drawBuffers||(o=Math.min(o,1)),r.multisample>1&&this.canMultisampleFramebuffer(e)?r.msaaBuffer=r.msaaBuffer||i.createRenderbuffer():r.msaaBuffer&&(i.deleteRenderbuffer(r.msaaBuffer),r.msaaBuffer=null,r.blitFramebuffer&&(r.blitFramebuffer.dispose(),r.blitFramebuffer=null));const a=[];for(let l=0;l<o;l++){const h=s[l],u=h.parentTextureArray||h;this.renderer.texture.bind(u,0),l===0&&r.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,r.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,r.multisample,u._glTextures[this.CONTEXT_UID].internalFormat,e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,r.msaaBuffer)):(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+l,h.target,u._glTextures[this.CONTEXT_UID].texture,t),a.push(i.COLOR_ATTACHMENT0+l))}if(a.length>1&&i.drawBuffers(a),e.depthTexture&&this.writeDepthTexture){const l=e.depthTexture;this.renderer.texture.bind(l,0),i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,l._glTextures[this.CONTEXT_UID].texture,t)}if((e.stencil||e.depth)&&!(e.depthTexture&&this.writeDepthTexture)){r.stencil=r.stencil||i.createRenderbuffer();let l,h;this.renderer.context.webGLVersion===1?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH_STENCIL):e.depth&&e.stencil?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH24_STENCIL8):e.depth?(l=i.DEPTH_ATTACHMENT,h=i.DEPTH_COMPONENT24):(l=i.STENCIL_ATTACHMENT,h=i.STENCIL_INDEX8),i.bindRenderbuffer(i.RENDERBUFFER,r.stencil),r.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,r.multisample,h,e.width,e.height):i.renderbufferStorage(i.RENDERBUFFER,h,e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,l,i.RENDERBUFFER,r.stencil)}else r.stencil&&(i.deleteRenderbuffer(r.stencil),r.stencil=null)}canMultisampleFramebuffer(e){return this.renderer.context.webGLVersion!==1&&e.colorTextures.length<=1&&!e.depthTexture}detectSamples(e){const{msaaSamples:t}=this;let i=pt.NONE;if(e<=1||t===null)return i;for(let r=0;r<t.length;r++)if(t[r]<=e){i=t[r];break}return i===1&&(i=pt.NONE),i}blit(e,t,i){const{current:r,renderer:s,gl:o,CONTEXT_UID:a}=this;if(s.context.webGLVersion!==2||!r)return;const l=r.glFramebuffers[a];if(!l)return;if(!e){if(!l.msaaBuffer)return;const u=r.colorTextures[0];if(!u)return;l.blitFramebuffer||(l.blitFramebuffer=new _h(r.width,r.height),l.blitFramebuffer.addColorTexture(0,u)),e=l.blitFramebuffer,e.colorTextures[0]!==u&&(e.colorTextures[0]=u,e.dirtyId++,e.dirtyFormat++),(e.width!==r.width||e.height!==r.height)&&(e.width=r.width,e.height=r.height,e.dirtyId++,e.dirtySize++)}t||(t=Vb,t.width=r.width,t.height=r.height),i||(i=t);const h=t.width===i.width&&t.height===i.height;this.bind(e),o.bindFramebuffer(o.READ_FRAMEBUFFER,l.framebuffer),o.blitFramebuffer(t.left,t.top,t.right,t.bottom,i.left,i.top,i.right,i.bottom,o.COLOR_BUFFER_BIT,h?o.NEAREST:o.LINEAR),o.bindFramebuffer(o.READ_FRAMEBUFFER,e.glFramebuffers[this.CONTEXT_UID].framebuffer)}disposeFramebuffer(e,t){const i=e.glFramebuffers[this.CONTEXT_UID],r=this.gl;if(!i)return;delete e.glFramebuffers[this.CONTEXT_UID];const s=this.managedFramebuffers.indexOf(e);s>=0&&this.managedFramebuffers.splice(s,1),e.disposeRunner.remove(this),t||(r.deleteFramebuffer(i.framebuffer),i.msaaBuffer&&r.deleteRenderbuffer(i.msaaBuffer),i.stencil&&r.deleteRenderbuffer(i.stencil)),i.blitFramebuffer&&this.disposeFramebuffer(i.blitFramebuffer,t)}disposeAll(e){const t=this.managedFramebuffers;this.managedFramebuffers=[];for(let i=0;i<t.length;i++)this.disposeFramebuffer(t[i],e)}forceStencil(){const e=this.current;if(!e)return;const t=e.glFramebuffers[this.CONTEXT_UID];if(!t||t.stencil&&e.stencil)return;e.stencil=!0;const i=e.width,r=e.height,s=this.gl,o=t.stencil=s.createRenderbuffer();s.bindRenderbuffer(s.RENDERBUFFER,o);let a,l;this.renderer.context.webGLVersion===1?(a=s.DEPTH_STENCIL_ATTACHMENT,l=s.DEPTH_STENCIL):e.depth?(a=s.DEPTH_STENCIL_ATTACHMENT,l=s.DEPTH24_STENCIL8):(a=s.STENCIL_ATTACHMENT,l=s.STENCIL_INDEX8),t.msaaBuffer?s.renderbufferStorageMultisample(s.RENDERBUFFER,t.multisample,l,i,r):s.renderbufferStorage(s.RENDERBUFFER,l,i,r),s.framebufferRenderbuffer(s.FRAMEBUFFER,a,s.RENDERBUFFER,o)}reset(){this.current=this.unknownFramebuffer,this.viewport=new Fe}destroy(){this.renderer=null}}qg.extension={type:ue.RendererSystem,name:"framebuffer"};_e.add(qg);const Il={5126:4,5123:2,5121:1};class $g{constructor(e){this.renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this.canUseUInt32ElementIndex=!1,this.managedGeometries={}}contextChange(){this.disposeAll(!0);const e=this.gl=this.renderer.gl,t=this.renderer.context;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,t.webGLVersion!==2){let i=this.renderer.context.extensions.vertexArrayObject;pe.PREFER_ENV===Yn.WEBGL_LEGACY&&(i=null),i?(e.createVertexArray=()=>i.createVertexArrayOES(),e.bindVertexArray=r=>i.bindVertexArrayOES(r),e.deleteVertexArray=r=>i.deleteVertexArrayOES(r)):(this.hasVao=!1,e.createVertexArray=()=>null,e.bindVertexArray=()=>null,e.deleteVertexArray=()=>null)}if(t.webGLVersion!==2){const i=e.getExtension("ANGLE_instanced_arrays");i?(e.vertexAttribDivisor=(r,s)=>i.vertexAttribDivisorANGLE(r,s),e.drawElementsInstanced=(r,s,o,a,l)=>i.drawElementsInstancedANGLE(r,s,o,a,l),e.drawArraysInstanced=(r,s,o,a)=>i.drawArraysInstancedANGLE(r,s,o,a)):this.hasInstance=!1}this.canUseUInt32ElementIndex=t.webGLVersion===2||!!t.extensions.uint32ElementIndex}bind(e,t){t=t||this.renderer.shader.shader;const{gl:i}=this;let r=e.glVertexArrayObjects[this.CONTEXT_UID],s=!1;r||(this.managedGeometries[e.id]=e,e.disposeRunner.add(this),e.glVertexArrayObjects[this.CONTEXT_UID]=r={},s=!0);const o=r[t.program.id]||this.initGeometryVao(e,t,s);this._activeGeometry=e,this._activeVao!==o&&(this._activeVao=o,this.hasVao?i.bindVertexArray(o):this.activateVao(e,t.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const e=this._activeGeometry,t=this.renderer.buffer;for(let i=0;i<e.buffers.length;i++){const r=e.buffers[i];t.update(r)}}checkCompatibility(e,t){const i=e.attributes,r=t.attributeData;for(const s in r)if(!i[s])throw new Error(`shader and geometry incompatible, geometry missing the "${s}" attribute`)}getSignature(e,t){const i=e.attributes,r=t.attributeData,s=["g",e.id];for(const o in i)r[o]&&s.push(o,r[o].location);return s.join("-")}initGeometryVao(e,t,i=!0){const r=this.gl,s=this.CONTEXT_UID,o=this.renderer.buffer,a=t.program;a.glPrograms[s]||this.renderer.shader.generateProgram(t),this.checkCompatibility(e,a);const l=this.getSignature(e,a),h=e.glVertexArrayObjects[this.CONTEXT_UID];let u=h[l];if(u)return h[a.id]=u,u;const c=e.buffers,d=e.attributes,f={},p={};for(const g in c)f[g]=0,p[g]=0;for(const g in d)!d[g].size&&a.attributeData[g]?d[g].size=a.attributeData[g].size:d[g].size||console.warn(`PIXI Geometry attribute '${g}' size cannot be determined (likely the bound shader does not have the attribute)`),f[d[g].buffer]+=d[g].size*Il[d[g].type];for(const g in d){const v=d[g],m=v.size;v.stride===void 0&&(f[v.buffer]===m*Il[v.type]?v.stride=0:v.stride=f[v.buffer]),v.start===void 0&&(v.start=p[v.buffer],p[v.buffer]+=m*Il[v.type])}u=r.createVertexArray(),r.bindVertexArray(u);for(let g=0;g<c.length;g++){const v=c[g];o.bind(v),i&&v._glBuffers[s].refCount++}return this.activateVao(e,a),h[a.id]=u,h[l]=u,r.bindVertexArray(null),o.unbind(Ci.ARRAY_BUFFER),u}disposeGeometry(e,t){var i;if(!this.managedGeometries[e.id])return;delete this.managedGeometries[e.id];const r=e.glVertexArrayObjects[this.CONTEXT_UID],s=this.gl,o=e.buffers,a=(i=this.renderer)==null?void 0:i.buffer;if(e.disposeRunner.remove(this),!!r){if(a)for(let l=0;l<o.length;l++){const h=o[l]._glBuffers[this.CONTEXT_UID];h&&(h.refCount--,h.refCount===0&&!t&&a.dispose(o[l],t))}if(!t){for(const l in r)if(l[0]==="g"){const h=r[l];this._activeVao===h&&this.unbind(),s.deleteVertexArray(h)}}delete e.glVertexArrayObjects[this.CONTEXT_UID]}}disposeAll(e){const t=Object.keys(this.managedGeometries);for(let i=0;i<t.length;i++)this.disposeGeometry(this.managedGeometries[t[i]],e)}activateVao(e,t){const i=this.gl,r=this.CONTEXT_UID,s=this.renderer.buffer,o=e.buffers,a=e.attributes;e.indexBuffer&&s.bind(e.indexBuffer);let l=null;for(const h in a){const u=a[h],c=o[u.buffer],d=c._glBuffers[r];if(t.attributeData[h]){l!==d&&(s.bind(c),l=d);const f=t.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(e,t,i,r){const{gl:s}=this,o=this._activeGeometry;if(o.indexBuffer){const a=o.indexBuffer.data.BYTES_PER_ELEMENT,l=a===2?s.UNSIGNED_SHORT:s.UNSIGNED_INT;a===2||a===4&&this.canUseUInt32ElementIndex?o.instanced?s.drawElementsInstanced(e,t||o.indexBuffer.data.length,l,(i||0)*a,r||1):s.drawElements(e,t||o.indexBuffer.data.length,l,(i||0)*a):console.warn("unsupported index buffer type: uint32")}else o.instanced?s.drawArraysInstanced(e,i,t||o.getSize(),r||1):s.drawArrays(e,i,t||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}$g.extension={type:ue.RendererSystem,name:"geometry"};_e.add($g);const vf=new tt;class Zg{constructor(e,t){this._texture=e,this.mapCoord=new tt,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=typeof t>"u"?.5:t,this.isSimple=!1}get texture(){return this._texture}set texture(e){this._texture=e,this._textureID=-1}
vendor: 1,373 bytes, lines 447-464
447multiplyUvs(e,t){t===void 0&&(t=e);const i=this.mapCoord;for(let r=0;r<e.length;r+=2){const s=e[r],o=e[r+1];t[r]=s*i.a+o*i.c+i.tx,t[r+1]=s*i.b+o*i.d+i.ty}return t}update(e){const t=this._texture;if(!t||!t.valid||!e&&this._textureID===t._updateID)return!1;this._textureID=t._updateID,this._updateID++;const i=t._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 r=t.orig,s=t.trim;s&&(vf.set(r.width/s.width,0,0,r.height/s.height,-s.x/s.width,-s.y/s.height),this.mapCoord.append(vf));const o=t.baseTexture,a=this.uClampFrame,l=this.clampMargin/o.resolution,h=this.clampOffset;return a[0]=(t._frame.x+l+h)/o.width,a[1]=(t._frame.y+l+h)/o.height,a[2]=(t._frame.x+t._frame.width-l+h)/o.width,a[3]=(t._frame.y+t._frame.height-l+h)/o.height,this.uClampOffset[0]=h/o.realWidth,this.uClampOffset[1]=h/o.realHeight,this.isSimple=t._frame.width===o.width&&t._frame.height===o.height&&t.rotate===0,!0}}var jb=`varying vec2 vMaskCoord; 448varying vec2 vTextureCoord; 449 450uniform sampler2D uSampler; 451uniform sampler2D mask; 452uniform float alpha; 453uniform float npmAlpha; 454uniform vec4 maskClamp; 455 456void main(void) 457{ 458 float clip = step(3.5, 459 step(maskClamp.x, vMaskCoord.x) + 460 step(maskClamp.y, vMaskCoord.y) + 461 step(vMaskCoord.x, maskClamp.z) + 462 step(vMaskCoord.y, maskClamp.w)); 463 464 vec4 original = texture2D(uSampler, vTextureCoord);
465 vec4 masky = texture2D(mask, vMaskCoord); 466 float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a); 467 468 original *= (alphaMul * masky.r * alpha * clip); 469 470 gl_FragColor = original; 471} 472`,Xb=`attribute vec2 aVertexPosition; 473attribute vec2 aTextureCoord; 474 475uniform mat3 projectionMatrix; 476uniform mat3 otherMatrix; 477 478varying vec2 vMaskCoord; 479varying vec2 vTextureCoord; 480 481void main(void) 482{ 483 gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); 484 485 vTextureCoord = aTextureCoord; 486 vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy; 487} 488`;class Wb extends Ft{constructor(e,t,i){let r=null;typeof e!="string"&&t===void 0&&i===void 0&&(r=e,e=void 0,t=void 0,i=void 0),super(e||Xb,t||jb,i),this.maskSprite=r,this.maskMatrix=new tt}get maskSprite(){return this._maskSprite}set maskSprite(e){this._maskSprite=e,this._maskSprite&&(this._maskSprite.renderable=!1)}apply(e,t,i,r){const s=this._maskSprite,o=s._texture;o.valid&&(o.uvMatrix||(o.uvMatrix=new Zg(o,0)),o.uvMatrix.update(),this.uniforms.npmAlpha=o.baseTexture.alphaMode?0:1,this.uniforms.mask=o,this.uniforms.otherMatrix=e.calculateSpriteMatrix(this.maskMatrix,s).prepend(o.uvMatrix.mapCoord),this.uniforms.alpha=s.worldAlpha,this.uniforms.maskClamp=o.uvMatrix.uClampFrame,e.applyFilter(this,t,i,r))}}class Yb{constructor(e=null){this.type=mt.NONE,this.autoDetect=!0,this.maskObject=e||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=Ft.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(e){e?this._filters?this._filters[0]=e:this._filters=[e]:this._filters=null}reset(){this.pooled&&(this.maskObject=null,this.type=mt.NONE,this.autoDetect=!0),this._target=null,this._scissorRectLocal=null}copyCountersOrReset(e){e?(this._stencilCounter=e._stencilCounter,this._scissorCounter=e._scissorCounter,this._scissorRect=e._scissorRect):(this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null)}}class Kg{constructor(e){this.renderer=e,this.enableScissor=!0,this.alphaMaskPool=[],this.maskDataPool=[],this.maskStack=[],this.alphaMaskIndex=0}setMaskStack(e){this.maskStack=e,this.renderer.scissor.setMaskStack(e),this.renderer.stencil.setMaskStack(e)}push(e,t){let i=t;if(!i.isMaskData){const s=this.maskDataPool.pop()||new Yb;s.pooled=!0,s.maskObject=t,i=s}const r=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null;if(i.copyCountersOrReset(r),i._colorMask=r?r._colorMask:15,i.autoDetect&&this.detect(i),i._target=e,i.type!==mt.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case mt.SCISSOR:this.renderer.scissor.push(i);break;case mt.STENCIL:this.renderer.stencil.push(i);break;case mt.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case mt.COLOR:this.pushColorMask(i);break}i.type===mt.SPRITE&&this.maskStack.push(i)}pop(e){const t=this.maskStack.pop();if(!(!t||t._target!==e)){if(t.enabled)switch(t.type){case mt.SCISSOR:this.renderer.scissor.pop(t);break;case mt.STENCIL:this.renderer.stencil.pop(t.maskObject);break;case mt.SPRITE:this.popSpriteMask(t);break;case mt.COLOR:this.popColorMask(t);break}if(t.reset(),t.pooled&&this.maskDataPool.push(t),this.maskStack.length!==0){const i=this.maskStack[this.maskStack.length-1];i.type===mt.SPRITE&&i._filters&&(i._filters[0].maskSprite=i.maskObject)}}}detect(e){const t=e.maskObject;t?t.isSprite?e.type=mt.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(e)?e.type=mt.SCISSOR:e.type=mt.STENCIL:e.type=mt.COLOR}pushSpriteMask(e){const{maskObject:t}=e,i=e._target;let r=e._filters;r||(r=this.alphaMaskPool[this.alphaMaskIndex],r||(r=this.alphaMaskPool[this.alphaMaskIndex]=[new Wb])),r[0].resolution=e.resolution,r[0].multisample=e.multisample,r[0].maskSprite=t;const s=i.filterArea;i.filterArea=t.getBounds(!0),this.renderer.filter.push(i,r),i.filterArea=s,e._filters||this.alphaMaskIndex++}popSpriteMask(e){this.renderer.filter.pop(),e._filters?e._filters[0].maskSprite=null:(this.alphaMaskIndex--,this.alphaMaskPool[this.alphaMaskIndex][0].maskSprite=null)}pushColorMask(e){const t=e._colorMask,i=e._colorMask=t&e.colorMask;i!==t&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}popColorMask(e){const t=e._colorMask,i=this.maskStack.length>0?this.maskStack[this.maskStack.length-1]._colorMask:15;i!==t&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}destroy(){this.renderer=null}}Kg.extension={type:ue.RendererSystem,name:"mask"};_e.add(Kg);
vendor: 40,211 bytes, lines 488-567
488class Jg{constructor(e){this.renderer=e,this.maskStack=[],this.glConst=0}getStackLength(){return this.maskStack.length}setMaskStack(e){const{gl:t}=this.renderer,i=this.getStackLength();this.maskStack=e;const r=this.getStackLength();r!==i&&(r===0?t.disable(this.glConst):(t.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}const yf=new tt,xf=[],Qg=class Po extends Jg{constructor(e){super(e),this.glConst=pe.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST}getStackLength(){const e=this.maskStack[this.maskStack.length-1];return e?e._scissorCounter:0}calcScissorRect(e){if(e._scissorRectLocal)return;const t=e._scissorRect,{maskObject:i}=e,{renderer:r}=this,s=r.renderTexture,o=i.getBounds(!0,xf.pop()??new Fe);this.roundFrameToPixels(o,s.current?s.current.resolution:r.resolution,s.sourceFrame,s.destinationFrame,r.projection.transform),t&&o.fit(t),e._scissorRectLocal=o}static isMatrixRotated(e){if(!e)return!1;const{a:t,b:i,c:r,d:s}=e;return(Math.abs(i)>1e-4||Math.abs(r)>1e-4)&&(Math.abs(t)>1e-4||Math.abs(s)>1e-4)}testScissor(e){const{maskObject:t}=e;if(!t.isFastRect||!t.isFastRect()||Po.isMatrixRotated(t.worldTransform)||Po.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(e);const i=e._scissorRectLocal;return i.width>0&&i.height>0}roundFrameToPixels(e,t,i,r,s){Po.isMatrixRotated(s)||(s=s?yf.copyFrom(s):yf.identity(),s.translate(-i.x,-i.y).scale(r.width/i.width,r.height/i.height).translate(r.x,r.y),this.renderer.filter.transformAABB(s,e),e.fit(r),e.x=Math.round(e.x*t),e.y=Math.round(e.y*t),e.width=Math.round(e.width*t),e.height=Math.round(e.height*t))}push(e){e._scissorRectLocal||this.calcScissorRect(e);const{gl:t}=this.renderer;e._scissorRect||t.enable(t.SCISSOR_TEST),e._scissorCounter++,e._scissorRect=e._scissorRectLocal,this._useCurrent()}pop(e){const{gl:t}=this.renderer;e&&xf.push(e._scissorRectLocal),this.getStackLength()>0?this._useCurrent():t.disable(t.SCISSOR_TEST)}_useCurrent(){const e=this.maskStack[this.maskStack.length-1]._scissorRect;let t;this.renderer.renderTexture.current?t=e.y:t=this.renderer.height-e.height-e.y,this.renderer.gl.scissor(e.x,t,e.width,e.height)}};Qg.extension={type:ue.RendererSystem,name:"scissor"};let qb=Qg;_e.add(qb);class em extends Jg{constructor(e){super(e),this.glConst=pe.ADAPTER.getWebGLRenderingContext().STENCIL_TEST}getStackLength(){const e=this.maskStack[this.maskStack.length-1];return e?e._stencilCounter:0}push(e){const t=e.maskObject,{gl:i}=this.renderer,r=e._stencilCounter;r===0&&(this.renderer.framebuffer.forceStencil(),i.clearStencil(0),i.clear(i.STENCIL_BUFFER_BIT),i.enable(i.STENCIL_TEST)),e._stencilCounter++;const s=e._colorMask;s!==0&&(e._colorMask=0,i.colorMask(!1,!1,!1,!1)),i.stencilFunc(i.EQUAL,r,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.INCR),t.renderable=!0,t.render(this.renderer),this.renderer.batch.flush(),t.renderable=!1,s!==0&&(e._colorMask=s,i.colorMask((s&1)!==0,(s&2)!==0,(s&4)!==0,(s&8)!==0)),this._useCurrent()}pop(e){const t=this.renderer.gl;if(this.getStackLength()===0)t.disable(t.STENCIL_TEST);else{const i=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null,r=i?i._colorMask:15;r!==0&&(i._colorMask=0,t.colorMask(!1,!1,!1,!1)),t.stencilOp(t.KEEP,t.KEEP,t.DECR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,r!==0&&(i._colorMask=r,t.colorMask((r&1)!==0,(r&2)!==0,(r&4)!==0,(r&8)!==0)),this._useCurrent()}}_useCurrent(){const e=this.renderer.gl;e.stencilFunc(e.EQUAL,this.getStackLength(),4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP)}}em.extension={type:ue.RendererSystem,name:"stencil"};_e.add(em);class tm{constructor(e){this.renderer=e,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get(){return Ue("7.0.0","renderer.plugins.extract has moved to renderer.extract"),e.extract}},prepare:{enumerable:!1,get(){return Ue("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),e.prepare}},interaction:{enumerable:!1,get(){return Ue("7.0.0","renderer.plugins.interaction has been deprecated, use renderer.events"),e.events}}})}init(){const e=this.rendererPlugins;for(const t in e)this.plugins[t]=new e[t](this.renderer)}destroy(){for(const e in this.plugins)this.plugins[e].destroy(),this.plugins[e]=null}}tm.extension={type:[ue.RendererSystem,ue.CanvasRendererSystem],name:"_plugin"};_e.add(tm);class im{constructor(e){this.renderer=e,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new tt,this.transform=null}update(e,t,i,r){this.destinationFrame=e||this.destinationFrame||this.defaultFrame,this.sourceFrame=t||this.sourceFrame||e,this.calculateProjection(this.destinationFrame,this.sourceFrame,i,r),this.transform&&this.projectionMatrix.append(this.transform);const s=this.renderer;s.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,s.globalUniforms.update(),s.shader.shader&&s.shader.syncUniformGroup(s.shader.shader.uniforms.globals)}calculateProjection(e,t,i,r){const s=this.projectionMatrix,o=r?-1:1;s.identity(),s.a=1/t.width*2,s.d=o*(1/t.height*2),s.tx=-1-t.x*s.a,s.ty=-o-t.y*s.d}setTransform(e){}destroy(){this.renderer=null}}im.extension={type:ue.RendererSystem,name:"projection"};_e.add(im);const $b=new yu,_f=new Fe;class nm{constructor(e){this.renderer=e,this._tempMatrix=new tt}generateTexture(e,t){const{region:i,...r}=t||{},s=i?.copyTo(_f)||e.getLocalBounds(_f,!0),o=r.resolution||this.renderer.resolution;s.width=Math.max(s.width,1/o),s.height=Math.max(s.height,1/o),r.width=s.width,r.height=s.height,r.resolution=o,r.multisample??(r.multisample=this.renderer.multisample);const a=qn.create(r);this._tempMatrix.tx=-s.x,this._tempMatrix.ty=-s.y;const l=e.transform;return e.transform=$b,this.renderer.render(e,{renderTexture:a,transform:this._tempMatrix,skipUpdateTransform:!!e.parent,blit:!0}),e.transform=l,a}destroy(){}}nm.extension={type:[ue.RendererSystem,ue.CanvasRendererSystem],name:"textureGenerator"};_e.add(nm);const wn=new Fe,Qr=new Fe;class rm{constructor(e){this.renderer=e,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new Fe,this.destinationFrame=new Fe,this.viewportFrame=new Fe}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}bind(e=null,t,i){const r=this.renderer;this.current=e;let s,o,a;e?(s=e.baseTexture,a=s.resolution,t||(wn.width=e.frame.width,wn.height=e.frame.height,t=wn),i||(Qr.x=e.frame.x,Qr.y=e.frame.y,Qr.width=t.width,Qr.height=t.height,i=Qr),o=s.framebuffer):(a=r.resolution,t||(wn.width=r._view.screen.width,wn.height=r._view.screen.height,t=wn),i||(i=wn,i.width=t.width,i.height=t.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,e||(l.y=r.view.height-(l.y+l.height)),l.ceil(),this.renderer.framebuffer.bind(o,l),this.renderer.projection.update(i,t,a,!o),e?this.renderer.mask.setMaskStack(s.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(t),this.destinationFrame.copyFrom(i)}clear(e,t){const i=this.current?this.current.baseTexture.clear:this.renderer.background.backgroundColor,r=Ze.shared.setValue(e||i);(this.current&&this.current.baseTexture.alphaMode>0||!this.current&&this._rendererPremultipliedAlpha)&&r.premultiply(r.alpha);const s=this.destinationFrame,o=this.current?this.current.baseTexture:this.renderer._view.screen,a=s.width!==o.width||s.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(r.red,r.green,r.blue,r.alpha,t),a&&this.renderer.scissor.pop()}resize(){this.bind(null)}reset(){this.bind(null)}destroy(){this.renderer=null}}rm.extension={type:ue.RendererSystem,name:"renderTexture"};_e.add(rm);class Zb{constructor(e,t){this.program=e,this.uniformData=t,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBufferBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBufferBindings=null,this.program=null}}function Kb(n,e){const t={},i=e.getProgramParameter(n,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const s=e.getActiveAttrib(n,r);if(s.name.startsWith("gl_"))continue;const o=Gg(e,s.type),a={type:o,name:s.name,size:Hg(o),location:e.getAttribLocation(n,s.name)};t[s.name]=a}return t}function Jb(n,e){const t={},i=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let r=0;r<i;r++){const s=e.getActiveUniform(n,r),o=s.name.replace(/\[.*?\]$/,""),a=!!s.name.match(/\[.*?\]$/),l=Gg(e,s.type);t[o]={name:o,index:r,type:l,size:s.size,isArray:a,value:kg(l,s.size)}}return t}function Qb(n,e){var t;const i=cf(n,n.VERTEX_SHADER,e.vertexSrc),r=cf(n,n.FRAGMENT_SHADER,e.fragmentSrc),s=n.createProgram();n.attachShader(s,i),n.attachShader(s,r);const o=(t=e.extra)==null?void 0:t.transformFeedbackVaryings;if(o&&(typeof n.transformFeedbackVaryings!="function"?console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given."):n.transformFeedbackVaryings(s,o.names,o.bufferMode==="separate"?n.SEPARATE_ATTRIBS:n.INTERLEAVED_ATTRIBS)),n.linkProgram(s),n.getProgramParameter(s,n.LINK_STATUS)||Pb(n,s,i,r),e.attributeData=Kb(s,n),e.uniformData=Jb(s,n),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(e.vertexSrc)){const l=Object.keys(e.attributeData);l.sort((h,u)=>h>u?1:-1);for(let h=0;h<l.length;h++)e.attributeData[l[h]].location=h,n.bindAttribLocation(s,h,l[h]);n.linkProgram(s)}n.deleteShader(i),n.deleteShader(r);const a={};for(const l in e.uniformData){const h=e.uniformData[l];a[l]={location:n.getUniformLocation(s,l),value:kg(h.type,h.size)}}return new Zb(s,a)}function e1(n,e,t,i,r){t.buffer.update(r)}const t1={float:` 489 data[offset] = v; 490 `,vec2:` 491 data[offset] = v[0]; 492 data[offset+1] = v[1]; 493 `,vec3:` 494 data[offset] = v[0]; 495 data[offset+1] = v[1]; 496 data[offset+2] = v[2]; 497 498 `,vec4:` 499 data[offset] = v[0]; 500 data[offset+1] = v[1]; 501 data[offset+2] = v[2]; 502 data[offset+3] = v[3]; 503 `,mat2:` 504 data[offset] = v[0]; 505 data[offset+1] = v[1]; 506 507 data[offset+4] = v[2]; 508 data[offset+5] = v[3]; 509 `,mat3:` 510 data[offset] = v[0]; 511 data[offset+1] = v[1]; 512 data[offset+2] = v[2]; 513 514 data[offset + 4] = v[3]; 515 data[offset + 5] = v[4]; 516 data[offset + 6] = v[5]; 517 518 data[offset + 8] = v[6]; 519 data[offset + 9] = v[7]; 520 data[offset + 10] = v[8]; 521 `,mat4:` 522 for(var i = 0; i < 16; i++) 523 { 524 data[offset + i] = v[i]; 525 } 526 `},sm={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:32,mat3:48,mat4:64};function i1(n){const e=n.map(s=>({data:s,offset:0,dataLen:0,dirty:0}));let t=0,i=0,r=0;for(let s=0;s<e.length;s++){const o=e[s];if(t=sm[o.data.type],o.data.size>1&&(t=Math.max(t,16)*o.data.size),o.dataLen=t,i%t!==0&&i<16){const a=i%t%16;i+=a,r+=a}i+t>16?(r=Math.ceil(r/16)*16,o.offset=r,r+=t,i=t):(o.offset=r,i+=t,r+=t)}return r=Math.ceil(r/16)*16,{uboElements:e,size:r}}function n1(n,e){const t=[];for(const i in n)e[i]&&t.push(e[i]);return t.sort((i,r)=>i.index-r.index),t}function r1(n,e){if(!n.autoManage)return{size:0,syncFunc:e1};const t=n1(n.uniforms,e),{uboElements:i,size:r}=i1(t),s=[` 527 var v = null; 528 var v2 = null; 529 var cv = null; 530 var t = 0; 531 var gl = renderer.gl 532 var index = 0; 533 var data = buffer.data; 534 `];for(let o=0;o<i.length;o++){const a=i[o],l=n.uniforms[a.data.name],h=a.data.name;let u=!1;for(let c=0;c<Sr.length;c++){const d=Sr[c];if(d.codeUbo&&d.test(a.data,l)){s.push(`offset = ${a.offset/4};`,Sr[c].codeUbo(a.data.name,l)),u=!0;break}}if(!u)if(a.data.size>1){const c=Hg(a.data.type),d=Math.max(sm[a.data.type]/16,1),f=c/d,p=(4-f%4)%4;s.push(` 535 cv = ud.${h}.value; 536 v = uv.${h}; 537 offset = ${a.offset/4}; 538 539 t = 0; 540 541 for(var i=0; i < ${a.data.size*d}; i++) 542 { 543 for(var j = 0; j < ${f}; j++) 544 { 545 data[offset++] = v[t++]; 546 } 547 offset += ${p}; 548 } 549 550 `)}else{const c=t1[a.data.type];s.push(` 551 cv = ud.${h}.value; 552 v = uv.${h}; 553 offset = ${a.offset/4}; 554 ${c}; 555 `)}}return s.push(` 556 renderer.buffer.update(buffer); 557 `),{size:r,syncFunc:new Function("ud","uv","renderer","syncData","buffer",s.join(` 558`))}}let s1=0;const oo={textureCount:0,uboCount:0};class om{constructor(e){this.destroyed=!1,this.renderer=e,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=s1++}systemCheck(){if(!Ib())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(e){this.gl=e,this.reset()}bind(e,t){e.disposeRunner.add(this),e.uniforms.globals=this.renderer.globalUniforms;const i=e.program,r=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(e);return this.shader=e,this.program!==i&&(this.program=i,this.gl.useProgram(r.program)),t||(oo.textureCount=0,oo.uboCount=0,this.syncUniformGroup(e.uniformGroup,oo)),r}setUniforms(e){const t=this.shader.program,i=t.glPrograms[this.renderer.CONTEXT_UID];t.syncUniforms(i.uniformData,e,this.renderer)}syncUniformGroup(e,t){const i=this.getGlProgram();(!e.static||e.dirtyId!==i.uniformDirtyGroups[e.id])&&(i.uniformDirtyGroups[e.id]=e.dirtyId,this.syncUniforms(e,i,t))}syncUniforms(e,t,i){(e.syncUniforms[this.shader.program.id]||this.createSyncGroups(e))(t.uniformData,e.uniforms,this.renderer,i)}createSyncGroups(e){const t=this.getSignature(e,this.shader.program.uniformData,"u");return this.cache[t]||(this.cache[t]=Sb(e,this.shader.program.uniformData)),e.syncUniforms[this.shader.program.id]=this.cache[t],e.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(e,t){const i=this.getGlProgram();if(!e.static||e.dirtyId!==0||!i.uniformGroups[e.id]){e.dirtyId=0;const r=i.uniformGroups[e.id]||this.createSyncBufferGroup(e,i,t);e.buffer.update(),r(i.uniformData,e.uniforms,this.renderer,oo,e.buffer)}this.renderer.buffer.bindBufferBase(e.buffer,i.uniformBufferBindings[t])}createSyncBufferGroup(e,t,i){const{gl:r}=this.renderer;this.renderer.buffer.bind(e.buffer);const s=this.gl.getUniformBlockIndex(t.program,i);t.uniformBufferBindings[i]=this.shader.uniformBindCount,r.uniformBlockBinding(t.program,s,this.shader.uniformBindCount),this.shader.uniformBindCount++;const o=this.getSignature(e,this.shader.program.uniformData,"ubo");let a=this._uboCache[o];if(a||(a=this._uboCache[o]=r1(e,this.shader.program.uniformData)),e.autoManage){const l=new Float32Array(a.size/4);e.buffer.update(l)}return t.uniformGroups[e.id]=a.syncFunc,t.uniformGroups[e.id]}getSignature(e,t,i){const r=e.uniforms,s=[`${i}-`];for(const o in r)s.push(o),t[o]&&s.push(t[o].type);return s.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(e){const t=this.gl,i=e.program,r=Qb(t,i);return i.glPrograms[this.renderer.CONTEXT_UID]=r,r}reset(){this.program=null,this.shader=null}disposeShader(e){this.shader===e&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}om.extension={type:ue.RendererSystem,name:"shader"};_e.add(om);class ea{constructor(e){this.renderer=e}run(e){const{renderer:t}=this;t.runners.init.emit(t.options),e.hello&&console.log(`PixiJS 7.4.3 - ${t.rendererLogId} - https://pixijs.com`),t.resize(t.screen.width,t.screen.height)}destroy(){}}ea.defaultOptions={hello:!1},ea.extension={type:[ue.RendererSystem,ue.CanvasRendererSystem],name:"startup"};_e.add(ea);function o1(n,e=[]){return e[Ce.NORMAL]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[Ce.ADD]=[n.ONE,n.ONE],e[Ce.MULTIPLY]=[n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA],e[Ce.SCREEN]=[n.ONE,n.ONE_MINUS_SRC_COLOR,n.ONE,n.ONE_MINUS_SRC_ALPHA],e[Ce.OVERLAY]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[Ce.DARKEN]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[Ce.LIGHTEN]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[Ce.COLOR_DODGE]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[Ce.COLOR_BURN]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[Ce.HARD_LIGHT]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[Ce.SOFT_LIGHT]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[Ce.DIFFERENCE]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[Ce.EXCLUSION]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[Ce.HUE]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[Ce.SATURATION]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[Ce.COLOR]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[Ce.LUMINOSITY]=[n.ONE,n.ONE_MINUS_SRC_ALPHA],e[Ce.NONE]=[0,0],e[Ce.NORMAL_NPM]=[n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA],e[Ce.ADD_NPM]=[n.SRC_ALPHA,n.ONE,n.ONE,n.ONE],e[Ce.SCREEN_NPM]=[n.SRC_ALPHA,n.ONE_MINUS_SRC_COLOR,n.ONE,n.ONE_MINUS_SRC_ALPHA],e[Ce.SRC_IN]=[n.DST_ALPHA,n.ZERO],e[Ce.SRC_OUT]=[n.ONE_MINUS_DST_ALPHA,n.ZERO],e[Ce.SRC_ATOP]=[n.DST_ALPHA,n.ONE_MINUS_SRC_ALPHA],e[Ce.DST_OVER]=[n.ONE_MINUS_DST_ALPHA,n.ONE],e[Ce.DST_IN]=[n.ZERO,n.SRC_ALPHA],e[Ce.DST_OUT]=[n.ZERO,n.ONE_MINUS_SRC_ALPHA],e[Ce.DST_ATOP]=[n.ONE_MINUS_DST_ALPHA,n.SRC_ALPHA],e[Ce.XOR]=[n.ONE_MINUS_DST_ALPHA,n.ONE_MINUS_SRC_ALPHA],e[Ce.SUBTRACT]=[n.ONE,n.ONE,n.ONE,n.ONE,n.FUNC_REVERSE_SUBTRACT,n.FUNC_ADD],e}const a1=0,l1=1,h1=2,u1=3,c1=4,d1=5,am=class wh{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=Ce.NONE,this._blendEq=!1,this.map=[],this.map[a1]=this.setBlend,this.map[l1]=this.setOffset,this.map[h1]=this.setCullFace,this.map[u1]=this.setDepthTest,this.map[c1]=this.setFrontFace,this.map[d1]=this.setDepthMask,this.checks=[],this.defaultState=new Di,this.defaultState.blend=!0}contextChange(e){this.gl=e,this.blendModes=o1(e),this.set(this.defaultState),this.reset()}set(e){if(e=e||this.defaultState,this.stateId!==e.data){let t=this.stateId^e.data,i=0;for(;t;)t&1&&this.map[i].call(this,!!(e.data&1<<i)),t=t>>1,i++;this.stateId=e.data}for(let t=0;t<this.checks.length;t++)this.checks[t](this,e)}forceState(e){e=e||this.defaultState;for(let t=0;t<this.map.length;t++)this.map[t].call(this,!!(e.data&1<<t));for(let t=0;t<this.checks.length;t++)this.checks[t](this,e);this.stateId=e.data}setBlend(e){this.updateCheck(wh.checkBlendMode,e),this.gl[e?"enable":"disable"](this.gl.BLEND)}setOffset(e){this.updateCheck(wh.checkPolygonOffset,e),this.gl[e?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(e){this.gl[e?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(e){this.gl.depthMask(e)}setCullFace(e){this.gl[e?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(e){this.gl.frontFace(this.gl[e?"CW":"CCW"])}setBlendMode(e){if(e===this.blendMode)return;this.blendMode=e;const t=this.blendModes[e],i=this.gl;t.length===2?i.blendFunc(t[0],t[1]):i.blendFuncSeparate(t[0],t[1],t[2],t[3]),t.length===6?(this._blendEq=!0,i.blendEquationSeparate(t[4],t[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(e,t){this.gl.polygonOffset(e,t)}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(e,t){const i=this.checks.indexOf(e);t&&i===-1?this.checks.push(e):!t&&i!==-1&&this.checks.splice(i,1)}static checkBlendMode(e,t){e.setBlendMode(t.blendMode)}static checkPolygonOffset(e,t){e.setPolygonOffset(1,t.polygonOffset)}destroy(){this.gl=null}};am.extension={type:ue.RendererSystem,name:"state"};let f1=am;_e.add(f1);class p1 extends Hs{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(e){this.addRunners(...e.runners);const t=(e.priority??[]).filter(r=>e.systems[r]),i=[...t,...Object.keys(e.systems).filter(r=>!t.includes(r))];for(const r of i)this.addSystem(e.systems[r],r)}addRunners(...e){e.forEach(t=>{this.runners[t]=new ci(t)})}addSystem(e,t){const i=new e(this);if(this[t])throw new Error(`Whoops! The name "${t}" is already in use`);this[t]=i,this._systemsHash[t]=i;for(const r in this.runners)this.runners[r].add(i);return this}emitWithCustomOptions(e,t){const i=Object.keys(this._systemsHash);e.items.forEach(r=>{const s=i.find(o=>this._systemsHash[o]===r);r[e.name](t[s])})}destroy(){Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash={}}}const os=class Co{constructor(e){this.renderer=e,this.count=0,this.checkCount=0,this.maxIdle=Co.defaultMaxIdle,this.checkCountMax=Co.defaultCheckCountMax,this.mode=Co.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==pu.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const e=this.renderer.texture,t=e.managedTextures;let i=!1;for(let r=0;r<t.length;r++){const s=t[r];s.resource&&this.count-s.touched>this.maxIdle&&(e.destroyTexture(s,!0),t[r]=null,i=!0)}if(i){let r=0;for(let s=0;s<t.length;s++)t[s]!==null&&(t[r++]=t[s]);t.length=r}}unload(e){const t=this.renderer.texture,i=e._texture;i&&!i.framebuffer&&t.destroyTexture(i);for(let r=e.children.length-1;r>=0;r--)this.unload(e.children[r])}destroy(){this.renderer=null}};os.defaultMode=pu.AUTO,os.defaultMaxIdle=3600,os.defaultCheckCountMax=600,os.extension={type:ue.RendererSystem,name:"textureGC"};let Pn=os;_e.add(Pn);class Ml{constructor(e){this.texture=e,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=Ee.UNSIGNED_BYTE,this.internalFormat=oe.RGBA,this.samplerType=0}}function g1(n){let e;return"WebGL2RenderingContext"in globalThis&&n instanceof globalThis.WebGL2RenderingContext?e={[n.RGB]:fe.FLOAT,[n.RGBA]:fe.FLOAT,[n.ALPHA]:fe.FLOAT,[n.LUMINANCE]:fe.FLOAT,[n.LUMINANCE_ALPHA]:fe.FLOAT,[n.R8]:fe.FLOAT,[n.R8_SNORM]:fe.FLOAT,[n.RG8]:fe.FLOAT,[n.RG8_SNORM]:fe.FLOAT,[n.RGB8]:fe.FLOAT,[n.RGB8_SNORM]:fe.FLOAT,[n.RGB565]:fe.FLOAT,[n.RGBA4]:fe.FLOAT,[n.RGB5_A1]:fe.FLOAT,[n.RGBA8]:fe.FLOAT,[n.RGBA8_SNORM]:fe.FLOAT,[n.RGB10_A2]:fe.FLOAT,[n.RGB10_A2UI]:fe.FLOAT,[n.SRGB8]:fe.FLOAT,[n.SRGB8_ALPHA8]:fe.FLOAT,[n.R16F]:fe.FLOAT,[n.RG16F]:fe.FLOAT,[n.RGB16F]:fe.FLOAT,[n.RGBA16F]:fe.FLOAT,[n.R32F]:fe.FLOAT,[n.RG32F]:fe.FLOAT,[n.RGB32F]:fe.FLOAT,[n.RGBA32F]:fe.FLOAT,[n.R11F_G11F_B10F]:fe.FLOAT,[n.RGB9_E5]:fe.FLOAT,[n.R8I]:fe.INT,[n.R8UI]:fe.UINT,[n.R16I]:fe.INT,[n.R16UI]:fe.UINT,[n.R32I]:fe.INT,[n.R32UI]:fe.UINT,[n.RG8I]:fe.INT,[n.RG8UI]:fe.UINT,[n.RG16I]:fe.INT,[n.RG16UI]:fe.UINT,[n.RG32I]:fe.INT,[n.RG32UI]:fe.UINT,[n.RGB8I]:fe.INT,[n.RGB8UI]:fe.UINT,[n.RGB16I]:fe.INT,[n.RGB16UI]:fe.UINT,[n.RGB32I]:fe.INT,[n.RGB32UI]:fe.UINT,[n.RGBA8I]:fe.INT,[n.RGBA8UI]:fe.UINT,[n.RGBA16I]:fe.INT,[n.RGBA16UI]:fe.UINT,[n.RGBA32I]:fe.INT,[n.RGBA32UI]:fe.UINT,[n.DEPTH_COMPONENT16]:fe.FLOAT,[n.DEPTH_COMPONENT24]:fe.FLOAT,[n.DEPTH_COMPONENT32F]:fe.FLOAT,[n.DEPTH_STENCIL]:fe.FLOAT,[n.DEPTH24_STENCIL8]:fe.FLOAT,[n.DEPTH32F_STENCIL8]:fe.FLOAT}:e={[n.RGB]:fe.FLOAT,[n.RGBA]:fe.FLOAT,[n.ALPHA]:fe.FLOAT,[n.LUMINANCE]:fe.FLOAT,[n.LUMINANCE_ALPHA]:fe.FLOAT,[n.DEPTH_STENCIL]:fe.FLOAT},e}function m1(n){let e;return"WebGL2RenderingContext"in globalThis&&n instanceof globalThis.WebGL2RenderingContext?e={[Ee.UNSIGNED_BYTE]:{[oe.RGBA]:n.RGBA8,[oe.RGB]:n.RGB8,[oe.RG]:n.RG8,[oe.RED]:n.R8,[oe.RGBA_INTEGER]:n.RGBA8UI,[oe.RGB_INTEGER]:n.RGB8UI,[oe.RG_INTEGER]:n.RG8UI,[oe.RED_INTEGER]:n.R8UI,[oe.ALPHA]:n.ALPHA,[oe.LUMINANCE]:n.LUMINANCE,[oe.LUMINANCE_ALPHA]:n.LUMINANCE_ALPHA},[Ee.BYTE]:{[oe.RGBA]:n.RGBA8_SNORM,[oe.RGB]:n.RGB8_SNORM,[oe.RG]:n.RG8_SNORM,[oe.RED]:n.R8_SNORM,[oe.RGBA_INTEGER]:n.RGBA8I,[oe.RGB_INTEGER]:n.RGB8I,[oe.RG_INTEGER]:n.RG8I,[oe.RED_INTEGER]:n.R8I},[Ee.UNSIGNED_SHORT]:{[oe.RGBA_INTEGER]:n.RGBA16UI,[oe.RGB_INTEGER]:n.RGB16UI,[oe.RG_INTEGER]:n.RG16UI,[oe.RED_INTEGER]:n.R16UI,[oe.DEPTH_COMPONENT]:n.DEPTH_COMPONENT16},[Ee.SHORT]:{[oe.RGBA_INTEGER]:n.RGBA16I,[oe.RGB_INTEGER]:n.RGB16I,[oe.RG_INTEGER]:n.RG16I,[oe.RED_INTEGER]:n.R16I},[Ee.UNSIGNED_INT]:{[oe.RGBA_INTEGER]:n.RGBA32UI,[oe.RGB_INTEGER]:n.RGB32UI,[oe.RG_INTEGER]:n.RG32UI,[oe.RED_INTEGER]:n.R32UI,[oe.DEPTH_COMPONENT]:n.DEPTH_COMPONENT24},[Ee.INT]:{[oe.RGBA_INTEGER]:n.RGBA32I,[oe.RGB_INTEGER]:n.RGB32I,[oe.RG_INTEGER]:n.RG32I,[oe.RED_INTEGER]:n.R32I},[Ee.FLOAT]:{[oe.RGBA]:n.RGBA32F,[oe.RGB]:n.RGB32F,[oe.RG]:n.RG32F,[oe.RED]:n.R32F,[oe.DEPTH_COMPONENT]:n.DEPTH_COMPONENT32F},[Ee.HALF_FLOAT]:{[oe.RGBA]:n.RGBA16F,[oe.RGB]:n.RGB16F,[oe.RG]:n.RG16F,[oe.RED]:n.R16F},[Ee.UNSIGNED_SHORT_5_6_5]:{[oe.RGB]:n.RGB565},[Ee.UNSIGNED_SHORT_4_4_4_4]:{[oe.RGBA]:n.RGBA4},[Ee.UNSIGNED_SHORT_5_5_5_1]:{[oe.RGBA]:n.RGB5_A1},[Ee.UNSIGNED_INT_2_10_10_10_REV]:{[oe.RGBA]:n.RGB10_A2,[oe.RGBA_INTEGER]:n.RGB10_A2UI},[Ee.UNSIGNED_INT_10F_11F_11F_REV]:{[oe.RGB]:n.R11F_G11F_B10F},[Ee.UNSIGNED_INT_5_9_9_9_REV]:{[oe.RGB]:n.RGB9_E5},[Ee.UNSIGNED_INT_24_8]:{[oe.DEPTH_STENCIL]:n.DEPTH24_STENCIL8},[Ee.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[oe.DEPTH_STENCIL]:n.DEPTH32F_STENCIL8}}:e={[Ee.UNSIGNED_BYTE]:{[oe.RGBA]:n.RGBA,[oe.RGB]:n.RGB,[oe.ALPHA]:n.ALPHA,[oe.LUMINANCE]:n.LUMINANCE,[oe.LUMINANCE_ALPHA]:n.LUMINANCE_ALPHA},[Ee.UNSIGNED_SHORT_5_6_5]:{[oe.RGB]:n.RGB},[Ee.UNSIGNED_SHORT_4_4_4_4]:{[oe.RGBA]:n.RGBA},[Ee.UNSIGNED_SHORT_5_5_5_1]:{[oe.RGBA]:n.RGBA}},e}class lm{constructor(e){this.renderer=e,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new Le,this.hasIntegerTextures=!1}contextChange(){const e=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=m1(e),this.samplerTypes=g1(e);const t=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=t;for(let r=0;r<t;r++)this.boundTextures[r]=null;this.emptyTextures={};const i=new Ml(e.createTexture());e.bindTexture(e.TEXTURE_2D,i.texture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[e.TEXTURE_2D]=i,this.emptyTextures[e.TEXTURE_CUBE_MAP]=new Ml(e.createTexture()),e.bindTexture(e.TEXTURE_CUBE_MAP,this.emptyTextures[e.TEXTURE_CUBE_MAP].texture);for(let r=0;r<6;r++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MIN_FILTER,e.LINEAR);for(let r=0;r<this.boundTextures.length;r++)this.bind(null,r)}bind(e,t=0){const{gl:i}=this;if(e=e?.castToBaseTexture(),e?.valid&&!e.parentTextureArray){e.touched=this.renderer.textureGC.count;const r=e._glTextures[this.CONTEXT_UID]||this.initTexture(e);this.boundTextures[t]!==e&&(this.currentLocation!==t&&(this.currentLocation=t,i.activeTexture(i.TEXTURE0+t)),i.bindTexture(e.target,r.texture)),r.dirtyId!==e.dirtyId?(this.currentLocation!==t&&(this.currentLocation=t,i.activeTexture(i.TEXTURE0+t)),this.updateTexture(e)):r.dirtyStyleId!==e.dirtyStyleId&&this.updateTextureStyle(e),this.boundTextures[t]=e}else this.currentLocation!==t&&(this.currentLocation=t,i.activeTexture(i.TEXTURE0+t)),i.bindTexture(i.TEXTURE_2D,this.emptyTextures[i.TEXTURE_2D].texture),this.boundTextures[t]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let e=0;e<this.boundTextures.length;e++)this.boundTextures[e]=this.unknownTexture}unbind(e){const{gl:t,boundTextures:i}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let r=0;r<i.length;r++)i[r]===this.unknownTexture&&this.bind(null,r)}for(let r=0;r<i.length;r++)i[r]===e&&(this.currentLocation!==r&&(t.activeTexture(t.TEXTURE0+r),this.currentLocation=r),t.bindTexture(e.target,this.emptyTextures[e.target].texture),i[r]=null)}ensureSamplerType(e){const{boundTextures:t,hasIntegerTextures:i,CONTEXT_UID:r}=this;if(i)for(let s=e-1;s>=0;--s){const o=t[s];o&&o._glTextures[r].samplerType!==fe.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(e){const t=new Ml(this.gl.createTexture());return t.dirtyId=-1,e._glTextures[this.CONTEXT_UID]=t,this.managedTextures.push(e),e.on("dispose",this.destroyTexture,this),t}initTextureType(e,t){var i;t.internalFormat=((i=this.internalFormats[e.type])==null?void 0:i[e.format])??e.format,t.samplerType=this.samplerTypes[t.internalFormat]??fe.FLOAT,this.webGLVersion===2&&e.type===Ee.HALF_FLOAT?t.type=this.gl.HALF_FLOAT:t.type=e.type}updateTexture(e){var t;const i=e._glTextures[this.CONTEXT_UID];if(!i)return;const r=this.renderer;if(this.initTextureType(e,i),(t=e.resource)==null?void 0:t.upload(r,e,i))i.samplerType!==fe.FLOAT&&(this.hasIntegerTextures=!0);else{const s=e.realWidth,o=e.realHeight,a=r.gl;(i.width!==s||i.height!==o||i.dirtyId<0)&&(i.width=s,i.height=o,a.texImage2D(e.target,0,i.internalFormat,s,o,0,e.format,i.type,null))}e.dirtyStyleId!==i.dirtyStyleId&&this.updateTextureStyle(e),i.dirtyId=e.dirtyId}destroyTexture(e,t){const{gl:i}=this;if(e=e.castToBaseTexture(),e._glTextures[this.CONTEXT_UID]&&(this.unbind(e),i.deleteTexture(e._glTextures[this.CONTEXT_UID].texture),e.off("dispose",this.destroyTexture,this),delete e._glTextures[this.CONTEXT_UID],!t)){const r=this.managedTextures.indexOf(e);r!==-1&&br(this.managedTextures,r,1)}}updateTextureStyle(e){var t;const i=e._glTextures[this.CONTEXT_UID];i&&((e.mipmap===Mi.POW2||this.webGLVersion!==2)&&!e.isPowerOfTwo?i.mipmap=!1:i.mipmap=e.mipmap>=1,this.webGLVersion!==2&&!e.isPowerOfTwo?i.wrapMode=ln.CLAMP:i.wrapMode=e.wrapMode,(t=e.resource)!=null&&t.style(this.renderer,e,i)||this.setStyle(e,i),i.dirtyStyleId=e.dirtyStyleId)}setStyle(e,t){const i=this.gl;if(t.mipmap&&e.mipmap!==Mi.ON_MANUAL&&i.generateMipmap(e.target),i.texParameteri(e.target,i.TEXTURE_WRAP_S,t.wrapMode),i.texParameteri(e.target,i.TEXTURE_WRAP_T,t.wrapMode),t.mipmap){i.texParameteri(e.target,i.TEXTURE_MIN_FILTER,e.scaleMode===Ni.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const r=this.renderer.context.extensions.anisotropicFiltering;if(r&&e.anisotropicLevel>0&&e.scaleMode===Ni.LINEAR){const s=Math.min(e.anisotropicLevel,i.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(e.target,r.TEXTURE_MAX_ANISOTROPY_EXT,s)}}else i.texParameteri(e.target,i.TEXTURE_MIN_FILTER,e.scaleMode===Ni.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(e.target,i.TEXTURE_MAG_FILTER,e.scaleMode===Ni.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}lm.extension={type:ue.RendererSystem,name:"texture"};_e.add(lm);class hm{constructor(e){this.renderer=e}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(e){const{gl:t,CONTEXT_UID:i}=this,r=e._glTransformFeedbacks[i]||this.createGLTransformFeedback(e);t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,r)}unbind(){const{gl:e}=this;e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(e,t){const{gl:i,renderer:r}=this;t&&r.shader.bind(t),i.beginTransformFeedback(e)}endTransformFeedback(){const{gl:e}=this;e.endTransformFeedback()}createGLTransformFeedback(e){const{gl:t,renderer:i,CONTEXT_UID:r}=this,s=t.createTransformFeedback();e._glTransformFeedbacks[r]=s,t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,s);for(let o=0;o<e.buffers.length;o++){const a=e.buffers[o];a&&(i.buffer.update(a),a._glBuffers[r].refCount++,t.bindBufferBase(t.TRANSFORM_FEEDBACK_BUFFER,o,a._glBuffers[r].buffer||null))}return t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null),e.disposeRunner.add(this),s}disposeTransformFeedback(e,t){const i=e._glTransformFeedbacks[this.CONTEXT_UID],r=this.gl;e.disposeRunner.remove(this);const s=this.renderer.buffer;if(s)for(let o=0;o<e.buffers.length;o++){const a=e.buffers[o];if(!a)continue;const l=a._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!t&&s.dispose(a,t))}i&&(t||r.deleteTransformFeedback(i),delete e._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}hm.extension={type:ue.RendererSystem,name:"transformFeedback"};_e.add(hm);class ta{constructor(e){this.renderer=e}init(e){this.screen=new Fe(0,0,e.width,e.height),this.element=e.view||pe.ADAPTER.createCanvas(),this.resolution=e.resolution||pe.RESOLUTION,this.autoDensity=!!e.autoDensity}resizeView(e,t){this.element.width=Math.round(e*this.resolution),this.element.height=Math.round(t*this.resolution);const i=this.element.width/this.resolution,r=this.element.height/this.resolution;this.screen.width=i,this.screen.height=r,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${r}px`),this.renderer.emit("resize",i,r),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(e){var t;e&&((t=this.element.parentNode)==null||t.removeChild(this.element)),this.renderer=null,this.element=null,this.screen=null}}ta.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},ta.extension={type:[ue.RendererSystem,ue.CanvasRendererSystem],name:"_view"};_e.add(ta);pe.PREFER_ENV=Yn.WEBGL2;pe.STRICT_TEXTURE_CACHE=!1;pe.RENDER_OPTIONS={...Qo.defaultOptions,...Jo.defaultOptions,...ta.defaultOptions,...ea.defaultOptions};Object.defineProperties(pe,{WRAP_MODE:{get(){return Le.defaultOptions.wrapMode},set(n){Ue("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),Le.defaultOptions.wrapMode=n}},SCALE_MODE:{get(){return Le.defaultOptions.scaleMode},set(n){Ue("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),Le.defaultOptions.scaleMode=n}},MIPMAP_TEXTURES:{get(){return Le.defaultOptions.mipmap},set(n){Ue("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),Le.defaultOptions.mipmap=n}},ANISOTROPIC_LEVEL:{get(){return Le.defaultOptions.anisotropicLevel},set(n){Ue("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),Le.defaultOptions.anisotropicLevel=n}},FILTER_RESOLUTION:{get(){return Ue("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),Ft.defaultResolution},set(n){Ft.defaultResolution=n}},FILTER_MULTISAMPLE:{get(){return Ue("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),Ft.defaultMultisample},set(n){Ft.defaultMultisample=n}},SPRITE_MAX_TEXTURES:{get(){return Rn.defaultMaxTextures},set(n){Ue("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),Rn.defaultMaxTextures=n}},SPRITE_BATCH_SIZE:{get(){return Rn.defaultBatchSize},set(n){Ue("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),Rn.defaultBatchSize=n}},CAN_UPLOAD_SAME_BUFFER:{get(){return Rn.canUploadSameBuffer},set(n){Ue("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),Rn.canUploadSameBuffer=n}},GC_MODE:{get(){return Pn.defaultMode},set(n){Ue("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),Pn.defaultMode=n}},GC_MAX_IDLE:{get(){return Pn.defaultMaxIdle},set(n){Ue("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),Pn.defaultMaxIdle=n}},GC_MAX_CHECK_COUNT:{get(){return Pn.defaultCheckCountMax},set(n){Ue("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),Pn.defaultCheckCountMax=n}},PRECISION_VERTEX:{get(){return Hi.defaultVertexPrecision},set(n){Ue("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),Hi.defaultVertexPrecision=n}},PRECISION_FRAGMENT:{get(){return Hi.defaultFragmentPrecision},set(n){Ue("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),Hi.defaultFragmentPrecision=n}}});var Wn=(n=>(n[n.INTERACTION=50]="INTERACTION",n[n.HIGH=25]="HIGH",n[n.NORMAL=0]="NORMAL",n[n.LOW=-25]="LOW",n[n.UTILITY=-50]="UTILITY",n))(Wn||{});class Dl{constructor(e,t=null,i=0,r=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=e,this.context=t,this.priority=i,this.once=r}match(e,t=null){return this.fn===e&&this.context===t}emit(e){this.fn&&(this.context?this.fn.call(this.context,e):this.fn(e));const t=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),t}connect(e){this.previous=e,e.next&&(e.next.previous=this),this.next=e.next,e.next=this}destroy(e=!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 t=this.next;return this.next=e?null:t,this.previous=null,t}}const um=class zt{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 Dl(null,null,1/0),this.deltaMS=1/zt.targetFPMS,this.elapsedMS=1/zt.targetFPMS,this._tick=e=>{this._requestId=null,this.started&&(this.update(e),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(e,t,i=Wn.NORMAL){return this._addListener(new Dl(e,t,i))}addOnce(e,t,i=Wn.NORMAL){return this._addListener(new Dl(e,t,i,!0))}_addListener(e){let t=this._head.next,i=this._head;if(!t)e.connect(i);else{for(;t;){if(e.priority>t.priority){e.connect(i);break}i=t,t=t.next}e.previous||e.connect(i)}return this._startIfPossible(),this}remove(e,t){let i=this._head.next;for(;i;)i.match(e,t)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let e=0,t=this._head;for(;t=t.next;)e++;return e}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let e=this._head.next;for(;e;)e=e.destroy(!0);this._head.destroy(),this._head=null}}update(e=performance.now()){let t;if(e>this.lastTime){if(t=this.elapsedMS=e-this.lastTime,t>this._maxElapsedMS&&(t=this._maxElapsedMS),t*=this.speed,this._minElapsedMS){const s=e-this._lastFrame|0;if(s<this._minElapsedMS)return;this._lastFrame=e-s%this._minElapsedMS}this.deltaMS=t,this.deltaTime=this.deltaMS*zt.targetFPMS;const i=this._head;let r=i.next;for(;r;)r=r.emit(this.deltaTime);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=e}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(e){const t=Math.min(this.maxFPS,e),i=Math.min(Math.max(0,t)/1e3,zt.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(e){if(e===0)this._minElapsedMS=0;else{const t=Math.max(this.minFPS,e);this._minElapsedMS=1/(t/1e3)}}static get shared(){if(!zt._shared){const e=zt._shared=new zt;e.autoStart=!0,e._protected=!0}return zt._shared}static get system(){if(!zt._system){const e=zt._system=new zt;e.autoStart=!0,e._protected=!0}return zt._system}};um.targetFPMS=.06;let Yt=um;Object.defineProperties(pe,{TARGET_FPMS:{get(){return Yt.targetFPMS},set(n){Ue("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),Yt.targetFPMS=n}}});class cm{static init(e){e=Object.assign({autoStart:!0,sharedTicker:!1},e),Object.defineProperty(this,"ticker",{set(t){this._ticker&&this._ticker.remove(this.render,this),this._ticker=t,t&&t.add(this.render,this,Wn.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=e.sharedTicker?Yt.shared:new Yt,e.autoStart&&this.start()}static destroy(){if(this._ticker){const e=this._ticker;this.ticker=null,e.destroy()}}}cm.extension=ue.Application;_e.add(cm);const dm=[];_e.handleByList(ue.Renderer,dm);function fm(n){for(const e of dm)if(e.test(n))return new e(n);throw new Error("Unable to auto-detect a suitable renderer.")}var v1=`attribute vec2 aVertexPosition; 559attribute vec2 aTextureCoord; 560 561uniform mat3 projectionMatrix; 562 563varying vec2 vTextureCoord; 564 565void main(void) 566{ 567 gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0
567)).xy, 0.0, 1.0); 568 vTextureCoord = aTextureCoord; 569}`,y1=`attribute vec2 aVertexPosition; 570 571uniform mat3 projectionMatrix; 572 573varying vec2 vTextureCoord; 574 575uniform vec4 inputSize; 576uniform vec4 outputFrame; 577 578vec4 filterVertexPosition( void ) 579{ 580 vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; 581 582 return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); 583} 584 585vec2 filterTextureCoord( void ) 586{ 587 return aVertexPosition * (outputFrame.zw * inputSize.zw); 588} 589 590void main(void) 591{ 592 gl_Position = filterVertexPosition(); 593 vTextureCoord = filterTextureCoord(); 594} 595`;const x1=v1,pm=y1;class gm{constructor(e){this.renderer=e}contextChange(e){let t;if(this.renderer.context.webGLVersion===1){const i=e.getParameter(e.FRAMEBUFFER_BINDING);e.bindFramebuffer(e.FRAMEBUFFER,null),t=e.getParameter(e.SAMPLES),e.bindFramebuffer(e.FRAMEBUFFER,i)}else{const i=e.getParameter(e.DRAW_FRAMEBUFFER_BINDING);e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),t=e.getParameter(e.SAMPLES),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,i)}t>=pt.HIGH?this.multisample=pt.HIGH:t>=pt.MEDIUM?this.multisample=pt.MEDIUM:t>=pt.LOW?this.multisample=pt.LOW:this.multisample=pt.NONE}destroy(){}}gm.extension={type:ue.RendererSystem,name:"_multisample"};_e.add(gm);class _1{constructor(e){this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class mm{constructor(e){this.renderer=e,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(e){const{gl:t,CONTEXT_UID:i}=this,r=e._glBuffers[i]||this.createGLBuffer(e);t.bindBuffer(e.type,r.buffer)}unbind(e){const{gl:t}=this;t.bindBuffer(e,null)}bindBufferBase(e,t){const{gl:i,CONTEXT_UID:r}=this;if(this.boundBufferBases[t]!==e){const s=e._glBuffers[r]||this.createGLBuffer(e);this.boundBufferBases[t]=e,i.bindBufferBase(i.UNIFORM_BUFFER,t,s.buffer)}}bindBufferRange(e,t,i){const{gl:r,CONTEXT_UID:s}=this;i=i||0;const o=e._glBuffers[s]||this.createGLBuffer(e);r.bindBufferRange(r.UNIFORM_BUFFER,t||0,o.buffer,i*256,256)}update(e){const{gl:t,CONTEXT_UID:i}=this,r=e._glBuffers[i]||this.createGLBuffer(e);if(e._updateID!==r.updateID)if(r.updateID=e._updateID,t.bindBuffer(e.type,r.buffer),r.byteLength>=e.data.byteLength)t.bufferSubData(e.type,0,e.data);else{const s=e.static?t.STATIC_DRAW:t.DYNAMIC_DRAW;r.byteLength=e.data.byteLength,t.bufferData(e.type,e.data,s)}}dispose(e,t){if(!this.managedBuffers[e.id])return;delete this.managedBuffers[e.id];const i=e._glBuffers[this.CONTEXT_UID],r=this.gl;e.disposeRunner.remove(this),i&&(t||r.deleteBuffer(i.buffer),delete e._glBuffers[this.CONTEXT_UID])}disposeAll(e){const t=Object.keys(this.managedBuffers);for(let i=0;i<t.length;i++)this.dispose(this.managedBuffers[t[i]],e)}createGLBuffer(e){const{CONTEXT_UID:t,gl:i}=this;return e._glBuffers[t]=new _1(i.createBuffer()),this.managedBuffers[e.id]=e,e.disposeRunner.add(this),e._glBuffers[t]}}mm.extension={type:ue.RendererSystem,name:"buffer"};_e.add(mm);class vm{constructor(e){this.renderer=e}render(e,t){const i=this.renderer;let r,s,o,a;if(t&&(r=t.renderTexture,s=t.clear,o=t.transform,a=t.skipUpdateTransform),this.renderingToScreen=!r,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=o,!i.context.isLost){if(r||(this.lastObjectRendered=e),!a){const l=e.enableTempParent();e.updateTransform(),e.disableTempParent(l)}i.renderTexture.bind(r),i.batch.currentRenderer.start(),(s??i.background.clearBeforeRender)&&i.renderTexture.clear(),e.render(i),i.batch.currentRenderer.flush(),r&&(t.blit&&i.framebuffer.blit(),r.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}vm.extension={type:ue.RendererSystem,name:"objectRenderer"};_e.add(vm);const Io=class Th extends p1{constructor(e){super(),this.type=ug.WEBGL,e=Object.assign({},pe.RENDER_OPTIONS,e),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new di({projectionMatrix:new tt},!0);const t={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:Th.__systems,priority:["_view","textureGenerator","background","_plugin","startup","context","state","texture","buffer","geometry","framebuffer","transformFeedback","mask","scissor","stencil","projection","textureGC","filter","renderTexture","batch","objectRenderer","_multisample"]};
vendor: 4,584 bytes, line 595
595this.setup(t),"useContextAlpha"in e&&(Ue("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),e.premultipliedAlpha=e.useContextAlpha&&e.useContextAlpha!=="notMultiplied",e.backgroundAlpha=e.useContextAlpha===!1?1:e.backgroundAlpha),this._plugin.rendererPlugins=Th.__plugins,this.options=e,this.startup.run(this.options)}static test(e){return e!=null&&e.forceCanvas?!1:jE()}render(e,t){this.objectRenderer.render(e,t)}resize(e,t){this._view.resizeView(e,t)}reset(){return this.runners.reset.emit(),this}clear(){this.renderTexture.bind(),this.renderTexture.clear()}destroy(e=!1){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:e}),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(e){this._view.resolution=e,this.runners.resolutionChange.emit(e)}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 Ue("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return Ue("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return Ue("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return Ue("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(e){Ue("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=e}get backgroundAlpha(){return Ue("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(e){Ue("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=e}get powerPreference(){return Ue("7.0.0","renderer.powerPreference has been deprecated, we can only know this if pixi creates the context"),this.context.powerPreference}generateTexture(e,t){return this.textureGenerator.generateTexture(e,t)}};Io.extension={type:ue.Renderer,priority:1},Io.__plugins={},Io.__systems={};let _u=Io;_e.handleByMap(ue.RendererPlugin,_u.__plugins);_e.handleByMap(ue.RendererSystem,_u.__systems);_e.add(_u);class ym extends Ms{constructor(e,t){const{width:i,height:r}=t||{};super(i,r),this.items=[],this.itemDirtyIds=[];for(let s=0;s<e;s++){const o=new Le;this.items.push(o),this.itemDirtyIds.push(-2)}this.length=e,this._load=null,this.baseTexture=null}initFromArray(e,t){for(let i=0;i<this.length;i++)e[i]&&(e[i].castToBaseTexture?this.addBaseTextureAt(e[i].castToBaseTexture(),i):e[i]instanceof Ms?this.addResourceAt(e[i],i):this.addResourceAt(Bg(e[i],t),i))}dispose(){for(let e=0,t=this.length;e<t;e++)this.items[e].destroy();this.items=null,this.itemDirtyIds=null,this._load=null}addResourceAt(e,t){if(!this.items[t])throw new Error(`Index ${t} is out of bounds`);return e.valid&&!this.valid&&this.resize(e.width,e.height),this.items[t].setResource(e),this}bind(e){if(this.baseTexture!==null)throw new Error("Only one base texture per TextureArray is allowed");super.bind(e);for(let t=0;t<this.length;t++)this.items[t].parentTextureArray=e,this.items[t].on("update",e.update,e)}unbind(e){super.unbind(e);for(let t=0;t<this.length;t++)this.items[t].parentTextureArray=null,this.items[t].off("update",e.update,e)}load(){if(this._load)return this._load;const e=this.items.map(t=>t.resource).filter(t=>t).map(t=>t.load());return this._load=Promise.all(e).then(()=>{const{realWidth:t,realHeight:i}=this.items[0];return this.resize(t,i),this.update(),Promise.resolve(this)}),this._load}}class w1 extends ym{constructor(e,t){const{width:i,height:r}=t||{};let s,o;Array.isArray(e)?(s=e,o=e.length):o=e,super(o,{width:i,height:r}),s&&this.initFromArray(s,t)}addBaseTextureAt(e,t){if(e.resource)this.addResourceAt(e.resource,t);
vendor: 19,501 bytes, line 595
595else throw new Error("ArrayResource does not support RenderTexture");return this}bind(e){super.bind(e),e.target=Tr.TEXTURE_2D_ARRAY}upload(e,t,i){const{length:r,itemDirtyIds:s,items:o}=this,{gl:a}=e;i.dirtyId<0&&a.texImage3D(a.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,r,0,t.format,i.type,null);for(let l=0;l<r;l++){const h=o[l];s[l]<h.dirtyId&&(s[l]=h.dirtyId,h.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,l,h.resource.width,h.resource.height,1,t.format,i.type,h.resource.source))}return!0}}class T1 extends Xi{constructor(e){super(e)}static test(e){const{OffscreenCanvas:t}=globalThis;return t&&e instanceof t?!0:globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement}}const xm=class as extends ym{constructor(e,t){const{width:i,height:r,autoLoad:s,linkBaseTexture:o}=t||{};if(e&&e.length!==as.SIDES)throw new Error(`Invalid length. Got ${e.length}, expected 6`);super(6,{width:i,height:r});for(let a=0;a<as.SIDES;a++)this.items[a].target=Tr.TEXTURE_CUBE_MAP_POSITIVE_X+a;this.linkBaseTexture=o!==!1,e&&this.initFromArray(e,t),s!==!1&&this.load()}bind(e){super.bind(e),e.target=Tr.TEXTURE_CUBE_MAP}addBaseTextureAt(e,t,i){if(i===void 0&&(i=this.linkBaseTexture),!this.items[t])throw new Error(`Index ${t} is out of bounds`);if(!this.linkBaseTexture||e.parentTextureArray||Object.keys(e._glTextures).length>0)if(e.resource)this.addResourceAt(e.resource,t);else throw new Error("CubeResource does not support copying of renderTexture.");else e.target=Tr.TEXTURE_CUBE_MAP_POSITIVE_X+t,e.parentTextureArray=this.baseTexture,this.items[t]=e;return e.valid&&!this.valid&&this.resize(e.realWidth,e.realHeight),this.items[t]=e,this}upload(e,t,i){const r=this.itemDirtyIds;for(let s=0;s<as.SIDES;s++){const o=this.items[s];(r[s]<o.dirtyId||i.dirtyId<t.dirtyId)&&(o.valid&&o.resource?(o.resource.upload(e,o,i),r[s]=o.dirtyId):r[s]<-1&&(e.gl.texImage2D(o.target,0,i.internalFormat,t.realWidth,t.realHeight,0,t.format,i.type,null),r[s]=-1))}return!0}static test(e){return Array.isArray(e)&&e.length===as.SIDES}};xm.SIDES=6;let E1=xm;class vr extends Xi{constructor(e,t){t=t||{};let i,r,s;typeof e=="string"?(i=vr.EMPTY,r=e,s=!0):(i=e,r=null,s=!1),super(i),this.url=r,this.crossOrigin=t.crossOrigin??!0,this.alphaMode=typeof t.alphaMode=="number"?t.alphaMode:null,this.ownsImageBitmap=t.ownsImageBitmap??s,this._load=null,t.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(async(e,t)=>{if(this.url===null){e(this);return}try{const i=await pe.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const r=await i.blob();if(this.destroyed)return;const s=await createImageBitmap(r,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Ut.UNPACK?"premultiply":"none"});if(this.destroyed){s.close();return}this.source=s,this.update(),e(this)}catch(i){if(this.destroyed)return;t(i),this.onError.emit(i)}}),this._load)}upload(e,t,i){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(t.alphaMode=this.alphaMode),super.upload(e,t,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(e){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof e=="string"||e instanceof ImageBitmap)}static get EMPTY(){return vr._EMPTY=vr._EMPTY??pe.ADAPTER.createCanvas(0,0),vr._EMPTY}}const Eh=class Mo extends Xi{constructor(e,t){t=t||{},super(pe.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=e,this.scale=t.scale||1,this._overrideWidth=t.width,this._overrideHeight=t.height,this._resolve=null,this._crossorigin=t.crossorigin,this._load=null,t.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(e=>{if(this._resolve=()=>{this.update(),e(this)},Mo.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 e=new Image;Xi.crossOrigin(e,this.svg,this._crossorigin),e.src=this.svg,e.onerror=t=>{this._resolve&&(e.onerror=null,this.onError.emit(t))},e.onload=()=>{if(!this._resolve)return;const t=e.width,i=e.height;if(!t||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let r=t*this.scale,s=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(r=this._overrideWidth||this._overrideHeight/i*t,s=this._overrideHeight||this._overrideWidth/t*i),r=Math.round(r),s=Math.round(s);const o=this.source;o.width=r,o.height=s,o._pixiId=`canvas_${Xn()}`,o.getContext("2d").drawImage(e,0,0,t,i,0,0,r,s),this._resolve(),this._resolve=null}}static getSize(e){const t=Mo.SVG_SIZE.exec(e),i={};return t&&(i[t[1]]=Math.round(parseFloat(t[3])),i[t[5]]=Math.round(parseFloat(t[7]))),i}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(e,t){return t==="svg"||typeof e=="string"&&e.startsWith("data:image/svg+xml")||typeof e=="string"&&Mo.SVG_XML.test(e)}};Eh.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,Eh.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let bh=Eh;class b1 extends Xi{constructor(e){super(e)}static test(e){return!!globalThis.VideoFrame&&e instanceof globalThis.VideoFrame}}const Sh=class Ah extends Xi{constructor(e,t){if(t=t||{},!(e instanceof HTMLVideoElement)){const i=document.createElement("video");t.autoLoad!==!1&&i.setAttribute("preload","auto"),t.playsinline!==!1&&(i.setAttribute("webkit-playsinline",""),i.setAttribute("playsinline","")),t.muted===!0&&(i.setAttribute("muted",""),i.muted=!0),t.loop===!0&&i.setAttribute("loop",""),t.autoPlay!==!1&&i.setAttribute("autoplay",""),typeof e=="string"&&(e=[e]);const r=e[0].src||e[0];Xi.crossOrigin(i,r,t.crossorigin);for(let s=0;s<e.length;++s){const o=document.createElement("source");let{src:a,mime:l}=e[s];if(a=a||e[s],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||Ah.MIME_TYPES[u]||`video/${u}`}o.src=a,l&&(o.type=l),i.appendChild(o)}e=i}super(e),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.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),t.autoLoad!==!1&&this.load()}update(e=0){if(!this.destroyed){if(this._updateFPS){const t=Yt.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!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 e=this.source;return(e.readyState===e.HAVE_ENOUGH_DATA||e.readyState===e.HAVE_FUTURE_DATA)&&e.width&&e.height&&(e.complete=!0),e.addEventListener("play",this._onPlayStart),e.addEventListener("pause",this._onPlayStop),e.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._onCanPlay():(e.addEventListener("canplay",this._onCanPlay),e.addEventListener("canplaythrough",this._onCanPlay),e.addEventListener("error",this._onError,!0)),this._load=new Promise((t,i)=>{this.valid?t(this):(this._resolve=t,this._reject=i,e.load())}),this._load}_onError(e){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(e),this._reject&&(this._reject(e),this._reject=null,this._resolve=null)}_isSourcePlaying(){const e=this.source;return!e.paused&&!e.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 e=this.source;e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay);const t=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!t&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&e.play()}dispose(){this._configureAutoUpdate();const e=this.source;e&&(e.removeEventListener("play",this._onPlayStart),e.removeEventListener("pause",this._onPlayStop),e.removeEventListener("seeked",this._onSeeked),e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay),e.removeEventListener("error",this._onError,!0),e.pause(),e.src="",e.load()),super.dispose()}get autoUpdate(){return this._autoUpdate}set autoUpdate(e){e!==this._autoUpdate&&(this._autoUpdate=e,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(e){e!==this._updateFPS&&(this._updateFPS=e,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.source.requestVideoFrameCallback?(this._isConnectedToTicker&&(Yt.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||(Yt.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Yt.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(e,t){return globalThis.HTMLVideoElement&&e instanceof HTMLVideoElement||Ah.TYPES.includes(t)}};Sh.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],Sh.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let _m=Sh;dh.push(vr,jg,T1,_m,b1,bh,Ta,E1,w1);class ia{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(e){return this.minX>this.maxX||this.minY>this.maxY?Fe.EMPTY:(e=e||new Fe(0,0,1,1),e.x=this.minX,e.y=this.minY,e.width=this.maxX-this.minX,e.height=this.maxY-this.minY,e)}addPoint(e){this.minX=Math.min(this.minX,e.x),this.maxX=Math.max(this.maxX,e.x),this.minY=Math.min(this.minY,e.y),this.maxY=Math.max(this.maxY,e.y)}addPointMatrix(e,t){const{a:i,b:r,c:s,d:o,tx:a,ty:l}=e,h=i*t.x+s*t.y+a,u=r*t.x+o*t.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(e){let t=this.minX,i=this.minY,r=this.maxX,s=this.maxY,o=e[0],a=e[1];t=o<t?o:t,i=a<i?a:i,r=o>r?o:r,s=a>s?a:s,o=e[2],a=e[3],t=o<t?o:t,i=a<i?a:i,r=o>r?o:r,s=a>s?a:s,o=e[4],a=e[5],t=o<t?o:t,i=a<i?a:i,r=o>r?o:r,s=a>s?a:s,o=e[6],a=e[7],t=o<t?o:t,i=a<i?a:i,r=o>r?o:r,s=a>s?a:s,this.minX=t,this.minY=i,this.maxX=r,this.maxY=s}addFrame(e,t,i,r,s){this.addFrameMatrix(e.worldTransform,t,i,r,s)}addFrameMatrix(e,t,i,r,s){const o=e.a,a=e.b,l=e.c,h=e.d,u=e.tx,c=e.ty;let d=this.minX,f=this.minY,p=this.maxX,g=this.maxY,v=o*t+l*i+u,m=a*t+h*i+c;d=v<d?v:d,f=m<f?m:f,p=v>p?v:p,g=m>g?m:g,v=o*r+l*i+u,m=a*r+h*i+c,d=v<d?v:d,f=m<f?m:f,p=v>p?v:p,g=m>g?m:g,v=o*t+l*s+u,m=a*t+h*s+c,d=v<d?v:d,f=m<f?m:f,p=v>p?v:p,g=m>g?m:g,v=o*r+l*s+u,m=a*r+h*s+c,d=v<d?v:d,f=m<f?m:f,p=v>p?v:p,g=m>g?m:g,this.minX=d,this.minY=f,this.maxX=p,this.maxY=g}addVertexData(e,t,i){let r=this.minX,s=this.minY,o=this.maxX,a=this.maxY;for(let l=t;l<i;l+=2){const h=e[l],u=e[l+1];r=h<r?h:r,s=u<s?u:s,o=h>o?h:o,a=u>a?u:a}this.minX=r,this.minY=s,this.maxX=o,this.maxY=a}addVertices(e,t,i,r){this.addVerticesMatrix(e.worldTransform,t,i,r)}addVerticesMatrix(e,t,i,r,s=0,o=s){const a=e.a,l=e.b,h=e.c,u=e.d,c=e.tx,d=e.ty;let f=this.minX,p=this.minY,g=this.maxX,v=this.maxY;for(let m=i;m<r;m+=2){const x=t[m],y=t[m+1],E=a*x+h*y+c,R=u*y+l*x+d;f=Math.min(f,E-s),g=Math.max(g,E+s),p=Math.min(p,R-o),v=Math.max(v,R+o)}this.minX=f,this.minY=p,this.maxX=g,this.maxY=v}addBounds(e){const t=this.minX,i=this.minY,r=this.maxX,s=this.maxY;this.minX=e.minX<t?e.minX:t,this.minY=e.minY<i?e.minY:i,this.maxX=e.maxX>r?e.maxX:r,this.maxY=e.maxY>s?e.maxY:s}addBoundsMask(e,t){const i=e.minX>t.minX?e.minX:t.minX,r=e.minY>t.minY?e.minY:t.minY,s=e.maxX<t.maxX?e.maxX:t.maxX,o=e.maxY<t.maxY?e.maxY:t.maxY;if(i<=s&&r<=o){const a=this.minX,l=this.minY,h=this.maxX,u=this.maxY;this.minX=i<a?i:a,this.minY=r<l?r:l,this.maxX=s>h?s:h,this.maxY=o>u?o:u}}addBoundsMatrix(e,t){this.addFrameMatrix(t,e.minX,e.minY,e.maxX,e.maxY)}addBoundsArea(e,t){const i=e.minX>t.x?e.minX:t.x,r=e.minY>t.y?e.minY:t.y,s=e.maxX<t.x+t.width?e.maxX:t.x+t.width,o=e.maxY<t.y+t.height?e.maxY:t.y+t.height;if(i<=s&&r<=o){const a=this.minX,l=this.minY,h=this.maxX,u=this.maxY;this.minX=i<a?i:a,this.minY=r<l?r:l,this.maxX=s>h?s:h,this.maxY=o>u?o:u}}pad(e=0,t=e){this.isEmpty()||(this.minX-=e,this.maxX+=e,this.minY-=t,this.maxY+=t)}addFramePad(e,t,i,r,s,o){e-=s,t-=o,i+=s,r+=o,this.minX=this.minX<e?this.minX:e,this.maxX=this.maxX>i?this.maxX:i,this.minY=this.minY<t?this.minY:t,this.maxY=this.maxY>r?this.maxY:r}}class lt extends Hs{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new yu,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 ia,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(e){const t=Object.keys(e);for(let i=0;i<t.length;++i){const r=t[i];Object.defineProperty(lt.prototype,r,Object.getOwnPropertyDescriptor(e,r))}}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(e,t){return e||(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),t||(this._boundsRect||(this._boundsRect=new Fe),t=this._boundsRect),this._bounds.getRectangle(t)}getLocalBounds(e){e||(this._localBoundsRect||(this._localBoundsRect=new Fe),e=this._localBoundsRect),this._localBounds||(this._localBounds=new ia);const t=this.transform,i=this.parent;this.parent=null,this._tempDisplayObjectParent.worldAlpha=i?.worldAlpha??1,this.transform=this._tempDisplayObjectParent.transform;const r=this._bounds,s=this._boundsID;this._bounds=this._localBounds;const o=this.getBounds(!1,e);return this.parent=i,this.transform=t,this._bounds=r,this._bounds.updateID+=this._boundsID-s,o}toGlobal(e,t,i=!1){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(e,t)}toLocal(e,t,i,r){return t&&(e=t.toGlobal(e,i,r)),r||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(e,i)}setParent(e){if(!e||!e.addChild)throw new Error("setParent: Argument must be a Container");return e.addChild(this),e}removeFromParent(){var e;(e=this.parent)==null||e.removeChild(this)}setTransform(e=0,t=0,i=1,r=1,s=0,o=0,a=0,l=0,h=0){return this.position.x=e,this.position.y=t,this.scale.x=i||1,this.scale.y=r||1,this.rotation=s,this.skew.x=o,this.skew.y=a,this.pivot.x=l,this.pivot.y=h,this}destroy(e){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 S1),this.tempDisplayObjectParent}enableTempParent(){const e=this.parent;return this.parent=this._tempDisplayObjectParent,e}disableTempParent(e){this.parent=e}get x(){return this.position.x}set x(e){this.transform.position.x=e}get y(){return this.position.y}set y(e){this.transform.position.y=e}get worldTransform(){return this.transform.worldTransform}get localTransform(){return this.transform.localTransform}get position(){return this.transform.position}set position(e){this.transform.position.copyFrom(e)}get scale(){return this.transform.scale}set scale(e){this.transform.scale.copyFrom(e)}get pivot(){return this.transform.pivot}set pivot(e){this.transform.pivot.copyFrom(e)}get skew(){return this.transform.skew}set skew(e){this.transform.skew.copyFrom(e)}get rotation(){return this.transform.rotation}set rotation(e){this.transform.rotation=e}get angle(){return this.transform.rotation*yb}set angle(e){this.transform.rotation=e*xb}get zIndex(){return this._zIndex}set zIndex(e){this._zIndex!==e&&(this._zIndex=e,this.parent&&(this.parent.sortDirty=!0))}get worldVisible(){let e=this;do{if(!e.visible)return!1;e=e.parent}while(e);return!0}get mask(){return this._mask}set mask(e){if(this._mask!==e){if(this._mask){const t=this._mask.isMaskData?this._mask.maskObject:this._mask;t&&(t._maskRefCount--,t._maskRefCount===0&&(t.renderable=!0,t.isMask=!1))}if(this._mask=e,this._mask){const t=this._mask.isMaskData?this._mask.maskObject:this._mask;t&&(t._maskRefCount===0&&(t.renderable=!1,t.isMask=!0),t._maskRefCount++)}}}}class S1 extends lt{constructor(){super(...arguments),this.sortDirty=null}}lt.prototype.displayObjectUpdateTransform=lt.prototype.updateTransform;const A1=new tt;function R1(n,e){return n.zIndex===e.zIndex?n._lastSortedIndex-e._lastSortedIndex:n.zIndex-e.zIndex}const wm=class Rh extends lt{constructor(){super(),this.children=[],this.sortableChildren=Rh.defaultSortableChildren,this.sortDirty=!1}onChildrenChange(e){}addChild(...e){if(e.length>1)for(let t=0;t<e.length;t++)this.addChild(e[t]);else{const t=e[0];t.parent&&t.parent.removeChild(t),t.parent=this,this.sortDirty=!0,t.transform._parentID=-1,this.children.push(t),this._boundsID++,this.onChildrenChange(this.children.length-1),this.emit
vendor: 17,493 bytes, lines 595-604
595("childAdded",t,this,this.children.length-1),t.emit("added",this)}return e[0]}addChildAt(e,t){if(t<0||t>this.children.length)throw new Error(`${e}addChildAt: The index ${t} supplied is out of bounds ${this.children.length}`);return e.parent&&e.parent.removeChild(e),e.parent=this,this.sortDirty=!0,e.transform._parentID=-1,this.children.splice(t,0,e),this._boundsID++,this.onChildrenChange(t),e.emit("added",this),this.emit("childAdded",e,this,t),e}swapChildren(e,t){if(e===t)return;const i=this.getChildIndex(e),r=this.getChildIndex(t);this.children[i]=t,this.children[r]=e,this.onChildrenChange(i<r?i:r)}getChildIndex(e){const t=this.children.indexOf(e);if(t===-1)throw new Error("The supplied DisplayObject must be a child of the caller");return t}setChildIndex(e,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);const i=this.getChildIndex(e);br(this.children,i,1),this.children.splice(t,0,e),this.onChildrenChange(t)}getChildAt(e){if(e<0||e>=this.children.length)throw new Error(`getChildAt: Index (${e}) does not exist.`);return this.children[e]}removeChild(...e){if(e.length>1)for(let t=0;t<e.length;t++)this.removeChild(e[t]);else{const t=e[0],i=this.children.indexOf(t);if(i===-1)return null;t.parent=null,t.transform._parentID=-1,br(this.children,i,1),this._boundsID++,this.onChildrenChange(i),t.emit("removed",this),this.emit("childRemoved",t,this,i)}return e[0]}removeChildAt(e){const t=this.getChildAt(e);return t.parent=null,t.transform._parentID=-1,br(this.children,e,1),this._boundsID++,this.onChildrenChange(e),t.emit("removed",this),this.emit("childRemoved",t,this,e),t}removeChildren(e=0,t=this.children.length){const i=e,r=t,s=r-i;let o;if(s>0&&s<=r){o=this.children.splice(i,s);for(let a=0;a<o.length;++a)o[a].parent=null,o[a].transform&&(o[a].transform._parentID=-1);this._boundsID++,this.onChildrenChange(e);for(let a=0;a<o.length;++a)o[a].emit("removed",this),this.emit("childRemoved",o[a],this,a);return o}else if(s===0&&this.children.length===0)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")}sortChildren(){let e=!1;for(let t=0,i=this.children.length;t<i;++t){const r=this.children[t];r._lastSortedIndex=t,!e&&r.zIndex!==0&&(e=!0)}e&&this.children.length>1&&this.children.sort(R1),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 e=0,t=this.children.length;e<t;++e){const i=this.children[e];i.visible&&i.updateTransform()}}calculateBounds(){this._bounds.clear(),this._calculateBounds();for(let e=0;e<this.children.length;e++){const t=this.children[e];if(!(!t.visible||!t.renderable))if(t.calculateBounds(),t._mask){const i=t._mask.isMaskData?t._mask.maskObject:t._mask;i?(i.calculateBounds(),this._bounds.addBoundsMask(t._bounds,i._bounds)):this._bounds.addBounds(t._bounds)}else t.filterArea?this._bounds.addBoundsArea(t._bounds,t.filterArea):this._bounds.addBounds(t._bounds)}this._bounds.updateID=this._boundsID}getLocalBounds(e,t=!1){const i=super.getLocalBounds(e);if(!t)for(let r=0,s=this.children.length;r<s;++r){const o=this.children[r];o.visible&&o.updateTransform()}return i}_calculateBounds(){}_renderWithCulling(e){const t=e.renderTexture.sourceFrame;if(!(t.width>0&&t.height>0))return;let i,r;this.cullArea?(i=this.cullArea,r=this.worldTransform):this._render!==Rh.prototype._render&&(i=this.getBounds(!0));const s=e.projection.transform;if(s&&(r?(r=A1.copyFrom(r),r.prepend(s)):r=s),i&&t.intersects(i,r))this._render(e);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(e),l.cullable=h}}render(e){var t;if(!(!this.visible||this.worldAlpha<=0||!this.renderable))if(this._mask||(t=this.filters)!=null&&t.length)this.renderAdvanced(e);else if(this.cullable)this._renderWithCulling(e);else{this._render(e);for(let i=0,r=this.children.length;i<r;++i)this.children[i].render(e)}}renderAdvanced(e){var t,i,r;const s=this.filters,o=this._mask;if(s){this._enabledFilters||(this._enabledFilters=[]),this._enabledFilters.length=0;for(let l=0;l<s.length;l++)s[l].enabled&&this._enabledFilters.push(s[l])}const a=s&&((t=this._enabledFilters)==null?void 0:t.length)||o&&(!o.isMaskData||o.enabled&&(o.autoDetect||o.type!==mt.NONE));if(a&&e.batch.flush(),s&&(i=this._enabledFilters)!=null&&i.length&&e.filter.push(this,this._enabledFilters),o&&e.mask.push(this,this._mask),this.cullable)this._renderWithCulling(e);else{this._render(e);for(let l=0,h=this.children.length;l<h;++l)this.children[l].render(e)}a&&e.batch.flush(),o&&e.mask.pop(this),s&&(r=this._enabledFilters)!=null&&r.length&&e.filter.pop()}_render(e){}destroy(e){super.destroy(),this.sortDirty=!1;const t=typeof e=="boolean"?e:e?.children,i=this.removeChildren(0,this.children.length);if(t)for(let r=0;r<i.length;++r)i[r].destroy(e)}get width(){return this.scale.x*this.getLocalBounds().width}set width(e){const t=this.getLocalBounds().width;t!==0?this.scale.x=e/t:this.scale.x=1,this._width=e}get height(){return this.scale.y*this.getLocalBounds().height}set height(e){const t=this.getLocalBounds().height;t!==0?this.scale.y=e/t:this.scale.y=1,this._height=e}};wm.defaultSortableChildren=!1;let gi=wm;gi.prototype.containerUpdateTransform=gi.prototype.updateTransform;Object.defineProperties(pe,{SORTABLE_CHILDREN:{get(){return gi.defaultSortableChildren},set(n){Ue("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),gi.defaultSortableChildren=n}}});const es=new ze,P1=new Uint16Array([0,1,2,0,2,3]);class Xr extends gi{constructor(e){super(),this._anchor=new Ui(this._onAnchorUpdate,this,e?e.defaultAnchor.x:0,e?e.defaultAnchor.y:0),this._texture=null,this._width=0,this._height=0,this._tintColor=new Ze(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=Ce.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=e||xe.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=P1,this.pluginName="batch",this.isSprite=!0,this._roundPixels=pe.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=rn(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=rn(this.scale.y)*this._height/this._texture.orig.height)}_onAnchorUpdate(){this._transformID=-1,this._transformTrimmedID=-1}calculateVertices(){const e=this._texture;if(this._transformID===this.transform._worldID&&this._textureID===e._updateID)return;this._textureID!==e._updateID&&(this.uvs=this._texture._uvs.uvsFloat32),this._transformID=this.transform._worldID,this._textureID=e._updateID;const t=this.transform.worldTransform,i=t.a,r=t.b,s=t.c,o=t.d,a=t.tx,l=t.ty,h=this.vertexData,u=e.trim,c=e.orig,d=this._anchor;let f=0,p=0,g=0,v=0;if(u?(p=u.x-d._x*c.width,f=p+u.width,v=u.y-d._y*c.height,g=v+u.height):(p=-d._x*c.width,f=p+c.width,v=-d._y*c.height,g=v+c.height),h[0]=i*p+s*v+a,h[1]=o*v+r*p+l,h[2]=i*f+s*v+a,h[3]=o*v+r*f+l,h[4]=i*f+s*g+a,h[5]=o*g+r*f+l,h[6]=i*p+s*g+a,h[7]=o*g+r*p+l,this._roundPixels){const m=pe.RESOLUTION;for(let x=0;x<h.length;++x)h[x]=Math.round(h[x]*m)/m}}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 e=this._texture,t=this.vertexTrimmedData,i=e.orig,r=this._anchor,s=this.transform.worldTransform,o=s.a,a=s.b,l=s.c,h=s.d,u=s.tx,c=s.ty,d=-r._x*i.width,f=d+i.width,p=-r._y*i.height,g=p+i.height;if(t[0]=o*d+l*p+u,t[1]=h*p+a*d+c,t[2]=o*f+l*p+u,t[3]=h*p+a*f+c,t[4]=o*f+l*g+u,t[5]=h*g+a*f+c,t[6]=o*d+l*g+u,t[7]=h*g+a*d+c,this._roundPixels){const v=pe.RESOLUTION;for(let m=0;m<t.length;++m)t[m]=Math.round(t[m]*v)/v}}_render(e){this.calculateVertices(),e.batch.setObjectRenderer(e.plugins[this.pluginName]),e.plugins[this.pluginName].render(this)}_calculateBounds(){const e=this._texture.trim,t=this._texture.orig;!e||e.width===t.width&&e.height===t.height?(this.calculateVertices(),this._bounds.addQuad(this.vertexData)):(this.calculateTrimmedVertices(),this._bounds.addQuad(this.vertexTrimmedData))}getLocalBounds(e){return this.children.length===0?(this._localBounds||(this._localBounds=new ia),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),e||(this._localBoundsRect||(this._localBoundsRect=new Fe),e=this._localBoundsRect),this._localBounds.getRectangle(e)):super.getLocalBounds.call(this,e)}containsPoint(e){this.worldTransform.applyInverse(e,es);const t=this._texture.orig.width,i=this._texture.orig.height,r=-t*this.anchor.x;let s=0;return es.x>=r&&es.x<r+t&&(s=-i*this.anchor.y,es.y>=s&&es.y<s+i)}destroy(e){if(super.destroy(e),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,typeof e=="boolean"?e:e?.texture){const t=typeof e=="boolean"?e:e?.baseTexture;this._texture.destroy(!!t)}this._texture=null}static from(e,t){const i=e instanceof xe?e:xe.from(e,t);return new Xr(i)}set roundPixels(e){this._roundPixels!==e&&(this._transformID=-1,this._transformTrimmedID=-1),this._roundPixels=e}get roundPixels(){return this._roundPixels}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(e){const t=rn(this.scale.x)||1;this.scale.x=t*e/this._texture.orig.width,this._width=e}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(e){const t=rn(this.scale.y)||1;this.scale.y=t*e/this._texture.orig.height,this._height=e}get anchor(){return this._anchor}set anchor(e){this._anchor.copyFrom(e)}get tint(){return this._tintColor.value}set tint(e){this._tintColor.setValue(e),this._tintRGB=this._tintColor.toLittleEndianNumber()}get tintValue(){return this._tintColor.toNumber()}get texture(){return this._texture}set texture(e){this._texture!==e&&(this._texture&&this._texture.off("update",this._onTextureUpdate,this),this._texture=e||xe.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,e&&(e.baseTexture.valid?this._onTextureUpdate():e.once("update",this._onTextureUpdate,this)))}}const Tm=new tt;lt.prototype._cacheAsBitmap=!1;lt.prototype._cacheData=null;lt.prototype._cacheAsBitmapResolution=null;lt.prototype._cacheAsBitmapMultisample=null;class C1{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(lt.prototype,{cacheAsBitmapResolution:{get(){return this._cacheAsBitmapResolution},set(n){n!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=n,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmapMultisample:{get(){return this._cacheAsBitmapMultisample},set(n){n!==this._cacheAsBitmapMultisample&&(this._cacheAsBitmapMultisample=n,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get(){return this._cacheAsBitmap},set(n){if(this._cacheAsBitmap===n)return;this._cacheAsBitmap=n;let e;n?(this._cacheData||(this._cacheData=new C1),e=this._cacheData,e.originalRender=this.render,e.originalRenderCanvas=this.renderCanvas,e.originalUpdateTransform=this.updateTransform,e.originalCalculateBounds=this.calculateBounds,e.originalGetLocalBounds=this.getLocalBounds,e.originalDestroy=this.destroy,e.originalContainsPoint=this.containsPoint,e.originalMask=this._mask,e.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):(e=this._cacheData,e.sprite&&this._destroyCachedDisplayObject(),this.render=e.originalRender,this.renderCanvas=e.originalRenderCanvas,this.calculateBounds=e.originalCalculateBounds,this.getLocalBounds=e.originalGetLocalBounds,this.destroy=e.originalDestroy,this.updateTransform=e.originalUpdateTransform,this.containsPoint=e.originalContainsPoint,this._mask=e.originalMask,this.filterArea=e.originalFilterArea)}}});lt.prototype._renderCached=function(n){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(n),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(n))};lt.prototype._initCachedDisplayObject=function(n){var e,t;if((e=this._cacheData)!=null&&e.sprite)return;const i=this.alpha;this.alpha=1,n.batch.flush();const r=this.getLocalBounds(new Fe,!0);if((t=this.filters)!=null&&t.length){const p=this.filters[0].padding;r.pad(p)}const s=this.cacheAsBitmapResolution||n.resolution;r.ceil(s),r.width=Math.max(r.width,1/s),r.height=Math.max(r.height,1/s);const o=n.renderTexture.current,a=n.renderTexture.sourceFrame.clone(),l=n.renderTexture.destinationFrame.clone(),h=n.projection.transform,u=qn.create({width:r.width,height:r.height,resolution:s,multisample:this.cacheAsBitmapMultisample??n.multisample}),c=`cacheAsBitmap_${Xn()}`;this._cacheData.textureCacheId=c,Le.addToCache(u.baseTexture,c),xe.addToCache(u,c);const d=this.transform.localTransform.copyTo(Tm).invert().translate(-r.x,-r.y);this.render=this._cacheData.originalRender,n.render(this,{renderTexture:u,clear:!0,transform:d,skipUpdateTransform:!1}),n.framebuffer.blit(),n.projection.transform=h,n.renderTexture.bind(o,a,l),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=i;const f=new Xr(u);f.transform.worldTransform=this.transform.worldTransform,f.anchor.x=-(r.x/r.width),f.anchor.y=-(r.y/r.height),f.alpha=i,f._bounds=this._bounds,this._cacheData.sprite=f,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=f.containsPoint.bind(f)};lt.prototype._renderCachedCanvas=function(n){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(n),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(n))};lt.prototype._initCachedDisplayObjectCanvas=function(n){var e;if((e=this._cacheData)!=null&&e.sprite)return;const t=this.getLocalBounds(new Fe,!0),i=this.alpha;this.alpha=1;const r=n.canvasContext.activeContext,s=n._projTransform,o=this.cacheAsBitmapResolution||n.resolution;t.ceil(o),t.width=Math.max(t.width,1/o),t.height=Math.max(t.height,1/o);const a=qn.create({width:t.width,height:t.height,resolution:o}),l=`cacheAsBitmap_${Xn()}`;this._cacheData.textureCacheId=l,Le.addToCache(a.baseTexture,l),xe.addToCache(a,l);const h=Tm;this.transform.localTransform.copyTo(h),h.invert(),h.tx-=t.x,h.ty-=t.y,this.renderCanvas=this._cacheData.originalRenderCanvas,n.render(this,{renderTexture:a,clear:!0,transform:h,skipUpdateTransform:!1}),n.canvasContext.activeContext=r,n._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=i;const u=new Xr(a);u.transform.worldTransform=this.transform.worldTransform,u.anchor.x=-(t.x/t.width),u.anchor.y=-(t.y/t.height),u.alpha=i,u._bounds=this._bounds,this._cacheData.sprite=u,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=n._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=u.containsPoint.bind(u)};lt.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID};lt.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)};lt.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,Le.removeFromCache(this._cacheData.textureCacheId),xe.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null};lt.prototype._cacheAsBitmapDestroy=function(n){this.cacheAsBitmap=!1,this.destroy(n)};lt.prototype.name=null;gi.prototype.getChildByName=function(n,e){for(let t=0,i=this.children.length;t<i;t++)if(this.children[t].name===n)return this.children[t];if(e)for(let t=0,i=this.children.length;t<i;t++){const r=this.children[t];if(!r.getChildByName)continue;const s=r.getChildByName(n,!0);if(s)return s}return null};lt.prototype.getGlobalPosition=function(n=new ze,e=!1){return this.parent?this.parent.toGlobal(this.position,n,e):(n.x=this.position.x,n.y=this.position.y),n};var I1=`varying vec2 vTextureCoord; 596 597uniform sampler2D uSampler; 598uniform float uAlpha; 599 600void main(void) 601{ 602 gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha; 603} 604`;
vendor: 13,947 bytes, lines 604-783
604class M1 extends Ft{constructor(e=1){super(x1,I1,{uAlpha:1}),this.alpha=e}get alpha(){return this.uniforms.uAlpha}set alpha(e){this.uniforms.uAlpha=e}}const D1={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]},O1=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(` 605`);function L1(n){const e=D1[n],t=e.length;let i=O1,r="";const s="gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;";let o;for(let a=0;a<n;a++){let l=s.replace("%index%",a.toString());o=a,a>=t&&(o=n-a-1),l=l.replace("%value%",e[o].toString()),r+=l,r+=` 606`}return i=i.replace("%blur%",r),i=i.replace("%size%",n.toString()),i}const B1=` 607 attribute vec2 aVertexPosition; 608 609 uniform mat3 projectionMatrix; 610 611 uniform float strength; 612 613 varying vec2 vBlurTexCoords[%size%]; 614 615 uniform vec4 inputSize; 616 uniform vec4 outputFrame; 617 618 vec4 filterVertexPosition( void ) 619 { 620 vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; 621 622 return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); 623 } 624 625 vec2 filterTextureCoord( void ) 626 { 627 return aVertexPosition * (outputFrame.zw * inputSize.zw); 628 } 629 630 void main(void) 631 { 632 gl_Position = filterVertexPosition(); 633 634 vec2 textureCoord = filterTextureCoord(); 635 %blur% 636 }`;function F1(n,e){const t=Math.ceil(n/2);let i=B1,r="",s;e?s="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":s="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(let o=0;o<n;o++){let a=s.replace("%index%",o.toString());a=a.replace("%sampleIndex%",`${o-(t-1)}.0`),r+=a,r+=` 637`}return i=i.replace("%blur%",r),i=i.replace("%size%",n.toString()),i}class Ph extends Ft{constructor(e,t=8,i=4,r=Ft.defaultResolution,s=5){const o=F1(s,e),a=L1(s);super(o,a),this.horizontal=e,this.resolution=r,this._quality=0,this.quality=i,this.blur=t}apply(e,t,i,r){if(i?this.horizontal?this.uniforms.strength=1/i.width*(i.width/t.width):this.uniforms.strength=1/i.height*(i.height/t.height):this.horizontal?this.uniforms.strength=1/e.renderer.width*(e.renderer.width/t.width):this.uniforms.strength=1/e.renderer.height*(e.renderer.height/t.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)e.applyFilter(this,t,i,r);else{const s=e.getFilterTexture(),o=e.renderer;let a=t,l=s;this.state.blend=!1,e.applyFilter(this,a,l,Ti.CLEAR);for(let h=1;h<this.passes-1;h++){e.bindAndClear(a,Ti.BLIT),this.uniforms.uSampler=l;const u=l;l=a,a=u,o.shader.bind(this),o.geometry.draw(5)}this.state.blend=!0,e.applyFilter(this,l,i,r),e.returnFilterTexture(s)}}get blur(){return this.strength}set blur(e){this.padding=1+Math.abs(e)*2,this.strength=e}get quality(){return this._quality}set quality(e){this._quality=e,this.passes=e}}class N1 extends Ft{constructor(e=8,t=4,i=Ft.defaultResolution,r=5){super(),this._repeatEdgePixels=!1,this.blurXFilter=new Ph(!0,e,t,i,r),this.blurYFilter=new Ph(!1,e,t,i,r),this.resolution=i,this.quality=t,this.blur=e,this.repeatEdgePixels=!1}apply(e,t,i,r){const s=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(s&&o){const a=e.getFilterTexture();this.blurXFilter.apply(e,t,a,Ti.CLEAR),this.blurYFilter.apply(e,a,i,r),e.returnFilterTexture(a)}else o?this.blurYFilter.apply(e,t,i,r):this.blurXFilter.apply(e,t,i,r)}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(e){this.blurXFilter.blur=this.blurYFilter.blur=e,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(e){this.blurXFilter.quality=this.blurYFilter.quality=e}get blurX(){return this.blurXFilter.blur}set blurX(e){this.blurXFilter.blur=e,this.updatePadding()}get blurY(){return this.blurYFilter.blur}set blurY(e){this.blurYFilter.blur=e,this.updatePadding()}get blendMode(){return this.blurYFilter.blendMode}set blendMode(e){this.blurYFilter.blendMode=e}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(e){this._repeatEdgePixels=e,this.updatePadding()}}var k1=`varying vec2 vTextureCoord; 638uniform sampler2D uSampler; 639uniform float m[20]; 640uniform float uAlpha; 641 642void main(void) 643{ 644 vec4 c = texture2D(uSampler, vTextureCoord); 645 646 if (uAlpha == 0.0) { 647 gl_FragColor = c; 648 return; 649 } 650 651 // Un-premultiply alpha before applying the color matrix. See issue #3539. 652 if (c.a > 0.0) { 653 c.rgb /= c.a; 654 } 655 656 vec4 result; 657 658 result.r = (m[0] * c.r); 659 result.r += (m[1] * c.g); 660 result.r += (m[2] * c.b); 661 result.r += (m[3] * c.a); 662 result.r += m[4]; 663 664 result.g = (m[5] * c.r); 665 result.g += (m[6] * c.g); 666 result.g += (m[7] * c.b); 667 result.g += (m[8] * c.a); 668 result.g += m[9]; 669 670 result.b = (m[10] * c.r); 671 result.b += (m[11] * c.g); 672 result.b += (m[12] * c.b); 673 result.b += (m[13] * c.a); 674 result.b += m[14]; 675 676 result.a = (m[15] * c.r); 677 result.a += (m[16] * c.g); 678 result.a += (m[17] * c.b); 679 result.a += (m[18] * c.a); 680 result.a += m[19]; 681 682 vec3 rgb = mix(c.rgb, result.rgb, uAlpha); 683 684 // Premultiply alpha again. 685 rgb *= result.a; 686 687 gl_FragColor = vec4(rgb, result.a); 688} 689`;class Ch extends Ft{constructor(){const e={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,k1,e),this.alpha=1}_loadMatrix(e,t=!1){let i=e;t&&(this._multiply(i,this.uniforms.m,e),i=this._colorMatrix(i)),this.uniforms.m=i}_multiply(e,t,i){return e[0]=t[0]*i[0]+t[1]*i[5]+t[2]*i[10]+t[3]*i[15],e[1]=t[0]*i[1]+t[1]*i[6]+t[2]*i[11]+t[3]*i[16],e[2]=t[0]*i[2]+t[1]*i[7]+t[2]*i[12]+t[3]*i[17],e[3]=t[0]*i[3]+t[1]*i[8]+t[2]*i[13]+t[3]*i[18],e[4]=t[0]*i[4]+t[1]*i[9]+t[2]*i[14]+t[3]*i[19]+t[4],e[5]=t[5]*i[0]+t[6]*i[5]+t[7]*i[10]+t[8]*i[15],e[6]=t[5]*i[1]+t[6]*i[6]+t[7]*i[11]+t[8]*i[16],e[7]=t[5]*i[2]+t[6]*i[7]+t[7]*i[12]+t[8]*i[17],e[8]=t[5]*i[3]+t[6]*i[8]+t[7]*i[13]+t[8]*i[18],e[9]=t[5]*i[4]+t[6]*i[9]+t[7]*i[14]+t[8]*i[19]+t[9],e[10]=t[10]*i[0]+t[11]*i[5]+t[12]*i[10]+t[13]*i[15],e[11]=t[10]*i[1]+t[11]*i[6]+t[12]*i[11]+t[13]*i[16],e[12]=t[10]*i[2]+t[11]*i[7]+t[12]*i[12]+t[13]*i[17],e[13]=t[10]*i[3]+t[11]*i[8]+t[12]*i[13]+t[13]*i[18],e[14]=t[10]*i[4]+t[11]*i[9]+t[12]*i[14]+t[13]*i[19]+t[14],e[15]=t[15]*i[0]+t[16]*i[5]+t[17]*i[10]+t[18]*i[15],e[16]=t[15]*i[1]+t[16]*i[6]+t[17]*i[11]+t[18]*i[16],e[17]=t[15]*i[2]+t[16]*i[7]+t[17]*i[12]+t[18]*i[17],e[18]=t[15]*i[3]+t[16]*i[8]+t[17]*i[13]+t[18]*i[18],e[19]=t[15]*i[4]+t[16]*i[9]+t[17]*i[14]+t[18]*i[19]+t[19],e}_colorMatrix(e){const t=new Float32Array(e);return t[4]/=255,t[9]/=255,t[14]/=255,t[19]/=255,t}brightness(e,t){const i=[e,0,0,0,0,0,e,0,0,0,0,0,e,0,0,0,0,0,1,0];this._loadMatrix(i,t)}tint(e,t){const[i,r,s]=Ze.shared.setValue(e).toArray(),o=[i,0,0,0,0,0,r,0,0,0,0,0,s,0,0,0,0,0,1,0];this._loadMatrix(o,t)}greyscale(e,t){const i=[e,e,e,0,0,e,e,e,0,0,e,e,e,0,0,0,0,0,1,0];this._loadMatrix(i,t)}blackAndWhite(e){const t=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(t,e)}hue(e,t){e=(e||0)/180*Math.PI;const i=Math.cos(e),r=Math.sin(e),s=Math.sqrt,o=1/3,a=s(o),l=i+(1-i)*o,h=o*(1-i)-a*r,u=o*(1-i)+a*r,c=o*(1-i)+a*r,d=i+o*(1-i),f=o*(1-i)-a*r,p=o*(1-i)-a*r,g=o*(1-i)+a*r,v=i+o*(1-i),m=[l,h,u,0,0,c,d,f,0,0,p,g,v,0,0,0,0,0,1,0];this._loadMatrix(m,t)}contrast(e,t){const i=(e||0)+1,r=-.5*(i-1),s=[i,0,0,0,r,0,i,0,0,r,0,0,i,0,r,0,0,0,1,0];this._loadMatrix(s,t)}saturate(e=0,t){const i=e*2/3+1,r=(i-1)*-.5,s=[i,r,r,0,0,r,i,r,0,0,r,r,i,0,0,0,0,0,1,0];this._loadMatrix(s,t)}desaturate(){this.saturate(-1)}negative(e){const t=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(t,e)}sepia(e){const t=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(t,e)}technicolor(e){const t=[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(t,e)}polaroid(e){const t=[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(t,e)}toBGR(e){const t=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(t,e)}kodachrome(e){const t=[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(t,e)}browni(e){const t=[.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(t,e)}vintage(e){const t=[.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(t,e)}colorTone(e,t,i,r,s){e=e||.2,t=t||.15,i=i||16770432,r=r||3375104;const o=Ze.shared,[a,l,h]=o.setValue(i).toArray(),[u,c,d]=o.setValue(r).toArray(),f=[.3,.59,.11,0,0,a,l,h,e,0,u,c,d,t,0,a-u,l-c,h-d,0,0];this._loadMatrix(f,s)}night(e,t){e=e||.1;const i=[e*-2,-e,0,0,0,-e,0,e,0,0,0,e,e*2,0,0,0,0,0,1,0];this._loadMatrix(i,t)}predator(e,t){const i=[11.224130630493164*e,-4.794486999511719*e,-2.8746118545532227*e,0*e,.40342438220977783*e,-3.6330697536468506*e,9.193157196044922*e,-2.951810836791992*e,0*e,-1.316135048866272*e,-3.2184197902679443*e,-4.2375030517578125*e,7.476448059082031*e,0*e,.8044459223747253*e,0,0,0,1,0];this._loadMatrix(i,t)}lsd(e){const t=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(t,e)}reset(){const e=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(e,!1)}get matrix(){return this.uniforms.m}set matrix(e){this.uniforms.m=e}get alpha(){return this.uniforms.uAlpha}set alpha(e){this.uniforms.uAlpha=e}}Ch.prototype.grayscale=Ch.prototype.greyscale;var U1=`varying vec2 vFilterCoord; 690varying vec2 vTextureCoord; 691 692uniform vec2 scale; 693uniform mat2 rotation; 694uniform sampler2D uSampler; 695uniform sampler2D mapSampler; 696 697uniform highp vec4 inputSize; 698uniform vec4 inputClamp; 699 700void main(void) 701{ 702 vec4 map = texture2D(mapSampler, vFilterCoord); 703 704 map -= 0.5; 705 map.xy = scale * inputSize.zw * (rotation * map.xy); 706 707 gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw)); 708} 709`,H1=`attribute vec2 aVertexPosition; 710 711uniform mat3 projectionMatrix; 712uniform mat3 filterMatrix; 713 714varying vec2 vTextureCoord; 715varying vec2 vFilterCoord; 716 717uniform vec4 inputSize; 718uniform vec4 outputFrame; 719 720vec4 filterVertexPosition( void ) 721{ 722 vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; 723 724 return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); 725} 726 727vec2 filterTextureCoord( void ) 728{ 729 return aVertexPosition * (outputFrame.zw * inputSize.zw); 730} 731 732void main(void) 733{ 734 gl_Position = filterVertexPosition(); 735 vTextureCoord = filterTextureCoord(); 736 vFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0) ).xy; 737} 738`;class G1 extends Ft{constructor(e,t){const i=new tt;e.renderable=!1,super(H1,U1,{mapSampler:e._texture,filterMatrix:i,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])}),this.maskSprite=e,this.maskMatrix=i,t==null&&(t=20),this.scale=new ze(t,t)}apply(e,t,i,r){this.uniforms.filterMatrix=e.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;const s=this.maskSprite.worldTransform,o=Math.sqrt(s.a*s.a+s.b*s.b),a=Math.sqrt(s.c*s.c+s.d*s.d);o!==0&&a!==0&&(this.uniforms.rotation[0]=s.a/o,this.uniforms.rotation[1]=s.b/o,this.uniforms.rotation[2]=s.c/a,this.uniforms.rotation[3]=s.d/a),e.applyFilter(this,t,i,r)}get map(){return this.uniforms.mapSampler}set map(e){this.uniforms.mapSampler=e}}var z1=`varying vec2 v_rgbNW; 739varying vec2 v_rgbNE; 740varying vec2 v_rgbSW; 741varying vec2 v_rgbSE; 742varying vec2 v_rgbM; 743 744varying vec2 vFragCoord; 745uniform sampler2D uSampler; 746uniform highp vec4 inputSize; 747 748 749/** 750 Basic FXAA implementation based on the code on geeks3d.com with the 751 modification that the texture2DLod stuff was removed since it's 752 unsupported by WebGL. 753 754 -- 755 756 From: 757 https://github.com/mitsuhiko/webgl-meincraft 758 759 Copyright (c) 2011 by Armin Ronacher. 760 761 Some rights reserved. 762 763 Redistribution and use in source and binary forms, with or without 764 modification, are permitted provided that the following conditions are 765 met: 766 767 * Redistributions of source code must retain the above copyright 768 notice, this list of conditions and the following disclaimer. 769 770 * Redistributions in binary form must reproduce the above 771 copyright notice, this list of conditions and the following 772 disclaimer in the documentation and/or other materials provided 773 with the distribution. 774 775 * The names of the contributors may not be used to endorse or 776 promote products derived from this software without specific 777 prior written permission. 778 779 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 780 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 781 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 782 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 783 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
784 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 785 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 786 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 787 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 788 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 789 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 790 */ 791 792#ifndef FXAA_REDUCE_MIN 793#define FXAA_REDUCE_MIN (1.0/ 128.0) 794#endif 795#ifndef FXAA_REDUCE_MUL 796#define FXAA_REDUCE_MUL (1.0 / 8.0) 797#endif 798#ifndef FXAA_SPAN_MAX 799#define FXAA_SPAN_MAX 8.0 800#endif 801 802//optimized version for mobile, where dependent 803//texture reads can be a bottleneck 804vec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 inverseVP, 805 vec2 v_rgbNW, vec2 v_rgbNE, 806 vec2 v_rgbSW, vec2 v_rgbSE, 807 vec2 v_rgbM) { 808 vec4 color; 809 vec3 rgbNW = texture2D(tex, v_rgbNW).xyz; 810 vec3 rgbNE = texture2D(tex, v_rgbNE).xyz; 811 vec3 rgbSW = texture2D(tex, v_rgbSW).xyz; 812 vec3 rgbSE = texture2D(tex, v_rgbSE).xyz; 813 vec4 texColor = texture2D(tex, v_rgbM); 814 vec3 rgbM = texColor.xyz; 815 vec3 luma = vec3(0.299, 0.587, 0.114); 816 float lumaNW = dot(rgbNW, luma); 817 float lumaNE = dot(rgbNE, luma); 818 float lumaSW = dot(rgbSW, luma); 819 float lumaSE = dot(rgbSE, luma); 820 float lumaM = dot(rgbM, luma); 821 float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); 822 float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); 823 824 mediump vec2 dir; 825 dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE)); 826 dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE)); 827 828 float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * 829 (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN); 830 831 float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce); 832 dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), 833 max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), 834 dir * rcpDirMin)) * inverseVP; 835 836 vec3 rgbA = 0.5 * ( 837 texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz + 838 texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz); 839 vec3 rgbB = rgbA * 0.5 + 0.25 * ( 840 texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz + 841 texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz); 842 843 float lumaB = dot(rgbB, luma); 844 if ((lumaB < lumaMin) || (lumaB > lumaMax)) 845 color = vec4(rgbA, texColor.a); 846 else 847 color = vec4(rgbB, texColor.a); 848 return color; 849} 850 851void main() { 852 853 vec4 color; 854 855 color = fxaa(uSampler, vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM); 856 857 gl_FragColor = color; 858} 859`,V1=` 860attribute vec2 aVertexPosition; 861 862uniform mat3 projectionMatrix; 863 864varying vec2 v_rgbNW; 865varying vec2 v_rgbNE; 866varying vec2 v_rgbSW; 867varying vec2 v_rgbSE; 868varying vec2 v_rgbM; 869 870varying vec2 vFragCoord; 871 872uniform vec4 inputSize; 873uniform vec4 outputFrame; 874 875vec4 filterVertexPosition( void ) 876{ 877 vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; 878 879 return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); 880} 881 882void texcoords(vec2 fragCoord, vec2 inverseVP, 883 out vec2 v_rgbNW, out vec2 v_rgbNE, 884 out vec2 v_rgbSW, out vec2 v_rgbSE, 885 out vec2 v_rgbM) { 886 v_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP; 887 v_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP; 888 v_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP; 889 v_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP; 890 v_rgbM = vec2(fragCoord * inverseVP); 891} 892 893void main(void) { 894 895 gl_Position = filterVertexPosition(); 896 897 vFragCoord = aVertexPosition * outputFrame.zw; 898 899 texcoords(vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM); 900} 901`;class j1 extends Ft{constructor(){super(V1,z1)}}var X1=`precision highp float; 902 903varying vec2 vTextureCoord; 904varying vec4 vColor; 905 906uniform float uNoise; 907uniform float uSeed; 908uniform sampler2D uSampler; 909 910float rand(vec2 co) 911{ 912 return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); 913} 914 915void main() 916{ 917 vec4 color = texture2D(uSampler, vTextureCoord); 918 float randomValue = rand(gl_FragCoord.xy * uSeed); 919 float diff = (randomValue - 0.5) * uNoise; 920 921 // Un-premultiply alpha before applying the color matrix. See issue #3539. 922 if (color.a > 0.0) { 923 color.rgb /= color.a; 924 } 925 926 color.r += diff; 927 color.g += diff; 928 color.b += diff; 929 930 // Premultiply alpha again. 931 color.rgb *= color.a; 932 933 gl_FragColor = color; 934} 935`;class W1 extends Ft{constructor(e=.5,t=Math.random()){super(pm,X1,{uNoise:0,uSeed:0}),this.noise=e,this.seed=t}get noise(){return this.uniforms.uNoise}set noise(e){this.uniforms.uNoise=e}get seed(){return this.uniforms.uSeed}set seed(e){this.uniforms.uSeed=e}}const wf={AlphaFilter:M1,BlurFilter:N1,BlurFilterPass:Ph,ColorMatrixFilter:Ch,DisplacementFilter:G1,FXAAFilter:j1,NoiseFilter:W1};Object.entries(wf).forEach(([n,e])=>{Object.defineProperty(wf,n,{get(){return Ue("7.1.0",`filters.${n} has moved to ${n}`),e}})});class Y1{constructor(){this.interactionFrequency=10,this._deltaT
vendor: 12,556 bytes, line 935
935ime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}init(e){this.removeTickerListener(),this.events=e,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(e){this._pauseUpdate=e}addTickerListener(){this.tickerAdded||!this.domElement||(Yt.system.add(this.tickerUpdate,this,Wn.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(Yt.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 e=this.events.rootPointerEvent;this.events.supportsTouchEvents&&e.pointerType==="touch"||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:e.clientX,clientY:e.clientY}))}tickerUpdate(e){this._deltaTime+=e,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.update())}}const Qi=new Y1;class js{constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=js.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new ze,this.page=new ze,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){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(e,t,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,t,i,r,s){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 na extends js{constructor(){super(...arguments),this.client=new ze,this.movement=new ze,this.offset=new ze,this.global=new ze,this.screen=new ze}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(e,t,i){return e.worldTransform.applyInverse(i||this.global,t)}getModifierState(e){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(e)}initMouseEvent(e,t,i,r,s,o,a,l,h,u,c,d,f,p,g){throw new Error("Method not implemented.")}}class hi extends na{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 Ar extends na{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}Ar.DOM_DELTA_PIXEL=0,Ar.DOM_DELTA_LINE=1,Ar.DOM_DELTA_PAGE=2;const q1=2048,$1=new ze,Ol=new ze;class Z1{constructor(e){this.dispatch=new Hs,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=e,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.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(e,t){this.mappingTable[e]||(this.mappingTable[e]=[]),this.mappingTable[e].push({fn:t,priority:0}),this.mappingTable[e].sort((i,r)=>i.priority-r.priority)}dispatchEvent(e,t){e.propagationStopped=!1,e.propagationImmediatelyStopped=!1,this.propagate(e,t),this.dispatch.emit(t||e.type,e)}mapEvent(e){if(!this.rootTarget)return;const t=this.mappingTable[e.type];if(t)for(let i=0,r=t.length;i<r;i++)t[i].fn(e);else console.warn(`[EventBoundary]: Event mapping not defined for ${e.type}`)}hitTest(e,t){Qi.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",r=this[i](this.rootTarget,this.rootTarget.eventMode,$1.set(e,t),this.hitTestFn,this.hitPruneFn);return r&&r[0]}propagate(e,t){if(!e.target)return;const i=e.composedPath();e.eventPhase=e.CAPTURING_PHASE;for(let r=0,s=i.length-1;r<s;r++)if(e.currentTarget=i[r],this.notifyTarget(e,t),e.propagationStopped||e.propagationImmediatelyStopped)return;if(e.eventPhase=e.AT_TARGET,e.currentTarget=e.target,this.notifyTarget(e,t),!(e.propagationStopped||e.propagationImmediatelyStopped)){e.eventPhase=e.BUBBLING_PHASE;for(let r=i.length-2;r>=0;r--)if(e.currentTarget=i[r],this.notifyTarget(e,t),e.propagationStopped||e.propagationImmediatelyStopped)return}}all(e,t,i=this._allInteractiveElements){if(i.length===0)return;e.eventPhase=e.BUBBLING_PHASE;const r=Array.isArray(t)?t:[t];for(let s=i.length-1;s>=0;s--)r.forEach(o=>{e.currentTarget=i[s],this.notifyTarget(e,o)})}propagationPath(e){const t=[e];for(let i=0;i<q1&&e!==this.rootTarget;i++){if(!e.parent)throw new Error("Cannot find propagation path to disconnected target");t.push(e.parent),e=e.parent}return t.reverse(),t}hitTestMoveRecursive(e,t,i,r,s,o=!1){let a=!1;if(this._interactivePrune(e))return null;if((e.eventMode==="dynamic"||t==="dynamic")&&(Qi.pauseUpdate=!1),e.interactiveChildren&&e.children){const u=e.children;for(let c=u.length-1;c>=0;c--){const d=u[c],f=this.hitTestMoveRecursive(d,this._isInteractive(t)?t:d.eventMode,i,r,s,o||s(e,i));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const p=e.isInteractive();(f.length>0||p)&&(p&&this._allInteractiveElements.push(e),f.push(e)),this._hitElements.length===0&&(this._hitElements=f),a=!0}}}const l=this._isInteractive(t),h=e.isInteractive();return l&&h&&this._allInteractiveElements.push(e),o||this._hitElements.length>0?null:a?this._hitElements:l&&!s(e,i)&&r(e,i)?h?[e]:[]:null}hitTestRecursive(e,t,i,r,s){if(this._interactivePrune(e)||s(e,i))return null;if((e.eventMode==="dynamic"||t==="dynamic")&&(Qi.pauseUpdate=!1),e.interactiveChildren&&e.children){const l=e.children;for(let h=l.length-1;h>=0;h--){const u=l[h],c=this.hitTestRecursive(u,this._isInteractive(t)?t:u.eventMode,i,r,s);if(c){if(c.length>0&&!c[c.length-1].parent)continue;const d=e.isInteractive();return(c.length>0||d)&&c.push(e),c}}}const o=this._isInteractive(t),a=e.isInteractive();return o&&r(e,i)?a?[e]:[]:null}_isInteractive(e){return e==="static"||e==="dynamic"}_interactivePrune(e){return!!(!e||e.isMask||!e.visible||!e.renderable||e.eventMode==="none"||e.eventMode==="passive"&&!e.interactiveChildren||e.isMask)}hitPruneFn(e,t){var i;if(e.hitArea&&(e.worldTransform.applyInverse(t,Ol),!e.hitArea.contains(Ol.x,Ol.y)))return!0;if(e._mask){const r=e._mask.isMaskData?e._mask.maskObject:e._mask;if(r&&!((i=r.containsPoint)!=null&&i.call(r,t)))return!0}return!1}hitTestFn(e,t){return e.eventMode==="passive"?!1:e.hitArea?!0:e.containsPoint?e.containsPoint(t):!1}notifyTarget(e,t){var i,r;t=t??e.type;const s=`on${t}`;(r=(i=e.currentTarget)[s])==null||r.call(i,e);const o=e.eventPhase===e.CAPTURING_PHASE||e.eventPhase===e.AT_TARGET?`${t}capture`:t;this.notifyListeners(e,o),e.eventPhase===e.AT_TARGET&&this.notifyListeners(e,t)}mapPointerDown(e){if(!(e instanceof hi)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.createPointerEvent(e);if(this.dispatchEvent(t,"pointerdown"),t.pointerType==="touch")this.dispatchEvent(t,"touchstart");else if(t.pointerType==="mouse"||t.pointerType==="pen"){const r=t.button===2;this.dispatchEvent(t,r?"rightdown":"mousedown")}const i=this.trackingData(e.pointerId);i.pressTargetsByButton[e.button]=t.composedPath(),this.freeEvent(t)}mapPointerMove(e){var t,i;if(!(e instanceof hi)){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 r=this.createPointerEvent(e);this._isPointerMoveEvent=!1;const s=r.pointerType==="mouse"||r.pointerType==="pen",o=this.trackingData(e.pointerId),a=this.findMountedTarget(o.overTargets);if(((t=o.overTargets)==null?void 0:t.length)>0&&a!==r.target){const u=e.type==="mousemove"?"mouseout":"pointerout",c=this.createPointerEvent(e,u,a);if(this.dispatchEvent(c,"pointerout"),s&&this.dispatchEvent(c,"mouseout"),!r.composedPath().includes(a)){const d=this.createPointerEvent(e,"pointerleave",a);for(d.eventPhase=d.AT_TARGET;d.target&&!r.composedPath().includes(d.target);)d.currentTarget=d.target,this.notifyTarget(d),s&&this.notifyTarget(d,"mouseleave"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(c)}if(a!==r.target){const u=e.type==="mousemove"?"mouseover":"pointerover",c=this.clonePointerEvent(r,u);this.dispatchEvent(c,"pointerover"),s&&this.dispatchEvent(c,"mouseover");let d=a?.parent;for(;d&&d!==this.rootTarget.parent&&d!==r.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const f=this.clonePointerEvent(r,"pointerenter");for(f.eventPhase=f.AT_TARGET;f.target&&f.target!==a&&f.target!==this.rootTarget.parent;)f.currentTarget=f.target,this.notifyTarget(f),s&&this.notifyTarget(f,"mouseenter"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(c)}const l=[],h=this.enableGlobalMoveEvents??!0;this.moveOnAll?l.push("pointermove"):this.dispatchEvent(r,"pointermove"),h&&l.push("globalpointermove"),r.pointerType==="touch"&&(this.moveOnAll?l.splice(1,0,"touchmove"):this.dispatchEvent(r,"touchmove"),h&&l.push("globaltouchmove")),s&&(this.moveOnAll?l.splice(1,0,"mousemove"):this.dispatchEvent(r,"mousemove"),h&&l.push("globalmousemove"),this.cursor=(i=r.target)==null?void 0:i.cursor),l.length>0&&this.all(r,l),this._allInteractiveElements.length=0,this._hitElements.length=0,o.overTargets=r.composedPath(),this.freeEvent(r)}mapPointerOver(e){var t;if(!(e instanceof hi)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const i=this.trackingData(e.pointerId),r=this.createPointerEvent(e),s=r.pointerType==="mouse"||r.pointerType==="pen";this.dispatchEvent(r,"pointerover"),s&&this.dispatchEvent(r,"mouseover"),r.pointerType==="mouse"&&(this.cursor=(t=r.target)==null?void 0:t.cursor);const o=this.clonePointerEvent(r,"pointerenter");for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),s&&this.notifyTarget(o,"mouseenter"),o.target=o.target.parent;i.overTargets=r.composedPath(),this.freeEvent(r),this.freeEvent(o)}mapPointerOut(e){if(!(e instanceof hi)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId);if(t.overTargets){const i=e.pointerType==="mouse"||e.pointerType==="pen",r=this.findMountedTarget(t.overTargets),s=this.createPointerEvent(e,"pointerout",r);this.dispatchEvent(s),i&&this.dispatchEvent(s,"mouseout");const o=this.createPointerEvent(e,"pointerleave",r);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;t.overTargets=null,this.freeEvent(s),this.freeEvent(o)}this.cursor=null}mapPointerUp(e){if(!(e instanceof hi)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=performance.now(),i=this.createPointerEvent(e);
vendor: 13,283 bytes, line 935
935if(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 r=this.trackingData(e.pointerId),s=this.findMountedTarget(r.pressTargetsByButton[e.button]);let o=s;if(s&&!i.composedPath().includes(s)){let a=s;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 r.pressTargetsByButton[e.button],o=a}if(o){const a=this.clonePointerEvent(i,"click");a.target=o,a.path=null,r.clicksByButton[e.button]||(r.clicksByButton[e.button]={clickCount:0,target:a.target,timeStamp:t});const l=r.clicksByButton[e.button];if(l.target===a.target&&t-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=t,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(e){if(!(e instanceof hi)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId),i=this.findMountedTarget(t.pressTargetsByButton[e.button]),r=this.createPointerEvent(e);if(i){let s=i;for(;s;)r.currentTarget=s,this.notifyTarget(r,"pointerupoutside"),r.pointerType==="touch"?this.notifyTarget(r,"touchendoutside"):(r.pointerType==="mouse"||r.pointerType==="pen")&&this.notifyTarget(r,r.button===2?"rightupoutside":"mouseupoutside"),s=s.parent;delete t.pressTargetsByButton[e.button]}this.freeEvent(r)}mapWheel(e){if(!(e instanceof Ar)){console.warn("EventBoundary cannot map a non-wheel event as a wheel event");return}const t=this.createWheelEvent(e);this.dispatchEvent(t),this.freeEvent(t)}findMountedTarget(e){if(!e)return null;let t=e[0];for(let i=1;i<e.length&&e[i].parent===t;i++)t=e[i];return t}createPointerEvent(e,t,i){const r=this.allocateEvent(hi);return this.copyPointerData(e,r),this.copyMouseData(e,r),this.copyData(e,r),r.nativeEvent=e.nativeEvent,r.originalEvent=e,r.target=i??this.hitTest(r.global.x,r.global.y)??this._hitElements[0],typeof t=="string"&&(r.type=t),r}createWheelEvent(e){const t=this.allocateEvent(Ar);return this.copyWheelData(e,t),this.copyMouseData(e,t),this.copyData(e,t),t.nativeEvent=e.nativeEvent,t.originalEvent=e,t.target=this.hitTest(t.global.x,t.global.y),t}clonePointerEvent(e,t){const i=this.allocateEvent(hi);return i.nativeEvent=e.nativeEvent,i.originalEvent=e.originalEvent,this.copyPointerData(e,i),this.copyMouseData(e,i),this.copyData(e,i),i.target=e.target,i.path=e.composedPath().slice(),i.type=t??i.type,i}copyWheelData(e,t){t.deltaMode=e.deltaMode,t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ}copyPointerData(e,t){e instanceof hi&&t instanceof hi&&(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)}copyMouseData(e,t){e instanceof na&&t instanceof na&&(t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.copyFrom(e.client),t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.copyFrom(e.movement),t.screen.copyFrom(e.screen),t.shiftKey=e.shiftKey,t.global.copyFrom(e.global))}copyData(e,t){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.detail=e.detail,t.view=e.view,t.which=e.which,t.layer.copyFrom(e.layer),t.page.copyFrom(e.page)}trackingData(e){return this.mappingState.trackingData[e]||(this.mappingState.trackingData[e]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[e]}allocateEvent(e){this.eventPool.has(e)||this.eventPool.set(e,[]);const t=this.eventPool.get(e).pop()||new e(this);return t.eventPhase=t.NONE,t.currentTarget=null,t.path=null,t.target=null,t}freeEvent(e){if(e.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const t=e.constructor;this.eventPool.has(t)||this.eventPool.set(t,[]),this.eventPool.get(t).push(e)}notifyListeners(e,t){const i=e.currentTarget._events[t];if(i&&e.currentTarget.isInteractive())if("fn"in i)i.once&&e.currentTarget.removeListener(t,i.fn,void 0,!0),i.fn.call(i.context,e);else for(let r=0,s=i.length;r<s&&!e.propagationImmediatelyStopped;r++)i[r].once&&e.currentTarget.removeListener(t,i[r].fn,void 0,!0),i[r].fn.call(i[r].context,e)}}const K1=1,J1={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Ih=class Mh{constructor(e){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=e,this.rootBoundary=new Z1(null),Qi.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new hi(null),this.rootWheelEvent=new Ar(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...Mh.defaultEventFeatures},{set:(t,i,r)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=r),t[i]=r,!0)}),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOverOut=this.onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(e){const{view:t,resolution:i}=this.renderer;this.setTargetElement(t),this.resolution=i,Mh._defaultEventMode=e.eventMode??"auto",Object.assign(this.features,e.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(e){this.resolution=e}destroy(){this.setTargetElement(null),this.renderer=null}setCursor(e){e=e||"default";let t=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(t=!1),this.currentCursor===e)return;this.currentCursor=e;const i=this.cursorStyles[e];if(i)switch(typeof i){case"string":t&&(this.domElement.style.cursor=i);break;case"function":i(e);break;case"object":t&&Object.assign(this.domElement.style,i);break}else t&&typeof e=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,e)&&(this.domElement.style.cursor=e)}get pointer(){return this.rootPointerEvent}onPointerDown(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const t=this.normalizeToPointerData(e);this.autoPreventDefault&&t[0].isNormalized&&(e.cancelable||!("cancelable"in e))&&e.preventDefault();for(let i=0,r=t.length;i<r;i++){const s=t[i],o=this.bootstrapEvent(this.rootPointerEvent,s);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}onPointerMove(e){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,Qi.pointerMoved();const t=this.normalizeToPointerData(e);for(let i=0,r=t.length;i<r;i++){const s=this.bootstrapEvent(this.rootPointerEvent,t[i]);this.rootBoundary.mapEvent(s)}this.setCursor(this.rootBoundary.cursor)}onPointerUp(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let t=e.target;e.composedPath&&e.composedPath().length>0&&(t=e.composedPath()[0]);const i=t!==this.domElement?"outside":"",r=this.normalizeToPointerData(e);for(let s=0,o=r.length;s<o;s++){const a=this.bootstrapEvent(this.rootPointerEvent,r[s]);a.type+=i,this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}onPointerOverOut(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const t=this.normalizeToPointerData(e);for(let i=0,r=t.length;i<r;i++){const s=this.bootstrapEvent(this.rootPointerEvent,t[i]);this.rootBoundary.mapEvent(s)}this.setCursor(this.rootBoundary.cursor)}onWheel(e){if(!this.features.wheel)return;const t=this.normalizeWheelEvent(e);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(t)}setTargetElement(e){this.removeEvents(),this.domElement=e,Qi.domElement=e,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;Qi.addTickerListener();const e=this.domElement.style;e&&(globalThis.navigator.msPointerEnabled?(e.msContentZooming="none",e.msTouchAction="none"):this.supportsPointerEvents&&(e.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;Qi.removeTickerListener();const e=this.domElement.style;globalThis.navigator.msPointerEnabled?(e.msContentZooming="",e.msTouchAction=""):this.supportsPointerEvents&&(e.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(e,t,i){const r=this.domElement.isConnected?this.domElement.getBoundingClientRect():{width:this.domElement.width,height:this.domElement.height,left:0,top:0},s=1/this.resolution;e.x=(t-r.left)*(this.domElement.width/r.width)*s,e.y=(i-r.top)*(this.domElement.height/r.height)*s}normalizeToPointerData(e){const t=[];if(this.supportsTouchEvents&&e instanceof TouchEvent)for(let i=0,r=e.changedTouches.length;i<r;i++){const s=e.changedTouches[i];typeof s.button>"u"&&(s.button=0),typeof s.buttons>"u"&&(s.buttons=1),typeof s.isPrimary>"u"&&(s.isPrimary=e.touches.length===1&&e.type==="touchstart"),typeof s.width>"u"&&(s.width=s.radiusX||1),typeof s.height>"u"&&(s.height=s.radiusY||1),typeof s.tiltX>"u"&&(s.tiltX=0),typeof s.tiltY>"u"&&(s.tiltY=0),typeof s.pointerType>"u"&&(s.pointerType="touch"),typeof s.pointerId>"u"&&(s.pointerId=s.identifier||0),typeof s.pressure>"u"&&(s.pressure=s.force||.5),typeof s.twist>"u"&&(s.twist=0),typeof s.tangentialPressure>"u"&&(s.tangentialPressure=0),typeof s.layerX>"u"&&(s.layerX=s.offsetX=s.clientX),typeof s.layerY>"u"&&(s.layerY=s.offsetY=s.clientY),s.isNormalized=!0,s.type=e.type,t.push(s)}else if(!globalThis.MouseEvent||e instanceof MouseEvent&&(!this.supportsPointerEvents||!(e instanceof globalThis.PointerEvent))){const i=e;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=K1),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),i.isNormalized=!0,t.push(i)}else t.push(e);return t}normalizeWheelEvent(e){const t=this.rootWheelEvent;return this.transferMouseData(t,e),t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ,t.deltaMode=e.deltaMode,this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.nativeEvent=e,t.type=e.type,t}bootstrapEvent(e,t){return e.originalEvent=null,e.nativeEvent=t,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.t
vendor: 10,978 bytes, line 935
935iltY=t.tiltY,e.twist=t.twist,this.transferMouseData(e,t),this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.isTrusted=t.isTrusted,e.type==="pointerleave"&&(e.type="pointerout"),e.type.startsWith("mouse")&&(e.type=e.type.replace("mouse","pointer")),e.type.startsWith("touch")&&(e.type=J1[e.type]||e.type),e}transferMouseData(e,t){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.x=t.clientX,e.client.y=t.clientY,e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.x=t.movementX,e.movement.y=t.movementY,e.page.x=t.pageX,e.page.y=t.pageY,e.relatedTarget=null,e.shiftKey=t.shiftKey}};Ih.extension={name:"events",type:[ue.RendererSystem,ue.CanvasRendererSystem]},Ih.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Dh=Ih;_e.add(Dh);function Tf(n){return n==="dynamic"||n==="static"}const Q1={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,_internalInteractive:void 0,get interactive(){return this._internalInteractive??Tf(Dh.defaultEventMode)},set interactive(n){Ue("7.2.0","Setting interactive is deprecated, use eventMode = 'none'/'passive'/'auto'/'static'/'dynamic' instead."),this._internalInteractive=n,this.eventMode=n?"static":"auto"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??Dh.defaultEventMode},set eventMode(n){this._internalInteractive=Tf(n),this._internalEventMode=n},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(n,e,t){const i=typeof t=="boolean"&&t||typeof t=="object"&&t.capture,r=typeof t=="object"?t.signal:void 0,s=typeof t=="object"?t.once===!0:!1,o=typeof e=="function"?void 0:e;n=i?`${n}capture`:n;const a=typeof e=="function"?e:e.handleEvent,l=this;r&&r.addEventListener("abort",()=>{l.off(n,a,o)}),s?l.once(n,a,o):l.on(n,a,o)},removeEventListener(n,e,t){const i=typeof t=="boolean"&&t||typeof t=="object"&&t.capture,r=typeof e=="function"?void 0:e;n=i?`${n}capture`:n,e=typeof e=="function"?e:e.handleEvent,this.off(n,e,r)},dispatchEvent(n){if(!(n instanceof js))throw new Error("DisplayObject cannot propagate events outside of the Federated Events API");return n.defaultPrevented=!1,n.path=null,n.target=this,n.manager.dispatchEvent(n),!n.defaultPrevented}};lt.mixin(Q1);const eS={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};lt.mixin(eS);const tS=9,ao=100,iS=0,nS=0,Ef=2,bf=1,rS=-1e3,sS=-1e3,oS=2;class Em{constructor(e){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,(ki.tablet||ki.phone)&&this.createTouchHook();const t=document.createElement("div");t.style.width=`${ao}px`,t.style.height=`${ao}px`,t.style.position="absolute",t.style.top=`${iS}px`,t.style.left=`${nS}px`,t.style.zIndex=Ef.toString(),this.div=t,this.renderer=e,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 e=document.createElement("button");e.style.width=`${bf}px`,e.style.height=`${bf}px`,e.style.position="absolute",e.style.top=`${rS}px`,e.style.left=`${sS}px`,e.style.zIndex=oS.toString(),e.style.backgroundColor="#FF0000",e.title="select to enable accessibility for this content",e.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this.activate(),this.destroyTouchHook()}),document.body.appendChild(e),this._hookDiv=e}destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}activate(){var e;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),(e=this.renderer.view.parentNode)==null||e.appendChild(this.div))}deactivate(){var e;!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),(e=this.div.parentNode)==null||e.removeChild(this.div))}updateAccessibleObjects(e){if(!e.visible||!e.accessibleChildren)return;e.accessible&&e.isInteractive()&&(e._accessibleActive||this.addChild(e),e.renderId=this.renderId);const t=e.children;if(t)for(let i=0;i<t.length;i++)this.updateAccessibleObjects(t[i])}update(){const e=performance.now();if(ki.android.device&&e<this.androidUpdateCount||(this.androidUpdateCount=e+this.androidUpdateFrequency,!this.renderer.renderingToScreen))return;this.renderer.lastObjectRendered&&this.updateAccessibleObjects(this.renderer.lastObjectRendered);const{x:t,y:i,width:r,height:s}=this.renderer.view.getBoundingClientRect(),{width:o,height:a,resolution:l}=this.renderer,h=r/o*l,u=s/a*l;let c=this.div;c.style.left=`${t}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,br(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 g=f.worldTransform;f.hitArea?(c.style.left=`${(g.tx+p.x*g.a)*h}px`,c.style.top=`${(g.ty+p.y*g.d)*u}px`,c.style.width=`${p.width*g.a*h}px`,c.style.height=`${p.height*g.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(e){e.innerHTML=`type: ${e.type}</br> title : ${e.title}</br> tabIndex: ${e.tabIndex}`}capHitArea(e){e.x<0&&(e.width+=e.x,e.x=0),e.y<0&&(e.height+=e.y,e.y=0);const{width:t,height:i}=this.renderer;e.x+e.width>t&&(e.width=t-e.x),e.y+e.height>i&&(e.height=i-e.y)}addChild(e){let t=this.pool.pop();t||(t=document.createElement("button"),t.style.width=`${ao}px`,t.style.height=`${ao}px`,t.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",t.style.position="absolute",t.style.zIndex=Ef.toString(),t.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?t.setAttribute("aria-live","off"):t.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?t.setAttribute("aria-relevant","additions"):t.setAttribute("aria-relevant","text"),t.addEventListener("click",this._onClick.bind(this)),t.addEventListener("focus",this._onFocus.bind(this)),t.addEventListener("focusout",this._onFocusOut.bind(this))),t.style.pointerEvents=e.accessiblePointerEvents,t.type=e.accessibleType,e.accessibleTitle&&e.accessibleTitle!==null?t.title=e.accessibleTitle:(!e.accessibleHint||e.accessibleHint===null)&&(t.title=`displayObject ${e.tabIndex}`),e.accessibleHint&&e.accessibleHint!==null&&t.setAttribute("aria-label",e.accessibleHint),this.debug&&this.updateDebugHTML(t),e._accessibleActive=!0,e._accessibleDiv=t,t.displayObject=e,this.children.push(e),this.div.appendChild(e._accessibleDiv),e._accessibleDiv.tabIndex=e.tabIndex}_dispatchEvent(e,t){const{displayObject:i}=e.target,r=this.renderer.events.rootBoundary,s=Object.assign(new js(r),{target:i});r.rootTarget=this.renderer.lastObjectRendered,t.forEach(o=>r.dispatchEvent(s,o))}_onClick(e){this._dispatchEvent(e,["click","pointertap","tap"])}_onFocus(e){e.target.getAttribute("aria-live")||e.target.setAttribute("aria-live","assertive"),this._dispatchEvent(e,["mouseover"])}_onFocusOut(e){e.target.getAttribute("aria-live")||e.target.setAttribute("aria-live","polite"),this._dispatchEvent(e,["mouseout"])}_onKeyDown(e){e.keyCode===tS&&this.activate()}_onMouseMove(e){e.movementX===0&&e.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}}Em.extension={name:"accessibility",type:[ue.RendererPlugin,ue.CanvasRendererPlugin]};_e.add(Em);const bm=class Oh{constructor(e){this.stage=new gi,e=Object.assign({forceCanvas:!1},e),this.renderer=fm(e),Oh._plugins.forEach(t=>{t.init.call(this,e)})}render(){this.renderer.render(this.stage)}get view(){var e;return(e=this.renderer)==null?void 0:e.view}get screen(){var e;return(e=this.renderer)==null?void 0:e.screen}destroy(e,t){const i=Oh._plugins.slice(0);i.reverse(),i.forEach(r=>{r.destroy.call(this)}),this.stage.destroy(t),this.stage=null,this.renderer.destroy(e),this.renderer=null}};bm._plugins=[];let aS=bm;_e.handleByList(ue.Application,aS._plugins);class Sm{static init(e){Object.defineProperty(this,"resizeTo",{set(t){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=t,t&&(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 t,i;if(this._resizeTo===globalThis.window)t=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:r,clientHeight:s}=this._resizeTo;t=r,i=s}this.renderer.resize(t,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=e.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this.cancelResize(),this.cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Sm.extension=ue.Application;_e.add(Sm);const Sf={loader:ue.LoadParser,resolver:ue.ResolveParser,cache:ue.Cac
935heParser,detection:ue.DetectionParser};_e.handle(ue.Asset,n=>{const e=n.ref;Object.entries(Sf).filter(([t])=>!!e[t]).forEach(([t,i])=>_e.add(Object.assign(e[t],{extension:e[t].extension??i})))},n=>{const e=n.ref;Object.keys(Sf).filter(t=>!!e[t]).forEach(t=>_e.remove(e[t]))});class lS{constructor(e,t=!1){this._loader=e,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=t}add(e){e.forEach(t=>{this._assetList.push(t)}),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 e=[],t=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<t;i++)e.push(this._assetList.pop());await this._loader.load(e),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(e){this._isActive!==e&&(this._isActive=e,e&&!this._isLoading&&this._next())}}function Wr(n,e){if(Array.isArray(e)){for(const t of e)if(n.startsWith(`data:${t}`))return!0;return!1}return n.startsWith(`data:${e}`)}function xn(n,e){const t=n.split("?")[0],i=Tt.extname(t).toLowerCase();return Array.isArray(e)?e.includes(i):i===e}const ui=(n,e,t=!1)=>(Array.isArray(n)||(n=[n]),e?n.map(i=>typeof i=="string"||t?e(i):i):n),Lh=(n,e)=>{const t=e.split("?")[1];return t&&(n+=`?${t}`),n};function Am(n,e,t,i,r){const s=e[t];for(let o=0;o<s.length;o++){const a=s[o];t<e.length-1?Am(n.replace(i[t],a),e,t+1,i,r):r.push(n.replace(i[t],a))}}function hS(n){const e=/\{(.*?)\}/g,t=n.match(e),i=[];if(t){const r=[];t.forEach(s=>{const o=s.substring(1,s.length-1).split(",");r.push(o)}),Am(n,r,0,t,i)}else i.push(n);return i}const ra=n=>!Array.isArray(n);class uS{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(e){return this._cache.has(e)}get(e){const t=this._cache.get(e);return t||console.warn(`[Assets] Asset id ${e} was not found in the Cache`),t}set(e,t){const i=ui(e);let r;for(let a=0;a<this.parsers.length;a++){const l=this.parsers[a];if(l.test(t)){r=l.getCacheableAssets(i,t);break}}r||(r={},i.forEach(a=>{r[a]=t}));const s=Object.keys(r),o={cacheKeys:s,keys:i};if(i.forEach(a=>{this._cacheMap.set(a,o)}),s.forEach(a=>{const l=r?r[a]:t;this._cache.has(a)&&this._cache.get(a)!==l&&console.warn("[Cache] already has key:",a),this._cache.set(a,r[a])}),t instanceof xe){const a=t;i.forEach(l=>{a.baseTexture!==xe.EMPTY.baseTexture&&Le.addToCache(a.baseTexture,l),xe.addToCache(a,l)})}}remove(e){if(!this._cacheMap.has(e)){console.warn(`[Assets] Asset id ${e} was not found in the Cache`);return}const t=this._cacheMap.get(e);t.cacheKeys.forEach(i=>{this._cache.delete(i)}),t.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}}const Mn=new uS;class cS{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(e,t,i)=>(this._parsersValidated=!1,e[t]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(e,t){const i={promise:null,parser:null};return i.promise=(async()=>{var r,s;let o=null,a=null;if(t.loadParser&&(a=this._parserHash[t.loadParser],a||console.warn(`[Assets] specified load parser "${t.loadParser}" not found while loading ${e}`)),!a){for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];if(h.load&&(r=h.test)!=null&&r.call(h,e,t,this)){a=h;break}}if(!a)return console.warn(`[Assets] ${e} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}o=await a.load(e,t,this),i.parser=a;for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];h.parse&&h.parse&&await((s=h.testParse)==null?void 0:s.call(h,o,t,this))&&(o=await h.parse(o,t,this)||o,i.parser=h)}return o})(),i}async load(e,t){this._parsersValidated||this._validateParsers();let i=0;const r={},s=ra(e),o=ui(e,h=>({alias:[h],src:h})),a=o.length,l=o.map(async h=>{const u=Tt.toAbsolute(h.src);if(!r[h.src])try{this.promiseCache[u]||(this.promiseCache[u]=this._getLoadPromiseAndParser(u,h)),r[h.src]=await this.promiseCache[u].promise,t&&t(++i/a)}catch(c){throw delete this.promiseCache[u],delete r[h.src],new Error(`[Loader.load] Failed to load ${u}. 936${c}`)}});return await Promise.all(l),s?r[o[0].src]:r}async unload(e){const t=ui(e,i=>({alias:[i],src:i})).map(async i=>{var r,s;const o=Tt.toAbsolute(i.src),a=this.promiseCache[o];if(a){const l=await a.promise;delete this.promiseCache[o],(s=(r=a.parser)==null?void 0:r.unload)==null||s.call(r,l,i,this)}});await Promise.all(t)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(e=>e.name).reduce((e,t)=>
936(e[t.name]&&console.warn(`[Assets] loadParser name conflict "${t.name}"`),{...e,[t.name]:t}),{})}}var mi=(n=>(n[n.Low=0]="Low",n[n.Normal=1]="Normal",n[n.High=2]="High",n))(mi||{});const dS=".json",fS="application/json",pS={extension:{type:ue.LoadParser,priority:mi.Low},name:"loadJson",test(n){return Wr(n,fS)||xn(n,dS)},async load(n){return await(await pe.ADAPTER.fetch(n)).json()}};_e.add(pS);const gS=".txt",mS="text/plain",vS={name:"loadTxt",extension:{type:ue.LoadParser,priority:mi.Low},test(n){return Wr(n,mS)||xn(n,gS)},async load(n){return await(await pe.ADAPTER.fetch(n)).text()}};_e.add(vS);const yS=["normal","bold","100","200","300","400","500","600","700","800","900"],xS=[".ttf",".otf",".woff",".woff2"],_S=["font/ttf","font/otf","font/woff","font/woff2"],wS=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function TS(n){const e=Tt.extname(n),t=Tt.basename(n,e).replace(/(-|_)/g," ").toLowerCase().split(" ").map(s=>s.charAt(0).toUpperCase()+s.slice(1));let i=t.length>0;for(const s of t)if(!s.match(wS)){i=!1;break}let r=t.join(" ");return i||(r=`"${r.replace(/[\\"]/g,"\\$&")}"`),r}const ES=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function bS(n){return ES.test(n)?n:encodeURI(n)}const SS={extension:{type:ue.LoadParser,priority:mi.Low},name:"loadWebFont",test(n){return Wr(n,_S)||xn(n,xS)},async load(n,e){var t,i,r;const s=pe.ADAPTER.getFontFaceSet();if(s){const o=[],a=((t=e.data)==null?void 0:t.family)??TS(n),l=((r=(i=e.data)==null?void 0:i.weights)==null?void 0:r.filter(u=>yS.includes(u)))??["normal"],h=e.data??{};for(let u=0;u<l.length;u++){const c=l[u],d=new FontFace(a,`url(${bS(n)})`,{...h,weight:c});await d.load(),s.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(n){(Array.isArray(n)?n:[n]).forEach(e=>pe.ADAPTER.getFontFaceSet().delete(e))}};_e.add(SS);const AS=`(function() { 937 "use strict"; 938 const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII="; 939 async function checkImageBitmap() { 940 try { 941 if (typeof createImageBitmap != "function") 942 return !1; 943 const imageBlob = await (await fetch(WHITE_PNG)).blob(), imageBitmap = await createImageBitmap(imageBlob); 944 return imageBitmap.width === 1 && imageBitmap.height === 1; 945 } catch { 946 return !1; 947 } 948 } 949 checkImageBitmap().then((result) => { 950 self.postMessage(result); 951 }); 952})(); 953`;let Rr=null,Bh=class{constructor(){Rr||(Rr=URL.createObjectURL(new Blob([AS],{type:"application/javascript"}))),this.worker=new Worker(Rr)}};Bh.revokeObjectURL=function(){Rr&&(URL.revokeObjectURL(Rr),Rr=null)};const RS=`(function() { 954 "use strict"; 955 async function loadImageBitmap(url) { 956 const response = await fetch(url); 957 if (!response.ok) 958 throw new Error(\`[WorkerManager.loadImageBitmap] Failed to fetch \${url}: \${response.status} \${response.statusText}\`); 959 const imageBlob = await response.blob(); 960 return await createImageBitmap(imageBlob); 961 } 962 self.onmessage = async (event) => { 963 try { 964 const imageBitmap = await loadImageBitmap(event.data.data[0]); 965 self.postMessage({ 966 data: imageBitmap, 967 uuid: event.data.uuid, 968 id: event.data.id 969 }, [imageBitmap]); 970 } catch (e) { 971 self.postMessage({ 972 error: e, 973 uuid: event.data.uuid, 974 id: event.data.id 975 }); 976 } 977 }; 978})(); 979`;let Pr=null;class Rm{constructor(){Pr||(Pr=URL.createObjectURL(new Blob([RS],{type:"application/javascript"}))),this.worker=new Worker(Pr)}}Rm.revokeObjectURL=function(){Pr&&(URL.revokeObjectURL(Pr),Pr=null)};let Af=0,Ll;class PS{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(e=>{const{worker:t}=new Bh;t.addEventListener("message",i=>{t.terminate(),Bh.revokeObjectURL(),e(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(e){return this._run("loadImageBitmap",[e])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){Ll===void 0&&(Ll=navigator.hardwareConcurrency||4);let e=this.workerPool.pop();return!e&&this._createdWorkers<Ll&&(this._createdWorkers++,e=new Rm().worker,e.addEventListener("message",t=>{this.complete(t.data),this.returnWorker(t.target),this.next()})),e}returnWorker(e){this.workerPool.push(e)}complete(e){e.error!==void 0?this.resolveHash[e.uuid].reject(e.error):this.resolveHash[e.uuid].resolve(e.data),this.resolveHash[e.uuid]=null}async _run(e,t){await this._initWorkers();const i=new Promise((r,s)=>{this.queue.push({id:e,arguments:t,resolve:r,reject:s})});return this.next(),i}next(){if(!this.queue.length)return;const e=this.getWorker();if(!e)return;const t=this.queue.pop(),i=t.id;this.resolveHash[Af]={resolve:t.resolve,reject:t.reject},e.postMessage({data:t.arguments,uuid:Af++,id:i})}}const Rf=new PS;function Xs(n,e,t){n.resource.internal=!0;const i=new xe(n),r=()=>{delete e.promiseCache[t],Mn.has(t)&&Mn.remove(t)};return i.baseTexture.once("destroyed",()=>{t in e.promiseCache&&(console.warn("[Assets] A BaseTexture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the BaseTexture."),r())}),i.once("destroyed",()=>{n.destroyed||(console.warn("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),r())}),i}const CS=[".jpeg",".jpg",".png",".webp",".avif"],IS=["image/jpeg","image/png","image/webp","image/avif"];async function MS(n){const e=await pe.ADAPTER.fetch(n);if(!e.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${n}: ${e.status} ${e.statusText}`);const t=await e.blob();return await createImageBitmap(t)}
979const Ra={name:"loadTextures",extension:{type:ue.LoadParser,priority:mi.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(n){return Wr(n,IS)||xn(n,CS)},async load(n,e,t){var i;const r=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let s;r?this.config.preferWorkers&&await Rf.isImageBitmapSupported()?s=await Rf.loadImageBitmap(n):s=await MS(n):s=await new Promise((l,h)=>{const u=new Image;u.crossOrigin=this.config.crossOrigin,u.src=n,u.complete?l(u):(u.onload=()=>l(u),u.onerror=c=>h(c))});const o={...e.data};o.resolution??(o.resolution=ji(n)),r&&((i=o.resourceOptions)==null?void 0:i.ownsImageBitmap)===void 0&&(o.resourceOptions={...o.resourceOptions},o.resourceOptions.ownsImageBitmap=!0);const a=new Le(s,o);return a.resource.src=n,Xs(a,t,n)},unload(n){n.destroy(!0)}};_e.add(Ra);const DS=".svg",OS="image/svg+xml",LS={extension:{type:ue.LoadParser,priority:mi.High},name:"loadSVG",test(n){return Wr(n,OS)||xn(n,DS)},async testParse(n){return bh.test(n)},async parse(n,e,t){var i;const r=new bh(n,(i=e?.data)==null?void 0:i.resourceOptions);await r.load();const s=new Le(r,{resolution:ji(n),...e?.data});return s.resource.src=e.src,Xs(s,t,e.src)},async load(n,e){return(await pe.ADAPTER.fetch(n)).text()},unload:Ra.unload};_e.add(LS);const BS=[".mp4",".m4v",".webm",".ogv"],FS=["video/mp4","video/webm","video/ogg"],NS={name:"loadVideo",extension:{type:ue.LoadParser,priority:mi.High},config:{defaultAutoPlay:!0,defaultUpdateFPS:0,defaultLoop:!1,defaultMuted:!1,defaultPlaysinline:!0},test(n){return Wr(n,FS)||xn(n,BS)},async load(n,e,t){var i;let r;const s=await(await pe.ADAPTER.fetch(n)).blob(),o=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,...(i=e?.data)==null?void 0:i.resourceOptions,autoLoad:!0},l=new _m(o,a);await l.load();const h=new Le(l,{alphaMode:await VE(),resolution:ji(n),...e?.data});h.resource.src=n,r=Xs(h,t,n),r.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(o)})}catch(a){throw URL.revokeObjectURL(o),a}return r},unload(n){n.destroy(!0)}};_e.add(NS);class kS{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(e,t)=>`${e}${this._bundleIdConnector}${t}`,extractAssetIdFromBundle:(e,t)=>t.replace(`${e}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(e){if(this._bundleIdConnector=e.connector??this._bundleIdConnector,this._createBundleAssetId=e.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=e.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...e){e.forEach(t=>{this._preferredOrder.push(t),t.priority||(t.priority=Object.keys(t.params))}),this._resolverHash={}}set basePath(e){this._basePath=e}get basePath(){return this._basePath}set rootPath(e){this._rootPath=e}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(e){if(typeof e=="string")this._defaultSearchParams=e;else{const t=e;this._defaultSearchParams=Object.keys(t).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(t[i])}`).join("&")}}getAlias(e){const{alias:t,name:i,src:r,srcs:s}=e;return ui(t||i||r||s,o=>typeof o=="string"?o:Array.isArray(o)?o.map(a=>a?.src??a?.srcs??a):o!=null&&o.src||o!=null&&o.srcs?o.src??o.srcs:o,!0)}addManifest(e){this._manifest&&console.warn("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=e,e.bundles.forEac
979h(t=>{this.addBundle(t.name,t.assets)})}addBundle(e,t){const i=[];Array.isArray(t)?t.forEach(r=>{const s=r.src??r.srcs,o=r.alias??r.name;let a;if(typeof o=="string"){const l=this._createBundleAssetId(e,o);i.push(l),a=[o,l]}else{const l=o.map(h=>this._createBundleAssetId(e,h));i.push(...l),a=[...o,...l]}this.add({...r,alias:a,src:s})}):Object.keys(t).forEach(r=>{const s=[r,this._createBundleAssetId(e,r)];if(typeof t[r]=="string")this.add({alias:s,src:t[r]});else if(Array.isArray(t[r]))this.add({alias:s,src:t[r]});else{const o=t[r],a=o.src??o.srcs;this.add({...o,alias:s,src:Array.isArray(a)?a:[a]})}i.push(...s)}),this._bundles[e]=i}add(e,t,i,r,s){const o=[];typeof e=="string"||Array.isArray(e)&&typeof e[0]=="string"?(Ue("7.2.0",`Assets.add now uses an object instead of individual parameters. 980Please use Assets.add({ alias, src, data, format, loadParser }) instead.`),o.push({alias:e,src:t,data:i,format:r,loadParser:s})):Array.isArray(e)?o.push(...e):o.push(e);let a;a=l=>{this.hasKey(l)&&console.warn(`[Resolver] already has key: ${l} overwriting`)},ui(o).forEach(l=>{const{src:h,srcs:u}=l;let{data:c,format:d,loadParser:f}=l;const p=ui(h||u).map(m=>typeof m=="string"?hS(m):Array.isArray(m)?m:[m]),g=this.getAlias(l);Array.isArray(g)?g.forEach(a):a(g);const v=[];p.forEach(m=>{m.forEach(x=>{let y={};if(typeof x!="object"){y.src=x;for(let E=0;E<this._parsers.length;E++){const R=this._parsers[E];if(R.test(x)){y=R.parse(x);break}}}else c=x.data??c,d=x.format??d,f=x.loadParser??f,y={...y,...x};if(!g)throw new Error(`[Resolver] alias is undefined for this asset: ${y.src}`);y=this.buildResolvedAsset(y,{aliases:g,data:c,format:d,loadParser:f}),v.push(y)})}),g.forEach(m=>{this._assetMap[m]=v})})}resolveBundle(e){const t=ra(e);e=ui(e);const i={};return e.forEach(r=>{const s=this._bundles[r];if(s){const o=this.resolve(s),a={};for(const l in o){const h=o[l];a[this._extractAssetIdFromBundle(r,l)]=h}i[r]=a}}),t?i[e[0]]:i}resolveUrl(e){const t=this.resolve(e);if(typeof e!="string"){const i={};for(const r in t)i[r]=t[r].src;return i}return t.src}resolve(e){const t=ra(e);e=ui(e);const i={};return e.forEach(r=>{if(!this._resolverHash[r])if(this._assetMap[r]){let s=this._assetMap[r];const o=s[0],a=this._getPreferredOrder(s);a?.priority.forEach(l=>{a.params[l].forEach(h=>{const u=s.filter(c=>c[l]?c[l]===h:!1);u.length&&(s=u)})}),this._resolverHash[r]=s[0]??o}else this._resolverHash[r]=this.buildResolvedAsset({alias:[r],src:r},{});i[r]=this._resolverHash[r]}),t?i[e[0]]:i}hasKey(e){return!!this._assetMap[e]}hasBundle(e){return!!this._bundles[e]}_getPreferredOrder(e){for(let t=0;t<e.length;t++){const i=e[0],r=this._preferredOrder.find(s=>s.params.format.includes(i.format));if(r)return r}return this._preferredOrder[0]}_appendDefaultSearchParams(e){if(!this._defaultSearchParams)return e;const t=/\?/.test(e)?"&":"?";return`${e}${t}${this._defaultSearchParams}`}buildResolvedAsset(e,t){const{aliases:i,data:r,loadParser:s,format:o}=t;return(this._basePath||this._rootPath)&&(e.src=Tt.toAbsolute(e.src,this._basePath,this._rootPath)),e.alias=i??e.alias??[e.src],e.src=this._appendDefaultSearchParams(e.src),e.data={...r||{},...e.data},e.loadParser=s??e.loadParser,e.format=o??e.format??Tt.extname(e.src).slice(1),e.srcs=e.src,e.name=e.alias,e}}class US{constructor(){this._detections=[],this._initialized=!1,this.resolver=new kS,this.loader=new cS,this.cache=Mn,this._backgroundLoader=new lS(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(e={}){var t,i;if(this._initialized){console.warn("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,e.defaultSearchParams&&this.resolver.setDefaultSearchParams(e.defaultSearchParams),e.basePath&&(this.resolver.basePath=e.basePath),e.bundleIdentifier&&this.resolver.setBundleIdentifier(e.bundleIdentifier),e.manifest){let a=e.manifest;typeof a=="string"&&(a=await this.load(a)),this.resolver.addManifest(a)}const r=((t=e.texturePreference)==null?void 0:t.resolution)??1,s=typeof r=="number"?[r]:r,o=await this._detectFormats({preferredFormats:(i=e.texturePreference)==null?void 0:i.format,skipDetections:e.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:o,resolution:s}}),e.preferences&&this.setPreferences(e.preferences)}add(e,t,i,r,s){this.resolver.add(e,t,i,r,s)}async load(e,t){this._initialized||await this.init();const i=ra(e),r=ui(e).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}),s=this.resolver.resolve(r),o=await this._mapLoadToResolve(s,t);return i?o[r[0]]:o}
980addBundle(e,t){this.resolver.addBundle(e,t)}async loadBundle(e,t){this._initialized||await this.init();let i=!1;typeof e=="string"&&(i=!0,e=[e]);const r=this.resolver.resolveBundle(e),s={},o=Object.keys(r);let a=0,l=0;const h=()=>{t?.(++a/l)},u=o.map(c=>{const d=r[c];return l+=Object.keys(d).length,this._mapLoadToResolve(d,h).then(f=>{s[c]=f})});return await Promise.all(u),i?s[e[0]]:s}async backgroundLoad(e){this._initialized||await this.init(),typeof e=="string"&&(e=[e]);const t=this.resolver.resolve(e);this._backgroundLoader.add(Object.values(t))}async backgroundLoadBundle(e){this._initialized||await this.init(),typeof e=="string"&&(e=[e]);const t=this.resolver.resolveBundle(e);Object.values(t).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(e){if(typeof e=="string")return Mn.get(e);const t={};for(let i=0;i<e.length;i++)t[i]=Mn.get(e[i]);return t}async _mapLoadToResolve(e,t){const i=Object.values(e),r=Object.keys(e);this._backgroundLoader.active=!1;const s=await this.loader.load(i,t);this._backgroundLoader.active=!0;const o={};return i.forEach((a,l)=>{const h=s[a.src],u=[a.src];a.alias&&u.push(...a.alias),o[r[l]]=h,Mn.set(u,h)}),o}async unload(e){this._initialized||await this.init();const t=ui(e).map(r=>typeof r!="string"?r.src:r),i=this.resolver.resolve(t);await this._unloadFromResolved(i)}async unloadBundle(e){this._initialized||await this.init(),e=ui(e);const t=this.resolver.resolveBundle(e),i=Object.keys(t).map(r=>this._unloadFromResolved(t[r]));await Promise.all(i)}async _unloadFromResolved(e){const t=Object.values(e);t.forEach(i=>{Mn.remove(i.src)}),await this.loader.unload(t)}async _detectFormats(e){let t=[];e.preferredFormats&&(t=Array.isArray(e.preferredFormats)?e.preferredFormats:[e.preferredFormats]);for(const i of e.detections)e.skipDetections||await i.test()?t=await i.add(t):e.skipDetections||(t=await i.remove(t));return t=t.filter((i,r)=>t.indexOf(i)===r),t}get detections(){return this._detections}get preferWorkers(){return Ra.config.preferWorkers}set preferWorkers(e){Ue("7.2.0","Assets.prefersWorkers is deprecated, use Assets.setPreferences({ preferWorkers: true }) instead."),this.setPreferences({preferWorkers:e})}setPreferences(e){this.loader.parsers.forEach(t=>{t.config&&Object.keys(t.config).filter(i=>i in e).forEach(i=>{t.config[i]=e[i]})})}}const lo=new US;_e.handleByList(ue.LoadParser,lo.loader.parsers).handleByList(ue.ResolveParser,lo.resolver.parsers).handleByList(ue.Cac
980heParser,lo.cache.parsers).handleByList(ue.DetectionParser,lo.detections);const HS={extension:ue.CacheParser,test:n=>Array.isArray(n)&&n.every(e=>e instanceof xe),getCacheableAssets:(n,e)=>{const t={};return n.forEach(i=>{e.forEach((r,s)=>{t[i+(s===0?"":s+1)]=r})}),t}};_e.add(HS);async function Pm(n){if("Image"in globalThis)return new Promise(e=>{const t=new Image;t.onload=()=>{e(!0)},t.onerror=()=>{e(!1)},t.src=n});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const e=await(await fetch(n)).blob();await createImageBitmap(e)}catch{return!1}return!0}return!1}const GS={extension:{type:ue.DetectionParser,priority:1},test:async()=>Pm("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async n=>[...n,"avif"],remove:async n=>n.filter(e=>e!=="avif")};_e.add(GS);const zS={extension:{type:ue.DetectionParser,priority:0},test:async()=>Pm("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async n=>[...n,"webp"],remove:async n=>n.filter(e=>e!=="webp")};_e.add(zS);const Pf=["png","jpg","jpeg"],VS={extension:{type:ue.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async n=>[...n,...Pf],remove:async n=>n.filter(e=>!Pf.includes(e))};_e.add(VS);const jS="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function wu(n){return jS?!1:document.createElement("video").canPlayType(n)!==""}const XS={extension:{type:ue.DetectionParser,priority:0},test:async()=>wu("video/webm"),add:async n=>[...n,"webm"],remove:async n=>n.filter(e=>e!=="webm")};_e.add(XS);const WS={extension:{type:ue.DetectionParser,priority:0},test:async()=>wu("video/mp4"),add:async n=>[...n,"mp4","m4v"],remove:async n=>n.filter(e=>e!=="mp4"&&e!=="m4v")};_e.add(WS);const YS={extension:{type:ue.DetectionParser,priority:0},test:async()=>wu("video/ogg"),add:async n=>[...n,"ogv"],remove:async n=>n.filter(e=>e!=="ogv")};_e.add(YS);const qS={extension:ue.ResolveParser,test:Ra.test,parse:n=>{var e;return{resolution:parseFloat(((e=pe.RETINA_PREFIX.exec(n))==null?void 0:e[1])??"1"),format:Tt.extname(n).slice(1),src:n}}};_e.add(qS);var Rt=(n=>(n[n.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",n[n.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",n[n.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",n[n.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",n[n.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",n[n.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",n[n.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",n[n.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",n[n.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",n[n.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",n[n.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",n[n.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",n[n.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",n[n.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",n[n.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",n[n.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",n[n.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",n[n.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",n[n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",n[n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",n[n.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",n[n.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",n[n.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",n[n.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",n[n.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35987]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",n[n.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",n[n.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",n[n.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",n[n.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",n[n.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",n[n.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",n))(Rt||{});const sa={33776:.5,33777:.5,33778:1,33779:1,35916:.5,35917:.5,35918:1,35919:1,37488:.5,37489:.5,3749
9800: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 xi,fr;function Cf(){fr={bptc:xi.getExtension("EXT_texture_compression_bptc"),astc:xi.getExtension("WEBGL_compressed_texture_astc"),etc:xi.getExtension("WEBGL_compressed_texture_etc"),s3tc:xi.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:xi.getExtension("WEBGL_compressed_texture_s3tc_srgb"),pvrtc:xi.getExtension("WEBGL_compressed_texture_pvrtc")||xi.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:xi.getExtension("WEBGL_compressed_texture_etc1"),atc:xi.getExtension("WEBGL_compressed_texture_atc")}}const $S={extension:{type:ue.DetectionParser,priority:2},test:async()=>{const n=pe.ADAPTER.createCanvas().getContext("webgl");return n?(xi=n,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async n=>{fr||Cf();const e=[];for(const t in fr)fr[t]&&e.push(t);return[...e,...n]},remove:async n=>(fr||Cf(),n.filter(e=>!(e in fr)))};_e.add($S);class ZS extends Ta{constructor(e,t={width:1,height:1,autoLoad:!0}){let i,r;typeof e=="string"?(i=e,r=new Uint8Array):(i=null,r=e),super(r,t),this.origin=i,this.buffer=r?new ch(r):null,this._load=null,this.loaded=!1,this.origin!==null&&t.autoLoad!==!1&&this.load(),this.origin===null&&this.buffer&&(this._load=Promise.resolve(this),this.loaded=!0,this.onBlobLoaded(this.buffer.rawBinaryData))}onBlobLoaded(e){}load(){return this._load?this._load:(this._load=fetch(this.origin).then(e=>e.blob()).then(e=>e.arrayBuffer()).then(e=>(this.data=new Uint32Array(e),this.buffer=new ch(e),this.loaded=!0,this.onBlobLoaded(e),this.update(),this)),this._load)}}class Un extends ZS{constructor(e,t){super(e,t),this.format=t.format,this.levels=t.levels||1,this._width=t.width,this._height=t.height,this._extension=Un._formatToExtension(this.format),(t.levelBuffers||this.buffer)&&(this._levelBuffers=t.levelBuffers||Un._createLevelBuffers(e instanceof Uint8Array?e:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(e,t,i){const r=e.gl;if(!e.context.extensions[this._extension])throw new Error(`${this._extension} textures are not supported on the current machine`);if(!this._levelBuffers)return!1;r.pixelStorei(r.UNPACK_ALIGNMENT,4);for(let s=0,o=this.levels;s<o;s++){const{levelID:a,levelWidth:l,levelHeight:h,levelBuffer:u}=this._levelBuffers[s];r.compressedTexImage2D(r.TEXTURE_2D,a,this.format,l,h,0,u)}return!0}onBlobLoaded(){this._levelBuffers=Un._createLevelBuffers(this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height)}static _formatToExtension(e){if(e>=33776&&e<=33779)return"s3tc";if(e>=35916&&e<=35919)return"s3tc_sRGB";if(e>=37488&&e<=37497)return"etc";if(e>=35840&&e<=35843)return"pvrtc";if(e===36196)return"etc1";if(e===35986||e===35987||e===34798)return"atc";if(e>=36492&&e<=36495)return"bptc";if(e===37808)return"astc";throw new Error(`Invalid (compressed) texture format given: ${e}`)}static _createLevelBuffers(e,t,i,r,s,o,a){const l=new Array(i);let h=e.byteOffset,u=o,c=a,d=u+r-1&~(r-1),f=c+s-1&~(s-1),p=d*f*sa[t];for(let g=0;g<i;g++)l[g]={levelID:g,levelWidth:i>1?u:d,levelHeight:i>1?c:f,levelBuffer:new Uint8Array(e.buffer,h,p)},h+=p,u=u>>1||1,c=c>>1||1,d=u+r-1&~(r-1),f=c+s-1&~(s-1),p=d*f*sa[t];return l}}const Bl=4,ho=124,KS=32,If=20,JS=542327876,uo={HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},QS={FOURCC:2},co={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3},eA=1,tA=2,iA=4,nA=64,rA=512,sA=131072,oA=827611204,aA=861165636,lA=894720068,hA=808540228,uA=4,cA={[oA]:Rt.COMPRESSED_RGBA_S3TC_DXT1_EXT,[aA]:Rt.COMPRESSED_RGBA_S3TC_DXT3_EXT,[lA]:Rt.COMPRESSED_RGBA_S3TC_DXT5_EXT},dA={70:Rt.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:Rt.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:Rt.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:Rt.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:Rt.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:Rt.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:Rt.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:Rt.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:Rt.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,96:Rt.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,95:Rt.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,98:Rt.COMPRESSED_RGBA_BPTC_UNORM_EXT,99:Rt.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT};function fA(n){const e=new Uint32Array(n);if(e[0]!==JS)throw new Error("Invalid DDS file magic word");const t=new Uint32Array(n,0,ho/Uint32Array.BYTES_PER_ELEMENT),i=t[uo.HEIGHT],r=t[uo.WIDTH],s=t[uo.MIPMAP_COUNT],o=new Uint32Array(n,uo.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,KS/Uint32Array.BYTES_PER_ELEMENT),a=o[eA];if(a&iA){const l=o[QS.FOURCC];if(l!==hA){const x=cA[l],y=Bl+ho,E=new Uint8Array(n,y);return[new Un(E,{format:x,width:r,height:i,levels:s})]}const h=Bl+ho,u=new Uint32Array(e.buffer,h,If/Uint32Array.BYTES_PER_ELEMENT),c=u[co.DXGI_FORMAT],d=u[co.RESOURCE_DIMENSION],f=u[co.MISC_FLAG],p=u[co.ARRAY_SIZE],g=dA[c];if(g===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${c}`);if(f===uA)throw new Error("DDSParser does not support cubemap textures");if(d===6)throw new Error("DDSParser does not supported 3D texture data");const v=new Array,m=Bl+ho+If;if(p===1)v.push(new Uint8Array(n,m));else{const x=sa[g];let y=0,E=r,R=i;for(let S=0;S<s;S++){const L=Math.max(1,E+3&-4),k=Math.max(1,R+3&-4),W=L*k*x;y+=W,E=E>>>1,R=R>>>1}let P=m;for(let S=0;S<p;
980S++)v.push(new Uint8Array(n,P,y)),P+=y}return v.map(x=>new Un(x,{format:g,width:r,height:i,levels:s}))}throw a&nA?new Error("DDSParser does not support uncompressed texture data."):a&rA?new Error("DDSParser does not supported YUV uncompressed texture data."):a&sA?new Error("DDSParser does not support single-channel (lumninance) texture data!"):a&tA?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 Mf=[171,75,84,88,32,49,49,187,13,10,26,10],pA=67305985,ai={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},Fh=64,Df={[Ee.UNSIGNED_BYTE]:1,[Ee.UNSIGNED_SHORT]:2,[Ee.INT]:4,[Ee.UNSIGNED_INT]:4,[Ee.FLOAT]:4,[Ee.HALF_FLOAT]:8},gA={[oe.RGBA]:4,[oe.RGB]:3,[oe.RG]:2,[oe.RED]:1,[oe.LUMINANCE]:1,[oe.LUMINANCE_ALPHA]:2,[oe.ALPHA]:1},mA={[Ee.UNSIGNED_SHORT_4_4_4_4]:2,[Ee.UNSIGNED_SHORT_5_5_5_1]:2,[Ee.UNSIGNED_SHORT_5_6_5]:2};function vA(n,e,t=!1){const i=new DataView(e);if(!yA(n,i))return null;const r=i.getUint32(ai.ENDIANNESS,!0)===pA,s=i.getUint32(ai.GL_TYPE,r),o=i.getUint32(ai.GL_FORMAT,r),a=i.getUint32(ai.GL_INTERNAL_FORMAT,r),l=i.getUint32(ai.PIXEL_WIDTH,r),h=i.getUint32(ai.PIXEL_HEIGHT,r)||1,u=i.getUint32(ai.PIXEL_DEPTH,r)||1,c=i.getUint32(ai.NUMBER_OF_ARRAY_ELEMENTS,r)||1,d=i.getUint32(ai.NUMBER_OF_FACES,r),f=i.getUint32(ai.NUMBER_OF_MIPMAP_LEVELS,r),p=i.getUint32(ai.BYTES_OF_KEY_VALUE_DATA,r);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 g=4,v=4,m=l+3&-4,x=h+3&-4,y=new Array(c);let E=l*h;s===0&&(E=m*x);let R;if(s!==0?Df[s]?R=Df[s]*gA[o]:R=mA[s]:R=sa[a],R===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const P=t?_A(i,p,r):null;let S=E*R,L=l,k=h,W=m,j=x,V=Fh+p;for(let N=0;N<f;N++){const D=i.getUint32(V,r);let A=V+4;for(let O=0;O<c;O++){let B=y[O];B||(B=y[O]=new Array(f)),B[N]={levelID:N,levelWidth:f>1||s!==0?L:W,levelHeight:f>1||s!==0?k:j,levelBuffer:new Uint8Array(e,A,S)},A+=S}V+=D+4,V=V%4!==0?V+4-V%4:V,L=L>>1||1,k=k>>1||1,W=L+g-1&-4,j=k+v-1&-4,S=W*j*R}return s!==0?{uncompressed:y.map(N=>{let D=N[0].levelBuffer,A=!1;return s===Ee.FLOAT?D=new Float32Array(N[0].levelBuffer.buffer,N[0].levelBuffer.byteOffset,N[0].levelBuffer.byteLength/4):s===Ee.UNSIGNED_INT?(A=!0,D=new Uint32Array(N[0].levelBuffer.buffer,N[0].levelBuffer.byteOffset,N[0].levelBuffer.byteLength/4)):s===Ee.INT&&(A=!0,D=new Int32Array(N[0].levelBuffer.buffer,N[0].levelBuffer.byteOffset,N[0].levelBuffer.byteLength/4)),{resource:new Ta(D,{width:N[0].levelWidth,height:N[0].levelHeight}),type:s,format:A?xA(o):o}}),kvData:P}:{compressed:y.map(N=>new Un(null,{format:a,width:l,height:h,levels:f,levelBuffers:N})),kvData:P}}function yA(n,e){for(let t=0;t<Mf.length;t++)if(e.getUint8(t)!==Mf[t])return console.error(`${n} is not a valid *.ktx file!`),!1;return!0}function xA(n){switch(n){case oe.RGBA:return oe.RGBA_INTEGER;case oe.RGB:return oe.RGB_INTEGER;case oe.RG:return oe.RG_INTEGER;case oe.RED:return oe.RED_INTEGER;default:return n}}function _A(n,e,t){const i=new Map;let r=0;for(;r<e;){const s=n.getUint32(Fh+r,t),o=Fh+r+4,a=3-(s+3)%4;if(s===0||s>e-r){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let l=0;for(;l<s&&n.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(n.buffer,o,l)),u=new DataView(n.buffer,o+l+1,s-l-1);i.set(h,u),r+=4+s+a}return i}const wA={extension:{type:ue.LoadParser,priority:mi.High},name:"loadDDS",test(n){return xn(n,".dds")},async load(n,e,t){const i=await(await pe.ADAPTER.fetch(n)).arrayBuffer(),r=fA(i).map(s=>{const o=new Le(s,{mipmap:Mi.OFF,alphaMode:Ut.NO_PREMULTIPLIED_ALPHA,resolution:ji(n),...e.data});return Xs(o,t,n)});return r.length===1?r[0]:r}
980,unload(n){Array.isArray(n)?n.forEach(e=>e.destroy(!0)):n.destroy(!0)}};_e.add(wA);const TA={extension:{type:ue.LoadParser,priority:mi.High},name:"loadKTX",test(n){return xn(n,".ktx")},async load(n,e,t){const i=await(await pe.ADAPTER.fetch(n)).arrayBuffer(),{compressed:r,uncompressed:s,kvData:o}=vA(n,i),a=r??s,l={mipmap:Mi.OFF,alphaMode:Ut.NO_PREMULTIPLIED_ALPHA,resolution:ji(n),...e.data},h=a.map(u=>{a===s&&Object.assign(l,{type:u.type,format:u.format});const c=u.resource??u,d=new Le(c,l);return d.ktxKeyValueData=o,Xs(d,t,n)});return h.length===1?h[0]:h},unload(n){Array.isArray(n)?n.forEach(e=>e.destroy(!0)):n.destroy(!0)}};_e.add(TA);const EA=["s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"],bA={extension:ue.ResolveParser,test:n=>{const e=Tt.extname(n).slice(1);return["basis","ktx","dds"].includes(e)},parse:n=>{var e,t;const i=n.split("."),r=i.pop();if(["ktx","dds"].includes(r)){const s=i.pop();if(EA.includes(s))return{resolution:parseFloat(((e=pe.RETINA_PREFIX.exec(n))==null?void 0:e[1])??"1"),format:s,src:n}}return{resolution:parseFloat(((t=pe.RETINA_PREFIX.exec(n))==null?void 0:t[1])??"1"),format:r,src:n}}};_e.add(bA);const fo=new Fe,SA=4,Cm=class ls{constructor(e){this.renderer=e,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(e,t,i,r){const s=new Image;return s.src=await this.base64(e,t,i,r),s}async base64(e,t,i,r){const s=this.canvas(e,r);if(s.toBlob!==void 0)return new Promise((o,a)=>{s.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)},t,i)});if(s.toDataURL!==void 0)return s.toDataURL(t,i);if(s.convertToBlob!==void 0){const o=await s.convertToBlob({type:t,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(e,t){const{pixels:i,width:r,height:s,flipY:o,premultipliedAlpha:a}=this._rawPixels(e,t);o&&ls._flipY(i,r,s),a&&ls._unpremultiplyAlpha(i);const l=new sb(r,s,1),h=new ImageData(new Uint8ClampedArray(i.buffer),r,s);return l.context.putImageData(h,0,0),l.canvas}pixels(e,t){const{pixels:i,width:r,height:s,flipY:o,premultipliedAlpha:a}=this._rawPixels(e,t);return o&&ls._flipY(i,r,s),a&&ls._unpremultiplyAlpha(i),i}_rawPixels(e,t){const i=this.renderer;if(!i)throw new Error("The Extract has already been destroyed");let r,s=!1,o=!1,a,l=!1;e&&(e instanceof qn?a=e:(a=i.generateTexture(e,{region:t,resolution:i.resolution,multisample:i.multisample}),l=!0,t&&(fo.width=t.width,fo.height=t.height,t=fo)));const h=i.gl;if(a){if(r=a.baseTexture.resolution,t=t??a.frame,s=!1,o=a.baseTexture.alphaMode>0&&a.baseTexture.format===oe.RGBA,!l){i.renderTexture.bind(a);const f=a.framebuffer.glFramebuffers[i.CONTEXT_UID];f.blitFramebuffer&&i.framebuffer.bind(f.blitFramebuffer)}}else r=i.resolution,t||(t=fo,t.width=i.width/r,t.height=i.height/r),s=!0,o=this._rendererPremultipliedAlpha,i.renderTexture.bind();const u=Math.max(Math.round(t.width*r),1),c=Math.max(Math.round(t.height*r),1),d=new Uint8Array(SA*u*c);return h.readPixels(Math.round(t.x*r),Math.round(t.y*r),u,c,h.RGBA,h.UNSIGNED_BYTE,d),l&&a?.destroy(!0),{pixels:d,width:u,height:c,flipY:s,premultipliedAlpha:o}}destroy(){this.renderer=null}static _flipY(e,t,i){const r=t<<2,s=i>>1,o=new Uint8Array(r);for(let a=0;a<s;a++){const l=a*r,h=(i-a-1)*r;o.set(e.subarray(l,l+r)),e.copyWithin(l,h,h+r),e.set(o,h)}}static _unpremultiplyAlpha(e){e instanceof Uint8ClampedArray&&(e=new Uint8Array(e.buffer));const t=e.length;for(let i=0;i<t;i+=4){const r=e[i+3];if(r!==0){const s=255.001/r;e[i]=e[i]*s+.5,e[i+1]=e[i+1]*s+.5,e[i+2]=e[i+2]*s+.5}}}};Cm.extension={name:"extract",type:ue.RendererSystem};let AA=Cm;_e.add(AA);const oa={build(n){const e=n.points;let t,i,r,s,o,a;if(n.type===Pt.CIRC){const p=n.shape;t=p.x,i=p.y,o=a=p.radius,r=s=0}else if(n.type===Pt.ELIP){const p=n.shape;t=p.x,i=p.y,o=p.width,a=p.height,r=s=0}else{const p=n.shape,g=p.width/2,v=p.height/2;t=p.x+g,i=p.y+v,o=a=Math.max(0,Math.min(p.radius,Math.min(g,v))),r
980=g-o,s=v-a}if(!(o>=0&&a>=0&&r>=0&&s>=0)){e.length=0;return}const l=Math.ceil(2.3*Math.sqrt(o+a)),h=l*8+(r?4:0)+(s?4:0);if(e.length=h,h===0)return;if(l===0){e.length=8,e[0]=e[6]=t+r,e[1]=e[3]=i+s,e[2]=e[4]=t-r,e[5]=e[7]=i-s;return}let u=0,c=l*4+(r?2:0)+2,d=c,f=h;{const p=r+o,g=s,v=t+p,m=t-p,x=i+g;if(e[u++]=v,e[u++]=x,e[--c]=x,e[--c]=m,s){const y=i-g;e[d++]=m,e[d++]=y,e[--f]=y,e[--f]=v}}for(let p=1;p<l;p++){const g=Math.PI/2*(p/l),v=r+Math.cos(g)*o,m=s+Math.sin(g)*a,x=t+v,y=t-v,E=i+m,R=i-m;e[u++]=x,e[u++]=E,e[--c]=E,e[--c]=y,e[d++]=y,e[d++]=R,e[--f]=R,e[--f]=x}{const p=r,g=s+a,v=t+p,m=t-p,x=i+g,y=i-g;e[u++]=v,e[u++]=x,e[--f]=y,e[--f]=v,r&&(e[u++]=m,e[u++]=x,e[--f]=y,e[--f]=m)}},triangulate(n,e){const t=n.points,i=e.points,r=e.indices;if(t.length===0)return;let s=i.length/2;const o=s;let a,l;if(n.type!==Pt.RREC){const u=n.shape;a=u.x,l=u.y}else{const u=n.shape;a=u.x+u.width/2,l=u.y+u.height/2}const h=n.matrix;i.push(n.matrix?h.a*a+h.c*l+h.tx:a,n.matrix?h.b*a+h.d*l+h.ty:l),s++,i.push(t[0],t[1]);for(let u=2;u<t.length;u+=2)i.push(t[u],t[u+1]),r.push(s++,o,s);r.push(o+1,o,s)}};function Of(n,e=!1){const t=n.length;if(t<6)return;let i=0;for(let r=0,s=n[t-2],o=n[t-1];r<t;r+=2){const a=n[r],l=n[r+1];i+=(a-s)*(l+o),s=a,o=l}if(!e&&i>0||e&&i<=0){const r=t/2;for(let s=r+r%2;s<t;s+=2){const o=t-s-2,a=t-s-1,l=s,h=s+1;[n[o],n[l]]=[n[l],n[o]],[n[a],n[h]]=[n[h],n[a]]}}}const Im={build(n){n.points=n.shape.points.slice()},triangulate(n,e){let t=n.points;const i=n.holes,r=e.points,s=e.indices;if(t.length>=6){Of(t,!1);const o=[];for(let h=0;h<i.length;h++){const u=i[h];Of(u.points,!0),o.push(t.length/2),t=t.concat(u.points)}const a=vT(t,o,2);if(!a)return;const l=r.length/2;for(let h=0;h<a.length;h+=3)s.push(a[h]+l),s.push(a[h+1]+l),s.push(a[h+2]+l);for(let h=0;h<t.length;h++)r.push(t[h])}}},RA={build(n){const e=n.shape,t=e.x,i=e.y,r=e.width,s=e.height,o=n.points;o.length=0,r>=0&&s>=0&&o.push(t,i,t+r,i,t+r,i+s,t,i+s)},triangulate(n,e){const t=n.points,i=e.points;if(t.length===0)return;const r=i.length/2;i.push(t[0],t[1],t[2],t[3],t[6],t[7],t[4],t[5]),e.indices.push(r,r+1,r+2,r+1,r+2,r+3)}},PA={build(n){oa.build(n)},triangulate(n,e){oa.triangulate(n,e)}};var qt=(n=>(n.MITER="miter",n.BEVEL="bevel",n.ROUND="round",n))(qt||{}),sn=(n=>(n.BUTT="butt",n.ROUND="round",n.SQUARE="square",n))(sn||{});const Br={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(n,e=20){if(!this.adaptive||!n||isNaN(n))return e;let t=Math.ceil(n/this.maxLength);return t<this.minSegments?t=this.minSegments:t>this.maxSegments&&(t=this.maxSegments),t}};class Lf{static curveTo(e,t,i,r,s,o){const a=o[o.length-2],l=o[o.length-1]-t,h=a-e,u=r-t,c=i-e,d=Math.abs(l*c-h*u);if(d<1e-8||s===0)return(o[o.length-2]!==e||o[o.length-1]!==t)&&o.push(e,t),null;const f=l*l+h*h,p=u*u+c*c,g=l*u+h*c,v=s*Math.sqrt(f)/d,m=s*Math.sqrt(p)/d,x=v*g/f,y=m*g/p,E=v*c+m*h,R=v*u+m*l,P=h*(m+x),S=l*(m+x),L=c*(v+y),k=u*(v+y),W=Math.atan2(S-R,P-E),j=Math.atan2(k-R,L-E);return{cx:E+e,cy:R+t,radius:s,startAngle:W,endAngle:j,anticlockwise:h*u>c*l}}static arc(e,t,i,r,s,o,a,l,h){const u=a-o,c=Br._segmentsCount(Math.abs(u)*s,Math.ceil(Math.abs(u)/Ko)*40),d=u/(c*2),f=d*2,p=Math.cos(d),g=Math.sin(d),v=c-1,m=v%1/v;for(let x=0;x<=v;++x){const y=x+m*x,E=d+o+f*y,R=Math.cos(E),P=-Math.sin(E);h.push((p*R+g*P)*s+i,(p*-P+g*R)*s+r)}}}class CA{constructor(){this.reset()}begin(e,t,i){this.reset(),this.style=e,this.start=t,this.attribStart=i}end(e,t){this.attribSize=t-this.attribStart,this.size=e-this.start}reset(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0}}class Tu{static curveLength(e,t,i,r,s,o,a,l){let h=0,u=0,c=0,d=0,f=0,p=0,g=0,v=0,m=0,x=0,y=0,E=e,R=t;for(let P=1;P<=10;++P)u=P/10,c=u*u,d=c*u,f=1-u,p=f*f,g=p*f,v=g*e+3*p*u*i+3*f*c*s+d*a,m=g*t+3*p*u*r+3*f*c*o+d*l,x=E-v,y=R-m,E=v,R=m,h+=Math.sqrt(x*x+y*y);return h}static curveTo(e,t,i,r,s,o,a){const l=a[a.length-2],h=a[a.length-1];a.length-=2;const u=Br._segmentsCount(Tu.curveLength(l,h,e,t,i,r,s,o));let c=0,d=0,f=0,p=0,g=0;a.push(l,h);for(let v=1,m=0;v<=u;++v)m=v/u,c=1-m,d=c*c,f=d*c,p=m*m,g=p*m,a.push(f*l+3*d*m*e+3*c*p*i+g*s,f*
980h+3*d*m*t+3*c*p*r+g*o)}}function Bf(n,e,t,i,r,s,o,a){const l=n-t*r,h=e-i*r,u=n+t*s,c=e+i*s;let d,f;o?(d=i,f=-t):(d=-i,f=t);const p=l+d,g=h+f,v=u+d,m=c+f;return a.push(p,g,v,m),2}function Tn(n,e,t,i,r,s,o,a){const l=t-n,h=i-e;let u=Math.atan2(l,h),c=Math.atan2(r-n,s-e);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),g=Math.sqrt(l*l+h*h),v=(15*p*Math.sqrt(g)/Math.PI>>0)+1,m=f/v;if(d+=m,a){o.push(n,e,t,i);for(let x=1,y=d;x<v;x++,y+=m)o.push(n,e,n+Math.sin(y)*g,e+Math.cos(y)*g);o.push(n,e,r,s)}else{o.push(t,i,n,e);for(let x=1,y=d;x<v;x++,y+=m)o.push(n+Math.sin(y)*g,e+Math.cos(y)*g,n,e);o.push(r,s,n,e)}return v*2}function IA(n,e){const t=n.shape;let i=n.points||t.points.slice();const r=e.closePointEps;if(i.length===0)return;const s=n.lineStyle,o=new ze(i[0],i[1]),a=new ze(i[i.length-2],i[i.length-1]),l=t.type!==Pt.POLY||t.closeStroke,h=Math.abs(o.x-a.x)<r&&Math.abs(o.y-a.y)<r;if(l){i=i.slice(),h&&(i.pop(),i.pop(),a.set(i[i.length-2],i[i.length-1]));const B=(o.x+a.x)*.5,G=(a.y+o.y)*.5;i.unshift(B,G),i.push(B,G)}const u=e.points,c=i.length/2;let d=i.length;const f=u.length/2,p=s.width/2,g=p*p,v=s.miterLimit*s.miterLimit;let m=i[0],x=i[1],y=i[2],E=i[3],R=0,P=0,S=-(x-E),L=m-y,k=0,W=0,j=Math.sqrt(S*S+L*L);S/=j,L/=j,S*=p,L*=p;const V=s.alignment,N=(1-V)*2,D=V*2;l||(s.cap===sn.ROUND?d+=Tn(m-S*(N-D)*.5,x-L*(N-D)*.5,m-S*N,x-L*N,m+S*D,x+L*D,u,!0)+2:s.cap===sn.SQUARE&&(d+=Bf(m,x,S,L,N,D,!0,u))),u.push(m-S*N,x-L*N,m+S*D,x+L*D);for(let B=1;B<c-1;++B){m=i[(B-1)*2],x=i[(B-1)*2+1],y=i[B*2],E=i[B*2+1],R=i[(B+1)*2],P=i[(B+1)*2+1],S=-(x-E),L=m-y,j=Math.sqrt(S*S+L*L),S/=j,L/=j,S*=p,L*=p,k=-(E-P),W=y-R,j=Math.sqrt(k*k+W*W),k/=j,W/=j,k*=p,W*=p;const G=y-m,Y=x-E,z=y-R,b=P-E,H=G*z+Y*b,X=Y*z-b*G,$=X<0;if(Math.abs(X)<.001*Math.abs(H)){u.push(y-S*N,E-L*N,y+S*D,E+L*D),H>=0&&(s.join===qt.ROUND?d+=Tn(y,E,y-S*N,E-L*N,y-k*N,E-W*N,u,!1)+4:d+=2,u.push(y-k*D,E-W*D,y+k*N,E+W*N));continue}const re=(-S+m)*(-L+E)-(-S+y)*(-L+x),se=(-k+R)*(-W+E)-(-k+y)*(-W+P),ce=(G*se-z*re)/X,ie=(b*re-Y*se)/X,ge=(ce-y)*(ce-y)+(ie-E)*(ie-E),de=y+(ce-y)*N,Te=E+(ie-E)*N,me=y-(ce-y)*D,De=E-(ie-E)
980*D,it=Math.min(G*G+Y*Y,z*z+b*b),Je=$?N:D,ht=it+Je*Je*g,w=ge<=ht;let I=s.join;if(I===qt.MITER&&ge/g>v&&(I=qt.BEVEL),w)switch(I){case qt.MITER:{u.push(de,Te,me,De);break}case qt.BEVEL:{$?u.push(de,Te,y+S*D,E+L*D,de,Te,y+k*D,E+W*D):u.push(y-S*N,E-L*N,me,De,y-k*N,E-W*N,me,De),d+=2;break}case qt.ROUND:{$?(u.push(de,Te,y+S*D,E+L*D),d+=Tn(y,E,y+S*D,E+L*D,y+k*D,E+W*D,u,!0)+4,u.push(de,Te,y+k*D,E+W*D)):(u.push(y-S*N,E-L*N,me,De),d+=Tn(y,E,y-S*N,E-L*N,y-k*N,E-W*N,u,!1)+4,u.push(y-k*N,E-W*N,me,De));break}}else{switch(u.push(y-S*N,E-L*N,y+S*D,E+L*D),I){case qt.MITER:{$?u.push(me,De,me,De):u.push(de,Te,de,Te),d+=2;break}case qt.ROUND:{$?d+=Tn(y,E,y+S*D,E+L*D,y+k*D,E+W*D,u,!0)+2:d+=Tn(y,E,y-S*N,E-L*N,y-k*N,E-W*N,u,!1)+2;break}}u.push(y-k*N,E-W*N,y+k*D,E+W*D),d+=2}}m=i[(c-2)*2],x=i[(c-2)*2+1],y=i[(c-1)*2],E=i[(c-1)*2+1],S=-(x-E),L=m-y,j=Math.sqrt(S*S+L*L),S/=j,L/=j,S*=p,L*=p,u.push(y-S*N,E-L*N,y+S*D,E+L*D),l||(s.cap===sn.ROUND?d+=Tn(y-S*(N-D)*.5,E-L*(N-D)*.5,y-S*N,E-L*N,y+S*D,E+L*D,u,!1)+2:s.cap===sn.SQUARE&&(d+=Bf(y,E,S,L,N,D,!1,u)));const A=e.indices,O=Br.epsilon*Br.epsilon;for(let B=f;B<d+f-2;++B)m=u[B*2],x=u[B*2+1],y=u[(B+1)*2],E=u[(B+1)*2+1],R=u[(B+2)*2],P=u[(B+2)*2+1],!(Math.abs(m*(E-P)+y*(P-x)+R*(x-E))<O)&&A.push(B,B+1,B+2)}function MA(n,e){let t=0;const i=n.shape,r=n.points||i.points,s=i.type!==Pt.POLY||i.closeStroke;if(r.length===0)return;const o=e.points,a=e.indices,l=r.length/2,h=o.length/2;let u=h;for(o.push(r[0],r[1]),t=1;t<l;t++)o.push(r[t*2],r[t*2+1]),a.push(u,u+1),u++;s&&a.push(u,h)}function Ff(n,e){n.lineStyle.native?MA(n,e):IA(n,e)}class Eu{static curveLength(e,t,i,r,s,o){const a=e-2*i+s,l=t-2*r+o,h=2*i-2*e,u=2*r-2*t,c=4*(a*a+l*l),d=4*(a*h+l*u),f=h*h+u*u,p=2*Math.sqrt(c+d+f),g=Math.sqrt(c),v=2*c*g,m=2*Math.sqrt(f),x=d/g;return(v*p+g*d*(p-m)+(4*f*c-d*d)*Math.log((2*g+x+p)/(x+m)))/(4*v)}static curveTo(e,t,i,r,s){const o=s[s.length-2],a=s[s.length-1],l=Br._segmentsCount(Eu.curveLength(o,a,e,t,i,r));let h=0,u=0;for(let c=1;c<=l;++c){const d=c/l;h=o+(e-o)*d,u=a+(t-a)*d,s.push(h+(e+(i-e)*d-h)*d,u+(t+(r-t)*d-u)*d)}}}const Fl={[Pt.POLY]:Im,[Pt.CIRC]:oa,[Pt.ELIP]:oa,[Pt.RECT]:RA,[Pt.RREC]:PA},Nf=[],po=[];class aa{constructor(e,t=null,i=null,r=null){this.points=[],this.holes=[],this.shape=e,this.lineStyle=i,this.fillStyle=t,this.matrix=r,this.type=e.type}clone(){return new aa(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 rr=new ze,Mm=class Dm extends Fg{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 ia,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 e=0;e<this.drawCalls.length;e++)this.drawCalls[e].texArray.clear(),po.push(this.drawCalls[e]);this.drawCalls.length=0;for(let e=0;e<this.batches.length;e++){const t=this.batches[e];t.reset(),Nf.push(t)}this.batches.length=0}clear(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(e,t=null,i=null,r=null){const s=new aa(e,t,i,r);return this.graphicsData.push(s),this.dirty++,this}drawHole(e,t=null){if(!this.graphicsData.length)return null;const i=new aa(e,null,null,t),r=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=r.lineStyle,r.holes.push(i),this.dirty++,this}destroy(){super.destroy();for(let e=0;e<this.graphicsData.length;++e)this.graphicsData[e].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(e){const t=this.graphicsData;for(let i=0;i<t.length;++i){const r=t[i];if(r.fillStyle.visible&&r.shape&&(r.matrix?r.matrix.applyInverse(e,rr):rr.copyFrom(e),r.shape.contains(rr.x,rr.y))){let s=!1;if(r.holes){for(let o=0;o<r.holes.length;o++)if(r.holes[o].shape.contains(rr.x,rr.y)){s=!0;break}}if(!s)return!0}}return!1}updateBatches(){if(!this.graphicsData.length){this.batchable=!0;return}if(!this.validateBatching())return;this.cacheDirty=this.dirty;const e=this.uvs,t=this.graphicsData;let i=null,r=null;this.batches.length>0&&(i=this.batches[this.batches.length-1],r=i.style);for(let l=this.shapeIndex;l<t.length;l++){this.shapeIndex++;const h=t[l],u=h.fillStyle,c=h.lineStyle;Fl[h.type].build(h),h.matrix&&this.transformPoints(h.points,h.matrix
980),(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,g=this.indices.length,v=this.points.length/2;p.wrapMode=ln.REPEAT,d===0?this.processFill(h):this.processLine(h);const m=this.points.length/2-v;m!==0&&(i&&!this._compareStyles(r,f)&&(i.end(g,v),i=null),i||(i=Nf.pop()||new CA,i.begin(f,g,v),this.batches.push(i),r=f),this.addUvs(this.points,e,f.texture,v,m,f.matrix))}}const s=this.indices.length,o=this.points.length/2;if(i&&i.end(s,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(e,t){return!(!e||!t||e.texture.baseTexture!==t.texture.baseTexture||e.color+e.alpha!==t.color+t.alpha||!!e.native!=!!t.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let e=0,t=this.graphicsData.length;e<t;e++){const i=this.graphicsData[e],r=i.fillStyle,s=i.lineStyle;if(r&&!r.texture.baseTexture.valid||s&&!s.texture.baseTexture.valid)return!1}return!0}packBatches(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);const e=this.batches;for(let t=0,i=e.length;t<i;t++){const r=e[t];for(let s=0;s<r.size;s++){const o=r.start+s;this.indicesUint16[o]=this.indicesUint16[o]-r.attribStart}}}isBatchable(){if(this.points.length>65535*2)return!1;const e=this.batches;for(let t=0;t<e.length;t++)if(e[t].style.native)return!1;return this.points.length<Dm.BATCHABLE_SIZE*2}buildDrawCalls(){let e=++Le._globalBatch;for(let c=0;c<this.drawCalls.length;c++)this.drawCalls[c].texArray.clear(),po.push(this.drawCalls[c]);this.drawCalls.length=0;const t=this.colors,i=this.textureIds;let r=po.pop();r||(r=new ph,r.texArray=new yh),r.texArray.count=0,r.start=0,r.size=0,r.type=bi.TRIANGLES;let s=0,o=null,a=0,l=!1,h=bi.TRIANGLES,u=0;this.drawCalls.push(r);for(let c=0;c<this.batches.length;c++){const d=this.batches[c],f=8,p=d.style,g=p.texture.baseTexture;l!==!!p.native&&(l=!!p.native,h=l?bi.LINES:bi.TRIANGLES,o=null,s=f,e++),o!==g&&(o=g,g._batchEnabled!==e&&(s===f&&(e++,s=0,r.size>0&&(r=po.pop(),r||(r=new ph,r.texArray=new yh),this.drawCalls.push(r)),r.start=u,r.size=0,r.texArray.count=0,r.type=h),g.touched=1,g._batchEnabled=e,g._batchLocation=s,g.wrapMode=ln.REPEAT,r.texArray.elements[r.texArray.count++]=g,s++)),r.size+=d.size,u+=d.size,a=g._batchLocation,this.addColors(t,p.color,p.alpha,d.attribSize,d.attribStart),this.addTextureIds(i,a,d.attribSize,d.attribStart)}Le._globalBatch=e,this.packAttributes()}packAttributes(){const e=this.points,t=this.uvs,i=this.colors,r=this.textureIds,s=new ArrayBuffer(e.length*3*4),o=new Float32Array(s),a=new Uint32Array(s);let l=0;for(let h=0;h<e.length/2;h++)o[l++]=e[h*2],o[l++]=e[h*2+1],o[l++]=t[h*2],o[l++]=t[h*2+1],a[l++]=i[h],o[l++]=r[h];this._buffer.update(s),this._indexBuffer.update(this.indicesUint16)}processFill(e){e.holes.length?Im.triangulate(e,this):Fl[e.type].triangulate(e,this)}processLine(e){Ff(e,this);for(let t=0;t<e.holes.length;t++)Ff(e.holes[t],this)}processHoles(e){for(let t=0;t<e.length;t++){const i=e[t];Fl[i.type].build(i),i.matrix&&this.transformPoints(i.points,i.matrix)}}calculateBounds(){const e=this._bounds;e.clear(),e.addVertexData(this.points,0,this.points.length),e.pad(this.boundsPadding,this.boundsPadding)}transformPoints(e,t){for(let i=0;i<e.length/2;i++){const r=e[i*2],s=e[i*2+1];e[i*2]=t.a*r+t.c*s+t.tx,e[i*2+1]=t.b*r+t.d*s+t.ty}}addColors(e,t,i,r,s=0){const o=Ze.shared.setValue(t).toLittleEndianNumber(),a=Ze.shared.setValue(o).toPremultiplied(i);e.length=Math.max(e.length,s+r);for(let l=0;l<r;l++)e[s+l]=a}addTextureIds(e,t,i,r=0){e.length=Math.max(e.length,r+i);for(let s=0;s<i;s++)e[r+s]=t}addUvs(e,t,i,r,s,o=null){let a=0;const l=t.length,h=i.frame;for(;a<s;){let c=e[(r+a)*2],d=e[(r+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++,t.push(c/h.width,d/h.height)}const u=i.baseTexture;(h.width<u.width||h.height<u.height)&&this.adjustUvs(t,i,l,s)}adjustUvs(e,t,i,r){const s=t.baseTexture,o=1e-6,a=i+r*2,l=t.frame,h=l.width/s.width,u=l.height/s.height;
980let c=l.x/l.width,d=l.y/l.height,f=Math.floor(e[i]+o),p=Math.floor(e[i+1]+o);for(let g=i+2;g<a;g+=2)f=Math.min(f,Math.floor(e[g]+o)),p=Math.min(p,Math.floor(e[g+1]+o));c-=f,d-=p;for(let g=i;g<a;g+=2)e[g]=(e[g]+c)*h,e[g+1]=(e[g+1]+d)*u}};Mm.BATCHABLE_SIZE=100;let DA=Mm;class Pa{constructor(){this.color=16777215,this.alpha=1,this.texture=xe.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const e=new Pa;return e.color=this.color,e.alpha=this.alpha,e.texture=this.texture,e.matrix=this.matrix,e.visible=this.visible,e}reset(){this.color=16777215,this.alpha=1,this.texture=xe.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class bu extends Pa{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=sn.BUTT,this.join=qt.MITER,this.miterLimit=10}clone(){const e=new bu;return e.color=this.color,e.alpha=this.alpha,e.texture=this.texture,e.matrix=this.matrix,e.visible=this.visible,e.width=this.width,e.alignment=this.alignment,e.native=this.native,e.cap=this.cap,e.join=this.join,e.miterLimit=this.miterLimit,e}reset(){super.reset(),this.color=0,this.alignment=.5,this.width=0,this.native=!1,this.cap=sn.BUTT,this.join=qt.MITER,this.miterLimit=10}}const Nl={},Nh=class Do extends gi{constructor(e=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 Pa,this._lineStyle=new bu,this._matrix=null,this._holeMode=!1,this.state=Di.for2d(),this._geometry=e||new DA,this._geometry.refCount++,this._transformID=-1,this._tintColor=new Ze(16777215),this.blendMode=Ce.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new Do(this._geometry)}set blendMode(e){this.state.blendMode=e}get blendMode(){return this.state.blendMode}get tint(){return this._tintColor.value}set tint(e){this._tintColor.setValue(e)}get fill(){return this._fillStyle}get line(){return this._lineStyle}lineStyle(e=null,t=0,i,r=.5,s=!1){return typeof e=="number"&&(e={width:e,color:t,alpha:i,alignment:r,native:s}),this.lineTextureStyle(e)}lineTextureStyle(e){const t={width:0,texture:xe.WHITE,color:e!=null&&e.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:sn.BUTT,join:qt.MITER,miterLimit:10};e=Object.assign(t,e),this.normalizeColor(e),this.currentPath&&this.startPoly();const i=e.width>0&&e.alpha>0;return i?(e.matrix&&(e.matrix=e.matrix.clone(),e.matrix.invert()),Object.assign(this._lineStyle,{visible:i},e)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const e=this.currentPath.points,t=this.currentPath.points.length;t>2&&(this.drawShape(this.currentPath),this.currentPath=new kn,this.currentPath.closeStroke=!1,this.currentPath.points.push(e[t-2],e[t-1]))}else this.currentPath=new kn,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(e,t){return this.startPoly(),this.currentPath.points[0]=e,this.currentPath.points[1]=t,this}lineTo(e,t){this.currentPath||this.moveTo(0,0);const i=this.currentPath.points,r=i[i.length-2],s=i[i.length-1];return(r!==e||s!==t)&&i.push(e,t),this}_initCurve(e=0,t=0){this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[e,t]):this.moveTo(e,t)}quadraticCurveTo(e,t,i,r){this._initCurve();const s=this.currentPath.points;return s.length===0&&this.moveTo(0,0),Eu.curveTo(e,t,i,r,s),this}bezierCurveTo(e,t,i,r,s,o){return this._initCurve(),Tu.curveTo(e,t,i,r,s,o,this.currentPath.points),this}arcTo(e,t,i,r,s){this._initCurve(e,t);const o=this.currentPath.points,a=Lf.curveTo(e,t,i,r,s,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(e,t,i,r,s,o=!1){if(r===s)return this;if(!o&&s<=r?s+=Ko:o&&r<=s&&(r+=Ko),s-r===0)return this;const a=e+Math.cos(r)*i,l=t+Math.sin(r)*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 Lf.arc(a,l,e,t,i,r,s,o,u),this}beginFill(e=0,t){return this.beginTextureFill({texture:xe.WHITE,color:e,alpha:t})}normalizeColor(e){const t=Ze.shared.setValue(e.color??0);e.color=t.toNumber(),e.alpha??(e.alpha=t.alpha)}beginTextureFill(e){const t={texture:xe.WHITE,color:16777215,matrix:null};e=Object.assign(t,e),this.normalizeColor(e),this.currentPath&&this.startPoly();const i=e.alpha>0;return i?(e.matrix&&(e.matrix=e.matrix.clone(),e.matrix.invert()),Object.assign(this._fillStyle,{visible:i},e)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(e,t,i,r){return this.drawShape(new Fe(e,t,i,r))}drawRoundedRect(e,t,i,r,s){return this.drawShape(new Sa(e,t,i,r,s))}drawCircle(e,t,i){return this.drawShape(new Ea(e,t,i))}drawEllipse(e,t,i,r){return this.drawShape(new ba(e,t,i,r))}drawPolygon(...e){let t,i=!0;const r=e[0];r.points?(i=r.closeStroke,t=r.points):Array.isArray(e[0])?t=e[0]:t=e;const s=new kn(t);return s.closeStroke=i,this.drawShape(s),this}drawShape(e){return this._holeMode?this._geometry.drawHole(e,this._matrix):this._geometry.drawShape(e,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}
980isFastRect(){const e=this._geometry.graphicsData;return e.length===1&&e[0].shape.type===Pt.RECT&&!e[0].matrix&&!e[0].holes.length&&!(e[0].lineStyle.visible&&e[0].lineStyle.width)}_render(e){this.finishPoly();const t=this._geometry;t.updateBatches(),t.batchable?(this.batchDirty!==t.batchDirty&&this._populateBatches(),this._renderBatched(e)):(e.batch.flush(),this._renderDirect(e))}_populateBatches(){const e=this._geometry,t=this.blendMode,i=e.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=e.batchDirty,this.batches.length=i,this.vertexData=new Float32Array(e.points);for(let r=0;r<i;r++){const s=e.batches[r],o=s.style.color,a=new Float32Array(this.vertexData.buffer,s.attribStart*4*2,s.attribSize*2),l=new Float32Array(e.uvsFloat32.buffer,s.attribStart*4*2,s.attribSize*2),h=new Uint16Array(e.indicesUint16.buffer,s.start*2,s.size),u={vertexData:a,blendMode:t,indices:h,uvs:l,_batchRGB:Ze.shared.setValue(o).toRgbArray(),_tintRGB:o,_texture:s.style.texture,alpha:s.style.alpha,worldAlpha:1};this.batches[r]=u}}_renderBatched(e){if(this.batches.length){e.batch.setObjectRenderer(e.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(let t=0,i=this.batches.length;t<i;t++){const r=this.batches[t];r.worldAlpha=this.worldAlpha*r.alpha,e.plugins[this.pluginName].render(r)}}}_renderDirect(e){const t=this._resolveDirectShader(e),i=this._geometry,r=this.worldAlpha,s=t.uniforms,o=i.drawCalls;s.translationMatrix=this.transform.worldTransform,Ze.shared.setValue(this._tintColor).premultiply(r).toArray(s.tint),e.shader.bind(t),e.geometry.bind(i,t),e.state.set(this.state);for(let a=0,l=o.length;a<l;a++)this._renderDrawCallDirect(e,i.drawCalls[a])}_renderDrawCallDirect(e,t){const{texArray:i,type:r,size:s,start:o}=t,a=i.count;for(let l=0;l<a;l++)e.texture.bind(i.elements[l],l);e.geometry.draw(r,s,o)}_resolveDirectShader(e){let t=this.shader;const i=this.pluginName;if(!t){if(!Nl[i]){const{maxTextures:r}=e.plugins[i],s=new Int32Array(r);for(let l=0;l<r;l++)s[l]=l;const o={tint:new Float32Array([1,1,1,1]),translationMatrix:new tt,default:di.from({uSamplers:s},!0)},a=e.plugins[i]._shader.program;Nl[i]=new Ii(a,o)}t=Nl[i]}return t}_calculateBounds(){this.finishPoly();const e=this._geometry;if(!e.graphicsData.length)return;const{minX:t,minY:i,maxX:r,maxY:s}=e.bounds;this._bounds.addFrame(this.transform,t,i,r,s)}containsPoint(e){return this.worldTransform.applyInverse(e,Do._TEMP_POINT),this._geometry.containsPoint(Do._TEMP_POINT)}calculateTints(){if(this.batchTint!==this.tint){this.batchTint=this._tintColor.toNumber();for(let e=0;e<this.batches.length;e++){const t=this.batches[e];t._tintRGB=Ze.shared.setValue(this._tintColor).multiply(t._batchRGB).toLittleEndianNumber()}}}calculateVertices(){const e=this.transform._worldID;if(this._transformID===e)return;this._transformID=e;const t=this.transform.worldTransform,i=t.a,r=t.b,s=t.c,o=t.d,a=t.tx,l=t.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+s*p+a,u[c++]=o*p+r*f+l}}closePath(){const e=this.currentPath;return e&&(e.closeStroke=!0,this.finishPoly()),this}setMatrix(e){return this._matrix=e,this}beginHole(){return this.finishPoly(),this._holeMode=!0,this}endHole(){return this.finishPoly(),this._holeMode=!1,this}destroy(e){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,
980super.destroy(e)}};Nh.curves=Br,Nh._TEMP_POINT=new ze;let Ds=Nh;class OA{constructor(e,t){this.uvBuffer=e,this.uvMatrix=t,this.data=null,this._bufferUpdateId=-1,this._textureUpdateId=-1,this._updateID=0}update(e){if(!e&&this._bufferUpdateId===this.uvBuffer._updateID&&this._textureUpdateId===this.uvMatrix._updateID)return;this._bufferUpdateId=this.uvBuffer._updateID,this._textureUpdateId=this.uvMatrix._updateID;const t=this.uvBuffer.data;(!this.data||this.data.length!==t.length)&&(this.data=new Float32Array(t.length)),this.uvMatrix.multiplyUvs(t,this.data),this._updateID++}}const kl=new ze,kf=new kn,Om=class Lm extends gi{constructor(e,t,i,r=bi.TRIANGLES){super(),this.geometry=e,this.shader=t,this.state=i||Di.for2d(),this.drawMode=r,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=pe.ROUND_PIXELS,this.batchUvs=null}get geometry(){return this._geometry}set geometry(e){this._geometry!==e&&(this._geometry&&(this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose()),this._geometry=e,this._geometry&&this._geometry.refCount++,this.vertexDirty=-1)}get uvBuffer(){return this.geometry.buffers[1]}get verticesBuffer(){return this.geometry.buffers[0]}set material(e){this.shader=e}get material(){return this.shader}set blendMode(e){this.state.blendMode=e}get blendMode(){return this.state.blendMode}set roundPixels(e){this._roundPixels!==e&&(this._transformID=-1),this._roundPixels=e}get roundPixels(){return this._roundPixels}get tint(){return"tint"in this.shader?this.shader.tint:null}set tint(e){this.shader.tint=e}get tintValue(){return this.shader.tintValue}get texture(){return"texture"in this.shader?this.shader.texture:null}set texture(e){this.shader.texture=e}_render(e){const t=this.geometry.buffers[0].data;this.shader.batchable&&this.drawMode===bi.TRIANGLES&&t.length<Lm.BATCHABLE_SIZE*2?this._renderToBatch(e):this._renderDefault(e)}_renderDefault(e){const t=this.shader;t.alpha=this.worldAlpha,t.update&&t.update(),e.batch.flush(),t.uniforms.translationMatrix=this.transform.worldTransform.toArray(!0),e.shader.bind(t),e.state.set(this.state),e.geometry.bind(this.geometry,t),e.geometry.draw(this.drawMode,this.size,this.start,this.geometry.instanceCount)}_renderToBatch(e){const t=this.geometry,i=this.shader;i.uvMatrix&&(i.uvMatrix.update(),this.calculateUvs()),this.calculateVertices(),this.indices=t.indexBuffer.data,this._tintRGB=i._tintRGB,this._texture=i.texture;const r=this.material.pluginName;e.batch.setObjectRenderer(e.plugins[r]),e.plugins[r].render(this)}calculateVertices(){const e=this.geometry.buffers[0],t=e.data,i=e._updateID;if(i===this.vertexDirty&&this._transformID===this.transform._worldID)return;this._transformID=this.transform._worldID,this.vertexData.length!==t.length&&(this.vertexData=new Float32Array(t.length));const r=this.transform.worldTransform,s=r.a,o=r.b,a=r.c,l=r.d,h=r.tx,u=r.ty,c=this.vertexData;for(let d=0;d<c.length/2;d++){const f=t[d*2],p=t[d*2+1];c[d*2]=s*f+a*p+h,c[d*2+1]=o*f+l*p+u}if(this._roundPixels){const d=pe.RESOLUTION;for(let f=0;f<c.length;++f)c[f]=Math.round(c[f]*d)/d}this.vertexDirty=i}calculateUvs(){const e=this.geometry.buffers[1],t=this.shader;t.uvMatrix.isSimple?this.uvs=e.data:(this.batchUvs||(this.batchUvs=new OA(e,t.uvMatrix)),this.batchUvs.update(),this.uvs=this.batchUvs.data)}_calculateBounds(){this.calculateVertices(),this._bounds.addVertexData(this.vertexData,0,this.vertexData.length)}containsPoint(e){if(!this.getBounds().contains(e.x,e.y))return!1;this.worldTransform.applyInverse(e,kl);const t=this.geometry.getBuffer("aVertexPosition").data,i=kf.points,r=this.geometry.getIndex().data,s=r.length,o=this.drawMode===4?3:1;for(let a=0;a+2<s;a+=o){const l=r[a]*2,h=r[a+1]*2,u=r[a+2]*2;if(i[0]=t[l],i[1]=t[l+1],i[2]=t[h],i[3]=t[h+1],i[4]=t[u],i[5]=t[u+1],kf.contains(kl.x,kl.y))return!0}return!1}destroy(e){super.destroy(e),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}};Om.BATCHABLE_SIZE=100;let Uf=Om;class LA extends fn{constructor(e,t,i){super();const r=new dt(e),s=new dt(t,!0),o=new dt(i,!0,!0);this.addAttribute("aVertexPosition",r,2,!1,Ee.FLOAT).addAttribute("aTextureCoord",s,2,!1,Ee.FLOAT).addIndex(o),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var BA=`varying vec2 vTextureCoord; 981uniform vec4 uColor; 982 983uniform sampler2D uSampler; 984 985void main(void) 986{ 987 gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; 988} 989`,FA=`attribute vec2 aVertexPosition; 990attribute vec2 aTextureCoord; 991 992uniform mat3 projectionMatrix; 993uniform mat3 translationMatrix; 994uniform mat3 uTextureMatrix; 995 996varying vec2 vTextureCoord; 997 998void main(void) 999{ 1000 gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0
1000)).xy, 0.0, 1.0); 1001 1002 vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; 1003} 1004`;class Hf extends Ii{constructor(e,t){const i={uSampler:e,alpha:1,uTextureMatrix:tt.IDENTITY,uColor:new Float32Array([1,1,1,1])};t=Object.assign({tint:16777215,alpha:1,pluginName:"batch"},t),t.uniforms&&Object.assign(i,t.uniforms),super(t.program||Hi.from(FA,BA),i),this._colorDirty=!1,this.uvMatrix=new Zg(e),this.batchable=t.program===void 0,this.pluginName=t.pluginName,this._tintColor=new Ze(t.tint),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0,this.alpha=t.alpha}get texture(){return this.uniforms.uSampler}set texture(e){this.uniforms.uSampler!==e&&(!this.uniforms.uSampler.baseTexture.alphaMode!=!e.baseTexture.alphaMode&&(this._colorDirty=!0),this.uniforms.uSampler=e,this.uvMatrix.texture=e)}set alpha(e){e!==this._alpha&&(this._alpha=e,this._colorDirty=!0)}get alpha(){return this._alpha}set tint(e){e!==this.tint&&(this._tintColor.setValue(e),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 e=this.texture.baseTexture.alphaMode;Ze.shared.setValue(this._tintColor).premultiply(this._alpha,e).toArray(this.uniforms.uColor)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class Gf{constructor(e,t,i){this.geometry=new fn,this.indexBuffer=null,this.size=i,this.dynamicProperties=[],this.staticProperties=[];for(let r=0;r<e.length;++r){let s=e[r];s={attributeName:s.attributeName,size:s.size,uploadFunction:s.uploadFunction,type:s.type||Ee.FLOAT,offset:s.offset},t[r]?this.dynamicProperties.push(s):this.staticProperties.push(s)}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 e=this.geometry;let t=0;this.indexBuffer=new dt(nb(this.size),!0,!0),e.addIndex(this.indexBuffer),this.dynamicStride=0;for(let o=0;o<this.dynamicProperties.length;++o){const a=this.dynamicProperties[o];a.offset=t,t+=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 dt(this.dynamicData,!1,!1);let r=0;this.staticStride=0;for(let o=0;o<this.staticProperties.length;++o){const a=this.staticProperties[o];a.offset=r,r+=a.size,this.staticStride+=a.size}const s=new ArrayBuffer(this.size*this.staticStride*4*4);this.staticData=new Float32Array(s),this.staticDataUint32=new Uint32Array(s),this.staticBuffer=new dt(this.staticData,!0,!1);for(let o=0;o<this.dynamicProperties.length;++o){const a=this.dynamicProperties[o];e.addAttribute(a.attributeName,this.dynamicBuffer,0,a.type===Ee.UNSIGNED_BYTE,a.type,this.dynamicStride*4,a.offset*4)}for(let o=0;o<this.staticProperties.length;++o){const a=this.staticProperties[o];e.addAttribute(a.attributeName,this.staticBuffer,0,a.type===Ee.UNSIGNED_BYTE,a.type,this.staticStride*4,a.offset*4)}}uploadDynamic(e,t,i){for(let r=0;r<this.dynamicProperties.length;r++){const s=this.dynamicProperties[r];s.uploadFunction(e,t,i,s.type===Ee.UNSIGNED_BYTE?this.dynamicDataUint32:this.dynamicData,this.dynamicStride,s.offset)}this.dynamicBuffer._updateID++}uploadStatic(e,t,i){for(let r=0;r<this.staticProperties.length;r++){const s=this.staticProperties[r];s.uploadFunction(e,t,i,s.type===Ee.UNSIGNED_BYTE?this.staticDataUint32:this.staticData,this.staticStride,s.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 NA=`varying vec2 vTextureCoord; 1005varying vec4 vColor; 1006 1007uniform sampler2D uSampler; 1008 1009void main(void){ 1010 vec4 color = texture2D(uSampler, vTextureCoord) * vColor; 1011 gl_FragColor = color; 1012}`,kA=`attribute vec2 aVertexPosition; 1013attribute vec2 aTextureCoord; 1014attribute vec4 aColor; 1015 1016attribute vec2 aPositionCoord; 1017attribute float aRotation; 1018 1019uniform mat3 translationMatrix; 1020uniform vec4 uColor; 1021 1022varying vec2 vTextureCoord; 1023varying vec4 vColor; 1024 1025void main(void){ 1026 float x = (aVertexPosition.x) * cos(aRotation) - (aVertexPosition.y) * sin(aRotation); 1027 float y = (aVertexPosition.x) * sin(aRotation) + (aVertexPosition.y) * cos(aRotation); 1028 1029 vec2 v = vec2(x, y); 1030 v = v + aPositionCoord; 1031 1032 gl_Position = vec4((translationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0); 1033 1034 vTextureCoord = aTextureCoord; 1035 vColor = aColor * uColor; 1036} 1037`;class Bm extends Aa{constructor(e){super(e),this.shader=null,this.properties=null,this.tempMatrix=new tt,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:Ee.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=Ii.from(kA,NA,{}),this.state=Di.for2d()}render(e){const t=e.children,i=e._maxSize,r=e._batchSize,s=this.renderer;let o=t.length;if(o===0)return;o>i&&!e.autoResize&&(o=i);let a=e._buffers;a||(a=e._buffers=this.generateBuffers(e));const l=t[0]._texture.baseTexture,h=l.alphaMode>0;this.state.blendMode=Og(e.blendMode,h),s.state.set(this.state);const u=s.gl,c=e.worldTransform.copyTo(this.tempMatrix);c.prepend(s.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=c.toArray(!0),this.shader.uniforms.uColor=Ze.shared.setValue(e.tintRgb).premultiply(e.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+=r,p+=1){let g=o-f;g>r&&(g=r),p>=a.length&&a.push(this._generateOneMoreBuffer(e));const v=a[p];v.uploadDynamic(t,f,g);const m=e._bufferUpdateIDs[p]||0;d=d||v._updateID<m,d&&(v._updateID=e._updateID,v.uploadStatic(t,f,g)),s.geometry.bind(v.geometry),u.drawElements(u.TRIANGLES,g*6,u.UNSIGNED_SHORT,0)}}generateBuffers(e){const t=[],i=e._maxSize,r=e._batchSize,s=e._properties;for(let o=0;o<i;o+=r)t.push(new Gf(this.properties,s,r));return t}_generateOneMoreBuffer(e){const t=e._batchSize,i=e._properties;return new Gf(this.properties,i,t)}uploadVertices(e,t,i,r,s,o){let a=0,l=0,h=0,u=0;for(let c=0;c<i;++c){const d=e[t+c],f=d._texture,p=d.scale.x,g=d.scale.y,v=f.trim,m=f.orig;v?(l=v.x-d.anchor.x*m.width,a=l+v.width,u=v.y-d.anchor.y*m.height,h=u+v.height):(a=m.width*(1-d.anchor.x),l=m.width*-d.anchor.x,h=m.height*(1-d.anchor.y),u=m.height*-d.anchor.y),r[o]=l*p,r[o+1]=u*g,r[o+s]=a*p,r[o+s+1]=u*g,r[o+s*2]=a*p,r[o+s*2+1]=h*g,r[o+s*3]=l*p,r[o+s*3+1]=h*g,o+=s*4}}uploadPosition(e,t,i,r,s,o){for(let a=0;a<i;a++){const l=e[t+a].position;r[o]=l.x,r[o+1]=l.y,r[o+s]=l.x,r[o+s+1]=l.y,r[o+s*2]=l.x,r[o+s*2+1]=l.y,r[o+s*3]=l.x,r[o+s*3+1]=l.y,o+=s*4}}uploadRotation(e,t,i,r,s,o){for(let a=0;a<i;a++){const l=e[t+a].rotation;r[o]=l,r[o+s]=l,r[o+s*2]=l,r[o+s*3]=l,o+=s*4}}uploadUvs(e,t,i,r,s,o){for(let a=0;a<i;++a){const l=e[t+a]._texture._uvs;l?(r[o]=l.x0,r[o+1]=l.y0,r[o+s]=l.x1,r[o+s+1]=l.y1,r[o+s*2]=l.x2,r[o+s*2+1]=l.y2,r[o+s*3]=l.x3,r[o+s*3+1]=l.y3,o+=s*4):(r[o]=0,r[o+1]=0,r[o+s]=0,r[o+s+1]=0,r[o+s*2]=0,r[o+s*2+1]=0,r[o+s*3]=0,r[o+s*3+1]=0,o+=s*4)}}uploadTint(e,t,i,r,s,o){for(let a=0;a<i;++a){const l=e[t+a],h=Ze.shared.setValue(l._tintRGB).toPremultiplied(l.alpha,l.texture.baseTexture.alphaMode>0);r[o]=h,r[o+s]=h,r[o+s*2]=h,r[o+s*3]=h,o+=s*4}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}Bm.extension={name:"particle",type:ue.RendererPlugin};_e.add(Bm);var Ca=(n=>
vendor: 4,387 bytes, lines 1037-1038
1037(n[n.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",n[n.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",n))(Ca||{});const go={willReadFrequently:!0},_i=class we{static get experimentalLetterSpacingSupported(){let e=we._experimentalLetterSpacingSupported;if(e!==void 0){const t=pe.ADAPTER.getCanvasRenderingContext2D().prototype;e=we._experimentalLetterSpacingSupported="letterSpacing"in t||"textLetterSpacing"in t}return e}constructor(e,t,i,r,s,o,a,l,h){this.text=e,this.style=t,this.width=i,this.height=r,this.lines=s,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=h}static measureText(e,t,i,r=we._canvas){i=i??t.wordWrap;const s=t.toFontString(),o=we.measureFont(s);o.fontSize===0&&(o.fontSize=t.fontSize,o.ascent=t.fontSize);const a=r.getContext("2d",go);a.font=s;const l=(i?we.wordWrap(e,t,r):e).split(/(?:\r\n|\r|\n)/),h=new Array(l.length);let u=0;for(let p=0;p<l.length;p++){const g=we._measureText(l[p],t.letterSpacing,a);h[p]=g,u=Math.max(u,g)}let c=u+t.strokeThickness;t.dropShadow&&(c+=t.dropShadowDistance);const d=t.lineHeight||o.fontSize+t.strokeThickness;let f=Math.max(d,o.fontSize+t.strokeThickness*2)+t.leading+(l.length-1)*(d+t.leading);return t.dropShadow&&(f+=t.dropShadowDistance),new we(e,t,c,f,l,h,d+t.leading,u,o)}static _measureText(e,t,i){let r=!1;we.experimentalLetterSpacingSupported&&(we.experimentalLetterSpacing?(i.letterSpacing=`${t}px`,i.textLetterSpacing=`${t}px`,r=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));let s=i.measureText(e).width;return s>0&&(r?s-=t:s+=(we.graphemeSegmenter(e).length-1)*t),s}static wordWrap(e,t,i=we._canvas){const r=i.getContext("2d",go);let s=0,o="",a="";const l=Object.create(null),{letterSpacing:h,whiteSpace:u}=t,c=we.collapseSpaces(u),d=we.collapseNewlines(u);let f=!c;const p=t.wordWrapWidth+h,g=we.tokenize(e);for(let v=0;v<g.length;v++){let m=g[v];if(we.isNewline(m)){if(!d){a+=we.addLine(o),f=!c,o="",s=0;continue}m=" "}if(c){const y=we.isBreakingSpace(m),E=we.isBreakingSpace(o[o.length-1]);if(y&&E)continue}const x=we.getFromCache(m,h,l,r);if(x>p)if(o!==""&&(a+=we.addLine(o),o="",s=0),we.canBreakWords(m,t.breakWords)){const y=we.wordWrapSplit(m);for(let E=0;E<y.length;E++){let R=y[E],P=R,S=1;for(;y[E+S];){const k=y[E+S];if(!we.canBreakChars(P,k,m,E,t.breakWords))R+=k;else break;P=k,S++}E+=S-1;const L=we.getFromCache(R,h,l,r);L+s>p&&(a+=we.addLine(o),f=!1,o="",s=0),o+=R,s+=L}}else{o.length>0&&(a+=we.addLine(o),o="",s=0);const y=v===g.length-1;a+=we.addLine(m,!y),f=!1,o="",s=0}else x+s>p&&(f=!1,a+=we.addLine(o),o="",s=0),(o.length>0||!we.isBreakingSpace(m)||f)&&(o+=m,s+=x)}return a+=we.addLine(o,!1),a}static addLine(e,t=!0){return e=we.trimRight(e),e=t?`${e} 1038`:e,e}static getFromCache(e,t,i,r){let s=i[e];return typeof s!="number"&&(s=we._measureText(e,t,r)+t,i[e]=s),s}static collapseSpaces(e){return e==="normal"||e==="pre-line"}static collapseNewlines(e){return e==="normal"}static trimRight(e){if(typeof e!="string")return"";for(let t=e.length-1;t>=0;t--){const i=e[t];if(!we.isBreakingSpace(i))break;e=e.slice(0,-1)}return e}static isNewline(e){return typeof e!="string"?!1:we._newlines.includes(e.charCodeAt(0))}static isBreakingSpace(e,t){return typeof e!="string"?!1:we._breakingSpaces.includes(e.charCodeAt(0))}static tokenize(e){const t=[];let i="";if(typeof e!="string")return t;for(let r=0;r<e.length;r++){const s=e[r],o=e[r+1];if(we.isBreakingSpace(s,o)||we.isNewline(s)){i!==""&&(t.push(i),i=""),t.push(s);continue}i+=s}return i!==""&&t.push(i),t}static canBreakWords(e,t){return t}static canBreakChars(e,t,i,r,s){return!0}static wordWrapSplit(e){return we.graphemeSegmenter(e)}static measureFont(e){if(we._fonts[e])return we._fonts[e];const t={ascent:0,descent:0,fontSize:0},i=we._canvas,r=we._context;r.font=e;const s=we.METRICS_STRING+we.BASELINE_SYMBOL,o=Math.ceil(r.measureText(s).width);let a=Math.ceil(r.measureText(we.BASELINE_SYMBOL).width);const l=Math.ceil(we.HEIGHT_MULTIPLIER*a);if(a=a*we.BASELINE_MULTIPLIER|0,o===0||l===0)return we._fonts[e]=t,t;i.width=o,i.height=l,r.fillStyle="#f00",r.fillRect(0,0,o,l),r.font=e,r.textBaseline="alphabetic",r.fillStyle="#000",r.fillText(s,0,a);const h=r.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 g=0;g<c;g+=4)if(h[f+g]!==255){p=!0;break}if(!p)f+=c;else break}for(t.ascent=a-d,f=u-c,p=!1,d=l;d>a;--d){for(let g=0;g<c;g+=4)if(h[f+g]!==255){p=!0;break}if(!p)f-=c;else break}
1038return t.descent=d-a,t.fontSize=t.ascent+t.descent,we._fonts[e]=t,t}static clearMetrics(e=""){e?delete we._fonts[e]:we._fonts={}}static get _canvas(){var e;if(!we.__canvas){let t;try{const i=new OffscreenCanvas(0,0);if((e=i.getContext("2d",go))!=null&&e.measureText)return we.__canvas=i,i;t=pe.ADAPTER.createCanvas()}catch{t=pe.ADAPTER.createCanvas()}t.width=t.height=10,we.__canvas=t}return we.__canvas}static get _context(){return we.__context||(we.__context=we._canvas.getContext("2d",go)),we.__context}};_i.METRICS_STRING="|ÉqÅ",_i.BASELINE_SYMBOL="M",_i.BASELINE_MULTIPLIER=1.4,_i.HEIGHT_MULTIPLIER=2,_i.graphemeSegmenter=(()=>{if(typeof Intl?.Segmenter=="function"){const n=new Intl.Segmenter;return e=>[...n.segment(e)].map(t=>t.segment)}return n=>[...n]})(),_i.experimentalLetterSpacing=!1,_i._fonts={},_i._newlines=[10,13],_i._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let Ji=_i;const UA=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],Fm=class hs{constructor(e){this.styleID=0,this.reset(),Hl(this,e,e)}clone(){const e={};return Hl(e,this,hs.defaultStyle),new hs(e)}reset(){Hl(this,hs.defaultStyle,hs.defaultStyle)}get align(){return this._align}set align(e){this._align!==e&&(this._align=e,this.styleID++)}get breakWords(){return this._breakWords}set breakWords(e){this._breakWords!==e&&(this._breakWords=e,this.styleID++)}get dropShadow(){return this._dropShadow}set dropShadow(e){this._dropShadow!==e&&(this._dropShadow=e,this.styleID++)}get dropShadowAlpha(){return this._dropShadowAlpha}set dropShadowAlpha(e){this._dropShadowAlpha!==e&&(this._dropShadowAlpha=e,this.styleID++)}get dropShadowAngle(){return this._dropShadowAngle}set dropShadowAngle(e){this._dropShadowAngle!==e&&(this._dropShadowAngle=e,this.styleID++)}get dropShadowBlur(){return this._dropShadowBlur}set dropShadowBlur(e){this._dropShadowBlur!==e&&(this._dropShadowBlur=e,this.styleID++)}get dropShadowColor(){return this._dropShadowColor}set dropShadowColor(e){const t=Ul(e);this._dropShadowColor!==t&&(this._dropShadowColor=t,this.styleID++)}get dropShadowDistance(){return this._dropShadowDistance}set dropShadowDistance(e){this._dropShadowDistance!==e&&(this._dropShadowDistance=e,this.styleID++)}get fill(){return this._fill}set fill(e){const t=Ul(e);this._fill!==t&&(this._fill=t,this.styleID++)}get fillGradientType(){return this._fillGradientType}set fillGradientType(e){this._fillGradientType!==e&&(this._fillGradientType=e,this.styleID++)}get fillGradientStops(){return this._fillGradientStops}set fillGradientStops(e){HA(this._fillGradientStops,e)||(this._fillGradientStops=e,this.styleID++)}get fontFamily(){return this._fontFamily}set fontFamily(e){this.fontFamily!==e&&(this._fontFamily=e,this.styleID++)}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize!==e&&(this._fontSize=e,this.styleID++)}get fontStyle(){return this._fontStyle}set fontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.styleID++)}get fontVariant(){return this._fontVariant}set fontVariant(e){this._fontVariant!==e&&(this._fontVariant=e,this.styleID++)}get fontWeight(){return this._fontWeight}set fontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.styleID++)}get letterSpacing(){return this._letterSpacing}set letterSpacing(e){this._letterSpacing!==e&&(this._letterSpacing=e,this.styleID++)}get lineHeight(){return this._lineHeight}set lineHeight(e){this._lineHeight!==e&&(this._lineHeight=e,this.styleID++)}get leading(){return this._leading}set leading(e){this._leading!==e&&(this._leading=e,this.styleID++)}get lineJoin(){return this._lineJoin}set lineJoin(e){this._lineJoin!==e&&(this._lineJoin=e,this.styleID++)}get miterLimit(){return this._miterLimit}set miterLimit(e){this._miterLimit!==e&&(this._miterLimit=e,this.styleID++)}get padding(){return this._padding}set padding(e){this._padding!==e&&(this._padding=e,this.styleID++)}get stroke(){return this._stroke}set stroke(e){const t=Ul(e);this._stroke!==t&&(this._stroke=t,this.styleID++)}get strokeThickness(){return this._strokeThickness}set strokeThickness(e){this._strokeThickness!==e&&(this._strokeThickness=e,this.styleID++)}get textBaseline(){return this._textBaseline}set textBaseline(e){this._textBaseline!==e&&(this._textBaseline=e,this.styleID++)}get trim(){return this._trim}set trim(e){this._trim!==e&&(this._trim=e,this.styleID++)}get whiteSpace(){return this._whiteSpace}set whiteSpace(e){this._whiteSpace!==e&&(this._whiteSpace=e,this.styleID++)}get wordWrap(){return this._wordWrap}set wordWrap(e){this._wordWrap!==e&&(this._wordWrap=e,this.styleID++)}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(e){this._wordWrapWidth!==e&&(this._wordWrapWidth=e,this.styleID++)}toFontString(){const e=typeof this.fontSize=="number"?`${this.fontSize}px`:this.fontSize;let t=this.fontFamily;Array.isArray(this.fontFamily)||(t=this.fontFamily.split(","));for(let i=t.length-1;i>=0;i--){let r=t[i].trim();!/([\"\'])[^\'\"]+\1/.test(r)&&!UA.includes(r)&&(r=`"${r}"`),t[i]=r}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${e} ${t.join(",")}`}};Fm.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:Ca.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 pn=Fm;function Ul(n){const e=Ze.shared,t=i=>{const r=e.setValue(i);return r.alpha===1?r.toHex():r.toRgbaString()};return Array.isArray(n)?n.map(t):t(n)}
1038function HA(n,e){if(!Array.isArray(n)||!Array.isArray(e)||n.length!==e.length)return!1;for(let t=0;t<n.length;++t)if(n[t]!==e[t])return!1;return!0}function Hl(n,e,t){for(const i in t)Array.isArray(e[i])?n[i]=e[i].slice():n[i]=e[i]}const GA={texture:!0,children:!1,baseTexture:!0},Nm=class kh extends Xr{constructor(e,t,i){let r=!1;i||(i=pe.ADAPTER.createCanvas(),r=!0),i.width=3,i.height=3;const s=xe.from(i);s.orig=new Fe,s.trim=new Fe,super(s),this._ownCanvas=r,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=kh.defaultResolution??pe.RESOLUTION,this._autoResolution=kh.defaultAutoResolution,this._text=null,this._style=null,this._styleListener=null,this._font="",this.text=e,this.style=t,this.localStyleID=-1}static get experimentalLetterSpacing(){return Ji.experimentalLetterSpacing}static set experimentalLetterSpacing(e){Ue("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),Ji.experimentalLetterSpacing=e}updateText(e){const t=this._style;if(this.localStyleID!==t.styleID&&(this.dirty=!0,this.localStyleID=t.styleID),!this.dirty&&e)return;this._font=this._style.toFontString();const i=this.context,r=Ji.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),s=r.width,o=r.height,a=r.lines,l=r.lineHeight,h=r.lineWidths,u=r.maxLineWidth,c=r.fontProperties;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,s)+t.padding*2)*this._resolution),this.canvas.height=Math.ceil(Math.ceil(Math.max(1,o)+t.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=t.strokeThickness,i.textBaseline=t.textBaseline,i.lineJoin=t.lineJoin,i.miterLimit=t.miterLimit;let d,f;const p=t.dropShadow?2:1;for(let g=0;g<p;++g){const v=t.dropShadow&&g===0,m=v?Math.ceil(Math.max(1,o)+t.padding*2):0,x=m*this._resolution;if(v){i.fillStyle="black",i.strokeStyle="black";const E=t.dropShadowColor,R=t.dropShadowBlur*this._resolution,P=t.dropShadowDistance*this._resolution;i.shadowColor=Ze.shared.setValue(E).setAlpha(t.dropShadowAlpha).toRgbaString(),i.shadowBlur=R,i.shadowOffsetX=Math.cos(t.dropShadowAngle)*P,i.shadowOffsetY=Math.sin(t.dropShadowAngle)*P+x}else i.fillStyle=this._generateFillStyle(t,a,r),i.strokeStyle=t.stroke,i.shadowColor="black",i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0;let y=(l-c.fontSize)/2;l-c.fontSize<0&&(y=0);for(let E=0;E<a.length;E++)d=t.strokeThickness/2,f=t.strokeThickness/2+E*l+c.ascent+y,t.align==="right"?d+=u-h[E]:t.align==="center"&&(d+=(u-h[E])/2),t.stroke&&t.strokeThickness&&this.drawLetterSpacing(a[E],d+t.padding,f+t.padding-m,!0),t.fill&&this.drawLetterSpacing(a[E],d+t.padding,f+t.padding-m)}this.updateTexture()}drawLetterSpacing(e,t,i,r=!1){const s=this._style.letterSpacing;let o=!1;if(Ji.experimentalLetterSpacingSupported&&(Ji.experimentalLetterSpacing?(this.context.letterSpacing=`${s}px`,this.context.textLetterSpacing=`${s}px`,o=!0):(this.context.letterSpacing="0px",this.context.textLetterSpacing="0px")),s===0||o){r?this.context.strokeText(e,t,i):this.context.fillText(e,t,i);return}let a=t;const l=Ji.graphemeSegmenter(e);let h=this.context.measureText(e).width,u=0;for(let c=0;c<l.length;++c){const d=l[c];r?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+s,h=u}}updateTexture(){const e=this.canvas;if(this._style.trim){const o=ab(e);o.data&&(e.width=o.width,e.height=o.height,this.context.putImageData(o.data,0,0))}const t=this._texture,i=this._style,r=i.trim?0:i.padding,s=t.baseTexture;t.trim.width=t._frame.width=e.width/this._resolution,t.trim.height=t._frame.height=e.height/this._resolution,t.trim.x=-r,t.trim.y=-r,t.orig.width=t._frame.width-r*2,t.orig.height=t._frame.height-r*2,this._onTextureUpdate(),s.setRealSize(e.width,e.height,this._resolution),t.updateUvs(),this.dirty=!1}_render(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),super._render(e)}updateTransform(){this.updateText(!0),super.updateTransform()}getBounds(e,t){return this.updateText(!0),this._textureID===-1&&(e=!1),super.getBounds(e,t)}getLocalBounds(e){return this.updateText(!0),super.getLocalBounds.call(this,e)}_calculateBounds(){this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_generateFillStyle(e,t,i){const r=e.fill;if(Array.isArray(r)){if(r.length===1)return r[0]}else return r;let s;const o=e.dropShadow?e.dropShadowDistance:0,a=e.padding||0,l=this.canvas.width/this._resolution-o-a*2,h=this.canvas.height/this._resolution-o-a*2,u=r.slice(),c=e.fillGradientStops.slice();if(!c.length){const d=u.length+1;for(let f=1;f<d;++f)c.push(f/d)}if(u.unshift(r[0]),c.unshift(0),u.push(r[r.length-1]),c.push(1),e.fillGradientType===Ca.LINEAR_VERTICAL){s=this.context.createLinearGradient(l/2,a,l/2,h+a);const d=i.fontProperties.fontSize+e.strokeThickness;for(let f=0;f<t.length;f++){const p=i.lineHeight*(f-1)+d,g=i.lineHeight*f;let v=g;f>0&&p>g&&(v=(g+p)/2);const m=g+d,x=i.lineHeight*(f+1);let y=m;f+1<t.length&&x<m&&(y=(m+x)/2);const E=(y-v)/h;for(let R=0;R<u.length;R++){let P=0;typeof c[R]=="number"?P=c[R]:P=R/u.length;let S=Math.min(1,Math.max(0,v/h+P*E));S=Number(S.toFixed(5)),s.addColorStop(S,u[R])}}}else{s=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 g;typeof c[p]=="number"?g=c[p]:g=f/d,s.addColorStop(g,u[p]),f++}}return s}destroy(e){typeof e=="boolean"&&(e={children:e}),e=Object.assign({},GA,e),super.destroy(e),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(e){this.updateText(!0);const t=rn(this.scale.x)||1;this.scale.x=t*e/this._texture.orig.width,this._width=e}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._texture.orig.height}set height(e){this.updateText(!0);const t=rn(this.scale.y)||1;this.scale.y=t*e/this._texture.orig.height,this._height=e}get style(){return this._style}set style(e){e=e||{},e instanceof pn?this._style=e:this._style=new pn(e),this.localStyleID=-1,this.dirty=!0}get text(){return this._text}set text(e){e=String(e??""),this._text!==e&&(this._text=e,this.dirty=!0)}get resolution(){return this._resolution}set resolution(e){this._autoResolution=!1,this._resolution!==e&&(this._resolution=e,this.dirty=!0)}};Nm.defaultAutoResolution=!0;let km=Nm;class zA{constructor(e){this.maxItemsPerFrame=e,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function VA(n,e){var t;let i=!1;if((t=n?._textures)!=null&&t.length){for(let r=0;r<n._textures.length;r++)if(n._textures[r]instanceof xe){const s=n._textures[r].baseTexture;e.includes(s)||(e.push(s),i=!0)}}return i}function jA(n,e){if(n.baseTexture instanceof Le){const t=n.baseTexture;return e.includes(t)||e.push(t),!0}return!1}function XA(n,e){if(n._texture&&n._texture instanceof xe){const t=n._texture.baseTexture;return e.includes(t)||e.push(t),!0}return!1}function WA(n,e){return e instanceof km?(e.updateText(!0),!0):!1}function YA(n,e){if(e instanceof pn){const t=e.toFontString();return Ji.measureFont(t),!0}return!1}function qA(n,e){if(n instanceof km){e.includes(n.style)||e.push(n.style),e.includes(n)||e.push(n);const t=n._texture.baseTexture;return e.includes(t)||e.push(t),!0}return!1}function $A(n,e){return n instanceof pn?(e.includes(n)||e.push(n),!0):!1}const Um=class Hm{constructor(e){this.limiter=new zA(Hm.uploadsPerFrame),this.renderer=e,this.uploadHookHelper=null,this.queue=[],this.addHooks=[],this.uploadHooks=[],this.completes=[],this.ticking=!1,this.delayedTick=()=>{this.queue&&this.prepareItems()},this.registerFindHook(qA),this.registerFindHook($A),this.registerFindHook(VA),this.registerFindHook(jA),this.registerFindHook(XA),this.registerUploadHook(WA),this.registerUploadHook(YA)}upload(e){return new Promise(t=>{e&&this.add(e),this.queue.length?(this.completes.push(t),this.ticking||(this.ticking=!0,Yt.system.addOnce(this.tick,this,Wn.UTILITY))):t()})}tick(){setTimeout(this.delayedTick,0)}prepareItems(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){const e=this.queue[0];let t=!1;if(e&&!e._destroyed){for(let i=0,r=this.uploadHooks.length;i<r;i++)if(this.uploadHooks[i](this.uploadHookHelper,e)){this.queue.shift(),t=!0;break}}t||this.queue.shift()}if(this.queue.length)Yt.system.addOnce(this.tick,this,Wn.UTILITY);else{this.ticking=!1;const e=this.completes.slice(0);this.completes.length=0;for(let t=0,i=e.length;t<i;t++)e[t]()}}registerFindHook(e){return e&&this.addHooks.push(e),this}registerUploadHook(e){return e&&this.uploadHooks.push(e),this}add(e){for(let t=0,i=this.addHooks.length;t<i&&!this.addHooks[t](e,this.queue);t++);if(e instanceof gi)for(let t=e.children.length-1;t>=0;t--)this.add(e.children[t]);return this}destroy(){this.ticking&&Yt.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}};Um.uploadsPerFrame=4;let Uh=Um;Object.defineProperties(pe,{UPLOADS_PER_FRAME:{get(){return Uh.uploadsPerFrame},set(n){Ue("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),Uh.uploadsPerFrame=n}}});function Gm(n,e){return e instanceof Le?(e._glTextures[n.CONTEXT_UID]||n.texture.bind(e),!0):!1}function ZA(n,e){if(!(e instanceof Ds))return!1;const{geometry:t}=e;e.finishPoly(),t.updateBatches();const{batches:i}=t;
1038for(let r=0;r<i.length;r++){const{texture:s}=i[r].style;s&&Gm(n,s.baseTexture)}return t.batchable||n.geometry.bind(t,e._resolveDirectShader(n)),!0}function KA(n,e){return n instanceof Ds?(e.push(n),!0):!1}class zm extends Uh{constructor(e){super(e),this.uploadHookHelper=this.renderer,this.registerFindHook(KA),this.registerUploadHook(Gm),this.registerUploadHook(ZA)}}zm.extension={name:"prepare",type:ue.RendererSystem};_e.add(zm);var JA=`#version 300 es 1039#define SHADER_NAME Tiling-Sprite-100 1040 1041precision lowp float; 1042 1043in vec2 vTextureCoord; 1044 1045out vec4 fragmentColor; 1046 1047uniform sampler2D uSampler; 1048uniform vec4 uColor; 1049uniform mat3 uMapCoord; 1050uniform vec4 uClampFrame; 1051uniform vec2 uClampOffset; 1052 1053void main(void) 1054{ 1055 vec2 coord = vTextureCoord + ceil(uClampOffset - vTextureCoord); 1056 coord = (uMapCoord * vec3(coord, 1.0)).xy; 1057 vec2 unclamped = coord; 1058 coord = clamp(coord, uClampFrame.xy, uClampFrame.zw); 1059 1060 vec4 texSample = texture(uSampler, coord, unclamped == coord ? 0.0f : -32.0f);// lod-bias very negative to force lod 0 1061 1062 fragmentColor = texSample * uColor; 1063} 1064`,QA=`#version 300 es 1065#define SHADER_NAME Tiling-Sprite-300 1066 1067precision lowp float; 1068 1069in vec2 aVertexPosition; 1070in vec2 aTextureCoord; 1071 1072uniform mat3 projectionMatrix; 1073uniform mat3 translationMatrix; 1074uniform mat3 uTransform; 1075 1076out vec2 vTextureCoord; 1077 1078void main(void) 1079{ 1080 gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0
1080)).xy, 0.0, 1.0); 1081 1082 vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy; 1083} 1084`,eR=`#version 100 1085#ifdef GL_EXT_shader_texture_lod 1086 #extension GL_EXT_shader_texture_lod : enable 1087#endif 1088#define SHADER_NAME Tiling-Sprite-100 1089 1090precision lowp float; 1091 1092varying vec2 vTextureCoord; 1093 1094uniform sampler2D uSampler; 1095uniform vec4 uColor; 1096uniform mat3 uMapCoord; 1097uniform vec4 uClampFrame; 1098uniform vec2 uClampOffset; 1099 1100void main(void) 1101{ 1102 vec2 coord = vTextureCoord + ceil(uClampOffset - vTextureCoord); 1103 coord = (uMapCoord * vec3(coord, 1.0)).xy; 1104 vec2 unclamped = coord; 1105 coord = clamp(coord, uClampFrame.xy, uClampFrame.zw); 1106 1107 #ifdef GL_EXT_shader_texture_lod 1108 vec4 texSample = unclamped == coord 1109 ? texture2D(uSampler, coord) 1110 : texture2DLodEXT(uSampler, coord, 0); 1111 #else 1112 vec4 texSample = texture2D(uSampler, coord); 1113 #endif 1114 1115 gl_FragColor = texSample * uColor; 1116} 1117`,zf=`#version 100 1118#define SHADER_NAME Tiling-Sprite-100 1119 1120precision lowp float; 1121 1122attribute vec2 aVertexPosition; 1123attribute vec2 aTextureCoord; 1124 1125uniform mat3 projectionMatrix; 1126uniform mat3 translationMatrix; 1127uniform mat3 uTransform; 1128 1129varying vec2 vTextureCoord; 1130 1131void main(void) 1132{ 1133 gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0
1133)).xy, 0.0, 1.0); 1134 1135 vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy; 1136} 1137`,tR=`#version 100 1138#define SHADER_NAME Tiling-Sprite-Simple-100 1139 1140precision lowp float; 1141 1142varying vec2 vTextureCoord; 1143 1144uniform sampler2D uSampler; 1145uniform vec4 uColor; 1146 1147void main(void) 1148{ 1149 vec4 texSample = texture2D(uSampler, vTextureCoord); 1150 gl_FragColor = texSample * uColor; 1151} 1152`;const mo=new tt;class Vm extends Aa{constructor(e){super(e),e.runners.contextChange.add(this),this.quad=new Wg,this.state=Di.for2d()}contextChange(){const e=this.renderer,t={globals:e.globalUniforms};this.simpleShader=Ii.from(zf,tR,t),this.shader=e.context.webGLVersion>1?Ii.from(QA,JA,t):Ii.from(zf,eR,t)}render(e){const t=this.renderer,i=this.quad;let r=i.vertices;r[0]=r[6]=e._width*-e.anchor.x,r[1]=r[3]=e._height*-e.anchor.y,r[2]=r[4]=e._width*(1-e.anchor.x),r[5]=r[7]=e._height*(1-e.anchor.y);const s=e.uvRespectAnchor?e.anchor.x:0,o=e.uvRespectAnchor?e.anchor.y:0;r=i.uvs,r[0]=r[6]=-s,r[1]=r[3]=-o,r[2]=r[4]=1-s,r[5]=r[7]=1-o,i.invalidate();const a=e._texture,l=a.baseTexture,h=l.alphaMode>0,u=e.tileTransform.localTransform,c=e.uvMatrix;let d=l.isPowerOfTwo&&a.frame.width===l.width&&a.frame.height===l.height;d&&(l._glTextures[t.CONTEXT_UID]?d=l.wrapMode!==ln.CLAMP:l.wrapMode===ln.CLAMP&&(l.wrapMode=ln.REPEAT));const f=d?this.simpleShader:this.shader,p=a.width,g=a.height,v=e._width,m=e._height;mo.set(u.a*p/v,u.b*p/m,u.c*g/v,u.d*g/m,u.tx/v,u.ty/m),mo.invert(),d?mo.prepend(c.mapCoord):(f.uniforms.uMapCoord=c.mapCoord.toArray(!0),f.uniforms.uClampFrame=c.uClampFrame,f.uniforms.uClampOffset=c.uClampOffset),f.uniforms.uTransform=mo.toArray(!0),f.uniforms.uColor=Ze.shared.setValue(e.tint).premultiply(e.worldAlpha,h).toArray(f.uniforms.uColor),f.uniforms.translationMatrix=e.transform.worldTransform.toArray(!0),f.uniforms.uSampler=a,t.shader.bind(f),t.geometry.bind(i),this.state.blendMode=Og(e.blendMode,h),t.state.set(this.state),t.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}Vm.extension={name:"tilingSprite",type:ue.RendererPlugin};_e.add(Vm);const jm=class us{constructor(e,t,i){this.linkedSheets=[],(e instanceof Le||e instanceof xe)&&(e={texture:e,data:t,resolutionFilename:i});const{texture:r,data:s,resolutionFilename:o=null,cachePrefix:a=""}=e;this.cachePrefix=a,this._texture=r instanceof xe?r:null,this.baseTexture=r instanceof Le?r:this._texture.baseTexture,this.textures={},this.animations={},this.data=s;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(e=null){const{scale:t}=this.data.meta;let i=ji(e,null);return i===null&&(i=typeof t=="number"?t:parseFloat(t??"1")),i!==1&&this.baseTexture.setResolution(i),i}parse(){return new Promise(e=>{this._callback=e,this._batchIndex=0,this._frameKeys.length<=us.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(e){let t=e;const i=us.BATCH_SIZE;for(;t-e<i&&t<this._frameKeys.length;){const r=this._frameKeys[t],s=this._frames[r],o=s.frame;if(o){let a=null,l=null;const h=s.trimmed!==!1&&s.sourceSize?s.sourceSize:s.frame,u=new Fe(0,0,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution);s.rotated?a=new Fe(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 Fe(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution),s.trimmed!==!1&&s.spriteSourceSize&&(l=new Fe(Math.floor(s.spriteSourceSize.x)/this.resolution,Math.floor(s.spriteSourceSize.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution)),this.textures[r]=new xe(this.baseTexture,a,u,l,s.rotated?2:0,s.anchor,s.borders),xe.addToCache(this.textures[r],this.cachePrefix+r.toString())}t++}}_processAnimations(){const e=this.data.animations||{};for(const t in e){this.animations[t]=[];for(let i=0;i<e[t].length;i++){const r=e[t][i];this.animations[t].push(this.textures[r])}}}_parseComplete(){const e=this._callback;this._callback=null,this._batchIndex=0,e.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*us.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*us.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(e=!1){var t;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,e&&((t=this._texture)==null||t.destroy(),this.baseTexture.destroy()),this._texture=null,this.baseTexture=null,this.linkedSheets=[]}};jm.BATCH_SIZE=1e3;let Vf=jm;const iR=["jpg","png","jpeg","avif","webp","s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"];function Xm(n,e,t){const i={};if(n.forEach(r=>{i[r]=e}
1152),Object.keys(e.textures).forEach(r=>{i[`${e.cachePrefix}${r}`]=e.textures[r]}),!t){const r=Tt.dirname(n[0]);e.linkedSheets.forEach((s,o)=>{Object.assign(i,Xm([`${r}/${e.data.meta.related_multi_packs[o]}`],s,!0))})}return i}const nR={extension:ue.Asset,cache:{test:n=>n instanceof Vf,getCacheableAssets:(n,e)=>Xm(n,e,!1)},resolver:{test:n=>{const e=n.split("?")[0].split("."),t=e.pop(),i=e.pop();return t==="json"&&iR.includes(i)},parse:n=>{var e;const t=n.split(".");return{resolution:parseFloat(((e=pe.RETINA_PREFIX.exec(n))==null?void 0:e[1])??"1"),format:t[t.length-2],src:n}}},loader:{name:"spritesheetLoader",extension:{type:ue.LoadParser,priority:mi.Normal},async testParse(n,e){return Tt.extname(e.src).toLowerCase()===".json"&&!!n.frames},async parse(n,e,t){var i,r;const{texture:s,imageFilename:o,cachePrefix:a}=e?.data??{};let l=Tt.dirname(e.src);l&&l.lastIndexOf("/")!==l.length-1&&(l+="/");let h;if(s&&s.baseTexture)h=s;else{const d=Lh(l+(o??n.meta.image),e.src);h=(await t.load([d]))[d]}const u=new Vf({texture:h.baseTexture,data:n,resolutionFilename:e.src,cachePrefix:a});await u.parse();const c=(i=n?.meta)==null?void 0:i.related_multi_packs;if(Array.isArray(c)){const d=[];for(const p of c){if(typeof p!="string")continue;let g=l+p;(r=e.data)!=null&&r.ignoreMultiPack||(g=Lh(g,e.src),d.push(t.load({src:g,data:{ignoreMultiPack:!0}})))}const f=await Promise.all(d);u.linkedSheets=f,f.forEach(p=>{p.linkedSheets=[u].concat(u.linkedSheets.filter(g=>g!==p))})}return u},unload(n){n.destroy(!0)}}};_e.add(nR);class la{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class Oo{static test(e){return typeof e=="string"&&e.startsWith("info face=")}static parse(e){const t=e.match(/^[a-z]+\s+.+$/gm),i={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const s in t){const o=t[s].match(/^[a-z]+/gm)[0],a=t[s].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 r=new la;return i.info.forEach(s=>r.info.push({face:s.face,size:parseInt(s.size,10)})),i.common.forEach(s=>r.common.push({lineHeight:parseInt(s.lineHeight,10)})),i.page.forEach(s=>r.page.push({id:parseInt(s.id,10),file:s.file})),i.char.forEach(s=>r.char.push({id:parseInt(s.id,10),page:parseInt(s.page,10),x:parseInt(s.x,10),y:parseInt(s.y,10),width:parseInt(s.width,10),height:parseInt(s.height,10),xoffset:parseInt(s.xoffset,10),yoffset:parseInt(s.yoffset,10),xadvance:parseInt(s.xadvance,10)})),i.kerning.forEach(s=>r.kerning.push({first:parseInt(s.first,10),second:parseInt(s.second,10),amount:parseInt(s.amount,10)})),i.distanceField.forEach(s=>r.distanceField.push({distanceRange:parseInt(s.distanceRange,10),fieldType:s.fieldType})),r}}class Hh{static test(e){const t=e;return typeof e!="string"&&"getElementsByTagName"in e&&t.getElementsByTagName("page").length&&t.getElementsByTagName("info")[0].getAttribute("face")!==null}static parse(e){const t=new la,i=e.getElementsByTagName("info"),r=e.getElementsByTagName("common"),s=e.getElementsByTagName("page"),o=e.getElementsByTagName("char"),a=e.getElementsByTagName("kerning"),l=e.getElementsByTagName("distanceField");for(let h=0;h<i.length;h++)t.info.push({face:i[h].getAttribute("face"),size:parseInt(i[h].getAttribute("size"),10)});for(let h=0;h<r.length;h++)t.common.push({lineHeight:parseInt(r[h].getAttribute("lineHeight"),10)});for(let h=0;h<s.length;h++)t.page.push({id:parseInt(s[h].getAttribute("id"),10)||0,file:s[h].getAttribute("file")});for(let h=0;h<o.length;h++){const u=o[h];t.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++)t.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;
1152h++)t.distanceField.push({fieldType:l[h].getAttribute("fieldType"),distanceRange:parseInt(l[h].getAttribute("distanceRange"),10)});return t}}class Gh{static test(e){return typeof e=="string"&&e.includes("<font>")?Hh.test(pe.ADAPTER.parseXML(e)):!1}static parse(e){return Hh.parse(pe.ADAPTER.parseXML(e))}}const Gl=[Oo,Hh,Gh];function rR(n){for(let e=0;e<Gl.length;e++)if(Gl[e].test(n))return Gl[e];return null}function sR(n,e,t,i,r,s){const o=t.fill;if(Array.isArray(o)){if(o.length===1)return o[0]}else return o;let a;const l=t.dropShadow?t.dropShadowDistance:0,h=t.padding||0,u=n.width/i-l-h*2,c=n.height/i-l-h*2,d=o.slice(),f=t.fillGradientStops.slice();if(!f.length){const p=d.length+1;for(let g=1;g<p;++g)f.push(g/p)}if(d.unshift(o[0]),f.unshift(0),d.push(o[o.length-1]),f.push(1),t.fillGradientType===Ca.LINEAR_VERTICAL){a=e.createLinearGradient(u/2,h,u/2,c+h);let p=0;const g=(s.fontProperties.fontSize+t.strokeThickness)/c;for(let v=0;v<r.length;v++){const m=s.lineHeight*v;for(let x=0;x<d.length;x++){let y=0;typeof f[x]=="number"?y=f[x]:y=x/d.length;const E=m/c+y*g;let R=Math.max(p,E);R=Math.min(R,1),a.addColorStop(R,d[x]),p=R}}}else{a=e.createLinearGradient(h,c/2,u+h,c/2);const p=d.length+1;let g=1;for(let v=0;v<d.length;v++){let m;typeof f[v]=="number"?m=f[v]:m=g/p,a.addColorStop(m,d[v]),g++}}return a}function oR(n,e,t,i,r,s,o){const a=t.text,l=t.fontProperties;e.translate(i,r),e.scale(s,s);const h=o.strokeThickness/2,u=-(o.strokeThickness/2);if(e.font=o.toFontString(),e.lineWidth=o.strokeThickness,e.textBaseline=o.textBaseline,e.lineJoin=o.lineJoin,e.miterLimit=o.miterLimit,e.fillStyle=sR(n,e,o,s,[a],t),e.strokeStyle=o.stroke,o.dropShadow){const c=o.dropShadowColor,d=o.dropShadowBlur*s,f=o.dropShadowDistance*s;e.shadowColor=Ze.shared.setValue(c).setAlpha(o.dropShadowAlpha).toRgbaString(),e.shadowBlur=d,e.shadowOffsetX=Math.cos(o.dropShadowAngle)*f,e.shadowOffsetY=Math.sin(o.dropShadowAngle)*f}else e.shadowColor="black",e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0;o.stroke&&o.strokeThickness&&e.strokeText(a,h,u+t.lineHeight-l.descent),o.fill&&e.fillText(a,h,u+t.lineHeight-l.descent),e.setTransform(1,0,0,1,0,0),e.fillStyle="rgba(0, 0, 0, 0)"}function Lo(n){return n.codePointAt?n.codePointAt(0):n.charCodeAt(0)}function Wm(n){return Array.from?Array.from(n):n.split("")}function aR(n){typeof n=="string"&&(n=[n]);const e=[];for(let t=0,i=n.length;t<i;t++){const r=n[t];if(Array.isArray(r)){if(r.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${r.length}.`);const s=r[0].charCodeAt(0),o=r[1].charCodeAt(0);if(o<s)throw new Error("[BitmapFont]: Invalid character range.");for(let a=s,l=o;a<=l;a++)e.push(String.fromCharCode(a))}else e.push(...Wm(r))}if(e.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return e}const $i=class wi{constructor(e,t,i){var r;const[s]=e.info,[o]=e.common,[a]=e.page,[l]=e.distanceField,h=ji(a.file),u={};this._ownsTextures=i,this.font=s.face,this.size=s.size,this.lineHeight=o.lineHeight/h,this.chars={},this.pageTextures=u;for(let c=0;c<e.page.length;c++){const{id:d,file:f}=e.page[c];u[d]=t instanceof Array?t[c]:t[f],l!=null&&l.fieldType&&l.fieldType!=="none"&&(u[d].baseTexture.alphaMode=Ut.NO_PREMULTIPLIED_ALPHA,u[d].baseTexture.mipmap=Mi.OFF)}for(let c=0;c<e.char.length;c++){const{id:d,page:f}=e.char[c];let{x:p,y:g,width:v,height:m,xoffset:x,yoffset:y,xadvance:E}=e.char[c];p/=h,g/=h,v/=h,m/=h,x/=h,y/=h,E/=h;const R=new Fe(p+u[f].frame.x/h,g+u[f].frame.y/h,v,m);this.chars[d]={xOffset:x,yOffset:y,xAdvance:E,kerning:{},texture:new xe(u[f].baseTexture,R),page:f}}for(let c=0;c<e.kerning.length;c++){let{first:d,second:f,amount:p}=e.kerning[c];d/=h,f/=h,p/=h,this.chars[f]&&(this.chars[f].kerning[d]=p)}this.distanceFieldRange=l?.distanceRange,this.distanceFieldType=((r=l?.fieldType)==null?void 0:r.toLowerCase())??"none"}destroy(){for(const e in this.chars)this.chars[e].texture.destroy(),this.chars[e].texture=null;for(const e in this.pageTextures)this._ownsTextures&&this.pageTextures[e].destroy(!0),this.pageTextures[e]=null;this.chars=null,this.pageTextures=null}static install(e,t,i){let r;if(e instanceof la)r=e;else{const o=rR(e);if(!o)throw new Error("Unrecognized data format for font.");r=o.parse(e)}t instanceof xe&&(t=[t]);const s=new wi(r,t,i);return wi.available[s.font]=s,s}static uninstall(e){const t=wi.available[e];if(!t)throw new Error(`No font found named '${e}'`);t.destroy(),delete wi.available[e]}static from(e,t,i){if(!e)throw new Error("[BitmapFont] Property `name` is required.");const{chars:r,padding:s,resolution:o,textureWidth:a,textureHeight:l,...h}=Object.assign({},wi.defaultOptions,i),u=aR(r),c=t instanceof pn?t:new pn(t),d=a,f=new la;f.info[0]={face:c.fontFamily,size:c.fontSize},f.common[0]={lineHeight:c.fontSize};let p=0,g=0,v,m,x,y=0;const E=[];for(let P=0;P<u.length;P++){v||(v=pe.ADAPTER.createCanvas(),v.width=a,v.height=l,m=v.getContext("2d"),x=new Le(v,{resolution:o,...h}),E.push(new xe(x)),f.page.push({id:E.length-1,file:""}));const S=u[P],L=Ji.measureText(S,c,!1,v),k=L.width,W=Math.ceil(L.height),j=Math.ceil((c.fontStyle==="italic"?2:1)*k);if(g>=l-W*o){if(g===0)throw new Error(`[BitmapFont] textureHeight ${l}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${S}')`);--P,v=null,m=null,x=null,g=0,p=0,y=0;continue}if(y=Math.max(W+L.fontProperties.descent,y),j*o+p>
1152=d){if(p===0)throw new Error(`[BitmapFont] textureWidth ${a}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${S}')`);--P,g+=y*o,g=Math.ceil(g),p=0,y=0;continue}oR(v,m,L,p,g,o,c);const V=Lo(L.text);f.char.push({id:V,page:E.length-1,x:p/o,y:g/o,width:j,height:W,xoffset:0,yoffset:0,xadvance:k-(c.dropShadow?c.dropShadowDistance:0)-(c.stroke?c.strokeThickness:0)}),p+=(j+2*s)*o,p=Math.ceil(p)}if(!(i!=null&&i.skipKerning))for(let P=0,S=u.length;P<S;P++){const L=u[P];for(let k=0;k<S;k++){const W=u[k],j=m.measureText(L).width,V=m.measureText(W).width,N=m.measureText(L+W).width-(j+V);N&&f.kerning.push({first:Lo(L),second:Lo(W),amount:N})}}const R=new wi(f,E,!0);return wi.available[e]!==void 0&&wi.uninstall(e),wi.available[e]=R,R}};$i.ALPHA=[["a","z"],["A","Z"]," "],$i.NUMERIC=[["0","9"]],$i.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],$i.ASCII=[[" ","~"]],$i.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:$i.ALPHANUMERIC},$i.available={};let Zi=$i;var lR=`// Pixi texture info\r 1153varying vec2 vTextureCoord;\r 1154uniform sampler2D uSampler;\r 1155\r 1156// Tint\r 1157uniform vec4 uColor;\r 1158\r 1159// on 2D applications fwidth is screenScale / glyphAtlasScale * distanceFieldRange\r 1160uniform float uFWidth;\r 1161\r 1162void main(void) {\r 1163\r 1164 // To stack MSDF and SDF we need a non-pre-multiplied-alpha texture.\r 1165 vec4 texColor = texture2D(uSampler, vTextureCoord);\r 1166\r 1167 // MSDF\r 1168 float median = texColor.r + texColor.g + texColor.b -\r 1169 min(texColor.r, min(texColor.g, texColor.b)) -\r 1170 max(texColor.r, max(texColor.g, texColor.b));\r 1171 // SDF\r 1172 median = min(median, texColor.a);\r 1173\r 1174 float screenPxDistance = uFWidth * (median - 0.5);\r 1175 float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\r 1176 if (median < 0.01) {\r 1177 alpha = 0.0;\r 1178 } else if (median > 0.99) {\r 1179 alpha = 1.0;\r 1180 }\r 1181\r 1182 // Gamma correction for coverage-like alpha\r 1183 float luma = dot(uColor.rgb, vec3(0.299, 0.587, 0.114));\r 1184 float gamma = mix(1.0, 1.0 / 2.2, luma);\r 1185 float coverage = pow(uColor.a * alpha, gamma); \r 1186\r 1187 // NPM Textures, NPM outputs\r 1188 gl_FragColor = vec4(uColor.rgb, coverage);\r 1189}\r 1190`,hR=`// Mesh material default fragment\r 1191attribute vec2 aVertexPosition;\r 1192attribute vec2 aTextureCoord;\r 1193\r 1194uniform mat3 projectionMatrix;\r 1195uniform mat3 translationMatrix;\r 1196uniform mat3 uTextureMatrix;\r 1197\r 1198varying vec2 vTextureCoord;\r 1199\r 1200void main(void)\r 1201{\r 1202 gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0
1202)).xy, 0.0, 1.0);\r 1203\r 1204 vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\r 1205}\r 1206`;const jf=[],Xf=[],Wf=[],uR=class Ym extends gi{constructor(e,t={}){super();const{align:i,tint:r,maxWidth:s,letterSpacing:o,fontName:a,fontSize:l}=Object.assign({},Ym.styleDefaults,t);if(!Zi.available[a])throw new Error(`Missing BitmapFont "${a}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=i,this._tintColor=new Ze(r),this._font=void 0,this._fontName=a,this._fontSize=l,this.text=e,this._maxWidth=s,this._maxLineHeight=0,this._letterSpacing=o,this._anchor=new Ui(()=>{this.dirty=!0},this,0,0),this._roundPixels=pe.ROUND_PIXELS,this.dirty=!0,this._resolution=pe.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){var e;const t=Zi.available[this._fontName],i=this.fontSize,r=i/t.size,s=new ze,o=[],a=[],l=[],h=this._text.replace(/(?:\r\n|\r)/g,` 1207`)||" ",u=Wm(h),c=this._maxWidth*t.size/i,d=t.distanceFieldType==="none"?jf:Xf;let f=null,p=0,g=0,v=0,m=-1,x=0,y=0,E=0,R=0;for(let V=0;V<u.length;V++){const N=u[V],D=Lo(N);if(/(?:\s)/.test(N)&&(m=V,x=p,R++),N==="\r"||N===` 1208`){a.push(p),l.push(-1),g=Math.max(g,p),++v,++y,s.x=0,s.y+=t.lineHeight,f=null,R=0;continue}const A=t.chars[D];if(!A)continue;f&&A.kerning[f]&&(s.x+=A.kerning[f]);const O=Wf.pop()||{texture:xe.EMPTY,line:0,charCode:0,prevSpaces:0,position:new ze};O.texture=A.texture,O.line=v,O.charCode=D,O.position.x=Math.round(s.x+A.xOffset+this._letterSpacing/2),O.position.y=Math.round(s.y+A.yOffset),O.prevSpaces=R,o.push(O),p=O.position.x+Math.max(A.xAdvance-A.xOffset,A.texture.orig.width),s.x+=A.xAdvance+this._letterSpacing,E=Math.max(E,A.yOffset+A.texture.height),f=D,m!==-1&&c>0&&s.x>c&&(++y,br(o,1+m-y,1+V-m),V=m,m=-1,a.push(x),l.push(o.length>0?o[o.length-1].prevSpaces:0),g=Math.max(g,x),v++,s.x=0,s.y+=t.lineHeight,f=null,R=0)}const P=u[u.length-1];P!=="\r"&&P!==` 1209`&&(/(?:\s)/.test(P)&&(p=x),a.push(p),g=Math.max(g,p),l.push(-1));const S=[];for(let V=0;V<=v;V++){let N=0;this._align==="right"?N=g-a[V]:this._align==="center"?N=(g-a[V])/2:this._align==="justify"&&(N=l[V]<0?0:(g-a[V])/l[V]),S.push(N)}const L=o.length,k={},W=[],j=this._activePagesMeshData;d.push(...j);for(let V=0;V<L;V++){const N=o[V].texture,D=N.baseTexture.uid;if(!k[D]){let A=d.pop();if(!A){const B=new LA;let G,Y;t.distanceFieldType==="none"?(G=new Hf(xe.EMPTY),Y=Ce.NORMAL):(G=new Hf(xe.EMPTY,{program:Hi.from(hR,lR),uniforms:{uFWidth:0}}),Y=Ce.NORMAL_NPM);const z=new Uf(B,G);z.blendMode=Y,A={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:z,vertices:null,uvs:null,indices:null}}A.index=0,A.indexCount=0,A.vertexCount=0,A.uvsCount=0,A.total=0;const{_textureCache:O}=this;O[D]=O[D]||new xe(N.baseTexture),A.mesh.texture=O[D],A.mesh.tint=this._tintColor.value,W.push(A),k[D]=A}k[D].total++}for(let V=0;V<j.length;V++)W.includes(j[V])||this.removeChild(j[V].mesh);for(let V=0;V<W.length;V++)W[V].mesh.parent!==this&&this.addChild(W[V].mesh);this._activePagesMeshData=W;for(const V in k){const N=k[V],D=N.total;if(!(((e=N.indices)==null?void 0:e.length)>6*D)||N.vertices.length<Uf.BATCHABLE_SIZE*2)N.vertices=new Float32Array(8*D),N.uvs=new Float32Array(8*D),N.indices=new Uint16Array(6*D);else{const A=N.total,O=N.vertices;for(let B=A*4*2;B<O.length;B++)O[B]=0}N.mesh.size=6*D}for(let V=0;V<L;V++){const N=o[V];let D=N.position.x+S[N.line]*(this._align==="justify"?N.prevSpaces:1);this._roundPixels&&(D=Math.round(D));const A=D*r,O=N.position.y*r,B=N.texture,G=k[B.baseTexture.uid],Y=B.frame,z=B._uvs,b=G.index++;G.indices[b*6+0]=0+b*4,G.indices[b*6+1]=1+b*4,G.indices[b*6+2]=2+b*4,G.indices[b*6+3]=0+b*4,G.indices[b*6+4]=2+b*4,G.indices[b*6+5]=3+b*4,G.vertices[b*8+0]=A,G.vertices[b*8+1]=O,G.vertices[b*8+2]=A+Y.width*r,G.vertices[b*8+3]=O,G.vertices[b*8+4]=A+Y.width*r,G.vertices[b*8+5]=O+Y.height*r,G.vertices[b*8+6]=A,G.vertices[b*8+7]=O+Y.height*r,G.uvs[b*8+0]=z.x0,G.uvs[b*8+1]=z.y0,G.uvs[b*8+2]=z.x1,G.uvs[b*8+3]=z.y1,G.uvs[b*8+4]=z.x2,G.uvs[b*8+5]=z.y2,G.uvs[b*8+6]=z.x3,G.uvs[b*8+7]=z.y3}this._textWidth=g*r,this._textHeight=(s.y+t.lineHeight)*r;for(const V in k){const N=k[V];if(this.anchor.x!==0||this.anchor.y!==0){let B=0;const G=this._textWidth*this.anchor.x,Y=this._textHeight*this.anchor.y;for(let z=0;z<N.total;z++)N.vertices[B++]-=G,N.vertices[B++]-=Y,N.vertices[B++]-=G,N.vertices[B++]-=Y,N.vertices[B++]-=G,N.vertices[B++]-=Y,N.vertices[B++]-=G,N.vertices[B++]-=Y}this._maxLineHeight=E*r;const D=N.mesh.geometry.getBuffer("aVertexPosition"),A=N.mesh.geometry.getBuffer("aTextureCoord"),O=N.mesh.geometry.getIndex();D.data=N.vertices,A.data=N.uvs,O.data=N.indices,D.update(),A.update(
1209),O.update()}for(let V=0;V<o.length;V++)Wf.push(o[V]);this._font=t,this.dirty=!1}updateTransform(){this.validate(),this.containerUpdateTransform()}_render(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0);const{distanceFieldRange:t,distanceFieldType:i,size:r}=Zi.available[this._fontName];if(i!=="none"){const{a:s,b:o,c:a,d:l}=this.worldTransform,h=Math.sqrt(s*s+o*o),u=Math.sqrt(a*a+l*l),c=(Math.abs(h)+Math.abs(u))/2,d=this.fontSize/r,f=e._view.resolution;for(const p of this._activePagesMeshData)p.mesh.shader.uniforms.uFWidth=c*t*d*f}super._render(e)}getLocalBounds(){return this.validate(),super.getLocalBounds()}validate(){const e=Zi.available[this._fontName];if(!e)throw new Error(`Missing BitmapFont "${this._fontName}"`);this._font!==e&&(this.dirty=!0),this.dirty&&this.updateText()}get tint(){return this._tintColor.value}set tint(e){if(this.tint!==e){this._tintColor.setValue(e);for(let t=0;t<this._activePagesMeshData.length;t++)this._activePagesMeshData[t].mesh.tint=e}}get align(){return this._align}set align(e){this._align!==e&&(this._align=e,this.dirty=!0)}get fontName(){return this._fontName}set fontName(e){if(!Zi.available[e])throw new Error(`Missing BitmapFont "${e}"`);this._fontName!==e&&(this._fontName=e,this.dirty=!0)}get fontSize(){return this._fontSize??Zi.available[this._fontName].size}set fontSize(e){this._fontSize!==e&&(this._fontSize=e,this.dirty=!0)}get anchor(){return this._anchor}set anchor(e){typeof e=="number"?this._anchor.set(e):this._anchor.copyFrom(e)}get text(){return this._text}set text(e){e=String(e??""),this._text!==e&&(this._text=e,this.dirty=!0)}get maxWidth(){return this._maxWidth}set maxWidth(e){this._maxWidth!==e&&(this._maxWidth=e,this.dirty=!0)}get maxLineHeight(){return this.validate(),this._maxLineHeight}get textWidth(){return this.validate(),this._textWidth}get letterSpacing(){return this._letterSpacing}set letterSpacing(e){this._letterSpacing!==e&&(this._letterSpacing=e,this.dirty=!0)}get roundPixels(){return this._roundPixels}set roundPixels(e){e!==this._roundPixels&&(this._roundPixels=e,this.dirty=!0)}get textHeight(){return this.validate(),this._textHeight}get resolution(){return this._resolution}set resolution(e){this._autoResolution=!1,this._resolution!==e&&(this._resolution=e,this.dirty=!0)}destroy(e){const{_textureCache:t}=this,i=Zi.available[this._fontName].distanceFieldType==="none"?jf:Xf;i.push(...this._activePagesMeshData);for(const r of this._activePagesMeshData)this.removeChild(r.mesh);this._activePagesMeshData=[],i.filter(r=>t[r.mesh.texture.baseTexture.uid]).forEach(r=>{r.mesh.texture=xe.EMPTY});for(const r in t)t[r].destroy(),delete t[r];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(e)}};uR.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};const cR=[".xml",".fnt"],dR={extension:{type:ue.LoadParser,priority:mi.Normal},name:"loadBitmapFont",test(n){return cR.includes(Tt.extname(n).toLowerCase())},async testParse(n){return Oo.test(n)||Gh.test(n)},async parse(n,e,t){const i=Oo.test(n)?Oo.parse(n):Gh.parse(n),{src:r}=e,{page:s}=i,o=[];for(let h=0;h<s.length;++h){const u=s[h].file;let c=Tt.join(Tt.dirname(r),u);c=Lh(c,r),o.push(c)}const a=await t.load(o),l=o.map(h=>a[h]);return Zi.install(i,l,!0)},async load(n,e){return(await pe.ADAPTER.fetch(n)).text()},unload(n){n.destroy()}};_e.add(dR);const zh=class pr extends pn{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(e){return new pr(Object.keys(pr.defaultOptions).reduce((t,i)=>({...t,[i]:e[i]}),{}))}cleanFonts(){this._fonts.length>0&&(this._fonts.forEach(e=>{URL.revokeObjectURL(e.src),e.refs--,e.refs===0&&(e.fontFace&&document.fonts.delete(e.fontFace),delete pr.availableFonts[e.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(e,t={}){const{availableFonts:i}=pr;if(i[e]){const r=i[e];return this._fonts.push(r),r.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return pe.ADAPTER.fetch(e).then(r=>r.blob()).then(async r=>new Promise((s,o)=>{const a=URL.createObjectURL(r),l=new FileReader;l.onload=()=>
1209s([a,l.result]),l.onerror=o,l.readAsDataURL(r)})).then(async([r,s])=>{const o=Object.assign({family:Tt.basename(e,Tt.extname(e)),weight:"normal",style:"normal",display:"auto",src:r,dataSrc:s,refs:1,originalUrl:e,fontFace:null},t);i[e]=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(...e){const t=e.filter(i=>!this._overrides.includes(i));t.length>0&&(this._overrides.push(...t),this.styleID++)}removeOverride(...e){const t=e.filter(i=>this._overrides.includes(i));t.length>0&&(this._overrides=this._overrides.filter(i=>!t.includes(i)),this.styleID++)}toCSS(e){return[`transform: scale(${e})`,"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((e,t)=>`${e} 1210 @font-face { 1211 font-family: "${t.family}"; 1212 src: url('${t.dataSrc}'); 1213 font-weight: ${t.weight}; 1214 font-style: ${t.style}; 1215 font-display: ${t.display}; 1216 }`,this._stylesheet)}get stylesheet(){return this._stylesheet}set stylesheet(e){this._stylesheet!==e&&(this._stylesheet=e,this.styleID++)}normalizeColor(e){return Array.isArray(e)&&(e=tb(e)),typeof e=="number"?eb(e):e}dropShadowToCSS(){let e=this.normalizeColor(this.dropShadowColor);const t=this.dropShadowAlpha,i=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),r=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);e.startsWith("#")&&t<1&&(e+=(t*255|0).toString(16).padStart(2,"0"));const s=`${i}px ${r}px`;return this.dropShadowBlur>0?`text-shadow: ${s} ${this.dropShadowBlur}px ${e}`:`text-shadow: ${s} ${e}`}reset(){Object.assign(this,pr.defaultOptions)}onBeforeDraw(){const{fontsDirty:e}=this;return this.fontsDirty=!1,this.isSafari&&this._fonts.length>0&&e?new Promise(t=>setTimeout(t,100)):Promise.resolve()}get isSafari(){const{userAgent:e}=pe.ADAPTER.getNavigator();return/^((?!chrome|android).)*safari/i.test(e)}set fillGradientStops(e){console.warn("[HTMLTextStyle] fillGradientStops is not supported by HTMLText")}get fillGradientStops(){return super.fillGradientStops}set fillGradientType(e){console.warn("[HTMLTextStyle] fillGradientType is not supported by HTMLText")}get fillGradientType(){return super.fillGradientType}set miterLimit(e){console.warn("[HTMLTextStyle] miterLimit is not supported by HTMLText")}get miterLimit(){return super.miterLimit}set trim(e){console.warn("[HTMLTextStyle] trim is not supported by HTMLText")}get trim(){return super.trim}set textBaseline(e){console.warn("[HTMLTextStyle] textBaseline is not supported by HTMLText")}get textBaseline(){return super.textBaseline}set leading(e){console.warn("[HTMLTextStyle] leading is not supported by HTMLText")}get leading(){return super.leading}set lineJoin(e){console.warn("[HTMLTextStyle] lineJoin is not supported by HTMLText")}get lineJoin(){return super.lineJoin}};zh.availableFonts={},zh.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 zl=zh;const vo=class gr extends Xr{constructor(e="",t={}){super(xe.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,r=xe.from(i,{scaleMode:pe.SCALE_MODE,resourceOptions:{autoLoad:!1}});r.orig=new Fe,r.trim=new Fe,this.texture=r;const s="http://www.w3.org/2000/svg",o="http://www.w3.org/1999/xhtml",a=document.createElementNS(s,"svg"),l=document.createElementNS(s,"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=gr.defaultMaxWidth,this.maxHeight=gr.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=gr.defaultAutoResolution,this._resolution=gr.defaultResolution??pe.RESOLUTION,this.text=e,this.style=t}measureText(e){var t,i;const{text:r,style:s,resolution:o}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},e);Object.assign(this._domElement,{innerHTML:r,style:s.toCSS(o)}),this._styleElement.textContent=s.toGlobalCSS(),document.body.appendChild(this._svgRoot);const a=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:l,height:h}=a;(l>this.maxWidth||h>this.maxHeight)&&console.warn("[HTMLText] Large expanse of text, increase HTMLText.maxWidth or HTMLText.maxHeight property.");const u=Math.min(this.maxWidth,Math.ceil(l)),c=Math.min(this.maxHeight,Math.ceil(h));return this._svgRoot.setAttribute("width",u.toString()),this._svgRoot.setAttribute("height",c.toString()),r!==this._text&&(this._domElement.innerHTML=this._text),s!==this._style&&(Object.assign(this._domElement,{style:(t=this._style)==null?void 0:t.toCSS(o)}),this._styleElement.textContent=(i=this._style)==null?void 0:i.toGlobalCSS()),{width:u+s.padding*2,height:c+s.padding*2}}async updateText(e=!0){const{style:t,_image:i,_loadImage:r}=this;if(this.localStyleID!==t.styleID&&(this.dirty=!0,this.localStyleID=t.styleID),!this.dirty&&e)return;const{width:s,height:o}=this.measureText();i.width=r.width=Math.ceil(Math.max(1,s)),i.height=r.height=Math.ceil(Math.max(1,o)),this._updateID++;const a=this._updateID;await new Promise(l=>{r.onload=async()=>
1216{if(a<this._updateID){l();return}await t.onBeforeDraw(),i.src=r.src,r.onload=null,r.src="",this.updateTexture(),l()};const h=new XMLSerializer().serializeToString(this._svgRoot);r.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(h)}`})}get source(){return this._image}updateTexture(){const{style:e,texture:t,_image:i,resolution:r}=this,{padding:s}=e,{baseTexture:o}=t;t.trim.width=t._frame.width=i.width/r,t.trim.height=t._frame.height=i.height/r,t.trim.x=-s,t.trim.y=-s,t.orig.width=t._frame.width-s*2,t.orig.height=t._frame.height-s*2,this._onTextureUpdate(),o.setRealSize(i.width,i.height,r),this.dirty=!1}_render(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),super._render(e)}_renderCanvas(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),super._renderCanvas(e)}getLocalBounds(e){return this.updateText(!0),super.getLocalBounds(e)}_calculateBounds(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_onStyleChange(){this.dirty=!0}destroy(e){var t,i,r,s,o;typeof e=="boolean"&&(e={children:e}),e=Object.assign({},gr.defaultDestroyOptions,e),super.destroy(e);const a=null;this.ownsStyle&&((t=this._style)==null||t.cleanFonts()),this._style=a,(i=this._svgRoot)==null||i.remove(),this._svgRoot=a,(r=this._domElement)==null||r.remove(),this._domElement=a,(s=this._foreignObject)==null||s.remove(),this._foreignObject=a,(o=this._styleElement)==null||o.remove(),this._styleElement=a,this._loadImage.src="",this._loadImage.onload=null,this._loadImage=a,this._image.src="",this._image=a}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._image.width/this.resolution}set width(e){this.updateText(!0);const t=rn(this.scale.x)||1;this.scale.x=t*e/this._image.width/this.resolution,this._width=e}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._image.height/this.resolution}set height(e){this.updateText(!0);const t=rn(this.scale.y)||1;this.scale.y=t*e/this._image.height/this.resolution,this._height=e}get style(){return this._style}set style(e){this._style!==e&&(e=e||{},e instanceof zl?(this.ownsStyle=!1,this._style=e):e instanceof pn?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=zl.from(e)):(this.ownsStyle=!0,this._style=new zl(e)),this.localStyleID=-1,this.dirty=!0)}get text(){return this._text}set text(e){e=String(e===""||e===null||e===void 0?" ":e),e=this.sanitiseText(e),this._text!==e&&(this._text=e,this.dirty=!0)}get resolution(){return this._resolution}set resolution(e){this._autoResolution=!1,this._resolution!==e&&(this._resolution=e,this.dirty=!0)}sanitiseText(e){return e.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/ /gi," ")}};vo.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},vo.defaultMaxWidth=2024,vo.defaultMaxHeight=2024,vo.defaultAutoResolution=!0;const fR=16777215,pR=.25,gR=16777215,mR=1,vR=1.5;let en=!1,Hn;const Vh=n=>{const e={tint:n!=null&&n.fill?new Ze(n.fill).toNumber():fR,alpha:n?.fillOpacity!==void 0?Math.min(n.fillOpacity,1):String(n?.fill).toLowerCase().startsWith("rgba(")?new Ze(n?.fill).alpha:pR},t={tint:n!=null&&n.stroke?new Ze(n.stroke).toNumber():gR,alpha:n?.strokeOpacity!==void 0?Math.min(n.strokeOpacity,1):String(n?.stroke).toLowerCase().startsWith("rgba(")?new Ze(n?.stroke).alpha:mR,lineWidth:n?.strokeWidth===void 0?vR:n.strokeWidth};return{fillStyle:e,strokeStyle:t}},Yr=n=>(e,t,i,r={})=>{const{fillStyle:s,strokeStyle:o}=Vh(i),a=new Ds;r.strokeOnly||(a.beginFill(16777215),n(t,a),a.endFill(),a.tint=s.tint,a.alpha=s.alpha),e.addChild(a);const l=new Ds,h=o.lineWidth===1?1:o.lineWidth/Hn;return l.lineStyle(h,16777215,1,.5,o.lineWidth===1),n(t,l),l.tint=o.tint||16777215,l.alpha=o.alpha,e.addChild(l),{fill:a,stroke:l,strokeWidth:o.lineWidth}},yR=Yr((n,e)=>{const{x:t,y:i,w:r,h:s,rot:o=0}=n.geometry;o===0?e.drawRect(t,i,r,s):(e.position.set(t+r/2,i+s/2),e.rotation=o,e.drawRect(-r/2,-s/2,r,s))}),xR=Yr((n,e)=>{const{cx:t,cy:i,rx:r,ry:s}=n.geometry;e.drawEllipse(t,i,r,s)}),_R=Yr((n,e)=>{const[[t,i],[r,s]]=n.geometry.points;e.moveTo(t,i),e.lineTo(r,s),e.closePath()}),wR=Yr((n,e)=>{const t=n.geometry.points.reduce((i,r)=>[...i,...r],[]);e.drawPolygon(t)}),TR=Yr((n,e)=>{const{points:t,closed:i}=n.geometry;if(t.length===0)return;i||e.beginFill(0,0);const r=(o,a)=>{const[l,h]=o.point,[u,c]=a.point;if(o.type==="CURVE"||a.type==="CURVE"){const d=o.type==="CURVE"&&o.outHandle?o.outHandle[0]:l,f=o.type==="CURVE"&&o.outHandle?o.outHandle[1]:h,p=a.type==="CURVE"&&a.inHandle?a.inHandle[0]:u,g=a.type==="CURVE"&&a.inHandle?a.inHandle[1]:c;e.bezierCurveTo(d,f,p,g,u,c)}else e.lineTo(u,c)},s=t[0];e.moveTo(s.point[0],s.point[1]);for(let o=1;o<t.length;o++){const a=t[o-1],l=t[o];r(a,l)}if(i&&t.length>2){const o=t[t.length-1],a=t[0];r(o,a),e.closePath()}else e.endFill()}),ER=Yr((n,e)=>{const t=i=>i.points.reduce((r,s)=>[...r,...s],[]);n.geometry.polygons.forEach(i=>
1216{const[r,...s]=i.rings;e.drawPolygon(t(r)),s.forEach(o=>{e.beginHole(),e.drawPolygon(t(o)),e.endHole()})})}),jh=n=>{const e=n.viewport.getContainerSize().x;return n.viewport.getZoom(!0)*e/n.world.getContentFactor()},Yf=(n,e,t,i)=>()=>{const r=jh(n);(r!==Hn||!en)&&(en=!0,t.forEach(({stroke:h,strokeWidth:u})=>{const{lineStyle:c}=h.geometry.graphicsData[0];u>1?(en=r===Hn,c.width=u/r,c.native=!1,h.geometry.invalidate()):u===1&&!c.native&&(c.width=1,c.native=!0,h.geometry.invalidate())})),Hn=r;const s=n.viewport.getFlip();let o=Math.PI*n.viewport.getRotation(!0)/180;o=(o%(2*Math.PI)+2*Math.PI)%(2*Math.PI);const a=n.viewport.getContainerSize(),l=n.viewport.pixelFromPoint(new Sp.Point(0,0),!0);s?(e.scale.set(-r,r),e.rotation=-o,e.position.x=a.x-l.x,e.position.y=l.y):(e.scale.set(r,r),e.rotation=o,e.position.x=l.x,e.position.y=l.y),i.render(e)},bR=(n,e)=>{const t=new Ds,i=fm({width:e.width,height:e.height,backgroundAlpha:0,view:e,antialias:!0,resolution:2}),r=new Map;let s=new Set,o,a;Hn=jh(n);const l=(x,y)=>{Hn=jh(n),en=!1;const E=r.get(x.id);E&&(E.fill.destroy(),E.stroke.destroy());const{selector:R}=x.target,P=typeof a=="function"?a(x,y):a;let S;if(R.type===$e.RECTANGLE)S=yR(t,R,P);else if(R.type===$e.POLYGON)S=wR(t,R,P);else if(R.type===$e.ELLIPSE)S=xR(t,R,P);else if(R.type===$e.MULTIPOLYGON)S=ER(t,R,P);else if(R.type===$e.POLYLINE){const L=R;S=TR(t,L,P,{strokeOnly:!L.geometry.closed})}else R.type===$e.LINE?S=_R(t,R,P):console.warn(`Unsupported shape type: ${R.type}`);S&&r.set(x.id,{annotation:x,...S})},h=x=>{const y=r.get(x.id);y&&(r.delete(x.id),y.fill.destroy(),y.stroke.destroy())},u=(x,y,E)=>{en=!1;const R=r.get(x.id);if(R&&(r.delete(x.id),R.fill.destroy(),R.stroke.destroy(),l(y,E),s.has(y.id))){const{fill:P,stroke:S}=r.get(y.id);t.removeChild(P),t.removeChild(S)}},c=(x,y)=>{const E=r.get(x);E&&(r.delete(x),E.fill.destroy(),E.stroke.destroy(),l(E.annotation,y))},d=(x,y)=>{i.resize(x,y),i.render(t)},f=x=>{en=!1;const{children:y}=t;r.forEach(({fill:E,stroke:R,annotation:P})=>{const S=x?s.has(P.id)||x(P):!0;S&&!y.includes(E)?(t.addChild(E),t.addChild(R)):!S&&y.includes(E)&&(t.removeChild(E),t.removeChild(R))}),i.render(t)},p=x=>{const y=new Set(x.selected.filter(P=>P.editable).map(P=>P.id)),E=x.selected.filter(({id:P})=>!s.has(P)),R=[...s].filter(P=>!y.has(P));E.forEach(({id:P,editable:S})=>{if(S){const L=r.get(P);L&&Qp(L.annotation.target.selector)&&(t.removeChild(L.fill),t.removeChild(L.stroke))}else c(P,{selected:!0,hovered:P===o})}),R.forEach(P=>c(P,{hovered:P===o})),s=y,i.render(t)},g=x=>{o!==x&&(x&&s.has(x)||(o&&!s.has(o)&&c(o,{selected:s.has(o)}),x&&c(x,{selected:s.has(x),hovered:!0}),o=x,i.render(t)))},v=x=>{if(typeof x=="function")r.forEach(({annotation:y,fill:E,stroke:R,strokeWidth:P},S)=>{P>1&&(en=!1);const L={selected:s.has(y.id),hovered:o===y.id},{fillStyle:k,strokeStyle:W}=Vh(x(y,L));E.tint=k.tint,E.alpha=k.alpha,R.tint=W.tint||16777215,R.alpha=W.alpha,r.set(y.id,{annotation:y,fill:E,stroke:R,strokeWidth:W.lineWidth})});else{const{fillStyle:y,strokeStyle:E}=Vh(x);E.lineWidth>1&&(en=!1),r.forEach(({annotation:R,fill:P,stroke:S,strokeWidth:L},k)=>{P.tint=y.tint,P.alpha=y.alpha,S.tint=E.tint||16777215,S.alpha=E.alpha,r.set(R.id,{annotation:R,fill:P,stroke:S,strokeWidth:E.lineWidth})})}a=x,i.render(t),Yf(n,t,r,i)()},m=x=>{x?e.classList.remove("hidden"):e.classList.add("hidden")};return{addAnnotation:l,destroy:()=>i.destroy(),getScale:()=>Hn,redraw:Yf(n,t,r,i),removeAnnotation:h,resize:d,setFilter:f,setHovered:g,setSelected:p,setStyle:v,setVisible:m,updateAnnotation:u}},Bn=(n,e)=>{const[t,i]=$p(n.element,e);return new zi.Point(t,i)},gs=(n,e)=>{const t=n.viewport;if(t.getFlip()){const i=t.getContainerSize(),r=i.x-e.x,s=e.y,o=t.getBoundsNoRotate(!0),a=o.x+r/i.x*o.width,l=o.y+s/i.x*o.width,h=t.getRotation(!0);if(h===0)return t.viewportToImageCoordinates(new zi.Point(a,l));{const u=t.getCenter(!0),c=-h*Math.PI/180,d=Math.cos(c),f=Math.sin(c),p=a-u.x,g=l-u.y,v=u.x+p*d-g*f,m=u.y+p*f+g*d;return t.viewportToImageCoordinates(new zi.Point(v,m))}}else return t.viewportToImageCoordinates(t.pointFromPixel(e,!0))},qm=(n,e,t,i)=>{if(!i)return n;if(e.shiftKey||e.ctrlKey||e.metaKey){const r=(t.selected||[]).map(s=>s.id);return r.includes(n)?r.filter(s=>s!==n):[...r,n]}else return n};function SR(n,e,t){let i,r,{filter:s}=e,{state:o}=e,{style:a}=e,{viewer:l}=e,{visible:h=!0}=e,{polygonSimplificationTolerance:u=1}=e;const{store:c,hover:d,selection:f,viewport:p}=o;Ss(n,d,L=>t(12,i=L)),Ss(n,f,L=>t(9,r=L));const g=cu(),v=ti?10:2;let m,x;const y=()=>v/m.getScale(),E=L=>{const{x:k,y:W}=Bn(l,L.originalEvent);x={x:k,y:W}},R=L=>k=>{const{x:W,y:j}=gs(l,Bn(l,k)),V=y(),N=c.getAt(W,j,s,V);N?(L.classList.add("hover"),i!==N.id&&(d.set(N.id),m.setHovered(N.id))):(L.classList.remove("hover"),i&&(d.set(void 0),m.setHovered(void 0)))},P=L=>{if(!x)return;const k=L.originalEvent,{x:W,y:j}=Bn(l,k),V=W-x.x,N=j-x.y;if(Math.sqrt(V*V+N*N)<5){const{x:D,y:A}=gs(l,Bn(l,k)),O=y(),B=c.getAt(D,A,s,O,!0).filter(G=>f.evalSelectAction(G)!==su.NONE)[0];B?g("click",{originalEvent:k,annotation:B}):g("click",{originalEvent:k})}x=void 0};let S;return Us(()=>{var L;const{offsetWidth:k,offsetHeight:W}=l.canvas,j=document.createElement("canvas");j.width=k,j.height=W,j.className="a9s-gl-canvas",(L=l.element.querySelector(".openseadragon-canvas"))==null||L.appendChild(j),t(8,m=bR(l,j));const V=R(j);j.addEventListener("pointermove",V);const N=new ResizeObserver(Y=>{try{const{width:z,height:b}=Y[0].contentRect;j.width=z,j.height=b,m.resize(z,b)}catch{console.warn("WebGL canvas already disposed")}});N.observe(j);const D=()=>{const Y=l.viewport.getBounds();S=l.viewport.viewportToImageRectangle(Y);const{x:z,y:b,width:H,height:X}=S,$=c.getIntersecting(z,b,H,X);p.set($.map(re=>re.id))};l.addHandler("canvas-press",E),l.addHandler("canvas-release",P),l.addHandler("update-viewport",m.redraw),l.addHandler("animation-finish",D);const A=Y=>Y.filter(z=>nn(z)),O=Y=>nn(Y.oldValue)&&nn(Y.newValue),B=Y=>{const{selector:z}=Y.target;if(z.type===$e.POLYGON){const b=Uw(z,u);return{...Y,target:{...Y.target,selector:{...b}}}}else if(z.type===$e.MULTIPOLYGON){const b=Nw(z,u);return{...Y,target:{...Y.target,selector:{...b}}}}else return Y},G=Y=>{const{created:z,updated:b,deleted:H}=Y.changes,X=(z||[]).filter($=>nn($)).map(B);
1216if(A(H||[]).forEach($=>m.removeAnnotation($)),X.forEach($=>m.addAnnotation($)),(b||[]).filter($=>O($)).map(({oldValue:$,newValue:re})=>({oldValue:$,newValue:B(re)})).forEach(({oldValue:$,newValue:re})=>m.updateAnnotation($,re)),S){const{x:$,y:re,width:se,height:ce}=S,ie=c.getIntersecting($,re,se,ce);p.set(ie.map(ge=>ge.id))}else p.set(c.all().map($=>$.id));m.redraw()};return c.observe(G),()=>{var Y;j.removeEventListener("pointermove",V),N.disconnect(),l.removeHandler("canvas-press",E),l.removeHandler("canvas-release",P),l.removeHandler("update-viewport",m.redraw),l.removeHandler("animation-finish",D),c.unobserve(G),m.destroy(),(Y=j.parentNode)==null||Y.removeChild(j)}}),n.$$set=L=>{"filter"in L&&t(2,s=L.filter),"state"in L&&t(3,o=L.state),"style"in L&&t(4,a=L.style),"viewer"in L&&t(5,l=L.viewer),"visible"in L&&t(6,h=L.visible),"polygonSimplificationTolerance"in L&&t(7,u=L.polygonSimplificationTolerance)},n.$$.update=()=>{n.$$.dirty&260&&m?.setFilter(s),n.$$.dirty&768&&m?.setSelected(r),n.$$.dirty&272&&m?.setStyle(a),n.$$.dirty&320&&m?.setVisible(h)},[d,f,s,o,a,l,h,u,m,r]}class AR extends Ot{constructor(e){super(),Dt(this,e,SR,null,Et,{filter:2,state:3,style:4,viewer:5,visible:6,polygonSimplificationTolerance:7})}}const RR=n=>({transform:n&2,scale:n&1}),qf=n=>({transform:n[1],scale:n[0]});function PR(n){let e;const t=n[4].default,i=pw(t,n,n[3],qf);return{c(){i&&i.c()},m(r,s){i&&i.m(r,s),e=!0},p(r,[s]){i&&i.p&&(!e||s&11)&&mw(i,t,r,r[3],e?gw(t,r[3],s,RR):vw(r[3]),qf)},i(r){e||(Me(i,r),e=!0)},o(r){ke(i,r),e=!1},d(r){i&&i.d(r)}}}function CR(n,e,t){let{$$slots:i={},$$scope:r}=e,{viewer:s}=e,o=1,a;const l=()=>{const h=s.viewport.getContainerSize().x,u=s.viewport.getZoom(!0),c=s.viewport.getFlip(),d=s.viewport.pixelFromPoint(new zi.Point(0,0),!0);c&&(d.x=h-d.x);const f=u*h/s.world.getContentFactor(),p=c?-f:f,g=s.viewport.getRotation(!0);t(1,a=`translate(${d.x}, ${d.y}) scale(${p}, ${f}) rotate(${g})`),t(0,o=u*h/s.world.getContentFactor())};return Us(()=>(s.addHandler("update-viewport",l),()=>{s.removeHandler("update-viewport",l)})),n.$$set=h=>{"viewer"in h&&t(2,s=h.viewer),"$$scope"in h&&t(3,r=h.$$scope)},[o,a,s,r,i]}class Su extends Ot{constructor(e){super(),Dt(this,e,CR,PR,Et,{viewer:2})}}function IR(n,e,t){const i=cu();let{drawingMode:r}=e,{opts:s}=e,{target:o}=e,{tool:a}=e,{transform:l}=e,{viewer:h}=e,{viewportScale:u}=e,c;return Us(()=>{const d=o.closest("svg"),f=[],p=(g,v,m)=>{if(d?.addEventListener(g,v,m),f.push(()=>d?.removeEventListener(g,v,m)),g==="pointerup"||g==="dblclick"){const x=E=>{const{originalEvent:R}=E;v(R)},y=g==="pointerup"?"canvas-click":"canvas-double-click";h.addHandler(y,x),f.push(()=>h.removeHandler(y,x))}else if(g==="pointermove"){const x=y=>{const{originalEvent:E}=y;v(E)};h.addHandler("canvas-drag",x),f.push(()=>h.removeHandler("canvas-drag",x))}};return t(7,c=new a({target:o,props:{addEventListener:p,drawingMode:r,opts:s,transform:l,viewportScale:u,svgEl:d}})),c.$on("create",g=>i("create",g.detail)),()=>{f.forEach(g=>g()),c.$destroy()}}),n.$$set=d=>{"drawingMode"in d&&t(0,r=d.drawingMode),"opts"in d&&t(1,s=d.opts),"target"in d&&t(2,o=d.target),"tool"in d&&t(3,a=d.tool),"transform"in d&&t(4,l=d.transform),"viewer"in d&&t(5,h=d.viewer),"viewportScale"in d&&t(6,u=d.viewportScale)},n.$$.update=()=>{n.$$.dirty&144&&c&&c.$set({transform:l}),n.$$.dirty&192&&c&&c.$set({viewportScale:u})},[r,s,o,a,l,h,u,c]}class MR extends Ot{constructor(e){super(),Dt(this,e,IR,null,Et,{drawingMode:0,opts:1,target:2,tool:3,transform:4,viewer:5,viewportScale:6})}}const{Boolean:DR}=hu;function $f(n,e,t){const i=n.slice();i[43]=e[t];const r=i[20](i[43].target.selector);return i[44]=r,i}function OR(n){let e=`${n[2]}-${n[8]}`,t,i,r=Zf(n);return{c(){r.c(),t=Yi()},m(s,o){r.m(s,o),at(s,t,o),i=!0},p(s,o){o[0]&260&&Et(e,e=`${s[2]}-${s[8]}`)?(ri(),ke(r,1,1,ft),si(),r=Zf(s),r.c(),Me(r,1),r.m(t.parentNode,t)):r.p(s,o)},i(s){i||(Me(r),i=!0)},o(s){ke(r),i=!1},d(s){s&&nt(t),r.d(s)}}}function LR(n){let e,t,i=dn(n[10].filter(n[30])),r=[];for(let o=0;o<i.length;o+=1)r[o]=Qf($f(n,i,o));const s=o=>ke(r[o],1,1,()=>{r[o]=null});return{c(){for(let o=0;o<r.length;o+=1)r[o].c();e=Yi()},m(o,a){for(let l=0;l<r.length;l+=1)r[l]&&r[l].m(o,a);at(o,e,a),t=!0},p(o,a){if(a[0]&1426946|a[1]&2048){i=dn(o[10].filter(o[30]));let l;for(l=0;l<i.length;l+=1){const h=$f(o,i,l);r[l]?(r[l].p(h,a),Me(r[l],1)):(r[l]=Qf(h),r[l].c(),Me(r[l],1),r[l].m(e.parentNode,e))}for(ri(),l=i.length;l<r.length;l+=1)s(l);si()}},i(o){if(!t){for(let a=0;a<i.length;a+=1)Me(r[a]);t=!0}},o(o){r=r.filter(DR);for(let a=0;a<r.length;a+=1)ke(r[a]);t=!1},d(o){o&&nt(e),va(r,o)}}}function Zf(n){let e,t;return e=new MR({props:{target:n[9],tool:n[11],drawingMode:n[4],transform:{elementToImage:n[14]},viewer:n[3],viewportScale:n[42],opts:n[5]}}),e.$on("create",n[19]),{c(){Nt(e.$$.fragment)},m(i,r){It(e,i,r),t=!0},p(i,r){const s={};r[0]&512&&(s.target=i[9]),r[0]&2048&&(s.tool=i[11]),r[0]&16&&(s.drawingMode=i[4]),r[0]&8&&(s.viewer=i[3]),r[1]&2048&&(s.viewportScale=i[42]),r[0]&32&&(s.opts=i[5]),e.$set(s)},i(i){t||(Me(e.$$.fragment,i),t=!0)},o(i){ke(e.$$.fragment,i),t=!1},d(i){Mt(e,i)}}}function Kf(n){let e=n[43].id,t,i,r=Jf(n);return{c(){r.c(),t=Yi()},m(s,o){r.m(s,o),at(s,t,o),i=!0},p(s,o){o[0]&1024&&Et(e,e=s[43].id)?(ri(),ke(r,1,1,ft),si(),r=Jf(s),r.c(),Me(r,1),r.m(t.parentNode,t)):r.p(s,o)},i(s){i||(Me(r),i=!0)},o(s){ke(r),i=!1},d(s){s&&nt(t),r.d(s)}}}function Jf(n){let e,t;return e=new Zw({props:{target:n[9],editor:n[20](n[43].target.selector),annotation:n[43],style:n[1],transform:{elementToImage:n[14]},viewportScale:n[42]}}),e.$on("grab",n[15]),e.$on("change",function(){lu(n[18](n[43]))&&n[18](n[43]).apply(this,arguments)}),e.$on("release",n[16]),{c(){Nt(e.$$.fragment)},m(i,r){It(e,i,r),t=!0},p(i,r){n=i;const s={};r[0]&512&&(s.target=n[9]),r[0]&1024&&(s.editor=n[20](n[43].target.selector)),r[0]&1024&&(s.annotation=n[43]),r[0]&2&&(s.style=n[1]),r[1]&2048&&(s.viewportScale=n[42]),e.$set(s)},i(i){t||(Me(e.$$.fragment,i),t=!0)},o(i){ke(e.$$.fragment,i),t=!1},d(i){Mt(e,i)}}}function Qf(n){let e,t,i=n[44]&&Kf(n);return{c(){i&&i.c(),e=Yi()}
1216,m(r,s){i&&i.m(r,s),at(r,e,s),t=!0},p(r,s){r[44]?i?(i.p(r,s),s[0]&1024&&Me(i,1)):(i=Kf(r),i.c(),Me(i,1),i.m(e.parentNode,e)):i&&(ri(),ke(i,1,1,()=>{i=null}),si())},i(r){t||(Me(i),t=!0)},o(r){ke(i),t=!1},d(r){r&&nt(e),i&&i.d(r)}}}function BR(n){let e,t,i,r,s,o,a,l;const h=[LR,OR],u=[];function c(d,f){var p;return d[9]&&((p=d[10])==null?void 0:p.length)===1?0:d[9]&&d[11]&&d[0]?1:-1}return~(i=c(n))&&(r=u[i]=h[i](n)),{c(){e=ot("svg"),t=ot("g"),r&&r.c(),te(t,"transform",s=n[41]),te(t,"class","svelte-g4ws1v"),te(e,"tabindex",0),te(e,"class","a9s-annotationlayer a9s-osd-drawinglayer svelte-g4ws1v"),te(e,"data-flipped",n[6]),er(e,"drawing",n[0]),er(e,"editing",n[10]),er(e,"hover",n[7])},m(d,f){at(d,e,f),Ri(e,t),~i&&u[i].m(t,null),n[31](t),o=!0,a||(l=yw(e,"pointermove",n[17]),a=!0)},p(d,f){let p=i;i=c(d),i===p?~i&&u[i].p(d,f):(r&&(ri(),ke(u[p],1,1,()=>{u[p]=null}),si()),~i?(r=u[i],r?r.p(d,f):(r=u[i]=h[i](d),r.c()),Me(r,1),r.m(t,null)):r=null),(!o||f[1]&1024&&s!==(s=d[41]))&&te(t,"transform",s),(!o||f[0]&64)&&te(e,"data-flipped",d[6]),(!o||f[0]&1)&&er(e,"drawing",d[0]),(!o||f[0]&1024)&&er(e,"editing",d[10]),(!o||f[0]&128)&&er(e,"hover",d[7])},i(d){o||(Me(r),o=!0)},o(d){ke(r),o=!1},d(d){d&&nt(e),~i&&u[i].d(),n[31](null),a=!1,l()}}}function FR(n){let e,t;return e=new Su({props:{viewer:n[3],$$slots:{default:[BR,({transform:i,scale:r})=>({41:i,42:r}),({transform:i,scale:r})=>[0,(i?1024:0)|(r?2048:0)]]},$$scope:{ctx:n}}}),{c(){Nt(e.$$.fragment)},m(i,r){It(e,i,r),t=!0},p(i,r){const s={};r[0]&8&&(s.viewer=i[3]),r[0]&4095|r[1]&68608&&(s.$$scope={dirty:r,ctx:i}),e.$set(s)},i(i){t||(Me(e.$$.fragment,i),t=!0)},o(i){ke(e.$$.fragment,i),t=!1},d(i){Mt(e,i)}}}function NR(n,e,t){let i,r,s,o,a,{drawingEnabled:l}=e,{filter:h}=e,{multiSelect:u}=e,{preferredDrawingMode:c}=e,{state:d}=e,{style:f=void 0}=e,{toolName:p=eg()[0]}=e,{user:g}=e,{viewer:v}=e;const m=ti?10:2;let x=v.viewport.getFlip(),y=!1,E=0;const R=()=>t(8,E+=1),P=()=>p,S=()=>l;let L;const{store:k,selection:W,hover:j}=d;Ss(n,W,ie=>t(29,o=ie)),Ss(n,j,ie=>t(34,a=ie));let V,N,D;const A=ie=>{k.unobserve(V);const ge=ie.filter(({editable:de})=>de).map(({id:de})=>de);ge.length>0?(t(10,N=ge.map(de=>k.getAnnotation(de))),V=de=>{const{updated:Te}=de.changes;t(10,N=(Te||[]).map(me=>me.newValue))},k.observe(V,{annotations:ge}),v.forceRedraw()):t(10,N=void 0)},O=(ie,ge)=>{const{x:de,y:Te}=gs(v,new zi.Point(ie,ge));return[de,Te]},B=ie=>{const{x:ge,y:de}=Bn(v,ie);return O(ge,de)},G=()=>{const ie=v.viewport.getContainerSize().x;return v.viewport.getZoom(!0)*ie/v.world.getContentFactor()},Y=()=>m/G(),z=ie=>{v.setMouseNavEnabled(!1),D=ie.timeStamp},b=ie=>{if(v.setMouseNavEnabled(!0),performance.now()-(D||0)<300){const[ge,de]=B(ie.detail),Te=Y(),me=k.getAt(ge,de,void 0,Te,!0).filter(De=>W.evalSelectAction(De)!==su.NONE&&(!h||h(De)))[0];if(me&&!N.find(De=>De.id===me.id)){j.set(me.id);const De=qm(me.id,ie.detail,W,u);W.userSelect(De)}}},H=ie=>{const{x:ge,y:de}=gs(v,Bn(v,ie)),Te=Y(),me=k.getAt(ge,de,h,Te);me?a!==me.id&&j.set(me.id):a&&j.set(void 0)},X=ie=>ge=>{var de;const{target:Te}=ie,me=600*1e3,De=((de=Te.creator)==null?void 0:de.id)!==g.id||!Te.created||new Date().getTime()-Te.created.getTime()>me;k.updateTarget({...Te,selector:ge.detail,created:De?Te.created:new Date,updated:De?new Date:void 0,updatedBy:De?g:void 0})},$=ie=>{const ge=Ww(),de={id:ge,bodies:[],target:{annotation:ge,selector:ie.detail,creator:g,created:new Date}};k.addAnnotation(de),W.setSelected(de.id),v.setMouseNavEnabled(!0)},re=ie=>Qp(ie);Us(()=>{const ie=de=>{if(o.selected.length===0)return;const{x:Te,y:me}=gs(v,Bn(v,de)),De=Y();t(7,y=!!k.getAt(Te,me,h,De))},ge=de=>{t(6,x=de.flipped)};return v.addHandler("flip",ge),v.element.addEventListener("pointermove",ie),()=>{var de;v.removeHandler("flip",ge),(de=v.element)==null||de.removeEventListener("pointermove",ie)}});const se=ie=>nn(ie);function ce(ie){Vo[ie?"unshift":"push"](()=>{L=ie,t(9,L)})}return n.$$set=ie=>{"drawingEnabled"in ie&&t(0,l=ie.drawingEnabled),"filter"in ie&&t(21,h=ie.filter),"multiSelect"in ie&&t(22,u=ie.multiSelect),"preferredDrawingMode"in ie&&t(23,c=ie.preferredDrawingMode),"state"in ie&&t(24,d=ie.state),"style"in ie&&t(1,f=ie.style),"toolName"in ie&&t(2,p=ie.toolName),"user"in ie&&t(25,g=ie.user),"viewer"in ie&&t(3,v=ie.viewer)},n.$$.update=()=>{n.$$.dirty[0]&4&&t(11,{tool:i,opts:r}=tg(p)||{tool:void 0,opts:void 0},i,(t(5,r),t(2,p))),n.$$.dirty[0]&8388640&&t(4,s=r?.drawingMode||c),n.$$.dirty[0]&25&&(l&&s==="drag"?v.setMouseNavEnabled(!1):v.setMouseNavEnabled(!0)),n.$$.dirty[0]&1&&l&&W.clear(),n.$$.dirty[0]&536870937&&o.selected.length===0&&s==="drag"&&l&&v.setMouseNavEnabled(!1),n.$$.dirty[0]&536870912&&A(o.selected)},[l,f,p,v,s,r,x,y,E,L,N,i,W,j,O,z,b,H,X,$,re,h,u,c,d,g,R,P,S,o,se,ce]}class kR extends Ot{constructor(e){super(),Dt(this,e,NR,FR,Et,{drawingEnabled:0,filter:21,multiSelect:22,preferredDrawingMode:23,state:24,style:1,toolName:2,user:25,viewer:3,cancelDrawing:2
12166,getDrawingTool:27,isDrawingEnabled:28},null,[-1,-1])}get cancelDrawing(){return this.$$.ctx[26]}get getDrawingTool(){return this.$$.ctx[27]}get isDrawingEnabled(){return this.$$.ctx[28]}}function UR(n){let e,t,i,r,s,o,a,l=n[2].appearance.label+"",h,u,c,d;return{c(){e=ot("g"),t=ot("rect"),a=ot("text"),h=sg(l),te(t,"class","a9s-presence-label-bg svelte-1rehw2p"),te(t,"x",n[0]),te(t,"y",i=n[1]-18/n[3]),te(t,"height",r=18/n[3]),te(t,"fill",s=n[2].appearance.color),te(t,"stroke",o=n[2].appearance.color),te(a,"font-size",u=12/n[3]),te(a,"x",c=n[0]+Math.round(5/n[3])),te(a,"y",d=n[1]-5/n[3]),te(a,"class","svelte-1rehw2p"),te(e,"class","a9s-presence-label")},m(f,p){at(f,e,p),Ri(e,t),Ri(e,a),Ri(a,h),n[6](e)},p(f,[p]){p&1&&te(t,"x",f[0]),p&10&&i!==(i=f[1]-18/f[3])&&te(t,"y",i),p&8&&r!==(r=18/f[3])&&te(t,"height",r),p&4&&s!==(s=f[2].appearance.color)&&te(t,"fill",s),p&4&&o!==(o=f[2].appearance.color)&&te(t,"stroke",o),p&4&&l!==(l=f[2].appearance.label+"")&&_w(h,l),p&8&&u!==(u=12/f[3])&&te(a,"font-size",u),p&9&&c!==(c=f[0]+Math.round(5/f[3]))&&te(a,"x",c),p&10&&d!==(d=f[1]-5/f[3])&&te(a,"y",d)},i:ft,o:ft,d(f){f&&nt(e),n[6](null)}}}function HR(n,e,t){let{x:i}=e,{y:r}=e,{user:s}=e,{scale:o}=e,{hAlign:a=null}=e,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){Vo[c?"unshift":"push"](()=>{l=c,t(4,l)})}return n.$$set=c=>{"x"in c&&t(0,i=c.x),"y"in c&&t(1,r=c.y),"user"in c&&t(2,s=c.user),"scale"in c&&t(3,o=c.scale),"hAlign"in c&&t(5,a=c.hAlign)},n.$$.update=()=>{n.$$.dirty&24&&l&&h(o)},[i,r,s,o,l,a,u]}class $m extends Ot{constructor(e){super(),Dt(this,e,HR,UR,Et,{x:0,y:1,user:2,scale:3,hAlign:5})}}function GR(n){let e,t,i,r,s,o;return t=new $m({props:{scale:n[1],user:n[0],x:n[3][0],y:n[3][1],hAlign:"CENTER"}}),{c(){e=ot("g"),Nt(t.$$.fragment),i=ot("polygon"),te(i,"class","a9s-presence-shape a9s-presence-polygon svelte-fgq4n0"),te(i,"stroke",r=n[0].appearance.color),te(i,"fill","transparent"),te(i,"points",s=n[2].points.map(ep).join(" ")),te(e,"class","a9s-presence-overlay")},m(a,l){at(a,e,l),It(t,e,null),Ri(e,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]),t.$set(h),(!o||l&1&&r!==(r=a[0].appearance.color))&&te(i,"stroke",r),(!o||l&4&&s!==(s=a[2].points.map(ep).join(" ")))&&te(i,"points",s)},i(a){o||(Me(t.$$.fragment,a),o=!0)},o(a){ke(t.$$.fragment,a),o=!1},d(a){a&&nt(e),Mt(t)}}}const ep=n=>n.join(",");function zR(n,e,t){let i,r,{annotation:s}=e,{user:o}=e,{scale:a}=e;const l=h=>{let[u,...c]=h.points;return c.forEach(([d,f])=>{f<u[1]&&(u=[d,f])}),u};return n.$$set=h=>{"annotation"in h&&t(4,s=h.annotation),"user"in h&&t(0,o=h.user),"scale"in h&&t(1,a=h.scale)},n.$$.update=()=>{n.$$.dirty&16&&t(2,i=s.target.selector.geometry),n.$$.dirty&4&&t(3,r=l(i))},[o,a,i,r,s]}class VR extends Ot{constructor(e){super(),Dt(this,e,zR,GR,Et,{annotation:4,user:0,scale:1})}}function jR(n){let e,t,i,r,s,o,a,l,h;return t=new $m({props:{scale:n[1],user:n[0],x:n[2].x,y:n[2].y}}),{c(){e=ot("g"),Nt(t.$$.fragment),i=ot("rect"),te(i,"class","a9s-presence-shape a9s-presence-rectangle svelte-gze948"),te(i,"stroke",r=n[0].appearance.color),te(i,"fill","transparent"),te(i,"x",s=n[2].x),te(i,"y",o=n[2].y),te(i,"width",a=n[2].w),te(i,"height",l=n[2].h),te(e,"class","a9s-presence-overlay")},m(u,c){at(u,e,c),It(t,e,null),Ri(e,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),t.$set(d),(!h||c&1&&r!==(r=u[0].appearance.color))&&te(i,"stroke",r),(!h||c&4&&s!==(s=u[2].x))&&te(i,"x",s),(!h||c&4&&o!==(o=u[2].y))&&te(i,"y",o),(!h||c&4&&a!==(a=u[2].w))&&te(i,"width",a),(!h||c&4&&l!==(l=u[2].h))&&te(i,"height",l)},i(u){h||(Me(t.$$.fragment,u),h=!0)},o(u){ke(t.$$.fragment,u),h=!1},d(u){u&&nt(e),Mt(t)}}}function XR(n,e,t){let i,{annotation:r}=e,{user:s}=e,{scale:o}=e;return n.$$set=a=>{"annotation"in a&&t(3,r=a.annotation),"user"in a&&t(0,s=a.user),"scale"in a&&t(1,o=a.scale)},n.$$.update=()=>
1216{n.$$.dirty&8&&t(2,i=r.target.selector.geometry)},[s,o,i,r]}class WR extends Ot{constructor(e){super(),Dt(this,e,XR,jR,Et,{annotation:3,user:0,scale:1})}}const{Boolean:YR}=hu;function tp(n,e,t){const i=n.slice();return i[8]=e[t],i}function ip(n){let e,t;return e=new Su({props:{viewer:n[0],$$slots:{default:[ZR,({transform:i,scale:r})=>({6:i,7:r}),({transform:i,scale:r})=>(i?64:0)|(r?128:0)]},$$scope:{ctx:n}}}),{c(){Nt(e.$$.fragment)},m(i,r){It(e,i,r),t=!0},p(i,r){const s={};r&1&&(s.viewer=i[0]),r&2244&&(s.$$scope={dirty:r,ctx:i}),e.$set(s)},i(i){t||(Me(e.$$.fragment,i),t=!0)},o(i){ke(e.$$.fragment,i),t=!1},d(i){Mt(e,i)}}}function np(n){let e,t,i=dn(n[2]),r=[];for(let o=0;o<i.length;o+=1)r[o]=rp(tp(n,i,o));const s=o=>ke(r[o],1,1,()=>{r[o]=null});return{c(){for(let o=0;o<r.length;o+=1)r[o].c();e=Yi()},m(o,a){for(let l=0;l<r.length;l+=1)r[l]&&r[l].m(o,a);at(o,e,a),t=!0},p(o,a){if(a&132){i=dn(o[2]);let l;for(l=0;l<i.length;l+=1){const h=tp(o,i,l);r[l]?(r[l].p(h,a),Me(r[l],1)):(r[l]=rp(h),r[l].c(),Me(r[l],1),r[l].m(e.parentNode,e))}for(ri(),l=i.length;l<r.length;l+=1)s(l);si()}},i(o){if(!t){for(let a=0;a<i.length;a+=1)Me(r[a]);t=!0}},o(o){r=r.filter(YR);for(let a=0;a<r.length;a+=1)ke(r[a]);t=!1},d(o){o&&nt(e),va(r,o)}}}function qR(n){let e,t;return e=new VR({props:{annotation:n[8].annotation,user:n[8].selectedBy,scale:n[7]}}),{c(){Nt(e.$$.fragment)},m(i,r){It(e,i,r),t=!0},p(i,r){const s={};r&4&&(s.annotation=i[8].annotation),r&4&&(s.user=i[8].selectedBy),r&128&&(s.scale=i[7]),e.$set(s)},i(i){t||(Me(e.$$.fragment,i),t=!0)},o(i){ke(e.$$.fragment,i),t=!1},d(i){Mt(e,i)}}}function $R(n){let e,t;return e=new WR({props:{annotation:n[8].annotation,user:n[8].selectedBy,scale:n[7]}}),{c(){Nt(e.$$.fragment)},m(i,r){It(e,i,r),t=!0},p(i,r){const s={};r&4&&(s.annotation=i[8].annotation),r&4&&(s.user=i[8].selectedBy),r&128&&(s.scale=i[7]),e.$set(s)},i(i){t||(Me(e.$$.fragment,i),t=!0)},o(i){ke(e.$$.fragment,i),t=!1},d(i){Mt(e,i)}}}function rp(n){let e,t,i,r;const s=[$R,qR],o=[];function a(l,h){return l[8].annotation.target.selector.type===$e.RECTANGLE?0:l[8].annotation.target.selector.type===$e.POLYGON?1:-1}return~(e=a(n))&&(t=o[e]=s[e](n)),{c(){t&&t.c(),i=Yi()},m(l,h){~e&&o[e].m(l,h),at(l,i,h),r=!0},p(l,h){let u=e;e=a(l),e===u?~e&&o[e].p(l,h):(t&&(ri(),ke(o[u],1,1,()=>{o[u]=null}),si()),~e?(t=o[e],t?t.p(l,h):(t=o[e]=s[e](l),t.c()),Me(t,1),t.m(i.parentNode,i)):t=null)},i(l){r||(Me(t),r=!0)},o(l){ke(t),r=!1},d(l){l&&nt(i),~e&&o[e].d(l)}}}function ZR(n){let e,t,i,r,s=n[2].length>0&&np(n);return{c(){e=ot("svg"),t=ot("g"),s&&s.c(),te(t,"transform",i=n[6]),te(e,"class","a9s-osd-presencelayer svelte-1krwc4m")},m(o,a){at(o,e,a),Ri(e,t),s&&s.m(t,null),r=!0},p(o,a){o[2].length>0?s?(s.p(o,a),a&4&&Me(s,1)):(s=np(o),s.c(),Me(s,1),s.m(t,null)):s&&(ri(),ke(s,1,1,()=>{s=null}),si()),(!r||a&64&&i!==(i=o[6]))&&te(t,"transform",i)},i(o){r||(Me(s),r=!0)},o(o){ke(s),r=!1},d(o){o&&nt(e),s&&s.d()}}}function KR(n){let e=!!n[1],t,i,r=e&&ip(n);return{c(){r&&r.c(),t=Yi()},m(s,o){r&&r.m(s,o),at(s,t,o),i=!0},p(s,[o]){o&2&&(e=!!s[1]),e?r?(r.p(s,o),o&2&&Me(r,1)):(r=ip(s),r.c(),Me(r,1),r.m(t.parentNode,t)):r&&(ri(),ke(r,1,1,()=>{r=null}),si())},i(s){i||(Me(r),i=!0)},o(s){ke(r),i=!1},d(s){s&&nt(t),r&&r.d(s)}}}function JR(n,e,t){let{store:i}=e,{viewer:r}=e,{provider:s}=e,o=[],a;const l=(h,u)=>{t(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(v=>v.id)),g=o.filter(({annotation:v})=>!p.has(v.id)).map(v=>{const m=(f||[]).find(x=>x.oldValue.id===v.annotation.id);return m?{selectedBy:v.selectedBy,annotation:m.newValue}:v});t(2,o=g)},i.observe(a,{annotations:o.map(c=>c.annotation.id)})};return Tw(()=>{a&&i.unobserve(a)}),n.$$set=h=>{"store"in h&&t(3,i=h.store),"viewer"in h&&t(0,r=h.viewer),"provider"in h&&t(1,s=h.provider)},n.$$.update=()=>{n.$$.dirty&2&&s&&s.on("selectionChange",l)},[r,s,o,i]}class QR extends Ot{constructor(e){super(),Dt(this,e,JR,KR,Et,{store:3,viewer:0,provider:1})}}function eP(n){let e,t,i,r,s;return{c(){e=ot("ellipse"),te(e,"cx",t=n[0].cx),te(e,"cy",i=n[0].cy),te(e,"rx",r=n[0].rx),te(e,"ry",s=n[0].ry)},m(o,a){at(o,e,a)},p(o,[a]){a&1&&t!==(t=o[0].cx)&&te(e,"cx",t),a&1&&i!==(i=o[0].cy)&&te(e,"cy",i),a&1&&r!==(r=o[0].rx)&&te(e,"rx",r),a&1&&s!==(s=o[0].ry)&&te(e,"ry",s)},i:ft,o:ft,d(o){o&&nt(e)}}}function tP(n,e,t){let i,{annotation:r}=e;return n.$$set=s=>{"annotation"in s&&t(1,r=s.annotation)},n.$$.update=()=>{n.$$.dirty&2&&t(0,i=r.target.selector.geometry)},[i,r]}class iP extends Ot{constructor(e){super(),Dt(this,e,tP,eP,Et,{annotation:1})}}function nP(n){let e,t,i,r,s;return{c(){e=ot("line"),te(e,"x1",t=n[0].points[0][0]),te(e,"y1",i=n[0].points[0][1]),te(e,"x2",r=n[0].points[1][0]),te(e,"y2",s=n[0].points[1][1])},m(o,a){at(o,e,a)},p(o,[a]){a&1&&t!==(t=o[0].points[0][0])&&te(e,"x1",t),a&1&&i!==(i=o[0].points[0][1])&&te(e,"y1",i),a&1&&r!==(r=o[0].points[1][0])&&te(e,"x2",r),a&1&&s!==(s=o[0].points[1][1])&&te(e,"y2",s)},i:ft,o:ft,d(o){o&&nt(e)}}}function rP(n,e,t){let i,{annotation:r}=e;return n.$$set=s=>{"annotation"in s&&t(1,r=s.annotation)},n.$$.update=()=>{n.$$.dirty&2&&t(0,i=r.target.selector.geometry)},[i,r]}class sP extends Ot{constructor(e){super(),Dt(this,e,rP,nP,Et,{annotation:1})}}function sp(n,e,t){const i=n.slice();return i[2]=e[t],i}function op(n){let e,t;return{c(){e=ot("path"),t=ot("path"),te(e,"fill-rule","evenodd"),te(e,"d",Ki(n[2])),te(t,"class","a9s-inner"),te(t,"fill-rule","evenodd"),te(t,"d",Ki(n[2]))},m(i,r){at(i,e,r),at(i,t,r)},p:ft,d(i){i&&(nt(e),nt(t))}}}function oP(n){let e,t=dn(n[0]),i=[];for(let r=0;r<t.length;r+=1)i[r]=op(sp(n,t,r));return{c(){e=ot("g");for(let r=0;r<i.length;r+=1)i[r].c()},m(r,s){at(r,e,s);for(let o=0;o<i.length;o+=1)i[o]&&i[o].m(e,null)}
1216,p(r,[s]){if(s&1){t=dn(r[0]);let o;for(o=0;o<t.length;o+=1){const a=sp(r,t,o);i[o]?i[o].p(a,s):(i[o]=op(a),i[o].c(),i[o].m(e,null))}for(;o<i.length;o+=1)i[o].d(1);i.length=t.length}},i:ft,o:ft,d(r){r&&nt(e),va(i,r)}}}function aP(n,e,t){let{annotation:i}=e;const{polygons:r}=i.target.selector.geometry;return n.$$set=s=>{"annotation"in s&&t(1,i=s.annotation)},[r,i]}class lP extends Ot{constructor(e){super(),Dt(this,e,aP,oP,Et,{annotation:1})}}function hP(n){let e,t;return{c(){e=ot("polygon"),te(e,"points",t=n[0].points.map(ap).join(" "))},m(i,r){at(i,e,r)},p(i,[r]){r&1&&t!==(t=i[0].points.map(ap).join(" "))&&te(e,"points",t)},i:ft,o:ft,d(i){i&&nt(e)}}}const ap=n=>n.join(",");function uP(n,e,t){let i,{annotation:r}=e;return n.$$set=s=>{"annotation"in s&&t(1,r=s.annotation)},n.$$.update=()=>{n.$$.dirty&2&&t(0,i=r.target.selector.geometry)},[i,r]}class cP extends Ot{constructor(e){super(),Dt(this,e,uP,hP,Et,{annotation:1})}}function dP(n){let e;return{c(){e=ot("path"),te(e,"d",n[0])},m(t,i){at(t,e,i)},p(t,[i]){i&1&&te(e,"d",t[0])},i:ft,o:ft,d(t){t&&nt(e)}}}function fP(n,e,t){let i,r,{annotation:s}=e;return n.$$set=o=>{"annotation"in o&&t(1,s=o.annotation)},n.$$.update=()=>{n.$$.dirty&2&&t(2,i=s.target.selector.geometry),n.$$.dirty&4&&t(0,r=k0(i))},[r,s,i]}class pP extends Ot{constructor(e){super(),Dt(this,e,fP,dP,Et,{annotation:1})}}function gP(n){let e,t,i,r,s;return{c(){e=ot("rect"),te(e,"x",t=n[0].x),te(e,"y",i=n[0].y),te(e,"width",r=n[0].w),te(e,"height",s=n[0].h)},m(o,a){at(o,e,a)},p(o,[a]){a&1&&t!==(t=o[0].x)&&te(e,"x",t),a&1&&i!==(i=o[0].y)&&te(e,"y",i),a&1&&r!==(r=o[0].w)&&te(e,"width",r),a&1&&s!==(s=o[0].h)&&te(e,"height",s)},i:ft,o:ft,d(o){o&&nt(e)}}}function mP(n,e,t){let i,{annotation:r}=e;return n.$$set=s=>{"annotation"in s&&t(1,r=s.annotation)},n.$$.update=()=>{n.$$.dirty&2&&t(0,i=r.target.selector.geometry)},[i,r]}class vP extends Ot{constructor(e){super(),Dt(this,e,mP,gP,Et,{annotation:1})}}const{Boolean:yP}=hu;function lp(n,e,t){const i=n.slice();return i[10]=e[t],i}function hp(n){let e,t;return e=new Su({props:{viewer:n[0],$$slots:{default:[SP,({transform:i})=>({9:i}),({transform:i})=>i?512:0]},$$scope:{ctx:n}}}),{c(){Nt(e.$$.fragment)},m(i,r){It(e,i,r),t=!0},p(i,r){const s={};r&1&&(s.viewer=i[0]),r&8710&&(s.$$scope={dirty:r,ctx:i}),e.$set(s)},i(i){t||(Me(e.$$.fragment,i),t=!0)},o(i){ke(e.$$.fragment,i),t=!1},d(i){Mt(e,i)}}}function xP(n){let e,t;return e=new sP({props:{annotation:n[10]}}),{c(){Nt(e.$$.fragment)},m(i,r){It(e,i,r),t=!0},p(i,r){const s={};r&2&&(s.annotation=i[10]),e.$set(s)},i(i){t||(Me(e.$$.fragment,i),t=!0)},o(i){ke(e.$$.fragment,i),t=!1},d(i){Mt(e,i)}}}function _P(n){let e,t;return e=new iP({props:{annotation:n[10]}}),{c(){Nt(e.$$.fragment)},m(i,r){It(e,i,r),t=!0},p(i,r){const s={};r&2&&(s.annotation=i[10]),e.$set(s)},i(i){t||(Me(e.$$.fragment,i),t=!0)},o(i){ke(e.$$.fragment,i),t=!1},d(i){Mt(e,i)}}}function wP(n){let e,t;return e=new pP({props:{annotation:n[10]}}),{c(){Nt(e.$$.fragment)},m(i,r){It(e,i,r),t=!0},p(i,r){const s={};r&2&&(s.annotation=i[10]),e.$set(s)},i(i){t||(Me(e.$$.fragment,i),t=!0)},o(i){ke(e.$$.fragment,i),t=!1},d(i){Mt(e,i)}}}function TP(n){let e,t;return e=new lP({props:{annotation:n[10]}}),{c(){Nt(e.$$.fragment)},m(i,r){It(e,i,r),t=!0},p(i,r){const s={};r&2&&(s.annotation=i[10]),e.$set(s)},i(i){t||(Me(e.$$.fragment,i),t=!0)},o(i){ke(e.$$.fragment,i),t=!1},d(i){Mt(e,i)}}}function EP(n){let e,t;return e=new cP({props:{annotation:n[10]}}),{c(){Nt(e.$$.fragment)},m(i,r){It(e,i,r),t=!0},p(i,r){const s={};r&2&&(s.annotation=i[10]),e.$set(s)},i(i){t||(Me(e.$$.fragment,i),t=!0)},o(i){ke(e.$$.fragment,i),t=!1},d(i){Mt(e,i)}}}function bP(n){let e,t;return e=new vP({props:{annotation:n[10]}}),{c(){Nt(e.$$.fragment)},m(i,r){It(e,i,r),t=!0},p(i,r){const s={};r&2&&(s.annotation=i[10]),e.$set(s)},i(i){t||(Me(e.$$.fragment,i),t=!0)},o(i){ke(e.$$.fragment,i),t=!1},d(i){Mt(e,i)}}}function up(n){let e,t,i,r;const s=[bP,EP,TP,wP,_P,xP],o=[];function a(l,h){return l[10].target.selector.type===$e.RECTANGLE?0:l[10].target.selector.type===$e.POLYGON?1:l[10].target.selector.type===$e.MULTIPOLYGON?2:l[10].target.selector.type===$e.POLYLINE?3:l[10].target.selector.type===$e.ELLIPSE?4:l[10].target.selector.type===$e.LINE?5:-1}return~(e=a(n))&&(t=o[e]=s[e](n)),{c(){t&&t.c(),i=Yi()},m(l,h){~e&&o[e].m(l,h),at(l,i,h),r=!0},p(l,h){let u=e;e=a(l),e===u?~e&&o[e].p(l,h):(t&&(ri(),ke(o[u],1,1,()=>{o[u]=null}),si()),~e?(t=o[e],t?t.p(l,h):(t=o[e]=s[e](l),t.c()),Me(t,1),t.m(i.parentNode,i)):t=null)},i(l){r||(Me(t),r=!0)},o(l){ke(t),r=!1},d(l){l&&nt(i),~e&&o[e].d(l)}}}function SP(n){let e,t,i,r,s,o,a,l,h,u,c,d,f,p,g=dn(n[1].filter(n[6])),v=[];for(let x=0;x<g.length;x+=1)v[x]=up(lp(n,g,x));const m=x=>ke(v[x],1,1,()=>{v[x]=null});return{c(){var x,y,E,R;e=ot("svg"),t=ot("g"),i=ot("rect"),l=ot("rect");for(let P=0;P<v.length;P+=1)v[P].c();te(i,"class","a9s-union-bg svelte-jwrce3"),te(i,"x",r=(x=n[2])==null?void 0:x.minX),te(i,"y",s=(y=n[2])==null?void 0:y.minY),te(i,"width",o=n[2]?n[2].maxX-n[2].minX:0),te(i,"height",a=n[2]?n[2].maxY-n[2].minY:0),te(l,"class","a9s-union-fg svelte-jwrce3"),te(l,"x",h=(E=n[2])==null?void 0:E.minX),te(l,"y",u=(R=n[2])==null?void 0:R.minY),te(l,"width",c=n[2]?n[2].maxX-n[2].minX:0),te(l,"height",d=n[2]?n[2].maxY-n[2].minY:0),te(t,"transform",f=n[9]),te(e,"class","a9s-osd-selectionlayer svelte-jwrce3")},m(x,y){at(x,e,y),Ri(e,t),Ri(t,i),Ri(t,l);for(let E=0;E<v.length;E+=1)v[E]&&v[E].m(t,null);p=!0}
1216,p(x,y){var E,R,P,S;if((!p||y&4&&r!==(r=(E=x[2])==null?void 0:E.minX))&&te(i,"x",r),(!p||y&4&&s!==(s=(R=x[2])==null?void 0:R.minY))&&te(i,"y",s),(!p||y&4&&o!==(o=x[2]?x[2].maxX-x[2].minX:0))&&te(i,"width",o),(!p||y&4&&a!==(a=x[2]?x[2].maxY-x[2].minY:0))&&te(i,"height",a),(!p||y&4&&h!==(h=(P=x[2])==null?void 0:P.minX))&&te(l,"x",h),(!p||y&4&&u!==(u=(S=x[2])==null?void 0:S.minY))&&te(l,"y",u),(!p||y&4&&c!==(c=x[2]?x[2].maxX-x[2].minX:0))&&te(l,"width",c),(!p||y&4&&d!==(d=x[2]?x[2].maxY-x[2].minY:0))&&te(l,"height",d),y&2){g=dn(x[1].filter(x[6]));let L;for(L=0;L<g.length;L+=1){const k=lp(x,g,L);v[L]?(v[L].p(k,y),Me(v[L],1)):(v[L]=up(k),v[L].c(),Me(v[L],1),v[L].m(t,null))}for(ri(),L=g.length;L<v.length;L+=1)m(L);si()}(!p||y&512&&f!==(f=x[9]))&&te(t,"transform",f)},i(x){if(!p){for(let y=0;y<g.length;y+=1)Me(v[y]);p=!0}},o(x){v=v.filter(yP);for(let y=0;y<v.length;y+=1)ke(v[y]);p=!1},d(x){x&&nt(e),va(v,x)}}}function AP(n){let e=!!n[2],t,i,r=e&&hp(n);return{c(){r&&r.c(),t=Yi()},m(s,o){r&&r.m(s,o),at(s,t,o),i=!0},p(s,[o]){o&4&&(e=!!s[2]),e?r?(r.p(s,o),o&4&&Me(r,1)):(r=hp(s),r.c(),Me(r,1),r.m(t.parentNode,t)):r&&(ri(),ke(r,1,1,()=>{r=null}),si())},i(s){i||(Me(r),i=!0)},o(s){ke(r),i=!1},d(s){s&&nt(t),r&&r.d(s)}}}function RP(n,e,t){let i,r,s,{state:o}=e,{viewer:a}=e;const{store:l}=o,{selection:h}=o;Ss(n,h,d=>t(5,s=d));const u=d=>{let f=-1/0,p=-1/0,g=1/0,v=1/0;for(let m of d.filter(x=>nn(x))){const{bounds:x}=m.target.selector.geometry;x.maxX>f&&(f=x.maxX),x.maxY>p&&(p=x.maxY),x.minX<g&&(g=x.minX),x.minY<v&&(v=x.minY)}return a.forceRedraw(),{maxX:f,maxY:p,minX:g,minY:v}},c=d=>nn(d);return n.$$set=d=>{"state"in d&&t(4,o=d.state),"viewer"in d&&t(0,a=d.viewer)},n.$$.update=()=>{n.$$.dirty&32&&t(1,i=s.selected.map(({id:d})=>l.getAnnotation(d))),n.$$.dirty&2&&t(2,r=i.length>1?u(i):void 0)},[a,i,r,h,o,s,c]}class PP extends Ot{constructor(e){super(),Dt(this,e,RP,AP,Et,{state:4,viewer:0})}}const cp=(n,e)=>{e==="auto"?n.addHandler("open",t=>{const i=n.world.getItemCount();n.world.getItemAt(i-1).addOnceHandler("fully-loaded-change",r=>{const{fullyLoaded:s}=r;if(s){const o=n.canvas.querySelector("canvas"),a=lw(o);n.element.setAttribute("data-theme",a)}})}):n.element.setAttribute("data-theme",e)},Zm=(n,e,t)=>(i,r={})=>{const s=typeof i=="string"?i:i.id,o=e.getAnnotation(s);if(!o||!nn(o))return;const a=n.container.getBoundingClientRect(),{padding:l}=r;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:g,maxY:v}=o.target.selector.geometry.bounds,m=g-f,x=v-p,y=f-d*m,E=p-h*x,R=m+(u+d)*m,P=x+(h+c)*x,S=n.viewport.imageToViewportRectangle(y,E,R,P);n.viewport[t](S,r.immediately)},CP=(n,e)=>Zm(n,e,"fitBounds"),IP=(n,e)=>Zm(n,e,"fitBoundsWithConstraints"),MP=(n,e={})=>{const t=hw(e,{drawingEnabled:!1,drawingMode:ti?"drag":"click",userSelectAction:Up.EDIT,theme:"light"}),i=ow(t),{hover:r,selection:s,store:o}=i,a=s0(o,t.initialHistory),l=o0(i,a,t.adapter,t.autoSave);let h=p0(),u=t.drawingEnabled,c=t.drawingMode,d=t.modalSelect;const f=uw(a,n.element),p=new AR({target:n.element,props:{state:i,viewer:n,style:t.style,filter:void 0,polygonSimplificationTolerance:t.polygonSimplificationTolerance}}),g=new QR({target:n.element.querySelector(".openseadragon-canvas"),props:{provider:void 0,store:o,viewer:n}}),v=new kR({target:n.element.querySelector(".openseadragon-canvas"),props:{drawingEnabled:!!u,filter:void 0,multiSelect:t.multiSelect,preferredDrawingMode:c,state:i,style:t.style,user:h,viewer:n}}),m=e.multiSelect?new PP({target:n.element.querySelector(".openseadragon-canvas"),props:{state:i,viewer:n}}):void 0;p.$on("click",H=>{const{originalEvent:X,annotation:$}=H.detail,re=se=>qm(se.id,X,s,t.multiSelect);d?s.isEmpty()&&$&&s.userSelect(re($),X):$&&!(c==="click"&&u)?s.userSelect(re($),X):s.isEmpty()||(t.multiSelect?X.metaKey||X.shiftKey||X.ctrlKey||s.userSelect([],X):s.userSelect([],X))}),n.element.addEventListener("pointerdown",H=>{if(r.current){const X=o.getAnnotation(r.current);l.emit("clickAnnotation",X,H)}}),cp(n,t.theme);const x=l0(i,a,t.adapter),y=()=>v.cancelDrawing(),E=()=>{p.$destroy(),g.$destroy(),v.$destroy(),m?.$destroy(),f.destroy(),a.destroy()},R=CP(n,o),P=IP(n,o),S=()=>v.getDrawingTool(),L=()=>h,k=()=>v.isDrawingEnabled(),W=(H,X,$)=>K_(H,X,$),j=(H,X)=>z_(H,X),V=H=>{if(!tg(H))throw`No drawing tool named ${H}`;v.$set({toolName:H})},N=H=>{u=H,v.$set({drawingEnabled:H})},D=H=>{c=H||(ti?"drag":"click"),v.$set({preferredDrawingMode:c})},A=H=>{p.$set({filter:H}),v.$set({filter:H})},O=H=>d=H,B=H=>{p.$set({style:H}),v.$set({style:H})},G=H=>g.$set({provider:H}),Y=H=>cp(n,H),z=H=>{h=H,v.$set({user:H})},b=H=>p.$set({visible:H});return{...x,cancelDrawing:y,destroy:E,fitBounds:R,fitBoundsWithConstraints:P,getDrawingTool:S,getUser:L,isDrawingEnabled:k,listDrawingTools:eg,on:l.on,off:l.off,registerDrawingTool:W,registerShapeEditor:j,setDrawingEnabled:N,setDrawingMode:D,setDrawingTool:V,setFilter:A,setModalSelect:O,setPresenceProvider:G,setStyle:B,setTheme:Y,setUser:z,setVisible:b,state:i,viewer:n}},Au=le.createContext({viewer:null,setViewer:null}),$P=le.forwardRef((n,e)=>{const{children:t,tool:i,...r}=n,[s,o]=le.useState(),{anno:a,setAnno:l}=le.useContext(Ls);return le.useImperativeHandle(e,()=>
1216a,[a]),le.useEffect(()=>{var h;if(s!=null&&s.element)try{const u=MP(s,r);return l(u),()=>{u.destroy(),l(void 0)}}catch(u){(h=n.onInitError)==null||h.call(n,u)}},[s]),le.useEffect(()=>{a&&a.setDrawingEnabled(n.drawingEnabled)},[a,n.drawingEnabled]),le.useEffect(()=>{a&&a.setDrawingMode(n.drawingMode)},[a,n.drawingMode]),le.useEffect(()=>{a&&a.setFilter(n.filter)},[a,n.filter]),le.useEffect(()=>{a&&a.setVisible(!n.hideAnnotations)},[a,n.hideAnnotations]),le.useEffect(()=>{a&&a.setStyle(n.style)},[a,n.style]),le.useEffect(()=>{a&&a.setDrawingTool(i||"rectangle")},[a,i]),le.useEffect(()=>{a&&a.setModalSelect(n.modalSelect)},[a,n.modalSelect]),le.useEffect(()=>{a&&(n.user?a.setUser(n.user):a.setUser(Yx()))},[a,n.user]),le.useEffect(()=>{a&&a.setUserSelectAction(n.userSelectAction)},[a,n.userSelectAction]),Ei.jsx(Au.Provider,{value:{viewer:s,setViewer:o},children:n.children})}),DP=()=>{const{viewer:n}=le.useContext(Au);return n},OP=(n,e)=>{const{minX:t,minY:i,maxX:r,maxY:s}=e.bounds,{top:o,left:a}=n.element.getBoundingClientRect(),l=n.viewport.imageToViewerElementCoordinates(new zi.Point(t,i)),h=n.viewport.imageToViewerElementCoordinates(new zi.Point(r,s));return new DOMRect(l.x+a,l.y+o,h.x-l.x,h.y-l.y)},LP=n=>{var e;return((e=n?.target)==null?void 0:e.selector)&&"geometry"in n.target.selector},ZP=n=>{var e;const t=Ap(),[i,r]=le.useState(!1),s=DP(),o=le.useRef(null),{selected:a,event:l}=vy(),[h,u]=le.useMemo(()=>{const m=a[0];return LP(m?.annotation)?[m.annotation,m.editable]:[void 0,void 0]},[a]),{refs:c,floatingStyles:d,context:f}=Bx({open:i,onOpenChange:r,placement:n.placement,middleware:[Tx(),xx(10),wx({crossAxis:!0}),_x({crossAxis:!0,boundary:s?.element,padding:{right:5,left:5,top:10,bottom:10}}),Ex({element:o,padding:((e=n.arrowProps)==null?void 0:e.padding)||5})],whileElementsMounted:hx});le.useEffect(()=>{if(a.length===0||!h)r(!1);else{const m=()=>{if(!s.element)return;const x=OP(s,h.target.selector.geometry);c.setReference({getBoundingClientRect:()=>x,getClientRects:()=>Fx(x)})};return window.addEventListener("scroll",m,!0),window.addEventListener("resize",m),s.addHandler("update-viewport",m),m(),r(!0),()=>{window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m),s.removeHandler("update-viewport",m)}}},[n.popup,a,s]);const p=m=>{const x=m.id||Rc();t.state.store.addBody({...m,id:x,annotation:h.id,created:m.created||new Date,creator:t.getUser()})},g=m=>{t.state.store.deleteBody({id:m,annotation:h.id})},v=(m,x)=>{const y=x.id||Rc(),E={updated:new Date,updatedBy:t.getUser(),...x,id:y,annotation:h.id};t.state.store.updateBody(m,E)};return i&&h?Wh.createPortal(Ei.jsxs("div",{className:"a9s-popup a9s-image-popup",ref:c.setFloating,style:d,children:[n.arrow&&Ei.jsx(Px,{ref:o,context:f,...n.arrowProps||{}}),n.popup({annotation:h,editable:u,event:l,onCreateBody:p,onDeleteBody:g,onUpdateBody:v})]}),s.element):null},BP=(n,e)=>{if(!n)return!1;const{tileSources:t,...i}=n,{tileSources:r,...s}=e,o=!Mr(t,r),a=!Mr(i,s);return o&&!a},KP=le.forwardRef((n,e)=>{const{className:t,options:i}=n,r=le.useRef(null),s=le.useRef(null),o=le.useRef(null),{viewer:a,setViewer:l}=le.useContext(Au);return le.useLayoutEffect(()=>{if(r.current&&!s.current){const h=zi({...i,element:r.current});return s.current=h,o.current=i,l&&l(h),()=>{l&&l(void 0),h.destroy(),s.current=void 0}}},[]),le.useLayoutEffect(()=>{const h=s.current,u=o.current;if(!(!h||!u)){if(BP(u,i)){const c=Array.isArray(i.tileSources)?i.tileSources:[i.tileSources];h.world.removeAll(),c.forEach((d,f)=>{const p=typeof d=="object"&&"tileSource"in d?d:{tileSource:d};h.addTiledImage({...p,index:f,success:()=>{f===0&&h.viewport.goHome()}})}),o.current=i}else if(!Mr(u,i)&&(console.warn("Forced re-creation of OpenSeadragon viewer. Beware of race conditions!"),l&&l(void 0),h.destroy(),r.current)){const c=zi({...i,element:r.current});s.current=c,o.current=i,l&&l(c)}}},[i]),le.useImperativeHandle(e,()=>a),Ei.jsx("div",{className:t,ref:r})});export{KP as H,zi as O,WP as Q,fp as R,YP as T,$P as V,vy as X,qP as Y,dp as a,nv as b,Wh as c,FP as d,tv as e,NP as f,Xh as g,Ap as h,ZP as i,Ei as j,kP as k,Sp as o,le as r,Si as x};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.