react-iiif-vault 2.0.11 → 2.0.13
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 +7 -3
- package/dist/bundle.global.js +52 -46
- package/dist/canvas-panel.cjs +6 -6
- 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-WI6XIZ2T.js +49 -0
- package/dist/{index-BAwkF_tl.d.cts → index-DHghDluJ.d.cts} +5 -2
- package/dist/{index-C3XrwwYg.d.ts → index-DijgVxjb.d.ts} +5 -2
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +1 -1
- package/package.json +2 -1
- package/dist/chunk-MOYFNKQ7.js +0 -49
package/dist/canvas-panel.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{$b as a}from"./chunk-WI6XIZ2T.js";import"./chunk-P7XHGETS.js";export{a as CanvasPanel};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import{c as dn,l as mn}from"./chunk-P7XHGETS.js";import{forwardRef as qr,useImperativeHandle as Ql,useMemo as Xl}from"react";import Fr,{useContext as $r,useMemo as Wr}from"react";import{jsx as _r}from"react/jsx-runtime";var Ur={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0,annotationPage:void 0},Ue=Fr.createContext(Ur),_=()=>$r(Ue);function ie({value:e,children:t}){let n=_(),o=Wr(()=>({...n,...e}),[e,n]);return _r(Ue.Provider,{value:o,children:t})}import{jsx as jr}from"react/jsx-runtime";function te({canvas:e,children:t}){return jr(ie,{value:{canvas:e},children:t})}import Kr,{useState as Yr}from"react";import{Vault as pn,globalVault as Gr}from"@iiif/helpers/vault";import{jsx as fn}from"react/jsx-runtime";var le=Kr.createContext({vault:null,setVaultInstance:e=>{}});function ge({vault:e,vaultOptions:t,useGlobal:n,resources:o,children:s}){let[i,r]=Yr(()=>e||(n?Gr(t):t?new pn(t):new pn));return fn(le.Provider,{value:{vault:i,setVaultInstance:r},children:fn(ie,{value:o||{},children:s})})}import{useContext as Jr}from"react";import ei from"react";import{useContext as Qr}from"react";var M=()=>{let{vault:e}=Qr(le);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};import{useEffect as Xr,useState as Zr}from"react";function k(e,t=[]){let n=M(),[o,s]=Zr(()=>e(n.getState(),n));return Xr(()=>n.subscribe(i=>e(i,n),i=>{s(i)},!1),t),o}var he=ei.createContext([]);function _e(){let e=Jr(he);return k(t=>e.map(n=>t.iiif.entities.Canvas[n]).filter(Boolean),[e])}import{globalVault as ti}from"@iiif/helpers/vault";import{useContext as ni}from"react";function ye(e){let t=ni(le);return e||(t&&t.vault?t.vault:ti())}import{useMemo as oi}from"react";function B(e={},t=[]){let{id:n,selector:o}=e,s=_(),i=M(),r=n||s.manifest,a=k(l=>r?l.iiif.entities.Manifest[r]:void 0,[r]);return oi(()=>{if(a)return o?o(a):a},[a,o,...t])}import{useContext as Ti}from"react";import{createContext as Ii,useMemo as Mi}from"react";import{useEffect as ri,useMemo as ii,useState as xt}from"react";function gn(e,{noCache:t=!1}={}){let n=typeof e=="string"?e:e.id,o=ye(),[s,i]=xt(n),[r,a]=xt(void 0),l=ii(()=>o.get(n,{skipSelfReturn:!0})||void 0,[n,o]),[u,m]=xt(l);return ri(()=>{(async()=>{try{let c=l&&!t?l:await o.load(n),d=c?c.id||c["@id"]:null;c&&s!==d&&i(d),m(c)}catch(c){a(c)}})()},[n,t]),{isLoaded:!!u,id:s,requestId:n,error:r,resource:u,cached:!!(u&&u===l)}}function hn(e,t){let{id:n,isLoaded:o,error:s,resource:i,requestId:r,cached:a}=gn(e,t);return{id:n,isLoaded:o,error:s,manifest:i,requestId:r,cached:a}}import{jsx as ai}from"react/jsx-runtime";function yn({manifest:e,children:t}){return ai(ie,{value:{manifest:e},children:t})}import{jsx as si}from"react/jsx-runtime";function vn({range:e,children:t}){return si(ie,{value:{range:e},children:t})}function li(e,t){for(let n of t.items){if(n.type==="Canvas")return n;if(n.type==="SpecificResource")return n.source;if(n.type==="Range"){let o=li(e,e.get(n));if(o)return o}}return null}function bt(e,t){let n=[];for(let o of t.items)if(o.type==="SpecificResource"&&o.source?.type==="Canvas"&&(o.source.id.indexOf("#")!==-1?n.push({id:o.source.id.split("#")[0],type:"Canvas"}):n.push(o.source)),o.type==="Range"&&n.push(...bt(e,e.get(o))),o.type==="SpecificResource"){let s=typeof o.source=="string"?o.source:o.source.id;n.push({id:s,type:"Canvas"})}return n}function Qu(e,t,n){for(let o of t.structures){let s=Sn(e,e.get(o),n);if(s)return s}return null}function Sn(e,t,n){for(let o of t.items){let s=o?.source?.id?.split("#")[0];if(o.type==="SpecificResource"&&o.source===n||o.type==="SpecificResource"&&o.source?.type==="Canvas"&&n===s)return t;if(o.type==="Range"){let i=Sn(e,e.get(o),n);if(i)return i}}return null}function Ju(e,t,n,o=!1){let s=t.behavior,i=n?e.get(n):null;if(!i)return[];let r=i.behavior,a=o?!1:s.includes("paged"),l=a?!1:s.includes("continuous"),u=a||l?!1:s.includes("individuals"),m=r.includes("facing-pages"),c=r.includes("non-paged");if(m||c||u||o)return[{id:i.id,type:"Canvas"}];let[d,p]=Ct(e,t);if(l)return d;let g=d.findIndex(h=>h.id===n);if(g===-1)return[];for(let h of p)if(h.includes(g))return h.map(S=>d[S]);return[{id:i.id,type:"Canvas"}]}function Ct(e,t,{disablePaging:n,skipNonPaged:o}={}){let s=t.behavior,i=s.includes("paged"),r=i?!1:s.includes("continuous"),a=i||r?!1:s.includes("individuals"),l=t.type==="Manifest"?t.items:bt(e,t);if(r)return[l,[l.map((g,h)=>h)]];if(a||!i||n)return[l,l.map((g,h)=>[h])];let u=[],m=[],c=()=>{m.length&&(u.push([...m]),m=[])},d=0,p=!1;for(let g=0;g<l.length;g++){let h=e.get(l[g]);if(h.behavior.includes("non-paged")){g===d&&d++,o||(c(),u.push([g]),c());continue}if(g===d||h.behavior.includes("facing-pages")){m.length&&(p=!0),c(),u.push([g]),c();continue}if(m.push(g),p){c(),p=!1;continue}m.length>1&&c()}return m.length&&c(),[l,u]}import{useCallback as je,useMemo as ci,useRef as di,useState as mi}from"react";import{useMemo as ui}from"react";function xn(e={},t=[]){let{id:n,selector:o}=e,s=_(),i=n||s.range,r=k(a=>i?a.iiif.entities.Range[i]:void 0,[i]);return ui(()=>{if(r)return o?o(r):r},[r,o,...t])}function bn({startCanvas:e,disablePaging:t}){let n=M(),o=B(),s=xn(),[i,r]=mi(void 0),a=s||o;if(!a)throw new Error("Nothing selected");let[l,u]=ci(()=>Ct(n,a,{disablePaging:t}),[n,a,t]),m=di(u);if(m.current!==u){let S=m.current[i][0],v=u.findIndex(f=>f.includes(S));m.current=u,r(v)}let c=je(h=>{let S=u.findIndex(v=>v.includes(h));r(S===-1?0:S)},[l,u]),d=je(h=>{let S=l.findIndex(v=>v.id===h);S!==-1?c(S):r(0)},[l,u]),p=je(()=>{r(h=>h>=u.length-1?h:h+1)},[u]),g=je(()=>{r(h=>h<=0?0:h-1)},[u]);return typeof i>"u"&&(e?d(e):r(0)),{visibleItems:u[i]?.map(h=>l[h].id)||[],cursor:i,items:l,sequence:u,hasPrevious:i>0,hasNext:i<u.length-1,setSequenceIndex:r,setCanvasIndex:c,setCanvasId:d,next:p,previous:g}}import{createContext as Pt,useContext as Vn,useEffect as fi,useMemo as gi}from"react";import{useStore as Ve}from"zustand";import{createStore as Rn}from"zustand/vanilla";function mc(e){let t=e.service||e.services||[];for(let n of t)if(n.type==="AuthProbeService2")return!0;return!1}function j(e,t,n){let o=t.findIndex(r=>r.service.id===e);if(o===-1)return t;let s=[...t],i=n(s[o]);return i===s[o]?t:(s[o]=i,s)}var An=()=>Rn((e,t)=>({currentAuth:-1,authItems:[],login:()=>{let n=t().authItems[t().currentAuth];if(!n||n.isPending||n.isLoggedIn)return;if(n.type!=="active")throw new Error("Cannot login to non-active service");let o=n.service.service.find(s=>s.type==="AuthAccessTokenService2");if(!o)throw new Error("Token service not found");e(()=>({authItems:j(n.id,t().authItems,s=>({...s,isPending:!0}))})),Cn(n.service).then(()=>{Rt(o).then(s=>{let i=s.expiresIn,r=Date.now()+i*1e3;e(()=>({authItems:j(n.id,t().authItems,a=>({...a,isLoggedIn:!0,isPending:!1,session:{token:s.accessToken,expires:r}}))}))}).catch(s=>{e(()=>({authItems:j(n.id,t().authItems,i=>({...i,isLoggedIn:!1,isPending:!1,error:s.message}))}))})})},logout:()=>{let n=t().authItems[t().currentAuth];if(!n||n.isPending||!n.isLoggedIn)return;if(n.type!=="active")throw new Error("Cannot logout of non-active service");let o=n.service.service.find(r=>r.type==="AuthLogoutService2");if(!o)return;let s=`${o.id}?origin=${Tn()}`,i=window.open(s);e(()=>({authItems:j(n.id,t().authItems,r=>({...r,isLoggedIn:!1,session:null,isPending:!1}))}))},nextAuth:()=>{let n=t().authItems.length,o=t().currentAuth+1;o>=n||e(()=>({currentAuth:o}))},previousAuth:()=>{let n=t().currentAuth-1;n<0||e(()=>({currentAuth:n}))},setAuth:n=>{n!==-1&&(n<0||n>=t().authItems.length)||e(()=>({currentAuth:n}))},addService:(n,o)=>{if(!n.service)return;let s=n.service.find(a=>a.type==="AuthAccessTokenService2"),i=n;if(t().authItems.find(a=>a.service.id===n.id)){e(()=>({authItems:j(n.id,t().authItems,a=>({...a,instances:a.instances+1}))}));return}if(e(()=>({currentAuth:i.profile==="active"?0:t().currentAuth,authItems:[{id:n.id,type:n.profile,service:n,probeId:o,canAuthenticate:!0,instances:1,isPending:!1,isLoggedIn:!1,session:null},...t().authItems]})),n.profile==="external"){if(!s)throw new Error("Token service not found");Rt(s).then(a=>{e(()=>({authItems:j(n.id,t().authItems,l=>({...l,isLoggedIn:!0,isPending:!1,session:{token:a.accessToken,expires:a.expiresIn}}))}))}).catch(a=>{e(()=>({authItems:j(n.id,t().authItems,l=>({...l,isLoggedIn:!1,isPending:!1,canAuthenticate:!1,error:a.message}))}))})}if(n.profile==="kiosk"){if(!s)throw new Error("Token service not found");e(()=>({authItems:j(n.id,t().authItems,a=>({...a,isPending:!0}))})),Cn(i).then(()=>{Rt(s).then(a=>{e(()=>({authItems:j(n.id,t().authItems,l=>({...l,isLoggedIn:!0,isPending:!1,session:{token:a.accessToken,expires:a.expiresIn}}))}))}).catch(a=>{e(()=>({authItems:j(n.id,t().authItems,l=>({...l,isLoggedIn:!1,isPending:!1,error:a.message}))}))})})}n.profile},removeService:(n,o)=>{let s=t().currentAuth===t().authItems.findIndex(r=>r.service.id===n.id),i=t().currentAuth;if(s){let r=t().authItems.find(l=>l.service.id===n.id);r&&r.instances>1||(i=t().authItems.findIndex(u=>u.service.id!==n.id&&u.instances>0))}e(()=>({authItems:j(n.id,t().authItems,r=>({...r,instances:r.instances-1})),currentAuth:i}))}})),Pn=(e,t)=>Rn((n,o)=>({service:e,status:e?"unknown":"success",shouldRedirect:!1,redirectResource:null,shouldSubstitute:!1,substituteResource:null,error:null,errorHeading:null,errorNote:null,shouldDisplayResource:!1,token:t||null,async probe(){if(!o().service)return;let s=o().service?.id;if(!s){n({status:"error",error:"Service ID not found",errorHeading:{en:["Service ID not found"]}});return}n({status:"probing"});let i=o().token;try{let r=await fetch(s,{headers:i?{Authorization:`Bearer ${o().token}`,Accept:"application/json"}:{Accept:"application/json"}}).then(a=>a.json());if(r.status===200)n({status:"success",shouldDisplayResource:!0,error:null,errorHeading:null,errorNote:null,shouldSubstitute:!1,shouldRedirect:!1});else if(r.status<400&&r.status>=300){if(!r.location)throw new Error("Redirect location not found");n({status:"error",shouldDisplayResource:!1,shouldRedirect:!0,redirectResource:r.location||null})}else if(r.status===401)n({status:"error",shouldDisplayResource:!1,shouldRedirect:!1,shouldSubstitute:!!r.substitute,substituteResource:r.substitute||null,error:"Unauthorized",errorHeading:r.heading||{en:["Unauthorized"]},errorNote:r.note||null});else throw new Error("Unknown error")}catch(r){n({status:"error",error:r.message,errorHeading:{en:["Unknown error"]}})}},setToken(s){n({token:s})}}));function wn(e){let t=e.service||e.services||[],n={hasAuth:!1,services:{}};for(let o of t)if(o.type==="AuthProbeService2"){n.services.probe=o,n.hasAuth=!0;let s=o.service.filter(i=>i.type==="AuthAccessService2");s[0]&&(n.services.access=s[0])}return n}async function Rt(e,{strict:t=!0}={}){return new Promise((n,o)=>{let s=Math.random().toString(36).substring(7),i=`${e.id}?messageId=${s}&origin=${window.location.origin}`,r=u=>{let m=u.data;if(m.messageId===s){if(t&&m.type!=="AuthAccessToken2"){a(),o("Invalid response, expected type=AuthAccessToken2");return}if(!m.accessToken){a(),o("Invalid response, expected accessToken");return}a(),n(m)}},a=()=>window.removeEventListener("message",r),l=document.createElement("iframe");l.src=i,l.style.display="none",document.body.appendChild(l),window.addEventListener("message",r)})}function Tn(e){let t=window.location;if(e){let n=document.createElement("a");return n.href=e,n.protocol+"//"+n.hostname+(n.port?":"+n.port:"")}return t.protocol+"//"+t.hostname+(t.port?":"+t.port:"")}async function Cn(e){let t=`${e.id}?origin=${Tn()}`,n=window.open(t);if(!n)throw new Error("Failed to open window");return new Promise((o,s)=>{let i=setInterval(()=>{n.closed&&(clearInterval(i),o())},500)})}import{useEffect as In,useMemo as Mn}from"react";import{useStore as pi}from"zustand";function kn(e){let t=Mn(()=>wn(e),[e]),n=En(t.services.access?.id),o=Mn(()=>Pn(t.services.probe,n),[t.services.probe]),s=pi(o);return In(()=>{s.status==="unknown"&&!n&&s.probe()},[t.services.probe,s.status]),In(()=>{n&&(s.setToken(n),s.probe())},[n]),[e,s,t.hasAuth]}import{jsx as Ke}from"react/jsx-runtime";var ve=Pt(null),hi=Pt(null);hi.displayName="CurrentAuth";var yi=Pt(null);yi.displayName="AuthActions";function Nn({children:e}){let t=gi(()=>An(),[]);return Ke(ve.Provider,{value:t,children:e})}function Ln(){return!!Vn(ve)}function Ne(){let e=Vn(ve);if(!e)throw new Error("useAuthActions must be used within a AuthProvider");return e}function vi(){let e=Ne();return Ve(e,n=>({login:n.login,logout:n.logout,nextAuth:n.nextAuth,previousAuth:n.previousAuth,setAuth:n.setAuth,addService:n.addService,removeService:n.removeService}))}function kc(){let e=Ne();return Ve(e,t=>t)}function Si(e){let t=Ne();return Ve(t,o=>o.authItems.find(s=>s.service.id===e))}function En(e){let t=Ne();return Ve(t,o=>o.authItems.find(s=>s.id===e)?.session?.token)}function Ec(e){let t=Ne();return Ve(t,o=>{let s=o.authItems.find(i=>i.service.id===e);return!s||!s.isLoggedIn||!s.session?null:s.session?.token||null})}function xi(e){let t=vi(),n=Si(e.service.id);return fi(()=>(t?.addService(e.service,e.probeId),()=>{t?.removeService(e.service,e.probeId)}),[e.service]),n?(n.error||!n.isLoggedIn,e.children):null}function At(){return null}function zn(e){let[t,n,o]=kn(e.resource),s=e.fallbackComponent||At,i=e.loadingComponent||At,r=e.errorComponent||At,a=n.service,l=null;if(!o||!a)return e.children(t);let u=a.service.filter(m=>m.type==="AuthAccessService2");n.status==="error"&&(l=Ke(r,{resource:e.resource,error:n.error||"",heading:n.errorHeading,note:n.errorNote,extra:e.extra})),(n.status==="unknown"||n.status==="probing")&&(l=Ke(i,{})),n.status==="success"&&(l=e.children(t));for(let m of u)l=Ke(xi,{service:m,probeId:a.id,children:l},m.id);return l}import{createContext as Ai,useContext as qc,useMemo as Pi}from"react";import{createStore as bi}from"zustand/vanilla";var Ci=e=>e.id||e["@id"];function Ri(e){return(Array.isArray(e.service)?e.service:[e.service]).find(n=>n.profile==="http://iiif.io/api/search/0/autocomplete"||n.profile==="http://iiif.io/api/search/1/autocomplete"||n.profile==="AutoCompleteService1")}var On=e=>{let t;typeof e=="string"?t={"@context":"http://iiif.io/api/search/1/context.json",profile:"http://iiif.io/api/search/1/search","@id":e,id:e,service:[]}:t=e;let n=t?Ci(t):void 0,o=null;return bi((s,i)=>({service:t,resources:[],lastQuery:{},loading:!1,error:!1,highlight:null,hasSearch:!!t,hasAutocomplete:t?!!Ri(t):!1,errorMessage:"",search(r,a={}){if(!n)throw new Error("No search service found.");o&&!o.signal.aborted&&o.abort(),o=new AbortController;let l=new URLSearchParams;r.q&&l.set("q",r.q),r.motivation&&l.set("motivation",r.motivation),r.date&&l.set("date",r.date),r.user&&l.set("user",r.user),s({loading:!0}),fetch(`${n}?${l.toString()}`,{signal:o.signal,headers:{"Content-Type":"application/json",Accept:"application/json",...a.headers||{}}}).then(async u=>{if(!o?.signal.aborted)if(u.ok){let m=await u.json();s({resources:m.resources,error:!1,errorMessage:""})}else s({resources:[],error:!0,errorMessage:u.statusText})})},clearSearch(){s({resources:[],error:!1,errorMessage:""})},highlightResult(r){let a=i().resources.find(l=>l["@id"]===r);s({highlight:a})},nextResult(){let r=i().resources,a=i().highlight;if(!a){s({highlight:r[0]||null});return}let l=r.findIndex(u=>u["@id"]===a["@id"]);if(l===-1){s({highlight:r[0]||null});return}s({highlight:r[l+1]||r[0]||null})},previousResult(){let r=i().resources,a=i().highlight;if(!a){s({highlight:r[r.length-1]||null});return}let l=r.findIndex(u=>u["@id"]===a["@id"]);if(l===-1){s({highlight:r[r.length-1]||null});return}if(l===0){s({highlight:r[r.length-1]||null});return}s({highlight:r[l-1]||r[r.length-1]||null})}}))};import{useStore as _c}from"zustand";function Bn(){let e=B();return e?e.service.find(t=>t.profile==="SearchService1"||t.profile==="http://iiif.io/api/search/1/search"):void 0}import{jsx as wt}from"react/jsx-runtime";var Se=Ai(null);Se.displayName="Search";function Hn(e){let t=Bn();return e.store?wt(Se.Provider,{value:e.store,children:e.children}):wt(wi,{service:t,children:e.children})}function wi({service:e,children:t}){let n=Pi(()=>On(e),[e]);return wt(Se.Provider,{value:n,children:t})}import{jsx as $}from"react/jsx-runtime";var Le=()=>{},ze=Ii({setCurrentCanvasId:Le,setCurrentCanvasIndex:Le,nextCanvas:Le,previousCanvas:Le,items:[],sequence:[],setSequenceIndex:Le,currentSequenceIndex:0,hasNext:!1,hasPrevious:!1});function ki(e){let t=B(),{cursor:n,visibleItems:o,next:s,sequence:i,items:r,setCanvasIndex:a,setCanvasId:l,previous:u,setSequenceIndex:m,hasNext:c,hasPrevious:d}=bn({startCanvas:e.startCanvas,disablePaging:e.pagingEnabled===!1}),p=Mi(()=>({sequence:i,items:r,setCurrentCanvasId:l,nextCanvas:s,previousCanvas:u,totalCanvases:r.length,setCurrentCanvasIndex:a,setSequenceIndex:m,currentSequenceIndex:n,hasNext:c,hasPrevious:d}),[i,r,l,s,u,r,a,m,n]);return t?o.length===0?null:$(ze.Provider,{value:p,children:$(he.Provider,{value:o,children:$(te,{canvas:o[0],children:e.children})})}):(console.warn("The manifest passed to the provider is not a valid IIIF manifest."),$("div",{children:"Sorry, something went wrong."}))}function Dn(e){let t=ye(e.vault),n=hn(e.manifest);if(!n)return console.warn("The manifest passed to the provider is not a valid IIIF manifest."),$("div",{children:"Sorry, something went wrong."});if(n.error)return $("div",{children:n.error.toString()});if(!n.isLoaded)return $("div",{children:"Loading..."});let o=$(ki,{...e,children:e.children});return $(ge,{vault:t,children:$(yn,{manifest:n.id,children:$(Nn,{children:$(Hn,{children:e.rangeId?$(vn,{range:e.rangeId,children:o}):o})})})})}function Ye(){return Ti(ze)}import{ModeContext as qi}from"@atlas-viewer/atlas";import{createContext as Fi,useContext as jn,useEffect as $i,useMemo as Wi}from"react";import{useStore as Ui}from"zustand";import Ei from"mitt";import{createContext as Vi,useContext as qn,useEffect as Ni}from"react";import{jsx as zi}from"react/jsx-runtime";var Li=Ei(),Tt=Vi(Li);function Sd({children:e,emitter:t}){return zi(Tt.Provider,{value:t,children:e})}function Fn(){return qn(Tt)}function $n(e,t,n=[]){let o=qn(Tt);Ni(()=>{let s=i=>{t(i)};return o.on(e,s),()=>{o.off(e,s)}},[o,e,...n])}import{createHelper as Bi}from"polygon-editor";import{createStore as Hi}from"zustand/vanilla";function It(e){let t=Math.max(...e.map(i=>i[0])),n=Math.min(...e.map(i=>i[0])),o=Math.max(...e.map(i=>i[1])),s=Math.min(...e.map(i=>i[1]));for(let i of e)if(i[0]!==n&&i[0]!==t&&i[1]!==s&&i[1]!==o||i[0]<n||i[0]>t||i[1]<s||i[1]>o)return!1;return!0}function xe(e){if(!e)return null;if(e.points.length>2){let t=Math.min(...e.points.map(i=>i[0])),n=Math.min(...e.points.map(i=>i[1])),o=Math.max(0,...e.points.map(i=>i[0])),s=Math.max(0,...e.points.map(i=>i[1]));return{x:t,y:n,width:o-t,height:s-n}}return null}function Oi(e){return e.type==="SvgSelector"}function Ad(e){return e.type==="BoxSelector"}function Mt(e,t){if(Oi(e)){let r=e.svgShape==="polyline";if(!e.points||e.points.length===0)return null;if(t){let{width:a,height:l}=t;return{type:"SvgSelector",value:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${a} ${l}" width="${a}" height="${l}"><${r?"polygon":"polyline"} points="${e.points.map(m=>m.join(",")).join(" ")}" /></svg>`}}return{type:"SvgSelector",value:`<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'><g><path d='M${e.points.map(a=>a.join(",")).join(" ")}${r?" Z":""}' /></g></svg>`}}if(!e.spatial)return null;let{x:n,y:o,width:s,height:i}=e.spatial||{};return!s||!i?null:{type:"FragmentSelector",value:`xywh=${~~n},${~~o},${~~s},${~~i}`}}function kt(e,t){if(!e||!e.points.length)return null;if(It(e.points)){let n=e.points.map(l=>l[0]),o=e.points.map(l=>l[1]),s=Math.min(...n),i=Math.min(...o),r=Math.max(...n)-s,a=Math.max(...o)-i;return Mt({type:"BoxSelector",spatial:{x:s,y:i,width:r,height:a}},t)}return Mt({type:"SvgSelector",points:e.points,svgShape:e.open?"polygon":"polyline"},t)}function Wn(e){if(e.type==="polygon"&&!e.noBox&&e.points&&It(e.points)){let n=xe({open:!1,points:e.points||[]});return Wn({...e,type:"box",selector:n})}if(e.type==="polygon"||e.type==="draw")return{polygon:{points:e.points||[],open:e.open||!1},requestType:e.type,boundingBox:xe({points:e.points||[],open:!1}),metadata:{},arguments:e.arguments||{},target:kt({points:e.points||[],open:!1},e.bounds)};let t=e.selector;if(t){let n=[[t.x,t.y],[t.x+t.width,t.y],[t.x+t.width,t.y+t.height],[t.x,t.y+t.height]];return{polygon:{points:n,open:!1},requestType:e.type,boundingBox:t,metadata:{},target:kt({points:n,open:!1},e.bounds),arguments:e.arguments||{}}}return{polygon:{points:[],open:!1},requestType:e.type,boundingBox:null,target:null,metadata:{},arguments:e.arguments||{}}}var Di={shapeId:null,noShape:!0,transitioning:!1,actionIntentType:null,transitionIntentType:null,selectedPoints:[],hasClosestLine:!1,lastCreationTool:null,modifiers:{Alt:!1,Shift:!1,Meta:!1,proximity:0},bounds:null,showBoundingBox:!1,currentModifiers:{},validIntentKeys:{},pointerInsideShape:!1,closestPoint:null,transitionModifiers:null,selectedStamp:null,bezierLines:[],boxMode:!1,fixedAspectRatio:!1,cursor:"",enabledTools:["pointer","pen","box","lineBox","stamp","hand","line","pencil"],canDelete:!0,canDeselect:!0,isToolSwitchingLocked:!1,currentTool:"box",snapEnabled:!1,snapToPoints:!1,snapToLines:!1,snapToIntersections:!1,snapToGrid:!1,snapToParallel:!1};function Un({events:e,enabledTools:t,keyboardShortcutMapping:n,keyboardShortcutsEnabled:o=!1,debug:s}){let i=Hi((a,l)=>{let u=null,c=Bi({emitter:e,keyboardShortcutsEnabled:o,keyboardShortcutMapping:n,enabledTools:t,customSetState:d=>{s&&console.log("partial state",d),a(p=>({polygonState:{...p.polygonState,...d}}))}},d=>{a(p=>p.tool.requestId?{polygon:{...d,id:p.tool.requestId}}:{polygon:{id:void 0,points:[],open:!0}}),e.emit("atlas.polygon-update",d)});return{mode:"explore",tool:{enabled:!1,requestId:null,canvasId:null},runtime:null,requestType:null,requests:{},history:c.history,polygon:null,validRequestIds:[],metadata:{},stableViewport:null,canvasRelativePositions:{},canvasViewports:{},polygons:c,polygonState:Di,setMetadata:(d,p)=>{let g=p||l().tool.requestId;g&&a(h=>({metadata:{...h.metadata,[g]:{...h.metadata[g]||{},...d}}}))},setToolCanvasId:d=>{a(p=>({tool:{...p.tool,canvasId:d}}))},switchTool:{pointer(){a({mode:"sketch"}),r.tools.setTool("pointer")},hand(){a({mode:"explore"}),r.tools.setTool("hand")},draw(){a({mode:"sketch"}),r.tools.setTool("pencil")},pen(){a({mode:"sketch"}),r.tools.setTool("pen")},line(){a({mode:"sketch"}),r.tools.setTool("line")},lineBox(){a({mode:"sketch"}),r.tools.setTool("lineBox")},box(){a({mode:"sketch"}),r.tools.setTool("box")},triangle(){a({mode:"sketch"}),r.tools.setTool("stamp"),r.stamps.triangle()},hexagon(){a({mode:"sketch"}),r.tools.setTool("stamp"),r.stamps.hexagon()},circle(){a({mode:"sketch"}),r.tools.setTool("stamp"),r.stamps.circle()},remove(){let d=l();d.tool.requestId&&(c.setShape({points:[],open:!0}),d.cancelRequest(d.tool.requestId))}},reset:()=>{let d=l();d.tool.requestId&&d.cancelRequest(d.tool.requestId)},setPolygonState:d=>a({polygonState:typeof d=="function"?d(l().polygonState):d}),getRequestId:()=>{let d=Math.random().toString(36).slice(2);return a(p=>({validRequestIds:[...p.validRequestIds,d]})),{requestId:d,clear:()=>{l().tool.requestId,a(p=>({tool:p.tool.requestId===d?{enabled:!1,requestId:null,canvasId:null}:p.tool,validRequestIds:p.validRequestIds.filter(g=>g!==d)}))}}},cancelRequest:d=>{let p=d||l().tool.requestId;p&&(a(g=>({mode:"explore",tool:g.tool.requestId===p?{enabled:!1,requestId:null,canvasId:null}:g.tool,validRequestIds:g.validRequestIds.filter(h=>h!==p)})),e.emit("atlas.request-cancelled",{id:p}))},requestAnnotation:async(d,p)=>{let h={...l().requests,[p.requestId]:d},S=Wn(d);s&&console.log("requestAnnotation",{response:S,request:d});try{let{points:v=[],open:f=!0}=S.polygon||{},{requestId:y,canvasId:b=null,toolId:x}=p,C=x,R=l(),A=R.validRequestIds.includes(y),L=S.requestType;return s&&console.log("setting points",{requestType:L,points:v,open:f}),!A||R.tool.enabled?null:(c.setShape({id:y,points:v,open:f}),L==="polygon"&&(C=C||"pen",c.tools.setTool("pen")),L==="draw"&&(C=C||"draw",c.tools.setTool("pencil")),L==="box"&&(C=C||"box",c.tools.setTool("box")),L==="target"?(C=C||"box",c.tools.setTool("box"),c.lockAspectRatio(),c.tools.lockToolSwitching(),c.tools.setCanDeselect(!1),c.tools.setCanDelete(!1)):(c.tools.unlockToolSwitching(),c.tools.setCanDeselect(!0),c.tools.setCanDelete(!0)),d.bounds&&c.setBounds(d.bounds),e.emit("atlas.annotation-request",{id:y}),a({polygon:{id:y,points:v,open:f},mode:"sketch",requestType:L,tool:{enabled:!0,requestId:y,canvasId:b},requests:h}),C?R.switchTool[C]?.():v.length===0&&R.switchTool.box(),(typeof d.selectByDefault>"u"&&v.length&&L==="box"||d.selectByDefault)&&R.switchTool.pointer(),new Promise(Q=>{let T=w=>{w.id===y&&(a(I=>({mode:"explore",tool:{requestId:null,enabled:!1,canvasId:null},requests:Object.fromEntries(Object.entries(I.requests).filter(([E])=>E!==y))})),e.off("atlas.request-cancelled",T),e.off("atlas.annotation-completed",z),Q(null))},z=w=>{w.id===y&&(a(I=>({mode:"explore",tool:{requestId:null,enabled:!1,canvasId:null},requests:Object.fromEntries(Object.entries(I.requests).filter(([E])=>E!==y))})),e.off("atlas.annotation-completed",z),e.off("atlas.request-cancelled",T),Q(w))};e.on("atlas.request-cancelled",T),e.on("atlas.annotation-completed",z)}))}catch(v){return console.error(v),null}},completeRequest:d=>{let p=l().tool.requestId;if(typeof d=="string"&&d&&d!==p)return;let g=p?l().requests[p]?.arguments||{}:{},h=p?l().metadata[p]||{}:{},S=l().polygonState.bounds,v=l().polygon;v&&(e.emit("atlas.annotation-completed",{id:v.id,polygon:v,requestType:l().requestType,target:kt(v,S),canvasId:l().tool.canvasId,boundingBox:xe(v),metadata:h,arguments:{...g}}),c.setShape(null))},setAtlasRuntime:d=>{u=d,e.emit("atlas.ready",{runtime:d}),r.setScale(1/u._lastGoodScale),u.world.addLayoutSubscriber((p,g)=>{(p==="event-activation"||p==="zoom-to"||p==="go-home")&&u?._lastGoodScale&&!Number.isNaN(u._lastGoodScale)&&r.setScale(1/u._lastGoodScale)}),a({runtime:u})},clearAtlasRuntime:()=>{u=null,a({stableViewport:null,runtime:null})},setCanvasRelativePosition:(d,p)=>{a(g=>({canvasRelativePositions:{...g.canvasRelativePositions,[d]:p}}))},clearCanvasRelativePosition:d=>{a(p=>{let g={...p.canvasRelativePositions};return delete g[d],{canvasRelativePositions:g}})},changeMode:d=>{a({mode:d})},nudgeLeft:d=>{if(!u)return;let p=u.getViewport(),g=d??p.width*.1;u.world.gotoRegion({x:p.x-g,y:p.y,width:p.width,height:p.height,nudge:!0})},nudgeRight:d=>{if(!u)return;let p=u.getViewport(),g=d??p.width*.1;u.world.gotoRegion({x:p.x+g,y:p.y,width:p.width,height:p.height,nudge:!0})},nudgeUp:d=>{if(!u)return;let p=u.getViewport(),g=d??p.height*.1;u.world.gotoRegion({x:p.x,y:p.y-g,width:p.width,height:p.height,nudge:!0})},nudgeDown:d=>{if(!u)return;let p=u.getViewport(),g=d??p.height*.1;u.world.gotoRegion({x:p.x,y:p.y+g,width:p.width,height:p.height,nudge:!0})},zoomIn:()=>{u?.world?.zoomIn()},zoomOut:()=>{u?.world?.zoomOut()},goHome:()=>{u?.world?.goHome()},goToRegion:d=>{u?.world?.gotoRegion(d)},getRuntime:()=>u}}),r=i.getState().polygons;return e.on("atlas.annotation-request",()=>{r.clock.start((a,l,u)=>{e.emit("atlas.polygon-render",{state:a,slowState:l,dt:u})},a=>{typeof a=="object"?i.setState({polygonState:a}):i.setState(l=>({polygonState:a(l.polygonState)}))})}),e.on("atlas.annotation-completed",()=>{r.clock.stop()}),e.on("atlas.request-cancelled",()=>{r.clock.stop()}),i}import{jsx as _n}from"react/jsx-runtime";var be=Fi(null);function q(){return jn(be)}var Et={};function Kn(e="atlas"){return Et[e]?.getState()}function Oe({children:e,name:t="atlas",existing:n,atlasStoreConfig:o}){let s=Fn(),i=jn(be),r=Wi(()=>n||i||Un({events:s,...o||{}}),[s,n,i]),a=Ui(r,l=>l.mode);return $i(()=>{let l=t;return l&&(Et[l]=r),()=>{l&&delete Et[l]}},[r,t]),_n(be.Provider,{value:r,children:_n(qi.Provider,{value:a||"explore",children:e})})}import{mergeStyles as Xe}from"@atlas-viewer/atlas";import{useMemo as ua}from"react";import{createContext as _i,useContext as ji,useMemo as Ki}from"react";import{jsx as Yi}from"react/jsx-runtime";function Yn(){return{default:{backgroundColor:"rgba(0,0,0,0)",borderWidth:"2px",borderColor:"rgba(252,0,98, .5)"},highlighted:{backgroundColor:"rgba(75, 103, 225, 0.4)",borderWidth:"1px",borderColor:"rgba(75,103,225,0.99)"},hidden:{borderWidth:"0px",borderColor:"rgba(0,0,0,0)",backgroundColor:"rgba(0,0,0,0)",hidden:!0}}}var Vt=_i(Yn());Vt.displayName="AnnotationStyle";function Gn(){return ji(Vt)}function Fd({theme:e,children:t}){let n=Ki(()=>e||Yn(),[e]);return Yi(Vt.Provider,{value:n,children:t})}import{expandTarget as ea}from"@iiif/helpers/annotation-targets";import{useMemo as ta}from"react";import{useEffect as Gi,useMemo as Qi,useState as Xi}from"react";import{create as Zi}from"zustand";var Ji=Zi()((e,t)=>{let n=new Map,o=()=>Math.random().toString(36).substring(2,15),s=i=>{let r=n.get(i);if(r)return r;let a=o();return n.set(i,a),a};return{stylesheets:{},loading:[],errors:[],async parseStylesheet(i){let{loadStylesheet:r,setStylesheet:a}=t();if(!i)return null;if(typeof i=="string")return i.startsWith("http")?{id:i,type:"CssStylesheet",value:await r(i)}:{id:a(i),type:"CssStylesheet",value:i};if(i.type==="CssStylesheet"){let l=i.id;if("value"in i){let u=Array.isArray(i.value)?i.value.join(`
|
|
2
|
+
`):i.value;if(u)return{id:a(u,l),type:"CssStylesheet",value:u}}if("id"in i&&i.id){let u=await r(i.id);return{id:i.id,type:"CssStylesheet",value:u}}}return null},async loadStylesheet(i){if(t().loading.includes(i))return"";try{let a=await fetch(i);if(!a.ok)throw new Error(`Failed to load stylesheet from ${i}`);let l=await a.text();return e(u=>({stylesheets:{...u.stylesheets,[i]:l}})),l}catch(a){return e(l=>({errors:[...l.errors,{url:i,error:a}]})),""}},setStylesheet(i,r){let a=r||s(i);return e(l=>({stylesheets:{...l.stylesheets,[a]:i}})),a}}});function Qn(e){let[t,n]=Xi(""),{loading:o,errors:s,stylesheets:i,parseStylesheet:r}=Ji();return Gi(()=>{e&&r(e).then(l=>{l?.id&&n(l.id)})},[e,r]),[Qi(()=>{let l={};return t&&i[t]&&(l[t]=i[t]),l},[t,i]),{id:t,stylesheets:i,loading:o,errors:s}]}function Ge(e={},t=[]){let{id:n,selector:o}=e,s=_(),i=M(),r=n||s.annotation,a=k(m=>r?m.iiif.entities.Annotation[r]:void 0,[r]),[l]=Qn(a?.stylesheet),u=k(m=>a&&a.body?a.body.map(c=>c?c.type==="SpecificResource"?{...c,source:i.get(c)}:c?m.iiif.entities[c.type][c.id]:null:null).filter(Boolean):[],[a]);return ta(()=>{if(!a)return;let m={...a,body:u,target:ea(a.target,{typeMap:i.getState().iiif.mapping,loadedStylesheets:l})};return o?o(m):m},[a,o,u,l,...t])}import{useMemo as na}from"react";function P(e={},t=[]){let{id:n,selector:o}=e,s=_(),i=n||s.canvas,r=k(a=>i?a.iiif.entities.Canvas[i]:void 0,[i]);return na(()=>{if(r)return o?o(r):r},[r,o,...t])}import{useMemo as Xn}from"react";import{createEventsHelper as oa}from"@iiif/helpers/events";function Qe(e,t){let n=M(),o=Xn(()=>oa(n),[n]),s=k(()=>e&&e.id?n.getResourceMeta(e.id,"eventManager"):null,[e]);return Xn(()=>e?o.getListenersAsProps(e,t):{},[s,e,n,t])}import{useMemo as ra}from"react";import{createStylesHelper as ia}from"@iiif/helpers/styles";function Ce(e,t){let n=M(),o=ra(()=>ia(n),[n]);return k(()=>{if(!e)return null;let s=o.getAppliedStyles(e.id);return s?t?s[t]:s:void 0},[e,t])}import{useCallback as la}from"react";import{HTMLPortal as aa,useResizeWorldItem as sa}from"@atlas-viewer/atlas";import{useMemo as ne}from"react";import{Fragment as Nt,jsx as K,jsxs as Lt}from"react/jsx-runtime";function Zn({handleSize:e,resizable:t,onSave:n,children:o,maintainAspectRatio:s,disableCardinalControls:i,aspectRatio:r,...a}){let l=typeof e>"u"?s?12:8:e,{portalRef:u,mode:m,mouseEvent:c,isEditing:d}=sa({x:a.x||0,y:a.y||0,width:a.width,height:a.height,aspectRatio:r,maintainAspectRatio:s},n),p=ne(()=>c("translate"),[c]),g=ne(()=>c("east"),[c]),h=ne(()=>c("west"),[c]),S=ne(()=>c("south"),[c]),v=ne(()=>c("north"),[c]),f=ne(()=>c("south-east"),[c]),y=ne(()=>c("south-west"),[c]),b=ne(()=>c("north-east"),[c]),x=ne(()=>c("north-west"),[c]),C=m==="sketch",R={zIndex:999,boxShadow:"0px 2px 3px 0 rgba(0,0,0,0.2)",outline:"2px solid rgba(155,155,155,.7)",borderRadius:s||i?"50%":2,position:"absolute",background:"#fff",pointerEvents:d?"none":C?"initial":"none"};return K(Nt,{children:Lt("world-object",{...a,children:[o,C&&t?K(aa,{ref:u,target:{x:0,y:0,height:a.height,width:a.width},relative:!0,interactive:!1,children:C&&t?Lt(Nt,{children:[K("div",{onMouseDown:p,onTouchStart:p,style:{display:"block",width:"100%",height:"100%",cursor:"move",border:"1px solid rgba(255,255,255, .7)",outline:"2px solid rgba(155,155,155, .7)",boxSizing:"border-box",pointerEvents:d?"none":C?"initial":"none"}}),s?null:Lt(Nt,{children:[K("div",{title:"east",onTouchStart:g,onMouseDown:g,style:{...R,cursor:"e-resize",height:l*2,width:l,right:0,top:"50%",opacity:i?0:1,transform:`translate(${l/2}px, -${l}px)`}}),K("div",{title:"west",onMouseDown:h,style:{...R,cursor:"w-resize",position:"absolute",height:l*2,width:l,left:0,top:"50%",opacity:i?0:1,transform:`translate(-${l/2}px, -${l}px)`}}),K("div",{title:"north",onMouseDown:v,style:{...R,cursor:"n-resize",position:"absolute",height:l,width:l*2,left:"50%",top:0,opacity:i?0:1,transform:`translate(-${l}px, -${l/2}px)`}}),K("div",{title:"south",onMouseDown:S,style:{...R,cursor:"s-resize",position:"absolute",height:l,width:l*2,left:"50%",bottom:0,opacity:i?0:1,transform:`translate(-${l}px, ${l/2}px)`}})]}),K("div",{title:"north-east",onMouseDown:b,style:{...R,cursor:"ne-resize",position:"absolute",height:l,width:l,right:0,top:0,transform:`translate(${l/2}px, -${l/2}px)`}}),K("div",{title:"south-east",onMouseDown:f,style:{...R,cursor:"se-resize",position:"absolute",height:l,width:l,bottom:0,right:0,transform:`translate(${l/2}px, ${l/2}px)`}}),K("div",{title:"south-west",onMouseDown:y,style:{...R,cursor:"sw-resize",position:"absolute",height:l,width:l,bottom:0,left:0,transform:`translate(-${l/2}px, ${l/2}px)`}}),K("div",{title:"north-west",onMouseDown:x,style:{...R,cursor:"nw-resize",position:"absolute",height:l,width:l,top:0,left:0,transform:`translate(-${l/2}px, -${l/2}px)`}})]}):null}):null]})})}import{jsx as Jn}from"react/jsx-runtime";function eo({id:e,interactive:t,region:n,onClick:o,onHover:s,onSave:i,aspectRatio:r,maintainAspectRatio:a,disableCardinalControls:l,isEditing:u,style:m={backgroundColor:"rgba(0,0,0,.5)"}}){let c=la(d=>{u&&i?.({id:n.id,x:n.x,y:n.y,height:n.height,width:n.width,...d})},[i,u,n.id,n.x,n.y,n.height,n.width]);return Jn(Zn,{id:e,x:n.x,y:n.y,width:n.width,aspectRatio:r,height:n.height,resizable:u,onSave:c,maintainAspectRatio:a,disableCardinalControls:l,children:Jn("box",{interactive:t,onClick:d=>{d.preventDefault(),d.stopPropagation(),o?.(n)},relativeStyle:!0,onMouseEnter:()=>{s?.(n)},target:{x:0,y:0,width:n.width,height:n.height},style:m})})}import{jsx as ca}from"react/jsx-runtime";var Re=({id:e,style:t,className:n,interactive:o,targetId:s,ignoreTargetId:i})=>{let r=Ge({id:e}),a=Ce(r,"atlas"),l=Ce(r,"html"),u=Qe(r,["atlas"]),m=P(),c=Gn(),d=ua(()=>Xe(Xe(Xe(Xe(t,a),r?.motivation?.includes("highlighting")?c.highlighted:c.default),r?.target?.selector?.boxStyle||{})),[t,a,c,r?.motivation,r?.target]),p=s||m?.id;return m&&r&&r.target&&r.target.selector&&(r.target.selector.type==="BoxSelector"||r.target.selector.type==="SvgSelector")&&r.target.source&&(i?!0:r.target.source.id===p||r.target.source===p)?ca(eo,{id:r.id,isEditing:!0,region:r.target.selector.spatial,style:d,className:l?.className||n,interactive:!!(l?.href||o),href:l?.href||null,title:l?.title||null,hrefTarget:l?.target||null,onClick:()=>{},...u}):null};import{Fragment as ma}from"react";import{useMemo as da}from"react";function to(e={},t=[]){let{id:n,selector:o}=e,s=_(),i=n||s.annotationPage,r=k(a=>i?a.iiif.entities.AnnotationPage[i]:void 0,[i]);return da(()=>{if(r)return o?o(r):r},[r,...t])}import{jsx as no}from"react/jsx-runtime";var ue=({className:e,page:t,targetId:n,ignoreTargetId:o})=>{let s=to({id:t.id})||t,i=Ce(s,"atlas"),r=Ce(s,"html");return k(a=>s.id?a.iiif.entities.AnnotationPage[s.id]:null,[]),no(ma,{children:s.items?.map(a=>no(Re,{id:a.id,style:i,className:r?.className||e,targetId:n,ignoreTargetId:o},a.id))})};import{createContext as Ot,useContext as Bt}from"react";import{jsx as zt}from"react/jsx-runtime";var oo=Ot(null),ro=Ot(null),io=Ot(null);function _m(){let e=Bt(oo);if(!e)throw new Error("Ctx not found");return e}function jm(){let e=Bt(ro);if(!e)throw new Error("Ctx not found");return e}function Km(){let e=Bt(io);if(!e)throw new Error("Ctx not found");return e}function Ze({actions:e,state:t,children:n,currentTime:o,progress:s,element:i}){return zt(io.Provider,{value:{currentTime:o,progress:s,element:i},children:zt(ro.Provider,{value:e,children:zt(oo.Provider,{value:t,children:n})})})}import{useMemo as pa}from"react";import{expandTarget as fa}from"@iiif/helpers";function Je(){let e=B(),t=P();return pa(()=>{if(!e||!t||!e.start)return null;let n=fa(e.start);return!n||n.source.id!==t.id||!n||!n.selector||n.selector.type!=="TemporalSelector"?null:n.selector.temporal},[e,t])}import{useCallback as X,useEffect as Ht,useReducer as ga,useRef as et}from"react";function ao(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function ha(e,t){switch(t.type){case"RESET":return t.state;case"FINISHED":return{...e,isFinished:!0,isPlaying:!1,playRequested:!1};case"PLAY_PAUSE":return{...e,isFinished:!1,isPlaying:!e.isPlaying};case"PLAY_REQUESTED":return{...e,isFinished:!1,playRequested:!0};case"PAUSE":return{...e,isPlaying:!1};case"PLAY":return{...e,isFinished:!1,playRequested:!1,isPlaying:!0};case"MUTE":return{...e,isMuted:!0};case"SET_VOLUME":return{...e,volume:t.volume,isMuted:t.volume===0};case"TOGGLE_MUTE":return{...e,isMuted:!e.isMuted};case"UNMUTE":return{...e,isMuted:!1}}return e}function Dt(e){let t=Math.round(e);return`${Math.floor(t/60)}:${`${t%60}`.padStart(2,"0")}`}function Ae(e){let[t,n]=ga(ha,ao(e.duration));Ht(()=>{n({type:"RESET",state:ao(e.duration)})},[e.duration]);let o=et(null),s=et(null),i=et(null),r=et(!1),a=X(()=>{s.current&&o.current&&(s.current.innerHTML=Dt(o.current.currentTime),i.current&&(i.current.style.width=`${o.current.currentTime/e.duration*100}%`),r.current!==o.current.muted&&(r.current=o.current.muted,n(o.current.muted?{type:"MUTE"}:{type:"UNMUTE"})))},[e.duration]),l=X(()=>{o.current&&(n({type:"PLAY_REQUESTED"}),o.current.play().then(()=>{n({type:"PLAY"})}),a())},[a]),u=X(()=>{o.current&&(o.current.duration>0&&o.current.paused?l():m())},[a]),m=X(()=>{o.current&&(o.current.pause(),n({type:"PAUSE"}),a())},[a]),c=X(()=>{o.current&&(o.current.muted=!o.current.muted,n(o.current.muted?{type:"MUTE"}:{type:"UNMUTE"}))},[]),d=X(()=>{o.current&&(o.current.muted=!0,n({type:"MUTE"}))},[]),p=X(()=>{o.current&&(o.current.muted=!1,n({type:"UNMUTE"}))},[]),g=X(v=>{o.current&&(o.current.muted=!1,o.current.volume=v/100,n({type:"SET_VOLUME",volume:v}))},[]),h=X(v=>{o.current&&(o.current.currentTime=Math.max(0,Math.min(v*e.duration,e.duration)),a())},[]),S=X(v=>{if(o.current){let f=typeof v=="function"?v(o.current.currentTime):v;o.current.currentTime=Math.max(0,Math.min(f,e.duration)),a()}},[]);return Ht(()=>{let v=setInterval(()=>{a()},350);return()=>clearInterval(v)},[a,e.duration]),Ht(()=>{let v=()=>{n({type:"FINISHED"})},f=o.current;return f?.addEventListener("ended",v),()=>f?.removeEventListener("ended",v)},[]),[{element:o,currentTime:s,progress:i},t,{play:l,pause:m,playPause:u,mute:d,unmute:p,toggleMute:c,setVolume:g,setDurationPercent:h,setTime:S}]}import{createContext as so,useContext as ya,useEffect as va}from"react";var qt=so(()=>{}),Ft=so(()=>{});function D(e,t,n,o,s=[]){let i=ya(e==="portal"?Ft:qt);va(()=>(e!=="none"&&i(t,n,o),()=>{i(t,null)}),[t,e,i,...s])}import{jsx as Sa,jsxs as xa}from"react/jsx-runtime";function $t({media:e,startTime:t,children:n}){let[{element:o,currentTime:s,progress:i},r,a]=Ae({duration:e.duration}),l=t?`${e.url}#t=${t}`:e.url;return xa(Ze,{state:r,actions:a,currentTime:s,progress:i,element:o,children:[Sa("audio",{ref:o,src:l}),n]},e.url)}function tt({media:e,mediaControlsDeps:t,audioCopmonent:n=$t,children:o}){let s=Je();return D("portal","audio",n,{media:e,startTime:s?s.startTime:null,children:o},[e,s,...t||[]]),null}import{createContext as ba,useContext as Ca}from"react";var ce=ba(null);ce.displayName="Strategy";function V(){let e=Ca(ce);if(!e)throw new Error("useStrategy must be used within a StrategyProvider");return e}import{Fragment as Ra,jsx as Wt,jsxs as Aa}from"react/jsx-runtime";function Ut({model:e}){return Aa(Ra,{children:[Wt("style",{children:`
|
|
3
|
+
.model-container {
|
|
4
|
+
position: absolute;
|
|
5
|
+
top: 0;
|
|
6
|
+
bottom: 0;
|
|
7
|
+
left: 0;
|
|
8
|
+
right: 0;
|
|
9
|
+
background: #000;
|
|
10
|
+
z-index: 13;
|
|
11
|
+
display: flex;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
pointer-events: visible;
|
|
14
|
+
}
|
|
15
|
+
`}),Wt("div",{className:"model-container",children:Wt("model-viewer",{"interaction-prompt":"none",style:{width:"100%",height:"100%"},"camera-controls":"","ar-status":"not-presenting",src:e.id})})]})}function nt({model:e,name:t}){return D("overlay",`model-${t}`,Ut,{model:e},[e]),null}import{jsx as Pa}from"react/jsx-runtime";function lo(){let{strategy:e}=V();return e.type!=="3d-model"?null:Pa(nt,{model:e.model})}import{createContext as wa,useContext as Ta}from"react";var ot=wa(null);ot.displayName="Controls";function F(){let e=Ta(ot);if(!e)throw new Error("useStrategy must be used within a StrategyProvider");return e}import{Fragment as Ia,jsx as rt,jsxs as Ma}from"react/jsx-runtime";function uo(){let{strategy:e}=V(),{renderViewerControls:t,viewControlsDeps:n}=F(),o=P(),s=o?.accompanyingCanvas,i=o?.placeholderCanvas;return Ma(Ia,{children:[e.type==="media"&&e.media.type==="Sound"&&s?rt(te,{canvas:s.id,children:rt(de,{renderViewerControls:t,viewControlsDeps:n})}):null,e.type==="media"&&e.media.type==="Sound"&&i&&!s?rt(te,{canvas:i.id,children:rt(de,{renderViewerControls:t,viewControlsDeps:n})}):null]})}import{createContext as La,useContext as za,useMemo as Oa}from"react";import{useCallback as mo,useLayoutEffect as Ea,useMemo as Va,useRef as Na}from"react";import{entityActions as _t}from"@iiif/helpers/vault/actions";import{useMemo as ka}from"react";function co(){let t=M().getStore();return ka(()=>n=>t.dispatch(n),[t])}function po(e){return typeof e!="string"&&e&&e.bindToVault}function fo(){let e=M(),t=Na([]),n=co(),o=Va(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);Ea(()=>{let a={id:o,type:"AnnotationPage",behavior:[],label:null,thumbnail:[],summary:null,requiredStatement:null,metadata:[],rights:null,provider:[],items:[],seeAlso:[],homepage:[],rendering:[],service:[]};n(_t.importEntities({entities:{AnnotationPage:{[a.id]:a}}}))},[o]);let s=k(a=>o&&a.iiif.entities.AnnotationPage[o]||null,[o]),i=mo((a,l)=>{if(o){if(po(a)){let c=a;c.__vault||c.bindToVault(e),a=typeof c.source=="string"?c.source:c.source.id,t.current[a]=c}else typeof a!="string"&&(a=a.id);let u=e.get({id:o,type:"AnnotationPage"}),m=e.get({id:a,type:"Annotation"});u&&m&&(u.items.find(c=>c.id===m.id)||n(_t.addReference({id:o,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"},index:l})))}},[o]),r=mo(a=>{o&&(po(a)?a=typeof a.source=="string"?a.source:a.source.id:typeof a!="string"&&(a=a.id),t.current[a]&&t.current[a].beforeRemove(),e.get({id:o,type:"AnnotationPage"})&&n(_t.removeReference({id:o,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"}})))},[o]);return[s,{addAnnotation:i,removeAnnotation:r}]}import{jsx as Ba}from"react/jsx-runtime";var go=La(null);function ho(){let e=za(go);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function yo({children:e}){let[t,{addAnnotation:n,removeAnnotation:o}]=fo();return Ba(go.Provider,{value:Oa(()=>({fullPage:t,addAnnotation:n,removeAnnotation:o}),[t]),children:e})}import{Fragment as Ha,jsx as vo,jsxs as Da}from"react/jsx-runtime";function So({children:e}){let{strategy:t}=V(),[n]=ho();return t.type!=="images"?null:Da(Ha,{children:[n?vo(ue,{page:n}):null,t.annotations&&t.annotations.pages?t.annotations.pages.map(o=>vo(ue,{page:o},o.id)):null,e]})}import{useEffect as _a,useMemo as ja,useRef as Ka,useState as Ya}from"react";import{useEffect as qa}from"react";var xo=(e,t=[])=>{let n=M();qa(()=>{e(n)},[n,...t])};import Fa,{useContext as $a}from"react";import{ImageServiceLoader as Wa}from"@iiif/helpers/image-service";var Ua=Fa.createContext(new Wa);function bo(){return $a(Ua)}import{createThumbnailHelper as Ga}from"@iiif/helpers/thumbnail";function Pe(e,t,{canvasId:n,manifestId:o}={}){let s=M(),i=bo(),r=ja(()=>Ga(s,{imageServiceLoader:i}),[s,i]),[a,l]=Ya(),u=B(o?{id:o}:void 0),m=P(n?{id:n}:void 0),c=m||u,d=Ka(!1);if(_a(()=>(d.current=!1,()=>{d.current=!0}),[]),!c)throw new Error("Must be called under a manifest or canvas context.");return xo(p=>{r.getBestThumbnailAtSize(c,e,t).then(g=>{g.best&&!d.current&&l(g.best)})},[c]),a}import{jsx as Co}from"react/jsx-runtime";function we({x:e=0,y:t=0}){let n=P(),o=Pe({maxWidth:256,maxHeight:256});return!n||!o||o.type!=="fixed"?null:Co("world-object",{height:n.height,width:n.width,x:e,y:t,children:Co("world-image",{uri:o.id,target:{x:0,y:0,width:n.width,height:n.height},display:o.width&&o.height?{width:o.width,height:o.height}:void 0,crop:void 0})})}import{jsx as Qa,jsxs as Xa}from"react/jsx-runtime";function Ro({as:e}){let{strategy:t}=V(),{renderMediaControls:n,mediaControlsDeps:o}=F();return t.type!=="media"||t.media.type!=="Sound"?null:Xa(tt,{media:t.media,mediaControlsDeps:o,audioCopmonent:e,children:[Qa(we,{}),n?n(t):null]},t.media.url)}import{HTMLPortal as Uo}from"@atlas-viewer/atlas";import{useLayoutEffect as vs,useMemo as Ss}from"react";import{useStore as _o}from"zustand";import{createContext as Za,useContext as Ja}from"react";import{useStore as es}from"zustand";import{jsx as ts}from"react/jsx-runtime";var jt=Za(null);jt.displayName="ComplexTimeline";function Ao({children:e,store:t}){return ts(jt.Provider,{value:t,children:e})}function Af(e){let t=Ja(jt);if(!t)throw new Error("useComplexTimeline must be used within a ComplexTimelineProvider");return es(t,e)}import ns from"mitt";import{createStore as os}from"zustand/vanilla";function Po({currentKeyFrameIndex:e,keyframes:t,targetTime:n,currentTime:o}){if(o<=n){let s=t.findIndex(a=>a.time>n);if(s===-1)return[e,[]];let i={},r=t.slice(e,s);for(let a of r)a.type==="enter"&&(i[a.id]=a),a.type==="exit"&&(i[a.id]?delete i[a.id]:i[a.id]=a);return[s,Object.values(i)]}return[e,[]]}function wo({complexTimeline:e,startTime:t=0}){let n=ns(),o={},s={progress:null,currentTime:null},i=0,r=null,a=0,l=null;function u(){let f=S.getState().visibleElements,y=o,b=[],x=Object.keys(y);for(let C of x){let R=y[C],A=f[C];R&&A&&b.push(R)}return b}function m(){return Object.keys(o).map(f=>o[f])}function c(v){s.currentTime&&(s.currentTime.innerHTML=Dt(v),s.progress&&(s.progress.style.width=`${v/e.duration*100}%`))}let d=()=>{let v=S.getState(),f=v.currentPrime;if(!f)return;let y=o,b=v.visibleElements,x=Object.keys(y);for(let C of x){let R=y[C],A=b[C];if(R&&C!==f.id&&A){let L=a-A.time*1e3;Math.abs(a-A.time*1e3-R.currentTime*1e3)>300&&(R.currentTime=L/1e3)}}},p=(v=0)=>{let f=v-i,y=S.getState();if(y.isPlaying){let b=y.currentPrime;if(b){let A=o[b.id];A&&(A.paused?a+=f:a=(b.time+A.currentTime)*1e3)}else a+=f;let x=a/1e3;if(x>y.duration){S.getState().setTime(0),S.setState({isPlaying:!1}),g(),c(0);return}c(x);let[C,R]=Po({currentTime:x,currentKeyFrameIndex:y.nextKeyframeIndex,keyframes:y.complexTimeline.keyframes,targetTime:x});R.length&&y.applyKeyframes(C,R)}i=v,r=requestAnimationFrame(p)},g=()=>{r&&cancelAnimationFrame(r)},h=(v,f)=>{},S=os((v,f)=>({complexTimeline:e,elements:{},visibleElements:{},isBuffering:!1,bufferMap:{},isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,isReady:!1,volume:100,duration:e.duration,clockStartRequests:0,clockStartTime:0,primeTime:0,currentPrime:null,clockRunning:!1,nextKeyframeIndex:0,startClock:()=>{f().clockRunning||(p(),l=setInterval(d,500)),v({clockRunning:!0,clockStartRequests:f().clockStartRequests+1})},applyKeyframes(y,b){let x=f(),C={...x.visibleElements},R=x.currentPrime;for(let A of b)A.type==="enter"&&(C[A.id]=A,n.emit("complex-timeline.enter",{id:A.id})),A.type==="exit"&&(C[A.id]=null,n.emit("complex-timeline.exit",{id:A.id})),A.isPrime&&(R=A);v({nextKeyframeIndex:y,visibleElements:C,currentPrime:R})},stopClock:()=>{let y=f().clockStartRequests;if(y!==0){if(y===1){g(),l&&clearInterval(l),v({clockRunning:!1,clockStartRequests:0});return}v({clockStartRequests:y-1})}},setElement:(y,b)=>{o[y]=b;let x=Object.keys(o),C=f().complexTimeline;h(b,y),C.items.filter(A=>A.type!=="Image"&&A.type!=="Text").every(A=>x.includes(A.annotationId))&&!f().isReady&&(n.emit("complex-timeline.ready",{complexTimeline:C}),v({isReady:!0}))},removeElement:y=>{delete o[y]},mute(){for(let y of m())y.muted=!0;v({isMuted:!0})},unmute(){for(let y of m())y.muted=!1;v({isMuted:!1})},play(){if(!f().isPlaying){for(let b of u())b.play();v({isPlaying:!0})}},pause(){if(f().isPlaying){for(let b of u())b.pause();v({isPlaying:!1})}},playPause(){let y=f();y.isPlaying?y.pause():y.play()},setDurationPercent(y){let x=f().duration*y;f().setTime(x)},setTime(y){let b=f(),x=a/1e3,C=typeof y=="function"?y(x):y,R=b.nextKeyframeIndex;if(x>C){v({visibleElements:{},currentPrime:null});let I=Object.keys(b.visibleElements);for(let E of I)n.emit("complex-timeline.exit",{id:E});x=0,R=0}let[A,L]=Po({currentTime:x,currentKeyFrameIndex:R,keyframes:b.complexTimeline.keyframes,targetTime:C});b.applyKeyframes(A,L),a=C*1e3;let T=S.getState().visibleElements,z=o,w=Object.keys(T);for(let I of w){let E=T[I];if(E){let Ee=z[I];Ee&&(Ee.currentTime=(a-E.time*1e3)/1e3)}}c(C)},setVolume(y){for(let b of m())b.volume=Math.min(1,Math.max(0,y/100));v({volume:y})},toggleMute(){let y=f();y.isMuted?(y.unmute(),v({isMuted:!1})):(y.mute(),v({isMuted:!0}))},clearProgressElement(){s.progress=null},setProgressElement(y){s.progress=y},setCurrentTimeElement(y){s.currentTime=y},clearCurrentTimeElement(){s.currentTime=null}}));return n.on("complex-timeline.enter",v=>{let f=S.getState(),y=v.id,b=o[y];b&&f.isPlaying&&b.play()}),n.on("complex-timeline.exit",v=>{let f=S.getState(),y=v.id,b=o[y];b&&(b.currentTime=0,b.pause())}),S.getState().setTime(t),{store:S,emitter:n}}import{Fragment as Fo,useMemo as $o}from"react";import{useEffect as To,useRef as De,useState as is}from"react";var rs=[.6,.02,0,.75],Ef=16,Be={linear:[0,0,1,1],"ease-in":[.42,0,1,1],"ease-out":[0,0,.58,1],"ease-in-out":[.42,0,.58,1],"ease-in-cubic":rs,"ease-out-cubic":[.215,.61,.355,1]};function Vf(e,t,n){let o=Math.max(0,Math.min(1,n));return{x:e.x+(t.x-e.x)*o,y:e.y+(t.y-e.y)*o,width:e.width+(t.width-e.width)*o,height:e.height+(t.height-e.height)*o}}function Nf(e,t){let n=[],o=e;for(let s of t)n.push({from:o,to:s}),o=s;return n}function He([e,t,n,o]){let s=3*e,i=3*(n-e)-s,r=1-s-i,a=3*t,l=3*(o-t)-a,u=1-a-l;function m(g){return((r*g+i)*g+s)*g}function c(g){return((u*g+l)*g+a)*g}function d(g){return(3*r*g+2*i)*g+s}function p(g,h=1e-6){let S=g;for(let y=0;y<8;y++){let b=m(S)-g;if(Math.abs(b)<h)return S;let x=d(S);if(Math.abs(x)<1e-6)break;S=S-b/x}let v=0,f=1;for(S=g;v<f;){let y=m(S);if(Math.abs(y-g)<h)return S;g>y?v=S:f=S,S=(f-v)*.5+v}return S}return g=>{if(g<=0)return 0;if(g>=1)return 1;let h=p(g);return c(h)}}function Lf(e,t){if(!t||t.length===0)return{index:-1,t:0};if(Number.isNaN(e)||!isFinite(e))return{index:-1,t:0};if(e<0)return{index:-1,t:0};if(e>=t.length)return{index:t.length,t:0};let n=Math.floor(e),o=e-n;return{index:n,t:o}}function Io(e,{duration:t=300,easing:n}={}){let o=De(He(Be["ease-in-out"]));To(()=>{if(!n)o.current=He(Be["ease-in-out"]);else if(typeof n=="function")o.current=n;else if(Array.isArray(n))o.current=He(n);else{let m=Be[n];o.current=He(m??Be["ease-in-out"])}},[n]);let[s,i]=is(e),r=De(e??0),a=De(null),l=De(null),u=De(e);return To(()=>{if(e===void 0){i(void 0);return}let m=u.current;if(u.current=e,m===void 0){r.current=e,i(e);return}if(m===e&&s===e)return;l.current!==null&&(cancelAnimationFrame(l.current),l.current=null),a.current=null;let c=r.current,d=(((e||0)-c)%360+540)%360-180,p=c+d;function g(h){a.current===null&&(a.current=h);let S=h-a.current,v=Math.min(S/t,1),f=o.current(v),y=c+(p-c)*f;r.current=y,i(y),v<1?l.current=requestAnimationFrame(g):(r.current=((e||0)%360+360)%360,i(r.current),l.current=null)}return l.current=requestAnimationFrame(g),()=>{l.current!==null&&(cancelAnimationFrame(l.current),l.current=null)}},[e,t]),s}import{HTMLPortal as ps}from"@atlas-viewer/atlas";import{getId as fs}from"@iiif/parser/image-3";import as,{useContext as ss}from"react";import{imageServices as ls}from"@iiif/helpers/image-service";import{useStore as it}from"zustand";var Mo=as.createContext(ls.store);Mo.displayName="ImageServicesHelper";function at(){return ss(Mo)}function ko(e){let t=at();return it(t,({loaded:n})=>n[e])}function st(){let e=at();return it(e,({loadServiceSync:t})=>t)}function Eo(){let e=at();return it(e,({loaded:t})=>t)}function Wf(){let e=at();return it(e,({loadService:t})=>t)}import Te,{useMemo as Kt}from"react";import{jsx as Z}from"react/jsx-runtime";var No=Te.createContext("en"),Lo=Te.createContext({}),zo=Te.createContext(null);function Kf(e){return Z(Lo.Provider,{value:e.translations,children:e.children})}function Yf(e){return Z(No.Provider,{value:e.language,children:e.children})}function Gf(e){return Z(zo.Provider,{value:e.convert,children:e.children})}function Oo(){return Te.useContext(zo)}function Yt(){return Te.useContext(No)}function Bo(){return Te.useContext(Lo)}function Vo(e){return e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):e}function us({as:e,language:t,children:n,viewingDirection:o,...s}){let i=Yt();return Kt(()=>Vo(i)===Vo(t),[i,t])?e?Z(e,{...s,children:n}):Z("span",{...s,children:n}):e?Z(e,{...s,lang:t,dir:o,children:n}):Z("span",{...s,lang:t,dir:o,children:n})}function Ho(e,t,n){if(t.length===0)return;if(t.length===1)return t[0];if(t.indexOf(e)!==-1)return e;let o=e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):null;if(o&&t.indexOf(o)!==-1)return o;for(let s of n)if(t.indexOf(s)!==-1)return s;return t.indexOf("none")!==-1?"none":t.indexOf("@none")!==-1?"@none":t[0]}var cs=(e,t=[])=>{let n=Yt();return Kt(()=>{let o=e();return Ho(n,o,[])},[n,...t])};function me(e,t,n,o){return t?n?n(e[t]||t,o||"none"):e[t]||t:""}function ds(e,t,n=`
|
|
16
|
+
`,o={}){let s=Oo(),i=cs(()=>Object.keys(e||{}),[e]);return[Kt(()=>{if(!e)return me(o,t,s)||"";if(typeof e=="string")return me(o,e,s);let r=i?e[i]:void 0;return r?typeof r=="string"?r:r.map(a=>me(o,a,s,i)).join(n):""},[i,t,e]),i]}function Qf(){let e=Yt(),t=Bo(),n=Oo();return function(s,i="",r=`
|
|
17
|
+
`,a=t){let l=Object.keys(s||{}),u=Ho(e,l,[]);if(!s)return me(a,i,n)||"";if(typeof s=="string")return me(a,s,n);let m=u?s[u]:void 0;return m?typeof m=="string"?me(a,m,n,u):m.map(c=>me(a,c,n,u)).join(typeof r<"u"?r:`
|
|
18
|
+
`):""}}function qe({as:e,defaultText:t,enableDangerouslySetInnerHTML:n,children:o,separator:s,...i}){let r=Bo(),[a,l]=ds(o,t,s,r);return l?Z(us,{...i,as:e,language:l,title:n?void 0:a,dangerouslySetInnerHTML:n?{__html:a}:void 0,children:n?void 0:a}):e?Z(e,{...i,children:a}):Z("span",{...i,title:n?void 0:a,dangerouslySetInnerHTML:n?{__html:a}:void 0,children:n?void 0:a})}import{isImageServiceLevel as Do}from"@iiif/parser/image-3";import{useMemo as Gt}from"react";import{jsx as lt,jsxs as ms}from"react/jsx-runtime";var Qt=e=>{let t=e.format||"jpg",n=e.width/(e.crop?.width||e.tiles.width),o=e.tiles.imageService.sizes||[],s=e.enableThumbnail,i=e.enableSizes,r=Gt(()=>{let u=e.tiles.imageService.id||e.tiles.imageService["@id"];return u?.endsWith("/info.json")?u.slice(0,-1*10):u},[e.tiles.imageService.id,e.tiles.imageService["@id"]]),a=Gt(()=>{let u=e.tiles.imageService.tiles||[];if(!u.length){let m=e.width,c=[1],d=1;for(;2**d<m;)d=d*2,c.push(d);return(e.tiles.imageService.maxArea||e.tiles.imageService.maxWidth||e.tiles.imageService.maxHeight)&&Do(2,e.tiles.imageService)?[{width:256,height:256,scaleFactors:c}]:Do(2,e.tiles.imageService)?[{width:256,height:256,scaleFactors:c}]:[]}return u},[e.tiles.imageService,e.width]),l=Gt(()=>{let u=e.tiles.imageService;return(u?u["@context"]?Array.isArray(u["@context"])?u["@context"]:[u["@context"]]:[]:[]).indexOf("http://iiif.io/api/image/3/context.json")!==-1},[e.tiles.imageService.id,e.tiles.imageService]);return lt("world-object",{rotation:e.rotation,scale:n,height:e.crop?.height||e.tiles.height,width:e.crop?.width||e.tiles.width,x:e.x,y:e.y,onClick:e.onClick,children:ms("composite-image",{id:e.tiles.imageService.id,width:e.crop?.width||e.tiles.width,height:e.crop?.height||e.tiles.height,crop:e.crop,renderOptions:e.renderOptions,children:[s&&e.tiles.thumbnail?lt("world-image",{priority:!0,uri:e.tiles.thumbnail.id,target:{width:e.tiles.width,height:e.tiles.height},display:{width:e.tiles.thumbnail.width,height:e.tiles.thumbnail.height},crop:e.crop}):null,i&&o.map((u,m)=>lt("world-image",{uri:`${r}/full/${u.width},${l?u.height:""}/0/default.${t}`,target:{width:e.tiles.width,height:e.tiles.height},display:{width:u.width,height:u.height},crop:e.crop},m)),a.map(u=>(u.scaleFactors||[]).map(m=>lt("tiled-image",{uri:e.tiles.imageService.id,display:{width:e.tiles.width,height:e.tiles.height},format:t,tile:u,scaleFactor:m,crop:e.crop,version3:l},`${e.tiles.imageService.id}-tile-${m}`)))]},e.tiles.imageService.id)},e.tiles.imageService.id)};import{jsx as oe,jsxs as hs}from"react/jsx-runtime";function gs({resource:e,heading:t,note:n,extra:o}){return o?oe(ps,{target:{x:0,y:0,width:o.target?.spatial.width,height:o.target?.spatial.height},backgroundColor:"#333",relative:!0,children:oe("div",{style:{display:"flex",alignContent:"center",justifyContent:"center",alignItems:"center",height:"100%",width:"100%",background:"#444",color:"#BBB"},children:hs("div",{children:[oe(qe,{children:t||"Not authorised"}),n&&oe("p",{children:oe(qe,{children:n})}),oe("p",{children:e.id||e["@id"]||"unknown"})]})})}):null}function qo({image:e,thumbnail:t,crop:n,enableSizes:o,enableThumbnail:s,renderOptions:i,rotation:r,manualRotation:a}){let l=Ln(),u=fs(e.service),m=ko(u),c=st(),d=m?.service;c(e.service,e);let p=d&&m?.status==="done",g=(d?.preferredFormats||[])[0],h=t&&t.type==="fixed"&&t.id&&!t.id.includes("/full/full/")&&!t.id.includes("/max/")?t:void 0;if(p===!1)return null;if(!l){let S=e.service,v=S.width||e.width||0,f=S.height||e.height||0,y=0,b=0,x=e.target?.spatial.width||v,C=e.target?.spatial.height||f,R=x,A=C;return(r===90||r===270)&&!a&&([x,C]=[C,x],y=(R-x)/2,b=(A-C)/2),a&&([x,C]=[C,x]),oe(Qt,{enableThumbnail:s,renderOptions:i,rotation:r,tiles:{id:S.id||S["@id"]||"unknown",height:f,width:v,imageService:S,thumbnail:h},enableSizes:o,x:y,y:b,format:g,width:x,height:C,crop:n})}return oe(zn,{resource:e.service,errorComponent:gs,extra:e,children:S=>{let v=S.width||e.width||0,f=S.height||e.height||0,y=0,b=0,x=e.target?.spatial.width||v,C=e.target?.spatial.height||f,R=x,A=C;return(r===90||r===270)&&!a&&([x,C]=[C,x],y=(R-x)/2,b=(A-C)/2),oe(Qt,{enableThumbnail:s,renderOptions:i,tiles:{id:S.id||S["@id"]||"unknown",height:f,width:v,imageService:S,thumbnail:h},rotation:r,format:g,enableSizes:o,x:y,y:b,width:x,height:C,crop:n})}},e.id)}import{jsx as Xt,jsxs as Zt}from"react/jsx-runtime";function Ie({id:e,image:t,thumbnail:n,isStatic:o,x:s=0,y:i=0,children:r,selector:a,onClick:l,rotation:u,enableSizes:m,enableAnnotations:c}){let d=$o(()=>{if(!(!a||a.spatial.x===0&&a.spatial.y===0))return a.spatial},[a]),p=$o(()=>{if(typeof t.rotation<"u")return t.rotation;if(!t.annotation)return 0;let C=Array.isArray(t.annotation.body)?t.annotation.body?.[0]:t.annotation.body;if(C&&C.selector?.type==="ImageApiSelector")return Number(C.selector.rotation)},[t]),g=Io(u),h=!!t.service,S=s+t.target.spatial.x,v=i+t.target.spatial.y,f=t.target.spatial.width,y=t.target.spatial.height,b=t.target.spatial.width,x=t.target.spatial.height;return(p===90||p===270)&&([b,x]=[x,b],h||([f,y]=[y,f],S+=(t.target.spatial.width-f)/2,v+=(t.target.spatial.height-y)/2)),Zt("world-object",{x:S,y:v,width:f,height:y,onClick:l,rotation:t.service?void 0:typeof g<"u"?g:p,children:[t.service?Zt(Fo,{children:[Xt(qo,{image:t,thumbnail:n,crop:d,enableSizes:m,rotation:typeof g<"u"?g:p,manualRotation:typeof u<"u"}),r]},"service"):Zt(Fo,{children:[Xt("world-image",{onClick:l,uri:t.id,target:{x:0,y:0,width:b,height:x},display:b&&x?{width:b,height:x}:void 0,crop:d}),r]},"no-service"),c&&t.annotationPages?t.annotationPages.map(C=>Xt(ue,{page:C,className:"image-service-annotation",ignoreTargetId:!0},C.id)):null]},e+(h?"server":"no-service"))}import{HTMLPortal as ys}from"@atlas-viewer/atlas";import{Fragment as Wo,jsx as Fe}from"react/jsx-runtime";function ut({strategy:e,onClickPaintingAnnotation:t}){return Fe(Wo,{children:e.items.map((n,o)=>Fe(Wo,{children:Fe(ys,{onClick:t?s=>{s.stopPropagation(),t(n.annotationId,n,s)}:void 0,target:n.target?.spatial||void 0,children:Fe("div",{"data-textual-content":!0,children:Fe(qe,{enableDangerouslySetInnerHTML:!0,children:n.text})})},o)}))})}import{Fragment as xs,jsx as pe,jsxs as bs}from"react/jsx-runtime";function jo({strategy:e,children:t}){let{store:n}=Ss(()=>wo({complexTimeline:e}),[e]),o=_o(n,r=>r.isReady),s=_o(n,r=>r.visibleElements);function i(r){return a=>{a&&n.getState().setElement(r,a)}}return vs(()=>{if(o){let{startClock:r,stopClock:a}=n.getState();return r(),()=>{a()}}},[e,o]),D("portal","custom-controls",Ao,{store:n,children:t},[o]),bs(xs,{children:[e.items.map(r=>r.type!=="Image"||!s[r.annotationId]?null:pe(Ie,{image:r,id:r.annotationId},r.id)),e.items.map((r,a)=>r.type!=="Text"||!s[r.annotationId]?null:pe(ut,{strategy:{type:"textual-content",items:[r]}},a)),e.items.map((r,a)=>r.type!=="Video"||!r.target.spatial?null:pe(Uo,{target:r.target.spatial,children:pe("video",{ref:i(r.annotationId),src:r.url,style:{height:"100%",width:"100%",opacity:s[r.annotationId]?1:0}})},a)),e.items.map((r,a)=>r.type!=="Sound"?null:pe(Uo,{children:pe("audio",{ref:i(r.annotationId),src:r.url})},a)),e.highlights.map(({annotation:r})=>s[r.id]?pe(Re,{id:r.id,ignoreTargetId:!0,style:{outline:"3px solid red"},className:"image-service-annotation"},r.id):null)]})}import{jsx as Cs}from"react/jsx-runtime";function Ko(){let{strategy:e}=V(),{renderComplexTimelineControls:t}=F();return e.type!=="complex-timeline"?null:Cs(jo,{strategy:e,children:t?t(e):null})}import{jsx as Rs}from"react/jsx-runtime";function ct({style:e}){let t=P();return!t||!t.height||!t.width?null:Rs("box",{interactive:!1,target:{x:0,y:0,width:Number(t.width),height:Number(t.height)},style:e})}import{jsx as As}from"react/jsx-runtime";function Yo({backgroundStyle:e,alwaysShowBackground:t}){let{strategy:n}=V();return n.type!=="empty"&&!t?null:As(ct,{style:e})}import{createContext as Ps,useContext as ws}from"react";var fe=Ps(null);function dt(){return ws(fe)}import{Fragment as Is,jsx as Ts,jsxs as Ms}from"react/jsx-runtime";function Go({isStatic:e=!1,enableSizes:t=!1,enableAnnotations:n=!0,onClickPaintingAnnotation:o,rotation:s,children:i}){let{strategy:r}=V(),{renderViewerControls:a,viewControlsDeps:l}=F(),u=P(),m=dt(),c=Pe({maxWidth:256,maxHeight:256});if(D(m&&r.type==="images"&&a?"overlay":"none",`canvas-portal-controls-${u?.id}`,fe.Provider,a?{value:m||null,children:a(r)}:{},[u,m,r,...l||[]]),r.type!=="images")return null;let d=r.images.length===1?s:0;return Ms(Is,{children:[r.images.map((p,g)=>Ts(Ie,{isStatic:e,image:p,id:p.id,thumbnail:g===0?c:void 0,selector:p.selector,enableSizes:t,enableAnnotations:n,rotation:d,onClick:o?h=>{o(p.annotationId,p,h)}:void 0},p.id+g)),i]})}import{Fragment as Es,jsx as ks,jsxs as Vs}from"react/jsx-runtime";function Qo({onClickPaintingAnnotation:e,children:t}){let{strategy:n}=V(),{renderViewerControls:o,viewControlsDeps:s}=F(),i=dt(),r=P();return D(i&&n.type==="textual-content"&&o?"overlay":"none",`canvas-portal-controls-${r?.id}`,fe.Provider,o?{value:i||null,children:o(n)}:{},[r,i,n,...s||[]]),n.type!=="textual-content"?null:Vs(Es,{children:[ks(ut,{strategy:n,onClickPaintingAnnotation:e}),t]})}import{jsx as Xo,jsxs as Ns}from"react/jsx-runtime";function Jt({element:e,media:t,startTime:n,playPause:o,poster:s}){let i="div",r=n?`${t.url}#t=${n}`:t.url;return Ns(i,{className:"video-container",part:"video-container",onClick:o,children:[Xo("style",{children:`
|
|
19
|
+
.video-container {
|
|
20
|
+
position: absolute;
|
|
21
|
+
top: 0;
|
|
22
|
+
bottom: 0;
|
|
23
|
+
left: 0;
|
|
24
|
+
right: 0;
|
|
25
|
+
background: #000;
|
|
26
|
+
z-index: 13;
|
|
27
|
+
display: flex;
|
|
28
|
+
justify-content: center;
|
|
29
|
+
pointer-events: visible;
|
|
30
|
+
}
|
|
31
|
+
`}),Xo("video",{poster:s,ref:e,src:r,style:{width:"100%",objectFit:"contain"}})]})}function mt({media:e,mediaControlsDeps:t,children:n,videoComponent:o=Jt,captions:s}){let i=P(),r=Je(),a=i&&i.placeholderCanvas&&i.placeholderCanvas.id||void 0,l=Pe({},!1,{canvasId:a}),[{element:u,currentTime:m,progress:c},d,p]=Ae({duration:e.duration});return D("overlay","video-element",o,{element:u,media:e,playPause:p.playPause,poster:l?.id,canvas:i,startTime:r?r.startTime:null,captions:s},[l]),D("portal","custom-controls",Ze,{state:d,actions:p,currentTime:m,progress:c,element:u,children:n},[m,d,e,...t||[]]),null}import{jsx as Ls,jsxs as zs}from"react/jsx-runtime";function Zo({as:e}){let{strategy:t}=V(),{renderMediaControls:n,mediaControlsDeps:o}=F();return t.type!=="media"||t.media.type!=="Video"?null:zs(mt,{captions:t.captions,media:t.media,mediaControlsDeps:o,videoComponent:e,children:[Ls(we,{}),n?n(t):null]},t.media.url)}import{useRef as Os}from"react";import{jsx as Jo,jsxs as Hs}from"react/jsx-runtime";function Bs({element:e,media:t,playPause:n}){let o=Os(null);return t.youTubeId?Hs("div",{className:"video-container",part:"video-container",onClick:n,children:[Jo("style",{children:`
|
|
32
|
+
.video-container {
|
|
33
|
+
position: absolute;
|
|
34
|
+
top: 0;
|
|
35
|
+
bottom: 0;
|
|
36
|
+
left: 0;
|
|
37
|
+
right: 0;
|
|
38
|
+
background: #000;
|
|
39
|
+
z-index: 13;
|
|
40
|
+
display: flex;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
pointer-events: visible;
|
|
43
|
+
}
|
|
44
|
+
.video-yt {
|
|
45
|
+
border: none;
|
|
46
|
+
width: 100%;
|
|
47
|
+
object-fit: contain;
|
|
48
|
+
}
|
|
49
|
+
`}),Jo("iframe",{className:"video-yt",ref:o,src:`https://www.youtube.com/embed/${t.youTubeId}?enablejsapi=1&origin=${window.location.host}`,referrerPolicy:"no-referrer",sandbox:"allow-scripts allow-same-origin allow-presentation"})]}):null}function er({media:e,mediaControlsDeps:t,children:n}){let[{element:o,currentTime:s,progress:i},r,a]=Ae({duration:e.duration});return D("overlay","video-element",Bs,{element:o,media:e,playPause:a.playPause}),null}import{jsx as Ds,jsxs as qs}from"react/jsx-runtime";function tr(){let{strategy:e}=V(),{renderMediaControls:t,mediaControlsDeps:n}=F();return e.type!=="media"||e.media.type!=="VideoYouTube"?null:qs(er,{media:e.media,mediaControlsDeps:n,children:[Ds(we,{}),t?t(e):null]})}import{startTransition as bl,useMemo as Cl}from"react";import{useStore as ee}from"zustand";import{HTMLPortal as Us,useAtlas as _s}from"@atlas-viewer/atlas";import{useCallback as nn,useEffect as on}from"react";import{createSvgHelpers as Fs}from"polygon-editor";import{useEffect as $s,useRef as J,useState as or}from"react";import{useStore as en}from"zustand";function nr(e){let t=q(),n=en(t,i=>i.polygons),o=en(t,i=>i.polygonState),s=en(t,i=>i.polygon);return $n("atlas.polygon-render",({state:i,slowState:r,dt:a})=>{e(i,r,a)}),{currentShape:s,state:o,helper:n}}import{Fragment as tn,jsx as N,jsxs as Me}from"react/jsx-runtime";var re=Fs(),Ws={shapeFill:"#ffffff33",shapeStroke:"#000",lineStroke:"#000",ghostLineStroke:"#0F0",activeLineStroke:"#4D7EEA",boundingBoxDottedStroke:"#0007",boundingBoxStroke:"#fffA",controlFill:"#fff"};function rr(e){let{image:t}=e,n={...Ws,...e.theme||{}},o=J(),s=J(),i=J(),r=J(),a=J(),l=J(),u=J(),m=J(),c=J(),d=J(),[p,g]=or(null),[h,S]=or(!1),{helper:v,state:f,currentShape:y}=nr((T,z)=>{if(T.closestLineIndex,re.updateTransitionBoundingBox(i.current,T,z),re.updateBoundingBoxPolygon(o.current,T,z),re.updateBoundingBoxPolygon(s.current,T,z),re.updateTransitionShape(u.current,T,z),re.updateClosestLinePointTransform(a.current,T,z),re.updateSelectBox(r.current,T,z),re.updatePointLine(m.current,T,z),re.updateDrawPreview(l.current,T,z,3),re.updateLineBox(c.current,T),g(T.transitionDirection),S(T.transitionRotate),T.closestLineIndex!==-1&&d.current){let w=T.polygon,I=w.points[T.closestLineIndex],E=w.points[(T.closestLineIndex+1)%w.points.length];I&&E&&d.current.setAttribute("points",`${I[0]},${I[1]} ${E[0]},${E[1]}`)}});$s(()=>{let T=()=>{v.modifiers.reset()};return document.addEventListener("mouseleave",T),()=>{document.removeEventListener("mouseleave",T)}},[]);let b=Me(tn,{children:[Me("marker",{id:"dot",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:[N("circle",{cx:"5",cy:"5",r:"5",fill:n.lineStroke,className:"marker"}),N("circle",{cx:"5",cy:"5",r:"3",fill:n.controlFill})]}),N("marker",{id:"newdot",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:N("circle",{cx:"5",cy:"5",r:"5",fill:n.activeLineStroke,className:"marker"})}),Me("marker",{id:"selected",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:[N("circle",{cx:"5",cy:"5",r:"5",fill:n.lineStroke}),N("circle",{cx:"5",cy:"5",r:"3",fill:n.activeLineStroke})]}),Me("marker",{id:"resizer",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"6",markerHeight:"6",children:[N("rect",{width:"10",height:"10",fill:n.lineStroke}),N("rect",{x:"1",y:"1",width:"8",height:"8",fill:n.controlFill})]})]}),x=y?y.open?"polyline":"polygon":null,C=!f.showBoundingBox&&f.closestPoint!==null&&f.actionIntentType==="select-point",R=f.actionIntentType==="add-open-point",A=f.transitionIntentType==="split-line",L=f.transitioning&&f.selectedStamp&&f.transitionIntentType==="stamp-shape",Q=y&&x?Me(tn,{children:[N(x,{fill:(!f.transitioning||f.transitionIntentType==="select-multiple-points")&&!y.open?n.shapeFill:"none",strokeWidth:L||f.showBoundingBox&&f.boxMode||f.transitioning&&f.transitionIntentType==="split-line"||f.transitioning&&f.transitionIntentType==="move-point"?0:2,stroke:n.shapeStroke,points:y.points.map(T=>T.join(",")).join(" "),vectorEffect:"non-scaling-stroke",markerStart:f.showBoundingBox?void 0:f.boxMode?"url(#resizer)":"url(#dot)",markerMid:f.showBoundingBox?void 0:f.boxMode?"url(#resizer)":"url(#dot)",markerEnd:f.showBoundingBox?void 0:f.boxMode?"url(#resizer)":"url(#dot)",style:{pointerEvents:"none"},opacity:f.transitioning&&f.transitionIntentType==="move-shape"?0:1}),f.currentTool==="lineBox"&&f.actionIntentType==="close-line-box"?N("polygon",{fill:n.shapeFill,ref:c,stroke:n.lineStroke,strokeWidth:2,vectorEffect:"non-scaling-stroke"}):null,f.transitionIntentType==="draw-shape"&&f.transitioning?N("polyline",{ref:l,fill:"none",stroke:n.activeLineStroke,strokeWidth:2,vectorEffect:"non-scaling-stroke"}):null,!(f.transitioning&&f.transitionIntentType==="move-point")&&!(f.transitioning&&f.transitionIntentType==="stamp-shape")&&!f.showBoundingBox&&f.selectedPoints&&f.selectedPoints.length?N("polyline",{strokeWidth:2,vectorEffect:"non-scaling-stroke",stroke:"transparent",markerStart:"url(#selected)",markerMid:"url(#selected)",markerEnd:"url(#selected)",fill:"transparent",points:y.points.filter((T,z)=>f.selectedPoints?.includes(z)).map(T=>T.join(",")).join(" "),opacity:f.transitioning&&f.transitionIntentType==="move-shape"?0:1}):null,C&&!f.transitioning&&f.closestPoint!==null&&y.points[f.closestPoint]?N("polyline",{strokeWidth:2,vectorEffect:"non-scaling-stroke",stroke:"transparent",markerStart:"url(#selected)",markerMid:"url(#selected)",markerEnd:"url(#selected)",fill:n.activeLineStroke,points:`${y.points[f.closestPoint][0]},${y.points[f.closestPoint][1]}`,opacity:f.transitioning&&f.transitionIntentType==="move-shape"?0:1}):null,!f.transitioning&&(f.actionIntentType==="add-open-point"||f.actionIntentType==="close-shape"||f.actionIntentType==="close-shape-line")?N("polyline",{stroke:n.activeLineStroke,ref:m,strokeWidth:f.actionIntentType==="add-open-point"?1:2,vectorEffect:"non-scaling-stroke"}):null,f.hasClosestLine&&!f.showBoundingBox&&!f.transitioning&&f.currentTool!=="box"&&f.transitionIntentType==="split-line"?N("g",{children:N("polyline",{ref:d,vectorEffect:"non-scaling-stroke",fill:"transparent",stroke:n.activeLineStroke,strokeWidth:3})}):null,f.hasClosestLine&&!f.showBoundingBox&&!f.transitioning&&f.currentTool!=="box"&&f.transitionIntentType==="split-line"?N("g",{ref:a,children:N("polyline",{markerStart:"url(#newdot)",points:"0,0 1,1",vectorEffect:"non-scaling-stroke",stroke:"transparent",fill:"transparent",strokeWidth:2})}):null,f.transitioning?N(x,{ref:u,fill:y.open?"none":n.shapeFill,stroke:f.transitionIntentType==="stamp-shape"?n.activeLineStroke:n.shapeStroke,vectorEffect:"non-scaling-stroke",strokeWidth:(y.open,2)}):null,f.transitioning&&f.transitionIntentType==="select-multiple-points"?N("rect",{ref:r,fill:"rgba(255, 255, 255, .3)",strokeWidth:1,stroke:"rgba(0,0,0,.2)",vectorEffect:"non-scaling-stroke"}):null,f.showBoundingBox&&!L?Me(tn,{children:[N("polygon",{ref:o,strokeWidth:2,stroke:n.boundingBoxStroke,fill:"none",markerStart:"url(#resizer)",markerMid:"url(#resizer)",markerEnd:"url(#resizer)",vectorEffect:"non-scaling-stroke"}),N("polygon",{ref:s,strokeWidth:2,stroke:n.boundingBoxDottedStroke,fill:"none",strokeDasharray:"4 4",markerStart:"url(#resizer)",markerMid:"url(#resizer)",markerEnd:"url(#resizer)",vectorEffect:"non-scaling-stroke"})]}):null]}):null;return{currentTool:v.state.slowState.currentTool,setCurrentTool:v.tools.setTool,helper:v,currentShape:y,state:f,isAddingPoint:R,isSplitting:A,isStamping:L,isHoveringPoint:C,transitionDirection:p,transitionRotate:h,defs:b,editor:Q}}import{jsx as $e,jsxs as js}from"react/jsx-runtime";function ir(e){let t=_s(),{image:n}=e,{helper:o,defs:s,editor:i,state:r,transitionDirection:a,isSplitting:l,transitionRotate:u,isHoveringPoint:m,isAddingPoint:c}=rr({image:e.image,theme:e.theme}),d=nn(h=>{h.button!==2&&o.pointer([[~~h.atlas.x,~~h.atlas.y]])},[o]),p=nn(h=>{h.button!==2&&o.pointerDown()},[o]),g=nn(h=>{h.button!==2&&o.pointerUp()},[o]);return on(()=>{let h=S=>{o.key.up(S.key)};return document.addEventListener("keyup",h),()=>{document.removeEventListener("keyup",h)}},[o]),on(()=>{let h=S=>{S.target&&["INPUT","TEXTAREA"].includes(S.target.tagName)||S.target?.isContentEditable||document.activeElement&&(document.activeElement instanceof HTMLInputElement||document.activeElement instanceof HTMLTextAreaElement||document.activeElement.isContentEditable)||o.key.down(S.key)};return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h)}},[o]),on(()=>{let h=[];return a&&h.push(`atlas-cursor-${a}`),r.actionIntentType==="cut-line"&&r.modifiers?.Shift&&h.push("atlas-cursor-cut"),(m||r.transitionIntentType==="move-shape"||r.transitionIntentType==="move-point")&&h.push("atlas-cursor-move"),c&&h.push("atlas-cursor-crosshair"),l&&h.push("atlas-cursor-copy"),u&&h.push("atlas-cursor-rotate"),r.transitionIntentType==="draw-shape"&&h.push("atlas-cursor-draw"),t?.canvas&&t.canvas.classList.add(...h),()=>{t?.canvas&&t.canvas.classList.remove(...h)}},[t?.canvas,c,m,l,r.modifiers?.Shift,r.actionIntentType,r.transitionIntentType,a,u]),$e("world-object",{height:n.height,width:n.width,onMouseMove:d,onMouseDown:p,onMouseUp:g,onMouseLeave:o.blur,children:$e(Us,{relative:!0,interactive:!1,children:$e("div",{className:"absolute top-0 right-0 left-0 bottom-0",children:js("svg",{width:"100%",height:"100%",viewBox:`0 0 ${n.width} ${n.height}`,tabIndex:-1,children:[$e("title",{children:"Annotation Editor"}),$e("defs",{children:s}),i]})})})})}import{useCallback as hl}from"react";import{create as yl}from"zustand";import{HTMLPortal as nl}from"@atlas-viewer/atlas";import{autoUpdate as ol,detectOverflow as rl,flip as il,offset as al,shift as sl,useDismiss as ll,useFloating as ul,useInteractions as cl}from"@floating-ui/react";import{createPortal as dl}from"react-dom";import Js,{useContext as W,useMemo as el}from"react";import Ks from"react";import{createContext as Ys,useMemo as Gs}from"react";import Qs from"mitt";import{jsx as Zs}from"react/jsx-runtime";var Xs=Qs(),ke=Ys({emitter:Xs});ke.displayName="Events";function ar(){return Ks.useContext(ke).emitter}function oy({emitter:e,children:t}){return Zs(ke.Provider,{value:Gs(()=>({emitter:e}),[e]),children:t})}import{jsx as U}from"react/jsx-runtime";var We=Js.createContext({});function pt(){let e=W(We),t=Object.keys(e),n={};for(let o of t)e[o].Provider&&(n[o]={value:W(e[o]),Provider:e[o].Provider});return n}function tl(e){let t=Object.keys(e),n=e.children;for(let o of t){if(o==="children")continue;let{value:s,Provider:i}=e[o];n=U(i,{value:s,children:n})}return n}function hy(e){let t=W(We),n=el(()=>({...t,...e.providers}),[e.providers]);return U(We.Provider,{value:n,children:e.children})}function ft(){return{VaultContext:W(le),ResourceContext:W(Ue),SimpleViewerReactContext:W(ze),VisibleCanvasReactContext:W(he),AuthRContext:W(ve),SearchReactContext:W(Se),ReactEventContext:W(ke),ContextBridgeReactContext:W(We),StrategyReactContext:W(ce),AtlasStoreReactContext:W(be)}}function gt(e){return U(ge,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:U(he.Provider,{value:e.bridge.VisibleCanvasReactContext,children:U(ze.Provider,{value:e.bridge.SimpleViewerReactContext,children:U(ke.Provider,{value:e.bridge.ReactEventContext,children:U(be.Provider,{value:e.bridge.AtlasStoreReactContext,children:U(ve.Provider,{value:e.bridge.AuthRContext,children:U(Se.Provider,{value:e.bridge.SearchReactContext,children:U(We.Provider,{value:e.bridge.ContextBridgeReactContext,children:U(ce.Provider,{value:e.bridge.StrategyReactContext,children:e.custom?U(tl,{...e.custom,children:e.children}):e.children})})})})})})})})})}import{jsx as rn,jsxs as gl}from"react/jsx-runtime";var ur=10,sr=1;function ml(e){let[t,n]=e.split("-");return[t,n]}function lr(e,t,n){return t>n?e:Math.min(Math.max(e,t),n)}function pl(e){return e.top>0||e.right>0||e.bottom>0||e.left>0}function fl(e){return{name:"insideHighlightFallback",options:e,async fn(t){if(e.width<=sr||e.height<=sr)return{};let n=await rl(t,{altBoundary:!0});if(!pl(n))return{};let{reference:o,floating:s}=t.rects,[i,r]=ml(t.initialPlacement),a=Math.min(ur,o.width/2,o.height/2),l=o.x+(o.width-s.width)/2,u=o.y+(o.height-s.height)/2,m=t.x,c=t.y;return i==="top"||i==="bottom"?(c=i==="top"?o.y+a:o.y+o.height-s.height-a,r==="start"?m=o.x+a:r==="end"?m=o.x+o.width-s.width-a:m=l,m=lr(m,o.x+a,o.x+o.width-s.width-a)):(m=i==="left"?o.x+a:o.x+o.width-s.width-a,r==="start"?c=o.y+a:r==="end"?c=o.y+o.height-s.height-a:c=u,c=lr(c,o.y+a,o.y+o.height-s.height-a)),{x:m,y:c}}}}function ht({annotation:e,target:t,children:n,dismissable:o,isOpen:s,onOpenChange:i,placement:r}){let a=ft(),l=pt(),{refs:u,floatingStyles:m,context:c}=ul({open:s,onOpenChange:i,nodeId:e.id,placement:r||"bottom",middleware:[al(ur),il({mainAxis:!0,fallbackStrategy:"bestFit",altBoundary:!0}),sl({altBoundary:!0}),fl(t)],whileElementsMounted:ol}),d=ll(c),{getReferenceProps:p,getFloatingProps:g}=cl([o?d:null].filter(h=>h!==null));return gl(nl,{relative:!0,target:t,interactive:!1,children:[rn("div",{ref:u.setReference,...p(),style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"}}),dl(rn(gt,{bridge:a,custom:l,children:rn("div",{ref:u.setFloating,style:m,...g(),children:n})}),document.getElementById("atlas-floating-ui"))]})}import{Fragment as Sl,jsx as cr}from"react/jsx-runtime";var vl=yl()(e=>({isMenuOpen:!1,menuPosition:{x:0,y:0},setMenuPosition(t){e({menuPosition:t})},toggle(t){e(n=>({isMenuOpen:!n.isMenuOpen,menuPosition:t}))},open(t){e({isMenuOpen:!0,menuPosition:t})},setIsMenuOpen(t){e(typeof t=="function"?n=>({isMenuOpen:t(n.isMenuOpen)}):{isMenuOpen:t})},close(){e({isMenuOpen:!1})}}));function yt(e,t,n){let{isMenuOpen:o,setIsMenuOpen:s,close:i,open:r,menuPosition:a,setMenuPosition:l,toggle:u}=vl(),m=hl(p=>{n&&(p.preventDefault(),p.stopPropagation(),u(p.atlas))},[u,n]);return[cr(Sl,{children:n&&o&&cr(ht,{dismissable:!0,placement:"bottom-start",isOpen:o,onOpenChange:s,annotation:{id:e},target:{x:a.x,y:a.y,height:1,width:1},children:o&&n({canvasId:t,position:a,close:()=>s(!1)})})}),{onContextMenu:m},{open:r,close:i,toggle:u,isMenuOpen:o,setIsMenuOpen:s,menuPosition:a,setMenuPosition:l}]}import{useStore as xl}from"zustand";function dr(){let e=q();return xl(e,t=>t.tool.requestId&&t.requests[t.tool.requestId]||null)}import{Fragment as mr,jsx as ae,jsxs as an}from"react/jsx-runtime";function pr({theme:e,renderContextMenu:t,children:n}){let o=q(),s=P(),i=ee(o,x=>x.polygon),r=ee(o,x=>x.polygonState.currentTool),a=ee(o,x=>x.mode),l=ee(o,x=>x.changeMode),u=ee(o,x=>x.polygonState.transitioning),{enabled:m,requestId:c}=ee(o,x=>x.tool),d=Cl(()=>xe(i),[i]),p=dr(),[g,h]=yt("editing-annotation",s?.id,t),S=p?.annotationPopup||n||ae(Rl,{}),v=p?.svgTheme||e,f=()=>{l("sketch")};if(!m||!s||!c||!i)return null;let y=d&&i.id&&!u&&(r==="pointer"||r==="hand"||!i.open)?ae(ht,{annotation:i,target:d,children:S}):null,b="shape";return a==="explore"?an(mr,{children:[ae(b,{id:`shape-${i.id}`,points:i.points,open:i.open,onClick:f,relativeStyle:!0,target:{x:0,y:0,width:s.width,height:s.height},style:{":hover":{backgroundColor:"rgba(0,0,0,0.2)"},backgroundColor:"rgba(0,0,0,0)",borderWidth:"4px",borderColor:"rgba(255, 255, 255, .4)"},...h}),ae(b,{id:`shape-${i.id}`,points:i.points,open:i.open,onClick:f,relativeStyle:!0,target:{x:0,y:0,width:s.width,height:s.height},style:{backgroundColor:"rgba(0,0,0,0)",borderWidth:"2px",borderColor:"rgba(0, 0, 0, .4)"}}),y]}):an(mr,{children:[t?ae(b,{id:`shape-${i.id}`,points:i.points,open:i.open,target:{x:0,y:0,width:s.width,height:s.height},...h}):null,ae(ir,{image:s,theme:v}),y,g]})}function Rl(){let e=q(),t=ee(e,r=>r.changeMode),n=ee(e,r=>r.mode),o=ee(e,r=>r.completeRequest),s=ee(e,r=>r.tool),i=()=>{bl(()=>{o()})};return s.enabled?an("div",{className:"svg-tools-container animate-fadeIn",children:[n!=="sketch"&&ae("button",{className:"svg-tools-button",onClick:()=>{t("sketch")},children:"Edit"}),ae("button",{className:"svg-tools-button",onClick:i,children:"Save"})]}):null}import{useEffect as sn,useMemo as ln}from"react";import{useEffect as Rr,useMemo as Ar}from"react";import{useCallback as hr,useMemo as Pl}from"react";function Al(e,t){let n=e?.iiif?.meta[t];return n?n.annotationPageManager:null}function fr(e,t){return k(n=>{let o=[];if(!e)return o;let s=Object.keys(n.iiif.entities.AnnotationPage);for(let i of s)if(!t||t.indexOf(i)!==-1){let r=Al(n,i);r&&r.views&&r.views[e]&&o.push(i)}return o},[e,t])}function gr({canvas:e,manifest:t,all:n,canvases:o}){let s=[];if(t)for(let i of t.annotations)s.indexOf(i.id)===-1&&s.push(i.id);if(n){if(o&&o.length)for(let i of o)for(let r of i.annotations)s.indexOf(r.id)===-1&&s.push(r.id)}else if(e)for(let i of e.annotations)s.indexOf(i.id)===-1&&s.push(i.id);return s}function wl(e,t){let n=e?.iiif?.meta[t];return n?n.annotationPageManager:null}function yr(e,t={}){let n=M(),o=B(),s=P(),i=_e(),r=Pl(()=>gr({all:t.all,manifest:o,canvas:s,canvases:i}),[t.all,s,i,o]),a=fr(e,t.all?void 0:r),l=hr(m=>{e&&n.setMetaValue([m,"annotationPageManager","views"],c=>c&&!c[e]?c:{...c||{},[e]:!1})},[e,n]),u=hr((m,c={})=>{if(!e)return;let d=n.getState(),p=[];if(c?.deselectOthers){let g=Object.keys(d.iiif.entities.AnnotationPage);for(let h of g){let S=wl(d,h);S&&S.views&&S.views[e]&&p.push(h)}}for(let g of p)l(g);n.setMetaValue([m,"annotationPageManager","views"],g=>g&&g[e]?g:{...g||{},[e]:!0})},[e,l,n]);return{availablePageIds:r,enabledPageIds:a,setPageEnabled:u,setPageDisabled:l}}function vr(e,t){return k((n,o)=>o.get(e.map(s=>({id:s,type:t}))),[e,t])}import Tl from"mitt";import{useCallback as Il}from"react";import{createStore as Ml}from"zustand";var kl=Ml((e,t)=>({loaded:{},setLoaded:(n,o="done")=>{e(s=>({loaded:{...s.loaded,[n]:o}}))}})),El=Tl();El.on("loaded",e=>{kl.getState().setLoaded(e.imageServiceId)});function Sr(){let e=st(),t=Eo();return[Il((o,{height:s,width:i})=>o&&e(o,{height:s,width:i},!0),[e]),t]}import{useCallback as Vl,useMemo as br,useState as Nl}from"react";function xr(e={}){let t=Ge(),n=P(e.canvasId?{id:e.canvasId}:void 0);return k((o,s)=>{if(!n)return[];if(t&&e.enableSingleAnnotation)return[t];let i=s.get(n.items),r=[];for(let a of i)r.push(...s.get(a.items));return r},[n])}import{createPaintingAnnotationsHelper as Ll}from"@iiif/helpers/painting-annotations";function Cr(e,t=[]){let n=M(),o=br(()=>Ll(n),[]),s=xr({enableSingleAnnotation:e?.enableSingleAnnotation}),[i,r]=Nl(e?.defaultChoices||[]),a=br(()=>o.getPaintables(s,i),[n,s,i,...t]),u={makeChoice:Vl((m,{deselectOthers:c=!0,deselect:d=!1}={})=>{a.choice&&r(p=>{if(d){let h=p.filter(S=>S!==m);if(h.length===0){let S=a.items[0].resource.id;return S?[S]:[]}return h}if(c)return[m];let g=[...p];if(g.length===0&&a.items.length){let h=a.items[0].resource.id;h&&g.push(h)}return p.indexOf(m)!==-1?p:[...p,m]})},[a.choice])};return[a,u]}function Pr(e){let t=B(),n=P(),o=M(),s=ar(),i=e?.emitter||s,[r,a]=Sr(),{enabledPageIds:l}=yr(e?.annotationPageManagerId||t?.id||n?.id,{all:!1}),u=vr(l,"AnnotationPage"),m=e?.strategies||["empty","images","media","textual-content","complex-timeline"],[c,d]=Cr(e,[a]);Rr(()=>{let g=h=>{d.makeChoice(h.choiceId,{deselectOthers:h.deselectOthers,deselect:h.deselect})};return i.on("make-choice",g),()=>{i.off("make-choice",g)}},[]);let p=Ar(()=>mn({canvas:n,paintables:c,supports:m,loadImageService:r,vault:o}),[n,c,o,d.makeChoice]);return Rr(()=>{let g=c.allChoices,h={canvasId:n?.id,manifestId:t?.id};g&&i.emit("choice-change",{choice:g,partOf:h})},[n?.id,c.allChoices]),Ar(()=>p.type==="unknown"?[p,dn]:[{...p,annotations:{pages:u}},d],[p,u])}import{createStylesHelper as zl}from"@iiif/helpers";import{jsx as wr}from"react/jsx-runtime";function Tr({strategies:e,registerActions:t,defaultChoices:n,onChoiceChange:o,mediaControlsDeps:s,renderMediaControls:i,renderViewerControls:r,viewControlsDeps:a,renderComplexTimelineControls:l,complexTimelineControlsDeps:u,throwOnUnknown:m,children:c}){let d=P(),p=M(),g=ln(()=>zl(p),[p]),[h,S]=Pr({strategies:e||["images"],defaultChoices:n?.map(({id:b})=>b)}),v="choice"in h?h.choice:void 0;if(sn(()=>{t&&t(S)},[h.annotations]),sn(()=>{o&&o(v)},[v]),sn(()=>{if(n)for(let b of n)typeof b.opacity<"u"&&g.applyStyles({id:b.id},"atlas",{opacity:b.opacity})},[n]),h.type==="unknown"&&m)throw new Error(h.reason||"Unknown strategy");let f=ln(()=>({renderMediaControls:i,mediaControlsDeps:s||[],renderViewerControls:r,viewControlsDeps:a||[],renderComplexTimelineControls:l,complexTimelineControlsDeps:u||[]}),[s,i,r,a,l,u]),y=ln(()=>({strategy:h,actions:S,choices:"choice"in h?h.choice:[]}),[h,d]);return wr(ot.Provider,{value:f,children:wr(ce.Provider,{value:y,children:c})})}import{useEffect as Mr,useMemo as Dl}from"react";import{useStore as kr}from"zustand";import{createContext as Ol,useContext as Bl,useEffect as Hl}from"react";var un=Ol(()=>{});function Ir(e){let t=P(),n=Bl(un);Hl(()=>t&&t.id?(n(t.id,e),()=>n(t.id,-1)):()=>{},[t,e])}import{jsxs as ql}from"react/jsx-runtime";function Er({x:e=0,y:t=0,keepCanvasScale:n=!0,renderContextMenu:o,children:s}){let{strategy:i}=V(),r=P(),a=q(),l=Qe(r,["deep-zoom"]),u=kr(a,h=>h.setCanvasRelativePosition),m=kr(a,h=>h.clearCanvasRelativePosition),[c,d]=yt(`context-menu/${r?.id}`,r?.id,o),p=Dl(()=>n?1:Math.max(1,...i.type==="images"?i.images.map(h=>(h.width||0)/h.target?.spatial.width):[]),[n,i]);Mr(()=>{if(r)return u(r.id,{x:e,y:t,width:r.width,height:r.height}),()=>{m(r.id)}},[e,t,r,m,u]),Mr(()=>{r&&a.getState().reset()},[a,r]),Ir(p);let g=i.type==="images"?i.images.length:0;return r?ql("world-object",{height:r.height,width:r.width,x:e,y:t,...d,...l,children:[c,s]},`${r.id}/${i.type}/${g}`):null}import{jsx as Y,jsxs as Vr}from"react/jsx-runtime";function de({x:e,y:t,onChoiceChange:n,registerActions:o,defaultChoices:s,isStatic:i,renderViewerControls:r,renderMediaControls:a,renderComplexTimelineControls:l,complexTimelineControlsDeps:u,viewControlsDeps:m,mediaControlsDeps:c,strategies:d,throwOnUnknown:p,rotation:g,backgroundStyle:h,alwaysShowBackground:S,keepCanvasScale:v=!1,enableSizes:f=!1,enableYouTube:y=!0,onClickPaintingAnnotation:b,components:x={},children:C,annotationPopup:R,svgTheme:A,renderContextMenu:L,renderAnnotationContextMenu:Q}){return Vr(Tr,{throwOnUnknown:p,onChoiceChange:n,registerActions:o,strategies:d,defaultChoices:s,mediaControlsDeps:c,renderMediaControls:a,renderViewerControls:r,renderComplexTimelineControls:l,complexTimelineControlsDeps:u,viewControlsDeps:m,children:[Vr(Er,{keepCanvasScale:v,x:e,y:t,renderContextMenu:L,children:[Y(Yo,{alwaysShowBackground:S,backgroundStyle:h}),Y(Ko,{}),Y(Qo,{}),Y(Go,{isStatic:i,enableSizes:f,onClickPaintingAnnotation:b,rotation:g}),Y(So,{}),Y(lo,{}),Y(Ro,{as:x.Audio}),Y(Zo,{as:x.Video}),y?Y(tr,{}):null,Y(pr,{theme:A,renderContextMenu:Q,children:R}),C]}),Y(uo,{})]})}import{jsx as Nr}from"react/jsx-runtime";function Lr(e){let t=P();return!t||!t.placeholderCanvas?null:Nr(te,{canvas:t.placeholderCanvas.id,children:Nr(de,{renderViewerControls:e.renderViewerControls})})}import{AtlasAuto as Ul}from"@atlas-viewer/atlas";import Br,{useCallback as vt,useMemo as _l,useState as St}from"react";import{ErrorBoundary as jl}from"react-error-boundary";import{useStore as Hr}from"zustand";import{useEffect as Fl,useMemo as $l}from"react";function zr(e,t=2e3){let{currentSequenceIndex:n,sequence:o,items:s}=Ye(),i=P(),r=$l(()=>{let l=o[n]||[];return l.length===0&&i?[{id:i.id,type:"Canvas"}]:l.map(u=>s[u])},[o,n,i,s]),a=q();Fl(()=>{let u=setInterval(()=>{if(e&&t!==-1){let m={x:e.x,y:e.y,width:e.width,height:e.height},c=a.getState().canvasRelativePositions,d={};for(let p of r){let g=c[p.id];if(g){let h=g.x,S=g.y,v=g.width,f=g.height,y={x:Math.max(h,m.x),y:Math.max(S,m.y),width:Math.min(h+v,m.x+m.width)-Math.max(h,m.x),height:Math.min(S+f,m.y+m.height)-Math.max(S,m.y)};y.width<=0||y.height<=0||(d[p.id]={x:y.x-g.x,y:y.y-g.y,width:y.width,height:y.height}),a.setState({canvasViewports:d})}}}},t);return()=>{clearTimeout(u)}},[r,e,a,t])}import{jsx as cn,jsxs as Wl}from"react/jsx-runtime";function Or({width:e,style:t,height:n,error:o,resetErrorBoundary:s}){return Wl("div",{style:{width:e,height:n,minHeight:500,...t||{},background:"#f9f9f9"},children:[cn("h3",{children:"Error occurred"}),cn("p",{children:o.message}),cn("button",{type:"button",onClick:s,children:"Reset"})]})}import{Fragment as Yl,jsx as O,jsxs as Gl}from"react/jsx-runtime";function Dr(e){let t=q();return O(Oe,{name:e.name,existing:t,children:O(Kl,{...e})})}function Kl({name:e,children:t,errorFallback:n,outerContainerProps:o={},worldScale:s,updateViewportTimeout:i,...r}){let a=q(),l=Hr(a,w=>w.mode),u=Hr(a,w=>w.setAtlasRuntime),[m,c]=St(),d=pt(),p=ft(),g=n||Or,[h,S]=St({}),v=Object.entries(h),[f,y]=St({}),b=Object.entries(f),[x,C]=St({}),{worldScale:R,runtimeOptions:A}=_l(()=>{if(Object.values(x).length===0)return{worldScale:1,runtimeOptions:r.runtimeOptions||{maxOverZoom:1}};let I=Math.max(...Object.values(x));return{worldScale:I,runtimeOptions:{maxOverZoom:I||1,...r.runtimeOptions||{}}}},[x,r.runtimeOptions]);zr(m?.runtime,i);let L=vt((w,I)=>{C(E=>{if(I===-1){let{[w]:Ee,...se}=E;return se}return{...E,[w]:I}})},[]),Q=vt((w,I,E)=>{S(({[w]:Ee,...se})=>I?{...se,[w]:{element:I,props:E}}:se)},[]),T=vt((w,I,E)=>{y(({[w]:Ee,...se})=>I?{...se,[w]:{element:I,props:E}}:se)},[]),z=vt(w=>{c(w),u(w.runtime),r.onCreated&&r.onCreated(w)},[r.onCreated,u]);return Gl(jl,{resetKeys:[],fallbackRender:w=>O(g,{...r,...w}),children:[O(Ul,{...r,mode:l,containerProps:{style:{position:"relative"},...r.containerProps||{}},htmlChildren:O(Yl,{children:v.map(([w,{element:I,props:E}])=>O(Br.Fragment,{children:O(I,{...E||{}})},w))}),onCreated:z,runtimeOptions:A,children:O(Oe,{name:e,existing:a,children:O(fe.Provider,{value:m,children:O(un.Provider,{value:L,children:O(qt.Provider,{value:Q,children:O(Ft.Provider,{value:T,children:O(gt,{bridge:p,custom:d,children:O(yo,{children:t})})})})})})})}),O("div",{children:b.map(([w,{element:I,props:E}])=>O(Br.Fragment,{children:O(I,{...E||{}})},w))}),O("div",{id:"atlas-floating-ui",style:{position:"relative",zIndex:999999}})]})}import{Fragment as Jl,jsx as G,jsxs as eu}from"react/jsx-runtime";var Zl=qr(function(t,n){let o=B(),s=_e(),i=Ye(),{ViewerControls:r,MediaControls:a,ComplexTimelineControls:l}=t.components||{};if(Ql(n,()=>i,[i]),!o)return G("div",{});let u=0,m=o.viewingDirection==="top-to-bottom",c=o.viewingDirection==="bottom-to-top",d=o.viewingDirection==="left-to-right",p=o.viewingDirection==="right-to-left",h=o.behavior.includes("continuous")?0:t.spacing||0,S=c||p,v=Xl(()=>S?[...s].reverse():s,[s,S]);return eu(Jl,{children:[t.header,G(H.Viewer,{height:t.height,mode:t.mode,renderPreset:t.renderPreset,runtimeOptions:t.runtimeOptions,updateViewportTimeout:t.updateViewportTimeout,homePaddingPx:t.padding,children:v.map((f,y)=>{let b=0,x=0;return!m&&!c?(b=u,u+=f.width+h):(x=u,u+=f.height+h),G(te,{canvas:f.id,children:G(H.RenderCanvas,{strategies:["3d-model","media","images","empty","textual-content","complex-timeline"],renderViewerControls:y===0&&r?()=>G(r,{}):void 0,renderMediaControls:y===0&&a?()=>G(a,{}):void 0,annotationPopup:t.annotationPopup,renderContextMenu:t.renderContextMenu,keepCanvasScale:t.keepCanvasScale,renderComplexTimelineControls:y===0&&l?()=>G(l,{}):void 0,renderAnnotationContextMenu:t.renderAnnotationContextMenu,x:b,y:x,svgTheme:t.svgTheme,rotation:t.rotation,...t.canvasProps||{},children:t.annotations},f.id)},f.id)})},t.reuseAtlas?"":i.currentSequenceIndex),t.children]})}),H=qr(function({children:t,height:n,annotations:o,canvasProps:s,spacing:i,header:r,components:a,mode:l,reuseAtlas:u,renderPreset:m,runtimeOptions:c,annotationPopup:d,name:p,svgTheme:g,updateViewportTimeout:h,renderContextMenu:S,keepCanvasScale:v,renderAnnotationContextMenu:f,padding:y,rotation:b,...x},C){let R=ye();return G(Oe,{name:p,children:G(ge,{vault:R,children:G(Dn,{...x,children:G(Zl,{ref:C,height:n,components:a,spacing:i,canvasProps:s,annotations:o,header:r,mode:l,reuseAtlas:u,renderPreset:m,runtimeOptions:c,annotationPopup:d,svgTheme:g,updateViewportTimeout:h,renderContextMenu:S,keepCanvasScale:v,renderAnnotationContextMenu:f,padding:y,rotation:b,children:t})})})})});H.RenderImage=Ie;H.RenderCanvas=de;H.RenderAnnotationPage=ue;H.RenderAnnotation=Re;H.Viewer=Dr;H.CanvasBackground=ct;H.Audio=tt;H.Video=mt;H.Model=nt;H.AudioHTML=$t;H.VideoHTML=Jt;H.ModelHTML=Ut;H.PlaceholderCanvas=Lr;H.getAtlasStoreByName=Kn;export{Ue as a,_ as b,ie as c,te as d,le as e,ge as f,M as g,k as h,he as i,_e as j,ye as k,B as l,gn as m,hn as n,yn as o,vn as p,li as q,bt as r,Qu as s,Sn as t,Ju as u,Ct as v,xn as w,bn as x,mc as y,An as z,Pn as A,wn as B,Rt as C,Cn as D,ve as E,hi as F,yi as G,Nn as H,Ln as I,Ne as J,vi as K,kc as L,Si as M,En as N,Ec as O,zn as P,Bn as Q,ze as R,ki as S,Dn as T,Ye as U,Tt as V,Sd as W,Fn as X,$n as Y,It as Z,xe as _,Oi as $,Ad as aa,Mt as ba,kt as ca,Wn as da,Un as ea,be as fa,q as ga,Kn as ha,Oe as ia,Yn as ja,Gn as ka,Fd as la,Ji as ma,Qn as na,Ge as oa,P as pa,Qe as qa,Ce as ra,Zn as sa,eo as ta,Re as ua,to as va,ue as wa,_m as xa,jm as ya,Km as za,Ze as Aa,Je as Ba,Dt as Ca,Ae as Da,D as Ea,ce as Fa,V as Ga,lo as Ha,ot as Ia,F as Ja,uo as Ka,co as La,fo as Ma,ho as Na,yo as Oa,So as Pa,xo as Qa,Ua as Ra,bo as Sa,Pe as Ta,we as Ua,Ro as Va,Ao as Wa,Af as Xa,rs as Ya,Ef as Za,Be as _a,Vf as $a,Nf as ab,He as bb,Lf as cb,st as db,Wf as eb,Kf as fb,Yf as gb,Gf as hb,Oo as ib,Yt as jb,Bo as kb,us as lb,cs as mb,ds as nb,Qf as ob,qe as pb,Ie as qb,Ko as rb,Yo as sb,fe as tb,dt as ub,Go as vb,Qo as wb,Zo as xb,tr as yb,nr as zb,Ws as Ab,rr as Bb,Xs as Cb,ke as Db,ar as Eb,oy as Fb,pt as Gb,tl as Hb,hy as Ib,ft as Jb,gt as Kb,vl as Lb,yt as Mb,dr as Nb,pr as Ob,Rl as Pb,gr as Qb,yr as Rb,vr as Sb,Sr as Tb,xr as Ub,Cr as Vb,Pr as Wb,Tr as Xb,Er as Yb,Or as Zb,Dr as _b,H as $b};
|
|
@@ -558,17 +558,18 @@ type CanvasProps = {
|
|
|
558
558
|
Video?: React__default.ComponentType<VideoComponentProps>;
|
|
559
559
|
Audio?: React__default.ComponentType<AudioComponentProps>;
|
|
560
560
|
};
|
|
561
|
+
rotation?: number;
|
|
561
562
|
annotationPopup?: React__default.ReactNode;
|
|
562
563
|
svgTheme?: Partial<SVGTheme>;
|
|
563
564
|
renderAnnotationContextMenu?: (options: RenderContextProps) => React__default.ReactNode;
|
|
564
565
|
};
|
|
565
|
-
declare function RenderCanvas({ x, y, onChoiceChange, registerActions, defaultChoices, isStatic, renderViewerControls, renderMediaControls, renderComplexTimelineControls, complexTimelineControlsDeps, viewControlsDeps, mediaControlsDeps, strategies, throwOnUnknown, backgroundStyle, alwaysShowBackground, keepCanvasScale, enableSizes, enableYouTube, onClickPaintingAnnotation, components, children, annotationPopup, svgTheme, renderContextMenu, renderAnnotationContextMenu, }: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
566
|
+
declare function RenderCanvas({ x, y, onChoiceChange, registerActions, defaultChoices, isStatic, renderViewerControls, renderMediaControls, renderComplexTimelineControls, complexTimelineControlsDeps, viewControlsDeps, mediaControlsDeps, strategies, throwOnUnknown, rotation, backgroundStyle, alwaysShowBackground, keepCanvasScale, enableSizes, enableYouTube, onClickPaintingAnnotation, components, children, annotationPopup, svgTheme, renderContextMenu, renderAnnotationContextMenu, }: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
566
567
|
|
|
567
568
|
declare function CanvasBackground({ style }: {
|
|
568
569
|
style?: BoxStyle;
|
|
569
570
|
}): react_jsx_runtime.JSX.Element | null;
|
|
570
571
|
|
|
571
|
-
declare function RenderImage({ id, image, thumbnail, isStatic, x, y, children, selector, onClick, enableSizes, enableAnnotations, }: {
|
|
572
|
+
declare function RenderImage({ id, image, thumbnail, isStatic, x, y, children, selector, onClick, rotation: _rotation, enableSizes, enableAnnotations, }: {
|
|
572
573
|
id: string;
|
|
573
574
|
image: ImageWithOptionalService;
|
|
574
575
|
thumbnail?: ImageCandidate;
|
|
@@ -580,6 +581,7 @@ declare function RenderImage({ id, image, thumbnail, isStatic, x, y, children, s
|
|
|
580
581
|
y?: number;
|
|
581
582
|
children?: ReactNode;
|
|
582
583
|
onClick?: (e: any) => void;
|
|
584
|
+
rotation?: number;
|
|
583
585
|
}): react_jsx_runtime.JSX.Element;
|
|
584
586
|
|
|
585
587
|
declare function ModelHTML({ model }: {
|
|
@@ -627,6 +629,7 @@ interface CanvasPanelProps {
|
|
|
627
629
|
padding?: AtlasProps['homePaddingPx'];
|
|
628
630
|
height?: number;
|
|
629
631
|
spacing?: number;
|
|
632
|
+
rotation?: number;
|
|
630
633
|
components?: {
|
|
631
634
|
ViewerControls?: FC;
|
|
632
635
|
MediaControls?: FC;
|
|
@@ -558,17 +558,18 @@ type CanvasProps = {
|
|
|
558
558
|
Video?: React__default.ComponentType<VideoComponentProps>;
|
|
559
559
|
Audio?: React__default.ComponentType<AudioComponentProps>;
|
|
560
560
|
};
|
|
561
|
+
rotation?: number;
|
|
561
562
|
annotationPopup?: React__default.ReactNode;
|
|
562
563
|
svgTheme?: Partial<SVGTheme>;
|
|
563
564
|
renderAnnotationContextMenu?: (options: RenderContextProps) => React__default.ReactNode;
|
|
564
565
|
};
|
|
565
|
-
declare function RenderCanvas({ x, y, onChoiceChange, registerActions, defaultChoices, isStatic, renderViewerControls, renderMediaControls, renderComplexTimelineControls, complexTimelineControlsDeps, viewControlsDeps, mediaControlsDeps, strategies, throwOnUnknown, backgroundStyle, alwaysShowBackground, keepCanvasScale, enableSizes, enableYouTube, onClickPaintingAnnotation, components, children, annotationPopup, svgTheme, renderContextMenu, renderAnnotationContextMenu, }: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
566
|
+
declare function RenderCanvas({ x, y, onChoiceChange, registerActions, defaultChoices, isStatic, renderViewerControls, renderMediaControls, renderComplexTimelineControls, complexTimelineControlsDeps, viewControlsDeps, mediaControlsDeps, strategies, throwOnUnknown, rotation, backgroundStyle, alwaysShowBackground, keepCanvasScale, enableSizes, enableYouTube, onClickPaintingAnnotation, components, children, annotationPopup, svgTheme, renderContextMenu, renderAnnotationContextMenu, }: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
566
567
|
|
|
567
568
|
declare function CanvasBackground({ style }: {
|
|
568
569
|
style?: BoxStyle;
|
|
569
570
|
}): react_jsx_runtime.JSX.Element | null;
|
|
570
571
|
|
|
571
|
-
declare function RenderImage({ id, image, thumbnail, isStatic, x, y, children, selector, onClick, enableSizes, enableAnnotations, }: {
|
|
572
|
+
declare function RenderImage({ id, image, thumbnail, isStatic, x, y, children, selector, onClick, rotation: _rotation, enableSizes, enableAnnotations, }: {
|
|
572
573
|
id: string;
|
|
573
574
|
image: ImageWithOptionalService;
|
|
574
575
|
thumbnail?: ImageCandidate;
|
|
@@ -580,6 +581,7 @@ declare function RenderImage({ id, image, thumbnail, isStatic, x, y, children, s
|
|
|
580
581
|
y?: number;
|
|
581
582
|
children?: ReactNode;
|
|
582
583
|
onClick?: (e: any) => void;
|
|
584
|
+
rotation?: number;
|
|
583
585
|
}): react_jsx_runtime.JSX.Element;
|
|
584
586
|
|
|
585
587
|
declare function ModelHTML({ model }: {
|
|
@@ -627,6 +629,7 @@ interface CanvasPanelProps {
|
|
|
627
629
|
padding?: AtlasProps['homePaddingPx'];
|
|
628
630
|
height?: number;
|
|
629
631
|
spacing?: number;
|
|
632
|
+
rotation?: number;
|
|
630
633
|
components?: {
|
|
631
634
|
ViewerControls?: FC;
|
|
632
635
|
MediaControls?: FC;
|