react-iiif-vault 1.5.3 → 1.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bundle.global.js
CHANGED
|
@@ -8,7 +8,7 @@ Error generating stack: `+g.message+`
|
|
|
8
8
|
`+(d.join(" > ")+`
|
|
9
9
|
|
|
10
10
|
No matching component was found for:
|
|
11
|
-
`)+o.join(" > ")}return null},i.getPublicRootInstance=function(o){if(o=o.current,!o.child)return null;switch(o.child.tag){case 5:return ke(o.child.stateNode);default:return o.child.stateNode}},i.injectIntoDevTools=function(o){if(o={bundleType:o.bundleType,version:o.version,rendererPackageName:o.rendererPackageName,rendererConfig:o.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:c.ReactCurrentDispatcher,findHostInstanceByFiber:Mb,findFiberByHostInstance:o.findFiberByHostInstance||kb,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.2.0"},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")o=!1;else{var s=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(s.isDisabled||!s.supportsFiber)o=!0;else{try{Xa=s.inject(o),un=s}catch{}o=!!s.checkDCE}}return o},i.isAlreadyRendering=function(){return!1},i.observeVisibleRects=function(o,s,u,d){if(!Ti)throw Error(l(363));o=Kd(o,s);var f=Y(o,u,d).disconnect;return{disconnect:function(){f()}}},i.registerMutableSourceForHydration=function(o,s){var u=s._getVersion;u=u(s._source),o.mutableSourceEagerHydrationData==null?o.mutableSourceEagerHydrationData=[s,u]:o.mutableSourceEagerHydrationData.push(s,u)},i.runWithPriority=function(o,s){var u=Fe;try{return Fe=o,s()}finally{Fe=u}},i.shouldError=function(){return null},i.shouldSuspend=function(){return!1},i.updateContainer=function(o,s,u,d){var f=s.current,g=Gt(),b=tr(f);return u=Iy(u),s.context===null?s.context=u:s.pendingContext=u,s=Tn(g,b),s.payload={element:o},d=d===void 0?null:d,d!==null&&(s.callback=d),o=Zn(f,s,b),o!==null&&(Fi(o,f,b,g),rl(o,f,b)),b},i}});var Av=St((vT,Ev)=>{"use strict";Ev.exports=Pv()});var Ws=St((YT,Sx)=>{"use strict";Sx.exports=ReactDOM});var bx=St(Ap=>{"use strict";var wx=Ws();Ap.createRoot=wx.createRoot,Ap.hydrateRoot=wx.hydrateRoot;var XT});var SS=St(xS=>{"use strict";var Ko=q();function DA(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var jA=typeof Object.is=="function"?Object.is:DA,VA=Ko.useState,UA=Ko.useEffect,WA=Ko.useLayoutEffect,HA=Ko.useDebugValue;function qA(e,t){var i=t(),n=VA({inst:{value:i,getSnapshot:t}}),r=n[0].inst,a=n[1];return WA(function(){r.value=i,r.getSnapshot=t,Cf(r)&&a({inst:r})},[e,i,t]),UA(function(){return Cf(r)&&a({inst:r}),e(function(){Cf(r)&&a({inst:r})})},[e]),HA(i),i}function Cf(e){var t=e.getSnapshot;e=e.value;try{var i=t();return!jA(e,i)}catch{return!0}}function QA(e,t){return t()}var $A=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?QA:qA;xS.useSyncExternalStore=Ko.useSyncExternalStore!==void 0?Ko.useSyncExternalStore:$A});var bS=St((xk,wS)=>{"use strict";wS.exports=SS()});var PS=St(CS=>{"use strict";var ac=q(),GA=bS();function YA(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var XA=typeof Object.is=="function"?Object.is:YA,KA=GA.useSyncExternalStore,ZA=ac.useRef,JA=ac.useEffect,eI=ac.useMemo,tI=ac.useDebugValue;CS.useSyncExternalStoreWithSelector=function(e,t,i,n,r){var a=ZA(null);if(a.current===null){var l={hasValue:!1,value:null};a.current=l}else l=a.current;a=eI(function(){function p(w){if(!m){if(m=!0,h=w,w=n(w),r!==void 0&&l.hasValue){var v=l.value;if(r(v,w))return y=v}return y=w}if(v=y,XA(h,w))return v;var x=n(w);return r!==void 0&&r(v,x)?v:(h=w,y=x)}var m=!1,h,y,S=i===void 0?null:i;return[function(){return p(t())},S===null?void 0:function(){return p(S())}]},[t,i,n,r]);var c=KA(e,a[0],a[1]);return JA(function(){l.hasValue=!0,l.value=c},[c]),tI(c),c}});var AS=St((wk,ES)=>{"use strict";ES.exports=PS()});var i1=St((_D,t1)=>{"use strict";(()=>{var e={296:(r,a,l)=>{var c=/^\s+|\s+$/g,p=/^[-+]0x[0-9a-f]+$/i,m=/^0b[01]+$/i,h=/^0o[0-7]+$/i,y=parseInt,S=typeof l.g=="object"&&l.g&&l.g.Object===Object&&l.g,w=typeof self=="object"&&self&&self.Object===Object&&self,v=S||w||Function("return this")(),x=Object.prototype.toString,A=Math.max,C=Math.min,I=function(){return v.Date.now()};function E(z){var M=typeof z;return!!z&&(M=="object"||M=="function")}function L(z){if(typeof z=="number")return z;if(function(V){return typeof V=="symbol"||function(J){return!!J&&typeof J=="object"}(V)&&x.call(V)=="[object Symbol]"}(z))return NaN;if(E(z)){var M=typeof z.valueOf=="function"?z.valueOf():z;z=E(M)?M+"":M}if(typeof z!="string")return z===0?z:+z;z=z.replace(c,"");var Q=m.test(z);return Q||h.test(z)?y(z.slice(2),Q?2:8):p.test(z)?NaN:+z}r.exports=function(z,M,Q){var V,J,U,W,ee,Me,pe=0,Re=!1,ke=!1,He=!0;if(typeof z!="function")throw new TypeError("Expected a function");function qe($e){var N=V,G=J;return V=J=void 0,pe=$e,W=z.apply(G,N)}function $($e){var N=$e-Me;return Me===void 0||N>=M||N<0||ke&&$e-pe>=U}function ve(){var $e=I();if($($e))return it($e);ee=setTimeout(ve,function(N){var G=M-(N-Me);return ke?C(G,U-(N-pe)):G}($e))}function it($e){return ee=void 0,He&&V?qe($e):(V=J=void 0,W)}function Qe(){var $e=I(),N=$($e);if(V=arguments,J=this,Me=$e,N){if(ee===void 0)return function(G){return pe=G,ee=setTimeout(ve,M),Re?qe(G):W}(Me);if(ke)return ee=setTimeout(ve,M),qe(Me)}return ee===void 0&&(ee=setTimeout(ve,M)),W}return M=L(M)||0,E(Q)&&(Re=!!Q.leading,U=(ke="maxWait"in Q)?A(L(Q.maxWait)||0,M):U,He="trailing"in Q?!!Q.trailing:He),Qe.cancel=function(){ee!==void 0&&clearTimeout(ee),pe=0,V=Me=J=ee=void 0},Qe.flush=function(){return ee===void 0?W:it(I())},Qe}},96:(r,a,l)=>{var c="Expected a function",p=NaN,m="[object Symbol]",h=/^\s+|\s+$/g,y=/^[-+]0x[0-9a-f]+$/i,S=/^0b[01]+$/i,w=/^0o[0-7]+$/i,v=parseInt,x=typeof l.g=="object"&&l.g&&l.g.Object===Object&&l.g,A=typeof self=="object"&&self&&self.Object===Object&&self,C=x||A||Function("return this")(),I=Object.prototype.toString,E=Math.max,L=Math.min,z=function(){return C.Date.now()};function M(V){var J=typeof V;return!!V&&(J=="object"||J=="function")}function Q(V){if(typeof V=="number")return V;if(function(W){return typeof W=="symbol"||function(ee){return!!ee&&typeof ee=="object"}(W)&&I.call(W)==m}(V))return p;if(M(V)){var J=typeof V.valueOf=="function"?V.valueOf():V;V=M(J)?J+"":J}if(typeof V!="string")return V===0?V:+V;V=V.replace(h,"");var U=S.test(V);return U||w.test(V)?v(V.slice(2),U?2:8):y.test(V)?p:+V}r.exports=function(V,J,U){var W=!0,ee=!0;if(typeof V!="function")throw new TypeError(c);return M(U)&&(W="leading"in U?!!U.leading:W,ee="trailing"in U?!!U.trailing:ee),function(Me,pe,Re){var ke,He,qe,$,ve,it,Qe=0,$e=!1,N=!1,G=!0;if(typeof Me!="function")throw new TypeError(c);function de(Pe){var ne=ke,he=He;return ke=He=void 0,Qe=Pe,$=Me.apply(he,ne)}function ye(Pe){var ne=Pe-it;return it===void 0||ne>=pe||ne<0||N&&Pe-Qe>=qe}function ge(){var Pe=z();if(ye(Pe))return Ve(Pe);ve=setTimeout(ge,function(ne){var he=pe-(ne-it);return N?L(he,qe-(ne-Qe)):he}(Pe))}function Ve(Pe){return ve=void 0,G&&ke?de(Pe):(ke=He=void 0,$)}function ze(){var Pe=z(),ne=ye(Pe);if(ke=arguments,He=this,it=Pe,ne){if(ve===void 0)return function(he){return Qe=he,ve=setTimeout(ge,pe),$e?de(he):$}(it);if(N)return ve=setTimeout(ge,pe),de(it)}return ve===void 0&&(ve=setTimeout(ge,pe)),$}return pe=Q(pe)||0,M(Re)&&($e=!!Re.leading,qe=(N="maxWait"in Re)?E(Q(Re.maxWait)||0,pe):qe,G="trailing"in Re?!!Re.trailing:G),ze.cancel=function(){ve!==void 0&&clearTimeout(ve),Qe=0,ke=it=He=ve=void 0},ze.flush=function(){return ve===void 0?$:Ve(z())},ze}(V,J,{leading:W,maxWait:J,trailing:ee})}},703:(r,a,l)=>{"use strict";var c=l(414);function p(){}function m(){}m.resetWarningCache=p,r.exports=function(){function h(w,v,x,A,C,I){if(I!==c){var E=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw E.name="Invariant Violation",E}}function y(){return h}h.isRequired=h;var S={array:h,bigint:h,bool:h,func:h,number:h,object:h,string:h,symbol:h,any:h,arrayOf:y,element:h,elementType:h,instanceOf:y,node:h,objectOf:y,oneOf:y,oneOfType:y,shape:y,exact:y,checkPropTypes:m,resetWarningCache:p};return S.PropTypes=S,S}},697:(r,a,l)=>{r.exports=l(703)()},414:r=>{"use strict";r.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}},t={};function i(r){var a=t[r];if(a!==void 0)return a.exports;var l=t[r]={exports:{}};return e[r](l,l.exports,i),l.exports}i.n=r=>{var a=r&&r.__esModule?()=>r.default:()=>r;return i.d(a,{a}),a},i.d=(r,a)=>{for(var l in a)i.o(a,l)&&!i.o(r,l)&&Object.defineProperty(r,l,{enumerable:!0,get:a[l]})},i.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),i.o=(r,a)=>Object.prototype.hasOwnProperty.call(r,a),i.r=r=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})};var n={};(()=>{"use strict";i.r(n),i.d(n,{LazyLoadComponent:()=>Oe,LazyLoadImage:()=>Kc,trackWindowScroll:()=>it});let r=q();var a=i.n(r),l=i(697);let c=Ws();var p=i.n(c);function m(){return typeof window<"u"&&"IntersectionObserver"in window&&"isIntersecting"in window.IntersectionObserverEntry.prototype}function h(Y){return h=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(k){return typeof k}:function(k){return k&&typeof Symbol=="function"&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k},h(Y)}function y(Y,k){var X=Object.keys(Y);if(Object.getOwnPropertySymbols){var K=Object.getOwnPropertySymbols(Y);k&&(K=K.filter(function(be){return Object.getOwnPropertyDescriptor(Y,be).enumerable})),X.push.apply(X,K)}return X}function S(Y,k,X){return(k=v(k))in Y?Object.defineProperty(Y,k,{value:X,enumerable:!0,configurable:!0,writable:!0}):Y[k]=X,Y}function w(Y,k){for(var X=0;X<k.length;X++){var K=k[X];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(Y,v(K.key),K)}}function v(Y){var k=function(X,K){if(h(X)!=="object"||X===null)return X;var be=X[Symbol.toPrimitive];if(be!==void 0){var Ae=be.call(X,"string");if(h(Ae)!=="object")return Ae;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(X)}(Y);return h(k)==="symbol"?k:String(k)}function x(Y,k){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(X,K){return X.__proto__=K,X},x(Y,k)}function A(Y){return A=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(k){return k.__proto__||Object.getPrototypeOf(k)},A(Y)}var C=function(Y){Y.forEach(function(k){k.isIntersecting&&k.target.onVisible()})},I={},E=function(Y){(function(j,H){if(typeof H!="function"&&H!==null)throw new TypeError("Super expression must either be null or a function");j.prototype=Object.create(H&&H.prototype,{constructor:{value:j,writable:!0,configurable:!0}}),Object.defineProperty(j,"prototype",{writable:!1}),H&&x(j,H)})(je,Y);var k,X,K,be,Ae=(K=je,be=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}(),function(){var j,H=A(K);if(be){var ue=A(this).constructor;j=Reflect.construct(H,arguments,ue)}else j=H.apply(this,arguments);return function(oe,se){if(se&&(h(se)==="object"||typeof se=="function"))return se;if(se!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(Ie){if(Ie===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return Ie}(oe)}(this,j)});function je(j){var H;if(function(oe,se){if(!(oe instanceof se))throw new TypeError("Cannot call a class as a function")}(this,je),(H=Ae.call(this,j)).supportsObserver=!j.scrollPosition&&j.useIntersectionObserver&&m(),H.supportsObserver){var ue=j.threshold;H.observer=function(oe){return I[oe]=I[oe]||new IntersectionObserver(C,{rootMargin:oe+"px"}),I[oe]}(ue)}return H}return k=je,X=[{key:"componentDidMount",value:function(){this.placeholder&&this.observer&&(this.placeholder.onVisible=this.props.onVisible,this.observer.observe(this.placeholder)),this.supportsObserver||this.updateVisibility()}},{key:"componentWillUnmount",value:function(){this.observer&&this.placeholder&&this.observer.unobserve(this.placeholder)}},{key:"componentDidUpdate",value:function(){this.supportsObserver||this.updateVisibility()}},{key:"getPlaceholderBoundingBox",value:function(){var j=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.props.scrollPosition,H=this.placeholder.getBoundingClientRect(),ue=p().findDOMNode(this.placeholder).style,oe=parseInt(ue.getPropertyValue("margin-left"),10)||0,se=parseInt(ue.getPropertyValue("margin-top"),10)||0;return{bottom:j.y+H.bottom+se,left:j.x+H.left+oe,right:j.x+H.right+oe,top:j.y+H.top+se}}},{key:"isPlaceholderInViewport",value:function(){if(typeof window>"u"||!this.placeholder)return!1;var j=this.props,H=j.scrollPosition,ue=j.threshold,oe=this.getPlaceholderBoundingBox(H),se=H.y+window.innerHeight,Ie=H.x,Xe=H.x+window.innerWidth,Ke=H.y;return Ke-ue<=oe.bottom&&se+ue>=oe.top&&Ie-ue<=oe.right&&Xe+ue>=oe.left}},{key:"updateVisibility",value:function(){this.isPlaceholderInViewport()&&this.props.onVisible()}},{key:"render",value:function(){var j=this,H=this.props,ue=H.className,oe=H.height,se=H.placeholder,Ie=H.style,Xe=H.width;if(se&&typeof se.type!="function")return a().cloneElement(se,{ref:function(Ue){return j.placeholder=Ue}});var Ke=function(Ue){for(var Et=1;Et<arguments.length;Et++){var st=arguments[Et]!=null?arguments[Et]:{};Et%2?y(Object(st),!0).forEach(function(At){S(Ue,At,st[At])}):Object.getOwnPropertyDescriptors?Object.defineProperties(Ue,Object.getOwnPropertyDescriptors(st)):y(Object(st)).forEach(function(At){Object.defineProperty(Ue,At,Object.getOwnPropertyDescriptor(st,At))})}return Ue}({display:"inline-block"},Ie);return Xe!==void 0&&(Ke.width=Xe),oe!==void 0&&(Ke.height=oe),a().createElement("span",{className:ue,ref:function(Ue){return j.placeholder=Ue},style:Ke},se)}}],X&&w(k.prototype,X),Object.defineProperty(k,"prototype",{writable:!1}),je}(a().Component);E.propTypes={onVisible:l.PropTypes.func.isRequired,className:l.PropTypes.string,height:l.PropTypes.oneOfType([l.PropTypes.number,l.PropTypes.string]),placeholder:l.PropTypes.element,threshold:l.PropTypes.number,useIntersectionObserver:l.PropTypes.bool,scrollPosition:l.PropTypes.shape({x:l.PropTypes.number.isRequired,y:l.PropTypes.number.isRequired}),width:l.PropTypes.oneOfType([l.PropTypes.number,l.PropTypes.string])},E.defaultProps={className:"",placeholder:null,threshold:100,useIntersectionObserver:!0};let L=E;var z=i(296),M=i.n(z),Q=i(96),V=i.n(Q),J=function(Y){var k=getComputedStyle(Y,null);return k.getPropertyValue("overflow")+k.getPropertyValue("overflow-y")+k.getPropertyValue("overflow-x")};let U=function(Y){if(!(Y instanceof HTMLElement))return window;for(var k=Y;k&&k instanceof HTMLElement;){if(/(scroll|auto)/.test(J(k)))return k;k=k.parentNode}return window};function W(Y){return W=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(k){return typeof k}:function(k){return k&&typeof Symbol=="function"&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k},W(Y)}var ee=["delayMethod","delayTime"];function Me(){return Me=Object.assign?Object.assign.bind():function(Y){for(var k=1;k<arguments.length;k++){var X=arguments[k];for(var K in X)Object.prototype.hasOwnProperty.call(X,K)&&(Y[K]=X[K])}return Y},Me.apply(this,arguments)}function pe(Y,k){for(var X=0;X<k.length;X++){var K=k[X];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(Y,(be=function(Ae,je){if(W(Ae)!=="object"||Ae===null)return Ae;var j=Ae[Symbol.toPrimitive];if(j!==void 0){var H=j.call(Ae,"string");if(W(H)!=="object")return H;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(Ae)}(K.key),W(be)==="symbol"?be:String(be)),K)}var be}function Re(Y,k){return Re=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(X,K){return X.__proto__=K,X},Re(Y,k)}function ke(Y,k){if(k&&(W(k)==="object"||typeof k=="function"))return k;if(k!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return He(Y)}function He(Y){if(Y===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return Y}function qe(Y){return qe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(k){return k.__proto__||Object.getPrototypeOf(k)},qe(Y)}var $=function(){return typeof window>"u"?0:window.scrollX||window.pageXOffset},ve=function(){return typeof window>"u"?0:window.scrollY||window.pageYOffset};let it=function(Y){var k=function(X){(function(ue,oe){if(typeof oe!="function"&&oe!==null)throw new TypeError("Super expression must either be null or a function");ue.prototype=Object.create(oe&&oe.prototype,{constructor:{value:ue,writable:!0,configurable:!0}}),Object.defineProperty(ue,"prototype",{writable:!1}),oe&&Re(ue,oe)})(H,X);var K,be,Ae,je,j=(Ae=H,je=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}(),function(){var ue,oe=qe(Ae);if(je){var se=qe(this).constructor;ue=Reflect.construct(oe,arguments,se)}else ue=oe.apply(this,arguments);return ke(this,ue)});function H(ue){var oe;if(function(Ie,Xe){if(!(Ie instanceof Xe))throw new TypeError("Cannot call a class as a function")}(this,H),(oe=j.call(this,ue)).useIntersectionObserver=ue.useIntersectionObserver&&m(),oe.useIntersectionObserver)return ke(oe);var se=oe.onChangeScroll.bind(He(oe));return ue.delayMethod==="debounce"?oe.delayedScroll=M()(se,ue.delayTime):ue.delayMethod==="throttle"&&(oe.delayedScroll=V()(se,ue.delayTime)),oe.state={scrollPosition:{x:$(),y:ve()}},oe.baseComponentRef=a().createRef(),oe}return K=H,(be=[{key:"componentDidMount",value:function(){this.addListeners()}},{key:"componentWillUnmount",value:function(){this.removeListeners()}},{key:"componentDidUpdate",value:function(){typeof window>"u"||this.useIntersectionObserver||U(p().findDOMNode(this.baseComponentRef.current))!==this.scrollElement&&(this.removeListeners(),this.addListeners())}},{key:"addListeners",value:function(){typeof window>"u"||this.useIntersectionObserver||(this.scrollElement=U(p().findDOMNode(this.baseComponentRef.current)),this.scrollElement.addEventListener("scroll",this.delayedScroll,{passive:!0}),window.addEventListener("resize",this.delayedScroll,{passive:!0}),this.scrollElement!==window&&window.addEventListener("scroll",this.delayedScroll,{passive:!0}))}},{key:"removeListeners",value:function(){typeof window>"u"||this.useIntersectionObserver||(this.scrollElement.removeEventListener("scroll",this.delayedScroll),window.removeEventListener("resize",this.delayedScroll),this.scrollElement!==window&&window.removeEventListener("scroll",this.delayedScroll))}},{key:"onChangeScroll",value:function(){this.useIntersectionObserver||this.setState({scrollPosition:{x:$(),y:ve()}})}},{key:"render",value:function(){var ue=this.props,oe=(ue.delayMethod,ue.delayTime,function(Ie,Xe){if(Ie==null)return{};var Ke,Ue,Et=function(At,Gn){if(At==null)return{};var Qi,Ar,gs={},Wa=Object.keys(At);for(Ar=0;Ar<Wa.length;Ar++)Qi=Wa[Ar],Gn.indexOf(Qi)>=0||(gs[Qi]=At[Qi]);return gs}(Ie,Xe);if(Object.getOwnPropertySymbols){var st=Object.getOwnPropertySymbols(Ie);for(Ue=0;Ue<st.length;Ue++)Ke=st[Ue],Xe.indexOf(Ke)>=0||Object.prototype.propertyIsEnumerable.call(Ie,Ke)&&(Et[Ke]=Ie[Ke])}return Et}(ue,ee)),se=this.useIntersectionObserver?null:this.state.scrollPosition;return a().createElement(Y,Me({forwardRef:this.baseComponentRef,scrollPosition:se},oe))}}])&&pe(K.prototype,be),Object.defineProperty(K,"prototype",{writable:!1}),H}(a().Component);return k.propTypes={delayMethod:l.PropTypes.oneOf(["debounce","throttle"]),delayTime:l.PropTypes.number,useIntersectionObserver:l.PropTypes.bool},k.defaultProps={delayMethod:"throttle",delayTime:300,useIntersectionObserver:!0},k};function Qe(Y){return Qe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(k){return typeof k}:function(k){return k&&typeof Symbol=="function"&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k},Qe(Y)}function $e(Y,k){for(var X=0;X<k.length;X++){var K=k[X];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(Y,(be=function(Ae,je){if(Qe(Ae)!=="object"||Ae===null)return Ae;var j=Ae[Symbol.toPrimitive];if(j!==void 0){var H=j.call(Ae,"string");if(Qe(H)!=="object")return H;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(Ae)}(K.key),Qe(be)==="symbol"?be:String(be)),K)}var be}function N(Y,k){return N=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(X,K){return X.__proto__=K,X},N(Y,k)}function G(Y){return G=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(k){return k.__proto__||Object.getPrototypeOf(k)},G(Y)}var de=function(Y){(function(j,H){if(typeof H!="function"&&H!==null)throw new TypeError("Super expression must either be null or a function");j.prototype=Object.create(H&&H.prototype,{constructor:{value:j,writable:!0,configurable:!0}}),Object.defineProperty(j,"prototype",{writable:!1}),H&&N(j,H)})(je,Y);var k,X,K,be,Ae=(K=je,be=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}(),function(){var j,H=G(K);if(be){var ue=G(this).constructor;j=Reflect.construct(H,arguments,ue)}else j=H.apply(this,arguments);return function(oe,se){if(se&&(Qe(se)==="object"||typeof se=="function"))return se;if(se!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(Ie){if(Ie===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return Ie}(oe)}(this,j)});function je(j){return function(H,ue){if(!(H instanceof ue))throw new TypeError("Cannot call a class as a function")}(this,je),Ae.call(this,j)}return k=je,(X=[{key:"render",value:function(){return a().createElement(L,this.props)}}])&&$e(k.prototype,X),Object.defineProperty(k,"prototype",{writable:!1}),je}(a().Component);let ye=it(de);function ge(Y){return ge=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(k){return typeof k}:function(k){return k&&typeof Symbol=="function"&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k},ge(Y)}function Ve(Y,k){for(var X=0;X<k.length;X++){var K=k[X];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(Y,(be=function(Ae,je){if(ge(Ae)!=="object"||Ae===null)return Ae;var j=Ae[Symbol.toPrimitive];if(j!==void 0){var H=j.call(Ae,"string");if(ge(H)!=="object")return H;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(Ae)}(K.key),ge(be)==="symbol"?be:String(be)),K)}var be}function ze(Y,k){return ze=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(X,K){return X.__proto__=K,X},ze(Y,k)}function Pe(Y){if(Y===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return Y}function ne(Y){return ne=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(k){return k.__proto__||Object.getPrototypeOf(k)},ne(Y)}var he=function(Y){(function(j,H){if(typeof H!="function"&&H!==null)throw new TypeError("Super expression must either be null or a function");j.prototype=Object.create(H&&H.prototype,{constructor:{value:j,writable:!0,configurable:!0}}),Object.defineProperty(j,"prototype",{writable:!1}),H&&ze(j,H)})(je,Y);var k,X,K,be,Ae=(K=je,be=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}(),function(){var j,H=ne(K);if(be){var ue=ne(this).constructor;j=Reflect.construct(H,arguments,ue)}else j=H.apply(this,arguments);return function(oe,se){if(se&&(ge(se)==="object"||typeof se=="function"))return se;if(se!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Pe(oe)}(this,j)});function je(j){var H;(function(Xe,Ke){if(!(Xe instanceof Ke))throw new TypeError("Cannot call a class as a function")})(this,je),H=Ae.call(this,j);var ue=j.afterLoad,oe=j.beforeLoad,se=j.scrollPosition,Ie=j.visibleByDefault;return H.state={visible:Ie},Ie&&(oe(),ue()),H.onVisible=H.onVisible.bind(Pe(H)),H.isScrollTracked=!!(se&&Number.isFinite(se.x)&&se.x>=0&&Number.isFinite(se.y)&&se.y>=0),H}return k=je,(X=[{key:"componentDidUpdate",value:function(j,H){H.visible!==this.state.visible&&this.props.afterLoad()}},{key:"onVisible",value:function(){this.props.beforeLoad(),this.setState({visible:!0})}},{key:"render",value:function(){if(this.state.visible)return this.props.children;var j=this.props,H=j.className,ue=j.delayMethod,oe=j.delayTime,se=j.height,Ie=j.placeholder,Xe=j.scrollPosition,Ke=j.style,Ue=j.threshold,Et=j.useIntersectionObserver,st=j.width;return this.isScrollTracked||Et&&m()?a().createElement(L,{className:H,height:se,onVisible:this.onVisible,placeholder:Ie,scrollPosition:Xe,style:Ke,threshold:Ue,useIntersectionObserver:Et,width:st}):a().createElement(ye,{className:H,delayMethod:ue,delayTime:oe,height:se,onVisible:this.onVisible,placeholder:Ie,style:Ke,threshold:Ue,width:st})}}])&&Ve(k.prototype,X),Object.defineProperty(k,"prototype",{writable:!1}),je}(a().Component);he.propTypes={afterLoad:l.PropTypes.func,beforeLoad:l.PropTypes.func,useIntersectionObserver:l.PropTypes.bool,visibleByDefault:l.PropTypes.bool},he.defaultProps={afterLoad:function(){return{}},beforeLoad:function(){return{}},useIntersectionObserver:!0,visibleByDefault:!1};let Oe=he;function ot(Y){return ot=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(k){return typeof k}:function(k){return k&&typeof Symbol=="function"&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k},ot(Y)}var Ri=["afterLoad","beforeLoad","delayMethod","delayTime","effect","placeholder","placeholderSrc","scrollPosition","threshold","useIntersectionObserver","visibleByDefault","wrapperClassName","wrapperProps"];function Dt(Y,k){var X=Object.keys(Y);if(Object.getOwnPropertySymbols){var K=Object.getOwnPropertySymbols(Y);k&&(K=K.filter(function(be){return Object.getOwnPropertyDescriptor(Y,be).enumerable})),X.push.apply(X,K)}return X}function Wt(Y){for(var k=1;k<arguments.length;k++){var X=arguments[k]!=null?arguments[k]:{};k%2?Dt(Object(X),!0).forEach(function(K){ps(Y,K,X[K])}):Object.getOwnPropertyDescriptors?Object.defineProperties(Y,Object.getOwnPropertyDescriptors(X)):Dt(Object(X)).forEach(function(K){Object.defineProperty(Y,K,Object.getOwnPropertyDescriptor(X,K))})}return Y}function ps(Y,k,X){return(k=Ua(k))in Y?Object.defineProperty(Y,k,{value:X,enumerable:!0,configurable:!0,writable:!0}):Y[k]=X,Y}function Ti(){return Ti=Object.assign?Object.assign.bind():function(Y){for(var k=1;k<arguments.length;k++){var X=arguments[k];for(var K in X)Object.prototype.hasOwnProperty.call(X,K)&&(Y[K]=X[K])}return Y},Ti.apply(this,arguments)}function Xc(Y,k){for(var X=0;X<k.length;X++){var K=k[X];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(Y,Ua(K.key),K)}}function Ua(Y){var k=function(X,K){if(ot(X)!=="object"||X===null)return X;var be=X[Symbol.toPrimitive];if(be!==void 0){var Ae=be.call(X,"string");if(ot(Ae)!=="object")return Ae;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(X)}(Y);return ot(k)==="symbol"?k:String(k)}function fs(Y,k){return fs=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(X,K){return X.__proto__=K,X},fs(Y,k)}function ln(Y){return ln=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(k){return k.__proto__||Object.getPrototypeOf(k)},ln(Y)}var ms=function(Y){(function(j,H){if(typeof H!="function"&&H!==null)throw new TypeError("Super expression must either be null or a function");j.prototype=Object.create(H&&H.prototype,{constructor:{value:j,writable:!0,configurable:!0}}),Object.defineProperty(j,"prototype",{writable:!1}),H&&fs(j,H)})(je,Y);var k,X,K,be,Ae=(K=je,be=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}(),function(){var j,H=ln(K);if(be){var ue=ln(this).constructor;j=Reflect.construct(H,arguments,ue)}else j=H.apply(this,arguments);return function(oe,se){if(se&&(ot(se)==="object"||typeof se=="function"))return se;if(se!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(Ie){if(Ie===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return Ie}(oe)}(this,j)});function je(j){var H;return function(ue,oe){if(!(ue instanceof oe))throw new TypeError("Cannot call a class as a function")}(this,je),(H=Ae.call(this,j)).state={loaded:!1},H}return k=je,(X=[{key:"onImageLoad",value:function(){var j=this;return this.state.loaded?null:function(H){j.props.onLoad(H),j.props.afterLoad(),j.setState({loaded:!0})}}},{key:"getImg",value:function(){var j=this.props,H=(j.afterLoad,j.beforeLoad,j.delayMethod,j.delayTime,j.effect,j.placeholder,j.placeholderSrc,j.scrollPosition,j.threshold,j.useIntersectionObserver,j.visibleByDefault,j.wrapperClassName,j.wrapperProps,function(ue,oe){if(ue==null)return{};var se,Ie,Xe=function(Ue,Et){if(Ue==null)return{};var st,At,Gn={},Qi=Object.keys(Ue);for(At=0;At<Qi.length;At++)st=Qi[At],Et.indexOf(st)>=0||(Gn[st]=Ue[st]);return Gn}(ue,oe);if(Object.getOwnPropertySymbols){var Ke=Object.getOwnPropertySymbols(ue);for(Ie=0;Ie<Ke.length;Ie++)se=Ke[Ie],oe.indexOf(se)>=0||Object.prototype.propertyIsEnumerable.call(ue,se)&&(Xe[se]=ue[se])}return Xe}(j,Ri));return a().createElement("img",Ti({},H,{onLoad:this.onImageLoad()}))}},{key:"getLazyLoadImage",value:function(){var j=this.props,H=j.beforeLoad,ue=j.className,oe=j.delayMethod,se=j.delayTime,Ie=j.height,Xe=j.placeholder,Ke=j.scrollPosition,Ue=j.style,Et=j.threshold,st=j.useIntersectionObserver,At=j.visibleByDefault,Gn=j.width;return a().createElement(Oe,{beforeLoad:H,className:ue,delayMethod:oe,delayTime:se,height:Ie,placeholder:Xe,scrollPosition:Ke,style:Ue,threshold:Et,useIntersectionObserver:st,visibleByDefault:At,width:Gn},this.getImg())}},{key:"getWrappedLazyLoadImage",value:function(j){var H=this.props,ue=H.effect,oe=H.height,se=H.placeholderSrc,Ie=H.width,Xe=H.wrapperClassName,Ke=H.wrapperProps,Ue=this.state.loaded,Et=Ue?" lazy-load-image-loaded":"",st=Ue||!se?{}:{backgroundImage:"url(".concat(se,")"),backgroundSize:"100% 100%"};return a().createElement("span",Ti({className:Xe+" lazy-load-image-background "+ue+Et,style:Wt(Wt({},st),{},{color:"transparent",display:"inline-block",height:oe,width:Ie})},Ke),j)}},{key:"render",value:function(){var j=this.props,H=j.effect,ue=j.placeholderSrc,oe=j.visibleByDefault,se=j.wrapperClassName,Ie=j.wrapperProps,Xe=this.getLazyLoadImage();return(H||ue)&&!oe||se||Ie?this.getWrappedLazyLoadImage(Xe):Xe}}])&&Xc(k.prototype,X),Object.defineProperty(k,"prototype",{writable:!1}),je}(a().Component);ms.propTypes={onLoad:l.PropTypes.func,afterLoad:l.PropTypes.func,beforeLoad:l.PropTypes.func,delayMethod:l.PropTypes.string,delayTime:l.PropTypes.number,effect:l.PropTypes.string,placeholderSrc:l.PropTypes.string,threshold:l.PropTypes.number,useIntersectionObserver:l.PropTypes.bool,visibleByDefault:l.PropTypes.bool,wrapperClassName:l.PropTypes.string,wrapperProps:l.PropTypes.object},ms.defaultProps={onLoad:function(){},afterLoad:function(){return{}},beforeLoad:function(){return{}},delayMethod:"throttle",delayTime:300,effect:"",placeholderSrc:null,threshold:100,useIntersectionObserver:!0,visibleByDefault:!1,wrapperClassName:""};let Kc=ms})(),t1.exports=n})()});var ZR={};Db(ZR,{AnnotationContext:()=>jR,AnnotationPageContext:()=>VR,AnnotationStyleProvider:()=>uR,Auth:()=>kf,AuthProvider:()=>_f,AuthRContext:()=>to,AuthReactContext:()=>OS,AuthReactContextActions:()=>LS,CanvasAnnotations:()=>KI,CanvasContext:()=>Vi,CanvasPanel:()=>Bt,CanvasStrategyProvider:()=>cm,CanvasWorldObject:()=>dm,CollectionContext:()=>UR,CombinedMetadata:()=>ZI,ComplexTimelineProvider:()=>gm,ContextBridge:()=>Bf,ControlsReactContext:()=>_a,CreateCustomShape:()=>Hm,CustomContextBridge:()=>qS,CustomContextBridgeProvider:()=>pI,EventsProvider:()=>hI,Image:()=>Jw,ImageService:()=>BR,ImageServiceLoaderContext:()=>jw,InnerViewerProvider:()=>jS,LanguageProvider:()=>VI,LanguageString:()=>Mw,LocaleString:()=>Ii,ManifestContext:()=>xf,ManifestMetadata:()=>eR,MediaPlayerProvider:()=>Oa,Metadata:()=>Da,PolygonSelector:()=>NR,RangeContext:()=>Sf,ReactEventContext:()=>io,ReactVaultContext:()=>mr,Render3DModelStrategy:()=>bm,RenderAccompanyingCanvas:()=>Im,RenderAnnotationStrategy:()=>Cm,RenderAudioStrategy:()=>Am,RenderComplexTimelineStrategy:()=>ym,RenderEmptyStrategy:()=>hm,RenderImageStrategy:()=>Sm,RenderSvgEditorControls:()=>oR,RenderTextualContentStrategy:()=>vm,RenderVideoStrategy:()=>Tm,RenderYouTubeStrategy:()=>_m,ResourceProvider:()=>ei,ResourceReactContext:()=>Js,SelectorControllerProvider:()=>sR,SequenceThumbnails:()=>nR,SimpleViewerProvider:()=>Lf,SimpleViewerReactContext:()=>ts,SingleCanvasThumbnail:()=>Om,StrategyReactContext:()=>Ta,ThumbnailFallbackImage:()=>ho,TranslationProvider:()=>jI,TransliterationProvider:()=>UI,VaultProvider:()=>Kr,ViewerPresetContext:()=>Ui,VirtualAnnotationProvider:()=>Uf,VisibleCanvasReactContext:()=>Jr,authDetailsForResource:()=>If,createAuthStateStore:()=>Ef,createProbe:()=>Af,defaultEmitter:()=>US,emptyActions:()=>Jf,emptyStrategy:()=>em,expandTarget:()=>Nt,findAllCanvasesInRange:()=>oc,findFirstCanvasFromRange:()=>mS,findManifestSelectedRange:()=>NA,findSelectedRange:()=>wf,flattenAnnotationPageIds:()=>tm,formatTime:()=>Pc,get3dStrategy:()=>rm,getComplexTimelineStrategy:()=>om,getDefaultAnnotationStyles:()=>Fm,getImageStrategy:()=>Aa,getManifestSequence:()=>sc,getParsedTargetSelector:()=>wa,getRenderingStrategy:()=>am,getTextualContentStrategy:()=>Ia,getVideoStrategy:()=>Ra,getVisibleCanvasesFromCanvasId:()=>BA,hasAuth:()=>oI,isImageApiSelector:()=>mc,makeAccessServiceRequest:()=>Pf,makeAccessTokenRequest:()=>lc,parseRotation:()=>gc,parseSelector:()=>Wn,parseSpecificResource:()=>kI,svgThemes:()=>v1,unknownResponse:()=>ba,unsupportedStrategy:()=>et,useAnnotation:()=>xa,useAnnotationPage:()=>Gf,useAnnotationPageManager:()=>Pa,useAnnotationStyles:()=>Bm,useAnnotationsAtTime:()=>WR,useAuthActions:()=>zS,useAuthService:()=>FS,useAuthStore:()=>Jo,useAuthToken:()=>aI,useAuthTokens:()=>Rf,useCanvas:()=>Ce,useCanvasChoices:()=>HR,useCanvasClock:()=>qR,useCanvasSequence:()=>bf,useCanvasStartTime:()=>La,useCanvasSubset:()=>QR,useClosestLanguage:()=>Ow,useCollection:()=>$R,useComplexTimeline:()=>qI,useContextBridge:()=>Nf,useCreateLocaleString:()=>WI,useCurrentAuth:()=>sI,useCustomContextBridge:()=>Ff,useDispatch:()=>Df,useEventEmitter:()=>pa,useEventListener:()=>GR,useExistingVault:()=>Zr,useExternalCollection:()=>YR,useExternalManifest:()=>vf,useExternalResource:()=>aa,useIIIFLanguage:()=>Ec,useImage:()=>Bc,useImageService:()=>Qm,useImageServiceLoader:()=>ka,useImageTile:()=>XR,useIsAuthEnabled:()=>Mf,useLoadImageService:()=>Ea,useLocaleString:()=>Lw,useManifest:()=>vt,useMediaActions:()=>$I,useMediaElements:()=>GI,useMediaState:()=>QI,usePaintables:()=>nm,usePaintingAnnotations:()=>oo,usePolygonHelper:()=>Um,useRange:()=>la,useRenderControls:()=>ni,useRenderingStrategy:()=>lm,useResourceContext:()=>Xt,useResourceEvents:()=>ga,useResources:()=>im,useSearchService:()=>Of,useSelectorController:()=>zm,useSelectorEmitter:()=>aR,useSelectorEvents:()=>Lm,useSelectorHelper:()=>lR,useSimpleMediaPlayer:()=>ao,useSimpleViewer:()=>ha,useStrategy:()=>pt,useStyleHelper:()=>KR,useStyles:()=>ro,useSvgEditor:()=>Wm,useThumbnail:()=>Qn,useTranslations:()=>fm,useTransliteration:()=>pm,useVault:()=>_e,useVaultEffect:()=>xm,useVaultSelector:()=>De,useViewerPreset:()=>fa,useVirtualAnnotationPage:()=>jf,useVirtualAnnotationPageContext:()=>Vf,useVisibleCanvases:()=>eo});var Na=R(q(),1);var ii=R(q(),1);var or=(e,t,i)=>{let n=e.length,r=i||re(n);for(let a=0;a<n;a++)r[a]=a%5===0?e[a+1]<t[3]&&e[a+3]>t[1]&&e[a+2]<t[4]&&e[a+4]>t[2]?1:0:e[a];return r};function re(e,t,i){return new Float32Array(e,t,i)}var ky=(e,t,i)=>{let n=e[1]<=t[3]&&e[3]>=t[1]&&e[2]<=t[4]&&e[4]>=t[2],r=i||re(5);return n?(r[0]=1,r[1]=Math.max(e[1],t[1]),r[2]=Math.max(e[2],t[2]),r[3]=Math.min(e[3],t[3]),r[4]=Math.min(e[4],t[4]),r):(r[0]=0,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r)},Oy=e=>e.length/5;var pi=(e,t,i)=>{let n=i||re(9);return n[0]=e[0]*t[0]+e[1]*t[3]+e[2]*t[6],n[1]=e[0]*t[1]+e[1]*t[4]+e[2]*t[7],n[2]=e[0]*t[2]+e[1]*t[5]+e[2]*t[8],n[3]=e[3]*t[0]+e[4]*t[3]+e[5]*t[6],n[4]=e[3]*t[1]+e[4]*t[4]+e[5]*t[7],n[5]=e[3]*t[2]+e[4]*t[5]+e[5]*t[8],n[6]=e[6]*t[0]+e[7]*t[3]+e[8]*t[6],n[7]=e[6]*t[1]+e[7]*t[4]+e[8]*t[7],n[8]=e[6]*t[2]+e[7]*t[5]+e[8]*t[8],n},xe=class e{constructor(t){this.index=0,this.length=t,this.points=re(this.length)}static grid(t=1,i=1){return new e(5*t*i)}static point(t,i){let n=re(5);return n[0]=1,n[1]=t,n[2]=i,n[3]=t,n[4]=i,n}static positionPair(t){let i=re(5);return i[0]=1,i[1]=t.x1,i[2]=t.y1,i[3]=t.x2,i[4]=t.y2,i}static projection(t){return e.singleBox(t.width,t.height,t.x,t.y)}static singleBox(t,i,n=0,r=0){let a=re(5);return a[0]=1,a[1]=n,a[2]=r,a[3]=t+n,a[4]=i+r,a}row(t){return t(this)}addPoints(t,i,n,r){return this.points[this.index]=1,this.points[1+this.index]=t,this.points[2+this.index]=i,this.points[3+this.index]=n,this.points[4+this.index]=r,this.index+=5,this}addBox(t,i,n,r){return this.addPoints(t,i,t+n,i+r),this}build(){return this.points}};var Zt=(e,t)=>{let i=e.length;for(let n=0;n<i;n++)e[n]=n%5===0?t[6]*e[n+1]+t[7]*e[n+2]+t[8]*e[n]:n%5%2===1?t[0]*e[n]+t[1]*e[n+1]+t[2]:t[3]*e[n-1]+t[4]*e[n]+t[5];return e},wi=e=>{let t=re(9);return t[0]=e,t[4]=e,t[8]=1,t},ut=(e,t)=>{let i=re(9);return i[0]=1,i[2]=e,i[4]=1,i[5]=t,i[8]=1,i},On=(e,t,i)=>pi(ut((1-e)*t,(1-e)*i),wi(e)),bi=(e,t,i)=>{let n=e.length,r=i&&i.length>=n?i.slice(0,n):re(n);for(let a=0;a<n;a++)r[a]=a%5===0?t[6]*e[a+1]+t[7]*e[a+2]+t[8]*e[a]:a%5%2===1?t[0]*e[a]+t[1]*e[a+1]+t[2]:t[3]*e[a-1]+t[4]*e[a]+t[5];return r};var Fs=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Vb=typeof AbortController=="function",Nl=Vb?AbortController:class{constructor(){this.signal=new Ly}abort(t=new Error("This operation was aborted")){this.signal.reason=this.signal.reason||t,this.signal.aborted=!0,this.signal.dispatchEvent({type:"abort",target:this.signal})}},Ub=typeof AbortSignal=="function",Wb=typeof Nl.AbortSignal=="function",Ly=Ub?AbortSignal:Wb?Nl.AbortController:class{constructor(){this.reason=void 0,this.aborted=!1,this._listeners=[]}dispatchEvent(t){t.type==="abort"&&(this.aborted=!0,this.onabort(t),this._listeners.forEach(i=>i(t),this))}onabort(){}addEventListener(t,i){t==="abort"&&this._listeners.push(i)}removeEventListener(t,i){t==="abort"&&(this._listeners=this._listeners.filter(n=>n!==i))}},fh=new Set,dh=(e,t)=>{let i=`LRU_CACHE_OPTION_${e}`;Bl(i)&&mh(i,`${e} option`,`options.${t}`,_o)},hh=(e,t)=>{let i=`LRU_CACHE_METHOD_${e}`;if(Bl(i)){let{prototype:n}=_o,{get:r}=Object.getOwnPropertyDescriptor(n,e);mh(i,`${e} method`,`cache.${t}()`,r)}},Hb=(e,t)=>{let i=`LRU_CACHE_PROPERTY_${e}`;if(Bl(i)){let{prototype:n}=_o,{get:r}=Object.getOwnPropertyDescriptor(n,e);mh(i,`${e} property`,`cache.${t}`,r)}},zy=(...e)=>{typeof process=="object"&&process&&typeof process.emitWarning=="function"?process.emitWarning(...e):console.error(...e)},Bl=e=>!fh.has(e),mh=(e,t,i,n)=>{fh.add(e);let r=`The ${t} is deprecated. Please use ${i} instead.`;zy(r,"DeprecationWarning",e,n)},sr=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),Fy=e=>sr(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?To:null:null,To=class extends Array{constructor(t){super(t),this.fill(0)}},ph=class{constructor(t){if(t===0)return[];let i=Fy(t);this.heap=new i(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}},_o=class e{constructor(t={}){let{max:i=0,ttl:n,ttlResolution:r=1,ttlAutopurge:a,updateAgeOnGet:l,updateAgeOnHas:c,allowStale:p,dispose:m,disposeAfter:h,noDisposeOnSet:y,noUpdateTTL:S,maxSize:w=0,maxEntrySize:v=0,sizeCalculation:x,fetchMethod:A,fetchContext:C,noDeleteOnFetchRejection:I,noDeleteOnStaleGet:E,allowStaleOnFetchRejection:L,allowStaleOnFetchAbort:z,ignoreFetchAbort:M}=t,{length:Q,maxAge:V,stale:J}=t instanceof e?{}:t;if(i!==0&&!sr(i))throw new TypeError("max option must be a nonnegative integer");let U=i?Fy(i):Array;if(!U)throw new Error("invalid max value: "+i);if(this.max=i,this.maxSize=w,this.maxEntrySize=v||this.maxSize,this.sizeCalculation=x||Q,this.sizeCalculation){if(!this.maxSize&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(this.fetchMethod=A||null,this.fetchMethod&&typeof this.fetchMethod!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.fetchContext=C,!this.fetchMethod&&C!==void 0)throw new TypeError("cannot set fetchContext without fetchMethod");if(this.keyMap=new Map,this.keyList=new Array(i).fill(null),this.valList=new Array(i).fill(null),this.next=new U(i),this.prev=new U(i),this.head=0,this.tail=0,this.free=new ph(i),this.initialFill=1,this.size=0,typeof m=="function"&&(this.dispose=m),typeof h=="function"?(this.disposeAfter=h,this.disposed=[]):(this.disposeAfter=null,this.disposed=null),this.noDisposeOnSet=!!y,this.noUpdateTTL=!!S,this.noDeleteOnFetchRejection=!!I,this.allowStaleOnFetchRejection=!!L,this.allowStaleOnFetchAbort=!!z,this.ignoreFetchAbort=!!M,this.maxEntrySize!==0){if(this.maxSize!==0&&!sr(this.maxSize))throw new TypeError("maxSize must be a positive integer if specified");if(!sr(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.initializeSizeTracking()}if(this.allowStale=!!p||!!J,this.noDeleteOnStaleGet=!!E,this.updateAgeOnGet=!!l,this.updateAgeOnHas=!!c,this.ttlResolution=sr(r)||r===0?r:1,this.ttlAutopurge=!!a,this.ttl=n||V||0,this.ttl){if(!sr(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.initializeTTLTracking()}if(this.max===0&&this.ttl===0&&this.maxSize===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.max&&!this.maxSize){let W="LRU_CACHE_UNBOUNDED";Bl(W)&&(fh.add(W),zy("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",W,e))}J&&dh("stale","allowStale"),V&&dh("maxAge","ttl"),Q&&dh("length","sizeCalculation")}getRemainingTTL(t){return this.has(t,{updateAgeOnHas:!1})?1/0:0}initializeTTLTracking(){this.ttls=new To(this.max),this.starts=new To(this.max),this.setItemTTL=(n,r,a=Fs.now())=>{if(this.starts[n]=r!==0?a:0,this.ttls[n]=r,r!==0&&this.ttlAutopurge){let l=setTimeout(()=>{this.isStale(n)&&this.delete(this.keyList[n])},r+1);l.unref&&l.unref()}},this.updateItemAge=n=>{this.starts[n]=this.ttls[n]!==0?Fs.now():0},this.statusTTL=(n,r)=>{n&&(n.ttl=this.ttls[r],n.start=this.starts[r],n.now=t||i(),n.remainingTTL=n.now+n.ttl-n.start)};let t=0,i=()=>{let n=Fs.now();if(this.ttlResolution>0){t=n;let r=setTimeout(()=>t=0,this.ttlResolution);r.unref&&r.unref()}return n};this.getRemainingTTL=n=>{let r=this.keyMap.get(n);return r===void 0?0:this.ttls[r]===0||this.starts[r]===0?1/0:this.starts[r]+this.ttls[r]-(t||i())},this.isStale=n=>this.ttls[n]!==0&&this.starts[n]!==0&&(t||i())-this.starts[n]>this.ttls[n]}updateItemAge(t){}statusTTL(t,i){}setItemTTL(t,i,n){}isStale(t){return!1}initializeSizeTracking(){this.calculatedSize=0,this.sizes=new To(this.max),this.removeItemSize=t=>{this.calculatedSize-=this.sizes[t],this.sizes[t]=0},this.requireSize=(t,i,n,r)=>{if(this.isBackgroundFetch(i))return 0;if(!sr(n))if(r){if(typeof r!="function")throw new TypeError("sizeCalculation must be a function");if(n=r(i,t),!sr(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return n},this.addItemSize=(t,i,n)=>{if(this.sizes[t]=i,this.maxSize){let r=this.maxSize-this.sizes[t];for(;this.calculatedSize>r;)this.evict(!0)}this.calculatedSize+=this.sizes[t],n&&(n.entrySize=i,n.totalCalculatedSize=this.calculatedSize)}}removeItemSize(t){}addItemSize(t,i){}requireSize(t,i,n,r){if(n||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache")}*indexes({allowStale:t=this.allowStale}={}){if(this.size)for(let i=this.tail;!(!this.isValidIndex(i)||((t||!this.isStale(i))&&(yield i),i===this.head));)i=this.prev[i]}*rindexes({allowStale:t=this.allowStale}={}){if(this.size)for(let i=this.head;!(!this.isValidIndex(i)||((t||!this.isStale(i))&&(yield i),i===this.tail));)i=this.next[i]}isValidIndex(t){return t!==void 0&&this.keyMap.get(this.keyList[t])===t}*entries(){for(let t of this.indexes())this.valList[t]!==void 0&&this.keyList[t]!==void 0&&!this.isBackgroundFetch(this.valList[t])&&(yield[this.keyList[t],this.valList[t]])}*rentries(){for(let t of this.rindexes())this.valList[t]!==void 0&&this.keyList[t]!==void 0&&!this.isBackgroundFetch(this.valList[t])&&(yield[this.keyList[t],this.valList[t]])}*keys(){for(let t of this.indexes())this.keyList[t]!==void 0&&!this.isBackgroundFetch(this.valList[t])&&(yield this.keyList[t])}*rkeys(){for(let t of this.rindexes())this.keyList[t]!==void 0&&!this.isBackgroundFetch(this.valList[t])&&(yield this.keyList[t])}*values(){for(let t of this.indexes())this.valList[t]!==void 0&&!this.isBackgroundFetch(this.valList[t])&&(yield this.valList[t])}*rvalues(){for(let t of this.rindexes())this.valList[t]!==void 0&&!this.isBackgroundFetch(this.valList[t])&&(yield this.valList[t])}[Symbol.iterator](){return this.entries()}find(t,i){for(let n of this.indexes()){let r=this.valList[n],a=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;if(a!==void 0&&t(a,this.keyList[n],this))return this.get(this.keyList[n],i)}}forEach(t,i=this){for(let n of this.indexes()){let r=this.valList[n],a=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;a!==void 0&&t.call(i,a,this.keyList[n],this)}}rforEach(t,i=this){for(let n of this.rindexes()){let r=this.valList[n],a=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;a!==void 0&&t.call(i,a,this.keyList[n],this)}}get prune(){return hh("prune","purgeStale"),this.purgeStale}purgeStale(){let t=!1;for(let i of this.rindexes({allowStale:!0}))this.isStale(i)&&(this.delete(this.keyList[i]),t=!0);return t}dump(){let t=[];for(let i of this.indexes({allowStale:!0})){let n=this.keyList[i],r=this.valList[i],a=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;if(a===void 0)continue;let l={value:a};if(this.ttls){l.ttl=this.ttls[i];let c=Fs.now()-this.starts[i];l.start=Math.floor(Date.now()-c)}this.sizes&&(l.size=this.sizes[i]),t.unshift([n,l])}return t}load(t){this.clear();for(let[i,n]of t){if(n.start){let r=Date.now()-n.start;n.start=Fs.now()-r}this.set(i,n.value,n)}}dispose(t,i,n){}set(t,i,{ttl:n=this.ttl,start:r,noDisposeOnSet:a=this.noDisposeOnSet,size:l=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:p=this.noUpdateTTL,status:m}={}){if(l=this.requireSize(t,i,l,c),this.maxEntrySize&&l>this.maxEntrySize)return m&&(m.set="miss",m.maxEntrySizeExceeded=!0),this.delete(t),this;let h=this.size===0?void 0:this.keyMap.get(t);if(h===void 0)h=this.newIndex(),this.keyList[h]=t,this.valList[h]=i,this.keyMap.set(t,h),this.next[this.tail]=h,this.prev[h]=this.tail,this.tail=h,this.size++,this.addItemSize(h,l,m),m&&(m.set="add"),p=!1;else{this.moveToTail(h);let y=this.valList[h];if(i!==y){if(this.isBackgroundFetch(y)?y.__abortController.abort(new Error("replaced")):a||(this.dispose(y,t,"set"),this.disposeAfter&&this.disposed.push([y,t,"set"])),this.removeItemSize(h),this.valList[h]=i,this.addItemSize(h,l,m),m){m.set="replace";let S=y&&this.isBackgroundFetch(y)?y.__staleWhileFetching:y;S!==void 0&&(m.oldValue=S)}}else m&&(m.set="update")}if(n!==0&&this.ttl===0&&!this.ttls&&this.initializeTTLTracking(),p||this.setItemTTL(h,n,r),this.statusTTL(m,h),this.disposeAfter)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift());return this}newIndex(){return this.size===0?this.tail:this.size===this.max&&this.max!==0?this.evict(!1):this.free.length!==0?this.free.pop():this.initialFill++}pop(){if(this.size){let t=this.valList[this.head];return this.evict(!0),t}}evict(t){let i=this.head,n=this.keyList[i],r=this.valList[i];return this.isBackgroundFetch(r)?r.__abortController.abort(new Error("evicted")):(this.dispose(r,n,"evict"),this.disposeAfter&&this.disposed.push([r,n,"evict"])),this.removeItemSize(i),t&&(this.keyList[i]=null,this.valList[i]=null,this.free.push(i)),this.head=this.next[i],this.keyMap.delete(n),this.size--,i}has(t,{updateAgeOnHas:i=this.updateAgeOnHas,status:n}={}){let r=this.keyMap.get(t);if(r!==void 0)if(this.isStale(r))n&&(n.has="stale",this.statusTTL(n,r));else return i&&this.updateItemAge(r),n&&(n.has="hit"),this.statusTTL(n,r),!0;else n&&(n.has="miss");return!1}peek(t,{allowStale:i=this.allowStale}={}){let n=this.keyMap.get(t);if(n!==void 0&&(i||!this.isStale(n))){let r=this.valList[n];return this.isBackgroundFetch(r)?r.__staleWhileFetching:r}}backgroundFetch(t,i,n,r){let a=i===void 0?void 0:this.valList[i];if(this.isBackgroundFetch(a))return a;let l=new Nl;n.signal&&n.signal.addEventListener("abort",()=>l.abort(n.signal.reason));let c={signal:l.signal,options:n,context:r},p=(w,v=!1)=>{let{aborted:x}=l.signal,A=n.ignoreFetchAbort&&w!==void 0;return n.status&&(x&&!v?(n.status.fetchAborted=!0,n.status.fetchError=l.signal.reason,A&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),x&&!A&&!v?h(l.signal.reason):(this.valList[i]===S&&(w===void 0?S.__staleWhileFetching?this.valList[i]=S.__staleWhileFetching:this.delete(t):(n.status&&(n.status.fetchUpdated=!0),this.set(t,w,c.options))),w)},m=w=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=w),h(w)),h=w=>{let{aborted:v}=l.signal,x=v&&n.allowStaleOnFetchAbort,A=x||n.allowStaleOnFetchRejection,C=A||n.noDeleteOnFetchRejection;if(this.valList[i]===S&&(!C||S.__staleWhileFetching===void 0?this.delete(t):x||(this.valList[i]=S.__staleWhileFetching)),A)return n.status&&S.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),S.__staleWhileFetching;if(S.__returned===S)throw w},y=(w,v)=>{this.fetchMethod(t,a,c).then(x=>w(x),v),l.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(w(),n.allowStaleOnFetchAbort&&(w=x=>p(x,!0)))})};n.status&&(n.status.fetchDispatched=!0);let S=new Promise(y).then(p,m);return S.__abortController=l,S.__staleWhileFetching=a,S.__returned=null,i===void 0?(this.set(t,S,{...c.options,status:void 0}),i=this.keyMap.get(t)):this.valList[i]=S,S}isBackgroundFetch(t){return t&&typeof t=="object"&&typeof t.then=="function"&&Object.prototype.hasOwnProperty.call(t,"__staleWhileFetching")&&Object.prototype.hasOwnProperty.call(t,"__returned")&&(t.__returned===t||t.__returned===null)}async fetch(t,{allowStale:i=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:c=0,sizeCalculation:p=this.sizeCalculation,noUpdateTTL:m=this.noUpdateTTL,noDeleteOnFetchRejection:h=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:y=this.allowStaleOnFetchRejection,ignoreFetchAbort:S=this.ignoreFetchAbort,allowStaleOnFetchAbort:w=this.allowStaleOnFetchAbort,fetchContext:v=this.fetchContext,forceRefresh:x=!1,status:A,signal:C}={}){if(!this.fetchMethod)return A&&(A.fetch="get"),this.get(t,{allowStale:i,updateAgeOnGet:n,noDeleteOnStaleGet:r,status:A});let I={allowStale:i,updateAgeOnGet:n,noDeleteOnStaleGet:r,ttl:a,noDisposeOnSet:l,size:c,sizeCalculation:p,noUpdateTTL:m,noDeleteOnFetchRejection:h,allowStaleOnFetchRejection:y,allowStaleOnFetchAbort:w,ignoreFetchAbort:S,status:A,signal:C},E=this.keyMap.get(t);if(E===void 0){A&&(A.fetch="miss");let L=this.backgroundFetch(t,E,I,v);return L.__returned=L}else{let L=this.valList[E];if(this.isBackgroundFetch(L)){let J=i&&L.__staleWhileFetching!==void 0;return A&&(A.fetch="inflight",J&&(A.returnedStale=!0)),J?L.__staleWhileFetching:L.__returned=L}let z=this.isStale(E);if(!x&&!z)return A&&(A.fetch="hit"),this.moveToTail(E),n&&this.updateItemAge(E),this.statusTTL(A,E),L;let M=this.backgroundFetch(t,E,I,v),Q=M.__staleWhileFetching!==void 0,V=Q&&i;return A&&(A.fetch=Q&&z?"stale":"refresh",V&&z&&(A.returnedStale=!0)),V?M.__staleWhileFetching:M.__returned=M}}get(t,{allowStale:i=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:a}={}){let l=this.keyMap.get(t);if(l!==void 0){let c=this.valList[l],p=this.isBackgroundFetch(c);return this.statusTTL(a,l),this.isStale(l)?(a&&(a.get="stale"),p?(a&&(a.returnedStale=i&&c.__staleWhileFetching!==void 0),i?c.__staleWhileFetching:void 0):(r||this.delete(t),a&&(a.returnedStale=i),i?c:void 0)):(a&&(a.get="hit"),p?c.__staleWhileFetching:(this.moveToTail(l),n&&this.updateItemAge(l),c))}else a&&(a.get="miss")}connect(t,i){this.prev[i]=t,this.next[t]=i}moveToTail(t){t!==this.tail&&(t===this.head?this.head=this.next[t]:this.connect(this.prev[t],this.next[t]),this.connect(this.tail,t),this.tail=t)}get del(){return hh("del","delete"),this.delete}delete(t){let i=!1;if(this.size!==0){let n=this.keyMap.get(t);if(n!==void 0)if(i=!0,this.size===1)this.clear();else{this.removeItemSize(n);let r=this.valList[n];this.isBackgroundFetch(r)?r.__abortController.abort(new Error("deleted")):(this.dispose(r,t,"delete"),this.disposeAfter&&this.disposed.push([r,t,"delete"])),this.keyMap.delete(t),this.keyList[n]=null,this.valList[n]=null,n===this.tail?this.tail=this.prev[n]:n===this.head?this.head=this.next[n]:(this.next[this.prev[n]]=this.next[n],this.prev[this.next[n]]=this.prev[n]),this.size--,this.free.push(n)}}if(this.disposed)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift());return i}clear(){for(let t of this.rindexes({allowStale:!0})){let i=this.valList[t];if(this.isBackgroundFetch(i))i.__abortController.abort(new Error("deleted"));else{let n=this.keyList[t];this.dispose(i,n,"delete"),this.disposeAfter&&this.disposed.push([i,n,"delete"])}}if(this.keyMap.clear(),this.valList.fill(null),this.keyList.fill(null),this.ttls&&(this.ttls.fill(0),this.starts.fill(0)),this.sizes&&this.sizes.fill(0),this.head=0,this.tail=0,this.initialFill=1,this.free.length=0,this.calculatedSize=0,this.size=0,this.disposed)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift())}get reset(){return hh("reset","clear"),this.clear}get length(){return Hb("length","size"),this.size}static get AbortController(){return Nl}static get AbortSignal(){return Ly}},Ny=_o;var Wx=R(rv(),1);var dt=R(q(),1),Au=R(q(),1),IP=R(B(),1);var Ci=R(q()),Eh=R(uv());function Hl(e){let{debounce:t,scroll:i,polyfill:n,offsetSize:r}=e===void 0?{debounce:0,scroll:!1,offsetSize:!1}:e,a=n||(typeof window>"u"?class{}:window.ResizeObserver);if(!a)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");let[l,c]=(0,Ci.useState)({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),p=(0,Ci.useRef)({element:null,scrollContainers:null,resizeObserver:null,lastBounds:l}),m=t?typeof t=="number"?t:t.scroll:null,h=t?typeof t=="number"?t:t.resize:null,y=(0,Ci.useRef)(!1);(0,Ci.useEffect)(()=>(y.current=!0,()=>void(y.current=!1)));let[S,w,v]=(0,Ci.useMemo)(()=>{let I=()=>{if(!p.current.element)return;let{left:E,top:L,width:z,height:M,bottom:Q,right:V,x:J,y:U}=p.current.element.getBoundingClientRect(),W={left:E,top:L,width:z,height:M,bottom:Q,right:V,x:J,y:U};p.current.element instanceof HTMLElement&&r&&(W.height=p.current.element.offsetHeight,W.width=p.current.element.offsetWidth),Object.freeze(W),y.current&&!rC(p.current.lastBounds,W)&&c(p.current.lastBounds=W)};return[I,h?(0,Eh.default)(I,h):I,m?(0,Eh.default)(I,m):I]},[c,r,m,h]);function x(){p.current.scrollContainers&&(p.current.scrollContainers.forEach(I=>I.removeEventListener("scroll",v,!0)),p.current.scrollContainers=null),p.current.resizeObserver&&(p.current.resizeObserver.disconnect(),p.current.resizeObserver=null)}function A(){p.current.element&&(p.current.resizeObserver=new a(v),p.current.resizeObserver.observe(p.current.element),i&&p.current.scrollContainers&&p.current.scrollContainers.forEach(I=>I.addEventListener("scroll",v,{capture:!0,passive:!0})))}let C=I=>{!I||I===p.current.element||(x(),p.current.element=I,p.current.scrollContainers=cv(I),A())};return iC(v,!!i),tC(w),(0,Ci.useEffect)(()=>{x(),A()},[i,v,w]),(0,Ci.useEffect)(()=>x,[]),[C,l,S]}function tC(e){(0,Ci.useEffect)(()=>{let t=e;return window.addEventListener("resize",t),()=>void window.removeEventListener("resize",t)},[e])}function iC(e,t){(0,Ci.useEffect)(()=>{if(t){let i=e;return window.addEventListener("scroll",i,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",i,!0)}},[e,t])}function cv(e){let t=[];if(!e||e===document.body)return t;let{overflow:i,overflowX:n,overflowY:r}=window.getComputedStyle(e);return[i,n,r].some(a=>a==="auto"||a==="scroll")&&t.push(e),[...t,...cv(e.parentElement)]}var nC=["x","y","top","bottom","left","right","width","height"],rC=(e,t)=>nC.every(i=>e[i]===t[i]);var Lp=R(q(),1),wn=R(q(),1),qx=R(Av(),1),Qx=R(q(),1),Tu=R(q(),1),Lo=R(B(),1),Di=R(q(),1),i0=R(q(),1),n0=R(q(),1),r0=R(B(),1),Jt=R(B(),1),_u=R(q(),1);var Ks=R(B(),1),Fp=R(q(),1),s0=R(q(),1),qP=R(q(),1),a0=R(q(),1),u0=R(q(),1),Sn=R(q(),1),c0=R(q(),1),_p=R(B(),1),d0=R(q(),1),xn=R(q(),1),_t=R(q(),1),h0=R(q(),1),Lu=R(q(),1),wt=R(B(),1),Mp=R(B(),1),kp=R(q(),1),Vr=R(B(),1),f0=R(q(),1);var sC=Object.defineProperty,aC=(e,t,i)=>t in e?sC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Xl=(e,t,i)=>(aC(e,typeof t!="symbol"?t+"":t,i),i);function Dr(e){return e.endsWith("info.json")?e:e.endsWith("/")?`${e}info.json`:`${e}/info.json`}var lC="http://library.stanford.edu/iiif/image-api/compliance.html#level0",_v="http://library.stanford.edu/iiif/image-api/compliance.html#level1",Mv="http://library.stanford.edu/iiif/image-api/compliance.html#level2",uC="http://library.stanford.edu/iiif/image-api/conformance.html#level0",kv="http://library.stanford.edu/iiif/image-api/conformance.html#level1",Ov="http://library.stanford.edu/iiif/image-api/conformance.html#level2",cC="http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0",Lv="http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level1",zv="http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2",dC="http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level0",Fv="http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level1",Nv="http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level2",hC="http://iiif.io/api/image/1/level0.json",pC="http://iiif.io/api/image/1/profiles/level0.json",Bv="http://iiif.io/api/image/1/level1.json",Dv="http://iiif.io/api/image/1/profiles/level1.json",jv="http://iiif.io/api/image/1/level2.json",Vv="http://iiif.io/api/image/1/profiles/level2.json",fC="http://iiif.io/api/image/2/level0.json",mC="http://iiif.io/api/image/2/profiles/level0.json",Uv="http://iiif.io/api/image/2/level1.json",Wv="http://iiif.io/api/image/2/profiles/level1.json",Hv="http://iiif.io/api/image/2/level2.json",qv="http://iiif.io/api/image/2/profiles/level2.json",gC="level0",Qv="level1",$v="level2",yC="http://iiif.io/api/image/2/level0",Gv="http://iiif.io/api/image/2/level1",Yv="http://iiif.io/api/image/2/level2",Xv=[Yv,Mv,Ov,zv,Nv,jv,Vv,Hv,qv,$v],Kv=[...Xv,Gv,_v,kv,Lv,Fv,Bv,Dv,Uv,Wv,Qv],vC=[yC,Gv,Yv,lC,_v,Mv,uC,kv,Ov,cC,Lv,zv,dC,Fv,Nv,hC,pC,Bv,Dv,jv,Vv,fC,mC,Uv,Wv,Hv,qv,gC,Qv,$v];var xC={extraFormats:["jpg"],extraQualities:["default"],extraFeatures:["sizeByWhListed"]},SC={extraFormats:["jpg"],extraQualities:["default"],extraFeatures:["baseUriRedirect","cors","jsonldMediaType","regionByPx","regionSquare","sizeByWhListed","sizeByH","sizeByW","sizeByWh"]},wC={extraFormats:["jpg","png"],extraQualities:["default"],extraFeatures:["baseUriRedirect","cors","jsonldMediaType","regionByPct","regionByPx","regionSquare","rotationBy90s","sizeByWhListed","sizeByConfinedWh","sizeByH","sizeByPct","sizeByW","sizeByWh"]};function bC(e){return Xv.indexOf(e)!==-1?wC:Kv.indexOf(e)!==-1?SC:xC}function CC(e){let t=e?Array.isArray(e.profile)?e.profile:[e.profile]:[],i={extraQualities:[],extraFormats:[],extraFeatures:[]};for(let n of t)if(typeof n=="string"&&(n=bC(n)),!!n){if(n.formats)for(let r of n.formats)i.extraFormats.indexOf(r)===-1&&i.extraFormats.push(r);if(n.qualities)for(let r of n.qualities)i.extraQualities.indexOf(r)===-1&&i.extraQualities.push(r);if(n.supports)for(let r of n.supports)i.extraFeatures.indexOf(r)===-1&&i.extraFeatures.push(r);if(n.maxHeight&&(i.maxHeight=n.maxHeight),n.maxWidth&&(i.maxWidth=n.maxWidth),n.maxArea&&(i.maxArea=n.maxArea),n.extraFormats)for(let r of n.extraFormats)i.extraFormats.indexOf(r)===-1&&i.extraFormats.push(r);if(n.extraQualities)for(let r of n.extraQualities)i.extraQualities.indexOf(r)===-1&&i.extraQualities.push(r);if(n.extraFeatures)for(let r of n.extraFeatures)i.extraFeatures.indexOf(r)===-1&&i.extraFeatures.push(r);n.maxHeight&&(i.maxHeight=n.maxHeight),n.maxWidth&&(i.maxWidth=n.maxWidth),n.maxArea&&(i.maxArea=n.maxArea)}if(e.extraFormats)for(let n of e.extraFormats)i.extraFormats.indexOf(n)===-1&&i.extraFormats.push(n);if(e.extraFeatures)for(let n of e.extraFeatures)i.extraFeatures.indexOf(n)===-1&&i.extraFeatures.push(n);if(e.extraQualities)for(let n of e.extraQualities)i.extraQualities.indexOf(n)===-1&&i.extraQualities.push(n);return i}function PC(e){try{if(e==="full")return{full:!0};if(e==="square")return{square:!0};let t=e.startsWith("pct:"),i=e.substr(t?4:0).split(",").map(n=>parseFloat(n));return{x:i[0],y:i[1],w:i[2],h:i[3],percent:t}}catch{throw new Error("Expected 'full', 'square' or 'x,y,w,h'. Found "+e)}}function EC(e){let t={upscaled:!1,max:!1,confined:!1};if(e[0]==="^"&&(t.upscaled=!0,e=e.slice(1)),e==="max"||e==="full")return t.max=!0,t.serialiseAsFull=e==="full",t;if(e[0]==="!"&&(t.confined=!0,e=e.slice(1)),e[0]==="p")return t.percentScale=parseFloat(e.slice(4)),t;let i=e.split(",").map(n=>n.trim());return i.length&&typeof i[0]<"u"&&(i[0]!==""&&(t.width=parseInt(i[0],10)),typeof i[1]<"u"&&i[1]!==""?(t.height=parseInt(i[1],10),t.version=2):t.version=3),t}function AC(e){let t={angle:0};if(e[0]==="!"&&(t.mirror=!0,e=e.substr(1)),t.angle=parseFloat(e)%360,Number.isNaN(t.angle))throw new Error(`Invalid rotation ${e}`);return t}function IC(e,t=""){let i=e.match(/^(([a-zA-Z]+):\/\/([^/]+))?((.*)+)/);if(!i)throw new Error(`Invalid or unknown input ${e}`);let n=i[2],r=i[3],a=i[4];if(a[0]==="/"&&(a=a.substring(1)),t.length>0){if(t[0]==="/"&&(t=t.substring(1)),t!==a.substring(0,t.length))throw new Error(`Path does not start with prefix (path: ${a}, prefix: ${t})`);a=a.substring(t.length)}return{scheme:n,server:r,path:a,prefix:t}}function RC(e,t=""){let{path:i,scheme:n,server:r,prefix:a}=IC(e,t),l=(i||"").split("/").reverse(),[c,p,m,h,...y]=l,S=y.reverse().filter(Boolean).join("/");if(l.length===1||c==="")return{type:"base",scheme:n,server:r,prefix:a,identifier:S};if(c==="info.json"){let[,...v]=l;return{type:"info",scheme:n,server:r,prefix:a,identifier:v.reverse().filter(Boolean).join("/")}}let w=(c||"").split(".");if(typeof w[1]>"u"||typeof w[0]>"u"||typeof h>"u"||typeof m>"u"||typeof p>"u")throw new Error("Invalid image request");return{type:"image",scheme:n,server:r,prefix:a,identifier:S,originalPath:i,region:PC(h),size:EC(m),rotation:AC(p),quality:w[0],format:w[1]}}function TC(e){let t=RC(Dr(e.id));if(t.type!=="info")throw new Error("Invalid service URL");let i=CC(e);return{identifier:t.identifier,originalPath:"",server:t.server,prefix:t.prefix,scheme:t.scheme,type:"image",quality:i.extraQualities.indexOf("default")===-1?i.extraQualities[0]:"default",region:{full:!0},size:{max:!0,upscaled:!1,confined:!1},format:"jpg",rotation:{angle:0}}}function _C(e,t,i){let n=i.length,r=[];for(let a=0;a<n;a++){let l=i[a];if(l){let c=l.width;r.push(e/c)}}return r}function MC(e,t,i){let n=i.length,r=[];for(let a=0;a<n;a++){let l=i[a];l&&r.push({width:Math.floor(e/l),height:Math.floor(t/l)})}return r}function ft(e){if(e["@id"])return e["@id"];if(e.id)return e.id}function Zl(e){if(!e||!e.profile||!ft(e))return!1;let t=Array.isArray(e.profile)?e.profile:[e.profile];for(let i of t)if(typeof i=="string"&&vC.indexOf(i)!==-1)return!0;return!1}function kC(e){if(!Zl(e))return!1;let t=Array.isArray(e.profile)?e.profile:[e.profile];for(let i of t)if(typeof i=="string"){if(Kv.indexOf(i)!==-1)return!0}else{let n=[...i.supports||[],...i.extraFeatures||[]];if(n.indexOf("regionByPx")!==-1&&(n.indexOf("sizeByW")!==-1||n.indexOf("sizeByWh")!==-1))return!0}return!1}function Kl(e,t){if(t&&t.profile){let i=t.profile;if(i){let n=Array.isArray(i)?i:[i];return n.includes(`level${e}`)||n.includes(`http://iiif.io/api/image/2/level${e}.json`)||n.includes(`http://iiif.io/api/image/1/level${e}.json`)||n.includes(`http://iiif.io/api/image/1/profiles/level${e}.json`)}}return!1}function Fh(e){return Zl(e)?Kl(0,e)?0:Kl(1,e)?1:Kl(2,e)?2:null:null}function Zv(e){return(e["@context"]?Array.isArray(e["@context"])?e["@context"]:[e["@context"]]:[]).indexOf("http://iiif.io/api/image/3/context.json")!==-1}function OC(e){if(!kC(e))return[];let t=[],i=Array.isArray(e.profile)?e.profile:[e.profile],n=i.length;for(let r=0;r<n;r++){let a=i[r];if(a&&typeof a!="string"&&(a.maxHeight||a.maxWidth))return[{id:ft(e),type:"variable",minWidth:0,minHeight:0,maxHeight:a.maxHeight||a.maxWidth,maxWidth:a.maxWidth||a.maxHeight,level:Fh(e),version:e["@context"]==="http://iiif.io/api/image/3/context.json"?3:2}]}if(e.tiles){let r=e.tiles.length;for(let a=0;a<r;a++){let l=e.tiles[a];l&&(l.height||l.width)&&t.push({id:ft(e),type:"variable",minHeight:0,minWidth:0,maxHeight:l.height||l.width,maxWidth:l.width,level:Fh(e),version:Zv(e)?3:2})}}return t}function Iv(e){let t=/^.*\/(full)\/(((\d+),(\d+)?)|max)\/(\d+)\/default\.(jpg|png|jpeg)$/,i=e.match(t);if(i&&i[4]&&i[5]){let n=i[1],r=parseInt(i[4],10),a=parseInt(i[5],10),l=i[7];if((n==="max"||n==="full")&&r&&a&&l)return{type:"fixed",id:e,height:a,width:r}}return{type:"unknown",id:e}}function LC(e){if(e["@type"])return e["@type"];if(e.type)return e.type}function zC(e){if(typeof e=="string")return Iv(e);let t=LC(e);if(t!=="Image"&&t!=="sc:Image")return null;let i=e,n=ft(i);return n?n&&i.width&&i.height?{id:n,type:"fixed",width:i.width,height:i.height,unsafe:!0}:Iv(n):null}function FC(e){return Zl(e)?(e&&e.sizes?e.sizes:[]).map(t=>({id:ft(e),type:"fixed-service",height:t.height,width:t.width,level:Fh(e),version:Zv(e)?3:2})):[]}function Rv(e){let t=[],i=e.length;for(let n=0;n<i;n++){let r=e[n];if(!r)continue;let a=FC(r);a.length&&t.push(...a);let l=OC(r);l.length&&t.push(...l)}return t}function Jv(e){let t=e.service?Array.isArray(e.service)?e.service:[e.service]:[],i=t.length,n=[];for(let r=0;r<i;r++)Zl(t[r])&&n.push(t[r]);return n}function NC(e,t=!0,i){let n=[],r=zC(e);if(r===null)return n;let a=e;if(n.push(r),t&&a&&a.width&&a.height){let l=[],c=Jv(a);for(let p of c){let m={id:ft(p),width:a.width,height:a.height};if(i.canLoadSync(m)){let h=i.loadServiceSync(m);h&&(h.height||(h.height=a.height),h.width||(h.width=a.width),l.push(...Rv([h])))}}if(l.length)return n.push(...l),n}return a.service&&n.push(...Rv(a.service)),n}function BC({x:e=0,y:t=0,w:i,h:n,full:r,square:a,percent:l}){if(r)return"full";if(a)return"square";if(typeof i>"u"||typeof n>"u")throw new Error("RegionParameter: invalid region");let c=`${e},${t},${i},${n}`;return l?`pct:${c}`:c}function DC({max:e,percentScale:t,upscaled:i,confined:n,width:r,height:a,serialiseAsFull:l,version:c}){let p=[];return i&&p.push("^"),e?(p.push(l?"full":"max"),p.join("")):(n&&p.push("!"),t&&p.push(`pct:${t}`),r&&p.push(`${r}`),p.push(","),a&&c===3&&p.push(`${a}`),p.join(""))}function jC(e){return`${e.mirror?"!":""}${(e.angle||0)%360}`}function VC(e,t){let i=e.prefix.startsWith("/")?e.prefix.substr(1):e.prefix,n=`${e.scheme}://${e.server}/${i?`${i}/`:""}${e.identifier}`;if(e.type==="base")return n;if(e.type==="info")return`${n}/info.json`;let{size:r}=e,{region:a,rotation:l,format:c,quality:p}=e;if(t){let m=t["@context"]?Array.isArray(t["@context"])?t["@context"]:[t["@context"]]:[],h=m.indexOf("http://iiif.io/api/image/2/context.json")!==-1,y=m.indexOf("http://iiif.io/api/image/3/context.json")!==-1;if((r.width===t.width&&!r.height||r.height===t.height&&!r.width||r.width===t.width&&r.height===t.height)&&(r={...r,max:!0}),h&&(r.max&&!r.serialiseAsFull&&(r={...r,serialiseAsFull:!0}),!r.max&&r.width&&r.height&&(r={...r,height:void 0}),r={...r,version:2}),y){if(r.max&&r.serialiseAsFull&&(r={...r,serialiseAsFull:!1}),r.width&&!r.height&&t.width&&t.height){let S=t.height/t.width;r={...r,height:Math.ceil(r.width*S)}}r={...r,version:3}}}return[n,BC(a),DC(r),jC(l),`${p}.${c}`].filter(Boolean).join("/")}function zh(e,t,i){let n=TC({"@context":e.version===3?"http://iiif.io/api/image/3/context.json":"http://iiif.io/api/image/2/context.json",id:Dr(ft(e)),profile:e.level===null||typeof e.level>"u"?"level0":`level${e.level}`,type:e.version===3?"ImageService3":"ImageService2"});if(n.type!=="image")throw new Error("Invalid service");return n.size.max=!1,n.size.width=t,n.size.height=i,{id:VC(n),type:"fixed",width:t,height:i||e.height/(e.width||1)*t,unsafe:e.width>t}}function Mo(e){let t=e.replace(/(https?:\/\/)?(www.)?/i,"");return t.indexOf("/")!==-1?t.split("/")[0]:t}function UC(e,t,i){let n=e.width?e.width:e.maxWidth;return i.height<=e.maxHeight&&i.width<=e.maxWidth&&i.height>=e.minHeight&&i.width>=e.minWidth&&(!t||Math.abs(i.width-n)<Math.abs(t.width-n))}function WC(e,t){let i=[],n=Object.assign({unsafeImageService:!1,atAnyCost:!0,fallback:!0,minHeight:64,minWidth:64,maxHeight:1/0,maxWidth:1/0,returnAllOptions:!1,preferFixedSize:!1,allowUnsafe:!1,explain:!1,height:0,width:0},e),r=(h,y=0)=>n.explain?i.push(new Array(y).fill(0).map(S=>" ").join("")+h().trim()):void 0,a=[],l=[],c=null;r(()=>`Using configuration: ${JSON.stringify(n,null,2)}`);let p=(h,y)=>{if(r(()=>"Swapping choice",3),UC(n,y,h)){if(n.preferFixedSize&&h.unsafe){r(()=>`We found an image that was marked as unsafe, but it was the best size. (${h.id})`,4),l.push(h);return}n.returnAllOptions&&y&&l.push(y),r(()=>`We found a new image that was the best size. (${h.id})`,4),c=h}else n.returnAllOptions&&l.push(h)};r(()=>`The input shows we have ${t.length} list(s) of candidates to choose from.`);let m=t.length;for(let h=0;h<m;h++){let y=t[h]();r(()=>`Candidate group ${h}: ${JSON.stringify(y,null,2)}`,1);let S=y.length;r(()=>`Checking candidate list number ${h} and found ${S} potential ways of creating image(s)`,1);for(let w=0;w<S;w++){let v=y[w];if(r(()=>`-> Checking candidate ${w}`,1),v.type==="unknown"&&n.atAnyCost&&(r(()=>`We've found an unknown image type, adding this to the "last resort" list`,2),a.push(v)),v.type==="fixed"&&(v.unsafe?(r(()=>`We've found an unsafe fixed image type, adding this to the "last resort" list`,2),a.push(v)):(r(()=>"We've found a fixed size image, checking if it matches the request",2),p(v,c))),v.type==="fixed-service")if(n.unsafeImageService){r(()=>"Checking for an image from the tile source, without calculating the right height and width (unsafeImageService)",2);let x=zh(v,n.width,n.height);p(x,c)}else{r(()=>"Checking for an image from the tile source 3",2);let x=zh(v,v.width,v.height);p(x,c)}if(v.type==="variable"&&v.maxWidth){let x=zh({id:v.id,type:"fixed-service",width:v.maxWidth,height:v.maxWidth,level:v.level,version:v.version},v.maxWidth);p(x,c)}}if(c&&!n.returnAllOptions){if(c.unsafe||n.allowUnsafe)continue;r(()=>`We found a match in choice list number ${h}, no searching any more`);break}}return n.atAnyCost&&l.length===0?(r(()=>c?`We found an image! ${c.id} of type ${c.type}`:'We found no images, but "atAnyCost" is set, so returning that'),{best:c||a[0]||null,fallback:a.slice(1),log:i}):n.returnAllOptions?(r(()=>"Returning all options that we have found"),{best:(n.atAnyCost?c||l[0]||a[0]:c||l[0])||null,fallback:[...l,...a],log:i}):(r(()=>"Returning the best image that we found, and a fallback"),{best:c||l[0]||null,fallback:c?l:l.slice(1),log:i})}function HC(e,t,i){let n=e>t?e:t,r=i.length,a=[];for(let l=0;l<r;l++){let c=i[l];if(!c||c.scaleFactors.length===0)continue;let p=c.scaleFactors[0];if(!p)continue;let m=n/p,h=[p];for(;m>=c.width;)p=p*2,h.push(p),m=m/2;a.push({...c,scaleFactors:h})}return a}function qC(e,t){if(e.length!==t.length)return!1;if(e.length===0&&t.length===0)return!0;let i=e.length,n=!0;for(let a=0;a<i;a++){let l=e[a],c=t[a];if(l.width!==c.width||l.height!==c.height){n=!1;break}}if(n)return!0;let r=0;for(let a=0;a<i;a++)for(let l=0;l<i;l++)if(e[a].width===t[l].width&&e[a].height===t[l].height){r++;break}return r===i}function Tv(e){return Kl(0,e)}var ex=class{constructor(e={}){Xl(this,"config",{verificationsRequired:1,approximateServices:!1,enableFetching:!0,disableThrottling:!1}),Xl(this,"fetchingCount",0),Xl(this,"imageServices",{}),Xl(this,"knownImageServers",{}),this.config=Object.assign(this.config,e)}setConfig(e){Object.assign(this.config,e)}sample(e,t,i=!0){let n=Mo(ft(e)),r=Dr(ft(e)),a=this.knownImageServers[n];return this.imageServices[r]=Object.assign(e,{real:!0}),!a&&e.tiles&&!Tv(e)?(this.knownImageServers[n]={verifications:0,malformed:!1,root:n,preLoaded:i,sampledId:ft(e),verified:!1,server:null,result:{context:e["@context"]||[],sampledProfile:e.profile,resourceServiceRatio:t&&e.height?t.height/e.height:1,sampledSizes:e.sizes||[],sizeRatios:_C(e.width,e.height,e.sizes||[]),sampledTiles:e.tiles||[]}},!0):this.verify(e)}preLoad(e,t=!0){this.knownImageServers[e.root]=e,t&&(this.knownImageServers[e.root].malformed=!1,this.knownImageServers[e.root].verifications=this.config.verificationsRequired)}predict(e,t=!1,i=!1){let n=e?.source,r=Mo(ft(e)),a=this.knownImageServers[r],l=Dr(ft(e));return this.imageServices[l]?this.imageServices[l]||null:!this.config.approximateServices||!a||!a.result||!(n?.height||e.height)||!(n?.width||e.width)||!i&&(a.malformed||a.verifications<this.config.verificationsRequired)||Tv(e.source)?null:(this.imageServices[l]||(this.imageServices[l]={"@context":a.result.context,"@id":ft(e),id:ft(e),protocol:"http://iiif.io/api/image",tiles:n?.tiles||HC(e.width,e.height,a.result.sampledTiles),sizes:n?.sizes||MC(Math.round(e.width/a.result.resourceServiceRatio),Math.round(e.height/a.result.resourceServiceRatio),a.result.sizeRatios),profile:n?.profile||a.result.sampledProfile,height:n?.height||e.height,width:n?.width||e.width,real:!1}),this.imageServices[l]||null)}async getThumbnailFromResource(e,t,i=!0,n=[]){let r=e?await this.getImageCandidates(e,i):[];return WC(t,[()=>n,()=>r])}async getImageCandidates(e,t=!0){let i=e;if(t&&i&&i.height&&i.width){let n=Jv(i);for(let r of n){let a={id:ft(r),width:r.width?r.width:i.width,height:r.height?r.height:i.height,source:r};await this.loadService(a)}}return NC(e,t,this)}async verify(e){let t=this.predict(e,!1,!0),i=await this.fetchService(ft(e));if(!t)return!1;let n=t.height===i.height&&t.width===i.width&&t["@context"]===i["@context"]&&qC(t.sizes||[],i.sizes||[]);if(n){let r=Mo(ft(e)),a=this.knownImageServers[r];a&&(a.verifications+=1,a.verifications>=this.config.verificationsRequired&&(a.verified=!0))}return n}canLoadSync(e){let t=typeof e=="string"?e:ft(e),i=Dr(t);if(this.imageServices[i])return!0;let n=this.knownImageServers[Mo(t)];return!!(n&&!n.malformed&&n.verifications>=this.config.verificationsRequired)}async markAsMalformed(e){return this.knownImageServers[Mo(ft(e))].malformed=!0,this.loadService(e,!0)}async fetchService(e,t=!1){let i=Dr(e),n=this.imageServices[i];if(n&&(!t||n.real))return n;if(!this.config.enableFetching)throw new Error("Fetching is not enabled");let r=await this.fetch(i).then(a=>a.json());return!r.id&&r["@id"]&&(r.id=r["@id"]),r.id!==e&&(r.id=e,r["@id"]&&(r["@id"]=e)),this.imageServices[i]=Object.assign(r,{real:!0}),this.imageServices[i]}async fetch(e,t){return fetch(e,t)}async loadService(e,t=!1){if(!this.config.disableThrottling){let r=!0;for(;r;)if(this.fetchingCount>=this.config.verificationsRequired)await new Promise(a=>setTimeout(a,500));else{r=!1;break}}let i=this.knownImageServers[Mo(ft(e))];if(i&&!i.malformed&&!t){await i.result;let r=this.loadServiceSync(e);if(r)return r}this.fetchingCount++;let n=await this.fetchService(ft(e),t);return this.fetchingCount--,n.real&&this.sample(n,e),n}loadServiceSync(e){let t=Dr(ft(e));return this.imageServices[t]?this.imageServices[t]:this.config.approximateServices?this.predict(e):null}},xT=new ex;function Jl(e){return{all:e=e||new Map,on:function(t,i){var n=e.get(t);n?n.push(i):e.set(t,[i])},off:function(t,i){var n=e.get(t);n&&(i?n.splice(n.indexOf(i)>>>0,1):e.set(t,[]))},emit:function(t,i){var n=e.get(t);n&&n.slice().map(function(r){r(i)}),(n=e.get("*"))&&n.slice().map(function(r){r(t,i)})}}}var ix={},tx=e=>{let t,i=new Set,n=(h,y)=>{let S=typeof h=="function"?h(t):h;if(!Object.is(S,t)){let w=t;t=y??(typeof S!="object"||S===null)?S:Object.assign({},t,S),i.forEach(v=>v(t,w))}},r=()=>t,p={setState:n,getState:r,getInitialState:()=>m,subscribe:h=>(i.add(h),()=>i.delete(h)),destroy:()=>{(ix.env?ix.env.MODE:void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),i.clear()}},m=t=e(n,r,p);return p},eu=e=>e?tx(e):tx;var QC=Object.create,Nh=Object.defineProperty,$C=Object.getOwnPropertyDescriptor,nx=Object.getOwnPropertyNames,GC=Object.getPrototypeOf,YC=Object.prototype.hasOwnProperty,XC=(e,t,i)=>t in e?Nh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Bh=(e,t)=>function(){return t||(0,e[nx(e)[0]])((t={exports:{}}).exports,t),t.exports},KC=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of nx(t))!YC.call(e,r)&&r!==i&&Nh(e,r,{get:()=>t[r],enumerable:!(n=$C(t,r))||n.enumerable});return e},Dh=(e,t,i)=>(i=e!=null?QC(GC(e)):{},KC(t||!e||!e.__esModule?Nh(i,"default",{value:e,enumerable:!0}):i,e)),Tt=(e,t,i)=>(XC(e,typeof t!="symbol"?t+"":t,i),i);var jh="http://library.stanford.edu/iiif/image-api/compliance.html#level0",Vh="http://library.stanford.edu/iiif/image-api/compliance.html#level1",Uh="http://library.stanford.edu/iiif/image-api/compliance.html#level2",Wh="http://library.stanford.edu/iiif/image-api/conformance.html#level0",Hh="http://library.stanford.edu/iiif/image-api/conformance.html#level1",qh="http://library.stanford.edu/iiif/image-api/conformance.html#level2",Qh="http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0",$h="http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level1",Gh="http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2",Yh="http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level0",Xh="http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level1",Kh="http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level2",Zh="http://iiif.io/api/image/1/level0.json",Jh="http://iiif.io/api/image/1/profiles/level0.json",ep="http://iiif.io/api/image/1/level1.json",tp="http://iiif.io/api/image/1/profiles/level1.json",ip="http://iiif.io/api/image/1/level2.json",np="http://iiif.io/api/image/1/profiles/level2.json",rp="http://iiif.io/api/image/2/level0.json",op="http://iiif.io/api/image/2/profiles/level0.json",sp="http://iiif.io/api/image/2/level1.json",ap="http://iiif.io/api/image/2/profiles/level1.json",lp="http://iiif.io/api/image/2/level2.json",up="http://iiif.io/api/image/2/profiles/level2.json",cp="level0",dp="level1",hp="level2",pp="http://iiif.io/api/image/2/level0",fp="http://iiif.io/api/image/2/level1",mp="http://iiif.io/api/image/2/level2",ko=[mp,Uh,qh,Gh,Kh,ip,np,lp,up,hp],tu=[...ko,fp,Vh,Hh,$h,Xh,ep,tp,sp,ap,dp],gp=[pp,fp,mp,jh,Vh,Uh,Wh,Hh,qh,Qh,$h,Gh,Yh,Xh,Kh,Zh,Jh,ep,tp,ip,np,rp,op,sp,ap,lp,up,cp,dp,hp],yp=gp,vp=[pp,jh,Wh,Qh,Yh,Zh,Jh,rp,op,cp],rx={extraFormats:["jpg"],extraQualities:["default"],extraFeatures:["sizeByWhListed"]},ox={extraFormats:["jpg"],extraQualities:["default"],extraFeatures:["baseUriRedirect","cors","jsonldMediaType","regionByPx","regionSquare","sizeByWhListed","sizeByH","sizeByW","sizeByWh"]},sx={extraFormats:["jpg","png"],extraQualities:["default"],extraFeatures:["baseUriRedirect","cors","jsonldMediaType","regionByPct","regionByPx","regionSquare","rotationBy90s","sizeByWhListed","sizeByConfinedWh","sizeByH","sizeByPct","sizeByW","sizeByWh"]};var ZC=Object.defineProperty,JC=(e,t,i)=>t in e?ZC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,vn=(e,t,i)=>(JC(e,typeof t!="symbol"?t+"":t,i),i);function eP(e){try{if(e==="full")return{full:!0};if(e==="square")return{square:!0};let t=e.startsWith("pct:"),i=e.substr(t?4:0).split(",").map(n=>parseFloat(n));return{x:i[0],y:i[1],w:i[2],h:i[3],percent:t}}catch{throw new Error("Expected 'full', 'square' or 'x,y,w,h'. Found "+e)}}function tP(e){let t={upscaled:!1,max:!1,confined:!1};if(e[0]==="^"&&(t.upscaled=!0,e=e.slice(1)),e==="max"||e==="full")return t.max=!0,t.serialiseAsFull=e==="full",t;if(e[0]==="!"&&(t.confined=!0,e=e.slice(1)),e[0]==="p")return t.percentScale=parseFloat(e.slice(4)),t;let i=e.split(",").map(n=>n.trim());return i.length&&(i[0]!==""&&(t.width=parseInt(i[0],10)),i[1]!==""&&(t.height=parseInt(i[1],10))),t}function iP(e){let t={angle:0};if(e[0]==="!"&&(t.mirror=!0,e=e.substr(1)),t.angle=parseFloat(e)%360,Number.isNaN(t.angle))throw new Error(`Invalid rotation ${e}`);return t}function nP(e,t=""){let i=e.match(/^(([a-zA-Z]+):\/\/([^/]+))?((.*)+)/);if(!i)throw new Error(`Invalid or unknown input ${e}`);let n=i[2],r=i[3],a=i[4];if(a[0]==="/"&&(a=a.substring(1)),t.length>0){if(t[0]==="/"&&(t=t.substring(1)),t!==a.substring(0,t.length))throw new Error(`Path does not start with prefix (path: ${a}, prefix: ${t})`);a=a.substring(t.length)}return{scheme:n,server:r,path:a,prefix:t}}function rP(e,t=""){let{path:i,scheme:n,server:r,prefix:a}=nP(e,t),l=i.split("/").reverse(),[c,p,m,h,...y]=l,S=y.reverse().filter(Boolean).join("/");if(l.length===1||c==="")return{type:"base",scheme:n,server:r,prefix:a,identifier:S};if(c==="info.json"){let[,...x]=l;return{type:"info",scheme:n,server:r,prefix:a,identifier:x.reverse().filter(Boolean).join("/")}}if(typeof n>"u"||typeof r>"u"||typeof i>"u"||typeof h>"u"||typeof m>"u"||typeof p>"u"||typeof c>"u")throw new Error("Invalid image service URL");let[w="",v=""]=c.split(".");return{type:"image",scheme:n,server:r,prefix:a,identifier:S,originalPath:i,region:eP(h),size:tP(m),rotation:iP(p),quality:w,format:v}}function oP(e){return ko.indexOf(e)!==-1?sx:tu.indexOf(e)!==-1?ox:rx}function sP(e){let t=e?Array.isArray(e.profile)?e.profile:[e.profile]:[],i={extraQualities:[],extraFormats:[],extraFeatures:[]};for(let n of t)if(typeof n=="string"&&(n=oP(n)),!!n){if(n.formats)for(let r of n.formats)i.extraFormats.indexOf(r)===-1&&i.extraFormats.push(r);if(n.qualities)for(let r of n.qualities)i.extraQualities.indexOf(r)===-1&&i.extraQualities.push(r);if(n.supports)for(let r of n.supports)i.extraFeatures.indexOf(r)===-1&&i.extraFeatures.push(r);if(n.maxHeight&&(i.maxHeight=n.maxHeight),n.maxWidth&&(i.maxWidth=n.maxWidth),n.maxArea&&(i.maxArea=n.maxArea),n.extraFormats)for(let r of n.extraFormats)i.extraFormats.indexOf(r)===-1&&i.extraFormats.push(r);if(n.extraQualities)for(let r of n.extraQualities)i.extraQualities.indexOf(r)===-1&&i.extraQualities.push(r);if(n.extraFeatures)for(let r of n.extraFeatures)i.extraFeatures.indexOf(r)===-1&&i.extraFeatures.push(r);n.maxHeight&&(i.maxHeight=n.maxHeight),n.maxWidth&&(i.maxWidth=n.maxWidth),n.maxArea&&(i.maxArea=n.maxArea)}if(e.extraFormats)for(let n of e.extraFormats)i.extraFormats.indexOf(n)===-1&&i.extraFormats.push(n);if(e.extraFeatures)for(let n of e.extraFeatures)i.extraFeatures.indexOf(n)===-1&&i.extraFeatures.push(n);if(e.extraQualities)for(let n of e.extraQualities)i.extraQualities.indexOf(n)===-1&&i.extraQualities.push(n);return i}function Sp(e){let t=Array.isArray(e.profile)?e.profile:[e.profile];for(let i of t)if(typeof i=="string"&&vp.indexOf(i)!==-1)return!0;return!1}function Le(e){if(e["@id"])return e["@id"];if(e.id)return e.id}function js(e){if(!e||!e.profile||!Le(e))return!1;let t=Array.isArray(e.profile)?e.profile:[e.profile];for(let i of t)if(typeof i=="string"&&gp.indexOf(i)!==-1)return!0;return!1}function ax(e){if(!js(e))return!1;let t=Array.isArray(e.profile)?e.profile:[e.profile];for(let i of t)if(typeof i=="string"){if(tu.indexOf(i)!==-1)return!0}else{let n=[...i.supports||[],...i.extraFeatures||[]];if(n.indexOf("regionByPx")!==-1&&(n.indexOf("sizeByW")!==-1||n.indexOf("sizeByWh")!==-1))return!0}return!1}function aP({x:e=0,y:t=0,w:i,h:n,full:r,square:a,percent:l}){if(r)return"full";if(a)return"square";if(typeof i>"u"||typeof n>"u")throw new Error("RegionParameter: invalid region");let c=`${e},${t},${i},${n}`;return l?`pct:${c}`:c}function lP({max:e,percentScale:t,upscaled:i,confined:n,width:r,height:a,serialiseAsFull:l,version:c}){let p=[];return i&&p.push("^"),e?(p.push(l?"full":"max"),p.join("")):(n&&p.push("!"),t&&p.push(`pct:${t}`),r&&p.push(`${r}`),p.push(","),a&&c===3&&p.push(`${a}`),p.join(""))}function uP(e){return`${e.mirror?"!":""}${(e.angle||0)%360}`}function iu(e,t){let i=e.prefix.startsWith("/")?e.prefix.substring(1):e.prefix,n=`${e.scheme}://${e.server}/${i?`${i}/`:""}${e.identifier}`;if(e.type==="base")return n;if(e.type==="info")return`${n}/info.json`;let{size:r}=e,{region:a,rotation:l,format:c,quality:p}=e;if(t){let m=t["@context"]?Array.isArray(t["@context"])?t["@context"]:[t["@context"]]:[],h=m.indexOf("http://iiif.io/api/image/2/context.json")!==-1,y=m.indexOf("http://iiif.io/api/image/3/context.json")!==-1;if((r.width===t.width&&!r.height||r.height===t.height&&!r.width||r.width===t.width&&r.height===t.height)&&(r={...r,max:!0}),h&&(r.max&&!r.serialiseAsFull&&(r={...r,serialiseAsFull:!0}),!r.max&&r.width&&r.height&&(r={...r,height:void 0}),r={...r,version:2}),y){if(r.max&&r.serialiseAsFull&&(r={...r,serialiseAsFull:!1}),r.width&&!r.height&&t.width&&t.height){let S=t.height/t.width;r={...r,height:Math.ceil(r.width*S)}}r={...r,version:3}}}return[n,aP(a),lP(r),uP(l),`${p}.${c}`].filter(Boolean).join("/")}function Ln(e){return e.endsWith("info.json")?e:e.endsWith("/")?`${e}info.json`:`${e}/info.json`}function nu(e){let t=rP(Ln(e.id));if(t.type!=="info")throw new Error("Invalid service URL");let i=sP(e);return{identifier:t.identifier,originalPath:"",server:t.server,prefix:t.prefix,scheme:t.scheme,type:"image",quality:i.extraQualities.indexOf("default")===-1?i.extraQualities[0]:"default",region:{full:!0},size:{max:!0,upscaled:!1,confined:!1},format:"jpg",rotation:{angle:0}}}function lx(e,t,i){let n=i.length,r=[];for(let a=0;a<n;a++){let l=i[a];if(!l)continue;let c=l.width;r.push(e/c)}return r}function ux(e,t,i){let n=i.length,r=[];for(let a=0;a<n;a++){let l=i[a];l&&r.push({width:Math.floor(e/l),height:Math.floor(t/l)})}return r}function xp(e,t){if(t&&t.profile){let i=t.profile;if(i){let n=Array.isArray(i)?i:[i];if(n.includes(`level${e}`)||n.includes(`http://iiif.io/api/image/2/level${e}.json`)||n.includes(`http://iiif.io/api/image/1/level${e}.json`)||n.includes(`http://iiif.io/api/image/1/profiles/level${e}.json`))return!0;if(e===2){for(let r of n)if(ko.includes(r))return!0}if(e===1){for(let r of n)if(tu.includes(r))return!0}if(e===0){for(let r of n)if(vp.includes(r))return!0}}}return!1}function Vs(e){return js(e)?xp(0,e)?0:xp(1,e)?1:xp(2,e)?2:null:null}function zn(e){let t=e.service?Array.isArray(e.service)?e.service:[e.service]:[],i=t.length,n=[];for(let r=0;r<i;r++)js(t[r])&&n.push(t[r]);return n}function cx(e){if(e["@type"])return e["@type"];if(e.type)return e.type}function jr(e){let t=e.replace(/(https?:\/\/)?(www.)?/i,"");return t.indexOf("/")!==-1?t.split("/")[0]:t}function dx(e,t,i){let n=e>t?e:t,r=i.length,a=[];for(let l=0;l<r;l++){let c=i[l];if(!c||c.scaleFactors.length===0)continue;let p=c.scaleFactors[0];if(!p)continue;let m=n/p,h=[p];for(;m>=c.width;)p=p*2,h.push(p),m=m/2;a.push({...c,scaleFactors:h})}return a}function ru(e,t,i){let n=nu({"@context":e.version===3?"http://iiif.io/api/image/3/context.json":"http://iiif.io/api/image/2/context.json",id:Ln(Le(e)),profile:e.level===null||typeof e.level>"u"?"level0":`level${e.level}`,type:e.version===3?"ImageService3":"ImageService2"});if(n.type!=="image")throw new Error("Invalid service");return n.size.max=!1,n.size.width=t,n.size.height=i,{id:iu(n),type:"fixed",width:t,height:i||e.height/(e.width||1)*t,unsafe:e.width>t}}function hx(e,t,i){let n=e.width?e.width:e.maxWidth;return i.height<=e.maxHeight&&i.width<=e.maxWidth&&i.height>=e.minHeight&&i.width>=e.minWidth&&(!t||Math.abs(i.width-n)<Math.abs(t.width-n))}function px(e,t){let i=[],n=Object.assign({unsafeImageService:!1,atAnyCost:!0,fallback:!0,minHeight:64,minWidth:64,maxHeight:1/0,maxWidth:1/0,returnAllOptions:!1,preferFixedSize:!1,allowUnsafe:!1,explain:!1,height:0,width:0},e),r=(h,y=0)=>n.explain?i.push(new Array(y).fill(0).map(S=>" ").join("")+h().trim()):void 0,a=[],l=[],c=null;r(()=>`Using configuration: ${JSON.stringify(n,null,2)}`);let p=(h,y)=>{if(r(()=>"Swapping choice",3),hx(n,y,h)){if(n.preferFixedSize&&h.unsafe){r(()=>`We found an image that was marked as unsafe, but it was the best size. (${h.id})`,4),l.push(h);return}n.returnAllOptions&&y&&l.push(y),r(()=>`We found a new image that was the best size. (${h.id})`,4),c=h}else n.returnAllOptions&&l.push(h)};r(()=>`The input shows we have ${t.length} list(s) of candidates to choose from.`);let m=t.length;for(let h=0;h<m;h++){let y=t[h]();r(()=>`Candidate group ${h}: ${JSON.stringify(y,null,2)}`,1);let S=y.length;r(()=>`Checking candidate list number ${h} and found ${S} potential ways of creating image(s)`,1);for(let w=0;w<S;w++){let v=y[w];if(r(()=>`-> Checking candidate ${w}`,1),v.type==="unknown"&&n.atAnyCost&&(r(()=>`We've found an unknown image type, adding this to the "last resort" list`,2),a.push(v)),v.type==="fixed"&&(v.unsafe?(r(()=>`We've found an unsafe fixed image type, adding this to the "last resort" list`,2),a.push(v)):(r(()=>"We've found a fixed size image, checking if it matches the request",2),p(v,c))),v.type==="fixed-service")if(n.unsafeImageService){r(()=>"Checking for an image from the tile source, without calculating the right height and width (unsafeImageService)",2);let x=ru(v,n.width,n.height);p(x,c)}else{r(()=>"Checking for an image from the tile source 3",2);let x=ru(v,v.width,v.height);p(x,c)}if(v.type==="variable"&&v.maxWidth){let x=ru({id:v.id,type:"fixed-service",width:v.maxWidth,height:v.maxWidth,level:v.level,version:v.version},v.maxWidth);p(x,c)}}if(c&&!n.returnAllOptions){if(c.unsafe||n.allowUnsafe)continue;r(()=>`We found a match in choice list number ${h}, no searching any more`);break}}return n.atAnyCost&&l.length===0?(r(()=>c?`We found an image! ${c.id} of type ${c.type}`:'We found no images, but "atAnyCost" is set, so returning that'),{best:c||a[0]||null,fallback:a.slice(1),log:i}):n.returnAllOptions?(r(()=>"Returning all options that we have found"),{best:(n.atAnyCost?c||l[0]||a[0]:c||l[0])||null,fallback:[...l,...a],log:i}):(r(()=>"Returning the best image that we found, and a fallback"),{best:c||l[0]||null,fallback:c?l:l.slice(1),log:i})}function Cp(e){return(e["@context"]?Array.isArray(e["@context"])?e["@context"]:[e["@context"]]:[]).indexOf("http://iiif.io/api/image/3/context.json")!==-1}function fx(e){return js(e)?(e&&e.sizes?e.sizes:[]).map(t=>({id:Le(e),type:"fixed-service",height:t.height,width:t.width,level:Vs(e),version:Cp(e)?3:2})):[]}function mx(e){if(!ax(e))return[];let t=[],i=Array.isArray(e.profile)?e.profile:[e.profile],n=i.length;for(let r=0;r<n;r++){let a=i[r];if(a&&typeof a!="string"&&(a.maxHeight||a.maxWidth))return[{id:Le(e),type:"variable",minWidth:0,minHeight:0,maxHeight:a.maxHeight||a.maxWidth,maxWidth:a.maxWidth||a.maxHeight,level:Vs(e),version:e["@context"]==="http://iiif.io/api/image/3/context.json"?3:2}]}if(e.tiles){let r=e.tiles.length;for(let a=0;a<r;a++){let l=e.tiles[a];l&&(l.height||l.width)&&t.push({id:Le(e),type:"variable",minHeight:0,minWidth:0,maxHeight:l.height||l.width,maxWidth:l.width,level:Vs(e),version:Cp(e)?3:2})}}return t}function wp(e){let t=[],i=e.length;for(let n=0;n<i;n++){let r=e[n];if(!r)continue;let a=fx(r);a.length&&t.push(...a);let l=mx(r);l.length&&t.push(...l)}return t}function bp(e){let t=/^.*\/(full)\/(((\d+),(\d+)?)|max)\/(\d+)\/default\.(jpg|png|jpeg)$/,i=e.match(t);if(i&&i[4]&&i[5]){let n=i[1],r=parseInt(i[4],10),a=parseInt(i[5],10),l=i[7];if((n==="max"||n==="full")&&r&&a&&l)return{type:"fixed",id:e,height:a,width:r}}return{type:"unknown",id:e}}function Us(e){if(typeof e=="string")return bp(e);let t=cx(e);if(t!=="Image"&&t!=="sc:Image")return null;let i=e,n=Le(i);return n?n&&i.width&&i.height?{id:n,type:"fixed",width:i.width,height:i.height,unsafe:!0}:bp(n):null}function gx(e,t=!0,i){let n=[],r=Us(e);if(r===null)return n;let a=e;if(n.push(r),t&&a&&a.width&&a.height){let l=[],c=zn(a);for(let p of c){let m={id:Le(p),width:a.width,height:a.height};if(i.canLoadSync(m)){let h=i.loadServiceSync(m);h&&(h.height||(h.height=a.height),h.width||(h.width=a.width),l.push(...wp([h])))}}if(l.length)return n.push(...l),n}return a.service&&n.push(...wp(a.service)),n}function yx(e,t){if(e.length!==t.length)return!1;if(e.length===0&&t.length===0)return!0;let i=e.length,n=!0;for(let a=0;a<i;a++){let l=e[a],c=t[a];if(l.width!==c.width||l.height!==c.height){n=!1;break}}if(n)return!0;let r=0;for(let a=0;a<i;a++)for(let l=0;l<i;l++)if(e[a].width===t[l].width&&e[a].height===t[l].height){r++;break}return r===i}var Oo=class{constructor(e={}){Tt(this,"config",{verificationsRequired:1,approximateServices:!1,enableFetching:!0,disableThrottling:!1}),Tt(this,"fetchingCount",0),Tt(this,"imageServices",{}),Tt(this,"knownImageServers",{}),this.config=Object.assign(this.config,e)}setConfig(e){Object.assign(this.config,e)}sample(e,t,i=!0){let n=jr(Le(e)),r=Ln(Le(e)),a=this.knownImageServers[n];return this.imageServices[r]=Object.assign(e,{real:!0}),!a&&e.tiles&&!Sp(e)?(this.knownImageServers[n]={verifications:0,malformed:!1,root:n,preLoaded:i,sampledId:Le(e),verified:!1,server:null,result:{context:e["@context"]||[],sampledProfile:e.profile,resourceServiceRatio:t&&e.height?t.height/e.height:1,sampledSizes:e.sizes||[],sizeRatios:lx(e.width,e.height,e.sizes||[]),sampledTiles:e.tiles||[]}},!0):this.verify(e)}preLoad(e,t=!0){this.knownImageServers[e.root]=e,t&&(this.knownImageServers[e.root].malformed=!1,this.knownImageServers[e.root].verifications=this.config.verificationsRequired)}predict(e,t=!1,i=!1){let n=e?.source,r=jr(Le(e)),a=this.knownImageServers[r],l=Ln(Le(e));return this.imageServices[l]?this.imageServices[l]||null:!this.config.approximateServices||!a||!a.result||!(n?.height||e.height)||!(n?.width||e.width)||!i&&(a.malformed||a.verifications<this.config.verificationsRequired)||e.source&&Sp(e.source)?null:(this.imageServices[l]||(this.imageServices[l]={"@context":a.result.context,"@id":Le(e),id:Le(e),protocol:"http://iiif.io/api/image",tiles:n?.tiles||dx(e.width,e.height,a.result.sampledTiles),sizes:n?.sizes||ux(Math.round(e.width/a.result.resourceServiceRatio),Math.round(e.height/a.result.resourceServiceRatio),a.result.sizeRatios),profile:n?.profile||a.result.sampledProfile,height:n?.height||e.height,width:n?.width||e.width,real:!1}),this.imageServices[l]||null)}async getThumbnailFromResource(e,t,i=!0,n=[]){let r=e?await this.getImageCandidates(e,i):[];return px(t,[()=>n,()=>r])}async getImageCandidates(e,t=!0){let i=e;if(t&&i&&i.height&&i.width){let n=zn(i);for(let r of n){let a={id:Le(r),width:r.width?r.width:i.width,height:r.height?r.height:i.height,source:r};await this.loadService(a)}}return gx(e,t,this)}async verify(e){let t=this.predict(e,!1,!0),i=await this.fetchService(Le(e));if(!t)return!1;let n=t.height===i.height&&t.width===i.width&&t["@context"]===i["@context"]&&yx(t.sizes||[],i.sizes||[]);if(n){let r=jr(Le(e)),a=this.knownImageServers[r];a&&(a.verifications+=1,a.verifications>=this.config.verificationsRequired&&(a.verified=!0))}return n}canLoadSync(e){let t=typeof e=="string"?e:Le(e),i=Ln(t);if(this.imageServices[i])return!0;let n=this.knownImageServers[jr(t)];return!!(n&&!n.malformed&&n.verifications>=this.config.verificationsRequired)}async markAsMalformed(e){return this.knownImageServers[jr(Le(e))].malformed=!0,this.loadService(e,!0)}async fetchService(e,t=!1){let i=Ln(e),n=this.imageServices[i];if(n&&(!t||n.real))return n;if(!this.config.enableFetching)throw new Error("Fetching is not enabled");let r=await this.fetch(i).then(a=>a.json());return!r.id&&r["@id"]&&(r.id=r["@id"]),r.id!==e&&(r.id=e,r["@id"]&&(r["@id"]=e)),this.imageServices[i]=Object.assign(r,{real:!0}),this.imageServices[i]}async fetch(e,t){return fetch(e,t)}async loadService(e,t=!1){if(!this.config.disableThrottling){let r=!0;for(;r;)if(this.fetchingCount>=this.config.verificationsRequired)await new Promise(a=>setTimeout(a,500));else{r=!1;break}}let i=this.knownImageServers[jr(Le(e))];if(i&&!i.malformed&&!t){await i.result;let r=this.loadServiceSync(e);if(r)return r}this.fetchingCount++;let n=await this.fetchService(Le(e),t);return this.fetchingCount--,n.real&&this.sample(n,e),n}loadServiceSync(e){let t=Ln(Le(e));return this.imageServices[t]?this.imageServices[t]:this.config.approximateServices?this.predict(e):null}};function vx(e={}){let t=e.events||Jl(),i=e.loader||new Oo;return{store:eu((r,a)=>({loaded:{},loadServiceSync:(l,c,p)=>{let m=l.id||l["@id"],h=a().loaded[m];if(h&&h.status==="done")return h.service;if(h&&h.status==="loading")return null;if(h&&h.status==="error")throw new Error("Failed to load image service");let y={id:Le(l),width:l.width||c?.width||0,height:l.height||c?.height||0,source:l},S=i.loadServiceSync(y);return S?(r(w=>({loaded:{...w.loaded,[m]:{status:"done",service:S,real:!0}}})),t.emit("image-service.loaded",{id:m,service:S})):p&&a().loadService(l,c).then(()=>{}),S},loadService:async(l,c)=>{let p=l.id||l["@id"],m=a().loaded[p];if(m&&m.status==="done")return m.service;if(m&&m.status==="loading")return new Promise((h,y)=>{let S=w=>{w.id===p&&(t.off("image-service.loaded",S),h(w.service||l))};t.on("image-service.loaded",S)});if(m&&m.status==="error"&&!c?.force)throw new Error("Failed to load image service");t.emit("image-service.loading",{id:p});try{let h={id:Le(l),width:l.width||0,height:l.height||0,source:l},y=await i.loadService(h,c?.force);return r(S=>({loaded:{...S.loaded,[p]:{status:"done",service:y,real:y.real}}})),t.emit("image-service.loaded",{id:p,service:y}),y}catch(h){throw t.emit("image-service.error",{id:p,error:h}),h}}})),events:t}}var Pp=vx();var ou={},Fn={get(e){return e},setMetaValue([e,t,i],n){let r=Fn.getResourceMeta(e,t),a=r?r[i]:void 0,l=typeof n=="function"?n(a):n;ou[e]={...ou[e]||{},[t]:{...(ou[e]||{})[t]||{},[i]:l}}},getResourceMeta:(e,t)=>{let i=ou[e];if(i)return t?i[t]:i},async load(e){let t=typeof e=="string"?e:e.id;return fetch(t).then(i=>i.json())},requestStatus(e){}};var xx=new Oo;function Ep(e=Fn,t={}){let i=t.imageServiceLoader||xx;async function n(r,a,l=!1,c=[],p){let m=()=>i.getThumbnailFromResource(void 0,a,l,c);if(!r)return await i.getThumbnailFromResource(void 0,a,l,c);if(typeof r=="string"){let S=Us(r);return S&&c.push(S),await i.getThumbnailFromResource(void 0,a,l,c)}let h=e.get(r,{skipSelfReturn:!1});if(typeof h=="string")return{best:Us(h),fallback:[],log:[]};if(!h)return await m();switch(await(async S=>{if(S&&S.thumbnail&&S.thumbnail.length){let w=e.get(S.thumbnail[0]),v=await i.getImageCandidates(w,l);v&&v.length&&c.push(...v)}})(h),h.type){case"Annotation":{let S=Array.isArray(h.body)?h.body:[h.body],w=e.get(S[0]);return p&&!w.width&&(w.width=p.width,w.height=p.height),await i.getThumbnailFromResource(w,a,l,c)}case"Canvas":{let S=h;return n(S.items[0],a,l,c,{width:S.width,height:S.height})}case"AnnotationPage":return n(h.items[0],a,l,c,p);case"Choice":{let S=h;return!S.items||S.items[0]?await m():n(S.items[0],a,l,c,p)}case"Collection":{let w=h.items[0];return w?n(w,a,l,c,p):await m()}case"Manifest":{let w=h.items[0];return w?n(w,a,l,c,p):await m()}case"SpecificResource":case"Image":case"Dataset":case"Sound":case"Text":case"TextualBody":case"Video":return p&&!h.width&&(h.width=p.width,h.height=p.height),i.getThumbnailFromResource(h,a,l,c)}return await m()}return{getBestThumbnailAtSize:n}}var KP=R(B(),1),ZP=R(q(),1),Zs=R(q(),1),JP=R(B(),1),eE=R(q(),1),m0=R(q(),1),cP=Object.defineProperty,dP=(e,t,i)=>t in e?cP(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,P=(e,t,i)=>(dP(e,typeof t!="symbol"?t+"":t,i),i),bu=["onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp","onTouchCancel","onTouchEnd","onTouchMove","onTouchStart","onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut","onScroll","onWheel","onClick","onDragStart","onDragEnd","onDragEnter","onDragExit","onDrag","onDragOver"];function hP(){return bu.reduce((e,t)=>(e[t]=[],e),{})}var zo=bu.reduce((e,t)=>(e[t.slice(2).toLowerCase()]=t,e[t]=t,e),{}),pP="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",Cu=(e=21)=>{let t="",i=crypto.getRandomValues(new Uint8Array(e));for(;e--;)t+=pP[i[e]&63];return t},bn=class{constructor(){P(this,"__id"),P(this,"__revision",0),P(this,"__host"),P(this,"__onCreate"),P(this,"__parent"),P(this,"__owner",{value:void 0}),P(this,"__state",{}),P(this,"eventHandlers"),P(this,"scale",1),P(this,"layers",[]),P(this,"time",[]),P(this,"_crop"),P(this,"cropData"),P(this,"id"),P(this,"addEventListener",(e,t,i)=>{let n=zo[e];if(!this.eventHandlers[n])throw new Error(`Unknown event ${n}`);this.eventHandlers[n].indexOf(t)===-1&&this.eventHandlers[n].push(t)}),P(this,"removeEventListener",(e,t)=>{let i=zo[e];if(!this.eventHandlers[i]){console.warn(`Unknown event ${i}`);return}this.eventHandlers[i].indexOf(t)!==-1&&(this.eventHandlers[i]=this.eventHandlers[i].filter(n=>n!==t))}),this.id=this.__id=Cu(),this.eventHandlers=hP()}get crop(){return this._crop}set crop(e){this._crop=e}getObjectsAt(e){return[]}getAllPointsAt(e,t,i){return[]}getScheduledUpdates(e,t){return[]}dispatchEvent(e,t){let i=this.eventHandlers[e],n=i?i.length:0,r=!1;if(n)for(let a=0;a<n;a++)try{i[a](t),r=!0}catch(l){console.error(e,l)}return r}get x(){return this.points[1]}get y(){return this.points[2]}get width(){return this.points[3]-this.points[1]}get height(){return this.points[4]-this.points[2]}translate(e,t){Zt(this.points,ut(e,t))}atScale(e){Zt(this.points,On(e,this.x,this.y)),this.scale*=e}transform(e){Zt(this.points,e)}applyProps(e){this.__revision++}appendChild(e){}removeChild(e){}insertBefore(e,t){}hideInstance(){}},cr=class Ip extends bn{constructor(t){if(super(),P(this,"type","spacial-content"),P(this,"id"),P(this,"uri"),P(this,"display"),P(this,"points"),P(this,"priority"),P(this,"style",{opacity:1}),!t)this.id="",this.uri="",this.display={x:0,y:0,scale:1,width:0,height:0,points:re(5)},this.points=re(5);else{let i=t.scale||1;this.id=t.id||t.uri,this.uri=t.uri,this.points=xe.singleBox(t.width,t.height,t.x,t.y),this.display={x:0,y:0,scale:i,width:t.width/i,height:t.height/i,points:xe.singleBox(t.width/i,t.height/i),rotation:t?.rotation}}}applyProps(t){let i=t.display?t.display.width:t.target.width,n=t.target.width/i;if(this.id=t.id||t.uri,this.uri=t.uri,this.points.set(xe.singleBox(t.target.width,t.target.height,t.target.x,t.target.y)),t.style&&typeof t.style.opacity<"u"&&(this.style.opacity=t.style.opacity),t.crop){this.cropData=t.crop;let r=xe.singleBox(t.crop.width,t.crop.height,t.crop.x,t.crop.y);Zt(r,ut(-t.crop.x,-t.crop.y)),this.crop?this.crop.set(r):this.crop=re(r)}t.display?(this.display.scale=n,this.display.width=t.display.width,this.display.height=t.display.height,this.display.rotation=t.display.rotation,this.display.points=xe.singleBox(t.display.width,t.display.height)):(this.display.scale=n,this.display.width=t.target.width/n,this.display.height=t.target.height/n,this.display.points=xe.singleBox(t.target.width/n,t.target.height/n))}getAllPointsAt(t,i,n){return[[this,this.crop||this.points,i]]}static fromSvg(t,i,n,r){return Ip.fromImage("data:image/svg+xml;base64,"+btoa(t),i,n,r)}static fromImage(t,i,n,r){let a=new Ip;return a.applyProps({uri:t,id:r,display:n,target:i}),a}getImageUrl(){return this.uri}},Rp=class extends bn{constructor(e){if(super(),P(this,"type","spacial-content"),P(this,"id"),P(this,"uri"),P(this,"display"),P(this,"points"),P(this,"getTexture"),this.getTexture=()=>({source:void 0,hash:-1}),!e)this.id="",this.uri="",this.display={x:0,y:0,scale:1,width:0,height:0,points:re(5)},this.points=re(5);else{let t=e.scale||1;this.id=e.id||e.uri,this.uri=e.uri,this.points=xe.singleBox(e.width,e.height),this.display={x:0,y:0,scale:t,width:e.width/t,height:e.height/t,points:t!==1?xe.singleBox(e.width/t,e.height/t):this.points}}}applyProps(e){let t=e.display?e.display.width:e.target.width,i=e.target.width/t;this.id=e.id,this.points.set(xe.singleBox(e.target.width,e.target.height)),this.display.scale=i,this.display.width=e.target.width/i,this.display.height=e.target.height/i,this.getTexture=e.getTexture,this.display.points=i!==1?xe.singleBox(e.target.width/i,e.target.height/i):this.points}getAllPointsAt(e,t,i){return[[this,this.points,t]]}};function fP(e,t,i=1){let n=t.length;if(n===0)throw new Error("No resources passed in.");let r=0;for(let a=0;a<n&&!(!t[a]||!t[a].display);a++)r=Math.abs(t[a].display.scale-e)*i<Math.abs(t[r].display.scale-e)?a:r;return r}function Cx(e,t){return Math.abs(e-t)}function vu(e,t){let i=Cx(e.x,t.x),n=Cx(e.y,t.y);return Math.sqrt(Math.pow(i,2)+Math.pow(n,2))}function mP(e){let t=e.length;return e.indexOf("/info.json")===t-10?e.slice(0,-10):e}function su(e,t,i){return Math.min(Math.max(e,t),i)}var Xs=class Bx extends bn{constructor(t){super(),P(this,"id"),P(this,"type","spacial-content"),P(this,"display"),P(this,"tileWidth"),P(this,"style",{opacity:1}),P(this,"points"),P(this,"service"),P(this,"format","jpg"),P(this,"crop2"),P(this,"tileUrl"),this.tileUrl=mP(t.url),this.id=t.id||`${this.tileUrl}--${t.scaleFactor}`,this.points=t.displayPoints?t.displayPoints:bi(t.points,wi(t.scaleFactor)),this.tileWidth=t.tileWidth,this.display={x:0,y:0,width:t.width/t.scaleFactor,height:t.height/t.scaleFactor,points:t.points,scale:t.scaleFactor},t.format&&(this.format=t.format)}applyProps(t){if(t.style&&typeof t.style.opacity<"u"&&(this.style.opacity=t.style.opacity),t.service!==this.service&&(this.service=t.service),t.format?this.format=t.format:this.format="jpg",t.crop){this.cropData=t.crop;let i=re([...this.points]),n=i.length/5,r=t.crop.x||0,a=t.crop.y||0,l=t.crop.x+t.crop.width,c=t.crop.y+t.crop.height;for(let p=0;p<n;p++){let m=p*5;i[m+1]<l&&i[m+3]>r&&i[m+2]<c&&i[m+4]>a?(i[m+1]=su(i[m+1],r,l),i[m+3]=su(i[m+3],r,l),i[m+2]=su(i[m+2],a,c),i[m+4]=su(i[m+4],a,c)):i[m]=0}Zt(i,ut(-t.crop.x,-t.crop.y)),this.crop?this.crop.set(i):this.crop=i}}static fromTile(t,i,n,r,a,l){n.height=n.height?n.height:n.width;let c=Math.ceil(i.width/r),p=Math.ceil(i.height/r),m=Math.ceil(c/n.width),h=Math.ceil(p/n.height),y=xe.grid(m,h),S=xe.grid(m,h);for(let v=0;v<h;v++)for(let x=0;x<m;x++){let A=x*n.width,C=v*n.height;S.addPoints(A*r,C*r,x===m-1?i.width:(A+n.width)*r,v===h-1?i.height:(C+n.height)*r),y.addPoints(A,C,x===m-1?c:A+n.width,v===h-1?p:C+n.height)}let w=new Bx({url:t,scaleFactor:r,points:y.build(),displayPoints:S.build(),width:i.width,height:i.height,tileWidth:n.width,format:l});return w.applyProps({service:a}),w}getImageUrl(t){let i=this.points.slice(t*5,t*5+5),n=i[3]-i[1],r=i[4]-i[2],a=Math.ceil(n/this.display.scale);return`${this.tileUrl}/${i[1]},${i[2]},${n},${r}/${a>this.tileWidth?this.tileWidth:a},/0/default.${this.format||"jpg"}`}getAllPointsAt(t,i,n){let r=or(this.crop||this.points,t);return[[this,r,i]]}transform(t){Zt(this.points,t)}getScheduledUpdates(t,i){return[]}},gP=class extends bn{constructor(){super(...arguments),P(this,"type","spacial-content")}getAllPointsAt(e,t,i){return[[this,this.points,t]]}},yP=class extends gP{constructor(e){super(),P(this,"id"),P(this,"display"),P(this,"points"),P(this,"images",[]),P(this,"allImages",[]),P(this,"scaleFactors",[]),P(this,"aggregateBuffer",re(9)),P(this,"lazyLoader"),P(this,"isFullyLoaded",!1),P(this,"maxScaleFactor",0),P(this,"renderOptions"),P(this,"_scheduleSortByScales",!1),P(this,"_sortByScales",()=>{this._scheduleSortByScales=!1,this.allImages.sort((i,n)=>n.display.width-i.display.width),this.images=[];let t=.1;for(let i of this.allImages)if(!(i.display.width<this.renderOptions.minSize&&i.display.height<this.renderOptions.minSize&&!i.priority||i instanceof cr&&(i.display.width>this.renderOptions.maxImageSize||i.display.height>this.renderOptions.maxImageSize)&&!i.priority)){if(Math.abs(i.display.scale-t)<.25||i.priority){let n=this.images.pop();n&&(n instanceof cr||n.priority)?(i.priority&&this.images.push(i),this.images.push(n)):i&&this.images.push(i)}else i&&this.images.push(i);t=i.display.scale}this.images.length===0&&(this.images=[...this.allImages]),this.scaleFactors=this.images.map(i=>i.display.scale),this.maxScaleFactor=Math.max(...this.scaleFactors)}),P(this,"loadFullResource",async()=>{if(!this.isFullyLoaded&&this.lazyLoader){this.isFullyLoaded=!0;let t=await this.lazyLoader();this.addImages(t)}}),P(this,"fallback",[this.loadFullResource]),this.id=e.id,this.points=xe.singleBox(e.width,e.height),this.lazyLoader=e.loadFullImages,e.loadFullImages||(this.isFullyLoaded=!0),this.display={x:0,y:0,points:xe.singleBox(e.width,e.height),height:e.height,width:e.width,scale:1},this.renderOptions={renderSmallestFallback:!0,renderLayers:2,minSize:255,maxImageSize:1024,quality:1.75,...e.renderOptions||{}},this.addImages(e.images)}applyProps(e){typeof e.renderSmallestFallback<"u"&&e.renderSmallestFallback!==this.renderOptions.renderSmallestFallback&&(this.renderOptions.renderSmallestFallback=e.renderSmallestFallback),typeof e.renderLayers<"u"&&e.renderLayers!==this.renderOptions.renderLayers&&(this.renderOptions.renderLayers=e.renderLayers),typeof e.minSize<"u"&&e.minSize!==this.renderOptions.minSize&&(this.renderOptions.minSize=e.minSize),typeof e.maxImageSize<"u"&&e.maxImageSize!==this.renderOptions.maxImageSize&&(this.renderOptions.maxImageSize=e.maxImageSize),typeof e.quality<"u"&&e.quality!==this.renderOptions.quality&&(this.renderOptions.quality=e.quality)}appendChild(e){this.addImages([e])}removeChild(e){this.images.indexOf(e)!==-1&&(this.images=this.images.filter(t=>t!==e),this.sortByScales())}insertBefore(e,t){this.addImages([e])}hideInstance(){}addImages(e){for(let t of e)t.__parent=this,t.__owner=this.__owner;this.allImages.push(...e.filter(Boolean)),this.sortByScales()}sortByScales(){this._scheduleSortByScales=!0}getScheduledUpdates(e,t){return this._scheduleSortByScales?[this._sortByScales]:this.isFullyLoaded?[]:t>1/this.maxScaleFactor?this.fallback:[]}getAllPointsAt(e,t,i){if(this.images.length===0)return[];let n=fP(1/(i||1)/(window.devicePixelRatio||1),this.images,this.renderOptions.quality),r=this.images.length,a=t?pi(t,ut(this.x,this.y)):ut(this.x,this.y);if(n!==this.images.length-1&&this.images[n+1]){let l=[];for(let m=r-1;m>=n;m--)l.push(m);let c=l[0];this.renderOptions.renderLayers&&(l=l.slice(-Math.min(l.length,this.renderOptions.renderLayers))),this.renderOptions.renderSmallestFallback&&l.indexOf(c)===-1&&l.unshift(c);let p=[];for(let m=0;m<l.length;m++)p.push(...this.images[l[m]].getAllPointsAt(e,a,i));return p}return this.images[n].getAllPointsAt(e,a,i)}};function au(e,t,i,n,r){let a=Math.PI/180*r,l=Math.cos(a),c=Math.sin(a),p=l*(i-e)+c*(n-t)+e,m=l*(n-t)-c*(i-e)+t;return[p,m]}var Op=class Dx extends bn{constructor(t,i){super(),P(this,"id"),P(this,"type","world-object"),P(this,"scale"),P(this,"layers"),P(this,"points"),P(this,"worldPoints"),P(this,"intersectionBuffer",re(5)),P(this,"aggregateBuffer",re(9)),P(this,"invertedBuffer",re(9)),P(this,"rotation",0),P(this,"filteredPointsBuffer"),P(this,"_updatedList",[]),P(this,"geometry");let{x:n=0,y:r=0}=i||{};t?(this.id=t.id||"",this.scale=1,this.layers=t.layers,this.points=re([1,n,r,n+t.width,r+t.height]),this.worldPoints=re([1,n,r,n+t.width,r+t.height]),this.filteredPointsBuffer=re(t.layers.length*5)):(this.id="",this.scale=1,this.layers=[],this.points=re(5),this.worldPoints=re(5),this.filteredPointsBuffer=re(5))}static createWithProps(t){let i=new Dx;return i.applyProps(t),i}applyProps(t){let i=t.x||0,n=t.y||0;this.id=t.id;let r=typeof t.scale<"u"?t.scale:this.scale;this.points[0]=1,this.points[1]=i,this.points[2]=n,this.points[3]=i+t.width,this.points[4]=n+t.height,this.rotation=t.rotation||0,this.worldPoints[3]=this.worldPoints[1]+t.width,this.worldPoints[4]=this.worldPoints[2]+t.height,t.scale&&t.scale!==1&&this.atScale(r),this.scale=r}appendChild(t){t.points[0]===0&&t.points.set(this.points),t.__owner.value=this,this.addLayers([t])}removeChild(t){this.layers=this.layers.filter(i=>i!==t),this.filteredPointsBuffer=re(this.layers.length*5)}insertBefore(t,i){let n=this.layers.indexOf(i);if(n===-1||this.layers.indexOf(t)!==-1)return;let r=this.layers.slice(0,n),a=this.layers.slice(n);this.layers=[...r,t,...a]}hideInstance(){console.warn("hideInstance: not yet implemented")}getObjectsAt(t,i){if(this.rotation&&(t=this.applyRotation(t)),or(this.points,t,this.filteredPointsBuffer)[0]===0)return[];let n=this.layers.length,r=[];for(let a=0;a<n;a++){let l=this.layers[a];if(i&&l.isShape){let c=bi(l.points,ut(this.x,this.y));if(!l.intersects([t[1]-c[1],t[2]-c[2]]))continue}if(or(bi(l.points,ut(this.x,this.y)),t,this.filteredPointsBuffer)[0]!==0&&r.push(l),i){let c=l;r.push(...c.getObjectsAt(t,i))}}return r}applyRotation(t){if(this.rotation){let i={x:t[1],y:t[2]},n={x:t[1],y:t[4]},r={x:t[3],y:t[2]},a={x:t[3],y:t[4]},l=this.points[1]+(this.points[3]-this.points[1])/2,c=this.points[2]+(this.points[4]-this.points[2])/2,[p,m]=au(l,c,i.x,i.y,this.rotation),[h,y]=au(l,c,n.x,n.y,this.rotation),[S,w]=au(l,c,r.x,r.y,this.rotation),[v,x]=au(l,c,a.x,a.y,this.rotation),A=Math.min(p,h,S,v),C=Math.max(p,h,S,v),I=Math.min(m,y,w,x),E=Math.max(m,y,w,x);return re([t[0],A,I,C,E])}return t}getAllPointsAt(t,i,n){let r=pi(ut(this.x,this.y),wi(this.scale),this.aggregateBuffer);this.rotation&&(t=this.applyRotation(t));let a=ky(t,this.points,this.intersectionBuffer),l=this.layers.length,c=[],p=bi(a,pi(wi(1/this.scale),ut(-this.x,-this.y),this.invertedBuffer)),m=i?pi(i,r,this.aggregateBuffer):r,h=n*this.scale;for(let y=0;y<l;y++)c.push(...this.layers[y].getAllPointsAt(p,m,h));return c}addLayers(t){let i=[];for(let n of t)this.layers.indexOf(n)===-1&&(i.push(n),n.points.length===5&&(n.points[1]<this.worldPoints[1]/this.scale||n.points[2]<this.worldPoints[2]/this.scale||n.points[3]>this.worldPoints[3]/this.scale||n.points[4]>this.worldPoints[4]/this.scale)&&(n.crop=n.crop||re([1,Math.max(this.worldPoints[1]/this.scale,n.points[1]),Math.max(this.worldPoints[2]/this.scale,n.points[2]),Math.min(this.worldPoints[3]/this.scale,n.points[3]),Math.min(this.worldPoints[4]/this.scale,n.points[4])])));this.layers=this.layers.concat(i),this.filteredPointsBuffer=re(this.layers.length*5)}getScheduledUpdates(t,i){let n=this.layers.length;this._updatedList=[];let r=i*this.scale;for(let a=0;a<n;a++){let l=this.layers[a].getScheduledUpdates(t,r);l&&this._updatedList.push(...l)}return this._updatedList}},Pu=class jx extends bn{constructor(t=0,i=0,n=100,r="left-to-right"){super(),P(this,"id","world"),P(this,"_width"),P(this,"_height"),P(this,"aspectRatio"),P(this,"viewingDirection"),P(this,"aggregateBuffer",re(9)),P(this,"isDirty",!1),P(this,"zones",[]),P(this,"filteredPointsBuffer"),P(this,"selectedZone"),P(this,"triggerQueue",[]),P(this,"activatedEvents",[]),P(this,"_updatedList",[]),P(this,"translationBuffer",re(9)),P(this,"needsRecalculate",!0),P(this,"emptyPaintables",[]),P(this,"renderOrder",[]),P(this,"points"),P(this,"objects",[]),P(this,"subscriptions",[]),P(this,"_propagateEventTargets",[]),P(this,"_alreadyFlushed",[]),this._width=t,this._height=i,this.aspectRatio=Number.isNaN(t/i)?1:t/i,this.viewingDirection=r,this.points=re(n*5),this.filteredPointsBuffer=re(n*5)}get x(){return 0}get y(){return 0}get width(){return this._width}get height(){return this._height}static withProps(t){let i=new jx;return i.applyProps(t),i}applyProps(t){typeof t.width<"u"&&typeof t.height<"u"&&(t.width!==this._width||t.height!==this._height)&&this.resize(t.width,t.height),t.viewingDirection!==this.viewingDirection&&(this.viewingDirection=t.viewingDirection,this.triggerRepaint())}propagateTouchEvent(t,i,n){let r=[];for(let a of n)if(a.x&&a.y){let l=xe.singleBox(1,1,a.x,a.y);r.push(this.getObjectsAt(l,!0).reverse())}return r.map(a=>this.propagateEvent(t,i,a,{bubbles:!0,cancelable:!0}))}propagatePointerEvent(t,i,n,r,a={}){let l=xe.singleBox(1,1,n,r),c=this.getObjectsAt(l,!0).reverse();return this.propagateEvent(t,i,c,a)}propagateEvent(t,i,n,{bubbles:r=!1,cancelable:a=!1}={}){i.atlasTarget=this,this._propagateEventTargets.length=1,this._propagateEventTargets[0]=this;let l=!1;i.stopPropagation=()=>{l=!0};let c=n.length;for(let h=c-1;h>=0;h--){this._propagateEventTargets.unshift(n[h][0]);let y=n[h][1].length;if(y)for(let S=0;S<y;S++)this._propagateEventTargets.unshift(n[h][1][S])}let p=this._propagateEventTargets.length,m=!1;for(let h=0;h<p&&(i.atlasTarget=this._propagateEventTargets[h],i.atlasWorld=this,m=this._propagateEventTargets[h].dispatchEvent(t,i)||m,!l);h++);return m&&this.triggerRepaint(),this._propagateEventTargets}appendChild(t){let i=this.appendWorldObject(t);this.renderOrder.push(i/5)}removeChild(t){let i=this.objects.indexOf(t);if(i===-1){for(let n of this.objects)if(n&&n.id===t.id){this.removeChild(n);return}return}this.objects[i]=null,this.renderOrder=this.renderOrder.filter(n=>n!==i),this.points[i*5]=0,this.triggerRepaint(),this.needsRecalculate=!0}insertBefore(t,i){let n=this.objects.indexOf(i);if(n===-1)return;let r=this.appendWorldObject(t);this.renderOrder.splice(n-1,0,r/5)}hideInstance(){}asWorldObject(){return null}addZone(t){this.zones.push(t)}selectZone(t){if(typeof t=="string"){let i=this.zones.length;for(let n=0;n<i;n++)if(this.zones[n].id===t){this.selectedZone=n,this.trigger("zone-changed");return}}else this.zones[t]&&(this.selectedZone=t,this.trigger("zone-changed"))}deselectZone(){this.selectedZone=void 0}getActiveZone(){if(this.selectedZone)return this.zones[this.selectedZone]}hasActiveZone(){return typeof this.selectedZone<"u"}checkResizeInternalBuffer(){if(Oy(this.points)===this.objects.length){let t=this.points,i=re(this.points.length*2);i.set(t,0),this.points=i}}appendWorldObject(t){this.checkResizeInternalBuffer();let i=this.objects.length*5,n=t.points;return t.points=this.points.subarray(this.objects.length*5,this.objects.length*5+5),t.points[1]=n[1],t.points[2]=n[2],t.points[3]=n[3],t.points[4]=n[4],this.objects.push(t),this.filteredPointsBuffer=re(this.objects.length*5),this.needsRecalculate=!0,this.triggerRepaint(),i}recalculateWorldSize(){let t=!1;if(this.needsRecalculate){let i=new Int32Array(this.objects.length),n=new Int32Array(this.objects.length),r=this.renderOrder.length;for(let c=0;c<r;c++){let p=this.renderOrder[c];this.objects[p]&&(i[c]=this.points[p*5+3],n[c]=this.points[p*5+4])}let a=Math.max(...i);a!==this._width&&(this._width=a,t=!0);let l=Math.max(...n);l!==this._height&&(this._height=l,t=!0),t&&this.trigger("recalculate-world-size",{width:a,height:l}),this.needsRecalculate=!1}return t}addObjectAt(t,i){i.width&&!i.height?i.height=i.width/t.width*t.height:i.height&&!i.width&&(i.width=i.height/t.height*t.width),(!i||!i.width||!i.height)&&(i.width=t.width,i.height=t.height);let{width:n,x:r,y:a}=i,l=n/t.width;this.checkResizeInternalBuffer(),this.points.set(xe.singleBox(t.width,t.height,0,0),this.objects.length*5);let c=new Op(t);return c.points=this.points.subarray(this.objects.length*5,this.objects.length*5+5),this.objects.push(c),this.scaleWorldObject(this.objects.length-1,l),this.translateWorldObject(this.objects.length-1,r,a),this.filteredPointsBuffer=re(this.points.length*2),this.triggerRepaint(),this.needsRecalculate=!0,c}scaleWorldObject(t,i){Zt(this.points.subarray(t*5,t*5+5),On(i,this.points[t*5+1],this.points[t*5+2]));let n=this.objects[t];n&&(n.atScale(i),this.triggerRepaint())}translateWorldObject(t,i,n){Zt(this.points.subarray(t*5,t*5+5),ut(i,n));let r=this.objects[t];r&&(r.translate(i,n),this.triggerRepaint())}resize(t,i){return this._width=t,this._height=i,this.aspectRatio=t/i,this.triggerRepaint(),this}getObjects(){return this.objects}getPoints(){return this.points}getPointsFromViewer(t,i){let n=xe.singleBox(t.width,t.height,t.x,t.y);return this.getPointsAt(n,i,t.scale)}addLayoutSubscriber(t){return this.subscriptions.push(t),()=>{this.subscriptions.splice(this.subscriptions.indexOf(t),1)}}getScheduledUpdates(t,i){let n=or(this.points,t,this.filteredPointsBuffer),r=this.objects.length;this._updatedList=[];for(let a=0;a<r;a++)if(n[a*5]!==0){if(!this.objects[a])continue;this._updatedList.push(...this.objects[a].getScheduledUpdates(t,i))}return this._updatedList}getObjectsAt(t,i=!1){let n=this.getActiveZone(),r=or(this.points,t,this.filteredPointsBuffer),a=this.renderOrder.length,l=[];for(let c=0;c<a;c++){let p=this.renderOrder[c];if(r[p*5]!==0){let m=this.objects[p];if(!m||n&&n.objects.indexOf(m)===-1)continue;if(m.type!=="world-object"){l.push([m,[m]]);continue}i?l.push([m,m.getObjectsAt(t,i)]):l.push([m,this.emptyPaintables])}}return l}getPointsAt(t,i,n=1){let r=this.getObjectsAt(t),a=pi(wi(n),ut(-t[1],-t[2]),this.translationBuffer),l=i?pi(i,a,this.aggregateBuffer):a,c=r.length,p=[];for(let m=0;m<c;m++)r[m]&&p.push(...r[m][0].getAllPointsAt(t,l,n));return p}flushSubscriptions(){if(this.triggerQueue.length){this._alreadyFlushed=[];let t=this.triggerQueue.length;for(let i=0;i<t;i++){if(this._alreadyFlushed.indexOf(this.triggerQueue[i][0])!==-1)continue;typeof this.triggerQueue[i][1]>"u"&&this._alreadyFlushed.push(this.triggerQueue[i][0]);let n=this.subscriptions.length;for(let r=0;r<n;r++)this.subscriptions[r].apply(null,this.triggerQueue[i])}this.triggerQueue=[]}}trigger(t,i){this.triggerQueue.push([t,i])}triggerEventActivation(){this.trigger("event-activation")}triggerRepaint(){this.trigger("repaint")}gotoRegion(t){this.trigger("goto-region",t)}goHome(t=!1){this.trigger("go-home",{immediate:t})}zoomTo(t,i,n){this.trigger("zoom-to",{point:i,factor:t,stream:n})}zoomIn(t){this.trigger("zoom-to",{point:t,factor:.5})}zoomOut(t){this.trigger("zoom-to",{point:t,factor:2})}constraintBounds(t){this.trigger("constrain-bounds",{immediate:t})}};var lu=/([0-9]+(px|em)\s+)+(solid)\s+(.*)/g,uu={},vP=["backgroundColor","opacity","boxShadow","borderColor","borderWidth","borderStyle","outlineColor","outlineWidth","outlineOffset","outlineStyle"],Qs=class extends bn{constructor(){super(),P(this,"id"),P(this,"type","spacial-content"),P(this,"points"),P(this,"hoverEvents",!1),P(this,"activeEvents",!1),P(this,"display",{x:0,y:0,scale:1,width:-1,height:-1,points:re(5)}),P(this,"_parsed",{border:{id:null,match:[]},outline:{id:null,match:[]}}),P(this,"hovering"),P(this,"pressing"),P(this,"props",{}),P(this,"addHover",()=>{this.hovering=!0,this.__revision++}),P(this,"removeHover",()=>{this.hovering=!1,this.pressing=!1,this.__revision++}),P(this,"addPress",()=>{this.pressing=!0,this.__revision++}),P(this,"removePress",()=>{this.pressing=!1,this.__revision++}),this.id=Cu(12),this.points=re(5)}getAllPointsAt(e,t){return[[this,this.points,t]]}applyProps(e={}){let t=!1;if(e.interactive!==this.props.interactive&&(t=!0,this.props.interactive=e.interactive),e.style){let i=e.border||e.style.border;if(i!==this._parsed.border.id)if(!i)this._parsed.border.id=null,this._parsed.border.match=[];else{let n=uu[i]||lu.exec(i)||lu.exec(i);n&&(this._parsed.border.id=i,this._parsed.border.match=uu[i]=n)}if(this._parsed.border.id&&(e.style.borderWidth=this._parsed.border.match[1],e.style.borderStyle="solid",e.style.borderColor=this._parsed.border.match[4]),e.style.outline!==this._parsed.outline.id)if(!e.style.outline)this._parsed.outline.id=null,this._parsed.outline.match=[];else{let n=uu[e.style.outline]||lu.exec(e.style.outline)||lu.exec(e.style.outline);n&&(this._parsed.outline.id=e.style.outline,this._parsed.outline.match=uu[e.style.outline]=n)}this._parsed.outline.id&&(e.style.outlineWidth=this._parsed.outline.match[1],e.style.outlineStyle="solid",e.style.outlineColor=this._parsed.outline.match[4]),this.props.style=e.style,e.backgroundColor&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=e.backgroundColor,t=!0),e.style.background&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=e.style.background,t=!0);for(let n of vP)if(this.props.style[n]!==e.style[n]){t=!0;break}e.style[":hover"]!==this.props.hoverStyles&&(this.props.hoverStyles=e.style[":hover"],this.hoverEvents||(this.hoverEvents=!0,this.addEventListener("pointerenter",this.addHover),this.addEventListener("pointerleave",this.removeHover)),t=!0),e.style[":active"]!==this.props.pressStyles&&(this.props.pressStyles=e.style[":active"],this.activeEvents||(this.activeEvents=!0,this.addEventListener("mousedown",this.addPress),this.addEventListener("mouseup",this.removePress)),t=!0)}e.href!==this.props.href&&(this.props.href=e.href,t=!0),e.hrefTarget!==this.props.hrefTarget&&(this.props.hrefTarget=e.hrefTarget,t=!0),e.title!==this.props.title&&(this.props.title=e.title,t=!0),e.className!==this.props.className&&(this.props.className=e.className,e.className&&!this.hoverEvents&&(this.hoverEvents=!0,this.addEventListener("pointerenter",this.addHover),this.addEventListener("pointerleave",this.removeHover)),e.className&&!this.activeEvents&&(this.activeEvents=!0,this.addEventListener("mousedown",this.addPress),this.addEventListener("mouseup",this.removePress)),t=!0),e.relativeSize!==this.props.relativeSize&&(this.props.relativeSize=e.relativeSize,t=!0),e.relativeStyle!==this.props.relativeStyle&&(this.props.relativeStyle=e.relativeStyle,t=!0),e.html!==this.props.html&&(this.props.html=e.html,t=!0),e.target&&(e.target.width!==this.display.width||e.target.height!==this.display.height||e.target.x!==this.points[1]||e.target.y!==this.points[2])&&(t=!0,this.points=xe.singleBox(e.target.width,e.target.height,e.target.x,e.target.y),this.display.points=xe.singleBox(e.target.width,e.target.height,e.target.x,e.target.y),this.display.width=e.target.width,this.display.height=e.target.height),t&&this.__revision++}},gu=class extends bn{constructor(){super(),P(this,"type","spacial-content"),P(this,"id"),P(this,"points"),P(this,"color","#000"),P(this,"backgroundColor"),P(this,"hovering"),P(this,"pressing"),P(this,"text",""),P(this,"display",{x:0,y:0,scale:1,width:100,height:100,points:re(5)}),P(this,"className"),P(this,"html"),P(this,"interactive",!1),P(this,"props",{font:"18px Arial, sans-serif",lineHeight:1,textAlign:"left",verticalAlign:"top",paddingX:0,paddingY:0,fitParent:!1,lineBreak:"auto",strokeText:!1,sizeToFill:!1,maxFontSizeToFill:void 0,allowNewLine:!0,justifyLines:!1,renderHDPI:!1,textDecoration:"none",interactive:!1,relativeSize:!1}),this.id="",this.points=re(5)}getAllPointsAt(e,t){return[[this,this.points,t]]}applyProps({id:e,target:t,text:i,color:n,backgroundColor:r,fontSize:a=18,interactive:l,fontFamily:c="Arial, sans-serif",...p}){p.font=`${a}px ${c}`,this.interactive=l||!1,typeof i<"u"&&(this.text=i||""),n&&(this.color=n),r&&(this.backgroundColor=r),e&&(this.id=e),t&&(this.points=xe.singleBox(t.width,t.height,t.x,t.y),this.display.points=this.points,this.display.width=t.width,this.display.height=t.height),this.props={...this.props,...p},this.__revision++}},ct=Math.pow,cu=Math.sqrt,Hs=Math.sin,Px=Math.cos,$s=Math.PI,xu=1.70158,du=xu*1.525,Ex=xu+1,Ax=2*$s/3,Ix=2*$s/4.5,hu=function(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},ur={linear:e=>e,easeInQuad:function(e){return e*e},easeOutQuad:function(e){return 1-(1-e)*(1-e)},easeInOutQuad:function(e){return e<.5?2*e*e:1-ct(-2*e+2,2)/2},easeInCubic:function(e){return e*e*e},easeOutCubic:function(e){return 1-ct(1-e,3)},easeInOutCubic:function(e){return e<.5?4*e*e*e:1-ct(-2*e+2,3)/2},easeInQuart:function(e){return e*e*e*e},easeOutQuart:function(e){return 1-ct(1-e,4)},easeInOutQuart:function(e){return e<.5?8*e*e*e*e:1-ct(-2*e+2,4)/2},easeInQuint:function(e){return e*e*e*e*e},easeOutQuint:function(e){return 1-ct(1-e,5)},easeInOutQuint:function(e){return e<.5?16*e*e*e*e*e:1-ct(-2*e+2,5)/2},easeInSine:function(e){return 1-Px(e*$s/2)},easeOutSine:function(e){return Hs(e*$s/2)},easeInOutSine:function(e){return-(Px($s*e)-1)/2},easeInExpo:function(e){return e===0?0:ct(2,10*e-10)},easeOutExpo:function(e){return e===1?1:1-ct(2,-10*e)},easeInOutExpo:function(e){return e===0?0:e===1?1:e<.5?ct(2,20*e-10)/2:(2-ct(2,-20*e+10))/2},easeInCirc:function(e){return 1-cu(1-ct(e,2))},easeOutCirc:function(e){return cu(1-ct(e-1,2))},easeInOutCirc:function(e){return e<.5?(1-cu(1-ct(2*e,2)))/2:(cu(1-ct(-2*e+2,2))+1)/2},easeInBack:function(e){return Ex*e*e*e-xu*e*e},easeOutBack:function(e){return 1+Ex*ct(e-1,3)+xu*ct(e-1,2)},easeInOutBack:function(e){return e<.5?ct(2*e,2)*((du+1)*2*e-du)/2:(ct(2*e-2,2)*((du+1)*(e*2-2)+du)+2)/2},easeInElastic:function(e){return e===0?0:e===1?1:-ct(2,10*e-10)*Hs((e*10-10.75)*Ax)},easeOutElastic:function(e){return e===0?0:e===1?1:ct(2,-10*e)*Hs((e*10-.75)*Ax)+1},easeInOutElastic:function(e){return e===0?0:e===1?1:e<.5?-(ct(2,20*e-10)*Hs((20*e-11.125)*Ix))/2:ct(2,-20*e+10)*Hs((20*e-11.125)*Ix)/2+1},easeInBounce:function(e){return 1-hu(1-e)},easeOutBounce:hu,easeInOutBounce:function(e){return e<.5?(1-hu(1-2*e))/2:(1+hu(2*e-1))/2}},xP=class{constructor(e){P(this,"runtime"),P(this,"pendingTransition"),this.runtime=e,this.pendingTransition={from:re(5),to:re(5),elapsed_time:0,done:!0,total_time:0,timingFunction:ur.easeInOutQuad,constrain:!1}}hasPending(){return!this.pendingTransition.done}getPendingTransition(){return this.pendingTransition}getPendingFrom(){return this.pendingTransition.from}customTransition(e){e(this.pendingTransition)}stopTransition(){this.pendingTransition.from=re(this.runtime.target),this.pendingTransition.to=re(this.runtime.target),this.pendingTransition.done=!0,this.pendingTransition.elapsed_time=0,this.pendingTransition.total_time=0}runTransition(e,t){if(!this.pendingTransition.done){let i=this.pendingTransition,n=i.total_time===0?0:(i.elapsed_time+t)/i.total_time,r=i.total_time===0?1:n===0?0:i.timingFunction(n);e[1]=i.from[1]+(i.to[1]-i.from[1])*r,e[2]=i.from[2]+(i.to[2]-i.from[2])*r,e[3]=i.from[3]+(i.to[3]-i.from[3])*r,e[4]=i.from[4]+(i.to[4]-i.from[4])*r,this.pendingTransition.elapsed_time+=t,this.pendingTransition.elapsed_time>=this.pendingTransition.total_time&&(this.pendingTransition.done=!0,this.pendingTransition.constrain&&this.constrainBounds({transition:{duration:this.pendingTransition.total_time===0?0:500,easing:ur.easeOutExpo}}))}}zoomTo(e,{origin:t,stream:i=!1,transition:n}={}){let r=this.runtime.getZoomedPosition(e,{origin:t}),a=Math.abs(1-e);this.applyTransition(r,n,{duration:2e3*a,easing:ur.easeOutExpo,constrain:!0},{stream:!1})}constrainBounds({transition:e,panPadding:t=0}={}){let[i,n]=this.runtime.constrainBounds(this.runtime.target,{panPadding:t});i&&(this.applyTransition(n,e,{duration:500,easing:ur.easeOutQuart,constrain:!1}),this.runtime.updateNextFrame())}applyTransition(e,t,i,{stream:n}={}){this.pendingTransition.from=re(this.runtime.target),this.pendingTransition.to=e,n||(this.pendingTransition.elapsed_time=0),this.pendingTransition.done=!1,this.pendingTransition.total_time=typeof t?.duration<"u"?t.duration:typeof i?.duration<"u"?i.duration:1e3,this.pendingTransition.constrain=typeof t?.constrain<"u"?t.constrain:typeof i?.constrain<"u"?i.constrain:!1,this.pendingTransition.timingFunction=t?.easing||i?.easing||ur.easeInOutSine}goToRegion(e,{transition:t}={}){let i=this.runtime.clampRegion(e);this.applyTransition(xe.singleBox(i.width,i.height,i.x,i.y),t,{duration:1e3,easing:ur.easeOutExpo,constrain:!0}),this.runtime.updateNextFrame()}},c_=Number.MIN_VALUE+1,Eu=class{constructor(e,t,i,n=[],r){P(this,"id",Cu()),P(this,"ready",!1),P(this,"renderer"),P(this,"world"),P(this,"target"),P(this,"homePosition"),P(this,"manualHomePosition"),P(this,"manualFocalPosition"),P(this,"focalPosition"),P(this,"transitionManager"),P(this,"aggregate"),P(this,"transformBuffer",re(500)),P(this,"lastTarget",re(5)),P(this,"zoomBuffer",re(5)),P(this,"logNextRender",!1),P(this,"pendingUpdate",!0),P(this,"isCommitting",!1),P(this,"firstRender",!0),P(this,"lastTime"),P(this,"stopId"),P(this,"mode","explore"),P(this,"controllers",[]),P(this,"controllersRunning",!1),P(this,"controllerStopFunctions",[]),P(this,"maxScaleFactor",1),P(this,"_viewerToWorld",{x:0,y:0}),P(this,"_lastGoodScale",1),P(this,"hooks",{useFrame:[],useBeforeFrame:[],useAfterPaint:[],useAfterFrame:[]}),P(this,"fpsLimit"),P(this,"options"),P(this,"hookOptions",{filters:{grayscale:0,contrast:0,brightness:0,saturate:0,sepia:0,invert:0,hueRotate:0,blur:0}}),P(this,"_viewport",{x:0,y:0,width:0,height:0}),P(this,"setViewport",a=>{let l=Math.round(typeof a.x>"u"?this.target[1]:a.x),c=Math.round(typeof a.y>"u"?this.target[2]:a.y);a.width?this.target[3]=l+a.width:this.target[3]=this.target[3]-this.target[1]+l,a.height?this.target[4]=c+a.height:this.target[4]=this.target[4]-this.target[2]+c,Math.abs(this.target[1]-l)>.01&&(this.target[1]=l),Math.abs(this.target[2]-c)>.01&&(this.target[2]=c),this.pendingUpdate=!0}),P(this,"render",a=>{let l=a-this.lastTime;if(this.isCommitting||this.fpsLimit&&l<1e3/this.fpsLimit){this.stopId=window.requestAnimationFrame(this.render);return}this.lastTime=a,this.world.flushSubscriptions(),this.stopId=window.requestAnimationFrame(this.render),this.hook("useFrame",l);let c=this.pendingUpdate,p=this.renderer.pendingUpdate();if(this.transitionManager.hasPending()&&(this.transitionManager.runTransition(this.target,l),this.pendingUpdate=!0,this.updateControllerPosition()),!this.firstRender&&!c&&!p&&this.target[0]===this.lastTarget[0]&&this.target[1]===this.lastTarget[1]&&this.target[2]===this.lastTarget[2]&&this.target[3]===this.lastTarget[3]&&this.target[4]===this.lastTarget[4])return;this.hook("useBeforeFrame",l),this.renderer.beforeFrame(this.world,l,this.target,this.hookOptions);let m=this.getScaleFactor(),h=this.renderer.getPointsAt(this.world,this.target,this.aggregate,m),y=h.length;for(let v=0;v<y;v++){let x=h[v][0],A=h[v][1],C=h[v][2],I=C?bi(A,C,this.transformBuffer):A;this.renderer.prepareLayer(x,x.__parent&&C?bi(x.__parent.crop||x.__parent.points,C):I);let E=I.length/5;for(let L=0;L<E;L++){let z=L*5;I[z]!==0&&(this.renderer.paint(x,L,I[z+1],I[z+2],I[z+3]-I[z+1],I[z+4]-I[z+2]),this.hook("useAfterPaint",x))}this.renderer.finishLayer(x,A)}this.renderer.afterFrame(this.world,l,this.target,this.hookOptions),this.hook("useAfterFrame",l),this.lastTarget[0]=this.target[0],this.lastTarget[1]=this.target[1],this.lastTarget[2]=this.target[2],this.lastTarget[3]=this.target[3],this.lastTarget[4]=this.target[4],this.firstRender=!1,this.pendingUpdate=!1,this.logNextRender=!1,this.renderer.isReady()&&(this.ready=!0,this.world.trigger("ready")),this.world.flushSubscriptions();let S=this.world.getScheduledUpdates(this.target,m),w=S.length;if(w>0)for(let v=0;v<w;v++){let x=S[w-v-1]();x?x.then(()=>{this.pendingUpdate=!0}):this.pendingUpdate=!0}}),this.renderer=e,this.world=t,this.options={maxOverZoom:1,maxUnderZoom:1,visibilityRatio:1.5,...r||{}},this.target=xe.projection(i),this.manualHomePosition=!1,this.pendingUpdate=!0,this.homePosition=xe.projection(this.world),this.manualFocalPosition=!1,this.focalPosition=this.target,this.updateFocalPosition(),this.transitionManager=new xP(this),this.aggregate=wi(1),this.world.addLayoutSubscriber(a=>{a==="repaint"&&(this.pendingUpdate=!0),a==="recalculate-world-size"&&(this.manualHomePosition||(this.setHomePosition(),this.goHome()),this.updateFocalPosition())}),this.lastTime=performance.now(),this.controllers=n,this.render(this.lastTime),this.startControllers()}get x(){return this.target[1]}set x(e){this.target[1]=e}get y(){return this.target[2]}set y(e){this.target[2]=e}get x2(){return this.target[3]}set x2(e){this.target[3]=e}get y2(){return this.target[4]}set y2(e){this.target[4]=e}get width(){return this.target[3]-this.target[1]}set width(e){this.target[3]=this.target[1]+e}get height(){return this.target[4]-this.target[2]}set height(e){this.target[4]=this.target[2]=e}setHomePosition(e){this.homePosition.set(xe.projection(e||this.world)),this.pendingUpdate=!0}startControllers(){if(!this.controllersRunning){for(let e of this.controllers)this.controllerStopFunctions.push(e.start(this));this.controllersRunning=!0}}stopControllers(){if(this.controllersRunning){for(let e of this.controllerStopFunctions)e();this.controllersRunning=!1,this.controllerStopFunctions=[]}}updateControllerPosition(){for(let e of this.controllers)e.updatePosition(this.x,this.y,this.width,this.height)}triggerResize(){this.renderer.triggerResize&&this.renderer.triggerResize(),this.pendingUpdate=!0}addController(e){this.controllers.push(e),this.controllersRunning&&e.start(this),this.pendingUpdate=!0}cover(){return this.goHome({cover:!0})}getRendererScreenPosition(){return this.renderer.getRendererScreenPosition()}updateRendererScreenPosition(){this.pendingUpdate=!0,this.renderer.resize()}setOptions(e){this.options={...this.options,...e}}goHome(e={}){if(this.world.width<=0||this.world.height<=0)return;let t=this.getScaleFactor(),i=e.position?{x:e.position[1],y:e.position[2],width:e.position[3]-e.position[1],height:e.position[4]-e.position[2]}:{x:this.homePosition[1],y:this.homePosition[2],width:this.homePosition[3]-this.homePosition[1],height:this.homePosition[4]-this.homePosition[2]},n=this.width*t,r=this.height*t,a=i.width/n,l=i.height/r,c=n/r;if(e.cover?a>l:a<l){let p=c*i.height,m=(p-i.width)/2;this.target[1]=Math.round(-m+i.x),this.target[2]=Math.round(i.y),this.target[3]=Math.round(p-m+i.x),this.target[4]=Math.round(i.height+i.y)}else{let p=i.width/c,m=(p-i.height)/2;this.target[1]=Math.round(i.x),this.target[2]=Math.round(i.y-m),this.target[3]=Math.round(i.x+i.width),this.target[4]=Math.round(i.y+p-m)}this.constrainBounds(this.target),this.updateControllerPosition()}resize(e,t,i,n){this.updateFocalPosition(e-t,i-n);let r=t/e,a=n/i;this.target[3]=this.target[1]+(this.target[3]-this.target[1])*r,this.target[4]=this.target[2]+(this.target[4]-this.target[2])*a,this.goHome({position:this.focalPosition}),this.renderer.resize(t,n),this.pendingUpdate=!0}updateFocalPosition(e,t){if(!this.manualFocalPosition){let i=this.width,n=this.height,r=Math.min(i,n),a=0,l=0,c=this.x+a,p=this.y+l;if(i<n){let m=this.height-this.width;this.focalPosition=xe.projection({x:c,y:p+m/2,width:r-a*2,height:r-l*2}),this.pendingUpdate=!0}else{let m=this.width-this.height;this.focalPosition=xe.projection({x:c+m/2,y:p,width:r-a*2,height:r-l*2}),this.pendingUpdate=!0}}}getViewport(){return this._viewport.x=this.target[1],this._viewport.y=this.target[2],this._viewport.width=this.target[3]-this.target[1],this._viewport.height=this.target[4]-this.target[2],this._viewport}constrainBounds(e,{panPadding:t=0,ref:i=!1}={}){let{minX:n,maxX:r,minY:a,maxY:l}=this.getBounds({target:e,padding:t}),c=!1,p=i?e:re(e),m=Math.round(e[3]-e[1]),h=Math.round(e[4]-e[2]);return n>e[1]&&(c=!0,p[1]=n,p[3]=n+m),a>e[2]&&(c=!0,p[2]=a,p[4]=a+h),r<e[1]&&(c=!0,p[1]=r,p[3]=r+m),l<e[2]&&(c=!0,p[2]=l,p[4]=l+h),[c,p]}getBounds(e){let t=e.target||this.target,i=e.padding,n=this.options.visibilityRatio,r=Math.abs(1-n);if(this.world.hasActiveZone()){let C=this.world.getActiveZone();if(C){let I=t[3]-t[1]<C.points[3]-C.points[1],E=t[4]-t[2]<C.points[4]-C.points[2];return{minX:I?C.points[1]-i:C.points[1]+(C.points[3]-C.points[1])/2-(t[3]-t[1])/2,maxX:E?C.points[2]-i:C.points[2]+(C.points[4]-C.points[2])/2-(t[4]-t[2])/2,minY:I?C.points[3]+i:C.points[1]+(C.points[3]-C.points[1])/2-(t[3]-t[1])/2,maxY:E?C.points[4]+i:C.points[2]+(C.points[4]-C.points[2])/2-(t[4]-t[2])/2}}}let a=t[3]-t[1],l=this.world.width,c=-a*r,p=l-a-c,m=t[4]-t[2],h=this.world.height,y=-m*r,S=h-m-y,w=Math.round(Math.max(c,p)),v=Math.round(Math.min(c,p)),x=Math.round(Math.max(y,S)),A=Math.round(Math.min(y,S));return{minX:v,maxX:w,minY:A,maxY:x}}getScaleFactor(e=!1){let t=this.renderer.getScale(this.target[3]-this.target[1],this.target[4]-this.target[2],e);return t===0?this._lastGoodScale:(this._lastGoodScale=t,t)}getZoomedPosition(e,{origin:t,fromPos:i}){let n=i?{width:i[3]-i[1],height:i[4]-i[2]}:void 0,r=n?this.renderer.getScale(n.width,n.height):this.getScaleFactor(),a=n?n.width:this.width,l=n?n.height:this.height,c=this.getRendererScreenPosition()?.width,p=this.world.width,m=c?c/p:1,h=this.options.maxUnderZoom,y=Math.max(m||1,this.options.maxOverZoom),S=1/e,w=r*S;if(S<1){let x=a*r,A=l*r,C=this.world.width/x,I=this.world.height/A;if(C>I){let E=this.world.width*w,L=~~(a*r)*h;E<L&&(e=this.world.width*r/(a*r*h))}else{let E=this.world.height*w,L=~~(l*r)*h;E<L&&(e=this.world.height*r/(l*r*h))}}else w>y&&(e=r/y);let v=bi(this.target,On(e,t?t.x:this.target[1]+(this.target[3]-this.target[1])/2,t?t.y:this.target[2]+(this.target[4]-this.target[2])/2),this.zoomBuffer);return this.constrainBounds(v,{ref:!0,panPadding:100}),v}clampRegion({x:e,y:t,width:i,height:n,padding:r=0}){let a=this.width,l=this.height,c=i/a<n/l,p=e-r,m=t-r,h=i+r*2,y=n+r*2;if(c){let w=y/l*a;return{x:p-(w-h)/2,y:m,width:w,height:y}}let S=h/a*l;return{x:p,y:m-(S-y)/2,width:h,height:S}}viewerToWorld(e,t){let i=this.getScaleFactor();return this._viewerToWorld.x=this.target[1]+e/i,this._viewerToWorld.y=this.target[2]+t/i,this._viewerToWorld}worldToViewer(e,t,i,n){let r=xe.singleBox(i,n,e,t);return Zt(r,pi(wi(this.getScaleFactor()),ut(-this.target[1],-this.target[2]))),{x:r[1],y:r[2],width:r[3]-r[1],height:r[4]-r[2],strand:r}}setScale(e,t){Zt(this.target,On(e,t?t.x:this.target[1]+(this.target[3]-this.target[1])/2,t?t.y:this.target[2]+(this.target[4]-this.target[2])/2)),this.pendingUpdate=!0}syncTo(e){let t=this.target;return this.target=e.target,this.pendingUpdate=!0,()=>{this.target=t}}stop(){return typeof this.stopId<"u"&&(window.cancelAnimationFrame(this.stopId),this.stopId=void 0),()=>{this.render(performance.now())}}reset(){this.renderer.reset()}selectZone(e){this.world.selectZone(e),this.pendingUpdate=!0}deselectZone(){this.world.deselectZone(),this.pendingUpdate=!0}hook(e,t){let i=this.hooks[e].length;if(i!==0)for(let n=0;n<i;n++)this.hooks[e][n](t)}registerHook(e,t){return this.hooks[e].push(t),()=>{this.hooks[e]=this.hooks[e].filter(i=>i!==t)}}updateNextFrame(){this.pendingUpdate=!0}},pu=/([0-9]+(px|em)\s+)+(solid)\s+(.*)/g,fu={},SP=["backgroundColor","opacity","boxShadow","borderColor","borderWidth","borderStyle","outlineColor","outlineWidth","outlineOffset","outlineStyle"],Vx=class extends bn{constructor(){super(),P(this,"id"),P(this,"type","spacial-content"),P(this,"isShape",!0),P(this,"points"),P(this,"hoverEvents",!1),P(this,"activeEvents",!1),P(this,"display",{x:0,y:0,scale:1,width:-1,height:-1,points:re(5)}),P(this,"boundingBox",null),P(this,"_parsed",{border:{id:null,match:[]},outline:{id:null,match:[]}}),P(this,"hovering"),P(this,"pressing"),P(this,"props",{}),P(this,"shape",{type:"none"}),P(this,"addHover",()=>{this.hovering=!0,this.__revision++}),P(this,"removeHover",()=>{this.hovering=!1,this.pressing=!1,this.__revision++}),P(this,"addPress",()=>{this.pressing=!0,this.__revision++}),P(this,"removePress",()=>{this.pressing=!1,this.__revision++}),this.id=Cu(12),this.points=re(5),this.shape={type:"none"}}updateBoundingBox(){if(this.shape.type==="none")return;let e=this.shape.points;if(this.shape.points.length>2){let t=Math.min(...e.map(a=>a[0])),i=Math.min(...e.map(a=>a[1])),n=Math.max(0,...e.map(a=>a[0])),r=Math.max(0,...e.map(a=>a[1]));this.boundingBox={x:t,y:i,width:n-t,height:r-i};return}this.boundingBox=null}intersects(e){if(!e||this.shape.type==="none")return!1;let[t,i]=e,n=this.shape.points,r=this.boundingBox;if(r||(this.updateBoundingBox(),r=this.boundingBox),!r||t<r.x||t>r.x+r.width||i<r.y||i>r.height+r.y)return!1;let a=!1;for(let l=0,c=n.length-1;l<n.length;c=l++)n[l][1]>i!=n[c][1]>i&&t<(n[c][0]-n[l][0])*(i-n[l][1])/(n[c][1]-n[l][1])+n[l][0]&&(a=!a);return a}getAllPointsAt(e,t){return e[3]-e[1]===1&&e[4]-e[2]===1?this.intersects([e[1],e[2]])?[[this,this.points,t]]:[]:[[this,this.points,t]]}applyProps(e={}){let t=!1;if(e.points)if(this.shape.type!=="polygon"||this.shape.points.length!==e.points.length)this.shape={type:"polygon",points:e.points,open:e.open},this.updateBoundingBox();else{let i=!1,n=e.points.length;for(let r=0;r<n;r++)if(e.points[r][0]!==this.shape.points[r][0]||e.points[r][1]!==this.shape.points[r][1]){i=!0;break}i&&(this.shape={type:"polygon",points:e.points,open:e.open},this.updateBoundingBox())}if(e.interactive!==this.props.interactive&&(t=!0,this.props.interactive=e.interactive),(e.open||e.open===!1)&&(t=!0,this.shape.open=e.open),e.style){let i=e.border||e.style.border;if(i!==this._parsed.border.id)if(!i)this._parsed.border.id=null,this._parsed.border.match=[];else{let n=fu[i]||pu.exec(i)||pu.exec(i);n&&(this._parsed.border.id=i,this._parsed.border.match=fu[i]=n)}if(this._parsed.border.id&&(e.style.borderWidth=this._parsed.border.match[1],e.style.borderStyle="solid",e.style.borderColor=this._parsed.border.match[4]),e.style.outline!==this._parsed.outline.id)if(!e.style.outline)this._parsed.outline.id=null,this._parsed.outline.match=[];else{let n=fu[e.style.outline]||pu.exec(e.style.outline)||pu.exec(e.style.outline);n&&(this._parsed.outline.id=e.style.outline,this._parsed.outline.match=fu[e.style.outline]=n)}this._parsed.outline.id&&(e.style.outlineWidth=this._parsed.outline.match[1],e.style.outlineStyle="solid",e.style.outlineColor=this._parsed.outline.match[4]),this.props.style=e.style,e.backgroundColor&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=e.backgroundColor,t=!0),e.style.background&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=e.style.background,t=!0);for(let n of SP)if(this.props.style[n]!==e.style[n]){t=!0;break}e.style[":hover"]!==this.props.hoverStyles&&(this.props.hoverStyles=e.style[":hover"],this.hoverEvents||(this.hoverEvents=!0,this.addEventListener("pointerenter",this.addHover),this.addEventListener("pointerleave",this.removeHover)),t=!0),e.style[":active"]!==this.props.pressStyles&&(this.props.pressStyles=e.style[":active"],this.activeEvents||(this.activeEvents=!0,this.addEventListener("mousedown",this.addPress),this.addEventListener("mouseup",this.removePress)),t=!0)}e.href!==this.props.href&&(this.props.href=e.href,t=!0),e.hrefTarget!==this.props.hrefTarget&&(this.props.hrefTarget=e.hrefTarget,t=!0),e.title!==this.props.title&&(this.props.title=e.title,t=!0),e.className!==this.props.className&&(this.props.className=e.className,e.className&&!this.hoverEvents&&(this.hoverEvents=!0,this.addEventListener("pointerenter",this.addHover),this.addEventListener("pointerleave",this.removeHover)),e.className&&!this.activeEvents&&(this.activeEvents=!0,this.addEventListener("mousedown",this.addPress),this.addEventListener("mouseup",this.removePress)),t=!0),e.relativeSize!==this.props.relativeSize&&(this.props.relativeSize=e.relativeSize,t=!0),e.relativeStyle!==this.props.relativeStyle&&(this.props.relativeStyle=e.relativeStyle,t=!0),e.html!==this.props.html&&(this.props.html=e.html,t=!0),e.target&&(e.target.width!==this.display.width||e.target.height!==this.display.height||e.target.x!==this.points[1]||e.target.y!==this.points[2])&&(t=!0,this.points=xe.singleBox(e.target.width,e.target.height,e.target.x,e.target.y),this.display.points=xe.singleBox(e.target.width,e.target.height,e.target.x,e.target.y),this.display.width=e.target.width,this.display.height=e.target.height),t&&this.__revision++}},Rx=/(-?[0-9]+(px|em)\s+|0\s+)(-?[0-9]+(px|em)\s+|0\s+)(-?[0-9]+(px|em)\s+|0\s+)?(-?[0-9]+(px|em)\s+|0\s+)?(.*)/g,Tx={},wP=typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes("firefox"),mu={},bP=class{constructor(e,t){P(this,"canvas"),P(this,"ctx"),P(this,"options"),P(this,"imagesPending",0),P(this,"imagesLoaded",0),P(this,"imageIdsLoaded",[]),P(this,"frameIsRendering",!1),P(this,"pendingDrawCall",!1),P(this,"firstMeaningfulPaint",!1),P(this,"parallelTasks",8),P(this,"frameTasks",0),P(this,"loadingQueueOrdered",!0),P(this,"loadingQueue",[]),P(this,"currentTask",Promise.resolve()),P(this,"tasksRunning",0),P(this,"stats"),P(this,"averageJobTime",64),P(this,"lastKnownScale",1),P(this,"visible",[]),P(this,"previousVisible",[]),P(this,"rendererPosition"),P(this,"dpi"),P(this,"drawCalls",[]),P(this,"lastPaintedObject"),P(this,"hostCache"),P(this,"invalidated",[]),P(this,"_worker",()=>{if(this.loadingQueue.length){let i=this.loadingQueue.pop();i&&(this.tasksRunning++,this.frameTasks++,this.currentTask=i.task().then(()=>{this.tasksRunning--}).catch(()=>{this.tasksRunning--}))}}),P(this,"_scheduled",0),P(this,"_doWork",()=>{this.loadingQueue.length===0&&this.tasksRunning===0&&this._scheduled&&(clearInterval(this._scheduled),this._scheduled=0);let i=this.parallelTasks||1;!this.firstMeaningfulPaint&&this.loadingQueue.length&&(i=this.loadingQueue.length);for(let n=0;n<=i;n++)this._worker()}),this.canvas=e,this.rendererPosition=e.getBoundingClientRect(),this.ctx=e.getContext("2d",{alpha:!0}),this.ctx.imageSmoothingEnabled=!0,this.options=t||{},this.canvas.style.opacity="0",this.canvas.style.transition="opacity .3s",this.dpi=t?.dpi||1,this.hostCache=t?.lruCache?new Ny({maxSize:1024*512*512,dispose:(i,n,r)=>{this.invalidated.push(n),i.width=0,i.height=0},sizeCalculation:(i,n)=>i.width*i.height}):{store:{},get(i){return this.store[i]},set(i,n){this.store[i]=n}}}getCanvasDims(){return{width:this.canvas.width/this.dpi,height:this.canvas.height/this.dpi}}resize(){this.rendererPosition=this.canvas.getBoundingClientRect()}isReady(){return this.firstMeaningfulPaint}afterFrame(e){if(this.clearTransform(),this.lastPaintedObject=void 0,this.frameIsRendering=!1,this.imagesPending=Math.max(0,this.imagesPending-this.imagesLoaded),this.imagesLoaded=0,this.loadingQueueOrdered||(this.loadingQueue=this.loadingQueue.sort((t,i)=>t.network&&t.scale===i.scale?i.distance-t.distance:t.scale<i.scale?-1:1),this.loadingQueueOrdered=!0),this.previousVisible=this.visible,this.pendingDrawCall=!!this.drawCalls.length,this.pendingDrawCall)for(let t=0;t<this.drawCalls.length;t++){let i=this.drawCalls.shift();i&&i()}this.doOffscreenWork(),this.options.debug&&this.stats&&this.stats.end()}doOffscreenWork(){this.frameTasks=0,this.loadingQueue.length&&(this._worker(),this.loadingQueue.length&&(this._scheduled||(this._scheduled=setInterval(this._doWork,0))))}getScale(e,t,i){if(Number.isNaN(e)||Number.isNaN(t))return this.lastKnownScale;let n=this.getCanvasDims(),r=n.width/e,a=n.height/t,l=(r<a?a:r)*(i&&this.dpi||1);return Number.isNaN(l)||(this.lastKnownScale=l),this.lastKnownScale}beforeFrame(e,t,i,n){this.options.debug&&this.stats&&this.stats.begin(),this.frameIsRendering=!0,this.visible=[],this.options.beforeFrame&&this.options.beforeFrame(t);let r=this.getCanvasDims();if(this.ctx.globalAlpha=1,this.ctx.fillStyle=this.canvas.dataset.background??"rgb(0, 0, 0)",this.ctx.fillRect(0,0,r.width,r.height),n.enableFilters&&(n.filters.brightness||n.filters.contrast||n.filters.grayscale||n.filters.invert||n.filters.sepia||n.filters.saturate||n.filters.hueRotate||n.filters.blur)){let a="";n.filters.brightness&&(a+=`brightness(${~~(100+n.filters.brightness*100)}%) `),n.filters.contrast&&(a+=`contrast(${~~(100+n.filters.contrast*100)}%) `),n.filters.grayscale&&(a+=`grayscale(${~~(n.filters.grayscale*100)}%) `),n.filters.invert&&(a+=`invert(${~~(n.filters.invert*100)}%) `),n.filters.sepia&&(a+=`sepia(${~~(n.filters.sepia*100)}%) `),n.filters.saturate&&(a+=`saturate(${~~(100+n.filters.saturate*100)}%) `),n.filters.hueRotate&&(a+=`hue-rotate(${n.filters.hueRotate}deg) `),n.filters.blur&&(a+=`blur(${n.filters.blur}px) `),this.ctx.filter=a}else this.ctx.filter="none"}applyTransform(e,t,i,n,r){let a=e.__owner.value;if(a&&a.rotation){this.ctx.save();let l=t+n/2,c=i+r/2;this.ctx.translate(l,c),this.ctx.rotate(a.rotation*Math.PI/180),this.ctx.translate(-l,-c),this.lastPaintedObject=a}}clearTransform(){this.lastPaintedObject&&(this.lastPaintedObject.rotation&&this.ctx.restore(),this.lastPaintedObject=void 0)}paint(e,t,i,n,r,a){let l=this.ctx.globalAlpha;if(e instanceof cr||e instanceof Xs){if(e.display.rotation){this.ctx.save();let m=i+r/2,h=n+a/2;e.crop&&(m-=e.crop[t*5+1],h-=e.crop[t*5+2]),this.ctx.translate(m,h),this.ctx.rotate(e.display.rotation*Math.PI/180),this.ctx.translate(-m,-h)}if(this.visible.push(e),typeof e.style&&e.style.opacity!=="undefined"){if(!e.style.opacity)return;this.ctx.globalAlpha=e.style.opacity}try{let m=e.__host.canvas,h=this.getCanvasDims();if((m.indices.indexOf(t)===-1||this.invalidated.indexOf(m.canvases[t])!==-1)&&this.schedulePaintToCanvas(m,e,t,vu({x:i+r/2,y:n+r/2},{x:h.width/2,y:h.height/2})),!this.firstMeaningfulPaint)return;let y=this.hostCache.get(m.canvases[t]);if(y)if(e.crop&&e.cropData){if(e.crop[t*5]){let S=[e.crop[t*5+1]/e.display.scale-e.display.points[t*5+1],e.crop[t*5+2]/e.display.scale-e.display.points[t*5+2],1+(e.crop[t*5+3]-e.crop[t*5+1])/e.display.scale,1+(e.crop[t*5+4]-e.crop[t*5+2])/e.display.scale];S[0]+=e.cropData.x/e.display.scale,S[1]+=e.cropData.y/e.display.scale;let w=e.x*this.lastKnownScale,v=e.y*this.lastKnownScale,x=[i+w,n+v,r,a];x[0]+=w,x[1]+=v,this.ctx.drawImage(y,S[0],S[1],S[2],S[3],x[0],x[1],x[2]+1,x[3]+1)}}else wP?this.ctx.drawImage(y,0,0,e.display.points[t*5+3]-e.display.points[t*5+1],e.display.points[t*5+4]-e.display.points[t*5+2],i,n,r+1,a+1):this.ctx.drawImage(y,0,0,e.display.points[t*5+3]-e.display.points[t*5+1],e.display.points[t*5+4]-e.display.points[t*5+2],i,n,r+Number.MIN_VALUE+.5,a+Number.MIN_VALUE+.5)}catch{}e.display.rotation&&this.ctx.restore()}let c=e instanceof Qs&&this.options.box,p=e instanceof Vx&&this.options.polygon;if((c||p)&&!e.props.className&&!e.props.html&&!e.props.href){if(this.visible.push(e),e.props.style){let m=Object.assign({},e.props.style||{},e.hovering?e.props.hoverStyles:{},e.pressing?e.props.pressStyles:{}),h=e.props.relativeStyle?1:r/e.width;typeof m.opacity<"u"&&(this.ctx.globalAlpha=m.opacity);let y=0;typeof m.borderWidth<"u"&&(y=parseInt(m.borderWidth,10)*h);let S=0;typeof m.outlineWidth<"u"&&(S=parseInt(m.outlineWidth,10)*h);let w=0;if(typeof m.outlineOffset<"u"&&(w=parseInt(m.outlineOffset,10)*h),m.borderColor&&(this.ctx.strokeStyle=m.borderColor),m.boxShadow){let v=m.boxShadow.split(/,(?![^(]*\))/);for(let x of v){let A=Tx[x]||Rx.exec(x)||Rx.exec(x);Tx[x]=A,A&&(this.ctx.save(),this.ctx.shadowOffsetX=parseInt(A[1])*this.dpi*h,this.ctx.shadowOffsetY=parseInt(A[3])*this.dpi*h,this.ctx.shadowBlur=parseInt(A[5])*this.dpi*h,this.ctx.shadowColor=A[9],this.ctx.fillStyle="rgba(0,0,0,1)",this.ctx.fillRect(i+y,n+y,r,a),this.ctx.restore())}}if(this.ctx.fillStyle=m.backgroundColor||"transparent",this.ctx.lineWidth=y,p){let v=e.shape,x=v.points||[],A=x.length;this.ctx.beginPath();for(let C=0;C<A;C++)this.ctx.lineTo(i+x[C][0]*this.lastKnownScale,n+x[C][1]*this.lastKnownScale);v.open||this.ctx.closePath(),y&&this.ctx.stroke(),v.open||this.ctx.fill()}else y&&this.ctx.strokeRect(i+y/2,n+y/2,r+y,a+y),this.ctx.fillRect(i+y,n+y,r,a);S&&(m.outlineColor&&(this.ctx.strokeStyle=m.outlineColor),this.ctx.lineWidth=S,this.ctx.strokeRect(i-S/2-w,n-S/2-w,r+y*2+S+w*2,a+y*2+S+w*2))}this.ctx.globalAlpha=l}}loadImage(e,t,i,n=!1){if(mu[e]&&mu[e].naturalWidth>0){t(mu[e]);return}try{let r=!1;n||setTimeout(()=>{r||this.loadImage(e,t,i,!0)},3e3);let a=document.createElement("img");a.decoding="auto",a.onload=function(){r=!0,t(a),mu[e]=a,a.onload=null},this.options.crossOrigin&&(a.crossOrigin="anonymous"),a.src=e,a.complete&&a.onload({}),a.width}catch(r){console.log("image error",r),i(r)}}schedulePaintToCanvas(e,t,i,n){this.imagesPending++,e.indices.push(i);let r=`${t.id}--${t.display.scale}-${i}`,a=this.invalidated.indexOf(r);a!==-1&&this.invalidated.splice(a,1),e.canvases[i]=r,t.__host.canvas.loading=!0,this.loadingQueueOrdered=!1,this.loadingQueue.push({id:r,scale:t.display.scale,network:!0,distance:n,task:()=>new Promise(l=>{if(this.visible.indexOf(t)===-1){this.imagesPending--,e.indices.splice(e.indices.indexOf(i),1),l();return}let c=t.getImageUrl(i);this.loadImage(c,p=>{this.loadingQueue.push({id:r,scale:t.display.scale,distance:n,task:()=>new Promise(m=>{this.imageIdsLoaded.includes(r)||(this.imagesLoaded++,this.imageIdsLoaded.push(r)),e.loaded.push(i),e.loaded.length===e.indices.length&&(e.loading=!1);let h=t.display.points.slice(i*5,i*5+5),y=document.createElement("canvas"),S=y.getContext("2d");y.width=h[3]-h[1],y.height=h[4]-h[2],this.hostCache.set(e.canvases[i],y),this.drawCalls.push(()=>{S.drawImage(p,0,0,h[3]-h[1],h[4]-h[2]),m()})})}),l()},p=>{this.imagesPending--,e.indices.splice(e.indices.indexOf(i),1),l()})})})}afterPaintLayer(e,t){}prepareLayer(e,t){if(e.__owner.value)if(e.cropData){let i=this.lastKnownScale*(1/e.display.scale);this.applyTransform(e,t[1],t[2],t[3]-t[1],t[4]-t[2])}else this.applyTransform(e,t[1],t[2],t[3]-t[1],t[4]-t[2]);(!e.__host||!e.__host.canvas)&&(e instanceof cr||e instanceof Xs)&&this.createImageHost(e)}finishLayer(){this.lastPaintedObject&&this.clearTransform()}createImageHost(e){e.__host=e.__host?e.__host:{},e.__host.canvas={canvas:void 0,canvases:[],indices:[],loaded:[],loading:!1}}getPointsAt(e,t,i,n){return e.getPointsAt(t,i,n)}getViewportBounds(e,t,i){let n=e.getActiveZone();if(n){let r=t[3]-t[1]<n.points[3]-n.points[1],a=t[4]-t[2]<n.points[4]-n.points[2];return{x1:r?n.points[1]-i:n.points[1]+(n.points[3]-n.points[1])/2-(t[3]-t[1])/2,y1:a?n.points[2]-i:n.points[2]+(n.points[4]-n.points[2])/2-(t[4]-t[2])/2,x2:r?n.points[3]+i:n.points[1]+(n.points[3]-n.points[1])/2-(t[3]-t[1])/2,y2:a?n.points[4]+i:n.points[2]+(n.points[4]-n.points[2])/2-(t[4]-t[2])/2}}return null}pendingUpdate(){let e=!this.pendingDrawCall&&this.drawCalls.length===0&&this.imagesPending===0&&this.loadingQueue.length===0&&this.tasksRunning===0;return!e&&this.visible.length===0&&setTimeout(()=>{this.canvas.style.opacity="1",this.firstMeaningfulPaint=!0},500),!this.firstMeaningfulPaint&&e&&this.visible.length?(this.canvas.style.opacity="1",this.firstMeaningfulPaint=e,!0):this.options.debug?!0:!e}getRendererScreenPosition(){return this.rendererPosition}reset(){this.loadingQueue=[],this.drawCalls=[]}},Ux=class{constructor(e){P(this,"renderers",[]),P(this,"length");for(let t of e)t&&this.renderers.push(t);this.length=this.renderers.length}afterFrame(e,t,i,n){for(let r=0;r<this.length;r++)this.renderers[r].afterFrame(e,t,i,n)}afterPaintLayer(e,t){for(let i=0;i<this.length;i++)this.renderers[i].afterPaintLayer(e,t)}beforeFrame(e,t,i,n){for(let r=0;r<this.length;r++)this.renderers[r].beforeFrame(e,t,i,n)}triggerResize(){for(let e=0;e<this.length;e++){let t=this.renderers[e];t.triggerResize&&t.triggerResize()}}getPointsAt(e,t,i,n){return this.renderers[0].getPointsAt(e,t,i,n)}getScale(e,t){return this.renderers[0].getScale(e,t)}getViewportBounds(e,t,i){return this.renderers[0].getViewportBounds(e,t,i)}getRendererScreenPosition(){return this.renderers[0].getRendererScreenPosition()}isReady(){for(let e=0;e<this.length;e++)if(!this.renderers[e].isReady())return!1;return!0}paint(e,t,i,n,r,a){for(let l=0;l<this.length;l++)this.renderers[l].paint(e,t,i,n,r,a)}pendingUpdate(){for(let e=0;e<this.length;e++)if(this.renderers[e].pendingUpdate())return!0;return!1}prepareLayer(e,t){for(let i=0;i<this.length;i++)this.renderers[i].prepareLayer(e,t)}finishLayer(e,t){for(let i=0;i<this.length;i++)this.renderers[i].finishLayer(e,t)}resize(e,t){for(let i=0;i<this.length;i++)this.renderers[i].resize(e,t)}reset(){for(let e=0;e<this.length;e++)this.renderers[e].reset()}},CP=class{constructor(e){P(this,"canvas"),P(this,"context"),P(this,"heightRatio",1),P(this,"widthRatio",1),P(this,"target",new Float32Array(5)),P(this,"initialWidth"),P(this,"initialHeight"),P(this,"bounds"),P(this,"aggregate"),P(this,"delta",0),P(this,"renderNextFrame",!0),this.canvas=e,this.initialWidth=e.width,this.initialHeight=e.height,this.context=e.getContext("2d"),this.context.globalAlpha=.5,this.aggregate=wi(1)}isReady(){return!0}resize(){this.initialWidth=this.canvas.width,this.initialHeight=this.canvas.height,this.renderNextFrame=!0}afterFrame(e,t,i){if(this.renderNextFrame){this.context.clearRect(0,0,this.canvas.width,this.canvas.height);let n=this.initialWidth/e.width,r=this.initialHeight/e.height,a=this.widthRatio>this.heightRatio?n:r;if(this.target=i,this.bounds){let l=e.getPointsAt(this.bounds,this.aggregate,a);for(let[c,p]of l)if(c instanceof cr&&c.__host.canvas){let m=p.length/5;for(let h=0;h<m;h++)if(c.__host.canvas.canvases[h]){let y={x1:p[h+1]*a,y1:p[h+2]*a,width:(p[h+3]-p[h+1])*a,height:(p[h+4]-p[h+2])*a}}}}e.getPoints().forEach((l,c,p)=>{if(c%5===0&&l){let m={x1:p[c+1]*a,y1:p[c+2]*a,x2:p[c+3]*a,y2:p[c+4]*a,width:(p[c+3]-p[c+1])*a,height:(p[c+4]-p[c+2])*a};this.context.strokeStyle="red",this.context.strokeRect(m.x1,m.y1,m.width,m.height)}}),i&&(this.context.strokeStyle="red",this.context.lineWidth=window.devicePixelRatio||1,this.context.strokeRect(i[1]*a,i[2]*a,(i[3]-i[1])*a,(i[4]-i[2])*a))}}getActiveZone(e){return null}getPointsAt(e,t,i,n){return e.getPointsAt(t,i,n)}getScale(e,t){return 1}beforeFrame(e,t){this.bounds=xe.singleBox(e.width,e.height)}drawImage(){}afterPaintLayer(e,t){}paint(e,t,i,n,r,a){this.renderNextFrame=!0}prepareLayer(e){}pendingUpdate(){return!1}hasActiveZone(){return!1}getViewportBounds(e,t,i){return null}getRendererScreenPosition(){return this.canvas.getBoundingClientRect()}finishLayer(){}reset(){}};function PP(e){return{x:e[1],y:e[2],width:e[3]-e[1],height:e[4]-e[2]}}var _x="pan",Mx="scroll",EP="gesture",AP={zoomOutFactor:.8,zoomInFactor:1.25,maxZoomFactor:1,minZoomFactor:.05,zoomDuration:300,zoomWheelConstant:20,zoomClamp:.6,panBounceStiffness:120,panBounceDamping:15,panTimeConstant:240,panPower:.1,nudgeDistance:100,panPadding:0,devicePixelRatio:1,enableWheel:!0,enableClickToZoom:!0,ignoreSingleFingerTouch:!1,enablePanOnWait:!1,requireMetaKeyForWheelZoom:!1,panOnWaitDelay:40,onPanInSketchMode:()=>{},parentElement:null},Hx=(e={})=>({start:function(t){let{zoomWheelConstant:i,enableWheel:n,enableClickToZoom:r,ignoreSingleFingerTouch:a,enablePanOnWait:l,panOnWaitDelay:c,parentElement:p,requireMetaKeyForWheelZoom:m}={...AP,...e},h={pointerStart:{x:0,y:0},isPressing:!1,mousemoveBuffer:re(5),multiTouch:{distance:0}};t.world.activatedEvents.push("onMouseUp","onMouseDown","onMouseMove","onTouchStart","onTouchEnd","onTouchMove");function y(){x=0,C="",E(),E(void 0,"notice"),A=0}function S(){t.world.constraintBounds(),y()}function w(U){if(U.which>1){h.isPressing=!1;return}t.mode==="explore"&&(U.preventDefault(),h.pointerStart.x=U.atlas.x,h.pointerStart.y=U.atlas.y,t.transitionManager.stopTransition(),h.isPressing=!0)}function v(){y(),h.isPressing&&(t.mode==="explore"&&t.world.constraintBounds(),h.isPressing=!1)}let x=0,A=0,C="";function I(U){if(t.mode==="explore"){if(U.atlasTouches.length===1&&(A=performance.now(),a==!1&&U.preventDefault(),h.pointerStart.x=U.atlasTouches[0].x,h.pointerStart.y=U.atlasTouches[0].y),U.atlasTouches.length===2){C=EP,U.preventDefault();let W=U.atlasTouches[0].x,ee=U.atlasTouches[1].x;h.pointerStart.x=(W+ee)/2;let Me=U.atlasTouches[0].y,pe=U.atlasTouches[1].y;h.pointerStart.y=(Me+pe)/2,x=vu({x:U.touches[0].clientX,y:U.touches[0].clientY},{x:U.touches[1].clientX,y:U.touches[1].clientY})}t.transitionManager.stopTransition(),h.isPressing=!0}}function E(U,W="intent"){p&&(p.dataset[W]=U)}function L(U){let W=null,ee=null,Me=!1,pe=0;if(h.isPressing&&U.touches.length===2){let Re=U.touches[0].clientX,ke=U.touches[1].clientX;W=(Re+ke)/2;let He=U.touches[0].clientY,qe=U.touches[1].clientY;ee=(He+qe)/2,pe=vu({x:U.touches[0].clientX,y:U.touches[0].clientY},{x:U.touches[1].clientX,y:U.touches[1].clientY}),Me=!0}if(E(C),h.isPressing&&U.touches.length===1){if(l&&(performance.now()-A<c&&C==""&&(C=Mx),C==""&&(C=_x)),E(C),C==""&&a==!0||C==Mx){E("require-two-finger","notice");return}let Re=U.touches[0];W=Re.clientX,ee=Re.clientY}if(W!==null&&ee!==null){let Re=t.getRendererScreenPosition();if(Re){let{x:ke,y:He}=t.viewerToWorld(W-Re.x,ee-Re.y),qe=pe&&x?pe/x:1;t.transitionManager.customTransition($=>{$.from=re(t.target),$.to=bi($.from,pi(ut(h.pointerStart.x-ke,h.pointerStart.y-He),On(1/qe,ke,He)),h.mousemoveBuffer),$.elapsed_time=0,$.total_time=0,$.timingFunction=ur.easeInOutExpo,$.done=!1})}x=pe}C==_x&&U.preventDefault()}function z(U){if(h.isPressing){let W=t.getRendererScreenPosition();if(W){let{x:ee,y:Me}=t.viewerToWorld(U.clientX-W.x,U.clientY-W.y);t.transitionManager.customTransition(pe=>{pe.from=re(t.target),pe.to=bi(pe.from,ut(h.pointerStart.x-ee,h.pointerStart.y-Me),h.mousemoveBuffer),pe.elapsed_time=0,pe.total_time=0,pe.timingFunction=ur.easeInOutExpo,pe.done=!1})}}}function M(U){t.mode==="explore"&&t.world.zoomIn(U.atlas)}function Q(U){let W=1+(0,Wx.default)(U).spinY/i;t.world.zoomTo(W,U.atlas,!0)}function V(U){return m&&U.metaKey==!1?(E("meta-required","notice"),U.stopPropagation(),!1):!0}t.world.addEventListener("mouseup",S),t.world.addEventListener("touchend",S),t.world.addEventListener("touchstart",I),t.world.addEventListener("mousedown",w),window.addEventListener("touchend",v),window.addEventListener("mouseup",v),window.addEventListener("mousemove",z),p&&p.addEventListener("touchmove",L),r&&(t.world.activatedEvents.push("onClick"),t.world.addEventListener("click",M)),n&&(t.world.activatedEvents.push("onWheel"),m&&p?.addEventListener("wheel",V,{passive:!0,capture:!0}),t.world.addEventListener("wheel",Q));let J=t.world.addLayoutSubscriber((U,W)=>{if(U==="zone-changed"&&t.transitionManager.constrainBounds({transition:{duration:0}}),U==="zoom-to"&&W&&t.transitionManager.zoomTo(W.factor,{origin:W.point,stream:W.stream}),U==="go-home"){let ee=W.immediate?{duration:0}:void 0;t.transitionManager.goToRegion(PP(t.homePosition),{transition:ee})}if(U==="goto-region"&&W){let ee=W.immediate?{duration:0}:{};t.transitionManager.goToRegion(W,{transition:ee})}U==="constrain-bounds"&&t.transitionManager.constrainBounds({transition:W?.immediate?{duration:0}:void 0})});return()=>{t.world.removeEventListener("mouseup",S),t.world.removeEventListener("touchend",S),t.world.removeEventListener("touchstart",I),t.world.removeEventListener("mousedown",w),window.removeEventListener("touchend",v),window.removeEventListener("mouseup",v),t.world.removeEventListener("mousemove",z),p&&(p.removeEventListener("touchmove",z),p.removeEventListener("wheel",V,{passive:!0,capture:!0})),r&&t.world.removeEventListener("click",M),n&&t.world.removeEventListener("wheel",Q),J()}},updatePosition(){}}),Fo=Au.default.createContext("explore");Fo.displayName="Mode";var RP=()=>(0,Au.useContext)(Fo);var Iu=Lp.default.createContext(null);Iu.displayName="Atlas";var Ru=Lp.default.createContext(null);Ru.displayName="Bounds";var Su,TP=typeof performance=="object"&&typeof performance.now=="function";if(TP){let e=performance;Su=()=>e.now()}else{let e=Date,t=e.now();Su=()=>e.now()-t}var _P=16;function kx(e,t){e&&e.appendChild&&t&&e.appendChild(t)}function $x(e,t){e&&e.removeChild&&t&&e.removeChild(t)}function MP(e,t){return $x(e.world,t)}function kP(e,t,i){return Gx(e.world,t,i)}function Gx(e,t,i){e&&e instanceof Eu&&(e=e.world),e&&e.insertBefore&&e.insertBefore(t,i)}function Yx(e,t,i){if(i&&(e.applyProps&&e.applyProps(i),e instanceof bn))for(let n of bu){let r=n.slice(2).toLowerCase();i[n]!==t[n]&&(t[n]&&e.removeEventListener(r,t[n]),e.addEventListener(r,i[n]))}}function Xx(e,t){let i=Object.keys(t),n=!1;for(let r of i)if(bu.indexOf(r)!==-1){let a=zo[r];if(a){if(e.activatedEvents.indexOf(a)!==-1)continue;n=!0,e.activatedEvents.push(a)}}n&&e.triggerEventActivation()}var wu=new Map,Ox={};function OP(e,{args:t=[],...i},n,r,a){if(!(n instanceof Eu)&&a){let p=m=>m.return?p(m.return):m.stateNode&&m.stateNode.containerInfo;n=p(a)}let l,c=n.world;switch(e){case"world":l=Pu.withProps({width:i.width,height:i.height,viewingDirection:"left-to-right"}),l.activatedEvents=c.activatedEvents,l.eventHandlers=c.eventHandlers,l.subscriptions=c.subscriptions,l.triggerEventActivation(),c=l;break;case"box":l=new Qs;break;case"shape":l=new Vx;break;case"worldObject":case"world-object":l=new Op;break;case"worldImage":case"world-image":l=new cr;break;case"texture":l=new Rp;break;case"compositeImage":case"composite-image":l=new yP({id:i.id,width:i.width,height:i.height,images:[],renderOptions:i.renderOptions});break;case"tiledImage":case"tiled-image":l=Xs.fromTile(i.uri,i.display,i.tile,i.scaleFactor,void 0,i.format);break;case"paragraph":l=new gu,l.text=i.children;break;default:return}return Xx(c,i),Yx(l,{},i),l}function LP(e,t){if(t instanceof Pu)e.world=t;else if(t instanceof Op)e.world.appendChild(t);else if(t)throw new Error("Invalid root")}var Gs=(0,qx.default)({unstable_now:Su,now:Su,createInstance:OP,removeChild:$x,appendChild:kx,appendInitialChild:kx,insertBefore:Gx,warnsIfNotActing:!0,supportsMutation:!0,isPrimaryRenderer:!1,scheduleTimeout:typeof setTimeout<"u"?setTimeout:void 0,cancelTimeout:typeof clearTimeout<"u"?clearTimeout:void 0,setTimeout:typeof setTimeout<"u"?setTimeout:void 0,clearTimeout:typeof clearTimeout<"u"?clearTimeout:void 0,noTimeout:-1,appendChildToContainer:LP,removeChildFromContainer:MP,createTextInstance(){},insertInContainerBefore:kP,prepareUpdate(e,t,i,n,r){return Xx(r.world,n),n},commitUpdate(e,t,i,n,r,a){e.applyProps&&t&&Yx(e,n,t)},finalizeInitialChildren(e){return e?.__handlers},getChildHostContext(){return Ox},getRootHostContext(){return Ox},prepareForCommit(e){return e.isCommitting=!0,null},preparePortalMount(){},hideInstance(e){e&&e.points&&(e.points[0]=0)},unhideInstance(e,t){e&&e.points&&(e.points[0]=1)},getPublicInstance(e){return e},hideTextInstance(){throw new Error("Text is not allowed in the react-three-fibre tree. You may have extraneous whitespace between components.")},resetAfterCommit(e){e.isCommitting=!1,e.pendingUpdate=!0,e.world&&e.world.needsRecalculate&&(e.world.recalculateWorldSize(),e.world.triggerRepaint())},shouldSetTextContent(){return!1},clearContainer(){return!1},supportsHydration:!1,supportsPersistence:!1,detachDeletedInstance(e){},afterActiveInstanceBlur(){},beforeActiveInstanceBlur(){},getCurrentEventPriority(){return console.log("getCurrentEventPriority"),_P},getInstanceFromNode(e){throw console.log("getInstanceFromNode",e),new Error("Not implemented")},getInstanceFromScope(e){throw console.log("getInstanceFromScope",e),new Error("Not implemented")},prepareScopeUpdate(e,t){throw console.log("prepareScopeUpdate",e,t),new Error("Not implemented")},logRecoverableError(){},requestPostPaintCallback(){}});Gs.injectIntoDevTools({bundleType:0,version:Qx.version,rendererPackageName:"@atlas-viewer/atlas"});function zp(e,t){let i=wu.get(e);i&&Gs.updateContainer(null,i,null,()=>{wu.delete(e),t&&t(e)})}var Lx={render(e,t){let i=wu.get(t);if(i)Gs.updateContainer(e,i,null);else{let n=Gs.createContainer(t,0,null,!1,null,"",()=>{},null);Gs.updateContainer(e,n,null),wu.set(t,n)}},unmountComponentAtNode(e,t){zp(e,t)}},Ys=typeof window<"u"&&(window.document?.createElement||window.navigator?.product==="ReactNative")?Tu.useLayoutEffect:Tu.useEffect,zP=wn.default.memo(({children:e,setIsReady:t,onCreated:i,bounds:n,preset:r,mode:a="explore"})=>{let l=(0,wn.useCallback)(function(c){let p=(0,wn.useRef)(!1),m=()=>{t(!0)};return(0,wn.useEffect)(()=>{if(r&&!p.current){r.runtime.goHome();let h=i&&i(r);return void(h&&h.then?h.then(m):m())}return()=>{}},[]),(0,wn.useEffect)(()=>{p.current=!0},[]),c.children},[r]);return Ys(()=>{if(r){let c=r.runtime;a!==c.mode&&(c.mode=a),Lx.render((0,Lo.jsx)(wn.default.StrictMode,{children:(0,Lo.jsx)(l,{children:(0,Lo.jsx)(Ru.Provider,{value:n,children:(0,Lo.jsx)(Fo.Provider,{value:a,children:(0,Lo.jsx)(Iu.Provider,{value:r,children:e})})})})}),c)}},[r,a,e]),Ys(()=>{if(r){let c=r.runtime;return()=>{Lx.unmountComponentAtNode(c)}}return()=>{}},[r]),null}),FP=class{constructor(e,t){P(this,"canvas"),P(this,"gl"),P(this,"program"),P(this,"fragmentShader"),P(this,"vertexShader"),P(this,"rectBuffer"),P(this,"fragmentShaderSource",`
|
|
11
|
+
`)+o.join(" > ")}return null},i.getPublicRootInstance=function(o){if(o=o.current,!o.child)return null;switch(o.child.tag){case 5:return ke(o.child.stateNode);default:return o.child.stateNode}},i.injectIntoDevTools=function(o){if(o={bundleType:o.bundleType,version:o.version,rendererPackageName:o.rendererPackageName,rendererConfig:o.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:c.ReactCurrentDispatcher,findHostInstanceByFiber:Mb,findFiberByHostInstance:o.findFiberByHostInstance||kb,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.2.0"},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")o=!1;else{var s=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(s.isDisabled||!s.supportsFiber)o=!0;else{try{Xa=s.inject(o),un=s}catch{}o=!!s.checkDCE}}return o},i.isAlreadyRendering=function(){return!1},i.observeVisibleRects=function(o,s,u,d){if(!Ti)throw Error(l(363));o=Kd(o,s);var f=Y(o,u,d).disconnect;return{disconnect:function(){f()}}},i.registerMutableSourceForHydration=function(o,s){var u=s._getVersion;u=u(s._source),o.mutableSourceEagerHydrationData==null?o.mutableSourceEagerHydrationData=[s,u]:o.mutableSourceEagerHydrationData.push(s,u)},i.runWithPriority=function(o,s){var u=Fe;try{return Fe=o,s()}finally{Fe=u}},i.shouldError=function(){return null},i.shouldSuspend=function(){return!1},i.updateContainer=function(o,s,u,d){var f=s.current,g=Gt(),b=tr(f);return u=Iy(u),s.context===null?s.context=u:s.pendingContext=u,s=Tn(g,b),s.payload={element:o},d=d===void 0?null:d,d!==null&&(s.callback=d),o=Zn(f,s,b),o!==null&&(Fi(o,f,b,g),rl(o,f,b)),b},i}});var Av=St((vT,Ev)=>{"use strict";Ev.exports=Pv()});var Ws=St((YT,Sx)=>{"use strict";Sx.exports=ReactDOM});var bx=St(Ap=>{"use strict";var wx=Ws();Ap.createRoot=wx.createRoot,Ap.hydrateRoot=wx.hydrateRoot;var XT});var SS=St(xS=>{"use strict";var Ko=q();function DA(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var jA=typeof Object.is=="function"?Object.is:DA,VA=Ko.useState,UA=Ko.useEffect,WA=Ko.useLayoutEffect,HA=Ko.useDebugValue;function qA(e,t){var i=t(),n=VA({inst:{value:i,getSnapshot:t}}),r=n[0].inst,a=n[1];return WA(function(){r.value=i,r.getSnapshot=t,Cf(r)&&a({inst:r})},[e,i,t]),UA(function(){return Cf(r)&&a({inst:r}),e(function(){Cf(r)&&a({inst:r})})},[e]),HA(i),i}function Cf(e){var t=e.getSnapshot;e=e.value;try{var i=t();return!jA(e,i)}catch{return!0}}function QA(e,t){return t()}var $A=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?QA:qA;xS.useSyncExternalStore=Ko.useSyncExternalStore!==void 0?Ko.useSyncExternalStore:$A});var bS=St((xk,wS)=>{"use strict";wS.exports=SS()});var PS=St(CS=>{"use strict";var ac=q(),GA=bS();function YA(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var XA=typeof Object.is=="function"?Object.is:YA,KA=GA.useSyncExternalStore,ZA=ac.useRef,JA=ac.useEffect,eI=ac.useMemo,tI=ac.useDebugValue;CS.useSyncExternalStoreWithSelector=function(e,t,i,n,r){var a=ZA(null);if(a.current===null){var l={hasValue:!1,value:null};a.current=l}else l=a.current;a=eI(function(){function p(w){if(!m){if(m=!0,h=w,w=n(w),r!==void 0&&l.hasValue){var v=l.value;if(r(v,w))return y=v}return y=w}if(v=y,XA(h,w))return v;var x=n(w);return r!==void 0&&r(v,x)?v:(h=w,y=x)}var m=!1,h,y,S=i===void 0?null:i;return[function(){return p(t())},S===null?void 0:function(){return p(S())}]},[t,i,n,r]);var c=KA(e,a[0],a[1]);return JA(function(){l.hasValue=!0,l.value=c},[c]),tI(c),c}});var AS=St((wk,ES)=>{"use strict";ES.exports=PS()});var i1=St((RD,t1)=>{"use strict";(()=>{var e={296:(r,a,l)=>{var c=/^\s+|\s+$/g,p=/^[-+]0x[0-9a-f]+$/i,m=/^0b[01]+$/i,h=/^0o[0-7]+$/i,y=parseInt,S=typeof l.g=="object"&&l.g&&l.g.Object===Object&&l.g,w=typeof self=="object"&&self&&self.Object===Object&&self,v=S||w||Function("return this")(),x=Object.prototype.toString,A=Math.max,C=Math.min,I=function(){return v.Date.now()};function E(z){var M=typeof z;return!!z&&(M=="object"||M=="function")}function L(z){if(typeof z=="number")return z;if(function(V){return typeof V=="symbol"||function(J){return!!J&&typeof J=="object"}(V)&&x.call(V)=="[object Symbol]"}(z))return NaN;if(E(z)){var M=typeof z.valueOf=="function"?z.valueOf():z;z=E(M)?M+"":M}if(typeof z!="string")return z===0?z:+z;z=z.replace(c,"");var Q=m.test(z);return Q||h.test(z)?y(z.slice(2),Q?2:8):p.test(z)?NaN:+z}r.exports=function(z,M,Q){var V,J,U,W,ee,Me,pe=0,Re=!1,ke=!1,He=!0;if(typeof z!="function")throw new TypeError("Expected a function");function qe($e){var N=V,G=J;return V=J=void 0,pe=$e,W=z.apply(G,N)}function $($e){var N=$e-Me;return Me===void 0||N>=M||N<0||ke&&$e-pe>=U}function ve(){var $e=I();if($($e))return it($e);ee=setTimeout(ve,function(N){var G=M-(N-Me);return ke?C(G,U-(N-pe)):G}($e))}function it($e){return ee=void 0,He&&V?qe($e):(V=J=void 0,W)}function Qe(){var $e=I(),N=$($e);if(V=arguments,J=this,Me=$e,N){if(ee===void 0)return function(G){return pe=G,ee=setTimeout(ve,M),Re?qe(G):W}(Me);if(ke)return ee=setTimeout(ve,M),qe(Me)}return ee===void 0&&(ee=setTimeout(ve,M)),W}return M=L(M)||0,E(Q)&&(Re=!!Q.leading,U=(ke="maxWait"in Q)?A(L(Q.maxWait)||0,M):U,He="trailing"in Q?!!Q.trailing:He),Qe.cancel=function(){ee!==void 0&&clearTimeout(ee),pe=0,V=Me=J=ee=void 0},Qe.flush=function(){return ee===void 0?W:it(I())},Qe}},96:(r,a,l)=>{var c="Expected a function",p=NaN,m="[object Symbol]",h=/^\s+|\s+$/g,y=/^[-+]0x[0-9a-f]+$/i,S=/^0b[01]+$/i,w=/^0o[0-7]+$/i,v=parseInt,x=typeof l.g=="object"&&l.g&&l.g.Object===Object&&l.g,A=typeof self=="object"&&self&&self.Object===Object&&self,C=x||A||Function("return this")(),I=Object.prototype.toString,E=Math.max,L=Math.min,z=function(){return C.Date.now()};function M(V){var J=typeof V;return!!V&&(J=="object"||J=="function")}function Q(V){if(typeof V=="number")return V;if(function(W){return typeof W=="symbol"||function(ee){return!!ee&&typeof ee=="object"}(W)&&I.call(W)==m}(V))return p;if(M(V)){var J=typeof V.valueOf=="function"?V.valueOf():V;V=M(J)?J+"":J}if(typeof V!="string")return V===0?V:+V;V=V.replace(h,"");var U=S.test(V);return U||w.test(V)?v(V.slice(2),U?2:8):y.test(V)?p:+V}r.exports=function(V,J,U){var W=!0,ee=!0;if(typeof V!="function")throw new TypeError(c);return M(U)&&(W="leading"in U?!!U.leading:W,ee="trailing"in U?!!U.trailing:ee),function(Me,pe,Re){var ke,He,qe,$,ve,it,Qe=0,$e=!1,N=!1,G=!0;if(typeof Me!="function")throw new TypeError(c);function de(Pe){var ne=ke,he=He;return ke=He=void 0,Qe=Pe,$=Me.apply(he,ne)}function ye(Pe){var ne=Pe-it;return it===void 0||ne>=pe||ne<0||N&&Pe-Qe>=qe}function ge(){var Pe=z();if(ye(Pe))return Ve(Pe);ve=setTimeout(ge,function(ne){var he=pe-(ne-it);return N?L(he,qe-(ne-Qe)):he}(Pe))}function Ve(Pe){return ve=void 0,G&&ke?de(Pe):(ke=He=void 0,$)}function ze(){var Pe=z(),ne=ye(Pe);if(ke=arguments,He=this,it=Pe,ne){if(ve===void 0)return function(he){return Qe=he,ve=setTimeout(ge,pe),$e?de(he):$}(it);if(N)return ve=setTimeout(ge,pe),de(it)}return ve===void 0&&(ve=setTimeout(ge,pe)),$}return pe=Q(pe)||0,M(Re)&&($e=!!Re.leading,qe=(N="maxWait"in Re)?E(Q(Re.maxWait)||0,pe):qe,G="trailing"in Re?!!Re.trailing:G),ze.cancel=function(){ve!==void 0&&clearTimeout(ve),Qe=0,ke=it=He=ve=void 0},ze.flush=function(){return ve===void 0?$:Ve(z())},ze}(V,J,{leading:W,maxWait:J,trailing:ee})}},703:(r,a,l)=>{"use strict";var c=l(414);function p(){}function m(){}m.resetWarningCache=p,r.exports=function(){function h(w,v,x,A,C,I){if(I!==c){var E=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw E.name="Invariant Violation",E}}function y(){return h}h.isRequired=h;var S={array:h,bigint:h,bool:h,func:h,number:h,object:h,string:h,symbol:h,any:h,arrayOf:y,element:h,elementType:h,instanceOf:y,node:h,objectOf:y,oneOf:y,oneOfType:y,shape:y,exact:y,checkPropTypes:m,resetWarningCache:p};return S.PropTypes=S,S}},697:(r,a,l)=>{r.exports=l(703)()},414:r=>{"use strict";r.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}},t={};function i(r){var a=t[r];if(a!==void 0)return a.exports;var l=t[r]={exports:{}};return e[r](l,l.exports,i),l.exports}i.n=r=>{var a=r&&r.__esModule?()=>r.default:()=>r;return i.d(a,{a}),a},i.d=(r,a)=>{for(var l in a)i.o(a,l)&&!i.o(r,l)&&Object.defineProperty(r,l,{enumerable:!0,get:a[l]})},i.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),i.o=(r,a)=>Object.prototype.hasOwnProperty.call(r,a),i.r=r=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})};var n={};(()=>{"use strict";i.r(n),i.d(n,{LazyLoadComponent:()=>Oe,LazyLoadImage:()=>Kc,trackWindowScroll:()=>it});let r=q();var a=i.n(r),l=i(697);let c=Ws();var p=i.n(c);function m(){return typeof window<"u"&&"IntersectionObserver"in window&&"isIntersecting"in window.IntersectionObserverEntry.prototype}function h(Y){return h=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(k){return typeof k}:function(k){return k&&typeof Symbol=="function"&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k},h(Y)}function y(Y,k){var X=Object.keys(Y);if(Object.getOwnPropertySymbols){var K=Object.getOwnPropertySymbols(Y);k&&(K=K.filter(function(be){return Object.getOwnPropertyDescriptor(Y,be).enumerable})),X.push.apply(X,K)}return X}function S(Y,k,X){return(k=v(k))in Y?Object.defineProperty(Y,k,{value:X,enumerable:!0,configurable:!0,writable:!0}):Y[k]=X,Y}function w(Y,k){for(var X=0;X<k.length;X++){var K=k[X];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(Y,v(K.key),K)}}function v(Y){var k=function(X,K){if(h(X)!=="object"||X===null)return X;var be=X[Symbol.toPrimitive];if(be!==void 0){var Ae=be.call(X,"string");if(h(Ae)!=="object")return Ae;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(X)}(Y);return h(k)==="symbol"?k:String(k)}function x(Y,k){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(X,K){return X.__proto__=K,X},x(Y,k)}function A(Y){return A=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(k){return k.__proto__||Object.getPrototypeOf(k)},A(Y)}var C=function(Y){Y.forEach(function(k){k.isIntersecting&&k.target.onVisible()})},I={},E=function(Y){(function(j,H){if(typeof H!="function"&&H!==null)throw new TypeError("Super expression must either be null or a function");j.prototype=Object.create(H&&H.prototype,{constructor:{value:j,writable:!0,configurable:!0}}),Object.defineProperty(j,"prototype",{writable:!1}),H&&x(j,H)})(je,Y);var k,X,K,be,Ae=(K=je,be=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}(),function(){var j,H=A(K);if(be){var ue=A(this).constructor;j=Reflect.construct(H,arguments,ue)}else j=H.apply(this,arguments);return function(oe,se){if(se&&(h(se)==="object"||typeof se=="function"))return se;if(se!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(Ie){if(Ie===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return Ie}(oe)}(this,j)});function je(j){var H;if(function(oe,se){if(!(oe instanceof se))throw new TypeError("Cannot call a class as a function")}(this,je),(H=Ae.call(this,j)).supportsObserver=!j.scrollPosition&&j.useIntersectionObserver&&m(),H.supportsObserver){var ue=j.threshold;H.observer=function(oe){return I[oe]=I[oe]||new IntersectionObserver(C,{rootMargin:oe+"px"}),I[oe]}(ue)}return H}return k=je,X=[{key:"componentDidMount",value:function(){this.placeholder&&this.observer&&(this.placeholder.onVisible=this.props.onVisible,this.observer.observe(this.placeholder)),this.supportsObserver||this.updateVisibility()}},{key:"componentWillUnmount",value:function(){this.observer&&this.placeholder&&this.observer.unobserve(this.placeholder)}},{key:"componentDidUpdate",value:function(){this.supportsObserver||this.updateVisibility()}},{key:"getPlaceholderBoundingBox",value:function(){var j=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.props.scrollPosition,H=this.placeholder.getBoundingClientRect(),ue=p().findDOMNode(this.placeholder).style,oe=parseInt(ue.getPropertyValue("margin-left"),10)||0,se=parseInt(ue.getPropertyValue("margin-top"),10)||0;return{bottom:j.y+H.bottom+se,left:j.x+H.left+oe,right:j.x+H.right+oe,top:j.y+H.top+se}}},{key:"isPlaceholderInViewport",value:function(){if(typeof window>"u"||!this.placeholder)return!1;var j=this.props,H=j.scrollPosition,ue=j.threshold,oe=this.getPlaceholderBoundingBox(H),se=H.y+window.innerHeight,Ie=H.x,Xe=H.x+window.innerWidth,Ke=H.y;return Ke-ue<=oe.bottom&&se+ue>=oe.top&&Ie-ue<=oe.right&&Xe+ue>=oe.left}},{key:"updateVisibility",value:function(){this.isPlaceholderInViewport()&&this.props.onVisible()}},{key:"render",value:function(){var j=this,H=this.props,ue=H.className,oe=H.height,se=H.placeholder,Ie=H.style,Xe=H.width;if(se&&typeof se.type!="function")return a().cloneElement(se,{ref:function(Ue){return j.placeholder=Ue}});var Ke=function(Ue){for(var Et=1;Et<arguments.length;Et++){var st=arguments[Et]!=null?arguments[Et]:{};Et%2?y(Object(st),!0).forEach(function(At){S(Ue,At,st[At])}):Object.getOwnPropertyDescriptors?Object.defineProperties(Ue,Object.getOwnPropertyDescriptors(st)):y(Object(st)).forEach(function(At){Object.defineProperty(Ue,At,Object.getOwnPropertyDescriptor(st,At))})}return Ue}({display:"inline-block"},Ie);return Xe!==void 0&&(Ke.width=Xe),oe!==void 0&&(Ke.height=oe),a().createElement("span",{className:ue,ref:function(Ue){return j.placeholder=Ue},style:Ke},se)}}],X&&w(k.prototype,X),Object.defineProperty(k,"prototype",{writable:!1}),je}(a().Component);E.propTypes={onVisible:l.PropTypes.func.isRequired,className:l.PropTypes.string,height:l.PropTypes.oneOfType([l.PropTypes.number,l.PropTypes.string]),placeholder:l.PropTypes.element,threshold:l.PropTypes.number,useIntersectionObserver:l.PropTypes.bool,scrollPosition:l.PropTypes.shape({x:l.PropTypes.number.isRequired,y:l.PropTypes.number.isRequired}),width:l.PropTypes.oneOfType([l.PropTypes.number,l.PropTypes.string])},E.defaultProps={className:"",placeholder:null,threshold:100,useIntersectionObserver:!0};let L=E;var z=i(296),M=i.n(z),Q=i(96),V=i.n(Q),J=function(Y){var k=getComputedStyle(Y,null);return k.getPropertyValue("overflow")+k.getPropertyValue("overflow-y")+k.getPropertyValue("overflow-x")};let U=function(Y){if(!(Y instanceof HTMLElement))return window;for(var k=Y;k&&k instanceof HTMLElement;){if(/(scroll|auto)/.test(J(k)))return k;k=k.parentNode}return window};function W(Y){return W=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(k){return typeof k}:function(k){return k&&typeof Symbol=="function"&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k},W(Y)}var ee=["delayMethod","delayTime"];function Me(){return Me=Object.assign?Object.assign.bind():function(Y){for(var k=1;k<arguments.length;k++){var X=arguments[k];for(var K in X)Object.prototype.hasOwnProperty.call(X,K)&&(Y[K]=X[K])}return Y},Me.apply(this,arguments)}function pe(Y,k){for(var X=0;X<k.length;X++){var K=k[X];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(Y,(be=function(Ae,je){if(W(Ae)!=="object"||Ae===null)return Ae;var j=Ae[Symbol.toPrimitive];if(j!==void 0){var H=j.call(Ae,"string");if(W(H)!=="object")return H;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(Ae)}(K.key),W(be)==="symbol"?be:String(be)),K)}var be}function Re(Y,k){return Re=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(X,K){return X.__proto__=K,X},Re(Y,k)}function ke(Y,k){if(k&&(W(k)==="object"||typeof k=="function"))return k;if(k!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return He(Y)}function He(Y){if(Y===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return Y}function qe(Y){return qe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(k){return k.__proto__||Object.getPrototypeOf(k)},qe(Y)}var $=function(){return typeof window>"u"?0:window.scrollX||window.pageXOffset},ve=function(){return typeof window>"u"?0:window.scrollY||window.pageYOffset};let it=function(Y){var k=function(X){(function(ue,oe){if(typeof oe!="function"&&oe!==null)throw new TypeError("Super expression must either be null or a function");ue.prototype=Object.create(oe&&oe.prototype,{constructor:{value:ue,writable:!0,configurable:!0}}),Object.defineProperty(ue,"prototype",{writable:!1}),oe&&Re(ue,oe)})(H,X);var K,be,Ae,je,j=(Ae=H,je=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}(),function(){var ue,oe=qe(Ae);if(je){var se=qe(this).constructor;ue=Reflect.construct(oe,arguments,se)}else ue=oe.apply(this,arguments);return ke(this,ue)});function H(ue){var oe;if(function(Ie,Xe){if(!(Ie instanceof Xe))throw new TypeError("Cannot call a class as a function")}(this,H),(oe=j.call(this,ue)).useIntersectionObserver=ue.useIntersectionObserver&&m(),oe.useIntersectionObserver)return ke(oe);var se=oe.onChangeScroll.bind(He(oe));return ue.delayMethod==="debounce"?oe.delayedScroll=M()(se,ue.delayTime):ue.delayMethod==="throttle"&&(oe.delayedScroll=V()(se,ue.delayTime)),oe.state={scrollPosition:{x:$(),y:ve()}},oe.baseComponentRef=a().createRef(),oe}return K=H,(be=[{key:"componentDidMount",value:function(){this.addListeners()}},{key:"componentWillUnmount",value:function(){this.removeListeners()}},{key:"componentDidUpdate",value:function(){typeof window>"u"||this.useIntersectionObserver||U(p().findDOMNode(this.baseComponentRef.current))!==this.scrollElement&&(this.removeListeners(),this.addListeners())}},{key:"addListeners",value:function(){typeof window>"u"||this.useIntersectionObserver||(this.scrollElement=U(p().findDOMNode(this.baseComponentRef.current)),this.scrollElement.addEventListener("scroll",this.delayedScroll,{passive:!0}),window.addEventListener("resize",this.delayedScroll,{passive:!0}),this.scrollElement!==window&&window.addEventListener("scroll",this.delayedScroll,{passive:!0}))}},{key:"removeListeners",value:function(){typeof window>"u"||this.useIntersectionObserver||(this.scrollElement.removeEventListener("scroll",this.delayedScroll),window.removeEventListener("resize",this.delayedScroll),this.scrollElement!==window&&window.removeEventListener("scroll",this.delayedScroll))}},{key:"onChangeScroll",value:function(){this.useIntersectionObserver||this.setState({scrollPosition:{x:$(),y:ve()}})}},{key:"render",value:function(){var ue=this.props,oe=(ue.delayMethod,ue.delayTime,function(Ie,Xe){if(Ie==null)return{};var Ke,Ue,Et=function(At,Gn){if(At==null)return{};var Qi,Ar,gs={},Wa=Object.keys(At);for(Ar=0;Ar<Wa.length;Ar++)Qi=Wa[Ar],Gn.indexOf(Qi)>=0||(gs[Qi]=At[Qi]);return gs}(Ie,Xe);if(Object.getOwnPropertySymbols){var st=Object.getOwnPropertySymbols(Ie);for(Ue=0;Ue<st.length;Ue++)Ke=st[Ue],Xe.indexOf(Ke)>=0||Object.prototype.propertyIsEnumerable.call(Ie,Ke)&&(Et[Ke]=Ie[Ke])}return Et}(ue,ee)),se=this.useIntersectionObserver?null:this.state.scrollPosition;return a().createElement(Y,Me({forwardRef:this.baseComponentRef,scrollPosition:se},oe))}}])&&pe(K.prototype,be),Object.defineProperty(K,"prototype",{writable:!1}),H}(a().Component);return k.propTypes={delayMethod:l.PropTypes.oneOf(["debounce","throttle"]),delayTime:l.PropTypes.number,useIntersectionObserver:l.PropTypes.bool},k.defaultProps={delayMethod:"throttle",delayTime:300,useIntersectionObserver:!0},k};function Qe(Y){return Qe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(k){return typeof k}:function(k){return k&&typeof Symbol=="function"&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k},Qe(Y)}function $e(Y,k){for(var X=0;X<k.length;X++){var K=k[X];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(Y,(be=function(Ae,je){if(Qe(Ae)!=="object"||Ae===null)return Ae;var j=Ae[Symbol.toPrimitive];if(j!==void 0){var H=j.call(Ae,"string");if(Qe(H)!=="object")return H;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(Ae)}(K.key),Qe(be)==="symbol"?be:String(be)),K)}var be}function N(Y,k){return N=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(X,K){return X.__proto__=K,X},N(Y,k)}function G(Y){return G=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(k){return k.__proto__||Object.getPrototypeOf(k)},G(Y)}var de=function(Y){(function(j,H){if(typeof H!="function"&&H!==null)throw new TypeError("Super expression must either be null or a function");j.prototype=Object.create(H&&H.prototype,{constructor:{value:j,writable:!0,configurable:!0}}),Object.defineProperty(j,"prototype",{writable:!1}),H&&N(j,H)})(je,Y);var k,X,K,be,Ae=(K=je,be=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}(),function(){var j,H=G(K);if(be){var ue=G(this).constructor;j=Reflect.construct(H,arguments,ue)}else j=H.apply(this,arguments);return function(oe,se){if(se&&(Qe(se)==="object"||typeof se=="function"))return se;if(se!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(Ie){if(Ie===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return Ie}(oe)}(this,j)});function je(j){return function(H,ue){if(!(H instanceof ue))throw new TypeError("Cannot call a class as a function")}(this,je),Ae.call(this,j)}return k=je,(X=[{key:"render",value:function(){return a().createElement(L,this.props)}}])&&$e(k.prototype,X),Object.defineProperty(k,"prototype",{writable:!1}),je}(a().Component);let ye=it(de);function ge(Y){return ge=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(k){return typeof k}:function(k){return k&&typeof Symbol=="function"&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k},ge(Y)}function Ve(Y,k){for(var X=0;X<k.length;X++){var K=k[X];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(Y,(be=function(Ae,je){if(ge(Ae)!=="object"||Ae===null)return Ae;var j=Ae[Symbol.toPrimitive];if(j!==void 0){var H=j.call(Ae,"string");if(ge(H)!=="object")return H;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(Ae)}(K.key),ge(be)==="symbol"?be:String(be)),K)}var be}function ze(Y,k){return ze=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(X,K){return X.__proto__=K,X},ze(Y,k)}function Pe(Y){if(Y===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return Y}function ne(Y){return ne=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(k){return k.__proto__||Object.getPrototypeOf(k)},ne(Y)}var he=function(Y){(function(j,H){if(typeof H!="function"&&H!==null)throw new TypeError("Super expression must either be null or a function");j.prototype=Object.create(H&&H.prototype,{constructor:{value:j,writable:!0,configurable:!0}}),Object.defineProperty(j,"prototype",{writable:!1}),H&&ze(j,H)})(je,Y);var k,X,K,be,Ae=(K=je,be=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}(),function(){var j,H=ne(K);if(be){var ue=ne(this).constructor;j=Reflect.construct(H,arguments,ue)}else j=H.apply(this,arguments);return function(oe,se){if(se&&(ge(se)==="object"||typeof se=="function"))return se;if(se!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Pe(oe)}(this,j)});function je(j){var H;(function(Xe,Ke){if(!(Xe instanceof Ke))throw new TypeError("Cannot call a class as a function")})(this,je),H=Ae.call(this,j);var ue=j.afterLoad,oe=j.beforeLoad,se=j.scrollPosition,Ie=j.visibleByDefault;return H.state={visible:Ie},Ie&&(oe(),ue()),H.onVisible=H.onVisible.bind(Pe(H)),H.isScrollTracked=!!(se&&Number.isFinite(se.x)&&se.x>=0&&Number.isFinite(se.y)&&se.y>=0),H}return k=je,(X=[{key:"componentDidUpdate",value:function(j,H){H.visible!==this.state.visible&&this.props.afterLoad()}},{key:"onVisible",value:function(){this.props.beforeLoad(),this.setState({visible:!0})}},{key:"render",value:function(){if(this.state.visible)return this.props.children;var j=this.props,H=j.className,ue=j.delayMethod,oe=j.delayTime,se=j.height,Ie=j.placeholder,Xe=j.scrollPosition,Ke=j.style,Ue=j.threshold,Et=j.useIntersectionObserver,st=j.width;return this.isScrollTracked||Et&&m()?a().createElement(L,{className:H,height:se,onVisible:this.onVisible,placeholder:Ie,scrollPosition:Xe,style:Ke,threshold:Ue,useIntersectionObserver:Et,width:st}):a().createElement(ye,{className:H,delayMethod:ue,delayTime:oe,height:se,onVisible:this.onVisible,placeholder:Ie,style:Ke,threshold:Ue,width:st})}}])&&Ve(k.prototype,X),Object.defineProperty(k,"prototype",{writable:!1}),je}(a().Component);he.propTypes={afterLoad:l.PropTypes.func,beforeLoad:l.PropTypes.func,useIntersectionObserver:l.PropTypes.bool,visibleByDefault:l.PropTypes.bool},he.defaultProps={afterLoad:function(){return{}},beforeLoad:function(){return{}},useIntersectionObserver:!0,visibleByDefault:!1};let Oe=he;function ot(Y){return ot=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(k){return typeof k}:function(k){return k&&typeof Symbol=="function"&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k},ot(Y)}var Ri=["afterLoad","beforeLoad","delayMethod","delayTime","effect","placeholder","placeholderSrc","scrollPosition","threshold","useIntersectionObserver","visibleByDefault","wrapperClassName","wrapperProps"];function Dt(Y,k){var X=Object.keys(Y);if(Object.getOwnPropertySymbols){var K=Object.getOwnPropertySymbols(Y);k&&(K=K.filter(function(be){return Object.getOwnPropertyDescriptor(Y,be).enumerable})),X.push.apply(X,K)}return X}function Wt(Y){for(var k=1;k<arguments.length;k++){var X=arguments[k]!=null?arguments[k]:{};k%2?Dt(Object(X),!0).forEach(function(K){ps(Y,K,X[K])}):Object.getOwnPropertyDescriptors?Object.defineProperties(Y,Object.getOwnPropertyDescriptors(X)):Dt(Object(X)).forEach(function(K){Object.defineProperty(Y,K,Object.getOwnPropertyDescriptor(X,K))})}return Y}function ps(Y,k,X){return(k=Ua(k))in Y?Object.defineProperty(Y,k,{value:X,enumerable:!0,configurable:!0,writable:!0}):Y[k]=X,Y}function Ti(){return Ti=Object.assign?Object.assign.bind():function(Y){for(var k=1;k<arguments.length;k++){var X=arguments[k];for(var K in X)Object.prototype.hasOwnProperty.call(X,K)&&(Y[K]=X[K])}return Y},Ti.apply(this,arguments)}function Xc(Y,k){for(var X=0;X<k.length;X++){var K=k[X];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(Y,Ua(K.key),K)}}function Ua(Y){var k=function(X,K){if(ot(X)!=="object"||X===null)return X;var be=X[Symbol.toPrimitive];if(be!==void 0){var Ae=be.call(X,"string");if(ot(Ae)!=="object")return Ae;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(X)}(Y);return ot(k)==="symbol"?k:String(k)}function fs(Y,k){return fs=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(X,K){return X.__proto__=K,X},fs(Y,k)}function ln(Y){return ln=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(k){return k.__proto__||Object.getPrototypeOf(k)},ln(Y)}var ms=function(Y){(function(j,H){if(typeof H!="function"&&H!==null)throw new TypeError("Super expression must either be null or a function");j.prototype=Object.create(H&&H.prototype,{constructor:{value:j,writable:!0,configurable:!0}}),Object.defineProperty(j,"prototype",{writable:!1}),H&&fs(j,H)})(je,Y);var k,X,K,be,Ae=(K=je,be=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}(),function(){var j,H=ln(K);if(be){var ue=ln(this).constructor;j=Reflect.construct(H,arguments,ue)}else j=H.apply(this,arguments);return function(oe,se){if(se&&(ot(se)==="object"||typeof se=="function"))return se;if(se!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(Ie){if(Ie===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return Ie}(oe)}(this,j)});function je(j){var H;return function(ue,oe){if(!(ue instanceof oe))throw new TypeError("Cannot call a class as a function")}(this,je),(H=Ae.call(this,j)).state={loaded:!1},H}return k=je,(X=[{key:"onImageLoad",value:function(){var j=this;return this.state.loaded?null:function(H){j.props.onLoad(H),j.props.afterLoad(),j.setState({loaded:!0})}}},{key:"getImg",value:function(){var j=this.props,H=(j.afterLoad,j.beforeLoad,j.delayMethod,j.delayTime,j.effect,j.placeholder,j.placeholderSrc,j.scrollPosition,j.threshold,j.useIntersectionObserver,j.visibleByDefault,j.wrapperClassName,j.wrapperProps,function(ue,oe){if(ue==null)return{};var se,Ie,Xe=function(Ue,Et){if(Ue==null)return{};var st,At,Gn={},Qi=Object.keys(Ue);for(At=0;At<Qi.length;At++)st=Qi[At],Et.indexOf(st)>=0||(Gn[st]=Ue[st]);return Gn}(ue,oe);if(Object.getOwnPropertySymbols){var Ke=Object.getOwnPropertySymbols(ue);for(Ie=0;Ie<Ke.length;Ie++)se=Ke[Ie],oe.indexOf(se)>=0||Object.prototype.propertyIsEnumerable.call(ue,se)&&(Xe[se]=ue[se])}return Xe}(j,Ri));return a().createElement("img",Ti({},H,{onLoad:this.onImageLoad()}))}},{key:"getLazyLoadImage",value:function(){var j=this.props,H=j.beforeLoad,ue=j.className,oe=j.delayMethod,se=j.delayTime,Ie=j.height,Xe=j.placeholder,Ke=j.scrollPosition,Ue=j.style,Et=j.threshold,st=j.useIntersectionObserver,At=j.visibleByDefault,Gn=j.width;return a().createElement(Oe,{beforeLoad:H,className:ue,delayMethod:oe,delayTime:se,height:Ie,placeholder:Xe,scrollPosition:Ke,style:Ue,threshold:Et,useIntersectionObserver:st,visibleByDefault:At,width:Gn},this.getImg())}},{key:"getWrappedLazyLoadImage",value:function(j){var H=this.props,ue=H.effect,oe=H.height,se=H.placeholderSrc,Ie=H.width,Xe=H.wrapperClassName,Ke=H.wrapperProps,Ue=this.state.loaded,Et=Ue?" lazy-load-image-loaded":"",st=Ue||!se?{}:{backgroundImage:"url(".concat(se,")"),backgroundSize:"100% 100%"};return a().createElement("span",Ti({className:Xe+" lazy-load-image-background "+ue+Et,style:Wt(Wt({},st),{},{color:"transparent",display:"inline-block",height:oe,width:Ie})},Ke),j)}},{key:"render",value:function(){var j=this.props,H=j.effect,ue=j.placeholderSrc,oe=j.visibleByDefault,se=j.wrapperClassName,Ie=j.wrapperProps,Xe=this.getLazyLoadImage();return(H||ue)&&!oe||se||Ie?this.getWrappedLazyLoadImage(Xe):Xe}}])&&Xc(k.prototype,X),Object.defineProperty(k,"prototype",{writable:!1}),je}(a().Component);ms.propTypes={onLoad:l.PropTypes.func,afterLoad:l.PropTypes.func,beforeLoad:l.PropTypes.func,delayMethod:l.PropTypes.string,delayTime:l.PropTypes.number,effect:l.PropTypes.string,placeholderSrc:l.PropTypes.string,threshold:l.PropTypes.number,useIntersectionObserver:l.PropTypes.bool,visibleByDefault:l.PropTypes.bool,wrapperClassName:l.PropTypes.string,wrapperProps:l.PropTypes.object},ms.defaultProps={onLoad:function(){},afterLoad:function(){return{}},beforeLoad:function(){return{}},delayMethod:"throttle",delayTime:300,effect:"",placeholderSrc:null,threshold:100,useIntersectionObserver:!0,visibleByDefault:!1,wrapperClassName:""};let Kc=ms})(),t1.exports=n})()});var ZR={};Db(ZR,{AnnotationContext:()=>jR,AnnotationPageContext:()=>VR,AnnotationStyleProvider:()=>uR,Auth:()=>kf,AuthProvider:()=>_f,AuthRContext:()=>to,AuthReactContext:()=>OS,AuthReactContextActions:()=>LS,CanvasAnnotations:()=>KI,CanvasContext:()=>Vi,CanvasPanel:()=>Bt,CanvasStrategyProvider:()=>cm,CanvasWorldObject:()=>dm,CollectionContext:()=>UR,CombinedMetadata:()=>ZI,ComplexTimelineProvider:()=>gm,ContextBridge:()=>Bf,ControlsReactContext:()=>_a,CreateCustomShape:()=>Hm,CustomContextBridge:()=>qS,CustomContextBridgeProvider:()=>pI,EventsProvider:()=>hI,Image:()=>Jw,ImageService:()=>BR,ImageServiceLoaderContext:()=>jw,InnerViewerProvider:()=>jS,LanguageProvider:()=>VI,LanguageString:()=>Mw,LocaleString:()=>Ii,ManifestContext:()=>xf,ManifestMetadata:()=>eR,MediaPlayerProvider:()=>Oa,Metadata:()=>Da,PolygonSelector:()=>NR,RangeContext:()=>Sf,ReactEventContext:()=>io,ReactVaultContext:()=>mr,Render3DModelStrategy:()=>bm,RenderAccompanyingCanvas:()=>Im,RenderAnnotationStrategy:()=>Cm,RenderAudioStrategy:()=>Am,RenderComplexTimelineStrategy:()=>ym,RenderEmptyStrategy:()=>hm,RenderImageStrategy:()=>Sm,RenderSvgEditorControls:()=>oR,RenderTextualContentStrategy:()=>vm,RenderVideoStrategy:()=>Tm,RenderYouTubeStrategy:()=>_m,ResourceProvider:()=>ei,ResourceReactContext:()=>Js,SelectorControllerProvider:()=>sR,SequenceThumbnails:()=>nR,SimpleViewerProvider:()=>Lf,SimpleViewerReactContext:()=>ts,SingleCanvasThumbnail:()=>Om,StrategyReactContext:()=>Ta,ThumbnailFallbackImage:()=>ho,TranslationProvider:()=>jI,TransliterationProvider:()=>UI,VaultProvider:()=>Kr,ViewerPresetContext:()=>Ui,VirtualAnnotationProvider:()=>Uf,VisibleCanvasReactContext:()=>Jr,authDetailsForResource:()=>If,createAuthStateStore:()=>Ef,createProbe:()=>Af,defaultEmitter:()=>US,emptyActions:()=>Jf,emptyStrategy:()=>em,expandTarget:()=>Nt,findAllCanvasesInRange:()=>oc,findFirstCanvasFromRange:()=>mS,findManifestSelectedRange:()=>NA,findSelectedRange:()=>wf,flattenAnnotationPageIds:()=>tm,formatTime:()=>Pc,get3dStrategy:()=>rm,getComplexTimelineStrategy:()=>om,getDefaultAnnotationStyles:()=>Fm,getImageStrategy:()=>Aa,getManifestSequence:()=>sc,getParsedTargetSelector:()=>wa,getRenderingStrategy:()=>am,getTextualContentStrategy:()=>Ia,getVideoStrategy:()=>Ra,getVisibleCanvasesFromCanvasId:()=>BA,hasAuth:()=>oI,isImageApiSelector:()=>mc,makeAccessServiceRequest:()=>Pf,makeAccessTokenRequest:()=>lc,parseRotation:()=>gc,parseSelector:()=>Wn,parseSpecificResource:()=>kI,svgThemes:()=>v1,unknownResponse:()=>ba,unsupportedStrategy:()=>et,useAnnotation:()=>xa,useAnnotationPage:()=>Gf,useAnnotationPageManager:()=>Pa,useAnnotationStyles:()=>Bm,useAnnotationsAtTime:()=>WR,useAuthActions:()=>zS,useAuthService:()=>FS,useAuthStore:()=>Jo,useAuthToken:()=>aI,useAuthTokens:()=>Rf,useCanvas:()=>Ce,useCanvasChoices:()=>HR,useCanvasClock:()=>qR,useCanvasSequence:()=>bf,useCanvasStartTime:()=>La,useCanvasSubset:()=>QR,useClosestLanguage:()=>Ow,useCollection:()=>$R,useComplexTimeline:()=>qI,useContextBridge:()=>Nf,useCreateLocaleString:()=>WI,useCurrentAuth:()=>sI,useCustomContextBridge:()=>Ff,useDispatch:()=>Df,useEventEmitter:()=>pa,useEventListener:()=>GR,useExistingVault:()=>Zr,useExternalCollection:()=>YR,useExternalManifest:()=>vf,useExternalResource:()=>aa,useIIIFLanguage:()=>Ec,useImage:()=>Bc,useImageService:()=>Qm,useImageServiceLoader:()=>ka,useImageTile:()=>XR,useIsAuthEnabled:()=>Mf,useLoadImageService:()=>Ea,useLocaleString:()=>Lw,useManifest:()=>vt,useMediaActions:()=>$I,useMediaElements:()=>GI,useMediaState:()=>QI,usePaintables:()=>nm,usePaintingAnnotations:()=>oo,usePolygonHelper:()=>Um,useRange:()=>la,useRenderControls:()=>ni,useRenderingStrategy:()=>lm,useResourceContext:()=>Xt,useResourceEvents:()=>ga,useResources:()=>im,useSearchService:()=>Of,useSelectorController:()=>zm,useSelectorEmitter:()=>aR,useSelectorEvents:()=>Lm,useSelectorHelper:()=>lR,useSimpleMediaPlayer:()=>ao,useSimpleViewer:()=>ha,useStrategy:()=>pt,useStyleHelper:()=>KR,useStyles:()=>ro,useSvgEditor:()=>Wm,useThumbnail:()=>Qn,useTranslations:()=>fm,useTransliteration:()=>pm,useVault:()=>_e,useVaultEffect:()=>xm,useVaultSelector:()=>De,useViewerPreset:()=>fa,useVirtualAnnotationPage:()=>jf,useVirtualAnnotationPageContext:()=>Vf,useVisibleCanvases:()=>eo});var Na=R(q(),1);var ii=R(q(),1);var or=(e,t,i)=>{let n=e.length,r=i||re(n);for(let a=0;a<n;a++)r[a]=a%5===0?e[a+1]<t[3]&&e[a+3]>t[1]&&e[a+2]<t[4]&&e[a+4]>t[2]?1:0:e[a];return r};function re(e,t,i){return new Float32Array(e,t,i)}var ky=(e,t,i)=>{let n=e[1]<=t[3]&&e[3]>=t[1]&&e[2]<=t[4]&&e[4]>=t[2],r=i||re(5);return n?(r[0]=1,r[1]=Math.max(e[1],t[1]),r[2]=Math.max(e[2],t[2]),r[3]=Math.min(e[3],t[3]),r[4]=Math.min(e[4],t[4]),r):(r[0]=0,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r)},Oy=e=>e.length/5;var pi=(e,t,i)=>{let n=i||re(9);return n[0]=e[0]*t[0]+e[1]*t[3]+e[2]*t[6],n[1]=e[0]*t[1]+e[1]*t[4]+e[2]*t[7],n[2]=e[0]*t[2]+e[1]*t[5]+e[2]*t[8],n[3]=e[3]*t[0]+e[4]*t[3]+e[5]*t[6],n[4]=e[3]*t[1]+e[4]*t[4]+e[5]*t[7],n[5]=e[3]*t[2]+e[4]*t[5]+e[5]*t[8],n[6]=e[6]*t[0]+e[7]*t[3]+e[8]*t[6],n[7]=e[6]*t[1]+e[7]*t[4]+e[8]*t[7],n[8]=e[6]*t[2]+e[7]*t[5]+e[8]*t[8],n},xe=class e{constructor(t){this.index=0,this.length=t,this.points=re(this.length)}static grid(t=1,i=1){return new e(5*t*i)}static point(t,i){let n=re(5);return n[0]=1,n[1]=t,n[2]=i,n[3]=t,n[4]=i,n}static positionPair(t){let i=re(5);return i[0]=1,i[1]=t.x1,i[2]=t.y1,i[3]=t.x2,i[4]=t.y2,i}static projection(t){return e.singleBox(t.width,t.height,t.x,t.y)}static singleBox(t,i,n=0,r=0){let a=re(5);return a[0]=1,a[1]=n,a[2]=r,a[3]=t+n,a[4]=i+r,a}row(t){return t(this)}addPoints(t,i,n,r){return this.points[this.index]=1,this.points[1+this.index]=t,this.points[2+this.index]=i,this.points[3+this.index]=n,this.points[4+this.index]=r,this.index+=5,this}addBox(t,i,n,r){return this.addPoints(t,i,t+n,i+r),this}build(){return this.points}};var Zt=(e,t)=>{let i=e.length;for(let n=0;n<i;n++)e[n]=n%5===0?t[6]*e[n+1]+t[7]*e[n+2]+t[8]*e[n]:n%5%2===1?t[0]*e[n]+t[1]*e[n+1]+t[2]:t[3]*e[n-1]+t[4]*e[n]+t[5];return e},wi=e=>{let t=re(9);return t[0]=e,t[4]=e,t[8]=1,t},ut=(e,t)=>{let i=re(9);return i[0]=1,i[2]=e,i[4]=1,i[5]=t,i[8]=1,i},On=(e,t,i)=>pi(ut((1-e)*t,(1-e)*i),wi(e)),bi=(e,t,i)=>{let n=e.length,r=i&&i.length>=n?i.slice(0,n):re(n);for(let a=0;a<n;a++)r[a]=a%5===0?t[6]*e[a+1]+t[7]*e[a+2]+t[8]*e[a]:a%5%2===1?t[0]*e[a]+t[1]*e[a+1]+t[2]:t[3]*e[a-1]+t[4]*e[a]+t[5];return r};var Fs=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Vb=typeof AbortController=="function",Nl=Vb?AbortController:class{constructor(){this.signal=new Ly}abort(t=new Error("This operation was aborted")){this.signal.reason=this.signal.reason||t,this.signal.aborted=!0,this.signal.dispatchEvent({type:"abort",target:this.signal})}},Ub=typeof AbortSignal=="function",Wb=typeof Nl.AbortSignal=="function",Ly=Ub?AbortSignal:Wb?Nl.AbortController:class{constructor(){this.reason=void 0,this.aborted=!1,this._listeners=[]}dispatchEvent(t){t.type==="abort"&&(this.aborted=!0,this.onabort(t),this._listeners.forEach(i=>i(t),this))}onabort(){}addEventListener(t,i){t==="abort"&&this._listeners.push(i)}removeEventListener(t,i){t==="abort"&&(this._listeners=this._listeners.filter(n=>n!==i))}},fh=new Set,dh=(e,t)=>{let i=`LRU_CACHE_OPTION_${e}`;Bl(i)&&mh(i,`${e} option`,`options.${t}`,_o)},hh=(e,t)=>{let i=`LRU_CACHE_METHOD_${e}`;if(Bl(i)){let{prototype:n}=_o,{get:r}=Object.getOwnPropertyDescriptor(n,e);mh(i,`${e} method`,`cache.${t}()`,r)}},Hb=(e,t)=>{let i=`LRU_CACHE_PROPERTY_${e}`;if(Bl(i)){let{prototype:n}=_o,{get:r}=Object.getOwnPropertyDescriptor(n,e);mh(i,`${e} property`,`cache.${t}`,r)}},zy=(...e)=>{typeof process=="object"&&process&&typeof process.emitWarning=="function"?process.emitWarning(...e):console.error(...e)},Bl=e=>!fh.has(e),mh=(e,t,i,n)=>{fh.add(e);let r=`The ${t} is deprecated. Please use ${i} instead.`;zy(r,"DeprecationWarning",e,n)},sr=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),Fy=e=>sr(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?To:null:null,To=class extends Array{constructor(t){super(t),this.fill(0)}},ph=class{constructor(t){if(t===0)return[];let i=Fy(t);this.heap=new i(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}},_o=class e{constructor(t={}){let{max:i=0,ttl:n,ttlResolution:r=1,ttlAutopurge:a,updateAgeOnGet:l,updateAgeOnHas:c,allowStale:p,dispose:m,disposeAfter:h,noDisposeOnSet:y,noUpdateTTL:S,maxSize:w=0,maxEntrySize:v=0,sizeCalculation:x,fetchMethod:A,fetchContext:C,noDeleteOnFetchRejection:I,noDeleteOnStaleGet:E,allowStaleOnFetchRejection:L,allowStaleOnFetchAbort:z,ignoreFetchAbort:M}=t,{length:Q,maxAge:V,stale:J}=t instanceof e?{}:t;if(i!==0&&!sr(i))throw new TypeError("max option must be a nonnegative integer");let U=i?Fy(i):Array;if(!U)throw new Error("invalid max value: "+i);if(this.max=i,this.maxSize=w,this.maxEntrySize=v||this.maxSize,this.sizeCalculation=x||Q,this.sizeCalculation){if(!this.maxSize&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(this.fetchMethod=A||null,this.fetchMethod&&typeof this.fetchMethod!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.fetchContext=C,!this.fetchMethod&&C!==void 0)throw new TypeError("cannot set fetchContext without fetchMethod");if(this.keyMap=new Map,this.keyList=new Array(i).fill(null),this.valList=new Array(i).fill(null),this.next=new U(i),this.prev=new U(i),this.head=0,this.tail=0,this.free=new ph(i),this.initialFill=1,this.size=0,typeof m=="function"&&(this.dispose=m),typeof h=="function"?(this.disposeAfter=h,this.disposed=[]):(this.disposeAfter=null,this.disposed=null),this.noDisposeOnSet=!!y,this.noUpdateTTL=!!S,this.noDeleteOnFetchRejection=!!I,this.allowStaleOnFetchRejection=!!L,this.allowStaleOnFetchAbort=!!z,this.ignoreFetchAbort=!!M,this.maxEntrySize!==0){if(this.maxSize!==0&&!sr(this.maxSize))throw new TypeError("maxSize must be a positive integer if specified");if(!sr(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.initializeSizeTracking()}if(this.allowStale=!!p||!!J,this.noDeleteOnStaleGet=!!E,this.updateAgeOnGet=!!l,this.updateAgeOnHas=!!c,this.ttlResolution=sr(r)||r===0?r:1,this.ttlAutopurge=!!a,this.ttl=n||V||0,this.ttl){if(!sr(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.initializeTTLTracking()}if(this.max===0&&this.ttl===0&&this.maxSize===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.max&&!this.maxSize){let W="LRU_CACHE_UNBOUNDED";Bl(W)&&(fh.add(W),zy("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",W,e))}J&&dh("stale","allowStale"),V&&dh("maxAge","ttl"),Q&&dh("length","sizeCalculation")}getRemainingTTL(t){return this.has(t,{updateAgeOnHas:!1})?1/0:0}initializeTTLTracking(){this.ttls=new To(this.max),this.starts=new To(this.max),this.setItemTTL=(n,r,a=Fs.now())=>{if(this.starts[n]=r!==0?a:0,this.ttls[n]=r,r!==0&&this.ttlAutopurge){let l=setTimeout(()=>{this.isStale(n)&&this.delete(this.keyList[n])},r+1);l.unref&&l.unref()}},this.updateItemAge=n=>{this.starts[n]=this.ttls[n]!==0?Fs.now():0},this.statusTTL=(n,r)=>{n&&(n.ttl=this.ttls[r],n.start=this.starts[r],n.now=t||i(),n.remainingTTL=n.now+n.ttl-n.start)};let t=0,i=()=>{let n=Fs.now();if(this.ttlResolution>0){t=n;let r=setTimeout(()=>t=0,this.ttlResolution);r.unref&&r.unref()}return n};this.getRemainingTTL=n=>{let r=this.keyMap.get(n);return r===void 0?0:this.ttls[r]===0||this.starts[r]===0?1/0:this.starts[r]+this.ttls[r]-(t||i())},this.isStale=n=>this.ttls[n]!==0&&this.starts[n]!==0&&(t||i())-this.starts[n]>this.ttls[n]}updateItemAge(t){}statusTTL(t,i){}setItemTTL(t,i,n){}isStale(t){return!1}initializeSizeTracking(){this.calculatedSize=0,this.sizes=new To(this.max),this.removeItemSize=t=>{this.calculatedSize-=this.sizes[t],this.sizes[t]=0},this.requireSize=(t,i,n,r)=>{if(this.isBackgroundFetch(i))return 0;if(!sr(n))if(r){if(typeof r!="function")throw new TypeError("sizeCalculation must be a function");if(n=r(i,t),!sr(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return n},this.addItemSize=(t,i,n)=>{if(this.sizes[t]=i,this.maxSize){let r=this.maxSize-this.sizes[t];for(;this.calculatedSize>r;)this.evict(!0)}this.calculatedSize+=this.sizes[t],n&&(n.entrySize=i,n.totalCalculatedSize=this.calculatedSize)}}removeItemSize(t){}addItemSize(t,i){}requireSize(t,i,n,r){if(n||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache")}*indexes({allowStale:t=this.allowStale}={}){if(this.size)for(let i=this.tail;!(!this.isValidIndex(i)||((t||!this.isStale(i))&&(yield i),i===this.head));)i=this.prev[i]}*rindexes({allowStale:t=this.allowStale}={}){if(this.size)for(let i=this.head;!(!this.isValidIndex(i)||((t||!this.isStale(i))&&(yield i),i===this.tail));)i=this.next[i]}isValidIndex(t){return t!==void 0&&this.keyMap.get(this.keyList[t])===t}*entries(){for(let t of this.indexes())this.valList[t]!==void 0&&this.keyList[t]!==void 0&&!this.isBackgroundFetch(this.valList[t])&&(yield[this.keyList[t],this.valList[t]])}*rentries(){for(let t of this.rindexes())this.valList[t]!==void 0&&this.keyList[t]!==void 0&&!this.isBackgroundFetch(this.valList[t])&&(yield[this.keyList[t],this.valList[t]])}*keys(){for(let t of this.indexes())this.keyList[t]!==void 0&&!this.isBackgroundFetch(this.valList[t])&&(yield this.keyList[t])}*rkeys(){for(let t of this.rindexes())this.keyList[t]!==void 0&&!this.isBackgroundFetch(this.valList[t])&&(yield this.keyList[t])}*values(){for(let t of this.indexes())this.valList[t]!==void 0&&!this.isBackgroundFetch(this.valList[t])&&(yield this.valList[t])}*rvalues(){for(let t of this.rindexes())this.valList[t]!==void 0&&!this.isBackgroundFetch(this.valList[t])&&(yield this.valList[t])}[Symbol.iterator](){return this.entries()}find(t,i){for(let n of this.indexes()){let r=this.valList[n],a=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;if(a!==void 0&&t(a,this.keyList[n],this))return this.get(this.keyList[n],i)}}forEach(t,i=this){for(let n of this.indexes()){let r=this.valList[n],a=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;a!==void 0&&t.call(i,a,this.keyList[n],this)}}rforEach(t,i=this){for(let n of this.rindexes()){let r=this.valList[n],a=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;a!==void 0&&t.call(i,a,this.keyList[n],this)}}get prune(){return hh("prune","purgeStale"),this.purgeStale}purgeStale(){let t=!1;for(let i of this.rindexes({allowStale:!0}))this.isStale(i)&&(this.delete(this.keyList[i]),t=!0);return t}dump(){let t=[];for(let i of this.indexes({allowStale:!0})){let n=this.keyList[i],r=this.valList[i],a=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;if(a===void 0)continue;let l={value:a};if(this.ttls){l.ttl=this.ttls[i];let c=Fs.now()-this.starts[i];l.start=Math.floor(Date.now()-c)}this.sizes&&(l.size=this.sizes[i]),t.unshift([n,l])}return t}load(t){this.clear();for(let[i,n]of t){if(n.start){let r=Date.now()-n.start;n.start=Fs.now()-r}this.set(i,n.value,n)}}dispose(t,i,n){}set(t,i,{ttl:n=this.ttl,start:r,noDisposeOnSet:a=this.noDisposeOnSet,size:l=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:p=this.noUpdateTTL,status:m}={}){if(l=this.requireSize(t,i,l,c),this.maxEntrySize&&l>this.maxEntrySize)return m&&(m.set="miss",m.maxEntrySizeExceeded=!0),this.delete(t),this;let h=this.size===0?void 0:this.keyMap.get(t);if(h===void 0)h=this.newIndex(),this.keyList[h]=t,this.valList[h]=i,this.keyMap.set(t,h),this.next[this.tail]=h,this.prev[h]=this.tail,this.tail=h,this.size++,this.addItemSize(h,l,m),m&&(m.set="add"),p=!1;else{this.moveToTail(h);let y=this.valList[h];if(i!==y){if(this.isBackgroundFetch(y)?y.__abortController.abort(new Error("replaced")):a||(this.dispose(y,t,"set"),this.disposeAfter&&this.disposed.push([y,t,"set"])),this.removeItemSize(h),this.valList[h]=i,this.addItemSize(h,l,m),m){m.set="replace";let S=y&&this.isBackgroundFetch(y)?y.__staleWhileFetching:y;S!==void 0&&(m.oldValue=S)}}else m&&(m.set="update")}if(n!==0&&this.ttl===0&&!this.ttls&&this.initializeTTLTracking(),p||this.setItemTTL(h,n,r),this.statusTTL(m,h),this.disposeAfter)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift());return this}newIndex(){return this.size===0?this.tail:this.size===this.max&&this.max!==0?this.evict(!1):this.free.length!==0?this.free.pop():this.initialFill++}pop(){if(this.size){let t=this.valList[this.head];return this.evict(!0),t}}evict(t){let i=this.head,n=this.keyList[i],r=this.valList[i];return this.isBackgroundFetch(r)?r.__abortController.abort(new Error("evicted")):(this.dispose(r,n,"evict"),this.disposeAfter&&this.disposed.push([r,n,"evict"])),this.removeItemSize(i),t&&(this.keyList[i]=null,this.valList[i]=null,this.free.push(i)),this.head=this.next[i],this.keyMap.delete(n),this.size--,i}has(t,{updateAgeOnHas:i=this.updateAgeOnHas,status:n}={}){let r=this.keyMap.get(t);if(r!==void 0)if(this.isStale(r))n&&(n.has="stale",this.statusTTL(n,r));else return i&&this.updateItemAge(r),n&&(n.has="hit"),this.statusTTL(n,r),!0;else n&&(n.has="miss");return!1}peek(t,{allowStale:i=this.allowStale}={}){let n=this.keyMap.get(t);if(n!==void 0&&(i||!this.isStale(n))){let r=this.valList[n];return this.isBackgroundFetch(r)?r.__staleWhileFetching:r}}backgroundFetch(t,i,n,r){let a=i===void 0?void 0:this.valList[i];if(this.isBackgroundFetch(a))return a;let l=new Nl;n.signal&&n.signal.addEventListener("abort",()=>l.abort(n.signal.reason));let c={signal:l.signal,options:n,context:r},p=(w,v=!1)=>{let{aborted:x}=l.signal,A=n.ignoreFetchAbort&&w!==void 0;return n.status&&(x&&!v?(n.status.fetchAborted=!0,n.status.fetchError=l.signal.reason,A&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),x&&!A&&!v?h(l.signal.reason):(this.valList[i]===S&&(w===void 0?S.__staleWhileFetching?this.valList[i]=S.__staleWhileFetching:this.delete(t):(n.status&&(n.status.fetchUpdated=!0),this.set(t,w,c.options))),w)},m=w=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=w),h(w)),h=w=>{let{aborted:v}=l.signal,x=v&&n.allowStaleOnFetchAbort,A=x||n.allowStaleOnFetchRejection,C=A||n.noDeleteOnFetchRejection;if(this.valList[i]===S&&(!C||S.__staleWhileFetching===void 0?this.delete(t):x||(this.valList[i]=S.__staleWhileFetching)),A)return n.status&&S.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),S.__staleWhileFetching;if(S.__returned===S)throw w},y=(w,v)=>{this.fetchMethod(t,a,c).then(x=>w(x),v),l.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(w(),n.allowStaleOnFetchAbort&&(w=x=>p(x,!0)))})};n.status&&(n.status.fetchDispatched=!0);let S=new Promise(y).then(p,m);return S.__abortController=l,S.__staleWhileFetching=a,S.__returned=null,i===void 0?(this.set(t,S,{...c.options,status:void 0}),i=this.keyMap.get(t)):this.valList[i]=S,S}isBackgroundFetch(t){return t&&typeof t=="object"&&typeof t.then=="function"&&Object.prototype.hasOwnProperty.call(t,"__staleWhileFetching")&&Object.prototype.hasOwnProperty.call(t,"__returned")&&(t.__returned===t||t.__returned===null)}async fetch(t,{allowStale:i=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:c=0,sizeCalculation:p=this.sizeCalculation,noUpdateTTL:m=this.noUpdateTTL,noDeleteOnFetchRejection:h=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:y=this.allowStaleOnFetchRejection,ignoreFetchAbort:S=this.ignoreFetchAbort,allowStaleOnFetchAbort:w=this.allowStaleOnFetchAbort,fetchContext:v=this.fetchContext,forceRefresh:x=!1,status:A,signal:C}={}){if(!this.fetchMethod)return A&&(A.fetch="get"),this.get(t,{allowStale:i,updateAgeOnGet:n,noDeleteOnStaleGet:r,status:A});let I={allowStale:i,updateAgeOnGet:n,noDeleteOnStaleGet:r,ttl:a,noDisposeOnSet:l,size:c,sizeCalculation:p,noUpdateTTL:m,noDeleteOnFetchRejection:h,allowStaleOnFetchRejection:y,allowStaleOnFetchAbort:w,ignoreFetchAbort:S,status:A,signal:C},E=this.keyMap.get(t);if(E===void 0){A&&(A.fetch="miss");let L=this.backgroundFetch(t,E,I,v);return L.__returned=L}else{let L=this.valList[E];if(this.isBackgroundFetch(L)){let J=i&&L.__staleWhileFetching!==void 0;return A&&(A.fetch="inflight",J&&(A.returnedStale=!0)),J?L.__staleWhileFetching:L.__returned=L}let z=this.isStale(E);if(!x&&!z)return A&&(A.fetch="hit"),this.moveToTail(E),n&&this.updateItemAge(E),this.statusTTL(A,E),L;let M=this.backgroundFetch(t,E,I,v),Q=M.__staleWhileFetching!==void 0,V=Q&&i;return A&&(A.fetch=Q&&z?"stale":"refresh",V&&z&&(A.returnedStale=!0)),V?M.__staleWhileFetching:M.__returned=M}}get(t,{allowStale:i=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:a}={}){let l=this.keyMap.get(t);if(l!==void 0){let c=this.valList[l],p=this.isBackgroundFetch(c);return this.statusTTL(a,l),this.isStale(l)?(a&&(a.get="stale"),p?(a&&(a.returnedStale=i&&c.__staleWhileFetching!==void 0),i?c.__staleWhileFetching:void 0):(r||this.delete(t),a&&(a.returnedStale=i),i?c:void 0)):(a&&(a.get="hit"),p?c.__staleWhileFetching:(this.moveToTail(l),n&&this.updateItemAge(l),c))}else a&&(a.get="miss")}connect(t,i){this.prev[i]=t,this.next[t]=i}moveToTail(t){t!==this.tail&&(t===this.head?this.head=this.next[t]:this.connect(this.prev[t],this.next[t]),this.connect(this.tail,t),this.tail=t)}get del(){return hh("del","delete"),this.delete}delete(t){let i=!1;if(this.size!==0){let n=this.keyMap.get(t);if(n!==void 0)if(i=!0,this.size===1)this.clear();else{this.removeItemSize(n);let r=this.valList[n];this.isBackgroundFetch(r)?r.__abortController.abort(new Error("deleted")):(this.dispose(r,t,"delete"),this.disposeAfter&&this.disposed.push([r,t,"delete"])),this.keyMap.delete(t),this.keyList[n]=null,this.valList[n]=null,n===this.tail?this.tail=this.prev[n]:n===this.head?this.head=this.next[n]:(this.next[this.prev[n]]=this.next[n],this.prev[this.next[n]]=this.prev[n]),this.size--,this.free.push(n)}}if(this.disposed)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift());return i}clear(){for(let t of this.rindexes({allowStale:!0})){let i=this.valList[t];if(this.isBackgroundFetch(i))i.__abortController.abort(new Error("deleted"));else{let n=this.keyList[t];this.dispose(i,n,"delete"),this.disposeAfter&&this.disposed.push([i,n,"delete"])}}if(this.keyMap.clear(),this.valList.fill(null),this.keyList.fill(null),this.ttls&&(this.ttls.fill(0),this.starts.fill(0)),this.sizes&&this.sizes.fill(0),this.head=0,this.tail=0,this.initialFill=1,this.free.length=0,this.calculatedSize=0,this.size=0,this.disposed)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift())}get reset(){return hh("reset","clear"),this.clear}get length(){return Hb("length","size"),this.size}static get AbortController(){return Nl}static get AbortSignal(){return Ly}},Ny=_o;var Wx=R(rv(),1);var dt=R(q(),1),Au=R(q(),1),IP=R(B(),1);var Ci=R(q()),Eh=R(uv());function Hl(e){let{debounce:t,scroll:i,polyfill:n,offsetSize:r}=e===void 0?{debounce:0,scroll:!1,offsetSize:!1}:e,a=n||(typeof window>"u"?class{}:window.ResizeObserver);if(!a)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");let[l,c]=(0,Ci.useState)({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),p=(0,Ci.useRef)({element:null,scrollContainers:null,resizeObserver:null,lastBounds:l}),m=t?typeof t=="number"?t:t.scroll:null,h=t?typeof t=="number"?t:t.resize:null,y=(0,Ci.useRef)(!1);(0,Ci.useEffect)(()=>(y.current=!0,()=>void(y.current=!1)));let[S,w,v]=(0,Ci.useMemo)(()=>{let I=()=>{if(!p.current.element)return;let{left:E,top:L,width:z,height:M,bottom:Q,right:V,x:J,y:U}=p.current.element.getBoundingClientRect(),W={left:E,top:L,width:z,height:M,bottom:Q,right:V,x:J,y:U};p.current.element instanceof HTMLElement&&r&&(W.height=p.current.element.offsetHeight,W.width=p.current.element.offsetWidth),Object.freeze(W),y.current&&!rC(p.current.lastBounds,W)&&c(p.current.lastBounds=W)};return[I,h?(0,Eh.default)(I,h):I,m?(0,Eh.default)(I,m):I]},[c,r,m,h]);function x(){p.current.scrollContainers&&(p.current.scrollContainers.forEach(I=>I.removeEventListener("scroll",v,!0)),p.current.scrollContainers=null),p.current.resizeObserver&&(p.current.resizeObserver.disconnect(),p.current.resizeObserver=null)}function A(){p.current.element&&(p.current.resizeObserver=new a(v),p.current.resizeObserver.observe(p.current.element),i&&p.current.scrollContainers&&p.current.scrollContainers.forEach(I=>I.addEventListener("scroll",v,{capture:!0,passive:!0})))}let C=I=>{!I||I===p.current.element||(x(),p.current.element=I,p.current.scrollContainers=cv(I),A())};return iC(v,!!i),tC(w),(0,Ci.useEffect)(()=>{x(),A()},[i,v,w]),(0,Ci.useEffect)(()=>x,[]),[C,l,S]}function tC(e){(0,Ci.useEffect)(()=>{let t=e;return window.addEventListener("resize",t),()=>void window.removeEventListener("resize",t)},[e])}function iC(e,t){(0,Ci.useEffect)(()=>{if(t){let i=e;return window.addEventListener("scroll",i,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",i,!0)}},[e,t])}function cv(e){let t=[];if(!e||e===document.body)return t;let{overflow:i,overflowX:n,overflowY:r}=window.getComputedStyle(e);return[i,n,r].some(a=>a==="auto"||a==="scroll")&&t.push(e),[...t,...cv(e.parentElement)]}var nC=["x","y","top","bottom","left","right","width","height"],rC=(e,t)=>nC.every(i=>e[i]===t[i]);var Lp=R(q(),1),wn=R(q(),1),qx=R(Av(),1),Qx=R(q(),1),Tu=R(q(),1),Lo=R(B(),1),Di=R(q(),1),i0=R(q(),1),n0=R(q(),1),r0=R(B(),1),Jt=R(B(),1),_u=R(q(),1);var Ks=R(B(),1),Fp=R(q(),1),s0=R(q(),1),qP=R(q(),1),a0=R(q(),1),u0=R(q(),1),Sn=R(q(),1),c0=R(q(),1),_p=R(B(),1),d0=R(q(),1),xn=R(q(),1),_t=R(q(),1),h0=R(q(),1),Lu=R(q(),1),wt=R(B(),1),Mp=R(B(),1),kp=R(q(),1),Vr=R(B(),1),f0=R(q(),1);var sC=Object.defineProperty,aC=(e,t,i)=>t in e?sC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Xl=(e,t,i)=>(aC(e,typeof t!="symbol"?t+"":t,i),i);function Dr(e){return e.endsWith("info.json")?e:e.endsWith("/")?`${e}info.json`:`${e}/info.json`}var lC="http://library.stanford.edu/iiif/image-api/compliance.html#level0",_v="http://library.stanford.edu/iiif/image-api/compliance.html#level1",Mv="http://library.stanford.edu/iiif/image-api/compliance.html#level2",uC="http://library.stanford.edu/iiif/image-api/conformance.html#level0",kv="http://library.stanford.edu/iiif/image-api/conformance.html#level1",Ov="http://library.stanford.edu/iiif/image-api/conformance.html#level2",cC="http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0",Lv="http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level1",zv="http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2",dC="http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level0",Fv="http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level1",Nv="http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level2",hC="http://iiif.io/api/image/1/level0.json",pC="http://iiif.io/api/image/1/profiles/level0.json",Bv="http://iiif.io/api/image/1/level1.json",Dv="http://iiif.io/api/image/1/profiles/level1.json",jv="http://iiif.io/api/image/1/level2.json",Vv="http://iiif.io/api/image/1/profiles/level2.json",fC="http://iiif.io/api/image/2/level0.json",mC="http://iiif.io/api/image/2/profiles/level0.json",Uv="http://iiif.io/api/image/2/level1.json",Wv="http://iiif.io/api/image/2/profiles/level1.json",Hv="http://iiif.io/api/image/2/level2.json",qv="http://iiif.io/api/image/2/profiles/level2.json",gC="level0",Qv="level1",$v="level2",yC="http://iiif.io/api/image/2/level0",Gv="http://iiif.io/api/image/2/level1",Yv="http://iiif.io/api/image/2/level2",Xv=[Yv,Mv,Ov,zv,Nv,jv,Vv,Hv,qv,$v],Kv=[...Xv,Gv,_v,kv,Lv,Fv,Bv,Dv,Uv,Wv,Qv],vC=[yC,Gv,Yv,lC,_v,Mv,uC,kv,Ov,cC,Lv,zv,dC,Fv,Nv,hC,pC,Bv,Dv,jv,Vv,fC,mC,Uv,Wv,Hv,qv,gC,Qv,$v];var xC={extraFormats:["jpg"],extraQualities:["default"],extraFeatures:["sizeByWhListed"]},SC={extraFormats:["jpg"],extraQualities:["default"],extraFeatures:["baseUriRedirect","cors","jsonldMediaType","regionByPx","regionSquare","sizeByWhListed","sizeByH","sizeByW","sizeByWh"]},wC={extraFormats:["jpg","png"],extraQualities:["default"],extraFeatures:["baseUriRedirect","cors","jsonldMediaType","regionByPct","regionByPx","regionSquare","rotationBy90s","sizeByWhListed","sizeByConfinedWh","sizeByH","sizeByPct","sizeByW","sizeByWh"]};function bC(e){return Xv.indexOf(e)!==-1?wC:Kv.indexOf(e)!==-1?SC:xC}function CC(e){let t=e?Array.isArray(e.profile)?e.profile:[e.profile]:[],i={extraQualities:[],extraFormats:[],extraFeatures:[]};for(let n of t)if(typeof n=="string"&&(n=bC(n)),!!n){if(n.formats)for(let r of n.formats)i.extraFormats.indexOf(r)===-1&&i.extraFormats.push(r);if(n.qualities)for(let r of n.qualities)i.extraQualities.indexOf(r)===-1&&i.extraQualities.push(r);if(n.supports)for(let r of n.supports)i.extraFeatures.indexOf(r)===-1&&i.extraFeatures.push(r);if(n.maxHeight&&(i.maxHeight=n.maxHeight),n.maxWidth&&(i.maxWidth=n.maxWidth),n.maxArea&&(i.maxArea=n.maxArea),n.extraFormats)for(let r of n.extraFormats)i.extraFormats.indexOf(r)===-1&&i.extraFormats.push(r);if(n.extraQualities)for(let r of n.extraQualities)i.extraQualities.indexOf(r)===-1&&i.extraQualities.push(r);if(n.extraFeatures)for(let r of n.extraFeatures)i.extraFeatures.indexOf(r)===-1&&i.extraFeatures.push(r);n.maxHeight&&(i.maxHeight=n.maxHeight),n.maxWidth&&(i.maxWidth=n.maxWidth),n.maxArea&&(i.maxArea=n.maxArea)}if(e.extraFormats)for(let n of e.extraFormats)i.extraFormats.indexOf(n)===-1&&i.extraFormats.push(n);if(e.extraFeatures)for(let n of e.extraFeatures)i.extraFeatures.indexOf(n)===-1&&i.extraFeatures.push(n);if(e.extraQualities)for(let n of e.extraQualities)i.extraQualities.indexOf(n)===-1&&i.extraQualities.push(n);return i}function PC(e){try{if(e==="full")return{full:!0};if(e==="square")return{square:!0};let t=e.startsWith("pct:"),i=e.substr(t?4:0).split(",").map(n=>parseFloat(n));return{x:i[0],y:i[1],w:i[2],h:i[3],percent:t}}catch{throw new Error("Expected 'full', 'square' or 'x,y,w,h'. Found "+e)}}function EC(e){let t={upscaled:!1,max:!1,confined:!1};if(e[0]==="^"&&(t.upscaled=!0,e=e.slice(1)),e==="max"||e==="full")return t.max=!0,t.serialiseAsFull=e==="full",t;if(e[0]==="!"&&(t.confined=!0,e=e.slice(1)),e[0]==="p")return t.percentScale=parseFloat(e.slice(4)),t;let i=e.split(",").map(n=>n.trim());return i.length&&typeof i[0]<"u"&&(i[0]!==""&&(t.width=parseInt(i[0],10)),typeof i[1]<"u"&&i[1]!==""?(t.height=parseInt(i[1],10),t.version=2):t.version=3),t}function AC(e){let t={angle:0};if(e[0]==="!"&&(t.mirror=!0,e=e.substr(1)),t.angle=parseFloat(e)%360,Number.isNaN(t.angle))throw new Error(`Invalid rotation ${e}`);return t}function IC(e,t=""){let i=e.match(/^(([a-zA-Z]+):\/\/([^/]+))?((.*)+)/);if(!i)throw new Error(`Invalid or unknown input ${e}`);let n=i[2],r=i[3],a=i[4];if(a[0]==="/"&&(a=a.substring(1)),t.length>0){if(t[0]==="/"&&(t=t.substring(1)),t!==a.substring(0,t.length))throw new Error(`Path does not start with prefix (path: ${a}, prefix: ${t})`);a=a.substring(t.length)}return{scheme:n,server:r,path:a,prefix:t}}function RC(e,t=""){let{path:i,scheme:n,server:r,prefix:a}=IC(e,t),l=(i||"").split("/").reverse(),[c,p,m,h,...y]=l,S=y.reverse().filter(Boolean).join("/");if(l.length===1||c==="")return{type:"base",scheme:n,server:r,prefix:a,identifier:S};if(c==="info.json"){let[,...v]=l;return{type:"info",scheme:n,server:r,prefix:a,identifier:v.reverse().filter(Boolean).join("/")}}let w=(c||"").split(".");if(typeof w[1]>"u"||typeof w[0]>"u"||typeof h>"u"||typeof m>"u"||typeof p>"u")throw new Error("Invalid image request");return{type:"image",scheme:n,server:r,prefix:a,identifier:S,originalPath:i,region:PC(h),size:EC(m),rotation:AC(p),quality:w[0],format:w[1]}}function TC(e){let t=RC(Dr(e.id));if(t.type!=="info")throw new Error("Invalid service URL");let i=CC(e);return{identifier:t.identifier,originalPath:"",server:t.server,prefix:t.prefix,scheme:t.scheme,type:"image",quality:i.extraQualities.indexOf("default")===-1?i.extraQualities[0]:"default",region:{full:!0},size:{max:!0,upscaled:!1,confined:!1},format:"jpg",rotation:{angle:0}}}function _C(e,t,i){let n=i.length,r=[];for(let a=0;a<n;a++){let l=i[a];if(l){let c=l.width;r.push(e/c)}}return r}function MC(e,t,i){let n=i.length,r=[];for(let a=0;a<n;a++){let l=i[a];l&&r.push({width:Math.floor(e/l),height:Math.floor(t/l)})}return r}function ft(e){if(e["@id"])return e["@id"];if(e.id)return e.id}function Zl(e){if(!e||!e.profile||!ft(e))return!1;let t=Array.isArray(e.profile)?e.profile:[e.profile];for(let i of t)if(typeof i=="string"&&vC.indexOf(i)!==-1)return!0;return!1}function kC(e){if(!Zl(e))return!1;let t=Array.isArray(e.profile)?e.profile:[e.profile];for(let i of t)if(typeof i=="string"){if(Kv.indexOf(i)!==-1)return!0}else{let n=[...i.supports||[],...i.extraFeatures||[]];if(n.indexOf("regionByPx")!==-1&&(n.indexOf("sizeByW")!==-1||n.indexOf("sizeByWh")!==-1))return!0}return!1}function Kl(e,t){if(t&&t.profile){let i=t.profile;if(i){let n=Array.isArray(i)?i:[i];return n.includes(`level${e}`)||n.includes(`http://iiif.io/api/image/2/level${e}.json`)||n.includes(`http://iiif.io/api/image/1/level${e}.json`)||n.includes(`http://iiif.io/api/image/1/profiles/level${e}.json`)}}return!1}function Fh(e){return Zl(e)?Kl(0,e)?0:Kl(1,e)?1:Kl(2,e)?2:null:null}function Zv(e){return(e["@context"]?Array.isArray(e["@context"])?e["@context"]:[e["@context"]]:[]).indexOf("http://iiif.io/api/image/3/context.json")!==-1}function OC(e){if(!kC(e))return[];let t=[],i=Array.isArray(e.profile)?e.profile:[e.profile],n=i.length;for(let r=0;r<n;r++){let a=i[r];if(a&&typeof a!="string"&&(a.maxHeight||a.maxWidth))return[{id:ft(e),type:"variable",minWidth:0,minHeight:0,maxHeight:a.maxHeight||a.maxWidth,maxWidth:a.maxWidth||a.maxHeight,level:Fh(e),version:e["@context"]==="http://iiif.io/api/image/3/context.json"?3:2}]}if(e.tiles){let r=e.tiles.length;for(let a=0;a<r;a++){let l=e.tiles[a];l&&(l.height||l.width)&&t.push({id:ft(e),type:"variable",minHeight:0,minWidth:0,maxHeight:l.height||l.width,maxWidth:l.width,level:Fh(e),version:Zv(e)?3:2})}}return t}function Iv(e){let t=/^.*\/(full)\/(((\d+),(\d+)?)|max)\/(\d+)\/default\.(jpg|png|jpeg)$/,i=e.match(t);if(i&&i[4]&&i[5]){let n=i[1],r=parseInt(i[4],10),a=parseInt(i[5],10),l=i[7];if((n==="max"||n==="full")&&r&&a&&l)return{type:"fixed",id:e,height:a,width:r}}return{type:"unknown",id:e}}function LC(e){if(e["@type"])return e["@type"];if(e.type)return e.type}function zC(e){if(typeof e=="string")return Iv(e);let t=LC(e);if(t!=="Image"&&t!=="sc:Image")return null;let i=e,n=ft(i);return n?n&&i.width&&i.height?{id:n,type:"fixed",width:i.width,height:i.height,unsafe:!0}:Iv(n):null}function FC(e){return Zl(e)?(e&&e.sizes?e.sizes:[]).map(t=>({id:ft(e),type:"fixed-service",height:t.height,width:t.width,level:Fh(e),version:Zv(e)?3:2})):[]}function Rv(e){let t=[],i=e.length;for(let n=0;n<i;n++){let r=e[n];if(!r)continue;let a=FC(r);a.length&&t.push(...a);let l=OC(r);l.length&&t.push(...l)}return t}function Jv(e){let t=e.service?Array.isArray(e.service)?e.service:[e.service]:[],i=t.length,n=[];for(let r=0;r<i;r++)Zl(t[r])&&n.push(t[r]);return n}function NC(e,t=!0,i){let n=[],r=zC(e);if(r===null)return n;let a=e;if(n.push(r),t&&a&&a.width&&a.height){let l=[],c=Jv(a);for(let p of c){let m={id:ft(p),width:a.width,height:a.height};if(i.canLoadSync(m)){let h=i.loadServiceSync(m);h&&(h.height||(h.height=a.height),h.width||(h.width=a.width),l.push(...Rv([h])))}}if(l.length)return n.push(...l),n}return a.service&&n.push(...Rv(a.service)),n}function BC({x:e=0,y:t=0,w:i,h:n,full:r,square:a,percent:l}){if(r)return"full";if(a)return"square";if(typeof i>"u"||typeof n>"u")throw new Error("RegionParameter: invalid region");let c=`${e},${t},${i},${n}`;return l?`pct:${c}`:c}function DC({max:e,percentScale:t,upscaled:i,confined:n,width:r,height:a,serialiseAsFull:l,version:c}){let p=[];return i&&p.push("^"),e?(p.push(l?"full":"max"),p.join("")):(n&&p.push("!"),t&&p.push(`pct:${t}`),r&&p.push(`${r}`),p.push(","),a&&c===3&&p.push(`${a}`),p.join(""))}function jC(e){return`${e.mirror?"!":""}${(e.angle||0)%360}`}function VC(e,t){let i=e.prefix.startsWith("/")?e.prefix.substr(1):e.prefix,n=`${e.scheme}://${e.server}/${i?`${i}/`:""}${e.identifier}`;if(e.type==="base")return n;if(e.type==="info")return`${n}/info.json`;let{size:r}=e,{region:a,rotation:l,format:c,quality:p}=e;if(t){let m=t["@context"]?Array.isArray(t["@context"])?t["@context"]:[t["@context"]]:[],h=m.indexOf("http://iiif.io/api/image/2/context.json")!==-1,y=m.indexOf("http://iiif.io/api/image/3/context.json")!==-1;if((r.width===t.width&&!r.height||r.height===t.height&&!r.width||r.width===t.width&&r.height===t.height)&&(r={...r,max:!0}),h&&(r.max&&!r.serialiseAsFull&&(r={...r,serialiseAsFull:!0}),!r.max&&r.width&&r.height&&(r={...r,height:void 0}),r={...r,version:2}),y){if(r.max&&r.serialiseAsFull&&(r={...r,serialiseAsFull:!1}),r.width&&!r.height&&t.width&&t.height){let S=t.height/t.width;r={...r,height:Math.ceil(r.width*S)}}r={...r,version:3}}}return[n,BC(a),DC(r),jC(l),`${p}.${c}`].filter(Boolean).join("/")}function zh(e,t,i){let n=TC({"@context":e.version===3?"http://iiif.io/api/image/3/context.json":"http://iiif.io/api/image/2/context.json",id:Dr(ft(e)),profile:e.level===null||typeof e.level>"u"?"level0":`level${e.level}`,type:e.version===3?"ImageService3":"ImageService2"});if(n.type!=="image")throw new Error("Invalid service");return n.size.max=!1,n.size.width=t,n.size.height=i,{id:VC(n),type:"fixed",width:t,height:i||e.height/(e.width||1)*t,unsafe:e.width>t}}function Mo(e){let t=e.replace(/(https?:\/\/)?(www.)?/i,"");return t.indexOf("/")!==-1?t.split("/")[0]:t}function UC(e,t,i){let n=e.width?e.width:e.maxWidth;return i.height<=e.maxHeight&&i.width<=e.maxWidth&&i.height>=e.minHeight&&i.width>=e.minWidth&&(!t||Math.abs(i.width-n)<Math.abs(t.width-n))}function WC(e,t){let i=[],n=Object.assign({unsafeImageService:!1,atAnyCost:!0,fallback:!0,minHeight:64,minWidth:64,maxHeight:1/0,maxWidth:1/0,returnAllOptions:!1,preferFixedSize:!1,allowUnsafe:!1,explain:!1,height:0,width:0},e),r=(h,y=0)=>n.explain?i.push(new Array(y).fill(0).map(S=>" ").join("")+h().trim()):void 0,a=[],l=[],c=null;r(()=>`Using configuration: ${JSON.stringify(n,null,2)}`);let p=(h,y)=>{if(r(()=>"Swapping choice",3),UC(n,y,h)){if(n.preferFixedSize&&h.unsafe){r(()=>`We found an image that was marked as unsafe, but it was the best size. (${h.id})`,4),l.push(h);return}n.returnAllOptions&&y&&l.push(y),r(()=>`We found a new image that was the best size. (${h.id})`,4),c=h}else n.returnAllOptions&&l.push(h)};r(()=>`The input shows we have ${t.length} list(s) of candidates to choose from.`);let m=t.length;for(let h=0;h<m;h++){let y=t[h]();r(()=>`Candidate group ${h}: ${JSON.stringify(y,null,2)}`,1);let S=y.length;r(()=>`Checking candidate list number ${h} and found ${S} potential ways of creating image(s)`,1);for(let w=0;w<S;w++){let v=y[w];if(r(()=>`-> Checking candidate ${w}`,1),v.type==="unknown"&&n.atAnyCost&&(r(()=>`We've found an unknown image type, adding this to the "last resort" list`,2),a.push(v)),v.type==="fixed"&&(v.unsafe?(r(()=>`We've found an unsafe fixed image type, adding this to the "last resort" list`,2),a.push(v)):(r(()=>"We've found a fixed size image, checking if it matches the request",2),p(v,c))),v.type==="fixed-service")if(n.unsafeImageService){r(()=>"Checking for an image from the tile source, without calculating the right height and width (unsafeImageService)",2);let x=zh(v,n.width,n.height);p(x,c)}else{r(()=>"Checking for an image from the tile source 3",2);let x=zh(v,v.width,v.height);p(x,c)}if(v.type==="variable"&&v.maxWidth){let x=zh({id:v.id,type:"fixed-service",width:v.maxWidth,height:v.maxWidth,level:v.level,version:v.version},v.maxWidth);p(x,c)}}if(c&&!n.returnAllOptions){if(c.unsafe||n.allowUnsafe)continue;r(()=>`We found a match in choice list number ${h}, no searching any more`);break}}return n.atAnyCost&&l.length===0?(r(()=>c?`We found an image! ${c.id} of type ${c.type}`:'We found no images, but "atAnyCost" is set, so returning that'),{best:c||a[0]||null,fallback:a.slice(1),log:i}):n.returnAllOptions?(r(()=>"Returning all options that we have found"),{best:(n.atAnyCost?c||l[0]||a[0]:c||l[0])||null,fallback:[...l,...a],log:i}):(r(()=>"Returning the best image that we found, and a fallback"),{best:c||l[0]||null,fallback:c?l:l.slice(1),log:i})}function HC(e,t,i){let n=e>t?e:t,r=i.length,a=[];for(let l=0;l<r;l++){let c=i[l];if(!c||c.scaleFactors.length===0)continue;let p=c.scaleFactors[0];if(!p)continue;let m=n/p,h=[p];for(;m>=c.width;)p=p*2,h.push(p),m=m/2;a.push({...c,scaleFactors:h})}return a}function qC(e,t){if(e.length!==t.length)return!1;if(e.length===0&&t.length===0)return!0;let i=e.length,n=!0;for(let a=0;a<i;a++){let l=e[a],c=t[a];if(l.width!==c.width||l.height!==c.height){n=!1;break}}if(n)return!0;let r=0;for(let a=0;a<i;a++)for(let l=0;l<i;l++)if(e[a].width===t[l].width&&e[a].height===t[l].height){r++;break}return r===i}function Tv(e){return Kl(0,e)}var ex=class{constructor(e={}){Xl(this,"config",{verificationsRequired:1,approximateServices:!1,enableFetching:!0,disableThrottling:!1}),Xl(this,"fetchingCount",0),Xl(this,"imageServices",{}),Xl(this,"knownImageServers",{}),this.config=Object.assign(this.config,e)}setConfig(e){Object.assign(this.config,e)}sample(e,t,i=!0){let n=Mo(ft(e)),r=Dr(ft(e)),a=this.knownImageServers[n];return this.imageServices[r]=Object.assign(e,{real:!0}),!a&&e.tiles&&!Tv(e)?(this.knownImageServers[n]={verifications:0,malformed:!1,root:n,preLoaded:i,sampledId:ft(e),verified:!1,server:null,result:{context:e["@context"]||[],sampledProfile:e.profile,resourceServiceRatio:t&&e.height?t.height/e.height:1,sampledSizes:e.sizes||[],sizeRatios:_C(e.width,e.height,e.sizes||[]),sampledTiles:e.tiles||[]}},!0):this.verify(e)}preLoad(e,t=!0){this.knownImageServers[e.root]=e,t&&(this.knownImageServers[e.root].malformed=!1,this.knownImageServers[e.root].verifications=this.config.verificationsRequired)}predict(e,t=!1,i=!1){let n=e?.source,r=Mo(ft(e)),a=this.knownImageServers[r],l=Dr(ft(e));return this.imageServices[l]?this.imageServices[l]||null:!this.config.approximateServices||!a||!a.result||!(n?.height||e.height)||!(n?.width||e.width)||!i&&(a.malformed||a.verifications<this.config.verificationsRequired)||Tv(e.source)?null:(this.imageServices[l]||(this.imageServices[l]={"@context":a.result.context,"@id":ft(e),id:ft(e),protocol:"http://iiif.io/api/image",tiles:n?.tiles||HC(e.width,e.height,a.result.sampledTiles),sizes:n?.sizes||MC(Math.round(e.width/a.result.resourceServiceRatio),Math.round(e.height/a.result.resourceServiceRatio),a.result.sizeRatios),profile:n?.profile||a.result.sampledProfile,height:n?.height||e.height,width:n?.width||e.width,real:!1}),this.imageServices[l]||null)}async getThumbnailFromResource(e,t,i=!0,n=[]){let r=e?await this.getImageCandidates(e,i):[];return WC(t,[()=>n,()=>r])}async getImageCandidates(e,t=!0){let i=e;if(t&&i&&i.height&&i.width){let n=Jv(i);for(let r of n){let a={id:ft(r),width:r.width?r.width:i.width,height:r.height?r.height:i.height,source:r};await this.loadService(a)}}return NC(e,t,this)}async verify(e){let t=this.predict(e,!1,!0),i=await this.fetchService(ft(e));if(!t)return!1;let n=t.height===i.height&&t.width===i.width&&t["@context"]===i["@context"]&&qC(t.sizes||[],i.sizes||[]);if(n){let r=Mo(ft(e)),a=this.knownImageServers[r];a&&(a.verifications+=1,a.verifications>=this.config.verificationsRequired&&(a.verified=!0))}return n}canLoadSync(e){let t=typeof e=="string"?e:ft(e),i=Dr(t);if(this.imageServices[i])return!0;let n=this.knownImageServers[Mo(t)];return!!(n&&!n.malformed&&n.verifications>=this.config.verificationsRequired)}async markAsMalformed(e){return this.knownImageServers[Mo(ft(e))].malformed=!0,this.loadService(e,!0)}async fetchService(e,t=!1){let i=Dr(e),n=this.imageServices[i];if(n&&(!t||n.real))return n;if(!this.config.enableFetching)throw new Error("Fetching is not enabled");let r=await this.fetch(i).then(a=>a.json());return!r.id&&r["@id"]&&(r.id=r["@id"]),r.id!==e&&(r.id=e,r["@id"]&&(r["@id"]=e)),this.imageServices[i]=Object.assign(r,{real:!0}),this.imageServices[i]}async fetch(e,t){return fetch(e,t)}async loadService(e,t=!1){if(!this.config.disableThrottling){let r=!0;for(;r;)if(this.fetchingCount>=this.config.verificationsRequired)await new Promise(a=>setTimeout(a,500));else{r=!1;break}}let i=this.knownImageServers[Mo(ft(e))];if(i&&!i.malformed&&!t){await i.result;let r=this.loadServiceSync(e);if(r)return r}this.fetchingCount++;let n=await this.fetchService(ft(e),t);return this.fetchingCount--,n.real&&this.sample(n,e),n}loadServiceSync(e){let t=Dr(ft(e));return this.imageServices[t]?this.imageServices[t]:this.config.approximateServices?this.predict(e):null}},xT=new ex;function Jl(e){return{all:e=e||new Map,on:function(t,i){var n=e.get(t);n?n.push(i):e.set(t,[i])},off:function(t,i){var n=e.get(t);n&&(i?n.splice(n.indexOf(i)>>>0,1):e.set(t,[]))},emit:function(t,i){var n=e.get(t);n&&n.slice().map(function(r){r(i)}),(n=e.get("*"))&&n.slice().map(function(r){r(t,i)})}}}var ix={},tx=e=>{let t,i=new Set,n=(h,y)=>{let S=typeof h=="function"?h(t):h;if(!Object.is(S,t)){let w=t;t=y??(typeof S!="object"||S===null)?S:Object.assign({},t,S),i.forEach(v=>v(t,w))}},r=()=>t,p={setState:n,getState:r,getInitialState:()=>m,subscribe:h=>(i.add(h),()=>i.delete(h)),destroy:()=>{(ix.env?ix.env.MODE:void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),i.clear()}},m=t=e(n,r,p);return p},eu=e=>e?tx(e):tx;var QC=Object.create,Nh=Object.defineProperty,$C=Object.getOwnPropertyDescriptor,nx=Object.getOwnPropertyNames,GC=Object.getPrototypeOf,YC=Object.prototype.hasOwnProperty,XC=(e,t,i)=>t in e?Nh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Bh=(e,t)=>function(){return t||(0,e[nx(e)[0]])((t={exports:{}}).exports,t),t.exports},KC=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of nx(t))!YC.call(e,r)&&r!==i&&Nh(e,r,{get:()=>t[r],enumerable:!(n=$C(t,r))||n.enumerable});return e},Dh=(e,t,i)=>(i=e!=null?QC(GC(e)):{},KC(t||!e||!e.__esModule?Nh(i,"default",{value:e,enumerable:!0}):i,e)),Tt=(e,t,i)=>(XC(e,typeof t!="symbol"?t+"":t,i),i);var jh="http://library.stanford.edu/iiif/image-api/compliance.html#level0",Vh="http://library.stanford.edu/iiif/image-api/compliance.html#level1",Uh="http://library.stanford.edu/iiif/image-api/compliance.html#level2",Wh="http://library.stanford.edu/iiif/image-api/conformance.html#level0",Hh="http://library.stanford.edu/iiif/image-api/conformance.html#level1",qh="http://library.stanford.edu/iiif/image-api/conformance.html#level2",Qh="http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0",$h="http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level1",Gh="http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2",Yh="http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level0",Xh="http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level1",Kh="http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level2",Zh="http://iiif.io/api/image/1/level0.json",Jh="http://iiif.io/api/image/1/profiles/level0.json",ep="http://iiif.io/api/image/1/level1.json",tp="http://iiif.io/api/image/1/profiles/level1.json",ip="http://iiif.io/api/image/1/level2.json",np="http://iiif.io/api/image/1/profiles/level2.json",rp="http://iiif.io/api/image/2/level0.json",op="http://iiif.io/api/image/2/profiles/level0.json",sp="http://iiif.io/api/image/2/level1.json",ap="http://iiif.io/api/image/2/profiles/level1.json",lp="http://iiif.io/api/image/2/level2.json",up="http://iiif.io/api/image/2/profiles/level2.json",cp="level0",dp="level1",hp="level2",pp="http://iiif.io/api/image/2/level0",fp="http://iiif.io/api/image/2/level1",mp="http://iiif.io/api/image/2/level2",ko=[mp,Uh,qh,Gh,Kh,ip,np,lp,up,hp],tu=[...ko,fp,Vh,Hh,$h,Xh,ep,tp,sp,ap,dp],gp=[pp,fp,mp,jh,Vh,Uh,Wh,Hh,qh,Qh,$h,Gh,Yh,Xh,Kh,Zh,Jh,ep,tp,ip,np,rp,op,sp,ap,lp,up,cp,dp,hp],yp=gp,vp=[pp,jh,Wh,Qh,Yh,Zh,Jh,rp,op,cp],rx={extraFormats:["jpg"],extraQualities:["default"],extraFeatures:["sizeByWhListed"]},ox={extraFormats:["jpg"],extraQualities:["default"],extraFeatures:["baseUriRedirect","cors","jsonldMediaType","regionByPx","regionSquare","sizeByWhListed","sizeByH","sizeByW","sizeByWh"]},sx={extraFormats:["jpg","png"],extraQualities:["default"],extraFeatures:["baseUriRedirect","cors","jsonldMediaType","regionByPct","regionByPx","regionSquare","rotationBy90s","sizeByWhListed","sizeByConfinedWh","sizeByH","sizeByPct","sizeByW","sizeByWh"]};var ZC=Object.defineProperty,JC=(e,t,i)=>t in e?ZC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,vn=(e,t,i)=>(JC(e,typeof t!="symbol"?t+"":t,i),i);function eP(e){try{if(e==="full")return{full:!0};if(e==="square")return{square:!0};let t=e.startsWith("pct:"),i=e.substr(t?4:0).split(",").map(n=>parseFloat(n));return{x:i[0],y:i[1],w:i[2],h:i[3],percent:t}}catch{throw new Error("Expected 'full', 'square' or 'x,y,w,h'. Found "+e)}}function tP(e){let t={upscaled:!1,max:!1,confined:!1};if(e[0]==="^"&&(t.upscaled=!0,e=e.slice(1)),e==="max"||e==="full")return t.max=!0,t.serialiseAsFull=e==="full",t;if(e[0]==="!"&&(t.confined=!0,e=e.slice(1)),e[0]==="p")return t.percentScale=parseFloat(e.slice(4)),t;let i=e.split(",").map(n=>n.trim());return i.length&&(i[0]!==""&&(t.width=parseInt(i[0],10)),i[1]!==""&&(t.height=parseInt(i[1],10))),t}function iP(e){let t={angle:0};if(e[0]==="!"&&(t.mirror=!0,e=e.substr(1)),t.angle=parseFloat(e)%360,Number.isNaN(t.angle))throw new Error(`Invalid rotation ${e}`);return t}function nP(e,t=""){let i=e.match(/^(([a-zA-Z]+):\/\/([^/]+))?((.*)+)/);if(!i)throw new Error(`Invalid or unknown input ${e}`);let n=i[2],r=i[3],a=i[4];if(a[0]==="/"&&(a=a.substring(1)),t.length>0){if(t[0]==="/"&&(t=t.substring(1)),t!==a.substring(0,t.length))throw new Error(`Path does not start with prefix (path: ${a}, prefix: ${t})`);a=a.substring(t.length)}return{scheme:n,server:r,path:a,prefix:t}}function rP(e,t=""){let{path:i,scheme:n,server:r,prefix:a}=nP(e,t),l=i.split("/").reverse(),[c,p,m,h,...y]=l,S=y.reverse().filter(Boolean).join("/");if(l.length===1||c==="")return{type:"base",scheme:n,server:r,prefix:a,identifier:S};if(c==="info.json"){let[,...x]=l;return{type:"info",scheme:n,server:r,prefix:a,identifier:x.reverse().filter(Boolean).join("/")}}if(typeof n>"u"||typeof r>"u"||typeof i>"u"||typeof h>"u"||typeof m>"u"||typeof p>"u"||typeof c>"u")throw new Error("Invalid image service URL");let[w="",v=""]=c.split(".");return{type:"image",scheme:n,server:r,prefix:a,identifier:S,originalPath:i,region:eP(h),size:tP(m),rotation:iP(p),quality:w,format:v}}function oP(e){return ko.indexOf(e)!==-1?sx:tu.indexOf(e)!==-1?ox:rx}function sP(e){let t=e?Array.isArray(e.profile)?e.profile:[e.profile]:[],i={extraQualities:[],extraFormats:[],extraFeatures:[]};for(let n of t)if(typeof n=="string"&&(n=oP(n)),!!n){if(n.formats)for(let r of n.formats)i.extraFormats.indexOf(r)===-1&&i.extraFormats.push(r);if(n.qualities)for(let r of n.qualities)i.extraQualities.indexOf(r)===-1&&i.extraQualities.push(r);if(n.supports)for(let r of n.supports)i.extraFeatures.indexOf(r)===-1&&i.extraFeatures.push(r);if(n.maxHeight&&(i.maxHeight=n.maxHeight),n.maxWidth&&(i.maxWidth=n.maxWidth),n.maxArea&&(i.maxArea=n.maxArea),n.extraFormats)for(let r of n.extraFormats)i.extraFormats.indexOf(r)===-1&&i.extraFormats.push(r);if(n.extraQualities)for(let r of n.extraQualities)i.extraQualities.indexOf(r)===-1&&i.extraQualities.push(r);if(n.extraFeatures)for(let r of n.extraFeatures)i.extraFeatures.indexOf(r)===-1&&i.extraFeatures.push(r);n.maxHeight&&(i.maxHeight=n.maxHeight),n.maxWidth&&(i.maxWidth=n.maxWidth),n.maxArea&&(i.maxArea=n.maxArea)}if(e.extraFormats)for(let n of e.extraFormats)i.extraFormats.indexOf(n)===-1&&i.extraFormats.push(n);if(e.extraFeatures)for(let n of e.extraFeatures)i.extraFeatures.indexOf(n)===-1&&i.extraFeatures.push(n);if(e.extraQualities)for(let n of e.extraQualities)i.extraQualities.indexOf(n)===-1&&i.extraQualities.push(n);return i}function Sp(e){let t=Array.isArray(e.profile)?e.profile:[e.profile];for(let i of t)if(typeof i=="string"&&vp.indexOf(i)!==-1)return!0;return!1}function Le(e){if(e["@id"])return e["@id"];if(e.id)return e.id}function js(e){if(!e||!e.profile||!Le(e))return!1;let t=Array.isArray(e.profile)?e.profile:[e.profile];for(let i of t)if(typeof i=="string"&&gp.indexOf(i)!==-1)return!0;return!1}function ax(e){if(!js(e))return!1;let t=Array.isArray(e.profile)?e.profile:[e.profile];for(let i of t)if(typeof i=="string"){if(tu.indexOf(i)!==-1)return!0}else{let n=[...i.supports||[],...i.extraFeatures||[]];if(n.indexOf("regionByPx")!==-1&&(n.indexOf("sizeByW")!==-1||n.indexOf("sizeByWh")!==-1))return!0}return!1}function aP({x:e=0,y:t=0,w:i,h:n,full:r,square:a,percent:l}){if(r)return"full";if(a)return"square";if(typeof i>"u"||typeof n>"u")throw new Error("RegionParameter: invalid region");let c=`${e},${t},${i},${n}`;return l?`pct:${c}`:c}function lP({max:e,percentScale:t,upscaled:i,confined:n,width:r,height:a,serialiseAsFull:l,version:c}){let p=[];return i&&p.push("^"),e?(p.push(l?"full":"max"),p.join("")):(n&&p.push("!"),t&&p.push(`pct:${t}`),r&&p.push(`${r}`),p.push(","),a&&c===3&&p.push(`${a}`),p.join(""))}function uP(e){return`${e.mirror?"!":""}${(e.angle||0)%360}`}function iu(e,t){let i=e.prefix.startsWith("/")?e.prefix.substring(1):e.prefix,n=`${e.scheme}://${e.server}/${i?`${i}/`:""}${e.identifier}`;if(e.type==="base")return n;if(e.type==="info")return`${n}/info.json`;let{size:r}=e,{region:a,rotation:l,format:c,quality:p}=e;if(t){let m=t["@context"]?Array.isArray(t["@context"])?t["@context"]:[t["@context"]]:[],h=m.indexOf("http://iiif.io/api/image/2/context.json")!==-1,y=m.indexOf("http://iiif.io/api/image/3/context.json")!==-1;if((r.width===t.width&&!r.height||r.height===t.height&&!r.width||r.width===t.width&&r.height===t.height)&&(r={...r,max:!0}),h&&(r.max&&!r.serialiseAsFull&&(r={...r,serialiseAsFull:!0}),!r.max&&r.width&&r.height&&(r={...r,height:void 0}),r={...r,version:2}),y){if(r.max&&r.serialiseAsFull&&(r={...r,serialiseAsFull:!1}),r.width&&!r.height&&t.width&&t.height){let S=t.height/t.width;r={...r,height:Math.ceil(r.width*S)}}r={...r,version:3}}}return[n,aP(a),lP(r),uP(l),`${p}.${c}`].filter(Boolean).join("/")}function Ln(e){return e.endsWith("info.json")?e:e.endsWith("/")?`${e}info.json`:`${e}/info.json`}function nu(e){let t=rP(Ln(e.id));if(t.type!=="info")throw new Error("Invalid service URL");let i=sP(e);return{identifier:t.identifier,originalPath:"",server:t.server,prefix:t.prefix,scheme:t.scheme,type:"image",quality:i.extraQualities.indexOf("default")===-1?i.extraQualities[0]:"default",region:{full:!0},size:{max:!0,upscaled:!1,confined:!1},format:"jpg",rotation:{angle:0}}}function lx(e,t,i){let n=i.length,r=[];for(let a=0;a<n;a++){let l=i[a];if(!l)continue;let c=l.width;r.push(e/c)}return r}function ux(e,t,i){let n=i.length,r=[];for(let a=0;a<n;a++){let l=i[a];l&&r.push({width:Math.floor(e/l),height:Math.floor(t/l)})}return r}function xp(e,t){if(t&&t.profile){let i=t.profile;if(i){let n=Array.isArray(i)?i:[i];if(n.includes(`level${e}`)||n.includes(`http://iiif.io/api/image/2/level${e}.json`)||n.includes(`http://iiif.io/api/image/1/level${e}.json`)||n.includes(`http://iiif.io/api/image/1/profiles/level${e}.json`))return!0;if(e===2){for(let r of n)if(ko.includes(r))return!0}if(e===1){for(let r of n)if(tu.includes(r))return!0}if(e===0){for(let r of n)if(vp.includes(r))return!0}}}return!1}function Vs(e){return js(e)?xp(0,e)?0:xp(1,e)?1:xp(2,e)?2:null:null}function zn(e){let t=e.service?Array.isArray(e.service)?e.service:[e.service]:[],i=t.length,n=[];for(let r=0;r<i;r++)js(t[r])&&n.push(t[r]);return n}function cx(e){if(e["@type"])return e["@type"];if(e.type)return e.type}function jr(e){let t=e.replace(/(https?:\/\/)?(www.)?/i,"");return t.indexOf("/")!==-1?t.split("/")[0]:t}function dx(e,t,i){let n=e>t?e:t,r=i.length,a=[];for(let l=0;l<r;l++){let c=i[l];if(!c||c.scaleFactors.length===0)continue;let p=c.scaleFactors[0];if(!p)continue;let m=n/p,h=[p];for(;m>=c.width;)p=p*2,h.push(p),m=m/2;a.push({...c,scaleFactors:h})}return a}function ru(e,t,i){let n=nu({"@context":e.version===3?"http://iiif.io/api/image/3/context.json":"http://iiif.io/api/image/2/context.json",id:Ln(Le(e)),profile:e.level===null||typeof e.level>"u"?"level0":`level${e.level}`,type:e.version===3?"ImageService3":"ImageService2"});if(n.type!=="image")throw new Error("Invalid service");return n.size.max=!1,n.size.width=t,n.size.height=i,{id:iu(n),type:"fixed",width:t,height:i||e.height/(e.width||1)*t,unsafe:e.width>t}}function hx(e,t,i){let n=e.width?e.width:e.maxWidth;return i.height<=e.maxHeight&&i.width<=e.maxWidth&&i.height>=e.minHeight&&i.width>=e.minWidth&&(!t||Math.abs(i.width-n)<Math.abs(t.width-n))}function px(e,t){let i=[],n=Object.assign({unsafeImageService:!1,atAnyCost:!0,fallback:!0,minHeight:64,minWidth:64,maxHeight:1/0,maxWidth:1/0,returnAllOptions:!1,preferFixedSize:!1,allowUnsafe:!1,explain:!1,height:0,width:0},e),r=(h,y=0)=>n.explain?i.push(new Array(y).fill(0).map(S=>" ").join("")+h().trim()):void 0,a=[],l=[],c=null;r(()=>`Using configuration: ${JSON.stringify(n,null,2)}`);let p=(h,y)=>{if(r(()=>"Swapping choice",3),hx(n,y,h)){if(n.preferFixedSize&&h.unsafe){r(()=>`We found an image that was marked as unsafe, but it was the best size. (${h.id})`,4),l.push(h);return}n.returnAllOptions&&y&&l.push(y),r(()=>`We found a new image that was the best size. (${h.id})`,4),c=h}else n.returnAllOptions&&l.push(h)};r(()=>`The input shows we have ${t.length} list(s) of candidates to choose from.`);let m=t.length;for(let h=0;h<m;h++){let y=t[h]();r(()=>`Candidate group ${h}: ${JSON.stringify(y,null,2)}`,1);let S=y.length;r(()=>`Checking candidate list number ${h} and found ${S} potential ways of creating image(s)`,1);for(let w=0;w<S;w++){let v=y[w];if(r(()=>`-> Checking candidate ${w}`,1),v.type==="unknown"&&n.atAnyCost&&(r(()=>`We've found an unknown image type, adding this to the "last resort" list`,2),a.push(v)),v.type==="fixed"&&(v.unsafe?(r(()=>`We've found an unsafe fixed image type, adding this to the "last resort" list`,2),a.push(v)):(r(()=>"We've found a fixed size image, checking if it matches the request",2),p(v,c))),v.type==="fixed-service")if(n.unsafeImageService){r(()=>"Checking for an image from the tile source, without calculating the right height and width (unsafeImageService)",2);let x=ru(v,n.width,n.height);p(x,c)}else{r(()=>"Checking for an image from the tile source 3",2);let x=ru(v,v.width,v.height);p(x,c)}if(v.type==="variable"&&v.maxWidth){let x=ru({id:v.id,type:"fixed-service",width:v.maxWidth,height:v.maxWidth,level:v.level,version:v.version},v.maxWidth);p(x,c)}}if(c&&!n.returnAllOptions){if(c.unsafe||n.allowUnsafe)continue;r(()=>`We found a match in choice list number ${h}, no searching any more`);break}}return n.atAnyCost&&l.length===0?(r(()=>c?`We found an image! ${c.id} of type ${c.type}`:'We found no images, but "atAnyCost" is set, so returning that'),{best:c||a[0]||null,fallback:a.slice(1),log:i}):n.returnAllOptions?(r(()=>"Returning all options that we have found"),{best:(n.atAnyCost?c||l[0]||a[0]:c||l[0])||null,fallback:[...l,...a],log:i}):(r(()=>"Returning the best image that we found, and a fallback"),{best:c||l[0]||null,fallback:c?l:l.slice(1),log:i})}function Cp(e){return(e["@context"]?Array.isArray(e["@context"])?e["@context"]:[e["@context"]]:[]).indexOf("http://iiif.io/api/image/3/context.json")!==-1}function fx(e){return js(e)?(e&&e.sizes?e.sizes:[]).map(t=>({id:Le(e),type:"fixed-service",height:t.height,width:t.width,level:Vs(e),version:Cp(e)?3:2})):[]}function mx(e){if(!ax(e))return[];let t=[],i=Array.isArray(e.profile)?e.profile:[e.profile],n=i.length;for(let r=0;r<n;r++){let a=i[r];if(a&&typeof a!="string"&&(a.maxHeight||a.maxWidth))return[{id:Le(e),type:"variable",minWidth:0,minHeight:0,maxHeight:a.maxHeight||a.maxWidth,maxWidth:a.maxWidth||a.maxHeight,level:Vs(e),version:e["@context"]==="http://iiif.io/api/image/3/context.json"?3:2}]}if(e.tiles){let r=e.tiles.length;for(let a=0;a<r;a++){let l=e.tiles[a];l&&(l.height||l.width)&&t.push({id:Le(e),type:"variable",minHeight:0,minWidth:0,maxHeight:l.height||l.width,maxWidth:l.width,level:Vs(e),version:Cp(e)?3:2})}}return t}function wp(e){let t=[],i=e.length;for(let n=0;n<i;n++){let r=e[n];if(!r)continue;let a=fx(r);a.length&&t.push(...a);let l=mx(r);l.length&&t.push(...l)}return t}function bp(e){let t=/^.*\/(full)\/(((\d+),(\d+)?)|max)\/(\d+)\/default\.(jpg|png|jpeg)$/,i=e.match(t);if(i&&i[4]&&i[5]){let n=i[1],r=parseInt(i[4],10),a=parseInt(i[5],10),l=i[7];if((n==="max"||n==="full")&&r&&a&&l)return{type:"fixed",id:e,height:a,width:r}}return{type:"unknown",id:e}}function Us(e){if(typeof e=="string")return bp(e);let t=cx(e);if(t!=="Image"&&t!=="sc:Image")return null;let i=e,n=Le(i);return n?n&&i.width&&i.height?{id:n,type:"fixed",width:i.width,height:i.height,unsafe:!0}:bp(n):null}function gx(e,t=!0,i){let n=[],r=Us(e);if(r===null)return n;let a=e;if(n.push(r),t&&a&&a.width&&a.height){let l=[],c=zn(a);for(let p of c){let m={id:Le(p),width:a.width,height:a.height};if(i.canLoadSync(m)){let h=i.loadServiceSync(m);h&&(h.height||(h.height=a.height),h.width||(h.width=a.width),l.push(...wp([h])))}}if(l.length)return n.push(...l),n}return a.service&&n.push(...wp(a.service)),n}function yx(e,t){if(e.length!==t.length)return!1;if(e.length===0&&t.length===0)return!0;let i=e.length,n=!0;for(let a=0;a<i;a++){let l=e[a],c=t[a];if(l.width!==c.width||l.height!==c.height){n=!1;break}}if(n)return!0;let r=0;for(let a=0;a<i;a++)for(let l=0;l<i;l++)if(e[a].width===t[l].width&&e[a].height===t[l].height){r++;break}return r===i}var Oo=class{constructor(e={}){Tt(this,"config",{verificationsRequired:1,approximateServices:!1,enableFetching:!0,disableThrottling:!1}),Tt(this,"fetchingCount",0),Tt(this,"imageServices",{}),Tt(this,"knownImageServers",{}),this.config=Object.assign(this.config,e)}setConfig(e){Object.assign(this.config,e)}sample(e,t,i=!0){let n=jr(Le(e)),r=Ln(Le(e)),a=this.knownImageServers[n];return this.imageServices[r]=Object.assign(e,{real:!0}),!a&&e.tiles&&!Sp(e)?(this.knownImageServers[n]={verifications:0,malformed:!1,root:n,preLoaded:i,sampledId:Le(e),verified:!1,server:null,result:{context:e["@context"]||[],sampledProfile:e.profile,resourceServiceRatio:t&&e.height?t.height/e.height:1,sampledSizes:e.sizes||[],sizeRatios:lx(e.width,e.height,e.sizes||[]),sampledTiles:e.tiles||[]}},!0):this.verify(e)}preLoad(e,t=!0){this.knownImageServers[e.root]=e,t&&(this.knownImageServers[e.root].malformed=!1,this.knownImageServers[e.root].verifications=this.config.verificationsRequired)}predict(e,t=!1,i=!1){let n=e?.source,r=jr(Le(e)),a=this.knownImageServers[r],l=Ln(Le(e));return this.imageServices[l]?this.imageServices[l]||null:!this.config.approximateServices||!a||!a.result||!(n?.height||e.height)||!(n?.width||e.width)||!i&&(a.malformed||a.verifications<this.config.verificationsRequired)||e.source&&Sp(e.source)?null:(this.imageServices[l]||(this.imageServices[l]={"@context":a.result.context,"@id":Le(e),id:Le(e),protocol:"http://iiif.io/api/image",tiles:n?.tiles||dx(e.width,e.height,a.result.sampledTiles),sizes:n?.sizes||ux(Math.round(e.width/a.result.resourceServiceRatio),Math.round(e.height/a.result.resourceServiceRatio),a.result.sizeRatios),profile:n?.profile||a.result.sampledProfile,height:n?.height||e.height,width:n?.width||e.width,real:!1}),this.imageServices[l]||null)}async getThumbnailFromResource(e,t,i=!0,n=[]){let r=e?await this.getImageCandidates(e,i):[];return px(t,[()=>n,()=>r])}async getImageCandidates(e,t=!0){let i=e;if(t&&i&&i.height&&i.width){let n=zn(i);for(let r of n){let a={id:Le(r),width:r.width?r.width:i.width,height:r.height?r.height:i.height,source:r};await this.loadService(a)}}return gx(e,t,this)}async verify(e){let t=this.predict(e,!1,!0),i=await this.fetchService(Le(e));if(!t)return!1;let n=t.height===i.height&&t.width===i.width&&t["@context"]===i["@context"]&&yx(t.sizes||[],i.sizes||[]);if(n){let r=jr(Le(e)),a=this.knownImageServers[r];a&&(a.verifications+=1,a.verifications>=this.config.verificationsRequired&&(a.verified=!0))}return n}canLoadSync(e){let t=typeof e=="string"?e:Le(e),i=Ln(t);if(this.imageServices[i])return!0;let n=this.knownImageServers[jr(t)];return!!(n&&!n.malformed&&n.verifications>=this.config.verificationsRequired)}async markAsMalformed(e){return this.knownImageServers[jr(Le(e))].malformed=!0,this.loadService(e,!0)}async fetchService(e,t=!1){let i=Ln(e),n=this.imageServices[i];if(n&&(!t||n.real))return n;if(!this.config.enableFetching)throw new Error("Fetching is not enabled");let r=await this.fetch(i).then(a=>a.json());return!r.id&&r["@id"]&&(r.id=r["@id"]),r.id!==e&&(r.id=e,r["@id"]&&(r["@id"]=e)),this.imageServices[i]=Object.assign(r,{real:!0}),this.imageServices[i]}async fetch(e,t){return fetch(e,t)}async loadService(e,t=!1){if(!this.config.disableThrottling){let r=!0;for(;r;)if(this.fetchingCount>=this.config.verificationsRequired)await new Promise(a=>setTimeout(a,500));else{r=!1;break}}let i=this.knownImageServers[jr(Le(e))];if(i&&!i.malformed&&!t){await i.result;let r=this.loadServiceSync(e);if(r)return r}this.fetchingCount++;let n=await this.fetchService(Le(e),t);return this.fetchingCount--,n.real&&this.sample(n,e),n}loadServiceSync(e){let t=Ln(Le(e));return this.imageServices[t]?this.imageServices[t]:this.config.approximateServices?this.predict(e):null}};function vx(e={}){let t=e.events||Jl(),i=e.loader||new Oo;return{store:eu((r,a)=>({loaded:{},loadServiceSync:(l,c,p)=>{let m=l.id||l["@id"],h=a().loaded[m];if(h&&h.status==="done")return h.service;if(h&&h.status==="loading")return null;if(h&&h.status==="error")throw new Error("Failed to load image service");let y={id:Le(l),width:l.width||c?.width||0,height:l.height||c?.height||0,source:l},S=i.loadServiceSync(y);return S?(r(w=>({loaded:{...w.loaded,[m]:{status:"done",service:S,real:!0}}})),t.emit("image-service.loaded",{id:m,service:S})):p&&a().loadService(l,c).then(()=>{}),S},loadService:async(l,c)=>{let p=l.id||l["@id"],m=a().loaded[p];if(m&&m.status==="done")return m.service;if(m&&m.status==="loading")return new Promise((h,y)=>{let S=w=>{w.id===p&&(t.off("image-service.loaded",S),h(w.service||l))};t.on("image-service.loaded",S)});if(m&&m.status==="error"&&!c?.force)throw new Error("Failed to load image service");t.emit("image-service.loading",{id:p});try{let h={id:Le(l),width:l.width||0,height:l.height||0,source:l},y=await i.loadService(h,c?.force);return r(S=>({loaded:{...S.loaded,[p]:{status:"done",service:y,real:y.real}}})),t.emit("image-service.loaded",{id:p,service:y}),y}catch(h){throw t.emit("image-service.error",{id:p,error:h}),h}}})),events:t}}var Pp=vx();var ou={},Fn={get(e){return e},setMetaValue([e,t,i],n){let r=Fn.getResourceMeta(e,t),a=r?r[i]:void 0,l=typeof n=="function"?n(a):n;ou[e]={...ou[e]||{},[t]:{...(ou[e]||{})[t]||{},[i]:l}}},getResourceMeta:(e,t)=>{let i=ou[e];if(i)return t?i[t]:i},async load(e){let t=typeof e=="string"?e:e.id;return fetch(t).then(i=>i.json())},requestStatus(e){}};var xx=new Oo;function Ep(e=Fn,t={}){let i=t.imageServiceLoader||xx;async function n(r,a,l=!1,c=[],p){let m=()=>i.getThumbnailFromResource(void 0,a,l,c);if(!r)return await i.getThumbnailFromResource(void 0,a,l,c);if(typeof r=="string"){let S=Us(r);return S&&c.push(S),await i.getThumbnailFromResource(void 0,a,l,c)}let h=e.get(r,{skipSelfReturn:!1});if(typeof h=="string")return{best:Us(h),fallback:[],log:[]};if(!h)return await m();switch(await(async S=>{if(S&&S.thumbnail&&S.thumbnail.length){let w=e.get(S.thumbnail[0]),v=await i.getImageCandidates(w,l);v&&v.length&&c.push(...v)}})(h),h.type){case"Annotation":{let S=Array.isArray(h.body)?h.body:[h.body],w=e.get(S[0]);return p&&!w.width&&(w.width=p.width,w.height=p.height),await i.getThumbnailFromResource(w,a,l,c)}case"Canvas":{let S=h;return n(S.items[0],a,l,c,{width:S.width,height:S.height})}case"AnnotationPage":return n(h.items[0],a,l,c,p);case"Choice":{let S=h;return!S.items||S.items[0]?await m():n(S.items[0],a,l,c,p)}case"Collection":{let w=h.items[0];return w?n(w,a,l,c,p):await m()}case"Manifest":{let w=h.items[0];return w?n(w,a,l,c,p):await m()}case"SpecificResource":case"Image":case"Dataset":case"Sound":case"Text":case"TextualBody":case"Video":return p&&!h.width&&(h.width=p.width,h.height=p.height),i.getThumbnailFromResource(h,a,l,c)}return await m()}return{getBestThumbnailAtSize:n}}var KP=R(B(),1),ZP=R(q(),1),Zs=R(q(),1),JP=R(B(),1),eE=R(q(),1),m0=R(q(),1),cP=Object.defineProperty,dP=(e,t,i)=>t in e?cP(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,P=(e,t,i)=>(dP(e,typeof t!="symbol"?t+"":t,i),i),bu=["onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp","onTouchCancel","onTouchEnd","onTouchMove","onTouchStart","onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut","onScroll","onWheel","onClick","onDragStart","onDragEnd","onDragEnter","onDragExit","onDrag","onDragOver"];function hP(){return bu.reduce((e,t)=>(e[t]=[],e),{})}var zo=bu.reduce((e,t)=>(e[t.slice(2).toLowerCase()]=t,e[t]=t,e),{}),pP="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",Cu=(e=21)=>{let t="",i=crypto.getRandomValues(new Uint8Array(e));for(;e--;)t+=pP[i[e]&63];return t},bn=class{constructor(){P(this,"__id"),P(this,"__revision",0),P(this,"__host"),P(this,"__onCreate"),P(this,"__parent"),P(this,"__owner",{value:void 0}),P(this,"__state",{}),P(this,"eventHandlers"),P(this,"scale",1),P(this,"layers",[]),P(this,"time",[]),P(this,"_crop"),P(this,"cropData"),P(this,"id"),P(this,"addEventListener",(e,t,i)=>{let n=zo[e];if(!this.eventHandlers[n])throw new Error(`Unknown event ${n}`);this.eventHandlers[n].indexOf(t)===-1&&this.eventHandlers[n].push(t)}),P(this,"removeEventListener",(e,t)=>{let i=zo[e];if(!this.eventHandlers[i]){console.warn(`Unknown event ${i}`);return}this.eventHandlers[i].indexOf(t)!==-1&&(this.eventHandlers[i]=this.eventHandlers[i].filter(n=>n!==t))}),this.id=this.__id=Cu(),this.eventHandlers=hP()}get crop(){return this._crop}set crop(e){this._crop=e}getObjectsAt(e){return[]}getAllPointsAt(e,t,i){return[]}getScheduledUpdates(e,t){return[]}dispatchEvent(e,t){let i=this.eventHandlers[e],n=i?i.length:0,r=!1;if(n)for(let a=0;a<n;a++)try{i[a](t),r=!0}catch(l){console.error(e,l)}return r}get x(){return this.points[1]}get y(){return this.points[2]}get width(){return this.points[3]-this.points[1]}get height(){return this.points[4]-this.points[2]}translate(e,t){Zt(this.points,ut(e,t))}atScale(e){Zt(this.points,On(e,this.x,this.y)),this.scale*=e}transform(e){Zt(this.points,e)}applyProps(e){this.__revision++}appendChild(e){}removeChild(e){}insertBefore(e,t){}hideInstance(){}},cr=class Ip extends bn{constructor(t){if(super(),P(this,"type","spacial-content"),P(this,"id"),P(this,"uri"),P(this,"display"),P(this,"points"),P(this,"priority"),P(this,"style",{opacity:1}),!t)this.id="",this.uri="",this.display={x:0,y:0,scale:1,width:0,height:0,points:re(5)},this.points=re(5);else{let i=t.scale||1;this.id=t.id||t.uri,this.uri=t.uri,this.points=xe.singleBox(t.width,t.height,t.x,t.y),this.display={x:0,y:0,scale:i,width:t.width/i,height:t.height/i,points:xe.singleBox(t.width/i,t.height/i),rotation:t?.rotation}}}applyProps(t){let i=t.display?t.display.width:t.target.width,n=t.target.width/i;if(this.id=t.id||t.uri,this.uri=t.uri,this.points.set(xe.singleBox(t.target.width,t.target.height,t.target.x,t.target.y)),t.style&&typeof t.style.opacity<"u"&&(this.style.opacity=t.style.opacity),t.crop){this.cropData=t.crop;let r=xe.singleBox(t.crop.width,t.crop.height,t.crop.x,t.crop.y);Zt(r,ut(-t.crop.x,-t.crop.y)),this.crop?this.crop.set(r):this.crop=re(r)}t.display?(this.display.scale=n,this.display.width=t.display.width,this.display.height=t.display.height,this.display.rotation=t.display.rotation,this.display.points=xe.singleBox(t.display.width,t.display.height)):(this.display.scale=n,this.display.width=t.target.width/n,this.display.height=t.target.height/n,this.display.points=xe.singleBox(t.target.width/n,t.target.height/n))}getAllPointsAt(t,i,n){return[[this,this.crop||this.points,i]]}static fromSvg(t,i,n,r){return Ip.fromImage("data:image/svg+xml;base64,"+btoa(t),i,n,r)}static fromImage(t,i,n,r){let a=new Ip;return a.applyProps({uri:t,id:r,display:n,target:i}),a}getImageUrl(){return this.uri}},Rp=class extends bn{constructor(e){if(super(),P(this,"type","spacial-content"),P(this,"id"),P(this,"uri"),P(this,"display"),P(this,"points"),P(this,"getTexture"),this.getTexture=()=>({source:void 0,hash:-1}),!e)this.id="",this.uri="",this.display={x:0,y:0,scale:1,width:0,height:0,points:re(5)},this.points=re(5);else{let t=e.scale||1;this.id=e.id||e.uri,this.uri=e.uri,this.points=xe.singleBox(e.width,e.height),this.display={x:0,y:0,scale:t,width:e.width/t,height:e.height/t,points:t!==1?xe.singleBox(e.width/t,e.height/t):this.points}}}applyProps(e){let t=e.display?e.display.width:e.target.width,i=e.target.width/t;this.id=e.id,this.points.set(xe.singleBox(e.target.width,e.target.height)),this.display.scale=i,this.display.width=e.target.width/i,this.display.height=e.target.height/i,this.getTexture=e.getTexture,this.display.points=i!==1?xe.singleBox(e.target.width/i,e.target.height/i):this.points}getAllPointsAt(e,t,i){return[[this,this.points,t]]}};function fP(e,t,i=1){let n=t.length;if(n===0)throw new Error("No resources passed in.");let r=0;for(let a=0;a<n&&!(!t[a]||!t[a].display);a++)r=Math.abs(t[a].display.scale-e)*i<Math.abs(t[r].display.scale-e)?a:r;return r}function Cx(e,t){return Math.abs(e-t)}function vu(e,t){let i=Cx(e.x,t.x),n=Cx(e.y,t.y);return Math.sqrt(Math.pow(i,2)+Math.pow(n,2))}function mP(e){let t=e.length;return e.indexOf("/info.json")===t-10?e.slice(0,-10):e}function su(e,t,i){return Math.min(Math.max(e,t),i)}var Xs=class Bx extends bn{constructor(t){super(),P(this,"id"),P(this,"type","spacial-content"),P(this,"display"),P(this,"tileWidth"),P(this,"style",{opacity:1}),P(this,"points"),P(this,"service"),P(this,"format","jpg"),P(this,"crop2"),P(this,"tileUrl"),this.tileUrl=mP(t.url),this.id=t.id||`${this.tileUrl}--${t.scaleFactor}`,this.points=t.displayPoints?t.displayPoints:bi(t.points,wi(t.scaleFactor)),this.tileWidth=t.tileWidth,this.display={x:0,y:0,width:t.width/t.scaleFactor,height:t.height/t.scaleFactor,points:t.points,scale:t.scaleFactor},t.format&&(this.format=t.format)}applyProps(t){if(t.style&&typeof t.style.opacity<"u"&&(this.style.opacity=t.style.opacity),t.service!==this.service&&(this.service=t.service),t.format?this.format=t.format:this.format="jpg",t.crop){this.cropData=t.crop;let i=re([...this.points]),n=i.length/5,r=t.crop.x||0,a=t.crop.y||0,l=t.crop.x+t.crop.width,c=t.crop.y+t.crop.height;for(let p=0;p<n;p++){let m=p*5;i[m+1]<l&&i[m+3]>r&&i[m+2]<c&&i[m+4]>a?(i[m+1]=su(i[m+1],r,l),i[m+3]=su(i[m+3],r,l),i[m+2]=su(i[m+2],a,c),i[m+4]=su(i[m+4],a,c)):i[m]=0}Zt(i,ut(-t.crop.x,-t.crop.y)),this.crop?this.crop.set(i):this.crop=i}}static fromTile(t,i,n,r,a,l){n.height=n.height?n.height:n.width;let c=Math.ceil(i.width/r),p=Math.ceil(i.height/r),m=Math.ceil(c/n.width),h=Math.ceil(p/n.height),y=xe.grid(m,h),S=xe.grid(m,h);for(let v=0;v<h;v++)for(let x=0;x<m;x++){let A=x*n.width,C=v*n.height;S.addPoints(A*r,C*r,x===m-1?i.width:(A+n.width)*r,v===h-1?i.height:(C+n.height)*r),y.addPoints(A,C,x===m-1?c:A+n.width,v===h-1?p:C+n.height)}let w=new Bx({url:t,scaleFactor:r,points:y.build(),displayPoints:S.build(),width:i.width,height:i.height,tileWidth:n.width,format:l});return w.applyProps({service:a}),w}getImageUrl(t){let i=this.points.slice(t*5,t*5+5),n=i[3]-i[1],r=i[4]-i[2],a=Math.ceil(n/this.display.scale);return`${this.tileUrl}/${i[1]},${i[2]},${n},${r}/${a>this.tileWidth?this.tileWidth:a},/0/default.${this.format||"jpg"}`}getAllPointsAt(t,i,n){let r=or(this.crop||this.points,t);return[[this,r,i]]}transform(t){Zt(this.points,t)}getScheduledUpdates(t,i){return[]}},gP=class extends bn{constructor(){super(...arguments),P(this,"type","spacial-content")}getAllPointsAt(e,t,i){return[[this,this.points,t]]}},yP=class extends gP{constructor(e){super(),P(this,"id"),P(this,"display"),P(this,"points"),P(this,"images",[]),P(this,"allImages",[]),P(this,"scaleFactors",[]),P(this,"aggregateBuffer",re(9)),P(this,"lazyLoader"),P(this,"isFullyLoaded",!1),P(this,"maxScaleFactor",0),P(this,"renderOptions"),P(this,"_scheduleSortByScales",!1),P(this,"_sortByScales",()=>{this._scheduleSortByScales=!1,this.allImages.sort((i,n)=>n.display.width-i.display.width),this.images=[];let t=.1;for(let i of this.allImages)if(!(i.display.width<this.renderOptions.minSize&&i.display.height<this.renderOptions.minSize&&!i.priority||i instanceof cr&&(i.display.width>this.renderOptions.maxImageSize||i.display.height>this.renderOptions.maxImageSize)&&!i.priority)){if(Math.abs(i.display.scale-t)<.25||i.priority){let n=this.images.pop();n&&(n instanceof cr||n.priority)?(i.priority&&this.images.push(i),this.images.push(n)):i&&this.images.push(i)}else i&&this.images.push(i);t=i.display.scale}this.images.length===0&&(this.images=[...this.allImages]),this.scaleFactors=this.images.map(i=>i.display.scale),this.maxScaleFactor=Math.max(...this.scaleFactors)}),P(this,"loadFullResource",async()=>{if(!this.isFullyLoaded&&this.lazyLoader){this.isFullyLoaded=!0;let t=await this.lazyLoader();this.addImages(t)}}),P(this,"fallback",[this.loadFullResource]),this.id=e.id,this.points=xe.singleBox(e.width,e.height),this.lazyLoader=e.loadFullImages,e.loadFullImages||(this.isFullyLoaded=!0),this.display={x:0,y:0,points:xe.singleBox(e.width,e.height),height:e.height,width:e.width,scale:1},this.renderOptions={renderSmallestFallback:!0,renderLayers:2,minSize:255,maxImageSize:1024,quality:1.75,...e.renderOptions||{}},this.addImages(e.images)}applyProps(e){typeof e.renderSmallestFallback<"u"&&e.renderSmallestFallback!==this.renderOptions.renderSmallestFallback&&(this.renderOptions.renderSmallestFallback=e.renderSmallestFallback),typeof e.renderLayers<"u"&&e.renderLayers!==this.renderOptions.renderLayers&&(this.renderOptions.renderLayers=e.renderLayers),typeof e.minSize<"u"&&e.minSize!==this.renderOptions.minSize&&(this.renderOptions.minSize=e.minSize),typeof e.maxImageSize<"u"&&e.maxImageSize!==this.renderOptions.maxImageSize&&(this.renderOptions.maxImageSize=e.maxImageSize),typeof e.quality<"u"&&e.quality!==this.renderOptions.quality&&(this.renderOptions.quality=e.quality)}appendChild(e){this.addImages([e])}removeChild(e){this.images.indexOf(e)!==-1&&(this.images=this.images.filter(t=>t!==e),this.sortByScales())}insertBefore(e,t){this.addImages([e])}hideInstance(){}addImages(e){for(let t of e)t.__parent=this,t.__owner=this.__owner;this.allImages.push(...e.filter(Boolean)),this.sortByScales()}sortByScales(){this._scheduleSortByScales=!0}getScheduledUpdates(e,t){return this._scheduleSortByScales?[this._sortByScales]:this.isFullyLoaded?[]:t>1/this.maxScaleFactor?this.fallback:[]}getAllPointsAt(e,t,i){if(this.images.length===0)return[];let n=fP(1/(i||1)/(window.devicePixelRatio||1),this.images,this.renderOptions.quality),r=this.images.length,a=t?pi(t,ut(this.x,this.y)):ut(this.x,this.y);if(n!==this.images.length-1&&this.images[n+1]){let l=[];for(let m=r-1;m>=n;m--)l.push(m);let c=l[0];this.renderOptions.renderLayers&&(l=l.slice(-Math.min(l.length,this.renderOptions.renderLayers))),this.renderOptions.renderSmallestFallback&&l.indexOf(c)===-1&&l.unshift(c);let p=[];for(let m=0;m<l.length;m++)p.push(...this.images[l[m]].getAllPointsAt(e,a,i));return p}return this.images[n].getAllPointsAt(e,a,i)}};function au(e,t,i,n,r){let a=Math.PI/180*r,l=Math.cos(a),c=Math.sin(a),p=l*(i-e)+c*(n-t)+e,m=l*(n-t)-c*(i-e)+t;return[p,m]}var Op=class Dx extends bn{constructor(t,i){super(),P(this,"id"),P(this,"type","world-object"),P(this,"scale"),P(this,"layers"),P(this,"points"),P(this,"worldPoints"),P(this,"intersectionBuffer",re(5)),P(this,"aggregateBuffer",re(9)),P(this,"invertedBuffer",re(9)),P(this,"rotation",0),P(this,"filteredPointsBuffer"),P(this,"_updatedList",[]),P(this,"geometry");let{x:n=0,y:r=0}=i||{};t?(this.id=t.id||"",this.scale=1,this.layers=t.layers,this.points=re([1,n,r,n+t.width,r+t.height]),this.worldPoints=re([1,n,r,n+t.width,r+t.height]),this.filteredPointsBuffer=re(t.layers.length*5)):(this.id="",this.scale=1,this.layers=[],this.points=re(5),this.worldPoints=re(5),this.filteredPointsBuffer=re(5))}static createWithProps(t){let i=new Dx;return i.applyProps(t),i}applyProps(t){let i=t.x||0,n=t.y||0;this.id=t.id;let r=typeof t.scale<"u"?t.scale:this.scale;this.points[0]=1,this.points[1]=i,this.points[2]=n,this.points[3]=i+t.width,this.points[4]=n+t.height,this.rotation=t.rotation||0,this.worldPoints[3]=this.worldPoints[1]+t.width,this.worldPoints[4]=this.worldPoints[2]+t.height,t.scale&&t.scale!==1&&this.atScale(r),this.scale=r}appendChild(t){t.points[0]===0&&t.points.set(this.points),t.__owner.value=this,this.addLayers([t])}removeChild(t){this.layers=this.layers.filter(i=>i!==t),this.filteredPointsBuffer=re(this.layers.length*5)}insertBefore(t,i){let n=this.layers.indexOf(i);if(n===-1||this.layers.indexOf(t)!==-1)return;let r=this.layers.slice(0,n),a=this.layers.slice(n);this.layers=[...r,t,...a]}hideInstance(){console.warn("hideInstance: not yet implemented")}getObjectsAt(t,i){if(this.rotation&&(t=this.applyRotation(t)),or(this.points,t,this.filteredPointsBuffer)[0]===0)return[];let n=this.layers.length,r=[];for(let a=0;a<n;a++){let l=this.layers[a];if(i&&l.isShape){let c=bi(l.points,ut(this.x,this.y));if(!l.intersects([t[1]-c[1],t[2]-c[2]]))continue}if(or(bi(l.points,ut(this.x,this.y)),t,this.filteredPointsBuffer)[0]!==0&&r.push(l),i){let c=l;r.push(...c.getObjectsAt(t,i))}}return r}applyRotation(t){if(this.rotation){let i={x:t[1],y:t[2]},n={x:t[1],y:t[4]},r={x:t[3],y:t[2]},a={x:t[3],y:t[4]},l=this.points[1]+(this.points[3]-this.points[1])/2,c=this.points[2]+(this.points[4]-this.points[2])/2,[p,m]=au(l,c,i.x,i.y,this.rotation),[h,y]=au(l,c,n.x,n.y,this.rotation),[S,w]=au(l,c,r.x,r.y,this.rotation),[v,x]=au(l,c,a.x,a.y,this.rotation),A=Math.min(p,h,S,v),C=Math.max(p,h,S,v),I=Math.min(m,y,w,x),E=Math.max(m,y,w,x);return re([t[0],A,I,C,E])}return t}getAllPointsAt(t,i,n){let r=pi(ut(this.x,this.y),wi(this.scale),this.aggregateBuffer);this.rotation&&(t=this.applyRotation(t));let a=ky(t,this.points,this.intersectionBuffer),l=this.layers.length,c=[],p=bi(a,pi(wi(1/this.scale),ut(-this.x,-this.y),this.invertedBuffer)),m=i?pi(i,r,this.aggregateBuffer):r,h=n*this.scale;for(let y=0;y<l;y++)c.push(...this.layers[y].getAllPointsAt(p,m,h));return c}addLayers(t){let i=[];for(let n of t)this.layers.indexOf(n)===-1&&(i.push(n),n.points.length===5&&(n.points[1]<this.worldPoints[1]/this.scale||n.points[2]<this.worldPoints[2]/this.scale||n.points[3]>this.worldPoints[3]/this.scale||n.points[4]>this.worldPoints[4]/this.scale)&&(n.crop=n.crop||re([1,Math.max(this.worldPoints[1]/this.scale,n.points[1]),Math.max(this.worldPoints[2]/this.scale,n.points[2]),Math.min(this.worldPoints[3]/this.scale,n.points[3]),Math.min(this.worldPoints[4]/this.scale,n.points[4])])));this.layers=this.layers.concat(i),this.filteredPointsBuffer=re(this.layers.length*5)}getScheduledUpdates(t,i){let n=this.layers.length;this._updatedList=[];let r=i*this.scale;for(let a=0;a<n;a++){let l=this.layers[a].getScheduledUpdates(t,r);l&&this._updatedList.push(...l)}return this._updatedList}},Pu=class jx extends bn{constructor(t=0,i=0,n=100,r="left-to-right"){super(),P(this,"id","world"),P(this,"_width"),P(this,"_height"),P(this,"aspectRatio"),P(this,"viewingDirection"),P(this,"aggregateBuffer",re(9)),P(this,"isDirty",!1),P(this,"zones",[]),P(this,"filteredPointsBuffer"),P(this,"selectedZone"),P(this,"triggerQueue",[]),P(this,"activatedEvents",[]),P(this,"_updatedList",[]),P(this,"translationBuffer",re(9)),P(this,"needsRecalculate",!0),P(this,"emptyPaintables",[]),P(this,"renderOrder",[]),P(this,"points"),P(this,"objects",[]),P(this,"subscriptions",[]),P(this,"_propagateEventTargets",[]),P(this,"_alreadyFlushed",[]),this._width=t,this._height=i,this.aspectRatio=Number.isNaN(t/i)?1:t/i,this.viewingDirection=r,this.points=re(n*5),this.filteredPointsBuffer=re(n*5)}get x(){return 0}get y(){return 0}get width(){return this._width}get height(){return this._height}static withProps(t){let i=new jx;return i.applyProps(t),i}applyProps(t){typeof t.width<"u"&&typeof t.height<"u"&&(t.width!==this._width||t.height!==this._height)&&this.resize(t.width,t.height),t.viewingDirection!==this.viewingDirection&&(this.viewingDirection=t.viewingDirection,this.triggerRepaint())}propagateTouchEvent(t,i,n){let r=[];for(let a of n)if(a.x&&a.y){let l=xe.singleBox(1,1,a.x,a.y);r.push(this.getObjectsAt(l,!0).reverse())}return r.map(a=>this.propagateEvent(t,i,a,{bubbles:!0,cancelable:!0}))}propagatePointerEvent(t,i,n,r,a={}){let l=xe.singleBox(1,1,n,r),c=this.getObjectsAt(l,!0).reverse();return this.propagateEvent(t,i,c,a)}propagateEvent(t,i,n,{bubbles:r=!1,cancelable:a=!1}={}){i.atlasTarget=this,this._propagateEventTargets.length=1,this._propagateEventTargets[0]=this;let l=!1;i.stopPropagation=()=>{l=!0};let c=n.length;for(let h=c-1;h>=0;h--){this._propagateEventTargets.unshift(n[h][0]);let y=n[h][1].length;if(y)for(let S=0;S<y;S++)this._propagateEventTargets.unshift(n[h][1][S])}let p=this._propagateEventTargets.length,m=!1;for(let h=0;h<p&&(i.atlasTarget=this._propagateEventTargets[h],i.atlasWorld=this,m=this._propagateEventTargets[h].dispatchEvent(t,i)||m,!l);h++);return m&&this.triggerRepaint(),this._propagateEventTargets}appendChild(t){let i=this.appendWorldObject(t);this.renderOrder.push(i/5)}removeChild(t){let i=this.objects.indexOf(t);if(i===-1){for(let n of this.objects)if(n&&n.id===t.id){this.removeChild(n);return}return}this.objects[i]=null,this.renderOrder=this.renderOrder.filter(n=>n!==i),this.points[i*5]=0,this.triggerRepaint(),this.needsRecalculate=!0}insertBefore(t,i){let n=this.objects.indexOf(i);if(n===-1)return;let r=this.appendWorldObject(t);this.renderOrder.splice(n-1,0,r/5)}hideInstance(){}asWorldObject(){return null}addZone(t){this.zones.push(t)}selectZone(t){if(typeof t=="string"){let i=this.zones.length;for(let n=0;n<i;n++)if(this.zones[n].id===t){this.selectedZone=n,this.trigger("zone-changed");return}}else this.zones[t]&&(this.selectedZone=t,this.trigger("zone-changed"))}deselectZone(){this.selectedZone=void 0}getActiveZone(){if(this.selectedZone)return this.zones[this.selectedZone]}hasActiveZone(){return typeof this.selectedZone<"u"}checkResizeInternalBuffer(){if(Oy(this.points)===this.objects.length){let t=this.points,i=re(this.points.length*2);i.set(t,0),this.points=i}}appendWorldObject(t){this.checkResizeInternalBuffer();let i=this.objects.length*5,n=t.points;return t.points=this.points.subarray(this.objects.length*5,this.objects.length*5+5),t.points[1]=n[1],t.points[2]=n[2],t.points[3]=n[3],t.points[4]=n[4],this.objects.push(t),this.filteredPointsBuffer=re(this.objects.length*5),this.needsRecalculate=!0,this.triggerRepaint(),i}recalculateWorldSize(){let t=!1;if(this.needsRecalculate){let i=new Int32Array(this.objects.length),n=new Int32Array(this.objects.length),r=this.renderOrder.length;for(let c=0;c<r;c++){let p=this.renderOrder[c];this.objects[p]&&(i[c]=this.points[p*5+3],n[c]=this.points[p*5+4])}let a=Math.max(...i);a!==this._width&&(this._width=a,t=!0);let l=Math.max(...n);l!==this._height&&(this._height=l,t=!0),t&&this.trigger("recalculate-world-size",{width:a,height:l}),this.needsRecalculate=!1}return t}addObjectAt(t,i){i.width&&!i.height?i.height=i.width/t.width*t.height:i.height&&!i.width&&(i.width=i.height/t.height*t.width),(!i||!i.width||!i.height)&&(i.width=t.width,i.height=t.height);let{width:n,x:r,y:a}=i,l=n/t.width;this.checkResizeInternalBuffer(),this.points.set(xe.singleBox(t.width,t.height,0,0),this.objects.length*5);let c=new Op(t);return c.points=this.points.subarray(this.objects.length*5,this.objects.length*5+5),this.objects.push(c),this.scaleWorldObject(this.objects.length-1,l),this.translateWorldObject(this.objects.length-1,r,a),this.filteredPointsBuffer=re(this.points.length*2),this.triggerRepaint(),this.needsRecalculate=!0,c}scaleWorldObject(t,i){Zt(this.points.subarray(t*5,t*5+5),On(i,this.points[t*5+1],this.points[t*5+2]));let n=this.objects[t];n&&(n.atScale(i),this.triggerRepaint())}translateWorldObject(t,i,n){Zt(this.points.subarray(t*5,t*5+5),ut(i,n));let r=this.objects[t];r&&(r.translate(i,n),this.triggerRepaint())}resize(t,i){return this._width=t,this._height=i,this.aspectRatio=t/i,this.triggerRepaint(),this}getObjects(){return this.objects}getPoints(){return this.points}getPointsFromViewer(t,i){let n=xe.singleBox(t.width,t.height,t.x,t.y);return this.getPointsAt(n,i,t.scale)}addLayoutSubscriber(t){return this.subscriptions.push(t),()=>{this.subscriptions.splice(this.subscriptions.indexOf(t),1)}}getScheduledUpdates(t,i){let n=or(this.points,t,this.filteredPointsBuffer),r=this.objects.length;this._updatedList=[];for(let a=0;a<r;a++)if(n[a*5]!==0){if(!this.objects[a])continue;this._updatedList.push(...this.objects[a].getScheduledUpdates(t,i))}return this._updatedList}getObjectsAt(t,i=!1){let n=this.getActiveZone(),r=or(this.points,t,this.filteredPointsBuffer),a=this.renderOrder.length,l=[];for(let c=0;c<a;c++){let p=this.renderOrder[c];if(r[p*5]!==0){let m=this.objects[p];if(!m||n&&n.objects.indexOf(m)===-1)continue;if(m.type!=="world-object"){l.push([m,[m]]);continue}i?l.push([m,m.getObjectsAt(t,i)]):l.push([m,this.emptyPaintables])}}return l}getPointsAt(t,i,n=1){let r=this.getObjectsAt(t),a=pi(wi(n),ut(-t[1],-t[2]),this.translationBuffer),l=i?pi(i,a,this.aggregateBuffer):a,c=r.length,p=[];for(let m=0;m<c;m++)r[m]&&p.push(...r[m][0].getAllPointsAt(t,l,n));return p}flushSubscriptions(){if(this.triggerQueue.length){this._alreadyFlushed=[];let t=this.triggerQueue.length;for(let i=0;i<t;i++){if(this._alreadyFlushed.indexOf(this.triggerQueue[i][0])!==-1)continue;typeof this.triggerQueue[i][1]>"u"&&this._alreadyFlushed.push(this.triggerQueue[i][0]);let n=this.subscriptions.length;for(let r=0;r<n;r++)this.subscriptions[r].apply(null,this.triggerQueue[i])}this.triggerQueue=[]}}trigger(t,i){this.triggerQueue.push([t,i])}triggerEventActivation(){this.trigger("event-activation")}triggerRepaint(){this.trigger("repaint")}gotoRegion(t){this.trigger("goto-region",t)}goHome(t=!1){this.trigger("go-home",{immediate:t})}zoomTo(t,i,n){this.trigger("zoom-to",{point:i,factor:t,stream:n})}zoomIn(t){this.trigger("zoom-to",{point:t,factor:.5})}zoomOut(t){this.trigger("zoom-to",{point:t,factor:2})}constraintBounds(t){this.trigger("constrain-bounds",{immediate:t})}};var lu=/([0-9]+(px|em)\s+)+(solid)\s+(.*)/g,uu={},vP=["backgroundColor","opacity","boxShadow","borderColor","borderWidth","borderStyle","outlineColor","outlineWidth","outlineOffset","outlineStyle"],Qs=class extends bn{constructor(){super(),P(this,"id"),P(this,"type","spacial-content"),P(this,"points"),P(this,"hoverEvents",!1),P(this,"activeEvents",!1),P(this,"display",{x:0,y:0,scale:1,width:-1,height:-1,points:re(5)}),P(this,"_parsed",{border:{id:null,match:[]},outline:{id:null,match:[]}}),P(this,"hovering"),P(this,"pressing"),P(this,"props",{}),P(this,"addHover",()=>{this.hovering=!0,this.__revision++}),P(this,"removeHover",()=>{this.hovering=!1,this.pressing=!1,this.__revision++}),P(this,"addPress",()=>{this.pressing=!0,this.__revision++}),P(this,"removePress",()=>{this.pressing=!1,this.__revision++}),this.id=Cu(12),this.points=re(5)}getAllPointsAt(e,t){return[[this,this.points,t]]}applyProps(e={}){let t=!1;if(e.interactive!==this.props.interactive&&(t=!0,this.props.interactive=e.interactive),e.style){let i=e.border||e.style.border;if(i!==this._parsed.border.id)if(!i)this._parsed.border.id=null,this._parsed.border.match=[];else{let n=uu[i]||lu.exec(i)||lu.exec(i);n&&(this._parsed.border.id=i,this._parsed.border.match=uu[i]=n)}if(this._parsed.border.id&&(e.style.borderWidth=this._parsed.border.match[1],e.style.borderStyle="solid",e.style.borderColor=this._parsed.border.match[4]),e.style.outline!==this._parsed.outline.id)if(!e.style.outline)this._parsed.outline.id=null,this._parsed.outline.match=[];else{let n=uu[e.style.outline]||lu.exec(e.style.outline)||lu.exec(e.style.outline);n&&(this._parsed.outline.id=e.style.outline,this._parsed.outline.match=uu[e.style.outline]=n)}this._parsed.outline.id&&(e.style.outlineWidth=this._parsed.outline.match[1],e.style.outlineStyle="solid",e.style.outlineColor=this._parsed.outline.match[4]),this.props.style=e.style,e.backgroundColor&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=e.backgroundColor,t=!0),e.style.background&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=e.style.background,t=!0);for(let n of vP)if(this.props.style[n]!==e.style[n]){t=!0;break}e.style[":hover"]!==this.props.hoverStyles&&(this.props.hoverStyles=e.style[":hover"],this.hoverEvents||(this.hoverEvents=!0,this.addEventListener("pointerenter",this.addHover),this.addEventListener("pointerleave",this.removeHover)),t=!0),e.style[":active"]!==this.props.pressStyles&&(this.props.pressStyles=e.style[":active"],this.activeEvents||(this.activeEvents=!0,this.addEventListener("mousedown",this.addPress),this.addEventListener("mouseup",this.removePress)),t=!0)}e.href!==this.props.href&&(this.props.href=e.href,t=!0),e.hrefTarget!==this.props.hrefTarget&&(this.props.hrefTarget=e.hrefTarget,t=!0),e.title!==this.props.title&&(this.props.title=e.title,t=!0),e.className!==this.props.className&&(this.props.className=e.className,e.className&&!this.hoverEvents&&(this.hoverEvents=!0,this.addEventListener("pointerenter",this.addHover),this.addEventListener("pointerleave",this.removeHover)),e.className&&!this.activeEvents&&(this.activeEvents=!0,this.addEventListener("mousedown",this.addPress),this.addEventListener("mouseup",this.removePress)),t=!0),e.relativeSize!==this.props.relativeSize&&(this.props.relativeSize=e.relativeSize,t=!0),e.relativeStyle!==this.props.relativeStyle&&(this.props.relativeStyle=e.relativeStyle,t=!0),e.html!==this.props.html&&(this.props.html=e.html,t=!0),e.target&&(e.target.width!==this.display.width||e.target.height!==this.display.height||e.target.x!==this.points[1]||e.target.y!==this.points[2])&&(t=!0,this.points=xe.singleBox(e.target.width,e.target.height,e.target.x,e.target.y),this.display.points=xe.singleBox(e.target.width,e.target.height,e.target.x,e.target.y),this.display.width=e.target.width,this.display.height=e.target.height),t&&this.__revision++}},gu=class extends bn{constructor(){super(),P(this,"type","spacial-content"),P(this,"id"),P(this,"points"),P(this,"color","#000"),P(this,"backgroundColor"),P(this,"hovering"),P(this,"pressing"),P(this,"text",""),P(this,"display",{x:0,y:0,scale:1,width:100,height:100,points:re(5)}),P(this,"className"),P(this,"html"),P(this,"interactive",!1),P(this,"props",{font:"18px Arial, sans-serif",lineHeight:1,textAlign:"left",verticalAlign:"top",paddingX:0,paddingY:0,fitParent:!1,lineBreak:"auto",strokeText:!1,sizeToFill:!1,maxFontSizeToFill:void 0,allowNewLine:!0,justifyLines:!1,renderHDPI:!1,textDecoration:"none",interactive:!1,relativeSize:!1}),this.id="",this.points=re(5)}getAllPointsAt(e,t){return[[this,this.points,t]]}applyProps({id:e,target:t,text:i,color:n,backgroundColor:r,fontSize:a=18,interactive:l,fontFamily:c="Arial, sans-serif",...p}){p.font=`${a}px ${c}`,this.interactive=l||!1,typeof i<"u"&&(this.text=i||""),n&&(this.color=n),r&&(this.backgroundColor=r),e&&(this.id=e),t&&(this.points=xe.singleBox(t.width,t.height,t.x,t.y),this.display.points=this.points,this.display.width=t.width,this.display.height=t.height),this.props={...this.props,...p},this.__revision++}},ct=Math.pow,cu=Math.sqrt,Hs=Math.sin,Px=Math.cos,$s=Math.PI,xu=1.70158,du=xu*1.525,Ex=xu+1,Ax=2*$s/3,Ix=2*$s/4.5,hu=function(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},ur={linear:e=>e,easeInQuad:function(e){return e*e},easeOutQuad:function(e){return 1-(1-e)*(1-e)},easeInOutQuad:function(e){return e<.5?2*e*e:1-ct(-2*e+2,2)/2},easeInCubic:function(e){return e*e*e},easeOutCubic:function(e){return 1-ct(1-e,3)},easeInOutCubic:function(e){return e<.5?4*e*e*e:1-ct(-2*e+2,3)/2},easeInQuart:function(e){return e*e*e*e},easeOutQuart:function(e){return 1-ct(1-e,4)},easeInOutQuart:function(e){return e<.5?8*e*e*e*e:1-ct(-2*e+2,4)/2},easeInQuint:function(e){return e*e*e*e*e},easeOutQuint:function(e){return 1-ct(1-e,5)},easeInOutQuint:function(e){return e<.5?16*e*e*e*e*e:1-ct(-2*e+2,5)/2},easeInSine:function(e){return 1-Px(e*$s/2)},easeOutSine:function(e){return Hs(e*$s/2)},easeInOutSine:function(e){return-(Px($s*e)-1)/2},easeInExpo:function(e){return e===0?0:ct(2,10*e-10)},easeOutExpo:function(e){return e===1?1:1-ct(2,-10*e)},easeInOutExpo:function(e){return e===0?0:e===1?1:e<.5?ct(2,20*e-10)/2:(2-ct(2,-20*e+10))/2},easeInCirc:function(e){return 1-cu(1-ct(e,2))},easeOutCirc:function(e){return cu(1-ct(e-1,2))},easeInOutCirc:function(e){return e<.5?(1-cu(1-ct(2*e,2)))/2:(cu(1-ct(-2*e+2,2))+1)/2},easeInBack:function(e){return Ex*e*e*e-xu*e*e},easeOutBack:function(e){return 1+Ex*ct(e-1,3)+xu*ct(e-1,2)},easeInOutBack:function(e){return e<.5?ct(2*e,2)*((du+1)*2*e-du)/2:(ct(2*e-2,2)*((du+1)*(e*2-2)+du)+2)/2},easeInElastic:function(e){return e===0?0:e===1?1:-ct(2,10*e-10)*Hs((e*10-10.75)*Ax)},easeOutElastic:function(e){return e===0?0:e===1?1:ct(2,-10*e)*Hs((e*10-.75)*Ax)+1},easeInOutElastic:function(e){return e===0?0:e===1?1:e<.5?-(ct(2,20*e-10)*Hs((20*e-11.125)*Ix))/2:ct(2,-20*e+10)*Hs((20*e-11.125)*Ix)/2+1},easeInBounce:function(e){return 1-hu(1-e)},easeOutBounce:hu,easeInOutBounce:function(e){return e<.5?(1-hu(1-2*e))/2:(1+hu(2*e-1))/2}},xP=class{constructor(e){P(this,"runtime"),P(this,"pendingTransition"),this.runtime=e,this.pendingTransition={from:re(5),to:re(5),elapsed_time:0,done:!0,total_time:0,timingFunction:ur.easeInOutQuad,constrain:!1}}hasPending(){return!this.pendingTransition.done}getPendingTransition(){return this.pendingTransition}getPendingFrom(){return this.pendingTransition.from}customTransition(e){e(this.pendingTransition)}stopTransition(){this.pendingTransition.from=re(this.runtime.target),this.pendingTransition.to=re(this.runtime.target),this.pendingTransition.done=!0,this.pendingTransition.elapsed_time=0,this.pendingTransition.total_time=0}runTransition(e,t){if(!this.pendingTransition.done){let i=this.pendingTransition,n=i.total_time===0?0:(i.elapsed_time+t)/i.total_time,r=i.total_time===0?1:n===0?0:i.timingFunction(n);e[1]=i.from[1]+(i.to[1]-i.from[1])*r,e[2]=i.from[2]+(i.to[2]-i.from[2])*r,e[3]=i.from[3]+(i.to[3]-i.from[3])*r,e[4]=i.from[4]+(i.to[4]-i.from[4])*r,this.pendingTransition.elapsed_time+=t,this.pendingTransition.elapsed_time>=this.pendingTransition.total_time&&(this.pendingTransition.done=!0,this.pendingTransition.constrain&&this.constrainBounds({transition:{duration:this.pendingTransition.total_time===0?0:500,easing:ur.easeOutExpo}}))}}zoomTo(e,{origin:t,stream:i=!1,transition:n}={}){let r=this.runtime.getZoomedPosition(e,{origin:t}),a=Math.abs(1-e);this.applyTransition(r,n,{duration:2e3*a,easing:ur.easeOutExpo,constrain:!0},{stream:!1})}constrainBounds({transition:e,panPadding:t=0}={}){let[i,n]=this.runtime.constrainBounds(this.runtime.target,{panPadding:t});i&&(this.applyTransition(n,e,{duration:500,easing:ur.easeOutQuart,constrain:!1}),this.runtime.updateNextFrame())}applyTransition(e,t,i,{stream:n}={}){this.pendingTransition.from=re(this.runtime.target),this.pendingTransition.to=e,n||(this.pendingTransition.elapsed_time=0),this.pendingTransition.done=!1,this.pendingTransition.total_time=typeof t?.duration<"u"?t.duration:typeof i?.duration<"u"?i.duration:1e3,this.pendingTransition.constrain=typeof t?.constrain<"u"?t.constrain:typeof i?.constrain<"u"?i.constrain:!1,this.pendingTransition.timingFunction=t?.easing||i?.easing||ur.easeInOutSine}goToRegion(e,{transition:t}={}){let i=this.runtime.clampRegion(e);this.applyTransition(xe.singleBox(i.width,i.height,i.x,i.y),t,{duration:1e3,easing:ur.easeOutExpo,constrain:!0}),this.runtime.updateNextFrame()}},c_=Number.MIN_VALUE+1,Eu=class{constructor(e,t,i,n=[],r){P(this,"id",Cu()),P(this,"ready",!1),P(this,"renderer"),P(this,"world"),P(this,"target"),P(this,"homePosition"),P(this,"manualHomePosition"),P(this,"manualFocalPosition"),P(this,"focalPosition"),P(this,"transitionManager"),P(this,"aggregate"),P(this,"transformBuffer",re(500)),P(this,"lastTarget",re(5)),P(this,"zoomBuffer",re(5)),P(this,"logNextRender",!1),P(this,"pendingUpdate",!0),P(this,"isCommitting",!1),P(this,"firstRender",!0),P(this,"lastTime"),P(this,"stopId"),P(this,"mode","explore"),P(this,"controllers",[]),P(this,"controllersRunning",!1),P(this,"controllerStopFunctions",[]),P(this,"maxScaleFactor",1),P(this,"_viewerToWorld",{x:0,y:0}),P(this,"_lastGoodScale",1),P(this,"hooks",{useFrame:[],useBeforeFrame:[],useAfterPaint:[],useAfterFrame:[]}),P(this,"fpsLimit"),P(this,"options"),P(this,"hookOptions",{filters:{grayscale:0,contrast:0,brightness:0,saturate:0,sepia:0,invert:0,hueRotate:0,blur:0}}),P(this,"_viewport",{x:0,y:0,width:0,height:0}),P(this,"setViewport",a=>{let l=Math.round(typeof a.x>"u"?this.target[1]:a.x),c=Math.round(typeof a.y>"u"?this.target[2]:a.y);a.width?this.target[3]=l+a.width:this.target[3]=this.target[3]-this.target[1]+l,a.height?this.target[4]=c+a.height:this.target[4]=this.target[4]-this.target[2]+c,Math.abs(this.target[1]-l)>.01&&(this.target[1]=l),Math.abs(this.target[2]-c)>.01&&(this.target[2]=c),this.pendingUpdate=!0}),P(this,"render",a=>{let l=a-this.lastTime;if(this.isCommitting||this.fpsLimit&&l<1e3/this.fpsLimit){this.stopId=window.requestAnimationFrame(this.render);return}this.lastTime=a,this.world.flushSubscriptions(),this.stopId=window.requestAnimationFrame(this.render),this.hook("useFrame",l);let c=this.pendingUpdate,p=this.renderer.pendingUpdate();if(this.transitionManager.hasPending()&&(this.transitionManager.runTransition(this.target,l),this.pendingUpdate=!0,this.updateControllerPosition()),!this.firstRender&&!c&&!p&&this.target[0]===this.lastTarget[0]&&this.target[1]===this.lastTarget[1]&&this.target[2]===this.lastTarget[2]&&this.target[3]===this.lastTarget[3]&&this.target[4]===this.lastTarget[4])return;this.hook("useBeforeFrame",l),this.renderer.beforeFrame(this.world,l,this.target,this.hookOptions);let m=this.getScaleFactor(),h=this.renderer.getPointsAt(this.world,this.target,this.aggregate,m),y=h.length;for(let v=0;v<y;v++){let x=h[v][0],A=h[v][1],C=h[v][2],I=C?bi(A,C,this.transformBuffer):A;this.renderer.prepareLayer(x,x.__parent&&C?bi(x.__parent.crop||x.__parent.points,C):I);let E=I.length/5;for(let L=0;L<E;L++){let z=L*5;I[z]!==0&&(this.renderer.paint(x,L,I[z+1],I[z+2],I[z+3]-I[z+1],I[z+4]-I[z+2]),this.hook("useAfterPaint",x))}this.renderer.finishLayer(x,A)}this.renderer.afterFrame(this.world,l,this.target,this.hookOptions),this.hook("useAfterFrame",l),this.lastTarget[0]=this.target[0],this.lastTarget[1]=this.target[1],this.lastTarget[2]=this.target[2],this.lastTarget[3]=this.target[3],this.lastTarget[4]=this.target[4],this.firstRender=!1,this.pendingUpdate=!1,this.logNextRender=!1,this.renderer.isReady()&&(this.ready=!0,this.world.trigger("ready")),this.world.flushSubscriptions();let S=this.world.getScheduledUpdates(this.target,m),w=S.length;if(w>0)for(let v=0;v<w;v++){let x=S[w-v-1]();x?x.then(()=>{this.pendingUpdate=!0}):this.pendingUpdate=!0}}),this.renderer=e,this.world=t,this.options={maxOverZoom:1,maxUnderZoom:1,visibilityRatio:1.5,...r||{}},this.target=xe.projection(i),this.manualHomePosition=!1,this.pendingUpdate=!0,this.homePosition=xe.projection(this.world),this.manualFocalPosition=!1,this.focalPosition=this.target,this.updateFocalPosition(),this.transitionManager=new xP(this),this.aggregate=wi(1),this.world.addLayoutSubscriber(a=>{a==="repaint"&&(this.pendingUpdate=!0),a==="recalculate-world-size"&&(this.manualHomePosition||(this.setHomePosition(),this.goHome()),this.updateFocalPosition())}),this.lastTime=performance.now(),this.controllers=n,this.render(this.lastTime),this.startControllers()}get x(){return this.target[1]}set x(e){this.target[1]=e}get y(){return this.target[2]}set y(e){this.target[2]=e}get x2(){return this.target[3]}set x2(e){this.target[3]=e}get y2(){return this.target[4]}set y2(e){this.target[4]=e}get width(){return this.target[3]-this.target[1]}set width(e){this.target[3]=this.target[1]+e}get height(){return this.target[4]-this.target[2]}set height(e){this.target[4]=this.target[2]=e}setHomePosition(e){this.homePosition.set(xe.projection(e||this.world)),this.pendingUpdate=!0}startControllers(){if(!this.controllersRunning){for(let e of this.controllers)this.controllerStopFunctions.push(e.start(this));this.controllersRunning=!0}}stopControllers(){if(this.controllersRunning){for(let e of this.controllerStopFunctions)e();this.controllersRunning=!1,this.controllerStopFunctions=[]}}updateControllerPosition(){for(let e of this.controllers)e.updatePosition(this.x,this.y,this.width,this.height)}triggerResize(){this.renderer.triggerResize&&this.renderer.triggerResize(),this.pendingUpdate=!0}addController(e){this.controllers.push(e),this.controllersRunning&&e.start(this),this.pendingUpdate=!0}cover(){return this.goHome({cover:!0})}getRendererScreenPosition(){return this.renderer.getRendererScreenPosition()}updateRendererScreenPosition(){this.pendingUpdate=!0,this.renderer.resize()}setOptions(e){this.options={...this.options,...e}}goHome(e={}){if(this.world.width<=0||this.world.height<=0)return;let t=this.getScaleFactor(),i=e.position?{x:e.position[1],y:e.position[2],width:e.position[3]-e.position[1],height:e.position[4]-e.position[2]}:{x:this.homePosition[1],y:this.homePosition[2],width:this.homePosition[3]-this.homePosition[1],height:this.homePosition[4]-this.homePosition[2]},n=this.width*t,r=this.height*t,a=i.width/n,l=i.height/r,c=n/r;if(e.cover?a>l:a<l){let p=c*i.height,m=(p-i.width)/2;this.target[1]=Math.round(-m+i.x),this.target[2]=Math.round(i.y),this.target[3]=Math.round(p-m+i.x),this.target[4]=Math.round(i.height+i.y)}else{let p=i.width/c,m=(p-i.height)/2;this.target[1]=Math.round(i.x),this.target[2]=Math.round(i.y-m),this.target[3]=Math.round(i.x+i.width),this.target[4]=Math.round(i.y+p-m)}this.constrainBounds(this.target),this.updateControllerPosition()}resize(e,t,i,n){this.updateFocalPosition(e-t,i-n);let r=t/e,a=n/i;this.target[3]=this.target[1]+(this.target[3]-this.target[1])*r,this.target[4]=this.target[2]+(this.target[4]-this.target[2])*a,this.goHome({position:this.focalPosition}),this.renderer.resize(t,n),this.pendingUpdate=!0}updateFocalPosition(e,t){if(!this.manualFocalPosition){let i=this.width,n=this.height,r=Math.min(i,n),a=0,l=0,c=this.x+a,p=this.y+l;if(i<n){let m=this.height-this.width;this.focalPosition=xe.projection({x:c,y:p+m/2,width:r-a*2,height:r-l*2}),this.pendingUpdate=!0}else{let m=this.width-this.height;this.focalPosition=xe.projection({x:c+m/2,y:p,width:r-a*2,height:r-l*2}),this.pendingUpdate=!0}}}getViewport(){return this._viewport.x=this.target[1],this._viewport.y=this.target[2],this._viewport.width=this.target[3]-this.target[1],this._viewport.height=this.target[4]-this.target[2],this._viewport}constrainBounds(e,{panPadding:t=0,ref:i=!1}={}){let{minX:n,maxX:r,minY:a,maxY:l}=this.getBounds({target:e,padding:t}),c=!1,p=i?e:re(e),m=Math.round(e[3]-e[1]),h=Math.round(e[4]-e[2]);return n>e[1]&&(c=!0,p[1]=n,p[3]=n+m),a>e[2]&&(c=!0,p[2]=a,p[4]=a+h),r<e[1]&&(c=!0,p[1]=r,p[3]=r+m),l<e[2]&&(c=!0,p[2]=l,p[4]=l+h),[c,p]}getBounds(e){let t=e.target||this.target,i=e.padding,n=this.options.visibilityRatio,r=Math.abs(1-n);if(this.world.hasActiveZone()){let C=this.world.getActiveZone();if(C){let I=t[3]-t[1]<C.points[3]-C.points[1],E=t[4]-t[2]<C.points[4]-C.points[2];return{minX:I?C.points[1]-i:C.points[1]+(C.points[3]-C.points[1])/2-(t[3]-t[1])/2,maxX:E?C.points[2]-i:C.points[2]+(C.points[4]-C.points[2])/2-(t[4]-t[2])/2,minY:I?C.points[3]+i:C.points[1]+(C.points[3]-C.points[1])/2-(t[3]-t[1])/2,maxY:E?C.points[4]+i:C.points[2]+(C.points[4]-C.points[2])/2-(t[4]-t[2])/2}}}let a=t[3]-t[1],l=this.world.width,c=-a*r,p=l-a-c,m=t[4]-t[2],h=this.world.height,y=-m*r,S=h-m-y,w=Math.round(Math.max(c,p)),v=Math.round(Math.min(c,p)),x=Math.round(Math.max(y,S)),A=Math.round(Math.min(y,S));return{minX:v,maxX:w,minY:A,maxY:x}}getScaleFactor(e=!1){let t=this.renderer.getScale(this.target[3]-this.target[1],this.target[4]-this.target[2],e);return t===0?this._lastGoodScale:(this._lastGoodScale=t,t)}getZoomedPosition(e,{origin:t,fromPos:i}){let n=i?{width:i[3]-i[1],height:i[4]-i[2]}:void 0,r=n?this.renderer.getScale(n.width,n.height):this.getScaleFactor(),a=n?n.width:this.width,l=n?n.height:this.height,c=this.getRendererScreenPosition()?.width,p=this.world.width,m=c?c/p:1,h=this.options.maxUnderZoom,y=Math.max(m||1,this.options.maxOverZoom),S=1/e,w=r*S;if(S<1){let x=a*r,A=l*r,C=this.world.width/x,I=this.world.height/A;if(C>I){let E=this.world.width*w,L=~~(a*r)*h;E<L&&(e=this.world.width*r/(a*r*h))}else{let E=this.world.height*w,L=~~(l*r)*h;E<L&&(e=this.world.height*r/(l*r*h))}}else w>y&&(e=r/y);let v=bi(this.target,On(e,t?t.x:this.target[1]+(this.target[3]-this.target[1])/2,t?t.y:this.target[2]+(this.target[4]-this.target[2])/2),this.zoomBuffer);return this.constrainBounds(v,{ref:!0,panPadding:100}),v}clampRegion({x:e,y:t,width:i,height:n,padding:r=0}){let a=this.width,l=this.height,c=i/a<n/l,p=e-r,m=t-r,h=i+r*2,y=n+r*2;if(c){let w=y/l*a;return{x:p-(w-h)/2,y:m,width:w,height:y}}let S=h/a*l;return{x:p,y:m-(S-y)/2,width:h,height:S}}viewerToWorld(e,t){let i=this.getScaleFactor();return this._viewerToWorld.x=this.target[1]+e/i,this._viewerToWorld.y=this.target[2]+t/i,this._viewerToWorld}worldToViewer(e,t,i,n){let r=xe.singleBox(i,n,e,t);return Zt(r,pi(wi(this.getScaleFactor()),ut(-this.target[1],-this.target[2]))),{x:r[1],y:r[2],width:r[3]-r[1],height:r[4]-r[2],strand:r}}setScale(e,t){Zt(this.target,On(e,t?t.x:this.target[1]+(this.target[3]-this.target[1])/2,t?t.y:this.target[2]+(this.target[4]-this.target[2])/2)),this.pendingUpdate=!0}syncTo(e){let t=this.target;return this.target=e.target,this.pendingUpdate=!0,()=>{this.target=t}}stop(){return typeof this.stopId<"u"&&(window.cancelAnimationFrame(this.stopId),this.stopId=void 0),()=>{this.render(performance.now())}}reset(){this.renderer.reset()}selectZone(e){this.world.selectZone(e),this.pendingUpdate=!0}deselectZone(){this.world.deselectZone(),this.pendingUpdate=!0}hook(e,t){let i=this.hooks[e].length;if(i!==0)for(let n=0;n<i;n++)this.hooks[e][n](t)}registerHook(e,t){return this.hooks[e].push(t),()=>{this.hooks[e]=this.hooks[e].filter(i=>i!==t)}}updateNextFrame(){this.pendingUpdate=!0}},pu=/([0-9]+(px|em)\s+)+(solid)\s+(.*)/g,fu={},SP=["backgroundColor","opacity","boxShadow","borderColor","borderWidth","borderStyle","outlineColor","outlineWidth","outlineOffset","outlineStyle"],Vx=class extends bn{constructor(){super(),P(this,"id"),P(this,"type","spacial-content"),P(this,"isShape",!0),P(this,"points"),P(this,"hoverEvents",!1),P(this,"activeEvents",!1),P(this,"display",{x:0,y:0,scale:1,width:-1,height:-1,points:re(5)}),P(this,"boundingBox",null),P(this,"_parsed",{border:{id:null,match:[]},outline:{id:null,match:[]}}),P(this,"hovering"),P(this,"pressing"),P(this,"props",{}),P(this,"shape",{type:"none"}),P(this,"addHover",()=>{this.hovering=!0,this.__revision++}),P(this,"removeHover",()=>{this.hovering=!1,this.pressing=!1,this.__revision++}),P(this,"addPress",()=>{this.pressing=!0,this.__revision++}),P(this,"removePress",()=>{this.pressing=!1,this.__revision++}),this.id=Cu(12),this.points=re(5),this.shape={type:"none"}}updateBoundingBox(){if(this.shape.type==="none")return;let e=this.shape.points;if(this.shape.points.length>2){let t=Math.min(...e.map(a=>a[0])),i=Math.min(...e.map(a=>a[1])),n=Math.max(0,...e.map(a=>a[0])),r=Math.max(0,...e.map(a=>a[1]));this.boundingBox={x:t,y:i,width:n-t,height:r-i};return}this.boundingBox=null}intersects(e){if(!e||this.shape.type==="none")return!1;let[t,i]=e,n=this.shape.points,r=this.boundingBox;if(r||(this.updateBoundingBox(),r=this.boundingBox),!r||t<r.x||t>r.x+r.width||i<r.y||i>r.height+r.y)return!1;let a=!1;for(let l=0,c=n.length-1;l<n.length;c=l++)n[l][1]>i!=n[c][1]>i&&t<(n[c][0]-n[l][0])*(i-n[l][1])/(n[c][1]-n[l][1])+n[l][0]&&(a=!a);return a}getAllPointsAt(e,t){return e[3]-e[1]===1&&e[4]-e[2]===1?this.intersects([e[1],e[2]])?[[this,this.points,t]]:[]:[[this,this.points,t]]}applyProps(e={}){let t=!1;if(e.points)if(this.shape.type!=="polygon"||this.shape.points.length!==e.points.length)this.shape={type:"polygon",points:e.points,open:e.open},this.updateBoundingBox();else{let i=!1,n=e.points.length;for(let r=0;r<n;r++)if(e.points[r][0]!==this.shape.points[r][0]||e.points[r][1]!==this.shape.points[r][1]){i=!0;break}i&&(this.shape={type:"polygon",points:e.points,open:e.open},this.updateBoundingBox())}if(e.interactive!==this.props.interactive&&(t=!0,this.props.interactive=e.interactive),(e.open||e.open===!1)&&(t=!0,this.shape.open=e.open),e.style){let i=e.border||e.style.border;if(i!==this._parsed.border.id)if(!i)this._parsed.border.id=null,this._parsed.border.match=[];else{let n=fu[i]||pu.exec(i)||pu.exec(i);n&&(this._parsed.border.id=i,this._parsed.border.match=fu[i]=n)}if(this._parsed.border.id&&(e.style.borderWidth=this._parsed.border.match[1],e.style.borderStyle="solid",e.style.borderColor=this._parsed.border.match[4]),e.style.outline!==this._parsed.outline.id)if(!e.style.outline)this._parsed.outline.id=null,this._parsed.outline.match=[];else{let n=fu[e.style.outline]||pu.exec(e.style.outline)||pu.exec(e.style.outline);n&&(this._parsed.outline.id=e.style.outline,this._parsed.outline.match=fu[e.style.outline]=n)}this._parsed.outline.id&&(e.style.outlineWidth=this._parsed.outline.match[1],e.style.outlineStyle="solid",e.style.outlineColor=this._parsed.outline.match[4]),this.props.style=e.style,e.backgroundColor&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=e.backgroundColor,t=!0),e.style.background&&!this.props.style.backgroundColor&&(this.props.style.backgroundColor=e.style.background,t=!0);for(let n of SP)if(this.props.style[n]!==e.style[n]){t=!0;break}e.style[":hover"]!==this.props.hoverStyles&&(this.props.hoverStyles=e.style[":hover"],this.hoverEvents||(this.hoverEvents=!0,this.addEventListener("pointerenter",this.addHover),this.addEventListener("pointerleave",this.removeHover)),t=!0),e.style[":active"]!==this.props.pressStyles&&(this.props.pressStyles=e.style[":active"],this.activeEvents||(this.activeEvents=!0,this.addEventListener("mousedown",this.addPress),this.addEventListener("mouseup",this.removePress)),t=!0)}e.href!==this.props.href&&(this.props.href=e.href,t=!0),e.hrefTarget!==this.props.hrefTarget&&(this.props.hrefTarget=e.hrefTarget,t=!0),e.title!==this.props.title&&(this.props.title=e.title,t=!0),e.className!==this.props.className&&(this.props.className=e.className,e.className&&!this.hoverEvents&&(this.hoverEvents=!0,this.addEventListener("pointerenter",this.addHover),this.addEventListener("pointerleave",this.removeHover)),e.className&&!this.activeEvents&&(this.activeEvents=!0,this.addEventListener("mousedown",this.addPress),this.addEventListener("mouseup",this.removePress)),t=!0),e.relativeSize!==this.props.relativeSize&&(this.props.relativeSize=e.relativeSize,t=!0),e.relativeStyle!==this.props.relativeStyle&&(this.props.relativeStyle=e.relativeStyle,t=!0),e.html!==this.props.html&&(this.props.html=e.html,t=!0),e.target&&(e.target.width!==this.display.width||e.target.height!==this.display.height||e.target.x!==this.points[1]||e.target.y!==this.points[2])&&(t=!0,this.points=xe.singleBox(e.target.width,e.target.height,e.target.x,e.target.y),this.display.points=xe.singleBox(e.target.width,e.target.height,e.target.x,e.target.y),this.display.width=e.target.width,this.display.height=e.target.height),t&&this.__revision++}},Rx=/(-?[0-9]+(px|em)\s+|0\s+)(-?[0-9]+(px|em)\s+|0\s+)(-?[0-9]+(px|em)\s+|0\s+)?(-?[0-9]+(px|em)\s+|0\s+)?(.*)/g,Tx={},wP=typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes("firefox"),mu={},bP=class{constructor(e,t){P(this,"canvas"),P(this,"ctx"),P(this,"options"),P(this,"imagesPending",0),P(this,"imagesLoaded",0),P(this,"imageIdsLoaded",[]),P(this,"frameIsRendering",!1),P(this,"pendingDrawCall",!1),P(this,"firstMeaningfulPaint",!1),P(this,"parallelTasks",8),P(this,"frameTasks",0),P(this,"loadingQueueOrdered",!0),P(this,"loadingQueue",[]),P(this,"currentTask",Promise.resolve()),P(this,"tasksRunning",0),P(this,"stats"),P(this,"averageJobTime",64),P(this,"lastKnownScale",1),P(this,"visible",[]),P(this,"previousVisible",[]),P(this,"rendererPosition"),P(this,"dpi"),P(this,"drawCalls",[]),P(this,"lastPaintedObject"),P(this,"hostCache"),P(this,"invalidated",[]),P(this,"_worker",()=>{if(this.loadingQueue.length){let i=this.loadingQueue.pop();i&&(this.tasksRunning++,this.frameTasks++,this.currentTask=i.task().then(()=>{this.tasksRunning--}).catch(()=>{this.tasksRunning--}))}}),P(this,"_scheduled",0),P(this,"_doWork",()=>{this.loadingQueue.length===0&&this.tasksRunning===0&&this._scheduled&&(clearInterval(this._scheduled),this._scheduled=0);let i=this.parallelTasks||1;!this.firstMeaningfulPaint&&this.loadingQueue.length&&(i=this.loadingQueue.length);for(let n=0;n<=i;n++)this._worker()}),this.canvas=e,this.rendererPosition=e.getBoundingClientRect(),this.ctx=e.getContext("2d",{alpha:!0}),this.ctx.imageSmoothingEnabled=!0,this.options=t||{},this.canvas.style.opacity="0",this.canvas.style.transition="opacity .3s",this.dpi=t?.dpi||1,this.hostCache=t?.lruCache?new Ny({maxSize:1024*512*512,dispose:(i,n,r)=>{this.invalidated.push(n),i.width=0,i.height=0},sizeCalculation:(i,n)=>i.width*i.height}):{store:{},get(i){return this.store[i]},set(i,n){this.store[i]=n}}}getCanvasDims(){return{width:this.canvas.width/this.dpi,height:this.canvas.height/this.dpi}}resize(){this.rendererPosition=this.canvas.getBoundingClientRect()}isReady(){return this.firstMeaningfulPaint}afterFrame(e){if(this.clearTransform(),this.lastPaintedObject=void 0,this.frameIsRendering=!1,this.imagesPending=Math.max(0,this.imagesPending-this.imagesLoaded),this.imagesLoaded=0,this.loadingQueueOrdered||(this.loadingQueue=this.loadingQueue.sort((t,i)=>t.network&&t.scale===i.scale?i.distance-t.distance:t.scale<i.scale?-1:1),this.loadingQueueOrdered=!0),this.previousVisible=this.visible,this.pendingDrawCall=!!this.drawCalls.length,this.pendingDrawCall)for(let t=0;t<this.drawCalls.length;t++){let i=this.drawCalls.shift();i&&i()}this.doOffscreenWork(),this.options.debug&&this.stats&&this.stats.end()}doOffscreenWork(){this.frameTasks=0,this.loadingQueue.length&&(this._worker(),this.loadingQueue.length&&(this._scheduled||(this._scheduled=setInterval(this._doWork,0))))}getScale(e,t,i){if(Number.isNaN(e)||Number.isNaN(t))return this.lastKnownScale;let n=this.getCanvasDims(),r=n.width/e,a=n.height/t,l=(r<a?a:r)*(i&&this.dpi||1);return Number.isNaN(l)||(this.lastKnownScale=l),this.lastKnownScale}beforeFrame(e,t,i,n){this.options.debug&&this.stats&&this.stats.begin(),this.frameIsRendering=!0,this.visible=[],this.options.beforeFrame&&this.options.beforeFrame(t);let r=this.getCanvasDims();if(this.ctx.globalAlpha=1,this.ctx.fillStyle=this.canvas.dataset.background??"rgb(0, 0, 0)",this.ctx.fillRect(0,0,r.width,r.height),n.enableFilters&&(n.filters.brightness||n.filters.contrast||n.filters.grayscale||n.filters.invert||n.filters.sepia||n.filters.saturate||n.filters.hueRotate||n.filters.blur)){let a="";n.filters.brightness&&(a+=`brightness(${~~(100+n.filters.brightness*100)}%) `),n.filters.contrast&&(a+=`contrast(${~~(100+n.filters.contrast*100)}%) `),n.filters.grayscale&&(a+=`grayscale(${~~(n.filters.grayscale*100)}%) `),n.filters.invert&&(a+=`invert(${~~(n.filters.invert*100)}%) `),n.filters.sepia&&(a+=`sepia(${~~(n.filters.sepia*100)}%) `),n.filters.saturate&&(a+=`saturate(${~~(100+n.filters.saturate*100)}%) `),n.filters.hueRotate&&(a+=`hue-rotate(${n.filters.hueRotate}deg) `),n.filters.blur&&(a+=`blur(${n.filters.blur}px) `),this.ctx.filter=a}else this.ctx.filter="none"}applyTransform(e,t,i,n,r){let a=e.__owner.value;if(a&&a.rotation){this.ctx.save();let l=t+n/2,c=i+r/2;this.ctx.translate(l,c),this.ctx.rotate(a.rotation*Math.PI/180),this.ctx.translate(-l,-c),this.lastPaintedObject=a}}clearTransform(){this.lastPaintedObject&&(this.lastPaintedObject.rotation&&this.ctx.restore(),this.lastPaintedObject=void 0)}paint(e,t,i,n,r,a){let l=this.ctx.globalAlpha;if(e instanceof cr||e instanceof Xs){if(e.display.rotation){this.ctx.save();let m=i+r/2,h=n+a/2;e.crop&&(m-=e.crop[t*5+1],h-=e.crop[t*5+2]),this.ctx.translate(m,h),this.ctx.rotate(e.display.rotation*Math.PI/180),this.ctx.translate(-m,-h)}if(this.visible.push(e),typeof e.style&&e.style.opacity!=="undefined"){if(!e.style.opacity)return;this.ctx.globalAlpha=e.style.opacity}try{let m=e.__host.canvas,h=this.getCanvasDims();if((m.indices.indexOf(t)===-1||this.invalidated.indexOf(m.canvases[t])!==-1)&&this.schedulePaintToCanvas(m,e,t,vu({x:i+r/2,y:n+r/2},{x:h.width/2,y:h.height/2})),!this.firstMeaningfulPaint)return;let y=this.hostCache.get(m.canvases[t]);if(y)if(e.crop&&e.cropData){if(e.crop[t*5]){let S=[e.crop[t*5+1]/e.display.scale-e.display.points[t*5+1],e.crop[t*5+2]/e.display.scale-e.display.points[t*5+2],1+(e.crop[t*5+3]-e.crop[t*5+1])/e.display.scale,1+(e.crop[t*5+4]-e.crop[t*5+2])/e.display.scale];S[0]+=e.cropData.x/e.display.scale,S[1]+=e.cropData.y/e.display.scale;let w=e.x*this.lastKnownScale,v=e.y*this.lastKnownScale,x=[i+w,n+v,r,a];x[0]+=w,x[1]+=v,this.ctx.drawImage(y,S[0],S[1],S[2],S[3],x[0],x[1],x[2]+1,x[3]+1)}}else wP?this.ctx.drawImage(y,0,0,e.display.points[t*5+3]-e.display.points[t*5+1],e.display.points[t*5+4]-e.display.points[t*5+2],i,n,r+1,a+1):this.ctx.drawImage(y,0,0,e.display.points[t*5+3]-e.display.points[t*5+1],e.display.points[t*5+4]-e.display.points[t*5+2],i,n,r+Number.MIN_VALUE+.5,a+Number.MIN_VALUE+.5)}catch{}e.display.rotation&&this.ctx.restore()}let c=e instanceof Qs&&this.options.box,p=e instanceof Vx&&this.options.polygon;if((c||p)&&!e.props.className&&!e.props.html&&!e.props.href){if(this.visible.push(e),e.props.style){let m=Object.assign({},e.props.style||{},e.hovering?e.props.hoverStyles:{},e.pressing?e.props.pressStyles:{}),h=e.props.relativeStyle?1:r/e.width;typeof m.opacity<"u"&&(this.ctx.globalAlpha=m.opacity);let y=0;typeof m.borderWidth<"u"&&(y=parseInt(m.borderWidth,10)*h);let S=0;typeof m.outlineWidth<"u"&&(S=parseInt(m.outlineWidth,10)*h);let w=0;if(typeof m.outlineOffset<"u"&&(w=parseInt(m.outlineOffset,10)*h),m.borderColor&&(this.ctx.strokeStyle=m.borderColor),m.boxShadow){let v=m.boxShadow.split(/,(?![^(]*\))/);for(let x of v){let A=Tx[x]||Rx.exec(x)||Rx.exec(x);Tx[x]=A,A&&(this.ctx.save(),this.ctx.shadowOffsetX=parseInt(A[1])*this.dpi*h,this.ctx.shadowOffsetY=parseInt(A[3])*this.dpi*h,this.ctx.shadowBlur=parseInt(A[5])*this.dpi*h,this.ctx.shadowColor=A[9],this.ctx.fillStyle="rgba(0,0,0,1)",this.ctx.fillRect(i+y,n+y,r,a),this.ctx.restore())}}if(this.ctx.fillStyle=m.backgroundColor||"transparent",this.ctx.lineWidth=y,p){let v=e.shape,x=v.points||[],A=x.length;this.ctx.beginPath();for(let C=0;C<A;C++)this.ctx.lineTo(i+x[C][0]*this.lastKnownScale,n+x[C][1]*this.lastKnownScale);v.open||this.ctx.closePath(),y&&this.ctx.stroke(),v.open||this.ctx.fill()}else y&&this.ctx.strokeRect(i+y/2,n+y/2,r+y,a+y),this.ctx.fillRect(i+y,n+y,r,a);S&&(m.outlineColor&&(this.ctx.strokeStyle=m.outlineColor),this.ctx.lineWidth=S,this.ctx.strokeRect(i-S/2-w,n-S/2-w,r+y*2+S+w*2,a+y*2+S+w*2))}this.ctx.globalAlpha=l}}loadImage(e,t,i,n=!1){if(mu[e]&&mu[e].naturalWidth>0){t(mu[e]);return}try{let r=!1;n||setTimeout(()=>{r||this.loadImage(e,t,i,!0)},3e3);let a=document.createElement("img");a.decoding="auto",a.onload=function(){r=!0,t(a),mu[e]=a,a.onload=null},this.options.crossOrigin&&(a.crossOrigin="anonymous"),a.src=e,a.complete&&a.onload({}),a.width}catch(r){console.log("image error",r),i(r)}}schedulePaintToCanvas(e,t,i,n){this.imagesPending++,e.indices.push(i);let r=`${t.id}--${t.display.scale}-${i}`,a=this.invalidated.indexOf(r);a!==-1&&this.invalidated.splice(a,1),e.canvases[i]=r,t.__host.canvas.loading=!0,this.loadingQueueOrdered=!1,this.loadingQueue.push({id:r,scale:t.display.scale,network:!0,distance:n,task:()=>new Promise(l=>{if(this.visible.indexOf(t)===-1){this.imagesPending--,e.indices.splice(e.indices.indexOf(i),1),l();return}let c=t.getImageUrl(i);this.loadImage(c,p=>{this.loadingQueue.push({id:r,scale:t.display.scale,distance:n,task:()=>new Promise(m=>{this.imageIdsLoaded.includes(r)||(this.imagesLoaded++,this.imageIdsLoaded.push(r)),e.loaded.push(i),e.loaded.length===e.indices.length&&(e.loading=!1);let h=t.display.points.slice(i*5,i*5+5),y=document.createElement("canvas"),S=y.getContext("2d");y.width=h[3]-h[1],y.height=h[4]-h[2],this.hostCache.set(e.canvases[i],y),this.drawCalls.push(()=>{S.drawImage(p,0,0,h[3]-h[1],h[4]-h[2]),m()})})}),l()},p=>{this.imagesPending--,e.indices.splice(e.indices.indexOf(i),1),l()})})})}afterPaintLayer(e,t){}prepareLayer(e,t){if(e.__owner.value)if(e.cropData){let i=this.lastKnownScale*(1/e.display.scale);this.applyTransform(e,t[1],t[2],t[3]-t[1],t[4]-t[2])}else this.applyTransform(e,t[1],t[2],t[3]-t[1],t[4]-t[2]);(!e.__host||!e.__host.canvas)&&(e instanceof cr||e instanceof Xs)&&this.createImageHost(e)}finishLayer(){this.lastPaintedObject&&this.clearTransform()}createImageHost(e){e.__host=e.__host?e.__host:{},e.__host.canvas={canvas:void 0,canvases:[],indices:[],loaded:[],loading:!1}}getPointsAt(e,t,i,n){return e.getPointsAt(t,i,n)}getViewportBounds(e,t,i){let n=e.getActiveZone();if(n){let r=t[3]-t[1]<n.points[3]-n.points[1],a=t[4]-t[2]<n.points[4]-n.points[2];return{x1:r?n.points[1]-i:n.points[1]+(n.points[3]-n.points[1])/2-(t[3]-t[1])/2,y1:a?n.points[2]-i:n.points[2]+(n.points[4]-n.points[2])/2-(t[4]-t[2])/2,x2:r?n.points[3]+i:n.points[1]+(n.points[3]-n.points[1])/2-(t[3]-t[1])/2,y2:a?n.points[4]+i:n.points[2]+(n.points[4]-n.points[2])/2-(t[4]-t[2])/2}}return null}pendingUpdate(){let e=!this.pendingDrawCall&&this.drawCalls.length===0&&this.imagesPending===0&&this.loadingQueue.length===0&&this.tasksRunning===0;return!e&&this.visible.length===0&&setTimeout(()=>{this.canvas.style.opacity="1",this.firstMeaningfulPaint=!0},500),!this.firstMeaningfulPaint&&e&&this.visible.length?(this.canvas.style.opacity="1",this.firstMeaningfulPaint=e,!0):this.options.debug?!0:!e}getRendererScreenPosition(){return this.rendererPosition}reset(){this.loadingQueue=[],this.drawCalls=[]}},Ux=class{constructor(e){P(this,"renderers",[]),P(this,"length");for(let t of e)t&&this.renderers.push(t);this.length=this.renderers.length}afterFrame(e,t,i,n){for(let r=0;r<this.length;r++)this.renderers[r].afterFrame(e,t,i,n)}afterPaintLayer(e,t){for(let i=0;i<this.length;i++)this.renderers[i].afterPaintLayer(e,t)}beforeFrame(e,t,i,n){for(let r=0;r<this.length;r++)this.renderers[r].beforeFrame(e,t,i,n)}triggerResize(){for(let e=0;e<this.length;e++){let t=this.renderers[e];t.triggerResize&&t.triggerResize()}}getPointsAt(e,t,i,n){return this.renderers[0].getPointsAt(e,t,i,n)}getScale(e,t){return this.renderers[0].getScale(e,t)}getViewportBounds(e,t,i){return this.renderers[0].getViewportBounds(e,t,i)}getRendererScreenPosition(){return this.renderers[0].getRendererScreenPosition()}isReady(){for(let e=0;e<this.length;e++)if(!this.renderers[e].isReady())return!1;return!0}paint(e,t,i,n,r,a){for(let l=0;l<this.length;l++)this.renderers[l].paint(e,t,i,n,r,a)}pendingUpdate(){for(let e=0;e<this.length;e++)if(this.renderers[e].pendingUpdate())return!0;return!1}prepareLayer(e,t){for(let i=0;i<this.length;i++)this.renderers[i].prepareLayer(e,t)}finishLayer(e,t){for(let i=0;i<this.length;i++)this.renderers[i].finishLayer(e,t)}resize(e,t){for(let i=0;i<this.length;i++)this.renderers[i].resize(e,t)}reset(){for(let e=0;e<this.length;e++)this.renderers[e].reset()}},CP=class{constructor(e){P(this,"canvas"),P(this,"context"),P(this,"heightRatio",1),P(this,"widthRatio",1),P(this,"target",new Float32Array(5)),P(this,"initialWidth"),P(this,"initialHeight"),P(this,"bounds"),P(this,"aggregate"),P(this,"delta",0),P(this,"renderNextFrame",!0),this.canvas=e,this.initialWidth=e.width,this.initialHeight=e.height,this.context=e.getContext("2d"),this.context.globalAlpha=.5,this.aggregate=wi(1)}isReady(){return!0}resize(){this.initialWidth=this.canvas.width,this.initialHeight=this.canvas.height,this.renderNextFrame=!0}afterFrame(e,t,i){if(this.renderNextFrame){this.context.clearRect(0,0,this.canvas.width,this.canvas.height);let n=this.initialWidth/e.width,r=this.initialHeight/e.height,a=this.widthRatio>this.heightRatio?n:r;if(this.target=i,this.bounds){let l=e.getPointsAt(this.bounds,this.aggregate,a);for(let[c,p]of l)if(c instanceof cr&&c.__host.canvas){let m=p.length/5;for(let h=0;h<m;h++)if(c.__host.canvas.canvases[h]){let y={x1:p[h+1]*a,y1:p[h+2]*a,width:(p[h+3]-p[h+1])*a,height:(p[h+4]-p[h+2])*a}}}}e.getPoints().forEach((l,c,p)=>{if(c%5===0&&l){let m={x1:p[c+1]*a,y1:p[c+2]*a,x2:p[c+3]*a,y2:p[c+4]*a,width:(p[c+3]-p[c+1])*a,height:(p[c+4]-p[c+2])*a};this.context.strokeStyle="red",this.context.strokeRect(m.x1,m.y1,m.width,m.height)}}),i&&(this.context.strokeStyle="red",this.context.lineWidth=window.devicePixelRatio||1,this.context.strokeRect(i[1]*a,i[2]*a,(i[3]-i[1])*a,(i[4]-i[2])*a))}}getActiveZone(e){return null}getPointsAt(e,t,i,n){return e.getPointsAt(t,i,n)}getScale(e,t){return 1}beforeFrame(e,t){this.bounds=xe.singleBox(e.width,e.height)}drawImage(){}afterPaintLayer(e,t){}paint(e,t,i,n,r,a){this.renderNextFrame=!0}prepareLayer(e){}pendingUpdate(){return!1}hasActiveZone(){return!1}getViewportBounds(e,t,i){return null}getRendererScreenPosition(){return this.canvas.getBoundingClientRect()}finishLayer(){}reset(){}};function PP(e){return{x:e[1],y:e[2],width:e[3]-e[1],height:e[4]-e[2]}}var _x="pan",Mx="scroll",EP="gesture",AP={zoomOutFactor:.8,zoomInFactor:1.25,maxZoomFactor:1,minZoomFactor:.05,zoomDuration:300,zoomWheelConstant:20,zoomClamp:.6,panBounceStiffness:120,panBounceDamping:15,panTimeConstant:240,panPower:.1,nudgeDistance:100,panPadding:0,devicePixelRatio:1,enableWheel:!0,enableClickToZoom:!0,ignoreSingleFingerTouch:!1,enablePanOnWait:!1,requireMetaKeyForWheelZoom:!1,panOnWaitDelay:40,onPanInSketchMode:()=>{},parentElement:null},Hx=(e={})=>({start:function(t){let{zoomWheelConstant:i,enableWheel:n,enableClickToZoom:r,ignoreSingleFingerTouch:a,enablePanOnWait:l,panOnWaitDelay:c,parentElement:p,requireMetaKeyForWheelZoom:m}={...AP,...e},h={pointerStart:{x:0,y:0},isPressing:!1,mousemoveBuffer:re(5),multiTouch:{distance:0}};t.world.activatedEvents.push("onMouseUp","onMouseDown","onMouseMove","onTouchStart","onTouchEnd","onTouchMove");function y(){x=0,C="",E(),E(void 0,"notice"),A=0}function S(){t.world.constraintBounds(),y()}function w(U){if(U.which>1){h.isPressing=!1;return}t.mode==="explore"&&(U.preventDefault(),h.pointerStart.x=U.atlas.x,h.pointerStart.y=U.atlas.y,t.transitionManager.stopTransition(),h.isPressing=!0)}function v(){y(),h.isPressing&&(t.mode==="explore"&&t.world.constraintBounds(),h.isPressing=!1)}let x=0,A=0,C="";function I(U){if(t.mode==="explore"){if(U.atlasTouches.length===1&&(A=performance.now(),a==!1&&U.preventDefault(),h.pointerStart.x=U.atlasTouches[0].x,h.pointerStart.y=U.atlasTouches[0].y),U.atlasTouches.length===2){C=EP,U.preventDefault();let W=U.atlasTouches[0].x,ee=U.atlasTouches[1].x;h.pointerStart.x=(W+ee)/2;let Me=U.atlasTouches[0].y,pe=U.atlasTouches[1].y;h.pointerStart.y=(Me+pe)/2,x=vu({x:U.touches[0].clientX,y:U.touches[0].clientY},{x:U.touches[1].clientX,y:U.touches[1].clientY})}t.transitionManager.stopTransition(),h.isPressing=!0}}function E(U,W="intent"){p&&(p.dataset[W]=U)}function L(U){let W=null,ee=null,Me=!1,pe=0;if(h.isPressing&&U.touches.length===2){let Re=U.touches[0].clientX,ke=U.touches[1].clientX;W=(Re+ke)/2;let He=U.touches[0].clientY,qe=U.touches[1].clientY;ee=(He+qe)/2,pe=vu({x:U.touches[0].clientX,y:U.touches[0].clientY},{x:U.touches[1].clientX,y:U.touches[1].clientY}),Me=!0}if(E(C),h.isPressing&&U.touches.length===1){if(l&&(performance.now()-A<c&&C==""&&(C=Mx),C==""&&(C=_x)),E(C),C==""&&a==!0||C==Mx){E("require-two-finger","notice");return}let Re=U.touches[0];W=Re.clientX,ee=Re.clientY}if(W!==null&&ee!==null){let Re=t.getRendererScreenPosition();if(Re){let{x:ke,y:He}=t.viewerToWorld(W-Re.x,ee-Re.y),qe=pe&&x?pe/x:1;t.transitionManager.customTransition($=>{$.from=re(t.target),$.to=bi($.from,pi(ut(h.pointerStart.x-ke,h.pointerStart.y-He),On(1/qe,ke,He)),h.mousemoveBuffer),$.elapsed_time=0,$.total_time=0,$.timingFunction=ur.easeInOutExpo,$.done=!1})}x=pe}C==_x&&U.preventDefault()}function z(U){if(h.isPressing){let W=t.getRendererScreenPosition();if(W){let{x:ee,y:Me}=t.viewerToWorld(U.clientX-W.x,U.clientY-W.y);t.transitionManager.customTransition(pe=>{pe.from=re(t.target),pe.to=bi(pe.from,ut(h.pointerStart.x-ee,h.pointerStart.y-Me),h.mousemoveBuffer),pe.elapsed_time=0,pe.total_time=0,pe.timingFunction=ur.easeInOutExpo,pe.done=!1})}}}function M(U){t.mode==="explore"&&t.world.zoomIn(U.atlas)}function Q(U){let W=1+(0,Wx.default)(U).spinY/i;t.world.zoomTo(W,U.atlas,!0)}function V(U){return m&&U.metaKey==!1?(E("meta-required","notice"),U.stopPropagation(),!1):!0}t.world.addEventListener("mouseup",S),t.world.addEventListener("touchend",S),t.world.addEventListener("touchstart",I),t.world.addEventListener("mousedown",w),window.addEventListener("touchend",v),window.addEventListener("mouseup",v),window.addEventListener("mousemove",z),p&&p.addEventListener("touchmove",L),r&&(t.world.activatedEvents.push("onClick"),t.world.addEventListener("click",M)),n&&(t.world.activatedEvents.push("onWheel"),m&&p?.addEventListener("wheel",V,{passive:!0,capture:!0}),t.world.addEventListener("wheel",Q));let J=t.world.addLayoutSubscriber((U,W)=>{if(U==="zone-changed"&&t.transitionManager.constrainBounds({transition:{duration:0}}),U==="zoom-to"&&W&&t.transitionManager.zoomTo(W.factor,{origin:W.point,stream:W.stream}),U==="go-home"){let ee=W.immediate?{duration:0}:void 0;t.transitionManager.goToRegion(PP(t.homePosition),{transition:ee})}if(U==="goto-region"&&W){let ee=W.immediate?{duration:0}:{};t.transitionManager.goToRegion(W,{transition:ee})}U==="constrain-bounds"&&t.transitionManager.constrainBounds({transition:W?.immediate?{duration:0}:void 0})});return()=>{t.world.removeEventListener("mouseup",S),t.world.removeEventListener("touchend",S),t.world.removeEventListener("touchstart",I),t.world.removeEventListener("mousedown",w),window.removeEventListener("touchend",v),window.removeEventListener("mouseup",v),t.world.removeEventListener("mousemove",z),p&&(p.removeEventListener("touchmove",z),p.removeEventListener("wheel",V,{passive:!0,capture:!0})),r&&t.world.removeEventListener("click",M),n&&t.world.removeEventListener("wheel",Q),J()}},updatePosition(){}}),Fo=Au.default.createContext("explore");Fo.displayName="Mode";var RP=()=>(0,Au.useContext)(Fo);var Iu=Lp.default.createContext(null);Iu.displayName="Atlas";var Ru=Lp.default.createContext(null);Ru.displayName="Bounds";var Su,TP=typeof performance=="object"&&typeof performance.now=="function";if(TP){let e=performance;Su=()=>e.now()}else{let e=Date,t=e.now();Su=()=>e.now()-t}var _P=16;function kx(e,t){e&&e.appendChild&&t&&e.appendChild(t)}function $x(e,t){e&&e.removeChild&&t&&e.removeChild(t)}function MP(e,t){return $x(e.world,t)}function kP(e,t,i){return Gx(e.world,t,i)}function Gx(e,t,i){e&&e instanceof Eu&&(e=e.world),e&&e.insertBefore&&e.insertBefore(t,i)}function Yx(e,t,i){if(i&&(e.applyProps&&e.applyProps(i),e instanceof bn))for(let n of bu){let r=n.slice(2).toLowerCase();i[n]!==t[n]&&(t[n]&&e.removeEventListener(r,t[n]),e.addEventListener(r,i[n]))}}function Xx(e,t){let i=Object.keys(t),n=!1;for(let r of i)if(bu.indexOf(r)!==-1){let a=zo[r];if(a){if(e.activatedEvents.indexOf(a)!==-1)continue;n=!0,e.activatedEvents.push(a)}}n&&e.triggerEventActivation()}var wu=new Map,Ox={};function OP(e,{args:t=[],...i},n,r,a){if(!(n instanceof Eu)&&a){let p=m=>m.return?p(m.return):m.stateNode&&m.stateNode.containerInfo;n=p(a)}let l,c=n.world;switch(e){case"world":l=Pu.withProps({width:i.width,height:i.height,viewingDirection:"left-to-right"}),l.activatedEvents=c.activatedEvents,l.eventHandlers=c.eventHandlers,l.subscriptions=c.subscriptions,l.triggerEventActivation(),c=l;break;case"box":l=new Qs;break;case"shape":l=new Vx;break;case"worldObject":case"world-object":l=new Op;break;case"worldImage":case"world-image":l=new cr;break;case"texture":l=new Rp;break;case"compositeImage":case"composite-image":l=new yP({id:i.id,width:i.width,height:i.height,images:[],renderOptions:i.renderOptions});break;case"tiledImage":case"tiled-image":l=Xs.fromTile(i.uri,i.display,i.tile,i.scaleFactor,void 0,i.format);break;case"paragraph":l=new gu,l.text=i.children;break;default:return}return Xx(c,i),Yx(l,{},i),l}function LP(e,t){if(t instanceof Pu)e.world=t;else if(t instanceof Op)e.world.appendChild(t);else if(t)throw new Error("Invalid root")}var Gs=(0,qx.default)({unstable_now:Su,now:Su,createInstance:OP,removeChild:$x,appendChild:kx,appendInitialChild:kx,insertBefore:Gx,warnsIfNotActing:!0,supportsMutation:!0,isPrimaryRenderer:!1,scheduleTimeout:typeof setTimeout<"u"?setTimeout:void 0,cancelTimeout:typeof clearTimeout<"u"?clearTimeout:void 0,setTimeout:typeof setTimeout<"u"?setTimeout:void 0,clearTimeout:typeof clearTimeout<"u"?clearTimeout:void 0,noTimeout:-1,appendChildToContainer:LP,removeChildFromContainer:MP,createTextInstance(){},insertInContainerBefore:kP,prepareUpdate(e,t,i,n,r){return Xx(r.world,n),n},commitUpdate(e,t,i,n,r,a){e.applyProps&&t&&Yx(e,n,t)},finalizeInitialChildren(e){return e?.__handlers},getChildHostContext(){return Ox},getRootHostContext(){return Ox},prepareForCommit(e){return e.isCommitting=!0,null},preparePortalMount(){},hideInstance(e){e&&e.points&&(e.points[0]=0)},unhideInstance(e,t){e&&e.points&&(e.points[0]=1)},getPublicInstance(e){return e},hideTextInstance(){throw new Error("Text is not allowed in the react-three-fibre tree. You may have extraneous whitespace between components.")},resetAfterCommit(e){e.isCommitting=!1,e.pendingUpdate=!0,e.world&&e.world.needsRecalculate&&(e.world.recalculateWorldSize(),e.world.triggerRepaint())},shouldSetTextContent(){return!1},clearContainer(){return!1},supportsHydration:!1,supportsPersistence:!1,detachDeletedInstance(e){},afterActiveInstanceBlur(){},beforeActiveInstanceBlur(){},getCurrentEventPriority(){return console.log("getCurrentEventPriority"),_P},getInstanceFromNode(e){throw console.log("getInstanceFromNode",e),new Error("Not implemented")},getInstanceFromScope(e){throw console.log("getInstanceFromScope",e),new Error("Not implemented")},prepareScopeUpdate(e,t){throw console.log("prepareScopeUpdate",e,t),new Error("Not implemented")},logRecoverableError(){},requestPostPaintCallback(){}});Gs.injectIntoDevTools({bundleType:0,version:Qx.version,rendererPackageName:"@atlas-viewer/atlas"});function zp(e,t){let i=wu.get(e);i&&Gs.updateContainer(null,i,null,()=>{wu.delete(e),t&&t(e)})}var Lx={render(e,t){let i=wu.get(t);if(i)Gs.updateContainer(e,i,null);else{let n=Gs.createContainer(t,0,null,!1,null,"",()=>{},null);Gs.updateContainer(e,n,null),wu.set(t,n)}},unmountComponentAtNode(e,t){zp(e,t)}},Ys=typeof window<"u"&&(window.document?.createElement||window.navigator?.product==="ReactNative")?Tu.useLayoutEffect:Tu.useEffect,zP=wn.default.memo(({children:e,setIsReady:t,onCreated:i,bounds:n,preset:r,mode:a="explore"})=>{let l=(0,wn.useCallback)(function(c){let p=(0,wn.useRef)(!1),m=()=>{t(!0)};return(0,wn.useEffect)(()=>{if(r&&!p.current){r.runtime.goHome();let h=i&&i(r);return void(h&&h.then?h.then(m):m())}return()=>{}},[]),(0,wn.useEffect)(()=>{p.current=!0},[]),c.children},[r]);return Ys(()=>{if(r){let c=r.runtime;a!==c.mode&&(c.mode=a),Lx.render((0,Lo.jsx)(wn.default.StrictMode,{children:(0,Lo.jsx)(l,{children:(0,Lo.jsx)(Ru.Provider,{value:n,children:(0,Lo.jsx)(Fo.Provider,{value:a,children:(0,Lo.jsx)(Iu.Provider,{value:r,children:e})})})})}),c)}},[r,a,e]),Ys(()=>{if(r){let c=r.runtime;return()=>{Lx.unmountComponentAtNode(c)}}return()=>{}},[r]),null}),FP=class{constructor(e,t){P(this,"canvas"),P(this,"gl"),P(this,"program"),P(this,"fragmentShader"),P(this,"vertexShader"),P(this,"rectBuffer"),P(this,"fragmentShaderSource",`
|
|
12
12
|
precision mediump float;
|
|
13
13
|
|
|
14
14
|
uniform sampler2D u_image;
|
|
@@ -90,7 +90,7 @@ No matching component was found for:
|
|
|
90
90
|
justify-content: center;
|
|
91
91
|
pointer-events: visible;
|
|
92
92
|
}
|
|
93
|
-
`}),(0,wr.jsx)("div",{className:"model-container",children:(0,wr.jsx)("model-viewer",{"interaction-prompt":"none",style:{width:"100%",height:"100%"},"camera-controls":"","ar-status":"not-presenting",src:e.id})})]})}function _c({model:e,name:t}){return Ft("overlay",`model-${t}`,wm,{model:e},[e]),null}var Vw=R(B(),1);function bm(){let{strategy:e}=pt();return e.type!=="3d-model"?null:(0,Vw.jsx)(_c,{model:e.model})}var co=R(B(),1);function Cm({children:e}){let{strategy:t}=pt(),[i]=Vf();return t.type!=="images"?null:(0,co.jsxs)(co.Fragment,{children:[i?(0,co.jsx)(Sa,{page:i}):null,t.annotations&&t.annotations.pages?t.annotations.pages.map(n=>(0,co.jsx)(Sa,{page:n},n.id)):null,e]})}var br=R(q(),1),Mc=R(B(),1),Uw=(0,br.createContext)(null),Ww=(0,br.createContext)(null),Hw=(0,br.createContext)(null);function QI(){let e=(0,br.useContext)(Uw);if(!e)throw new Error("Ctx not found");return e}function $I(){let e=(0,br.useContext)(Ww);if(!e)throw new Error("Ctx not found");return e}function GI(){let e=(0,br.useContext)(Hw);if(!e)throw new Error("Ctx not found");return e}function Oa({actions:e,state:t,children:i,currentTime:n,progress:r,element:a}){return(0,Mc.jsx)(Hw.Provider,{value:{currentTime:n,progress:r,element:a},children:(0,Mc.jsx)(Ww.Provider,{value:e,children:(0,Mc.jsx)(Uw.Provider,{value:t,children:i})})})}var qw=R(q(),1);function La(){let e=vt(),t=Ce();return(0,qw.useMemo)(()=>{if(!e||!t||!e.start)return null;let i=Nt(e.start);return!i||i.source.id!==t.id||!i||!i.selector||i.selector.type!=="TemporalSelector"?null:i.selector.temporal},[e,t])}var Oc=R(B(),1);function Pm({media:e,startTime:t,children:i}){let[{element:n,currentTime:r,progress:a},l,c]=ao({duration:e.duration}),p=t?`${e.url}#t=${t}`:e.url;return(0,Oc.jsxs)(Oa,{state:l,actions:c,currentTime:r,progress:a,element:n,children:[(0,Oc.jsx)("audio",{ref:n,src:p}),i]})}function kc({media:e,mediaControlsDeps:t,audioCopmonent:i=Pm,children:n}){let r=La();return Ft("portal","audio",i,{media:e,startTime:r?r.startTime:null,children:n},[e,r,...t||[]]),null}var Em=R(B(),1);function ho({x:e=0,y:t=0}){let i=Ce(),n=Qn({maxWidth:256,maxHeight:256});return!i||!n||n.type!=="fixed"?null:(0,Em.jsx)("world-object",{height:i.height,width:i.width,x:e,y:t,children:(0,Em.jsx)("world-image",{uri:n.id,target:{x:0,y:0,width:i.width,height:i.height},display:n.width&&n.height?{width:n.width,height:n.height}:void 0,crop:void 0})})}var po=R(B(),1);function Am({as:e}){let{strategy:t}=pt(),{renderMediaControls:i,mediaControlsDeps:n}=ni();return t.type!=="media"||t.media.type!=="Sound"?null:(0,po.jsx)(po.Fragment,{children:(0,po.jsxs)(kc,{media:t.media,mediaControlsDeps:n,audioCopmonent:e,children:[(0,po.jsx)(ho,{}),i?i(t):null]},t.media.url)})}var $n=R(B(),1);function Im(){let{strategy:e}=pt(),{renderViewerControls:t,viewControlsDeps:i}=ni(),n=Ce(),r=n?.accompanyingCanvas,a=n?.placeholderCanvas;return(0,$n.jsxs)($n.Fragment,{children:[e.type==="media"&&e.media.type==="Sound"&&r?(0,$n.jsx)(Vi,{canvas:r.id,children:(0,$n.jsx)(fo,{renderViewerControls:t,viewControlsDeps:i})}):null,e.type==="media"&&e.media.type==="Sound"&&a&&!r?(0,$n.jsx)(Vi,{canvas:a.id,children:(0,$n.jsx)(fo,{renderViewerControls:t,viewControlsDeps:i})}):null]})}var za=R(B(),1);function Rm({element:e,media:t,startTime:i,playPause:n,poster:r}){let a="div",l=i?`${t.url}#t=${i}`:t.url;return(0,za.jsxs)(a,{className:"video-container",part:"video-container",onClick:n,children:[(0,za.jsx)("style",{children:`
|
|
93
|
+
`}),(0,wr.jsx)("div",{className:"model-container",children:(0,wr.jsx)("model-viewer",{"interaction-prompt":"none",style:{width:"100%",height:"100%"},"camera-controls":"","ar-status":"not-presenting",src:e.id})})]})}function _c({model:e,name:t}){return Ft("overlay",`model-${t}`,wm,{model:e},[e]),null}var Vw=R(B(),1);function bm(){let{strategy:e}=pt();return e.type!=="3d-model"?null:(0,Vw.jsx)(_c,{model:e.model})}var co=R(B(),1);function Cm({children:e}){let{strategy:t}=pt(),[i]=Vf();return t.type!=="images"?null:(0,co.jsxs)(co.Fragment,{children:[i?(0,co.jsx)(Sa,{page:i}):null,t.annotations&&t.annotations.pages?t.annotations.pages.map(n=>(0,co.jsx)(Sa,{page:n},n.id)):null,e]})}var br=R(q(),1),Mc=R(B(),1),Uw=(0,br.createContext)(null),Ww=(0,br.createContext)(null),Hw=(0,br.createContext)(null);function QI(){let e=(0,br.useContext)(Uw);if(!e)throw new Error("Ctx not found");return e}function $I(){let e=(0,br.useContext)(Ww);if(!e)throw new Error("Ctx not found");return e}function GI(){let e=(0,br.useContext)(Hw);if(!e)throw new Error("Ctx not found");return e}function Oa({actions:e,state:t,children:i,currentTime:n,progress:r,element:a}){return console.log(t.duration),(0,Mc.jsx)(Hw.Provider,{value:{currentTime:n,progress:r,element:a},children:(0,Mc.jsx)(Ww.Provider,{value:e,children:(0,Mc.jsx)(Uw.Provider,{value:t,children:i})})})}var qw=R(q(),1);function La(){let e=vt(),t=Ce();return(0,qw.useMemo)(()=>{if(!e||!t||!e.start)return null;let i=Nt(e.start);return!i||i.source.id!==t.id||!i||!i.selector||i.selector.type!=="TemporalSelector"?null:i.selector.temporal},[e,t])}var Oc=R(B(),1);function Pm({media:e,startTime:t,children:i}){let[{element:n,currentTime:r,progress:a},l,c]=ao({duration:e.duration}),p=t?`${e.url}#t=${t}`:e.url;return(0,Oc.jsxs)(Oa,{state:l,actions:c,currentTime:r,progress:a,element:n,children:[(0,Oc.jsx)("audio",{ref:n,src:p}),i]},e.url)}function kc({media:e,mediaControlsDeps:t,audioCopmonent:i=Pm,children:n}){let r=La();return Ft("portal","audio",i,{media:e,startTime:r?r.startTime:null,children:n},[e,r,...t||[]]),null}var Em=R(B(),1);function ho({x:e=0,y:t=0}){let i=Ce(),n=Qn({maxWidth:256,maxHeight:256});return!i||!n||n.type!=="fixed"?null:(0,Em.jsx)("world-object",{height:i.height,width:i.width,x:e,y:t,children:(0,Em.jsx)("world-image",{uri:n.id,target:{x:0,y:0,width:i.width,height:i.height},display:n.width&&n.height?{width:n.width,height:n.height}:void 0,crop:void 0})})}var po=R(B(),1);function Am({as:e}){let{strategy:t}=pt(),{renderMediaControls:i,mediaControlsDeps:n}=ni();return t.type!=="media"||t.media.type!=="Sound"?null:(0,po.jsx)(po.Fragment,{children:(0,po.jsxs)(kc,{media:t.media,mediaControlsDeps:n,audioCopmonent:e,children:[(0,po.jsx)(ho,{}),i?i(t):null]},t.media.url)})}var $n=R(B(),1);function Im(){let{strategy:e}=pt(),{renderViewerControls:t,viewControlsDeps:i}=ni(),n=Ce(),r=n?.accompanyingCanvas,a=n?.placeholderCanvas;return(0,$n.jsxs)($n.Fragment,{children:[e.type==="media"&&e.media.type==="Sound"&&r?(0,$n.jsx)(Vi,{canvas:r.id,children:(0,$n.jsx)(fo,{renderViewerControls:t,viewControlsDeps:i})}):null,e.type==="media"&&e.media.type==="Sound"&&a&&!r?(0,$n.jsx)(Vi,{canvas:a.id,children:(0,$n.jsx)(fo,{renderViewerControls:t,viewControlsDeps:i})}):null]})}var za=R(B(),1);function Rm({element:e,media:t,startTime:i,playPause:n,poster:r}){let a="div",l=i?`${t.url}#t=${i}`:t.url;return(0,za.jsxs)(a,{className:"video-container",part:"video-container",onClick:n,children:[(0,za.jsx)("style",{children:`
|
|
94
94
|
.video-container {
|
|
95
95
|
position: absolute;
|
|
96
96
|
top: 0;
|