react-iiif-vault 1.0.10 → 1.0.11
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/cjs/index.js +3 -3
- package/dist/bundle/cjs/index.js.map +1 -1
- package/dist/bundle/esm/index.mjs +360 -355
- package/dist/bundle/esm/index.mjs.map +1 -1
- package/dist/canvas-panel/cjs/canvas-panel.js +2 -2
- package/dist/canvas-panel/cjs/canvas-panel.js.map +1 -1
- package/dist/canvas-panel/esm/canvas-panel.mjs +233 -228
- package/dist/canvas-panel/esm/canvas-panel.mjs.map +1 -1
- package/dist/index.umd.js +26 -26
- package/dist/index.umd.js.map +1 -1
- package/dist/react17/cjs/index.js +3 -3
- package/dist/react17/cjs/index.js.map +1 -1
- package/dist/react17/esm/index.mjs +360 -355
- package/dist/react17/esm/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),c=require("react"),Oe=require("@atlas-viewer/atlas"),Ye=require("@iiif/helpers/vault"),st=require("@iiif/helpers/styles"),Le=require("@iiif/helpers/annotation-targets"),Un=require("@iiif/helpers"),Ee=require("@atlas-viewer/iiif-image-api"),$n=require("@iiif/helpers/thumbnail"),Hn=require("react-dom"),Wn=c.createContext(null),rt={didCatch:!1,error:null};class Yn extends c.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=rt}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var n,o,r=arguments.length,s=new Array(r),i=0;i<r;i++)s[i]=arguments[i];(n=(o=this.props).onReset)===null||n===void 0||n.call(o,{args:s,reason:"imperative-api"}),this.setState(rt)}}componentDidCatch(t,n){var o,r;(o=(r=this.props).onError)===null||o===void 0||o.call(r,t,n)}componentDidUpdate(t,n){const{didCatch:o}=this.state,{resetKeys:r}=this.props;if(o&&n.error!==null&&zn(t.resetKeys,r)){var s,i;(s=(i=this.props).onReset)===null||s===void 0||s.call(i,{next:r,prev:t.resetKeys,reason:"keys"}),this.setState(rt)}}render(){const{children:t,fallbackRender:n,FallbackComponent:o,fallback:r}=this.props,{didCatch:s,error:i}=this.state;let a=t;if(s){const p={error:i,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")a=n(p);else if(o)a=c.createElement(o,p);else if(r===null||c.isValidElement(r))a=r;else throw i}return c.createElement(Wn.Provider,{value:{didCatch:s,error:i,resetErrorBoundary:this.resetErrorBoundary}},a)}}function zn(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((n,o)=>!Object.is(n,t[o]))}const Kn={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0,annotationPage:void 0},Ke=c.createContext(Kn),xe=()=>c.useContext(Ke);function we({value:e,children:t}){const n=xe(),o=c.useMemo(()=>({...n,...e}),[e,n]);return u.jsx(Ke.Provider,{value:o,children:t})}const ke=c.createContext({vault:null,setVaultInstance:e=>{}});function Qe({vault:e,vaultOptions:t,useGlobal:n,resources:o,children:r}){const[s,i]=c.useState(()=>e||(n?Ye.globalVault(t):t?new Ye.Vault(t):new Ye.Vault));return u.jsx(ke.Provider,{value:{vault:s,setVaultInstance:i},children:u.jsx(we,{value:o||{},children:r})})}function Ge(e){const t=c.useContext(ke);return e||(t&&t.vault?t.vault:Ye.globalVault())}function at(e,{noCache:t=!1}={}){const n=typeof e=="string"?e:e.id,o=Ge(),[r,s]=c.useState(n),[i,a]=c.useState(void 0),p=c.useMemo(()=>o.get(n,{skipSelfReturn:!0})||void 0,[n,o]),[y,f]=c.useState(p);return c.useEffect(()=>{(async()=>{try{const g=p&&!t?p:await o.load(n),O=g?g.id||g["@id"]:null;g&&r!==O&&s(O),f(g)}catch(g){a(g)}})()},[n,t]),{isLoaded:!!y,id:r,requestId:n,error:i,resource:y,cached:!!(y&&y===p)}}function Mt(e,t){const{id:n,isLoaded:o,error:r,resource:s,requestId:i,cached:a}=at(e,t);return{id:n,isLoaded:o,error:r,manifest:s,requestId:i,cached:a}}function Rt({manifest:e,children:t}){return u.jsx(we,{value:{manifest:e},children:t})}function Ve({canvas:e,children:t}){return u.jsx(we,{value:{canvas:e},children:t})}const te=()=>{const{vault:e}=c.useContext(ke);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};function se(e,t=[]){const n=te(),[o,r]=c.useState(()=>e(n.getState(),n));return c.useEffect(()=>n.subscribe(s=>e(s,n),s=>{r(s)},!1),t),o}const Ne=c.createContext([]);function ut(){const e=c.useContext(Ne);return se(t=>e.map(n=>t.iiif.entities.Canvas[n]).filter(Boolean),[e])}function ve(e={},t=[]){const{id:n,selector:o}=e,r=xe();te();const s=n||r.manifest,i=se(a=>s?a.iiif.entities.Manifest[s]:void 0,[s]);return c.useMemo(()=>{if(i)return o?o(i):i},[i,o,...t])}function Lt({range:e,children:t}){return u.jsx(we,{value:{range:e},children:t})}function At(e,t){for(const n of t.items){if(n.type==="Canvas")return n;if(n.type==="SpecificResource")return n.source;if(n.type==="Range"){const o=At(e,e.get(n));if(o)return o}}return null}function ct(e,t){var o;const n=[];for(const r of t.items)if(r.type==="SpecificResource"&&((o=r.source)==null?void 0:o.type)==="Canvas"&&(r.source.id.indexOf("#")!==-1?n.push({id:r.source.id.split("#")[0],type:"Canvas"}):n.push(r.source)),r.type==="Range"&&n.push(...ct(e,e.get(r))),r.type==="SpecificResource"){const s=typeof r.source=="string"?r.source:r.source.id;n.push({id:s,type:"Canvas"})}return n}function Qn(e,t,n){for(const o of t.structures){const r=lt(e,e.get(o),n);if(r)return r}return null}function lt(e,t,n){var o,r,s;for(const i of t.items){const a=(r=(o=i==null?void 0:i.source)==null?void 0:o.id)==null?void 0:r.split("#")[0];if(i.type==="SpecificResource"&&i.source===n||i.type==="SpecificResource"&&((s=i.source)==null?void 0:s.type)==="Canvas"&&n===a)return t;if(i.type==="Range"){const p=lt(e,e.get(i),n);if(p)return p}}return null}function Gn(e,t,n,o=!1){const r=t.behavior,s=n?e.get(n):null;if(!s)return[];const i=s.behavior,a=o?!1:r.includes("paged"),p=a?!1:r.includes("continuous"),y=a||p?!1:r.includes("individuals"),f=i.includes("facing-pages"),g=i.includes("non-paged");if(f||g||y||o)return[{id:s.id,type:"Canvas"}];const[O,R]=ft(e,t);if(p)return O;const E=O.findIndex(x=>x.id===n);if(E===-1)return[];for(const x of R)if(x.includes(E))return x.map(T=>O[T]);return[{id:s.id,type:"Canvas"}]}function ft(e,t,{disablePaging:n,skipNonPaged:o}={}){const r=t.behavior,s=r.includes("paged"),i=s?!1:r.includes("continuous"),a=s||i?!1:r.includes("individuals"),p=t.type==="Manifest"?t.items:ct(e,t);if(i)return[p,[p.map((E,x)=>x)]];if(a||!s||n)return[p,p.map((E,x)=>[x])];const y=[];let f=[];const g=()=>{f.length&&(y.push([...f]),f=[])};let O=0,R=!1;for(let E=0;E<p.length;E++){const x=e.get(p[E]);if(x.behavior.includes("non-paged")){E===O&&O++,o||(g(),y.push([E]),g());continue}if(E===O||x.behavior.includes("facing-pages")){f.length&&(R=!0),g(),y.push([E]),g();continue}if(f.push(E),R){g(),R=!1;continue}f.length>1&&g()}return f.length&&g(),[p,y]}function dt(e={},t=[]){const{id:n,selector:o}=e,r=xe(),s=n||r.range,i=se(a=>s?a.iiif.entities.Range[s]:void 0,[s]);return c.useMemo(()=>{if(i)return o?o(i):i},[i,o,...t])}function kt({startCanvas:e,disablePaging:t}){var E;const n=te(),o=ve(),r=dt(),[s,i]=c.useState(void 0),a=r||o;if(!a)throw new Error("Nothing selected");const[p,y]=c.useMemo(()=>ft(n,a,{disablePaging:t}),[n,a,t]),f=c.useCallback(x=>{const T=y.findIndex(I=>I.includes(x));i(T===-1?0:T)},[p,y]),g=c.useCallback(x=>{const T=p.findIndex(I=>I.id===x);T!==-1?f(T):i(0)},[p,y]),O=c.useCallback(()=>{i(x=>x>=y.length-1?x:x+1)},[y]),R=c.useCallback(()=>{i(x=>x<=0?0:x-1)},[y]);return typeof s>"u"&&(e?g(e):i(0)),{visibleItems:((E=y[s])==null?void 0:E.map(x=>p[x].id))||[],cursor:s,items:p,sequence:y,hasPrevious:s>0,hasNext:s<y.length-1,setSequenceIndex:i,setCanvasIndex:f,setCanvasId:g,next:O,previous:R}}const Re=()=>{},_e=c.createContext({setCurrentCanvasId:Re,setCurrentCanvasIndex:Re,nextCanvas:Re,previousCanvas:Re,items:[],sequence:[],setSequenceIndex:Re,currentSequenceIndex:0,hasNext:!1,hasPrevious:!1});function Vt(e){const t=ve(),{cursor:n,visibleItems:o,next:r,sequence:s,items:i,setCanvasIndex:a,setCanvasId:p,previous:y,setSequenceIndex:f,hasNext:g,hasPrevious:O}=kt({startCanvas:e.startCanvas,disablePaging:e.pagingEnabled===!1}),R=c.useMemo(()=>({sequence:s,items:i,setCurrentCanvasId:p,nextCanvas:r,previousCanvas:y,totalCanvases:i.length,setCurrentCanvasIndex:a,setSequenceIndex:f,currentSequenceIndex:n,hasNext:g,hasPrevious:O}),[s,i,p,r,y,i,a,f,n]);return t?o.length===0?null:u.jsx(_e.Provider,{value:R,children:u.jsx(Ne.Provider,{value:o,children:u.jsx(Ve,{canvas:o[0],children:e.children})})}):(console.warn("The manifest passed to the provider is not a valid IIIF manifest."),u.jsx("div",{children:"Sorry, something went wrong."}))}function Nt(e){const t=Ge(e.vault),n=Mt(e.manifest);if(!n)return console.warn("The manifest passed to the provider is not a valid IIIF manifest."),u.jsx("div",{children:"Sorry, something went wrong."});if(n.error)return u.jsx("div",{children:n.error.toString()});if(!n.isLoaded)return u.jsx("div",{children:"Loading..."});const o=u.jsx(Vt,{...e,children:e.children});return u.jsx(Qe,{vault:t,children:u.jsx(Rt,{manifest:n.id,children:e.rangeId?u.jsx(Lt,{range:e.rangeId,children:o}):o})})}function pt(){return c.useContext(_e)}function _t(){return{VaultContext:c.useContext(ke),ResourceContext:c.useContext(Ke),SimpleViewerReactContext:c.useContext(_e),VisibleCanvasReactContext:c.useContext(Ne)}}function Dt(e){return u.jsx(Qe,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:u.jsx(Ne.Provider,{value:e.bridge.VisibleCanvasReactContext,children:u.jsx(_e.Provider,{value:e.bridge.SimpleViewerReactContext,children:e.children})})})}const be=function(e){return function(){const t={type:e,getType:()=>e,toString:()=>e};return(n,o)=>({...t,...n!==void 0&&{payload:n},...o!==void 0&&{meta:o}})}},Xn="@iiif/IMPORT_ENTITIES",Jn="@iiif/MODIFY_ENTITY_FIELD",Zn="@iiif/REORDER_ENTITY_FIELD",er="@iiif/ADD_REFERENCE",tr="@iiif/UPDATE_REFERENCE",nr="@iiif/REMOVE_REFERENCE",rr="@iiif/ADD_METADATA",or="@iiif/REMOVE_METADATA",ir="@iiif/UPDATE_METADATA",sr="@iiif/REORDER_METADATA",ar=be(Xn)(),ur=be(Jn)(),cr=be(Zn)(),lr=be(er)(),fr=be(nr)(),dr=be(tr)(),pr=be(rr)(),hr=be(ir)(),yr=be(or)(),gr=be(sr)(),ot={importEntities:ar,modifyEntityField:ur,reorderEntityField:cr,addReference:lr,removeReference:fr,updateReference:dr,addMetadata:pr,removeMetadata:yr,updateMetadata:hr,reorderMetadata:gr};function qt(){const t=te().getStore();return c.useMemo(()=>n=>t.dispatch(n),[t])}function Et(e){return typeof e!="string"&&e&&e.bindToVault}function Ft(){const e=te(),t=c.useRef([]),n=qt(),o=c.useMemo(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);c.useLayoutEffect(()=>{const a={id:o,type:"AnnotationPage",behavior:[],label:null,thumbnail:[],summary:null,requiredStatement:null,metadata:[],rights:null,provider:[],items:[],seeAlso:[],homepage:[],rendering:[],service:[]};n(ot.importEntities({entities:{AnnotationPage:{[a.id]:a}}}))},[o]);const r=se(a=>o?a.iiif.entities.AnnotationPage[o]:null,[o]),s=c.useCallback((a,p)=>{if(o){if(Et(a)){const g=a;g.__vault||g.bindToVault(e),a=typeof g.source=="string"?g.source:g.source.id,t.current[a]=g}else typeof a!="string"&&(a=a.id);const y=e.get({id:o,type:"AnnotationPage"}),f=e.get({id:a,type:"Annotation"});y&&f&&(y.items.find(g=>g.id===f.id)||n(ot.addReference({id:o,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"},index:p})))}},[o]),i=c.useCallback(a=>{o&&(Et(a)?a=typeof a.source=="string"?a.source:a.source.id:typeof a!="string"&&(a=a.id),t.current[a]&&t.current[a].beforeRemove(),e.get({id:o,type:"AnnotationPage"})&&n(ot.removeReference({id:o,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"}})))},[o]);return[r,{addAnnotation:s,removeAnnotation:i}]}const Bt=c.createContext(null);function Ut(){const e=c.useContext(Bt);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function $t({children:e}){const[t,{addAnnotation:n,removeAnnotation:o}]=Ft();return u.jsx(Bt.Provider,{value:c.useMemo(()=>({fullPage:t,addAnnotation:n,removeAnnotation:o}),[t]),children:e})}function mr({width:e,style:t,height:n,error:o,resetErrorBoundary:r}){return u.jsxs("div",{style:{width:e,height:n,minHeight:500,...t||{},background:"#f9f9f9"},children:[u.jsx("h3",{children:"Error occurred"}),u.jsx("p",{children:o.message}),u.jsx("button",{onClick:r,children:"Reset"})]})}const Xe=c.createContext(null);function Ht(){return c.useContext(Xe)}const Wt=c.createContext(()=>{}),Yt=c.createContext(()=>{});function Ie(e,t,n,o,r=[]){const s=c.useContext(e==="portal"?Yt:Wt);c.useEffect(()=>(e!=="none"&&s(t,n,o),()=>{s(t,null)}),[t,e,s,...r])}function ye(e={},t=[]){const{id:n,selector:o}=e,r=xe(),s=n||r.canvas,i=se(a=>s?a.iiif.entities.Canvas[s]:void 0,[s]);return c.useMemo(()=>{if(i)return o?o(i):i},[i,o,...t])}const zt=c.createContext(()=>{});function vr(e){const t=ye(),n=c.useContext(zt);c.useEffect(()=>t&&t.id?(n(t.id,e),()=>n(t.id,-1)):()=>{},[t,e])}function br({children:e,errorFallback:t,outerContainerProps:n={},worldScale:o,...r}){const[s,i]=c.useState(),a=_t(),p=t||mr,[y,f]=c.useState({}),g=Object.entries(y),[O,R]=c.useState({}),E=Object.entries(O),[x,T]=c.useState({}),I=c.useMemo(()=>o||Math.max(...Object.values(x)),[x]),k=c.useMemo(()=>({maxOverZoom:I||1,...r.runtimeOptions||{}}),[I,r.runtimeOptions]),j=c.useCallback((L,q)=>{T(M=>{if(q===-1){const{[L]:P,...U}=M;return U}return{...M,[L]:q}})},[]),B=c.useCallback((L,q,M)=>{f(({[L]:P,...U})=>q?{...U,[L]:{element:q,props:M}}:U)},[]),A=c.useCallback((L,q,M)=>{R(({[L]:P,...U})=>q?{...U,[L]:{element:q,props:M}}:U)},[]);return u.jsxs(Yn,{resetKeys:[],fallbackRender:L=>u.jsx(p,{...r,...L}),children:[u.jsx(Oe.AtlasAuto,{...r,containerProps:{style:{position:"relative"},...r.containerProps||{}},htmlChildren:u.jsx(u.Fragment,{children:g.map(([L,{element:q,props:M}])=>u.jsx(c.Fragment,{children:u.jsx(q,{...M||{}})},L))}),onCreated:L=>{i(L),r.onCreated&&r.onCreated(L)},runtimeOptions:k,children:u.jsx(Xe.Provider,{value:s,children:u.jsx(zt.Provider,{value:j,children:u.jsx(Wt.Provider,{value:B,children:u.jsx(Yt.Provider,{value:A,children:u.jsx(Dt,{bridge:a,children:u.jsx(Oe.ModeContext.Provider,{value:r.mode||"explore",children:u.jsx($t,{children:e})})})})})})})}),u.jsx("div",{children:E.map(([L,{element:q,props:M}])=>u.jsx(c.Fragment,{children:u.jsx(q,{...M||{}})},L))})]})}const He={},Kt={get(e){return e},setMetaValue([e,t,n],o){const r=Kt.getResourceMeta(e,t),s=r?r[n]:void 0,i=typeof o=="function"?o(s):o;He[e]={...He[e]||{},[t]:{...(He[e]||{})[t]||{},[n]:i}}},getResourceMeta:(e,t)=>{const n=He[e];if(n)return t?n[t]:n}};function Qt(e=Kt){return{addEventListener(t,n,o,r){if(t)return e.setMetaValue([t.id,"eventManager",n],s=>{const i=s||[];for(const a of i)if(a.callback===o)return i;return[...i,{callback:o,scope:r}]}),o},removeEventListener(t,n,o){t&&e.setMetaValue([t.id,"eventManager",n],r=>(r||[]).filter(s=>s.callback!==o))},getListenersAsProps(t,n){const o=typeof t=="string"?{id:t}:t;if(!o||!o.id)return{};const r=e.getResourceMeta(o.id,"eventManager"),s={};if(r&&o)for(const i of Object.keys(r))s[i]=a=>{const p=e.get(o);for(const{callback:y,scope:f}of r[i]||[])(!f||n&&f.indexOf(n)!==-1)&&y(a,p)};return s}}}function ht(e,t){const n=te(),o=c.useMemo(()=>Qt(n),[n]),r=se(()=>e&&e.id?n.getResourceMeta(e.id,"eventManager"):null,[e]);return c.useMemo(()=>e?o.getListenersAsProps(e,t):{},[r,e,n,t])}function Ae(e,t){const n=te(),o=c.useMemo(()=>st.createStylesHelper(n),[n]);return se(()=>{if(!e)return null;const r=o.getAppliedStyles(e.id);return r?t?r[t]:r:void 0},[e,t])}function yt(e={},t=[]){const{id:n,selector:o}=e,r=xe(),s=te(),i=n||r.annotation,a=se(y=>i?y.iiif.entities.Annotation[i]:void 0,[i]),p=se(y=>a&&a.body?a.body.map(f=>f?f.type==="SpecificResource"?{...f,source:s.get(f)}:f?y.iiif.entities[f.type][f.id]:null:null).filter(Boolean):[],[a]);return c.useMemo(()=>{if(!a)return;const y={...a,body:p,target:Le.expandTarget(a.target,{typeMap:s.getState().iiif.mapping})};return o?o(y):y},[a,o,p,...t])}const Gt=({id:e,style:t,className:n,interactive:o})=>{const r=yt({id:e}),s=Ae(r,"atlas"),i=Ae(r,"html"),a=ht(r,["atlas"]),p=ye(),y=c.useMemo(()=>Oe.mergeStyles(t,s),[t,s]);return p&&r&&r.target&&r.target.selector&&r.target.selector.type==="BoxSelector"&&r.target.source&&(r.target.source.id===p.id||r.target.source===p.id)?u.jsx(Oe.RegionHighlight,{id:r.id,isEditing:!0,region:r.target.selector.spatial,style:y,className:(i==null?void 0:i.className)||n,interactive:!!(i!=null&&i.href||o),href:(i==null?void 0:i.href)||null,title:(i==null?void 0:i.title)||null,hrefTarget:(i==null?void 0:i.target)||null,onClick:()=>{},...a}):null};function Xt(e={},t=[]){const{id:n,selector:o}=e,r=xe(),s=n||r.annotationPage,i=se(a=>s?a.iiif.entities.AnnotationPage[s]:void 0,[s]);return c.useMemo(()=>{if(i)return o?o(i):i},[i,...t])}const it=({className:e,page:t})=>{var s;const n=Xt({id:t.id})||t,o=Ae(n,"atlas"),r=Ae(n,"html");return se(i=>n.id?i.iiif.entities.AnnotationPage[n.id]:null,[]),u.jsx(c.Fragment,{children:(s=n.items)==null?void 0:s.map(i=>u.jsx(Gt,{id:i.id,style:o,className:(r==null?void 0:r.className)||e},i.id))})};function Jt({id:e,image:t,thumbnail:n,isStatic:o,x:r=0,y:s=0,children:i,selector:a,onClick:p,enableSizes:y}){var g,O;const f=c.useMemo(()=>{if(!(!a||a.spatial.x===0&&a.spatial.y===0))return a.spatial},[a]);return u.jsx("world-object",{x:r+t.target.spatial.x,y:s+t.target.spatial.y,width:t.target.spatial.width,height:t.target.spatial.height,onClick:p,children:t.service?u.jsxs(c.Fragment,{children:[u.jsx(Oe.TileSet,{tiles:{id:t.service.id||t.service["@id"]||"unknown",height:t.height,width:t.width,imageService:t.service,thumbnail:n&&n.type==="fixed"?n:void 0},enableSizes:y,x:0,y:0,width:(g=t.target)==null?void 0:g.spatial.width,height:(O=t.target)==null?void 0:O.spatial.height,crop:f}),i]},"service"):u.jsxs(c.Fragment,{children:[u.jsx("world-image",{onClick:p,uri:t.id,target:{x:0,y:0,width:t.target.spatial.width,height:t.target.spatial.height},display:t.width&&t.height?{width:t.width,height:t.height}:void 0,crop:f}),i]},"no-service")},e+(t.service?"server":"no-service"))}function xr(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function gt(e,t){const{selector:n,source:o}=Un.expandTarget(t);if(o.id!==e.id)return[null,o];const r={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}};return[n?n.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:n.temporal,spatial:r.spatial}:n:null,o]}const Zt={makeChoice:()=>{}},ze={type:"unknown"},X=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),en=(e,t)=>({type:"empty",width:e,height:t,annotations:{pages:[]},image:null,images:[]});function wr(e,t){var o;const n=(o=e==null?void 0:e.iiif)==null?void 0:o.meta[t];return n?n.annotationPageManager:null}function Sr(e,t){return se(n=>{const o=[];if(!e)return o;const r=Object.keys(n.iiif.entities.AnnotationPage);for(const s of r)if(!t||t.indexOf(s)!==-1){const i=wr(n,s);i&&i.views&&i.views[e]&&o.push(s)}return o},[e,t])}function tn({canvas:e,manifest:t,all:n,canvases:o}){const r=[];if(t)for(const s of t.annotations)r.indexOf(s.id)===-1&&r.push(s.id);if(n){if(o&&o.length)for(const s of o)for(const i of s.annotations)r.indexOf(i.id)===-1&&r.push(i.id)}else if(e)for(const s of e.annotations)r.indexOf(s.id)===-1&&r.push(s.id);return r}function Pr(e,t){var o;const n=(o=e==null?void 0:e.iiif)==null?void 0:o.meta[t];return n?n.annotationPageManager:null}function mt(e,t={}){const n=te(),o=ve(),r=ye(),s=ut(),i=c.useMemo(()=>tn({all:t.all,manifest:o,canvas:r,canvases:s}),[t.all,r,s,o]),a=Sr(e,t.all?void 0:i),p=c.useCallback(f=>{e&&n.setMetaValue([f,"annotationPageManager","views"],g=>g&&!g[e]?g:{...g||{},[e]:!1})},[e,n]),y=c.useCallback((f,g={})=>{if(!e)return;const O=n.getState(),R=[];if(g!=null&&g.deselectOthers){const E=Object.keys(O.iiif.entities.AnnotationPage);for(const x of E){const T=Pr(O,x);T&&T.views&&T.views[e]&&R.push(x)}}for(const E of R)p(E);n.setMetaValue([f,"annotationPageManager","views"],E=>E&&E[e]?E:{...E||{},[e]:!0})},[e,p,n]);return{availablePageIds:i,enabledPageIds:a,setPageEnabled:y,setPageDisabled:p}}function nn(e,t){return se((n,o)=>o.get(e.map(r=>({id:r,type:t}))),[e,t])}const rn=c.createContext(new Ee.ImageServiceLoader);function De(){return c.useContext(rn)}function on(){const e=De(),[t,n]=c.useState({}),o=c.useRef(!1);return c.useEffect(()=>()=>{o.current=!0},[]),[c.useCallback((s,{height:i,width:a})=>{if(s){const p=s.id||s["@id"],y=e.loadServiceSync({id:p,width:s.width||a,height:s.height||i,source:s});y?s=y:t[p]||(o.current||n(f=>({...f,[p]:"loading"})),e.loadService({id:p,width:s.width||a,height:s.height||i}).then(()=>{o.current||n(f=>({...f,[p]:"done"}))}))}return s},[e,t]),t]}function Je(e={}){const t=yt(),n=ye(e.canvasId?{id:e.canvasId}:void 0);return se((o,r)=>{if(!n)return[];if(t&&e.enableSingleAnnotation)return[t];const s=r.get(n.items),i=[];for(const a of s)i.push(...r.get(a.items));return i},[n])}function jr(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}const We={},sn={get(e){return e},setMetaValue([e,t,n],o){const r=sn.getResourceMeta(e,t),s=r?r[n]:void 0,i=typeof o=="function"?o(s):o;We[e]={...We[e]||{},[t]:{...(We[e]||{})[t]||{},[n]:i}}},getResourceMeta:(e,t)=>{const n=We[e];if(n)return t?n[t]:n}};function Or(e=sn){function t(r){const s=r?typeof r=="string"?e.get(r):r:null;if(!s)return[];const i=e.get(s.items,{parent:s}),a=[];for(const p of i)a.push(...e.get(p.items,{parent:p}));return a}function n(r,s=[]){const i=Array.isArray(r)?r:t(r),a=[];let p=null;const y=[];for(const f of i){if(f.type!=="Annotation")throw new Error("getPaintables() accept either a canvas or list of annotations");const g=Array.from(Array.isArray(f.body)?f.body:[f.body]);for(const O of g){const[R,{selector:E}]=jr(O),x=e.get(R),T=(x.type||"unknown").toLowerCase();if(T==="choice"){const I=e.get(x.items,{parent:x.id}),k=s.length?s.map(j=>I.find(B=>B.id===j)).filter(Boolean):[I[0]];k.length===0&&k.push(I[0]),p={type:"single-choice",items:I.map(j=>({id:j.id,label:j.label,selected:k.indexOf(j)!==-1})),label:R.label},g.push(...k);continue}a.indexOf(T)===-1&&a.push(T),y.push({type:T,annotationId:f.id,resource:x,target:f.target,selector:E})}}return{types:a,items:y,choice:p}}function o(r){const{choice:s}=n(r);return s}return{getAllPaintingAnnotations:t,getPaintables:n,extractChoices:o}}function an(e,t=[]){const n=te(),o=c.useMemo(()=>Or(n),[]),r=Je({enableSingleAnnotation:e==null?void 0:e.enableSingleAnnotation}),[s,i]=c.useState((e==null?void 0:e.defaultChoices)||[]),a=c.useMemo(()=>o.getPaintables(r,s),[n,r,s,...t]),y={makeChoice:c.useCallback((f,{deselectOthers:g=!0,deselect:O=!1}={})=>{if(a.choice){if(a.choice.type!=="single-choice")throw new Error("Complex choice not supported yet");i(R=>{if(O){const x=R.filter(T=>T!==f);if(x.length===0){const T=a.items[0].resource.id;return T?[T]:[]}return x}if(g)return[f];const E=[...R];if(E.length===0&&a.items.length){const x=a.items[0].resource.id;x&&E.push(x)}return R.indexOf(f)!==-1?R:[...R,f]})}},[a.choice])};return[a,y]}const Cr=["model/gltf-binary"];function un(e,t){const o=t.items[0].resource;return o.format?Cr.indexOf(o.format)===-1?X(`3D format: ${o.format} is unsupported`):{type:"3d-model",model:o}:X("Unknown format")}function Tr(e,t){var o;if(!e.duration)return X("No duration on canvas");if(t.items.length>1)return X("Only one audio source supported");const n=(o=t.items[0])==null?void 0:o.resource;return n?n.format?{type:"media",media:{annotationId:t.items[0].annotationId,duration:e.duration,url:n.id,type:"Sound",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:n.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:X("Audio does not have format"):X("Unknown audio")}function cn(e,t,n){const o=[];for(const r of t.items){const s=r.resource&&r.resource.type==="SpecificResource"?r.resource.source:r.resource;if(!s.id)return X("No resource Identifier");let i;if(s.service){const R=Ee.getImageServices(s);R[0]&&(i=n(R[0],e))}const a={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[p,y]=gt(e,r.target);if(!(y.id===e.id||decodeURIComponent(y.id||"")===(e.id||"")))continue;r.resource.width&&r.resource.height&&(r.resource.width,r.resource.height);let f=r.resource.type==="SpecificResource"?Le.expandTarget(r.resource):null;if(r.selector){const R=Le.expandTarget({type:"SpecificResource",source:r.resource,selector:r.selector});R&&(f=R)}const g=f&&f.selector&&(f.selector.type==="BoxSelector"||f.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:f.selector.spatial.x,y:f.selector.spatial.y,width:f.selector.spatial.width,height:f.selector.spatial.height}}:void 0;i&&!i.id&&(i.id=i["@id"]);const O={id:s.id,type:"Image",annotationId:r.annotationId,width:Number(p||g?s.width:e.width),height:Number(p||g?s.height:e.height),service:i,sizes:i&&i.sizes?i.sizes:s.width&&s.height?[{width:s.width,height:s.height}]:[],target:p&&p.type!=="PointSelector"?p:a,selector:g};o.push(O)}return{type:"images",image:o[0],images:o,choice:t.choice}}function ln(e,t={},n){const o=e.language||n||"none";switch(e.type){case"TextualBody":{typeof e.value<"u"&&(t[o]=e.value);break}case"List":case"Composite":case"Choice":e.items&&e.items.forEach(r=>ln(r,t,o))}return t}function fn(e,t){const n=[];return t.items.forEach(o=>{if(o.resource){const[r]=gt(e,o.target);n.push({annotationId:o.annotationId,text:ln(o.resource),target:r})}}),{type:"textual-content",items:n}}const Er=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function dn(e,t){var a;const n=t.items.filter(p=>p.type==="video");let o=!1;if(e.duration||(o=!0),n.length>1)return X("Only one video source supported");const r=(a=n[0])==null?void 0:a.resource,s=!!(r.service||[]).find(p=>(p.profile||"").includes("youtube.com"));if(!s&&o)return X("Video does not have duration");if(!r)return X("Unknown video");if((!r.format||r.format==="text/html")&&!s)return X("Video does not have format");const i={annotationId:t.items[0].annotationId,duration:e.duration,url:r.id,type:"Video",items:[],target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:r.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}};if(s){i.type="VideoYouTube";const p=r.id.match(Er);if(!p[1])return X("Video is not known youtube video");i.youTubeId=p[1]}return{type:"media",media:i,annotations:{pages:[]}}}function pn({canvas:e,paintables:t,supports:n,loadImageService:o}){if(!e)return console.log("No canvas"),ze;if(t.types.length===0)return n.indexOf("empty")!==-1?en(e.width,e.height):(console.log("No paintables"),ze);if(t.types.length!==1)if(t.types.length===2&&t.types.indexOf("text")!==-1)t.types=t.types.filter(s=>s!=="text");else return n.indexOf("complex-timeline")===-1?X("Complex timeline not supported"):X("ComplexTimelineStrategy not yet supported");const r=t.types[0];return r==="image"?n.indexOf("images")===-1?X("Image not supported"):cn(e,t,o):r==="Model"||r==="model"?n.indexOf("3d-model")===-1?X("3D not supported"):un(e,t):r==="textualbody"?n.indexOf("textual-content")===-1?X("Textual content not supported"):fn(e,t):r==="sound"||r==="audio"?n.indexOf("media")===-1?X("Media not supported"):Tr(e,t):r==="video"?n.indexOf("media")===-1?X("Media not supported"):dn(e,t):ze}function hn(e){const t=ve(),n=ye(),o=te(),[r,s]=on(),{enabledPageIds:i}=mt((e==null?void 0:e.annotationPageManagerId)||(t==null?void 0:t.id)||(n==null?void 0:n.id),{all:!1}),a=nn(i,"AnnotationPage"),p=(e==null?void 0:e.strategies)||["empty","images","media","textual-content","complex-timeline"],[y,f]=an(e,[s]),g=c.useMemo(()=>pn({canvas:n,paintables:y,supports:p,loadImageService:r}),[n,y,o,f.makeChoice]);return c.useMemo(()=>g.type==="unknown"?[g,Zt]:[{...g,annotations:{pages:a}},f],[g,a])}const yn=(e,t=[])=>{const n=te();c.useEffect(()=>{e(n)},[n,...t])};function vt(e,t,{canvasId:n,manifestId:o}={}){const r=te(),s=De(),i=c.useMemo(()=>$n.createThumbnailHelper(r,{imageServiceLoader:s}),[r,s]),[a,p]=c.useState(),y=ve(o?{id:o}:void 0),f=ye(n?{id:n}:void 0),g=f||y,O=c.useRef(!1);if(c.useEffect(()=>(O.current=!1,()=>{O.current=!0}),[]),!g)throw new Error("Must be called under a manifest or canvas context.");return yn(R=>{i.getBestThumbnailAtSize(g,e,t).then(E=>{E.best&&!O.current&&p(E.best)})},[g]),a}function Ir(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function Mr(e,t){switch(t.type){case"FINISHED":return{...e,isFinished:!0,isPlaying:!1,playRequested:!1};case"PLAY_PAUSE":return{...e,isFinished:!1,isPlaying:!e.isPlaying};case"PLAY_REQUESTED":return{...e,isFinished:!1,playRequested:!0};case"PAUSE":return{...e,isPlaying:!1};case"PLAY":return{...e,isFinished:!1,playRequested:!1,isPlaying:!0};case"MUTE":return{...e,isMuted:!0};case"SET_VOLUME":return{...e,volume:t.volume,isMuted:t.volume===0};case"TOGGLE_MUTE":return{...e,isMuted:!e.isMuted};case"UNMUTE":return{...e,isMuted:!1}}return e}function gn(e){const t=Math.round(e);return`${Math.floor(t/60)}:${`${t%60}`.padStart(2,"0")}`}function Ze(e){const[t,n]=c.useReducer(Mr,Ir(e.duration)),o=c.useRef(null),r=c.useRef(null),s=c.useRef(null),i=c.useRef(!1),a=c.useCallback(()=>{r.current&&o.current&&(r.current.innerHTML=gn(o.current.currentTime),s.current&&(s.current.style.width=`${o.current.currentTime/e.duration*100}%`),i.current!==o.current.muted&&(i.current=o.current.muted,n(o.current.muted?{type:"MUTE"}:{type:"UNMUTE"})))},[e.duration]),p=c.useCallback(()=>{o.current&&(n({type:"PLAY_REQUESTED"}),o.current.play().then(()=>{n({type:"PLAY"})}),a())},[a]),y=c.useCallback(()=>{o.current&&(o.current.duration>0&&o.current.paused?p():f())},[a]),f=c.useCallback(()=>{o.current&&(o.current.pause(),n({type:"PAUSE"}),a())},[a]),g=c.useCallback(()=>{o.current&&(o.current.muted=!o.current.muted,n(o.current.muted?{type:"MUTE"}:{type:"UNMUTE"}))},[]),O=c.useCallback(()=>{o.current&&(o.current.muted=!0,n({type:"MUTE"}))},[]),R=c.useCallback(()=>{o.current&&(o.current.muted=!1,n({type:"UNMUTE"}))},[]),E=c.useCallback(I=>{o.current&&(o.current.muted=!1,o.current.volume=I/100,n({type:"SET_VOLUME",volume:I}))},[]),x=c.useCallback(I=>{o.current&&(o.current.currentTime=Math.max(0,Math.min(I*e.duration,e.duration)),a())},[]),T=c.useCallback(I=>{o.current&&(o.current.currentTime=Math.max(0,Math.min(I,e.duration)),a())},[]);return c.useEffect(()=>{const I=setInterval(()=>{a()},350);return()=>clearInterval(I)},[a,e.duration]),c.useEffect(()=>{const I=()=>{n({type:"FINISHED"})},k=o.current;return k==null||k.addEventListener("ended",I),()=>k==null?void 0:k.removeEventListener("ended",I)},[]),[{element:o,currentTime:r,progress:s},t,{play:p,pause:f,playPause:y,mute:O,unmute:R,toggleMute:g,setVolume:E,setDurationPercent:x,setTime:T}]}const mn=c.createContext(null),vn=c.createContext(null),bn=c.createContext(null);function Rr(){const e=c.useContext(mn);if(!e)throw new Error("Ctx not found");return e}function Lr(){const e=c.useContext(vn);if(!e)throw new Error("Ctx not found");return e}function Ar(){const e=c.useContext(bn);if(!e)throw new Error("Ctx not found");return e}function bt({actions:e,state:t,children:n,currentTime:o,progress:r,element:s}){return u.jsx(bn.Provider,{value:{currentTime:o,progress:r,element:s},children:u.jsx(vn.Provider,{value:e,children:u.jsx(mn.Provider,{value:t,children:n})})})}function xn({media:e,children:t}){const[{element:n,currentTime:o,progress:r},s,i]=Ze({duration:e.duration});return u.jsxs(bt,{state:s,actions:i,currentTime:o,progress:r,element:n,children:[u.jsx("audio",{ref:n,src:e.url}),t]})}function wn({media:e,mediaControlsDeps:t,children:n}){return Ie("portal","audio",xn,{media:e,children:n},[e,...t||[]]),null}function Sn({element:e,media:t,playPause:n}){return u.jsxs("div",{className:"video-container",part:"video-container",onClick:n,children:[u.jsx("style",{children:`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),c=require("react"),Oe=require("@atlas-viewer/atlas"),Ye=require("@iiif/helpers/vault"),st=require("@iiif/helpers/styles"),Le=require("@iiif/helpers/annotation-targets"),Un=require("@iiif/helpers"),Ee=require("@atlas-viewer/iiif-image-api"),$n=require("@iiif/helpers/thumbnail"),Hn=require("react-dom"),Wn=c.createContext(null),rt={didCatch:!1,error:null};class Yn extends c.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=rt}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var n,o,r=arguments.length,s=new Array(r),i=0;i<r;i++)s[i]=arguments[i];(n=(o=this.props).onReset)===null||n===void 0||n.call(o,{args:s,reason:"imperative-api"}),this.setState(rt)}}componentDidCatch(t,n){var o,r;(o=(r=this.props).onError)===null||o===void 0||o.call(r,t,n)}componentDidUpdate(t,n){const{didCatch:o}=this.state,{resetKeys:r}=this.props;if(o&&n.error!==null&&zn(t.resetKeys,r)){var s,i;(s=(i=this.props).onReset)===null||s===void 0||s.call(i,{next:r,prev:t.resetKeys,reason:"keys"}),this.setState(rt)}}render(){const{children:t,fallbackRender:n,FallbackComponent:o,fallback:r}=this.props,{didCatch:s,error:i}=this.state;let a=t;if(s){const p={error:i,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")a=n(p);else if(o)a=c.createElement(o,p);else if(r===null||c.isValidElement(r))a=r;else throw i}return c.createElement(Wn.Provider,{value:{didCatch:s,error:i,resetErrorBoundary:this.resetErrorBoundary}},a)}}function zn(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((n,o)=>!Object.is(n,t[o]))}const Kn={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0,annotationPage:void 0},Ke=c.createContext(Kn),xe=()=>c.useContext(Ke);function we({value:e,children:t}){const n=xe(),o=c.useMemo(()=>({...n,...e}),[e,n]);return u.jsx(Ke.Provider,{value:o,children:t})}const ke=c.createContext({vault:null,setVaultInstance:e=>{}});function Qe({vault:e,vaultOptions:t,useGlobal:n,resources:o,children:r}){const[s,i]=c.useState(()=>e||(n?Ye.globalVault(t):t?new Ye.Vault(t):new Ye.Vault));return u.jsx(ke.Provider,{value:{vault:s,setVaultInstance:i},children:u.jsx(we,{value:o||{},children:r})})}function Ge(e){const t=c.useContext(ke);return e||(t&&t.vault?t.vault:Ye.globalVault())}function at(e,{noCache:t=!1}={}){const n=typeof e=="string"?e:e.id,o=Ge(),[r,s]=c.useState(n),[i,a]=c.useState(void 0),p=c.useMemo(()=>o.get(n,{skipSelfReturn:!0})||void 0,[n,o]),[y,f]=c.useState(p);return c.useEffect(()=>{(async()=>{try{const g=p&&!t?p:await o.load(n),O=g?g.id||g["@id"]:null;g&&r!==O&&s(O),f(g)}catch(g){a(g)}})()},[n,t]),{isLoaded:!!y,id:r,requestId:n,error:i,resource:y,cached:!!(y&&y===p)}}function Mt(e,t){const{id:n,isLoaded:o,error:r,resource:s,requestId:i,cached:a}=at(e,t);return{id:n,isLoaded:o,error:r,manifest:s,requestId:i,cached:a}}function Rt({manifest:e,children:t}){return u.jsx(we,{value:{manifest:e},children:t})}function Ve({canvas:e,children:t}){return u.jsx(we,{value:{canvas:e},children:t})}const te=()=>{const{vault:e}=c.useContext(ke);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};function se(e,t=[]){const n=te(),[o,r]=c.useState(()=>e(n.getState(),n));return c.useEffect(()=>n.subscribe(s=>e(s,n),s=>{r(s)},!1),t),o}const Ne=c.createContext([]);function ut(){const e=c.useContext(Ne);return se(t=>e.map(n=>t.iiif.entities.Canvas[n]).filter(Boolean),[e])}function ve(e={},t=[]){const{id:n,selector:o}=e,r=xe();te();const s=n||r.manifest,i=se(a=>s?a.iiif.entities.Manifest[s]:void 0,[s]);return c.useMemo(()=>{if(i)return o?o(i):i},[i,o,...t])}function Lt({range:e,children:t}){return u.jsx(we,{value:{range:e},children:t})}function At(e,t){for(const n of t.items){if(n.type==="Canvas")return n;if(n.type==="SpecificResource")return n.source;if(n.type==="Range"){const o=At(e,e.get(n));if(o)return o}}return null}function ct(e,t){var o;const n=[];for(const r of t.items)if(r.type==="SpecificResource"&&((o=r.source)==null?void 0:o.type)==="Canvas"&&(r.source.id.indexOf("#")!==-1?n.push({id:r.source.id.split("#")[0],type:"Canvas"}):n.push(r.source)),r.type==="Range"&&n.push(...ct(e,e.get(r))),r.type==="SpecificResource"){const s=typeof r.source=="string"?r.source:r.source.id;n.push({id:s,type:"Canvas"})}return n}function Qn(e,t,n){for(const o of t.structures){const r=lt(e,e.get(o),n);if(r)return r}return null}function lt(e,t,n){var o,r,s;for(const i of t.items){const a=(r=(o=i==null?void 0:i.source)==null?void 0:o.id)==null?void 0:r.split("#")[0];if(i.type==="SpecificResource"&&i.source===n||i.type==="SpecificResource"&&((s=i.source)==null?void 0:s.type)==="Canvas"&&n===a)return t;if(i.type==="Range"){const p=lt(e,e.get(i),n);if(p)return p}}return null}function Gn(e,t,n,o=!1){const r=t.behavior,s=n?e.get(n):null;if(!s)return[];const i=s.behavior,a=o?!1:r.includes("paged"),p=a?!1:r.includes("continuous"),y=a||p?!1:r.includes("individuals"),f=i.includes("facing-pages"),g=i.includes("non-paged");if(f||g||y||o)return[{id:s.id,type:"Canvas"}];const[O,R]=ft(e,t);if(p)return O;const I=O.findIndex(C=>C.id===n);if(I===-1)return[];for(const C of R)if(C.includes(I))return C.map(x=>O[x]);return[{id:s.id,type:"Canvas"}]}function ft(e,t,{disablePaging:n,skipNonPaged:o}={}){const r=t.behavior,s=r.includes("paged"),i=s?!1:r.includes("continuous"),a=s||i?!1:r.includes("individuals"),p=t.type==="Manifest"?t.items:ct(e,t);if(i)return[p,[p.map((I,C)=>C)]];if(a||!s||n)return[p,p.map((I,C)=>[C])];const y=[];let f=[];const g=()=>{f.length&&(y.push([...f]),f=[])};let O=0,R=!1;for(let I=0;I<p.length;I++){const C=e.get(p[I]);if(C.behavior.includes("non-paged")){I===O&&O++,o||(g(),y.push([I]),g());continue}if(I===O||C.behavior.includes("facing-pages")){f.length&&(R=!0),g(),y.push([I]),g();continue}if(f.push(I),R){g(),R=!1;continue}f.length>1&&g()}return f.length&&g(),[p,y]}function dt(e={},t=[]){const{id:n,selector:o}=e,r=xe(),s=n||r.range,i=se(a=>s?a.iiif.entities.Range[s]:void 0,[s]);return c.useMemo(()=>{if(i)return o?o(i):i},[i,o,...t])}function kt({startCanvas:e,disablePaging:t}){var C;const n=te(),o=ve(),r=dt(),[s,i]=c.useState(void 0),a=r||o;if(!a)throw new Error("Nothing selected");const[p,y]=c.useMemo(()=>ft(n,a,{disablePaging:t}),[n,a,t]),f=c.useRef(y);if(f.current!==y){const E=f.current[s][0],A=y.findIndex(S=>S.includes(E));f.current=y,i(A)}const g=c.useCallback(x=>{const E=y.findIndex(A=>A.includes(x));i(E===-1?0:E)},[p,y]),O=c.useCallback(x=>{const E=p.findIndex(A=>A.id===x);E!==-1?g(E):i(0)},[p,y]),R=c.useCallback(()=>{i(x=>x>=y.length-1?x:x+1)},[y]),I=c.useCallback(()=>{i(x=>x<=0?0:x-1)},[y]);return typeof s>"u"&&(e?O(e):i(0)),{visibleItems:((C=y[s])==null?void 0:C.map(x=>p[x].id))||[],cursor:s,items:p,sequence:y,hasPrevious:s>0,hasNext:s<y.length-1,setSequenceIndex:i,setCanvasIndex:g,setCanvasId:O,next:R,previous:I}}const Re=()=>{},_e=c.createContext({setCurrentCanvasId:Re,setCurrentCanvasIndex:Re,nextCanvas:Re,previousCanvas:Re,items:[],sequence:[],setSequenceIndex:Re,currentSequenceIndex:0,hasNext:!1,hasPrevious:!1});function Vt(e){const t=ve(),{cursor:n,visibleItems:o,next:r,sequence:s,items:i,setCanvasIndex:a,setCanvasId:p,previous:y,setSequenceIndex:f,hasNext:g,hasPrevious:O}=kt({startCanvas:e.startCanvas,disablePaging:e.pagingEnabled===!1}),R=c.useMemo(()=>({sequence:s,items:i,setCurrentCanvasId:p,nextCanvas:r,previousCanvas:y,totalCanvases:i.length,setCurrentCanvasIndex:a,setSequenceIndex:f,currentSequenceIndex:n,hasNext:g,hasPrevious:O}),[s,i,p,r,y,i,a,f,n]);return t?o.length===0?null:u.jsx(_e.Provider,{value:R,children:u.jsx(Ne.Provider,{value:o,children:u.jsx(Ve,{canvas:o[0],children:e.children})})}):(console.warn("The manifest passed to the provider is not a valid IIIF manifest."),u.jsx("div",{children:"Sorry, something went wrong."}))}function Nt(e){const t=Ge(e.vault),n=Mt(e.manifest);if(!n)return console.warn("The manifest passed to the provider is not a valid IIIF manifest."),u.jsx("div",{children:"Sorry, something went wrong."});if(n.error)return u.jsx("div",{children:n.error.toString()});if(!n.isLoaded)return u.jsx("div",{children:"Loading..."});const o=u.jsx(Vt,{...e,children:e.children});return u.jsx(Qe,{vault:t,children:u.jsx(Rt,{manifest:n.id,children:e.rangeId?u.jsx(Lt,{range:e.rangeId,children:o}):o})})}function pt(){return c.useContext(_e)}function _t(){return{VaultContext:c.useContext(ke),ResourceContext:c.useContext(Ke),SimpleViewerReactContext:c.useContext(_e),VisibleCanvasReactContext:c.useContext(Ne)}}function Dt(e){return u.jsx(Qe,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:u.jsx(Ne.Provider,{value:e.bridge.VisibleCanvasReactContext,children:u.jsx(_e.Provider,{value:e.bridge.SimpleViewerReactContext,children:e.children})})})}const be=function(e){return function(){const t={type:e,getType:()=>e,toString:()=>e};return(n,o)=>({...t,...n!==void 0&&{payload:n},...o!==void 0&&{meta:o}})}},Xn="@iiif/IMPORT_ENTITIES",Jn="@iiif/MODIFY_ENTITY_FIELD",Zn="@iiif/REORDER_ENTITY_FIELD",er="@iiif/ADD_REFERENCE",tr="@iiif/UPDATE_REFERENCE",nr="@iiif/REMOVE_REFERENCE",rr="@iiif/ADD_METADATA",or="@iiif/REMOVE_METADATA",ir="@iiif/UPDATE_METADATA",sr="@iiif/REORDER_METADATA",ar=be(Xn)(),ur=be(Jn)(),cr=be(Zn)(),lr=be(er)(),fr=be(nr)(),dr=be(tr)(),pr=be(rr)(),hr=be(ir)(),yr=be(or)(),gr=be(sr)(),ot={importEntities:ar,modifyEntityField:ur,reorderEntityField:cr,addReference:lr,removeReference:fr,updateReference:dr,addMetadata:pr,removeMetadata:yr,updateMetadata:hr,reorderMetadata:gr};function qt(){const t=te().getStore();return c.useMemo(()=>n=>t.dispatch(n),[t])}function Et(e){return typeof e!="string"&&e&&e.bindToVault}function Ft(){const e=te(),t=c.useRef([]),n=qt(),o=c.useMemo(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);c.useLayoutEffect(()=>{const a={id:o,type:"AnnotationPage",behavior:[],label:null,thumbnail:[],summary:null,requiredStatement:null,metadata:[],rights:null,provider:[],items:[],seeAlso:[],homepage:[],rendering:[],service:[]};n(ot.importEntities({entities:{AnnotationPage:{[a.id]:a}}}))},[o]);const r=se(a=>o?a.iiif.entities.AnnotationPage[o]:null,[o]),s=c.useCallback((a,p)=>{if(o){if(Et(a)){const g=a;g.__vault||g.bindToVault(e),a=typeof g.source=="string"?g.source:g.source.id,t.current[a]=g}else typeof a!="string"&&(a=a.id);const y=e.get({id:o,type:"AnnotationPage"}),f=e.get({id:a,type:"Annotation"});y&&f&&(y.items.find(g=>g.id===f.id)||n(ot.addReference({id:o,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"},index:p})))}},[o]),i=c.useCallback(a=>{o&&(Et(a)?a=typeof a.source=="string"?a.source:a.source.id:typeof a!="string"&&(a=a.id),t.current[a]&&t.current[a].beforeRemove(),e.get({id:o,type:"AnnotationPage"})&&n(ot.removeReference({id:o,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"}})))},[o]);return[r,{addAnnotation:s,removeAnnotation:i}]}const Bt=c.createContext(null);function Ut(){const e=c.useContext(Bt);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function $t({children:e}){const[t,{addAnnotation:n,removeAnnotation:o}]=Ft();return u.jsx(Bt.Provider,{value:c.useMemo(()=>({fullPage:t,addAnnotation:n,removeAnnotation:o}),[t]),children:e})}function mr({width:e,style:t,height:n,error:o,resetErrorBoundary:r}){return u.jsxs("div",{style:{width:e,height:n,minHeight:500,...t||{},background:"#f9f9f9"},children:[u.jsx("h3",{children:"Error occurred"}),u.jsx("p",{children:o.message}),u.jsx("button",{onClick:r,children:"Reset"})]})}const Xe=c.createContext(null);function Ht(){return c.useContext(Xe)}const Wt=c.createContext(()=>{}),Yt=c.createContext(()=>{});function Ie(e,t,n,o,r=[]){const s=c.useContext(e==="portal"?Yt:Wt);c.useEffect(()=>(e!=="none"&&s(t,n,o),()=>{s(t,null)}),[t,e,s,...r])}function ye(e={},t=[]){const{id:n,selector:o}=e,r=xe(),s=n||r.canvas,i=se(a=>s?a.iiif.entities.Canvas[s]:void 0,[s]);return c.useMemo(()=>{if(i)return o?o(i):i},[i,o,...t])}const zt=c.createContext(()=>{});function vr(e){const t=ye(),n=c.useContext(zt);c.useEffect(()=>t&&t.id?(n(t.id,e),()=>n(t.id,-1)):()=>{},[t,e])}function br({children:e,errorFallback:t,outerContainerProps:n={},worldScale:o,...r}){const[s,i]=c.useState(),a=_t(),p=t||mr,[y,f]=c.useState({}),g=Object.entries(y),[O,R]=c.useState({}),I=Object.entries(O),[C,x]=c.useState({}),E=c.useMemo(()=>o||Math.max(...Object.values(C)),[C]),A=c.useMemo(()=>({maxOverZoom:E||1,...r.runtimeOptions||{}}),[E,r.runtimeOptions]),S=c.useCallback((L,q)=>{x(M=>{if(q===-1){const{[L]:j,...U}=M;return U}return{...M,[L]:q}})},[]),B=c.useCallback((L,q,M)=>{f(({[L]:j,...U})=>q?{...U,[L]:{element:q,props:M}}:U)},[]),k=c.useCallback((L,q,M)=>{R(({[L]:j,...U})=>q?{...U,[L]:{element:q,props:M}}:U)},[]);return u.jsxs(Yn,{resetKeys:[],fallbackRender:L=>u.jsx(p,{...r,...L}),children:[u.jsx(Oe.AtlasAuto,{...r,containerProps:{style:{position:"relative"},...r.containerProps||{}},htmlChildren:u.jsx(u.Fragment,{children:g.map(([L,{element:q,props:M}])=>u.jsx(c.Fragment,{children:u.jsx(q,{...M||{}})},L))}),onCreated:L=>{i(L),r.onCreated&&r.onCreated(L)},runtimeOptions:A,children:u.jsx(Xe.Provider,{value:s,children:u.jsx(zt.Provider,{value:S,children:u.jsx(Wt.Provider,{value:B,children:u.jsx(Yt.Provider,{value:k,children:u.jsx(Dt,{bridge:a,children:u.jsx(Oe.ModeContext.Provider,{value:r.mode||"explore",children:u.jsx($t,{children:e})})})})})})})}),u.jsx("div",{children:I.map(([L,{element:q,props:M}])=>u.jsx(c.Fragment,{children:u.jsx(q,{...M||{}})},L))})]})}const He={},Kt={get(e){return e},setMetaValue([e,t,n],o){const r=Kt.getResourceMeta(e,t),s=r?r[n]:void 0,i=typeof o=="function"?o(s):o;He[e]={...He[e]||{},[t]:{...(He[e]||{})[t]||{},[n]:i}}},getResourceMeta:(e,t)=>{const n=He[e];if(n)return t?n[t]:n}};function Qt(e=Kt){return{addEventListener(t,n,o,r){if(t)return e.setMetaValue([t.id,"eventManager",n],s=>{const i=s||[];for(const a of i)if(a.callback===o)return i;return[...i,{callback:o,scope:r}]}),o},removeEventListener(t,n,o){t&&e.setMetaValue([t.id,"eventManager",n],r=>(r||[]).filter(s=>s.callback!==o))},getListenersAsProps(t,n){const o=typeof t=="string"?{id:t}:t;if(!o||!o.id)return{};const r=e.getResourceMeta(o.id,"eventManager"),s={};if(r&&o)for(const i of Object.keys(r))s[i]=a=>{const p=e.get(o);for(const{callback:y,scope:f}of r[i]||[])(!f||n&&f.indexOf(n)!==-1)&&y(a,p)};return s}}}function ht(e,t){const n=te(),o=c.useMemo(()=>Qt(n),[n]),r=se(()=>e&&e.id?n.getResourceMeta(e.id,"eventManager"):null,[e]);return c.useMemo(()=>e?o.getListenersAsProps(e,t):{},[r,e,n,t])}function Ae(e,t){const n=te(),o=c.useMemo(()=>st.createStylesHelper(n),[n]);return se(()=>{if(!e)return null;const r=o.getAppliedStyles(e.id);return r?t?r[t]:r:void 0},[e,t])}function yt(e={},t=[]){const{id:n,selector:o}=e,r=xe(),s=te(),i=n||r.annotation,a=se(y=>i?y.iiif.entities.Annotation[i]:void 0,[i]),p=se(y=>a&&a.body?a.body.map(f=>f?f.type==="SpecificResource"?{...f,source:s.get(f)}:f?y.iiif.entities[f.type][f.id]:null:null).filter(Boolean):[],[a]);return c.useMemo(()=>{if(!a)return;const y={...a,body:p,target:Le.expandTarget(a.target,{typeMap:s.getState().iiif.mapping})};return o?o(y):y},[a,o,p,...t])}const Gt=({id:e,style:t,className:n,interactive:o})=>{const r=yt({id:e}),s=Ae(r,"atlas"),i=Ae(r,"html"),a=ht(r,["atlas"]),p=ye(),y=c.useMemo(()=>Oe.mergeStyles(t,s),[t,s]);return p&&r&&r.target&&r.target.selector&&r.target.selector.type==="BoxSelector"&&r.target.source&&(r.target.source.id===p.id||r.target.source===p.id)?u.jsx(Oe.RegionHighlight,{id:r.id,isEditing:!0,region:r.target.selector.spatial,style:y,className:(i==null?void 0:i.className)||n,interactive:!!(i!=null&&i.href||o),href:(i==null?void 0:i.href)||null,title:(i==null?void 0:i.title)||null,hrefTarget:(i==null?void 0:i.target)||null,onClick:()=>{},...a}):null};function Xt(e={},t=[]){const{id:n,selector:o}=e,r=xe(),s=n||r.annotationPage,i=se(a=>s?a.iiif.entities.AnnotationPage[s]:void 0,[s]);return c.useMemo(()=>{if(i)return o?o(i):i},[i,...t])}const it=({className:e,page:t})=>{var s;const n=Xt({id:t.id})||t,o=Ae(n,"atlas"),r=Ae(n,"html");return se(i=>n.id?i.iiif.entities.AnnotationPage[n.id]:null,[]),u.jsx(c.Fragment,{children:(s=n.items)==null?void 0:s.map(i=>u.jsx(Gt,{id:i.id,style:o,className:(r==null?void 0:r.className)||e},i.id))})};function Jt({id:e,image:t,thumbnail:n,isStatic:o,x:r=0,y:s=0,children:i,selector:a,onClick:p,enableSizes:y}){var g,O;const f=c.useMemo(()=>{if(!(!a||a.spatial.x===0&&a.spatial.y===0))return a.spatial},[a]);return u.jsx("world-object",{x:r+t.target.spatial.x,y:s+t.target.spatial.y,width:t.target.spatial.width,height:t.target.spatial.height,onClick:p,children:t.service?u.jsxs(c.Fragment,{children:[u.jsx(Oe.TileSet,{tiles:{id:t.service.id||t.service["@id"]||"unknown",height:t.height,width:t.width,imageService:t.service,thumbnail:n&&n.type==="fixed"?n:void 0},enableSizes:y,x:0,y:0,width:(g=t.target)==null?void 0:g.spatial.width,height:(O=t.target)==null?void 0:O.spatial.height,crop:f}),i]},"service"):u.jsxs(c.Fragment,{children:[u.jsx("world-image",{onClick:p,uri:t.id,target:{x:0,y:0,width:t.target.spatial.width,height:t.target.spatial.height},display:t.width&&t.height?{width:t.width,height:t.height}:void 0,crop:f}),i]},"no-service")},e+(t.service?"server":"no-service"))}function xr(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function gt(e,t){const{selector:n,source:o}=Un.expandTarget(t);if(o.id!==e.id)return[null,o];const r={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}};return[n?n.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:n.temporal,spatial:r.spatial}:n:null,o]}const Zt={makeChoice:()=>{}},ze={type:"unknown"},X=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),en=(e,t)=>({type:"empty",width:e,height:t,annotations:{pages:[]},image:null,images:[]});function wr(e,t){var o;const n=(o=e==null?void 0:e.iiif)==null?void 0:o.meta[t];return n?n.annotationPageManager:null}function Sr(e,t){return se(n=>{const o=[];if(!e)return o;const r=Object.keys(n.iiif.entities.AnnotationPage);for(const s of r)if(!t||t.indexOf(s)!==-1){const i=wr(n,s);i&&i.views&&i.views[e]&&o.push(s)}return o},[e,t])}function tn({canvas:e,manifest:t,all:n,canvases:o}){const r=[];if(t)for(const s of t.annotations)r.indexOf(s.id)===-1&&r.push(s.id);if(n){if(o&&o.length)for(const s of o)for(const i of s.annotations)r.indexOf(i.id)===-1&&r.push(i.id)}else if(e)for(const s of e.annotations)r.indexOf(s.id)===-1&&r.push(s.id);return r}function Pr(e,t){var o;const n=(o=e==null?void 0:e.iiif)==null?void 0:o.meta[t];return n?n.annotationPageManager:null}function mt(e,t={}){const n=te(),o=ve(),r=ye(),s=ut(),i=c.useMemo(()=>tn({all:t.all,manifest:o,canvas:r,canvases:s}),[t.all,r,s,o]),a=Sr(e,t.all?void 0:i),p=c.useCallback(f=>{e&&n.setMetaValue([f,"annotationPageManager","views"],g=>g&&!g[e]?g:{...g||{},[e]:!1})},[e,n]),y=c.useCallback((f,g={})=>{if(!e)return;const O=n.getState(),R=[];if(g!=null&&g.deselectOthers){const I=Object.keys(O.iiif.entities.AnnotationPage);for(const C of I){const x=Pr(O,C);x&&x.views&&x.views[e]&&R.push(C)}}for(const I of R)p(I);n.setMetaValue([f,"annotationPageManager","views"],I=>I&&I[e]?I:{...I||{},[e]:!0})},[e,p,n]);return{availablePageIds:i,enabledPageIds:a,setPageEnabled:y,setPageDisabled:p}}function nn(e,t){return se((n,o)=>o.get(e.map(r=>({id:r,type:t}))),[e,t])}const rn=c.createContext(new Ee.ImageServiceLoader);function De(){return c.useContext(rn)}function on(){const e=De(),[t,n]=c.useState({}),o=c.useRef(!1);return c.useEffect(()=>()=>{o.current=!0},[]),[c.useCallback((s,{height:i,width:a})=>{if(s){const p=s.id||s["@id"],y=e.loadServiceSync({id:p,width:s.width||a,height:s.height||i,source:s});y?s=y:t[p]||(o.current||n(f=>({...f,[p]:"loading"})),e.loadService({id:p,width:s.width||a,height:s.height||i}).then(()=>{o.current||n(f=>({...f,[p]:"done"}))}))}return s},[e,t]),t]}function Je(e={}){const t=yt(),n=ye(e.canvasId?{id:e.canvasId}:void 0);return se((o,r)=>{if(!n)return[];if(t&&e.enableSingleAnnotation)return[t];const s=r.get(n.items),i=[];for(const a of s)i.push(...r.get(a.items));return i},[n])}function jr(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}const We={},sn={get(e){return e},setMetaValue([e,t,n],o){const r=sn.getResourceMeta(e,t),s=r?r[n]:void 0,i=typeof o=="function"?o(s):o;We[e]={...We[e]||{},[t]:{...(We[e]||{})[t]||{},[n]:i}}},getResourceMeta:(e,t)=>{const n=We[e];if(n)return t?n[t]:n}};function Or(e=sn){function t(r){const s=r?typeof r=="string"?e.get(r):r:null;if(!s)return[];const i=e.get(s.items,{parent:s}),a=[];for(const p of i)a.push(...e.get(p.items,{parent:p}));return a}function n(r,s=[]){const i=Array.isArray(r)?r:t(r),a=[];let p=null;const y=[];for(const f of i){if(f.type!=="Annotation")throw new Error("getPaintables() accept either a canvas or list of annotations");const g=Array.from(Array.isArray(f.body)?f.body:[f.body]);for(const O of g){const[R,{selector:I}]=jr(O),C=e.get(R),x=(C.type||"unknown").toLowerCase();if(x==="choice"){const E=e.get(C.items,{parent:C.id}),A=s.length?s.map(S=>E.find(B=>B.id===S)).filter(Boolean):[E[0]];A.length===0&&A.push(E[0]),p={type:"single-choice",items:E.map(S=>({id:S.id,label:S.label,selected:A.indexOf(S)!==-1})),label:R.label},g.push(...A);continue}a.indexOf(x)===-1&&a.push(x),y.push({type:x,annotationId:f.id,resource:C,target:f.target,selector:I})}}return{types:a,items:y,choice:p}}function o(r){const{choice:s}=n(r);return s}return{getAllPaintingAnnotations:t,getPaintables:n,extractChoices:o}}function an(e,t=[]){const n=te(),o=c.useMemo(()=>Or(n),[]),r=Je({enableSingleAnnotation:e==null?void 0:e.enableSingleAnnotation}),[s,i]=c.useState((e==null?void 0:e.defaultChoices)||[]),a=c.useMemo(()=>o.getPaintables(r,s),[n,r,s,...t]),y={makeChoice:c.useCallback((f,{deselectOthers:g=!0,deselect:O=!1}={})=>{if(a.choice){if(a.choice.type!=="single-choice")throw new Error("Complex choice not supported yet");i(R=>{if(O){const C=R.filter(x=>x!==f);if(C.length===0){const x=a.items[0].resource.id;return x?[x]:[]}return C}if(g)return[f];const I=[...R];if(I.length===0&&a.items.length){const C=a.items[0].resource.id;C&&I.push(C)}return R.indexOf(f)!==-1?R:[...R,f]})}},[a.choice])};return[a,y]}const Cr=["model/gltf-binary"];function un(e,t){const o=t.items[0].resource;return o.format?Cr.indexOf(o.format)===-1?X(`3D format: ${o.format} is unsupported`):{type:"3d-model",model:o}:X("Unknown format")}function Tr(e,t){var o;if(!e.duration)return X("No duration on canvas");if(t.items.length>1)return X("Only one audio source supported");const n=(o=t.items[0])==null?void 0:o.resource;return n?n.format?{type:"media",media:{annotationId:t.items[0].annotationId,duration:e.duration,url:n.id,type:"Sound",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:n.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:X("Audio does not have format"):X("Unknown audio")}function cn(e,t,n){const o=[];for(const r of t.items){const s=r.resource&&r.resource.type==="SpecificResource"?r.resource.source:r.resource;if(!s.id)return X("No resource Identifier");let i;if(s.service){const R=Ee.getImageServices(s);R[0]&&(i=n(R[0],e))}const a={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[p,y]=gt(e,r.target);if(!(y.id===e.id||decodeURIComponent(y.id||"")===(e.id||"")))continue;r.resource.width&&r.resource.height&&(r.resource.width,r.resource.height);let f=r.resource.type==="SpecificResource"?Le.expandTarget(r.resource):null;if(r.selector){const R=Le.expandTarget({type:"SpecificResource",source:r.resource,selector:r.selector});R&&(f=R)}const g=f&&f.selector&&(f.selector.type==="BoxSelector"||f.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:f.selector.spatial.x,y:f.selector.spatial.y,width:f.selector.spatial.width,height:f.selector.spatial.height}}:void 0;i&&!i.id&&(i.id=i["@id"]);const O={id:s.id,type:"Image",annotationId:r.annotationId,width:Number(p||g?s.width:e.width),height:Number(p||g?s.height:e.height),service:i,sizes:i&&i.sizes?i.sizes:s.width&&s.height?[{width:s.width,height:s.height}]:[],target:p&&p.type!=="PointSelector"?p:a,selector:g};o.push(O)}return{type:"images",image:o[0],images:o,choice:t.choice}}function ln(e,t={},n){const o=e.language||n||"none";switch(e.type){case"TextualBody":{typeof e.value<"u"&&(t[o]=e.value);break}case"List":case"Composite":case"Choice":e.items&&e.items.forEach(r=>ln(r,t,o))}return t}function fn(e,t){const n=[];return t.items.forEach(o=>{if(o.resource){const[r]=gt(e,o.target);n.push({annotationId:o.annotationId,text:ln(o.resource),target:r})}}),{type:"textual-content",items:n}}const Er=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function dn(e,t){var a;const n=t.items.filter(p=>p.type==="video");let o=!1;if(e.duration||(o=!0),n.length>1)return X("Only one video source supported");const r=(a=n[0])==null?void 0:a.resource,s=!!(r.service||[]).find(p=>(p.profile||"").includes("youtube.com"));if(!s&&o)return X("Video does not have duration");if(!r)return X("Unknown video");if((!r.format||r.format==="text/html")&&!s)return X("Video does not have format");const i={annotationId:t.items[0].annotationId,duration:e.duration,url:r.id,type:"Video",items:[],target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:r.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}};if(s){i.type="VideoYouTube";const p=r.id.match(Er);if(!p[1])return X("Video is not known youtube video");i.youTubeId=p[1]}return{type:"media",media:i,annotations:{pages:[]}}}function pn({canvas:e,paintables:t,supports:n,loadImageService:o}){if(!e)return console.log("No canvas"),ze;if(t.types.length===0)return n.indexOf("empty")!==-1?en(e.width,e.height):(console.log("No paintables"),ze);if(t.types.length!==1)if(t.types.length===2&&t.types.indexOf("text")!==-1)t.types=t.types.filter(s=>s!=="text");else return n.indexOf("complex-timeline")===-1?X("Complex timeline not supported"):X("ComplexTimelineStrategy not yet supported");const r=t.types[0];return r==="image"?n.indexOf("images")===-1?X("Image not supported"):cn(e,t,o):r==="Model"||r==="model"?n.indexOf("3d-model")===-1?X("3D not supported"):un(e,t):r==="textualbody"?n.indexOf("textual-content")===-1?X("Textual content not supported"):fn(e,t):r==="sound"||r==="audio"?n.indexOf("media")===-1?X("Media not supported"):Tr(e,t):r==="video"?n.indexOf("media")===-1?X("Media not supported"):dn(e,t):ze}function hn(e){const t=ve(),n=ye(),o=te(),[r,s]=on(),{enabledPageIds:i}=mt((e==null?void 0:e.annotationPageManagerId)||(t==null?void 0:t.id)||(n==null?void 0:n.id),{all:!1}),a=nn(i,"AnnotationPage"),p=(e==null?void 0:e.strategies)||["empty","images","media","textual-content","complex-timeline"],[y,f]=an(e,[s]),g=c.useMemo(()=>pn({canvas:n,paintables:y,supports:p,loadImageService:r}),[n,y,o,f.makeChoice]);return c.useMemo(()=>g.type==="unknown"?[g,Zt]:[{...g,annotations:{pages:a}},f],[g,a])}const yn=(e,t=[])=>{const n=te();c.useEffect(()=>{e(n)},[n,...t])};function vt(e,t,{canvasId:n,manifestId:o}={}){const r=te(),s=De(),i=c.useMemo(()=>$n.createThumbnailHelper(r,{imageServiceLoader:s}),[r,s]),[a,p]=c.useState(),y=ve(o?{id:o}:void 0),f=ye(n?{id:n}:void 0),g=f||y,O=c.useRef(!1);if(c.useEffect(()=>(O.current=!1,()=>{O.current=!0}),[]),!g)throw new Error("Must be called under a manifest or canvas context.");return yn(R=>{i.getBestThumbnailAtSize(g,e,t).then(I=>{I.best&&!O.current&&p(I.best)})},[g]),a}function Ir(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function Mr(e,t){switch(t.type){case"FINISHED":return{...e,isFinished:!0,isPlaying:!1,playRequested:!1};case"PLAY_PAUSE":return{...e,isFinished:!1,isPlaying:!e.isPlaying};case"PLAY_REQUESTED":return{...e,isFinished:!1,playRequested:!0};case"PAUSE":return{...e,isPlaying:!1};case"PLAY":return{...e,isFinished:!1,playRequested:!1,isPlaying:!0};case"MUTE":return{...e,isMuted:!0};case"SET_VOLUME":return{...e,volume:t.volume,isMuted:t.volume===0};case"TOGGLE_MUTE":return{...e,isMuted:!e.isMuted};case"UNMUTE":return{...e,isMuted:!1}}return e}function gn(e){const t=Math.round(e);return`${Math.floor(t/60)}:${`${t%60}`.padStart(2,"0")}`}function Ze(e){const[t,n]=c.useReducer(Mr,Ir(e.duration)),o=c.useRef(null),r=c.useRef(null),s=c.useRef(null),i=c.useRef(!1),a=c.useCallback(()=>{r.current&&o.current&&(r.current.innerHTML=gn(o.current.currentTime),s.current&&(s.current.style.width=`${o.current.currentTime/e.duration*100}%`),i.current!==o.current.muted&&(i.current=o.current.muted,n(o.current.muted?{type:"MUTE"}:{type:"UNMUTE"})))},[e.duration]),p=c.useCallback(()=>{o.current&&(n({type:"PLAY_REQUESTED"}),o.current.play().then(()=>{n({type:"PLAY"})}),a())},[a]),y=c.useCallback(()=>{o.current&&(o.current.duration>0&&o.current.paused?p():f())},[a]),f=c.useCallback(()=>{o.current&&(o.current.pause(),n({type:"PAUSE"}),a())},[a]),g=c.useCallback(()=>{o.current&&(o.current.muted=!o.current.muted,n(o.current.muted?{type:"MUTE"}:{type:"UNMUTE"}))},[]),O=c.useCallback(()=>{o.current&&(o.current.muted=!0,n({type:"MUTE"}))},[]),R=c.useCallback(()=>{o.current&&(o.current.muted=!1,n({type:"UNMUTE"}))},[]),I=c.useCallback(E=>{o.current&&(o.current.muted=!1,o.current.volume=E/100,n({type:"SET_VOLUME",volume:E}))},[]),C=c.useCallback(E=>{o.current&&(o.current.currentTime=Math.max(0,Math.min(E*e.duration,e.duration)),a())},[]),x=c.useCallback(E=>{o.current&&(o.current.currentTime=Math.max(0,Math.min(E,e.duration)),a())},[]);return c.useEffect(()=>{const E=setInterval(()=>{a()},350);return()=>clearInterval(E)},[a,e.duration]),c.useEffect(()=>{const E=()=>{n({type:"FINISHED"})},A=o.current;return A==null||A.addEventListener("ended",E),()=>A==null?void 0:A.removeEventListener("ended",E)},[]),[{element:o,currentTime:r,progress:s},t,{play:p,pause:f,playPause:y,mute:O,unmute:R,toggleMute:g,setVolume:I,setDurationPercent:C,setTime:x}]}const mn=c.createContext(null),vn=c.createContext(null),bn=c.createContext(null);function Rr(){const e=c.useContext(mn);if(!e)throw new Error("Ctx not found");return e}function Lr(){const e=c.useContext(vn);if(!e)throw new Error("Ctx not found");return e}function Ar(){const e=c.useContext(bn);if(!e)throw new Error("Ctx not found");return e}function bt({actions:e,state:t,children:n,currentTime:o,progress:r,element:s}){return u.jsx(bn.Provider,{value:{currentTime:o,progress:r,element:s},children:u.jsx(vn.Provider,{value:e,children:u.jsx(mn.Provider,{value:t,children:n})})})}function xn({media:e,children:t}){const[{element:n,currentTime:o,progress:r},s,i]=Ze({duration:e.duration});return u.jsxs(bt,{state:s,actions:i,currentTime:o,progress:r,element:n,children:[u.jsx("audio",{ref:n,src:e.url}),t]})}function wn({media:e,mediaControlsDeps:t,children:n}){return Ie("portal","audio",xn,{media:e,children:n},[e,...t||[]]),null}function Sn({element:e,media:t,playPause:n}){return u.jsxs("div",{className:"video-container",part:"video-container",onClick:n,children:[u.jsx("style",{children:`
|
|
2
2
|
.video-container {
|
|
3
3
|
position: absolute;
|
|
4
4
|
top: 0;
|
|
@@ -44,6 +44,6 @@
|
|
|
44
44
|
width: 100%;
|
|
45
45
|
object-fit: contain;
|
|
46
46
|
}
|
|
47
|
-
`}),u.jsx("iframe",{className:"video-yt",ref:o,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 _r({media:e,mediaControlsDeps:t,children:n}){const[{element:o,currentTime:r,progress:s},i,a]=Ze({duration:e.duration});return Ie("overlay","video-element",Nr,{element:o,media:e,playPause:a.playPause}),null}function Ln({x:e,y:t,onChoiceChange:n,registerActions:o,defaultChoices:r,isStatic:s,renderViewerControls:i,renderMediaControls:a,viewControlsDeps:p,mediaControlsDeps:y,strategies:f,throwOnUnknown:g,backgroundStyle:O,alwaysShowBackground:R,keepCanvasScale:E=!1,enableSizes:x=!1,enableYouTube:T=!0,onClickPaintingAnnotation:I,children:k}){const j=ye(),B=ht(j,["deep-zoom"]),[A]=Ut(),L=Ht(),q=te(),M=c.useMemo(()=>st.createStylesHelper(q),[q]),[P,U]=hn({strategies:f||["images"],defaultChoices:r==null?void 0:r.map(({id:N})=>N)}),W=P.type==="images"?P.choice:void 0,Q=c.useMemo(()=>E?1:Math.max(1,...P.type==="images"?P.images.map(N=>{var ee;return(N.width||0)/((ee=N.target)==null?void 0:ee.spatial.width)}):[]),[E,P]);vr(Q),c.useEffect(()=>{o&&o(U)},[P.annotations]),c.useEffect(()=>{if(r)for(const N of r)typeof N.opacity<"u"&&M.applyStyles({id:N.id},"atlas",{opacity:N.opacity})},[r]),c.useLayoutEffect(()=>{n&&n(W)},[W]),Ie(L&&(P.type==="images"||P.type==="empty"||P.type==="textual-content"&&i)?"overlay":"none",`canvas-portal-controls-${j==null?void 0:j.id}`,Xe.Provider,i?{value:L||null,children:i(P)}:{},[j,L,P,...p||[]]);const Y=vt({maxWidth:256,maxHeight:256});if(!j)return null;const J=j.accompanyingCanvas,Z=Y&&Y.type==="fixed"?u.jsx("world-object",{height:j.height,width:j.width,x:e,y:t,children:u.jsx("world-image",{uri:Y.id,target:{x:0,y:0,width:j.width,height:j.height},display:Y.width&&Y.height?{width:Y.width,height:Y.height}:void 0,crop:void 0})}):null;if(P.type==="unknown"){if(Z)return Z;if(g)throw new Error(P.reason||"Unknown image strategy");return null}const oe=u.jsxs(c.Fragment,{children:[A?u.jsx(it,{page:A}):null,P.annotations&&P.annotations.pages?P.annotations.pages.map(N=>u.jsx(it,{page:N},N.id)):null,k]}),pe=P.type==="images"?P.images.length:0;return u.jsxs(u.Fragment,{children:[u.jsxs("world-object",{height:j.height,width:j.width,x:e,y:t,...B,children:[P.type==="empty"||R?u.jsx(Cn,{style:O}):null,P.type==="textual-content"?P.items.map((N,ee)=>{var $;return u.jsxs(u.Fragment,{children:[u.jsx(Oe.HTMLPortal,{onClick:I?ae=>{ae.stopPropagation(),I(N.annotationId,N,ae)}:void 0,target:(($=N.target)==null?void 0:$.spatial)||void 0,children:u.jsx("div",{"data-textual-content":!0,children:u.jsx(je,{enableDangerouslySetInnerHTML:!0,children:N.text})})},ee),oe]})}):null,P.type==="images"?u.jsxs(u.Fragment,{children:[P.images.map((N,ee)=>u.jsx(Jt,{isStatic:s,image:N,id:N.id,thumbnail:ee===0?Y:void 0,selector:N.selector,enableSizes:x,onClick:I?$=>{$.stopPropagation(),I(N.annotationId,N,$)}:void 0},N.id+ee)),oe]}):null,P.type==="3d-model"?u.jsx(On,{model:P.model}):null,P.type==="media"?u.jsx(u.Fragment,{children:P.media.type==="Sound"?u.jsxs(wn,{media:P.media,mediaControlsDeps:y,children:[Z,a?a(P):null]}):P.media.type==="Video"?u.jsxs(Pn,{media:P.media,mediaControlsDeps:y,children:[Z,a?a(P):null]}):P.media.type==="VideoYouTube"&&T?u.jsxs(_r,{media:P.media,mediaControlsDeps:y,children:[Z,a?a(P):null]}):null}):null]},`${j.id}/${P.type}/${pe}`),P.type==="media"&&P.media.type==="Sound"&&J?u.jsx(Ve,{canvas:J.id,children:u.jsx(Ln,{renderViewerControls:i})}):null]})}const Dr=c.forwardRef(function(t,n){const o=ve(),r=ut(),s=pt(),{ViewerControls:i,MediaControls:a}=t.components||{};if(c.useImperativeHandle(n,()=>s,[s]),!o)return u.jsx("div",{});let p=0;return u.jsxs(u.Fragment,{children:[t.header,u.jsx(de.Viewer,{height:t.height,mode:t.mode,children:r.map((y,f)=>{const g=p;return p+=y.width+(t.spacing||0),u.jsx(Ve,{canvas:y.id,children:u.jsx(de.RenderCanvas,{strategies:["3d-model","media","images","empty","textual-content"],renderViewerControls:f===0&&i?()=>u.jsx(i,{}):void 0,renderMediaControls:f===0&&a?()=>u.jsx(a,{}):void 0,x:g,...t.canvasProps||{},children:t.annotations},y.id)},y.id)})},t.reuseAtlas?"":s.currentSequenceIndex),t.children]})}),de=c.forwardRef(function({children:t,height:n,annotations:o,canvasProps:r,spacing:s,header:i,components:a,mode:p,reuseAtlas:y,...f},g){const O=Ge();return u.jsx(Qe,{vault:O,children:u.jsx(Nt,{...f,children:u.jsx(Dr,{ref:g,height:n,components:a,spacing:s,canvasProps:r,annotations:o,header:i,mode:p,reuseAtlas:y,children:t})})})});de.RenderImage=Jt;de.RenderCanvas=Ln;de.RenderAnnotationPage=it;de.RenderAnnotation=Gt;de.Viewer=br;de.CanvasBackground=Cn;de.Audio=wn;de.Video=Pn;de.Model=On;de.AudioHTML=xn;de.VideoHTML=Sn;de.ModelHTML=jn;const qr=c.forwardRef(function({canvasId:t},n){const o=Oe.useCanvas(),r=mt(t||(o==null?void 0:o.id)),s=te();return c.useImperativeHandle(n,()=>r,[t,o]),!o||r.enabledPageIds.length===0?null:u.jsx(u.Fragment,{children:r.enabledPageIds.map(i=>u.jsx(de.RenderAnnotationPage,{page:s.get(i)},i))})});function xt({metadata:e=[],config:t,labelWidth:n=16,showEmptyMessage:o=!0,allowHtml:r,emptyFallback:s,classes:i={},emptyMessage:a="No metadata available",emptyValueFallback:p="No value",emptyLabelFallback:y="",separator:f,tableFooter:g,tableHeader:O}){const R=c.useMemo(()=>{const x=(t||[]).reduce((I,k)=>[...I,...k.keys],[]),T={};for(const I of e){const k=I&&I.label?Object.values(I.label):[];for(const j of k)if(j&&j.length&&(x.indexOf(`metadata.${j[0]}`)!==-1||x.length===0)&&I){const B=`metadata.${j[0]}`;T[B]=T[B]?T[B]:[],T[B].push(I);break}}return T},[t,e]);return Object.keys(R).length===0&&o?u.jsx(u.Fragment,{children:s})||u.jsx("div",{className:i.empty,children:a}):t&&t.length?u.jsxs("table",{className:i.container,children:[O,u.jsx("tbody",{children:t.map((x,T)=>{const I=[];for(const k of x.keys)for(const j of R[k]||[])I.push(u.jsx(je,{enableDangerouslySetInnerHTML:r,defaultText:p,separator:f,children:j.value},T+"__"+k));return I.length===0?null:u.jsxs("tr",{className:i.row,children:[u.jsx("td",{className:i.label,style:n?{minWidth:n}:{},children:u.jsx(je,{enableDangerouslySetInnerHTML:r,separator:f,defaultText:y,children:x.label})}),u.jsx("td",{className:i.value,children:I})]},T)})}),g]}):u.jsxs("table",{className:i.container,children:[O,u.jsx("tbody",{children:e&&e.length?e.map((x,T)=>x?u.jsxs("tr",{className:i.row,children:[u.jsx("td",{className:i.label,style:n?{minWidth:n}:{},children:u.jsx(je,{enableDangerouslySetInnerHTML:r,defaultText:p,separator:f,children:x.label})}),u.jsx("td",{className:i.value,children:u.jsx(je,{enableDangerouslySetInnerHTML:r,defaultText:p,separator:f,children:x.value})})]},T):null):null}),g]})}function Fr(e){const t=ve(),n=ye(),o=dt(),r=c.useMemo(()=>{const s=(t==null?void 0:t.metadata)||[],i=(n==null?void 0:n.metadata)||[],a=(o==null?void 0:o.metadata)||[];return[...s,...i,...a]},[t,n,o]);return u.jsx(xt,{metadata:r,...e})}function wt(e,t={},n=[]){return c.useMemo(()=>{var i,a;if(!e)return null;let o=t.quality;e&&e.extraQualities&&t.quality&&(e.extraQualities.includes(t.quality)||(console.log("Invalid quality",t.quality,e.extraQualities),o="default"));const r=Ee.createImageServiceRequest(e);return Ee.imageServiceRequestToString({identifier:r.identifier,server:r.server,scheme:r.scheme,type:"image",size:{max:!((i=t.size)!=null&&i.width)&&!((a=t.size)!=null&&a.height),confined:!1,upscaled:!1,...t.size||{}},format:t.format||"jpg",region:t.region||{full:!0},rotation:t!=null&&t.rotation?Number.isInteger(t.rotation)?{angle:t.rotation}:t.rotation:{angle:0},quality:o||"default",prefix:r.prefix,originalPath:r.originalPath})},[...n])}function Br(e){const t=typeof e.src=="string"?e.src:e.src.id,n=De(),[o,r]=c.useState(!1);let s;if(t){const a=n.loadServiceSync({id:t});a&&(s=a)}!s&&!o&&n.loadService({id:t}).then(()=>{r(!0)});const i=wt(s,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[o,e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return c.useEffect(()=>()=>{r(!1)},[t]),i?u.jsx("img",{src:i,alt:e.alt,className:e.className,style:e.style}):u.jsx(An,{...e,fetchImageService:!1})}function An(e){if(e.fetchImageService)return u.jsx(Br,{...e});const t=typeof e.src=="string"?{id:e.src,profile:"level0"}:e.src,n=wt(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 n?u.jsx("img",{src:n,alt:e.alt,className:e.className,style:e.style}):null}function Ur(e){const t=ve();return u.jsx(xt,{metadata:(t==null?void 0:t.metadata)||[],...e})}var kn={exports:{}};(()=>{var e={296:(r,s,i)=>{var a=/^\s+|\s+$/g,p=/^[-+]0x[0-9a-f]+$/i,y=/^0b[01]+$/i,f=/^0o[0-7]+$/i,g=parseInt,O=typeof i.g=="object"&&i.g&&i.g.Object===Object&&i.g,R=typeof self=="object"&&self&&self.Object===Object&&self,E=O||R||Function("return this")(),x=Object.prototype.toString,T=Math.max,I=Math.min,k=function(){return E.Date.now()};function j(A){var L=typeof A;return!!A&&(L=="object"||L=="function")}function B(A){if(typeof A=="number")return A;if(function(M){return typeof M=="symbol"||function(P){return!!P&&typeof P=="object"}(M)&&x.call(M)=="[object Symbol]"}(A))return NaN;if(j(A)){var L=typeof A.valueOf=="function"?A.valueOf():A;A=j(L)?L+"":L}if(typeof A!="string")return A===0?A:+A;A=A.replace(a,"");var q=y.test(A);return q||f.test(A)?g(A.slice(2),q?2:8):p.test(A)?NaN:+A}r.exports=function(A,L,q){var M,P,U,W,Q,Y,J=0,Z=!1,oe=!1,pe=!0;if(typeof A!="function")throw new TypeError("Expected a function");function N(ne){var re=M,ce=P;return M=P=void 0,J=ne,W=A.apply(ce,re)}function ee(ne){var re=ne-Y;return Y===void 0||re>=L||re<0||oe&&ne-J>=U}function $(){var ne=k();if(ee(ne))return ae(ne);Q=setTimeout($,function(re){var ce=L-(re-Y);return oe?I(ce,U-(re-J)):ce}(ne))}function ae(ne){return Q=void 0,pe&&M?N(ne):(M=P=void 0,W)}function ue(){var ne=k(),re=ee(ne);if(M=arguments,P=this,Y=ne,re){if(Q===void 0)return function(ce){return J=ce,Q=setTimeout($,L),Z?N(ce):W}(Y);if(oe)return Q=setTimeout($,L),N(Y)}return Q===void 0&&(Q=setTimeout($,L)),W}return L=B(L)||0,j(q)&&(Z=!!q.leading,U=(oe="maxWait"in q)?T(B(q.maxWait)||0,L):U,pe="trailing"in q?!!q.trailing:pe),ue.cancel=function(){Q!==void 0&&clearTimeout(Q),J=0,M=Y=P=Q=void 0},ue.flush=function(){return Q===void 0?W:ae(k())},ue}},96:(r,s,i)=>{var a="Expected a function",p=NaN,y="[object Symbol]",f=/^\s+|\s+$/g,g=/^[-+]0x[0-9a-f]+$/i,O=/^0b[01]+$/i,R=/^0o[0-7]+$/i,E=parseInt,x=typeof i.g=="object"&&i.g&&i.g.Object===Object&&i.g,T=typeof self=="object"&&self&&self.Object===Object&&self,I=x||T||Function("return this")(),k=Object.prototype.toString,j=Math.max,B=Math.min,A=function(){return I.Date.now()};function L(M){var P=typeof M;return!!M&&(P=="object"||P=="function")}function q(M){if(typeof M=="number")return M;if(function(W){return typeof W=="symbol"||function(Q){return!!Q&&typeof Q=="object"}(W)&&k.call(W)==y}(M))return p;if(L(M)){var P=typeof M.valueOf=="function"?M.valueOf():M;M=L(P)?P+"":P}if(typeof M!="string")return M===0?M:+M;M=M.replace(f,"");var U=O.test(M);return U||R.test(M)?E(M.slice(2),U?2:8):g.test(M)?p:+M}r.exports=function(M,P,U){var W=!0,Q=!0;if(typeof M!="function")throw new TypeError(a);return L(U)&&(W="leading"in U?!!U.leading:W,Q="trailing"in U?!!U.trailing:Q),function(Y,J,Z){var oe,pe,N,ee,$,ae,ue=0,ne=!1,re=!1,ce=!0;if(typeof Y!="function")throw new TypeError(a);function Me(le){var he=oe,me=pe;return oe=pe=void 0,ue=le,ee=Y.apply(me,he)}function qe(le){var he=le-ae;return ae===void 0||he>=J||he<0||re&&le-ue>=N}function ge(){var le=A();if(qe(le))return Fe(le);$=setTimeout(ge,function(he){var me=J-(he-ae);return re?B(me,N-(he-ue)):me}(le))}function Fe(le){return $=void 0,ce&&oe?Me(le):(oe=pe=void 0,ee)}function Se(){var le=A(),he=qe(le);if(oe=arguments,pe=this,ae=le,he){if($===void 0)return function(me){return ue=me,$=setTimeout(ge,J),ne?Me(me):ee}(ae);if(re)return $=setTimeout(ge,J),Me(ae)}return $===void 0&&($=setTimeout(ge,J)),ee}return J=q(J)||0,L(Z)&&(ne=!!Z.leading,N=(re="maxWait"in Z)?j(q(Z.maxWait)||0,J):N,ce="trailing"in Z?!!Z.trailing:ce),Se.cancel=function(){$!==void 0&&clearTimeout($),ue=0,oe=ae=pe=$=void 0},Se.flush=function(){return $===void 0?ee:Fe(A())},Se}(M,P,{leading:W,maxWait:P,trailing:Q})}},703:(r,s,i)=>{var a=i(414);function p(){}function y(){}y.resetWarningCache=p,r.exports=function(){function f(R,E,x,T,I,k){if(k!==a){var j=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 j.name="Invariant Violation",j}}function g(){return f}f.isRequired=f;var O={array:f,bigint:f,bool:f,func:f,number:f,object:f,string:f,symbol:f,any:f,arrayOf:g,element:f,elementType:f,instanceOf:g,node:f,objectOf:g,oneOf:g,oneOfType:g,shape:g,exact:g,checkPropTypes:y,resetWarningCache:p};return O.PropTypes=O,O}},697:(r,s,i)=>{r.exports=i(703)()},414:r=>{r.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}},t={};function n(r){var s=t[r];if(s!==void 0)return s.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=r=>{var s=r&&r.__esModule?()=>r.default:()=>r;return n.d(s,{a:s}),s},n.d=(r,s)=>{for(var i in s)n.o(s,i)&&!n.o(r,i)&&Object.defineProperty(r,i,{enumerable:!0,get:s[i]})},n.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),n.o=(r,s)=>Object.prototype.hasOwnProperty.call(r,s),n.r=r=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})};var o={};(()=>{n.r(o),n.d(o,{LazyLoadComponent:()=>St,LazyLoadImage:()=>Bn,trackWindowScroll:()=>ae});const r=c;var s=n.n(r),i=n(697);const a=Hn;var p=n.n(a);function y(){return typeof window<"u"&&"IntersectionObserver"in window&&"isIntersecting"in window.IntersectionObserverEntry.prototype}function f(m){return f=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},f(m)}function g(m,l){var v=Object.keys(m);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(m);l&&(b=b.filter(function(V){return Object.getOwnPropertyDescriptor(m,V).enumerable})),v.push.apply(v,b)}return v}function O(m,l,v){return(l=E(l))in m?Object.defineProperty(m,l,{value:v,enumerable:!0,configurable:!0,writable:!0}):m[l]=v,m}function R(m,l){for(var v=0;v<l.length;v++){var b=l[v];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,E(b.key),b)}}function E(m){var l=function(v,b){if(f(v)!=="object"||v===null)return v;var V=v[Symbol.toPrimitive];if(V!==void 0){var _=V.call(v,"string");if(f(_)!=="object")return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(v)}(m);return f(l)==="symbol"?l:String(l)}function x(m,l){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,b){return v.__proto__=b,v},x(m,l)}function T(m){return T=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(l){return l.__proto__||Object.getPrototypeOf(l)},T(m)}var I=function(m){m.forEach(function(l){l.isIntersecting&&l.target.onVisible()})},k={},j=function(m){(function(d,h){if(typeof h!="function"&&h!==null)throw new TypeError("Super expression must either be null or a function");d.prototype=Object.create(h&&h.prototype,{constructor:{value:d,writable:!0,configurable:!0}}),Object.defineProperty(d,"prototype",{writable:!1}),h&&x(d,h)})(F,m);var l,v,b,V,_=(b=F,V=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 d,h=T(b);if(V){var C=T(this).constructor;d=Reflect.construct(h,arguments,C)}else d=h.apply(this,arguments);return function(S,w){if(w&&(f(w)==="object"||typeof w=="function"))return w;if(w!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(D){if(D===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return D}(S)}(this,d)});function F(d){var h;if(function(S,w){if(!(S instanceof w))throw new TypeError("Cannot call a class as a function")}(this,F),(h=_.call(this,d)).supportsObserver=!d.scrollPosition&&d.useIntersectionObserver&&y(),h.supportsObserver){var C=d.threshold;h.observer=function(S){return k[S]=k[S]||new IntersectionObserver(I,{rootMargin:S+"px"}),k[S]}(C)}return h}return l=F,v=[{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 d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.props.scrollPosition,h=this.placeholder.getBoundingClientRect(),C=p().findDOMNode(this.placeholder).style,S=parseInt(C.getPropertyValue("margin-left"),10)||0,w=parseInt(C.getPropertyValue("margin-top"),10)||0;return{bottom:d.y+h.bottom+w,left:d.x+h.left+S,right:d.x+h.right+S,top:d.y+h.top+w}}},{key:"isPlaceholderInViewport",value:function(){if(typeof window>"u"||!this.placeholder)return!1;var d=this.props,h=d.scrollPosition,C=d.threshold,S=this.getPlaceholderBoundingBox(h),w=h.y+window.innerHeight,D=h.x,z=h.x+window.innerWidth,K=h.y;return K-C<=S.bottom&&w+C>=S.top&&D-C<=S.right&&z+C>=S.left}},{key:"updateVisibility",value:function(){this.isPlaceholderInViewport()&&this.props.onVisible()}},{key:"render",value:function(){var d=this,h=this.props,C=h.className,S=h.height,w=h.placeholder,D=h.style,z=h.width;if(w&&typeof w.type!="function")return s().cloneElement(w,{ref:function(H){return d.placeholder=H}});var K=function(H){for(var ie=1;ie<arguments.length;ie++){var G=arguments[ie]!=null?arguments[ie]:{};ie%2?g(Object(G),!0).forEach(function(fe){O(H,fe,G[fe])}):Object.getOwnPropertyDescriptors?Object.defineProperties(H,Object.getOwnPropertyDescriptors(G)):g(Object(G)).forEach(function(fe){Object.defineProperty(H,fe,Object.getOwnPropertyDescriptor(G,fe))})}return H}({display:"inline-block"},D);return z!==void 0&&(K.width=z),S!==void 0&&(K.height=S),s().createElement("span",{className:C,ref:function(H){return d.placeholder=H},style:K},w)}}],v&&R(l.prototype,v),Object.defineProperty(l,"prototype",{writable:!1}),F}(s().Component);j.propTypes={onVisible:i.PropTypes.func.isRequired,className:i.PropTypes.string,height:i.PropTypes.oneOfType([i.PropTypes.number,i.PropTypes.string]),placeholder:i.PropTypes.element,threshold:i.PropTypes.number,useIntersectionObserver:i.PropTypes.bool,scrollPosition:i.PropTypes.shape({x:i.PropTypes.number.isRequired,y:i.PropTypes.number.isRequired}),width:i.PropTypes.oneOfType([i.PropTypes.number,i.PropTypes.string])},j.defaultProps={className:"",placeholder:null,threshold:100,useIntersectionObserver:!0};const B=j;var A=n(296),L=n.n(A),q=n(96),M=n.n(q),P=function(m){var l=getComputedStyle(m,null);return l.getPropertyValue("overflow")+l.getPropertyValue("overflow-y")+l.getPropertyValue("overflow-x")};const U=function(m){if(!(m instanceof HTMLElement))return window;for(var l=m;l&&l instanceof HTMLElement;){if(/(scroll|auto)/.test(P(l)))return l;l=l.parentNode}return window};function W(m){return W=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},W(m)}var Q=["delayMethod","delayTime"];function Y(){return Y=Object.assign?Object.assign.bind():function(m){for(var l=1;l<arguments.length;l++){var v=arguments[l];for(var b in v)Object.prototype.hasOwnProperty.call(v,b)&&(m[b]=v[b])}return m},Y.apply(this,arguments)}function J(m,l){for(var v=0;v<l.length;v++){var b=l[v];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,(V=function(_,F){if(W(_)!=="object"||_===null)return _;var d=_[Symbol.toPrimitive];if(d!==void 0){var h=d.call(_,"string");if(W(h)!=="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(_)}(b.key),W(V)==="symbol"?V:String(V)),b)}var V}function Z(m,l){return Z=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,b){return v.__proto__=b,v},Z(m,l)}function oe(m,l){if(l&&(W(l)==="object"||typeof l=="function"))return l;if(l!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return pe(m)}function pe(m){if(m===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m}function N(m){return N=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(l){return l.__proto__||Object.getPrototypeOf(l)},N(m)}var ee=function(){return typeof window>"u"?0:window.scrollX||window.pageXOffset},$=function(){return typeof window>"u"?0:window.scrollY||window.pageYOffset};const ae=function(m){var l=function(v){(function(C,S){if(typeof S!="function"&&S!==null)throw new TypeError("Super expression must either be null or a function");C.prototype=Object.create(S&&S.prototype,{constructor:{value:C,writable:!0,configurable:!0}}),Object.defineProperty(C,"prototype",{writable:!1}),S&&Z(C,S)})(h,v);var b,V,_,F,d=(_=h,F=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 C,S=N(_);if(F){var w=N(this).constructor;C=Reflect.construct(S,arguments,w)}else C=S.apply(this,arguments);return oe(this,C)});function h(C){var S;if(function(D,z){if(!(D instanceof z))throw new TypeError("Cannot call a class as a function")}(this,h),(S=d.call(this,C)).useIntersectionObserver=C.useIntersectionObserver&&y(),S.useIntersectionObserver)return oe(S);var w=S.onChangeScroll.bind(pe(S));return C.delayMethod==="debounce"?S.delayedScroll=L()(w,C.delayTime):C.delayMethod==="throttle"&&(S.delayedScroll=M()(w,C.delayTime)),S.state={scrollPosition:{x:ee(),y:$()}},S.baseComponentRef=s().createRef(),S}return b=h,(V=[{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:ee(),y:$()}})}},{key:"render",value:function(){var C=this.props,S=(C.delayMethod,C.delayTime,function(D,z){if(D==null)return{};var K,H,ie=function(fe,Te){if(fe==null)return{};var Pe,$e,Ct={},Tt=Object.keys(fe);for($e=0;$e<Tt.length;$e++)Pe=Tt[$e],Te.indexOf(Pe)>=0||(Ct[Pe]=fe[Pe]);return Ct}(D,z);if(Object.getOwnPropertySymbols){var G=Object.getOwnPropertySymbols(D);for(H=0;H<G.length;H++)K=G[H],z.indexOf(K)>=0||Object.prototype.propertyIsEnumerable.call(D,K)&&(ie[K]=D[K])}return ie}(C,Q)),w=this.useIntersectionObserver?null:this.state.scrollPosition;return s().createElement(m,Y({forwardRef:this.baseComponentRef,scrollPosition:w},S))}}])&&J(b.prototype,V),Object.defineProperty(b,"prototype",{writable:!1}),h}(s().Component);return l.propTypes={delayMethod:i.PropTypes.oneOf(["debounce","throttle"]),delayTime:i.PropTypes.number,useIntersectionObserver:i.PropTypes.bool},l.defaultProps={delayMethod:"throttle",delayTime:300,useIntersectionObserver:!0},l};function ue(m){return ue=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},ue(m)}function ne(m,l){for(var v=0;v<l.length;v++){var b=l[v];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,(V=function(_,F){if(ue(_)!=="object"||_===null)return _;var d=_[Symbol.toPrimitive];if(d!==void 0){var h=d.call(_,"string");if(ue(h)!=="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(_)}(b.key),ue(V)==="symbol"?V:String(V)),b)}var V}function re(m,l){return re=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,b){return v.__proto__=b,v},re(m,l)}function ce(m){return ce=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(l){return l.__proto__||Object.getPrototypeOf(l)},ce(m)}var Me=function(m){(function(d,h){if(typeof h!="function"&&h!==null)throw new TypeError("Super expression must either be null or a function");d.prototype=Object.create(h&&h.prototype,{constructor:{value:d,writable:!0,configurable:!0}}),Object.defineProperty(d,"prototype",{writable:!1}),h&&re(d,h)})(F,m);var l,v,b,V,_=(b=F,V=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 d,h=ce(b);if(V){var C=ce(this).constructor;d=Reflect.construct(h,arguments,C)}else d=h.apply(this,arguments);return function(S,w){if(w&&(ue(w)==="object"||typeof w=="function"))return w;if(w!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(D){if(D===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return D}(S)}(this,d)});function F(d){return function(h,C){if(!(h instanceof C))throw new TypeError("Cannot call a class as a function")}(this,F),_.call(this,d)}return l=F,(v=[{key:"render",value:function(){return s().createElement(B,this.props)}}])&&ne(l.prototype,v),Object.defineProperty(l,"prototype",{writable:!1}),F}(s().Component);const qe=ae(Me);function ge(m){return ge=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},ge(m)}function Fe(m,l){for(var v=0;v<l.length;v++){var b=l[v];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,(V=function(_,F){if(ge(_)!=="object"||_===null)return _;var d=_[Symbol.toPrimitive];if(d!==void 0){var h=d.call(_,"string");if(ge(h)!=="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(_)}(b.key),ge(V)==="symbol"?V:String(V)),b)}var V}function Se(m,l){return Se=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,b){return v.__proto__=b,v},Se(m,l)}function le(m){if(m===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m}function he(m){return he=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(l){return l.__proto__||Object.getPrototypeOf(l)},he(m)}var me=function(m){(function(d,h){if(typeof h!="function"&&h!==null)throw new TypeError("Super expression must either be null or a function");d.prototype=Object.create(h&&h.prototype,{constructor:{value:d,writable:!0,configurable:!0}}),Object.defineProperty(d,"prototype",{writable:!1}),h&&Se(d,h)})(F,m);var l,v,b,V,_=(b=F,V=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 d,h=he(b);if(V){var C=he(this).constructor;d=Reflect.construct(h,arguments,C)}else d=h.apply(this,arguments);return function(S,w){if(w&&(ge(w)==="object"||typeof w=="function"))return w;if(w!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return le(S)}(this,d)});function F(d){var h;(function(z,K){if(!(z instanceof K))throw new TypeError("Cannot call a class as a function")})(this,F),h=_.call(this,d);var C=d.afterLoad,S=d.beforeLoad,w=d.scrollPosition,D=d.visibleByDefault;return h.state={visible:D},D&&(S(),C()),h.onVisible=h.onVisible.bind(le(h)),h.isScrollTracked=!!(w&&Number.isFinite(w.x)&&w.x>=0&&Number.isFinite(w.y)&&w.y>=0),h}return l=F,(v=[{key:"componentDidUpdate",value:function(d,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 d=this.props,h=d.className,C=d.delayMethod,S=d.delayTime,w=d.height,D=d.placeholder,z=d.scrollPosition,K=d.style,H=d.threshold,ie=d.useIntersectionObserver,G=d.width;return this.isScrollTracked||ie&&y()?s().createElement(B,{className:h,height:w,onVisible:this.onVisible,placeholder:D,scrollPosition:z,style:K,threshold:H,useIntersectionObserver:ie,width:G}):s().createElement(qe,{className:h,delayMethod:C,delayTime:S,height:w,onVisible:this.onVisible,placeholder:D,style:K,threshold:H,width:G})}}])&&Fe(l.prototype,v),Object.defineProperty(l,"prototype",{writable:!1}),F}(s().Component);me.propTypes={afterLoad:i.PropTypes.func,beforeLoad:i.PropTypes.func,useIntersectionObserver:i.PropTypes.bool,visibleByDefault:i.PropTypes.bool},me.defaultProps={afterLoad:function(){return{}},beforeLoad:function(){return{}},useIntersectionObserver:!0,visibleByDefault:!1};const St=me;function Ce(m){return Ce=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},Ce(m)}var Dn=["afterLoad","beforeLoad","delayMethod","delayTime","effect","placeholder","placeholderSrc","scrollPosition","threshold","useIntersectionObserver","visibleByDefault","wrapperClassName","wrapperProps"];function Pt(m,l){var v=Object.keys(m);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(m);l&&(b=b.filter(function(V){return Object.getOwnPropertyDescriptor(m,V).enumerable})),v.push.apply(v,b)}return v}function jt(m){for(var l=1;l<arguments.length;l++){var v=arguments[l]!=null?arguments[l]:{};l%2?Pt(Object(v),!0).forEach(function(b){qn(m,b,v[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(v)):Pt(Object(v)).forEach(function(b){Object.defineProperty(m,b,Object.getOwnPropertyDescriptor(v,b))})}return m}function qn(m,l,v){return(l=Ot(l))in m?Object.defineProperty(m,l,{value:v,enumerable:!0,configurable:!0,writable:!0}):m[l]=v,m}function Be(){return Be=Object.assign?Object.assign.bind():function(m){for(var l=1;l<arguments.length;l++){var v=arguments[l];for(var b in v)Object.prototype.hasOwnProperty.call(v,b)&&(m[b]=v[b])}return m},Be.apply(this,arguments)}function Fn(m,l){for(var v=0;v<l.length;v++){var b=l[v];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,Ot(b.key),b)}}function Ot(m){var l=function(v,b){if(Ce(v)!=="object"||v===null)return v;var V=v[Symbol.toPrimitive];if(V!==void 0){var _=V.call(v,"string");if(Ce(_)!=="object")return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(v)}(m);return Ce(l)==="symbol"?l:String(l)}function tt(m,l){return tt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,b){return v.__proto__=b,v},tt(m,l)}function Ue(m){return Ue=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(l){return l.__proto__||Object.getPrototypeOf(l)},Ue(m)}var nt=function(m){(function(d,h){if(typeof h!="function"&&h!==null)throw new TypeError("Super expression must either be null or a function");d.prototype=Object.create(h&&h.prototype,{constructor:{value:d,writable:!0,configurable:!0}}),Object.defineProperty(d,"prototype",{writable:!1}),h&&tt(d,h)})(F,m);var l,v,b,V,_=(b=F,V=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 d,h=Ue(b);if(V){var C=Ue(this).constructor;d=Reflect.construct(h,arguments,C)}else d=h.apply(this,arguments);return function(S,w){if(w&&(Ce(w)==="object"||typeof w=="function"))return w;if(w!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(D){if(D===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return D}(S)}(this,d)});function F(d){var h;return function(C,S){if(!(C instanceof S))throw new TypeError("Cannot call a class as a function")}(this,F),(h=_.call(this,d)).state={loaded:!1},h}return l=F,(v=[{key:"onImageLoad",value:function(){var d=this;return this.state.loaded?null:function(h){d.props.onLoad(h),d.props.afterLoad(),d.setState({loaded:!0})}}},{key:"getImg",value:function(){var d=this.props,h=(d.afterLoad,d.beforeLoad,d.delayMethod,d.delayTime,d.effect,d.placeholder,d.placeholderSrc,d.scrollPosition,d.threshold,d.useIntersectionObserver,d.visibleByDefault,d.wrapperClassName,d.wrapperProps,function(C,S){if(C==null)return{};var w,D,z=function(H,ie){if(H==null)return{};var G,fe,Te={},Pe=Object.keys(H);for(fe=0;fe<Pe.length;fe++)G=Pe[fe],ie.indexOf(G)>=0||(Te[G]=H[G]);return Te}(C,S);if(Object.getOwnPropertySymbols){var K=Object.getOwnPropertySymbols(C);for(D=0;D<K.length;D++)w=K[D],S.indexOf(w)>=0||Object.prototype.propertyIsEnumerable.call(C,w)&&(z[w]=C[w])}return z}(d,Dn));return s().createElement("img",Be({},h,{onLoad:this.onImageLoad()}))}},{key:"getLazyLoadImage",value:function(){var d=this.props,h=d.beforeLoad,C=d.className,S=d.delayMethod,w=d.delayTime,D=d.height,z=d.placeholder,K=d.scrollPosition,H=d.style,ie=d.threshold,G=d.useIntersectionObserver,fe=d.visibleByDefault,Te=d.width;return s().createElement(St,{beforeLoad:h,className:C,delayMethod:S,delayTime:w,height:D,placeholder:z,scrollPosition:K,style:H,threshold:ie,useIntersectionObserver:G,visibleByDefault:fe,width:Te},this.getImg())}},{key:"getWrappedLazyLoadImage",value:function(d){var h=this.props,C=h.effect,S=h.height,w=h.placeholderSrc,D=h.width,z=h.wrapperClassName,K=h.wrapperProps,H=this.state.loaded,ie=H?" lazy-load-image-loaded":"",G=H||!w?{}:{backgroundImage:"url(".concat(w,")"),backgroundSize:"100% 100%"};return s().createElement("span",Be({className:z+" lazy-load-image-background "+C+ie,style:jt(jt({},G),{},{color:"transparent",display:"inline-block",height:S,width:D})},K),d)}},{key:"render",value:function(){var d=this.props,h=d.effect,C=d.placeholderSrc,S=d.visibleByDefault,w=d.wrapperClassName,D=d.wrapperProps,z=this.getLazyLoadImage();return(h||C)&&!S||w||D?this.getWrappedLazyLoadImage(z):z}}])&&Fn(l.prototype,v),Object.defineProperty(l,"prototype",{writable:!1}),F}(s().Component);nt.propTypes={onLoad:i.PropTypes.func,afterLoad:i.PropTypes.func,beforeLoad:i.PropTypes.func,delayMethod:i.PropTypes.string,delayTime:i.PropTypes.number,effect:i.PropTypes.string,placeholderSrc:i.PropTypes.string,threshold:i.PropTypes.number,useIntersectionObserver:i.PropTypes.bool,visibleByDefault:i.PropTypes.bool,wrapperClassName:i.PropTypes.string,wrapperProps:i.PropTypes.object},nt.defaultProps={onLoad:function(){},afterLoad:function(){return{}},beforeLoad:function(){return{}},delayMethod:"throttle",delayTime:300,effect:"",placeholderSrc:null,threshold:100,useIntersectionObserver:!0,visibleByDefault:!1,wrapperClassName:""};const Bn=nt})(),kn.exports=o})();var $r=kn.exports;function Hr(e,t,n=[],o=!1,r=[]){if(r.length&&(t=t.filter(i=>r.indexOf(i)===-1)),!t||t.length===0)return;if(t.length===1)return t[0];if(!e)return t.indexOf("none")!==-1?"none":t[0];if(t.indexOf(e)!==-1)return e;const s=e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):null;if(s&&t.indexOf(s)!==-1)return s;for(const i of n)if(t.indexOf(i)!==-1)return i;if(!o&&e){const i=t.map(a=>a.indexOf("-")!==-1?a.slice(0,a.indexOf("-")):null).indexOf(e);if(i!==-1)return t[i];for(const a of n){const p=a.indexOf("-")!==-1?a.slice(0,a.indexOf("-")):null,y=p?t.indexOf(p):-1;if(y!==-1)return t[y]}}return t.indexOf("none")!==-1?"none":t.indexOf("@none")!==-1?"@none":t[0]}function Vn(e,t,n={}){const{strictFallback:o=!1,defaultText:r="",separator:s=`
|
|
48
|
-
`,fallbackLanguages:i=[],closest:a,skipLanguages:p}=n,y=Object.keys(e||{}),f=a?t:Hr(t,y,i,o,p);if(!e)return r;if(typeof e=="string")return e;const g=f?e[f]:void 0;if(g&&f){if(typeof g=="string")return g;if(g.length===1&&g[0]===""){const O=n.skipLanguages||[];return Vn(e,t,{...n,skipLanguages:[...O,f]})}return g.join(s)}return""}function Wr(e,t={}){return Vn(e,t.language||(typeof navigator<"u"?navigator.language:"en"),t)}const Yr=$r.LazyLoadComponent;function Nn(e){const{size:t,visible:n,classes:o,canvasId:r,figure:s}=e,i=(t==null?void 0:t.width)||128,a=(t==null?void 0:t.height)||(t==null?void 0:t.width)||128,p=u.jsx(zr,{...e}),y=u.jsx(Yr,{threshold:300,style:{height:a,width:i},visibleByDefault:n,children:r?u.jsx(Ve,{canvas:r,children:p}):p});return s?u.jsx("figure",{className:o==null?void 0:o.figure,children:y}):y}function zr({fallback:e,size:t,classes:n,showLabel:o,alt:r,dereference:s=!1}){const i=ye(),a=(t==null?void 0:t.width)||128,p=(t==null?void 0:t.height)||(t==null?void 0:t.width)||128,y=r||Wr(i==null?void 0:i.label)||"",f=vt({width:a,height:p},s);return!f||f.type!=="fixed"?u.jsx(u.Fragment,{children:e}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:n==null?void 0:n.imageWrapper,children:u.jsx("img",{className:n==null?void 0:n.img,src:f.id,alt:y})}),o?u.jsx(je,{as:"figcaption",className:n==null?void 0:n.label,children:i==null?void 0:i.label}):null]})}function Kr({flat:e,size:t,classes:n={},showLabel:o,figure:r,fallback:s}){var R,
|
|
47
|
+
`}),u.jsx("iframe",{className:"video-yt",ref:o,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 _r({media:e,mediaControlsDeps:t,children:n}){const[{element:o,currentTime:r,progress:s},i,a]=Ze({duration:e.duration});return Ie("overlay","video-element",Nr,{element:o,media:e,playPause:a.playPause}),null}function Ln({x:e,y:t,onChoiceChange:n,registerActions:o,defaultChoices:r,isStatic:s,renderViewerControls:i,renderMediaControls:a,viewControlsDeps:p,mediaControlsDeps:y,strategies:f,throwOnUnknown:g,backgroundStyle:O,alwaysShowBackground:R,keepCanvasScale:I=!1,enableSizes:C=!1,enableYouTube:x=!0,onClickPaintingAnnotation:E,children:A}){const S=ye(),B=ht(S,["deep-zoom"]),[k]=Ut(),L=Ht(),q=te(),M=c.useMemo(()=>st.createStylesHelper(q),[q]),[j,U]=hn({strategies:f||["images"],defaultChoices:r==null?void 0:r.map(({id:N})=>N)}),W=j.type==="images"?j.choice:void 0,Q=c.useMemo(()=>I?1:Math.max(1,...j.type==="images"?j.images.map(N=>{var ee;return(N.width||0)/((ee=N.target)==null?void 0:ee.spatial.width)}):[]),[I,j]);vr(Q),c.useEffect(()=>{o&&o(U)},[j.annotations]),c.useEffect(()=>{if(r)for(const N of r)typeof N.opacity<"u"&&M.applyStyles({id:N.id},"atlas",{opacity:N.opacity})},[r]),c.useLayoutEffect(()=>{n&&n(W)},[W]),Ie(L&&(j.type==="images"||j.type==="empty"||j.type==="textual-content"&&i)?"overlay":"none",`canvas-portal-controls-${S==null?void 0:S.id}`,Xe.Provider,i?{value:L||null,children:i(j)}:{},[S,L,j,...p||[]]);const Y=vt({maxWidth:256,maxHeight:256});if(!S)return null;const J=S.accompanyingCanvas,Z=Y&&Y.type==="fixed"?u.jsx("world-object",{height:S.height,width:S.width,x:e,y:t,children:u.jsx("world-image",{uri:Y.id,target:{x:0,y:0,width:S.width,height:S.height},display:Y.width&&Y.height?{width:Y.width,height:Y.height}:void 0,crop:void 0})}):null;if(j.type==="unknown"){if(Z)return Z;if(g)throw new Error(j.reason||"Unknown image strategy");return null}const oe=u.jsxs(c.Fragment,{children:[k?u.jsx(it,{page:k}):null,j.annotations&&j.annotations.pages?j.annotations.pages.map(N=>u.jsx(it,{page:N},N.id)):null,A]}),pe=j.type==="images"?j.images.length:0;return u.jsxs(u.Fragment,{children:[u.jsxs("world-object",{height:S.height,width:S.width,x:e,y:t,...B,children:[j.type==="empty"||R?u.jsx(Cn,{style:O}):null,j.type==="textual-content"?j.items.map((N,ee)=>{var $;return u.jsxs(u.Fragment,{children:[u.jsx(Oe.HTMLPortal,{onClick:E?ae=>{ae.stopPropagation(),E(N.annotationId,N,ae)}:void 0,target:(($=N.target)==null?void 0:$.spatial)||void 0,children:u.jsx("div",{"data-textual-content":!0,children:u.jsx(je,{enableDangerouslySetInnerHTML:!0,children:N.text})})},ee),oe]})}):null,j.type==="images"?u.jsxs(u.Fragment,{children:[j.images.map((N,ee)=>u.jsx(Jt,{isStatic:s,image:N,id:N.id,thumbnail:ee===0?Y:void 0,selector:N.selector,enableSizes:C,onClick:E?$=>{$.stopPropagation(),E(N.annotationId,N,$)}:void 0},N.id+ee)),oe]}):null,j.type==="3d-model"?u.jsx(On,{model:j.model}):null,j.type==="media"?u.jsx(u.Fragment,{children:j.media.type==="Sound"?u.jsxs(wn,{media:j.media,mediaControlsDeps:y,children:[Z,a?a(j):null]}):j.media.type==="Video"?u.jsxs(Pn,{media:j.media,mediaControlsDeps:y,children:[Z,a?a(j):null]}):j.media.type==="VideoYouTube"&&x?u.jsxs(_r,{media:j.media,mediaControlsDeps:y,children:[Z,a?a(j):null]}):null}):null]},`${S.id}/${j.type}/${pe}`),j.type==="media"&&j.media.type==="Sound"&&J?u.jsx(Ve,{canvas:J.id,children:u.jsx(Ln,{renderViewerControls:i})}):null]})}const Dr=c.forwardRef(function(t,n){const o=ve(),r=ut(),s=pt(),{ViewerControls:i,MediaControls:a}=t.components||{};if(c.useImperativeHandle(n,()=>s,[s]),!o)return u.jsx("div",{});let p=0;return u.jsxs(u.Fragment,{children:[t.header,u.jsx(de.Viewer,{height:t.height,mode:t.mode,children:r.map((y,f)=>{const g=p;return p+=y.width+(t.spacing||0),u.jsx(Ve,{canvas:y.id,children:u.jsx(de.RenderCanvas,{strategies:["3d-model","media","images","empty","textual-content"],renderViewerControls:f===0&&i?()=>u.jsx(i,{}):void 0,renderMediaControls:f===0&&a?()=>u.jsx(a,{}):void 0,x:g,...t.canvasProps||{},children:t.annotations},y.id)},y.id)})},t.reuseAtlas?"":s.currentSequenceIndex),t.children]})}),de=c.forwardRef(function({children:t,height:n,annotations:o,canvasProps:r,spacing:s,header:i,components:a,mode:p,reuseAtlas:y,...f},g){const O=Ge();return u.jsx(Qe,{vault:O,children:u.jsx(Nt,{...f,children:u.jsx(Dr,{ref:g,height:n,components:a,spacing:s,canvasProps:r,annotations:o,header:i,mode:p,reuseAtlas:y,children:t})})})});de.RenderImage=Jt;de.RenderCanvas=Ln;de.RenderAnnotationPage=it;de.RenderAnnotation=Gt;de.Viewer=br;de.CanvasBackground=Cn;de.Audio=wn;de.Video=Pn;de.Model=On;de.AudioHTML=xn;de.VideoHTML=Sn;de.ModelHTML=jn;const qr=c.forwardRef(function({canvasId:t},n){const o=Oe.useCanvas(),r=mt(t||(o==null?void 0:o.id)),s=te();return c.useImperativeHandle(n,()=>r,[t,o]),!o||r.enabledPageIds.length===0?null:u.jsx(u.Fragment,{children:r.enabledPageIds.map(i=>u.jsx(de.RenderAnnotationPage,{page:s.get(i)},i))})});function xt({metadata:e=[],config:t,labelWidth:n=16,showEmptyMessage:o=!0,allowHtml:r,emptyFallback:s,classes:i={},emptyMessage:a="No metadata available",emptyValueFallback:p="No value",emptyLabelFallback:y="",separator:f,tableFooter:g,tableHeader:O}){const R=c.useMemo(()=>{const C=(t||[]).reduce((E,A)=>[...E,...A.keys],[]),x={};for(const E of e){const A=E&&E.label?Object.values(E.label):[];for(const S of A)if(S&&S.length&&(C.indexOf(`metadata.${S[0]}`)!==-1||C.length===0)&&E){const B=`metadata.${S[0]}`;x[B]=x[B]?x[B]:[],x[B].push(E);break}}return x},[t,e]);return Object.keys(R).length===0&&o?u.jsx(u.Fragment,{children:s})||u.jsx("div",{className:i.empty,children:a}):t&&t.length?u.jsxs("table",{className:i.container,children:[O,u.jsx("tbody",{children:t.map((C,x)=>{const E=[];for(const A of C.keys)for(const S of R[A]||[])E.push(u.jsx(je,{enableDangerouslySetInnerHTML:r,defaultText:p,separator:f,children:S.value},x+"__"+A));return E.length===0?null:u.jsxs("tr",{className:i.row,children:[u.jsx("td",{className:i.label,style:n?{minWidth:n}:{},children:u.jsx(je,{enableDangerouslySetInnerHTML:r,separator:f,defaultText:y,children:C.label})}),u.jsx("td",{className:i.value,children:E})]},x)})}),g]}):u.jsxs("table",{className:i.container,children:[O,u.jsx("tbody",{children:e&&e.length?e.map((C,x)=>C?u.jsxs("tr",{className:i.row,children:[u.jsx("td",{className:i.label,style:n?{minWidth:n}:{},children:u.jsx(je,{enableDangerouslySetInnerHTML:r,defaultText:p,separator:f,children:C.label})}),u.jsx("td",{className:i.value,children:u.jsx(je,{enableDangerouslySetInnerHTML:r,defaultText:p,separator:f,children:C.value})})]},x):null):null}),g]})}function Fr(e){const t=ve(),n=ye(),o=dt(),r=c.useMemo(()=>{const s=(t==null?void 0:t.metadata)||[],i=(n==null?void 0:n.metadata)||[],a=(o==null?void 0:o.metadata)||[];return[...s,...i,...a]},[t,n,o]);return u.jsx(xt,{metadata:r,...e})}function wt(e,t={},n=[]){return c.useMemo(()=>{var i,a;if(!e)return null;let o=t.quality;e&&e.extraQualities&&t.quality&&(e.extraQualities.includes(t.quality)||(console.log("Invalid quality",t.quality,e.extraQualities),o="default"));const r=Ee.createImageServiceRequest(e);return Ee.imageServiceRequestToString({identifier:r.identifier,server:r.server,scheme:r.scheme,type:"image",size:{max:!((i=t.size)!=null&&i.width)&&!((a=t.size)!=null&&a.height),confined:!1,upscaled:!1,...t.size||{}},format:t.format||"jpg",region:t.region||{full:!0},rotation:t!=null&&t.rotation?Number.isInteger(t.rotation)?{angle:t.rotation}:t.rotation:{angle:0},quality:o||"default",prefix:r.prefix,originalPath:r.originalPath})},[...n])}function Br(e){const t=typeof e.src=="string"?e.src:e.src.id,n=De(),[o,r]=c.useState(!1);let s;if(t){const a=n.loadServiceSync({id:t});a&&(s=a)}!s&&!o&&n.loadService({id:t}).then(()=>{r(!0)});const i=wt(s,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[o,e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return c.useEffect(()=>()=>{r(!1)},[t]),i?u.jsx("img",{src:i,alt:e.alt,className:e.className,style:e.style}):u.jsx(An,{...e,fetchImageService:!1})}function An(e){if(e.fetchImageService)return u.jsx(Br,{...e});const t=typeof e.src=="string"?{id:e.src,profile:"level0"}:e.src,n=wt(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 n?u.jsx("img",{src:n,alt:e.alt,className:e.className,style:e.style}):null}function Ur(e){const t=ve();return u.jsx(xt,{metadata:(t==null?void 0:t.metadata)||[],...e})}var kn={exports:{}};(()=>{var e={296:(r,s,i)=>{var a=/^\s+|\s+$/g,p=/^[-+]0x[0-9a-f]+$/i,y=/^0b[01]+$/i,f=/^0o[0-7]+$/i,g=parseInt,O=typeof i.g=="object"&&i.g&&i.g.Object===Object&&i.g,R=typeof self=="object"&&self&&self.Object===Object&&self,I=O||R||Function("return this")(),C=Object.prototype.toString,x=Math.max,E=Math.min,A=function(){return I.Date.now()};function S(k){var L=typeof k;return!!k&&(L=="object"||L=="function")}function B(k){if(typeof k=="number")return k;if(function(M){return typeof M=="symbol"||function(j){return!!j&&typeof j=="object"}(M)&&C.call(M)=="[object Symbol]"}(k))return NaN;if(S(k)){var L=typeof k.valueOf=="function"?k.valueOf():k;k=S(L)?L+"":L}if(typeof k!="string")return k===0?k:+k;k=k.replace(a,"");var q=y.test(k);return q||f.test(k)?g(k.slice(2),q?2:8):p.test(k)?NaN:+k}r.exports=function(k,L,q){var M,j,U,W,Q,Y,J=0,Z=!1,oe=!1,pe=!0;if(typeof k!="function")throw new TypeError("Expected a function");function N(ne){var re=M,ce=j;return M=j=void 0,J=ne,W=k.apply(ce,re)}function ee(ne){var re=ne-Y;return Y===void 0||re>=L||re<0||oe&&ne-J>=U}function $(){var ne=A();if(ee(ne))return ae(ne);Q=setTimeout($,function(re){var ce=L-(re-Y);return oe?E(ce,U-(re-J)):ce}(ne))}function ae(ne){return Q=void 0,pe&&M?N(ne):(M=j=void 0,W)}function ue(){var ne=A(),re=ee(ne);if(M=arguments,j=this,Y=ne,re){if(Q===void 0)return function(ce){return J=ce,Q=setTimeout($,L),Z?N(ce):W}(Y);if(oe)return Q=setTimeout($,L),N(Y)}return Q===void 0&&(Q=setTimeout($,L)),W}return L=B(L)||0,S(q)&&(Z=!!q.leading,U=(oe="maxWait"in q)?x(B(q.maxWait)||0,L):U,pe="trailing"in q?!!q.trailing:pe),ue.cancel=function(){Q!==void 0&&clearTimeout(Q),J=0,M=Y=j=Q=void 0},ue.flush=function(){return Q===void 0?W:ae(A())},ue}},96:(r,s,i)=>{var a="Expected a function",p=NaN,y="[object Symbol]",f=/^\s+|\s+$/g,g=/^[-+]0x[0-9a-f]+$/i,O=/^0b[01]+$/i,R=/^0o[0-7]+$/i,I=parseInt,C=typeof i.g=="object"&&i.g&&i.g.Object===Object&&i.g,x=typeof self=="object"&&self&&self.Object===Object&&self,E=C||x||Function("return this")(),A=Object.prototype.toString,S=Math.max,B=Math.min,k=function(){return E.Date.now()};function L(M){var j=typeof M;return!!M&&(j=="object"||j=="function")}function q(M){if(typeof M=="number")return M;if(function(W){return typeof W=="symbol"||function(Q){return!!Q&&typeof Q=="object"}(W)&&A.call(W)==y}(M))return p;if(L(M)){var j=typeof M.valueOf=="function"?M.valueOf():M;M=L(j)?j+"":j}if(typeof M!="string")return M===0?M:+M;M=M.replace(f,"");var U=O.test(M);return U||R.test(M)?I(M.slice(2),U?2:8):g.test(M)?p:+M}r.exports=function(M,j,U){var W=!0,Q=!0;if(typeof M!="function")throw new TypeError(a);return L(U)&&(W="leading"in U?!!U.leading:W,Q="trailing"in U?!!U.trailing:Q),function(Y,J,Z){var oe,pe,N,ee,$,ae,ue=0,ne=!1,re=!1,ce=!0;if(typeof Y!="function")throw new TypeError(a);function Me(le){var he=oe,me=pe;return oe=pe=void 0,ue=le,ee=Y.apply(me,he)}function qe(le){var he=le-ae;return ae===void 0||he>=J||he<0||re&&le-ue>=N}function ge(){var le=k();if(qe(le))return Fe(le);$=setTimeout(ge,function(he){var me=J-(he-ae);return re?B(me,N-(he-ue)):me}(le))}function Fe(le){return $=void 0,ce&&oe?Me(le):(oe=pe=void 0,ee)}function Se(){var le=k(),he=qe(le);if(oe=arguments,pe=this,ae=le,he){if($===void 0)return function(me){return ue=me,$=setTimeout(ge,J),ne?Me(me):ee}(ae);if(re)return $=setTimeout(ge,J),Me(ae)}return $===void 0&&($=setTimeout(ge,J)),ee}return J=q(J)||0,L(Z)&&(ne=!!Z.leading,N=(re="maxWait"in Z)?S(q(Z.maxWait)||0,J):N,ce="trailing"in Z?!!Z.trailing:ce),Se.cancel=function(){$!==void 0&&clearTimeout($),ue=0,oe=ae=pe=$=void 0},Se.flush=function(){return $===void 0?ee:Fe(k())},Se}(M,j,{leading:W,maxWait:j,trailing:Q})}},703:(r,s,i)=>{var a=i(414);function p(){}function y(){}y.resetWarningCache=p,r.exports=function(){function f(R,I,C,x,E,A){if(A!==a){var S=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 S.name="Invariant Violation",S}}function g(){return f}f.isRequired=f;var O={array:f,bigint:f,bool:f,func:f,number:f,object:f,string:f,symbol:f,any:f,arrayOf:g,element:f,elementType:f,instanceOf:g,node:f,objectOf:g,oneOf:g,oneOfType:g,shape:g,exact:g,checkPropTypes:y,resetWarningCache:p};return O.PropTypes=O,O}},697:(r,s,i)=>{r.exports=i(703)()},414:r=>{r.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}},t={};function n(r){var s=t[r];if(s!==void 0)return s.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=r=>{var s=r&&r.__esModule?()=>r.default:()=>r;return n.d(s,{a:s}),s},n.d=(r,s)=>{for(var i in s)n.o(s,i)&&!n.o(r,i)&&Object.defineProperty(r,i,{enumerable:!0,get:s[i]})},n.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),n.o=(r,s)=>Object.prototype.hasOwnProperty.call(r,s),n.r=r=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})};var o={};(()=>{n.r(o),n.d(o,{LazyLoadComponent:()=>St,LazyLoadImage:()=>Bn,trackWindowScroll:()=>ae});const r=c;var s=n.n(r),i=n(697);const a=Hn;var p=n.n(a);function y(){return typeof window<"u"&&"IntersectionObserver"in window&&"isIntersecting"in window.IntersectionObserverEntry.prototype}function f(m){return f=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},f(m)}function g(m,l){var v=Object.keys(m);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(m);l&&(b=b.filter(function(V){return Object.getOwnPropertyDescriptor(m,V).enumerable})),v.push.apply(v,b)}return v}function O(m,l,v){return(l=I(l))in m?Object.defineProperty(m,l,{value:v,enumerable:!0,configurable:!0,writable:!0}):m[l]=v,m}function R(m,l){for(var v=0;v<l.length;v++){var b=l[v];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,I(b.key),b)}}function I(m){var l=function(v,b){if(f(v)!=="object"||v===null)return v;var V=v[Symbol.toPrimitive];if(V!==void 0){var _=V.call(v,"string");if(f(_)!=="object")return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(v)}(m);return f(l)==="symbol"?l:String(l)}function C(m,l){return C=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,b){return v.__proto__=b,v},C(m,l)}function x(m){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(l){return l.__proto__||Object.getPrototypeOf(l)},x(m)}var E=function(m){m.forEach(function(l){l.isIntersecting&&l.target.onVisible()})},A={},S=function(m){(function(d,h){if(typeof h!="function"&&h!==null)throw new TypeError("Super expression must either be null or a function");d.prototype=Object.create(h&&h.prototype,{constructor:{value:d,writable:!0,configurable:!0}}),Object.defineProperty(d,"prototype",{writable:!1}),h&&C(d,h)})(F,m);var l,v,b,V,_=(b=F,V=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 d,h=x(b);if(V){var T=x(this).constructor;d=Reflect.construct(h,arguments,T)}else d=h.apply(this,arguments);return function(P,w){if(w&&(f(w)==="object"||typeof w=="function"))return w;if(w!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(D){if(D===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return D}(P)}(this,d)});function F(d){var h;if(function(P,w){if(!(P instanceof w))throw new TypeError("Cannot call a class as a function")}(this,F),(h=_.call(this,d)).supportsObserver=!d.scrollPosition&&d.useIntersectionObserver&&y(),h.supportsObserver){var T=d.threshold;h.observer=function(P){return A[P]=A[P]||new IntersectionObserver(E,{rootMargin:P+"px"}),A[P]}(T)}return h}return l=F,v=[{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 d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.props.scrollPosition,h=this.placeholder.getBoundingClientRect(),T=p().findDOMNode(this.placeholder).style,P=parseInt(T.getPropertyValue("margin-left"),10)||0,w=parseInt(T.getPropertyValue("margin-top"),10)||0;return{bottom:d.y+h.bottom+w,left:d.x+h.left+P,right:d.x+h.right+P,top:d.y+h.top+w}}},{key:"isPlaceholderInViewport",value:function(){if(typeof window>"u"||!this.placeholder)return!1;var d=this.props,h=d.scrollPosition,T=d.threshold,P=this.getPlaceholderBoundingBox(h),w=h.y+window.innerHeight,D=h.x,z=h.x+window.innerWidth,K=h.y;return K-T<=P.bottom&&w+T>=P.top&&D-T<=P.right&&z+T>=P.left}},{key:"updateVisibility",value:function(){this.isPlaceholderInViewport()&&this.props.onVisible()}},{key:"render",value:function(){var d=this,h=this.props,T=h.className,P=h.height,w=h.placeholder,D=h.style,z=h.width;if(w&&typeof w.type!="function")return s().cloneElement(w,{ref:function(H){return d.placeholder=H}});var K=function(H){for(var ie=1;ie<arguments.length;ie++){var G=arguments[ie]!=null?arguments[ie]:{};ie%2?g(Object(G),!0).forEach(function(fe){O(H,fe,G[fe])}):Object.getOwnPropertyDescriptors?Object.defineProperties(H,Object.getOwnPropertyDescriptors(G)):g(Object(G)).forEach(function(fe){Object.defineProperty(H,fe,Object.getOwnPropertyDescriptor(G,fe))})}return H}({display:"inline-block"},D);return z!==void 0&&(K.width=z),P!==void 0&&(K.height=P),s().createElement("span",{className:T,ref:function(H){return d.placeholder=H},style:K},w)}}],v&&R(l.prototype,v),Object.defineProperty(l,"prototype",{writable:!1}),F}(s().Component);S.propTypes={onVisible:i.PropTypes.func.isRequired,className:i.PropTypes.string,height:i.PropTypes.oneOfType([i.PropTypes.number,i.PropTypes.string]),placeholder:i.PropTypes.element,threshold:i.PropTypes.number,useIntersectionObserver:i.PropTypes.bool,scrollPosition:i.PropTypes.shape({x:i.PropTypes.number.isRequired,y:i.PropTypes.number.isRequired}),width:i.PropTypes.oneOfType([i.PropTypes.number,i.PropTypes.string])},S.defaultProps={className:"",placeholder:null,threshold:100,useIntersectionObserver:!0};const B=S;var k=n(296),L=n.n(k),q=n(96),M=n.n(q),j=function(m){var l=getComputedStyle(m,null);return l.getPropertyValue("overflow")+l.getPropertyValue("overflow-y")+l.getPropertyValue("overflow-x")};const U=function(m){if(!(m instanceof HTMLElement))return window;for(var l=m;l&&l instanceof HTMLElement;){if(/(scroll|auto)/.test(j(l)))return l;l=l.parentNode}return window};function W(m){return W=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},W(m)}var Q=["delayMethod","delayTime"];function Y(){return Y=Object.assign?Object.assign.bind():function(m){for(var l=1;l<arguments.length;l++){var v=arguments[l];for(var b in v)Object.prototype.hasOwnProperty.call(v,b)&&(m[b]=v[b])}return m},Y.apply(this,arguments)}function J(m,l){for(var v=0;v<l.length;v++){var b=l[v];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,(V=function(_,F){if(W(_)!=="object"||_===null)return _;var d=_[Symbol.toPrimitive];if(d!==void 0){var h=d.call(_,"string");if(W(h)!=="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(_)}(b.key),W(V)==="symbol"?V:String(V)),b)}var V}function Z(m,l){return Z=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,b){return v.__proto__=b,v},Z(m,l)}function oe(m,l){if(l&&(W(l)==="object"||typeof l=="function"))return l;if(l!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return pe(m)}function pe(m){if(m===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m}function N(m){return N=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(l){return l.__proto__||Object.getPrototypeOf(l)},N(m)}var ee=function(){return typeof window>"u"?0:window.scrollX||window.pageXOffset},$=function(){return typeof window>"u"?0:window.scrollY||window.pageYOffset};const ae=function(m){var l=function(v){(function(T,P){if(typeof P!="function"&&P!==null)throw new TypeError("Super expression must either be null or a function");T.prototype=Object.create(P&&P.prototype,{constructor:{value:T,writable:!0,configurable:!0}}),Object.defineProperty(T,"prototype",{writable:!1}),P&&Z(T,P)})(h,v);var b,V,_,F,d=(_=h,F=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 T,P=N(_);if(F){var w=N(this).constructor;T=Reflect.construct(P,arguments,w)}else T=P.apply(this,arguments);return oe(this,T)});function h(T){var P;if(function(D,z){if(!(D instanceof z))throw new TypeError("Cannot call a class as a function")}(this,h),(P=d.call(this,T)).useIntersectionObserver=T.useIntersectionObserver&&y(),P.useIntersectionObserver)return oe(P);var w=P.onChangeScroll.bind(pe(P));return T.delayMethod==="debounce"?P.delayedScroll=L()(w,T.delayTime):T.delayMethod==="throttle"&&(P.delayedScroll=M()(w,T.delayTime)),P.state={scrollPosition:{x:ee(),y:$()}},P.baseComponentRef=s().createRef(),P}return b=h,(V=[{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:ee(),y:$()}})}},{key:"render",value:function(){var T=this.props,P=(T.delayMethod,T.delayTime,function(D,z){if(D==null)return{};var K,H,ie=function(fe,Te){if(fe==null)return{};var Pe,$e,Ct={},Tt=Object.keys(fe);for($e=0;$e<Tt.length;$e++)Pe=Tt[$e],Te.indexOf(Pe)>=0||(Ct[Pe]=fe[Pe]);return Ct}(D,z);if(Object.getOwnPropertySymbols){var G=Object.getOwnPropertySymbols(D);for(H=0;H<G.length;H++)K=G[H],z.indexOf(K)>=0||Object.prototype.propertyIsEnumerable.call(D,K)&&(ie[K]=D[K])}return ie}(T,Q)),w=this.useIntersectionObserver?null:this.state.scrollPosition;return s().createElement(m,Y({forwardRef:this.baseComponentRef,scrollPosition:w},P))}}])&&J(b.prototype,V),Object.defineProperty(b,"prototype",{writable:!1}),h}(s().Component);return l.propTypes={delayMethod:i.PropTypes.oneOf(["debounce","throttle"]),delayTime:i.PropTypes.number,useIntersectionObserver:i.PropTypes.bool},l.defaultProps={delayMethod:"throttle",delayTime:300,useIntersectionObserver:!0},l};function ue(m){return ue=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},ue(m)}function ne(m,l){for(var v=0;v<l.length;v++){var b=l[v];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,(V=function(_,F){if(ue(_)!=="object"||_===null)return _;var d=_[Symbol.toPrimitive];if(d!==void 0){var h=d.call(_,"string");if(ue(h)!=="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(_)}(b.key),ue(V)==="symbol"?V:String(V)),b)}var V}function re(m,l){return re=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,b){return v.__proto__=b,v},re(m,l)}function ce(m){return ce=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(l){return l.__proto__||Object.getPrototypeOf(l)},ce(m)}var Me=function(m){(function(d,h){if(typeof h!="function"&&h!==null)throw new TypeError("Super expression must either be null or a function");d.prototype=Object.create(h&&h.prototype,{constructor:{value:d,writable:!0,configurable:!0}}),Object.defineProperty(d,"prototype",{writable:!1}),h&&re(d,h)})(F,m);var l,v,b,V,_=(b=F,V=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 d,h=ce(b);if(V){var T=ce(this).constructor;d=Reflect.construct(h,arguments,T)}else d=h.apply(this,arguments);return function(P,w){if(w&&(ue(w)==="object"||typeof w=="function"))return w;if(w!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(D){if(D===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return D}(P)}(this,d)});function F(d){return function(h,T){if(!(h instanceof T))throw new TypeError("Cannot call a class as a function")}(this,F),_.call(this,d)}return l=F,(v=[{key:"render",value:function(){return s().createElement(B,this.props)}}])&&ne(l.prototype,v),Object.defineProperty(l,"prototype",{writable:!1}),F}(s().Component);const qe=ae(Me);function ge(m){return ge=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},ge(m)}function Fe(m,l){for(var v=0;v<l.length;v++){var b=l[v];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,(V=function(_,F){if(ge(_)!=="object"||_===null)return _;var d=_[Symbol.toPrimitive];if(d!==void 0){var h=d.call(_,"string");if(ge(h)!=="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(_)}(b.key),ge(V)==="symbol"?V:String(V)),b)}var V}function Se(m,l){return Se=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,b){return v.__proto__=b,v},Se(m,l)}function le(m){if(m===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m}function he(m){return he=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(l){return l.__proto__||Object.getPrototypeOf(l)},he(m)}var me=function(m){(function(d,h){if(typeof h!="function"&&h!==null)throw new TypeError("Super expression must either be null or a function");d.prototype=Object.create(h&&h.prototype,{constructor:{value:d,writable:!0,configurable:!0}}),Object.defineProperty(d,"prototype",{writable:!1}),h&&Se(d,h)})(F,m);var l,v,b,V,_=(b=F,V=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 d,h=he(b);if(V){var T=he(this).constructor;d=Reflect.construct(h,arguments,T)}else d=h.apply(this,arguments);return function(P,w){if(w&&(ge(w)==="object"||typeof w=="function"))return w;if(w!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return le(P)}(this,d)});function F(d){var h;(function(z,K){if(!(z instanceof K))throw new TypeError("Cannot call a class as a function")})(this,F),h=_.call(this,d);var T=d.afterLoad,P=d.beforeLoad,w=d.scrollPosition,D=d.visibleByDefault;return h.state={visible:D},D&&(P(),T()),h.onVisible=h.onVisible.bind(le(h)),h.isScrollTracked=!!(w&&Number.isFinite(w.x)&&w.x>=0&&Number.isFinite(w.y)&&w.y>=0),h}return l=F,(v=[{key:"componentDidUpdate",value:function(d,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 d=this.props,h=d.className,T=d.delayMethod,P=d.delayTime,w=d.height,D=d.placeholder,z=d.scrollPosition,K=d.style,H=d.threshold,ie=d.useIntersectionObserver,G=d.width;return this.isScrollTracked||ie&&y()?s().createElement(B,{className:h,height:w,onVisible:this.onVisible,placeholder:D,scrollPosition:z,style:K,threshold:H,useIntersectionObserver:ie,width:G}):s().createElement(qe,{className:h,delayMethod:T,delayTime:P,height:w,onVisible:this.onVisible,placeholder:D,style:K,threshold:H,width:G})}}])&&Fe(l.prototype,v),Object.defineProperty(l,"prototype",{writable:!1}),F}(s().Component);me.propTypes={afterLoad:i.PropTypes.func,beforeLoad:i.PropTypes.func,useIntersectionObserver:i.PropTypes.bool,visibleByDefault:i.PropTypes.bool},me.defaultProps={afterLoad:function(){return{}},beforeLoad:function(){return{}},useIntersectionObserver:!0,visibleByDefault:!1};const St=me;function Ce(m){return Ce=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},Ce(m)}var Dn=["afterLoad","beforeLoad","delayMethod","delayTime","effect","placeholder","placeholderSrc","scrollPosition","threshold","useIntersectionObserver","visibleByDefault","wrapperClassName","wrapperProps"];function Pt(m,l){var v=Object.keys(m);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(m);l&&(b=b.filter(function(V){return Object.getOwnPropertyDescriptor(m,V).enumerable})),v.push.apply(v,b)}return v}function jt(m){for(var l=1;l<arguments.length;l++){var v=arguments[l]!=null?arguments[l]:{};l%2?Pt(Object(v),!0).forEach(function(b){qn(m,b,v[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(v)):Pt(Object(v)).forEach(function(b){Object.defineProperty(m,b,Object.getOwnPropertyDescriptor(v,b))})}return m}function qn(m,l,v){return(l=Ot(l))in m?Object.defineProperty(m,l,{value:v,enumerable:!0,configurable:!0,writable:!0}):m[l]=v,m}function Be(){return Be=Object.assign?Object.assign.bind():function(m){for(var l=1;l<arguments.length;l++){var v=arguments[l];for(var b in v)Object.prototype.hasOwnProperty.call(v,b)&&(m[b]=v[b])}return m},Be.apply(this,arguments)}function Fn(m,l){for(var v=0;v<l.length;v++){var b=l[v];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,Ot(b.key),b)}}function Ot(m){var l=function(v,b){if(Ce(v)!=="object"||v===null)return v;var V=v[Symbol.toPrimitive];if(V!==void 0){var _=V.call(v,"string");if(Ce(_)!=="object")return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(v)}(m);return Ce(l)==="symbol"?l:String(l)}function tt(m,l){return tt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,b){return v.__proto__=b,v},tt(m,l)}function Ue(m){return Ue=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(l){return l.__proto__||Object.getPrototypeOf(l)},Ue(m)}var nt=function(m){(function(d,h){if(typeof h!="function"&&h!==null)throw new TypeError("Super expression must either be null or a function");d.prototype=Object.create(h&&h.prototype,{constructor:{value:d,writable:!0,configurable:!0}}),Object.defineProperty(d,"prototype",{writable:!1}),h&&tt(d,h)})(F,m);var l,v,b,V,_=(b=F,V=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 d,h=Ue(b);if(V){var T=Ue(this).constructor;d=Reflect.construct(h,arguments,T)}else d=h.apply(this,arguments);return function(P,w){if(w&&(Ce(w)==="object"||typeof w=="function"))return w;if(w!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(D){if(D===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return D}(P)}(this,d)});function F(d){var h;return function(T,P){if(!(T instanceof P))throw new TypeError("Cannot call a class as a function")}(this,F),(h=_.call(this,d)).state={loaded:!1},h}return l=F,(v=[{key:"onImageLoad",value:function(){var d=this;return this.state.loaded?null:function(h){d.props.onLoad(h),d.props.afterLoad(),d.setState({loaded:!0})}}},{key:"getImg",value:function(){var d=this.props,h=(d.afterLoad,d.beforeLoad,d.delayMethod,d.delayTime,d.effect,d.placeholder,d.placeholderSrc,d.scrollPosition,d.threshold,d.useIntersectionObserver,d.visibleByDefault,d.wrapperClassName,d.wrapperProps,function(T,P){if(T==null)return{};var w,D,z=function(H,ie){if(H==null)return{};var G,fe,Te={},Pe=Object.keys(H);for(fe=0;fe<Pe.length;fe++)G=Pe[fe],ie.indexOf(G)>=0||(Te[G]=H[G]);return Te}(T,P);if(Object.getOwnPropertySymbols){var K=Object.getOwnPropertySymbols(T);for(D=0;D<K.length;D++)w=K[D],P.indexOf(w)>=0||Object.prototype.propertyIsEnumerable.call(T,w)&&(z[w]=T[w])}return z}(d,Dn));return s().createElement("img",Be({},h,{onLoad:this.onImageLoad()}))}},{key:"getLazyLoadImage",value:function(){var d=this.props,h=d.beforeLoad,T=d.className,P=d.delayMethod,w=d.delayTime,D=d.height,z=d.placeholder,K=d.scrollPosition,H=d.style,ie=d.threshold,G=d.useIntersectionObserver,fe=d.visibleByDefault,Te=d.width;return s().createElement(St,{beforeLoad:h,className:T,delayMethod:P,delayTime:w,height:D,placeholder:z,scrollPosition:K,style:H,threshold:ie,useIntersectionObserver:G,visibleByDefault:fe,width:Te},this.getImg())}},{key:"getWrappedLazyLoadImage",value:function(d){var h=this.props,T=h.effect,P=h.height,w=h.placeholderSrc,D=h.width,z=h.wrapperClassName,K=h.wrapperProps,H=this.state.loaded,ie=H?" lazy-load-image-loaded":"",G=H||!w?{}:{backgroundImage:"url(".concat(w,")"),backgroundSize:"100% 100%"};return s().createElement("span",Be({className:z+" lazy-load-image-background "+T+ie,style:jt(jt({},G),{},{color:"transparent",display:"inline-block",height:P,width:D})},K),d)}},{key:"render",value:function(){var d=this.props,h=d.effect,T=d.placeholderSrc,P=d.visibleByDefault,w=d.wrapperClassName,D=d.wrapperProps,z=this.getLazyLoadImage();return(h||T)&&!P||w||D?this.getWrappedLazyLoadImage(z):z}}])&&Fn(l.prototype,v),Object.defineProperty(l,"prototype",{writable:!1}),F}(s().Component);nt.propTypes={onLoad:i.PropTypes.func,afterLoad:i.PropTypes.func,beforeLoad:i.PropTypes.func,delayMethod:i.PropTypes.string,delayTime:i.PropTypes.number,effect:i.PropTypes.string,placeholderSrc:i.PropTypes.string,threshold:i.PropTypes.number,useIntersectionObserver:i.PropTypes.bool,visibleByDefault:i.PropTypes.bool,wrapperClassName:i.PropTypes.string,wrapperProps:i.PropTypes.object},nt.defaultProps={onLoad:function(){},afterLoad:function(){return{}},beforeLoad:function(){return{}},delayMethod:"throttle",delayTime:300,effect:"",placeholderSrc:null,threshold:100,useIntersectionObserver:!0,visibleByDefault:!1,wrapperClassName:""};const Bn=nt})(),kn.exports=o})();var $r=kn.exports;function Hr(e,t,n=[],o=!1,r=[]){if(r.length&&(t=t.filter(i=>r.indexOf(i)===-1)),!t||t.length===0)return;if(t.length===1)return t[0];if(!e)return t.indexOf("none")!==-1?"none":t[0];if(t.indexOf(e)!==-1)return e;const s=e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):null;if(s&&t.indexOf(s)!==-1)return s;for(const i of n)if(t.indexOf(i)!==-1)return i;if(!o&&e){const i=t.map(a=>a.indexOf("-")!==-1?a.slice(0,a.indexOf("-")):null).indexOf(e);if(i!==-1)return t[i];for(const a of n){const p=a.indexOf("-")!==-1?a.slice(0,a.indexOf("-")):null,y=p?t.indexOf(p):-1;if(y!==-1)return t[y]}}return t.indexOf("none")!==-1?"none":t.indexOf("@none")!==-1?"@none":t[0]}function Vn(e,t,n={}){const{strictFallback:o=!1,defaultText:r="",separator:s=`
|
|
48
|
+
`,fallbackLanguages:i=[],closest:a,skipLanguages:p}=n,y=Object.keys(e||{}),f=a?t:Hr(t,y,i,o,p);if(!e)return r;if(typeof e=="string")return e;const g=f?e[f]:void 0;if(g&&f){if(typeof g=="string")return g;if(g.length===1&&g[0]===""){const O=n.skipLanguages||[];return Vn(e,t,{...n,skipLanguages:[...O,f]})}return g.join(s)}return""}function Wr(e,t={}){return Vn(e,t.language||(typeof navigator<"u"?navigator.language:"en"),t)}const Yr=$r.LazyLoadComponent;function Nn(e){const{size:t,visible:n,classes:o,canvasId:r,figure:s}=e,i=(t==null?void 0:t.width)||128,a=(t==null?void 0:t.height)||(t==null?void 0:t.width)||128,p=u.jsx(zr,{...e}),y=u.jsx(Yr,{threshold:300,style:{height:a,width:i},visibleByDefault:n,children:r?u.jsx(Ve,{canvas:r,children:p}):p});return s?u.jsx("figure",{className:o==null?void 0:o.figure,children:y}):y}function zr({fallback:e,size:t,classes:n,showLabel:o,alt:r,dereference:s=!1}){const i=ye(),a=(t==null?void 0:t.width)||128,p=(t==null?void 0:t.height)||(t==null?void 0:t.width)||128,y=r||Wr(i==null?void 0:i.label)||"",f=vt({width:a,height:p},s);return!f||f.type!=="fixed"?u.jsx(u.Fragment,{children:e}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:n==null?void 0:n.imageWrapper,children:u.jsx("img",{className:n==null?void 0:n.img,src:f.id,alt:y})}),o?u.jsx(je,{as:"figcaption",className:n==null?void 0:n.label,children:i==null?void 0:i.label}):null]})}function Kr({flat:e,size:t,classes:n={},showLabel:o,figure:r,fallback:s}){var R,I,C,x,E,A;const i=c.useRef(null),{items:a,sequence:p,currentSequenceIndex:y,setSequenceIndex:f}=pt(),g={row:((R=n.selected)==null?void 0:R.row)||n.row,item:((I=n.selected)==null?void 0:I.item)||n.item,figure:((C=n.selected)==null?void 0:C.figure)||n.figure,img:((x=n.selected)==null?void 0:x.img)||n.img,label:((E=n.selected)==null?void 0:E.label)||n.label,imageWrapper:((A=n.selected)==null?void 0:A.imageWrapper)||n.imageWrapper};c.useLayoutEffect(()=>{if(!i.current)return;const S=i.current.querySelector("[data-selected=true]");S&&S.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},[y]);const O=[];for(const S of p){const B=[],k=p[y]===S;for(const L of S){const q=a[L];B.push(u.jsx("div",{className:k?g.item:n.item,children:u.jsx(Nn,{classes:k?g:n,canvasId:q.id,size:t,showLabel:o,figure:r,placeholder:u.jsx("div",{style:{height:128,width:128}}),fallback:s})},L))}if(e){O.push(B);continue}O.push(u.jsx("div",{onClick:L=>{f(p.indexOf(S))},"data-selected":k,className:k?g.row:n.row,children:B}))}return u.jsx("div",{ref:i,className:n.container,children:O})}function Qr({annotation:e,children:t}){return u.jsx(we,{value:{annotation:e},children:t})}function Gr({annotationPage:e,children:t}){return u.jsx(we,{value:{annotationPage:e},children:t})}function Xr({collection:e,children:t}){return u.jsx(we,{value:{collection:e},children:t})}function Jr(e,t={}){return Je(t)}function Zr(e,t=!1){}function eo(e){const n=xe().manifest,o=e?e.map(r=>typeof r=="string"?r:r==null?void 0:r.id):[];return se(r=>{const s=n?r.iiif.entities.Manifest[n]:void 0,i=(s==null?void 0:s.items)||[];if(typeof e>"u")return i;const a=[];for(const p of(s==null?void 0:s.items)||[])o.indexOf(p.id)!==-1&&a.push(p);return a},[o.join("/")])}function to(e,t=[]){const{id:n,selector:o}=e,r=xe(),s=n||r.collection,i=se(a=>s?a.iiif.entities.Collection[s]:void 0,[s]);return c.useMemo(()=>{if(i)return o?o(i):i},[i,o,...t])}function no(e,t,n,o,r=[]){const s=te(),i=c.useMemo(()=>Qt(s),[s]);c.useEffect(()=>{const a=e;return a?(i.addEventListener(a,t,n,o),()=>{i.removeEventListener(a,t,n)}):()=>{}},[i,e,t,...r])}function ro(e,t){const{id:n,isLoaded:o,error:r,resource:s,requestId:i,cached:a}=at(e,t);return{id:n,isLoaded:o,error:r,manifest:s,requestId:i,cached:a}}function _n({cacheKey:e}={}){const t=ye(),n=Je(),o=te(),r=De(),[s,i]=c.useState(void 0),[a,p]=c.useState(!1),[y,f]=c.useState("idle"),[g,O]=c.useState(void 0),R=t?t.id:"undefined",I=c.useMemo(()=>{try{if(t&&n.length){const x=n[0],E=o.get(x.body[0]),S=Ee.getImageServices(E)[0];return S&&r.loadServiceSync({id:S.id||S["@id"],width:S.width||t.width,height:S.height||t.height})||void 0}}catch(x){console.error(x)}},[R,e,t]),C=y==="success"&&s?s:I;return c.useEffect(()=>{(async()=>{try{if(t&&n.length){const x=n[0],E=o.get(x.body[0]),S=Ee.getImageServices(E)[0];if(!S)return;p(!0),f("loading");try{const B=await r.loadService({id:S.id||S["@id"],width:S.width||t.width,height:S.height||t.height})||void 0;i(B),f("success"),p(!1)}catch(B){f("error"),O(B)}}}catch(x){f("error"),O(x)}})()},[R,e]),c.useMemo(()=>({data:C,isFetching:a,status:y,error:g}),[C,a,y,g])}function oo(){const e=_n();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}}function io(){const e=ve();return e?e.service.find(t=>t.profile==="SearchService1"||t.profile==="http://iiif.io/api/search/1/search"):void 0}function so(){const e=te();return c.useMemo(()=>st.createStylesHelper(e),[e])}exports.AnnotationContext=Qr;exports.AnnotationPageContext=Gr;exports.CanvasAnnotations=qr;exports.CanvasContext=Ve;exports.CanvasPanel=de;exports.CollectionContext=Xr;exports.CombinedMetadata=Fr;exports.ContextBridge=Dt;exports.Image=An;exports.ImageServiceLoaderContext=rn;exports.InnerViewerProvider=Vt;exports.LanguageProvider=kr;exports.LanguageString=En;exports.LocaleString=je;exports.ManifestContext=Rt;exports.ManifestMetadata=Ur;exports.MediaPlayerProvider=bt;exports.Metadata=xt;exports.RangeContext=Lt;exports.ReactVaultContext=ke;exports.ResourceProvider=we;exports.ResourceReactContext=Ke;exports.SequenceThumbnails=Kr;exports.SimpleViewerProvider=Nt;exports.SimpleViewerReactContext=_e;exports.SingleCanvasThumbnail=Nn;exports.VaultProvider=Qe;exports.ViewerPresetContext=Xe;exports.VirtualAnnotationProvider=$t;exports.VisibleCanvasReactContext=Ne;exports.emptyActions=Zt;exports.emptyStrategy=en;exports.findAllCanvasesInRange=ct;exports.findFirstCanvasFromRange=At;exports.findManifestSelectedRange=Qn;exports.findSelectedRange=lt;exports.flattenAnnotationPageIds=tn;exports.formatTime=gn;exports.get3dStrategy=un;exports.getImageStrategy=cn;exports.getManifestSequence=ft;exports.getParsedTargetSelector=gt;exports.getRenderingStrategy=pn;exports.getTextualContentStrategy=fn;exports.getVideoStrategy=dn;exports.getVisibleCanvasesFromCanvasId=Gn;exports.parseSpecificResource=xr;exports.unknownResponse=ze;exports.unsupportedStrategy=X;exports.useAnnotation=yt;exports.useAnnotationPage=Xt;exports.useAnnotationPageManager=mt;exports.useAnnotationsAtTime=Jr;exports.useCanvas=ye;exports.useCanvasClock=Zr;exports.useCanvasSequence=kt;exports.useCanvasSubset=eo;exports.useClosestLanguage=Mn;exports.useCollection=to;exports.useContextBridge=_t;exports.useCreateLocaleString=Vr;exports.useDispatch=qt;exports.useEventListener=no;exports.useExistingVault=Ge;exports.useExternalCollection=ro;exports.useExternalManifest=Mt;exports.useExternalResource=at;exports.useIIIFLanguage=et;exports.useImage=wt;exports.useImageService=_n;exports.useImageServiceLoader=De;exports.useImageTile=oo;exports.useLoadImageService=on;exports.useLocaleString=Rn;exports.useManifest=ve;exports.useMediaActions=Lr;exports.useMediaElements=Ar;exports.useMediaState=Rr;exports.usePaintables=an;exports.usePaintingAnnotations=Je;exports.useRange=dt;exports.useRenderingStrategy=hn;exports.useResourceContext=xe;exports.useResourceEvents=ht;exports.useResources=nn;exports.useSearchService=io;exports.useSimpleMediaPlayer=Ze;exports.useSimpleViewer=pt;exports.useStyleHelper=so;exports.useStyles=Ae;exports.useThumbnail=vt;exports.useVault=te;exports.useVaultEffect=yn;exports.useVaultSelector=se;exports.useViewerPreset=Ht;exports.useVirtualAnnotationPage=Ft;exports.useVirtualAnnotationPageContext=Ut;exports.useVisibleCanvases=ut;Object.keys(Le).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>Le[e]})});
|
|
49
49
|
//# sourceMappingURL=index.js.map
|