react-iiif-vault 1.3.4 → 1.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{c as ht,l as yt}from"./chunk-UFC4ZSNV.js";import{forwardRef as er,useImperativeHandle as Li}from"react";import un,{useCallback as tt,useMemo as cn,useState as Re}from"react";import{AtlasAuto as vo,ModeContext as ho}from"@atlas-viewer/atlas";import{ErrorBoundary as yo}from"react-error-boundary";import{useContext as W}from"react";import nr,{useContext as rr,useMemo as or}from"react";import{jsx as ar}from"react/jsx-runtime";var ir={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0,annotationPage:void 0},Ce=nr.createContext(ir),H=()=>rr(Ce);function K({value:e,children:n}){let t=H(),r=or(()=>({...t,...e}),[e,t]);return ar(Ce.Provider,{value:r,children:n})}import sr,{useState as ur}from"react";import{Vault as xt,globalVault as cr}from"@iiif/helpers/vault";import{jsx as St}from"react/jsx-runtime";var Q=sr.createContext({vault:null,setVaultInstance:e=>{}});function J({vault:e,vaultOptions:n,useGlobal:t,resources:r,children:o}){let[s,i]=ur(()=>e||(t?cr(n):n?new xt(n):new xt));return St(Q.Provider,{value:{vault:s,setVaultInstance:i},children:St(K,{value:r||{},children:o})})}import{useContext as qr}from"react";import{createContext as Br,useMemo as _r}from"react";import{globalVault as lr}from"@iiif/helpers/vault";import{useContext as dr}from"react";function X(e){let n=dr(Q);return e||(n&&n.vault?n.vault:lr())}import{useEffect as mr,useMemo as fr,useState as Be}from"react";function Ct(e,{noCache:n=!1}={}){let t=typeof e=="string"?e:e.id,r=X(),[o,s]=Be(t),[i,a]=Be(void 0),u=fr(()=>r.get(t,{skipSelfReturn:!0})||void 0,[t,r]),[c,l]=Be(u);return mr(()=>{(async()=>{try{let d=u&&!n?u:await r.load(t),y=d?d.id||d["@id"]:null;d&&o!==y&&s(y),l(d)}catch(d){a(d)}})()},[t,n]),{isLoaded:!!c,id:o,requestId:t,error:i,resource:c,cached:!!(c&&c===u)}}function At(e,n){let{id:t,isLoaded:r,error:o,resource:s,requestId:i,cached:a}=Ct(e,n);return{id:t,isLoaded:r,error:o,manifest:s,requestId:i,cached:a}}import{jsx as pr}from"react/jsx-runtime";function bt({manifest:e,children:n}){return pr(K,{value:{manifest:e},children:n})}import{jsx as gr}from"react/jsx-runtime";function q({canvas:e,children:n}){return gr(K,{value:{canvas:e},children:n})}import{useContext as xr}from"react";import Sr from"react";import{useContext as vr}from"react";var R=()=>{let{vault:e}=vr(Q);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};import{useEffect as hr,useState as yr}from"react";function T(e,n=[]){let t=R(),[r,o]=yr(()=>e(t.getState(),t));return hr(()=>t.subscribe(s=>e(s,t),s=>{o(s)},!1),n),r}var ee=Sr.createContext([]);function Ae(){let e=xr(ee);return T(n=>e.map(t=>n.iiif.entities.Canvas[t]).filter(Boolean),[e])}import{useMemo as Cr}from"react";function E(e={},n=[]){let{id:t,selector:r}=e,o=H(),s=R(),i=t||o.manifest,a=T(u=>i?u.iiif.entities.Manifest[i]:void 0,[i]);return Cr(()=>{if(a)return r?r(a):a},[a,r,...n])}import{jsx as Ar}from"react/jsx-runtime";function Pt({range:e,children:n}){return Ar(K,{value:{range:e},children:n})}function br(e,n){for(let t of n.items){if(t.type==="Canvas")return t;if(t.type==="SpecificResource")return t.source;if(t.type==="Range"){let r=br(e,e.get(t));if(r)return r}}return null}function _e(e,n){let t=[];for(let r of n.items)if(r.type==="SpecificResource"&&r.source?.type==="Canvas"&&(r.source.id.indexOf("#")!==-1?t.push({id:r.source.id.split("#")[0],type:"Canvas"}):t.push(r.source)),r.type==="Range"&&t.push(..._e(e,e.get(r))),r.type==="SpecificResource"){let o=typeof r.source=="string"?r.source:r.source.id;t.push({id:o,type:"Canvas"})}return t}function La(e,n,t){for(let r of n.structures){let o=Rt(e,e.get(r),t);if(o)return o}return null}function Rt(e,n,t){for(let r of n.items){let o=r?.source?.id?.split("#")[0];if(r.type==="SpecificResource"&&r.source===t||r.type==="SpecificResource"&&r.source?.type==="Canvas"&&t===o)return n;if(r.type==="Range"){let s=Rt(e,e.get(r),t);if(s)return s}}return null}function Ha(e,n,t,r=!1){let o=n.behavior,s=t?e.get(t):null;if(!s)return[];let i=s.behavior,a=r?!1:o.includes("paged"),u=a?!1:o.includes("continuous"),c=a||u?!1:o.includes("individuals"),l=i.includes("facing-pages"),d=i.includes("non-paged");if(l||d||c||r)return[{id:s.id,type:"Canvas"}];let[y,A]=je(e,n);if(u)return y;let h=y.findIndex(g=>g.id===t);if(h===-1)return[];for(let g of A)if(g.includes(h))return g.map(b=>y[b]);return[{id:s.id,type:"Canvas"}]}function je(e,n,{disablePaging:t,skipNonPaged:r}={}){let o=n.behavior,s=o.includes("paged"),i=s?!1:o.includes("continuous"),a=s||i?!1:o.includes("individuals"),u=n.type==="Manifest"?n.items:_e(e,n);if(i)return[u,[u.map((h,g)=>g)]];if(a||!s||t)return[u,u.map((h,g)=>[g])];let c=[],l=[],d=()=>{l.length&&(c.push([...l]),l=[])},y=0,A=!1;for(let h=0;h<u.length;h++){let g=e.get(u[h]);if(g.behavior.includes("non-paged")){h===y&&y++,r||(d(),c.push([h]),d());continue}if(h===y||g.behavior.includes("facing-pages")){l.length&&(A=!0),d(),c.push([h]),d();continue}if(l.push(h),A){d(),A=!1;continue}l.length>1&&d()}return l.length&&d(),[u,c]}import{useCallback as be,useMemo as Rr,useRef as Tr,useState as Ir}from"react";import{useMemo as Pr}from"react";function Tt(e={},n=[]){let{id:t,selector:r}=e,o=H(),s=t||o.range,i=T(a=>s?a.iiif.entities.Range[s]:void 0,[s]);return Pr(()=>{if(i)return r?r(i):i},[i,r,...n])}function It({startCanvas:e,disablePaging:n}){let t=R(),r=E(),o=Tt(),[s,i]=Ir(void 0),a=o||r;if(!a)throw new Error("Nothing selected");let[u,c]=Rr(()=>je(t,a,{disablePaging:n}),[t,a,n]),l=Tr(c);if(l.current!==c){let b=l.current[s][0],p=c.findIndex(S=>S.includes(b));l.current=c,i(p)}let d=be(g=>{let b=c.findIndex(p=>p.includes(g));i(b===-1?0:b)},[u,c]),y=be(g=>{let b=u.findIndex(p=>p.id===g);b!==-1?d(b):i(0)},[u,c]),A=be(()=>{i(g=>g>=c.length-1?g:g+1)},[c]),h=be(()=>{i(g=>g<=0?0:g-1)},[c]);return typeof s>"u"&&(e?y(e):i(0)),{visibleItems:c[s]?.map(g=>u[g].id)||[],cursor:s,items:u,sequence:c,hasPrevious:s>0,hasNext:s<c.length-1,setSequenceIndex:i,setCanvasIndex:d,setCanvasId:y,next:A,previous:h}}import{createContext as Qe,useContext as Ft,useEffect as wr,useMemo as Er}from"react";import{useStore as de}from"zustand";import{createStore as wt}from"zustand/vanilla";function Ga(e){let n=e.service||e.services||[];for(let t of n)if(t.type==="AuthProbeService2")return!0;return!1}function F(e,n,t){let r=n.findIndex(i=>i.service.id===e);if(r===-1)return n;let o=[...n],s=t(o[r]);return s===o[r]?n:(o[r]=s,o)}var Et=()=>wt((e,n)=>({currentAuth:-1,authItems:[],login:()=>{let t=n().authItems[n().currentAuth];if(!t||t.isPending||t.isLoggedIn)return;if(t.type!=="active")throw new Error("Cannot login to non-active service");let r=t.service.service.find(o=>o.type==="AuthAccessTokenService2");if(!r)throw new Error("Token service not found");e(()=>({authItems:F(t.id,n().authItems,o=>({...o,isPending:!0}))})),Mt(t.service).then(()=>{Ke(r).then(o=>{let s=o.expiresIn,i=Date.now()+s*1e3;e(()=>({authItems:F(t.id,n().authItems,a=>({...a,isLoggedIn:!0,isPending:!1,session:{token:o.accessToken,expires:i}}))}))}).catch(o=>{e(()=>({authItems:F(t.id,n().authItems,s=>({...s,isLoggedIn:!1,isPending:!1,error:o.message}))}))})})},logout:()=>{let t=n().authItems[n().currentAuth];if(!t||t.isPending||!t.isLoggedIn)return;if(t.type!=="active")throw new Error("Cannot logout of non-active service");let r=t.service.service.find(i=>i.type==="AuthLogoutService2");if(!r)return;let o=`${r.id}?origin=${Nt()}`,s=window.open(o);e(()=>({authItems:F(t.id,n().authItems,i=>({...i,isLoggedIn:!1,session:null,isPending:!1}))}))},nextAuth:()=>{let t=n().authItems.length,r=n().currentAuth+1;r>=t||e(()=>({currentAuth:r}))},previousAuth:()=>{let t=n().currentAuth-1;t<0||e(()=>({currentAuth:t}))},setAuth:t=>{t!==-1&&(t<0||t>=n().authItems.length)||e(()=>({currentAuth:t}))},addService:(t,r)=>{if(!t.service)return;let o=t.service.find(a=>a.type==="AuthAccessTokenService2"),s=t;if(n().authItems.find(a=>a.service.id===t.id)){e(()=>({authItems:F(t.id,n().authItems,a=>({...a,instances:a.instances+1}))}));return}if(e(()=>({currentAuth:s.profile==="active"?0:n().currentAuth,authItems:[{id:t.id,type:t.profile,service:t,probeId:r,canAuthenticate:!0,instances:1,isPending:!1,isLoggedIn:!1,session:null},...n().authItems]})),t.profile==="external"){if(!o)throw new Error("Token service not found");Ke(o).then(a=>{e(()=>({authItems:F(t.id,n().authItems,u=>({...u,isLoggedIn:!0,isPending:!1,session:{token:a.accessToken,expires:a.expiresIn}}))}))}).catch(a=>{e(()=>({authItems:F(t.id,n().authItems,u=>({...u,isLoggedIn:!1,isPending:!1,canAuthenticate:!1,error:a.message}))}))})}if(t.profile==="kiosk"){if(!o)throw new Error("Token service not found");e(()=>({authItems:F(t.id,n().authItems,a=>({...a,isPending:!0}))})),Mt(s).then(()=>{Ke(o).then(a=>{e(()=>({authItems:F(t.id,n().authItems,u=>({...u,isLoggedIn:!0,isPending:!1,session:{token:a.accessToken,expires:a.expiresIn}}))}))}).catch(a=>{e(()=>({authItems:F(t.id,n().authItems,u=>({...u,isLoggedIn:!1,isPending:!1,error:a.message}))}))})})}t.profile},removeService:(t,r)=>{let o=n().currentAuth===n().authItems.findIndex(i=>i.service.id===t.id),s=n().currentAuth;if(o){let i=n().authItems.find(u=>u.service.id===t.id);i&&i.instances>1||(s=n().authItems.findIndex(c=>c.service.id!==t.id&&c.instances>0))}e(()=>({authItems:F(t.id,n().authItems,i=>({...i,instances:i.instances-1})),currentAuth:s}))}})),Vt=(e,n)=>wt((t,r)=>({service:e,status:e?"unknown":"success",shouldRedirect:!1,redirectResource:null,shouldSubstitute:!1,substituteResource:null,error:null,errorHeading:null,errorNote:null,shouldDisplayResource:!1,token:n||null,async probe(){if(!r().service)return;let o=r().service?.id;if(!o){t({status:"error",error:"Service ID not found",errorHeading:{en:["Service ID not found"]}});return}t({status:"probing"});let s=r().token;try{let i=await fetch(o,{headers:s?{Authorization:`Bearer ${r().token}`,Accept:"application/json"}:{Accept:"application/json"}}).then(a=>a.json());if(i.status===200)t({status:"success",shouldDisplayResource:!0,error:null,errorHeading:null,errorNote:null,shouldSubstitute:!1,shouldRedirect:!1});else if(i.status<400&&i.status>=300){if(!i.location)throw new Error("Redirect location not found");t({status:"error",shouldDisplayResource:!1,shouldRedirect:!0,redirectResource:i.location||null})}else if(i.status===401)t({status:"error",shouldDisplayResource:!1,shouldRedirect:!1,shouldSubstitute:!!i.substitute,substituteResource:i.substitute||null,error:"Unauthorized",errorHeading:i.heading||{en:["Unauthorized"]},errorNote:i.note||null});else throw new Error("Unknown error")}catch(i){t({status:"error",error:i.message,errorHeading:{en:["Unknown error"]}})}},setToken(o){t({token:o})}}));function kt(e){let n=e.service||e.services||[],t={hasAuth:!1,services:{}};for(let r of n)if(r.type==="AuthProbeService2"){t.services.probe=r,t.hasAuth=!0;let o=r.service.filter(s=>s.type==="AuthAccessService2");o[0]&&(t.services.access=o[0])}return t}async function Ke(e,{strict:n=!0}={}){return new Promise((t,r)=>{let o=Math.random().toString(36).substring(7),s=`${e.id}?messageId=${o}&origin=${window.location.origin}`,i=c=>{let l=c.data;if(l.messageId===o){if(n&&l.type!=="AuthAccessToken2"){a(),r("Invalid response, expected type=AuthAccessToken2");return}if(!l.accessToken){a(),r("Invalid response, expected accessToken");return}a(),t(l)}},a=()=>window.removeEventListener("message",i),u=document.createElement("iframe");u.src=s,u.style.display="none",document.body.appendChild(u),window.addEventListener("message",i)})}function Nt(e){let n=window.location;if(e){let t=document.createElement("a");return t.href=e,t.protocol+"//"+t.hostname+(t.port?":"+t.port:"")}return n.protocol+"//"+n.hostname+(n.port?":"+n.port:"")}async function Mt(e){let n=`${e.id}?origin=${Nt()}`,t=window.open(n);if(!t)throw new Error("Failed to open window");return new Promise((r,o)=>{let s=setInterval(()=>{t.closed&&(clearInterval(s),r())},500)})}import{useEffect as Lt,useMemo as zt}from"react";import{useStore as Mr}from"zustand";function Ot(e){let n=zt(()=>kt(e),[e]),t=Ht(n.services.access?.id),r=zt(()=>Vt(n.services.probe,t),[n.services.probe]),o=Mr(r);return Lt(()=>{o.status==="unknown"&&!t&&o.probe()},[n.services.probe,o.status]),Lt(()=>{t&&(o.setToken(t),o.probe())},[t]),[e,o,n.hasAuth]}import{jsx as Pe}from"react/jsx-runtime";var te=Qe(null),Vr=Qe(null);Vr.displayName="CurrentAuth";var kr=Qe(null);kr.displayName="AuthActions";function $t({children:e}){let n=Er(()=>Et(),[]);return Pe(te.Provider,{value:n,children:e})}function Dt(){return!!Ft(te)}function me(){let e=Ft(te);if(!e)throw new Error("useAuthActions must be used within a AuthProvider");return e}function Nr(){let e=me();return de(e,t=>({login:t.login,logout:t.logout,nextAuth:t.nextAuth,previousAuth:t.previousAuth,setAuth:t.setAuth,addService:t.addService,removeService:t.removeService}))}function ps(){let e=me();return de(e,n=>n)}function Lr(e){let n=me();return de(n,r=>r.authItems.find(o=>o.service.id===e))}function Ht(e){let n=me();return de(n,r=>r.authItems.find(o=>o.id===e)?.session?.token)}function gs(e){let n=me();return de(n,r=>{let o=r.authItems.find(s=>s.service.id===e);return!o||!o.isLoggedIn||!o.session?null:o.session?.token||null})}function zr(e){let n=Nr(),t=Lr(e.service.id);return wr(()=>(n?.addService(e.service,e.probeId),()=>{n?.removeService(e.service,e.probeId)}),[e.service]),t?(t.error||!t.isLoggedIn,e.children):null}function Ye(){return null}function Ut(e){let[n,t,r]=Ot(e.resource),o=e.fallbackComponent||Ye,s=e.loadingComponent||Ye,i=e.errorComponent||Ye,a=t.service,u=null;if(!r||!a)return e.children(n);let c=a.service.filter(l=>l.type==="AuthAccessService2");t.status==="error"&&(u=Pe(i,{resource:e.resource,error:t.error||"",heading:t.errorHeading,note:t.errorNote,extra:e.extra})),(t.status==="unknown"||t.status==="probing")&&(u=Pe(s,{})),t.status==="success"&&(u=e.children(n));for(let l of c)u=Pe(zr,{service:l,probeId:a.id,children:u},l.id);return u}import{createContext as $r,useContext as Ps,useMemo as Dr}from"react";import{createStore as Or}from"zustand/vanilla";var Hr=e=>e.id||e["@id"];function Fr(e){return(Array.isArray(e.service)?e.service:[e.service]).find(t=>t.profile==="http://iiif.io/api/search/0/autocomplete"||t.profile==="http://iiif.io/api/search/1/autocomplete"||t.profile==="AutoCompleteService1")}var qt=e=>{let n;typeof e=="string"?n={"@context":"http://iiif.io/api/search/1/context.json",profile:"http://iiif.io/api/search/1/search","@id":e,id:e,service:[]}:n=e;let t=n?Hr(n):void 0,r=null;return Or((o,s)=>({service:n,resources:[],lastQuery:{},loading:!1,error:!1,highlight:null,hasSearch:!!n,hasAutocomplete:n?!!Fr(n):!1,errorMessage:"",search(i,a={}){if(!t)throw new Error("No search service found.");r&&!r.signal.aborted&&r.abort(),r=new AbortController;let u=new URLSearchParams;i.q&&u.set("q",i.q),i.motivation&&u.set("motivation",i.motivation),i.date&&u.set("date",i.date),i.user&&u.set("user",i.user),o({loading:!0}),fetch(`${t}?${u.toString()}`,{signal:r.signal,headers:{"Content-Type":"application/json",Accept:"application/json",...a.headers||{}}}).then(async c=>{if(!r?.signal.aborted)if(c.ok){let l=await c.json();o({resources:l.resources,error:!1,errorMessage:""})}else o({resources:[],error:!0,errorMessage:c.statusText})})},clearSearch(){o({resources:[],error:!1,errorMessage:""})},highlightResult(i){let a=s().resources.find(u=>u["@id"]===i);o({highlight:a})},nextResult(){let i=s().resources,a=s().highlight;if(!a){o({highlight:i[0]||null});return}let u=i.findIndex(c=>c["@id"]===a["@id"]);if(u===-1){o({highlight:i[0]||null});return}o({highlight:i[u+1]||i[0]||null})},previousResult(){let i=s().resources,a=s().highlight;if(!a){o({highlight:i[i.length-1]||null});return}let u=i.findIndex(c=>c["@id"]===a["@id"]);if(u===-1){o({highlight:i[i.length-1]||null});return}if(u===0){o({highlight:i[i.length-1]||null});return}o({highlight:i[u-1]||i[i.length-1]||null})}}))};import{useStore as ws}from"zustand";function Bt(){let e=E();return e?e.service.find(n=>n.profile==="SearchService1"||n.profile==="http://iiif.io/api/search/1/search"):void 0}import{jsx as We}from"react/jsx-runtime";var ne=$r(null);ne.displayName="Search";function _t(e){let n=Bt();return e.store?We(ne.Provider,{value:e.store,children:e.children}):We(Ur,{service:n,children:e.children})}function Ur({service:e,children:n}){let t=Dr(()=>qt(e),[e]);return We(ne.Provider,{value:t,children:n})}import{jsx as z}from"react/jsx-runtime";var fe=()=>{},pe=Br({setCurrentCanvasId:fe,setCurrentCanvasIndex:fe,nextCanvas:fe,previousCanvas:fe,items:[],sequence:[],setSequenceIndex:fe,currentSequenceIndex:0,hasNext:!1,hasPrevious:!1});function jr(e){let n=E(),{cursor:t,visibleItems:r,next:o,sequence:s,items:i,setCanvasIndex:a,setCanvasId:u,previous:c,setSequenceIndex:l,hasNext:d,hasPrevious:y}=It({startCanvas:e.startCanvas,disablePaging:e.pagingEnabled===!1}),A=_r(()=>({sequence:s,items:i,setCurrentCanvasId:u,nextCanvas:o,previousCanvas:c,totalCanvases:i.length,setCurrentCanvasIndex:a,setSequenceIndex:l,currentSequenceIndex:t,hasNext:d,hasPrevious:y}),[s,i,u,o,c,i,a,l,t]);return n?r.length===0?null:z(pe.Provider,{value:A,children:z(ee.Provider,{value:r,children:z(q,{canvas:r[0],children:e.children})})}):(console.warn("The manifest passed to the provider is not a valid IIIF manifest."),z("div",{children:"Sorry, something went wrong."}))}function jt(e){let n=X(e.vault),t=At(e.manifest);if(!t)return console.warn("The manifest passed to the provider is not a valid IIIF manifest."),z("div",{children:"Sorry, something went wrong."});if(t.error)return z("div",{children:t.error.toString()});if(!t.isLoaded)return z("div",{children:"Loading..."});let r=z(jr,{...e,children:e.children});return z(J,{vault:n,children:z(bt,{manifest:t.id,children:z($t,{children:z(_t,{children:e.rangeId?z(Pt,{range:e.rangeId,children:r}):r})})})})}function Kt(){return qr(pe)}import Kr from"react";import{createContext as Yr,useMemo as Qr}from"react";import Wr from"mitt";import{jsx as Zr}from"react/jsx-runtime";var Gr=Wr(),re=Yr({emitter:Gr});re.displayName="Events";function Yt(){return Kr.useContext(re).emitter}function au({emitter:e,children:n}){return Zr(re.Provider,{value:Qr(()=>({emitter:e}),[e]),children:n})}import{jsx as oe}from"react/jsx-runtime";function Qt(){return{VaultContext:W(Q),ResourceContext:W(Ce),SimpleViewerReactContext:W(pe),VisibleCanvasReactContext:W(ee),AuthRContext:W(te),SearchReactContext:W(ne),ReactEventContext:W(re)}}function Wt(e){return oe(J,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:oe(ee.Provider,{value:e.bridge.VisibleCanvasReactContext,children:oe(pe.Provider,{value:e.bridge.SimpleViewerReactContext,children:oe(re.Provider,{value:e.bridge.ReactEventContext,children:oe(te.Provider,{value:e.bridge.AuthRContext,children:oe(ne.Provider,{value:e.bridge.SearchReactContext,children:e.children})})})})})})}import{createContext as no,useContext as ro,useMemo as oo}from"react";import{useCallback as Zt,useLayoutEffect as Xr,useMemo as eo,useRef as to}from"react";import{entityActions as Ge}from"@iiif/helpers/vault/actions";import{useMemo as Jr}from"react";function Gt(){let n=R().getStore();return Jr(()=>t=>n.dispatch(t),[n])}function Jt(e){return typeof e!="string"&&e&&e.bindToVault}function Xt(){let e=R(),n=to([]),t=Gt(),r=eo(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);Xr(()=>{let a={id:r,type:"AnnotationPage",behavior:[],label:null,thumbnail:[],summary:null,requiredStatement:null,metadata:[],rights:null,provider:[],items:[],seeAlso:[],homepage:[],rendering:[],service:[]};t(Ge.importEntities({entities:{AnnotationPage:{[a.id]:a}}}))},[r]);let o=T(a=>r&&a.iiif.entities.AnnotationPage[r]||null,[r]),s=Zt((a,u)=>{if(r){if(Jt(a)){let d=a;d.__vault||d.bindToVault(e),a=typeof d.source=="string"?d.source:d.source.id,n.current[a]=d}else typeof a!="string"&&(a=a.id);let c=e.get({id:r,type:"AnnotationPage"}),l=e.get({id:a,type:"Annotation"});c&&l&&(c.items.find(d=>d.id===l.id)||t(Ge.addReference({id:r,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"},index:u})))}},[r]),i=Zt(a=>{r&&(Jt(a)?a=typeof a.source=="string"?a.source:a.source.id:typeof a!="string"&&(a=a.id),n.current[a]&&n.current[a].beforeRemove(),e.get({id:r,type:"AnnotationPage"})&&t(Ge.removeReference({id:r,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"}})))},[r]);return[o,{addAnnotation:s,removeAnnotation:i}]}import{jsx as io}from"react/jsx-runtime";var en=no(null);function tn(){let e=ro(en);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function nn({children:e}){let[n,{addAnnotation:t,removeAnnotation:r}]=Xt();return io(en.Provider,{value:oo(()=>({fullPage:n,addAnnotation:t,removeAnnotation:r}),[n]),children:e})}import{jsx as Ze,jsxs as ao}from"react/jsx-runtime";function rn({width:e,style:n,height:t,error:r,resetErrorBoundary:o}){return ao("div",{style:{width:e,height:t,minHeight:500,...n||{},background:"#f9f9f9"},children:[Ze("h3",{children:"Error occurred"}),Ze("p",{children:r.message}),Ze("button",{onClick:o,children:"Reset"})]})}import{createContext as so,useContext as uo}from"react";var ge=so(null);function on(){return uo(ge)}import{createContext as an,useContext as co,useEffect as lo}from"react";var Je=an(()=>{}),Xe=an(()=>{});function O(e,n,t,r,o=[]){let s=co(e==="portal"?Xe:Je);lo(()=>(e!=="none"&&s(n,t,r),()=>{s(n,null)}),[n,e,s,...o])}import{createContext as fo,useContext as po,useEffect as go}from"react";import{useMemo as mo}from"react";function M(e={},n=[]){let{id:t,selector:r}=e,o=H(),s=t||o.canvas,i=T(a=>s?a.iiif.entities.Canvas[s]:void 0,[s]);return mo(()=>{if(i)return r?r(i):i},[i,r,...n])}var et=fo(()=>{});function sn(e){let n=M(),t=po(et);go(()=>n&&n.id?(t(n.id,e),()=>t(n.id,-1)):()=>{},[n,e])}import{Fragment as xo,jsx as V,jsxs as So}from"react/jsx-runtime";function ln({children:e,errorFallback:n,outerContainerProps:t={},worldScale:r,...o}){let[s,i]=Re(),a=Qt(),u=n||rn,[c,l]=Re({}),d=Object.entries(c),[y,A]=Re({}),h=Object.entries(y),[g,b]=Re({}),p=cn(()=>r||Math.max(...Object.values(g)),[g]),S=cn(()=>({maxOverZoom:p||1,...o.runtimeOptions||{}}),[p,o.runtimeOptions]),m=tt((x,P)=>{b(C=>{if(P===-1){let{[x]:_,...f}=C;return f}return{...C,[x]:P}})},[]),v=tt((x,P,C)=>{l(({[x]:_,...f})=>P?{...f,[x]:{element:P,props:C}}:f)},[]),I=tt((x,P,C)=>{A(({[x]:_,...f})=>P?{...f,[x]:{element:P,props:C}}:f)},[]);return So(yo,{resetKeys:[],fallbackRender:x=>V(u,{...o,...x}),children:[V(vo,{...o,containerProps:{style:{position:"relative"},...o.containerProps||{}},htmlChildren:V(xo,{children:d.map(([x,{element:P,props:C}])=>V(un.Fragment,{children:V(P,{...C||{}})},x))}),onCreated:x=>{i(x),o.onCreated&&o.onCreated(x)},runtimeOptions:S,children:V(ge.Provider,{value:s,children:V(et.Provider,{value:m,children:V(Je.Provider,{value:v,children:V(Xe.Provider,{value:I,children:V(Wt,{bridge:a,children:V(ho.Provider,{value:o.mode||"explore",children:V(nn,{children:e})})})})})})})}),V("div",{children:h.map(([x,{element:P,props:C}])=>V(un.Fragment,{children:V(P,{...C||{}})},x))})]})}import{mergeStyles as To,RegionHighlight as Io}from"@atlas-viewer/atlas";import{useMemo as dn}from"react";import{createEventsHelper as Co}from"@iiif/helpers/events";function Te(e,n){let t=R(),r=dn(()=>Co(t),[t]),o=T(()=>e&&e.id?t.getResourceMeta(e.id,"eventManager"):null,[e]);return dn(()=>e?r.getListenersAsProps(e,n):{},[o,e,t,n])}import{useMemo as Ao}from"react";import{createStylesHelper as bo}from"@iiif/helpers/styles";function ie(e,n){let t=R(),r=Ao(()=>bo(t),[t]);return T(()=>{if(!e)return null;let o=r.getAppliedStyles(e.id);return o?n?o[n]:o:void 0},[e,n])}import{useMemo as Mo}from"react";import{useMemo as Po}from"react";import{expandTarget as Ro}from"@iiif/helpers/annotation-targets";function Ie(e={},n=[]){let{id:t,selector:r}=e,o=H(),s=R(),i=t||o.annotation,a=T(c=>i?c.iiif.entities.Annotation[i]:void 0,[i]),u=T(c=>a&&a.body?a.body.map(l=>l?l.type==="SpecificResource"?{...l,source:s.get(l)}:l?c.iiif.entities[l.type][l.id]:null:null).filter(Boolean):[],[a]);return Po(()=>{if(!a)return;let c={...a,body:u,target:Ro(a.target,{typeMap:s.getState().iiif.mapping})};return r?r(c):c},[a,r,u,...n])}import{jsx as wo}from"react/jsx-runtime";var Me=({id:e,style:n,className:t,interactive:r})=>{let o=Ie({id:e}),s=ie(o,"atlas"),i=ie(o,"html"),a=Te(o,["atlas"]),u=M(),c=Mo(()=>To(n,s),[n,s]);return u&&o&&o.target&&o.target.selector&&o.target.selector.type==="BoxSelector"&&o.target.source&&(o.target.source.id===u.id||o.target.source===u.id)?wo(Io,{id:o.id,isEditing:!0,region:o.target.selector.spatial,style:c,className:i?.className||t,interactive:!!(i?.href||r),href:i?.href||null,title:i?.title||null,hrefTarget:i?.target||null,onClick:()=>{},...a}):null};import{Fragment as Vo}from"react";import{useMemo as Eo}from"react";function mn(e={},n=[]){let{id:t,selector:r}=e,o=H(),s=t||o.annotationPage,i=T(a=>s?a.iiif.entities.AnnotationPage[s]:void 0,[s]);return Eo(()=>{if(i)return r?r(i):i},[i,...n])}import{jsx as fn}from"react/jsx-runtime";var ve=({className:e,page:n})=>{let t=mn({id:n.id})||n,r=ie(t,"atlas"),o=ie(t,"html");return T(s=>t.id?s.iiif.entities.AnnotationPage[t.id]:null,[]),fn(Vo,{children:t.items?.map(s=>fn(Me,{id:s.id,style:r,className:o?.className||e},s.id))})};import{createStylesHelper as Vi}from"@iiif/helpers/styles";import{Fragment as bn,useMemo as Fo}from"react";import{HTMLPortal as zo,TileSet as Cn}from"@atlas-viewer/atlas";import ae,{useMemo as nt}from"react";import{jsx as $}from"react/jsx-runtime";var gn=ae.createContext("en"),vn=ae.createContext({}),hn=ae.createContext(null);function Xc(e){return $(vn.Provider,{value:e.translations,children:e.children})}function el(e){return $(gn.Provider,{value:e.language,children:e.children})}function tl(e){return $(hn.Provider,{value:e.convert,children:e.children})}function yn(){return ae.useContext(hn)}function rt(){return ae.useContext(gn)}function xn(){return ae.useContext(vn)}function pn(e){return e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):e}function ko({as:e,language:n,children:t,viewingDirection:r,...o}){let s=rt();return nt(()=>pn(s)===pn(n),[s,n])?e?$(e,{...o,children:t}):$("span",{...o,children:t}):e?$(e,{...o,lang:n,dir:r,children:t}):$("span",{...o,lang:n,dir:r,children:t})}function Sn(e,n,t){if(n.length===0)return;if(n.length===1)return n[0];if(n.indexOf(e)!==-1)return e;let r=e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):null;if(r&&n.indexOf(r)!==-1)return r;for(let o of t)if(n.indexOf(o)!==-1)return o;return n.indexOf("none")!==-1?"none":n.indexOf("@none")!==-1?"@none":n[0]}var No=(e,n=[])=>{let t=rt();return nt(()=>{let r=e();return Sn(t,r,[])},[t,...n])};function G(e,n,t,r){return n?t?t(e[n]||n,r||"none"):e[n]||n:""}function Lo(e,n,t=`
|
|
2
|
-
`,r={}){let o=
|
|
3
|
-
`,a=n){let u=Object.keys(o||{}),c=
|
|
4
|
-
`):""}}function he({as:e,defaultText:n,enableDangerouslySetInnerHTML:t,children:r,separator:o,...s}){let i=xn(),[a,u]=Lo(r,n,o,i);return u?$(ko,{...s,as:e,language:u,title:t?void 0:a,dangerouslySetInnerHTML:t?{__html:a}:void 0,children:t?void 0:a}):e?$(e,{...s,children:a}):$("span",{...s,title:t?void 0:a,dangerouslySetInnerHTML:t?{__html:a}:void 0,children:t?void 0:a})}import{jsx as B,jsxs as Ho}from"react/jsx-runtime";function Oo({resource:e,heading:n,note:t,extra:r}){return r?B(zo,{target:{x:0,y:0,width:r.target?.spatial.width,height:r.target?.spatial.height},backgroundColor:"#333",relative:!0,children:B("div",{style:{display:"flex",alignContent:"center",justifyContent:"center",alignItems:"center",height:"100%",width:"100%",background:"#444",color:"#BBB"},children:Ho("div",{children:[B(he,{children:n||"Not authorised"}),t&&B("p",{children:B(he,{children:t})}),B("p",{children:e.id||e["@id"]||"unknown"})]})})}):null}function An({image:e,thumbnail:n,crop:t,enableSizes:r}){if(!Dt()){let s=e.service,i=s.width||e.width||0,a=s.height||e.height||0;return B(Cn,{tiles:{id:s.id||s["@id"]||"unknown",height:a,width:i,imageService:s},enableSizes:r,x:0,y:0,width:e.target?.spatial.width,height:e.target?.spatial.height,crop:t})}return B(Ut,{resource:e.service,errorComponent:Oo,extra:e,children:s=>{let i=s.width||e.width||0,a=s.height||e.height||0;return B(Cn,{tiles:{id:s.id||s["@id"]||"unknown",height:a,width:i,imageService:s},enableSizes:r,x:0,y:0,width:e.target?.spatial.width,height:e.target?.spatial.height,crop:t})}},e.id)}import{jsx as ot,jsxs as Pn}from"react/jsx-runtime";function se({id:e,image:n,thumbnail:t,isStatic:r,x:o=0,y:s=0,children:i,selector:a,onClick:u,enableSizes:c}){let l=Fo(()=>{if(!(!a||a.spatial.x===0&&a.spatial.y===0))return a.spatial},[a]);return ot("world-object",{x:o+n.target.spatial.x,y:s+n.target.spatial.y,width:n.target.spatial.width,height:n.target.spatial.height,onClick:u,children:n.service?Pn(bn,{children:[ot(An,{image:n,thumbnail:t,crop:l,enableSizes:c}),i]},"service"):Pn(bn,{children:[ot("world-image",{onClick:u,uri:n.id,target:{x:0,y:0,width:n.target.spatial.width,height:n.target.spatial.height},display:n.width&&n.height?{width:n.width,height:n.height}:void 0,crop:l}),i]},"no-service")},e+(n.service?"server":"no-service"))}import{Fragment as ki,useEffect as Jn,useLayoutEffect as Ni,useMemo as Xn}from"react";import{useEffect as Ln,useMemo as zn}from"react";import{useCallback as In,useMemo as Do}from"react";function $o(e,n){let t=e?.iiif?.meta[n];return t?t.annotationPageManager:null}function Rn(e,n){return T(t=>{let r=[];if(!e)return r;let o=Object.keys(t.iiif.entities.AnnotationPage);for(let s of o)if(!n||n.indexOf(s)!==-1){let i=$o(t,s);i&&i.views&&i.views[e]&&r.push(s)}return r},[e,n])}function Tn({canvas:e,manifest:n,all:t,canvases:r}){let o=[];if(n)for(let s of n.annotations)o.indexOf(s.id)===-1&&o.push(s.id);if(t){if(r&&r.length)for(let s of r)for(let i of s.annotations)o.indexOf(i.id)===-1&&o.push(i.id)}else if(e)for(let s of e.annotations)o.indexOf(s.id)===-1&&o.push(s.id);return o}function Uo(e,n){let t=e?.iiif?.meta[n];return t?t.annotationPageManager:null}function Mn(e,n={}){let t=R(),r=E(),o=M(),s=Ae(),i=Do(()=>Tn({all:n.all,manifest:r,canvas:o,canvases:s}),[n.all,o,s,r]),a=Rn(e,n.all?void 0:i),u=In(l=>{e&&t.setMetaValue([l,"annotationPageManager","views"],d=>d&&!d[e]?d:{...d||{},[e]:!1})},[e,t]),c=In((l,d={})=>{if(!e)return;let y=t.getState(),A=[];if(d?.deselectOthers){let h=Object.keys(y.iiif.entities.AnnotationPage);for(let g of h){let b=Uo(y,g);b&&b.views&&b.views[e]&&A.push(g)}}for(let h of A)u(h);t.setMetaValue([l,"annotationPageManager","views"],h=>h&&h[e]?h:{...h||{},[e]:!0})},[e,u,t]);return{availablePageIds:i,enabledPageIds:a,setPageEnabled:c,setPageDisabled:u}}function wn(e,n){return T((t,r)=>r.get(e.map(o=>({id:o,type:n}))),[e,n])}import{useCallback as Ko,useEffect as Yo,useRef as Qo,useState as Wo}from"react";import qo,{useContext as Bo}from"react";import{ImageServiceLoader as _o}from"@atlas-viewer/iiif-image-api";var jo=qo.createContext(new _o);function we(){return Bo(jo)}function En(){let e=we(),[n,t]=Wo({}),r=Qo(!1);return Yo(()=>()=>{r.current=!0},[]),[Ko((s,{height:i,width:a})=>{if(s){let u=s.id||s["@id"],c=e.loadServiceSync({id:u,width:s.width||a,height:s.height||i,source:s});c?s=c:n[u]||(r.current||t(l=>({...l,[u]:"loading"})),e.loadService({id:u,width:s.width||a,height:s.height||i}).then(()=>{r.current||t(l=>({...l,[u]:"done"}))}))}return s},[e,n]),n]}import{useCallback as Go,useMemo as kn,useState as Zo}from"react";function Vn(e={}){let n=Ie(),t=M(e.canvasId?{id:e.canvasId}:void 0);return T((r,o)=>{if(!t)return[];if(n&&e.enableSingleAnnotation)return[n];let s=o.get(t.items),i=[];for(let a of s)i.push(...o.get(a.items));return i},[t])}import{createPaintingAnnotationsHelper as Jo}from"@iiif/helpers/painting-annotations";function Nn(e,n=[]){let t=R(),r=kn(()=>Jo(t),[]),o=Vn({enableSingleAnnotation:e?.enableSingleAnnotation}),[s,i]=Zo(e?.defaultChoices||[]),a=kn(()=>r.getPaintables(o,s),[t,o,s,...n]),c={makeChoice:Go((l,{deselectOthers:d=!0,deselect:y=!1}={})=>{a.choice&&i(A=>{if(y){let g=A.filter(b=>b!==l);if(g.length===0){let b=a.items[0].resource.id;return b?[b]:[]}return g}if(d)return[l];let h=[...A];if(h.length===0&&a.items.length){let g=a.items[0].resource.id;g&&h.push(g)}return A.indexOf(l)!==-1?A:[...A,l]})},[a.choice])};return[a,c]}function On(e){let n=E(),t=M(),r=R(),o=Yt(),s=e?.emitter||o,[i,a]=En(),{enabledPageIds:u}=Mn(e?.annotationPageManagerId||n?.id||t?.id,{all:!1}),c=wn(u,"AnnotationPage"),l=e?.strategies||["empty","images","media","textual-content","complex-timeline"],[d,y]=Nn(e,[a]);Ln(()=>{let h=g=>{y.makeChoice(g.choiceId,{deselectOthers:g.deselectOthers,deselect:g.deselect})};return s.on("make-choice",h),()=>{s.off("make-choice",h)}},[]);let A=zn(()=>yt({canvas:t,paintables:d,supports:l,loadImageService:i}),[t,d,r,y.makeChoice]);return Ln(()=>{let h=d.allChoices,g={canvasId:t?.id,manifestId:n?.id};h&&s.emit("choice-change",{choice:h,partOf:g})},[t?.id,d.allChoices]),zn(()=>A.type==="unknown"?[A,ht]:[{...A,annotations:{pages:c}},y],[A,c])}import{useEffect as ei,useMemo as ti,useRef as ni,useState as ri}from"react";import{useEffect as Xo}from"react";var Hn=(e,n=[])=>{let t=R();Xo(()=>{e(t)},[t,...n])};import{createThumbnailHelper as oi}from"@iiif/helpers/thumbnail";function Ee(e,n,{canvasId:t,manifestId:r}={}){let o=R(),s=we(),i=ti(()=>oi(o,{imageServiceLoader:s}),[o,s]),[a,u]=ri(),c=E(r?{id:r}:void 0),l=M(t?{id:t}:void 0),d=l||c,y=ni(!1);if(ei(()=>(y.current=!1,()=>{y.current=!0}),[]),!d)throw new Error("Must be called under a manifest or canvas context.");return Hn(A=>{i.getBestThumbnailAtSize(d,e,n).then(h=>{h.best&&!y.current&&u(h.best)})},[d]),a}import{useCallback as D,useEffect as Fn,useReducer as ii,useRef as Ve}from"react";function ai(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function si(e,n){switch(n.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:n.volume,isMuted:n.volume===0};case"TOGGLE_MUTE":return{...e,isMuted:!e.isMuted};case"UNMUTE":return{...e,isMuted:!1}}return e}function it(e){let n=Math.round(e);return`${Math.floor(n/60)}:${`${n%60}`.padStart(2,"0")}`}function ue(e){let[n,t]=ii(si,ai(e.duration)),r=Ve(null),o=Ve(null),s=Ve(null),i=Ve(!1),a=D(()=>{o.current&&r.current&&(o.current.innerHTML=it(r.current.currentTime),s.current&&(s.current.style.width=`${r.current.currentTime/e.duration*100}%`),i.current!==r.current.muted&&(i.current=r.current.muted,t(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"})))},[e.duration]),u=D(()=>{r.current&&(t({type:"PLAY_REQUESTED"}),r.current.play().then(()=>{t({type:"PLAY"})}),a())},[a]),c=D(()=>{r.current&&(r.current.duration>0&&r.current.paused?u():l())},[a]),l=D(()=>{r.current&&(r.current.pause(),t({type:"PAUSE"}),a())},[a]),d=D(()=>{r.current&&(r.current.muted=!r.current.muted,t(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"}))},[]),y=D(()=>{r.current&&(r.current.muted=!0,t({type:"MUTE"}))},[]),A=D(()=>{r.current&&(r.current.muted=!1,t({type:"UNMUTE"}))},[]),h=D(p=>{r.current&&(r.current.muted=!1,r.current.volume=p/100,t({type:"SET_VOLUME",volume:p}))},[]),g=D(p=>{r.current&&(r.current.currentTime=Math.max(0,Math.min(p*e.duration,e.duration)),a())},[]),b=D(p=>{if(r.current){let S=typeof p=="function"?p(r.current.currentTime):p;r.current.currentTime=Math.max(0,Math.min(S,e.duration)),a()}},[]);return Fn(()=>{let p=setInterval(()=>{a()},350);return()=>clearInterval(p)},[a,e.duration]),Fn(()=>{let p=()=>{t({type:"FINISHED"})},S=r.current;return S?.addEventListener("ended",p),()=>S?.removeEventListener("ended",p)},[]),[{element:r,currentTime:o,progress:s},n,{play:u,pause:l,playPause:c,mute:y,unmute:A,toggleMute:d,setVolume:h,setDurationPercent:g,setTime:b}]}import{createContext as st,useContext as ut}from"react";import{jsx as at}from"react/jsx-runtime";var $n=st(null),Dn=st(null),Un=st(null);function xd(){let e=ut($n);if(!e)throw new Error("Ctx not found");return e}function Sd(){let e=ut(Dn);if(!e)throw new Error("Ctx not found");return e}function Cd(){let e=ut(Un);if(!e)throw new Error("Ctx not found");return e}function ke({actions:e,state:n,children:t,currentTime:r,progress:o,element:s}){return at(Un.Provider,{value:{currentTime:r,progress:o,element:s},children:at(Dn.Provider,{value:e,children:at($n.Provider,{value:n,children:t})})})}import{useMemo as ui}from"react";import{expandTarget as ci}from"@iiif/helpers";function Ne(){let e=E(),n=M();return ui(()=>{if(!e||!n||!e.start)return null;let t=ci(e.start);return!t||t.source.id!==n.id||!t||!t.selector||t.selector.type!=="TemporalSelector"?null:t.selector.temporal},[e,n])}import{jsx as li,jsxs as di}from"react/jsx-runtime";function ct({media:e,startTime:n,children:t}){let[{element:r,currentTime:o,progress:s},i,a]=ue({duration:e.duration}),u=n?`${e.url}#t=${n}`:e.url;return di(ke,{state:i,actions:a,currentTime:o,progress:s,element:r,children:[li("audio",{ref:r,src:u}),t]})}function Le({media:e,mediaControlsDeps:n,children:t}){let r=Ne();return O("portal","audio",ct,{media:e,startTime:r?r.startTime:null,children:t},[e,r,...n||[]]),null}import{jsx as qn,jsxs as mi}from"react/jsx-runtime";function lt({element:e,media:n,startTime:t,playPause:r,poster:o}){let s="div",i=t?`${n.url}#t=${t}`:n.url;return mi(s,{className:"video-container",part:"video-container",onClick:r,children:[qn("style",{children:`
|
|
1
|
+
import{c as vt,l as ht}from"./chunk-UFC4ZSNV.js";import{forwardRef as Xn,useImperativeHandle as Li}from"react";import sn,{useCallback as tt,useMemo as un,useState as Re}from"react";import{AtlasAuto as vo,ModeContext as ho}from"@atlas-viewer/atlas";import{ErrorBoundary as yo}from"react-error-boundary";import{useContext as W}from"react";import nr,{useContext as rr,useMemo as or}from"react";import{jsx as ar}from"react/jsx-runtime";var ir={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0,annotationPage:void 0},Ce=nr.createContext(ir),H=()=>rr(Ce);function K({value:e,children:n}){let t=H(),r=or(()=>({...t,...e}),[e,t]);return ar(Ce.Provider,{value:r,children:n})}import sr,{useState as ur}from"react";import{Vault as yt,globalVault as cr}from"@iiif/helpers/vault";import{jsx as xt}from"react/jsx-runtime";var Q=sr.createContext({vault:null,setVaultInstance:e=>{}});function J({vault:e,vaultOptions:n,useGlobal:t,resources:r,children:o}){let[s,i]=ur(()=>e||(t?cr(n):n?new yt(n):new yt));return xt(Q.Provider,{value:{vault:s,setVaultInstance:i},children:xt(K,{value:r||{},children:o})})}import{useContext as qr}from"react";import{createContext as Br,useMemo as _r}from"react";import{globalVault as lr}from"@iiif/helpers/vault";import{useContext as dr}from"react";function X(e){let n=dr(Q);return e||(n&&n.vault?n.vault:lr())}import{useEffect as mr,useMemo as fr,useState as Be}from"react";function St(e,{noCache:n=!1}={}){let t=typeof e=="string"?e:e.id,r=X(),[o,s]=Be(t),[i,a]=Be(void 0),u=fr(()=>r.get(t,{skipSelfReturn:!0})||void 0,[t,r]),[c,l]=Be(u);return mr(()=>{(async()=>{try{let d=u&&!n?u:await r.load(t),y=d?d.id||d["@id"]:null;d&&o!==y&&s(y),l(d)}catch(d){a(d)}})()},[t,n]),{isLoaded:!!c,id:o,requestId:t,error:i,resource:c,cached:!!(c&&c===u)}}function Ct(e,n){let{id:t,isLoaded:r,error:o,resource:s,requestId:i,cached:a}=St(e,n);return{id:t,isLoaded:r,error:o,manifest:s,requestId:i,cached:a}}import{jsx as pr}from"react/jsx-runtime";function At({manifest:e,children:n}){return pr(K,{value:{manifest:e},children:n})}import{jsx as gr}from"react/jsx-runtime";function q({canvas:e,children:n}){return gr(K,{value:{canvas:e},children:n})}import{useContext as xr}from"react";import Sr from"react";import{useContext as vr}from"react";var R=()=>{let{vault:e}=vr(Q);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};import{useEffect as hr,useState as yr}from"react";function T(e,n=[]){let t=R(),[r,o]=yr(()=>e(t.getState(),t));return hr(()=>t.subscribe(s=>e(s,t),s=>{o(s)},!1),n),r}var ee=Sr.createContext([]);function Ae(){let e=xr(ee);return T(n=>e.map(t=>n.iiif.entities.Canvas[t]).filter(Boolean),[e])}import{useMemo as Cr}from"react";function E(e={},n=[]){let{id:t,selector:r}=e,o=H(),s=R(),i=t||o.manifest,a=T(u=>i?u.iiif.entities.Manifest[i]:void 0,[i]);return Cr(()=>{if(a)return r?r(a):a},[a,r,...n])}import{jsx as Ar}from"react/jsx-runtime";function bt({range:e,children:n}){return Ar(K,{value:{range:e},children:n})}function br(e,n){for(let t of n.items){if(t.type==="Canvas")return t;if(t.type==="SpecificResource")return t.source;if(t.type==="Range"){let r=br(e,e.get(t));if(r)return r}}return null}function _e(e,n){let t=[];for(let r of n.items)if(r.type==="SpecificResource"&&r.source?.type==="Canvas"&&(r.source.id.indexOf("#")!==-1?t.push({id:r.source.id.split("#")[0],type:"Canvas"}):t.push(r.source)),r.type==="Range"&&t.push(..._e(e,e.get(r))),r.type==="SpecificResource"){let o=typeof r.source=="string"?r.source:r.source.id;t.push({id:o,type:"Canvas"})}return t}function La(e,n,t){for(let r of n.structures){let o=Pt(e,e.get(r),t);if(o)return o}return null}function Pt(e,n,t){for(let r of n.items){let o=r?.source?.id?.split("#")[0];if(r.type==="SpecificResource"&&r.source===t||r.type==="SpecificResource"&&r.source?.type==="Canvas"&&t===o)return n;if(r.type==="Range"){let s=Pt(e,e.get(r),t);if(s)return s}}return null}function Ha(e,n,t,r=!1){let o=n.behavior,s=t?e.get(t):null;if(!s)return[];let i=s.behavior,a=r?!1:o.includes("paged"),u=a?!1:o.includes("continuous"),c=a||u?!1:o.includes("individuals"),l=i.includes("facing-pages"),d=i.includes("non-paged");if(l||d||c||r)return[{id:s.id,type:"Canvas"}];let[y,A]=je(e,n);if(u)return y;let h=y.findIndex(g=>g.id===t);if(h===-1)return[];for(let g of A)if(g.includes(h))return g.map(b=>y[b]);return[{id:s.id,type:"Canvas"}]}function je(e,n,{disablePaging:t,skipNonPaged:r}={}){let o=n.behavior,s=o.includes("paged"),i=s?!1:o.includes("continuous"),a=s||i?!1:o.includes("individuals"),u=n.type==="Manifest"?n.items:_e(e,n);if(i)return[u,[u.map((h,g)=>g)]];if(a||!s||t)return[u,u.map((h,g)=>[g])];let c=[],l=[],d=()=>{l.length&&(c.push([...l]),l=[])},y=0,A=!1;for(let h=0;h<u.length;h++){let g=e.get(u[h]);if(g.behavior.includes("non-paged")){h===y&&y++,r||(d(),c.push([h]),d());continue}if(h===y||g.behavior.includes("facing-pages")){l.length&&(A=!0),d(),c.push([h]),d();continue}if(l.push(h),A){d(),A=!1;continue}l.length>1&&d()}return l.length&&d(),[u,c]}import{useCallback as be,useMemo as Rr,useRef as Tr,useState as Ir}from"react";import{useMemo as Pr}from"react";function Rt(e={},n=[]){let{id:t,selector:r}=e,o=H(),s=t||o.range,i=T(a=>s?a.iiif.entities.Range[s]:void 0,[s]);return Pr(()=>{if(i)return r?r(i):i},[i,r,...n])}function Tt({startCanvas:e,disablePaging:n}){let t=R(),r=E(),o=Rt(),[s,i]=Ir(void 0),a=o||r;if(!a)throw new Error("Nothing selected");let[u,c]=Rr(()=>je(t,a,{disablePaging:n}),[t,a,n]),l=Tr(c);if(l.current!==c){let b=l.current[s][0],p=c.findIndex(S=>S.includes(b));l.current=c,i(p)}let d=be(g=>{let b=c.findIndex(p=>p.includes(g));i(b===-1?0:b)},[u,c]),y=be(g=>{let b=u.findIndex(p=>p.id===g);b!==-1?d(b):i(0)},[u,c]),A=be(()=>{i(g=>g>=c.length-1?g:g+1)},[c]),h=be(()=>{i(g=>g<=0?0:g-1)},[c]);return typeof s>"u"&&(e?y(e):i(0)),{visibleItems:c[s]?.map(g=>u[g].id)||[],cursor:s,items:u,sequence:c,hasPrevious:s>0,hasNext:s<c.length-1,setSequenceIndex:i,setCanvasIndex:d,setCanvasId:y,next:A,previous:h}}import{createContext as Qe,useContext as Ht,useEffect as wr,useMemo as Er}from"react";import{useStore as de}from"zustand";import{createStore as Mt}from"zustand/vanilla";function Ga(e){let n=e.service||e.services||[];for(let t of n)if(t.type==="AuthProbeService2")return!0;return!1}function F(e,n,t){let r=n.findIndex(i=>i.service.id===e);if(r===-1)return n;let o=[...n],s=t(o[r]);return s===o[r]?n:(o[r]=s,o)}var wt=()=>Mt((e,n)=>({currentAuth:-1,authItems:[],login:()=>{let t=n().authItems[n().currentAuth];if(!t||t.isPending||t.isLoggedIn)return;if(t.type!=="active")throw new Error("Cannot login to non-active service");let r=t.service.service.find(o=>o.type==="AuthAccessTokenService2");if(!r)throw new Error("Token service not found");e(()=>({authItems:F(t.id,n().authItems,o=>({...o,isPending:!0}))})),It(t.service).then(()=>{Ke(r).then(o=>{let s=o.expiresIn,i=Date.now()+s*1e3;e(()=>({authItems:F(t.id,n().authItems,a=>({...a,isLoggedIn:!0,isPending:!1,session:{token:o.accessToken,expires:i}}))}))}).catch(o=>{e(()=>({authItems:F(t.id,n().authItems,s=>({...s,isLoggedIn:!1,isPending:!1,error:o.message}))}))})})},logout:()=>{let t=n().authItems[n().currentAuth];if(!t||t.isPending||!t.isLoggedIn)return;if(t.type!=="active")throw new Error("Cannot logout of non-active service");let r=t.service.service.find(i=>i.type==="AuthLogoutService2");if(!r)return;let o=`${r.id}?origin=${kt()}`,s=window.open(o);e(()=>({authItems:F(t.id,n().authItems,i=>({...i,isLoggedIn:!1,session:null,isPending:!1}))}))},nextAuth:()=>{let t=n().authItems.length,r=n().currentAuth+1;r>=t||e(()=>({currentAuth:r}))},previousAuth:()=>{let t=n().currentAuth-1;t<0||e(()=>({currentAuth:t}))},setAuth:t=>{t!==-1&&(t<0||t>=n().authItems.length)||e(()=>({currentAuth:t}))},addService:(t,r)=>{if(!t.service)return;let o=t.service.find(a=>a.type==="AuthAccessTokenService2"),s=t;if(n().authItems.find(a=>a.service.id===t.id)){e(()=>({authItems:F(t.id,n().authItems,a=>({...a,instances:a.instances+1}))}));return}if(e(()=>({currentAuth:s.profile==="active"?0:n().currentAuth,authItems:[{id:t.id,type:t.profile,service:t,probeId:r,canAuthenticate:!0,instances:1,isPending:!1,isLoggedIn:!1,session:null},...n().authItems]})),t.profile==="external"){if(!o)throw new Error("Token service not found");Ke(o).then(a=>{e(()=>({authItems:F(t.id,n().authItems,u=>({...u,isLoggedIn:!0,isPending:!1,session:{token:a.accessToken,expires:a.expiresIn}}))}))}).catch(a=>{e(()=>({authItems:F(t.id,n().authItems,u=>({...u,isLoggedIn:!1,isPending:!1,canAuthenticate:!1,error:a.message}))}))})}if(t.profile==="kiosk"){if(!o)throw new Error("Token service not found");e(()=>({authItems:F(t.id,n().authItems,a=>({...a,isPending:!0}))})),It(s).then(()=>{Ke(o).then(a=>{e(()=>({authItems:F(t.id,n().authItems,u=>({...u,isLoggedIn:!0,isPending:!1,session:{token:a.accessToken,expires:a.expiresIn}}))}))}).catch(a=>{e(()=>({authItems:F(t.id,n().authItems,u=>({...u,isLoggedIn:!1,isPending:!1,error:a.message}))}))})})}t.profile},removeService:(t,r)=>{let o=n().currentAuth===n().authItems.findIndex(i=>i.service.id===t.id),s=n().currentAuth;if(o){let i=n().authItems.find(u=>u.service.id===t.id);i&&i.instances>1||(s=n().authItems.findIndex(c=>c.service.id!==t.id&&c.instances>0))}e(()=>({authItems:F(t.id,n().authItems,i=>({...i,instances:i.instances-1})),currentAuth:s}))}})),Et=(e,n)=>Mt((t,r)=>({service:e,status:e?"unknown":"success",shouldRedirect:!1,redirectResource:null,shouldSubstitute:!1,substituteResource:null,error:null,errorHeading:null,errorNote:null,shouldDisplayResource:!1,token:n||null,async probe(){if(!r().service)return;let o=r().service?.id;if(!o){t({status:"error",error:"Service ID not found",errorHeading:{en:["Service ID not found"]}});return}t({status:"probing"});let s=r().token;try{let i=await fetch(o,{headers:s?{Authorization:`Bearer ${r().token}`,Accept:"application/json"}:{Accept:"application/json"}}).then(a=>a.json());if(i.status===200)t({status:"success",shouldDisplayResource:!0,error:null,errorHeading:null,errorNote:null,shouldSubstitute:!1,shouldRedirect:!1});else if(i.status<400&&i.status>=300){if(!i.location)throw new Error("Redirect location not found");t({status:"error",shouldDisplayResource:!1,shouldRedirect:!0,redirectResource:i.location||null})}else if(i.status===401)t({status:"error",shouldDisplayResource:!1,shouldRedirect:!1,shouldSubstitute:!!i.substitute,substituteResource:i.substitute||null,error:"Unauthorized",errorHeading:i.heading||{en:["Unauthorized"]},errorNote:i.note||null});else throw new Error("Unknown error")}catch(i){t({status:"error",error:i.message,errorHeading:{en:["Unknown error"]}})}},setToken(o){t({token:o})}}));function Vt(e){let n=e.service||e.services||[],t={hasAuth:!1,services:{}};for(let r of n)if(r.type==="AuthProbeService2"){t.services.probe=r,t.hasAuth=!0;let o=r.service.filter(s=>s.type==="AuthAccessService2");o[0]&&(t.services.access=o[0])}return t}async function Ke(e,{strict:n=!0}={}){return new Promise((t,r)=>{let o=Math.random().toString(36).substring(7),s=`${e.id}?messageId=${o}&origin=${window.location.origin}`,i=c=>{let l=c.data;if(l.messageId===o){if(n&&l.type!=="AuthAccessToken2"){a(),r("Invalid response, expected type=AuthAccessToken2");return}if(!l.accessToken){a(),r("Invalid response, expected accessToken");return}a(),t(l)}},a=()=>window.removeEventListener("message",i),u=document.createElement("iframe");u.src=s,u.style.display="none",document.body.appendChild(u),window.addEventListener("message",i)})}function kt(e){let n=window.location;if(e){let t=document.createElement("a");return t.href=e,t.protocol+"//"+t.hostname+(t.port?":"+t.port:"")}return n.protocol+"//"+n.hostname+(n.port?":"+n.port:"")}async function It(e){let n=`${e.id}?origin=${kt()}`,t=window.open(n);if(!t)throw new Error("Failed to open window");return new Promise((r,o)=>{let s=setInterval(()=>{t.closed&&(clearInterval(s),r())},500)})}import{useEffect as Nt,useMemo as Lt}from"react";import{useStore as Mr}from"zustand";function zt(e){let n=Lt(()=>Vt(e),[e]),t=Ot(n.services.access?.id),r=Lt(()=>Et(n.services.probe,t),[n.services.probe]),o=Mr(r);return Nt(()=>{o.status==="unknown"&&!t&&o.probe()},[n.services.probe,o.status]),Nt(()=>{t&&(o.setToken(t),o.probe())},[t]),[e,o,n.hasAuth]}import{jsx as Pe}from"react/jsx-runtime";var te=Qe(null),Vr=Qe(null);Vr.displayName="CurrentAuth";var kr=Qe(null);kr.displayName="AuthActions";function Ft({children:e}){let n=Er(()=>wt(),[]);return Pe(te.Provider,{value:n,children:e})}function $t(){return!!Ht(te)}function me(){let e=Ht(te);if(!e)throw new Error("useAuthActions must be used within a AuthProvider");return e}function Nr(){let e=me();return de(e,t=>({login:t.login,logout:t.logout,nextAuth:t.nextAuth,previousAuth:t.previousAuth,setAuth:t.setAuth,addService:t.addService,removeService:t.removeService}))}function ps(){let e=me();return de(e,n=>n)}function Lr(e){let n=me();return de(n,r=>r.authItems.find(o=>o.service.id===e))}function Ot(e){let n=me();return de(n,r=>r.authItems.find(o=>o.id===e)?.session?.token)}function gs(e){let n=me();return de(n,r=>{let o=r.authItems.find(s=>s.service.id===e);return!o||!o.isLoggedIn||!o.session?null:o.session?.token||null})}function zr(e){let n=Nr(),t=Lr(e.service.id);return wr(()=>(n?.addService(e.service,e.probeId),()=>{n?.removeService(e.service,e.probeId)}),[e.service]),t?(t.error||!t.isLoggedIn,e.children):null}function Ye(){return null}function Dt(e){let[n,t,r]=zt(e.resource),o=e.fallbackComponent||Ye,s=e.loadingComponent||Ye,i=e.errorComponent||Ye,a=t.service,u=null;if(!r||!a)return e.children(n);let c=a.service.filter(l=>l.type==="AuthAccessService2");t.status==="error"&&(u=Pe(i,{resource:e.resource,error:t.error||"",heading:t.errorHeading,note:t.errorNote,extra:e.extra})),(t.status==="unknown"||t.status==="probing")&&(u=Pe(s,{})),t.status==="success"&&(u=e.children(n));for(let l of c)u=Pe(zr,{service:l,probeId:a.id,children:u},l.id);return u}import{createContext as $r,useContext as Ps,useMemo as Dr}from"react";import{createStore as Or}from"zustand/vanilla";var Hr=e=>e.id||e["@id"];function Fr(e){return(Array.isArray(e.service)?e.service:[e.service]).find(t=>t.profile==="http://iiif.io/api/search/0/autocomplete"||t.profile==="http://iiif.io/api/search/1/autocomplete"||t.profile==="AutoCompleteService1")}var Ut=e=>{let n;typeof e=="string"?n={"@context":"http://iiif.io/api/search/1/context.json",profile:"http://iiif.io/api/search/1/search","@id":e,id:e,service:[]}:n=e;let t=n?Hr(n):void 0,r=null;return Or((o,s)=>({service:n,resources:[],lastQuery:{},loading:!1,error:!1,highlight:null,hasSearch:!!n,hasAutocomplete:n?!!Fr(n):!1,errorMessage:"",search(i,a={}){if(!t)throw new Error("No search service found.");r&&!r.signal.aborted&&r.abort(),r=new AbortController;let u=new URLSearchParams;i.q&&u.set("q",i.q),i.motivation&&u.set("motivation",i.motivation),i.date&&u.set("date",i.date),i.user&&u.set("user",i.user),o({loading:!0}),fetch(`${t}?${u.toString()}`,{signal:r.signal,headers:{"Content-Type":"application/json",Accept:"application/json",...a.headers||{}}}).then(async c=>{if(!r?.signal.aborted)if(c.ok){let l=await c.json();o({resources:l.resources,error:!1,errorMessage:""})}else o({resources:[],error:!0,errorMessage:c.statusText})})},clearSearch(){o({resources:[],error:!1,errorMessage:""})},highlightResult(i){let a=s().resources.find(u=>u["@id"]===i);o({highlight:a})},nextResult(){let i=s().resources,a=s().highlight;if(!a){o({highlight:i[0]||null});return}let u=i.findIndex(c=>c["@id"]===a["@id"]);if(u===-1){o({highlight:i[0]||null});return}o({highlight:i[u+1]||i[0]||null})},previousResult(){let i=s().resources,a=s().highlight;if(!a){o({highlight:i[i.length-1]||null});return}let u=i.findIndex(c=>c["@id"]===a["@id"]);if(u===-1){o({highlight:i[i.length-1]||null});return}if(u===0){o({highlight:i[i.length-1]||null});return}o({highlight:i[u-1]||i[i.length-1]||null})}}))};import{useStore as ws}from"zustand";function qt(){let e=E();return e?e.service.find(n=>n.profile==="SearchService1"||n.profile==="http://iiif.io/api/search/1/search"):void 0}import{jsx as We}from"react/jsx-runtime";var ne=$r(null);ne.displayName="Search";function Bt(e){let n=qt();return e.store?We(ne.Provider,{value:e.store,children:e.children}):We(Ur,{service:n,children:e.children})}function Ur({service:e,children:n}){let t=Dr(()=>Ut(e),[e]);return We(ne.Provider,{value:t,children:n})}import{jsx as z}from"react/jsx-runtime";var fe=()=>{},pe=Br({setCurrentCanvasId:fe,setCurrentCanvasIndex:fe,nextCanvas:fe,previousCanvas:fe,items:[],sequence:[],setSequenceIndex:fe,currentSequenceIndex:0,hasNext:!1,hasPrevious:!1});function jr(e){let n=E(),{cursor:t,visibleItems:r,next:o,sequence:s,items:i,setCanvasIndex:a,setCanvasId:u,previous:c,setSequenceIndex:l,hasNext:d,hasPrevious:y}=Tt({startCanvas:e.startCanvas,disablePaging:e.pagingEnabled===!1}),A=_r(()=>({sequence:s,items:i,setCurrentCanvasId:u,nextCanvas:o,previousCanvas:c,totalCanvases:i.length,setCurrentCanvasIndex:a,setSequenceIndex:l,currentSequenceIndex:t,hasNext:d,hasPrevious:y}),[s,i,u,o,c,i,a,l,t]);return n?r.length===0?null:z(pe.Provider,{value:A,children:z(ee.Provider,{value:r,children:z(q,{canvas:r[0],children:e.children})})}):(console.warn("The manifest passed to the provider is not a valid IIIF manifest."),z("div",{children:"Sorry, something went wrong."}))}function _t(e){let n=X(e.vault),t=Ct(e.manifest);if(!t)return console.warn("The manifest passed to the provider is not a valid IIIF manifest."),z("div",{children:"Sorry, something went wrong."});if(t.error)return z("div",{children:t.error.toString()});if(!t.isLoaded)return z("div",{children:"Loading..."});let r=z(jr,{...e,children:e.children});return z(J,{vault:n,children:z(At,{manifest:t.id,children:z(Ft,{children:z(Bt,{children:e.rangeId?z(bt,{range:e.rangeId,children:r}):r})})})})}function jt(){return qr(pe)}import Kr from"react";import{createContext as Yr,useMemo as Qr}from"react";import Wr from"mitt";import{jsx as Zr}from"react/jsx-runtime";var Gr=Wr(),re=Yr({emitter:Gr});re.displayName="Events";function Kt(){return Kr.useContext(re).emitter}function au({emitter:e,children:n}){return Zr(re.Provider,{value:Qr(()=>({emitter:e}),[e]),children:n})}import{jsx as oe}from"react/jsx-runtime";function Yt(){return{VaultContext:W(Q),ResourceContext:W(Ce),SimpleViewerReactContext:W(pe),VisibleCanvasReactContext:W(ee),AuthRContext:W(te),SearchReactContext:W(ne),ReactEventContext:W(re)}}function Qt(e){return oe(J,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:oe(ee.Provider,{value:e.bridge.VisibleCanvasReactContext,children:oe(pe.Provider,{value:e.bridge.SimpleViewerReactContext,children:oe(re.Provider,{value:e.bridge.ReactEventContext,children:oe(te.Provider,{value:e.bridge.AuthRContext,children:oe(ne.Provider,{value:e.bridge.SearchReactContext,children:e.children})})})})})})}import{createContext as no,useContext as ro,useMemo as oo}from"react";import{useCallback as Gt,useLayoutEffect as Xr,useMemo as eo,useRef as to}from"react";import{entityActions as Ge}from"@iiif/helpers/vault/actions";import{useMemo as Jr}from"react";function Wt(){let n=R().getStore();return Jr(()=>t=>n.dispatch(t),[n])}function Zt(e){return typeof e!="string"&&e&&e.bindToVault}function Jt(){let e=R(),n=to([]),t=Wt(),r=eo(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);Xr(()=>{let a={id:r,type:"AnnotationPage",behavior:[],label:null,thumbnail:[],summary:null,requiredStatement:null,metadata:[],rights:null,provider:[],items:[],seeAlso:[],homepage:[],rendering:[],service:[]};t(Ge.importEntities({entities:{AnnotationPage:{[a.id]:a}}}))},[r]);let o=T(a=>r&&a.iiif.entities.AnnotationPage[r]||null,[r]),s=Gt((a,u)=>{if(r){if(Zt(a)){let d=a;d.__vault||d.bindToVault(e),a=typeof d.source=="string"?d.source:d.source.id,n.current[a]=d}else typeof a!="string"&&(a=a.id);let c=e.get({id:r,type:"AnnotationPage"}),l=e.get({id:a,type:"Annotation"});c&&l&&(c.items.find(d=>d.id===l.id)||t(Ge.addReference({id:r,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"},index:u})))}},[r]),i=Gt(a=>{r&&(Zt(a)?a=typeof a.source=="string"?a.source:a.source.id:typeof a!="string"&&(a=a.id),n.current[a]&&n.current[a].beforeRemove(),e.get({id:r,type:"AnnotationPage"})&&t(Ge.removeReference({id:r,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"}})))},[r]);return[o,{addAnnotation:s,removeAnnotation:i}]}import{jsx as io}from"react/jsx-runtime";var Xt=no(null);function en(){let e=ro(Xt);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function tn({children:e}){let[n,{addAnnotation:t,removeAnnotation:r}]=Jt();return io(Xt.Provider,{value:oo(()=>({fullPage:n,addAnnotation:t,removeAnnotation:r}),[n]),children:e})}import{jsx as Ze,jsxs as ao}from"react/jsx-runtime";function nn({width:e,style:n,height:t,error:r,resetErrorBoundary:o}){return ao("div",{style:{width:e,height:t,minHeight:500,...n||{},background:"#f9f9f9"},children:[Ze("h3",{children:"Error occurred"}),Ze("p",{children:r.message}),Ze("button",{onClick:o,children:"Reset"})]})}import{createContext as so,useContext as uo}from"react";var ge=so(null);function rn(){return uo(ge)}import{createContext as on,useContext as co,useEffect as lo}from"react";var Je=on(()=>{}),Xe=on(()=>{});function O(e,n,t,r,o=[]){let s=co(e==="portal"?Xe:Je);lo(()=>(e!=="none"&&s(n,t,r),()=>{s(n,null)}),[n,e,s,...o])}import{createContext as fo,useContext as po,useEffect as go}from"react";import{useMemo as mo}from"react";function M(e={},n=[]){let{id:t,selector:r}=e,o=H(),s=t||o.canvas,i=T(a=>s?a.iiif.entities.Canvas[s]:void 0,[s]);return mo(()=>{if(i)return r?r(i):i},[i,r,...n])}var et=fo(()=>{});function an(e){let n=M(),t=po(et);go(()=>n&&n.id?(t(n.id,e),()=>t(n.id,-1)):()=>{},[n,e])}import{Fragment as xo,jsx as V,jsxs as So}from"react/jsx-runtime";function cn({children:e,errorFallback:n,outerContainerProps:t={},worldScale:r,...o}){let[s,i]=Re(),a=Yt(),u=n||nn,[c,l]=Re({}),d=Object.entries(c),[y,A]=Re({}),h=Object.entries(y),[g,b]=Re({}),p=un(()=>r||Math.max(...Object.values(g)),[g]),S=un(()=>({maxOverZoom:p||1,...o.runtimeOptions||{}}),[p,o.runtimeOptions]),m=tt((x,P)=>{b(C=>{if(P===-1){let{[x]:_,...f}=C;return f}return{...C,[x]:P}})},[]),v=tt((x,P,C)=>{l(({[x]:_,...f})=>P?{...f,[x]:{element:P,props:C}}:f)},[]),I=tt((x,P,C)=>{A(({[x]:_,...f})=>P?{...f,[x]:{element:P,props:C}}:f)},[]);return So(yo,{resetKeys:[],fallbackRender:x=>V(u,{...o,...x}),children:[V(vo,{...o,containerProps:{style:{position:"relative"},...o.containerProps||{}},htmlChildren:V(xo,{children:d.map(([x,{element:P,props:C}])=>V(sn.Fragment,{children:V(P,{...C||{}})},x))}),onCreated:x=>{i(x),o.onCreated&&o.onCreated(x)},runtimeOptions:S,children:V(ge.Provider,{value:s,children:V(et.Provider,{value:m,children:V(Je.Provider,{value:v,children:V(Xe.Provider,{value:I,children:V(Qt,{bridge:a,children:V(ho.Provider,{value:o.mode||"explore",children:V(tn,{children:e})})})})})})})}),V("div",{children:h.map(([x,{element:P,props:C}])=>V(sn.Fragment,{children:V(P,{...C||{}})},x))})]})}import{mergeStyles as To,RegionHighlight as Io}from"@atlas-viewer/atlas";import{useMemo as ln}from"react";import{createEventsHelper as Co}from"@iiif/helpers/events";function Te(e,n){let t=R(),r=ln(()=>Co(t),[t]),o=T(()=>e&&e.id?t.getResourceMeta(e.id,"eventManager"):null,[e]);return ln(()=>e?r.getListenersAsProps(e,n):{},[o,e,t,n])}import{useMemo as Ao}from"react";import{createStylesHelper as bo}from"@iiif/helpers/styles";function ie(e,n){let t=R(),r=Ao(()=>bo(t),[t]);return T(()=>{if(!e)return null;let o=r.getAppliedStyles(e.id);return o?n?o[n]:o:void 0},[e,n])}import{useMemo as Mo}from"react";import{useMemo as Po}from"react";import{expandTarget as Ro}from"@iiif/helpers/annotation-targets";function Ie(e={},n=[]){let{id:t,selector:r}=e,o=H(),s=R(),i=t||o.annotation,a=T(c=>i?c.iiif.entities.Annotation[i]:void 0,[i]),u=T(c=>a&&a.body?a.body.map(l=>l?l.type==="SpecificResource"?{...l,source:s.get(l)}:l?c.iiif.entities[l.type][l.id]:null:null).filter(Boolean):[],[a]);return Po(()=>{if(!a)return;let c={...a,body:u,target:Ro(a.target,{typeMap:s.getState().iiif.mapping})};return r?r(c):c},[a,r,u,...n])}import{jsx as wo}from"react/jsx-runtime";var Me=({id:e,style:n,className:t,interactive:r})=>{let o=Ie({id:e}),s=ie(o,"atlas"),i=ie(o,"html"),a=Te(o,["atlas"]),u=M(),c=Mo(()=>To(n,s),[n,s]);return u&&o&&o.target&&o.target.selector&&o.target.selector.type==="BoxSelector"&&o.target.source&&(o.target.source.id===u.id||o.target.source===u.id)?wo(Io,{id:o.id,isEditing:!0,region:o.target.selector.spatial,style:c,className:i?.className||t,interactive:!!(i?.href||r),href:i?.href||null,title:i?.title||null,hrefTarget:i?.target||null,onClick:()=>{},...a}):null};import{Fragment as Vo}from"react";import{useMemo as Eo}from"react";function dn(e={},n=[]){let{id:t,selector:r}=e,o=H(),s=t||o.annotationPage,i=T(a=>s?a.iiif.entities.AnnotationPage[s]:void 0,[s]);return Eo(()=>{if(i)return r?r(i):i},[i,...n])}import{jsx as mn}from"react/jsx-runtime";var ve=({className:e,page:n})=>{let t=dn({id:n.id})||n,r=ie(t,"atlas"),o=ie(t,"html");return T(s=>t.id?s.iiif.entities.AnnotationPage[t.id]:null,[]),mn(Vo,{children:t.items?.map(s=>mn(Me,{id:s.id,style:r,className:o?.className||e},s.id))})};import{createStylesHelper as Vi}from"@iiif/helpers/styles";import{Fragment as An,useMemo as Fo}from"react";import{HTMLPortal as zo,TileSet as Sn}from"@atlas-viewer/atlas";import ae,{useMemo as nt}from"react";import{jsx as $}from"react/jsx-runtime";var pn=ae.createContext("en"),gn=ae.createContext({}),vn=ae.createContext(null);function Xc(e){return $(gn.Provider,{value:e.translations,children:e.children})}function el(e){return $(pn.Provider,{value:e.language,children:e.children})}function tl(e){return $(vn.Provider,{value:e.convert,children:e.children})}function hn(){return ae.useContext(vn)}function rt(){return ae.useContext(pn)}function yn(){return ae.useContext(gn)}function fn(e){return e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):e}function ko({as:e,language:n,children:t,viewingDirection:r,...o}){let s=rt();return nt(()=>fn(s)===fn(n),[s,n])?e?$(e,{...o,children:t}):$("span",{...o,children:t}):e?$(e,{...o,lang:n,dir:r,children:t}):$("span",{...o,lang:n,dir:r,children:t})}function xn(e,n,t){if(n.length===0)return;if(n.length===1)return n[0];if(n.indexOf(e)!==-1)return e;let r=e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):null;if(r&&n.indexOf(r)!==-1)return r;for(let o of t)if(n.indexOf(o)!==-1)return o;return n.indexOf("none")!==-1?"none":n.indexOf("@none")!==-1?"@none":n[0]}var No=(e,n=[])=>{let t=rt();return nt(()=>{let r=e();return xn(t,r,[])},[t,...n])};function G(e,n,t,r){return n?t?t(e[n]||n,r||"none"):e[n]||n:""}function Lo(e,n,t=`
|
|
2
|
+
`,r={}){let o=hn(),s=No(()=>Object.keys(e||{}),[e]);return[nt(()=>{if(!e)return G(r,n,o)||"";if(typeof e=="string")return G(r,e,o);let i=s?e[s]:void 0;return i?typeof i=="string"?i:i.map(a=>G(r,a,o,s)).join(t):""},[s,n,e]),s]}function nl(){let e=rt(),n=yn(),t=hn();return function(o,s="",i=`
|
|
3
|
+
`,a=n){let u=Object.keys(o||{}),c=xn(e,u,[]);if(!o)return G(a,s,t)||"";if(typeof o=="string")return G(a,o,t);let l=c?o[c]:void 0;return l?typeof l=="string"?G(a,l,t,c):l.map(d=>G(a,d,t,c)).join(typeof i<"u"?i:`
|
|
4
|
+
`):""}}function he({as:e,defaultText:n,enableDangerouslySetInnerHTML:t,children:r,separator:o,...s}){let i=yn(),[a,u]=Lo(r,n,o,i);return u?$(ko,{...s,as:e,language:u,title:t?void 0:a,dangerouslySetInnerHTML:t?{__html:a}:void 0,children:t?void 0:a}):e?$(e,{...s,children:a}):$("span",{...s,title:t?void 0:a,dangerouslySetInnerHTML:t?{__html:a}:void 0,children:t?void 0:a})}import{jsx as B,jsxs as Ho}from"react/jsx-runtime";function Oo({resource:e,heading:n,note:t,extra:r}){return r?B(zo,{target:{x:0,y:0,width:r.target?.spatial.width,height:r.target?.spatial.height},backgroundColor:"#333",relative:!0,children:B("div",{style:{display:"flex",alignContent:"center",justifyContent:"center",alignItems:"center",height:"100%",width:"100%",background:"#444",color:"#BBB"},children:Ho("div",{children:[B(he,{children:n||"Not authorised"}),t&&B("p",{children:B(he,{children:t})}),B("p",{children:e.id||e["@id"]||"unknown"})]})})}):null}function Cn({image:e,thumbnail:n,crop:t,enableSizes:r}){if(!$t()){let s=e.service,i=s.width||e.width||0,a=s.height||e.height||0;return B(Sn,{tiles:{id:s.id||s["@id"]||"unknown",height:a,width:i,imageService:s},enableSizes:r,x:0,y:0,width:e.target?.spatial.width,height:e.target?.spatial.height,crop:t})}return B(Dt,{resource:e.service,errorComponent:Oo,extra:e,children:s=>{let i=s.width||e.width||0,a=s.height||e.height||0;return B(Sn,{tiles:{id:s.id||s["@id"]||"unknown",height:a,width:i,imageService:s},enableSizes:r,x:0,y:0,width:e.target?.spatial.width,height:e.target?.spatial.height,crop:t})}},e.id)}import{jsx as ot,jsxs as bn}from"react/jsx-runtime";function se({id:e,image:n,thumbnail:t,isStatic:r,x:o=0,y:s=0,children:i,selector:a,onClick:u,enableSizes:c}){let l=Fo(()=>{if(!(!a||a.spatial.x===0&&a.spatial.y===0))return a.spatial},[a]);return ot("world-object",{x:o+n.target.spatial.x,y:s+n.target.spatial.y,width:n.target.spatial.width,height:n.target.spatial.height,onClick:u,children:n.service?bn(An,{children:[ot(Cn,{image:n,thumbnail:t,crop:l,enableSizes:c}),i]},"service"):bn(An,{children:[ot("world-image",{onClick:u,uri:n.id,target:{x:0,y:0,width:n.target.spatial.width,height:n.target.spatial.height},display:n.width&&n.height?{width:n.width,height:n.height}:void 0,crop:l}),i]},"no-service")},e+(n.service?"server":"no-service"))}import{Fragment as ki,useEffect as Zn,useLayoutEffect as Ni,useMemo as Jn}from"react";import{useEffect as Nn,useMemo as Ln}from"react";import{useCallback as Tn,useMemo as Do}from"react";function $o(e,n){let t=e?.iiif?.meta[n];return t?t.annotationPageManager:null}function Pn(e,n){return T(t=>{let r=[];if(!e)return r;let o=Object.keys(t.iiif.entities.AnnotationPage);for(let s of o)if(!n||n.indexOf(s)!==-1){let i=$o(t,s);i&&i.views&&i.views[e]&&r.push(s)}return r},[e,n])}function Rn({canvas:e,manifest:n,all:t,canvases:r}){let o=[];if(n)for(let s of n.annotations)o.indexOf(s.id)===-1&&o.push(s.id);if(t){if(r&&r.length)for(let s of r)for(let i of s.annotations)o.indexOf(i.id)===-1&&o.push(i.id)}else if(e)for(let s of e.annotations)o.indexOf(s.id)===-1&&o.push(s.id);return o}function Uo(e,n){let t=e?.iiif?.meta[n];return t?t.annotationPageManager:null}function In(e,n={}){let t=R(),r=E(),o=M(),s=Ae(),i=Do(()=>Rn({all:n.all,manifest:r,canvas:o,canvases:s}),[n.all,o,s,r]),a=Pn(e,n.all?void 0:i),u=Tn(l=>{e&&t.setMetaValue([l,"annotationPageManager","views"],d=>d&&!d[e]?d:{...d||{},[e]:!1})},[e,t]),c=Tn((l,d={})=>{if(!e)return;let y=t.getState(),A=[];if(d?.deselectOthers){let h=Object.keys(y.iiif.entities.AnnotationPage);for(let g of h){let b=Uo(y,g);b&&b.views&&b.views[e]&&A.push(g)}}for(let h of A)u(h);t.setMetaValue([l,"annotationPageManager","views"],h=>h&&h[e]?h:{...h||{},[e]:!0})},[e,u,t]);return{availablePageIds:i,enabledPageIds:a,setPageEnabled:c,setPageDisabled:u}}function Mn(e,n){return T((t,r)=>r.get(e.map(o=>({id:o,type:n}))),[e,n])}import{useCallback as Ko,useEffect as Yo,useRef as Qo,useState as Wo}from"react";import qo,{useContext as Bo}from"react";import{ImageServiceLoader as _o}from"@atlas-viewer/iiif-image-api";var jo=qo.createContext(new _o);function we(){return Bo(jo)}function wn(){let e=we(),[n,t]=Wo({}),r=Qo(!1);return Yo(()=>()=>{r.current=!0},[]),[Ko((s,{height:i,width:a})=>{if(s){let u=s.id||s["@id"],c=e.loadServiceSync({id:u,width:s.width||a,height:s.height||i,source:s});c?s=c:n[u]||(r.current||t(l=>({...l,[u]:"loading"})),e.loadService({id:u,width:s.width||a,height:s.height||i}).then(()=>{r.current||t(l=>({...l,[u]:"done"}))}))}return s},[e,n]),n]}import{useCallback as Go,useMemo as Vn,useState as Zo}from"react";function En(e={}){let n=Ie(),t=M(e.canvasId?{id:e.canvasId}:void 0);return T((r,o)=>{if(!t)return[];if(n&&e.enableSingleAnnotation)return[n];let s=o.get(t.items),i=[];for(let a of s)i.push(...o.get(a.items));return i},[t])}import{createPaintingAnnotationsHelper as Jo}from"@iiif/helpers/painting-annotations";function kn(e,n=[]){let t=R(),r=Vn(()=>Jo(t),[]),o=En({enableSingleAnnotation:e?.enableSingleAnnotation}),[s,i]=Zo(e?.defaultChoices||[]),a=Vn(()=>r.getPaintables(o,s),[t,o,s,...n]),c={makeChoice:Go((l,{deselectOthers:d=!0,deselect:y=!1}={})=>{a.choice&&i(A=>{if(y){let g=A.filter(b=>b!==l);if(g.length===0){let b=a.items[0].resource.id;return b?[b]:[]}return g}if(d)return[l];let h=[...A];if(h.length===0&&a.items.length){let g=a.items[0].resource.id;g&&h.push(g)}return A.indexOf(l)!==-1?A:[...A,l]})},[a.choice])};return[a,c]}function zn(e){let n=E(),t=M(),r=R(),o=Kt(),s=e?.emitter||o,[i,a]=wn(),{enabledPageIds:u}=In(e?.annotationPageManagerId||n?.id||t?.id,{all:!1}),c=Mn(u,"AnnotationPage"),l=e?.strategies||["empty","images","media","textual-content","complex-timeline"],[d,y]=kn(e,[a]);Nn(()=>{let h=g=>{y.makeChoice(g.choiceId,{deselectOthers:g.deselectOthers,deselect:g.deselect})};return s.on("make-choice",h),()=>{s.off("make-choice",h)}},[]);let A=Ln(()=>ht({canvas:t,paintables:d,supports:l,loadImageService:i}),[t,d,r,y.makeChoice]);return Nn(()=>{let h=d.allChoices,g={canvasId:t?.id,manifestId:n?.id};h&&s.emit("choice-change",{choice:h,partOf:g})},[t?.id,d.allChoices]),Ln(()=>A.type==="unknown"?[A,vt]:[{...A,annotations:{pages:c}},y],[A,c])}import{useEffect as ei,useMemo as ti,useRef as ni,useState as ri}from"react";import{useEffect as Xo}from"react";var On=(e,n=[])=>{let t=R();Xo(()=>{e(t)},[t,...n])};import{createThumbnailHelper as oi}from"@iiif/helpers/thumbnail";function Ee(e,n,{canvasId:t,manifestId:r}={}){let o=R(),s=we(),i=ti(()=>oi(o,{imageServiceLoader:s}),[o,s]),[a,u]=ri(),c=E(r?{id:r}:void 0),l=M(t?{id:t}:void 0),d=l||c,y=ni(!1);if(ei(()=>(y.current=!1,()=>{y.current=!0}),[]),!d)throw new Error("Must be called under a manifest or canvas context.");return On(A=>{i.getBestThumbnailAtSize(d,e,n).then(h=>{h.best&&!y.current&&u(h.best)})},[d]),a}import{useCallback as D,useEffect as Hn,useReducer as ii,useRef as Ve}from"react";function ai(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function si(e,n){switch(n.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:n.volume,isMuted:n.volume===0};case"TOGGLE_MUTE":return{...e,isMuted:!e.isMuted};case"UNMUTE":return{...e,isMuted:!1}}return e}function it(e){let n=Math.round(e);return`${Math.floor(n/60)}:${`${n%60}`.padStart(2,"0")}`}function ue(e){let[n,t]=ii(si,ai(e.duration)),r=Ve(null),o=Ve(null),s=Ve(null),i=Ve(!1),a=D(()=>{o.current&&r.current&&(o.current.innerHTML=it(r.current.currentTime),s.current&&(s.current.style.width=`${r.current.currentTime/e.duration*100}%`),i.current!==r.current.muted&&(i.current=r.current.muted,t(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"})))},[e.duration]),u=D(()=>{r.current&&(t({type:"PLAY_REQUESTED"}),r.current.play().then(()=>{t({type:"PLAY"})}),a())},[a]),c=D(()=>{r.current&&(r.current.duration>0&&r.current.paused?u():l())},[a]),l=D(()=>{r.current&&(r.current.pause(),t({type:"PAUSE"}),a())},[a]),d=D(()=>{r.current&&(r.current.muted=!r.current.muted,t(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"}))},[]),y=D(()=>{r.current&&(r.current.muted=!0,t({type:"MUTE"}))},[]),A=D(()=>{r.current&&(r.current.muted=!1,t({type:"UNMUTE"}))},[]),h=D(p=>{r.current&&(r.current.muted=!1,r.current.volume=p/100,t({type:"SET_VOLUME",volume:p}))},[]),g=D(p=>{r.current&&(r.current.currentTime=Math.max(0,Math.min(p*e.duration,e.duration)),a())},[]),b=D(p=>{if(r.current){let S=typeof p=="function"?p(r.current.currentTime):p;r.current.currentTime=Math.max(0,Math.min(S,e.duration)),a()}},[]);return Hn(()=>{let p=setInterval(()=>{a()},350);return()=>clearInterval(p)},[a,e.duration]),Hn(()=>{let p=()=>{t({type:"FINISHED"})},S=r.current;return S?.addEventListener("ended",p),()=>S?.removeEventListener("ended",p)},[]),[{element:r,currentTime:o,progress:s},n,{play:u,pause:l,playPause:c,mute:y,unmute:A,toggleMute:d,setVolume:h,setDurationPercent:g,setTime:b}]}import{createContext as st,useContext as ut}from"react";import{jsx as at}from"react/jsx-runtime";var Fn=st(null),$n=st(null),Dn=st(null);function xd(){let e=ut(Fn);if(!e)throw new Error("Ctx not found");return e}function Sd(){let e=ut($n);if(!e)throw new Error("Ctx not found");return e}function Cd(){let e=ut(Dn);if(!e)throw new Error("Ctx not found");return e}function ke({actions:e,state:n,children:t,currentTime:r,progress:o,element:s}){return at(Dn.Provider,{value:{currentTime:r,progress:o,element:s},children:at($n.Provider,{value:e,children:at(Fn.Provider,{value:n,children:t})})})}import{useMemo as ui}from"react";import{expandTarget as ci}from"@iiif/helpers";function Ne(){let e=E(),n=M();return ui(()=>{if(!e||!n||!e.start)return null;let t=ci(e.start);return!t||t.source.id!==n.id||!t||!t.selector||t.selector.type!=="TemporalSelector"?null:t.selector.temporal},[e,n])}import{jsx as li,jsxs as di}from"react/jsx-runtime";function ct({media:e,startTime:n,children:t}){let[{element:r,currentTime:o,progress:s},i,a]=ue({duration:e.duration}),u=n?`${e.url}#t=${n}`:e.url;return di(ke,{state:i,actions:a,currentTime:o,progress:s,element:r,children:[li("audio",{ref:r,src:u}),t]})}function Le({media:e,mediaControlsDeps:n,children:t}){let r=Ne();return O("portal","audio",ct,{media:e,startTime:r?r.startTime:null,children:t},[e,r,...n||[]]),null}import{jsx as Un,jsxs as mi}from"react/jsx-runtime";function lt({element:e,media:n,startTime:t,playPause:r,poster:o}){let s="div",i=t?`${n.url}#t=${t}`:n.url;return mi(s,{className:"video-container",part:"video-container",onClick:r,children:[Un("style",{children:`
|
|
5
5
|
.video-container {
|
|
6
6
|
position: absolute;
|
|
7
7
|
top: 0;
|
|
@@ -14,7 +14,7 @@ import{c as ht,l as yt}from"./chunk-UFC4ZSNV.js";import{forwardRef as er,useImpe
|
|
|
14
14
|
justify-content: center;
|
|
15
15
|
pointer-events: visible;
|
|
16
16
|
}
|
|
17
|
-
`}),
|
|
17
|
+
`}),Un("video",{poster:o,ref:e,src:i,style:{width:"100%",objectFit:"contain"}})]})}function ze({media:e,mediaControlsDeps:n,children:t,videoComponent:r=lt}){let o=M(),s=Ne(),i=o&&o.placeholderCanvas&&o.placeholderCanvas.id||void 0,a=Ee({},!1,{canvasId:i}),[{element:u,currentTime:c,progress:l},d,y]=ue({duration:e.duration});return O("overlay","video-element",r,{element:u,media:e,playPause:y.playPause,poster:a?.id,startTime:s?s.startTime:null},[a]),O("portal","custom-controls",ke,{state:d,actions:y,currentTime:c,progress:l,element:u,children:t},[c,d,e,...n||[]]),null}import{Fragment as fi,jsx as dt,jsxs as pi}from"react/jsx-runtime";function mt({model:e}){return pi(fi,{children:[dt("style",{children:`
|
|
18
18
|
.model-container {
|
|
19
19
|
position: absolute;
|
|
20
20
|
top: 0;
|
|
@@ -27,7 +27,7 @@ import{c as ht,l as yt}from"./chunk-UFC4ZSNV.js";import{forwardRef as er,useImpe
|
|
|
27
27
|
justify-content: center;
|
|
28
28
|
pointer-events: visible;
|
|
29
29
|
}
|
|
30
|
-
`}),dt("div",{className:"model-container",children:dt("model-viewer",{"interaction-prompt":"none",style:{width:"100%",height:"100%"},"camera-controls":"","ar-status":"not-presenting",src:e.id})})]})}function Oe({model:e,name:n}){return O("overlay",`model-${n}`,mt,{model:e},[e]),null}import{jsx as gi}from"react/jsx-runtime";function He({style:e}){let n=M();return!n||!n.height||!n.width?null:gi("box",{interactive:!1,target:{x:0,y:0,width:Number(n.width),height:Number(n.height)},style:e})}import{jsx as
|
|
30
|
+
`}),dt("div",{className:"model-container",children:dt("model-viewer",{"interaction-prompt":"none",style:{width:"100%",height:"100%"},"camera-controls":"","ar-status":"not-presenting",src:e.id})})]})}function Oe({model:e,name:n}){return O("overlay",`model-${n}`,mt,{model:e},[e]),null}import{jsx as gi}from"react/jsx-runtime";function He({style:e}){let n=M();return!n||!n.height||!n.width?null:gi("box",{interactive:!1,target:{x:0,y:0,width:Number(n.width),height:Number(n.height)},style:e})}import{jsx as qn}from"react/jsx-runtime";function Fe(e){let n=M();return!n||!n.placeholderCanvas?null:qn(q,{canvas:n.placeholderCanvas.id,children:qn(ce,{renderViewerControls:e.renderViewerControls})})}import{useRef as vi}from"react";import{jsx as Bn,jsxs as yi}from"react/jsx-runtime";function hi({element:e,media:n,playPause:t}){let r=vi(null);return n.youTubeId?yi("div",{className:"video-container",part:"video-container",onClick:t,children:[Bn("style",{children:`
|
|
31
31
|
.video-container {
|
|
32
32
|
position: absolute;
|
|
33
33
|
top: 0;
|
|
@@ -45,4 +45,4 @@ import{c as ht,l as yt}from"./chunk-UFC4ZSNV.js";import{forwardRef as er,useImpe
|
|
|
45
45
|
width: 100%;
|
|
46
46
|
object-fit: contain;
|
|
47
47
|
}
|
|
48
|
-
`}),_n("iframe",{className:"video-yt",ref:r,src:`https://www.youtube.com/embed/${n.youTubeId}?enablejsapi=1&origin=${window.location.host}`,referrerPolicy:"no-referrer",sandbox:"allow-scripts allow-same-origin allow-presentation"})]}):null}function jn({media:e,mediaControlsDeps:n,children:t}){let[{element:r,currentTime:o,progress:s},i,a]=ue({duration:e.duration});return O("overlay","video-element",hi,{element:r,media:e,playPause:a.playPause}),null}import{useLayoutEffect as Ti,useMemo as Ii}from"react";import xi from"mitt";import{createStore as Si}from"zustand/vanilla";function Kn({currentKeyFrameIndex:e,keyframes:n,targetTime:t,currentTime:r}){if(r<=t){let o=n.findIndex(a=>a.time>t);if(o===-1)return[e,[]];let s={},i=n.slice(e,o);for(let a of i)a.type==="enter"&&(s[a.id]=a),a.type==="exit"&&(s[a.id]?delete s[a.id]:s[a.id]=a);return[o,Object.values(s)]}return[e,[]]}function Yn({complexTimeline:e,startTime:n=0}){let t=xi(),r={},o={progress:null,currentTime:null},s=0,i=null,a=0,u=null;function c(){let S=b.getState().visibleElements,m=r,v=[],I=Object.keys(m);for(let x of I){let P=m[x],C=S[x];P&&C&&v.push(P)}return v}function l(){return Object.keys(r).map(S=>r[S])}function d(p){o.currentTime&&(o.currentTime.innerHTML=it(p),o.progress&&(o.progress.style.width=`${p/e.duration*100}%`))}let y=()=>{let p=b.getState(),S=p.currentPrime;if(!S)return;let m=r,v=p.visibleElements,I=Object.keys(m);for(let x of I){let P=m[x],C=v[x];if(P&&x!==S.id&&C){let _=a-C.time*1e3;Math.abs(a-C.time*1e3-P.currentTime*1e3)>300&&(P.currentTime=_/1e3)}}},A=(p=0)=>{let S=p-s,m=b.getState();if(m.isPlaying){let v=m.currentPrime;if(v){let C=r[v.id];C&&(C.paused?a+=S:a=(v.time+C.currentTime)*1e3)}else a+=S;let I=a/1e3;if(I>m.duration){b.getState().setTime(0),b.setState({isPlaying:!1}),h(),d(0);return}d(I);let[x,P]=Kn({currentTime:I,currentKeyFrameIndex:m.nextKeyframeIndex,keyframes:m.complexTimeline.keyframes,targetTime:I});P.length&&m.applyKeyframes(x,P)}s=p,i=requestAnimationFrame(A)},h=()=>{i&&cancelAnimationFrame(i)},g=(p,S)=>{},b=Si((p,S)=>({complexTimeline:e,elements:{},visibleElements:{},isBuffering:!1,bufferMap:{},isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,isReady:!1,volume:100,duration:e.duration,clockStartRequests:0,clockStartTime:0,primeTime:0,currentPrime:null,clockRunning:!1,nextKeyframeIndex:0,startClock:()=>{S().clockRunning||(A(),u=setInterval(y,500)),p({clockRunning:!0,clockStartRequests:S().clockStartRequests+1})},applyKeyframes(m,v){let I=S(),x={...I.visibleElements},P=I.currentPrime;for(let C of v)C.type==="enter"&&(x[C.id]=C,t.emit("complex-timeline.enter",{id:C.id})),C.type==="exit"&&(x[C.id]=null,t.emit("complex-timeline.exit",{id:C.id})),C.isPrime&&(P=C);p({nextKeyframeIndex:m,visibleElements:x,currentPrime:P})},stopClock:()=>{let m=S().clockStartRequests;if(m!==0){if(m===1){h(),u&&clearInterval(u),p({clockRunning:!1,clockStartRequests:0});return}p({clockStartRequests:m-1})}},setElement:(m,v)=>{r[m]=v;let I=Object.keys(r),x=S().complexTimeline;g(v,m),x.items.filter(C=>C.type!=="Image"&&C.type!=="Text").every(C=>I.includes(C.annotationId))&&!S().isReady&&(t.emit("complex-timeline.ready",{complexTimeline:x}),p({isReady:!0}))},removeElement:m=>{delete r[m]},mute(){for(let m of l())m.muted=!0;p({isMuted:!0})},unmute(){for(let m of l())m.muted=!1;p({isMuted:!1})},play(){if(!S().isPlaying){for(let v of c())v.play();p({isPlaying:!0})}},pause(){if(S().isPlaying){for(let v of c())v.pause();p({isPlaying:!1})}},playPause(){let m=S();m.isPlaying?m.pause():m.play()},setDurationPercent(m){let I=S().duration*m;S().setTime(I)},setTime(m){let v=S(),I=a/1e3,x=typeof m=="function"?m(I):m,P=v.nextKeyframeIndex;if(I>x){p({visibleElements:{},currentPrime:null});let L=Object.keys(v.visibleElements);for(let j of L)t.emit("complex-timeline.exit",{id:j});I=0,P=0}let[C,_]=Kn({currentTime:I,currentKeyFrameIndex:P,keyframes:v.complexTimeline.keyframes,targetTime:x});v.applyKeyframes(C,_),a=x*1e3;let xe=b.getState().visibleElements,Se=r,qe=Object.keys(xe);for(let L of qe){let j=xe[L];if(j){let Z=Se[L];Z&&(Z.currentTime=(a-j.time*1e3)/1e3)}}d(x)},setVolume(m){for(let v of l())v.volume=Math.min(1,Math.max(0,m/100));p({volume:m})},toggleMute(){let m=S();m.isMuted?(m.unmute(),p({isMuted:!1})):(m.mute(),p({isMuted:!0}))},clearProgressElement(){o.progress=null},setProgressElement(m){o.progress=m},setCurrentTimeElement(m){o.currentTime=m},clearCurrentTimeElement(){o.currentTime=null}}));return t.on("complex-timeline.enter",p=>{let S=b.getState(),m=p.id,v=r[m];v&&S.isPlaying&&v.play()}),t.on("complex-timeline.exit",p=>{let S=b.getState(),m=p.id,v=r[m];v&&(v.currentTime=0,v.pause())}),b.getState().setTime(n),{store:b,emitter:t}}import{HTMLPortal as Mi}from"@atlas-viewer/atlas";import{useStore as Gn}from"zustand";import{createContext as Ci,useContext as Ai}from"react";import{useStore as bi}from"zustand";import{jsx as Pi}from"react/jsx-runtime";var ft=Ci(null);ft.displayName="ComplexTimeline";function Qn({children:e,store:n}){return Pi(ft.Provider,{value:n,children:e})}function gm(e){let n=Ai(ft);if(!n)throw new Error("useComplexTimeline must be used within a ComplexTimelineProvider");return bi(n,e)}import{HTMLPortal as Ri}from"@atlas-viewer/atlas";import{Fragment as Wn,jsx as ye}from"react/jsx-runtime";function $e({strategy:e,onClickPaintingAnnotation:n}){return ye(Wn,{children:e.items.map((t,r)=>ye(Wn,{children:ye(Ri,{onClick:n?o=>{o.stopPropagation(),n(t.annotationId,t,o)}:void 0,target:t.target?.spatial||void 0,children:ye("div",{"data-textual-content":!0,children:ye(he,{enableDangerouslySetInnerHTML:!0,children:t.text})})},r)}))})}import{Fragment as wi,jsx as De,jsxs as Ei}from"react/jsx-runtime";function Zn({strategy:e,children:n}){let{store:t}=Ii(()=>Yn({complexTimeline:e}),[e]),r=Gn(t,i=>i.isReady),o=Gn(t,i=>i.visibleElements);function s(i){return a=>{a&&t.getState().setElement(i,a)}}return Ti(()=>{if(r){let{startClock:i,stopClock:a}=t.getState();return i(),()=>{a()}}},[e,r]),O("portal","custom-controls",Qn,{store:t,children:n},[r]),Ei(wi,{children:[e.items.map(i=>i.type!=="Image"||!o[i.annotationId]?null:De(se,{image:i,id:i.annotationId},i.id)),e.items.map((i,a)=>i.type!=="Text"||!o[i.annotationId]?null:De($e,{strategy:{type:"textual-content",items:[i]}},a)),e.items.map((i,a)=>i.type!=="Video"||!i.target.spatial?null:De(Mi,{target:i.target.spatial,children:De("video",{ref:s(i.annotationId),src:i.url,style:{height:"100%",width:"100%",opacity:o[i.annotationId]?1:0}})},a))]})}import{Fragment as Ue,jsx as k,jsxs as Y}from"react/jsx-runtime";function ce({x:e,y:n,onChoiceChange:t,registerActions:r,defaultChoices:o,isStatic:s,renderViewerControls:i,renderMediaControls:a,renderComplexTimelineControls:u,viewControlsDeps:c,mediaControlsDeps:l,strategies:d,throwOnUnknown:y,backgroundStyle:A,alwaysShowBackground:h,keepCanvasScale:g=!1,enableSizes:b=!1,enableYouTube:p=!0,onClickPaintingAnnotation:S,children:m}){let v=M(),I=Te(v,["deep-zoom"]),[x]=tn(),P=on(),C=R(),_=Xn(()=>Vi(C),[C]),[f,xe]=On({strategies:d||["images"],defaultChoices:o?.map(({id:w})=>w)}),Se=f.type==="images"?f.choice:void 0,qe=Xn(()=>g?1:Math.max(1,...f.type==="images"?f.images.map(w=>(w.width||0)/w.target?.spatial.width):[]),[g,f]);sn(qe),Jn(()=>{r&&r(xe)},[f.annotations]),Jn(()=>{if(o)for(let w of o)typeof w.opacity<"u"&&_.applyStyles({id:w.id},"atlas",{opacity:w.opacity})},[o]),Ni(()=>{t&&t(Se)},[Se]),O(P&&(f.type==="images"||f.type==="empty"||f.type==="textual-content"&&i)?"overlay":"none",`canvas-portal-controls-${v?.id}`,ge.Provider,i?{value:P||null,children:i(f)}:{},[v,P,f,...c||[]]);let L=Ee({maxWidth:256,maxHeight:256});if(!v)return null;let j=v.accompanyingCanvas,Z=v.placeholderCanvas,le=L&&L.type==="fixed"?k("world-object",{height:v.height,width:v.width,x:e,y:n,children:k("world-image",{uri:L.id,target:{x:0,y:0,width:v.width,height:v.height},display:L.width&&L.height?{width:L.width,height:L.height}:void 0,crop:void 0})}):null;if(f.type==="unknown"){if(le)return le;if(y)throw new Error(f.reason||"Unknown image strategy");return null}let pt=Y(ki,{children:[x?k(ve,{page:x}):null,f.annotations&&f.annotations.pages?f.annotations.pages.map(w=>k(ve,{page:w},w.id)):null,m]}),tr=f.type==="images"?f.images.length:0,Fi=f.type==="media"&&f.media.type==="Video"&&Z?k(Fe,{renderViewerControls:i}):null;return Y(Ue,{children:[Y("world-object",{height:v.height,width:v.width,x:e,y:n,...I,children:[f.type==="empty"||h?k(He,{style:A}):null,f.type==="complex-timeline"?k(Zn,{strategy:f,children:u?u(f):null}):null,f.type==="textual-content"?Y(Ue,{children:[k($e,{strategy:f,onClickPaintingAnnotation:S}),pt]}):null,f.type==="images"?Y(Ue,{children:[f.images.map((w,gt)=>k(se,{isStatic:s,image:w,id:w.id,thumbnail:gt===0?L:void 0,selector:w.selector,enableSizes:b,onClick:S?vt=>{vt.stopPropagation(),S(w.annotationId,w,vt)}:void 0},w.id+gt)),pt]}):null,f.type==="3d-model"?k(Oe,{model:f.model}):null,f.type==="media"?k(Ue,{children:f.media.type==="Sound"?Y(Le,{media:f.media,mediaControlsDeps:l,children:[le,a?a(f):null]}):f.media.type==="Video"?Y(ze,{media:f.media,mediaControlsDeps:l,children:[le,a?a(f):null]}):f.media.type==="VideoYouTube"&&p?Y(jn,{media:f.media,mediaControlsDeps:l,children:[le,a?a(f):null]}):null}):null]},`${v.id}/${f.type}/${tr}`),f.type==="media"&&f.media.type==="Sound"&&j?k(q,{canvas:j.id,children:k(ce,{renderViewerControls:i})}):null,f.type==="media"&&f.media.type==="Sound"&&Z&&!j?k(q,{canvas:Z.id,children:k(ce,{renderViewerControls:i})}):null]})}import{Fragment as Oi,jsx as U,jsxs as Hi}from"react/jsx-runtime";var zi=er(function(n,t){let r=E(),o=Ae(),s=Kt(),{ViewerControls:i,MediaControls:a,ComplexTimelineControls:u}=n.components||{};if(Li(t,()=>s,[s]),!r)return U("div",{});let c=0;return Hi(Oi,{children:[n.header,U(N.Viewer,{height:n.height,mode:n.mode,renderPreset:n.renderPreset,runtimeOptions:n.runtimeOptions,children:o.map((l,d)=>{let y=c;return c+=l.width+(n.spacing||0),U(q,{canvas:l.id,children:U(N.RenderCanvas,{strategies:["3d-model","media","images","empty","textual-content","complex-timeline"],renderViewerControls:d===0&&i?()=>U(i,{}):void 0,renderMediaControls:d===0&&a?()=>U(a,{}):void 0,renderComplexTimelineControls:d===0&&u?()=>U(u,{}):void 0,x:y,...n.canvasProps||{},children:n.annotations},l.id)},l.id)})},n.reuseAtlas?"":s.currentSequenceIndex),n.children]})}),N=er(function({children:n,height:t,annotations:r,canvasProps:o,spacing:s,header:i,components:a,mode:u,reuseAtlas:c,renderPreset:l,runtimeOptions:d,...y},A){let h=X();return U(J,{vault:h,children:U(jt,{...y,children:U(zi,{ref:A,height:t,components:a,spacing:s,canvasProps:o,annotations:r,header:i,mode:u,reuseAtlas:c,renderPreset:l,runtimeOptions:d,children:n})})})});N.RenderImage=se;N.RenderCanvas=ce;N.RenderAnnotationPage=ve;N.RenderAnnotation=Me;N.Viewer=ln;N.CanvasBackground=He;N.Audio=Le;N.Video=ze;N.Model=Oe;N.AudioHTML=ct;N.VideoHTML=lt;N.ModelHTML=mt;N.PlaceholderCanvas=Fe;export{Ce as a,H as b,K as c,Q as d,J as e,X as f,Ct as g,At as h,bt as i,q as j,R as k,T as l,ee as m,Ae as n,E as o,Pt as p,br as q,_e as r,La as s,Rt as t,Ha as u,je as v,Tt as w,It as x,Ga as y,Et as z,Vt as A,kt as B,Ke as C,Mt as D,te as E,Vr as F,kr as G,$t as H,Dt as I,me as J,Nr as K,ps as L,Lr as M,Ht as N,gs as O,Ut as P,Bt as Q,pe as R,jr as S,jt as T,Kt as U,Gr as V,re as W,Yt as X,au as Y,Qt as Z,Wt as _,Gt as $,Xt as aa,tn as ba,nn as ca,ge as da,on as ea,M as fa,Te as ga,ie as ha,Ie as ia,mn as ja,Xc as ka,el as la,tl as ma,yn as na,rt as oa,xn as pa,ko as qa,No as ra,Lo as sa,nl as ta,he as ua,Tn as va,Mn as wa,wn as xa,jo as ya,we as za,En as Aa,Vn as Ba,Nn as Ca,On as Da,Hn as Ea,Ee as Fa,it as Ga,ue as Ha,xd as Ia,Sd as Ja,Cd as Ka,ke as La,Ne as Ma,Qn as Na,gm as Oa,N as Pa};
|
|
48
|
+
`}),Bn("iframe",{className:"video-yt",ref:r,src:`https://www.youtube.com/embed/${n.youTubeId}?enablejsapi=1&origin=${window.location.host}`,referrerPolicy:"no-referrer",sandbox:"allow-scripts allow-same-origin allow-presentation"})]}):null}function _n({media:e,mediaControlsDeps:n,children:t}){let[{element:r,currentTime:o,progress:s},i,a]=ue({duration:e.duration});return O("overlay","video-element",hi,{element:r,media:e,playPause:a.playPause}),null}import{useLayoutEffect as Ti,useMemo as Ii}from"react";import xi from"mitt";import{createStore as Si}from"zustand/vanilla";function jn({currentKeyFrameIndex:e,keyframes:n,targetTime:t,currentTime:r}){if(r<=t){let o=n.findIndex(a=>a.time>t);if(o===-1)return[e,[]];let s={},i=n.slice(e,o);for(let a of i)a.type==="enter"&&(s[a.id]=a),a.type==="exit"&&(s[a.id]?delete s[a.id]:s[a.id]=a);return[o,Object.values(s)]}return[e,[]]}function Kn({complexTimeline:e,startTime:n=0}){let t=xi(),r={},o={progress:null,currentTime:null},s=0,i=null,a=0,u=null;function c(){let S=b.getState().visibleElements,m=r,v=[],I=Object.keys(m);for(let x of I){let P=m[x],C=S[x];P&&C&&v.push(P)}return v}function l(){return Object.keys(r).map(S=>r[S])}function d(p){o.currentTime&&(o.currentTime.innerHTML=it(p),o.progress&&(o.progress.style.width=`${p/e.duration*100}%`))}let y=()=>{let p=b.getState(),S=p.currentPrime;if(!S)return;let m=r,v=p.visibleElements,I=Object.keys(m);for(let x of I){let P=m[x],C=v[x];if(P&&x!==S.id&&C){let _=a-C.time*1e3;Math.abs(a-C.time*1e3-P.currentTime*1e3)>300&&(P.currentTime=_/1e3)}}},A=(p=0)=>{let S=p-s,m=b.getState();if(m.isPlaying){let v=m.currentPrime;if(v){let C=r[v.id];C&&(C.paused?a+=S:a=(v.time+C.currentTime)*1e3)}else a+=S;let I=a/1e3;if(I>m.duration){b.getState().setTime(0),b.setState({isPlaying:!1}),h(),d(0);return}d(I);let[x,P]=jn({currentTime:I,currentKeyFrameIndex:m.nextKeyframeIndex,keyframes:m.complexTimeline.keyframes,targetTime:I});P.length&&m.applyKeyframes(x,P)}s=p,i=requestAnimationFrame(A)},h=()=>{i&&cancelAnimationFrame(i)},g=(p,S)=>{},b=Si((p,S)=>({complexTimeline:e,elements:{},visibleElements:{},isBuffering:!1,bufferMap:{},isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,isReady:!1,volume:100,duration:e.duration,clockStartRequests:0,clockStartTime:0,primeTime:0,currentPrime:null,clockRunning:!1,nextKeyframeIndex:0,startClock:()=>{S().clockRunning||(A(),u=setInterval(y,500)),p({clockRunning:!0,clockStartRequests:S().clockStartRequests+1})},applyKeyframes(m,v){let I=S(),x={...I.visibleElements},P=I.currentPrime;for(let C of v)C.type==="enter"&&(x[C.id]=C,t.emit("complex-timeline.enter",{id:C.id})),C.type==="exit"&&(x[C.id]=null,t.emit("complex-timeline.exit",{id:C.id})),C.isPrime&&(P=C);p({nextKeyframeIndex:m,visibleElements:x,currentPrime:P})},stopClock:()=>{let m=S().clockStartRequests;if(m!==0){if(m===1){h(),u&&clearInterval(u),p({clockRunning:!1,clockStartRequests:0});return}p({clockStartRequests:m-1})}},setElement:(m,v)=>{r[m]=v;let I=Object.keys(r),x=S().complexTimeline;g(v,m),x.items.filter(C=>C.type!=="Image"&&C.type!=="Text").every(C=>I.includes(C.annotationId))&&!S().isReady&&(t.emit("complex-timeline.ready",{complexTimeline:x}),p({isReady:!0}))},removeElement:m=>{delete r[m]},mute(){for(let m of l())m.muted=!0;p({isMuted:!0})},unmute(){for(let m of l())m.muted=!1;p({isMuted:!1})},play(){if(!S().isPlaying){for(let v of c())v.play();p({isPlaying:!0})}},pause(){if(S().isPlaying){for(let v of c())v.pause();p({isPlaying:!1})}},playPause(){let m=S();m.isPlaying?m.pause():m.play()},setDurationPercent(m){let I=S().duration*m;S().setTime(I)},setTime(m){let v=S(),I=a/1e3,x=typeof m=="function"?m(I):m,P=v.nextKeyframeIndex;if(I>x){p({visibleElements:{},currentPrime:null});let L=Object.keys(v.visibleElements);for(let j of L)t.emit("complex-timeline.exit",{id:j});I=0,P=0}let[C,_]=jn({currentTime:I,currentKeyFrameIndex:P,keyframes:v.complexTimeline.keyframes,targetTime:x});v.applyKeyframes(C,_),a=x*1e3;let xe=b.getState().visibleElements,Se=r,qe=Object.keys(xe);for(let L of qe){let j=xe[L];if(j){let Z=Se[L];Z&&(Z.currentTime=(a-j.time*1e3)/1e3)}}d(x)},setVolume(m){for(let v of l())v.volume=Math.min(1,Math.max(0,m/100));p({volume:m})},toggleMute(){let m=S();m.isMuted?(m.unmute(),p({isMuted:!1})):(m.mute(),p({isMuted:!0}))},clearProgressElement(){o.progress=null},setProgressElement(m){o.progress=m},setCurrentTimeElement(m){o.currentTime=m},clearCurrentTimeElement(){o.currentTime=null}}));return t.on("complex-timeline.enter",p=>{let S=b.getState(),m=p.id,v=r[m];v&&S.isPlaying&&v.play()}),t.on("complex-timeline.exit",p=>{let S=b.getState(),m=p.id,v=r[m];v&&(v.currentTime=0,v.pause())}),b.getState().setTime(n),{store:b,emitter:t}}import{HTMLPortal as Mi}from"@atlas-viewer/atlas";import{useStore as Wn}from"zustand";import{createContext as Ci,useContext as Ai}from"react";import{useStore as bi}from"zustand";import{jsx as Pi}from"react/jsx-runtime";var ft=Ci(null);ft.displayName="ComplexTimeline";function Yn({children:e,store:n}){return Pi(ft.Provider,{value:n,children:e})}function gm(e){let n=Ai(ft);if(!n)throw new Error("useComplexTimeline must be used within a ComplexTimelineProvider");return bi(n,e)}import{HTMLPortal as Ri}from"@atlas-viewer/atlas";import{Fragment as Qn,jsx as ye}from"react/jsx-runtime";function $e({strategy:e,onClickPaintingAnnotation:n}){return ye(Qn,{children:e.items.map((t,r)=>ye(Qn,{children:ye(Ri,{onClick:n?o=>{o.stopPropagation(),n(t.annotationId,t,o)}:void 0,target:t.target?.spatial||void 0,children:ye("div",{"data-textual-content":!0,children:ye(he,{enableDangerouslySetInnerHTML:!0,children:t.text})})},r)}))})}import{Fragment as wi,jsx as De,jsxs as Ei}from"react/jsx-runtime";function Gn({strategy:e,children:n}){let{store:t}=Ii(()=>Kn({complexTimeline:e}),[e]),r=Wn(t,i=>i.isReady),o=Wn(t,i=>i.visibleElements);function s(i){return a=>{a&&t.getState().setElement(i,a)}}return Ti(()=>{if(r){let{startClock:i,stopClock:a}=t.getState();return i(),()=>{a()}}},[e,r]),O("portal","custom-controls",Yn,{store:t,children:n},[r]),Ei(wi,{children:[e.items.map(i=>i.type!=="Image"||!o[i.annotationId]?null:De(se,{image:i,id:i.annotationId},i.id)),e.items.map((i,a)=>i.type!=="Text"||!o[i.annotationId]?null:De($e,{strategy:{type:"textual-content",items:[i]}},a)),e.items.map((i,a)=>i.type!=="Video"||!i.target.spatial?null:De(Mi,{target:i.target.spatial,children:De("video",{ref:s(i.annotationId),src:i.url,style:{height:"100%",width:"100%",opacity:o[i.annotationId]?1:0}})},a))]})}import{Fragment as Ue,jsx as k,jsxs as Y}from"react/jsx-runtime";function ce({x:e,y:n,onChoiceChange:t,registerActions:r,defaultChoices:o,isStatic:s,renderViewerControls:i,renderMediaControls:a,renderComplexTimelineControls:u,viewControlsDeps:c,mediaControlsDeps:l,strategies:d,throwOnUnknown:y,backgroundStyle:A,alwaysShowBackground:h,keepCanvasScale:g=!1,enableSizes:b=!1,enableYouTube:p=!0,onClickPaintingAnnotation:S,children:m}){let v=M(),I=Te(v,["deep-zoom"]),[x]=en(),P=rn(),C=R(),_=Jn(()=>Vi(C),[C]),[f,xe]=zn({strategies:d||["images"],defaultChoices:o?.map(({id:w})=>w)}),Se=f.type==="images"?f.choice:void 0,qe=Jn(()=>g?1:Math.max(1,...f.type==="images"?f.images.map(w=>(w.width||0)/w.target?.spatial.width):[]),[g,f]);an(qe),Zn(()=>{r&&r(xe)},[f.annotations]),Zn(()=>{if(o)for(let w of o)typeof w.opacity<"u"&&_.applyStyles({id:w.id},"atlas",{opacity:w.opacity})},[o]),Ni(()=>{t&&t(Se)},[Se]),O(P&&(f.type==="images"||f.type==="empty"||f.type==="textual-content"&&i)?"overlay":"none",`canvas-portal-controls-${v?.id}`,ge.Provider,i?{value:P||null,children:i(f)}:{},[v,P,f,...c||[]]);let L=Ee({maxWidth:256,maxHeight:256});if(!v)return null;let j=v.accompanyingCanvas,Z=v.placeholderCanvas,le=L&&L.type==="fixed"?k("world-object",{height:v.height,width:v.width,x:e,y:n,children:k("world-image",{uri:L.id,target:{x:0,y:0,width:v.width,height:v.height},display:L.width&&L.height?{width:L.width,height:L.height}:void 0,crop:void 0})}):null;if(f.type==="unknown"){if(le)return le;if(y)throw new Error(f.reason||"Unknown image strategy");return null}let pt=Y(ki,{children:[x?k(ve,{page:x}):null,f.annotations&&f.annotations.pages?f.annotations.pages.map(w=>k(ve,{page:w},w.id)):null,m]}),er=f.type==="images"?f.images.length:0,Fi=f.type==="media"&&f.media.type==="Video"&&Z?k(Fe,{renderViewerControls:i}):null;return Y(Ue,{children:[Y("world-object",{height:v.height,width:v.width,x:e,y:n,...I,children:[f.type==="empty"||h?k(He,{style:A}):null,f.type==="complex-timeline"?k(Gn,{strategy:f,children:u?u(f):null}):null,f.type==="textual-content"?Y(Ue,{children:[k($e,{strategy:f,onClickPaintingAnnotation:S}),pt]}):null,f.type==="images"?Y(Ue,{children:[f.images.map((w,gt)=>k(se,{isStatic:s,image:w,id:w.id,thumbnail:gt===0?L:void 0,selector:w.selector,enableSizes:b,onClick:S?tr=>{S(w.annotationId,w,tr)}:void 0},w.id+gt)),pt]}):null,f.type==="3d-model"?k(Oe,{model:f.model}):null,f.type==="media"?k(Ue,{children:f.media.type==="Sound"?Y(Le,{media:f.media,mediaControlsDeps:l,children:[le,a?a(f):null]}):f.media.type==="Video"?Y(ze,{media:f.media,mediaControlsDeps:l,children:[le,a?a(f):null]}):f.media.type==="VideoYouTube"&&p?Y(_n,{media:f.media,mediaControlsDeps:l,children:[le,a?a(f):null]}):null}):null]},`${v.id}/${f.type}/${er}`),f.type==="media"&&f.media.type==="Sound"&&j?k(q,{canvas:j.id,children:k(ce,{renderViewerControls:i})}):null,f.type==="media"&&f.media.type==="Sound"&&Z&&!j?k(q,{canvas:Z.id,children:k(ce,{renderViewerControls:i})}):null]})}import{Fragment as Oi,jsx as U,jsxs as Hi}from"react/jsx-runtime";var zi=Xn(function(n,t){let r=E(),o=Ae(),s=jt(),{ViewerControls:i,MediaControls:a,ComplexTimelineControls:u}=n.components||{};if(Li(t,()=>s,[s]),!r)return U("div",{});let c=0;return Hi(Oi,{children:[n.header,U(N.Viewer,{height:n.height,mode:n.mode,renderPreset:n.renderPreset,runtimeOptions:n.runtimeOptions,children:o.map((l,d)=>{let y=c;return c+=l.width+(n.spacing||0),U(q,{canvas:l.id,children:U(N.RenderCanvas,{strategies:["3d-model","media","images","empty","textual-content","complex-timeline"],renderViewerControls:d===0&&i?()=>U(i,{}):void 0,renderMediaControls:d===0&&a?()=>U(a,{}):void 0,renderComplexTimelineControls:d===0&&u?()=>U(u,{}):void 0,x:y,...n.canvasProps||{},children:n.annotations},l.id)},l.id)})},n.reuseAtlas?"":s.currentSequenceIndex),n.children]})}),N=Xn(function({children:n,height:t,annotations:r,canvasProps:o,spacing:s,header:i,components:a,mode:u,reuseAtlas:c,renderPreset:l,runtimeOptions:d,...y},A){let h=X();return U(J,{vault:h,children:U(_t,{...y,children:U(zi,{ref:A,height:t,components:a,spacing:s,canvasProps:o,annotations:r,header:i,mode:u,reuseAtlas:c,renderPreset:l,runtimeOptions:d,children:n})})})});N.RenderImage=se;N.RenderCanvas=ce;N.RenderAnnotationPage=ve;N.RenderAnnotation=Me;N.Viewer=cn;N.CanvasBackground=He;N.Audio=Le;N.Video=ze;N.Model=Oe;N.AudioHTML=ct;N.VideoHTML=lt;N.ModelHTML=mt;N.PlaceholderCanvas=Fe;export{Ce as a,H as b,K as c,Q as d,J as e,X as f,St as g,Ct as h,At as i,q as j,R as k,T as l,ee as m,Ae as n,E as o,bt as p,br as q,_e as r,La as s,Pt as t,Ha as u,je as v,Rt as w,Tt as x,Ga as y,wt as z,Et as A,Vt as B,Ke as C,It as D,te as E,Vr as F,kr as G,Ft as H,$t as I,me as J,Nr as K,ps as L,Lr as M,Ot as N,gs as O,Dt as P,qt as Q,pe as R,jr as S,_t as T,jt as U,Gr as V,re as W,Kt as X,au as Y,Yt as Z,Qt as _,Wt as $,Jt as aa,en as ba,tn as ca,ge as da,rn as ea,M as fa,Te as ga,ie as ha,Ie as ia,dn as ja,Xc as ka,el as la,tl as ma,hn as na,rt as oa,yn as pa,ko as qa,No as ra,Lo as sa,nl as ta,he as ua,Rn as va,In as wa,Mn as xa,jo as ya,we as za,wn as Aa,En as Ba,kn as Ca,zn as Da,On as Ea,Ee as Fa,it as Ga,ue as Ha,xd as Ia,Sd as Ja,Cd as Ka,ke as La,Ne as Ma,Yn as Na,gm as Oa,N as Pa};
|