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