react-iiif-vault 1.5.3 → 1.5.5
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(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;
|
|
@@ -121,7 +121,7 @@ No matching component was found for:
|
|
|
121
121
|
width: 100%;
|
|
122
122
|
object-fit: contain;
|
|
123
123
|
}
|
|
124
|
-
`}),(0,Fa.jsx)("iframe",{className:"video-yt",ref:n,src:`https://www.youtube.com/embed/${t.youTubeId}?enablejsapi=1&origin=${window.location.host}`,referrerPolicy:"no-referrer",sandbox:"allow-scripts allow-same-origin allow-presentation"})]}):null}function $w({media:e,mediaControlsDeps:t,children:i}){let[{element:n,currentTime:r,progress:a},l,c]=ao({duration:e.duration});return Ft("overlay","video-element",YI,{element:n,media:e,playPause:c.playPause}),null}var Fc=R(B(),1);function _m(){let{strategy:e}=pt(),{renderMediaControls:t,mediaControlsDeps:i}=ni();return e.type!=="media"||e.media.type!=="VideoYouTube"?null:(0,Fc.jsxs)($w,{media:e.media,mediaControlsDeps:i,children:[(0,Fc.jsx)(ho,{}),t?t(e):null]})}var gi=R(B(),1);function fo({x:e,y:t,onChoiceChange:i,registerActions:n,defaultChoices:r,isStatic:a,renderViewerControls:l,renderMediaControls:c,renderComplexTimelineControls:p,complexTimelineControlsDeps:m,viewControlsDeps:h,mediaControlsDeps:y,strategies:S,throwOnUnknown:w,backgroundStyle:v,alwaysShowBackground:x,keepCanvasScale:A=!1,enableSizes:C=!1,enableYouTube:I=!0,onClickPaintingAnnotation:E,components:L={},children:z}){return(0,gi.jsxs)(cm,{throwOnUnknown:w,onChoiceChange:i,registerActions:n,strategies:S,defaultChoices:r,mediaControlsDeps:y,renderMediaControls:c,renderViewerControls:l,renderComplexTimelineControls:p,complexTimelineControlsDeps:m,viewControlsDeps:h,children:[(0,gi.jsxs)(dm,{keepCanvasScale:A,x:e,y:t,children:[(0,gi.jsx)(hm,{alwaysShowBackground:x,backgroundStyle:v}),(0,gi.jsx)(ym,{}),(0,gi.jsx)(vm,{}),(0,gi.jsx)(Sm,{isStatic:a,enableSizes:C,onClickPaintingAnnotation:E}),(0,gi.jsx)(Cm,{}),(0,gi.jsx)(bm,{}),(0,gi.jsx)(Am,{as:L.Audio}),(0,gi.jsx)(Tm,{as:L.Video}),I?(0,gi.jsx)(_m,{}):null,z]}),(0,gi.jsx)(Im,{})]})}var Mm=R(B(),1);function Gw(e){let t=Ce();return!t||!t.placeholderCanvas?null:(0,Mm.jsx)(Vi,{canvas:t.placeholderCanvas.id,children:(0,Mm.jsx)(fo,{renderViewerControls:e.renderViewerControls})})}var ri=R(B(),1),XI=(0,Na.forwardRef)(function(t,i){let n=vt(),r=eo(),a=ha(),{ViewerControls:l,MediaControls:c,ComplexTimelineControls:p}=t.components||{};if((0,Na.useImperativeHandle)(i,()=>a,[a]),!n)return(0,ri.jsx)("div",{});let m=0;return(0,ri.jsxs)(ri.Fragment,{children:[t.header,(0,ri.jsx)(Bt.Viewer,{height:t.height,mode:t.mode,renderPreset:t.renderPreset,runtimeOptions:t.runtimeOptions,children:r.map((h,y)=>{let S=m;return m+=h.width+(t.spacing||0),(0,ri.jsx)(Vi,{canvas:h.id,children:(0,ri.jsx)(Bt.RenderCanvas,{strategies:["3d-model","media","images","empty","textual-content","complex-timeline"],renderViewerControls:y===0&&l?()=>(0,ri.jsx)(l,{}):void 0,renderMediaControls:y===0&&c?()=>(0,ri.jsx)(c,{}):void 0,renderComplexTimelineControls:y===0&&p?()=>(0,ri.jsx)(p,{}):void 0,x:S,...t.canvasProps||{},children:t.annotations},h.id)},h.id)})},t.reuseAtlas?"":a.currentSequenceIndex),t.children]})}),Bt=(0,Na.forwardRef)(function({children:t,height:i,annotations:n,canvasProps:r,spacing:a,header:l,components:c,mode:p,reuseAtlas:m,renderPreset:h,runtimeOptions:y,...S},w){let v=Zr();return(0,ri.jsx)(Kr,{vault:v,children:(0,ri.jsx)(Lf,{...S,children:(0,ri.jsx)(XI,{ref:w,height:i,components:c,spacing:a,canvasProps:r,annotations:n,header:l,mode:p,reuseAtlas:m,renderPreset:h,runtimeOptions:y,children:t})})})});Bt.RenderImage=xr;Bt.RenderCanvas=fo;Bt.RenderAnnotationPage=Sa;Bt.RenderAnnotation=yc;Bt.Viewer=fc;Bt.CanvasBackground=Cc;Bt.Audio=kc;Bt.Video=Lc;Bt.Model=_c;Bt.AudioHTML=Pm;Bt.VideoHTML=Rm;Bt.ModelHTML=wm;Bt.PlaceholderCanvas=Gw;var Nc=R(q(),1),Ba=R(B(),1),KI=(0,Nc.forwardRef)(function({canvasId:t},i){let n=Ou(),r=Pa(t||n?.id),a=_e();return(0,Nc.useImperativeHandle)(i,()=>r,[t,n]),!n||r.enabledPageIds.length===0?null:(0,Ba.jsx)(Ba.Fragment,{children:r.enabledPageIds.map(l=>(0,Ba.jsx)(Bt.RenderAnnotationPage,{page:a.get(l)},l))})});var Xw=R(q(),1);var Yw=R(q(),1);var Pt=R(B(),1);function Da({metadata:e=[],config:t,labelWidth:i=16,showEmptyMessage:n=!0,allowHtml:r,emptyFallback:a,classes:l={},emptyMessage:c="No metadata available",emptyValueFallback:p="No value",emptyLabelFallback:m="",separator:h,tableFooter:y,tableHeader:S}){let w=(0,Yw.useMemo)(()=>{let x=(t||[]).reduce((C,I)=>[...C,...I.keys],[]),A={};for(let C of e){let I=C&&C.label?Object.values(C.label):[];for(let E of I)if(E&&E.length&&(x.indexOf(`metadata.${E[0]}`)!==-1||x.length===0)&&C){let L=`metadata.${E[0]}`;A[L]=A[L]?A[L]:[],A[L].push(C);break}}return A},[t,e]);return Object.keys(w).length===0&&n?(0,Pt.jsx)(Pt.Fragment,{children:a})||(0,Pt.jsx)("div",{className:l.empty,children:c}):t&&t.length?(0,Pt.jsxs)("table",{className:l.container,children:[S,(0,Pt.jsx)("tbody",{children:t.map((x,A)=>{let C=[];for(let I of x.keys)for(let E of w[I]||[])C.push((0,Pt.jsx)(Ii,{enableDangerouslySetInnerHTML:r,defaultText:p,separator:h,children:E.value},A+"__"+I));return C.length===0?null:(0,Pt.jsxs)("tr",{className:l.row,children:[(0,Pt.jsx)("td",{className:l.label,style:i?{minWidth:i}:{},children:(0,Pt.jsx)(Ii,{enableDangerouslySetInnerHTML:r,separator:h,defaultText:m,children:x.label})}),(0,Pt.jsx)("td",{className:l.value,children:C})]},A)})}),y]}):(0,Pt.jsxs)("table",{className:l.container,children:[S,(0,Pt.jsx)("tbody",{children:e&&e.length?e.map((x,A)=>x?(0,Pt.jsxs)("tr",{className:l.row,children:[(0,Pt.jsx)("td",{className:l.label,style:i?{minWidth:i}:{},children:(0,Pt.jsx)(Ii,{enableDangerouslySetInnerHTML:r,defaultText:p,separator:h,children:x.label})}),(0,Pt.jsx)("td",{className:l.value,children:(0,Pt.jsx)(Ii,{enableDangerouslySetInnerHTML:r,defaultText:p,separator:h,children:x.value})})]},A):null):null}),y]})}var Kw=R(B(),1);function ZI(e){let t=vt(),i=Ce(),n=la(),r=(0,Xw.useMemo)(()=>{let a=t?.metadata||[],l=i?.metadata||[],c=n?.metadata||[];return[...a,...l,...c]},[t,i,n]);return(0,Kw.jsx)(Da,{metadata:r,...e})}var Dc=R(q(),1);var Zw=R(q(),1);function Bc(e,t={},i=[]){return(0,Zw.useMemo)(()=>{if(!e)return null;let n=t.quality;e&&e.extraQualities&&t.quality&&(e.extraQualities.includes(t.quality)||(n="default"));let r=nu(e);return iu({identifier:r.identifier,server:r.server,scheme:r.scheme,type:"image",size:{max:!t.size?.width&&!t.size?.height,confined:!1,upscaled:!1,...t.size||{}},format:t.format||"jpg",region:t.region||{full:!0},rotation:t?.rotation?Number.isInteger(t.rotation)?{angle:t.rotation}:t.rotation:{angle:0},quality:n||"default",prefix:r.prefix,originalPath:r.originalPath})},[...i])}var ja=R(B(),1);function JI(e){let t=typeof e.src=="string"?e.src:e.src.id,i=ka(),[n,r]=(0,Dc.useState)(!1),a;if(t){let c=i.loadServiceSync({id:t});c&&(a=c)}!a&&!n&&i.loadService({id:t}).then(()=>{r(!0)});let l=Bc(a,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[n,e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return(0,Dc.useEffect)(()=>()=>{r(!1)},[t]),l?(0,ja.jsx)("img",{src:l,alt:e.alt,className:e.className,style:e.style}):(0,ja.jsx)(Jw,{...e,fetchImageService:!1})}function Jw(e){if(e.fetchImageService)return(0,ja.jsx)(JI,{...e});let t=typeof e.src=="string"?{id:e.src,profile:"level0"}:e.src,i=Bc(t,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return i?(0,ja.jsx)("img",{src:i,alt:e.alt,className:e.className,style:e.style}):null}var e1=R(B(),1);function eR(e){let t=vt();return(0,e1.jsx)(Da,{metadata:t?.metadata||[],...e})}var jc=R(q(),1);var km=R(i1(),1);var yi=R(B(),1),{LazyLoadComponent:tR}=km||km.default;function Om(e){let{size:t,visible:i,classes:n,canvasId:r,figure:a}=e,l=t?.width||128,c=t?.height||t?.width||128,p=(0,yi.jsx)(iR,{...e}),m=(0,yi.jsx)(tR,{threshold:300,style:{height:c,width:l},visibleByDefault:i,children:r?(0,yi.jsx)(Vi,{canvas:r,children:p}):p});return a?(0,yi.jsx)("figure",{className:n?.figure,children:m}):m}function iR({fallback:e,size:t,classes:i,showLabel:n,alt:r,dereference:a=!1}){let l=Ce(),c=t?.width||128,p=t?.height||t?.width||128,m=r||Zf(l?.label)||"",h=Qn({width:c,height:p,allowUnsafe:!0},a);return!h||h.type!=="fixed"?(0,yi.jsx)(yi.Fragment,{children:e}):(0,yi.jsxs)(yi.Fragment,{children:[(0,yi.jsx)("div",{className:i?.imageWrapper,children:(0,yi.jsx)("img",{className:i?.img,src:h.id,alt:m})}),n?(0,yi.jsx)(Ii,{as:"figcaption",className:i?.label,children:l?.label}):null]})}var cs=R(B(),1);function nR({scrollBehaviour:e,dereference:t,flat:i,size:n,classes:r={},showLabel:a,figure:l,fallback:c}){let p=(0,jc.useRef)(null),{items:m,sequence:h,currentSequenceIndex:y,setSequenceIndex:S}=ha(),w={row:r.selected?.row||r.row,item:r.selected?.item||r.item,figure:r.selected?.figure||r.figure,img:r.selected?.img||r.img,label:r.selected?.label||r.label,imageWrapper:r.selected?.imageWrapper||r.imageWrapper};(0,jc.useLayoutEffect)(()=>{if(!p.current)return;let x=p.current.querySelector("[data-selected=true]");x&&x.scrollIntoView({behavior:e||"instant",block:"nearest",inline:"center"})},[y]);let v=[];for(let x of h){let A=[],C=h[y]===x;for(let I of x){let E=m[I];A.push((0,cs.jsx)("div",{className:C?w.item:r.item,children:(0,cs.jsx)(Om,{classes:C?w:r,canvasId:E.id,size:n,dereference:t,showLabel:a,figure:l,placeholder:(0,cs.jsx)("div",{style:{height:128,width:128}}),fallback:c})},I))}if(i){v.push(A);continue}v.push((0,cs.jsx)("div",{onClick:I=>{S(h.indexOf(x))},"data-selected":C,className:C?w.row:r.row,children:A},x.join("-")))}return(0,cs.jsx)("div",{ref:p,className:r.container,children:v})}var oi=R(B(),1),rR={draw:!0,polygon:!0,line:!0,lineBox:!0,square:!0,triangle:!0,hexagon:!0,circle:!0,delete:!0};function oR({helper:e,showShapes:t,state:i,enabled:n=rR,classNames:r={},icons:a={}}){return(0,oi.jsxs)(oi.Fragment,{children:[t?(0,oi.jsxs)(oi.Fragment,{children:[n.draw&&(0,oi.jsx)("button",{className:r.button,onClick:()=>{e.stamps.clear(),e.draw.enable()},"data-active":!i.lineMode&&!i.selectedStamp&&t&&i.drawMode,children:a.DrawIcon||"Draw"}),n.polygon&&(0,oi.jsx)("button",{className:r.button,"data-active":!i.lineMode&&!i.selectedStamp&&t&&!i.drawMode,onClick:()=>{e.stamps.clear(),e.draw.disable(),e.modes.disableLineBoxMode(),e.modes.disableLineMode()},children:a.PolygonIcon||"Polygon"}),n.line&&(0,oi.jsx)("button",{className:r.button,"data-active":i.lineMode&&!i.lineBoxMode,onClick:()=>{e.modes.enableLineMode()},children:a.LineIcon||"Line"}),n.lineBox&&(0,oi.jsx)("button",{className:r.button,"data-active":i.lineBoxMode,onClick:()=>{e.modes.enableLineBoxMode()},children:a.LineBoxIcon||"LineBox"}),n.square&&(0,oi.jsx)("button",{className:r.button,"data-active":i.selectedStamp?.id==="square",onClick:()=>{e.stamps.square()},children:a.SquareIcon||"Square"}),n.triangle&&(0,oi.jsx)("button",{className:r.button,"data-active":i.selectedStamp?.id==="triangle",onClick:()=>{e.stamps.triangle()},children:a.TriangleIcon||"Triangle"}),n.hexagon&&(0,oi.jsx)("button",{className:r.button,"data-active":i.selectedStamp?.id==="hexagon",onClick:()=>{e.stamps.hexagon()},children:a.HexagonIcon||"Hexagon"})]}):null,i.showBoundingBox&&n.delete&&(0,oi.jsx)("button",{className:r.button,onClick:()=>e.key.down("Backspace"),children:a.DeleteForeverIcon||"Delete"})]})}var Ut=R(q(),1);var n1=R(B(),1),Vc=(0,Ut.createContext)(Vn());Vc.displayName="SelectorHelper";function sR({children:e}){return(0,n1.jsx)(Vc.Provider,{value:(0,Ut.useMemo)(()=>Vn(),[]),children:e})}function aR(){return(0,Ut.useContext)(Vc)}function Lm(e){let t=zm(),[i,n]=(0,Ut.useState)(!1);(0,Ut.useEffect)(()=>t.withSelector(e).on("highlight",()=>{n(!0)}),[t,e]),(0,Ut.useEffect)(()=>t.withSelector(e).on("clear-highlight",()=>{n(!1)}),[t,e]);let r=(0,Ut.useCallback)(l=>{t.emit("click",{selectorId:e,event:l})},[e,t]),a=(0,Ut.useCallback)(l=>{t.emit("hover",{selectorId:e,event:l})},[e,t]);return{controller:t,onClick:r,onHover:a,isHighlighted:i}}function zm(){let e=(0,Ut.useContext)(Vc);return(0,Ut.useMemo)(()=>({withSelector(t){return{on(i,n){let r=a=>{a&&a.selectorId===t&&n(a)};return e.on(i,r),()=>{e.off(i,r)}},emit(i,n){e.emit(i,{...n,selectorId:t})}}},on(t,i){return e.on(t,i),()=>{e.off(t,i)}},emit(t,i){e.emit(t,i)}}),[e])}function lR(){let e=zm();return(0,Ut.useMemo)(()=>({withSelector(t){return{highlight(){e.emit("highlight",{selectorId:t})},clearHighlight(){e.emit("clear-highlight",{selectorId:t})},zoomTo(){e.emit("zoom-to",{selectorId:t})},addEventListener(i,n){return e.emit("event-listener",{selectorId:t,name:i,callback:n}),()=>{e.emit("remove-event-listener",{selectorId:t,name:i,callback:n})}},getImagePreview(){return new Promise((i,n)=>{e.emit("image-preview-request",{selectorId:t,resolve:i,reject:n})})},on(i,n){return e.withSelector(t).on(i,n)}}},highlight(t){e.emit("highlight",{selectorId:t})},clearHighlight(t){e.emit("clear-highlight",{selectorId:t})},zoomTo(t){e.emit("zoom-to",{selectorId:t})},addEventListener(t,i,n){return e.emit("event-listener",{selectorId:t,name:i,callback:n}),()=>{e.emit("remove-event-listener",{selectorId:t,name:i,callback:n})}},getImagePreview(t){return new Promise((i,n)=>{e.emit("image-preview-request",{selectorId:t,resolve:i,reject:n})})},on(t,i){return e.on(t,i)}}),[e])}var ds=R(q(),1),r1=R(B(),1);function Fm(){return{default:{backgroundColor:"rgba(0,0,0,0)",borderWidth:"2px",borderColor:"rgba(252,0,98, .5)"},highlighted:{backgroundColor:"rgba(75, 103, 225, 0.4)",borderWidth:"1px",borderColor:"rgba(75,103,225,0.99)"},hidden:{borderWidth:"0px",borderColor:"rgba(0,0,0,0)",backgroundColor:"rgba(0,0,0,0)",hidden:!0}}}var Nm=(0,ds.createContext)(Fm());Nm.displayName="AnnotationStyle";function Bm(){return(0,ds.useContext)(Nm)}function uR({theme:e,children:t}){let i=(0,ds.useMemo)(()=>e||Fm(),[e]);return(0,r1.jsx)(Nm.Provider,{value:i,children:t})}var si=R(q(),1);var hs=R(q(),1);function l1(e){let t=e.points.length,i=!1,n=[];if(t>1){e.iedges=[];let r=e.points[t-1];for(let a=0;a<t;a++){let l=r;if(r=e.points[a],r.length===6){let m=r[2],h=r[3],y=r[4],S=r[5];n.push([a,[r[0]+m,r[1]+h],[r[0]+y,r[1]+S]]),i=!0}let c=[r[0]-l[0],r[1]-l[1]],p=c[0]*c[0]+c[1]*c[1];p>0?e.iedges.push([c[0]/p,c[1]/p]):e.iedges.push([0,0])}}else t===1?e.iedges=[[0,0]]:e.iedges=null;e.isBezier=i,e.bezierLines=n}function cR(e,t){let i=1/0,n=null,r=-1,a=e.points.length;if(a<=1)return[null,i,r];let l=e.points[a-1];for(let c=0;c<a;c++){let p=l;l=e.points[c];let m=p[0]-t[0],h=p[1]-t[1],y=m*m+h*h;y<i&&(n=p,i=y,r=c===0?a-1:c-1)}return[n,i,r]}function qc(e){if(e.points.length>2){let t=Math.min(...e.points.map(a=>a[0])),i=Math.min(...e.points.map(a=>a[1])),n=Math.max(0,...e.points.map(a=>a[0])),r=Math.max(0,...e.points.map(a=>a[1]));e.boundingBox={x:t,y:i,width:n-t,height:r-i};return}e.boundingBox=null}function dR(e){return e[0]*e[0]+e[1]*e[1]}function o1(e,t){let i=1/0,n=null,r=-1,a=[],l=e.points.length;if(l<=1)return[null,i,a,r];if(e.iedges===null&&(l1(e),!e.iedges))return[null,i,a,r];let c=e.points[l-1];for(let p=0;p<l;p++){let m=c;c=e.points[p];let h=(t[0]-m[0])*e.iedges[p][0]+(t[1]-m[1])*e.iedges[p][1],y;h<=0?y=m:h<1?y=[(1-h)*m[0]+h*c[0],(1-h)*m[1]+h*c[1]]:y=c;let S=dR([y[0]-t[0],y[1]-t[1]]);S<i&&(n=y,i=S,a=[m,c],r=p===0?l-1:p-1)}return[n,i,a,r]}var u1={type:"move-bounding-box",label:"Move bounding box",isValid(e,t,i){let n=t.polygon.points.length,r=n===t.selectedPoints.length,a=t.polygon.boundingBox;if(n<1||!r||!a)return!1;let l=e[0],c=l[0],p=l[1];return c>=a.x&&c<=a.x+a.width&&p>=a.y&&p<=a.y+a.height},transition(e,t,i){let n=t.transitionOrigin,r=t.polygon.boundingBox,a=e[0],l=a[0]-n[0],c=a[1]-n[1];t.transitionPoints=t.polygon.points.map(p=>p.length===6?[p[0]+l,p[1]+c,p[2],p[3],p[4],p[5]]:[p[0]+l,p[1]+c]),r&&(t.transitionBoundingBox={x:r.x+l,y:r.y+c,width:r.width,height:r.height})},commit(e,t,i){let n=t.transitionPoints;return t.transitionPoints=null,t.transitionBoundingBox=null,{points:n}}},c1={type:"move-shape",label:"Move shape",isValid(e,t,i){return i.Shift?!1:t.slowState.pointerInsideShape&&(!t.isOpen||t.line===null)},transition(e,t,i){u1.transition(e,t,i)},commit(e,t,i){let n=t.transitionPoints;return t.transitionPoints=null,t.transitionBoundingBox=null,{points:n}}};function s1(e,t){return Math.abs(e-t)}function qi(e,t){let i=s1(e[0],t[0]),n=s1(e[1],t[1]);return Math.sqrt(Math.pow(i,2)+Math.pow(n,2))}function Dm(e,t){return[e[0]-t[0],e[1]-t[1]]}function hR(e,t){return e[0]*t[0]+e[1]*t[1]}function d1(e){return e[0]*e[0]+e[1]*e[1]}function Uc(e,t){return d1(Dm(e,t))}function h1(e,t){let i,n,r,a;var l=function(v,x,A,C,I){if(C<=A+1)return;let E=A,L=0,z=v*v;i=[x[A],x[C]],n=Dm(i[1],i[0]);let M=d1(n),Q,V,J,U,W;for(let ee=A+1;ee<C;ee++)Q=Dm(x[ee],i[0]),U=hR(Q,n),U<=0?W=Uc(x[ee],i[0]):M<=U?W=Uc(x[ee],i[1]):(J=U/M,V=[i[0][0]+J*n[0],i[0][1]+J*n[1]],W=Uc(x[ee],V)),!(W<=L)&&(E=ee,L=W);L>z&&(I[E]=1,l(v,x,A,E,I),l(v,x,E,C,I))};let c=e.length,p=[],m,h,y,S,w=t*t;for(r=[],a=[],r[0]=e[0],m=h=1,S=0;m<c;m++)Uc(e[m],e[S])<w||(r[h++]=e[m],S=m);for(S<c-1&&(r[h++]=e[c-1]),a[0]=a[h-1]=1,l(t,r,0,h-1,a),m=y=0;m<h;m++)a[m]&&(p[y++]=r[m]);return p}var pR={type:"move-point",label:"Move point",modifiers:{Shift:"Constrain to axis"},isValid(e,t,i){if(i.Alt)return!1;let n=i.proximity,[r,a]=e[0],l=t.polygon.points,c=t.selectedPoints;for(let p=0;p<l.length;p++){let m=l[p],h=m[0]-r,y=m[1]-a;if(h*h+y*y<n*n)return!0}return!1},start(e,t,i){if(t.selectedPoints.length<2){let[n,r,a]=cR(t.polygon,e[0]);return{selectedPoints:[a]}}if(t.slowState.closestPoint&&!t.selectedPoints.includes(t.slowState.closestPoint))return{selectedPoints:[t.slowState.closestPoint]}},transition(e,t,i){let n=t.transitionOrigin,[r,a]=e[0],l=t.polygon.points,c=t.selectedPoints;if(t.slowState.closestPoint){let y=t.slowState.closestPoint;c.indexOf(y)===-1&&(c=[y])}let p=[],m=r-n[0],h=a-n[1];i.Shift&&(Math.abs(m)>Math.abs(h)?h=0:m=0);for(let y=0;y<l.length;y++){let S=c.indexOf(y)!==-1,w=l[y];S?w.length===6?p.push([w[0]+m,w[1]+h,w[2],w[3],w[4],w[5]]):p.push([w[0]+m,w[1]+h]):p.push(w)}t.transitionPoints=p},commit(e,t,i){let n=t.transitionPoints;return t.transitionPoints=null,t.transitionBoundingBox=null,{points:n}}},a1=10,fR={type:"select-point",label:"Select point",trigger:{type:"click"},modifiers:{Shift:"Add to selection"},isValid(e,t,i){let n=-1;if(t.selectedPoints.length===1){let c=t.selectedPoints[0];c===0&&(n=t.polygon.points.length-1),c===t.polygon.points.length-1&&(n=0)}let[r,a]=e[0],l=t.polygon.points;for(let c=0;c<l.length;c++){let p=l[c],m=p[0]-r,h=p[1]-a;if(m*m+h*h<a1*a1)return n!==c}return!1},commit(e,t,i){let n=i.Shift?[...t.selectedPoints]:[],[r,a]=e[0],l=t.polygon.points.map((c,p)=>{let m=c[0]-r,h=c[1]-a;return[m*m+h*h,p]}).sort((c,p)=>c[0]-p[0])[0];if(t.line=null,!n.includes(l[1]))n.push(l[1]);else if(i.Shift)return{selectedPoints:n.filter(c=>c!==l[1])};return{selectedPoints:n}}},p1={type:"split-line",label:"Split line",isValid(e,t,i){return i.Meta||t.slowState.lineMode?!1:!!(t.closestLinePoint&&t.closestLineDistance<i.proximity)},transition(e,t,i){let n=t.transitionOrigin,[r,a]=e[0],l=t.polygon.points,c=[],p=r-n[0],m=a-n[1];for(let h=0;h<l.length;h++)if(c.push(l[h]),t.closestLineIndex===h){let y=t.closestLinePoint;c.push([y[0]+p,y[1]+m])}t.transitionPoints=c},commit(e,t,i){let n=t.transitionPoints;return t.transitionPoints=null,t.transitionBoundingBox=null,{selectedPoints:[t.closestLineIndex+1],points:n}}},mR={type:"add-open-point",label:"Add point",trigger:{type:"click"},isValid(e,t,i){if(!t.isOpen)return!1;if(t.polygon.points.length===0)return!0;if(t.selectedPoints.length!==1||t.polygon.points.length>=2&&t.slowState.lineMode)return!1;let n=t.selectedPoints[0];return n===0||n===t.polygon.points.length-1},commit(e,t,i){let n=t.line?t.line[1]:e[0],r=t.polygon.points;return r.length===0?{selectedPoints:[0],points:[e[0]]}:(i.Shift,t.selectedPoints[0]===0?{selectedPoints:t.slowState.lineMode?[]:[0],points:[n,...r]}:(t.line=null,{selectedPoints:t.slowState.lineMode?[]:[r.length],points:[...r,n]}))}},f1={type:"close-shape",label:"Close shape",trigger:{type:"click"},isValid(e,t,i){if(!t.isOpen||t.selectedPoints.length!==1||t.polygon.points.length<2||i.Meta)return!1;let n=t.selectedPoints[0];if(n===0){let r=t.polygon.points[t.polygon.points.length-1];return qi(e[0],r)<i.proximity}if(n===t.polygon.points.length-1){let r=t.polygon.points[0];return qi(e[0],r)<i.proximity}return!1},commit(e,t,i){let n=t.selectedPoints[0];if(t.line=null,n===0)return{selectedPoints:[],points:t.polygon.points.slice(0).reverse(),isOpen:!1};if(n===t.polygon.points.length-1)return{selectedPoints:[],isOpen:!1}}},gR={type:"deselect-draw",label:"Deselect draw",trigger:{type:"key",key:"Escape"},isValid(e,t,i){return!0},commit(e,t,i){return{selectedPoints:[]}}},yR={type:"select-shape",label:"Select shape",trigger:{type:"click"},isValid(e,t,i){return c1.isValid(e,t,i)},commit(e,t,i){return{selectedPoints:t.polygon.points.map((n,r)=>r)}}},vR={type:"deselect-bounding-box",label:"Deselect bounding box",trigger:{type:"click"},isValid(e,t,i){return!t.isOpen&&t.selectedPoints.length>2&&t.selectedPoints.length===t.polygon.points.length},commit(e,t,i){return{selectedPoints:[]}}},xR={type:"bounding-box-corners",label:"Drag to resize",modifiers:{Shift:"Maintain aspect ratio",Alt:"Scale from center",Meta:"Rotate"},isValid(e,t,i){if(t.transitionDirection=null,t.transitionRotate=!1,t.isOpen||t.selectedPoints.length!==t.polygon.points.length||!t.polygon.boundingBox)return!1;let n=i.proximity*.5,r=i.proximity*3,a=e[0],l=t.polygon.boundingBox,c=l.x+n,p=l.x+l.width-n*2,m=l.y+n,h=l.y+l.height-n*2;if(a[0]>c&&a[0]<p&&a[1]>m&&a[1]<h)return!1;let y=[l.x+l.width,l.y+l.height],S=[l.x,l.y],w=[l.x+l.width,l.y],v=[l.x,l.y+l.height],x=["ne","nw","se","sw"],A=[qi(e[0],w),qi(e[0],S),qi(e[0],y),qi(e[0],v)],C=Math.min(...A);if(A[0]<r||A[1]<r||A[2]<r||A[3]<r){(C>i.proximity||i.Meta)&&(t.transitionRotate=!0);let I=A.indexOf(Math.min(...A));return t.transitionDirection=I!==-1?x[I]:null,!0}return!1},start(e,t,i){let n=e[0],r=t.polygon.boundingBox,a=[r.x+r.width,r.y+r.height],l=[r.x,r.y],c=[r.x+r.width,r.y],p=[r.x,r.y+r.height],m=["ne","nw","se","sw"],h=[qi(e[0],c),qi(e[0],l),qi(e[0],a),qi(e[0],p)],y=Math.min(...h),S=h.indexOf(y);t.transitionDirection=S!==-1?m[S]:null,y>i.proximity&&(t.transitionRotate=!0)},transition(e,t,i){let n=t.polygon.boundingBox,r=[n.x,n.y],a=t.transitionOrigin||e[0],[l,c]=e[0];if(i.Meta||t.transitionRotate){r=[n.x+n.width/2,n.y+n.height/2];let v=Math.atan2(a[1]-r[1],a[0]-r[0]),x=Math.atan2(c-r[1],l-r[0]),A=i.Shift,C=Math.PI/(i.Alt?4:12),I=x-v;A&&(I=Math.round(I/C)*C);let E=Math.cos(I),L=Math.sin(I),z=[];for(let M of t.polygon.points){let Q=M[0]-r[0],V=M[1]-r[1],J=Q*E-V*L,U=Q*L+V*E,W=J+r[0],ee=U+r[1];if(M.length===6){z.push([W,ee,M[2],M[3],M[4],M[5]]);continue}z.push([W,ee])}t.transitionPoints=z,qc({points:z,iedges:null,boundingBox:null,isBezier:!1,bezierLines:[]}),t.transitionBoundingBox=t.polygon.boundingBox?{...t.polygon.boundingBox,rotation:I}:null;return}let p=0,m=0;switch(t.transitionDirection){case"se":{r=[n.x,n.y],p=l-a[0],m=c-a[1];break}case"sw":{r=[n.x+n.width,n.y],p=a[0]-l,m=c-a[1];break}case"ne":{r=[n.x,n.y+n.height],p=l-a[0],m=a[1]-c;break}case"nw":{r=[n.x+n.width,n.y+n.height],p=a[0]-l,m=a[1]-c;break}}if(i.Alt&&(r=[n.x+n.width/2,n.y+n.height/2],p*=2,m*=2),i.Shift){let v=n.width/n.height;Math.abs(n.width/p)>Math.abs(n.height/m)?m=p/v:p=m*v}let h=(n.width+p)/n.width,y=(n.height+m)/n.height,S=[];for(let v of t.polygon.points){let x=v[0]-r[0],A=v[1]-r[1],C=x*h,I=A*y,E=C+r[0],L=I+r[1];if(v.length===6){S.push([E,L,v[2],v[3],v[4],v[5]]);continue}S.push([E,L])}t.transitionPoints=S;let w={points:S,iedges:null,boundingBox:null,bezierLines:[],isBezier:!1};qc(w),t.transitionBoundingBox=w.boundingBox},commit(e,t,i){let n=t.transitionPoints;return t.transitionPoints=null,t.transitionBoundingBox=null,t.transitionRotate=!1,{points:n}}},SR={type:"cut-line",label:"Add new point",trigger:{type:"click"},modifiers:{Shift:"Cut line"},isValid(e,t,i){return p1.isValid(e,t,i)},commit(e,t,i){if(i.Shift&&!t.isOpen){let a=t.polygon.points,l=[],c=[],p=!1;for(let m=0;m<a.length;m++)p?c.push(a[m]):l.push(a[m]),t.closestLineIndex===m&&(p=!0);return{isOpen:!0,points:[...c,...l]}}let n=t.polygon.points,r=[];for(let a=0;a<n.length;a++)if(r.push(n[a]),t.closestLineIndex===a){let l=t.closestLinePoint;r.push(l)}return{points:r}}},wR={type:"select-multiple-points",label:"Drag to select multiple points",isValid(e,t,i){return t.slowState.lineMode&&t.polygon.points.length>=2?!0:!t.line},transition(e,t,i){if(!t.transitionOrigin)return;let n=t.transitionOrigin[0],r=t.transitionOrigin[1],a=e[0][0],l=e[0][1],c=Math.min(n,a),p=Math.min(r,l),m=Math.abs(n-a),h=Math.abs(r-l);t.selectionBox={x:c,y:p,width:m,height:h}},commit(e,t,i){if(t.selectionBox){let n=[];i.Shift&&n.push(...t.selectedPoints);for(let r=0;r<t.polygon.points.length;r++){let a=t.polygon.points[r];a[0]>=t.selectionBox.x&&a[0]<=t.selectionBox.x+t.selectionBox.width&&a[1]>=t.selectionBox.y&&a[1]<=t.selectionBox.y+t.selectionBox.height&&n.push(r)}return{selectedPoints:n}}}},bR={type:"deselect-points",label:"Deselect points",trigger:{type:"click"},isValid(e,t,i){return t.selectedPoints.length>0},commit(e,t,i){return{selectedPoints:[]}}},Qc=4,CR={type:"nudge-right",label:"Nudge right",trigger:{type:"key",key:"ArrowRight"},modifiers:{Shift:"Nudge right more"},isValid(e,t,i){return t.selectedPoints.length>0},commit(e,t,i){let n=i.proximity*.3,r=t.polygon.points,a=t.selectedPoints;return{points:r.map((l,c)=>a.includes(c)?[l[0]+(i.Shift?Qc*n:1),l[1]]:l)}}},PR={type:"nudge-left",label:"Nudge left",trigger:{type:"key",key:"ArrowLeft"},modifiers:{Shift:"Nudge left more"},isValid(e,t,i){return t.selectedPoints.length>0},commit(e,t,i){let n=i.proximity*.3,r=t.polygon.points,a=t.selectedPoints;return{points:r.map((l,c)=>a.includes(c)?[Math.max(0,l[0]-(i.Shift?Qc*n:1)),l[1]]:l)}}},ER={type:"nudge-up",label:"Nudge up",trigger:{type:"key",key:"ArrowUp"},modifiers:{Shift:"Nudge up more"},isValid(e,t,i){return t.selectedPoints.length>0},commit(e,t,i){let n=i.proximity*.3,r=t.polygon.points,a=t.selectedPoints;return{points:r.map((l,c)=>{if(a.includes(c)){let p=l[0],m=Math.max(0,l[1]-(i.Shift?Qc*n:1));return l.length===6?[p,m,l[2],l[3],l[4],l[5]]:[p,m]}return l})}}},AR={type:"nudge-down",label:"Nudge down",trigger:{type:"key",key:"ArrowDown"},modifiers:{Shift:"Nudge down more"},isValid(e,t,i){return t.selectedPoints.length>0},commit(e,t,i){let n=i.proximity*.3,r=t.polygon.points,a=t.selectedPoints;return{points:r.map((l,c)=>{let p=l[0],m=Math.max(0,l[1]-(i.Shift?Qc*n:1));return a.includes(c)?l.length===6?[p,m,l[2],l[3],l[4],l[5]]:[p,m]:l})}}},IR={type:"delete-point",label:"Delete point",trigger:{type:"key",key:"Backspace"},isValid(e,t,i){return t.selectedPoints.length>0},commit(e,t,i){let n=t.polygon.points.filter((r,a)=>!t.selectedPoints.includes(a));return{isOpen:n.length<3,selectedPoints:[],points:n}}},RR={type:"draw-shape",label:"Draw shape",isValid(e,t,i){let n=i.Alt||t.slowState.drawMode;return!!(t.isOpen&&(t.line||t.polygon.points.length===0)&&n)},start(e,t,i){t.transitionDraw=[]},transition(e,t,i){t.transitionDraw.push(e[0])},commit(e,t,i){let n=h1(t.transitionDraw,t.scale*3);return t.transitionDraw=[],t.selectedPoints[0]===0?{isOpen:!1,points:[...n,...t.polygon.points.slice(0).reverse()]}:{isOpen:!1,points:[...t.polygon.points,...n]}}},TR={type:"stamp-shape",label:"Stamp shape",modifiers:{Shift:"Maintain aspect ratio"},isValid(e,t,i){return t.slowState.selectedStamp!==null},start(e,t,i){let n=e[0];if(n&&t.slowState.selectedStamp){let r=t.slowState.selectedStamp,a=n[0],l=n[1],c=[],p=Math.min(...r.points.map(x=>x[0])),m=Math.min(...r.points.map(x=>x[1])),h=Math.max(...r.points.map(x=>x[0]))-p,y=Math.max(...r.points.map(x=>x[1]))-m,S=h/32;y/32>S&&(S=y/32);let w=[],v=0;for(let x of r.points)w.push(v),c.push([a+(x[0]-p)/S,l+(x[1]-m)/S]),v++;return t.transitionPoints=c,{isOpen:!1,selectedPoints:w,points:c}}},transition(e,t,i){if(!t.transitionOrigin)return;let n=t.polygon.boundingBox,r=[n.x,n.y],a=t.transitionOrigin||e[0],[l,c]=e[0],p=t.transitionOrigin[0],m=t.transitionOrigin[1],h=e[0][0],y=e[0][1],S=h-p-32,w=y-m-32;if(i.Shift){let I=n.width/n.height;Math.abs(n.width/S)>Math.abs(n.height/w)?w=S/I:S=w*I}let v=(n.width+S)/n.width,x=(n.height+w)/n.height,A=[];for(let I of t.polygon.points){let E=I[0]-r[0],L=I[1]-r[1],z=E*v,M=L*x,Q=z+r[0],V=M+r[1];if(I.length===6){A.push([Q,V,I[2],I[3],I[4],I[5]]);continue}A.push([Q,V])}t.transitionPoints=A;let C={points:A,iedges:null,boundingBox:null,bezierLines:[],isBezier:!1};qc(C),t.transitionBoundingBox=C.boundingBox},commit(e,t,i){return{isOpen:!1,points:t.transitionPoints}}},_R={type:"close-shape-line",label:"Close shape line",trigger:{type:"click"},isValid(e,t,i){return!t.isOpen||t.polygon.points.length<3||!t.closestLinePoint||t.closestLineDistance>=i.proximity?!1:(t.closestLineIndex===0||(t.closestLineIndex,t.polygon.points.length-2),!0)},commit(e,t,i){return f1.commit(e,t,i)}},MR={type:"stamp-fixed-size-shape",label:"Stamp fixed size shape",trigger:{type:"click"},isValid(e,t,i){return t.slowState.selectedStamp!==null},commit(e,t,i){let n=e[0],r=t.slowState.selectedStamp;if(!n||!r)return;let a=n[0],l=n[1],c=[],p=Math.min(...r.points.map(x=>x[0])),m=Math.min(...r.points.map(x=>x[1])),h=Math.max(...r.points.map(x=>x[0]))-p,y=Math.max(...r.points.map(x=>x[1]))-m,S=4*i.proximity,w=h/S;y/S>w&&(w=y/S),a-=h/w/2,l-=y/w/2;let v=0;for(let x of r.points)c.push([a+(x[0]-p)/w,l+(x[1]-m)/w]),v++;return{isOpen:!1,points:c}}},kR={type:"move-line",label:"Move line",isValid(e,t,i){return t.slowState.lineMode?!!(t.closestLinePoint&&t.closestLineDistance<i.proximity):!1},transition(e,t){let i=t.transitionOrigin,n=t.polygon.boundingBox,r=e[0],a=r[0]-i[0],l=r[1]-i[1];t.transitionPoints=t.polygon.points.map(c=>c.length===6?[c[0]+a,c[1]+l,c[2],c[3],c[4],c[5]]:[c[0]+a,c[1]+l])},commit(e,t,i){let n=t.transitionPoints;return t.transitionPoints=null,t.transitionBoundingBox=null,{points:n}}},OR={type:"close-line-box",label:"Close Line Box",trigger:{type:"click"},isValid(e,t,i){return t.slowState.lineBoxMode===!0&&t.polygon.points.length===2&&t.lineBox!==null},commit(e,t,i){return t.lineBox?{isOpen:!1,points:t.lineBox}:{}}};function m1(e={}){let t=e.proximityThreshold||10,i=e.closestLinePointFill||{selected:"#fff",unselected:"rgba(255, 255, 255, .5)"},n=e.closestLinePointStroke||{selected:"#000",unselected:"rgba(0, 0, 0, .5)"};function r(v,x,A){v&&x.transitionBoundingBox&&A.transitioning&&(v.setAttribute("x",""+x.transitionBoundingBox.x),v.setAttribute("y",""+x.transitionBoundingBox.y),v.setAttribute("width",""+x.transitionBoundingBox.width),v.setAttribute("height",""+x.transitionBoundingBox.height))}function a(v,x,A){v&&x.polygon.boundingBox&&A.showBoundingBox&&(v.setAttribute("x",""+x.polygon.boundingBox.x),v.setAttribute("y",""+x.polygon.boundingBox.y),v.setAttribute("width",""+x.polygon.boundingBox.width),v.setAttribute("height",""+x.polygon.boundingBox.height))}function l(v,x,A){if(v&&x.polygon.boundingBox&&A.showBoundingBox){let C=x.transitionBoundingBox||x.polygon.boundingBox;C.rotation?(v.style.transformOrigin=`${C.x+C.width/2}px ${C.y+C.height/2}px`,v.style.transform=`rotate(${Math.round(100*C.rotation*(180/Math.PI))/100}deg)`):v.style.transform="",v.setAttribute("points",[[C.x,C.y],[C.x+C.width,C.y],[C.x+C.width,C.y+C.height],[C.x,C.y+C.height]].map(I=>I.join(",")).join(" "))}}function c(v,x,A){v&&x.transitionPoints&&A.transitioning&&v.setAttribute("points",x.transitionPoints.map(C=>C.join(",")).join(" "))}function p(v,x,A){v&&x.closestLinePoint&&A.hasClosestLine&&(v.setAttribute("cx",""+x.closestLinePoint[0]),v.setAttribute("cy",""+x.closestLinePoint[1]),v.setAttribute("fill",x.closestLineDistance<t?i.selected:i.unselected),v.setAttribute("stroke",x.closestLineDistance<t?n.selected:n.unselected))}function m(v,x,A){v&&x.closestLinePoint&&A.hasClosestLine&&v.setAttribute("transform",`translate(${x.closestLinePoint[0]}, ${x.closestLinePoint[1]})`)}function h(v,x,A){v&&x.selectionBox&&A.transitionIntentType==="select-multiple-points"&&(v.setAttribute("x",""+x.selectionBox.x),v.setAttribute("y",""+x.selectionBox.y),v.setAttribute("width",""+x.selectionBox.width),v.setAttribute("height",""+x.selectionBox.height))}function y(v,x,A){if(v&&x.pointer&&x.selectedPoints.length)if(A.actionIntentType==="close-shape"||A.actionIntentType==="close-shape-line"){let C=x.polygon.points[0],I=x.polygon.points[x.polygon.points.length-1];C&&I&&v.setAttribute("points",`${C.join(",")} ${I.join(",")}`)}else if(x.line)v.setAttribute("points",`${x.line[0].join(",")} ${x.line[1].join(",")}`);else{let C=x.polygon.points[x.selectedPoints[0]];C&&C.length&&v.setAttribute("points",`${x.pointer[0]},${x.pointer[1]} ${C.join(",")}`)}}function S(v,x,A,C=3){v&&x.transitionDraw.length&&v.setAttribute("points",h1(x.transitionDraw,C*3).map(I=>I.join(",")).join(" "))}function w(v,x){v&&x.lineBox&&v.setAttribute("points",x.lineBox.map(A=>A.join(",")).join(" "))}return{updateTransitionBoundingBox:r,updateClosestLinePointTransform:m,updateBoundingBoxPolygon:l,updateBoundingBox:a,updateTransitionShape:c,updateClosestLinePoint:p,updateSelectBox:h,updatePointLine:y,updateDrawPreview:S,updateLineBox:w}}var LR=typeof window<"u"?window.requestAnimationFrame:e=>setTimeout(e,16),zR=typeof window<"u"?window.cancelAnimationFrame:e=>clearTimeout(e),Vm=[TR,xR,pR,kR,p1,c1,u1,RR,wR],FR=Vm.length,jm=[OR,MR,f1,fR,_R,SR,mR,yR,vR,bR],Hc=[gR,CR,PR,ER,AR,IR],Va={};Vm.forEach(e=>{Va[e.type]=e});jm.forEach(e=>{Va[e.type]=e});Hc.forEach(e=>{Va[e.type]=e});var Wc=20;function g1(e,t){let i={shapeId:e?.id||null,noShape:e===null,transitioning:!1,actionIntentType:null,transitionIntentType:null,selectedPoints:[],hasClosestLine:!1,modifiers:{Alt:!1,Shift:!1,Meta:!1,proximity:Wc},showBoundingBox:!1,currentModifiers:{},validIntentKeys:{},pointerInsideShape:!1,closestPoint:null,transitionModifiers:null,selectedStamp:null,lineMode:!1,lineBoxMode:!1,drawMode:!1,bezierLines:[]},n={isOpen:e?e.open:!1,polygon:{points:e?.points||[],iedges:null,boundingBox:null,isBezier:null,bezierLines:[]},scale:1,selectedPoints:[],pointer:null,line:null,lineBox:null,transitionPoints:null,transitionOrigin:null,transitionBoundingBox:null,closestLinePoint:null,closestLineDistance:0,closestLineIndex:-1,transitionRotate:!1,transitionDirection:null,transitionBezierLine:null,selectionBox:null,slowState:i,transitionDraw:[]},r={startTime:0,time:0,shouldUpdate:!1,nextSlowState:null,renderFunc:()=>{},setStateFunc:()=>{},animationFrame:0,actionIntent:null,transitionIntent:null,undoStack:[],undoStackPointer:-1},a={isPressed:!1,isClicking:!1,lastPress:null,pressTimeout:0,noTransition:!1};function l(N){l1(N),N.isBezier&&c({bezierLines:N.bezierLines}),qc(N),r.shouldUpdate=!0}l(n.polygon);function c(N){let G=Object.keys(N);if(G.length===0)return;let de=r.nextSlowState||n.slowState,ye=!1;if(G.length===1&&G[0]==="validIntentKeys"&&de.validIntentKeys){let ge=Object.keys(de.validIntentKeys),Ve=Object.keys(N.validIntentKeys||{});if(ge.length===Ve.length){for(let ze of ge)de.validIntentKeys[ze]!==N.validIntentKeys[ze]&&(ye=!0);if(!ye)return}}if(!(G.length===1&&G.includes("hasClosestLine")&&N.hasClosestLine===de.hasClosestLine)){if(r.nextSlowState){r.nextSlowState={...r.nextSlowState,...N};return}r.nextSlowState={...n.slowState,...N}}}function p(N,G=!1){r.time+=N,m(),h(),C(),A(),x(),I(),L(),E(),r.renderFunc(n,n.slowState,N),!G&&(r.animationFrame=LR(p))}function m(){if(r.shouldUpdate&&(t({id:n.slowState.shapeId||void 0,open:n.isOpen,points:n.polygon.points}),r.shouldUpdate=!1),r.nextSlowState&&r.nextSlowState!==n.slowState){let N=Object.keys(n.slowState),G={},de=!1;for(let ye of N){let ge=n.slowState[ye],Ve=r.nextSlowState[ye];ge!==Ve?(de=!0,G[ye]=Ve):G[ye]=ge}de&&(n.slowState=G,r.nextSlowState=null,r.setStateFunc(n.slowState))}}function h(){n.slowState.showBoundingBox?(n.slowState.noShape||n.selectedPoints.length===0||n.selectedPoints.length!==n.polygon.points.length)&&c({showBoundingBox:!1}):!n.slowState.noShape&&n.polygon.points.length&&n.selectedPoints.length===n.polygon.points.length&&c({showBoundingBox:!0})}function y(N){n.selectedPoints=N.selectedPoints,c({selectedPoints:N.selectedPoints}),n.polygon.points=N.points,n.polygon.boundingBox=null,n.polygon.iedges=null,n.polygon.isBezier=null,l(n.polygon),c({closestPoint:null}),(N.isOpen===!0||N.isOpen===!1)&&(n.isOpen=N.isOpen,r.shouldUpdate=!0)}function S(){if(r.undoStackPointer===-1)return;r.undoStackPointer--;let N=r.undoStack[r.undoStackPointer];y(N)}function w(){if(r.undoStackPointer===r.undoStack.length-1)return;r.undoStackPointer++;let N=r.undoStack[r.undoStackPointer];y(N)}function v(N){r.undoStackPointer++,r.undoStack[r.undoStackPointer]=N,r.undoStack.length>15&&(r.undoStack.shift(),r.undoStackPointer--)}function x(){if(!n.pointer||n.slowState.noShape){c({pointerInsideShape:!1});return}let[N,G]=n.pointer,de=n.polygon.points,ye=n.polygon.boundingBox;if(!ye){c({pointerInsideShape:!1});return}if(N<ye.x||N>ye.x+ye.width||G<ye.y||G>ye.height+ye.y){c({pointerInsideShape:!1});return}let ge=!1;for(let Ve=0,ze=de.length-1;Ve<de.length;ze=Ve++)de[Ve][1]>G!=de[ze][1]>G&&N<(de[ze][0]-de[Ve][0])*(G-de[Ve][1])/(de[ze][1]-de[Ve][1])+de[Ve][0]&&(ge=!ge);c({pointerInsideShape:ge})}function A(){if(n.slowState.noShape||!n.pointer||n.slowState.transitioning||!n.polygon.points||n.polygon.points.length===0)return;let[N,G]=n.pointer,de=n.polygon.points.map((ye,ge)=>{let Ve=ye[0]-N,ze=ye[1]-G;return[Ve*Ve+ze*ze,ge]}).sort((ye,ge)=>ye[0]-ge[0]);de.length&&c({closestPoint:de[0][1]})}function C(){if(!n.pointer||n.slowState.transitioning)return;if(n.slowState.noShape){n.closestLineIndex=-1,n.closestLinePoint=null,n.closestLineDistance=0;return}let[N,G,de,ye]=o1(n.polygon,n.pointer),ge=pe()*pe();G<ge&&(!n.isOpen||n.slowState.lineMode||n.polygon.points.length-1!==ye)?(n.closestLinePoint=N,n.closestLineDistance=Math.sqrt(G),n.closestLineIndex=ye,c({hasClosestLine:!0})):(n.closestLinePoint=null,n.closestLineDistance=0,n.closestLineIndex=-1,c({hasClosestLine:!1}))}function I(){if(!n.pointer||n.slowState.transitioning||n.slowState.noShape)return;let N=!1;for(let ye=0;ye<FR;ye++){let ge=Vm[ye];if(ge.isValid(a.isPressed?[a.lastPress]:[n.pointer],n,z())){if(r.transitionIntent===ge){N=!0;break}c({transitionIntentType:ge.type}),r.transitionIntent=ge,N=!0;break}}N||r.transitionIntent&&(r.transitionIntent=null,c({transitionIntentType:null}));let G=!1;for(let ye=0;ye<jm.length;ye++){let ge=jm[ye];if(Q(ge)){if(r.actionIntent===ge){G=!0;break}c({actionIntentType:ge.type}),r.actionIntent=ge,G=!0;break}}G||r.actionIntent&&(r.actionIntent=null,c({actionIntentType:null}));let de={};for(let ye=0;ye<Hc.length;ye++){let ge=Hc[ye];ge.trigger.type==="key"&&Q(ge)&&(de[ge.trigger.key]=ge.label)}c({validIntentKeys:de})}function E(){let N=n.pointer;if(n.lineBox=null,!N||J()||n.polygon.points.length!==2)return;let[G,de]=N,[ye,ge]=n.polygon.points[0],[Ve,ze]=n.polygon.points[1],[Pe,ne,he,Oe]=o1(n.polygon,N);if(!Pe)return;let ot=G-Pe[0],Ri=de-Pe[1],Dt=[ye,ge],Wt=[Ve,ze],ps=[Wt[0]+ot,Wt[1]+Ri],Ti=[Dt[0]+ot,Dt[1]+Ri];n.lineBox=[Dt,Wt,ps,Ti]}function L(){let N=n.pointer;if(!N||!J()||n.slowState.noShape)return;let G=n.selectedPoints[0];if(n.line=[n.polygon.points[G],N],n.slowState.modifiers.Shift){let de=0;if(n.polygon.points.length>1){let ot=n.selectedPoints[0];ot===0?de=Math.atan2(n.polygon.points[1][1]-n.polygon.points[0][1],n.polygon.points[1][0]-n.polygon.points[0][0]):de=Math.atan2(n.polygon.points[ot-1][1]-n.polygon.points[ot][1],n.polygon.points[ot-1][0]-n.polygon.points[ot][0])}let ye=N[0]-n.polygon.points[G][0],ge=N[1]-n.polygon.points[G][1],Ve=Math.atan2(ge,ye),ze=Math.PI/4,Pe=Math.round((Ve-de)/ze)*ze+de,ne=qi(n.polygon.points[G],N),he=Math.cos(Pe)*ne+n.polygon.points[G][0],Oe=Math.sin(Pe)*ne+n.polygon.points[G][1];n.line[1]=[he,Oe]}}function z(){return n.slowState.modifiers}function M(N){let G=N.commit([a.lastPress],n,z());G&&(G.selectedPoints&&(n.selectedPoints=G.selectedPoints,c({selectedPoints:G.selectedPoints})),G.points&&(n.polygon.points=G.points,n.polygon.boundingBox=null,n.polygon.iedges=null,n.polygon.isBezier=null,n.transitionBoundingBox=null,l(n.polygon),c({closestPoint:null,selectedStamp:null})),(G.isOpen===!0||G.isOpen===!1)&&(n.isOpen=G.isOpen,r.shouldUpdate=!0),v({isOpen:n.isOpen,points:n.polygon.points,selectedPoints:n.selectedPoints})),c({transitionModifiers:null})}function Q(N){return N.isValid(n.pointer?[n.pointer]:[],n,z())}function V(N){N==="Delete"&&(N="Backspace");for(let G of Hc)if(!(G.trigger.type!=="key"||G.trigger.key!==N)&&Q(G))return M(G),!0}function J(){let N=n.polygon.points,G=n.pointer;if(!n.isOpen||!N.length||n.selectedPoints.length!==1||!G)return!1;let de=n.selectedPoints[0],ye=de===0,ge=de===N.length-1;return ye||ge}let U={reset(){c({modifiers:{Alt:!1,Shift:!1,Meta:!1,proximity:Wc}})},getForType(N){let G={};if(!N)return G;let de=Va[N];return!de||!de.modifiers?G:de.modifiers},set(N){N!=="Shift"&&N!=="Alt"&&N!=="Meta"||c({modifiers:{...r.nextSlowState?.modifiers||n.slowState.modifiers,[N]:!0}})},unset(N){N!=="Shift"&&N!=="Alt"&&N!=="Meta"||c({modifiers:{...r.nextSlowState?.modifiers||n.slowState.modifiers,[N]:!1}})}},W={set(N){c({selectedStamp:N})},clear(){c({selectedStamp:null})},square(){c({selectedStamp:{id:"square",open:!1,points:[[0,0],[0,100],[100,100],[100,0]]}})},triangle(){c({selectedStamp:{id:"triangle",open:!1,points:[[50,0],[0,100],[100,100]]}})},pentagon(){c({selectedStamp:{id:"pentagon",open:!1,points:[[0,0],[0,100],[100,100],[100,0],[50,-50]]}})},hexagon(){c({selectedStamp:{id:"hexagon",open:!1,points:[[0,0],[0,100],[50,150],[100,100],[100,0],[50,-50]]}})}},ee={down(N){return N=="Shift"||N=="Alt"||N=="Meta"?(U.set(N),!0):N==="Control"?(U.set("Meta"),!0):N==="z"&&n.slowState.modifiers.Meta?(n.slowState.modifiers.Shift?w():S(),!0):V(N)},up(N){if(N==="Control"){U.unset("Meta");return}N!=="Shift"&&N!=="Alt"&&N!=="Meta"||U.unset(N)}};function Me(N){n.scale=N,c({modifiers:{...r.nextSlowState?.modifiers||n.slowState.modifiers,proximity:N*Wc}})}function pe(){return Wc*n.scale}let Re={set:N=>{r.renderFunc=N},start:(N,G)=>{r.startTime=performance.now(),r.time=0,N&&(r.renderFunc=N),G&&(G(n.slowState),r.setStateFunc=G),p(0)},stop:()=>{r.animationFrame&&(zR(r.animationFrame),r.animationFrame=0)},step:(N=16)=>{p(N)}};function ke(N){let G=N[0];if(!(!G||!G[0]&&G[0]!==0||!G[1]&&G[1]!==0)&&!(Number.isNaN(G[0])||Number.isNaN(G[1]))){if(n.pointer=G||null,n.slowState.transitioning)r.transitionIntent&&r.transitionIntent.transition(N,n,z());else if(a.isPressed&&!a.noTransition&&(!a.isClicking||qi(a.lastPress,n.pointer)>10))if(clearTimeout(a.pressTimeout),a.isClicking=!1,r.transitionIntent){if(n.transitionOrigin=a.lastPress,c({transitioning:!0}),r.transitionIntent.start){let de=r.transitionIntent.start([a.lastPress],n,z());de&&(de.selectedPoints&&(n.selectedPoints=de.selectedPoints,c({selectedPoints:de.selectedPoints})),(de.isOpen===!0||de.isOpen===!1)&&(n.isOpen=de.isOpen,r.shouldUpdate=!0),de.points&&(n.polygon.points=de.points,n.polygon.boundingBox=null,n.polygon.iedges=null,l(n.polygon),c({closestPoint:null})))}c({transitionModifiers:r.transitionIntent.modifiers||null}),r.transitionIntent.transition([a.lastPress],n,z())}else a.noTransition=!0}}function He(){n.pointer=null,n.slowState.transitioning||(a.isPressed=!1,a.isClicking=!1,a.lastPress=null,c({transitionIntentType:null,actionIntentType:null}),r.transitionIntent=null,r.actionIntent=null)}function qe(){a.isClicking=!0,a.isPressed=!0,a.lastPress=n.pointer,a.pressTimeout=setTimeout(()=>{a.isPressed&&(a.isClicking=!1)},250)}function $(){n.slowState.transitioning?(c({transitioning:!1}),r.transitionIntent&&M(r.transitionIntent),r.transitionIntent=null,c({transitionIntentType:null})):a.isClicking&&(r.actionIntent&&M(r.actionIntent),r.actionIntent=null,c({actionIntentType:null})),a.isPressed=!1,a.isClicking=!1,a.lastPress=null,a.noTransition=!1,clearTimeout(a.pressTimeout)}function ve(N){n.polygon.points=N?.points||[],n.polygon.boundingBox=null,n.polygon.iedges=null,n.isOpen=N?.open||!1,l(n.polygon),r.nextSlowState=null,r.undoStack=[],r.undoStackPointer=-1,n.lineBox=null,n.line=null,a.pressTimeout&&clearTimeout(a.pressTimeout),c({noShape:N===null,shapeId:N?.id||null,transitioning:!1,actionIntentType:null,transitionIntentType:null,selectedPoints:[],hasClosestLine:!1,modifiers:{Alt:!1,Shift:!1,Meta:!1,proximity:n.slowState.modifiers.proximity},showBoundingBox:!1,currentModifiers:{},validIntentKeys:{},selectedStamp:null,drawMode:!1,closestPoint:null,pointerInsideShape:!1,lineBoxMode:!1,lineMode:!1}),m()}function it(N){if(!N)return"";let G=Va[N];return!G||!G.modifiers?G.label||"":n.slowState.modifiers.Shift&&G.modifiers.Shift?G.modifiers.Shift:n.slowState.modifiers.Alt&&G.modifiers.Alt?G.modifiers.Alt:n.slowState.modifiers.Meta&&G.modifiers.Meta?G.modifiers.Meta:G.label}function Qe(){n.slowState.lineMode?c({lineMode:!1,lineBoxMode:!1,drawMode:!1}):c({lineMode:!0,lineBoxMode:!1,drawMode:!1})}function $e(){n.slowState.lineBoxMode?c({lineMode:!1,lineBoxMode:!1,drawMode:!1}):c({lineBoxMode:!0,lineMode:!0,drawMode:!1})}return{draw:{enable(){c({drawMode:!0,lineMode:!1,lineBoxMode:!1})},disable(){c({drawMode:!1})},toggle(){c({drawMode:!n.slowState.drawMode,lineMode:!1,lineBoxMode:!1})}},state:n,modifiers:U,stamps:W,key:ee,setScale:Me,clock:Re,pointer:ke,blur:He,pointerDown:qe,pointerUp:$,setShape:ve,modes:{toggleLineBoxMode:$e,toggleLineMode:Qe,enableLineMode(){c({lineMode:!0,lineBoxMode:!1,drawMode:!1})},disableLineMode(){c({lineMode:!1,lineBoxMode:!1,drawMode:!1})},enableLineBoxMode(){c({lineMode:!0,lineBoxMode:!0,drawMode:!1})},disableLineBoxMode(){c({lineMode:!1,lineBoxMode:!1,drawMode:!1})}},label:it}}function Um(e,t,i){let[n,r]=(0,hs.useState)({}),a=(0,hs.useMemo)(()=>g1(e,i),[]);return(0,hs.useEffect)(()=>(a.clock.start(t,r),()=>{a.clock.stop()}),[]),{state:n,helper:a}}var tt=R(B(),1),Cr=m1();function Wm(e,t){let{image:i,currentShape:n,onChange:r,hideShapeLines:a}=e,l=(0,si.useRef)(),c=(0,si.useRef)(),p=(0,si.useRef)(),m=(0,si.useRef)(),h=(0,si.useRef)(),y=(0,si.useRef)(),S=(0,si.useRef)(),w=(0,si.useRef)(),[v,x]=(0,si.useState)(null),[A,C]=(0,si.useState)(!1),{helper:I,state:E}=Um(n,(W,ee)=>{Cr.updateTransitionBoundingBox(c.current,W,ee),Cr.updateBoundingBoxPolygon(l.current,W,ee),Cr.updateTransitionShape(y.current,W,ee),Cr.updateClosestLinePointTransform(m.current,W,ee),Cr.updateSelectBox(p.current,W,ee),Cr.updatePointLine(S.current,W,ee),Cr.updateDrawPreview(h.current,W,ee,3),Cr.updateLineBox(w.current,W),x(W.transitionDirection),C(W.transitionRotate)},r);(0,si.useEffect)(()=>{I.setShape(n||null)},t),(0,si.useEffect)(()=>{let W=()=>{I.modifiers.reset()};return document.addEventListener("mouseleave",W),()=>{document.removeEventListener("mouseleave",W)}},[]);let L=(0,tt.jsxs)(tt.Fragment,{children:[(0,tt.jsx)("marker",{id:"dot",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:(0,tt.jsx)("circle",{cx:"5",cy:"5",r:"4",className:"marker"})}),(0,tt.jsx)("marker",{id:"selected",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:(0,tt.jsx)("circle",{cx:"5",cy:"5",r:"4",fill:"#FAFF00"})}),(0,tt.jsx)("marker",{id:"resizer",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:(0,tt.jsx)("rect",{width:"10",height:"10",stroke:"#FF0DCB",fill:"#fff",strokeWidth:2})})]}),z=n?n.open?"polyline":"polygon":null,M=!E.showBoundingBox&&E.closestPoint!==null&&E.actionIntentType==="select-point",Q=E.actionIntentType==="add-open-point",V=E.transitionIntentType==="split-line",J=E.transitioning&&E.selectedStamp&&E.transitionIntentType==="stamp-shape",U=n&&z?(0,tt.jsxs)(tt.Fragment,{children:[(0,tt.jsx)(z,{fill:!E.transitioning&&E.showBoundingBox?"rgba(255, 0, 0, .5)":"none",strokeWidth:J?0:2,stroke:a?"transparent":"#000",points:n.points.map(W=>W.join(",")).join(" "),vectorEffect:"non-scaling-stroke",markerStart:E.showBoundingBox?void 0:"url(#dot)",markerMid:E.showBoundingBox?void 0:"url(#dot)",markerEnd:E.showBoundingBox?void 0:"url(#dot)",style:{pointerEvents:"none"}}),E.lineBoxMode&&E.actionIntentType==="close-line-box"?(0,tt.jsx)("polygon",{fill:"rgba(255, 0, 0, .4)",ref:w,stroke:"#000",strokeWidth:2,vectorEffect:"non-scaling-stroke"}):null,E.transitionIntentType==="draw-shape"&&E.transitioning?(0,tt.jsx)("polyline",{ref:h,fill:"none",stroke:"rgba(255, 0, 0, .5)",strokeWidth:2,vectorEffect:"non-scaling-stroke"}):null,!E.showBoundingBox&&E.selectedPoints&&E.selectedPoints.length?(0,tt.jsx)("polyline",{strokeWidth:2,vectorEffect:"non-scaling-stroke",stroke:"transparent",markerStart:"url(#selected)",markerMid:"url(#selected)",markerEnd:"url(#selected)",fill:"transparent",points:n.points.filter((W,ee)=>E.selectedPoints?.includes(ee)).map(W=>W.join(",")).join(" ")}):null,M&&E.closestPoint!==null&&n.points[E.closestPoint]?(0,tt.jsx)("polyline",{strokeWidth:2,vectorEffect:"non-scaling-stroke",stroke:"transparent",markerStart:"url(#selected)",markerMid:"url(#selected)",markerEnd:"url(#selected)",fill:"transparent",points:`${n.points[E.closestPoint][0]},${n.points[E.closestPoint][1]}`}):null,!E.transitioning&&(E.actionIntentType==="add-open-point"||E.actionIntentType==="close-shape"||E.actionIntentType==="close-shape-line")?(0,tt.jsx)("polyline",{stroke:"#000",ref:S,strokeWidth:E.actionIntentType==="close-shape"?2:1,vectorEffect:"non-scaling-stroke"}):null,E.hasClosestLine&&(!E.transitionIntentType||E.transitionIntentType==="split-line")?(0,tt.jsx)("g",{ref:m,children:(0,tt.jsx)("polyline",{style:{opacity:.5},markerStart:"url(#dot)",points:"0,0 10,10",vectorEffect:"non-scaling-stroke",fill:"transparent",strokeWidth:2})}):null,E.transitioning?(0,tt.jsx)(z,{ref:y,fill:n.open?"none":"rgba(255, 0, 0, .5)",stroke:"rgba(255, 0, 0, .5)",strokeWidth:n.open?2:0}):null,E.transitioning&&E.transitionIntentType==="select-multiple-points"?(0,tt.jsx)("rect",{ref:p,fill:"rgba(255, 255, 255, .3)",strokeWidth:1,stroke:"rgba(0,0,0,.2)",vectorEffect:"non-scaling-stroke"}):null,E.showBoundingBox?null:(0,tt.jsx)("g",{name:"controls",children:!1}),E.showBoundingBox&&!J?(0,tt.jsx)("polygon",{ref:l,strokeWidth:2,stroke:"#FF0DCB",fill:"none",markerStart:"url(#resizer)",markerMid:"url(#resizer)",markerEnd:"url(#resizer)",vectorEffect:"non-scaling-stroke"}):null]}):null;return{helper:I,state:E,isAddingPoint:Q,isSplitting:V,isStamping:J,isHoveringPoint:M,transitionDirection:v,transitionRotate:A,defs:L,editor:U}}var $c=R(q(),1),y1=R(Ws(),1),vi=R(B(),1),v1=[{name:"Default",outer:{borderWidth:4,borderColor:"rgba(255, 255, 255, .4)"},inner:{borderWidth:2,borderColor:"#000"}},{name:"High contrast",outer:{borderWidth:3,borderColor:"#fff"},inner:{borderWidth:1,borderColor:"#000"}},{name:"Lightsaber",outer:{borderWidth:"4",borderColor:"rgba(56,68,255,0.64)"},inner:{borderWidth:"2",borderColor:"#fff"}},{name:"Bright",outer:{borderWidth:"6",borderColor:"#25d527"},inner:{borderWidth:"3",borderColor:"#a916ff"}},{name:"pink",outer:{borderWidth:"4",borderColor:"#ff00ff"},inner:{borderWidth:"2",borderColor:"#ffffff"}},{name:"fine (dark)",outer:{borderWidth:"1",borderColor:"#000000"},inner:{}},{name:"fine (light)",outer:{borderWidth:"1",borderColor:"#FFF"},inner:{}}];function Hm(e){let t=e.theme||v1[0],i=Mu(),{image:n}=e,{helper:r,defs:a,editor:l,state:c,transitionDirection:p,isSplitting:m,transitionRotate:h,isHoveringPoint:y,isAddingPoint:S,isStamping:w}=Wm({currentShape:e.shape||null,onChange:e.updateShape,image:e.image,hideShapeLines:!0},[]),v=E=>{r.pointer([[~~E.atlas.x,~~E.atlas.y]])};(0,$c.useEffect)(()=>{let E=L=>{r.key.up(L.key)};return document.addEventListener("keyup",E),()=>{document.removeEventListener("keyup",E)}},[]),(0,$c.useEffect)(()=>{let E=L=>{r.key.down(L.key)};return document.addEventListener("keydown",E),()=>{document.removeEventListener("keydown",E)}},[]),(0,$c.useEffect)(()=>{let E=[];return p&&E.push(`atlas-cursor-${p}`),c.actionIntentType==="cut-line"&&c.modifiers?.Shift&&E.push("atlas-cursor-cut"),(y||c.transitionIntentType==="move-shape"||c.transitionIntentType==="move-point")&&E.push("atlas-cursor-move"),S&&E.push("atlas-cursor-crosshair"),m&&E.push("atlas-cursor-copy"),h&&E.push("atlas-cursor-rotate"),c.transitionIntentType==="draw-shape"&&E.push("atlas-cursor-draw"),i?.canvas&&i.canvas.classList.add(...E),()=>{i?.canvas&&i.canvas.classList.remove(...E)}},[i?.canvas,S,y,m,c.modifiers?.Shift,c.actionIntentType,c.transitionIntentType,p,h]);let x=e.shape&&e.shape?.points.length===0,A=e.renderControls?e.renderControls(r,c,x):null,C=document.getElementById(e.controlsHtmlId||"atlas-controls"),I="shape";return(0,vi.jsx)(vi.Fragment,{children:(0,vi.jsxs)("world-object",{height:n.height,width:n.width,onMouseMove:v,onMouseDown:r.pointerDown,onMouseUp:r.pointerUp,onMouseLeave:r.blur,children:[e.shape?(0,vi.jsxs)(vi.Fragment,{children:[(0,vi.jsx)(I,{open:e.shape.open,points:e.shape.points,relativeStyle:!0,style:w?{}:t.outer}),(0,vi.jsx)(I,{open:e.shape.open,points:e.shape.points,relativeStyle:!0,style:w?{}:t.inner})]}):null,(0,vi.jsxs)(Cn,{relative:!0,interactive:!1,children:[(0,vi.jsx)("div",{style:{position:"absolute",top:0,right:0,left:0,bottom:0},children:(0,vi.jsxs)("svg",{width:"100%",height:"100%",viewBox:`0 0 ${n.width} ${n.height}`,tabIndex:-1,children:[(0,vi.jsx)("defs",{children:a}),l]})}),C?(0,y1.createPortal)(A,C,"controls"):null]})]})})}var qm=R(B(),1);function NR(e){let t=Ce(),i=e.annotationBucket,n=e.readOnly,r=e.id,{onClick:a,isHighlighted:l}=Lm(e.id),c=Bm(),p=l?c.highlighted:c[i||"hidden"]||c.hidden;if(!t)return null;if(n){let m="shape",h=e.polygon,y=h.open;return h?(0,qm.jsx)(m,{id:`shape-${r}`,points:h.points,open:y,onClick:a,relativeStyle:!0,target:{x:0,y:0,width:t.width,height:t.height},style:p}):null}return(0,qm.jsx)(Hm,{image:t,shape:e.polygon||{id:e.id,open:!0,points:[]},updateShape:e.updatePolygon,theme:e.theme,controlsHtmlId:e.controlsHtmlId,renderControls:e.renderControls})}var Gc=R(q(),1);var Pr=R(B(),1);function BR({src:e,errorFallback:t,interactive:i,skipSizes:n,children:r,renderViewerControls:a,viewControlsDeps:l,fluid:c,x:p,y:m,...h}){let[y,S]=(0,Gc.useState)(),w=t||hc,[v,x]=Ea(),A=(0,Gc.useMemo)(()=>{let I=x[e]?.status,E=v({id:e},{});return E?.height&&E.width&&I!=="loading"?{id:e,width:E.width,height:E.height,service:E,type:"Image",selector:{type:"BoxSelector",spatial:{x:0,y:0,width:E.width,height:E.height}},target:{type:"BoxSelector",spatial:{x:0,y:0,width:E.width,height:E.height}}}:null},[v,e,x]);if(Ft(y&&a?"overlay":"none",`canvas-portal-controls-${e}`,Ui.Provider,a&&A?{value:y||null,children:a({image:A,images:[A],type:"images"})}:{},[e,A,y,...l||[]]),!A||!A.height||!A.width)return null;let C=c?void 0:h.homePosition?h.homePosition.width/h.homePosition.height:A.width/A.height;return console.log("here",C),(0,Pr.jsx)(No,{resetKeys:[],fallbackRender:I=>(0,Pr.jsx)(w,{...h,...I}),children:(0,Pr.jsx)(fc,{...h,aspectRatio:C,containerProps:{style:{position:"relative"},...h.containerProps||{}},onCreated:I=>{S(I),h.onCreated&&h.onCreated(I)},children:(0,Pr.jsxs)(Ui.Provider,{value:y,children:[(0,Pr.jsx)(xr,{image:A,id:A.id,isStatic:!i,x:p,y:m},A.id),(0,Pr.jsx)(DR,{viewerPreset:y,renderViewerControls:a,image:A,src:e,viewControlsDeps:l}),r]})})})}function DR({viewerPreset:e,renderViewerControls:t,image:i,src:n,viewControlsDeps:r}){return Ft(e&&t?"overlay":"none",`canvas-portal-controls-${n}`,Ui.Provider,t&&i?{value:e||null,children:t({image:i,images:[i],type:"images"})}:{},[n,e,...r||[]]),null}var x1=R(B(),1);function jR({annotation:e,children:t}){return(0,x1.jsx)(ei,{value:{annotation:e},children:t})}var S1=R(B(),1);function VR({annotationPage:e,children:t}){return(0,S1.jsx)(ei,{value:{annotationPage:e},children:t})}var w1=R(B(),1);function UR({collection:e,children:t}){return(0,w1.jsx)(ei,{value:{collection:e},children:t})}function WR(e,t={}){return oo(t)}var Er=R(q(),1);function HR({canvasId:e}={}){let t=Ou(),i=eo(),n=(0,Er.useMemo)(()=>e?[e]:t?[t.id]:i.map(m=>m.id),[e,t,i]),[r,a]=(0,Er.useState)({}),l=pa();(0,Er.useEffect)(()=>{let m=h=>{let y=h.partOf.canvasId;y&&a(S=>({...S,[y]:h.choice}))};return l.on("choice-change",m),()=>{l.off("choice-change",m)}},[]);let c=(0,Er.useMemo)(()=>{let m=[];for(let h of n){let y=r[h];y&&m.push({canvasId:h,choice:y})}return m},[n,r]),p=(0,Er.useMemo)(()=>({makeChoice:(m,h)=>{l.emit("make-choice",{choiceId:m,...h})}}),[l]);return{choices:c,actions:p}}function qR(e,t=!1){}function QR(e){let i=Xt().manifest,n=e?e.map(r=>typeof r=="string"?r:r?.id):[];return De(r=>{let a=i?r.iiif.entities.Manifest[i]:void 0,l=a?.items||[];if(typeof e>"u")return l;let c=[];for(let p of a?.items||[])n.indexOf(p.id)!==-1&&c.push(p);return c},[n.join("/")])}var b1=R(q(),1);function $R(e,t=[]){let{id:i,selector:n}=e,r=Xt(),a=i||r.collection,l=De(c=>a?c.iiif.entities.Collection[a]:void 0,[a]);return(0,b1.useMemo)(()=>{if(l)return n?n(l):l},[l,n,...t])}var Yc=R(q(),1);function GR(e,t,i,n,r=[]){let a=_e(),l=(0,Yc.useMemo)(()=>ma(a),[a]);(0,Yc.useEffect)(()=>{let c=e;return c?(l.addEventListener(c,t,i,n),()=>{l.removeEventListener(c,t,i)}):()=>{}},[l,e,t,...r])}function YR(e,t){let{id:i,isLoaded:n,error:r,resource:a,requestId:l,cached:c}=aa(e,t);return{id:i,isLoaded:n,error:r,manifest:a,requestId:l,cached:c}}var En=R(q(),1);function Qm({cacheKey:e}={}){let t=Ce(),i=oo(),n=_e(),r=ss(),a=gw(),[l,c]=(0,En.useState)(void 0),[p,m]=(0,En.useState)(!1),[h,y]=(0,En.useState)("idle"),[S,w]=(0,En.useState)(void 0),v=t?t.id:"undefined",x=(0,En.useMemo)(()=>{try{if(t&&i.length){let C=i[0],I=n.get(C.body[0]),L=zn(I)[0];return L&&r(L,{width:L.width||t.width,height:L.height||t.height},!0)||void 0}}catch(C){console.error(C)}},[v,e,t]),A=h==="success"&&l?l:x;return(0,En.useEffect)(()=>{(async()=>{try{if(t&&i.length){let C=i[0],I=n.get(C.body[0]),L=zn(I)[0];if(!L)return;m(!0),y("loading");try{let z=await a(L,{width:L.width||t.width,height:L.height||t.height})||void 0;c(z),y("success"),m(!1)}catch(z){y("error"),w(z)}}}catch(C){y("error"),w(C)}})()},[v,e]),(0,En.useMemo)(()=>({data:A,isFetching:p,status:h,error:S}),[A,p,h,S])}function XR(){let e=Qm();return{isLoading:e.isFetching,tile:e.data?{id:e.data.id||e.data["@id"],width:e.data.width,height:e.data.height,imageService:e.data,thumbnail:void 0}:null}}var C1=R(q(),1);function KR(){let e=_e();return(0,C1.useMemo)(()=>yr(e),[e])}return jb(ZR);})();
|
|
124
|
+
`}),(0,Fa.jsx)("iframe",{className:"video-yt",ref:n,src:`https://www.youtube.com/embed/${t.youTubeId}?enablejsapi=1&origin=${window.location.host}`,referrerPolicy:"no-referrer",sandbox:"allow-scripts allow-same-origin allow-presentation"})]}):null}function $w({media:e,mediaControlsDeps:t,children:i}){let[{element:n,currentTime:r,progress:a},l,c]=ao({duration:e.duration});return Ft("overlay","video-element",YI,{element:n,media:e,playPause:c.playPause}),null}var Fc=R(B(),1);function _m(){let{strategy:e}=pt(),{renderMediaControls:t,mediaControlsDeps:i}=ni();return e.type!=="media"||e.media.type!=="VideoYouTube"?null:(0,Fc.jsxs)($w,{media:e.media,mediaControlsDeps:i,children:[(0,Fc.jsx)(ho,{}),t?t(e):null]})}var gi=R(B(),1);function fo({x:e,y:t,onChoiceChange:i,registerActions:n,defaultChoices:r,isStatic:a,renderViewerControls:l,renderMediaControls:c,renderComplexTimelineControls:p,complexTimelineControlsDeps:m,viewControlsDeps:h,mediaControlsDeps:y,strategies:S,throwOnUnknown:w,backgroundStyle:v,alwaysShowBackground:x,keepCanvasScale:A=!1,enableSizes:C=!1,enableYouTube:I=!0,onClickPaintingAnnotation:E,components:L={},children:z}){return(0,gi.jsxs)(cm,{throwOnUnknown:w,onChoiceChange:i,registerActions:n,strategies:S,defaultChoices:r,mediaControlsDeps:y,renderMediaControls:c,renderViewerControls:l,renderComplexTimelineControls:p,complexTimelineControlsDeps:m,viewControlsDeps:h,children:[(0,gi.jsxs)(dm,{keepCanvasScale:A,x:e,y:t,children:[(0,gi.jsx)(hm,{alwaysShowBackground:x,backgroundStyle:v}),(0,gi.jsx)(ym,{}),(0,gi.jsx)(vm,{}),(0,gi.jsx)(Sm,{isStatic:a,enableSizes:C,onClickPaintingAnnotation:E}),(0,gi.jsx)(Cm,{}),(0,gi.jsx)(bm,{}),(0,gi.jsx)(Am,{as:L.Audio}),(0,gi.jsx)(Tm,{as:L.Video}),I?(0,gi.jsx)(_m,{}):null,z]}),(0,gi.jsx)(Im,{})]})}var Mm=R(B(),1);function Gw(e){let t=Ce();return!t||!t.placeholderCanvas?null:(0,Mm.jsx)(Vi,{canvas:t.placeholderCanvas.id,children:(0,Mm.jsx)(fo,{renderViewerControls:e.renderViewerControls})})}var ri=R(B(),1),XI=(0,Na.forwardRef)(function(t,i){let n=vt(),r=eo(),a=ha(),{ViewerControls:l,MediaControls:c,ComplexTimelineControls:p}=t.components||{};if((0,Na.useImperativeHandle)(i,()=>a,[a]),!n)return(0,ri.jsx)("div",{});let m=0;return(0,ri.jsxs)(ri.Fragment,{children:[t.header,(0,ri.jsx)(Bt.Viewer,{height:t.height,mode:t.mode,renderPreset:t.renderPreset,runtimeOptions:t.runtimeOptions,children:r.map((h,y)=>{let S=m;return m+=h.width+(t.spacing||0),(0,ri.jsx)(Vi,{canvas:h.id,children:(0,ri.jsx)(Bt.RenderCanvas,{strategies:["3d-model","media","images","empty","textual-content","complex-timeline"],renderViewerControls:y===0&&l?()=>(0,ri.jsx)(l,{}):void 0,renderMediaControls:y===0&&c?()=>(0,ri.jsx)(c,{}):void 0,renderComplexTimelineControls:y===0&&p?()=>(0,ri.jsx)(p,{}):void 0,x:S,...t.canvasProps||{},children:t.annotations},h.id)},h.id)})},t.reuseAtlas?"":a.currentSequenceIndex),t.children]})}),Bt=(0,Na.forwardRef)(function({children:t,height:i,annotations:n,canvasProps:r,spacing:a,header:l,components:c,mode:p,reuseAtlas:m,renderPreset:h,runtimeOptions:y,...S},w){let v=Zr();return(0,ri.jsx)(Kr,{vault:v,children:(0,ri.jsx)(Lf,{...S,children:(0,ri.jsx)(XI,{ref:w,height:i,components:c,spacing:a,canvasProps:r,annotations:n,header:l,mode:p,reuseAtlas:m,renderPreset:h,runtimeOptions:y,children:t})})})});Bt.RenderImage=xr;Bt.RenderCanvas=fo;Bt.RenderAnnotationPage=Sa;Bt.RenderAnnotation=yc;Bt.Viewer=fc;Bt.CanvasBackground=Cc;Bt.Audio=kc;Bt.Video=Lc;Bt.Model=_c;Bt.AudioHTML=Pm;Bt.VideoHTML=Rm;Bt.ModelHTML=wm;Bt.PlaceholderCanvas=Gw;var Nc=R(q(),1),Ba=R(B(),1),KI=(0,Nc.forwardRef)(function({canvasId:t},i){let n=Ou(),r=Pa(t||n?.id),a=_e();return(0,Nc.useImperativeHandle)(i,()=>r,[t,n]),!n||r.enabledPageIds.length===0?null:(0,Ba.jsx)(Ba.Fragment,{children:r.enabledPageIds.map(l=>(0,Ba.jsx)(Bt.RenderAnnotationPage,{page:a.get(l)},l))})});var Xw=R(q(),1);var Yw=R(q(),1);var Pt=R(B(),1);function Da({metadata:e=[],config:t,labelWidth:i=16,showEmptyMessage:n=!0,allowHtml:r,emptyFallback:a,classes:l={},emptyMessage:c="No metadata available",emptyValueFallback:p="No value",emptyLabelFallback:m="",separator:h,tableFooter:y,tableHeader:S}){let w=(0,Yw.useMemo)(()=>{let x=(t||[]).reduce((C,I)=>[...C,...I.keys],[]),A={};for(let C of e){let I=C&&C.label?Object.values(C.label):[];for(let E of I)if(E&&E.length&&(x.indexOf(`metadata.${E[0]}`)!==-1||x.length===0)&&C){let L=`metadata.${E[0]}`;A[L]=A[L]?A[L]:[],A[L].push(C);break}}return A},[t,e]);return Object.keys(w).length===0&&n?(0,Pt.jsx)(Pt.Fragment,{children:a})||(0,Pt.jsx)("div",{className:l.empty,children:c}):t&&t.length?(0,Pt.jsxs)("table",{className:l.container,children:[S,(0,Pt.jsx)("tbody",{children:t.map((x,A)=>{let C=[];for(let I of x.keys)for(let E of w[I]||[])C.push((0,Pt.jsx)(Ii,{enableDangerouslySetInnerHTML:r,defaultText:p,separator:h,children:E.value},A+"__"+I));return C.length===0?null:(0,Pt.jsxs)("tr",{className:l.row,children:[(0,Pt.jsx)("td",{className:l.label,style:i?{minWidth:i}:{},children:(0,Pt.jsx)(Ii,{enableDangerouslySetInnerHTML:r,separator:h,defaultText:m,children:x.label})}),(0,Pt.jsx)("td",{className:l.value,children:C})]},A)})}),y]}):(0,Pt.jsxs)("table",{className:l.container,children:[S,(0,Pt.jsx)("tbody",{children:e&&e.length?e.map((x,A)=>x?(0,Pt.jsxs)("tr",{className:l.row,children:[(0,Pt.jsx)("td",{className:l.label,style:i?{minWidth:i}:{},children:(0,Pt.jsx)(Ii,{enableDangerouslySetInnerHTML:r,defaultText:p,separator:h,children:x.label})}),(0,Pt.jsx)("td",{className:l.value,children:(0,Pt.jsx)(Ii,{enableDangerouslySetInnerHTML:r,defaultText:p,separator:h,children:x.value})})]},A):null):null}),y]})}var Kw=R(B(),1);function ZI(e){let t=vt(),i=Ce(),n=la(),r=(0,Xw.useMemo)(()=>{let a=t?.metadata||[],l=i?.metadata||[],c=n?.metadata||[];return[...a,...l,...c]},[t,i,n]);return(0,Kw.jsx)(Da,{metadata:r,...e})}var Dc=R(q(),1);var Zw=R(q(),1);function Bc(e,t={},i=[]){return(0,Zw.useMemo)(()=>{if(!e)return null;let n=t.quality;e&&e.extraQualities&&t.quality&&(e.extraQualities.includes(t.quality)||(n="default"));let r=nu(e);return iu({identifier:r.identifier,server:r.server,scheme:r.scheme,type:"image",size:{max:!t.size?.width&&!t.size?.height,confined:!1,upscaled:!1,...t.size||{}},format:t.format||"jpg",region:t.region||{full:!0},rotation:t?.rotation?Number.isInteger(t.rotation)?{angle:t.rotation}:t.rotation:{angle:0},quality:n||"default",prefix:r.prefix,originalPath:r.originalPath})},[...i])}var ja=R(B(),1);function JI(e){let t=typeof e.src=="string"?e.src:e.src.id,i=ka(),[n,r]=(0,Dc.useState)(!1),a;if(t){let c=i.loadServiceSync({id:t});c&&(a=c)}!a&&!n&&i.loadService({id:t}).then(()=>{r(!0)});let l=Bc(a,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[n,e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return(0,Dc.useEffect)(()=>()=>{r(!1)},[t]),l?(0,ja.jsx)("img",{src:l,alt:e.alt,className:e.className,style:e.style}):(0,ja.jsx)(Jw,{...e,fetchImageService:!1})}function Jw(e){if(e.fetchImageService)return(0,ja.jsx)(JI,{...e});let t=typeof e.src=="string"?{id:e.src,profile:"level0"}:e.src,i=Bc(t,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return i?(0,ja.jsx)("img",{src:i,alt:e.alt,className:e.className,style:e.style}):null}var e1=R(B(),1);function eR(e){let t=vt();return(0,e1.jsx)(Da,{metadata:t?.metadata||[],...e})}var jc=R(q(),1);var km=R(i1(),1);var yi=R(B(),1),{LazyLoadComponent:tR}=km||km.default;function Om(e){let{size:t,visible:i,classes:n,canvasId:r,figure:a}=e,l=t?.width||128,c=t?.height||t?.width||128,p=(0,yi.jsx)(iR,{...e}),m=(0,yi.jsx)(tR,{threshold:300,style:{height:c,width:l},visibleByDefault:i,children:r?(0,yi.jsx)(Vi,{canvas:r,children:p}):p});return a?(0,yi.jsx)("figure",{className:n?.figure,children:m}):m}function iR({fallback:e,size:t,classes:i,showLabel:n,alt:r,dereference:a=!1}){let l=Ce(),c=t?.width||128,p=t?.height||t?.width||128,m=r||Zf(l?.label)||"",h=Qn({width:c,height:p,allowUnsafe:!0},a);return!h||h.type!=="fixed"?(0,yi.jsx)(yi.Fragment,{children:e}):(0,yi.jsxs)(yi.Fragment,{children:[(0,yi.jsx)("div",{className:i?.imageWrapper,children:(0,yi.jsx)("img",{className:i?.img,src:h.id,alt:m})}),n?(0,yi.jsx)(Ii,{as:"figcaption",className:i?.label,children:l?.label}):null]})}var cs=R(B(),1);function nR({scrollBehaviour:e,dereference:t,flat:i,size:n,classes:r={},showLabel:a,figure:l,fallback:c}){let p=(0,jc.useRef)(null),{items:m,sequence:h,currentSequenceIndex:y,setSequenceIndex:S}=ha(),w={row:r.selected?.row||r.row,item:r.selected?.item||r.item,figure:r.selected?.figure||r.figure,img:r.selected?.img||r.img,label:r.selected?.label||r.label,imageWrapper:r.selected?.imageWrapper||r.imageWrapper};(0,jc.useLayoutEffect)(()=>{if(!p.current)return;let x=p.current.querySelector("[data-selected=true]");x&&x.scrollIntoView({behavior:e||"instant",block:"nearest",inline:"center"})},[y]);let v=[];for(let x of h){let A=[],C=h[y]===x;for(let I of x){let E=m[I];A.push((0,cs.jsx)("div",{className:C?w.item:r.item,children:(0,cs.jsx)(Om,{classes:C?w:r,canvasId:E.id,size:n,dereference:t,showLabel:a,figure:l,placeholder:(0,cs.jsx)("div",{style:{height:128,width:128}}),fallback:c})},I))}if(i){v.push(A);continue}v.push((0,cs.jsx)("div",{onClick:I=>{S(h.indexOf(x))},"data-selected":C,className:C?w.row:r.row,children:A},x.join("-")))}return(0,cs.jsx)("div",{ref:p,className:r.container,children:v})}var oi=R(B(),1),rR={draw:!0,polygon:!0,line:!0,lineBox:!0,square:!0,triangle:!0,hexagon:!0,circle:!0,delete:!0};function oR({helper:e,showShapes:t,state:i,enabled:n=rR,classNames:r={},icons:a={}}){return(0,oi.jsxs)(oi.Fragment,{children:[t?(0,oi.jsxs)(oi.Fragment,{children:[n.draw&&(0,oi.jsx)("button",{className:r.button,onClick:()=>{e.stamps.clear(),e.draw.enable()},"data-active":!i.lineMode&&!i.selectedStamp&&t&&i.drawMode,children:a.DrawIcon||"Draw"}),n.polygon&&(0,oi.jsx)("button",{className:r.button,"data-active":!i.lineMode&&!i.selectedStamp&&t&&!i.drawMode,onClick:()=>{e.stamps.clear(),e.draw.disable(),e.modes.disableLineBoxMode(),e.modes.disableLineMode()},children:a.PolygonIcon||"Polygon"}),n.line&&(0,oi.jsx)("button",{className:r.button,"data-active":i.lineMode&&!i.lineBoxMode,onClick:()=>{e.modes.enableLineMode()},children:a.LineIcon||"Line"}),n.lineBox&&(0,oi.jsx)("button",{className:r.button,"data-active":i.lineBoxMode,onClick:()=>{e.modes.enableLineBoxMode()},children:a.LineBoxIcon||"LineBox"}),n.square&&(0,oi.jsx)("button",{className:r.button,"data-active":i.selectedStamp?.id==="square",onClick:()=>{e.stamps.square()},children:a.SquareIcon||"Square"}),n.triangle&&(0,oi.jsx)("button",{className:r.button,"data-active":i.selectedStamp?.id==="triangle",onClick:()=>{e.stamps.triangle()},children:a.TriangleIcon||"Triangle"}),n.hexagon&&(0,oi.jsx)("button",{className:r.button,"data-active":i.selectedStamp?.id==="hexagon",onClick:()=>{e.stamps.hexagon()},children:a.HexagonIcon||"Hexagon"})]}):null,i.showBoundingBox&&n.delete&&(0,oi.jsx)("button",{className:r.button,onClick:()=>e.key.down("Backspace"),children:a.DeleteForeverIcon||"Delete"})]})}var Ut=R(q(),1);var n1=R(B(),1),Vc=(0,Ut.createContext)(Vn());Vc.displayName="SelectorHelper";function sR({children:e}){return(0,n1.jsx)(Vc.Provider,{value:(0,Ut.useMemo)(()=>Vn(),[]),children:e})}function aR(){return(0,Ut.useContext)(Vc)}function Lm(e){let t=zm(),[i,n]=(0,Ut.useState)(!1);(0,Ut.useEffect)(()=>t.withSelector(e).on("highlight",()=>{n(!0)}),[t,e]),(0,Ut.useEffect)(()=>t.withSelector(e).on("clear-highlight",()=>{n(!1)}),[t,e]);let r=(0,Ut.useCallback)(l=>{t.emit("click",{selectorId:e,event:l})},[e,t]),a=(0,Ut.useCallback)(l=>{t.emit("hover",{selectorId:e,event:l})},[e,t]);return{controller:t,onClick:r,onHover:a,isHighlighted:i}}function zm(){let e=(0,Ut.useContext)(Vc);return(0,Ut.useMemo)(()=>({withSelector(t){return{on(i,n){let r=a=>{a&&a.selectorId===t&&n(a)};return e.on(i,r),()=>{e.off(i,r)}},emit(i,n){e.emit(i,{...n,selectorId:t})}}},on(t,i){return e.on(t,i),()=>{e.off(t,i)}},emit(t,i){e.emit(t,i)}}),[e])}function lR(){let e=zm();return(0,Ut.useMemo)(()=>({withSelector(t){return{highlight(){e.emit("highlight",{selectorId:t})},clearHighlight(){e.emit("clear-highlight",{selectorId:t})},zoomTo(){e.emit("zoom-to",{selectorId:t})},addEventListener(i,n){return e.emit("event-listener",{selectorId:t,name:i,callback:n}),()=>{e.emit("remove-event-listener",{selectorId:t,name:i,callback:n})}},getImagePreview(){return new Promise((i,n)=>{e.emit("image-preview-request",{selectorId:t,resolve:i,reject:n})})},on(i,n){return e.withSelector(t).on(i,n)}}},highlight(t){e.emit("highlight",{selectorId:t})},clearHighlight(t){e.emit("clear-highlight",{selectorId:t})},zoomTo(t){e.emit("zoom-to",{selectorId:t})},addEventListener(t,i,n){return e.emit("event-listener",{selectorId:t,name:i,callback:n}),()=>{e.emit("remove-event-listener",{selectorId:t,name:i,callback:n})}},getImagePreview(t){return new Promise((i,n)=>{e.emit("image-preview-request",{selectorId:t,resolve:i,reject:n})})},on(t,i){return e.on(t,i)}}),[e])}var ds=R(q(),1),r1=R(B(),1);function Fm(){return{default:{backgroundColor:"rgba(0,0,0,0)",borderWidth:"2px",borderColor:"rgba(252,0,98, .5)"},highlighted:{backgroundColor:"rgba(75, 103, 225, 0.4)",borderWidth:"1px",borderColor:"rgba(75,103,225,0.99)"},hidden:{borderWidth:"0px",borderColor:"rgba(0,0,0,0)",backgroundColor:"rgba(0,0,0,0)",hidden:!0}}}var Nm=(0,ds.createContext)(Fm());Nm.displayName="AnnotationStyle";function Bm(){return(0,ds.useContext)(Nm)}function uR({theme:e,children:t}){let i=(0,ds.useMemo)(()=>e||Fm(),[e]);return(0,r1.jsx)(Nm.Provider,{value:i,children:t})}var si=R(q(),1);var hs=R(q(),1);function l1(e){let t=e.points.length,i=!1,n=[];if(t>1){e.iedges=[];let r=e.points[t-1];for(let a=0;a<t;a++){let l=r;if(r=e.points[a],r.length===6){let m=r[2],h=r[3],y=r[4],S=r[5];n.push([a,[r[0]+m,r[1]+h],[r[0]+y,r[1]+S]]),i=!0}let c=[r[0]-l[0],r[1]-l[1]],p=c[0]*c[0]+c[1]*c[1];p>0?e.iedges.push([c[0]/p,c[1]/p]):e.iedges.push([0,0])}}else t===1?e.iedges=[[0,0]]:e.iedges=null;e.isBezier=i,e.bezierLines=n}function cR(e,t){let i=1/0,n=null,r=-1,a=e.points.length;if(a<=1)return[null,i,r];let l=e.points[a-1];for(let c=0;c<a;c++){let p=l;l=e.points[c];let m=p[0]-t[0],h=p[1]-t[1],y=m*m+h*h;y<i&&(n=p,i=y,r=c===0?a-1:c-1)}return[n,i,r]}function qc(e){if(e.points.length>2){let t=Math.min(...e.points.map(a=>a[0])),i=Math.min(...e.points.map(a=>a[1])),n=Math.max(0,...e.points.map(a=>a[0])),r=Math.max(0,...e.points.map(a=>a[1]));e.boundingBox={x:t,y:i,width:n-t,height:r-i};return}e.boundingBox=null}function dR(e){return e[0]*e[0]+e[1]*e[1]}function o1(e,t){let i=1/0,n=null,r=-1,a=[],l=e.points.length;if(l<=1)return[null,i,a,r];if(e.iedges===null&&(l1(e),!e.iedges))return[null,i,a,r];let c=e.points[l-1];for(let p=0;p<l;p++){let m=c;c=e.points[p];let h=(t[0]-m[0])*e.iedges[p][0]+(t[1]-m[1])*e.iedges[p][1],y;h<=0?y=m:h<1?y=[(1-h)*m[0]+h*c[0],(1-h)*m[1]+h*c[1]]:y=c;let S=dR([y[0]-t[0],y[1]-t[1]]);S<i&&(n=y,i=S,a=[m,c],r=p===0?l-1:p-1)}return[n,i,a,r]}var u1={type:"move-bounding-box",label:"Move bounding box",isValid(e,t,i){let n=t.polygon.points.length,r=n===t.selectedPoints.length,a=t.polygon.boundingBox;if(n<1||!r||!a)return!1;let l=e[0],c=l[0],p=l[1];return c>=a.x&&c<=a.x+a.width&&p>=a.y&&p<=a.y+a.height},transition(e,t,i){let n=t.transitionOrigin,r=t.polygon.boundingBox,a=e[0],l=a[0]-n[0],c=a[1]-n[1];t.transitionPoints=t.polygon.points.map(p=>p.length===6?[p[0]+l,p[1]+c,p[2],p[3],p[4],p[5]]:[p[0]+l,p[1]+c]),r&&(t.transitionBoundingBox={x:r.x+l,y:r.y+c,width:r.width,height:r.height})},commit(e,t,i){let n=t.transitionPoints;return t.transitionPoints=null,t.transitionBoundingBox=null,{points:n}}},c1={type:"move-shape",label:"Move shape",isValid(e,t,i){return i.Shift?!1:t.slowState.pointerInsideShape&&(!t.isOpen||t.line===null)},transition(e,t,i){u1.transition(e,t,i)},commit(e,t,i){let n=t.transitionPoints;return t.transitionPoints=null,t.transitionBoundingBox=null,{points:n}}};function s1(e,t){return Math.abs(e-t)}function qi(e,t){let i=s1(e[0],t[0]),n=s1(e[1],t[1]);return Math.sqrt(Math.pow(i,2)+Math.pow(n,2))}function Dm(e,t){return[e[0]-t[0],e[1]-t[1]]}function hR(e,t){return e[0]*t[0]+e[1]*t[1]}function d1(e){return e[0]*e[0]+e[1]*e[1]}function Uc(e,t){return d1(Dm(e,t))}function h1(e,t){let i,n,r,a;var l=function(v,x,A,C,I){if(C<=A+1)return;let E=A,L=0,z=v*v;i=[x[A],x[C]],n=Dm(i[1],i[0]);let M=d1(n),Q,V,J,U,W;for(let ee=A+1;ee<C;ee++)Q=Dm(x[ee],i[0]),U=hR(Q,n),U<=0?W=Uc(x[ee],i[0]):M<=U?W=Uc(x[ee],i[1]):(J=U/M,V=[i[0][0]+J*n[0],i[0][1]+J*n[1]],W=Uc(x[ee],V)),!(W<=L)&&(E=ee,L=W);L>z&&(I[E]=1,l(v,x,A,E,I),l(v,x,E,C,I))};let c=e.length,p=[],m,h,y,S,w=t*t;for(r=[],a=[],r[0]=e[0],m=h=1,S=0;m<c;m++)Uc(e[m],e[S])<w||(r[h++]=e[m],S=m);for(S<c-1&&(r[h++]=e[c-1]),a[0]=a[h-1]=1,l(t,r,0,h-1,a),m=y=0;m<h;m++)a[m]&&(p[y++]=r[m]);return p}var pR={type:"move-point",label:"Move point",modifiers:{Shift:"Constrain to axis"},isValid(e,t,i){if(i.Alt)return!1;let n=i.proximity,[r,a]=e[0],l=t.polygon.points,c=t.selectedPoints;for(let p=0;p<l.length;p++){let m=l[p],h=m[0]-r,y=m[1]-a;if(h*h+y*y<n*n)return!0}return!1},start(e,t,i){if(t.selectedPoints.length<2){let[n,r,a]=cR(t.polygon,e[0]);return{selectedPoints:[a]}}if(t.slowState.closestPoint&&!t.selectedPoints.includes(t.slowState.closestPoint))return{selectedPoints:[t.slowState.closestPoint]}},transition(e,t,i){let n=t.transitionOrigin,[r,a]=e[0],l=t.polygon.points,c=t.selectedPoints;if(t.slowState.closestPoint){let y=t.slowState.closestPoint;c.indexOf(y)===-1&&(c=[y])}let p=[],m=r-n[0],h=a-n[1];i.Shift&&(Math.abs(m)>Math.abs(h)?h=0:m=0);for(let y=0;y<l.length;y++){let S=c.indexOf(y)!==-1,w=l[y];S?w.length===6?p.push([w[0]+m,w[1]+h,w[2],w[3],w[4],w[5]]):p.push([w[0]+m,w[1]+h]):p.push(w)}t.transitionPoints=p},commit(e,t,i){let n=t.transitionPoints;return t.transitionPoints=null,t.transitionBoundingBox=null,{points:n}}},a1=10,fR={type:"select-point",label:"Select point",trigger:{type:"click"},modifiers:{Shift:"Add to selection"},isValid(e,t,i){let n=-1;if(t.selectedPoints.length===1){let c=t.selectedPoints[0];c===0&&(n=t.polygon.points.length-1),c===t.polygon.points.length-1&&(n=0)}let[r,a]=e[0],l=t.polygon.points;for(let c=0;c<l.length;c++){let p=l[c],m=p[0]-r,h=p[1]-a;if(m*m+h*h<a1*a1)return n!==c}return!1},commit(e,t,i){let n=i.Shift?[...t.selectedPoints]:[],[r,a]=e[0],l=t.polygon.points.map((c,p)=>{let m=c[0]-r,h=c[1]-a;return[m*m+h*h,p]}).sort((c,p)=>c[0]-p[0])[0];if(t.line=null,!n.includes(l[1]))n.push(l[1]);else if(i.Shift)return{selectedPoints:n.filter(c=>c!==l[1])};return{selectedPoints:n}}},p1={type:"split-line",label:"Split line",isValid(e,t,i){return i.Meta||t.slowState.lineMode?!1:!!(t.closestLinePoint&&t.closestLineDistance<i.proximity)},transition(e,t,i){let n=t.transitionOrigin,[r,a]=e[0],l=t.polygon.points,c=[],p=r-n[0],m=a-n[1];for(let h=0;h<l.length;h++)if(c.push(l[h]),t.closestLineIndex===h){let y=t.closestLinePoint;c.push([y[0]+p,y[1]+m])}t.transitionPoints=c},commit(e,t,i){let n=t.transitionPoints;return t.transitionPoints=null,t.transitionBoundingBox=null,{selectedPoints:[t.closestLineIndex+1],points:n}}},mR={type:"add-open-point",label:"Add point",trigger:{type:"click"},isValid(e,t,i){if(!t.isOpen)return!1;if(t.polygon.points.length===0)return!0;if(t.selectedPoints.length!==1||t.polygon.points.length>=2&&t.slowState.lineMode)return!1;let n=t.selectedPoints[0];return n===0||n===t.polygon.points.length-1},commit(e,t,i){let n=t.line?t.line[1]:e[0],r=t.polygon.points;return r.length===0?{selectedPoints:[0],points:[e[0]]}:(i.Shift,t.selectedPoints[0]===0?{selectedPoints:t.slowState.lineMode?[]:[0],points:[n,...r]}:(t.line=null,{selectedPoints:t.slowState.lineMode?[]:[r.length],points:[...r,n]}))}},f1={type:"close-shape",label:"Close shape",trigger:{type:"click"},isValid(e,t,i){if(!t.isOpen||t.selectedPoints.length!==1||t.polygon.points.length<2||i.Meta)return!1;let n=t.selectedPoints[0];if(n===0){let r=t.polygon.points[t.polygon.points.length-1];return qi(e[0],r)<i.proximity}if(n===t.polygon.points.length-1){let r=t.polygon.points[0];return qi(e[0],r)<i.proximity}return!1},commit(e,t,i){let n=t.selectedPoints[0];if(t.line=null,n===0)return{selectedPoints:[],points:t.polygon.points.slice(0).reverse(),isOpen:!1};if(n===t.polygon.points.length-1)return{selectedPoints:[],isOpen:!1}}},gR={type:"deselect-draw",label:"Deselect draw",trigger:{type:"key",key:"Escape"},isValid(e,t,i){return!0},commit(e,t,i){return{selectedPoints:[]}}},yR={type:"select-shape",label:"Select shape",trigger:{type:"click"},isValid(e,t,i){return c1.isValid(e,t,i)},commit(e,t,i){return{selectedPoints:t.polygon.points.map((n,r)=>r)}}},vR={type:"deselect-bounding-box",label:"Deselect bounding box",trigger:{type:"click"},isValid(e,t,i){return!t.isOpen&&t.selectedPoints.length>2&&t.selectedPoints.length===t.polygon.points.length},commit(e,t,i){return{selectedPoints:[]}}},xR={type:"bounding-box-corners",label:"Drag to resize",modifiers:{Shift:"Maintain aspect ratio",Alt:"Scale from center",Meta:"Rotate"},isValid(e,t,i){if(t.transitionDirection=null,t.transitionRotate=!1,t.isOpen||t.selectedPoints.length!==t.polygon.points.length||!t.polygon.boundingBox)return!1;let n=i.proximity*.5,r=i.proximity*3,a=e[0],l=t.polygon.boundingBox,c=l.x+n,p=l.x+l.width-n*2,m=l.y+n,h=l.y+l.height-n*2;if(a[0]>c&&a[0]<p&&a[1]>m&&a[1]<h)return!1;let y=[l.x+l.width,l.y+l.height],S=[l.x,l.y],w=[l.x+l.width,l.y],v=[l.x,l.y+l.height],x=["ne","nw","se","sw"],A=[qi(e[0],w),qi(e[0],S),qi(e[0],y),qi(e[0],v)],C=Math.min(...A);if(A[0]<r||A[1]<r||A[2]<r||A[3]<r){(C>i.proximity||i.Meta)&&(t.transitionRotate=!0);let I=A.indexOf(Math.min(...A));return t.transitionDirection=I!==-1?x[I]:null,!0}return!1},start(e,t,i){let n=e[0],r=t.polygon.boundingBox,a=[r.x+r.width,r.y+r.height],l=[r.x,r.y],c=[r.x+r.width,r.y],p=[r.x,r.y+r.height],m=["ne","nw","se","sw"],h=[qi(e[0],c),qi(e[0],l),qi(e[0],a),qi(e[0],p)],y=Math.min(...h),S=h.indexOf(y);t.transitionDirection=S!==-1?m[S]:null,y>i.proximity&&(t.transitionRotate=!0)},transition(e,t,i){let n=t.polygon.boundingBox,r=[n.x,n.y],a=t.transitionOrigin||e[0],[l,c]=e[0];if(i.Meta||t.transitionRotate){r=[n.x+n.width/2,n.y+n.height/2];let v=Math.atan2(a[1]-r[1],a[0]-r[0]),x=Math.atan2(c-r[1],l-r[0]),A=i.Shift,C=Math.PI/(i.Alt?4:12),I=x-v;A&&(I=Math.round(I/C)*C);let E=Math.cos(I),L=Math.sin(I),z=[];for(let M of t.polygon.points){let Q=M[0]-r[0],V=M[1]-r[1],J=Q*E-V*L,U=Q*L+V*E,W=J+r[0],ee=U+r[1];if(M.length===6){z.push([W,ee,M[2],M[3],M[4],M[5]]);continue}z.push([W,ee])}t.transitionPoints=z,qc({points:z,iedges:null,boundingBox:null,isBezier:!1,bezierLines:[]}),t.transitionBoundingBox=t.polygon.boundingBox?{...t.polygon.boundingBox,rotation:I}:null;return}let p=0,m=0;switch(t.transitionDirection){case"se":{r=[n.x,n.y],p=l-a[0],m=c-a[1];break}case"sw":{r=[n.x+n.width,n.y],p=a[0]-l,m=c-a[1];break}case"ne":{r=[n.x,n.y+n.height],p=l-a[0],m=a[1]-c;break}case"nw":{r=[n.x+n.width,n.y+n.height],p=a[0]-l,m=a[1]-c;break}}if(i.Alt&&(r=[n.x+n.width/2,n.y+n.height/2],p*=2,m*=2),i.Shift){let v=n.width/n.height;Math.abs(n.width/p)>Math.abs(n.height/m)?m=p/v:p=m*v}let h=(n.width+p)/n.width,y=(n.height+m)/n.height,S=[];for(let v of t.polygon.points){let x=v[0]-r[0],A=v[1]-r[1],C=x*h,I=A*y,E=C+r[0],L=I+r[1];if(v.length===6){S.push([E,L,v[2],v[3],v[4],v[5]]);continue}S.push([E,L])}t.transitionPoints=S;let w={points:S,iedges:null,boundingBox:null,bezierLines:[],isBezier:!1};qc(w),t.transitionBoundingBox=w.boundingBox},commit(e,t,i){let n=t.transitionPoints;return t.transitionPoints=null,t.transitionBoundingBox=null,t.transitionRotate=!1,{points:n}}},SR={type:"cut-line",label:"Add new point",trigger:{type:"click"},modifiers:{Shift:"Cut line"},isValid(e,t,i){return p1.isValid(e,t,i)},commit(e,t,i){if(i.Shift&&!t.isOpen){let a=t.polygon.points,l=[],c=[],p=!1;for(let m=0;m<a.length;m++)p?c.push(a[m]):l.push(a[m]),t.closestLineIndex===m&&(p=!0);return{isOpen:!0,points:[...c,...l]}}let n=t.polygon.points,r=[];for(let a=0;a<n.length;a++)if(r.push(n[a]),t.closestLineIndex===a){let l=t.closestLinePoint;r.push(l)}return{points:r}}},wR={type:"select-multiple-points",label:"Drag to select multiple points",isValid(e,t,i){return t.slowState.lineMode&&t.polygon.points.length>=2?!0:!t.line},transition(e,t,i){if(!t.transitionOrigin)return;let n=t.transitionOrigin[0],r=t.transitionOrigin[1],a=e[0][0],l=e[0][1],c=Math.min(n,a),p=Math.min(r,l),m=Math.abs(n-a),h=Math.abs(r-l);t.selectionBox={x:c,y:p,width:m,height:h}},commit(e,t,i){if(t.selectionBox){let n=[];i.Shift&&n.push(...t.selectedPoints);for(let r=0;r<t.polygon.points.length;r++){let a=t.polygon.points[r];a[0]>=t.selectionBox.x&&a[0]<=t.selectionBox.x+t.selectionBox.width&&a[1]>=t.selectionBox.y&&a[1]<=t.selectionBox.y+t.selectionBox.height&&n.push(r)}return{selectedPoints:n}}}},bR={type:"deselect-points",label:"Deselect points",trigger:{type:"click"},isValid(e,t,i){return t.selectedPoints.length>0},commit(e,t,i){return{selectedPoints:[]}}},Qc=4,CR={type:"nudge-right",label:"Nudge right",trigger:{type:"key",key:"ArrowRight"},modifiers:{Shift:"Nudge right more"},isValid(e,t,i){return t.selectedPoints.length>0},commit(e,t,i){let n=i.proximity*.3,r=t.polygon.points,a=t.selectedPoints;return{points:r.map((l,c)=>a.includes(c)?[l[0]+(i.Shift?Qc*n:1),l[1]]:l)}}},PR={type:"nudge-left",label:"Nudge left",trigger:{type:"key",key:"ArrowLeft"},modifiers:{Shift:"Nudge left more"},isValid(e,t,i){return t.selectedPoints.length>0},commit(e,t,i){let n=i.proximity*.3,r=t.polygon.points,a=t.selectedPoints;return{points:r.map((l,c)=>a.includes(c)?[Math.max(0,l[0]-(i.Shift?Qc*n:1)),l[1]]:l)}}},ER={type:"nudge-up",label:"Nudge up",trigger:{type:"key",key:"ArrowUp"},modifiers:{Shift:"Nudge up more"},isValid(e,t,i){return t.selectedPoints.length>0},commit(e,t,i){let n=i.proximity*.3,r=t.polygon.points,a=t.selectedPoints;return{points:r.map((l,c)=>{if(a.includes(c)){let p=l[0],m=Math.max(0,l[1]-(i.Shift?Qc*n:1));return l.length===6?[p,m,l[2],l[3],l[4],l[5]]:[p,m]}return l})}}},AR={type:"nudge-down",label:"Nudge down",trigger:{type:"key",key:"ArrowDown"},modifiers:{Shift:"Nudge down more"},isValid(e,t,i){return t.selectedPoints.length>0},commit(e,t,i){let n=i.proximity*.3,r=t.polygon.points,a=t.selectedPoints;return{points:r.map((l,c)=>{let p=l[0],m=Math.max(0,l[1]-(i.Shift?Qc*n:1));return a.includes(c)?l.length===6?[p,m,l[2],l[3],l[4],l[5]]:[p,m]:l})}}},IR={type:"delete-point",label:"Delete point",trigger:{type:"key",key:"Backspace"},isValid(e,t,i){return t.selectedPoints.length>0},commit(e,t,i){let n=t.polygon.points.filter((r,a)=>!t.selectedPoints.includes(a));return{isOpen:n.length<3,selectedPoints:[],points:n}}},RR={type:"draw-shape",label:"Draw shape",isValid(e,t,i){let n=i.Alt||t.slowState.drawMode;return!!(t.isOpen&&(t.line||t.polygon.points.length===0)&&n)},start(e,t,i){t.transitionDraw=[]},transition(e,t,i){t.transitionDraw.push(e[0])},commit(e,t,i){let n=h1(t.transitionDraw,t.scale*3);return t.transitionDraw=[],t.selectedPoints[0]===0?{isOpen:!1,points:[...n,...t.polygon.points.slice(0).reverse()]}:{isOpen:!1,points:[...t.polygon.points,...n]}}},TR={type:"stamp-shape",label:"Stamp shape",modifiers:{Shift:"Maintain aspect ratio"},isValid(e,t,i){return t.slowState.selectedStamp!==null},start(e,t,i){let n=e[0];if(n&&t.slowState.selectedStamp){let r=t.slowState.selectedStamp,a=n[0],l=n[1],c=[],p=Math.min(...r.points.map(x=>x[0])),m=Math.min(...r.points.map(x=>x[1])),h=Math.max(...r.points.map(x=>x[0]))-p,y=Math.max(...r.points.map(x=>x[1]))-m,S=h/32;y/32>S&&(S=y/32);let w=[],v=0;for(let x of r.points)w.push(v),c.push([a+(x[0]-p)/S,l+(x[1]-m)/S]),v++;return t.transitionPoints=c,{isOpen:!1,selectedPoints:w,points:c}}},transition(e,t,i){if(!t.transitionOrigin)return;let n=t.polygon.boundingBox,r=[n.x,n.y],a=t.transitionOrigin||e[0],[l,c]=e[0],p=t.transitionOrigin[0],m=t.transitionOrigin[1],h=e[0][0],y=e[0][1],S=h-p-32,w=y-m-32;if(i.Shift){let I=n.width/n.height;Math.abs(n.width/S)>Math.abs(n.height/w)?w=S/I:S=w*I}let v=(n.width+S)/n.width,x=(n.height+w)/n.height,A=[];for(let I of t.polygon.points){let E=I[0]-r[0],L=I[1]-r[1],z=E*v,M=L*x,Q=z+r[0],V=M+r[1];if(I.length===6){A.push([Q,V,I[2],I[3],I[4],I[5]]);continue}A.push([Q,V])}t.transitionPoints=A;let C={points:A,iedges:null,boundingBox:null,bezierLines:[],isBezier:!1};qc(C),t.transitionBoundingBox=C.boundingBox},commit(e,t,i){return{isOpen:!1,points:t.transitionPoints}}},_R={type:"close-shape-line",label:"Close shape line",trigger:{type:"click"},isValid(e,t,i){return!t.isOpen||t.polygon.points.length<3||!t.closestLinePoint||t.closestLineDistance>=i.proximity?!1:(t.closestLineIndex===0||(t.closestLineIndex,t.polygon.points.length-2),!0)},commit(e,t,i){return f1.commit(e,t,i)}},MR={type:"stamp-fixed-size-shape",label:"Stamp fixed size shape",trigger:{type:"click"},isValid(e,t,i){return t.slowState.selectedStamp!==null},commit(e,t,i){let n=e[0],r=t.slowState.selectedStamp;if(!n||!r)return;let a=n[0],l=n[1],c=[],p=Math.min(...r.points.map(x=>x[0])),m=Math.min(...r.points.map(x=>x[1])),h=Math.max(...r.points.map(x=>x[0]))-p,y=Math.max(...r.points.map(x=>x[1]))-m,S=4*i.proximity,w=h/S;y/S>w&&(w=y/S),a-=h/w/2,l-=y/w/2;let v=0;for(let x of r.points)c.push([a+(x[0]-p)/w,l+(x[1]-m)/w]),v++;return{isOpen:!1,points:c}}},kR={type:"move-line",label:"Move line",isValid(e,t,i){return t.slowState.lineMode?!!(t.closestLinePoint&&t.closestLineDistance<i.proximity):!1},transition(e,t){let i=t.transitionOrigin,n=t.polygon.boundingBox,r=e[0],a=r[0]-i[0],l=r[1]-i[1];t.transitionPoints=t.polygon.points.map(c=>c.length===6?[c[0]+a,c[1]+l,c[2],c[3],c[4],c[5]]:[c[0]+a,c[1]+l])},commit(e,t,i){let n=t.transitionPoints;return t.transitionPoints=null,t.transitionBoundingBox=null,{points:n}}},OR={type:"close-line-box",label:"Close Line Box",trigger:{type:"click"},isValid(e,t,i){return t.slowState.lineBoxMode===!0&&t.polygon.points.length===2&&t.lineBox!==null},commit(e,t,i){return t.lineBox?{isOpen:!1,points:t.lineBox}:{}}};function m1(e={}){let t=e.proximityThreshold||10,i=e.closestLinePointFill||{selected:"#fff",unselected:"rgba(255, 255, 255, .5)"},n=e.closestLinePointStroke||{selected:"#000",unselected:"rgba(0, 0, 0, .5)"};function r(v,x,A){v&&x.transitionBoundingBox&&A.transitioning&&(v.setAttribute("x",""+x.transitionBoundingBox.x),v.setAttribute("y",""+x.transitionBoundingBox.y),v.setAttribute("width",""+x.transitionBoundingBox.width),v.setAttribute("height",""+x.transitionBoundingBox.height))}function a(v,x,A){v&&x.polygon.boundingBox&&A.showBoundingBox&&(v.setAttribute("x",""+x.polygon.boundingBox.x),v.setAttribute("y",""+x.polygon.boundingBox.y),v.setAttribute("width",""+x.polygon.boundingBox.width),v.setAttribute("height",""+x.polygon.boundingBox.height))}function l(v,x,A){if(v&&x.polygon.boundingBox&&A.showBoundingBox){let C=x.transitionBoundingBox||x.polygon.boundingBox;C.rotation?(v.style.transformOrigin=`${C.x+C.width/2}px ${C.y+C.height/2}px`,v.style.transform=`rotate(${Math.round(100*C.rotation*(180/Math.PI))/100}deg)`):v.style.transform="",v.setAttribute("points",[[C.x,C.y],[C.x+C.width,C.y],[C.x+C.width,C.y+C.height],[C.x,C.y+C.height]].map(I=>I.join(",")).join(" "))}}function c(v,x,A){v&&x.transitionPoints&&A.transitioning&&v.setAttribute("points",x.transitionPoints.map(C=>C.join(",")).join(" "))}function p(v,x,A){v&&x.closestLinePoint&&A.hasClosestLine&&(v.setAttribute("cx",""+x.closestLinePoint[0]),v.setAttribute("cy",""+x.closestLinePoint[1]),v.setAttribute("fill",x.closestLineDistance<t?i.selected:i.unselected),v.setAttribute("stroke",x.closestLineDistance<t?n.selected:n.unselected))}function m(v,x,A){v&&x.closestLinePoint&&A.hasClosestLine&&v.setAttribute("transform",`translate(${x.closestLinePoint[0]}, ${x.closestLinePoint[1]})`)}function h(v,x,A){v&&x.selectionBox&&A.transitionIntentType==="select-multiple-points"&&(v.setAttribute("x",""+x.selectionBox.x),v.setAttribute("y",""+x.selectionBox.y),v.setAttribute("width",""+x.selectionBox.width),v.setAttribute("height",""+x.selectionBox.height))}function y(v,x,A){if(v&&x.pointer&&x.selectedPoints.length)if(A.actionIntentType==="close-shape"||A.actionIntentType==="close-shape-line"){let C=x.polygon.points[0],I=x.polygon.points[x.polygon.points.length-1];C&&I&&v.setAttribute("points",`${C.join(",")} ${I.join(",")}`)}else if(x.line)v.setAttribute("points",`${x.line[0].join(",")} ${x.line[1].join(",")}`);else{let C=x.polygon.points[x.selectedPoints[0]];C&&C.length&&v.setAttribute("points",`${x.pointer[0]},${x.pointer[1]} ${C.join(",")}`)}}function S(v,x,A,C=3){v&&x.transitionDraw.length&&v.setAttribute("points",h1(x.transitionDraw,C*3).map(I=>I.join(",")).join(" "))}function w(v,x){v&&x.lineBox&&v.setAttribute("points",x.lineBox.map(A=>A.join(",")).join(" "))}return{updateTransitionBoundingBox:r,updateClosestLinePointTransform:m,updateBoundingBoxPolygon:l,updateBoundingBox:a,updateTransitionShape:c,updateClosestLinePoint:p,updateSelectBox:h,updatePointLine:y,updateDrawPreview:S,updateLineBox:w}}var LR=typeof window<"u"?window.requestAnimationFrame:e=>setTimeout(e,16),zR=typeof window<"u"?window.cancelAnimationFrame:e=>clearTimeout(e),Vm=[TR,xR,pR,kR,p1,c1,u1,RR,wR],FR=Vm.length,jm=[OR,MR,f1,fR,_R,SR,mR,yR,vR,bR],Hc=[gR,CR,PR,ER,AR,IR],Va={};Vm.forEach(e=>{Va[e.type]=e});jm.forEach(e=>{Va[e.type]=e});Hc.forEach(e=>{Va[e.type]=e});var Wc=20;function g1(e,t){let i={shapeId:e?.id||null,noShape:e===null,transitioning:!1,actionIntentType:null,transitionIntentType:null,selectedPoints:[],hasClosestLine:!1,modifiers:{Alt:!1,Shift:!1,Meta:!1,proximity:Wc},showBoundingBox:!1,currentModifiers:{},validIntentKeys:{},pointerInsideShape:!1,closestPoint:null,transitionModifiers:null,selectedStamp:null,lineMode:!1,lineBoxMode:!1,drawMode:!1,bezierLines:[]},n={isOpen:e?e.open:!1,polygon:{points:e?.points||[],iedges:null,boundingBox:null,isBezier:null,bezierLines:[]},scale:1,selectedPoints:[],pointer:null,line:null,lineBox:null,transitionPoints:null,transitionOrigin:null,transitionBoundingBox:null,closestLinePoint:null,closestLineDistance:0,closestLineIndex:-1,transitionRotate:!1,transitionDirection:null,transitionBezierLine:null,selectionBox:null,slowState:i,transitionDraw:[]},r={startTime:0,time:0,shouldUpdate:!1,nextSlowState:null,renderFunc:()=>{},setStateFunc:()=>{},animationFrame:0,actionIntent:null,transitionIntent:null,undoStack:[],undoStackPointer:-1},a={isPressed:!1,isClicking:!1,lastPress:null,pressTimeout:0,noTransition:!1};function l(N){l1(N),N.isBezier&&c({bezierLines:N.bezierLines}),qc(N),r.shouldUpdate=!0}l(n.polygon);function c(N){let G=Object.keys(N);if(G.length===0)return;let de=r.nextSlowState||n.slowState,ye=!1;if(G.length===1&&G[0]==="validIntentKeys"&&de.validIntentKeys){let ge=Object.keys(de.validIntentKeys),Ve=Object.keys(N.validIntentKeys||{});if(ge.length===Ve.length){for(let ze of ge)de.validIntentKeys[ze]!==N.validIntentKeys[ze]&&(ye=!0);if(!ye)return}}if(!(G.length===1&&G.includes("hasClosestLine")&&N.hasClosestLine===de.hasClosestLine)){if(r.nextSlowState){r.nextSlowState={...r.nextSlowState,...N};return}r.nextSlowState={...n.slowState,...N}}}function p(N,G=!1){r.time+=N,m(),h(),C(),A(),x(),I(),L(),E(),r.renderFunc(n,n.slowState,N),!G&&(r.animationFrame=LR(p))}function m(){if(r.shouldUpdate&&(t({id:n.slowState.shapeId||void 0,open:n.isOpen,points:n.polygon.points}),r.shouldUpdate=!1),r.nextSlowState&&r.nextSlowState!==n.slowState){let N=Object.keys(n.slowState),G={},de=!1;for(let ye of N){let ge=n.slowState[ye],Ve=r.nextSlowState[ye];ge!==Ve?(de=!0,G[ye]=Ve):G[ye]=ge}de&&(n.slowState=G,r.nextSlowState=null,r.setStateFunc(n.slowState))}}function h(){n.slowState.showBoundingBox?(n.slowState.noShape||n.selectedPoints.length===0||n.selectedPoints.length!==n.polygon.points.length)&&c({showBoundingBox:!1}):!n.slowState.noShape&&n.polygon.points.length&&n.selectedPoints.length===n.polygon.points.length&&c({showBoundingBox:!0})}function y(N){n.selectedPoints=N.selectedPoints,c({selectedPoints:N.selectedPoints}),n.polygon.points=N.points,n.polygon.boundingBox=null,n.polygon.iedges=null,n.polygon.isBezier=null,l(n.polygon),c({closestPoint:null}),(N.isOpen===!0||N.isOpen===!1)&&(n.isOpen=N.isOpen,r.shouldUpdate=!0)}function S(){if(r.undoStackPointer===-1)return;r.undoStackPointer--;let N=r.undoStack[r.undoStackPointer];y(N)}function w(){if(r.undoStackPointer===r.undoStack.length-1)return;r.undoStackPointer++;let N=r.undoStack[r.undoStackPointer];y(N)}function v(N){r.undoStackPointer++,r.undoStack[r.undoStackPointer]=N,r.undoStack.length>15&&(r.undoStack.shift(),r.undoStackPointer--)}function x(){if(!n.pointer||n.slowState.noShape){c({pointerInsideShape:!1});return}let[N,G]=n.pointer,de=n.polygon.points,ye=n.polygon.boundingBox;if(!ye){c({pointerInsideShape:!1});return}if(N<ye.x||N>ye.x+ye.width||G<ye.y||G>ye.height+ye.y){c({pointerInsideShape:!1});return}let ge=!1;for(let Ve=0,ze=de.length-1;Ve<de.length;ze=Ve++)de[Ve][1]>G!=de[ze][1]>G&&N<(de[ze][0]-de[Ve][0])*(G-de[Ve][1])/(de[ze][1]-de[Ve][1])+de[Ve][0]&&(ge=!ge);c({pointerInsideShape:ge})}function A(){if(n.slowState.noShape||!n.pointer||n.slowState.transitioning||!n.polygon.points||n.polygon.points.length===0)return;let[N,G]=n.pointer,de=n.polygon.points.map((ye,ge)=>{let Ve=ye[0]-N,ze=ye[1]-G;return[Ve*Ve+ze*ze,ge]}).sort((ye,ge)=>ye[0]-ge[0]);de.length&&c({closestPoint:de[0][1]})}function C(){if(!n.pointer||n.slowState.transitioning)return;if(n.slowState.noShape){n.closestLineIndex=-1,n.closestLinePoint=null,n.closestLineDistance=0;return}let[N,G,de,ye]=o1(n.polygon,n.pointer),ge=pe()*pe();G<ge&&(!n.isOpen||n.slowState.lineMode||n.polygon.points.length-1!==ye)?(n.closestLinePoint=N,n.closestLineDistance=Math.sqrt(G),n.closestLineIndex=ye,c({hasClosestLine:!0})):(n.closestLinePoint=null,n.closestLineDistance=0,n.closestLineIndex=-1,c({hasClosestLine:!1}))}function I(){if(!n.pointer||n.slowState.transitioning||n.slowState.noShape)return;let N=!1;for(let ye=0;ye<FR;ye++){let ge=Vm[ye];if(ge.isValid(a.isPressed?[a.lastPress]:[n.pointer],n,z())){if(r.transitionIntent===ge){N=!0;break}c({transitionIntentType:ge.type}),r.transitionIntent=ge,N=!0;break}}N||r.transitionIntent&&(r.transitionIntent=null,c({transitionIntentType:null}));let G=!1;for(let ye=0;ye<jm.length;ye++){let ge=jm[ye];if(Q(ge)){if(r.actionIntent===ge){G=!0;break}c({actionIntentType:ge.type}),r.actionIntent=ge,G=!0;break}}G||r.actionIntent&&(r.actionIntent=null,c({actionIntentType:null}));let de={};for(let ye=0;ye<Hc.length;ye++){let ge=Hc[ye];ge.trigger.type==="key"&&Q(ge)&&(de[ge.trigger.key]=ge.label)}c({validIntentKeys:de})}function E(){let N=n.pointer;if(n.lineBox=null,!N||J()||n.polygon.points.length!==2)return;let[G,de]=N,[ye,ge]=n.polygon.points[0],[Ve,ze]=n.polygon.points[1],[Pe,ne,he,Oe]=o1(n.polygon,N);if(!Pe)return;let ot=G-Pe[0],Ri=de-Pe[1],Dt=[ye,ge],Wt=[Ve,ze],ps=[Wt[0]+ot,Wt[1]+Ri],Ti=[Dt[0]+ot,Dt[1]+Ri];n.lineBox=[Dt,Wt,ps,Ti]}function L(){let N=n.pointer;if(!N||!J()||n.slowState.noShape)return;let G=n.selectedPoints[0];if(n.line=[n.polygon.points[G],N],n.slowState.modifiers.Shift){let de=0;if(n.polygon.points.length>1){let ot=n.selectedPoints[0];ot===0?de=Math.atan2(n.polygon.points[1][1]-n.polygon.points[0][1],n.polygon.points[1][0]-n.polygon.points[0][0]):de=Math.atan2(n.polygon.points[ot-1][1]-n.polygon.points[ot][1],n.polygon.points[ot-1][0]-n.polygon.points[ot][0])}let ye=N[0]-n.polygon.points[G][0],ge=N[1]-n.polygon.points[G][1],Ve=Math.atan2(ge,ye),ze=Math.PI/4,Pe=Math.round((Ve-de)/ze)*ze+de,ne=qi(n.polygon.points[G],N),he=Math.cos(Pe)*ne+n.polygon.points[G][0],Oe=Math.sin(Pe)*ne+n.polygon.points[G][1];n.line[1]=[he,Oe]}}function z(){return n.slowState.modifiers}function M(N){let G=N.commit([a.lastPress],n,z());G&&(G.selectedPoints&&(n.selectedPoints=G.selectedPoints,c({selectedPoints:G.selectedPoints})),G.points&&(n.polygon.points=G.points,n.polygon.boundingBox=null,n.polygon.iedges=null,n.polygon.isBezier=null,n.transitionBoundingBox=null,l(n.polygon),c({closestPoint:null,selectedStamp:null})),(G.isOpen===!0||G.isOpen===!1)&&(n.isOpen=G.isOpen,r.shouldUpdate=!0),v({isOpen:n.isOpen,points:n.polygon.points,selectedPoints:n.selectedPoints})),c({transitionModifiers:null})}function Q(N){return N.isValid(n.pointer?[n.pointer]:[],n,z())}function V(N){N==="Delete"&&(N="Backspace");for(let G of Hc)if(!(G.trigger.type!=="key"||G.trigger.key!==N)&&Q(G))return M(G),!0}function J(){let N=n.polygon.points,G=n.pointer;if(!n.isOpen||!N.length||n.selectedPoints.length!==1||!G)return!1;let de=n.selectedPoints[0],ye=de===0,ge=de===N.length-1;return ye||ge}let U={reset(){c({modifiers:{Alt:!1,Shift:!1,Meta:!1,proximity:Wc}})},getForType(N){let G={};if(!N)return G;let de=Va[N];return!de||!de.modifiers?G:de.modifiers},set(N){N!=="Shift"&&N!=="Alt"&&N!=="Meta"||c({modifiers:{...r.nextSlowState?.modifiers||n.slowState.modifiers,[N]:!0}})},unset(N){N!=="Shift"&&N!=="Alt"&&N!=="Meta"||c({modifiers:{...r.nextSlowState?.modifiers||n.slowState.modifiers,[N]:!1}})}},W={set(N){c({selectedStamp:N})},clear(){c({selectedStamp:null})},square(){c({selectedStamp:{id:"square",open:!1,points:[[0,0],[0,100],[100,100],[100,0]]}})},triangle(){c({selectedStamp:{id:"triangle",open:!1,points:[[50,0],[0,100],[100,100]]}})},pentagon(){c({selectedStamp:{id:"pentagon",open:!1,points:[[0,0],[0,100],[100,100],[100,0],[50,-50]]}})},hexagon(){c({selectedStamp:{id:"hexagon",open:!1,points:[[0,0],[0,100],[50,150],[100,100],[100,0],[50,-50]]}})}},ee={down(N){return N=="Shift"||N=="Alt"||N=="Meta"?(U.set(N),!0):N==="Control"?(U.set("Meta"),!0):N==="z"&&n.slowState.modifiers.Meta?(n.slowState.modifiers.Shift?w():S(),!0):V(N)},up(N){if(N==="Control"){U.unset("Meta");return}N!=="Shift"&&N!=="Alt"&&N!=="Meta"||U.unset(N)}};function Me(N){n.scale=N,c({modifiers:{...r.nextSlowState?.modifiers||n.slowState.modifiers,proximity:N*Wc}})}function pe(){return Wc*n.scale}let Re={set:N=>{r.renderFunc=N},start:(N,G)=>{r.startTime=performance.now(),r.time=0,N&&(r.renderFunc=N),G&&(G(n.slowState),r.setStateFunc=G),p(0)},stop:()=>{r.animationFrame&&(zR(r.animationFrame),r.animationFrame=0)},step:(N=16)=>{p(N)}};function ke(N){let G=N[0];if(!(!G||!G[0]&&G[0]!==0||!G[1]&&G[1]!==0)&&!(Number.isNaN(G[0])||Number.isNaN(G[1]))){if(n.pointer=G||null,n.slowState.transitioning)r.transitionIntent&&r.transitionIntent.transition(N,n,z());else if(a.isPressed&&!a.noTransition&&(!a.isClicking||qi(a.lastPress,n.pointer)>10))if(clearTimeout(a.pressTimeout),a.isClicking=!1,r.transitionIntent){if(n.transitionOrigin=a.lastPress,c({transitioning:!0}),r.transitionIntent.start){let de=r.transitionIntent.start([a.lastPress],n,z());de&&(de.selectedPoints&&(n.selectedPoints=de.selectedPoints,c({selectedPoints:de.selectedPoints})),(de.isOpen===!0||de.isOpen===!1)&&(n.isOpen=de.isOpen,r.shouldUpdate=!0),de.points&&(n.polygon.points=de.points,n.polygon.boundingBox=null,n.polygon.iedges=null,l(n.polygon),c({closestPoint:null})))}c({transitionModifiers:r.transitionIntent.modifiers||null}),r.transitionIntent.transition([a.lastPress],n,z())}else a.noTransition=!0}}function He(){n.pointer=null,n.slowState.transitioning||(a.isPressed=!1,a.isClicking=!1,a.lastPress=null,c({transitionIntentType:null,actionIntentType:null}),r.transitionIntent=null,r.actionIntent=null)}function qe(){a.isClicking=!0,a.isPressed=!0,a.lastPress=n.pointer,a.pressTimeout=setTimeout(()=>{a.isPressed&&(a.isClicking=!1)},250)}function $(){n.slowState.transitioning?(c({transitioning:!1}),r.transitionIntent&&M(r.transitionIntent),r.transitionIntent=null,c({transitionIntentType:null})):a.isClicking&&(r.actionIntent&&M(r.actionIntent),r.actionIntent=null,c({actionIntentType:null})),a.isPressed=!1,a.isClicking=!1,a.lastPress=null,a.noTransition=!1,clearTimeout(a.pressTimeout)}function ve(N){n.polygon.points=N?.points||[],n.polygon.boundingBox=null,n.polygon.iedges=null,n.isOpen=N?.open||!1,l(n.polygon),r.nextSlowState=null,r.undoStack=[],r.undoStackPointer=-1,n.lineBox=null,n.line=null,a.pressTimeout&&clearTimeout(a.pressTimeout),c({noShape:N===null,shapeId:N?.id||null,transitioning:!1,actionIntentType:null,transitionIntentType:null,selectedPoints:[],hasClosestLine:!1,modifiers:{Alt:!1,Shift:!1,Meta:!1,proximity:n.slowState.modifiers.proximity},showBoundingBox:!1,currentModifiers:{},validIntentKeys:{},selectedStamp:null,drawMode:!1,closestPoint:null,pointerInsideShape:!1,lineBoxMode:!1,lineMode:!1}),m()}function it(N){if(!N)return"";let G=Va[N];return!G||!G.modifiers?G.label||"":n.slowState.modifiers.Shift&&G.modifiers.Shift?G.modifiers.Shift:n.slowState.modifiers.Alt&&G.modifiers.Alt?G.modifiers.Alt:n.slowState.modifiers.Meta&&G.modifiers.Meta?G.modifiers.Meta:G.label}function Qe(){n.slowState.lineMode?c({lineMode:!1,lineBoxMode:!1,drawMode:!1}):c({lineMode:!0,lineBoxMode:!1,drawMode:!1})}function $e(){n.slowState.lineBoxMode?c({lineMode:!1,lineBoxMode:!1,drawMode:!1}):c({lineBoxMode:!0,lineMode:!0,drawMode:!1})}return{draw:{enable(){c({drawMode:!0,lineMode:!1,lineBoxMode:!1})},disable(){c({drawMode:!1})},toggle(){c({drawMode:!n.slowState.drawMode,lineMode:!1,lineBoxMode:!1})}},state:n,modifiers:U,stamps:W,key:ee,setScale:Me,clock:Re,pointer:ke,blur:He,pointerDown:qe,pointerUp:$,setShape:ve,modes:{toggleLineBoxMode:$e,toggleLineMode:Qe,enableLineMode(){c({lineMode:!0,lineBoxMode:!1,drawMode:!1})},disableLineMode(){c({lineMode:!1,lineBoxMode:!1,drawMode:!1})},enableLineBoxMode(){c({lineMode:!0,lineBoxMode:!0,drawMode:!1})},disableLineBoxMode(){c({lineMode:!1,lineBoxMode:!1,drawMode:!1})}},label:it}}function Um(e,t,i){let[n,r]=(0,hs.useState)({}),a=(0,hs.useMemo)(()=>g1(e,i),[]);return(0,hs.useEffect)(()=>(a.clock.start(t,r),()=>{a.clock.stop()}),[]),{state:n,helper:a}}var tt=R(B(),1),Cr=m1();function Wm(e,t){let{image:i,currentShape:n,onChange:r,hideShapeLines:a}=e,l=(0,si.useRef)(),c=(0,si.useRef)(),p=(0,si.useRef)(),m=(0,si.useRef)(),h=(0,si.useRef)(),y=(0,si.useRef)(),S=(0,si.useRef)(),w=(0,si.useRef)(),[v,x]=(0,si.useState)(null),[A,C]=(0,si.useState)(!1),{helper:I,state:E}=Um(n,(W,ee)=>{Cr.updateTransitionBoundingBox(c.current,W,ee),Cr.updateBoundingBoxPolygon(l.current,W,ee),Cr.updateTransitionShape(y.current,W,ee),Cr.updateClosestLinePointTransform(m.current,W,ee),Cr.updateSelectBox(p.current,W,ee),Cr.updatePointLine(S.current,W,ee),Cr.updateDrawPreview(h.current,W,ee,3),Cr.updateLineBox(w.current,W),x(W.transitionDirection),C(W.transitionRotate)},r);(0,si.useEffect)(()=>{I.setShape(n||null)},t),(0,si.useEffect)(()=>{let W=()=>{I.modifiers.reset()};return document.addEventListener("mouseleave",W),()=>{document.removeEventListener("mouseleave",W)}},[]);let L=(0,tt.jsxs)(tt.Fragment,{children:[(0,tt.jsx)("marker",{id:"dot",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:(0,tt.jsx)("circle",{cx:"5",cy:"5",r:"4",className:"marker"})}),(0,tt.jsx)("marker",{id:"selected",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:(0,tt.jsx)("circle",{cx:"5",cy:"5",r:"4",fill:"#FAFF00"})}),(0,tt.jsx)("marker",{id:"resizer",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:(0,tt.jsx)("rect",{width:"10",height:"10",stroke:"#FF0DCB",fill:"#fff",strokeWidth:2})})]}),z=n?n.open?"polyline":"polygon":null,M=!E.showBoundingBox&&E.closestPoint!==null&&E.actionIntentType==="select-point",Q=E.actionIntentType==="add-open-point",V=E.transitionIntentType==="split-line",J=E.transitioning&&E.selectedStamp&&E.transitionIntentType==="stamp-shape",U=n&&z?(0,tt.jsxs)(tt.Fragment,{children:[(0,tt.jsx)(z,{fill:!E.transitioning&&E.showBoundingBox?"rgba(255, 0, 0, .5)":"none",strokeWidth:J?0:2,stroke:a?"transparent":"#000",points:n.points.map(W=>W.join(",")).join(" "),vectorEffect:"non-scaling-stroke",markerStart:E.showBoundingBox?void 0:"url(#dot)",markerMid:E.showBoundingBox?void 0:"url(#dot)",markerEnd:E.showBoundingBox?void 0:"url(#dot)",style:{pointerEvents:"none"}}),E.lineBoxMode&&E.actionIntentType==="close-line-box"?(0,tt.jsx)("polygon",{fill:"rgba(255, 0, 0, .4)",ref:w,stroke:"#000",strokeWidth:2,vectorEffect:"non-scaling-stroke"}):null,E.transitionIntentType==="draw-shape"&&E.transitioning?(0,tt.jsx)("polyline",{ref:h,fill:"none",stroke:"rgba(255, 0, 0, .5)",strokeWidth:2,vectorEffect:"non-scaling-stroke"}):null,!E.showBoundingBox&&E.selectedPoints&&E.selectedPoints.length?(0,tt.jsx)("polyline",{strokeWidth:2,vectorEffect:"non-scaling-stroke",stroke:"transparent",markerStart:"url(#selected)",markerMid:"url(#selected)",markerEnd:"url(#selected)",fill:"transparent",points:n.points.filter((W,ee)=>E.selectedPoints?.includes(ee)).map(W=>W.join(",")).join(" ")}):null,M&&E.closestPoint!==null&&n.points[E.closestPoint]?(0,tt.jsx)("polyline",{strokeWidth:2,vectorEffect:"non-scaling-stroke",stroke:"transparent",markerStart:"url(#selected)",markerMid:"url(#selected)",markerEnd:"url(#selected)",fill:"transparent",points:`${n.points[E.closestPoint][0]},${n.points[E.closestPoint][1]}`}):null,!E.transitioning&&(E.actionIntentType==="add-open-point"||E.actionIntentType==="close-shape"||E.actionIntentType==="close-shape-line")?(0,tt.jsx)("polyline",{stroke:"#000",ref:S,strokeWidth:E.actionIntentType==="close-shape"?2:1,vectorEffect:"non-scaling-stroke"}):null,E.hasClosestLine&&(!E.transitionIntentType||E.transitionIntentType==="split-line")?(0,tt.jsx)("g",{ref:m,children:(0,tt.jsx)("polyline",{style:{opacity:.5},markerStart:"url(#dot)",points:"0,0 10,10",vectorEffect:"non-scaling-stroke",fill:"transparent",strokeWidth:2})}):null,E.transitioning?(0,tt.jsx)(z,{ref:y,fill:n.open?"none":"rgba(255, 0, 0, .5)",stroke:"rgba(255, 0, 0, .5)",strokeWidth:n.open?2:0}):null,E.transitioning&&E.transitionIntentType==="select-multiple-points"?(0,tt.jsx)("rect",{ref:p,fill:"rgba(255, 255, 255, .3)",strokeWidth:1,stroke:"rgba(0,0,0,.2)",vectorEffect:"non-scaling-stroke"}):null,E.showBoundingBox?null:(0,tt.jsx)("g",{name:"controls",children:!1}),E.showBoundingBox&&!J?(0,tt.jsx)("polygon",{ref:l,strokeWidth:2,stroke:"#FF0DCB",fill:"none",markerStart:"url(#resizer)",markerMid:"url(#resizer)",markerEnd:"url(#resizer)",vectorEffect:"non-scaling-stroke"}):null]}):null;return{helper:I,state:E,isAddingPoint:Q,isSplitting:V,isStamping:J,isHoveringPoint:M,transitionDirection:v,transitionRotate:A,defs:L,editor:U}}var $c=R(q(),1),y1=R(Ws(),1),vi=R(B(),1),v1=[{name:"Default",outer:{borderWidth:4,borderColor:"rgba(255, 255, 255, .4)"},inner:{borderWidth:2,borderColor:"#000"}},{name:"High contrast",outer:{borderWidth:3,borderColor:"#fff"},inner:{borderWidth:1,borderColor:"#000"}},{name:"Lightsaber",outer:{borderWidth:"4",borderColor:"rgba(56,68,255,0.64)"},inner:{borderWidth:"2",borderColor:"#fff"}},{name:"Bright",outer:{borderWidth:"6",borderColor:"#25d527"},inner:{borderWidth:"3",borderColor:"#a916ff"}},{name:"pink",outer:{borderWidth:"4",borderColor:"#ff00ff"},inner:{borderWidth:"2",borderColor:"#ffffff"}},{name:"fine (dark)",outer:{borderWidth:"1",borderColor:"#000000"},inner:{}},{name:"fine (light)",outer:{borderWidth:"1",borderColor:"#FFF"},inner:{}}];function Hm(e){let t=e.theme||v1[0],i=Mu(),{image:n}=e,{helper:r,defs:a,editor:l,state:c,transitionDirection:p,isSplitting:m,transitionRotate:h,isHoveringPoint:y,isAddingPoint:S,isStamping:w}=Wm({currentShape:e.shape||null,onChange:e.updateShape,image:e.image,hideShapeLines:!0},[]),v=E=>{r.pointer([[~~E.atlas.x,~~E.atlas.y]])};(0,$c.useEffect)(()=>{let E=L=>{r.key.up(L.key)};return document.addEventListener("keyup",E),()=>{document.removeEventListener("keyup",E)}},[]),(0,$c.useEffect)(()=>{let E=L=>{r.key.down(L.key)};return document.addEventListener("keydown",E),()=>{document.removeEventListener("keydown",E)}},[]),(0,$c.useEffect)(()=>{let E=[];return p&&E.push(`atlas-cursor-${p}`),c.actionIntentType==="cut-line"&&c.modifiers?.Shift&&E.push("atlas-cursor-cut"),(y||c.transitionIntentType==="move-shape"||c.transitionIntentType==="move-point")&&E.push("atlas-cursor-move"),S&&E.push("atlas-cursor-crosshair"),m&&E.push("atlas-cursor-copy"),h&&E.push("atlas-cursor-rotate"),c.transitionIntentType==="draw-shape"&&E.push("atlas-cursor-draw"),i?.canvas&&i.canvas.classList.add(...E),()=>{i?.canvas&&i.canvas.classList.remove(...E)}},[i?.canvas,S,y,m,c.modifiers?.Shift,c.actionIntentType,c.transitionIntentType,p,h]);let x=e.shape&&e.shape?.points.length===0,A=e.renderControls?e.renderControls(r,c,x):null,C=document.getElementById(e.controlsHtmlId||"atlas-controls"),I="shape";return(0,vi.jsx)(vi.Fragment,{children:(0,vi.jsxs)("world-object",{height:n.height,width:n.width,onMouseMove:v,onMouseDown:r.pointerDown,onMouseUp:r.pointerUp,onMouseLeave:r.blur,children:[e.shape?(0,vi.jsxs)(vi.Fragment,{children:[(0,vi.jsx)(I,{open:e.shape.open,points:e.shape.points,relativeStyle:!0,style:w?{}:t.outer}),(0,vi.jsx)(I,{open:e.shape.open,points:e.shape.points,relativeStyle:!0,style:w?{}:t.inner})]}):null,(0,vi.jsxs)(Cn,{relative:!0,interactive:!1,children:[(0,vi.jsx)("div",{style:{position:"absolute",top:0,right:0,left:0,bottom:0},children:(0,vi.jsxs)("svg",{width:"100%",height:"100%",viewBox:`0 0 ${n.width} ${n.height}`,tabIndex:-1,children:[(0,vi.jsx)("defs",{children:a}),l]})}),C?(0,y1.createPortal)(A,C,"controls"):null]})]})})}var qm=R(B(),1);function NR(e){let t=Ce(),i=e.annotationBucket,n=e.readOnly,r=e.id,{onClick:a,isHighlighted:l}=Lm(e.id),c=Bm(),p=l?c.highlighted:c[i||"hidden"]||c.hidden;if(!t)return null;if(n){let m="shape",h=e.polygon,y=h.open;return h?(0,qm.jsx)(m,{id:`shape-${r}`,points:h.points,open:y,onClick:a,relativeStyle:!0,target:{x:0,y:0,width:t.width,height:t.height},style:p}):null}return(0,qm.jsx)(Hm,{image:t,shape:e.polygon||{id:e.id,open:!0,points:[]},updateShape:e.updatePolygon,theme:e.theme,controlsHtmlId:e.controlsHtmlId,renderControls:e.renderControls})}var Gc=R(q(),1);var Pr=R(B(),1);function BR({src:e,errorFallback:t,interactive:i,skipSizes:n,children:r,renderViewerControls:a,viewControlsDeps:l,fluid:c,x:p,y:m,...h}){let[y,S]=(0,Gc.useState)(),w=t||hc,[v,x]=Ea(),A=(0,Gc.useMemo)(()=>{let I=x[e]?.status,E=v({id:e},{});return E?.height&&E.width&&I!=="loading"?{id:e,width:E.width,height:E.height,service:E,type:"Image",selector:{type:"BoxSelector",spatial:{x:0,y:0,width:E.width,height:E.height}},target:{type:"BoxSelector",spatial:{x:0,y:0,width:E.width,height:E.height}}}:null},[v,e,x]);if(Ft(y&&a?"overlay":"none",`canvas-portal-controls-${e}`,Ui.Provider,a&&A?{value:y||null,children:a({image:A,images:[A],type:"images"})}:{},[e,A,y,...l||[]]),!A||!A.height||!A.width)return null;let C=c?void 0:h.homePosition?h.homePosition.width/h.homePosition.height:A.width/A.height;return(0,Pr.jsx)(No,{resetKeys:[],fallbackRender:I=>(0,Pr.jsx)(w,{...h,...I}),children:(0,Pr.jsx)(fc,{...h,aspectRatio:C,containerProps:{style:{position:"relative"},...h.containerProps||{}},onCreated:I=>{S(I),h.onCreated&&h.onCreated(I)},children:(0,Pr.jsxs)(Ui.Provider,{value:y,children:[(0,Pr.jsx)(xr,{image:A,id:A.id,isStatic:!i,x:p,y:m},A.id),(0,Pr.jsx)(DR,{viewerPreset:y,renderViewerControls:a,image:A,src:e,viewControlsDeps:l}),r]})})})}function DR({viewerPreset:e,renderViewerControls:t,image:i,src:n,viewControlsDeps:r}){return Ft(e&&t?"overlay":"none",`canvas-portal-controls-${n}`,Ui.Provider,t&&i?{value:e||null,children:t({image:i,images:[i],type:"images"})}:{},[n,e,...r||[]]),null}var x1=R(B(),1);function jR({annotation:e,children:t}){return(0,x1.jsx)(ei,{value:{annotation:e},children:t})}var S1=R(B(),1);function VR({annotationPage:e,children:t}){return(0,S1.jsx)(ei,{value:{annotationPage:e},children:t})}var w1=R(B(),1);function UR({collection:e,children:t}){return(0,w1.jsx)(ei,{value:{collection:e},children:t})}function WR(e,t={}){return oo(t)}var Er=R(q(),1);function HR({canvasId:e}={}){let t=Ou(),i=eo(),n=(0,Er.useMemo)(()=>e?[e]:t?[t.id]:i.map(m=>m.id),[e,t,i]),[r,a]=(0,Er.useState)({}),l=pa();(0,Er.useEffect)(()=>{let m=h=>{let y=h.partOf.canvasId;y&&a(S=>({...S,[y]:h.choice}))};return l.on("choice-change",m),()=>{l.off("choice-change",m)}},[]);let c=(0,Er.useMemo)(()=>{let m=[];for(let h of n){let y=r[h];y&&m.push({canvasId:h,choice:y})}return m},[n,r]),p=(0,Er.useMemo)(()=>({makeChoice:(m,h)=>{l.emit("make-choice",{choiceId:m,...h})}}),[l]);return{choices:c,actions:p}}function qR(e,t=!1){}function QR(e){let i=Xt().manifest,n=e?e.map(r=>typeof r=="string"?r:r?.id):[];return De(r=>{let a=i?r.iiif.entities.Manifest[i]:void 0,l=a?.items||[];if(typeof e>"u")return l;let c=[];for(let p of a?.items||[])n.indexOf(p.id)!==-1&&c.push(p);return c},[n.join("/")])}var b1=R(q(),1);function $R(e,t=[]){let{id:i,selector:n}=e,r=Xt(),a=i||r.collection,l=De(c=>a?c.iiif.entities.Collection[a]:void 0,[a]);return(0,b1.useMemo)(()=>{if(l)return n?n(l):l},[l,n,...t])}var Yc=R(q(),1);function GR(e,t,i,n,r=[]){let a=_e(),l=(0,Yc.useMemo)(()=>ma(a),[a]);(0,Yc.useEffect)(()=>{let c=e;return c?(l.addEventListener(c,t,i,n),()=>{l.removeEventListener(c,t,i)}):()=>{}},[l,e,t,...r])}function YR(e,t){let{id:i,isLoaded:n,error:r,resource:a,requestId:l,cached:c}=aa(e,t);return{id:i,isLoaded:n,error:r,manifest:a,requestId:l,cached:c}}var En=R(q(),1);function Qm({cacheKey:e}={}){let t=Ce(),i=oo(),n=_e(),r=ss(),a=gw(),[l,c]=(0,En.useState)(void 0),[p,m]=(0,En.useState)(!1),[h,y]=(0,En.useState)("idle"),[S,w]=(0,En.useState)(void 0),v=t?t.id:"undefined",x=(0,En.useMemo)(()=>{try{if(t&&i.length){let C=i[0],I=n.get(C.body[0]),L=zn(I)[0];return L&&r(L,{width:L.width||t.width,height:L.height||t.height},!0)||void 0}}catch(C){console.error(C)}},[v,e,t]),A=h==="success"&&l?l:x;return(0,En.useEffect)(()=>{(async()=>{try{if(t&&i.length){let C=i[0],I=n.get(C.body[0]),L=zn(I)[0];if(!L)return;m(!0),y("loading");try{let z=await a(L,{width:L.width||t.width,height:L.height||t.height})||void 0;c(z),y("success"),m(!1)}catch(z){y("error"),w(z)}}}catch(C){y("error"),w(C)}})()},[v,e]),(0,En.useMemo)(()=>({data:A,isFetching:p,status:h,error:S}),[A,p,h,S])}function XR(){let e=Qm();return{isLoading:e.isFetching,tile:e.data?{id:e.data.id||e.data["@id"],width:e.data.width,height:e.data.height,imageService:e.data,thumbnail:void 0}:null}}var C1=R(q(),1);function KR(){let e=_e();return(0,C1.useMemo)(()=>yr(e),[e])}return jb(ZR);})();
|
|
125
125
|
/*! Bundled license information:
|
|
126
126
|
|
|
127
127
|
normalize-wheel/src/isEventSupported.js:
|