react-iiif-vault 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.d.ts +335 -3
- package/dist/bundle.global.js +26 -25
- package/dist/canvas-panel.cjs +5 -5
- package/dist/canvas-panel.js +1 -1
- package/dist/chunk-DXFXJCXN.js +1 -0
- package/dist/chunk-K3CE2M2P.js +48 -0
- package/dist/index.cjs +7 -6
- package/dist/index.d.cts +336 -4
- package/dist/index.d.ts +336 -4
- package/dist/index.js +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/package.json +5 -3
- package/dist/chunk-HEVA2EDS.js +0 -47
- package/dist/chunk-YSH2CIKG.js +0 -1
package/dist/chunk-HEVA2EDS.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import{c as ct,k as lt}from"./chunk-YSH2CIKG.js";import{forwardRef as Nn,useImperativeHandle as Wo}from"react";import Gt,{useCallback as We,useMemo as Zt,useState as xe}from"react";import{AtlasAuto as Ur,ModeContext as _r}from"@atlas-viewer/atlas";import{ErrorBoundary as qr}from"react-error-boundary";import{useContext as te}from"react";import Ln,{useContext as zn,useMemo as On}from"react";import{jsx as Hn}from"react/jsx-runtime";var Fn={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0,annotationPage:void 0},ye=Ln.createContext(Fn),k=()=>zn(ye);function U({value:e,children:n}){let t=k(),r=On(()=>({...t,...e}),[e,t]);return Hn(ye.Provider,{value:r,children:n})}import Dn,{useState as Un}from"react";import{Vault as dt,globalVault as _n}from"@iiif/helpers/vault";import{jsx as ft}from"react/jsx-runtime";var $=Dn.createContext({vault:null,setVaultInstance:e=>{}});function Q({vault:e,vaultOptions:n,useGlobal:t,resources:r,children:o}){let[s,i]=Un(()=>e||(t?_n(n):n?new dt(n):new dt));return ft($.Provider,{value:{vault:s,setVaultInstance:i},children:ft(U,{value:r||{},children:o})})}import{useContext as Sr}from"react";import{createContext as Ar,useMemo as xr}from"react";import{globalVault as qn}from"@iiif/helpers/vault";import{useContext as Bn}from"react";function W(e){let n=Bn($);return e||(n&&n.vault?n.vault:qn())}import{useEffect as $n,useMemo as jn,useState as ze}from"react";function mt(e,{noCache:n=!1}={}){let t=typeof e=="string"?e:e.id,r=W(),[o,s]=ze(t),[i,a]=ze(void 0),u=jn(()=>r.get(t,{skipSelfReturn:!0})||void 0,[t,r]),[c,l]=ze(u);return $n(()=>{(async()=>{try{let f=u&&!n?u:await r.load(t),d=f?f.id||f["@id"]:null;f&&o!==d&&s(d),l(f)}catch(f){a(f)}})()},[t,n]),{isLoaded:!!c,id:o,requestId:t,error:i,resource:c,cached:!!(c&&c===u)}}function pt(e,n){let{id:t,isLoaded:r,error:o,resource:s,requestId:i,cached:a}=mt(e,n);return{id:t,isLoaded:r,error:o,manifest:s,requestId:i,cached:a}}import{jsx as Yn}from"react/jsx-runtime";function gt({manifest:e,children:n}){return Yn(U,{value:{manifest:e},children:n})}import{jsx as Qn}from"react/jsx-runtime";function G({canvas:e,children:n}){return Qn(U,{value:{canvas:e},children:n})}import{useContext as Kn}from"react";import Jn from"react";import{useContext as Wn}from"react";var y=()=>{let{vault:e}=Wn($);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};import{useEffect as Gn,useState as Zn}from"react";function S(e,n=[]){let t=y(),[r,o]=Zn(()=>e(t.getState(),t));return Gn(()=>t.subscribe(s=>e(s,t),s=>{o(s)},!1),n),r}var Z=Jn.createContext([]);function Se(){let e=Kn(Z);return S(n=>e.map(t=>n.iiif.entities.Canvas[t]).filter(Boolean),[e])}import{useMemo as Xn}from"react";function w(e={},n=[]){let{id:t,selector:r}=e,o=k(),s=y(),i=t||o.manifest,a=S(u=>i?u.iiif.entities.Manifest[i]:void 0,[i]);return Xn(()=>{if(a)return r?r(a):a},[a,r,...n])}import{jsx as er}from"react/jsx-runtime";function ht({range:e,children:n}){return er(U,{value:{range:e},children:n})}function tr(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=tr(e,e.get(t));if(r)return r}}return null}function Oe(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(...Oe(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 Yi(e,n,t){for(let r of n.structures){let o=vt(e,e.get(r),t);if(o)return o}return null}function vt(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=vt(e,e.get(r),t);if(s)return s}}return null}function Gi(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"),f=i.includes("non-paged");if(l||f||c||r)return[{id:s.id,type:"Canvas"}];let[d,v]=Fe(e,n);if(u)return d;let m=d.findIndex(p=>p.id===t);if(m===-1)return[];for(let p of v)if(p.includes(m))return p.map(g=>d[g]);return[{id:s.id,type:"Canvas"}]}function Fe(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:Oe(e,n);if(i)return[u,[u.map((m,p)=>p)]];if(a||!s||t)return[u,u.map((m,p)=>[p])];let c=[],l=[],f=()=>{l.length&&(c.push([...l]),l=[])},d=0,v=!1;for(let m=0;m<u.length;m++){let p=e.get(u[m]);if(p.behavior.includes("non-paged")){m===d&&d++,r||(f(),c.push([m]),f());continue}if(m===d||p.behavior.includes("facing-pages")){l.length&&(v=!0),f(),c.push([m]),f();continue}if(l.push(m),v){f(),v=!1;continue}l.length>1&&f()}return l.length&&f(),[u,c]}import{useCallback as Ae,useMemo as rr,useRef as or,useState as ir}from"react";import{useMemo as nr}from"react";function yt(e={},n=[]){let{id:t,selector:r}=e,o=k(),s=t||o.range,i=S(a=>s?a.iiif.entities.Range[s]:void 0,[s]);return nr(()=>{if(i)return r?r(i):i},[i,r,...n])}function St({startCanvas:e,disablePaging:n}){let t=y(),r=w(),o=yt(),[s,i]=ir(void 0),a=o||r;if(!a)throw new Error("Nothing selected");let[u,c]=rr(()=>Fe(t,a,{disablePaging:n}),[t,a,n]),l=or(c);if(l.current!==c){let g=l.current[s][0],A=c.findIndex(H=>H.includes(g));l.current=c,i(A)}let f=Ae(p=>{let g=c.findIndex(A=>A.includes(p));i(g===-1?0:g)},[u,c]),d=Ae(p=>{let g=u.findIndex(A=>A.id===p);g!==-1?f(g):i(0)},[u,c]),v=Ae(()=>{i(p=>p>=c.length-1?p:p+1)},[c]),m=Ae(()=>{i(p=>p<=0?0:p-1)},[c]);return typeof s>"u"&&(e?d(e):i(0)),{visibleItems:c[s]?.map(p=>u[p].id)||[],cursor:s,items:u,sequence:c,hasPrevious:s>0,hasNext:s<c.length-1,setSequenceIndex:i,setCanvasIndex:f,setCanvasId:d,next:v,previous:m}}import{createContext as Ue,useContext as J,useEffect as sr,useMemo as De,useReducer as ur}from"react";import{useEffect as Rt,useMemo as It}from"react";import{createStore as At}from"zustand/vanilla";function ua(e){let n=e.service||e.services||[];for(let t of n)if(t.type==="AuthProbeService2")return!0;return!1}function E(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 xt=()=>At((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:E(t.id,n().authItems,o=>({...o,isPending:!0}))})),ae(t.service).then(()=>{j(r).then(o=>{let s=o.expiresIn,i=Date.now()+s*1e3;e(()=>({authItems:E(t.id,n().authItems,a=>({...a,isLoggedIn:!0,isPending:!1,session:{token:o.accessToken,expires:i}}))}))}).catch(o=>{e(()=>({authItems:E(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=${Pt()}`,s=window.open(o);e(()=>({authItems:E(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:E(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");j(o).then(a=>{e(()=>({authItems:E(t.id,n().authItems,u=>({...u,isLoggedIn:!0,isPending:!1,session:{token:a.accessToken,expires:a.expiresIn}}))}))}).catch(a=>{e(()=>({authItems:E(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:E(t.id,n().authItems,a=>({...a,isPending:!0}))})),ae(s).then(()=>{j(o).then(a=>{e(()=>({authItems:E(t.id,n().authItems,u=>({...u,isLoggedIn:!0,isPending:!1,session:{token:a.accessToken,expires:a.expiresIn}}))}))}).catch(a=>{e(()=>({authItems:E(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:E(t.id,n().authItems,i=>({...i,instances:i.instances-1})),currentAuth:s}))}})),Ct=(e,n)=>At((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 bt(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 j(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 Pt(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 ae(e){let n=`${e.id}?origin=${Pt()}`,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{useStore as ar}from"zustand";function wt(e){let n=It(()=>bt(e),[e]),t=Mt(n.services.access?.id);console.log("probe auth service");let r=It(()=>Ct(n.services.probe,t),[n.services.probe]),o=ar(r);return Rt(()=>{o.status==="unknown"&&!t&&o.probe()},[n.services.probe,o.status]),Rt(()=>{t&&(o.setToken(t),o.probe())},[t]),[e,o,n.hasAuth]}import{useStore as se}from"zustand";import{jsx as K}from"react/jsx-runtime";var ue=Ue(null),X=Ue(null);X.displayName="CurrentAuth";var _e=Ue(null);_e.displayName="AuthActions";function Y(e,n,t){let r=n.authItems.findIndex(i=>i.service.id===e);if(r===-1)return n;let o=[...n.authItems],s=t(o[r]);return s===o[r]?n:(o[r]=s,{...n,authItems:o})}function cr(e,n){switch(n.type){case"login.start":return Y(n.payload.id,e,t=>({...t,isPending:!0}));case"login.success":return Y(n.payload.id,e,t=>({...t,isLoggedIn:!0,isPending:!1,session:{token:n.payload.token,expires:n.payload.expires}}));case"login.error":return Y(n.payload.id,e,t=>({...t,isLoggedIn:!1,isPending:!1,canAuthenticate:!1,error:n.payload.error}));case"session.expire":return Y(n.payload.id,e,t=>({...t,isPending:!1,isLoggedIn:!1,session:null}));case"logout":return Y(n.payload.id,e,t=>({...t,isLoggedIn:!1,session:null,isPending:!1}));case"service.add":return e.authItems.find(r=>r.service.id===n.payload.service.id)?Y(n.payload.service.id,e,r=>({...r,instances:r.instances+1})):{...e,currentAuth:n.payload.service.profile==="active"?0:e.currentAuth,authItems:[{id:n.payload.service.id,type:n.payload.service.profile,service:n.payload.service,probeId:n.payload.probeId,canAuthenticate:!0,instances:1,isPending:!1,isLoggedIn:!1,session:null},...e.authItems]};case"service.remove":{let t=e.currentAuth===e.authItems.findIndex(o=>o.service.id===n.payload.id),r=e.currentAuth;if(t){let o=e.authItems.find(i=>i.service.id===n.payload.id);o&&o.instances>1||(r=e.authItems.findIndex(a=>a.service.id!==n.payload.id&&a.instances>0))}return{...Y(n.payload.id,e,o=>({...o,instances:o.instances-1})),currentAuth:r}}case"list.next":{let t=e.authItems.length,r=e.currentAuth+1;return r>=t?e:{...e,currentAuth:r}}case"list.previous":{let t=e.currentAuth-1;return t<0?e:{...e,currentAuth:t}}case"list.set":return n.payload!==-1&&(n.payload<0||n.payload>=e.authItems.length)?e:{...e,currentAuth:n.payload};default:return e}}function Tt({children:e}){let n=De(()=>xt(),[]);return console.log("authStateStore",n),K(ue.Provider,{value:n,children:e})}function Ia({children:e}){let[n,t]=ur(cr,{currentAuth:-1,authItems:[]}),r=(d,v)=>{if(!d.service)return;let m=d.service.find(g=>g.type==="AuthAccessTokenService2"),p=d;if(t({type:"service.add",payload:{service:d,probeId:v}}),d.profile==="external"){if(!m)throw new Error("Token service not found");j(m).then(g=>{t({type:"login.success",payload:{id:d.id,token:g.accessToken,expires:g.expiresIn}})}).catch(g=>{t({type:"login.error",payload:{id:d.id,error:g.message}})})}if(d.profile==="kiosk"){if(!m)throw new Error("Token service not found");t({type:"login.start",payload:{id:d.id}}),ae(p).then(()=>{j(m).then(g=>{t({type:"login.success",payload:{id:d.id,token:g.accessToken,expires:g.expiresIn}})}).catch(g=>{t({type:"login.error",payload:{id:d.id,error:g.message}})})}).catch(g=>{t({type:"login.error",payload:{id:d.id,error:g.message}})})}d.profile},o=d=>{t({type:"service.remove",payload:d})},s=()=>{let d=n.authItems[n.currentAuth];if(!d||d.isPending||d.isLoggedIn)return;if(d.type!=="active")throw new Error("Cannot login to non-active service");let v=d.service.service.find(m=>m.type==="AuthAccessTokenService2");if(!v)throw new Error("Token service not found");t({type:"login.start",payload:{id:d.id}}),ae(d.service).then(()=>{j(v).then(m=>{let p=m.expiresIn,g=Date.now()+p*1e3;t({type:"login.success",payload:{id:d.id,token:m.accessToken,expires:g}})}).catch(m=>{t({type:"login.error",payload:{id:d.id,error:m.message}})})})},i=()=>{let d=n.authItems[n.currentAuth];if(!d||d.isPending||!d.isLoggedIn)return;if(d.type!=="active")throw new Error("Cannot logout of non-active service");let v=d.service.service.find(g=>g.type==="AuthLogoutService2");if(!v)return;let m=`${v.id}?origin=${window.location.origin}`,p=window.open(m);t({type:"logout",payload:{id:d.id}})},a=()=>{},u=()=>{},c=d=>{},l=De(()=>({addService:r,removeService:o}),[]),f=De(()=>({...n,login:s,logout:i,nextAuth:a,previousAuth:u,setAuth:c}),[n]);return K(X.Provider,{value:f,children:K(_e.Provider,{value:l,children:e})})}function ce(){let e=J(ue);if(!e)throw new Error("useAuthActions must be used within a AuthProvider");return e}function lr(){let e=ce();return se(e,t=>({login:t.login,logout:t.logout,nextAuth:t.nextAuth,previousAuth:t.previousAuth,setAuth:t.setAuth,addService:t.addService,removeService:t.removeService}))}function wa(){let e=ce();return se(e,n=>n)}function dr(e){let n=ce();return se(n,r=>r.authItems.find(o=>o.service.id===e))}function Mt(e){let n=ce();return se(n,r=>r.authItems.find(o=>o.id===e)?.session?.token)}function Ma(e){let n=ce();return se(n,r=>{let o=r.authItems.find(s=>s.service.id===e);return!o||!o.isLoggedIn||!o.session?null:o.session?.token||null})}function Ta(){let e=J(X);if(!e)throw new Error("useCurrentAuth must be used within a AuthProvider");return e}function Va(e){let n=J(X);return n&&n.authItems.find(t=>t.service.id===e)||null}function Na(e){let n=J(X);return!n||!e?null:n.authItems.find(t=>t.id===e)?.session?.token||null}function ka(e){let n=J(X);if(!e||!n)return null;let t=n.authItems.find(r=>r.service.id===e);return!t||!t.isLoggedIn||!t.session?null:t.session?.token||null}function Ea(){return J(_e)}function fr(e){let n=lr(),t=dr(e.service.id);return sr(()=>(console.log("add service",e.service,e.probeId),n?.addService(e.service,e.probeId),()=>{n?.removeService(e.service,e.probeId)}),[e.service]),t?(t.error||!t.isLoggedIn,e.children):null}function He(){return null}function Vt(e){let[n,t,r]=wt(e.resource),o=e.fallbackComponent||He,s=e.loadingComponent||He,i=e.errorComponent||He,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=K(i,{resource:e.resource,error:t.error||"",heading:t.errorHeading,note:t.errorNote,extra:e.extra})),(t.status==="unknown"||t.status==="probing")&&(u=K(s,{})),t.status==="success"&&(u=e.children(n));for(let l of c)u=K(fr,{service:l,probeId:a.id,children:u},l.id);return u}import{createContext as hr,useContext as qa,useMemo as vr}from"react";import{createStore as mr}from"zustand/vanilla";var pr=e=>e.id||e["@id"];function gr(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 Nt=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?pr(n):void 0,r=null;return mr((o,s)=>({service:n,resources:[],lastQuery:{},loading:!1,error:!1,highlight:null,hasSearch:!!n,hasAutocomplete:n?!!gr(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 Qa}from"zustand";function kt(){let e=w();return e?e.service.find(n=>n.profile==="SearchService1"||n.profile==="http://iiif.io/api/search/1/search"):void 0}import{jsx as qe}from"react/jsx-runtime";var ee=hr(null);ee.displayName="Search";function Et(e){let n=kt();return e.store?qe(ee.Provider,{value:e.store,children:e.children}):qe(yr,{service:n,children:e.children})}function yr({service:e,children:n}){let t=vr(()=>Nt(e),[e]);return qe(ee.Provider,{value:t,children:n})}import{jsx as T}from"react/jsx-runtime";var le=()=>{},de=Ar({setCurrentCanvasId:le,setCurrentCanvasIndex:le,nextCanvas:le,previousCanvas:le,items:[],sequence:[],setSequenceIndex:le,currentSequenceIndex:0,hasNext:!1,hasPrevious:!1});function Cr(e){let n=w(),{cursor:t,visibleItems:r,next:o,sequence:s,items:i,setCanvasIndex:a,setCanvasId:u,previous:c,setSequenceIndex:l,hasNext:f,hasPrevious:d}=St({startCanvas:e.startCanvas,disablePaging:e.pagingEnabled===!1}),v=xr(()=>({sequence:s,items:i,setCurrentCanvasId:u,nextCanvas:o,previousCanvas:c,totalCanvases:i.length,setCurrentCanvasIndex:a,setSequenceIndex:l,currentSequenceIndex:t,hasNext:f,hasPrevious:d}),[s,i,u,o,c,i,a,l,t]);return n?r.length===0?null:T(de.Provider,{value:v,children:T(Z.Provider,{value:r,children:T(G,{canvas:r[0],children:e.children})})}):(console.warn("The manifest passed to the provider is not a valid IIIF manifest."),T("div",{children:"Sorry, something went wrong."}))}function Lt(e){let n=W(e.vault),t=pt(e.manifest);if(!t)return console.warn("The manifest passed to the provider is not a valid IIIF manifest."),T("div",{children:"Sorry, something went wrong."});if(t.error)return T("div",{children:t.error.toString()});if(!t.isLoaded)return T("div",{children:"Loading..."});let r=T(Cr,{...e,children:e.children});return T(Q,{vault:n,children:T(gt,{manifest:t.id,children:T(Tt,{children:T(Et,{children:e.rangeId?T(ht,{range:e.rangeId,children:r}):r})})})})}function zt(){return Sr(de)}import{jsx as fe}from"react/jsx-runtime";function Ot(){return{VaultContext:te($),ResourceContext:te(ye),SimpleViewerReactContext:te(de),VisibleCanvasReactContext:te(Z),AuthRContext:te(ue),SearchReactContext:te(ee)}}function Ft(e){return fe(Q,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:fe(Z.Provider,{value:e.bridge.VisibleCanvasReactContext,children:fe(de.Provider,{value:e.bridge.SimpleViewerReactContext,children:fe(ue.Provider,{value:e.bridge.AuthRContext,children:fe(ee.Provider,{value:e.bridge.SearchReactContext,children:e.children})})})})})}import{createContext as wr,useContext as Mr,useMemo as Tr}from"react";import{useCallback as Dt,useLayoutEffect as Pr,useMemo as Rr,useRef as Ir}from"react";import{entityActions as Be}from"@iiif/helpers/vault/actions";import{useMemo as br}from"react";function Ht(){let n=y().getStore();return br(()=>t=>n.dispatch(t),[n])}function Ut(e){return typeof e!="string"&&e&&e.bindToVault}function _t(){let e=y(),n=Ir([]),t=Ht(),r=Rr(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);Pr(()=>{let a={id:r,type:"AnnotationPage",behavior:[],label:null,thumbnail:[],summary:null,requiredStatement:null,metadata:[],rights:null,provider:[],items:[],seeAlso:[],homepage:[],rendering:[],service:[]};t(Be.importEntities({entities:{AnnotationPage:{[a.id]:a}}}))},[r]);let o=S(a=>r&&a.iiif.entities.AnnotationPage[r]||null,[r]),s=Dt((a,u)=>{if(r){if(Ut(a)){let f=a;f.__vault||f.bindToVault(e),a=typeof f.source=="string"?f.source:f.source.id,n.current[a]=f}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(f=>f.id===l.id)||t(Be.addReference({id:r,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"},index:u})))}},[r]),i=Dt(a=>{r&&(Ut(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(Be.removeReference({id:r,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"}})))},[r]);return[o,{addAnnotation:s,removeAnnotation:i}]}import{jsx as Vr}from"react/jsx-runtime";var qt=wr(null);function Bt(){let e=Mr(qt);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function $t({children:e}){let[n,{addAnnotation:t,removeAnnotation:r}]=_t();return Vr(qt.Provider,{value:Tr(()=>({fullPage:n,addAnnotation:t,removeAnnotation:r}),[n]),children:e})}import{jsx as $e,jsxs as Nr}from"react/jsx-runtime";function jt({width:e,style:n,height:t,error:r,resetErrorBoundary:o}){return Nr("div",{style:{width:e,height:t,minHeight:500,...n||{},background:"#f9f9f9"},children:[$e("h3",{children:"Error occurred"}),$e("p",{children:r.message}),$e("button",{onClick:o,children:"Reset"})]})}import{createContext as kr,useContext as Er}from"react";var me=kr(null);function Yt(){return Er(me)}import{createContext as Qt,useContext as Lr,useEffect as zr}from"react";var je=Qt(()=>{}),Ye=Qt(()=>{});function L(e,n,t,r,o=[]){let s=Lr(e==="portal"?Ye:je);zr(()=>(e!=="none"&&s(n,t,r),()=>{s(n,null)}),[n,e,s,...o])}import{createContext as Fr,useContext as Hr,useEffect as Dr}from"react";import{useMemo as Or}from"react";function b(e={},n=[]){let{id:t,selector:r}=e,o=k(),s=t||o.canvas,i=S(a=>s?a.iiif.entities.Canvas[s]:void 0,[s]);return Or(()=>{if(i)return r?r(i):i},[i,r,...n])}var Qe=Fr(()=>{});function Wt(e){let n=b(),t=Hr(Qe);Dr(()=>n&&n.id?(t(n.id,e),()=>t(n.id,-1)):()=>{},[n,e])}import{Fragment as Br,jsx as R,jsxs as $r}from"react/jsx-runtime";function Kt({children:e,errorFallback:n,outerContainerProps:t={},worldScale:r,...o}){let[s,i]=xe(),a=Ot(),u=n||jt,[c,l]=xe({}),f=Object.entries(c),[d,v]=xe({}),m=Object.entries(d),[p,g]=xe({}),A=Zt(()=>r||Math.max(...Object.values(p)),[p]),H=Zt(()=>({maxOverZoom:A||1,...o.runtimeOptions||{}}),[A,o.runtimeOptions]),I=We((C,P)=>{g(N=>{if(P===-1){let{[C]:h,...O}=N;return O}return{...N,[C]:P}})},[]),Le=We((C,P,N)=>{l(({[C]:h,...O})=>P?{...O,[C]:{element:P,props:N}}:O)},[]),he=We((C,P,N)=>{v(({[C]:h,...O})=>P?{...O,[C]:{element:P,props:N}}:O)},[]);return $r(qr,{resetKeys:[],fallbackRender:C=>R(u,{...o,...C}),children:[R(Ur,{...o,containerProps:{style:{position:"relative"},...o.containerProps||{}},htmlChildren:R(Br,{children:f.map(([C,{element:P,props:N}])=>R(Gt.Fragment,{children:R(P,{...N||{}})},C))}),onCreated:C=>{i(C),o.onCreated&&o.onCreated(C)},runtimeOptions:H,children:R(me.Provider,{value:s,children:R(Qe.Provider,{value:I,children:R(je.Provider,{value:Le,children:R(Ye.Provider,{value:he,children:R(Ft,{bridge:a,children:R(_r.Provider,{value:o.mode||"explore",children:R($t,{children:e})})})})})})})}),R("div",{children:m.map(([C,{element:P,props:N}])=>R(Gt.Fragment,{children:R(P,{...N||{}})},C))})]})}import{mergeStyles as Zr,RegionHighlight as Kr}from"@atlas-viewer/atlas";import{useMemo as Jt}from"react";import{createEventsHelper as jr}from"@iiif/helpers/events";function Ce(e,n){let t=y(),r=Jt(()=>jr(t),[t]),o=S(()=>e&&e.id?t.getResourceMeta(e.id,"eventManager"):null,[e]);return Jt(()=>e?r.getListenersAsProps(e,n):{},[o,e,t,n])}import{useMemo as Yr}from"react";import{createStylesHelper as Qr}from"@iiif/helpers/styles";function ne(e,n){let t=y(),r=Yr(()=>Qr(t),[t]);return S(()=>{if(!e)return null;let o=r.getAppliedStyles(e.id);return o?n?o[n]:o:void 0},[e,n])}import{useMemo as Jr}from"react";import{useMemo as Wr}from"react";import{expandTarget as Gr}from"@iiif/helpers/annotation-targets";function be(e={},n=[]){let{id:t,selector:r}=e,o=k(),s=y(),i=t||o.annotation,a=S(c=>i?c.iiif.entities.Annotation[i]:void 0,[i]),u=S(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 Wr(()=>{if(!a)return;let c={...a,body:u,target:Gr(a.target,{typeMap:s.getState().iiif.mapping})};return r?r(c):c},[a,r,u,...n])}import{jsx as Xr}from"react/jsx-runtime";var Pe=({id:e,style:n,className:t,interactive:r})=>{let o=be({id:e}),s=ne(o,"atlas"),i=ne(o,"html"),a=Ce(o,["atlas"]),u=b(),c=Jr(()=>Zr(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)?Xr(Kr,{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 to}from"react";import{useMemo as eo}from"react";function Xt(e={},n=[]){let{id:t,selector:r}=e,o=k(),s=t||o.annotationPage,i=S(a=>s?a.iiif.entities.AnnotationPage[s]:void 0,[s]);return eo(()=>{if(i)return r?r(i):i},[i,...n])}import{jsx as en}from"react/jsx-runtime";var pe=({className:e,page:n})=>{let t=Xt({id:n.id})||n,r=ne(t,"atlas"),o=ne(t,"html");return S(s=>t.id?s.iiif.entities.AnnotationPage[t.id]:null,[]),en(to,{children:t.items?.map(s=>en(Pe,{id:s.id,style:r,className:o?.className||e},s.id))})};import{createStylesHelper as $o}from"@iiif/helpers/styles";import{Fragment as sn,useMemo as co}from"react";import{HTMLPortal as io,TileSet as ao}from"@atlas-viewer/atlas";import nn,{useMemo as Ge}from"react";import{jsx as _}from"react/jsx-runtime";var rn=nn.createContext("en");function uc(e){return _(rn.Provider,{value:e.language,children:e.children})}function Ze(){return nn.useContext(rn)}function tn(e){return e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):e}function no({as:e,language:n,children:t,viewingDirection:r,...o}){let s=Ze();return Ge(()=>tn(s)===tn(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 on(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 ro=(e,n=[])=>{let t=Ze();return Ge(()=>{let r=e();return on(t,r,[])},[t,...n])};function oo(e,n,t=`
|
|
2
|
-
`){let r=ro(()=>Object.keys(e||{}),[e]);return[Ge(()=>{if(!e)return n||"";if(typeof e=="string")return e;let o=r?e[r]:void 0;return o?typeof o=="string"?o:o.join(t):""},[r,n,e]),r]}function cc(){let e=Ze();return function(t,r,o){let s=Object.keys(t||{}),i=on(e,s,[]);if(!t)return r||"";if(typeof t=="string")return t;let a=i?t[i]:void 0;return a?typeof a=="string"?a:a.join(typeof o<"u"?o:`
|
|
3
|
-
`):""}}function ge({as:e,defaultText:n,enableDangerouslySetInnerHTML:t,children:r,separator:o,...s}){let[i,a]=oo(r,n,o);return a?_(no,{...s,as:e,language:a,title:t?void 0:i,dangerouslySetInnerHTML:t?{__html:i}:void 0,children:t?void 0:i}):e?_(e,{...s,children:i}):_("span",{...s,title:t?void 0:i,dangerouslySetInnerHTML:t?{__html:i}:void 0,children:t?void 0:i})}import{jsx as q,jsxs as uo}from"react/jsx-runtime";function so({resource:e,heading:n,note:t,extra:r}){return r?q(io,{target:{x:0,y:0,width:r.target?.spatial.width,height:r.target?.spatial.height},backgroundColor:"#333",relative:!0,children:q("div",{style:{display:"flex",alignContent:"center",justifyContent:"center",alignItems:"center",height:"100%",width:"100%",background:"#444",color:"#BBB"},children:uo("div",{children:[q(ge,{children:n||"Not authorised"}),t&&q("p",{children:q(ge,{children:t})}),q("p",{children:e.id||e["@id"]||"unknown"})]})})}):null}function an({image:e,thumbnail:n,crop:t,enableSizes:r}){return q(Vt,{resource:e.service,errorComponent:so,extra:e,children:o=>{let s=o.width||e.width||0,i=o.height||e.height||0;return q(ao,{tiles:{id:o.id||o["@id"]||"unknown",height:i,width:s,imageService:o},enableSizes:r,x:0,y:0,width:e.target?.spatial.width,height:e.target?.spatial.height,crop:t})}},e.id)}import{jsx as Ke,jsxs as un}from"react/jsx-runtime";function Re({id:e,image:n,thumbnail:t,isStatic:r,x:o=0,y:s=0,children:i,selector:a,onClick:u,enableSizes:c}){let l=co(()=>{if(!(!a||a.spatial.x===0&&a.spatial.y===0))return a.spatial},[a]);return Ke("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?un(sn,{children:[Ke(an,{image:n,thumbnail:t,crop:l,enableSizes:c}),i]},"service"):un(sn,{children:[Ke("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 jo,useEffect as Tn,useLayoutEffect as Yo,useMemo as Vn}from"react";import{HTMLPortal as Qo}from"@atlas-viewer/atlas";import{useMemo as yn}from"react";import{useCallback as dn,useMemo as fo}from"react";function lo(e,n){let t=e?.iiif?.meta[n];return t?t.annotationPageManager:null}function cn(e,n){return S(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=lo(t,s);i&&i.views&&i.views[e]&&r.push(s)}return r},[e,n])}function ln({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 mo(e,n){let t=e?.iiif?.meta[n];return t?t.annotationPageManager:null}function fn(e,n={}){let t=y(),r=w(),o=b(),s=Se(),i=fo(()=>ln({all:n.all,manifest:r,canvas:o,canvases:s}),[n.all,o,s,r]),a=cn(e,n.all?void 0:i),u=dn(l=>{e&&t.setMetaValue([l,"annotationPageManager","views"],f=>f&&!f[e]?f:{...f||{},[e]:!1})},[e,t]),c=dn((l,f={})=>{if(!e)return;let d=t.getState(),v=[];if(f?.deselectOthers){let m=Object.keys(d.iiif.entities.AnnotationPage);for(let p of m){let g=mo(d,p);g&&g.views&&g.views[e]&&v.push(p)}}for(let m of v)u(m);t.setMetaValue([l,"annotationPageManager","views"],m=>m&&m[e]?m:{...m||{},[e]:!0})},[e,u,t]);return{availablePageIds:i,enabledPageIds:a,setPageEnabled:c,setPageDisabled:u}}function mn(e,n){return S((t,r)=>r.get(e.map(o=>({id:o,type:n}))),[e,n])}import{useCallback as yo,useEffect as So,useRef as Ao,useState as xo}from"react";import po,{useContext as go}from"react";import{ImageServiceLoader as ho}from"@atlas-viewer/iiif-image-api";var vo=po.createContext(new ho);function Ie(){return go(vo)}function pn(){let e=Ie(),[n,t]=xo({}),r=Ao(!1);return So(()=>()=>{r.current=!0},[]),[yo((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 Co,useMemo as hn,useState as bo}from"react";function gn(e={}){let n=be(),t=b(e.canvasId?{id:e.canvasId}:void 0);return S((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 Po}from"@iiif/helpers/painting-annotations";function vn(e,n=[]){let t=y(),r=hn(()=>Po(t),[]),o=gn({enableSingleAnnotation:e?.enableSingleAnnotation}),[s,i]=bo(e?.defaultChoices||[]),a=hn(()=>r.getPaintables(o,s),[t,o,s,...n]),c={makeChoice:Co((l,{deselectOthers:f=!0,deselect:d=!1}={})=>{if(a.choice){if(a.choice.type!=="single-choice")throw new Error("Complex choice not supported yet");i(v=>{if(d){let p=v.filter(g=>g!==l);if(p.length===0){let g=a.items[0].resource.id;return g?[g]:[]}return p}if(f)return[l];let m=[...v];if(m.length===0&&a.items.length){let p=a.items[0].resource.id;p&&m.push(p)}return v.indexOf(l)!==-1?v:[...v,l]})}},[a.choice])};return[a,c]}function Sn(e){let n=w(),t=b(),r=y(),[o,s]=pn(),{enabledPageIds:i}=fn(e?.annotationPageManagerId||n?.id||t?.id,{all:!1}),a=mn(i,"AnnotationPage"),u=e?.strategies||["empty","images","media","textual-content","complex-timeline"],[c,l]=vn(e,[s]),f=yn(()=>lt({canvas:t,paintables:c,supports:u,loadImageService:o}),[t,c,r,l.makeChoice]);return yn(()=>f.type==="unknown"?[f,ct]:[{...f,annotations:{pages:a}},l],[f,a])}import{useEffect as Io,useMemo as wo,useRef as Mo,useState as To}from"react";import{useEffect as Ro}from"react";var An=(e,n=[])=>{let t=y();Ro(()=>{e(t)},[t,...n])};import{createThumbnailHelper as Vo}from"@iiif/helpers/thumbnail";function xn(e,n,{canvasId:t,manifestId:r}={}){let o=y(),s=Ie(),i=wo(()=>Vo(o,{imageServiceLoader:s}),[o,s]),[a,u]=To(),c=w(r?{id:r}:void 0),l=b(t?{id:t}:void 0),f=l||c,d=Mo(!1);if(Io(()=>(d.current=!1,()=>{d.current=!0}),[]),!f)throw new Error("Must be called under a manifest or canvas context.");return An(v=>{i.getBestThumbnailAtSize(f,e,n).then(m=>{m.best&&!d.current&&u(m.best)})},[f]),a}import{useCallback as z,useEffect as Cn,useReducer as No,useRef as we}from"react";function ko(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function Eo(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 Lo(e){let n=Math.round(e);return`${Math.floor(n/60)}:${`${n%60}`.padStart(2,"0")}`}function re(e){let[n,t]=No(Eo,ko(e.duration)),r=we(null),o=we(null),s=we(null),i=we(!1),a=z(()=>{o.current&&r.current&&(o.current.innerHTML=Lo(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=z(()=>{r.current&&(t({type:"PLAY_REQUESTED"}),r.current.play().then(()=>{t({type:"PLAY"})}),a())},[a]),c=z(()=>{r.current&&(r.current.duration>0&&r.current.paused?u():l())},[a]),l=z(()=>{r.current&&(r.current.pause(),t({type:"PAUSE"}),a())},[a]),f=z(()=>{r.current&&(r.current.muted=!r.current.muted,t(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"}))},[]),d=z(()=>{r.current&&(r.current.muted=!0,t({type:"MUTE"}))},[]),v=z(()=>{r.current&&(r.current.muted=!1,t({type:"UNMUTE"}))},[]),m=z(A=>{r.current&&(r.current.muted=!1,r.current.volume=A/100,t({type:"SET_VOLUME",volume:A}))},[]),p=z(A=>{r.current&&(r.current.currentTime=Math.max(0,Math.min(A*e.duration,e.duration)),a())},[]),g=z(A=>{r.current&&(r.current.currentTime=Math.max(0,Math.min(A,e.duration)),a())},[]);return Cn(()=>{let A=setInterval(()=>{a()},350);return()=>clearInterval(A)},[a,e.duration]),Cn(()=>{let A=()=>{t({type:"FINISHED"})},H=r.current;return H?.addEventListener("ended",A),()=>H?.removeEventListener("ended",A)},[]),[{element:r,currentTime:o,progress:s},n,{play:u,pause:l,playPause:c,mute:d,unmute:v,toggleMute:f,setVolume:m,setDurationPercent:p,setTime:g}]}import{createContext as Xe,useContext as et}from"react";import{jsx as Je}from"react/jsx-runtime";var bn=Xe(null),Pn=Xe(null),Rn=Xe(null);function Ml(){let e=et(bn);if(!e)throw new Error("Ctx not found");return e}function Tl(){let e=et(Pn);if(!e)throw new Error("Ctx not found");return e}function Vl(){let e=et(Rn);if(!e)throw new Error("Ctx not found");return e}function Me({actions:e,state:n,children:t,currentTime:r,progress:o,element:s}){return Je(Rn.Provider,{value:{currentTime:r,progress:o,element:s},children:Je(Pn.Provider,{value:e,children:Je(bn.Provider,{value:n,children:t})})})}import{jsx as zo,jsxs as Oo}from"react/jsx-runtime";function tt({media:e,children:n}){let[{element:t,currentTime:r,progress:o},s,i]=re({duration:e.duration});return Oo(Me,{state:s,actions:i,currentTime:r,progress:o,element:t,children:[zo("audio",{ref:t,src:e.url}),n]})}function Te({media:e,mediaControlsDeps:n,children:t}){return L("portal","audio",tt,{media:e,children:t},[e,...n||[]]),null}import{jsx as In,jsxs as Fo}from"react/jsx-runtime";function nt({element:e,media:n,playPause:t}){return Fo("div",{className:"video-container",part:"video-container",onClick:t,children:[In("style",{children:`
|
|
4
|
-
.video-container {
|
|
5
|
-
position: absolute;
|
|
6
|
-
top: 0;
|
|
7
|
-
bottom: 0;
|
|
8
|
-
left: 0;
|
|
9
|
-
right: 0;
|
|
10
|
-
background: #000;
|
|
11
|
-
z-index: 13;
|
|
12
|
-
display: flex;
|
|
13
|
-
justify-content: center;
|
|
14
|
-
pointer-events: visible;
|
|
15
|
-
}
|
|
16
|
-
`}),In("video",{ref:e,src:n.url,style:{width:"100%",objectFit:"contain"}})]})}function Ve({media:e,mediaControlsDeps:n,children:t}){let[{element:r,currentTime:o,progress:s},i,a]=re({duration:e.duration});return L("overlay","video-element",nt,{element:r,media:e,playPause:a.playPause}),L("portal","custom-controls",Me,{state:i,actions:a,currentTime:o,progress:s,element:r,children:t},[o,i,e,...n||[]]),null}import{Fragment as Ho,jsx as rt,jsxs as Do}from"react/jsx-runtime";function ot({model:e}){return Do(Ho,{children:[rt("style",{children:`
|
|
17
|
-
.model-container {
|
|
18
|
-
position: absolute;
|
|
19
|
-
top: 0;
|
|
20
|
-
bottom: 0;
|
|
21
|
-
left: 0;
|
|
22
|
-
right: 0;
|
|
23
|
-
background: #000;
|
|
24
|
-
z-index: 13;
|
|
25
|
-
display: flex;
|
|
26
|
-
justify-content: center;
|
|
27
|
-
pointer-events: visible;
|
|
28
|
-
}
|
|
29
|
-
`}),rt("div",{className:"model-container",children:rt("model-viewer",{"interaction-prompt":"none",style:{width:"100%",height:"100%"},"camera-controls":"","ar-status":"not-presenting",src:e.id})})]})}function Ne({model:e,name:n}){return L("overlay",`model-${n}`,ot,{model:e},[e]),null}import{jsx as Uo}from"react/jsx-runtime";function ke({style:e}){let n=b();return!n||!n.height||!n.width?null:Uo("box",{interactive:!1,target:{x:0,y:0,width:Number(n.width),height:Number(n.height)},style:e})}import{useRef as _o}from"react";import{jsx as wn,jsxs as Bo}from"react/jsx-runtime";function qo({element:e,media:n,playPause:t}){let r=_o(null);return n.youTubeId?Bo("div",{className:"video-container",part:"video-container",onClick:t,children:[wn("style",{children:`
|
|
30
|
-
.video-container {
|
|
31
|
-
position: absolute;
|
|
32
|
-
top: 0;
|
|
33
|
-
bottom: 0;
|
|
34
|
-
left: 0;
|
|
35
|
-
right: 0;
|
|
36
|
-
background: #000;
|
|
37
|
-
z-index: 13;
|
|
38
|
-
display: flex;
|
|
39
|
-
justify-content: center;
|
|
40
|
-
pointer-events: visible;
|
|
41
|
-
}
|
|
42
|
-
.video-yt {
|
|
43
|
-
border: none;
|
|
44
|
-
width: 100%;
|
|
45
|
-
object-fit: contain;
|
|
46
|
-
}
|
|
47
|
-
`}),wn("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 Mn({media:e,mediaControlsDeps:n,children:t}){let[{element:r,currentTime:o,progress:s},i,a]=re({duration:e.duration});return L("overlay","video-element",qo,{element:r,media:e,playPause:a.playPause}),null}import{Fragment as Ee,jsx as V,jsxs as B}from"react/jsx-runtime";function it({x:e,y:n,onChoiceChange:t,registerActions:r,defaultChoices:o,isStatic:s,renderViewerControls:i,renderMediaControls:a,viewControlsDeps:u,mediaControlsDeps:c,strategies:l,throwOnUnknown:f,backgroundStyle:d,alwaysShowBackground:v,keepCanvasScale:m=!1,enableSizes:p=!1,enableYouTube:g=!0,onClickPaintingAnnotation:A,children:H}){let I=b(),Le=Ce(I,["deep-zoom"]),[he]=Bt(),C=Yt(),P=y(),N=Vn(()=>$o(P),[P]),[h,O]=Sn({strategies:l||["images"],defaultChoices:o?.map(({id:x})=>x)}),at=h.type==="images"?h.choice:void 0,kn=Vn(()=>m?1:Math.max(1,...h.type==="images"?h.images.map(x=>(x.width||0)/x.target?.spatial.width):[]),[m,h]);Wt(kn),Tn(()=>{r&&r(O)},[h.annotations]),Tn(()=>{if(o)for(let x of o)typeof x.opacity<"u"&&N.applyStyles({id:x.id},"atlas",{opacity:x.opacity})},[o]),Yo(()=>{t&&t(at)},[at]),L(C&&(h.type==="images"||h.type==="empty"||h.type==="textual-content"&&i)?"overlay":"none",`canvas-portal-controls-${I?.id}`,me.Provider,i?{value:C||null,children:i(h)}:{},[I,C,h,...u||[]]);let D=xn({maxWidth:256,maxHeight:256});if(!I)return null;let st=I.accompanyingCanvas,oe=D&&D.type==="fixed"?V("world-object",{height:I.height,width:I.width,x:e,y:n,children:V("world-image",{uri:D.id,target:{x:0,y:0,width:I.width,height:I.height},display:D.width&&D.height?{width:D.width,height:D.height}:void 0,crop:void 0})}):null;if(h.type==="unknown"){if(oe)return oe;if(f)throw new Error(h.reason||"Unknown image strategy");return null}let ut=B(jo,{children:[he?V(pe,{page:he}):null,h.annotations&&h.annotations.pages?h.annotations.pages.map(x=>V(pe,{page:x},x.id)):null,H]}),En=h.type==="images"?h.images.length:0;return B(Ee,{children:[B("world-object",{height:I.height,width:I.width,x:e,y:n,...Le,children:[h.type==="empty"||v?V(ke,{style:d}):null,h.type==="textual-content"?h.items.map((x,ve)=>B(Ee,{children:[V(Qo,{onClick:A?ie=>{ie.stopPropagation(),A(x.annotationId,x,ie)}:void 0,target:x.target?.spatial||void 0,children:V("div",{"data-textual-content":!0,children:V(ge,{enableDangerouslySetInnerHTML:!0,children:x.text})})},ve),ut]})):null,h.type==="images"?B(Ee,{children:[h.images.map((x,ve)=>V(Re,{isStatic:s,image:x,id:x.id,thumbnail:ve===0?D:void 0,selector:x.selector,enableSizes:p,onClick:A?ie=>{ie.stopPropagation(),A(x.annotationId,x,ie)}:void 0},x.id+ve)),ut]}):null,h.type==="3d-model"?V(Ne,{model:h.model}):null,h.type==="media"?V(Ee,{children:h.media.type==="Sound"?B(Te,{media:h.media,mediaControlsDeps:c,children:[oe,a?a(h):null]}):h.media.type==="Video"?B(Ve,{media:h.media,mediaControlsDeps:c,children:[oe,a?a(h):null]}):h.media.type==="VideoYouTube"&&g?B(Mn,{media:h.media,mediaControlsDeps:c,children:[oe,a?a(h):null]}):null}):null]},`${I.id}/${h.type}/${En}`),h.type==="media"&&h.media.type==="Sound"&&st?V(G,{canvas:st.id,children:V(it,{renderViewerControls:i})}):null]})}import{Fragment as Zo,jsx as F,jsxs as Ko}from"react/jsx-runtime";var Go=Nn(function(n,t){let r=w(),o=Se(),s=zt(),{ViewerControls:i,MediaControls:a}=n.components||{};if(Wo(t,()=>s,[s]),!r)return F("div",{});let u=0;return Ko(Zo,{children:[n.header,F(M.Viewer,{height:n.height,mode:n.mode,children:o.map((c,l)=>{let f=u;return u+=c.width+(n.spacing||0),F(G,{canvas:c.id,children:F(M.RenderCanvas,{strategies:["3d-model","media","images","empty","textual-content"],renderViewerControls:l===0&&i?()=>F(i,{}):void 0,renderMediaControls:l===0&&a?()=>F(a,{}):void 0,x:f,...n.canvasProps||{},children:n.annotations},c.id)},c.id)})},n.reuseAtlas?"":s.currentSequenceIndex),n.children]})}),M=Nn(function({children:n,height:t,annotations:r,canvasProps:o,spacing:s,header:i,components:a,mode:u,reuseAtlas:c,...l},f){let d=W();return F(Q,{vault:d,children:F(Lt,{...l,children:F(Go,{ref:f,height:t,components:a,spacing:s,canvasProps:o,annotations:r,header:i,mode:u,reuseAtlas:c,children:n})})})});M.RenderImage=Re;M.RenderCanvas=it;M.RenderAnnotationPage=pe;M.RenderAnnotation=Pe;M.Viewer=Kt;M.CanvasBackground=ke;M.Audio=Te;M.Video=Ve;M.Model=Ne;M.AudioHTML=tt;M.VideoHTML=nt;M.ModelHTML=ot;export{ye as a,k as b,U as c,$ as d,Q as e,W as f,mt as g,pt as h,gt as i,G as j,y as k,S as l,Z as m,Se as n,w as o,ht as p,tr as q,Oe as r,Yi as s,vt as t,Gi as u,Fe as v,yt as w,St as x,ua as y,xt as z,Ct as A,bt as B,j as C,ae as D,ue as E,X as F,_e as G,Tt as H,Ia as I,ce as J,lr as K,wa as L,dr as M,Mt as N,Ma as O,Ta as P,Va as Q,Na as R,ka as S,Ea as T,Vt as U,kt as V,de as W,Cr as X,Lt as Y,zt as Z,Ot as _,Ft as $,Ht as aa,_t as ba,Bt as ca,$t as da,me as ea,Yt as fa,b as ga,Ce as ha,ne as ia,be as ja,Xt as ka,uc as la,Ze as ma,no as na,ro as oa,oo as pa,cc as qa,ge as ra,ln as sa,fn as ta,mn as ua,vo as va,Ie as wa,pn as xa,gn as ya,vn as za,Sn as Aa,An as Ba,xn as Ca,Lo as Da,re as Ea,Ml as Fa,Tl as Ga,Vl as Ha,Me as Ia,M as Ja};
|
package/dist/chunk-YSH2CIKG.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{expandTarget as w}from"@iiif/helpers";function W(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function c(e,o){let{selector:r,source:i}=w(o);if(i.id!==e.id)return[null,i];let t={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}};return[r?r.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:r.temporal,spatial:t.spatial}:r:null,i]}var k={makeChoice:()=>{}},l={type:"unknown"},n=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),y=(e,o)=>({type:"empty",width:e,height:o,annotations:{pages:[]},image:null,images:[]});var P=["model/gltf-binary"];function S(e,o){let i=o.items[0].resource;return i.format?P.indexOf(i.format)===-1?n(`3D format: ${i.format} is unsupported`):{type:"3d-model",model:i}:n("Unknown format")}import{getImageServices as N}from"@atlas-viewer/iiif-image-api";import{expandTarget as h}from"@iiif/helpers/annotation-targets";function x(e,o,r){let i=[];for(let t of o.items){let a=t.resource&&t.resource.type==="SpecificResource"?t.resource.source:t.resource;if(!a.id)return n("No resource Identifier");let s;if(a.service){let u=N(a);u[0]&&(s=r(u[0],e))}let p={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[d,f]=c(e,t.target);if(!(f.id===e.id||decodeURIComponent(f.id||"")===(e.id||"")))continue;let z=t.resource.width&&t.resource.height?{type:"BoxSelector",spatial:{x:0,y:0,width:t.resource.width,height:t.resource.height}}:void 0,m=t.resource.type==="SpecificResource"?h(t.resource):null;if(t.selector){let u=h({type:"SpecificResource",source:t.resource,selector:t.selector});u&&(m=u)}let g=m&&m.selector&&(m.selector.type==="BoxSelector"||m.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:m.selector.spatial.x,y:m.selector.spatial.y,width:m.selector.spatial.width,height:m.selector.spatial.height}}:void 0;s&&!s.id&&(s.id=s["@id"]);let R={id:a.id,type:"Image",annotationId:t.annotationId,width:Number(d||g?a.width:e.width),height:Number(d||g?a.height:e.height),service:s,sizes:s&&s.sizes?s.sizes:a.width&&a.height?[{width:a.width,height:a.height}]:[],target:d&&d.type!=="PointSelector"?d:p,selector:g};i.push(R)}return{type:"images",image:i[0],images:i,choice:o.choice}}function T(e,o={},r){let i=e.language||r||"none";switch(e.type){case"TextualBody":{typeof e.value<"u"&&(o[i]=e.value);break}case"List":case"Composite":case"Choice":e.items&&e.items.forEach(t=>T(t,o,i))}return o}function I(e,o){let r=[];return o.items.forEach(i=>{if(i.resource){let[t]=c(e,i.target);r.push({annotationId:i.annotationId,text:T(i.resource),target:t})}}),{type:"textual-content",items:r}}var b=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function C(e,o){let r=o.items.filter(p=>p.type==="video"),i=!1;if(e.duration||(i=!0),r.length>1)return n("Only one video source supported");let t=r[0]?.resource,a=!!(t.service||[]).find(p=>(p.profile||"").includes("youtube.com"));if(!a&&i)return n("Video does not have duration");if(!t)return n("Unknown video");if((!t.format||t.format==="text/html")&&!a)return n("Video does not have format");let s={annotationId:o.items[0].annotationId,duration:e.duration,url:t.id,type:"Video",items:[],target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:t.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}};if(a){s.type="VideoYouTube";let p=t.id.match(b);if(!p[1])return n("Video is not known youtube video");s.youTubeId=p[1]}return{type:"media",media:s,annotations:{pages:[]}}}function v(e,o){if(!e.duration)return n("No duration on canvas");if(o.items.length>1)return n("Only one audio source supported");let r=o.items[0]?.resource;return r?r.format?{type:"media",media:{annotationId:o.items[0].annotationId,duration:e.duration,url:r.id,type:"Sound",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:r.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:n("Audio does not have format"):n("Unknown audio")}function te({canvas:e,paintables:o,supports:r,loadImageService:i}){if(!e)return console.log("No canvas"),l;if(o.types.length===0)return r.indexOf("empty")!==-1?y(e.width,e.height):(console.log("No paintables"),l);if(o.types.length!==1)if(o.types.length===2&&o.types.indexOf("text")!==-1)o.types=o.types.filter(a=>a!=="text");else return r.indexOf("complex-timeline")===-1?n("Complex timeline not supported"):n("ComplexTimelineStrategy not yet supported");let t=o.types[0];return t==="image"?r.indexOf("images")===-1?n("Image not supported"):x(e,o,i):t==="Model"||t==="model"?r.indexOf("3d-model")===-1?n("3D not supported"):S(e,o):t==="textualbody"?r.indexOf("textual-content")===-1?n("Textual content not supported"):I(e,o):t==="sound"||t==="audio"?r.indexOf("media")===-1?n("Media not supported"):v(e,o):t==="video"?r.indexOf("media")===-1?n("Media not supported"):C(e,o):l}export{W as a,c as b,k as c,l as d,n as e,y as f,S as g,x as h,I as i,C as j,te as k};
|