react-iiif-vault 1.3.4 → 1.3.6

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/index.js CHANGED
@@ -1 +1 @@
1
- import{$ as wo,A as to,Aa as on,B as oo,Ba as D,C as no,Ca as nn,D as ro,Da as un,E as io,Ea as dn,F as ao,Fa as le,G as so,Ga as fn,H as lo,Ha as pn,I as co,Ia as gn,J as mo,Ja as hn,K as uo,Ka as yn,L as fo,La as vn,M as po,Ma as xn,N as go,Na as bn,O as ho,Oa as Sn,P as yo,Pa as ce,Q as vo,R as xo,S as bo,T as So,U as ie,V as Co,W as Io,X as ae,Y as ko,Z as Po,_ as To,a as Wt,aa as Ro,b as A,ba as Eo,c as B,ca as Mo,d as Dt,da as No,e as Ft,ea as Bo,f as Ot,fa as T,g as te,ga as Lo,h as $t,ha as Ho,i as Vt,ia as Ao,j as oe,ja as zo,k as P,ka as qo,l as z,la as Wo,m as Xt,ma as Do,n as ne,na as Fo,o as q,oa as Oo,p as Yt,pa as $o,q as _t,qa as Vo,r as Kt,ra as Xo,s as Qt,sa as Yo,t as Ut,ta as _o,u as Gt,ua as N,v as Jt,va as jo,w as re,wa as se,x as Zt,xa as en,y as jt,ya as tn,z as eo,za as W}from"./chunk-L6FWDFSU.js";import{a as Ko,b as Qo,c as Uo,d as Go,e as Jo,f as Zo,g as rn,h as an,i as sn,j as ln,k as cn,l as mn}from"./chunk-UFC4ZSNV.js";import{useCanvas as We}from"@atlas-viewer/atlas";import{forwardRef as De,useImperativeHandle as Fe}from"react";import{Fragment as Oe,jsx as me}from"react/jsx-runtime";var wn=De(function({canvasId:t},o){let n=We(),i=se(t||n?.id),a=P();return Fe(o,()=>i,[t,n]),!n||i.enabledPageIds.length===0?null:me(Oe,{children:i.enabledPageIds.map(s=>me(ce.RenderAnnotationPage,{page:a.get(s)},s))})});import{useMemo as Xe}from"react";import{useMemo as $e}from"react";import{Fragment as Ve,jsx as C,jsxs as F}from"react/jsx-runtime";function O({metadata:e=[],config:t,labelWidth:o=16,showEmptyMessage:n=!0,allowHtml:i,emptyFallback:a,classes:s={},emptyMessage:l="No metadata available",emptyValueFallback:u="No value",emptyLabelFallback:m="",separator:c,tableFooter:f,tableHeader:x}){let h=$e(()=>{let g=(t||[]).reduce((p,b)=>[...p,...b.keys],[]),d={};for(let p of e){let b=p&&p.label?Object.values(p.label):[];for(let r of b)if(r&&r.length&&(g.indexOf(`metadata.${r[0]}`)!==-1||g.length===0)&&p){let S=`metadata.${r[0]}`;d[S]=d[S]?d[S]:[],d[S].push(p);break}}return d},[t,e]);return Object.keys(h).length===0&&n?C(Ve,{children:a})||C("div",{className:s.empty,children:l}):t&&t.length?F("table",{className:s.container,children:[x,C("tbody",{children:t.map((g,d)=>{let p=[];for(let b of g.keys)for(let r of h[b]||[])p.push(C(N,{enableDangerouslySetInnerHTML:i,defaultText:u,separator:c,children:r.value},d+"__"+b));return p.length===0?null:F("tr",{className:s.row,children:[C("td",{className:s.label,style:o?{minWidth:o}:{},children:C(N,{enableDangerouslySetInnerHTML:i,separator:c,defaultText:m,children:g.label})}),C("td",{className:s.value,children:p})]},d)})}),f]}):F("table",{className:s.container,children:[x,C("tbody",{children:e&&e.length?e.map((g,d)=>g?F("tr",{className:s.row,children:[C("td",{className:s.label,style:o?{minWidth:o}:{},children:C(N,{enableDangerouslySetInnerHTML:i,defaultText:u,separator:c,children:g.label})}),C("td",{className:s.value,children:C(N,{enableDangerouslySetInnerHTML:i,defaultText:u,separator:c,children:g.value})})]},d):null):null}),f]})}import{jsx as Ye}from"react/jsx-runtime";function Fn(e){let t=q(),o=T(),n=re(),i=Xe(()=>{let a=t?.metadata||[],s=o?.metadata||[],l=n?.metadata||[];return[...a,...s,...l]},[t,o,n]);return Ye(O,{metadata:i,...e})}import{useEffect as Ue,useState as Ge}from"react";import{createImageServiceRequest as _e,imageServiceRequestToString as Ke}from"@atlas-viewer/iiif-image-api";import{useMemo as Qe}from"react";function Q(e,t={},o=[]){return Qe(()=>{if(!e)return null;let n=t.quality;e&&e.extraQualities&&t.quality&&(e.extraQualities.includes(t.quality)||(n="default"));let i=_e(e);return Ke({identifier:i.identifier,server:i.server,scheme:i.scheme,type:"image",size:{max:!t.size?.width&&!t.size?.height,confined:!1,upscaled:!1,...t.size||{}},format:t.format||"jpg",region:t.region||{full:!0},rotation:t?.rotation?Number.isInteger(t.rotation)?{angle:t.rotation}:t.rotation:{angle:0},quality:n||"default",prefix:i.prefix,originalPath:i.originalPath})},[...o])}import{jsx as $}from"react/jsx-runtime";function Je(e){let t=typeof e.src=="string"?e.src:e.src.id,o=W(),[n,i]=Ge(!1),a;if(t){let l=o.loadServiceSync({id:t});l&&(a=l)}!a&&!n&&o.loadService({id:t}).then(()=>{i(!0)});let s=Q(a,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[n,e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return Ue(()=>()=>{i(!1)},[t]),s?$("img",{src:s,alt:e.alt,className:e.className,style:e.style}):$(Ze,{...e,fetchImageService:!1})}function Ze(e){if(e.fetchImageService)return $(Je,{...e});let t=typeof e.src=="string"?{id:e.src,profile:"level0"}:e.src,o=Q(t,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return o?$("img",{src:o,alt:e.alt,className:e.className,style:e.style}):null}import{jsx as je}from"react/jsx-runtime";function or(e){let t=q();return je(O,{metadata:t?.metadata||[],...e})}import{useLayoutEffect as rt,useRef as it}from"react";import*as U from"react-lazy-load-image-component";import{getValue as et}from"@iiif/helpers/i18n";import{Fragment as ue,jsx as w,jsxs as nt}from"react/jsx-runtime";var{LazyLoadComponent:tt}=U||U.default;function de(e){let{size:t,visible:o,classes:n,canvasId:i,figure:a}=e,s=t?.width||128,l=t?.height||t?.width||128,u=w(ot,{...e}),m=w(tt,{threshold:300,style:{height:l,width:s},visibleByDefault:o,children:i?w(oe,{canvas:i,children:u}):u});return a?w("figure",{className:n?.figure,children:m}):m}function ot({fallback:e,size:t,classes:o,showLabel:n,alt:i,dereference:a=!1}){let s=T(),l=t?.width||128,u=t?.height||t?.width||128,m=i||et(s?.label)||"",c=le({width:l,height:u},a);return!c||c.type!=="fixed"?w(ue,{children:e}):nt(ue,{children:[w("div",{className:o?.imageWrapper,children:w("img",{className:o?.img,src:c.id,alt:m})}),n?w(N,{as:"figcaption",className:o?.label,children:s?.label}):null]})}import{jsx as L}from"react/jsx-runtime";function gr({flat:e,size:t,classes:o={},showLabel:n,figure:i,fallback:a}){let s=it(null),{items:l,sequence:u,currentSequenceIndex:m,setSequenceIndex:c}=ie(),f={row:o.selected?.row||o.row,item:o.selected?.item||o.item,figure:o.selected?.figure||o.figure,img:o.selected?.img||o.img,label:o.selected?.label||o.label,imageWrapper:o.selected?.imageWrapper||o.imageWrapper};rt(()=>{if(!s.current)return;let h=s.current.querySelector("[data-selected=true]");h&&h.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},[m]);let x=[];for(let h of u){let I=[],g=u[m]===h;for(let d of h){let p=l[d];I.push(L("div",{className:g?f.item:o.item,children:L(de,{classes:g?f:o,canvasId:p.id,size:t,showLabel:n,figure:i,placeholder:L("div",{style:{height:128,width:128}}),fallback:a})},d))}if(e){x.push(I);continue}x.push(L("div",{onClick:d=>{c(u.indexOf(h))},"data-selected":g,className:g?f.row:o.row,children:I},h.join("-")))}return L("div",{ref:s,className:o.container,children:x})}import{Fragment as fe,jsx as R,jsxs as pe}from"react/jsx-runtime";var at={draw:!0,polygon:!0,line:!0,lineBox:!0,square:!0,triangle:!0,hexagon:!0,circle:!0,delete:!0};function vr({helper:e,showShapes:t,state:o,enabled:n=at,classNames:i={},icons:a={}}){return pe(fe,{children:[t?pe(fe,{children:[n.draw&&R("button",{className:i.button,onClick:()=>{e.stamps.clear(),e.draw.enable()},"data-active":!o.lineMode&&!o.selectedStamp&&t&&o.drawMode,children:a.DrawIcon||"Draw"}),n.polygon&&R("button",{className:i.button,"data-active":!o.lineMode&&!o.selectedStamp&&t&&!o.drawMode,onClick:()=>{e.stamps.clear(),e.draw.disable(),e.modes.disableLineBoxMode(),e.modes.disableLineMode()},children:a.PolygonIcon||"Polygon"}),n.line&&R("button",{className:i.button,"data-active":o.lineMode&&!o.lineBoxMode,onClick:()=>{e.modes.enableLineMode()},children:a.LineIcon||"Line"}),n.lineBox&&R("button",{className:i.button,"data-active":o.lineBoxMode,onClick:()=>{e.modes.enableLineBoxMode()},children:a.LineBoxIcon||"LineBox"}),n.square&&R("button",{className:i.button,"data-active":o.selectedStamp?.id==="square",onClick:()=>{e.stamps.square()},children:a.SquareIcon||"Square"}),n.triangle&&R("button",{className:i.button,"data-active":o.selectedStamp?.id==="triangle",onClick:()=>{e.stamps.triangle()},children:a.TriangleIcon||"Triangle"}),n.hexagon&&R("button",{className:i.button,"data-active":o.selectedStamp?.id==="hexagon",onClick:()=>{e.stamps.hexagon()},children:a.HexagonIcon||"Hexagon"})]}):null,o.showBoundingBox&&n.delete&&R("button",{className:i.button,onClick:()=>e.key.down("Backspace"),children:a.DeleteForeverIcon||"Delete"})]})}import{createContext as st,useCallback as ge,useContext as ye,useEffect as he,useMemo as G,useState as lt}from"react";import ve from"mitt";import{jsx as ct}from"react/jsx-runtime";var V=st(ve());V.displayName="SelectorHelper";function Tr({children:e}){return ct(V.Provider,{value:G(()=>ve(),[]),children:e})}function wr(){return ye(V)}function xe(e){let t=be(),[o,n]=lt(!1);he(()=>t.withSelector(e).on("highlight",()=>{n(!0)}),[t,e]),he(()=>t.withSelector(e).on("clear-highlight",()=>{n(!1)}),[t,e]);let i=ge(s=>{t.emit("click",{selectorId:e,event:s})},[e,t]),a=ge(s=>{t.emit("hover",{selectorId:e,event:s})},[e,t]);return{controller:t,onClick:i,onHover:a,isHighlighted:o}}function be(){let e=ye(V);return G(()=>({withSelector(t){return{on(o,n){let i=a=>{a&&a.selectorId===t&&n(a)};return e.on(o,i),()=>{e.off(o,i)}},emit(o,n){e.emit(o,{...n,selectorId:t})}}},on(t,o){return e.on(t,o),()=>{e.off(t,o)}},emit(t,o){e.emit(t,o)}}),[e])}function Rr(){let e=be();return G(()=>({withSelector(t){return{highlight(){e.emit("highlight",{selectorId:t})},clearHighlight(){e.emit("clear-highlight",{selectorId:t})},zoomTo(){e.emit("zoom-to",{selectorId:t})},addEventListener(o,n){return e.emit("event-listener",{selectorId:t,name:o,callback:n}),()=>{e.emit("remove-event-listener",{selectorId:t,name:o,callback:n})}},getImagePreview(){return new Promise((o,n)=>{e.emit("image-preview-request",{selectorId:t,resolve:o,reject:n})})},on(o,n){return e.withSelector(t).on(o,n)}}},highlight(t){e.emit("highlight",{selectorId:t})},clearHighlight(t){e.emit("clear-highlight",{selectorId:t})},zoomTo(t){e.emit("zoom-to",{selectorId:t})},addEventListener(t,o,n){return e.emit("event-listener",{selectorId:t,name:o,callback:n}),()=>{e.emit("remove-event-listener",{selectorId:t,name:o,callback:n})}},getImagePreview(t){return new Promise((o,n)=>{e.emit("image-preview-request",{selectorId:t,resolve:o,reject:n})})},on(t,o){return e.on(t,o)}}),[e])}import{createContext as mt,useContext as ut,useMemo as dt}from"react";import{jsx as ft}from"react/jsx-runtime";function Se(){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 J=mt(Se());J.displayName="AnnotationStyle";function Ce(){return ut(J)}function Br({theme:e,children:t}){let o=dt(()=>e||Se(),[e]);return ft(J.Provider,{value:o,children:t})}import{HTMLPortal as xt,useAtlas as bt}from"@atlas-viewer/atlas";import{useEffect as ke,useRef as E,useState as Pe}from"react";import{useEffect as pt,useMemo as gt,useState as ht}from"react";import{createHelper as yt}from"polygon-editor";function Ie(e,t,o){let[n,i]=ht({}),a=gt(()=>yt(e,o),[]);return pt(()=>(a.clock.start(t,i),()=>{a.clock.stop()}),[]),{state:n,helper:a}}import{createSvgHelpers as vt}from"polygon-editor";import{Fragment as Te,jsx as v,jsxs as we}from"react/jsx-runtime";var M=vt();function Re(e,t){let{image:o,currentShape:n,onChange:i,hideShapeLines:a}=e,s=E(),l=E(),u=E(),m=E(),c=E(),f=E(),x=E(),h=E(),[I,g]=Pe(null),[d,p]=Pe(!1),{helper:b,state:r}=Ie(n,(y,k)=>{M.updateTransitionBoundingBox(l.current,y,k),M.updateBoundingBoxPolygon(s.current,y,k),M.updateTransitionShape(f.current,y,k),M.updateClosestLinePointTransform(m.current,y,k),M.updateSelectBox(u.current,y,k),M.updatePointLine(x.current,y,k),M.updateDrawPreview(c.current,y,k,3),M.updateLineBox(h.current,y),g(y.transitionDirection),p(y.transitionRotate)},i);ke(()=>{b.setShape(n||null)},t),ke(()=>{let y=()=>{b.modifiers.reset()};return document.addEventListener("mouseleave",y),()=>{document.removeEventListener("mouseleave",y)}},[]);let S=we(Te,{children:[v("marker",{id:"dot",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:v("circle",{cx:"5",cy:"5",r:"4",className:"marker"})}),v("marker",{id:"selected",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:v("circle",{cx:"5",cy:"5",r:"4",fill:"#FAFF00"})}),v("marker",{id:"resizer",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:v("rect",{width:"10",height:"10",stroke:"#FF0DCB",fill:"#fff",strokeWidth:2})})]}),_=n?n.open?"polyline":"polygon":null,ee=!r.showBoundingBox&&r.closestPoint!==null&&r.actionIntentType==="select-point",Ae=r.actionIntentType==="add-open-point",ze=r.transitionIntentType==="split-line",K=r.transitioning&&r.selectedStamp&&r.transitionIntentType==="stamp-shape",qe=n&&_?we(Te,{children:[v(_,{fill:!r.transitioning&&r.showBoundingBox?"rgba(255, 0, 0, .5)":"none",strokeWidth:K?0:2,stroke:a?"transparent":"#000",points:n.points.map(y=>y.join(",")).join(" "),vectorEffect:"non-scaling-stroke",markerStart:r.showBoundingBox?void 0:"url(#dot)",markerMid:r.showBoundingBox?void 0:"url(#dot)",markerEnd:r.showBoundingBox?void 0:"url(#dot)",style:{pointerEvents:"none"}}),r.lineBoxMode&&r.actionIntentType==="close-line-box"?v("polygon",{fill:"rgba(255, 0, 0, .4)",ref:h,stroke:"#000",strokeWidth:2,vectorEffect:"non-scaling-stroke"}):null,r.transitionIntentType==="draw-shape"&&r.transitioning?v("polyline",{ref:c,fill:"none",stroke:"rgba(255, 0, 0, .5)",strokeWidth:2,vectorEffect:"non-scaling-stroke"}):null,!r.showBoundingBox&&r.selectedPoints&&r.selectedPoints.length?v("polyline",{strokeWidth:2,vectorEffect:"non-scaling-stroke",stroke:"transparent",markerStart:"url(#selected)",markerMid:"url(#selected)",markerEnd:"url(#selected)",fill:"transparent",points:n.points.filter((y,k)=>r.selectedPoints?.includes(k)).map(y=>y.join(",")).join(" ")}):null,ee&&r.closestPoint!==null&&n.points[r.closestPoint]?v("polyline",{strokeWidth:2,vectorEffect:"non-scaling-stroke",stroke:"transparent",markerStart:"url(#selected)",markerMid:"url(#selected)",markerEnd:"url(#selected)",fill:"transparent",points:`${n.points[r.closestPoint][0]},${n.points[r.closestPoint][1]}`}):null,!r.transitioning&&(r.actionIntentType==="add-open-point"||r.actionIntentType==="close-shape"||r.actionIntentType==="close-shape-line")?v("polyline",{stroke:"#000",ref:x,strokeWidth:r.actionIntentType==="close-shape"?2:1,vectorEffect:"non-scaling-stroke"}):null,r.hasClosestLine&&(!r.transitionIntentType||r.transitionIntentType==="split-line")?v("g",{ref:m,children:v("polyline",{style:{opacity:.5},markerStart:"url(#dot)",points:"0,0 10,10",vectorEffect:"non-scaling-stroke",fill:"transparent",strokeWidth:2})}):null,r.transitioning?v(_,{ref:f,fill:n.open?"none":"rgba(255, 0, 0, .5)",stroke:"rgba(255, 0, 0, .5)",strokeWidth:n.open?2:0}):null,r.transitioning&&r.transitionIntentType==="select-multiple-points"?v("rect",{ref:u,fill:"rgba(255, 255, 255, .3)",strokeWidth:1,stroke:"rgba(0,0,0,.2)",vectorEffect:"non-scaling-stroke"}):null,r.showBoundingBox?null:v("g",{name:"controls",children:!1}),r.showBoundingBox&&!K?v("polygon",{ref:s,strokeWidth:2,stroke:"#FF0DCB",fill:"none",markerStart:"url(#resizer)",markerMid:"url(#resizer)",markerEnd:"url(#resizer)",vectorEffect:"non-scaling-stroke"}):null]}):null;return{helper:b,state:r,isAddingPoint:Ae,isSplitting:ze,isStamping:K,isHoveringPoint:ee,transitionDirection:I,transitionRotate:d,defs:S,editor:qe}}import{useEffect as Z}from"react";import{createPortal as St}from"react-dom";import{Fragment as Ee,jsx as H,jsxs as X}from"react/jsx-runtime";var Ct=[{name:"Default",outer:{borderWidth:4,borderColor:"rgba(255, 255, 255, .4)"},inner:{borderWidth:2,borderColor:"#000"}},{name:"High contrast",outer:{borderWidth:3,borderColor:"#fff"},inner:{borderWidth:1,borderColor:"#000"}},{name:"Lightsaber",outer:{borderWidth:"4",borderColor:"rgba(56,68,255,0.64)"},inner:{borderWidth:"2",borderColor:"#fff"}},{name:"Bright",outer:{borderWidth:"6",borderColor:"#25d527"},inner:{borderWidth:"3",borderColor:"#a916ff"}},{name:"pink",outer:{borderWidth:"4",borderColor:"#ff00ff"},inner:{borderWidth:"2",borderColor:"#ffffff"}},{name:"fine (dark)",outer:{borderWidth:"1",borderColor:"#000000"},inner:{}},{name:"fine (light)",outer:{borderWidth:"1",borderColor:"#FFF"},inner:{}}];function Me(e){let t=e.theme||Ct[0],o=bt(),{image:n}=e,{helper:i,defs:a,editor:s,state:l,transitionDirection:u,isSplitting:m,transitionRotate:c,isHoveringPoint:f,isAddingPoint:x,isStamping:h}=Re({currentShape:e.shape||null,onChange:e.updateShape,image:e.image,hideShapeLines:!0},[]),I=r=>{i.pointer([[~~r.atlas.x,~~r.atlas.y]])};Z(()=>{let r=S=>{i.key.up(S.key)};return document.addEventListener("keyup",r),()=>{document.removeEventListener("keyup",r)}},[]),Z(()=>{let r=S=>{i.key.down(S.key)};return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[]),Z(()=>{let r=[];return u&&r.push(`atlas-cursor-${u}`),l.actionIntentType==="cut-line"&&l.modifiers?.Shift&&r.push("atlas-cursor-cut"),(f||l.transitionIntentType==="move-shape"||l.transitionIntentType==="move-point")&&r.push("atlas-cursor-move"),x&&r.push("atlas-cursor-crosshair"),m&&r.push("atlas-cursor-copy"),c&&r.push("atlas-cursor-rotate"),l.transitionIntentType==="draw-shape"&&r.push("atlas-cursor-draw"),o?.canvas&&o.canvas.classList.add(...r),()=>{o?.canvas&&o.canvas.classList.remove(...r)}},[o?.canvas,x,f,m,l.modifiers?.Shift,l.actionIntentType,l.transitionIntentType,u,c]);let g=e.shape&&e.shape?.points.length===0,d=e.renderControls?e.renderControls(i,l,g):null,p=document.getElementById(e.controlsHtmlId||"atlas-controls"),b="shape";return H(Ee,{children:X("world-object",{height:n.height,width:n.width,onMouseMove:I,onMouseDown:i.pointerDown,onMouseUp:i.pointerUp,onMouseLeave:i.blur,children:[e.shape?X(Ee,{children:[H(b,{open:e.shape.open,points:e.shape.points,relativeStyle:!0,style:h?{}:t.outer}),H(b,{open:e.shape.open,points:e.shape.points,relativeStyle:!0,style:h?{}:t.inner})]}):null,X(xt,{relative:!0,interactive:!1,children:[H("div",{style:{position:"absolute",top:0,right:0,left:0,bottom:0},children:X("svg",{width:"100%",height:"100%",viewBox:`0 0 ${n.width} ${n.height}`,tabIndex:-1,children:[H("defs",{children:a}),s]})}),p?St(d,p,"controls"):null]})]})})}import{jsx as Ne}from"react/jsx-runtime";function si(e){let t=T(),o=e.annotationBucket,n=e.readOnly,i=e.id,{onClick:a,isHighlighted:s}=xe(e.id),l=Ce(),u=s?l.highlighted:l[o||"hidden"]||l.hidden;if(!t)return null;if(n){let m="shape",c=e.polygon,f=c.open;return c?Ne(m,{id:`shape-${i}`,points:c.points,open:f,onClick:a,relativeStyle:!0,target:{x:0,y:0,width:t.width,height:t.height},style:u}):null}return Ne(Me,{image:t,shape:e.polygon||{id:e.id,open:!0,points:[]},updateShape:e.updatePolygon,theme:e.theme,controlsHtmlId:e.controlsHtmlId,renderControls:e.renderControls})}import{jsx as It}from"react/jsx-runtime";function ui({annotation:e,children:t}){return It(B,{value:{annotation:e},children:t})}import{jsx as kt}from"react/jsx-runtime";function gi({annotationPage:e,children:t}){return kt(B,{value:{annotationPage:e},children:t})}import{jsx as Pt}from"react/jsx-runtime";function xi({collection:e,children:t}){return Pt(B,{value:{collection:e},children:t})}function Ii(e,t={}){return D(t)}import{useCanvas as Tt}from"@atlas-viewer/atlas";import{useEffect as wt,useMemo as j,useState as Rt}from"react";function Ei({canvasId:e}={}){let t=Tt(),o=ne(),n=j(()=>e?[e]:t?[t.id]:o.map(m=>m.id),[e,t,o]),[i,a]=Rt({}),s=ae();wt(()=>{let m=c=>{let f=c.partOf.canvasId;f&&a(x=>({...x,[f]:c.choice}))};return s.on("choice-change",m),()=>{s.off("choice-change",m)}},[]);let l=j(()=>{let m=[];for(let c of n){let f=i[c];f&&m.push({canvasId:c,choice:f})}return m},[n,i]),u=j(()=>({makeChoice:(m,c)=>{s.emit("make-choice",{choiceId:m,...c})}}),[s]);return{choices:l,actions:u}}function Ni(e,t=!1){}function Ai(e){let o=A().manifest,n=e?e.map(i=>typeof i=="string"?i:i?.id):[];return z(i=>{let a=o?i.iiif.entities.Manifest[o]:void 0,s=a?.items||[];if(typeof e>"u")return s;let l=[];for(let u of a?.items||[])n.indexOf(u.id)!==-1&&l.push(u);return l},[n.join("/")])}import{useMemo as Et}from"react";function Fi(e,t=[]){let{id:o,selector:n}=e,i=A(),a=o||i.collection,s=z(l=>a?l.iiif.entities.Collection[a]:void 0,[a]);return Et(()=>{if(s)return n?n(s):s},[s,n,...t])}import{useEffect as Mt,useMemo as Nt}from"react";import{createEventsHelper as Bt}from"@iiif/helpers/events";function Yi(e,t,o,n,i=[]){let a=P(),s=Nt(()=>Bt(a),[a]);Mt(()=>{let l=e;return l?(s.addEventListener(l,t,o,n),()=>{s.removeEventListener(l,t,o)}):()=>{}},[s,e,t,...i])}function Ui(e,t){let{id:o,isLoaded:n,error:i,resource:a,requestId:s,cached:l}=te(e,t);return{id:o,isLoaded:n,error:i,manifest:a,requestId:s,cached:l}}import{getImageServices as Be}from"@atlas-viewer/iiif-image-api";import{useEffect as Lt,useMemo as Le,useState as Y}from"react";function He({cacheKey:e}={}){let t=T(),o=D(),n=P(),i=W(),[a,s]=Y(void 0),[l,u]=Y(!1),[m,c]=Y("idle"),[f,x]=Y(void 0),h=t?t.id:"undefined",I=Le(()=>{try{if(t&&o.length){let d=o[0],p=n.get(d.body[0]),r=Be(p)[0];return r&&i.loadServiceSync({id:r.id||r["@id"],width:r.width||t.width,height:r.height||t.height})||void 0}}catch(d){console.error(d)}},[h,e,t]),g=m==="success"&&a?a:I;return Lt(()=>{(async()=>{try{if(t&&o.length){let d=o[0],p=n.get(d.body[0]),r=Be(p)[0];if(!r)return;u(!0),c("loading");try{let S=await i.loadService({id:r.id||r["@id"],width:r.width||t.width,height:r.height||t.height})||void 0;s(S),c("success"),u(!1)}catch(S){c("error"),x(S)}}}catch(d){c("error"),x(d)}})()},[h,e]),Le(()=>({data:g,isFetching:l,status:m,error:f}),[g,l,m,f])}function ia(){let e=He();return{isLoading:e.isFetching,tile:e.data?{id:e.data.id||e.data["@id"],width:e.data.width,height:e.data.height,imageService:e.data,thumbnail:void 0}:null}}import{createStylesHelper as Ht}from"@iiif/helpers/styles";import{useMemo as At}from"react";function ma(){let e=P();return At(()=>Ht(e),[e])}export*from"@iiif/helpers/annotation-targets";export{ui as AnnotationContext,gi as AnnotationPageContext,Br as AnnotationStyleProvider,yo as Auth,lo as AuthProvider,io as AuthRContext,ao as AuthReactContext,so as AuthReactContextActions,wn as CanvasAnnotations,oe as CanvasContext,ce as CanvasPanel,xi as CollectionContext,Fn as CombinedMetadata,bn as ComplexTimelineProvider,To as ContextBridge,Me as CreateCustomShape,ko as EventsProvider,Ze as Image,tn as ImageServiceLoaderContext,bo as InnerViewerProvider,Wo as LanguageProvider,Vo as LanguageString,N as LocaleString,Vt as ManifestContext,or as ManifestMetadata,vn as MediaPlayerProvider,O as Metadata,si as PolygonSelector,Yt as RangeContext,Io as ReactEventContext,Dt as ReactVaultContext,vr as RenderSvgEditorControls,B as ResourceProvider,Wt as ResourceReactContext,Tr as SelectorControllerProvider,gr as SequenceThumbnails,So as SimpleViewerProvider,xo as SimpleViewerReactContext,de as SingleCanvasThumbnail,qo as TranslationProvider,Do as TransliterationProvider,Ft as VaultProvider,No as ViewerPresetContext,Mo as VirtualAnnotationProvider,Xt as VisibleCanvasReactContext,oo as authDetailsForResource,eo as createAuthStateStore,to as createProbe,Co as defaultEmitter,Uo as emptyActions,Zo as emptyStrategy,Kt as findAllCanvasesInRange,_t as findFirstCanvasFromRange,Qt as findManifestSelectedRange,Ut as findSelectedRange,jo as flattenAnnotationPageIds,fn as formatTime,rn as get3dStrategy,cn as getComplexTimelineStrategy,Se as getDefaultAnnotationStyles,an as getImageStrategy,Jt as getManifestSequence,Qo as getParsedTargetSelector,mn as getRenderingStrategy,sn as getTextualContentStrategy,ln as getVideoStrategy,Gt as getVisibleCanvasesFromCanvasId,jt as hasAuth,ro as makeAccessServiceRequest,no as makeAccessTokenRequest,Ko as parseSpecificResource,Ct as svgThemes,Go as unknownResponse,Jo as unsupportedStrategy,Ao as useAnnotation,zo as useAnnotationPage,se as useAnnotationPageManager,Ce as useAnnotationStyles,Ii as useAnnotationsAtTime,uo as useAuthActions,po as useAuthService,mo as useAuthStore,ho as useAuthToken,go as useAuthTokens,T as useCanvas,Ei as useCanvasChoices,Ni as useCanvasClock,Zt as useCanvasSequence,xn as useCanvasStartTime,Ai as useCanvasSubset,Xo as useClosestLanguage,Fi as useCollection,Sn as useComplexTimeline,Po as useContextBridge,_o as useCreateLocaleString,fo as useCurrentAuth,wo as useDispatch,ae as useEventEmitter,Yi as useEventListener,Ot as useExistingVault,Ui as useExternalCollection,$t as useExternalManifest,te as useExternalResource,Oo as useIIIFLanguage,Q as useImage,He as useImageService,W as useImageServiceLoader,ia as useImageTile,co as useIsAuthEnabled,on as useLoadImageService,Yo as useLocaleString,q as useManifest,hn as useMediaActions,yn as useMediaElements,gn as useMediaState,nn as usePaintables,D as usePaintingAnnotations,Ie as usePolygonHelper,re as useRange,un as useRenderingStrategy,A as useResourceContext,Lo as useResourceEvents,en as useResources,vo as useSearchService,be as useSelectorController,wr as useSelectorEmitter,xe as useSelectorEvents,Rr as useSelectorHelper,pn as useSimpleMediaPlayer,ie as useSimpleViewer,ma as useStyleHelper,Ho as useStyles,Re as useSvgEditor,le as useThumbnail,$o as useTranslations,Fo as useTransliteration,P as useVault,dn as useVaultEffect,z as useVaultSelector,Bo as useViewerPreset,Ro as useVirtualAnnotationPage,Eo as useVirtualAnnotationPageContext,ne as useVisibleCanvases};
1
+ import{$ as wo,A as to,Aa as on,B as oo,Ba as D,C as no,Ca as nn,D as ro,Da as un,E as io,Ea as dn,F as ao,Fa as le,G as so,Ga as fn,H as lo,Ha as pn,I as co,Ia as gn,J as mo,Ja as hn,K as uo,Ka as yn,L as fo,La as vn,M as po,Ma as xn,N as go,Na as bn,O as ho,Oa as Sn,P as yo,Pa as ce,Q as vo,R as xo,S as bo,T as So,U as ie,V as Co,W as Io,X as ae,Y as ko,Z as Po,_ as To,a as Wt,aa as Ro,b as A,ba as Eo,c as B,ca as Mo,d as Dt,da as No,e as Ft,ea as Bo,f as Ot,fa as T,g as te,ga as Lo,h as $t,ha as Ho,i as Vt,ia as Ao,j as oe,ja as zo,k as P,ka as qo,l as z,la as Wo,m as Xt,ma as Do,n as ne,na as Fo,o as q,oa as Oo,p as Yt,pa as $o,q as _t,qa as Vo,r as Kt,ra as Xo,s as Qt,sa as Yo,t as Ut,ta as _o,u as Gt,ua as N,v as Jt,va as Ko,w as re,wa as W,x as Zt,xa as en,y as jt,ya as se,z as eo,za as tn}from"./chunk-HGERM6K7.js";import{a as Qo,b as Uo,c as Go,d as Jo,e as Zo,f as jo,g as rn,h as an,i as sn,j as ln,k as cn,l as mn}from"./chunk-UFC4ZSNV.js";import{useCanvas as We}from"@atlas-viewer/atlas";import{forwardRef as De,useImperativeHandle as Fe}from"react";import{Fragment as Oe,jsx as me}from"react/jsx-runtime";var wn=De(function({canvasId:t},o){let n=We(),i=se(t||n?.id),a=P();return Fe(o,()=>i,[t,n]),!n||i.enabledPageIds.length===0?null:me(Oe,{children:i.enabledPageIds.map(s=>me(ce.RenderAnnotationPage,{page:a.get(s)},s))})});import{useMemo as Xe}from"react";import{useMemo as $e}from"react";import{Fragment as Ve,jsx as C,jsxs as F}from"react/jsx-runtime";function O({metadata:e=[],config:t,labelWidth:o=16,showEmptyMessage:n=!0,allowHtml:i,emptyFallback:a,classes:s={},emptyMessage:l="No metadata available",emptyValueFallback:u="No value",emptyLabelFallback:m="",separator:c,tableFooter:f,tableHeader:x}){let h=$e(()=>{let g=(t||[]).reduce((p,b)=>[...p,...b.keys],[]),d={};for(let p of e){let b=p&&p.label?Object.values(p.label):[];for(let r of b)if(r&&r.length&&(g.indexOf(`metadata.${r[0]}`)!==-1||g.length===0)&&p){let S=`metadata.${r[0]}`;d[S]=d[S]?d[S]:[],d[S].push(p);break}}return d},[t,e]);return Object.keys(h).length===0&&n?C(Ve,{children:a})||C("div",{className:s.empty,children:l}):t&&t.length?F("table",{className:s.container,children:[x,C("tbody",{children:t.map((g,d)=>{let p=[];for(let b of g.keys)for(let r of h[b]||[])p.push(C(N,{enableDangerouslySetInnerHTML:i,defaultText:u,separator:c,children:r.value},d+"__"+b));return p.length===0?null:F("tr",{className:s.row,children:[C("td",{className:s.label,style:o?{minWidth:o}:{},children:C(N,{enableDangerouslySetInnerHTML:i,separator:c,defaultText:m,children:g.label})}),C("td",{className:s.value,children:p})]},d)})}),f]}):F("table",{className:s.container,children:[x,C("tbody",{children:e&&e.length?e.map((g,d)=>g?F("tr",{className:s.row,children:[C("td",{className:s.label,style:o?{minWidth:o}:{},children:C(N,{enableDangerouslySetInnerHTML:i,defaultText:u,separator:c,children:g.label})}),C("td",{className:s.value,children:C(N,{enableDangerouslySetInnerHTML:i,defaultText:u,separator:c,children:g.value})})]},d):null):null}),f]})}import{jsx as Ye}from"react/jsx-runtime";function Fn(e){let t=q(),o=T(),n=re(),i=Xe(()=>{let a=t?.metadata||[],s=o?.metadata||[],l=n?.metadata||[];return[...a,...s,...l]},[t,o,n]);return Ye(O,{metadata:i,...e})}import{useEffect as Ue,useState as Ge}from"react";import{createImageServiceRequest as _e,imageServiceRequestToString as Ke}from"@atlas-viewer/iiif-image-api";import{useMemo as Qe}from"react";function Q(e,t={},o=[]){return Qe(()=>{if(!e)return null;let n=t.quality;e&&e.extraQualities&&t.quality&&(e.extraQualities.includes(t.quality)||(n="default"));let i=_e(e);return Ke({identifier:i.identifier,server:i.server,scheme:i.scheme,type:"image",size:{max:!t.size?.width&&!t.size?.height,confined:!1,upscaled:!1,...t.size||{}},format:t.format||"jpg",region:t.region||{full:!0},rotation:t?.rotation?Number.isInteger(t.rotation)?{angle:t.rotation}:t.rotation:{angle:0},quality:n||"default",prefix:i.prefix,originalPath:i.originalPath})},[...o])}import{jsx as $}from"react/jsx-runtime";function Je(e){let t=typeof e.src=="string"?e.src:e.src.id,o=W(),[n,i]=Ge(!1),a;if(t){let l=o.loadServiceSync({id:t});l&&(a=l)}!a&&!n&&o.loadService({id:t}).then(()=>{i(!0)});let s=Q(a,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[n,e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return Ue(()=>()=>{i(!1)},[t]),s?$("img",{src:s,alt:e.alt,className:e.className,style:e.style}):$(Ze,{...e,fetchImageService:!1})}function Ze(e){if(e.fetchImageService)return $(Je,{...e});let t=typeof e.src=="string"?{id:e.src,profile:"level0"}:e.src,o=Q(t,{size:e.size,selector:e.region,rotation:e.rotation,format:e.format,region:e.region,quality:e.quality},[e.src,e.size,e.region,e.rotation,e.format,e.region,e.quality]);return o?$("img",{src:o,alt:e.alt,className:e.className,style:e.style}):null}import{jsx as je}from"react/jsx-runtime";function or(e){let t=q();return je(O,{metadata:t?.metadata||[],...e})}import{useLayoutEffect as rt,useRef as it}from"react";import*as U from"react-lazy-load-image-component";import{getValue as et}from"@iiif/helpers/i18n";import{Fragment as ue,jsx as w,jsxs as nt}from"react/jsx-runtime";var{LazyLoadComponent:tt}=U||U.default;function de(e){let{size:t,visible:o,classes:n,canvasId:i,figure:a}=e,s=t?.width||128,l=t?.height||t?.width||128,u=w(ot,{...e}),m=w(tt,{threshold:300,style:{height:l,width:s},visibleByDefault:o,children:i?w(oe,{canvas:i,children:u}):u});return a?w("figure",{className:n?.figure,children:m}):m}function ot({fallback:e,size:t,classes:o,showLabel:n,alt:i,dereference:a=!1}){let s=T(),l=t?.width||128,u=t?.height||t?.width||128,m=i||et(s?.label)||"",c=le({width:l,height:u},a);return!c||c.type!=="fixed"?w(ue,{children:e}):nt(ue,{children:[w("div",{className:o?.imageWrapper,children:w("img",{className:o?.img,src:c.id,alt:m})}),n?w(N,{as:"figcaption",className:o?.label,children:s?.label}):null]})}import{jsx as L}from"react/jsx-runtime";function gr({flat:e,size:t,classes:o={},showLabel:n,figure:i,fallback:a}){let s=it(null),{items:l,sequence:u,currentSequenceIndex:m,setSequenceIndex:c}=ie(),f={row:o.selected?.row||o.row,item:o.selected?.item||o.item,figure:o.selected?.figure||o.figure,img:o.selected?.img||o.img,label:o.selected?.label||o.label,imageWrapper:o.selected?.imageWrapper||o.imageWrapper};rt(()=>{if(!s.current)return;let h=s.current.querySelector("[data-selected=true]");h&&h.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},[m]);let x=[];for(let h of u){let I=[],g=u[m]===h;for(let d of h){let p=l[d];I.push(L("div",{className:g?f.item:o.item,children:L(de,{classes:g?f:o,canvasId:p.id,size:t,showLabel:n,figure:i,placeholder:L("div",{style:{height:128,width:128}}),fallback:a})},d))}if(e){x.push(I);continue}x.push(L("div",{onClick:d=>{c(u.indexOf(h))},"data-selected":g,className:g?f.row:o.row,children:I},h.join("-")))}return L("div",{ref:s,className:o.container,children:x})}import{Fragment as fe,jsx as R,jsxs as pe}from"react/jsx-runtime";var at={draw:!0,polygon:!0,line:!0,lineBox:!0,square:!0,triangle:!0,hexagon:!0,circle:!0,delete:!0};function vr({helper:e,showShapes:t,state:o,enabled:n=at,classNames:i={},icons:a={}}){return pe(fe,{children:[t?pe(fe,{children:[n.draw&&R("button",{className:i.button,onClick:()=>{e.stamps.clear(),e.draw.enable()},"data-active":!o.lineMode&&!o.selectedStamp&&t&&o.drawMode,children:a.DrawIcon||"Draw"}),n.polygon&&R("button",{className:i.button,"data-active":!o.lineMode&&!o.selectedStamp&&t&&!o.drawMode,onClick:()=>{e.stamps.clear(),e.draw.disable(),e.modes.disableLineBoxMode(),e.modes.disableLineMode()},children:a.PolygonIcon||"Polygon"}),n.line&&R("button",{className:i.button,"data-active":o.lineMode&&!o.lineBoxMode,onClick:()=>{e.modes.enableLineMode()},children:a.LineIcon||"Line"}),n.lineBox&&R("button",{className:i.button,"data-active":o.lineBoxMode,onClick:()=>{e.modes.enableLineBoxMode()},children:a.LineBoxIcon||"LineBox"}),n.square&&R("button",{className:i.button,"data-active":o.selectedStamp?.id==="square",onClick:()=>{e.stamps.square()},children:a.SquareIcon||"Square"}),n.triangle&&R("button",{className:i.button,"data-active":o.selectedStamp?.id==="triangle",onClick:()=>{e.stamps.triangle()},children:a.TriangleIcon||"Triangle"}),n.hexagon&&R("button",{className:i.button,"data-active":o.selectedStamp?.id==="hexagon",onClick:()=>{e.stamps.hexagon()},children:a.HexagonIcon||"Hexagon"})]}):null,o.showBoundingBox&&n.delete&&R("button",{className:i.button,onClick:()=>e.key.down("Backspace"),children:a.DeleteForeverIcon||"Delete"})]})}import{createContext as st,useCallback as ge,useContext as ye,useEffect as he,useMemo as G,useState as lt}from"react";import ve from"mitt";import{jsx as ct}from"react/jsx-runtime";var V=st(ve());V.displayName="SelectorHelper";function Tr({children:e}){return ct(V.Provider,{value:G(()=>ve(),[]),children:e})}function wr(){return ye(V)}function xe(e){let t=be(),[o,n]=lt(!1);he(()=>t.withSelector(e).on("highlight",()=>{n(!0)}),[t,e]),he(()=>t.withSelector(e).on("clear-highlight",()=>{n(!1)}),[t,e]);let i=ge(s=>{t.emit("click",{selectorId:e,event:s})},[e,t]),a=ge(s=>{t.emit("hover",{selectorId:e,event:s})},[e,t]);return{controller:t,onClick:i,onHover:a,isHighlighted:o}}function be(){let e=ye(V);return G(()=>({withSelector(t){return{on(o,n){let i=a=>{a&&a.selectorId===t&&n(a)};return e.on(o,i),()=>{e.off(o,i)}},emit(o,n){e.emit(o,{...n,selectorId:t})}}},on(t,o){return e.on(t,o),()=>{e.off(t,o)}},emit(t,o){e.emit(t,o)}}),[e])}function Rr(){let e=be();return G(()=>({withSelector(t){return{highlight(){e.emit("highlight",{selectorId:t})},clearHighlight(){e.emit("clear-highlight",{selectorId:t})},zoomTo(){e.emit("zoom-to",{selectorId:t})},addEventListener(o,n){return e.emit("event-listener",{selectorId:t,name:o,callback:n}),()=>{e.emit("remove-event-listener",{selectorId:t,name:o,callback:n})}},getImagePreview(){return new Promise((o,n)=>{e.emit("image-preview-request",{selectorId:t,resolve:o,reject:n})})},on(o,n){return e.withSelector(t).on(o,n)}}},highlight(t){e.emit("highlight",{selectorId:t})},clearHighlight(t){e.emit("clear-highlight",{selectorId:t})},zoomTo(t){e.emit("zoom-to",{selectorId:t})},addEventListener(t,o,n){return e.emit("event-listener",{selectorId:t,name:o,callback:n}),()=>{e.emit("remove-event-listener",{selectorId:t,name:o,callback:n})}},getImagePreview(t){return new Promise((o,n)=>{e.emit("image-preview-request",{selectorId:t,resolve:o,reject:n})})},on(t,o){return e.on(t,o)}}),[e])}import{createContext as mt,useContext as ut,useMemo as dt}from"react";import{jsx as ft}from"react/jsx-runtime";function Se(){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 J=mt(Se());J.displayName="AnnotationStyle";function Ce(){return ut(J)}function Br({theme:e,children:t}){let o=dt(()=>e||Se(),[e]);return ft(J.Provider,{value:o,children:t})}import{HTMLPortal as xt,useAtlas as bt}from"@atlas-viewer/atlas";import{useEffect as ke,useRef as E,useState as Pe}from"react";import{useEffect as pt,useMemo as gt,useState as ht}from"react";import{createHelper as yt}from"polygon-editor";function Ie(e,t,o){let[n,i]=ht({}),a=gt(()=>yt(e,o),[]);return pt(()=>(a.clock.start(t,i),()=>{a.clock.stop()}),[]),{state:n,helper:a}}import{createSvgHelpers as vt}from"polygon-editor";import{Fragment as Te,jsx as v,jsxs as we}from"react/jsx-runtime";var M=vt();function Re(e,t){let{image:o,currentShape:n,onChange:i,hideShapeLines:a}=e,s=E(),l=E(),u=E(),m=E(),c=E(),f=E(),x=E(),h=E(),[I,g]=Pe(null),[d,p]=Pe(!1),{helper:b,state:r}=Ie(n,(y,k)=>{M.updateTransitionBoundingBox(l.current,y,k),M.updateBoundingBoxPolygon(s.current,y,k),M.updateTransitionShape(f.current,y,k),M.updateClosestLinePointTransform(m.current,y,k),M.updateSelectBox(u.current,y,k),M.updatePointLine(x.current,y,k),M.updateDrawPreview(c.current,y,k,3),M.updateLineBox(h.current,y),g(y.transitionDirection),p(y.transitionRotate)},i);ke(()=>{b.setShape(n||null)},t),ke(()=>{let y=()=>{b.modifiers.reset()};return document.addEventListener("mouseleave",y),()=>{document.removeEventListener("mouseleave",y)}},[]);let S=we(Te,{children:[v("marker",{id:"dot",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:v("circle",{cx:"5",cy:"5",r:"4",className:"marker"})}),v("marker",{id:"selected",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:v("circle",{cx:"5",cy:"5",r:"4",fill:"#FAFF00"})}),v("marker",{id:"resizer",viewBox:"0 0 10 10",refX:"5",refY:"5",markerWidth:"5",markerHeight:"5",children:v("rect",{width:"10",height:"10",stroke:"#FF0DCB",fill:"#fff",strokeWidth:2})})]}),_=n?n.open?"polyline":"polygon":null,ee=!r.showBoundingBox&&r.closestPoint!==null&&r.actionIntentType==="select-point",Ae=r.actionIntentType==="add-open-point",ze=r.transitionIntentType==="split-line",K=r.transitioning&&r.selectedStamp&&r.transitionIntentType==="stamp-shape",qe=n&&_?we(Te,{children:[v(_,{fill:!r.transitioning&&r.showBoundingBox?"rgba(255, 0, 0, .5)":"none",strokeWidth:K?0:2,stroke:a?"transparent":"#000",points:n.points.map(y=>y.join(",")).join(" "),vectorEffect:"non-scaling-stroke",markerStart:r.showBoundingBox?void 0:"url(#dot)",markerMid:r.showBoundingBox?void 0:"url(#dot)",markerEnd:r.showBoundingBox?void 0:"url(#dot)",style:{pointerEvents:"none"}}),r.lineBoxMode&&r.actionIntentType==="close-line-box"?v("polygon",{fill:"rgba(255, 0, 0, .4)",ref:h,stroke:"#000",strokeWidth:2,vectorEffect:"non-scaling-stroke"}):null,r.transitionIntentType==="draw-shape"&&r.transitioning?v("polyline",{ref:c,fill:"none",stroke:"rgba(255, 0, 0, .5)",strokeWidth:2,vectorEffect:"non-scaling-stroke"}):null,!r.showBoundingBox&&r.selectedPoints&&r.selectedPoints.length?v("polyline",{strokeWidth:2,vectorEffect:"non-scaling-stroke",stroke:"transparent",markerStart:"url(#selected)",markerMid:"url(#selected)",markerEnd:"url(#selected)",fill:"transparent",points:n.points.filter((y,k)=>r.selectedPoints?.includes(k)).map(y=>y.join(",")).join(" ")}):null,ee&&r.closestPoint!==null&&n.points[r.closestPoint]?v("polyline",{strokeWidth:2,vectorEffect:"non-scaling-stroke",stroke:"transparent",markerStart:"url(#selected)",markerMid:"url(#selected)",markerEnd:"url(#selected)",fill:"transparent",points:`${n.points[r.closestPoint][0]},${n.points[r.closestPoint][1]}`}):null,!r.transitioning&&(r.actionIntentType==="add-open-point"||r.actionIntentType==="close-shape"||r.actionIntentType==="close-shape-line")?v("polyline",{stroke:"#000",ref:x,strokeWidth:r.actionIntentType==="close-shape"?2:1,vectorEffect:"non-scaling-stroke"}):null,r.hasClosestLine&&(!r.transitionIntentType||r.transitionIntentType==="split-line")?v("g",{ref:m,children:v("polyline",{style:{opacity:.5},markerStart:"url(#dot)",points:"0,0 10,10",vectorEffect:"non-scaling-stroke",fill:"transparent",strokeWidth:2})}):null,r.transitioning?v(_,{ref:f,fill:n.open?"none":"rgba(255, 0, 0, .5)",stroke:"rgba(255, 0, 0, .5)",strokeWidth:n.open?2:0}):null,r.transitioning&&r.transitionIntentType==="select-multiple-points"?v("rect",{ref:u,fill:"rgba(255, 255, 255, .3)",strokeWidth:1,stroke:"rgba(0,0,0,.2)",vectorEffect:"non-scaling-stroke"}):null,r.showBoundingBox?null:v("g",{name:"controls",children:!1}),r.showBoundingBox&&!K?v("polygon",{ref:s,strokeWidth:2,stroke:"#FF0DCB",fill:"none",markerStart:"url(#resizer)",markerMid:"url(#resizer)",markerEnd:"url(#resizer)",vectorEffect:"non-scaling-stroke"}):null]}):null;return{helper:b,state:r,isAddingPoint:Ae,isSplitting:ze,isStamping:K,isHoveringPoint:ee,transitionDirection:I,transitionRotate:d,defs:S,editor:qe}}import{useEffect as Z}from"react";import{createPortal as St}from"react-dom";import{Fragment as Ee,jsx as H,jsxs as X}from"react/jsx-runtime";var Ct=[{name:"Default",outer:{borderWidth:4,borderColor:"rgba(255, 255, 255, .4)"},inner:{borderWidth:2,borderColor:"#000"}},{name:"High contrast",outer:{borderWidth:3,borderColor:"#fff"},inner:{borderWidth:1,borderColor:"#000"}},{name:"Lightsaber",outer:{borderWidth:"4",borderColor:"rgba(56,68,255,0.64)"},inner:{borderWidth:"2",borderColor:"#fff"}},{name:"Bright",outer:{borderWidth:"6",borderColor:"#25d527"},inner:{borderWidth:"3",borderColor:"#a916ff"}},{name:"pink",outer:{borderWidth:"4",borderColor:"#ff00ff"},inner:{borderWidth:"2",borderColor:"#ffffff"}},{name:"fine (dark)",outer:{borderWidth:"1",borderColor:"#000000"},inner:{}},{name:"fine (light)",outer:{borderWidth:"1",borderColor:"#FFF"},inner:{}}];function Me(e){let t=e.theme||Ct[0],o=bt(),{image:n}=e,{helper:i,defs:a,editor:s,state:l,transitionDirection:u,isSplitting:m,transitionRotate:c,isHoveringPoint:f,isAddingPoint:x,isStamping:h}=Re({currentShape:e.shape||null,onChange:e.updateShape,image:e.image,hideShapeLines:!0},[]),I=r=>{i.pointer([[~~r.atlas.x,~~r.atlas.y]])};Z(()=>{let r=S=>{i.key.up(S.key)};return document.addEventListener("keyup",r),()=>{document.removeEventListener("keyup",r)}},[]),Z(()=>{let r=S=>{i.key.down(S.key)};return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[]),Z(()=>{let r=[];return u&&r.push(`atlas-cursor-${u}`),l.actionIntentType==="cut-line"&&l.modifiers?.Shift&&r.push("atlas-cursor-cut"),(f||l.transitionIntentType==="move-shape"||l.transitionIntentType==="move-point")&&r.push("atlas-cursor-move"),x&&r.push("atlas-cursor-crosshair"),m&&r.push("atlas-cursor-copy"),c&&r.push("atlas-cursor-rotate"),l.transitionIntentType==="draw-shape"&&r.push("atlas-cursor-draw"),o?.canvas&&o.canvas.classList.add(...r),()=>{o?.canvas&&o.canvas.classList.remove(...r)}},[o?.canvas,x,f,m,l.modifiers?.Shift,l.actionIntentType,l.transitionIntentType,u,c]);let g=e.shape&&e.shape?.points.length===0,d=e.renderControls?e.renderControls(i,l,g):null,p=document.getElementById(e.controlsHtmlId||"atlas-controls"),b="shape";return H(Ee,{children:X("world-object",{height:n.height,width:n.width,onMouseMove:I,onMouseDown:i.pointerDown,onMouseUp:i.pointerUp,onMouseLeave:i.blur,children:[e.shape?X(Ee,{children:[H(b,{open:e.shape.open,points:e.shape.points,relativeStyle:!0,style:h?{}:t.outer}),H(b,{open:e.shape.open,points:e.shape.points,relativeStyle:!0,style:h?{}:t.inner})]}):null,X(xt,{relative:!0,interactive:!1,children:[H("div",{style:{position:"absolute",top:0,right:0,left:0,bottom:0},children:X("svg",{width:"100%",height:"100%",viewBox:`0 0 ${n.width} ${n.height}`,tabIndex:-1,children:[H("defs",{children:a}),s]})}),p?St(d,p,"controls"):null]})]})})}import{jsx as Ne}from"react/jsx-runtime";function si(e){let t=T(),o=e.annotationBucket,n=e.readOnly,i=e.id,{onClick:a,isHighlighted:s}=xe(e.id),l=Ce(),u=s?l.highlighted:l[o||"hidden"]||l.hidden;if(!t)return null;if(n){let m="shape",c=e.polygon,f=c.open;return c?Ne(m,{id:`shape-${i}`,points:c.points,open:f,onClick:a,relativeStyle:!0,target:{x:0,y:0,width:t.width,height:t.height},style:u}):null}return Ne(Me,{image:t,shape:e.polygon||{id:e.id,open:!0,points:[]},updateShape:e.updatePolygon,theme:e.theme,controlsHtmlId:e.controlsHtmlId,renderControls:e.renderControls})}import{jsx as It}from"react/jsx-runtime";function ui({annotation:e,children:t}){return It(B,{value:{annotation:e},children:t})}import{jsx as kt}from"react/jsx-runtime";function gi({annotationPage:e,children:t}){return kt(B,{value:{annotationPage:e},children:t})}import{jsx as Pt}from"react/jsx-runtime";function xi({collection:e,children:t}){return Pt(B,{value:{collection:e},children:t})}function Ii(e,t={}){return D(t)}import{useCanvas as Tt}from"@atlas-viewer/atlas";import{useEffect as wt,useMemo as j,useState as Rt}from"react";function Ei({canvasId:e}={}){let t=Tt(),o=ne(),n=j(()=>e?[e]:t?[t.id]:o.map(m=>m.id),[e,t,o]),[i,a]=Rt({}),s=ae();wt(()=>{let m=c=>{let f=c.partOf.canvasId;f&&a(x=>({...x,[f]:c.choice}))};return s.on("choice-change",m),()=>{s.off("choice-change",m)}},[]);let l=j(()=>{let m=[];for(let c of n){let f=i[c];f&&m.push({canvasId:c,choice:f})}return m},[n,i]),u=j(()=>({makeChoice:(m,c)=>{s.emit("make-choice",{choiceId:m,...c})}}),[s]);return{choices:l,actions:u}}function Ni(e,t=!1){}function Ai(e){let o=A().manifest,n=e?e.map(i=>typeof i=="string"?i:i?.id):[];return z(i=>{let a=o?i.iiif.entities.Manifest[o]:void 0,s=a?.items||[];if(typeof e>"u")return s;let l=[];for(let u of a?.items||[])n.indexOf(u.id)!==-1&&l.push(u);return l},[n.join("/")])}import{useMemo as Et}from"react";function Fi(e,t=[]){let{id:o,selector:n}=e,i=A(),a=o||i.collection,s=z(l=>a?l.iiif.entities.Collection[a]:void 0,[a]);return Et(()=>{if(s)return n?n(s):s},[s,n,...t])}import{useEffect as Mt,useMemo as Nt}from"react";import{createEventsHelper as Bt}from"@iiif/helpers/events";function Yi(e,t,o,n,i=[]){let a=P(),s=Nt(()=>Bt(a),[a]);Mt(()=>{let l=e;return l?(s.addEventListener(l,t,o,n),()=>{s.removeEventListener(l,t,o)}):()=>{}},[s,e,t,...i])}function Ui(e,t){let{id:o,isLoaded:n,error:i,resource:a,requestId:s,cached:l}=te(e,t);return{id:o,isLoaded:n,error:i,manifest:a,requestId:s,cached:l}}import{getImageServices as Be}from"@atlas-viewer/iiif-image-api";import{useEffect as Lt,useMemo as Le,useState as Y}from"react";function He({cacheKey:e}={}){let t=T(),o=D(),n=P(),i=W(),[a,s]=Y(void 0),[l,u]=Y(!1),[m,c]=Y("idle"),[f,x]=Y(void 0),h=t?t.id:"undefined",I=Le(()=>{try{if(t&&o.length){let d=o[0],p=n.get(d.body[0]),r=Be(p)[0];return r&&i.loadServiceSync({id:r.id||r["@id"],width:r.width||t.width,height:r.height||t.height})||void 0}}catch(d){console.error(d)}},[h,e,t]),g=m==="success"&&a?a:I;return Lt(()=>{(async()=>{try{if(t&&o.length){let d=o[0],p=n.get(d.body[0]),r=Be(p)[0];if(!r)return;u(!0),c("loading");try{let S=await i.loadService({id:r.id||r["@id"],width:r.width||t.width,height:r.height||t.height})||void 0;s(S),c("success"),u(!1)}catch(S){c("error"),x(S)}}}catch(d){c("error"),x(d)}})()},[h,e]),Le(()=>({data:g,isFetching:l,status:m,error:f}),[g,l,m,f])}function ia(){let e=He();return{isLoading:e.isFetching,tile:e.data?{id:e.data.id||e.data["@id"],width:e.data.width,height:e.data.height,imageService:e.data,thumbnail:void 0}:null}}import{createStylesHelper as Ht}from"@iiif/helpers/styles";import{useMemo as At}from"react";function ma(){let e=P();return At(()=>Ht(e),[e])}export*from"@iiif/helpers/annotation-targets";export{ui as AnnotationContext,gi as AnnotationPageContext,Br as AnnotationStyleProvider,yo as Auth,lo as AuthProvider,io as AuthRContext,ao as AuthReactContext,so as AuthReactContextActions,wn as CanvasAnnotations,oe as CanvasContext,ce as CanvasPanel,xi as CollectionContext,Fn as CombinedMetadata,bn as ComplexTimelineProvider,To as ContextBridge,Me as CreateCustomShape,ko as EventsProvider,Ze as Image,Ko as ImageServiceLoaderContext,bo as InnerViewerProvider,Wo as LanguageProvider,Vo as LanguageString,N as LocaleString,Vt as ManifestContext,or as ManifestMetadata,vn as MediaPlayerProvider,O as Metadata,si as PolygonSelector,Yt as RangeContext,Io as ReactEventContext,Dt as ReactVaultContext,vr as RenderSvgEditorControls,B as ResourceProvider,Wt as ResourceReactContext,Tr as SelectorControllerProvider,gr as SequenceThumbnails,So as SimpleViewerProvider,xo as SimpleViewerReactContext,de as SingleCanvasThumbnail,qo as TranslationProvider,Do as TransliterationProvider,Ft as VaultProvider,No as ViewerPresetContext,Mo as VirtualAnnotationProvider,Xt as VisibleCanvasReactContext,oo as authDetailsForResource,eo as createAuthStateStore,to as createProbe,Co as defaultEmitter,Go as emptyActions,jo as emptyStrategy,Kt as findAllCanvasesInRange,_t as findFirstCanvasFromRange,Qt as findManifestSelectedRange,Ut as findSelectedRange,en as flattenAnnotationPageIds,fn as formatTime,rn as get3dStrategy,cn as getComplexTimelineStrategy,Se as getDefaultAnnotationStyles,an as getImageStrategy,Jt as getManifestSequence,Uo as getParsedTargetSelector,mn as getRenderingStrategy,sn as getTextualContentStrategy,ln as getVideoStrategy,Gt as getVisibleCanvasesFromCanvasId,jt as hasAuth,ro as makeAccessServiceRequest,no as makeAccessTokenRequest,Qo as parseSpecificResource,Ct as svgThemes,Jo as unknownResponse,Zo as unsupportedStrategy,Ao as useAnnotation,zo as useAnnotationPage,se as useAnnotationPageManager,Ce as useAnnotationStyles,Ii as useAnnotationsAtTime,uo as useAuthActions,po as useAuthService,mo as useAuthStore,ho as useAuthToken,go as useAuthTokens,T as useCanvas,Ei as useCanvasChoices,Ni as useCanvasClock,Zt as useCanvasSequence,xn as useCanvasStartTime,Ai as useCanvasSubset,Xo as useClosestLanguage,Fi as useCollection,Sn as useComplexTimeline,Po as useContextBridge,_o as useCreateLocaleString,fo as useCurrentAuth,wo as useDispatch,ae as useEventEmitter,Yi as useEventListener,Ot as useExistingVault,Ui as useExternalCollection,$t as useExternalManifest,te as useExternalResource,Oo as useIIIFLanguage,Q as useImage,He as useImageService,W as useImageServiceLoader,ia as useImageTile,co as useIsAuthEnabled,on as useLoadImageService,Yo as useLocaleString,q as useManifest,hn as useMediaActions,yn as useMediaElements,gn as useMediaState,nn as usePaintables,D as usePaintingAnnotations,Ie as usePolygonHelper,re as useRange,un as useRenderingStrategy,A as useResourceContext,Lo as useResourceEvents,tn as useResources,vo as useSearchService,be as useSelectorController,wr as useSelectorEmitter,xe as useSelectorEvents,Rr as useSelectorHelper,pn as useSimpleMediaPlayer,ie as useSimpleViewer,ma as useStyleHelper,Ho as useStyles,Re as useSvgEditor,le as useThumbnail,$o as useTranslations,Fo as useTransliteration,P as useVault,dn as useVaultEffect,z as useVaultSelector,Bo as useViewerPreset,Ro as useVirtualAnnotationPage,Eo as useVirtualAnnotationPageContext,ne as useVisibleCanvases};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-iiif-vault",
3
- "version": "1.3.4",
3
+ "version": "1.3.6",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -1,48 +0,0 @@
1
- import{c as ht,l as yt}from"./chunk-UFC4ZSNV.js";import{forwardRef as er,useImperativeHandle as Li}from"react";import un,{useCallback as tt,useMemo as cn,useState as Re}from"react";import{AtlasAuto as vo,ModeContext as ho}from"@atlas-viewer/atlas";import{ErrorBoundary as yo}from"react-error-boundary";import{useContext as W}from"react";import nr,{useContext as rr,useMemo as or}from"react";import{jsx as ar}from"react/jsx-runtime";var ir={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0,annotationPage:void 0},Ce=nr.createContext(ir),H=()=>rr(Ce);function K({value:e,children:n}){let t=H(),r=or(()=>({...t,...e}),[e,t]);return ar(Ce.Provider,{value:r,children:n})}import sr,{useState as ur}from"react";import{Vault as xt,globalVault as cr}from"@iiif/helpers/vault";import{jsx as St}from"react/jsx-runtime";var Q=sr.createContext({vault:null,setVaultInstance:e=>{}});function J({vault:e,vaultOptions:n,useGlobal:t,resources:r,children:o}){let[s,i]=ur(()=>e||(t?cr(n):n?new xt(n):new xt));return St(Q.Provider,{value:{vault:s,setVaultInstance:i},children:St(K,{value:r||{},children:o})})}import{useContext as qr}from"react";import{createContext as Br,useMemo as _r}from"react";import{globalVault as lr}from"@iiif/helpers/vault";import{useContext as dr}from"react";function X(e){let n=dr(Q);return e||(n&&n.vault?n.vault:lr())}import{useEffect as mr,useMemo as fr,useState as Be}from"react";function Ct(e,{noCache:n=!1}={}){let t=typeof e=="string"?e:e.id,r=X(),[o,s]=Be(t),[i,a]=Be(void 0),u=fr(()=>r.get(t,{skipSelfReturn:!0})||void 0,[t,r]),[c,l]=Be(u);return mr(()=>{(async()=>{try{let d=u&&!n?u:await r.load(t),y=d?d.id||d["@id"]:null;d&&o!==y&&s(y),l(d)}catch(d){a(d)}})()},[t,n]),{isLoaded:!!c,id:o,requestId:t,error:i,resource:c,cached:!!(c&&c===u)}}function At(e,n){let{id:t,isLoaded:r,error:o,resource:s,requestId:i,cached:a}=Ct(e,n);return{id:t,isLoaded:r,error:o,manifest:s,requestId:i,cached:a}}import{jsx as pr}from"react/jsx-runtime";function bt({manifest:e,children:n}){return pr(K,{value:{manifest:e},children:n})}import{jsx as gr}from"react/jsx-runtime";function q({canvas:e,children:n}){return gr(K,{value:{canvas:e},children:n})}import{useContext as xr}from"react";import Sr from"react";import{useContext as vr}from"react";var R=()=>{let{vault:e}=vr(Q);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};import{useEffect as hr,useState as yr}from"react";function T(e,n=[]){let t=R(),[r,o]=yr(()=>e(t.getState(),t));return hr(()=>t.subscribe(s=>e(s,t),s=>{o(s)},!1),n),r}var ee=Sr.createContext([]);function Ae(){let e=xr(ee);return T(n=>e.map(t=>n.iiif.entities.Canvas[t]).filter(Boolean),[e])}import{useMemo as Cr}from"react";function E(e={},n=[]){let{id:t,selector:r}=e,o=H(),s=R(),i=t||o.manifest,a=T(u=>i?u.iiif.entities.Manifest[i]:void 0,[i]);return Cr(()=>{if(a)return r?r(a):a},[a,r,...n])}import{jsx as Ar}from"react/jsx-runtime";function Pt({range:e,children:n}){return Ar(K,{value:{range:e},children:n})}function br(e,n){for(let t of n.items){if(t.type==="Canvas")return t;if(t.type==="SpecificResource")return t.source;if(t.type==="Range"){let r=br(e,e.get(t));if(r)return r}}return null}function _e(e,n){let t=[];for(let r of n.items)if(r.type==="SpecificResource"&&r.source?.type==="Canvas"&&(r.source.id.indexOf("#")!==-1?t.push({id:r.source.id.split("#")[0],type:"Canvas"}):t.push(r.source)),r.type==="Range"&&t.push(..._e(e,e.get(r))),r.type==="SpecificResource"){let o=typeof r.source=="string"?r.source:r.source.id;t.push({id:o,type:"Canvas"})}return t}function La(e,n,t){for(let r of n.structures){let o=Rt(e,e.get(r),t);if(o)return o}return null}function Rt(e,n,t){for(let r of n.items){let o=r?.source?.id?.split("#")[0];if(r.type==="SpecificResource"&&r.source===t||r.type==="SpecificResource"&&r.source?.type==="Canvas"&&t===o)return n;if(r.type==="Range"){let s=Rt(e,e.get(r),t);if(s)return s}}return null}function Ha(e,n,t,r=!1){let o=n.behavior,s=t?e.get(t):null;if(!s)return[];let i=s.behavior,a=r?!1:o.includes("paged"),u=a?!1:o.includes("continuous"),c=a||u?!1:o.includes("individuals"),l=i.includes("facing-pages"),d=i.includes("non-paged");if(l||d||c||r)return[{id:s.id,type:"Canvas"}];let[y,A]=je(e,n);if(u)return y;let h=y.findIndex(g=>g.id===t);if(h===-1)return[];for(let g of A)if(g.includes(h))return g.map(b=>y[b]);return[{id:s.id,type:"Canvas"}]}function je(e,n,{disablePaging:t,skipNonPaged:r}={}){let o=n.behavior,s=o.includes("paged"),i=s?!1:o.includes("continuous"),a=s||i?!1:o.includes("individuals"),u=n.type==="Manifest"?n.items:_e(e,n);if(i)return[u,[u.map((h,g)=>g)]];if(a||!s||t)return[u,u.map((h,g)=>[g])];let c=[],l=[],d=()=>{l.length&&(c.push([...l]),l=[])},y=0,A=!1;for(let h=0;h<u.length;h++){let g=e.get(u[h]);if(g.behavior.includes("non-paged")){h===y&&y++,r||(d(),c.push([h]),d());continue}if(h===y||g.behavior.includes("facing-pages")){l.length&&(A=!0),d(),c.push([h]),d();continue}if(l.push(h),A){d(),A=!1;continue}l.length>1&&d()}return l.length&&d(),[u,c]}import{useCallback as be,useMemo as Rr,useRef as Tr,useState as Ir}from"react";import{useMemo as Pr}from"react";function Tt(e={},n=[]){let{id:t,selector:r}=e,o=H(),s=t||o.range,i=T(a=>s?a.iiif.entities.Range[s]:void 0,[s]);return Pr(()=>{if(i)return r?r(i):i},[i,r,...n])}function It({startCanvas:e,disablePaging:n}){let t=R(),r=E(),o=Tt(),[s,i]=Ir(void 0),a=o||r;if(!a)throw new Error("Nothing selected");let[u,c]=Rr(()=>je(t,a,{disablePaging:n}),[t,a,n]),l=Tr(c);if(l.current!==c){let b=l.current[s][0],p=c.findIndex(S=>S.includes(b));l.current=c,i(p)}let d=be(g=>{let b=c.findIndex(p=>p.includes(g));i(b===-1?0:b)},[u,c]),y=be(g=>{let b=u.findIndex(p=>p.id===g);b!==-1?d(b):i(0)},[u,c]),A=be(()=>{i(g=>g>=c.length-1?g:g+1)},[c]),h=be(()=>{i(g=>g<=0?0:g-1)},[c]);return typeof s>"u"&&(e?y(e):i(0)),{visibleItems:c[s]?.map(g=>u[g].id)||[],cursor:s,items:u,sequence:c,hasPrevious:s>0,hasNext:s<c.length-1,setSequenceIndex:i,setCanvasIndex:d,setCanvasId:y,next:A,previous:h}}import{createContext as Qe,useContext as Ft,useEffect as wr,useMemo as Er}from"react";import{useStore as de}from"zustand";import{createStore as wt}from"zustand/vanilla";function Ga(e){let n=e.service||e.services||[];for(let t of n)if(t.type==="AuthProbeService2")return!0;return!1}function F(e,n,t){let r=n.findIndex(i=>i.service.id===e);if(r===-1)return n;let o=[...n],s=t(o[r]);return s===o[r]?n:(o[r]=s,o)}var Et=()=>wt((e,n)=>({currentAuth:-1,authItems:[],login:()=>{let t=n().authItems[n().currentAuth];if(!t||t.isPending||t.isLoggedIn)return;if(t.type!=="active")throw new Error("Cannot login to non-active service");let r=t.service.service.find(o=>o.type==="AuthAccessTokenService2");if(!r)throw new Error("Token service not found");e(()=>({authItems:F(t.id,n().authItems,o=>({...o,isPending:!0}))})),Mt(t.service).then(()=>{Ke(r).then(o=>{let s=o.expiresIn,i=Date.now()+s*1e3;e(()=>({authItems:F(t.id,n().authItems,a=>({...a,isLoggedIn:!0,isPending:!1,session:{token:o.accessToken,expires:i}}))}))}).catch(o=>{e(()=>({authItems:F(t.id,n().authItems,s=>({...s,isLoggedIn:!1,isPending:!1,error:o.message}))}))})})},logout:()=>{let t=n().authItems[n().currentAuth];if(!t||t.isPending||!t.isLoggedIn)return;if(t.type!=="active")throw new Error("Cannot logout of non-active service");let r=t.service.service.find(i=>i.type==="AuthLogoutService2");if(!r)return;let o=`${r.id}?origin=${Nt()}`,s=window.open(o);e(()=>({authItems:F(t.id,n().authItems,i=>({...i,isLoggedIn:!1,session:null,isPending:!1}))}))},nextAuth:()=>{let t=n().authItems.length,r=n().currentAuth+1;r>=t||e(()=>({currentAuth:r}))},previousAuth:()=>{let t=n().currentAuth-1;t<0||e(()=>({currentAuth:t}))},setAuth:t=>{t!==-1&&(t<0||t>=n().authItems.length)||e(()=>({currentAuth:t}))},addService:(t,r)=>{if(!t.service)return;let o=t.service.find(a=>a.type==="AuthAccessTokenService2"),s=t;if(n().authItems.find(a=>a.service.id===t.id)){e(()=>({authItems:F(t.id,n().authItems,a=>({...a,instances:a.instances+1}))}));return}if(e(()=>({currentAuth:s.profile==="active"?0:n().currentAuth,authItems:[{id:t.id,type:t.profile,service:t,probeId:r,canAuthenticate:!0,instances:1,isPending:!1,isLoggedIn:!1,session:null},...n().authItems]})),t.profile==="external"){if(!o)throw new Error("Token service not found");Ke(o).then(a=>{e(()=>({authItems:F(t.id,n().authItems,u=>({...u,isLoggedIn:!0,isPending:!1,session:{token:a.accessToken,expires:a.expiresIn}}))}))}).catch(a=>{e(()=>({authItems:F(t.id,n().authItems,u=>({...u,isLoggedIn:!1,isPending:!1,canAuthenticate:!1,error:a.message}))}))})}if(t.profile==="kiosk"){if(!o)throw new Error("Token service not found");e(()=>({authItems:F(t.id,n().authItems,a=>({...a,isPending:!0}))})),Mt(s).then(()=>{Ke(o).then(a=>{e(()=>({authItems:F(t.id,n().authItems,u=>({...u,isLoggedIn:!0,isPending:!1,session:{token:a.accessToken,expires:a.expiresIn}}))}))}).catch(a=>{e(()=>({authItems:F(t.id,n().authItems,u=>({...u,isLoggedIn:!1,isPending:!1,error:a.message}))}))})})}t.profile},removeService:(t,r)=>{let o=n().currentAuth===n().authItems.findIndex(i=>i.service.id===t.id),s=n().currentAuth;if(o){let i=n().authItems.find(u=>u.service.id===t.id);i&&i.instances>1||(s=n().authItems.findIndex(c=>c.service.id!==t.id&&c.instances>0))}e(()=>({authItems:F(t.id,n().authItems,i=>({...i,instances:i.instances-1})),currentAuth:s}))}})),Vt=(e,n)=>wt((t,r)=>({service:e,status:e?"unknown":"success",shouldRedirect:!1,redirectResource:null,shouldSubstitute:!1,substituteResource:null,error:null,errorHeading:null,errorNote:null,shouldDisplayResource:!1,token:n||null,async probe(){if(!r().service)return;let o=r().service?.id;if(!o){t({status:"error",error:"Service ID not found",errorHeading:{en:["Service ID not found"]}});return}t({status:"probing"});let s=r().token;try{let i=await fetch(o,{headers:s?{Authorization:`Bearer ${r().token}`,Accept:"application/json"}:{Accept:"application/json"}}).then(a=>a.json());if(i.status===200)t({status:"success",shouldDisplayResource:!0,error:null,errorHeading:null,errorNote:null,shouldSubstitute:!1,shouldRedirect:!1});else if(i.status<400&&i.status>=300){if(!i.location)throw new Error("Redirect location not found");t({status:"error",shouldDisplayResource:!1,shouldRedirect:!0,redirectResource:i.location||null})}else if(i.status===401)t({status:"error",shouldDisplayResource:!1,shouldRedirect:!1,shouldSubstitute:!!i.substitute,substituteResource:i.substitute||null,error:"Unauthorized",errorHeading:i.heading||{en:["Unauthorized"]},errorNote:i.note||null});else throw new Error("Unknown error")}catch(i){t({status:"error",error:i.message,errorHeading:{en:["Unknown error"]}})}},setToken(o){t({token:o})}}));function kt(e){let n=e.service||e.services||[],t={hasAuth:!1,services:{}};for(let r of n)if(r.type==="AuthProbeService2"){t.services.probe=r,t.hasAuth=!0;let o=r.service.filter(s=>s.type==="AuthAccessService2");o[0]&&(t.services.access=o[0])}return t}async function Ke(e,{strict:n=!0}={}){return new Promise((t,r)=>{let o=Math.random().toString(36).substring(7),s=`${e.id}?messageId=${o}&origin=${window.location.origin}`,i=c=>{let l=c.data;if(l.messageId===o){if(n&&l.type!=="AuthAccessToken2"){a(),r("Invalid response, expected type=AuthAccessToken2");return}if(!l.accessToken){a(),r("Invalid response, expected accessToken");return}a(),t(l)}},a=()=>window.removeEventListener("message",i),u=document.createElement("iframe");u.src=s,u.style.display="none",document.body.appendChild(u),window.addEventListener("message",i)})}function Nt(e){let n=window.location;if(e){let t=document.createElement("a");return t.href=e,t.protocol+"//"+t.hostname+(t.port?":"+t.port:"")}return n.protocol+"//"+n.hostname+(n.port?":"+n.port:"")}async function Mt(e){let n=`${e.id}?origin=${Nt()}`,t=window.open(n);if(!t)throw new Error("Failed to open window");return new Promise((r,o)=>{let s=setInterval(()=>{t.closed&&(clearInterval(s),r())},500)})}import{useEffect as Lt,useMemo as zt}from"react";import{useStore as Mr}from"zustand";function Ot(e){let n=zt(()=>kt(e),[e]),t=Ht(n.services.access?.id),r=zt(()=>Vt(n.services.probe,t),[n.services.probe]),o=Mr(r);return Lt(()=>{o.status==="unknown"&&!t&&o.probe()},[n.services.probe,o.status]),Lt(()=>{t&&(o.setToken(t),o.probe())},[t]),[e,o,n.hasAuth]}import{jsx as Pe}from"react/jsx-runtime";var te=Qe(null),Vr=Qe(null);Vr.displayName="CurrentAuth";var kr=Qe(null);kr.displayName="AuthActions";function $t({children:e}){let n=Er(()=>Et(),[]);return Pe(te.Provider,{value:n,children:e})}function Dt(){return!!Ft(te)}function me(){let e=Ft(te);if(!e)throw new Error("useAuthActions must be used within a AuthProvider");return e}function Nr(){let e=me();return de(e,t=>({login:t.login,logout:t.logout,nextAuth:t.nextAuth,previousAuth:t.previousAuth,setAuth:t.setAuth,addService:t.addService,removeService:t.removeService}))}function ps(){let e=me();return de(e,n=>n)}function Lr(e){let n=me();return de(n,r=>r.authItems.find(o=>o.service.id===e))}function Ht(e){let n=me();return de(n,r=>r.authItems.find(o=>o.id===e)?.session?.token)}function gs(e){let n=me();return de(n,r=>{let o=r.authItems.find(s=>s.service.id===e);return!o||!o.isLoggedIn||!o.session?null:o.session?.token||null})}function zr(e){let n=Nr(),t=Lr(e.service.id);return wr(()=>(n?.addService(e.service,e.probeId),()=>{n?.removeService(e.service,e.probeId)}),[e.service]),t?(t.error||!t.isLoggedIn,e.children):null}function Ye(){return null}function Ut(e){let[n,t,r]=Ot(e.resource),o=e.fallbackComponent||Ye,s=e.loadingComponent||Ye,i=e.errorComponent||Ye,a=t.service,u=null;if(!r||!a)return e.children(n);let c=a.service.filter(l=>l.type==="AuthAccessService2");t.status==="error"&&(u=Pe(i,{resource:e.resource,error:t.error||"",heading:t.errorHeading,note:t.errorNote,extra:e.extra})),(t.status==="unknown"||t.status==="probing")&&(u=Pe(s,{})),t.status==="success"&&(u=e.children(n));for(let l of c)u=Pe(zr,{service:l,probeId:a.id,children:u},l.id);return u}import{createContext as $r,useContext as Ps,useMemo as Dr}from"react";import{createStore as Or}from"zustand/vanilla";var Hr=e=>e.id||e["@id"];function Fr(e){return(Array.isArray(e.service)?e.service:[e.service]).find(t=>t.profile==="http://iiif.io/api/search/0/autocomplete"||t.profile==="http://iiif.io/api/search/1/autocomplete"||t.profile==="AutoCompleteService1")}var qt=e=>{let n;typeof e=="string"?n={"@context":"http://iiif.io/api/search/1/context.json",profile:"http://iiif.io/api/search/1/search","@id":e,id:e,service:[]}:n=e;let t=n?Hr(n):void 0,r=null;return Or((o,s)=>({service:n,resources:[],lastQuery:{},loading:!1,error:!1,highlight:null,hasSearch:!!n,hasAutocomplete:n?!!Fr(n):!1,errorMessage:"",search(i,a={}){if(!t)throw new Error("No search service found.");r&&!r.signal.aborted&&r.abort(),r=new AbortController;let u=new URLSearchParams;i.q&&u.set("q",i.q),i.motivation&&u.set("motivation",i.motivation),i.date&&u.set("date",i.date),i.user&&u.set("user",i.user),o({loading:!0}),fetch(`${t}?${u.toString()}`,{signal:r.signal,headers:{"Content-Type":"application/json",Accept:"application/json",...a.headers||{}}}).then(async c=>{if(!r?.signal.aborted)if(c.ok){let l=await c.json();o({resources:l.resources,error:!1,errorMessage:""})}else o({resources:[],error:!0,errorMessage:c.statusText})})},clearSearch(){o({resources:[],error:!1,errorMessage:""})},highlightResult(i){let a=s().resources.find(u=>u["@id"]===i);o({highlight:a})},nextResult(){let i=s().resources,a=s().highlight;if(!a){o({highlight:i[0]||null});return}let u=i.findIndex(c=>c["@id"]===a["@id"]);if(u===-1){o({highlight:i[0]||null});return}o({highlight:i[u+1]||i[0]||null})},previousResult(){let i=s().resources,a=s().highlight;if(!a){o({highlight:i[i.length-1]||null});return}let u=i.findIndex(c=>c["@id"]===a["@id"]);if(u===-1){o({highlight:i[i.length-1]||null});return}if(u===0){o({highlight:i[i.length-1]||null});return}o({highlight:i[u-1]||i[i.length-1]||null})}}))};import{useStore as ws}from"zustand";function Bt(){let e=E();return e?e.service.find(n=>n.profile==="SearchService1"||n.profile==="http://iiif.io/api/search/1/search"):void 0}import{jsx as We}from"react/jsx-runtime";var ne=$r(null);ne.displayName="Search";function _t(e){let n=Bt();return e.store?We(ne.Provider,{value:e.store,children:e.children}):We(Ur,{service:n,children:e.children})}function Ur({service:e,children:n}){let t=Dr(()=>qt(e),[e]);return We(ne.Provider,{value:t,children:n})}import{jsx as z}from"react/jsx-runtime";var fe=()=>{},pe=Br({setCurrentCanvasId:fe,setCurrentCanvasIndex:fe,nextCanvas:fe,previousCanvas:fe,items:[],sequence:[],setSequenceIndex:fe,currentSequenceIndex:0,hasNext:!1,hasPrevious:!1});function jr(e){let n=E(),{cursor:t,visibleItems:r,next:o,sequence:s,items:i,setCanvasIndex:a,setCanvasId:u,previous:c,setSequenceIndex:l,hasNext:d,hasPrevious:y}=It({startCanvas:e.startCanvas,disablePaging:e.pagingEnabled===!1}),A=_r(()=>({sequence:s,items:i,setCurrentCanvasId:u,nextCanvas:o,previousCanvas:c,totalCanvases:i.length,setCurrentCanvasIndex:a,setSequenceIndex:l,currentSequenceIndex:t,hasNext:d,hasPrevious:y}),[s,i,u,o,c,i,a,l,t]);return n?r.length===0?null:z(pe.Provider,{value:A,children:z(ee.Provider,{value:r,children:z(q,{canvas:r[0],children:e.children})})}):(console.warn("The manifest passed to the provider is not a valid IIIF manifest."),z("div",{children:"Sorry, something went wrong."}))}function jt(e){let n=X(e.vault),t=At(e.manifest);if(!t)return console.warn("The manifest passed to the provider is not a valid IIIF manifest."),z("div",{children:"Sorry, something went wrong."});if(t.error)return z("div",{children:t.error.toString()});if(!t.isLoaded)return z("div",{children:"Loading..."});let r=z(jr,{...e,children:e.children});return z(J,{vault:n,children:z(bt,{manifest:t.id,children:z($t,{children:z(_t,{children:e.rangeId?z(Pt,{range:e.rangeId,children:r}):r})})})})}function Kt(){return qr(pe)}import Kr from"react";import{createContext as Yr,useMemo as Qr}from"react";import Wr from"mitt";import{jsx as Zr}from"react/jsx-runtime";var Gr=Wr(),re=Yr({emitter:Gr});re.displayName="Events";function Yt(){return Kr.useContext(re).emitter}function au({emitter:e,children:n}){return Zr(re.Provider,{value:Qr(()=>({emitter:e}),[e]),children:n})}import{jsx as oe}from"react/jsx-runtime";function Qt(){return{VaultContext:W(Q),ResourceContext:W(Ce),SimpleViewerReactContext:W(pe),VisibleCanvasReactContext:W(ee),AuthRContext:W(te),SearchReactContext:W(ne),ReactEventContext:W(re)}}function Wt(e){return oe(J,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:oe(ee.Provider,{value:e.bridge.VisibleCanvasReactContext,children:oe(pe.Provider,{value:e.bridge.SimpleViewerReactContext,children:oe(re.Provider,{value:e.bridge.ReactEventContext,children:oe(te.Provider,{value:e.bridge.AuthRContext,children:oe(ne.Provider,{value:e.bridge.SearchReactContext,children:e.children})})})})})})}import{createContext as no,useContext as ro,useMemo as oo}from"react";import{useCallback as Zt,useLayoutEffect as Xr,useMemo as eo,useRef as to}from"react";import{entityActions as Ge}from"@iiif/helpers/vault/actions";import{useMemo as Jr}from"react";function Gt(){let n=R().getStore();return Jr(()=>t=>n.dispatch(t),[n])}function Jt(e){return typeof e!="string"&&e&&e.bindToVault}function Xt(){let e=R(),n=to([]),t=Gt(),r=eo(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);Xr(()=>{let a={id:r,type:"AnnotationPage",behavior:[],label:null,thumbnail:[],summary:null,requiredStatement:null,metadata:[],rights:null,provider:[],items:[],seeAlso:[],homepage:[],rendering:[],service:[]};t(Ge.importEntities({entities:{AnnotationPage:{[a.id]:a}}}))},[r]);let o=T(a=>r&&a.iiif.entities.AnnotationPage[r]||null,[r]),s=Zt((a,u)=>{if(r){if(Jt(a)){let d=a;d.__vault||d.bindToVault(e),a=typeof d.source=="string"?d.source:d.source.id,n.current[a]=d}else typeof a!="string"&&(a=a.id);let c=e.get({id:r,type:"AnnotationPage"}),l=e.get({id:a,type:"Annotation"});c&&l&&(c.items.find(d=>d.id===l.id)||t(Ge.addReference({id:r,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"},index:u})))}},[r]),i=Zt(a=>{r&&(Jt(a)?a=typeof a.source=="string"?a.source:a.source.id:typeof a!="string"&&(a=a.id),n.current[a]&&n.current[a].beforeRemove(),e.get({id:r,type:"AnnotationPage"})&&t(Ge.removeReference({id:r,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"}})))},[r]);return[o,{addAnnotation:s,removeAnnotation:i}]}import{jsx as io}from"react/jsx-runtime";var en=no(null);function tn(){let e=ro(en);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function nn({children:e}){let[n,{addAnnotation:t,removeAnnotation:r}]=Xt();return io(en.Provider,{value:oo(()=>({fullPage:n,addAnnotation:t,removeAnnotation:r}),[n]),children:e})}import{jsx as Ze,jsxs as ao}from"react/jsx-runtime";function rn({width:e,style:n,height:t,error:r,resetErrorBoundary:o}){return ao("div",{style:{width:e,height:t,minHeight:500,...n||{},background:"#f9f9f9"},children:[Ze("h3",{children:"Error occurred"}),Ze("p",{children:r.message}),Ze("button",{onClick:o,children:"Reset"})]})}import{createContext as so,useContext as uo}from"react";var ge=so(null);function on(){return uo(ge)}import{createContext as an,useContext as co,useEffect as lo}from"react";var Je=an(()=>{}),Xe=an(()=>{});function O(e,n,t,r,o=[]){let s=co(e==="portal"?Xe:Je);lo(()=>(e!=="none"&&s(n,t,r),()=>{s(n,null)}),[n,e,s,...o])}import{createContext as fo,useContext as po,useEffect as go}from"react";import{useMemo as mo}from"react";function M(e={},n=[]){let{id:t,selector:r}=e,o=H(),s=t||o.canvas,i=T(a=>s?a.iiif.entities.Canvas[s]:void 0,[s]);return mo(()=>{if(i)return r?r(i):i},[i,r,...n])}var et=fo(()=>{});function sn(e){let n=M(),t=po(et);go(()=>n&&n.id?(t(n.id,e),()=>t(n.id,-1)):()=>{},[n,e])}import{Fragment as xo,jsx as V,jsxs as So}from"react/jsx-runtime";function ln({children:e,errorFallback:n,outerContainerProps:t={},worldScale:r,...o}){let[s,i]=Re(),a=Qt(),u=n||rn,[c,l]=Re({}),d=Object.entries(c),[y,A]=Re({}),h=Object.entries(y),[g,b]=Re({}),p=cn(()=>r||Math.max(...Object.values(g)),[g]),S=cn(()=>({maxOverZoom:p||1,...o.runtimeOptions||{}}),[p,o.runtimeOptions]),m=tt((x,P)=>{b(C=>{if(P===-1){let{[x]:_,...f}=C;return f}return{...C,[x]:P}})},[]),v=tt((x,P,C)=>{l(({[x]:_,...f})=>P?{...f,[x]:{element:P,props:C}}:f)},[]),I=tt((x,P,C)=>{A(({[x]:_,...f})=>P?{...f,[x]:{element:P,props:C}}:f)},[]);return So(yo,{resetKeys:[],fallbackRender:x=>V(u,{...o,...x}),children:[V(vo,{...o,containerProps:{style:{position:"relative"},...o.containerProps||{}},htmlChildren:V(xo,{children:d.map(([x,{element:P,props:C}])=>V(un.Fragment,{children:V(P,{...C||{}})},x))}),onCreated:x=>{i(x),o.onCreated&&o.onCreated(x)},runtimeOptions:S,children:V(ge.Provider,{value:s,children:V(et.Provider,{value:m,children:V(Je.Provider,{value:v,children:V(Xe.Provider,{value:I,children:V(Wt,{bridge:a,children:V(ho.Provider,{value:o.mode||"explore",children:V(nn,{children:e})})})})})})})}),V("div",{children:h.map(([x,{element:P,props:C}])=>V(un.Fragment,{children:V(P,{...C||{}})},x))})]})}import{mergeStyles as To,RegionHighlight as Io}from"@atlas-viewer/atlas";import{useMemo as dn}from"react";import{createEventsHelper as Co}from"@iiif/helpers/events";function Te(e,n){let t=R(),r=dn(()=>Co(t),[t]),o=T(()=>e&&e.id?t.getResourceMeta(e.id,"eventManager"):null,[e]);return dn(()=>e?r.getListenersAsProps(e,n):{},[o,e,t,n])}import{useMemo as Ao}from"react";import{createStylesHelper as bo}from"@iiif/helpers/styles";function ie(e,n){let t=R(),r=Ao(()=>bo(t),[t]);return T(()=>{if(!e)return null;let o=r.getAppliedStyles(e.id);return o?n?o[n]:o:void 0},[e,n])}import{useMemo as Mo}from"react";import{useMemo as Po}from"react";import{expandTarget as Ro}from"@iiif/helpers/annotation-targets";function Ie(e={},n=[]){let{id:t,selector:r}=e,o=H(),s=R(),i=t||o.annotation,a=T(c=>i?c.iiif.entities.Annotation[i]:void 0,[i]),u=T(c=>a&&a.body?a.body.map(l=>l?l.type==="SpecificResource"?{...l,source:s.get(l)}:l?c.iiif.entities[l.type][l.id]:null:null).filter(Boolean):[],[a]);return Po(()=>{if(!a)return;let c={...a,body:u,target:Ro(a.target,{typeMap:s.getState().iiif.mapping})};return r?r(c):c},[a,r,u,...n])}import{jsx as wo}from"react/jsx-runtime";var Me=({id:e,style:n,className:t,interactive:r})=>{let o=Ie({id:e}),s=ie(o,"atlas"),i=ie(o,"html"),a=Te(o,["atlas"]),u=M(),c=Mo(()=>To(n,s),[n,s]);return u&&o&&o.target&&o.target.selector&&o.target.selector.type==="BoxSelector"&&o.target.source&&(o.target.source.id===u.id||o.target.source===u.id)?wo(Io,{id:o.id,isEditing:!0,region:o.target.selector.spatial,style:c,className:i?.className||t,interactive:!!(i?.href||r),href:i?.href||null,title:i?.title||null,hrefTarget:i?.target||null,onClick:()=>{},...a}):null};import{Fragment as Vo}from"react";import{useMemo as Eo}from"react";function mn(e={},n=[]){let{id:t,selector:r}=e,o=H(),s=t||o.annotationPage,i=T(a=>s?a.iiif.entities.AnnotationPage[s]:void 0,[s]);return Eo(()=>{if(i)return r?r(i):i},[i,...n])}import{jsx as fn}from"react/jsx-runtime";var ve=({className:e,page:n})=>{let t=mn({id:n.id})||n,r=ie(t,"atlas"),o=ie(t,"html");return T(s=>t.id?s.iiif.entities.AnnotationPage[t.id]:null,[]),fn(Vo,{children:t.items?.map(s=>fn(Me,{id:s.id,style:r,className:o?.className||e},s.id))})};import{createStylesHelper as Vi}from"@iiif/helpers/styles";import{Fragment as bn,useMemo as Fo}from"react";import{HTMLPortal as zo,TileSet as Cn}from"@atlas-viewer/atlas";import ae,{useMemo as nt}from"react";import{jsx as $}from"react/jsx-runtime";var gn=ae.createContext("en"),vn=ae.createContext({}),hn=ae.createContext(null);function Xc(e){return $(vn.Provider,{value:e.translations,children:e.children})}function el(e){return $(gn.Provider,{value:e.language,children:e.children})}function tl(e){return $(hn.Provider,{value:e.convert,children:e.children})}function yn(){return ae.useContext(hn)}function rt(){return ae.useContext(gn)}function xn(){return ae.useContext(vn)}function pn(e){return e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):e}function ko({as:e,language:n,children:t,viewingDirection:r,...o}){let s=rt();return nt(()=>pn(s)===pn(n),[s,n])?e?$(e,{...o,children:t}):$("span",{...o,children:t}):e?$(e,{...o,lang:n,dir:r,children:t}):$("span",{...o,lang:n,dir:r,children:t})}function Sn(e,n,t){if(n.length===0)return;if(n.length===1)return n[0];if(n.indexOf(e)!==-1)return e;let r=e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):null;if(r&&n.indexOf(r)!==-1)return r;for(let o of t)if(n.indexOf(o)!==-1)return o;return n.indexOf("none")!==-1?"none":n.indexOf("@none")!==-1?"@none":n[0]}var No=(e,n=[])=>{let t=rt();return nt(()=>{let r=e();return Sn(t,r,[])},[t,...n])};function G(e,n,t,r){return n?t?t(e[n]||n,r||"none"):e[n]||n:""}function Lo(e,n,t=`
2
- `,r={}){let o=yn(),s=No(()=>Object.keys(e||{}),[e]);return[nt(()=>{if(!e)return G(r,n,o)||"";if(typeof e=="string")return G(r,e,o);let i=s?e[s]:void 0;return i?typeof i=="string"?i:i.map(a=>G(r,a,o,s)).join(t):""},[s,n,e]),s]}function nl(){let e=rt(),n=xn(),t=yn();return function(o,s="",i=`
3
- `,a=n){let u=Object.keys(o||{}),c=Sn(e,u,[]);if(!o)return G(a,s,t)||"";if(typeof o=="string")return G(a,o,t);let l=c?o[c]:void 0;return l?typeof l=="string"?G(a,l,t,c):l.map(d=>G(a,d,t,c)).join(typeof i<"u"?i:`
4
- `):""}}function he({as:e,defaultText:n,enableDangerouslySetInnerHTML:t,children:r,separator:o,...s}){let i=xn(),[a,u]=Lo(r,n,o,i);return u?$(ko,{...s,as:e,language:u,title:t?void 0:a,dangerouslySetInnerHTML:t?{__html:a}:void 0,children:t?void 0:a}):e?$(e,{...s,children:a}):$("span",{...s,title:t?void 0:a,dangerouslySetInnerHTML:t?{__html:a}:void 0,children:t?void 0:a})}import{jsx as B,jsxs as Ho}from"react/jsx-runtime";function Oo({resource:e,heading:n,note:t,extra:r}){return r?B(zo,{target:{x:0,y:0,width:r.target?.spatial.width,height:r.target?.spatial.height},backgroundColor:"#333",relative:!0,children:B("div",{style:{display:"flex",alignContent:"center",justifyContent:"center",alignItems:"center",height:"100%",width:"100%",background:"#444",color:"#BBB"},children:Ho("div",{children:[B(he,{children:n||"Not authorised"}),t&&B("p",{children:B(he,{children:t})}),B("p",{children:e.id||e["@id"]||"unknown"})]})})}):null}function An({image:e,thumbnail:n,crop:t,enableSizes:r}){if(!Dt()){let s=e.service,i=s.width||e.width||0,a=s.height||e.height||0;return B(Cn,{tiles:{id:s.id||s["@id"]||"unknown",height:a,width:i,imageService:s},enableSizes:r,x:0,y:0,width:e.target?.spatial.width,height:e.target?.spatial.height,crop:t})}return B(Ut,{resource:e.service,errorComponent:Oo,extra:e,children:s=>{let i=s.width||e.width||0,a=s.height||e.height||0;return B(Cn,{tiles:{id:s.id||s["@id"]||"unknown",height:a,width:i,imageService:s},enableSizes:r,x:0,y:0,width:e.target?.spatial.width,height:e.target?.spatial.height,crop:t})}},e.id)}import{jsx as ot,jsxs as Pn}from"react/jsx-runtime";function se({id:e,image:n,thumbnail:t,isStatic:r,x:o=0,y:s=0,children:i,selector:a,onClick:u,enableSizes:c}){let l=Fo(()=>{if(!(!a||a.spatial.x===0&&a.spatial.y===0))return a.spatial},[a]);return ot("world-object",{x:o+n.target.spatial.x,y:s+n.target.spatial.y,width:n.target.spatial.width,height:n.target.spatial.height,onClick:u,children:n.service?Pn(bn,{children:[ot(An,{image:n,thumbnail:t,crop:l,enableSizes:c}),i]},"service"):Pn(bn,{children:[ot("world-image",{onClick:u,uri:n.id,target:{x:0,y:0,width:n.target.spatial.width,height:n.target.spatial.height},display:n.width&&n.height?{width:n.width,height:n.height}:void 0,crop:l}),i]},"no-service")},e+(n.service?"server":"no-service"))}import{Fragment as ki,useEffect as Jn,useLayoutEffect as Ni,useMemo as Xn}from"react";import{useEffect as Ln,useMemo as zn}from"react";import{useCallback as In,useMemo as Do}from"react";function $o(e,n){let t=e?.iiif?.meta[n];return t?t.annotationPageManager:null}function Rn(e,n){return T(t=>{let r=[];if(!e)return r;let o=Object.keys(t.iiif.entities.AnnotationPage);for(let s of o)if(!n||n.indexOf(s)!==-1){let i=$o(t,s);i&&i.views&&i.views[e]&&r.push(s)}return r},[e,n])}function Tn({canvas:e,manifest:n,all:t,canvases:r}){let o=[];if(n)for(let s of n.annotations)o.indexOf(s.id)===-1&&o.push(s.id);if(t){if(r&&r.length)for(let s of r)for(let i of s.annotations)o.indexOf(i.id)===-1&&o.push(i.id)}else if(e)for(let s of e.annotations)o.indexOf(s.id)===-1&&o.push(s.id);return o}function Uo(e,n){let t=e?.iiif?.meta[n];return t?t.annotationPageManager:null}function Mn(e,n={}){let t=R(),r=E(),o=M(),s=Ae(),i=Do(()=>Tn({all:n.all,manifest:r,canvas:o,canvases:s}),[n.all,o,s,r]),a=Rn(e,n.all?void 0:i),u=In(l=>{e&&t.setMetaValue([l,"annotationPageManager","views"],d=>d&&!d[e]?d:{...d||{},[e]:!1})},[e,t]),c=In((l,d={})=>{if(!e)return;let y=t.getState(),A=[];if(d?.deselectOthers){let h=Object.keys(y.iiif.entities.AnnotationPage);for(let g of h){let b=Uo(y,g);b&&b.views&&b.views[e]&&A.push(g)}}for(let h of A)u(h);t.setMetaValue([l,"annotationPageManager","views"],h=>h&&h[e]?h:{...h||{},[e]:!0})},[e,u,t]);return{availablePageIds:i,enabledPageIds:a,setPageEnabled:c,setPageDisabled:u}}function wn(e,n){return T((t,r)=>r.get(e.map(o=>({id:o,type:n}))),[e,n])}import{useCallback as Ko,useEffect as Yo,useRef as Qo,useState as Wo}from"react";import qo,{useContext as Bo}from"react";import{ImageServiceLoader as _o}from"@atlas-viewer/iiif-image-api";var jo=qo.createContext(new _o);function we(){return Bo(jo)}function En(){let e=we(),[n,t]=Wo({}),r=Qo(!1);return Yo(()=>()=>{r.current=!0},[]),[Ko((s,{height:i,width:a})=>{if(s){let u=s.id||s["@id"],c=e.loadServiceSync({id:u,width:s.width||a,height:s.height||i,source:s});c?s=c:n[u]||(r.current||t(l=>({...l,[u]:"loading"})),e.loadService({id:u,width:s.width||a,height:s.height||i}).then(()=>{r.current||t(l=>({...l,[u]:"done"}))}))}return s},[e,n]),n]}import{useCallback as Go,useMemo as kn,useState as Zo}from"react";function Vn(e={}){let n=Ie(),t=M(e.canvasId?{id:e.canvasId}:void 0);return T((r,o)=>{if(!t)return[];if(n&&e.enableSingleAnnotation)return[n];let s=o.get(t.items),i=[];for(let a of s)i.push(...o.get(a.items));return i},[t])}import{createPaintingAnnotationsHelper as Jo}from"@iiif/helpers/painting-annotations";function Nn(e,n=[]){let t=R(),r=kn(()=>Jo(t),[]),o=Vn({enableSingleAnnotation:e?.enableSingleAnnotation}),[s,i]=Zo(e?.defaultChoices||[]),a=kn(()=>r.getPaintables(o,s),[t,o,s,...n]),c={makeChoice:Go((l,{deselectOthers:d=!0,deselect:y=!1}={})=>{a.choice&&i(A=>{if(y){let g=A.filter(b=>b!==l);if(g.length===0){let b=a.items[0].resource.id;return b?[b]:[]}return g}if(d)return[l];let h=[...A];if(h.length===0&&a.items.length){let g=a.items[0].resource.id;g&&h.push(g)}return A.indexOf(l)!==-1?A:[...A,l]})},[a.choice])};return[a,c]}function On(e){let n=E(),t=M(),r=R(),o=Yt(),s=e?.emitter||o,[i,a]=En(),{enabledPageIds:u}=Mn(e?.annotationPageManagerId||n?.id||t?.id,{all:!1}),c=wn(u,"AnnotationPage"),l=e?.strategies||["empty","images","media","textual-content","complex-timeline"],[d,y]=Nn(e,[a]);Ln(()=>{let h=g=>{y.makeChoice(g.choiceId,{deselectOthers:g.deselectOthers,deselect:g.deselect})};return s.on("make-choice",h),()=>{s.off("make-choice",h)}},[]);let A=zn(()=>yt({canvas:t,paintables:d,supports:l,loadImageService:i}),[t,d,r,y.makeChoice]);return Ln(()=>{let h=d.allChoices,g={canvasId:t?.id,manifestId:n?.id};h&&s.emit("choice-change",{choice:h,partOf:g})},[t?.id,d.allChoices]),zn(()=>A.type==="unknown"?[A,ht]:[{...A,annotations:{pages:c}},y],[A,c])}import{useEffect as ei,useMemo as ti,useRef as ni,useState as ri}from"react";import{useEffect as Xo}from"react";var Hn=(e,n=[])=>{let t=R();Xo(()=>{e(t)},[t,...n])};import{createThumbnailHelper as oi}from"@iiif/helpers/thumbnail";function Ee(e,n,{canvasId:t,manifestId:r}={}){let o=R(),s=we(),i=ti(()=>oi(o,{imageServiceLoader:s}),[o,s]),[a,u]=ri(),c=E(r?{id:r}:void 0),l=M(t?{id:t}:void 0),d=l||c,y=ni(!1);if(ei(()=>(y.current=!1,()=>{y.current=!0}),[]),!d)throw new Error("Must be called under a manifest or canvas context.");return Hn(A=>{i.getBestThumbnailAtSize(d,e,n).then(h=>{h.best&&!y.current&&u(h.best)})},[d]),a}import{useCallback as D,useEffect as Fn,useReducer as ii,useRef as Ve}from"react";function ai(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function si(e,n){switch(n.type){case"FINISHED":return{...e,isFinished:!0,isPlaying:!1,playRequested:!1};case"PLAY_PAUSE":return{...e,isFinished:!1,isPlaying:!e.isPlaying};case"PLAY_REQUESTED":return{...e,isFinished:!1,playRequested:!0};case"PAUSE":return{...e,isPlaying:!1};case"PLAY":return{...e,isFinished:!1,playRequested:!1,isPlaying:!0};case"MUTE":return{...e,isMuted:!0};case"SET_VOLUME":return{...e,volume:n.volume,isMuted:n.volume===0};case"TOGGLE_MUTE":return{...e,isMuted:!e.isMuted};case"UNMUTE":return{...e,isMuted:!1}}return e}function it(e){let n=Math.round(e);return`${Math.floor(n/60)}:${`${n%60}`.padStart(2,"0")}`}function ue(e){let[n,t]=ii(si,ai(e.duration)),r=Ve(null),o=Ve(null),s=Ve(null),i=Ve(!1),a=D(()=>{o.current&&r.current&&(o.current.innerHTML=it(r.current.currentTime),s.current&&(s.current.style.width=`${r.current.currentTime/e.duration*100}%`),i.current!==r.current.muted&&(i.current=r.current.muted,t(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"})))},[e.duration]),u=D(()=>{r.current&&(t({type:"PLAY_REQUESTED"}),r.current.play().then(()=>{t({type:"PLAY"})}),a())},[a]),c=D(()=>{r.current&&(r.current.duration>0&&r.current.paused?u():l())},[a]),l=D(()=>{r.current&&(r.current.pause(),t({type:"PAUSE"}),a())},[a]),d=D(()=>{r.current&&(r.current.muted=!r.current.muted,t(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"}))},[]),y=D(()=>{r.current&&(r.current.muted=!0,t({type:"MUTE"}))},[]),A=D(()=>{r.current&&(r.current.muted=!1,t({type:"UNMUTE"}))},[]),h=D(p=>{r.current&&(r.current.muted=!1,r.current.volume=p/100,t({type:"SET_VOLUME",volume:p}))},[]),g=D(p=>{r.current&&(r.current.currentTime=Math.max(0,Math.min(p*e.duration,e.duration)),a())},[]),b=D(p=>{if(r.current){let S=typeof p=="function"?p(r.current.currentTime):p;r.current.currentTime=Math.max(0,Math.min(S,e.duration)),a()}},[]);return Fn(()=>{let p=setInterval(()=>{a()},350);return()=>clearInterval(p)},[a,e.duration]),Fn(()=>{let p=()=>{t({type:"FINISHED"})},S=r.current;return S?.addEventListener("ended",p),()=>S?.removeEventListener("ended",p)},[]),[{element:r,currentTime:o,progress:s},n,{play:u,pause:l,playPause:c,mute:y,unmute:A,toggleMute:d,setVolume:h,setDurationPercent:g,setTime:b}]}import{createContext as st,useContext as ut}from"react";import{jsx as at}from"react/jsx-runtime";var $n=st(null),Dn=st(null),Un=st(null);function xd(){let e=ut($n);if(!e)throw new Error("Ctx not found");return e}function Sd(){let e=ut(Dn);if(!e)throw new Error("Ctx not found");return e}function Cd(){let e=ut(Un);if(!e)throw new Error("Ctx not found");return e}function ke({actions:e,state:n,children:t,currentTime:r,progress:o,element:s}){return at(Un.Provider,{value:{currentTime:r,progress:o,element:s},children:at(Dn.Provider,{value:e,children:at($n.Provider,{value:n,children:t})})})}import{useMemo as ui}from"react";import{expandTarget as ci}from"@iiif/helpers";function Ne(){let e=E(),n=M();return ui(()=>{if(!e||!n||!e.start)return null;let t=ci(e.start);return!t||t.source.id!==n.id||!t||!t.selector||t.selector.type!=="TemporalSelector"?null:t.selector.temporal},[e,n])}import{jsx as li,jsxs as di}from"react/jsx-runtime";function ct({media:e,startTime:n,children:t}){let[{element:r,currentTime:o,progress:s},i,a]=ue({duration:e.duration}),u=n?`${e.url}#t=${n}`:e.url;return di(ke,{state:i,actions:a,currentTime:o,progress:s,element:r,children:[li("audio",{ref:r,src:u}),t]})}function Le({media:e,mediaControlsDeps:n,children:t}){let r=Ne();return O("portal","audio",ct,{media:e,startTime:r?r.startTime:null,children:t},[e,r,...n||[]]),null}import{jsx as qn,jsxs as mi}from"react/jsx-runtime";function lt({element:e,media:n,startTime:t,playPause:r,poster:o}){let s="div",i=t?`${n.url}#t=${t}`:n.url;return mi(s,{className:"video-container",part:"video-container",onClick:r,children:[qn("style",{children:`
5
- .video-container {
6
- position: absolute;
7
- top: 0;
8
- bottom: 0;
9
- left: 0;
10
- right: 0;
11
- background: #000;
12
- z-index: 13;
13
- display: flex;
14
- justify-content: center;
15
- pointer-events: visible;
16
- }
17
- `}),qn("video",{poster:o,ref:e,src:i,style:{width:"100%",objectFit:"contain"}})]})}function ze({media:e,mediaControlsDeps:n,children:t,videoComponent:r=lt}){let o=M(),s=Ne(),i=o&&o.placeholderCanvas&&o.placeholderCanvas.id||void 0,a=Ee({},!1,{canvasId:i}),[{element:u,currentTime:c,progress:l},d,y]=ue({duration:e.duration});return O("overlay","video-element",r,{element:u,media:e,playPause:y.playPause,poster:a?.id,startTime:s?s.startTime:null},[a]),O("portal","custom-controls",ke,{state:d,actions:y,currentTime:c,progress:l,element:u,children:t},[c,d,e,...n||[]]),null}import{Fragment as fi,jsx as dt,jsxs as pi}from"react/jsx-runtime";function mt({model:e}){return pi(fi,{children:[dt("style",{children:`
18
- .model-container {
19
- position: absolute;
20
- top: 0;
21
- bottom: 0;
22
- left: 0;
23
- right: 0;
24
- background: #000;
25
- z-index: 13;
26
- display: flex;
27
- justify-content: center;
28
- pointer-events: visible;
29
- }
30
- `}),dt("div",{className:"model-container",children:dt("model-viewer",{"interaction-prompt":"none",style:{width:"100%",height:"100%"},"camera-controls":"","ar-status":"not-presenting",src:e.id})})]})}function Oe({model:e,name:n}){return O("overlay",`model-${n}`,mt,{model:e},[e]),null}import{jsx as gi}from"react/jsx-runtime";function He({style:e}){let n=M();return!n||!n.height||!n.width?null:gi("box",{interactive:!1,target:{x:0,y:0,width:Number(n.width),height:Number(n.height)},style:e})}import{jsx as Bn}from"react/jsx-runtime";function Fe(e){let n=M();return!n||!n.placeholderCanvas?null:Bn(q,{canvas:n.placeholderCanvas.id,children:Bn(ce,{renderViewerControls:e.renderViewerControls})})}import{useRef as vi}from"react";import{jsx as _n,jsxs as yi}from"react/jsx-runtime";function hi({element:e,media:n,playPause:t}){let r=vi(null);return n.youTubeId?yi("div",{className:"video-container",part:"video-container",onClick:t,children:[_n("style",{children:`
31
- .video-container {
32
- position: absolute;
33
- top: 0;
34
- bottom: 0;
35
- left: 0;
36
- right: 0;
37
- background: #000;
38
- z-index: 13;
39
- display: flex;
40
- justify-content: center;
41
- pointer-events: visible;
42
- }
43
- .video-yt {
44
- border: none;
45
- width: 100%;
46
- object-fit: contain;
47
- }
48
- `}),_n("iframe",{className:"video-yt",ref:r,src:`https://www.youtube.com/embed/${n.youTubeId}?enablejsapi=1&origin=${window.location.host}`,referrerPolicy:"no-referrer",sandbox:"allow-scripts allow-same-origin allow-presentation"})]}):null}function jn({media:e,mediaControlsDeps:n,children:t}){let[{element:r,currentTime:o,progress:s},i,a]=ue({duration:e.duration});return O("overlay","video-element",hi,{element:r,media:e,playPause:a.playPause}),null}import{useLayoutEffect as Ti,useMemo as Ii}from"react";import xi from"mitt";import{createStore as Si}from"zustand/vanilla";function Kn({currentKeyFrameIndex:e,keyframes:n,targetTime:t,currentTime:r}){if(r<=t){let o=n.findIndex(a=>a.time>t);if(o===-1)return[e,[]];let s={},i=n.slice(e,o);for(let a of i)a.type==="enter"&&(s[a.id]=a),a.type==="exit"&&(s[a.id]?delete s[a.id]:s[a.id]=a);return[o,Object.values(s)]}return[e,[]]}function Yn({complexTimeline:e,startTime:n=0}){let t=xi(),r={},o={progress:null,currentTime:null},s=0,i=null,a=0,u=null;function c(){let S=b.getState().visibleElements,m=r,v=[],I=Object.keys(m);for(let x of I){let P=m[x],C=S[x];P&&C&&v.push(P)}return v}function l(){return Object.keys(r).map(S=>r[S])}function d(p){o.currentTime&&(o.currentTime.innerHTML=it(p),o.progress&&(o.progress.style.width=`${p/e.duration*100}%`))}let y=()=>{let p=b.getState(),S=p.currentPrime;if(!S)return;let m=r,v=p.visibleElements,I=Object.keys(m);for(let x of I){let P=m[x],C=v[x];if(P&&x!==S.id&&C){let _=a-C.time*1e3;Math.abs(a-C.time*1e3-P.currentTime*1e3)>300&&(P.currentTime=_/1e3)}}},A=(p=0)=>{let S=p-s,m=b.getState();if(m.isPlaying){let v=m.currentPrime;if(v){let C=r[v.id];C&&(C.paused?a+=S:a=(v.time+C.currentTime)*1e3)}else a+=S;let I=a/1e3;if(I>m.duration){b.getState().setTime(0),b.setState({isPlaying:!1}),h(),d(0);return}d(I);let[x,P]=Kn({currentTime:I,currentKeyFrameIndex:m.nextKeyframeIndex,keyframes:m.complexTimeline.keyframes,targetTime:I});P.length&&m.applyKeyframes(x,P)}s=p,i=requestAnimationFrame(A)},h=()=>{i&&cancelAnimationFrame(i)},g=(p,S)=>{},b=Si((p,S)=>({complexTimeline:e,elements:{},visibleElements:{},isBuffering:!1,bufferMap:{},isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,isReady:!1,volume:100,duration:e.duration,clockStartRequests:0,clockStartTime:0,primeTime:0,currentPrime:null,clockRunning:!1,nextKeyframeIndex:0,startClock:()=>{S().clockRunning||(A(),u=setInterval(y,500)),p({clockRunning:!0,clockStartRequests:S().clockStartRequests+1})},applyKeyframes(m,v){let I=S(),x={...I.visibleElements},P=I.currentPrime;for(let C of v)C.type==="enter"&&(x[C.id]=C,t.emit("complex-timeline.enter",{id:C.id})),C.type==="exit"&&(x[C.id]=null,t.emit("complex-timeline.exit",{id:C.id})),C.isPrime&&(P=C);p({nextKeyframeIndex:m,visibleElements:x,currentPrime:P})},stopClock:()=>{let m=S().clockStartRequests;if(m!==0){if(m===1){h(),u&&clearInterval(u),p({clockRunning:!1,clockStartRequests:0});return}p({clockStartRequests:m-1})}},setElement:(m,v)=>{r[m]=v;let I=Object.keys(r),x=S().complexTimeline;g(v,m),x.items.filter(C=>C.type!=="Image"&&C.type!=="Text").every(C=>I.includes(C.annotationId))&&!S().isReady&&(t.emit("complex-timeline.ready",{complexTimeline:x}),p({isReady:!0}))},removeElement:m=>{delete r[m]},mute(){for(let m of l())m.muted=!0;p({isMuted:!0})},unmute(){for(let m of l())m.muted=!1;p({isMuted:!1})},play(){if(!S().isPlaying){for(let v of c())v.play();p({isPlaying:!0})}},pause(){if(S().isPlaying){for(let v of c())v.pause();p({isPlaying:!1})}},playPause(){let m=S();m.isPlaying?m.pause():m.play()},setDurationPercent(m){let I=S().duration*m;S().setTime(I)},setTime(m){let v=S(),I=a/1e3,x=typeof m=="function"?m(I):m,P=v.nextKeyframeIndex;if(I>x){p({visibleElements:{},currentPrime:null});let L=Object.keys(v.visibleElements);for(let j of L)t.emit("complex-timeline.exit",{id:j});I=0,P=0}let[C,_]=Kn({currentTime:I,currentKeyFrameIndex:P,keyframes:v.complexTimeline.keyframes,targetTime:x});v.applyKeyframes(C,_),a=x*1e3;let xe=b.getState().visibleElements,Se=r,qe=Object.keys(xe);for(let L of qe){let j=xe[L];if(j){let Z=Se[L];Z&&(Z.currentTime=(a-j.time*1e3)/1e3)}}d(x)},setVolume(m){for(let v of l())v.volume=Math.min(1,Math.max(0,m/100));p({volume:m})},toggleMute(){let m=S();m.isMuted?(m.unmute(),p({isMuted:!1})):(m.mute(),p({isMuted:!0}))},clearProgressElement(){o.progress=null},setProgressElement(m){o.progress=m},setCurrentTimeElement(m){o.currentTime=m},clearCurrentTimeElement(){o.currentTime=null}}));return t.on("complex-timeline.enter",p=>{let S=b.getState(),m=p.id,v=r[m];v&&S.isPlaying&&v.play()}),t.on("complex-timeline.exit",p=>{let S=b.getState(),m=p.id,v=r[m];v&&(v.currentTime=0,v.pause())}),b.getState().setTime(n),{store:b,emitter:t}}import{HTMLPortal as Mi}from"@atlas-viewer/atlas";import{useStore as Gn}from"zustand";import{createContext as Ci,useContext as Ai}from"react";import{useStore as bi}from"zustand";import{jsx as Pi}from"react/jsx-runtime";var ft=Ci(null);ft.displayName="ComplexTimeline";function Qn({children:e,store:n}){return Pi(ft.Provider,{value:n,children:e})}function gm(e){let n=Ai(ft);if(!n)throw new Error("useComplexTimeline must be used within a ComplexTimelineProvider");return bi(n,e)}import{HTMLPortal as Ri}from"@atlas-viewer/atlas";import{Fragment as Wn,jsx as ye}from"react/jsx-runtime";function $e({strategy:e,onClickPaintingAnnotation:n}){return ye(Wn,{children:e.items.map((t,r)=>ye(Wn,{children:ye(Ri,{onClick:n?o=>{o.stopPropagation(),n(t.annotationId,t,o)}:void 0,target:t.target?.spatial||void 0,children:ye("div",{"data-textual-content":!0,children:ye(he,{enableDangerouslySetInnerHTML:!0,children:t.text})})},r)}))})}import{Fragment as wi,jsx as De,jsxs as Ei}from"react/jsx-runtime";function Zn({strategy:e,children:n}){let{store:t}=Ii(()=>Yn({complexTimeline:e}),[e]),r=Gn(t,i=>i.isReady),o=Gn(t,i=>i.visibleElements);function s(i){return a=>{a&&t.getState().setElement(i,a)}}return Ti(()=>{if(r){let{startClock:i,stopClock:a}=t.getState();return i(),()=>{a()}}},[e,r]),O("portal","custom-controls",Qn,{store:t,children:n},[r]),Ei(wi,{children:[e.items.map(i=>i.type!=="Image"||!o[i.annotationId]?null:De(se,{image:i,id:i.annotationId},i.id)),e.items.map((i,a)=>i.type!=="Text"||!o[i.annotationId]?null:De($e,{strategy:{type:"textual-content",items:[i]}},a)),e.items.map((i,a)=>i.type!=="Video"||!i.target.spatial?null:De(Mi,{target:i.target.spatial,children:De("video",{ref:s(i.annotationId),src:i.url,style:{height:"100%",width:"100%",opacity:o[i.annotationId]?1:0}})},a))]})}import{Fragment as Ue,jsx as k,jsxs as Y}from"react/jsx-runtime";function ce({x:e,y:n,onChoiceChange:t,registerActions:r,defaultChoices:o,isStatic:s,renderViewerControls:i,renderMediaControls:a,renderComplexTimelineControls:u,viewControlsDeps:c,mediaControlsDeps:l,strategies:d,throwOnUnknown:y,backgroundStyle:A,alwaysShowBackground:h,keepCanvasScale:g=!1,enableSizes:b=!1,enableYouTube:p=!0,onClickPaintingAnnotation:S,children:m}){let v=M(),I=Te(v,["deep-zoom"]),[x]=tn(),P=on(),C=R(),_=Xn(()=>Vi(C),[C]),[f,xe]=On({strategies:d||["images"],defaultChoices:o?.map(({id:w})=>w)}),Se=f.type==="images"?f.choice:void 0,qe=Xn(()=>g?1:Math.max(1,...f.type==="images"?f.images.map(w=>(w.width||0)/w.target?.spatial.width):[]),[g,f]);sn(qe),Jn(()=>{r&&r(xe)},[f.annotations]),Jn(()=>{if(o)for(let w of o)typeof w.opacity<"u"&&_.applyStyles({id:w.id},"atlas",{opacity:w.opacity})},[o]),Ni(()=>{t&&t(Se)},[Se]),O(P&&(f.type==="images"||f.type==="empty"||f.type==="textual-content"&&i)?"overlay":"none",`canvas-portal-controls-${v?.id}`,ge.Provider,i?{value:P||null,children:i(f)}:{},[v,P,f,...c||[]]);let L=Ee({maxWidth:256,maxHeight:256});if(!v)return null;let j=v.accompanyingCanvas,Z=v.placeholderCanvas,le=L&&L.type==="fixed"?k("world-object",{height:v.height,width:v.width,x:e,y:n,children:k("world-image",{uri:L.id,target:{x:0,y:0,width:v.width,height:v.height},display:L.width&&L.height?{width:L.width,height:L.height}:void 0,crop:void 0})}):null;if(f.type==="unknown"){if(le)return le;if(y)throw new Error(f.reason||"Unknown image strategy");return null}let pt=Y(ki,{children:[x?k(ve,{page:x}):null,f.annotations&&f.annotations.pages?f.annotations.pages.map(w=>k(ve,{page:w},w.id)):null,m]}),tr=f.type==="images"?f.images.length:0,Fi=f.type==="media"&&f.media.type==="Video"&&Z?k(Fe,{renderViewerControls:i}):null;return Y(Ue,{children:[Y("world-object",{height:v.height,width:v.width,x:e,y:n,...I,children:[f.type==="empty"||h?k(He,{style:A}):null,f.type==="complex-timeline"?k(Zn,{strategy:f,children:u?u(f):null}):null,f.type==="textual-content"?Y(Ue,{children:[k($e,{strategy:f,onClickPaintingAnnotation:S}),pt]}):null,f.type==="images"?Y(Ue,{children:[f.images.map((w,gt)=>k(se,{isStatic:s,image:w,id:w.id,thumbnail:gt===0?L:void 0,selector:w.selector,enableSizes:b,onClick:S?vt=>{vt.stopPropagation(),S(w.annotationId,w,vt)}:void 0},w.id+gt)),pt]}):null,f.type==="3d-model"?k(Oe,{model:f.model}):null,f.type==="media"?k(Ue,{children:f.media.type==="Sound"?Y(Le,{media:f.media,mediaControlsDeps:l,children:[le,a?a(f):null]}):f.media.type==="Video"?Y(ze,{media:f.media,mediaControlsDeps:l,children:[le,a?a(f):null]}):f.media.type==="VideoYouTube"&&p?Y(jn,{media:f.media,mediaControlsDeps:l,children:[le,a?a(f):null]}):null}):null]},`${v.id}/${f.type}/${tr}`),f.type==="media"&&f.media.type==="Sound"&&j?k(q,{canvas:j.id,children:k(ce,{renderViewerControls:i})}):null,f.type==="media"&&f.media.type==="Sound"&&Z&&!j?k(q,{canvas:Z.id,children:k(ce,{renderViewerControls:i})}):null]})}import{Fragment as Oi,jsx as U,jsxs as Hi}from"react/jsx-runtime";var zi=er(function(n,t){let r=E(),o=Ae(),s=Kt(),{ViewerControls:i,MediaControls:a,ComplexTimelineControls:u}=n.components||{};if(Li(t,()=>s,[s]),!r)return U("div",{});let c=0;return Hi(Oi,{children:[n.header,U(N.Viewer,{height:n.height,mode:n.mode,renderPreset:n.renderPreset,runtimeOptions:n.runtimeOptions,children:o.map((l,d)=>{let y=c;return c+=l.width+(n.spacing||0),U(q,{canvas:l.id,children:U(N.RenderCanvas,{strategies:["3d-model","media","images","empty","textual-content","complex-timeline"],renderViewerControls:d===0&&i?()=>U(i,{}):void 0,renderMediaControls:d===0&&a?()=>U(a,{}):void 0,renderComplexTimelineControls:d===0&&u?()=>U(u,{}):void 0,x:y,...n.canvasProps||{},children:n.annotations},l.id)},l.id)})},n.reuseAtlas?"":s.currentSequenceIndex),n.children]})}),N=er(function({children:n,height:t,annotations:r,canvasProps:o,spacing:s,header:i,components:a,mode:u,reuseAtlas:c,renderPreset:l,runtimeOptions:d,...y},A){let h=X();return U(J,{vault:h,children:U(jt,{...y,children:U(zi,{ref:A,height:t,components:a,spacing:s,canvasProps:o,annotations:r,header:i,mode:u,reuseAtlas:c,renderPreset:l,runtimeOptions:d,children:n})})})});N.RenderImage=se;N.RenderCanvas=ce;N.RenderAnnotationPage=ve;N.RenderAnnotation=Me;N.Viewer=ln;N.CanvasBackground=He;N.Audio=Le;N.Video=ze;N.Model=Oe;N.AudioHTML=ct;N.VideoHTML=lt;N.ModelHTML=mt;N.PlaceholderCanvas=Fe;export{Ce as a,H as b,K as c,Q as d,J as e,X as f,Ct as g,At as h,bt as i,q as j,R as k,T as l,ee as m,Ae as n,E as o,Pt as p,br as q,_e as r,La as s,Rt as t,Ha as u,je as v,Tt as w,It as x,Ga as y,Et as z,Vt as A,kt as B,Ke as C,Mt as D,te as E,Vr as F,kr as G,$t as H,Dt as I,me as J,Nr as K,ps as L,Lr as M,Ht as N,gs as O,Ut as P,Bt as Q,pe as R,jr as S,jt as T,Kt as U,Gr as V,re as W,Yt as X,au as Y,Qt as Z,Wt as _,Gt as $,Xt as aa,tn as ba,nn as ca,ge as da,on as ea,M as fa,Te as ga,ie as ha,Ie as ia,mn as ja,Xc as ka,el as la,tl as ma,yn as na,rt as oa,xn as pa,ko as qa,No as ra,Lo as sa,nl as ta,he as ua,Tn as va,Mn as wa,wn as xa,jo as ya,we as za,En as Aa,Vn as Ba,Nn as Ca,On as Da,Hn as Ea,Ee as Fa,it as Ga,ue as Ha,xd as Ia,Sd as Ja,Cd as Ka,ke as La,Ne as Ma,Qn as Na,gm as Oa,N as Pa};