react-iiif-vault 1.0.7 → 1.0.9

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.
Files changed (65) hide show
  1. package/.build/types/canvas-panel/Viewer.d.ts +1 -1
  2. package/.build/types/canvas-panel/index.d.ts +2 -1
  3. package/.build/types/canvas-panel/render/Audio.d.ts +1 -1
  4. package/.build/types/canvas-panel/render/Canvas.d.ts +2 -2
  5. package/.build/types/canvas-panel/render/CanvasBackground.d.ts +1 -1
  6. package/.build/types/canvas-panel/render/DefaultCanvasFallback.d.ts +1 -1
  7. package/.build/types/canvas-panel/render/Image.d.ts +1 -1
  8. package/.build/types/canvas-panel/render/Model.d.ts +1 -1
  9. package/.build/types/canvas-panel/render/Video.d.ts +1 -1
  10. package/.build/types/canvas-panel/render/VideoYouTube.d.ts +1 -1
  11. package/.build/types/components/CanvasAnnotations.d.ts +10 -0
  12. package/.build/types/components/CombinedMetadata.d.ts +4 -0
  13. package/.build/types/components/Image.d.ts +15 -0
  14. package/.build/types/components/ManifestMetadata.d.ts +4 -0
  15. package/.build/types/components/Metadata.d.ts +39 -0
  16. package/.build/types/components/SequenceThumbnails.d.ts +29 -0
  17. package/.build/types/components/SingleCanvasThumbnail.d.ts +20 -0
  18. package/.build/types/context/AnnotationContext.d.ts +1 -1
  19. package/.build/types/context/AnnotationPageContext.d.ts +1 -1
  20. package/.build/types/context/CanvasContext.d.ts +1 -1
  21. package/.build/types/context/CollectionContext.d.ts +1 -1
  22. package/.build/types/context/ContextBridge.d.ts +1 -1
  23. package/.build/types/context/ManifestContext.d.ts +1 -1
  24. package/.build/types/context/MediaContext.d.ts +1 -1
  25. package/.build/types/context/RangeContext.d.ts +1 -1
  26. package/.build/types/context/ResourceContext.d.ts +2 -2
  27. package/.build/types/context/VaultContext.d.ts +1 -1
  28. package/.build/types/demo/media-controls.d.ts +1 -1
  29. package/.build/types/demo/viewer-controls.d.ts +1 -1
  30. package/.build/types/features/rendering-strategy/3d-strategy.d.ts +1 -1
  31. package/.build/types/features/rendering-strategy/image-strategy.d.ts +1 -1
  32. package/.build/types/features/rendering-strategy/resource-types.d.ts +7 -7
  33. package/.build/types/features/rendering-strategy/strategies.d.ts +5 -5
  34. package/.build/types/features/rendering-strategy/textual-content-strategy.d.ts +1 -1
  35. package/.build/types/hooks/useEventListener.d.ts +1 -1
  36. package/.build/types/hooks/useExternalResource.d.ts +1 -1
  37. package/.build/types/hooks/useImage.d.ts +10 -0
  38. package/.build/types/hooks/useLoadImageService.d.ts +1 -1
  39. package/.build/types/hooks/useRenderingStrategy.d.ts +3 -3
  40. package/.build/types/hooks/useSimpleMediaPlayer.d.ts +2 -2
  41. package/.build/types/hooks/useVirtualAnnotationPageContext.d.ts +81 -81
  42. package/.build/types/index.d.ts +8 -0
  43. package/.build/types/utility/i18n-utils.d.ts +8 -6
  44. package/.build/types/viewers/SimpleViewerContext.d.ts +2 -2
  45. package/.build/types/viewers/SimpleViewerContext.hooks.d.ts +2 -0
  46. package/.build/types/viewers/SimpleViewerContext.types.d.ts +6 -4
  47. package/dist/bundle/cjs/index.js +7 -6
  48. package/dist/bundle/cjs/index.js.map +1 -1
  49. package/dist/bundle/esm/index.mjs +2388 -1171
  50. package/dist/bundle/esm/index.mjs.map +1 -1
  51. package/dist/canvas-panel/cjs/canvas-panel.js +5 -5
  52. package/dist/canvas-panel/cjs/canvas-panel.js.map +1 -1
  53. package/dist/canvas-panel/esm/canvas-panel.mjs +581 -520
  54. package/dist/canvas-panel/esm/canvas-panel.mjs.map +1 -1
  55. package/dist/index.umd.js +78 -76
  56. package/dist/index.umd.js.map +1 -1
  57. package/dist/react17/cjs/index.js +7 -6
  58. package/dist/react17/cjs/index.js.map +1 -1
  59. package/dist/react17/esm/index.mjs +2388 -1171
  60. package/dist/react17/esm/index.mjs.map +1 -1
  61. package/dist/utils/cjs/utils.js +1 -1
  62. package/dist/utils/cjs/utils.js.map +1 -1
  63. package/dist/utils/esm/utils.mjs +108 -107
  64. package/dist/utils/esm/utils.mjs.map +1 -1
  65. package/package.json +24 -22
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),u=require("react"),F=require("@atlas-viewer/atlas"),K=require("@iiif/helpers/vault"),pe=require("@iiif/helpers/styles"),ne=require("@iiif/helpers/annotation-targets"),ze=require("@iiif/helpers"),ve=require("@atlas-viewer/iiif-image-api"),Ke=require("@iiif/helpers/thumbnail");function We(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const X=We(u);function re(e,t){return re=Object.setPrototypeOf||function(r,o){return r.__proto__=o,r},re(e,t)}function Ge(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,re(e,t)}var Qe=function(t,n){return t===void 0&&(t=[]),n===void 0&&(n=[]),t.length!==n.length||t.some(function(r,o){return!Object.is(r,n[o])})},ge={error:null},Je=function(e){Ge(t,e);function t(){for(var r,o=arguments.length,i=new Array(o),s=0;s<o;s++)i[s]=arguments[s];return r=e.call.apply(e,[this].concat(i))||this,r.state=ge,r.resetErrorBoundary=function(){for(var a,d=arguments.length,f=new Array(d),l=0;l<d;l++)f[l]=arguments[l];r.props.onReset==null||(a=r.props).onReset.apply(a,f),r.reset()},r}t.getDerivedStateFromError=function(o){return{error:o}};var n=t.prototype;return n.reset=function(){this.setState(ge)},n.componentDidCatch=function(o,i){var s,a;(s=(a=this.props).onError)==null||s.call(a,o,i)},n.componentDidUpdate=function(o,i){var s=this.state.error,a=this.props.resetKeys;if(s!==null&&i.error!==null&&Qe(o.resetKeys,a)){var d,f;(d=(f=this.props).onResetKeysChange)==null||d.call(f,o.resetKeys,a),this.reset()}},n.render=function(){var o=this.state.error,i=this.props,s=i.fallbackRender,a=i.FallbackComponent,d=i.fallback;if(o!==null){var f={error:o,resetErrorBoundary:this.resetErrorBoundary};if(X.isValidElement(d))return d;if(typeof s=="function")return s(f);if(a)return X.createElement(a,f);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},t}(X.Component);const Ze={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0,annotationPage:void 0},ie=u.createContext(Ze),D=()=>u.useContext(ie);function G({value:e,children:t}){const n=D(),r=u.useMemo(()=>({...n,...e}),[e,n]);return c.jsx(ie.Provider,{value:r,children:t})}const Q=u.createContext({vault:null,setVaultInstance:e=>{}});function ye({vault:e,vaultOptions:t,useGlobal:n,resources:r,children:o}){const[i,s]=u.useState(()=>e||(n?K.globalVault(t):t?new K.Vault(t):new K.Vault));return c.jsx(Q.Provider,{value:{vault:i,setVaultInstance:s},children:c.jsx(G,{value:r||{},children:o})})}const A=()=>{const{vault:e}=u.useContext(Q);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};function Xe(e,{noCache:t=!1}={}){const n=typeof e=="string"?e:e.id,r=A(),[o,i]=u.useState(n),[s,a]=u.useState(void 0),d=u.useMemo(()=>r.get(n,{skipSelfReturn:!0})||void 0,[n,r]),[f,l]=u.useState(d);return u.useEffect(()=>{(async()=>{try{const g=d&&!t?d:await r.load(n),v=g?g.id||g["@id"]:null;g&&o!==v&&i(v),l(g)}catch(g){a(g)}})()},[n,t]),{isLoaded:!!f,id:o,requestId:n,error:s,resource:f,cached:!!(f&&f===d)}}function et(e,t){const{id:n,isLoaded:r,error:o,resource:i,requestId:s,cached:a}=Xe(e,t);return{id:n,isLoaded:r,error:o,manifest:i,requestId:s,cached:a}}function tt({manifest:e,children:t}){return c.jsx(G,{value:{manifest:e},children:t})}function se({canvas:e,children:t}){return c.jsx(G,{value:{canvas:e},children:t})}function I(e,t=[]){const n=A(),[r,o]=u.useState(()=>e(n.getState(),n));return u.useEffect(()=>n.subscribe(i=>e(i,n),i=>{o(i)},!1),t),r}const J=u.createContext([]);function xe(){const e=u.useContext(J);return I(t=>e.map(n=>t.iiif.entities.Canvas[n]).filter(Boolean),[e])}function _(e={},t=[]){const{id:n,selector:r}=e,o=D();A();const i=n||o.manifest,s=I(a=>i?a.iiif.entities.Manifest[i]:void 0,[i]);return u.useMemo(()=>{if(s)return r?r(s):s},[s,r,...t])}function nt({range:e,children:t}){return c.jsx(G,{value:{range:e},children:t})}function be(e,t){var r;const n=[];for(const o of t.items)if(o.type==="SpecificResource"&&((r=o.source)==null?void 0:r.type)==="Canvas"&&(o.source.id.indexOf("#")!==-1?n.push({id:o.source.id.split("#")[0],type:"Canvas"}):n.push(o.source)),o.type==="Range"&&n.push(...be(e,e.get(o))),o.type==="SpecificResource"){const i=typeof o.source=="string"?o.source:o.source.id;n.push({id:i,type:"Canvas"})}return n}function rt(e,t,{disablePaging:n,skipNonPaged:r}={}){const o=t.behavior,i=o.includes("paged"),s=i?!1:o.includes("continuous"),a=i||s?!1:o.includes("individuals"),d=t.type==="Manifest"?t.items:be(e,t);if(s)return[d,[d.map((p,m)=>m)]];if(a||!i||n)return[d,d.map((p,m)=>[m])];const f=[];let l=[];const g=()=>{l.length&&(f.push([...l]),l=[])};let v=0,y=!1;for(let p=0;p<d.length;p++){const m=e.get(d[p]);if(m.behavior.includes("non-paged")){p===v&&v++,r||(g(),f.push([p]),g());continue}if(p===v||m.behavior.includes("facing-pages")){l.length&&(y=!0),g(),f.push([p]),g();continue}if(l.push(p),y){g(),y=!1;continue}l.length>1&&g()}return l.length&&g(),[d,f]}function ot(e={},t=[]){const{id:n,selector:r}=e,o=D(),i=n||o.range,s=I(a=>i?a.iiif.entities.Range[i]:void 0,[i]);return u.useMemo(()=>{if(s)return r?r(s):s},[s,r,...t])}function it({startCanvas:e,disablePaging:t}){var p;const n=A(),r=_(),o=ot(),[i,s]=u.useState(void 0),a=o||r;if(!a)throw new Error("Nothing selected");const[d,f]=u.useMemo(()=>rt(n,a,{disablePaging:t}),[n,a]),l=u.useCallback(m=>{const b=f.findIndex(x=>x.includes(m));s(b===-1?0:b)},[d,f]),g=u.useCallback(m=>{const b=d.findIndex(x=>x.id===m);b!==-1?l(b):s(0)},[d,f]),v=u.useCallback(()=>{s(m=>m>=f.length?m:m+1)},[f]),y=u.useCallback(()=>{s(m=>m<=0?0:m-1)},[f]);return typeof i>"u"&&(e?g(e):s(0)),{visibleItems:((p=f[i])==null?void 0:p.map(m=>d[m].id))||[],cursor:i,items:d,sequence:f,setSequenceIndex:s,setCanvasIndex:l,setCanvasId:g,next:v,previous:y}}const B=()=>{},Z=u.createContext({setCurrentCanvasId:B,setCurrentCanvasIndex:B,nextCanvas:B,previousCanvas:B,items:[],sequence:[],setSequenceIndex:B,currentSequenceIndex:0});function st(e){const t=_(),{cursor:n,visibleItems:r,next:o,sequence:i,items:s,setCanvasIndex:a,setCanvasId:d,previous:f,setSequenceIndex:l}=it({startCanvas:e.startCanvas,disablePaging:e.pagingEnabled===!1}),g=u.useMemo(()=>({sequence:i,items:s,setCurrentCanvasId:d,nextCanvas:o,previousCanvas:f,totalCanvases:s.length,setCurrentCanvasIndex:a,setSequenceIndex:l,currentSequenceIndex:n}),[i,s,d,o,f,s,a,l,n]);return t?r.length===0?null:c.jsx(Z.Provider,{value:g,children:c.jsx(J.Provider,{value:r,children:c.jsx(se,{canvas:r[0],children:e.children})})}):(console.warn("The manifest passed to the provider is not a valid IIIF manifest."),c.jsx("div",{children:"Sorry, something went wrong."}))}function at(e){const t=et(e.manifest);if(!t)return console.warn("The manifest passed to the provider is not a valid IIIF manifest."),c.jsx("div",{children:"Sorry, something went wrong."});if(t.error)return c.jsx("div",{children:t.error.toString()});if(!t.isLoaded)return c.jsx("div",{children:"Loading..."});const n=c.jsx(st,{...e,children:e.children});return c.jsx(tt,{manifest:t.id,children:e.rangeId?c.jsx(nt,{range:e.rangeId,children:n}):n})}function ut(){return u.useContext(Z)}function ct(){return{VaultContext:u.useContext(Q),ResourceContext:u.useContext(ie),SimpleViewerReactContext:u.useContext(Z),VisibleCanvasReactContext:u.useContext(J)}}function lt(e){return c.jsx(ye,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:c.jsx(J.Provider,{value:e.bridge.VisibleCanvasReactContext,children:c.jsx(Z.Provider,{value:e.bridge.SimpleViewerReactContext,children:e.children})})})}const R=function(e){return function(){const t={type:e,getType:()=>e,toString:()=>e};return(n,r)=>({...t,...n!==void 0&&{payload:n},...r!==void 0&&{meta:r}})}},dt="@iiif/IMPORT_ENTITIES",ft="@iiif/MODIFY_ENTITY_FIELD",gt="@iiif/REORDER_ENTITY_FIELD",ht="@iiif/ADD_REFERENCE",mt="@iiif/UPDATE_REFERENCE",pt="@iiif/REMOVE_REFERENCE",vt="@iiif/ADD_METADATA",yt="@iiif/REMOVE_METADATA",xt="@iiif/UPDATE_METADATA",bt="@iiif/REORDER_METADATA",Ct=R(dt)(),St=R(ft)(),wt=R(gt)(),Mt=R(ht)(),jt=R(pt)(),Pt=R(mt)(),Et=R(vt)(),At=R(xt)(),It=R(yt)(),Tt=R(bt)(),ee={importEntities:Ct,modifyEntityField:St,reorderEntityField:wt,addReference:Mt,removeReference:jt,updateReference:Pt,addMetadata:Et,removeMetadata:It,updateMetadata:At,reorderMetadata:Tt};function Rt(){const t=A().getStore();return u.useMemo(()=>n=>t.dispatch(n),[t])}function he(e){return typeof e!="string"&&e&&e.bindToVault}function Vt(){const e=A(),t=u.useRef([]),n=Rt(),r=u.useMemo(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);u.useLayoutEffect(()=>{const a={id:r,type:"AnnotationPage",behavior:[],label:null,thumbnail:[],summary:null,requiredStatement:null,metadata:[],rights:null,provider:[],items:[],seeAlso:[],homepage:[],rendering:[],service:[]};n(ee.importEntities({entities:{AnnotationPage:{[a.id]:a}}}))},[r]);const o=I(a=>r?a.iiif.entities.AnnotationPage[r]:null,[r]),i=u.useCallback((a,d)=>{if(r){if(he(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 f=e.get({id:r,type:"AnnotationPage"}),l=e.get({id:a,type:"Annotation"});f&&l&&(f.items.find(g=>g.id===l.id)||n(ee.addReference({id:r,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"},index:d})))}},[r]),s=u.useCallback(a=>{r&&(he(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:r,type:"AnnotationPage"})&&n(ee.removeReference({id:r,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"}})))},[r]);return[o,{addAnnotation:i,removeAnnotation:s}]}const Ce=u.createContext(null);function kt(){const e=u.useContext(Ce);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function Ot({children:e}){const[t,{addAnnotation:n,removeAnnotation:r}]=Vt();return c.jsx(Ce.Provider,{value:u.useMemo(()=>({fullPage:t,addAnnotation:n,removeAnnotation:r}),[t]),children:e})}function Lt({width:e,style:t,height:n,error:r,resetErrorBoundary:o}){return c.jsxs("div",{style:{width:e,height:n,minHeight:500,...t||{},background:"#f9f9f9"},children:[c.jsx("h3",{children:"Error occurred"}),c.jsx("p",{children:r.message}),c.jsx("button",{onClick:o,children:"Reset"})]})}const ae=u.createContext(null);function Ft(){return u.useContext(ae)}const Se=u.createContext(()=>{}),we=u.createContext(()=>{});function N(e,t,n,r,o=[]){const i=u.useContext(e==="portal"?we:Se);u.useEffect(()=>(e!=="none"&&i(t,n,r),()=>{i(t,null)}),[t,e,i,...o])}function O(e={},t=[]){const{id:n,selector:r}=e,o=D(),i=n||o.canvas,s=I(a=>i?a.iiif.entities.Canvas[i]:void 0,[i]);return u.useMemo(()=>{if(s)return r?r(s):s},[s,r,...t])}const Me=u.createContext(()=>{});function Nt(e){const t=O(),n=u.useContext(Me);u.useEffect(()=>t&&t.id?(n(t.id,e),()=>n(t.id,-1)):()=>{},[t,e])}function Dt({children:e,errorFallback:t,outerContainerProps:n={},worldScale:r,...o}){const[i,s]=u.useState(),a=ct(),d=t||Lt,[f,l]=u.useState({}),g=Object.entries(f),[v,y]=u.useState({}),p=Object.entries(v),[m,b]=u.useState({}),x=u.useMemo(()=>r||Math.max(...Object.values(m)),[m]),j=u.useMemo(()=>({maxOverZoom:x||1,...o.runtimeOptions||{}}),[x,o.runtimeOptions]),S=u.useCallback((w,P)=>{b(T=>{if(P===-1){const{[w]:h,...V}=T;return V}return{...T,[w]:P}})},[]),U=u.useCallback((w,P,T)=>{l(({[w]:h,...V})=>P?{...V,[w]:{element:P,props:T}}:V)},[]),H=u.useCallback((w,P,T)=>{y(({[w]:h,...V})=>P?{...V,[w]:{element:P,props:T}}:V)},[]);return c.jsxs(Je,{resetKeys:[],fallbackRender:w=>c.jsx(d,{...o,...w}),children:[c.jsx(F.AtlasAuto,{...o,containerProps:{style:{position:"relative"},...o.containerProps||{}},htmlChildren:c.jsx(c.Fragment,{children:g.map(([w,{element:P,props:T}])=>c.jsx(u.Fragment,{children:c.jsx(P,{...T||{}})},w))}),onCreated:w=>{s(w),o.onCreated&&o.onCreated(w)},runtimeOptions:j,children:c.jsx(ae.Provider,{value:i,children:c.jsx(Me.Provider,{value:S,children:c.jsx(Se.Provider,{value:U,children:c.jsx(we.Provider,{value:H,children:c.jsx(lt,{bridge:a,children:c.jsx(F.ModeContext.Provider,{value:o.mode||"explore",children:c.jsx(Ot,{children:e})})})})})})})}),c.jsx("div",{children:p.map(([w,{element:P,props:T}])=>c.jsx(u.Fragment,{children:c.jsx(P,{...T||{}})},w))})]})}const Y={},je={get(e){return e},setMetaValue([e,t,n],r){const o=je.getResourceMeta(e,t),i=o?o[n]:void 0,s=typeof r=="function"?r(i):r;Y[e]={...Y[e]||{},[t]:{...(Y[e]||{})[t]||{},[n]:s}}},getResourceMeta:(e,t)=>{const n=Y[e];if(n)return t?n[t]:n}};function _t(e=je){return{addEventListener(t,n,r,o){if(t)return e.setMetaValue([t.id,"eventManager",n],i=>{const s=i||[];for(const a of s)if(a.callback===r)return s;return[...s,{callback:r,scope:o}]}),r},removeEventListener(t,n,r){t&&e.setMetaValue([t.id,"eventManager",n],o=>(o||[]).filter(i=>i.callback!==r))},getListenersAsProps(t,n){const r=typeof t=="string"?{id:t}:t;if(!r||!r.id)return{};const o=e.getResourceMeta(r.id,"eventManager"),i={};if(o&&r)for(const s of Object.keys(o))i[s]=a=>{const d=e.get(r);for(const{callback:f,scope:l}of o[s]||[])(!l||n&&l.indexOf(n)!==-1)&&f(a,d)};return i}}}function Pe(e,t){const n=A(),r=u.useMemo(()=>_t(n),[n]),o=I(()=>e&&e.id?n.getResourceMeta(e.id,"eventManager"):null,[e]);return u.useMemo(()=>e?r.getListenersAsProps(e,t):{},[o,e,n,t])}function W(e,t){const n=A(),r=u.useMemo(()=>pe.createStylesHelper(n),[n]);return I(()=>{if(!e)return null;const o=r.getAppliedStyles(e.id);return o?t?o[t]:o:void 0},[e,t])}function Ee(e={},t=[]){const{id:n,selector:r}=e,o=D(),i=A(),s=n||o.annotation,a=I(f=>s?f.iiif.entities.Annotation[s]:void 0,[s]),d=I(f=>a&&a.body?a.body.map(l=>l?l.type==="SpecificResource"?{...l,source:i.get(l)}:l?f.iiif.entities[l.type][l.id]:null:null).filter(Boolean):[],[a]);return u.useMemo(()=>{if(!a)return;const f={...a,body:d,target:ne.expandTarget(a.target,{typeMap:i.getState().iiif.mapping})};return r?r(f):f},[a,r,d,...t])}const Ae=({id:e,style:t,className:n,interactive:r})=>{const o=Ee({id:e}),i=W(o,"atlas"),s=W(o,"html"),a=Pe(o,["atlas"]),d=O(),f=u.useMemo(()=>F.mergeStyles(t,i),[t,i]);return d&&o&&o.target&&o.target.selector&&o.target.selector.type==="BoxSelector"&&o.target.source&&(o.target.source.id===d.id||o.target.source===d.id)?c.jsx(F.RegionHighlight,{id:o.id,isEditing:!0,region:o.target.selector.spatial,style:f,className:(s==null?void 0:s.className)||n,interactive:!!(s!=null&&s.href||r),href:(s==null?void 0:s.href)||null,title:(s==null?void 0:s.title)||null,hrefTarget:(s==null?void 0:s.target)||null,onClick:()=>{},...a}):null};function Ut(e={},t=[]){const{id:n,selector:r}=e,o=D(),i=n||o.annotationPage,s=I(a=>i?a.iiif.entities.AnnotationPage[i]:void 0,[i]);return u.useMemo(()=>{if(s)return r?r(s):s},[s,...t])}const oe=({className:e,page:t})=>{var i;const n=Ut({id:t.id})||t,r=W(n,"atlas"),o=W(n,"html");return I(s=>n.id?s.iiif.entities.AnnotationPage[n.id]:null,[]),c.jsx(u.Fragment,{children:(i=n.items)==null?void 0:i.map(s=>c.jsx(Ae,{id:s.id,style:r,className:(o==null?void 0:o.className)||e},s.id))})};function Ie({id:e,image:t,thumbnail:n,isStatic:r,x:o=0,y:i=0,children:s,selector:a,onClick:d,enableSizes:f}){var g,v;const l=u.useMemo(()=>{if(!(!a||a.spatial.x===0&&a.spatial.y===0))return a.spatial},[a]);return c.jsx("world-object",{x:o+t.target.spatial.x,y:i+t.target.spatial.y,width:t.target.spatial.width,height:t.target.spatial.height,onClick:d,children:t.service?c.jsxs(u.Fragment,{children:[c.jsx(F.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:f,x:0,y:0,width:(g=t.target)==null?void 0:g.spatial.width,height:(v=t.target)==null?void 0:v.spatial.height,crop:l}),s]},"service"):c.jsxs(u.Fragment,{children:[c.jsx("world-image",{onClick:d,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:l}),s]},"no-service")},e+(t.service?"server":"no-service"))}function Te(e,t){const{selector:n,source:r}=ze.expandTarget(t);if(r.id!==e.id)return[null,r];const o={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:o.spatial}:n:null,r]}const qt={makeChoice:()=>{}},te={type:"unknown"},M=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),$t=(e,t)=>({type:"empty",width:e,height:t,annotations:{pages:[]},image:null,images:[]});function Bt(e,t){var r;const n=(r=e==null?void 0:e.iiif)==null?void 0:r.meta[t];return n?n.annotationPageManager:null}function Ht(e,t){return I(n=>{const r=[];if(!e)return r;const o=Object.keys(n.iiif.entities.AnnotationPage);for(const i of o)if(!t||t.indexOf(i)!==-1){const s=Bt(n,i);s&&s.views&&s.views[e]&&r.push(i)}return r},[e,t])}function Yt({canvas:e,manifest:t,all:n,canvases:r}){const o=[];if(t)for(const i of t.annotations)o.indexOf(i.id)===-1&&o.push(i.id);if(n){if(r&&r.length)for(const i of r)for(const s of i.annotations)o.indexOf(s.id)===-1&&o.push(s.id)}else if(e)for(const i of e.annotations)o.indexOf(i.id)===-1&&o.push(i.id);return o}function zt(e,t){var r;const n=(r=e==null?void 0:e.iiif)==null?void 0:r.meta[t];return n?n.annotationPageManager:null}function Kt(e,t={}){const n=A(),r=_(),o=O(),i=xe(),s=u.useMemo(()=>Yt({all:t.all,manifest:r,canvas:o,canvases:i}),[t.all,o,i,r]),a=Ht(e,t.all?void 0:s),d=u.useCallback(l=>{e&&n.setMetaValue([l,"annotationPageManager","views"],g=>g&&!g[e]?g:{...g||{},[e]:!1})},[e,n]),f=u.useCallback((l,g={})=>{if(!e)return;const v=n.getState(),y=[];if(g!=null&&g.deselectOthers){const p=Object.keys(v.iiif.entities.AnnotationPage);for(const m of p){const b=zt(v,m);b&&b.views&&b.views[e]&&y.push(m)}}for(const p of y)d(p);n.setMetaValue([l,"annotationPageManager","views"],p=>p&&p[e]?p:{...p||{},[e]:!0})},[e,d,n]);return{availablePageIds:s,enabledPageIds:a,setPageEnabled:f,setPageDisabled:d}}function Wt(e,t){return I((n,r)=>r.get(e.map(o=>({id:o,type:t}))),[e,t])}const Gt=u.createContext(new ve.ImageServiceLoader);function Re(){return u.useContext(Gt)}function Qt(){const e=Re(),[t,n]=u.useState({}),r=u.useRef(!1);return u.useEffect(()=>()=>{r.current=!0},[]),[u.useCallback((i,{height:s,width:a})=>{if(i){const d=i.id||i["@id"],f=e.loadServiceSync({id:d,width:i.width||a,height:i.height||s,source:i});f?i=f:t[d]||(r.current||n(l=>({...l,[d]:"loading"})),e.loadService({id:d,width:i.width||a,height:i.height||s}).then(()=>{r.current||n(l=>({...l,[d]:"done"}))}))}return i},[e,t]),t]}function Jt(e={}){const t=Ee(),n=O(e.canvasId?{id:e.canvasId}:void 0);return I((r,o)=>{if(!n)return[];if(t&&e.enableSingleAnnotation)return[t];const i=o.get(n.items),s=[];for(const a of i)s.push(...o.get(a.items));return s},[n])}function Zt(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}const z={},Ve={get(e){return e},setMetaValue([e,t,n],r){const o=Ve.getResourceMeta(e,t),i=o?o[n]:void 0,s=typeof r=="function"?r(i):r;z[e]={...z[e]||{},[t]:{...(z[e]||{})[t]||{},[n]:s}}},getResourceMeta:(e,t)=>{const n=z[e];if(n)return t?n[t]:n}};function Xt(e=Ve){function t(o){const i=o?typeof o=="string"?e.get(o):o:null;if(!i)return[];const s=e.get(i.items,{parent:i}),a=[];for(const d of s)a.push(...e.get(d.items,{parent:d}));return a}function n(o,i=[]){const s=Array.isArray(o)?o:t(o),a=[];let d=null;const f=[];for(const l of s){if(l.type!=="Annotation")throw new Error("getPaintables() accept either a canvas or list of annotations");const g=Array.from(Array.isArray(l.body)?l.body:[l.body]);for(const v of g){const[y,{selector:p}]=Zt(v),m=e.get(y),b=(m.type||"unknown").toLowerCase();if(b==="choice"){const x=e.get(m.items,{parent:m.id}),j=i.length?i.map(S=>x.find(U=>U.id===S)).filter(Boolean):[x[0]];j.length===0&&j.push(x[0]),d={type:"single-choice",items:x.map(S=>({id:S.id,label:S.label,selected:j.indexOf(S)!==-1})),label:y.label},g.push(...j);continue}a.indexOf(b)===-1&&a.push(b),f.push({type:b,annotationId:l.id,resource:m,target:l.target,selector:p})}}return{types:a,items:f,choice:d}}function r(o){const{choice:i}=n(o);return i}return{getAllPaintingAnnotations:t,getPaintables:n,extractChoices:r}}function en(e,t=[]){const n=A(),r=u.useMemo(()=>Xt(n),[]),o=Jt({enableSingleAnnotation:e==null?void 0:e.enableSingleAnnotation}),[i,s]=u.useState((e==null?void 0:e.defaultChoices)||[]),a=u.useMemo(()=>r.getPaintables(o,i),[n,o,i,...t]),f={makeChoice:u.useCallback((l,{deselectOthers:g=!0,deselect:v=!1}={})=>{if(a.choice){if(a.choice.type!=="single-choice")throw new Error("Complex choice not supported yet");s(y=>{if(v){const m=y.filter(b=>b!==l);if(m.length===0){const b=a.items[0].resource.id;return b?[b]:[]}return m}if(g)return[l];const p=[...y];if(p.length===0&&a.items.length){const m=a.items[0].resource.id;m&&p.push(m)}return y.indexOf(l)!==-1?y:[...y,l]})}},[a.choice])};return[a,f]}const tn=["model/gltf-binary"];function nn(e,t){const r=t.items[0].resource;return r.format?tn.indexOf(r.format)===-1?M(`3D format: ${r.format} is unsupported`):{type:"3d-model",model:r}:M("Unknown format")}function rn(e,t){var r;if(!e.duration)return M("No duration on canvas");if(t.items.length>1)return M("Only one audio source supported");const n=(r=t.items[0])==null?void 0:r.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:[]}}:M("Audio does not have format"):M("Unknown audio")}function on(e,t,n){const r=[];for(const o of t.items){const i=o.resource&&o.resource.type==="SpecificResource"?o.resource.source:o.resource;if(!i.id)return M("No resource Identifier");let s;if(i.service){const y=ve.getImageServices(i);y[0]&&(s=n(y[0],e))}const a={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[d,f]=Te(e,o.target);if(f.id!==e.id)continue;o.resource.width&&o.resource.height&&(o.resource.width,o.resource.height);let l=o.resource.type==="SpecificResource"?ne.expandTarget(o.resource):null;if(o.selector){const y=ne.expandTarget({type:"SpecificResource",source:o.resource,selector:o.selector});y&&(l=y)}const g=l&&l.selector&&(l.selector.type==="BoxSelector"||l.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:l.selector.spatial.x,y:l.selector.spatial.y,width:l.selector.spatial.width,height:l.selector.spatial.height}}:void 0;s&&!s.id&&(s.id=s["@id"]);const v={id:i.id,type:"Image",annotationId:o.annotationId,width:Number(d||g?i.width:e.width),height:Number(d||g?i.height:e.height),service:s,sizes:s&&s.sizes?s.sizes:i.width&&i.height?[{width:i.width,height:i.height}]:[],target:d&&d.type!=="PointSelector"?d:a,selector:g};r.push(v)}return{type:"images",image:r[0],images:r,choice:t.choice}}function ke(e,t={},n){const r=e.language||n||"none";switch(e.type){case"TextualBody":{typeof e.value<"u"&&(t[r]=e.value);break}case"List":case"Composite":case"Choice":e.items&&e.items.forEach(o=>ke(o,t,r))}return t}function sn(e,t){const n=[];return t.items.forEach(r=>{if(r.resource){const[o]=Te(e,r.target);n.push({annotationId:r.annotationId,text:ke(r.resource),target:o})}}),{type:"textual-content",items:n}}const an=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function un(e,t){var s;const n=t.items.filter(a=>a.type==="video");if(!e.duration)return M("No duration on canvas");if(n.length>1)return M("Only one video source supported");const r=(s=n[0])==null?void 0:s.resource,o=!!(r.service||[]).find(a=>(a.profile||"").includes("youtube.com"));if(!r)return M("Unknown video");if((!r.format||r.format==="text/html")&&!o)return M("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(o){i.type="VideoYouTube";const a=r.id.match(an);if(!a[1])return M("Video is not known youtube video");i.youTubeId=a[1]}return{type:"media",media:i,annotations:{pages:[]}}}function cn({canvas:e,paintables:t,supports:n,loadImageService:r}){if(!e)return console.log("No canvas"),te;if(t.types.length===0)return n.indexOf("empty")!==-1?$t(e.width,e.height):(console.log("No paintables"),te);if(t.types.length!==1)if(t.types.length===2&&t.types.indexOf("text")!==-1)t.types=t.types.filter(i=>i!=="text");else return n.indexOf("complex-timeline")===-1?M("Complex timeline not supported"):M("ComplexTimelineStrategy not yet supported");const o=t.types[0];return o==="image"?n.indexOf("images")===-1?M("Image not supported"):on(e,t,r):o==="Model"||o==="model"?n.indexOf("3d-model")===-1?M("3D not supported"):nn(e,t):o==="textualbody"?n.indexOf("textual-content")===-1?M("Textual content not supported"):sn(e,t):o==="sound"||o==="audio"?n.indexOf("media")===-1?M("Media not supported"):rn(e,t):o==="video"?n.indexOf("media")===-1?M("Media not supported"):un(e,t):te}function ln(e){const t=_(),n=O(),r=A(),[o,i]=Qt(),{enabledPageIds:s}=Kt((e==null?void 0:e.annotationPageManagerId)||(t==null?void 0:t.id)||(n==null?void 0:n.id),{all:!1}),a=Wt(s,"AnnotationPage"),d=(e==null?void 0:e.strategies)||["empty","images","media","textual-content","complex-timeline"],[f,l]=en(e,[i]),g=u.useMemo(()=>cn({canvas:n,paintables:f,supports:d,loadImageService:o}),[n,f,r,l.makeChoice]);return u.useMemo(()=>g.type==="unknown"?[g,qt]:[{...g,annotations:{pages:a}},l],[g,a])}const dn=(e,t=[])=>{const n=A();u.useEffect(()=>{e(n)},[n,...t])};function fn(e,t,{canvasId:n,manifestId:r}={}){const o=A(),i=Re(),s=u.useMemo(()=>Ke.createThumbnailHelper(o,{imageServiceLoader:i}),[o,i]),[a,d]=u.useState(),f=_(r?{id:r}:void 0),l=O(n?{id:n}:void 0),g=l||f,v=u.useRef(!1);if(u.useEffect(()=>(v.current=!1,()=>{v.current=!0}),[]),!g)throw new Error("Must be called under a manifest or canvas context.");return dn(y=>{s.getBestThumbnailAtSize(g,e,t).then(p=>{p.best&&!v.current&&d(p.best)})},[g]),a}function gn(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function hn(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 mn(e){const t=Math.round(e);return`${Math.floor(t/60)}:${`${t%60}`.padStart(2,"0")}`}function ue(e){const[t,n]=u.useReducer(hn,gn(e.duration)),r=u.useRef(null),o=u.useRef(null),i=u.useRef(null),s=u.useRef(!1),a=u.useCallback(()=>{o.current&&r.current&&(o.current.innerHTML=mn(r.current.currentTime),i.current&&(i.current.style.width=`${r.current.currentTime/e.duration*100}%`),s.current!==r.current.muted&&(s.current=r.current.muted,n(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"})))},[e.duration]),d=u.useCallback(()=>{r.current&&(n({type:"PLAY_REQUESTED"}),r.current.play().then(()=>{n({type:"PLAY"})}),a())},[a]),f=u.useCallback(()=>{r.current&&(r.current.duration>0&&r.current.paused?d():l())},[a]),l=u.useCallback(()=>{r.current&&(r.current.pause(),n({type:"PAUSE"}),a())},[a]),g=u.useCallback(()=>{r.current&&(r.current.muted=!r.current.muted,n(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"}))},[]),v=u.useCallback(()=>{r.current&&(r.current.muted=!0,n({type:"MUTE"}))},[]),y=u.useCallback(()=>{r.current&&(r.current.muted=!1,n({type:"UNMUTE"}))},[]),p=u.useCallback(x=>{r.current&&(r.current.muted=!1,r.current.volume=x/100,n({type:"SET_VOLUME",volume:x}))},[]),m=u.useCallback(x=>{r.current&&(r.current.currentTime=Math.max(0,Math.min(x*e.duration,e.duration)),a())},[]),b=u.useCallback(x=>{r.current&&(r.current.currentTime=Math.max(0,Math.min(x,e.duration)),a())},[]);return u.useEffect(()=>{const x=setInterval(()=>{a()},350);return()=>clearInterval(x)},[a,e.duration]),u.useEffect(()=>{const x=()=>{n({type:"FINISHED"})},j=r.current;return j==null||j.addEventListener("ended",x),()=>j==null?void 0:j.removeEventListener("ended",x)},[]),[{element:r,currentTime:o,progress:i},t,{play:d,pause:l,playPause:f,mute:v,unmute:y,toggleMute:g,setVolume:p,setDurationPercent:m,setTime:b}]}const pn=u.createContext(null),vn=u.createContext(null),yn=u.createContext(null);function Oe({actions:e,state:t,children:n,currentTime:r,progress:o,element:i}){return c.jsx(yn.Provider,{value:{currentTime:r,progress:o,element:i},children:c.jsx(vn.Provider,{value:e,children:c.jsx(pn.Provider,{value:t,children:n})})})}function Le({media:e,children:t}){const[{element:n,currentTime:r,progress:o},i,s]=ue({duration:e.duration});return c.jsxs(Oe,{state:i,actions:s,currentTime:r,progress:o,element:n,children:[c.jsx("audio",{ref:n,src:e.url}),t]})}function Fe({media:e,mediaControlsDeps:t,children:n}){return N("portal","audio",Le,{media:e,children:n},[e,...t||[]]),null}function Ne({element:e,media:t,playPause:n}){return c.jsxs("div",{className:"video-container",part:"video-container",onClick:n,children:[c.jsx("style",{children:`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),u=require("react"),F=require("@atlas-viewer/atlas"),K=require("@iiif/helpers/vault"),ge=require("@iiif/helpers/styles"),ne=require("@iiif/helpers/annotation-targets"),Ye=require("@iiif/helpers"),me=require("@atlas-viewer/iiif-image-api"),$e=require("@iiif/helpers/thumbnail"),ze=u.createContext(null),X={didCatch:!1,error:null};class Ke extends u.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=X}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var n,r,i=arguments.length,o=new Array(i),s=0;s<i;s++)o[s]=arguments[s];(n=(r=this.props).onReset)===null||n===void 0||n.call(r,{args:o,reason:"imperative-api"}),this.setState(X)}}componentDidCatch(t,n){var r,i;(r=(i=this.props).onError)===null||r===void 0||r.call(i,t,n)}componentDidUpdate(t,n){const{didCatch:r}=this.state,{resetKeys:i}=this.props;if(r&&n.error!==null&&We(t.resetKeys,i)){var o,s;(o=(s=this.props).onReset)===null||o===void 0||o.call(s,{next:i,prev:t.resetKeys,reason:"keys"}),this.setState(X)}}render(){const{children:t,fallbackRender:n,FallbackComponent:r,fallback:i}=this.props,{didCatch:o,error:s}=this.state;let a=t;if(o){const l={error:s,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")a=n(l);else if(r)a=u.createElement(r,l);else if(i===null||u.isValidElement(i))a=i;else throw s}return u.createElement(ze.Provider,{value:{didCatch:o,error:s,resetErrorBoundary:this.resetErrorBoundary}},a)}}function We(){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,r)=>!Object.is(n,t[r]))}const Ge={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0,annotationPage:void 0},ie=u.createContext(Ge),U=()=>u.useContext(ie);function G({value:e,children:t}){const n=U(),r=u.useMemo(()=>({...n,...e}),[e,n]);return c.jsx(ie.Provider,{value:r,children:t})}const Q=u.createContext({vault:null,setVaultInstance:e=>{}});function ve({vault:e,vaultOptions:t,useGlobal:n,resources:r,children:i}){const[o,s]=u.useState(()=>e||(n?K.globalVault(t):t?new K.Vault(t):new K.Vault));return c.jsx(Q.Provider,{value:{vault:o,setVaultInstance:s},children:c.jsx(G,{value:r||{},children:i})})}const I=()=>{const{vault:e}=u.useContext(Q);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};function Qe(e,{noCache:t=!1}={}){const n=typeof e=="string"?e:e.id,r=I(),[i,o]=u.useState(n),[s,a]=u.useState(void 0),l=u.useMemo(()=>r.get(n,{skipSelfReturn:!0})||void 0,[n,r]),[f,d]=u.useState(l);return u.useEffect(()=>{(async()=>{try{const h=l&&!t?l:await r.load(n),p=h?h.id||h["@id"]:null;h&&i!==p&&o(p),d(h)}catch(h){a(h)}})()},[n,t]),{isLoaded:!!f,id:i,requestId:n,error:s,resource:f,cached:!!(f&&f===l)}}function Je(e,t){const{id:n,isLoaded:r,error:i,resource:o,requestId:s,cached:a}=Qe(e,t);return{id:n,isLoaded:r,error:i,manifest:o,requestId:s,cached:a}}function Ze({manifest:e,children:t}){return c.jsx(G,{value:{manifest:e},children:t})}function oe({canvas:e,children:t}){return c.jsx(G,{value:{canvas:e},children:t})}function T(e,t=[]){const n=I(),[r,i]=u.useState(()=>e(n.getState(),n));return u.useEffect(()=>n.subscribe(o=>e(o,n),o=>{i(o)},!1),t),r}const J=u.createContext([]);function pe(){const e=u.useContext(J);return T(t=>e.map(n=>t.iiif.entities.Canvas[n]).filter(Boolean),[e])}function q(e={},t=[]){const{id:n,selector:r}=e,i=U();I();const o=n||i.manifest,s=T(a=>o?a.iiif.entities.Manifest[o]:void 0,[o]);return u.useMemo(()=>{if(s)return r?r(s):s},[s,r,...t])}function Xe({range:e,children:t}){return c.jsx(G,{value:{range:e},children:t})}function xe(e,t){var r;const n=[];for(const i of t.items)if(i.type==="SpecificResource"&&((r=i.source)==null?void 0:r.type)==="Canvas"&&(i.source.id.indexOf("#")!==-1?n.push({id:i.source.id.split("#")[0],type:"Canvas"}):n.push(i.source)),i.type==="Range"&&n.push(...xe(e,e.get(i))),i.type==="SpecificResource"){const o=typeof i.source=="string"?i.source:i.source.id;n.push({id:o,type:"Canvas"})}return n}function et(e,t,{disablePaging:n,skipNonPaged:r}={}){const i=t.behavior,o=i.includes("paged"),s=o?!1:i.includes("continuous"),a=o||s?!1:i.includes("individuals"),l=t.type==="Manifest"?t.items:xe(e,t);if(s)return[l,[l.map((v,m)=>m)]];if(a||!o||n)return[l,l.map((v,m)=>[m])];const f=[];let d=[];const h=()=>{d.length&&(f.push([...d]),d=[])};let p=0,x=!1;for(let v=0;v<l.length;v++){const m=e.get(l[v]);if(m.behavior.includes("non-paged")){v===p&&p++,r||(h(),f.push([v]),h());continue}if(v===p||m.behavior.includes("facing-pages")){d.length&&(x=!0),h(),f.push([v]),h();continue}if(d.push(v),x){h(),x=!1;continue}d.length>1&&h()}return d.length&&h(),[l,f]}function tt(e={},t=[]){const{id:n,selector:r}=e,i=U(),o=n||i.range,s=T(a=>o?a.iiif.entities.Range[o]:void 0,[o]);return u.useMemo(()=>{if(s)return r?r(s):s},[s,r,...t])}function nt({startCanvas:e,disablePaging:t}){var v;const n=I(),r=q(),i=tt(),[o,s]=u.useState(void 0),a=i||r;if(!a)throw new Error("Nothing selected");const[l,f]=u.useMemo(()=>et(n,a,{disablePaging:t}),[n,a]),d=u.useCallback(m=>{const C=f.findIndex(y=>y.includes(m));s(C===-1?0:C)},[l,f]),h=u.useCallback(m=>{const C=l.findIndex(y=>y.id===m);C!==-1?d(C):s(0)},[l,f]),p=u.useCallback(()=>{s(m=>m>=f.length-1?m:m+1)},[f]),x=u.useCallback(()=>{s(m=>m<=0?0:m-1)},[f]);return typeof o>"u"&&(e?h(e):s(0)),{visibleItems:((v=f[o])==null?void 0:v.map(m=>l[m].id))||[],cursor:o,items:l,sequence:f,hasPrevious:o>0,hasNext:o<f.length-1,setSequenceIndex:s,setCanvasIndex:d,setCanvasId:h,next:p,previous:x}}const H=()=>{},Z=u.createContext({setCurrentCanvasId:H,setCurrentCanvasIndex:H,nextCanvas:H,previousCanvas:H,items:[],sequence:[],setSequenceIndex:H,currentSequenceIndex:0,hasNext:!1,hasPrevious:!1});function rt(e){const t=q(),{cursor:n,visibleItems:r,next:i,sequence:o,items:s,setCanvasIndex:a,setCanvasId:l,previous:f,setSequenceIndex:d,hasNext:h,hasPrevious:p}=nt({startCanvas:e.startCanvas,disablePaging:e.pagingEnabled===!1}),x=u.useMemo(()=>({sequence:o,items:s,setCurrentCanvasId:l,nextCanvas:i,previousCanvas:f,totalCanvases:s.length,setCurrentCanvasIndex:a,setSequenceIndex:d,currentSequenceIndex:n,hasNext:h,hasPrevious:p}),[o,s,l,i,f,s,a,d,n]);return t?r.length===0?null:c.jsx(Z.Provider,{value:x,children:c.jsx(J.Provider,{value:r,children:c.jsx(oe,{canvas:r[0],children:e.children})})}):(console.warn("The manifest passed to the provider is not a valid IIIF manifest."),c.jsx("div",{children:"Sorry, something went wrong."}))}function it(e){const t=Je(e.manifest);if(!t)return console.warn("The manifest passed to the provider is not a valid IIIF manifest."),c.jsx("div",{children:"Sorry, something went wrong."});if(t.error)return c.jsx("div",{children:t.error.toString()});if(!t.isLoaded)return c.jsx("div",{children:"Loading..."});const n=c.jsx(rt,{...e,children:e.children});return c.jsx(Ze,{manifest:t.id,children:e.rangeId?c.jsx(Xe,{range:e.rangeId,children:n}):n})}function ot(){return u.useContext(Z)}function st(){return{VaultContext:u.useContext(Q),ResourceContext:u.useContext(ie),SimpleViewerReactContext:u.useContext(Z),VisibleCanvasReactContext:u.useContext(J)}}function at(e){return c.jsx(ve,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:c.jsx(J.Provider,{value:e.bridge.VisibleCanvasReactContext,children:c.jsx(Z.Provider,{value:e.bridge.SimpleViewerReactContext,children:e.children})})})}const R=function(e){return function(){const t={type:e,getType:()=>e,toString:()=>e};return(n,r)=>({...t,...n!==void 0&&{payload:n},...r!==void 0&&{meta:r}})}},ut="@iiif/IMPORT_ENTITIES",ct="@iiif/MODIFY_ENTITY_FIELD",lt="@iiif/REORDER_ENTITY_FIELD",dt="@iiif/ADD_REFERENCE",ft="@iiif/UPDATE_REFERENCE",ht="@iiif/REMOVE_REFERENCE",gt="@iiif/ADD_METADATA",mt="@iiif/REMOVE_METADATA",vt="@iiif/UPDATE_METADATA",pt="@iiif/REORDER_METADATA",xt=R(ut)(),yt=R(ct)(),Ct=R(lt)(),bt=R(dt)(),St=R(ht)(),wt=R(ft)(),Mt=R(gt)(),Pt=R(vt)(),jt=R(mt)(),Et=R(pt)(),ee={importEntities:xt,modifyEntityField:yt,reorderEntityField:Ct,addReference:bt,removeReference:St,updateReference:wt,addMetadata:Mt,removeMetadata:jt,updateMetadata:Pt,reorderMetadata:Et};function It(){const t=I().getStore();return u.useMemo(()=>n=>t.dispatch(n),[t])}function fe(e){return typeof e!="string"&&e&&e.bindToVault}function Tt(){const e=I(),t=u.useRef([]),n=It(),r=u.useMemo(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);u.useLayoutEffect(()=>{const a={id:r,type:"AnnotationPage",behavior:[],label:null,thumbnail:[],summary:null,requiredStatement:null,metadata:[],rights:null,provider:[],items:[],seeAlso:[],homepage:[],rendering:[],service:[]};n(ee.importEntities({entities:{AnnotationPage:{[a.id]:a}}}))},[r]);const i=T(a=>r?a.iiif.entities.AnnotationPage[r]:null,[r]),o=u.useCallback((a,l)=>{if(r){if(fe(a)){const h=a;h.__vault||h.bindToVault(e),a=typeof h.source=="string"?h.source:h.source.id,t.current[a]=h}else typeof a!="string"&&(a=a.id);const f=e.get({id:r,type:"AnnotationPage"}),d=e.get({id:a,type:"Annotation"});f&&d&&(f.items.find(h=>h.id===d.id)||n(ee.addReference({id:r,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"},index:l})))}},[r]),s=u.useCallback(a=>{r&&(fe(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:r,type:"AnnotationPage"})&&n(ee.removeReference({id:r,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"}})))},[r]);return[i,{addAnnotation:o,removeAnnotation:s}]}const ye=u.createContext(null);function At(){const e=u.useContext(ye);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function Rt({children:e}){const[t,{addAnnotation:n,removeAnnotation:r}]=Tt();return c.jsx(ye.Provider,{value:u.useMemo(()=>({fullPage:t,addAnnotation:n,removeAnnotation:r}),[t]),children:e})}function Vt({width:e,style:t,height:n,error:r,resetErrorBoundary:i}){return c.jsxs("div",{style:{width:e,height:n,minHeight:500,...t||{},background:"#f9f9f9"},children:[c.jsx("h3",{children:"Error occurred"}),c.jsx("p",{children:r.message}),c.jsx("button",{onClick:i,children:"Reset"})]})}const se=u.createContext(null);function kt(){return u.useContext(se)}const Ce=u.createContext(()=>{}),be=u.createContext(()=>{});function N(e,t,n,r,i=[]){const o=u.useContext(e==="portal"?be:Ce);u.useEffect(()=>(e!=="none"&&o(t,n,r),()=>{o(t,null)}),[t,e,o,...i])}function O(e={},t=[]){const{id:n,selector:r}=e,i=U(),o=n||i.canvas,s=T(a=>o?a.iiif.entities.Canvas[o]:void 0,[o]);return u.useMemo(()=>{if(s)return r?r(s):s},[s,r,...t])}const Se=u.createContext(()=>{});function Ot(e){const t=O(),n=u.useContext(Se);u.useEffect(()=>t&&t.id?(n(t.id,e),()=>n(t.id,-1)):()=>{},[t,e])}function Lt({children:e,errorFallback:t,outerContainerProps:n={},worldScale:r,...i}){const[o,s]=u.useState(),a=st(),l=t||Vt,[f,d]=u.useState({}),h=Object.entries(f),[p,x]=u.useState({}),v=Object.entries(p),[m,C]=u.useState({}),y=u.useMemo(()=>r||Math.max(...Object.values(m)),[m]),P=u.useMemo(()=>({maxOverZoom:y||1,...i.runtimeOptions||{}}),[y,i.runtimeOptions]),S=u.useCallback((w,j)=>{C(A=>{if(j===-1){const{[w]:g,...V}=A;return V}return{...A,[w]:j}})},[]),D=u.useCallback((w,j,A)=>{d(({[w]:g,...V})=>j?{...V,[w]:{element:j,props:A}}:V)},[]),Y=u.useCallback((w,j,A)=>{x(({[w]:g,...V})=>j?{...V,[w]:{element:j,props:A}}:V)},[]);return c.jsxs(Ke,{resetKeys:[],fallbackRender:w=>c.jsx(l,{...i,...w}),children:[c.jsx(F.AtlasAuto,{...i,containerProps:{style:{position:"relative"},...i.containerProps||{}},htmlChildren:c.jsx(c.Fragment,{children:h.map(([w,{element:j,props:A}])=>c.jsx(u.Fragment,{children:c.jsx(j,{...A||{}})},w))}),onCreated:w=>{s(w),i.onCreated&&i.onCreated(w)},runtimeOptions:P,children:c.jsx(se.Provider,{value:o,children:c.jsx(Se.Provider,{value:S,children:c.jsx(Ce.Provider,{value:D,children:c.jsx(be.Provider,{value:Y,children:c.jsx(at,{bridge:a,children:c.jsx(F.ModeContext.Provider,{value:i.mode||"explore",children:c.jsx(Rt,{children:e})})})})})})})}),c.jsx("div",{children:v.map(([w,{element:j,props:A}])=>c.jsx(u.Fragment,{children:c.jsx(j,{...A||{}})},w))})]})}const $={},we={get(e){return e},setMetaValue([e,t,n],r){const i=we.getResourceMeta(e,t),o=i?i[n]:void 0,s=typeof r=="function"?r(o):r;$[e]={...$[e]||{},[t]:{...($[e]||{})[t]||{},[n]:s}}},getResourceMeta:(e,t)=>{const n=$[e];if(n)return t?n[t]:n}};function Ft(e=we){return{addEventListener(t,n,r,i){if(t)return e.setMetaValue([t.id,"eventManager",n],o=>{const s=o||[];for(const a of s)if(a.callback===r)return s;return[...s,{callback:r,scope:i}]}),r},removeEventListener(t,n,r){t&&e.setMetaValue([t.id,"eventManager",n],i=>(i||[]).filter(o=>o.callback!==r))},getListenersAsProps(t,n){const r=typeof t=="string"?{id:t}:t;if(!r||!r.id)return{};const i=e.getResourceMeta(r.id,"eventManager"),o={};if(i&&r)for(const s of Object.keys(i))o[s]=a=>{const l=e.get(r);for(const{callback:f,scope:d}of i[s]||[])(!d||n&&d.indexOf(n)!==-1)&&f(a,l)};return o}}}function Me(e,t){const n=I(),r=u.useMemo(()=>Ft(n),[n]),i=T(()=>e&&e.id?n.getResourceMeta(e.id,"eventManager"):null,[e]);return u.useMemo(()=>e?r.getListenersAsProps(e,t):{},[i,e,n,t])}function W(e,t){const n=I(),r=u.useMemo(()=>ge.createStylesHelper(n),[n]);return T(()=>{if(!e)return null;const i=r.getAppliedStyles(e.id);return i?t?i[t]:i:void 0},[e,t])}function Pe(e={},t=[]){const{id:n,selector:r}=e,i=U(),o=I(),s=n||i.annotation,a=T(f=>s?f.iiif.entities.Annotation[s]:void 0,[s]),l=T(f=>a&&a.body?a.body.map(d=>d?d.type==="SpecificResource"?{...d,source:o.get(d)}:d?f.iiif.entities[d.type][d.id]:null:null).filter(Boolean):[],[a]);return u.useMemo(()=>{if(!a)return;const f={...a,body:l,target:ne.expandTarget(a.target,{typeMap:o.getState().iiif.mapping})};return r?r(f):f},[a,r,l,...t])}const je=({id:e,style:t,className:n,interactive:r})=>{const i=Pe({id:e}),o=W(i,"atlas"),s=W(i,"html"),a=Me(i,["atlas"]),l=O(),f=u.useMemo(()=>F.mergeStyles(t,o),[t,o]);return l&&i&&i.target&&i.target.selector&&i.target.selector.type==="BoxSelector"&&i.target.source&&(i.target.source.id===l.id||i.target.source===l.id)?c.jsx(F.RegionHighlight,{id:i.id,isEditing:!0,region:i.target.selector.spatial,style:f,className:(s==null?void 0:s.className)||n,interactive:!!(s!=null&&s.href||r),href:(s==null?void 0:s.href)||null,title:(s==null?void 0:s.title)||null,hrefTarget:(s==null?void 0:s.target)||null,onClick:()=>{},...a}):null};function Nt(e={},t=[]){const{id:n,selector:r}=e,i=U(),o=n||i.annotationPage,s=T(a=>o?a.iiif.entities.AnnotationPage[o]:void 0,[o]);return u.useMemo(()=>{if(s)return r?r(s):s},[s,...t])}const re=({className:e,page:t})=>{var o;const n=Nt({id:t.id})||t,r=W(n,"atlas"),i=W(n,"html");return T(s=>n.id?s.iiif.entities.AnnotationPage[n.id]:null,[]),c.jsx(u.Fragment,{children:(o=n.items)==null?void 0:o.map(s=>c.jsx(je,{id:s.id,style:r,className:(i==null?void 0:i.className)||e},s.id))})};function Ee({id:e,image:t,thumbnail:n,isStatic:r,x:i=0,y:o=0,children:s,selector:a,onClick:l,enableSizes:f}){var h,p;const d=u.useMemo(()=>{if(!(!a||a.spatial.x===0&&a.spatial.y===0))return a.spatial},[a]);return c.jsx("world-object",{x:i+t.target.spatial.x,y:o+t.target.spatial.y,width:t.target.spatial.width,height:t.target.spatial.height,onClick:l,children:t.service?c.jsxs(u.Fragment,{children:[c.jsx(F.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:f,x:0,y:0,width:(h=t.target)==null?void 0:h.spatial.width,height:(p=t.target)==null?void 0:p.spatial.height,crop:d}),s]},"service"):c.jsxs(u.Fragment,{children:[c.jsx("world-image",{onClick:l,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:d}),s]},"no-service")},e+(t.service?"server":"no-service"))}function Ie(e,t){const{selector:n,source:r}=Ye.expandTarget(t);if(r.id!==e.id)return[null,r];const i={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:i.spatial}:n:null,r]}const Ut={makeChoice:()=>{}},te={type:"unknown"},M=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),qt=(e,t)=>({type:"empty",width:e,height:t,annotations:{pages:[]},image:null,images:[]});function Dt(e,t){var r;const n=(r=e==null?void 0:e.iiif)==null?void 0:r.meta[t];return n?n.annotationPageManager:null}function _t(e,t){return T(n=>{const r=[];if(!e)return r;const i=Object.keys(n.iiif.entities.AnnotationPage);for(const o of i)if(!t||t.indexOf(o)!==-1){const s=Dt(n,o);s&&s.views&&s.views[e]&&r.push(o)}return r},[e,t])}function Bt({canvas:e,manifest:t,all:n,canvases:r}){const i=[];if(t)for(const o of t.annotations)i.indexOf(o.id)===-1&&i.push(o.id);if(n){if(r&&r.length)for(const o of r)for(const s of o.annotations)i.indexOf(s.id)===-1&&i.push(s.id)}else if(e)for(const o of e.annotations)i.indexOf(o.id)===-1&&i.push(o.id);return i}function Ht(e,t){var r;const n=(r=e==null?void 0:e.iiif)==null?void 0:r.meta[t];return n?n.annotationPageManager:null}function Yt(e,t={}){const n=I(),r=q(),i=O(),o=pe(),s=u.useMemo(()=>Bt({all:t.all,manifest:r,canvas:i,canvases:o}),[t.all,i,o,r]),a=_t(e,t.all?void 0:s),l=u.useCallback(d=>{e&&n.setMetaValue([d,"annotationPageManager","views"],h=>h&&!h[e]?h:{...h||{},[e]:!1})},[e,n]),f=u.useCallback((d,h={})=>{if(!e)return;const p=n.getState(),x=[];if(h!=null&&h.deselectOthers){const v=Object.keys(p.iiif.entities.AnnotationPage);for(const m of v){const C=Ht(p,m);C&&C.views&&C.views[e]&&x.push(m)}}for(const v of x)l(v);n.setMetaValue([d,"annotationPageManager","views"],v=>v&&v[e]?v:{...v||{},[e]:!0})},[e,l,n]);return{availablePageIds:s,enabledPageIds:a,setPageEnabled:f,setPageDisabled:l}}function $t(e,t){return T((n,r)=>r.get(e.map(i=>({id:i,type:t}))),[e,t])}const zt=u.createContext(new me.ImageServiceLoader);function Te(){return u.useContext(zt)}function Kt(){const e=Te(),[t,n]=u.useState({}),r=u.useRef(!1);return u.useEffect(()=>()=>{r.current=!0},[]),[u.useCallback((o,{height:s,width:a})=>{if(o){const l=o.id||o["@id"],f=e.loadServiceSync({id:l,width:o.width||a,height:o.height||s,source:o});f?o=f:t[l]||(r.current||n(d=>({...d,[l]:"loading"})),e.loadService({id:l,width:o.width||a,height:o.height||s}).then(()=>{r.current||n(d=>({...d,[l]:"done"}))}))}return o},[e,t]),t]}function Wt(e={}){const t=Pe(),n=O(e.canvasId?{id:e.canvasId}:void 0);return T((r,i)=>{if(!n)return[];if(t&&e.enableSingleAnnotation)return[t];const o=i.get(n.items),s=[];for(const a of o)s.push(...i.get(a.items));return s},[n])}function Gt(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}const z={},Ae={get(e){return e},setMetaValue([e,t,n],r){const i=Ae.getResourceMeta(e,t),o=i?i[n]:void 0,s=typeof r=="function"?r(o):r;z[e]={...z[e]||{},[t]:{...(z[e]||{})[t]||{},[n]:s}}},getResourceMeta:(e,t)=>{const n=z[e];if(n)return t?n[t]:n}};function Qt(e=Ae){function t(i){const o=i?typeof i=="string"?e.get(i):i:null;if(!o)return[];const s=e.get(o.items,{parent:o}),a=[];for(const l of s)a.push(...e.get(l.items,{parent:l}));return a}function n(i,o=[]){const s=Array.isArray(i)?i:t(i),a=[];let l=null;const f=[];for(const d of s){if(d.type!=="Annotation")throw new Error("getPaintables() accept either a canvas or list of annotations");const h=Array.from(Array.isArray(d.body)?d.body:[d.body]);for(const p of h){const[x,{selector:v}]=Gt(p),m=e.get(x),C=(m.type||"unknown").toLowerCase();if(C==="choice"){const y=e.get(m.items,{parent:m.id}),P=o.length?o.map(S=>y.find(D=>D.id===S)).filter(Boolean):[y[0]];P.length===0&&P.push(y[0]),l={type:"single-choice",items:y.map(S=>({id:S.id,label:S.label,selected:P.indexOf(S)!==-1})),label:x.label},h.push(...P);continue}a.indexOf(C)===-1&&a.push(C),f.push({type:C,annotationId:d.id,resource:m,target:d.target,selector:v})}}return{types:a,items:f,choice:l}}function r(i){const{choice:o}=n(i);return o}return{getAllPaintingAnnotations:t,getPaintables:n,extractChoices:r}}function Jt(e,t=[]){const n=I(),r=u.useMemo(()=>Qt(n),[]),i=Wt({enableSingleAnnotation:e==null?void 0:e.enableSingleAnnotation}),[o,s]=u.useState((e==null?void 0:e.defaultChoices)||[]),a=u.useMemo(()=>r.getPaintables(i,o),[n,i,o,...t]),f={makeChoice:u.useCallback((d,{deselectOthers:h=!0,deselect:p=!1}={})=>{if(a.choice){if(a.choice.type!=="single-choice")throw new Error("Complex choice not supported yet");s(x=>{if(p){const m=x.filter(C=>C!==d);if(m.length===0){const C=a.items[0].resource.id;return C?[C]:[]}return m}if(h)return[d];const v=[...x];if(v.length===0&&a.items.length){const m=a.items[0].resource.id;m&&v.push(m)}return x.indexOf(d)!==-1?x:[...x,d]})}},[a.choice])};return[a,f]}const Zt=["model/gltf-binary"];function Xt(e,t){const r=t.items[0].resource;return r.format?Zt.indexOf(r.format)===-1?M(`3D format: ${r.format} is unsupported`):{type:"3d-model",model:r}:M("Unknown format")}function en(e,t){var r;if(!e.duration)return M("No duration on canvas");if(t.items.length>1)return M("Only one audio source supported");const n=(r=t.items[0])==null?void 0:r.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:[]}}:M("Audio does not have format"):M("Unknown audio")}function tn(e,t,n){const r=[];for(const i of t.items){const o=i.resource&&i.resource.type==="SpecificResource"?i.resource.source:i.resource;if(!o.id)return M("No resource Identifier");let s;if(o.service){const x=me.getImageServices(o);x[0]&&(s=n(x[0],e))}const a={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[l,f]=Ie(e,i.target);if(!(f.id===e.id||decodeURIComponent(f.id||"")===(e.id||"")))continue;i.resource.width&&i.resource.height&&(i.resource.width,i.resource.height);let d=i.resource.type==="SpecificResource"?ne.expandTarget(i.resource):null;if(i.selector){const x=ne.expandTarget({type:"SpecificResource",source:i.resource,selector:i.selector});x&&(d=x)}const h=d&&d.selector&&(d.selector.type==="BoxSelector"||d.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:d.selector.spatial.x,y:d.selector.spatial.y,width:d.selector.spatial.width,height:d.selector.spatial.height}}:void 0;s&&!s.id&&(s.id=s["@id"]);const p={id:o.id,type:"Image",annotationId:i.annotationId,width:Number(l||h?o.width:e.width),height:Number(l||h?o.height:e.height),service:s,sizes:s&&s.sizes?s.sizes:o.width&&o.height?[{width:o.width,height:o.height}]:[],target:l&&l.type!=="PointSelector"?l:a,selector:h};r.push(p)}return{type:"images",image:r[0],images:r,choice:t.choice}}function Re(e,t={},n){const r=e.language||n||"none";switch(e.type){case"TextualBody":{typeof e.value<"u"&&(t[r]=e.value);break}case"List":case"Composite":case"Choice":e.items&&e.items.forEach(i=>Re(i,t,r))}return t}function nn(e,t){const n=[];return t.items.forEach(r=>{if(r.resource){const[i]=Ie(e,r.target);n.push({annotationId:r.annotationId,text:Re(r.resource),target:i})}}),{type:"textual-content",items:n}}const rn=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function on(e,t){var a;const n=t.items.filter(l=>l.type==="video");let r=!1;if(e.duration||(r=!0),n.length>1)return M("Only one video source supported");const i=(a=n[0])==null?void 0:a.resource,o=!!(i.service||[]).find(l=>(l.profile||"").includes("youtube.com"));if(!o&&r)return M("Video does not have duration");if(!i)return M("Unknown video");if((!i.format||i.format==="text/html")&&!o)return M("Video does not have format");const s={annotationId:t.items[0].annotationId,duration:e.duration,url:i.id,type:"Video",items:[],target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:i.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}};if(o){s.type="VideoYouTube";const l=i.id.match(rn);if(!l[1])return M("Video is not known youtube video");s.youTubeId=l[1]}return{type:"media",media:s,annotations:{pages:[]}}}function sn({canvas:e,paintables:t,supports:n,loadImageService:r}){if(!e)return console.log("No canvas"),te;if(t.types.length===0)return n.indexOf("empty")!==-1?qt(e.width,e.height):(console.log("No paintables"),te);if(t.types.length!==1)if(t.types.length===2&&t.types.indexOf("text")!==-1)t.types=t.types.filter(o=>o!=="text");else return n.indexOf("complex-timeline")===-1?M("Complex timeline not supported"):M("ComplexTimelineStrategy not yet supported");const i=t.types[0];return i==="image"?n.indexOf("images")===-1?M("Image not supported"):tn(e,t,r):i==="Model"||i==="model"?n.indexOf("3d-model")===-1?M("3D not supported"):Xt(e,t):i==="textualbody"?n.indexOf("textual-content")===-1?M("Textual content not supported"):nn(e,t):i==="sound"||i==="audio"?n.indexOf("media")===-1?M("Media not supported"):en(e,t):i==="video"?n.indexOf("media")===-1?M("Media not supported"):on(e,t):te}function an(e){const t=q(),n=O(),r=I(),[i,o]=Kt(),{enabledPageIds:s}=Yt((e==null?void 0:e.annotationPageManagerId)||(t==null?void 0:t.id)||(n==null?void 0:n.id),{all:!1}),a=$t(s,"AnnotationPage"),l=(e==null?void 0:e.strategies)||["empty","images","media","textual-content","complex-timeline"],[f,d]=Jt(e,[o]),h=u.useMemo(()=>sn({canvas:n,paintables:f,supports:l,loadImageService:i}),[n,f,r,d.makeChoice]);return u.useMemo(()=>h.type==="unknown"?[h,Ut]:[{...h,annotations:{pages:a}},d],[h,a])}const un=(e,t=[])=>{const n=I();u.useEffect(()=>{e(n)},[n,...t])};function cn(e,t,{canvasId:n,manifestId:r}={}){const i=I(),o=Te(),s=u.useMemo(()=>$e.createThumbnailHelper(i,{imageServiceLoader:o}),[i,o]),[a,l]=u.useState(),f=q(r?{id:r}:void 0),d=O(n?{id:n}:void 0),h=d||f,p=u.useRef(!1);if(u.useEffect(()=>(p.current=!1,()=>{p.current=!0}),[]),!h)throw new Error("Must be called under a manifest or canvas context.");return un(x=>{s.getBestThumbnailAtSize(h,e,t).then(v=>{v.best&&!p.current&&l(v.best)})},[h]),a}function ln(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function dn(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 fn(e){const t=Math.round(e);return`${Math.floor(t/60)}:${`${t%60}`.padStart(2,"0")}`}function ae(e){const[t,n]=u.useReducer(dn,ln(e.duration)),r=u.useRef(null),i=u.useRef(null),o=u.useRef(null),s=u.useRef(!1),a=u.useCallback(()=>{i.current&&r.current&&(i.current.innerHTML=fn(r.current.currentTime),o.current&&(o.current.style.width=`${r.current.currentTime/e.duration*100}%`),s.current!==r.current.muted&&(s.current=r.current.muted,n(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"})))},[e.duration]),l=u.useCallback(()=>{r.current&&(n({type:"PLAY_REQUESTED"}),r.current.play().then(()=>{n({type:"PLAY"})}),a())},[a]),f=u.useCallback(()=>{r.current&&(r.current.duration>0&&r.current.paused?l():d())},[a]),d=u.useCallback(()=>{r.current&&(r.current.pause(),n({type:"PAUSE"}),a())},[a]),h=u.useCallback(()=>{r.current&&(r.current.muted=!r.current.muted,n(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"}))},[]),p=u.useCallback(()=>{r.current&&(r.current.muted=!0,n({type:"MUTE"}))},[]),x=u.useCallback(()=>{r.current&&(r.current.muted=!1,n({type:"UNMUTE"}))},[]),v=u.useCallback(y=>{r.current&&(r.current.muted=!1,r.current.volume=y/100,n({type:"SET_VOLUME",volume:y}))},[]),m=u.useCallback(y=>{r.current&&(r.current.currentTime=Math.max(0,Math.min(y*e.duration,e.duration)),a())},[]),C=u.useCallback(y=>{r.current&&(r.current.currentTime=Math.max(0,Math.min(y,e.duration)),a())},[]);return u.useEffect(()=>{const y=setInterval(()=>{a()},350);return()=>clearInterval(y)},[a,e.duration]),u.useEffect(()=>{const y=()=>{n({type:"FINISHED"})},P=r.current;return P==null||P.addEventListener("ended",y),()=>P==null?void 0:P.removeEventListener("ended",y)},[]),[{element:r,currentTime:i,progress:o},t,{play:l,pause:d,playPause:f,mute:p,unmute:x,toggleMute:h,setVolume:v,setDurationPercent:m,setTime:C}]}const hn=u.createContext(null),gn=u.createContext(null),mn=u.createContext(null);function Ve({actions:e,state:t,children:n,currentTime:r,progress:i,element:o}){return c.jsx(mn.Provider,{value:{currentTime:r,progress:i,element:o},children:c.jsx(gn.Provider,{value:e,children:c.jsx(hn.Provider,{value:t,children:n})})})}function ke({media:e,children:t}){const[{element:n,currentTime:r,progress:i},o,s]=ae({duration:e.duration});return c.jsxs(Ve,{state:o,actions:s,currentTime:r,progress:i,element:n,children:[c.jsx("audio",{ref:n,src:e.url}),t]})}function Oe({media:e,mediaControlsDeps:t,children:n}){return N("portal","audio",ke,{media:e,children:n},[e,...t||[]]),null}function Le({element:e,media:t,playPause:n}){return c.jsxs("div",{className:"video-container",part:"video-container",onClick:n,children:[c.jsx("style",{children:`
2
2
  .video-container {
3
3
  position: absolute;
4
4
  top: 0;
@@ -11,7 +11,7 @@
11
11
  justify-content: center;
12
12
  pointer-events: visible;
13
13
  }
14
- `}),c.jsx("video",{ref:e,src:t.url,style:{width:"100%",objectFit:"contain"}})]})}function De({media:e,mediaControlsDeps:t,children:n}){const[{element:r,currentTime:o,progress:i},s,a]=ue({duration:e.duration});return N("overlay","video-element",Ne,{element:r,media:e,playPause:a.playPause}),N("portal","custom-controls",Oe,{state:s,actions:a,currentTime:o,progress:i,element:r,children:n},[o,s,e,...t||[]]),null}function _e({model:e}){return c.jsxs(c.Fragment,{children:[c.jsx("style",{children:`
14
+ `}),c.jsx("video",{ref:e,src:t.url,style:{width:"100%",objectFit:"contain"}})]})}function Fe({media:e,mediaControlsDeps:t,children:n}){const[{element:r,currentTime:i,progress:o},s,a]=ae({duration:e.duration});return N("overlay","video-element",Le,{element:r,media:e,playPause:a.playPause}),N("portal","custom-controls",Ve,{state:s,actions:a,currentTime:i,progress:o,element:r,children:n},[i,s,e,...t||[]]),null}function Ne({model:e}){return c.jsxs(c.Fragment,{children:[c.jsx("style",{children:`
15
15
  .model-container {
16
16
  position: absolute;
17
17
  top: 0;
@@ -24,8 +24,8 @@
24
24
  justify-content: center;
25
25
  pointer-events: visible;
26
26
  }
27
- `}),c.jsx("div",{className:"model-container",children:c.jsx("model-viewer",{"interaction-prompt":"none",style:{width:"100%",height:"100%"},"camera-controls":"","ar-status":"not-presenting",src:e.id})})]})}function Ue({model:e,name:t}){return N("overlay",`model-${t}`,_e,{model:e},[e]),null}function qe({style:e}){const t=O();return!t||!t.height||!t.width?null:c.jsx("box",{interactive:!1,target:{x:0,y:0,width:Number(t.width),height:Number(t.height)},style:e})}const xn=u.createContext("en");function $e(){return u.useContext(xn)}function me(e){return e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):e}function bn({as:e,language:t,children:n,viewingDirection:r,...o}){const i=$e();return u.useMemo(()=>me(i)===me(t),[i,t])?e?c.jsx(e,{...o,children:n}):c.jsx("span",{...o,children:n}):e?c.jsx(e,{...o,lang:t,dir:r,children:n}):c.jsx("span",{...o,lang:t,dir:r,children:n})}function Cn(e,t,n){if(t.length===0)return;if(t.length===1)return t[0];if(t.indexOf(e)!==-1)return e;const r=e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):null;if(r&&t.indexOf(r)!==-1)return r;for(const o of n)if(t.indexOf(o)!==-1)return o;return t.indexOf("none")!==-1?"none":t.indexOf("@none")!==-1?"@none":t[0]}const Sn=(e,t=[])=>{const n=$e();return u.useMemo(()=>{const r=e();return Cn(n,r,[])},[n,...t])};function wn(e,t){const n=Sn(()=>Object.keys(e||{}),[e]);return[u.useMemo(()=>{if(!e)return t||"";if(typeof e=="string")return e;const r=n?e[n]:void 0;return r?typeof r=="string"?r:r.join(`
28
- `):""},[n,t,e]),n]}const Mn=({as:e,defaultText:t,enableDangerouslySetInnerHTML:n,children:r,...o})=>{const[i,s]=wn(r,t);return s?c.jsx(bn,{...o,as:e,language:s,title:n?void 0:i,dangerouslySetInnerHTML:n?{__html:i}:void 0,children:n?void 0:i}):e?c.jsx(e,{...o,children:i}):c.jsx("span",{...o,title:n?void 0:i,dangerouslySetInnerHTML:n?{__html:i}:void 0,children:n?void 0:i})};function jn({element:e,media:t,playPause:n}){const r=u.useRef(null);return t.youTubeId?c.jsxs("div",{className:"video-container",part:"video-container",onClick:n,children:[c.jsx("style",{children:`
27
+ `}),c.jsx("div",{className:"model-container",children:c.jsx("model-viewer",{"interaction-prompt":"none",style:{width:"100%",height:"100%"},"camera-controls":"","ar-status":"not-presenting",src:e.id})})]})}function Ue({model:e,name:t}){return N("overlay",`model-${t}`,Ne,{model:e},[e]),null}function qe({style:e}){const t=O();return!t||!t.height||!t.width?null:c.jsx("box",{interactive:!1,target:{x:0,y:0,width:Number(t.width),height:Number(t.height)},style:e})}const vn=u.createContext("en");function De(){return u.useContext(vn)}function he(e){return e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):e}function pn({as:e,language:t,children:n,viewingDirection:r,...i}){const o=De();return u.useMemo(()=>he(o)===he(t),[o,t])?e?c.jsx(e,{...i,children:n}):c.jsx("span",{...i,children:n}):e?c.jsx(e,{...i,lang:t,dir:r,children:n}):c.jsx("span",{...i,lang:t,dir:r,children:n})}function xn(e,t,n){if(t.length===0)return;if(t.length===1)return t[0];if(t.indexOf(e)!==-1)return e;const r=e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):null;if(r&&t.indexOf(r)!==-1)return r;for(const i of n)if(t.indexOf(i)!==-1)return i;return t.indexOf("none")!==-1?"none":t.indexOf("@none")!==-1?"@none":t[0]}const yn=(e,t=[])=>{const n=De();return u.useMemo(()=>{const r=e();return xn(n,r,[])},[n,...t])};function Cn(e,t,n=`
28
+ `){const r=yn(()=>Object.keys(e||{}),[e]);return[u.useMemo(()=>{if(!e)return t||"";if(typeof e=="string")return e;const i=r?e[r]:void 0;return i?typeof i=="string"?i:i.join(n):""},[r,t,e]),r]}function bn({as:e,defaultText:t,enableDangerouslySetInnerHTML:n,children:r,separator:i,...o}){const[s,a]=Cn(r,t,i);return a?c.jsx(pn,{...o,as:e,language:a,title:n?void 0:s,dangerouslySetInnerHTML:n?{__html:s}:void 0,children:n?void 0:s}):e?c.jsx(e,{...o,children:s}):c.jsx("span",{...o,title:n?void 0:s,dangerouslySetInnerHTML:n?{__html:s}:void 0,children:n?void 0:s})}function Sn({element:e,media:t,playPause:n}){const r=u.useRef(null);return t.youTubeId?c.jsxs("div",{className:"video-container",part:"video-container",onClick:n,children:[c.jsx("style",{children:`
29
29
  .video-container {
30
30
  position: absolute;
31
31
  top: 0;
@@ -43,5 +43,5 @@
43
43
  width: 100%;
44
44
  object-fit: contain;
45
45
  }
46
- `}),c.jsx("iframe",{className:"video-yt",ref:r,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 Pn({media:e,mediaControlsDeps:t,children:n}){const[{element:r,currentTime:o,progress:i},s,a]=ue({duration:e.duration});return N("overlay","video-element",jn,{element:r,media:e,playPause:a.playPause}),null}function Be({x:e,y:t,onChoiceChange:n,registerActions:r,defaultChoices:o,isStatic:i,renderViewerControls:s,renderMediaControls:a,viewControlsDeps:d,mediaControlsDeps:f,strategies:l,throwOnUnknown:g,backgroundStyle:v,alwaysShowBackground:y,keepCanvasScale:p=!1,enableSizes:m=!1,enableYouTube:b=!0,onClickPaintingAnnotation:x,children:j}){const S=O(),U=Pe(S,["deep-zoom"]),[H]=kt(),w=Ft(),P=A(),T=u.useMemo(()=>pe.createStylesHelper(P),[P]),[h,V]=ln({strategies:l||["images"],defaultChoices:o==null?void 0:o.map(({id:C})=>C)}),ce=h.type==="images"?h.choice:void 0,He=u.useMemo(()=>p?1:Math.max(1,...h.type==="images"?h.images.map(C=>{var L;return(C.width||0)/((L=C.target)==null?void 0:L.spatial.width)}):[]),[p,h]);Nt(He),u.useEffect(()=>{r&&r(V)},[h.annotations]),u.useEffect(()=>{if(o)for(const C of o)typeof C.opacity<"u"&&T.applyStyles({id:C.id},"atlas",{opacity:C.opacity})},[o]),u.useLayoutEffect(()=>{n&&n(ce)},[ce]),N(w&&(h.type==="images"||h.type==="empty"||h.type==="textual-content"&&s)?"overlay":"none",`canvas-portal-controls-${S==null?void 0:S.id}`,ae.Provider,s?{value:w||null,children:s(h)}:{},[S,w,h,...d||[]]);const k=fn({maxWidth:256,maxHeight:256});if(!S)return null;const le=S.accompanyingCanvas,q=k&&k.type==="fixed"?c.jsx("world-object",{height:S.height,width:S.width,x:e,y:t,children:c.jsx("world-image",{uri:k.id,target:{x:0,y:0,width:S.width,height:S.height},display:k.width&&k.height?{width:k.width,height:k.height}:void 0,crop:void 0})}):null;if(h.type==="unknown"){if(q)return q;if(g)throw new Error(h.reason||"Unknown image strategy");return null}const de=c.jsxs(u.Fragment,{children:[H?c.jsx(oe,{page:H}):null,h.annotations&&h.annotations.pages?h.annotations.pages.map(C=>c.jsx(oe,{page:C},C.id)):null,j]}),Ye=h.type==="images"?h.images.length:0;return c.jsxs(c.Fragment,{children:[c.jsxs("world-object",{height:S.height,width:S.width,x:e,y:t,...U,children:[h.type==="empty"||y?c.jsx(qe,{style:v}):null,h.type==="textual-content"?h.items.map((C,L)=>{var $;return c.jsxs(c.Fragment,{children:[c.jsx(F.HTMLPortal,{onClick:x?fe=>{fe.stopPropagation(),x(C.annotationId,C,fe)}:void 0,target:(($=C.target)==null?void 0:$.spatial)||void 0,children:c.jsx("div",{"data-textual-content":!0,children:c.jsx(Mn,{enableDangerouslySetInnerHTML:!0,children:C.text})})},L),de]})}):null,h.type==="images"?c.jsxs(c.Fragment,{children:[h.images.map((C,L)=>c.jsx(Ie,{isStatic:i,image:C,id:C.id,thumbnail:L===0?k:void 0,selector:C.selector,enableSizes:m,onClick:x?$=>{$.stopPropagation(),x(C.annotationId,C,$)}:void 0},C.id+L)),de]}):null,h.type==="3d-model"?c.jsx(Ue,{model:h.model}):null,h.type==="media"?c.jsx(c.Fragment,{children:h.media.type==="Sound"?c.jsxs(Fe,{media:h.media,mediaControlsDeps:f,children:[q,a?a(h):null]}):h.media.type==="Video"?c.jsxs(De,{media:h.media,mediaControlsDeps:f,children:[q,a?a(h):null]}):h.media.type==="VideoYouTube"&&b?c.jsxs(Pn,{media:h.media,mediaControlsDeps:f,children:[q,a?a(h):null]}):null}):null]},`${S.id}/${h.type}/${Ye}`),h.type==="media"&&h.media.type==="Sound"&&le?c.jsx(se,{canvas:le.id,children:c.jsx(Be,{renderViewerControls:s})}):null]})}function En(){const e=u.useContext(Q);return e&&e.vault?e.vault:K.globalVault()}const An=u.forwardRef(function(t,n){const r=_(),o=xe(),i=ut(),{ViewerControls:s,MediaControls:a}=t.components||{};if(u.useImperativeHandle(n,()=>i,[i]),!r)return c.jsx("div",{});let d=0;return c.jsxs(c.Fragment,{children:[t.header,c.jsx(E.Viewer,{height:t.height,mode:t.mode,children:o.map((f,l)=>{const g=d;return d+=f.width+(t.spacing||0),c.jsx(se,{canvas:f.id,children:c.jsx(E.RenderCanvas,{strategies:["3d-model","media","images","empty","textual-content"],renderViewerControls:l===0&&s?()=>c.jsx(s,{}):void 0,renderMediaControls:l===0&&a?()=>c.jsx(a,{}):void 0,x:g,...t.canvasProps||{},children:t.annotations},f.id)},f.id)})},t.reuseAtlas?"":i.currentSequenceIndex),t.children]})}),E=u.forwardRef(function({children:t,height:n,annotations:r,canvasProps:o,spacing:i,header:s,components:a,mode:d,...f},l){const g=En();return c.jsx(ye,{vault:g,children:c.jsx(at,{...f,children:c.jsx(An,{ref:l,height:n,components:a,spacing:i,canvasProps:o,annotations:r,header:s,mode:d,children:t})})})});E.RenderImage=Ie;E.RenderCanvas=Be;E.RenderAnnotationPage=oe;E.RenderAnnotation=Ae;E.Viewer=Dt;E.CanvasBackground=qe;E.Audio=Fe;E.Video=De;E.Model=Ue;E.AudioHTML=Le;E.VideoHTML=Ne;E.ModelHTML=_e;exports.CanvasPanel=E;
46
+ `}),c.jsx("iframe",{className:"video-yt",ref:r,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 wn({media:e,mediaControlsDeps:t,children:n}){const[{element:r,currentTime:i,progress:o},s,a]=ae({duration:e.duration});return N("overlay","video-element",Sn,{element:r,media:e,playPause:a.playPause}),null}function _e({x:e,y:t,onChoiceChange:n,registerActions:r,defaultChoices:i,isStatic:o,renderViewerControls:s,renderMediaControls:a,viewControlsDeps:l,mediaControlsDeps:f,strategies:d,throwOnUnknown:h,backgroundStyle:p,alwaysShowBackground:x,keepCanvasScale:v=!1,enableSizes:m=!1,enableYouTube:C=!0,onClickPaintingAnnotation:y,children:P}){const S=O(),D=Me(S,["deep-zoom"]),[Y]=At(),w=kt(),j=I(),A=u.useMemo(()=>ge.createStylesHelper(j),[j]),[g,V]=an({strategies:d||["images"],defaultChoices:i==null?void 0:i.map(({id:b})=>b)}),ue=g.type==="images"?g.choice:void 0,Be=u.useMemo(()=>v?1:Math.max(1,...g.type==="images"?g.images.map(b=>{var L;return(b.width||0)/((L=b.target)==null?void 0:L.spatial.width)}):[]),[v,g]);Ot(Be),u.useEffect(()=>{r&&r(V)},[g.annotations]),u.useEffect(()=>{if(i)for(const b of i)typeof b.opacity<"u"&&A.applyStyles({id:b.id},"atlas",{opacity:b.opacity})},[i]),u.useLayoutEffect(()=>{n&&n(ue)},[ue]),N(w&&(g.type==="images"||g.type==="empty"||g.type==="textual-content"&&s)?"overlay":"none",`canvas-portal-controls-${S==null?void 0:S.id}`,se.Provider,s?{value:w||null,children:s(g)}:{},[S,w,g,...l||[]]);const k=cn({maxWidth:256,maxHeight:256});if(!S)return null;const ce=S.accompanyingCanvas,_=k&&k.type==="fixed"?c.jsx("world-object",{height:S.height,width:S.width,x:e,y:t,children:c.jsx("world-image",{uri:k.id,target:{x:0,y:0,width:S.width,height:S.height},display:k.width&&k.height?{width:k.width,height:k.height}:void 0,crop:void 0})}):null;if(g.type==="unknown"){if(_)return _;if(h)throw new Error(g.reason||"Unknown image strategy");return null}const le=c.jsxs(u.Fragment,{children:[Y?c.jsx(re,{page:Y}):null,g.annotations&&g.annotations.pages?g.annotations.pages.map(b=>c.jsx(re,{page:b},b.id)):null,P]}),He=g.type==="images"?g.images.length:0;return c.jsxs(c.Fragment,{children:[c.jsxs("world-object",{height:S.height,width:S.width,x:e,y:t,...D,children:[g.type==="empty"||x?c.jsx(qe,{style:p}):null,g.type==="textual-content"?g.items.map((b,L)=>{var B;return c.jsxs(c.Fragment,{children:[c.jsx(F.HTMLPortal,{onClick:y?de=>{de.stopPropagation(),y(b.annotationId,b,de)}:void 0,target:((B=b.target)==null?void 0:B.spatial)||void 0,children:c.jsx("div",{"data-textual-content":!0,children:c.jsx(bn,{enableDangerouslySetInnerHTML:!0,children:b.text})})},L),le]})}):null,g.type==="images"?c.jsxs(c.Fragment,{children:[g.images.map((b,L)=>c.jsx(Ee,{isStatic:o,image:b,id:b.id,thumbnail:L===0?k:void 0,selector:b.selector,enableSizes:m,onClick:y?B=>{B.stopPropagation(),y(b.annotationId,b,B)}:void 0},b.id+L)),le]}):null,g.type==="3d-model"?c.jsx(Ue,{model:g.model}):null,g.type==="media"?c.jsx(c.Fragment,{children:g.media.type==="Sound"?c.jsxs(Oe,{media:g.media,mediaControlsDeps:f,children:[_,a?a(g):null]}):g.media.type==="Video"?c.jsxs(Fe,{media:g.media,mediaControlsDeps:f,children:[_,a?a(g):null]}):g.media.type==="VideoYouTube"&&C?c.jsxs(wn,{media:g.media,mediaControlsDeps:f,children:[_,a?a(g):null]}):null}):null]},`${S.id}/${g.type}/${He}`),g.type==="media"&&g.media.type==="Sound"&&ce?c.jsx(oe,{canvas:ce.id,children:c.jsx(_e,{renderViewerControls:s})}):null]})}function Mn(){const e=u.useContext(Q);return e&&e.vault?e.vault:K.globalVault()}const Pn=u.forwardRef(function(t,n){const r=q(),i=pe(),o=ot(),{ViewerControls:s,MediaControls:a}=t.components||{};if(u.useImperativeHandle(n,()=>o,[o]),!r)return c.jsx("div",{});let l=0;return c.jsxs(c.Fragment,{children:[t.header,c.jsx(E.Viewer,{height:t.height,mode:t.mode,children:i.map((f,d)=>{const h=l;return l+=f.width+(t.spacing||0),c.jsx(oe,{canvas:f.id,children:c.jsx(E.RenderCanvas,{strategies:["3d-model","media","images","empty","textual-content"],renderViewerControls:d===0&&s?()=>c.jsx(s,{}):void 0,renderMediaControls:d===0&&a?()=>c.jsx(a,{}):void 0,x:h,...t.canvasProps||{},children:t.annotations},f.id)},f.id)})},t.reuseAtlas?"":o.currentSequenceIndex),t.children]})}),E=u.forwardRef(function({children:t,height:n,annotations:r,canvasProps:i,spacing:o,header:s,components:a,mode:l,reuseAtlas:f,...d},h){const p=Mn();return c.jsx(ve,{vault:p,children:c.jsx(it,{...d,children:c.jsx(Pn,{ref:h,height:n,components:a,spacing:o,canvasProps:i,annotations:r,header:s,mode:l,reuseAtlas:f,children:t})})})});E.RenderImage=Ee;E.RenderCanvas=_e;E.RenderAnnotationPage=re;E.RenderAnnotation=je;E.Viewer=Lt;E.CanvasBackground=qe;E.Audio=Oe;E.Video=Fe;E.Model=Ue;E.AudioHTML=ke;E.VideoHTML=Le;E.ModelHTML=Ne;exports.CanvasPanel=E;
47
47
  //# sourceMappingURL=canvas-panel.js.map