react-iiif-vault 1.3.6 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { S as SimpleViewerContext, a as SimpleViewerProps } from './index-D1lST-Xy.js';
2
- export { C as CanvasPanel, c as SimpleViewerActions, d as SimpleViewerActionsType, b as SimpleViewerReducerState } from './index-D1lST-Xy.js';
1
+ import { S as SimpleViewerContext, a as SimpleViewerProps } from './index-CnXzAuQK.js';
2
+ export { C as CanvasPanel, c as SimpleViewerActions, d as SimpleViewerActionsType, b as SimpleViewerReducerState } from './index-CnXzAuQK.js';
3
3
  import * as React$1 from 'react';
4
- import React__default, { ReactNode, FunctionComponent, RefObject } from 'react';
4
+ import React__default, { ReactNode, FunctionComponent, RefObject, Context } from 'react';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import { InternationalString, ImageService, ImageSize, AuthProbeService2, Auth2LocationResource, Auth2SubstituteResource, AuthAccessService2, AuthAccessTokenService2, AuthAccessToken2, SearchServiceQueryParams, SearchServiceSearchResponse, SearchService as SearchService$1, SearchServiceAutocomplete, Reference, Annotation } from '@iiif/presentation-3';
7
7
  import { RegionParameter, RotationParameter, SizeParameter, ImageServiceLoader, ImageCandidateRequest, ImageCandidate } from '@atlas-viewer/iiif-image-api';
@@ -12,13 +12,13 @@ import * as zustand_vanilla from 'zustand/vanilla';
12
12
  import { StoreApi } from 'zustand/vanilla';
13
13
  import * as zustand from 'zustand';
14
14
  import { StoreApi as StoreApi$1 } from 'zustand';
15
- import { C as ComplexTimelineStrategy, T as TimelineKeyframe, U as UnknownStrategy, M as MediaStrategy, d as ImageServiceLoaderType } from './useRenderingStrategy-2EaRC2Nc.js';
16
- export { f as AnnotationPageDescription, A as AudioSequence, n as ChoiceEvents, E as EmptyStrategy, I as ImageWithOptionalService, R as RenderingStrategy, k as Single3DModelStrategy, b as SingleAudio, a as SingleImageStrategy, c as SingleVideo, e as SingleYouTubeVideo, S as StrategyActions, i as TextContent, h as TextualContentStrategy, m as UseRenderingStrategy, o as UseRenderingStrategyOptions, V as VideoSequence, l as get3dStrategy, g as getImageStrategy, j as getTextualContentStrategy, u as useLoadImageService, p as useRenderingStrategy } from './useRenderingStrategy-2EaRC2Nc.js';
15
+ import { C as ComplexTimelineStrategy, T as TimelineKeyframe, U as UnknownStrategy, M as MediaStrategy, d as ImageServiceLoaderType } from './useRenderingStrategy-DkjxMKJV.js';
16
+ export { f as AnnotationPageDescription, A as AudioSequence, n as ChoiceEvents, E as EmptyStrategy, I as ImageWithOptionalService, R as RenderingStrategy, k as Single3DModelStrategy, S as SingleAudio, c as SingleImageStrategy, a as SingleVideo, e as SingleYouTubeVideo, b as StrategyActions, i as TextContent, h as TextualContentStrategy, m as UseRenderingStrategy, o as UseRenderingStrategyOptions, V as VideoSequence, l as get3dStrategy, g as getImageStrategy, j as getTextualContentStrategy, u as useLoadImageService, p as useRenderingStrategy } from './useRenderingStrategy-DkjxMKJV.js';
17
17
  import * as mitt from 'mitt';
18
18
  import { Emitter, EventType, Handler } from 'mitt';
19
19
  import { Vault, VaultOptions, NormalizedEntity, IIIFStore } from '@iiif/helpers/vault';
20
20
  import * as _iiif_helpers from '@iiif/helpers';
21
- import { Paintables, ComplexChoice } from '@iiif/helpers';
21
+ import { Paintables, Vault as Vault$1, ComplexChoice } from '@iiif/helpers';
22
22
  import { CanvasNormalized, AnnotationNormalized, AnnotationPageNormalized, CollectionNormalized, ManifestNormalized, RangeNormalized } from '@iiif/presentation-3-normalized';
23
23
  export { emptyActions, emptyStrategy, getParsedTargetSelector, getRenderingStrategy, parseSpecificResource, unknownResponse, unsupportedStrategy } from './utils.js';
24
24
  import { VaultZustandStore } from '@iiif/helpers/vault/store';
@@ -599,6 +599,20 @@ interface Search1Store {
599
599
  nextResult: () => void;
600
600
  }
601
601
 
602
+ declare function useCustomContextBridge(): Record<string, {
603
+ value: any;
604
+ Provider: React__default.Provider<any>;
605
+ }>;
606
+ declare function CustomContextBridge(props: Record<string, {
607
+ value: any;
608
+ Provider: React__default.Provider<any>;
609
+ }> & {
610
+ children: React__default.ReactNode;
611
+ }): ReactNode;
612
+ declare function CustomContextBridgeProvider(props: {
613
+ providers: Record<string, Context<any>>;
614
+ children: React__default.ReactNode;
615
+ }): react_jsx_runtime.JSX.Element;
602
616
  declare function useContextBridge(): {
603
617
  VaultContext: {
604
618
  vault: _iiif_helpers.Vault | null;
@@ -615,6 +629,7 @@ declare function useContextBridge(): {
615
629
  };
616
630
  declare function ContextBridge(props: {
617
631
  bridge: ReturnType<typeof useContextBridge>;
632
+ custom?: ReturnType<typeof useCustomContextBridge>;
618
633
  children: ReactNode;
619
634
  }): react_jsx_runtime.JSX.Element;
620
635
 
@@ -727,9 +742,9 @@ declare function AnnotationStyleProvider({ theme, children, }: {
727
742
  children: React.ReactNode;
728
743
  }): react_jsx_runtime.JSX.Element;
729
744
 
730
- declare function getVideoStrategy(canvas: CanvasNormalized, paintables: Paintables): UnknownStrategy | MediaStrategy;
745
+ declare function getVideoStrategy(canvas: CanvasNormalized, paintables: Paintables, vault: Vault$1): UnknownStrategy | MediaStrategy;
731
746
 
732
- declare function getComplexTimelineStrategy(canvas: CanvasNormalized, paintables: Paintables, loadImageService: ImageServiceLoaderType): ComplexTimelineStrategy;
747
+ declare function getComplexTimelineStrategy(canvas: CanvasNormalized, paintables: Paintables, loadImageService: ImageServiceLoaderType, vault: Vault$1): ComplexTimelineStrategy;
733
748
 
734
749
  declare function useAnnotation(options?: {
735
750
  id: string;
@@ -1120,4 +1135,4 @@ declare function findAllCanvasesInRange(vault: Vault, range: RangeNormalized): A
1120
1135
  declare function findManifestSelectedRange(vault: Vault, manifest: ManifestNormalized, canvasId: string): null | RangeNormalized;
1121
1136
  declare function findSelectedRange(vault: Vault, range: RangeNormalized, canvasId: string): null | RangeNormalized;
1122
1137
 
1123
- export { AnnotationContext, AnnotationPageContext, AnnotationStyleProvider, type AnnotationStyles, type AnnotationThemeDefinition, Auth, type AuthAccessState, type AuthContextActions, type AuthContextCurrentActions, type AuthContextState, AuthProvider, AuthRContext, AuthReactContext, AuthReactContextActions, type AuthState, CanvasAnnotations, CanvasContext, CollectionContext, CombinedMetadata, ComplexTimelineProvider, ComplexTimelineStrategy, ContextBridge, CreateCustomShape, type CreateCustomShapeProps, EventsProvider, Image, type ImageProps, ImageServiceLoaderContext, ImageServiceLoaderType, type ImageServiceRequestOptions, InnerViewerProvider, LanguageProvider, LanguageString, LocaleString, ManifestContext, ManifestMetadata, type MediaPlayerActions, MediaPlayerProvider, type MediaPlayerState, MediaStrategy, Metadata, type MetadataProps, PolygonSelector, type PolygonSelectorProps, type ProbeStore, RangeContext, ReactEventContext, ReactVaultContext, RenderSvgEditorControls, type ResourceContextType, ResourceProvider, ResourceReactContext, type ResourceRequestOptions, SelectorControllerProvider, type SelectorHelperEventTypes, SequenceThumbnails, SimpleViewerContext, SimpleViewerProps, SimpleViewerProvider, SimpleViewerReactContext, SingleCanvasThumbnail, type SvgTheme, TimelineKeyframe, TranslationProvider, TransliterationProvider, UnknownStrategy, type VaultActivatedAnnotation, VaultProvider, ViewerPresetContext, VirtualAnnotationProvider, VisibleCanvasReactContext, authDetailsForResource, createAuthStateStore, createProbe, defaultEmitter, findAllCanvasesInRange, findFirstCanvasFromRange, findManifestSelectedRange, findSelectedRange, flattenAnnotationPageIds, formatTime, getComplexTimelineStrategy, getDefaultAnnotationStyles, getManifestSequence, getVideoStrategy, getVisibleCanvasesFromCanvasId, hasAuth, makeAccessServiceRequest, makeAccessTokenRequest, svgThemes, useAnnotation, useAnnotationPage, useAnnotationPageManager, useAnnotationStyles, useAnnotationsAtTime, useAuthActions, useAuthService, useAuthStore, useAuthToken, useAuthTokens, useCanvas, useCanvasChoices, useCanvasClock, useCanvasSequence, useCanvasStartTime, useCanvasSubset, useClosestLanguage, useCollection, useComplexTimeline, useContextBridge, useCreateLocaleString, useCurrentAuth, useDispatch, useEventEmitter, useEventListener, useExistingVault, useExternalCollection, useExternalManifest, useExternalResource, useIIIFLanguage, useImage, useImageService, useImageServiceLoader, useImageTile, useIsAuthEnabled, useLocaleString, useManifest, useMediaActions, useMediaElements, useMediaState, usePaintables, usePaintingAnnotations, usePolygonHelper, useRange, useResourceContext, useResourceEvents, useResources, useSearchService, useSelectorController, useSelectorEmitter, useSelectorEvents, useSelectorHelper, useSimpleMediaPlayer, useSimpleViewer, useStyleHelper, useStyles, useSvgEditor, useThumbnail, useTranslations, useTransliteration, useVault, useVaultEffect, useVaultSelector, useViewerPreset, useVirtualAnnotationPage, useVirtualAnnotationPageContext, useVisibleCanvases };
1138
+ export { AnnotationContext, AnnotationPageContext, AnnotationStyleProvider, type AnnotationStyles, type AnnotationThemeDefinition, Auth, type AuthAccessState, type AuthContextActions, type AuthContextCurrentActions, type AuthContextState, AuthProvider, AuthRContext, AuthReactContext, AuthReactContextActions, type AuthState, CanvasAnnotations, CanvasContext, CollectionContext, CombinedMetadata, ComplexTimelineProvider, ComplexTimelineStrategy, ContextBridge, CreateCustomShape, type CreateCustomShapeProps, CustomContextBridge, CustomContextBridgeProvider, EventsProvider, Image, type ImageProps, ImageServiceLoaderContext, ImageServiceLoaderType, type ImageServiceRequestOptions, InnerViewerProvider, LanguageProvider, LanguageString, LocaleString, ManifestContext, ManifestMetadata, type MediaPlayerActions, MediaPlayerProvider, type MediaPlayerState, MediaStrategy, Metadata, type MetadataProps, PolygonSelector, type PolygonSelectorProps, type ProbeStore, RangeContext, ReactEventContext, ReactVaultContext, RenderSvgEditorControls, type ResourceContextType, ResourceProvider, ResourceReactContext, type ResourceRequestOptions, SelectorControllerProvider, type SelectorHelperEventTypes, SequenceThumbnails, SimpleViewerContext, SimpleViewerProps, SimpleViewerProvider, SimpleViewerReactContext, SingleCanvasThumbnail, type SvgTheme, TimelineKeyframe, TranslationProvider, TransliterationProvider, UnknownStrategy, type VaultActivatedAnnotation, VaultProvider, ViewerPresetContext, VirtualAnnotationProvider, VisibleCanvasReactContext, authDetailsForResource, createAuthStateStore, createProbe, defaultEmitter, findAllCanvasesInRange, findFirstCanvasFromRange, findManifestSelectedRange, findSelectedRange, flattenAnnotationPageIds, formatTime, getComplexTimelineStrategy, getDefaultAnnotationStyles, getManifestSequence, getVideoStrategy, getVisibleCanvasesFromCanvasId, hasAuth, makeAccessServiceRequest, makeAccessTokenRequest, svgThemes, useAnnotation, useAnnotationPage, useAnnotationPageManager, useAnnotationStyles, useAnnotationsAtTime, useAuthActions, useAuthService, useAuthStore, useAuthToken, useAuthTokens, useCanvas, useCanvasChoices, useCanvasClock, useCanvasSequence, useCanvasStartTime, useCanvasSubset, useClosestLanguage, useCollection, useComplexTimeline, useContextBridge, useCreateLocaleString, useCurrentAuth, useCustomContextBridge, useDispatch, useEventEmitter, useEventListener, useExistingVault, useExternalCollection, useExternalManifest, useExternalResource, useIIIFLanguage, useImage, useImageService, useImageServiceLoader, useImageTile, useIsAuthEnabled, useLocaleString, useManifest, useMediaActions, useMediaElements, useMediaState, usePaintables, usePaintingAnnotations, usePolygonHelper, useRange, useResourceContext, useResourceEvents, useResources, useSearchService, useSelectorController, useSelectorEmitter, useSelectorEvents, useSelectorHelper, useSimpleMediaPlayer, useSimpleViewer, useStyleHelper, useStyles, useSvgEditor, useThumbnail, useTranslations, useTransliteration, useVault, useVaultEffect, useVaultSelector, useViewerPreset, useVirtualAnnotationPage, useVirtualAnnotationPageContext, useVisibleCanvases };
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 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};
1
+ import{$ as wo,A as to,Aa as nn,B as oo,Ba as se,C as no,Ca as rn,D as ro,Da as an,E as io,Ea as D,F as ao,Fa as sn,G as so,Ga as pn,H as lo,Ha as gn,I as co,Ia as le,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 Cn,Q as vo,Qa as In,R as xo,Ra as kn,S as bo,Sa as ce,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 Lo,g as te,ga as Ho,h as $t,ha as Ao,i as Vt,ia as T,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 Ko,v as Jt,va as Qo,w as re,wa as Uo,x as Zt,xa as N,y as jt,ya as Go,z as eo,za as W}from"./chunk-7KUFVAUD.js";import{a as Jo,b as Zo,c as jo,d as en,e as tn,f as on,g as ln,h as cn,i as mn,j as un,k as dn,l as fn}from"./chunk-CCTBCLBV.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 Mn=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 Vn(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 ir(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 vr({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 Sr({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 Er({children:e}){return ct(V.Provider,{value:G(()=>ve(),[]),children:e})}function Mr(){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 Nr(){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 Ar({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 mi(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 pi({annotation:e,children:t}){return It(B,{value:{annotation:e},children:t})}import{jsx as kt}from"react/jsx-runtime";function vi({annotationPage:e,children:t}){return kt(B,{value:{annotationPage:e},children:t})}import{jsx as Pt}from"react/jsx-runtime";function Ci({collection:e,children:t}){return Pt(B,{value:{collection:e},children:t})}function Ti(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 Bi({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 Hi(e,t=!1){}function Wi(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 Vi(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 Qi(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 Zi(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 la(){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 fa(){let e=P();return At(()=>Ht(e),[e])}export*from"@iiif/helpers/annotation-targets";export{pi as AnnotationContext,vi as AnnotationPageContext,Ar as AnnotationStyleProvider,yo as Auth,lo as AuthProvider,io as AuthRContext,ao as AuthReactContext,so as AuthReactContextActions,Mn as CanvasAnnotations,oe as CanvasContext,ce as CanvasPanel,Ci as CollectionContext,Vn as CombinedMetadata,In as ComplexTimelineProvider,Eo as ContextBridge,Me as CreateCustomShape,To as CustomContextBridge,wo as CustomContextBridgeProvider,ko as EventsProvider,Ze as Image,Go as ImageServiceLoaderContext,bo as InnerViewerProvider,Oo as LanguageProvider,_o as LanguageString,N as LocaleString,Vt as ManifestContext,ir as ManifestMetadata,Sn as MediaPlayerProvider,O as Metadata,mi as PolygonSelector,Yt as RangeContext,Io as ReactEventContext,Dt as ReactVaultContext,Sr as RenderSvgEditorControls,B as ResourceProvider,Wt as ResourceReactContext,Er as SelectorControllerProvider,vr as SequenceThumbnails,So as SimpleViewerProvider,xo as SimpleViewerReactContext,de as SingleCanvasThumbnail,Fo as TranslationProvider,$o as TransliterationProvider,Ft as VaultProvider,Ho as ViewerPresetContext,Lo as VirtualAnnotationProvider,Xt as VisibleCanvasReactContext,oo as authDetailsForResource,eo as createAuthStateStore,to as createProbe,Co as defaultEmitter,jo as emptyActions,on as emptyStrategy,Kt as findAllCanvasesInRange,_t as findFirstCanvasFromRange,Qt as findManifestSelectedRange,Ut as findSelectedRange,nn as flattenAnnotationPageIds,hn as formatTime,ln as get3dStrategy,dn as getComplexTimelineStrategy,Se as getDefaultAnnotationStyles,cn as getImageStrategy,Jt as getManifestSequence,Zo as getParsedTargetSelector,fn as getRenderingStrategy,mn as getTextualContentStrategy,un as getVideoStrategy,Gt as getVisibleCanvasesFromCanvasId,jt as hasAuth,ro as makeAccessServiceRequest,no as makeAccessTokenRequest,Jo as parseSpecificResource,Ct as svgThemes,en as unknownResponse,tn as unsupportedStrategy,Wo as useAnnotation,Do as useAnnotationPage,se as useAnnotationPageManager,Ce as useAnnotationStyles,Ti as useAnnotationsAtTime,uo as useAuthActions,po as useAuthService,mo as useAuthStore,ho as useAuthToken,go as useAuthTokens,T as useCanvas,Bi as useCanvasChoices,Hi as useCanvasClock,Zt as useCanvasSequence,Cn as useCanvasStartTime,Wi as useCanvasSubset,Ko as useClosestLanguage,Vi as useCollection,kn as useComplexTimeline,Ro as useContextBridge,Uo as useCreateLocaleString,fo as useCurrentAuth,Po as useCustomContextBridge,Mo as useDispatch,ae as useEventEmitter,Qi as useEventListener,Ot as useExistingVault,Zi as useExternalCollection,$t as useExternalManifest,te as useExternalResource,Xo as useIIIFLanguage,Q as useImage,He as useImageService,W as useImageServiceLoader,la as useImageTile,co as useIsAuthEnabled,an as useLoadImageService,Qo as useLocaleString,q as useManifest,xn as useMediaActions,bn as useMediaElements,vn as useMediaState,sn as usePaintables,D as usePaintingAnnotations,Ie as usePolygonHelper,re as useRange,pn as useRenderingStrategy,A as useResourceContext,zo as useResourceEvents,rn as useResources,vo as useSearchService,be as useSelectorController,Mr as useSelectorEmitter,xe as useSelectorEvents,Nr as useSelectorHelper,yn as useSimpleMediaPlayer,ie as useSimpleViewer,fa as useStyleHelper,qo as useStyles,Re as useSvgEditor,le as useThumbnail,Yo as useTranslations,Vo as useTransliteration,P as useVault,gn as useVaultEffect,z as useVaultSelector,Ao as useViewerPreset,No as useVirtualAnnotationPage,Bo as useVirtualAnnotationPageContext,ne as useVisibleCanvases};
@@ -108,6 +108,13 @@ type MediaStrategy = {
108
108
  media: SingleAudio | SingleVideo | AudioSequence | VideoSequence | SingleYouTubeVideo;
109
109
  choice?: ChoiceDescription;
110
110
  annotations?: AnnotationPageDescription;
111
+ captions?: Array<{
112
+ id: string;
113
+ type: string;
114
+ format: string;
115
+ label?: InternationalString;
116
+ language?: string;
117
+ }>;
111
118
  };
112
119
  type ComplexTimelineStrategy = {
113
120
  type: 'complex-timeline';
@@ -170,4 +177,4 @@ type UseRenderingStrategyOptions = {
170
177
  };
171
178
  declare function useRenderingStrategy(options?: UseRenderingStrategyOptions): UseRenderingStrategy;
172
179
 
173
- export { type AudioSequence as A, type ComplexTimelineStrategy as C, type EmptyStrategy as E, type ImageWithOptionalService as I, type MediaStrategy as M, type RenderingStrategy as R, type StrategyActions as S, type TimelineKeyframe as T, type UnknownStrategy as U, type VideoSequence as V, type SingleImageStrategy as a, type SingleAudio as b, type SingleVideo as c, type ImageServiceLoaderType as d, type SingleYouTubeVideo as e, type AnnotationPageDescription as f, getImageStrategy as g, type TextualContentStrategy as h, type TextContent as i, getTextualContentStrategy as j, type Single3DModelStrategy as k, get3dStrategy as l, type UseRenderingStrategy as m, type ChoiceEvents as n, type UseRenderingStrategyOptions as o, useRenderingStrategy as p, useLoadImageService as u };
180
+ export { type AudioSequence as A, type ComplexTimelineStrategy as C, type EmptyStrategy as E, type ImageWithOptionalService as I, type MediaStrategy as M, type RenderingStrategy as R, type SingleAudio as S, type TimelineKeyframe as T, type UnknownStrategy as U, type VideoSequence as V, type SingleVideo as a, type StrategyActions as b, type SingleImageStrategy as c, type ImageServiceLoaderType as d, type SingleYouTubeVideo as e, type AnnotationPageDescription as f, getImageStrategy as g, type TextualContentStrategy as h, type TextContent as i, getTextualContentStrategy as j, type Single3DModelStrategy as k, get3dStrategy as l, type UseRenderingStrategy as m, type ChoiceEvents as n, type UseRenderingStrategyOptions as o, useRenderingStrategy as p, useLoadImageService as u };
@@ -108,6 +108,13 @@ type MediaStrategy = {
108
108
  media: SingleAudio | SingleVideo | AudioSequence | VideoSequence | SingleYouTubeVideo;
109
109
  choice?: ChoiceDescription;
110
110
  annotations?: AnnotationPageDescription;
111
+ captions?: Array<{
112
+ id: string;
113
+ type: string;
114
+ format: string;
115
+ label?: InternationalString;
116
+ language?: string;
117
+ }>;
111
118
  };
112
119
  type ComplexTimelineStrategy = {
113
120
  type: 'complex-timeline';
@@ -170,4 +177,4 @@ type UseRenderingStrategyOptions = {
170
177
  };
171
178
  declare function useRenderingStrategy(options?: UseRenderingStrategyOptions): UseRenderingStrategy;
172
179
 
173
- export { type AudioSequence as A, type ComplexTimelineStrategy as C, type EmptyStrategy as E, type ImageWithOptionalService as I, type MediaStrategy as M, type RenderingStrategy as R, type StrategyActions as S, type TimelineKeyframe as T, type UnknownStrategy as U, type VideoSequence as V, type SingleImageStrategy as a, type SingleAudio as b, type SingleVideo as c, type ImageServiceLoaderType as d, type SingleYouTubeVideo as e, type AnnotationPageDescription as f, getImageStrategy as g, type TextualContentStrategy as h, type TextContent as i, getTextualContentStrategy as j, type Single3DModelStrategy as k, get3dStrategy as l, type UseRenderingStrategy as m, type ChoiceEvents as n, type UseRenderingStrategyOptions as o, useRenderingStrategy as p, useLoadImageService as u };
180
+ export { type AudioSequence as A, type ComplexTimelineStrategy as C, type EmptyStrategy as E, type ImageWithOptionalService as I, type MediaStrategy as M, type RenderingStrategy as R, type SingleAudio as S, type TimelineKeyframe as T, type UnknownStrategy as U, type VideoSequence as V, type SingleVideo as a, type StrategyActions as b, type SingleImageStrategy as c, type ImageServiceLoaderType as d, type SingleYouTubeVideo as e, type AnnotationPageDescription as f, getImageStrategy as g, type TextualContentStrategy as h, type TextContent as i, getTextualContentStrategy as j, type Single3DModelStrategy as k, get3dStrategy as l, type UseRenderingStrategy as m, type ChoiceEvents as n, type UseRenderingStrategyOptions as o, useRenderingStrategy as p, useLoadImageService as u };
package/dist/utils.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var I=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var V=(e,t)=>{for(var i in t)I(e,i,{get:t[i],enumerable:!0})},U=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of O(t))!A.call(e,o)&&o!==i&&I(e,o,{get:()=>t[o],enumerable:!(r=D(t,o))||r.enumerable});return e};var W=e=>U(I({},"__esModule",{value:!0}),e);var G={};V(G,{emptyActions:()=>L,emptyStrategy:()=>w,getParsedTargetSelector:()=>f,getRenderingStrategy:()=>F,parseSpecificResource:()=>M,unknownResponse:()=>S,unsupportedStrategy:()=>m});module.exports=W(G);var P=require("@iiif/helpers");function M(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function f(e,t){let{selector:i,source:r}=(0,P.expandTarget)(t);if(r.id!==e.id)return[null,r];let o={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}};return[i?i.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:i.temporal,spatial:o.spatial}:i:null,r]}var L={makeChoice:()=>{}},S={type:"unknown"},m=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),w=(e,t)=>({type:"empty",width:e,height:t,annotations:{pages:[]},image:null,images:[]});var E=["model/gltf-binary"];function k(e,t){let r=t.items[0].resource;return r.format?E.indexOf(r.format)===-1?m(`3D format: ${r.format} is unsupported`):{type:"3d-model",model:r}:m("Unknown format")}function R(e,t){if(!e.duration)return m("No duration on canvas");if(t.items.length>1)return m("Only one audio source supported");let i=t.items[0]?.resource;return i?i.format?{type:"media",media:{annotationId:t.items[0].annotationId,duration:e.duration,url:i.id,type:"Sound",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:i.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:m("Audio does not have format"):m("Unknown audio")}var v=require("@atlas-viewer/iiif-image-api");var b=require("@iiif/helpers/annotation-targets");function h(e,t,i){let r=[];for(let o of t.items){let p=o.resource&&o.resource.type==="SpecificResource"?o.resource.source:o.resource;if(!p.id)return m("No resource Identifier");let c;if(p.service){let y=(0,v.getImageServices)(p);y[0]&&(c=i(y[0],e))}let d={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[n,a]=f(e,o.target),s=e.id?.split("?")[0]||"";if(!(a.id===e.id||decodeURIComponent(a.id||"")===(e.id||"")||a.id===s||decodeURIComponent(a.id||"")===s))continue;let l=o.resource.width&&o.resource.height?{type:"BoxSelector",spatial:{x:0,y:0,width:o.resource.width,height:o.resource.height}}:void 0,u=o.resource.type==="SpecificResource"?(0,b.expandTarget)(o.resource):null;if(o.selector){let y=(0,b.expandTarget)({type:"SpecificResource",source:o.resource,selector:o.selector});y&&(u=y)}let g=u&&u.selector&&(u.selector.type==="BoxSelector"||u.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:u.selector.spatial.x,y:u.selector.spatial.y,width:u.selector.spatial.width,height:u.selector.spatial.height}}:void 0;c&&!c.id&&(c.id=c["@id"]);let B={id:p.id,type:"Image",annotationId:o.annotationId,width:Number(n||g?p.width:e.width),height:Number(n||g?p.height:e.height),service:c,sizes:c&&c.sizes?c.sizes:p.width&&p.height?[{width:p.width,height:p.height}]:[],target:n&&n.type!=="PointSelector"?n:d,selector:g||{type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}}};r.push(B)}return{type:"images",image:r[0],images:r,choice:t.choice}}function N(e,t={},i){let r=e.language||i||"none";switch(e.type){case"TextualBody":{typeof e.value<"u"&&(t[r]=[e.value]);break}case"List":case"Composite":case"Choice":e.items&&e.items.forEach(o=>N(o,t,r))}return t}function x(e,t){let i=[];return t.items.forEach(r=>{if(r.resource){let[o]=f(e,r.target);i.push({type:"Text",annotationId:r.annotationId,text:N(r.resource),target:o})}}),{type:"textual-content",items:i}}var T=require("@iiif/helpers"),Y=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function C(e,t){let i=t.items.filter(s=>s.type==="video"),r=!1;if(e.duration||(r=!0),i.length>1)return m("Only one video source supported");let o=i[0]?.resource,p=!!(o.service||[]).find(s=>(s.profile||"").includes("youtube.com"));if(!p&&r)return m("Video does not have duration");if(!o)return m("Unknown video");if((!o.format||o.format==="text/html")&&!p)return m("Video does not have format");let c=t.items[0],d={annotationId:t.items[0].annotationId,duration:e.duration,url:o.id,type:"Video",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:o.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},n=(0,T.expandTarget)(c.target);n.selector&&n.selector.type==="TemporalBoxSelector"&&(d.target=n.selector);let{selector:a}=(0,T.parseSelector)(c.selector);if(a===null){let s=d.target.temporal.startTime,u=(d.target.temporal.endTime||e.duration)-s;d.selector={type:"TemporalSelector",temporal:{startTime:0,endTime:u}}}else a.type==="TemporalSelector"&&(d.selector=a);if(p){d.type="VideoYouTube";let s=o.id.match(Y);if(!s[1])return m("Video is not known youtube video");d.youTubeId=s[1]}return{type:"media",media:d,annotations:{pages:[]}}}function z(e,t,i){let r={type:"complex-timeline",items:[],keyframes:[],duration:e.duration||0},o={type:"complex-choice",items:[]};function p(n){n.choice&&(n.choice.type==="complex-choice"?o.items.push(...n.choice.items):o.items.push(n.choice))}for(let n of t.items){if(n.type==="image"){let a=h(e,{choice:null,allChoices:null,types:["image"],items:[n]},i);if(a.type==="images"){p(a),r.items.push(a.image);let s={id:a.image.annotationId,type:"enter",resourceType:"image",time:a.image.target?.temporal?.startTime||0};r.keyframes.push(s);let l={id:a.image.annotationId,type:"exit",resourceType:"image",time:a.image.target?.temporal?.endTime||e.duration||0};r.keyframes.push(l)}}if(n.type==="textualbody"){let a=x(e,{choice:null,allChoices:null,types:["textualbody"],items:[n]});if(a.type==="textual-content"){p(a);let s=a.items[0];r.items.push(s);let l=s.target,u={id:s.annotationId,type:"enter",resourceType:"text",time:l.temporal?.startTime||0};r.keyframes.push(u);let g={id:s.annotationId,type:"exit",resourceType:"text",time:l.temporal?.endTime||e.duration||0};r.keyframes.push(g)}}if(n.type==="video"){let a=C(e,{choice:null,allChoices:null,types:["video"],items:[n]});if(a.type==="media"){p(a);let s=a.media;r.items.push(s);let l={id:s.annotationId,type:"enter",resourceType:"video",time:s.target?.temporal?.startTime||0};r.keyframes.push(l);let u={id:s.annotationId,type:"exit",resourceType:"video",time:s.target?.temporal?.endTime||e.duration||0};r.keyframes.push(u)}}}r.keyframes.sort((n,a)=>n.time-a.time);let c=[],d=[];for(let n of r.keyframes){if(n.resourceType==="image"||n.resourceType==="text"){d.push(n);continue}if(n.type==="enter"){c.length===0&&(n.isPrime=!0),c.push(n),d.push(n);continue}if(n.type==="exit"&&(d.push(n),c=c.filter(a=>a.id!==n.id),c.length!==0)){let a=c[0],s={id:a.id,type:"change",isPrime:!0,resourceType:a.resourceType,time:n.time};d.push(s)}}return r.keyframes=d,o.items.length&&(r.choice=o),r}function F({canvas:e,paintables:t,supports:i,loadImageService:r}){if(!e)return S;if(t.types.length===0)return i.indexOf("empty")!==-1?w(e.width,e.height):S;if(t.types.length!==1)if(t.types.length===2&&t.types.indexOf("text")!==-1)t.types=t.types.filter(p=>p!=="text");else return i.indexOf("complex-timeline")===-1?m("Complex timeline not supported"):z(e,t,r);let o=t.types[0];return o==="image"?i.indexOf("images")===-1?m("Image not supported"):h(e,t,r):o==="Model"||o==="model"?i.indexOf("3d-model")===-1?m("3D not supported"):k(e,t):o==="textualbody"?i.indexOf("textual-content")===-1?m("Textual content not supported"):x(e,t):o==="sound"||o==="audio"?i.indexOf("media")===-1?m("Media not supported"):R(e,t):o==="video"?i.indexOf("media")===-1?m("Media not supported"):C(e,t):S}
1
+ "use strict";var v=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var E=(e,t)=>{for(var r in t)v(e,r,{get:t[r],enumerable:!0})},Y=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of L(t))!M.call(e,o)&&o!==r&&v(e,o,{get:()=>t[o],enumerable:!(a=W(t,o))||a.enumerable});return e};var F=e=>Y(v({},"__esModule",{value:!0}),e);var j={};E(j,{emptyActions:()=>_,emptyStrategy:()=>P,getParsedTargetSelector:()=>S,getRenderingStrategy:()=>$,parseSpecificResource:()=>G,unknownResponse:()=>x,unsupportedStrategy:()=>m});module.exports=F(j);var R=require("@iiif/helpers");function G(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function S(e,t){let{selector:r,source:a}=(0,R.expandTarget)(t);if(a.id!==e.id)return[null,a];let o={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}};return[r?r.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:r.temporal,spatial:o.spatial}:r:null,a]}var _={makeChoice:()=>{}},x={type:"unknown"},m=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),P=(e,t)=>({type:"empty",width:e,height:t,annotations:{pages:[]},image:null,images:[]});var K=["model/gltf-binary"];function N(e,t){let a=t.items[0].resource;return a.format?K.indexOf(a.format)===-1?m(`3D format: ${a.format} is unsupported`):{type:"3d-model",model:a}:m("Unknown format")}function V(e,t){if(!e.duration)return m("No duration on canvas");if(t.items.length>1)return m("Only one audio source supported");let r=t.items[0]?.resource;return r?r.format?{type:"media",media:{annotationId:t.items[0].annotationId,duration:e.duration,url:r.id,type:"Sound",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:r.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:m("Audio does not have format"):m("Unknown audio")}var z=require("@atlas-viewer/iiif-image-api");var k=require("@iiif/helpers/annotation-targets");function C(e,t,r){let a=[];for(let o of t.items){let s=o.resource&&o.resource.type==="SpecificResource"?o.resource.source:o.resource;if(!s.id)return m("No resource Identifier");let c;if(s.service){let g=(0,z.getImageServices)(s);g[0]&&(c=r(g[0],e))}let y={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[u,n]=S(e,o.target),i=e.id?.split("?")[0]||"";if(!(n.id===e.id||decodeURIComponent(n.id||"")===(e.id||"")||n.id===i||decodeURIComponent(n.id||"")===i))continue;let l=o.resource.width&&o.resource.height?{type:"BoxSelector",spatial:{x:0,y:0,width:o.resource.width,height:o.resource.height}}:void 0,p=o.resource.type==="SpecificResource"?(0,k.expandTarget)(o.resource):null;if(o.selector){let g=(0,k.expandTarget)({type:"SpecificResource",source:o.resource,selector:o.selector});g&&(p=g)}let d=p&&p.selector&&(p.selector.type==="BoxSelector"||p.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:p.selector.spatial.x,y:p.selector.spatial.y,width:p.selector.spatial.width,height:p.selector.spatial.height}}:void 0;c&&!c.id&&(c.id=c["@id"]);let f={id:s.id,type:"Image",annotationId:o.annotationId,width:Number(u||d?s.width:e.width),height:Number(u||d?s.height:e.height),service:c,sizes:c&&c.sizes?c.sizes:s.width&&s.height?[{width:s.width,height:s.height}]:[],target:u&&u.type!=="PointSelector"?u:y,selector:d||{type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}}};a.push(f)}return{type:"images",image:a[0],images:a,choice:t.choice}}function B(e,t={},r){let a=e.language||r||"none";switch(e.type){case"TextualBody":{typeof e.value<"u"&&(t[a]=[e.value]);break}case"List":case"Composite":case"Choice":e.items&&e.items.forEach(o=>B(o,t,a))}return t}function I(e,t){let r=[];return t.items.forEach(a=>{if(a.resource){let[o]=S(e,a.target);r.push({type:"Text",annotationId:a.annotationId,text:B(a.resource),target:o})}}),{type:"textual-content",items:r}}var b=require("@iiif/helpers"),Q=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function w(e,t,r){let a=t.items.filter(d=>d.type==="video"),o=!1;if(e.duration||(o=!0),a.length>1)return m("Only one video source supported");let s=a[0]?.resource,c=!!(s.service||[]).find(d=>(d.profile||"").includes("youtube.com"));if(!c&&o)return m("Video does not have duration");if(!s)return m("Unknown video");if((!s.format||s.format==="text/html")&&!c)return m("Video does not have format");let y=[],u=r.get(e.annotations);for(let d of u){let f=r.get(d.items);for(let g of f)if((g.motivation?Array.isArray(g.motivation||"")?g.motivation:[g.motivation]:[]).includes("supplementing")){let A=r.get(g.body);for(let O of A){let h=O;if(h.type==="Choice")for(let U of h.items){let T=r.get(U);T.format==="text/vtt"&&y.push({id:T.id,type:"Text",format:"text/vtt",label:T.label,language:T.language})}else h.format==="text/vtt"&&y.push({id:h.id,type:"Text",format:"text/vtt",label:h.label,language:h.language})}}}let n=t.items[0],i={annotationId:t.items[0].annotationId,duration:e.duration,url:s.id,type:"Video",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:s.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},l=(0,b.expandTarget)(n.target);l.selector&&l.selector.type==="TemporalBoxSelector"&&(i.target=l.selector);let{selector:p}=(0,b.parseSelector)(n.selector);if(p===null){let d=i.target.temporal.startTime,g=(i.target.temporal.endTime||e.duration)-d;i.selector={type:"TemporalSelector",temporal:{startTime:0,endTime:g}}}else p.type==="TemporalSelector"&&(i.selector=p);if(c){i.type="VideoYouTube";let d=s.id.match(Q);if(!d[1])return m("Video is not known youtube video");i.youTubeId=d[1]}return{type:"media",media:i,annotations:{pages:[]},captions:y}}function D(e,t,r,a){let o={type:"complex-timeline",items:[],keyframes:[],duration:e.duration||0},s={type:"complex-choice",items:[]};function c(n){n.choice&&(n.choice.type==="complex-choice"?s.items.push(...n.choice.items):s.items.push(n.choice))}for(let n of t.items){if(n.type==="image"){let i=C(e,{choice:null,allChoices:null,types:["image"],items:[n]},r);if(i.type==="images"){c(i),o.items.push(i.image);let l={id:i.image.annotationId,type:"enter",resourceType:"image",time:i.image.target?.temporal?.startTime||0};o.keyframes.push(l);let p={id:i.image.annotationId,type:"exit",resourceType:"image",time:i.image.target?.temporal?.endTime||e.duration||0};o.keyframes.push(p)}}if(n.type==="textualbody"){let i=I(e,{choice:null,allChoices:null,types:["textualbody"],items:[n]});if(i.type==="textual-content"){c(i);let l=i.items[0];o.items.push(l);let p=l.target,d={id:l.annotationId,type:"enter",resourceType:"text",time:p.temporal?.startTime||0};o.keyframes.push(d);let f={id:l.annotationId,type:"exit",resourceType:"text",time:p.temporal?.endTime||e.duration||0};o.keyframes.push(f)}}if(n.type==="video"){let i=w(e,{choice:null,allChoices:null,types:["video"],items:[n]},a);if(i.type==="media"){c(i);let l=i.media;o.items.push(l);let p={id:l.annotationId,type:"enter",resourceType:"video",time:l.target?.temporal?.startTime||0};o.keyframes.push(p);let d={id:l.annotationId,type:"exit",resourceType:"video",time:l.target?.temporal?.endTime||e.duration||0};o.keyframes.push(d)}}}o.keyframes.sort((n,i)=>n.time-i.time);let y=[],u=[];for(let n of o.keyframes){if(n.resourceType==="image"||n.resourceType==="text"){u.push(n);continue}if(n.type==="enter"){y.length===0&&(n.isPrime=!0),y.push(n),u.push(n);continue}if(n.type==="exit"&&(u.push(n),y=y.filter(i=>i.id!==n.id),y.length!==0)){let i=y[0],l={id:i.id,type:"change",isPrime:!0,resourceType:i.resourceType,time:n.time};u.push(l)}}return o.keyframes=u,s.items.length&&(o.choice=s),o}function $({canvas:e,paintables:t,supports:r,loadImageService:a,vault:o}){if(!e)return x;if(t.types.length===0)return r.indexOf("empty")!==-1?P(e.width,e.height):x;if(t.types.length!==1)if(t.types.length===2&&t.types.indexOf("text")!==-1)t.types=t.types.filter(c=>c!=="text");else return r.indexOf("complex-timeline")===-1?m("Complex timeline not supported"):D(e,t,a,o);let s=t.types[0];return s==="image"?r.indexOf("images")===-1?m("Image not supported"):C(e,t,a):s==="Model"||s==="model"?r.indexOf("3d-model")===-1?m("3D not supported"):N(e,t):s==="textualbody"?r.indexOf("textual-content")===-1?m("Textual content not supported"):I(e,t):s==="sound"||s==="audio"?r.indexOf("media")===-1?m("Media not supported"):V(e,t):s==="video"?r.indexOf("media")===-1?m("Media not supported"):w(e,t,o):x}
package/dist/utils.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- import { m as UseRenderingStrategy, U as UnknownStrategy, R as RenderingStrategy, d as ImageServiceLoaderType } from './useRenderingStrategy-2EaRC2Nc.cjs';
1
+ import { m as UseRenderingStrategy, U as UnknownStrategy, R as RenderingStrategy, d as ImageServiceLoaderType } from './useRenderingStrategy-DkjxMKJV.cjs';
2
2
  import { CanvasNormalized } from '@iiif/presentation-3-normalized';
3
3
  import { Paintables } from '@iiif/helpers/painting-annotations';
4
+ import { TemporalBoxSelector, BoxSelector, SupportedTarget, Vault } from '@iiif/helpers';
4
5
  import { ContentResource, W3CAnnotationTarget, PointSelector } from '@iiif/presentation-3';
5
- import { TemporalBoxSelector, BoxSelector, SupportedTarget } from '@iiif/helpers';
6
6
  import '@iiif/helpers/annotation-targets';
7
7
  import 'mitt';
8
8
 
@@ -27,7 +27,8 @@ interface GetRenderStrategyOptions {
27
27
  paintables: Paintables;
28
28
  supports: string[];
29
29
  loadImageService: ImageServiceLoaderType;
30
+ vault: Vault;
30
31
  }
31
- declare function getRenderingStrategy({ canvas, paintables, supports, loadImageService }: GetRenderStrategyOptions): RenderingStrategy;
32
+ declare function getRenderingStrategy({ canvas, paintables, supports, loadImageService, vault, }: GetRenderStrategyOptions): RenderingStrategy;
32
33
 
33
34
  export { emptyActions, emptyStrategy, getParsedTargetSelector, getRenderingStrategy, parseSpecificResource, unknownResponse, unsupportedStrategy };
package/dist/utils.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { m as UseRenderingStrategy, U as UnknownStrategy, R as RenderingStrategy, d as ImageServiceLoaderType } from './useRenderingStrategy-2EaRC2Nc.js';
1
+ import { m as UseRenderingStrategy, U as UnknownStrategy, R as RenderingStrategy, d as ImageServiceLoaderType } from './useRenderingStrategy-DkjxMKJV.js';
2
2
  import { CanvasNormalized } from '@iiif/presentation-3-normalized';
3
3
  import { Paintables } from '@iiif/helpers/painting-annotations';
4
+ import { TemporalBoxSelector, BoxSelector, SupportedTarget, Vault } from '@iiif/helpers';
4
5
  import { ContentResource, W3CAnnotationTarget, PointSelector } from '@iiif/presentation-3';
5
- import { TemporalBoxSelector, BoxSelector, SupportedTarget } from '@iiif/helpers';
6
6
  import '@iiif/helpers/annotation-targets';
7
7
  import 'mitt';
8
8
 
@@ -27,7 +27,8 @@ interface GetRenderStrategyOptions {
27
27
  paintables: Paintables;
28
28
  supports: string[];
29
29
  loadImageService: ImageServiceLoaderType;
30
+ vault: Vault;
30
31
  }
31
- declare function getRenderingStrategy({ canvas, paintables, supports, loadImageService }: GetRenderStrategyOptions): RenderingStrategy;
32
+ declare function getRenderingStrategy({ canvas, paintables, supports, loadImageService, vault, }: GetRenderStrategyOptions): RenderingStrategy;
32
33
 
33
34
  export { emptyActions, emptyStrategy, getParsedTargetSelector, getRenderingStrategy, parseSpecificResource, unknownResponse, unsupportedStrategy };
package/dist/utils.js CHANGED
@@ -1 +1 @@
1
- import{a as o,b as r,c as e,d as f,e as m,f as p,l as t}from"./chunk-UFC4ZSNV.js";export{e as emptyActions,p as emptyStrategy,r as getParsedTargetSelector,t as getRenderingStrategy,o as parseSpecificResource,f as unknownResponse,m as unsupportedStrategy};
1
+ import{a as o,b as r,c as e,d as f,e as m,f as p,l as t}from"./chunk-CCTBCLBV.js";export{e as emptyActions,p as emptyStrategy,r as getParsedTargetSelector,t as getRenderingStrategy,o as parseSpecificResource,f as unknownResponse,m as unsupportedStrategy};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-iiif-vault",
3
- "version": "1.3.6",
3
+ "version": "1.4.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -1,48 +0,0 @@
1
- import{c as vt,l as ht}from"./chunk-UFC4ZSNV.js";import{forwardRef as Xn,useImperativeHandle as zi}from"react";import sn,{useCallback as tt,useMemo as un,useState as Te}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},Ae=nr.createContext(ir),H=()=>rr(Ae);function K({value:e,children:n}){let t=H(),r=or(()=>({...t,...e}),[e,t]);return ar(Ae.Provider,{value:r,children:n})}import sr,{useState as ur}from"react";import{Vault as yt,globalVault as cr}from"@iiif/helpers/vault";import{jsx as 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 yt(n):new yt));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 xt(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),h=d?d.id||d["@id"]:null;d&&o!==h&&s(h),l(d)}catch(d){a(d)}})()},[t,n]),{isLoaded:!!c,id:o,requestId:t,error:i,resource:c,cached:!!(c&&c===u)}}function Ct(e,n){let{id:t,isLoaded:r,error:o,resource:s,requestId:i,cached:a}=xt(e,n);return{id:t,isLoaded:r,error:o,manifest:s,requestId:i,cached:a}}import{jsx as pr}from"react/jsx-runtime";function At({manifest:e,children:n}){return pr(K,{value:{manifest:e},children:n})}import{jsx as gr}from"react/jsx-runtime";function q({canvas:e,children:n}){return gr(K,{value:{canvas:e},children:n})}import{useContext as Sr}from"react";import xr 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=xr.createContext([]);function be(){let e=Sr(ee);return T(n=>e.map(t=>n.iiif.entities.Canvas[t]).filter(Boolean),[e])}import{useMemo as Cr}from"react";function E(e={},n=[]){let{id:t,selector:r}=e,o=H(),s=R(),i=t||o.manifest,a=T(u=>i?u.iiif.entities.Manifest[i]:void 0,[i]);return Cr(()=>{if(a)return r?r(a):a},[a,r,...n])}import{jsx as Ar}from"react/jsx-runtime";function bt({range:e,children:n}){return Ar(K,{value:{range:e},children:n})}function br(e,n){for(let t of n.items){if(t.type==="Canvas")return t;if(t.type==="SpecificResource")return t.source;if(t.type==="Range"){let r=br(e,e.get(t));if(r)return r}}return null}function _e(e,n){let t=[];for(let r of n.items)if(r.type==="SpecificResource"&&r.source?.type==="Canvas"&&(r.source.id.indexOf("#")!==-1?t.push({id:r.source.id.split("#")[0],type:"Canvas"}):t.push(r.source)),r.type==="Range"&&t.push(..._e(e,e.get(r))),r.type==="SpecificResource"){let o=typeof r.source=="string"?r.source:r.source.id;t.push({id:o,type:"Canvas"})}return t}function za(e,n,t){for(let r of n.structures){let o=Pt(e,e.get(r),t);if(o)return o}return null}function Pt(e,n,t){for(let r of n.items){let o=r?.source?.id?.split("#")[0];if(r.type==="SpecificResource"&&r.source===t||r.type==="SpecificResource"&&r.source?.type==="Canvas"&&t===o)return n;if(r.type==="Range"){let s=Pt(e,e.get(r),t);if(s)return s}}return null}function Fa(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[h,A]=je(e,n);if(u)return h;let y=h.findIndex(g=>g.id===t);if(y===-1)return[];for(let g of A)if(g.includes(y))return g.map(b=>h[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((y,g)=>g)]];if(a||!s||t)return[u,u.map((y,g)=>[g])];let c=[],l=[],d=()=>{l.length&&(c.push([...l]),l=[])},h=0,A=!1;for(let y=0;y<u.length;y++){let g=e.get(u[y]);if(g.behavior.includes("non-paged")){y===h&&h++,r||(d(),c.push([y]),d());continue}if(y===h||g.behavior.includes("facing-pages")){l.length&&(A=!0),d(),c.push([y]),d();continue}if(l.push(y),A){d(),A=!1;continue}l.length>1&&d()}return l.length&&d(),[u,c]}import{useCallback as Pe,useMemo as Rr,useRef as Tr,useState as Ir}from"react";import{useMemo as Pr}from"react";function Rt(e={},n=[]){let{id:t,selector:r}=e,o=H(),s=t||o.range,i=T(a=>s?a.iiif.entities.Range[s]:void 0,[s]);return Pr(()=>{if(i)return r?r(i):i},[i,r,...n])}function Tt({startCanvas:e,disablePaging:n}){let t=R(),r=E(),o=Rt(),[s,i]=Ir(void 0),a=o||r;if(!a)throw new Error("Nothing selected");let[u,c]=Rr(()=>je(t,a,{disablePaging:n}),[t,a,n]),l=Tr(c);if(l.current!==c){let b=l.current[s][0],p=c.findIndex(x=>x.includes(b));l.current=c,i(p)}let d=Pe(g=>{let b=c.findIndex(p=>p.includes(g));i(b===-1?0:b)},[u,c]),h=Pe(g=>{let b=u.findIndex(p=>p.id===g);b!==-1?d(b):i(0)},[u,c]),A=Pe(()=>{i(g=>g>=c.length-1?g:g+1)},[c]),y=Pe(()=>{i(g=>g<=0?0:g-1)},[c]);return typeof s>"u"&&(e?h(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:h,next:A,previous:y}}import{createContext as Qe,useContext as Ht,useEffect as wr,useMemo as Er}from"react";import{useStore as me}from"zustand";import{createStore as Mt}from"zustand/vanilla";function Za(e){let n=e.service||e.services||[];for(let t of n)if(t.type==="AuthProbeService2")return!0;return!1}function F(e,n,t){let r=n.findIndex(i=>i.service.id===e);if(r===-1)return n;let o=[...n],s=t(o[r]);return s===o[r]?n:(o[r]=s,o)}var wt=()=>Mt((e,n)=>({currentAuth:-1,authItems:[],login:()=>{let t=n().authItems[n().currentAuth];if(!t||t.isPending||t.isLoggedIn)return;if(t.type!=="active")throw new Error("Cannot login to non-active service");let r=t.service.service.find(o=>o.type==="AuthAccessTokenService2");if(!r)throw new Error("Token service not found");e(()=>({authItems:F(t.id,n().authItems,o=>({...o,isPending:!0}))})),It(t.service).then(()=>{Ke(r).then(o=>{let s=o.expiresIn,i=Date.now()+s*1e3;e(()=>({authItems:F(t.id,n().authItems,a=>({...a,isLoggedIn:!0,isPending:!1,session:{token:o.accessToken,expires:i}}))}))}).catch(o=>{e(()=>({authItems:F(t.id,n().authItems,s=>({...s,isLoggedIn:!1,isPending:!1,error:o.message}))}))})})},logout:()=>{let t=n().authItems[n().currentAuth];if(!t||t.isPending||!t.isLoggedIn)return;if(t.type!=="active")throw new Error("Cannot logout of non-active service");let r=t.service.service.find(i=>i.type==="AuthLogoutService2");if(!r)return;let o=`${r.id}?origin=${kt()}`,s=window.open(o);e(()=>({authItems:F(t.id,n().authItems,i=>({...i,isLoggedIn:!1,session:null,isPending:!1}))}))},nextAuth:()=>{let t=n().authItems.length,r=n().currentAuth+1;r>=t||e(()=>({currentAuth:r}))},previousAuth:()=>{let t=n().currentAuth-1;t<0||e(()=>({currentAuth:t}))},setAuth:t=>{t!==-1&&(t<0||t>=n().authItems.length)||e(()=>({currentAuth:t}))},addService:(t,r)=>{if(!t.service)return;let o=t.service.find(a=>a.type==="AuthAccessTokenService2"),s=t;if(n().authItems.find(a=>a.service.id===t.id)){e(()=>({authItems:F(t.id,n().authItems,a=>({...a,instances:a.instances+1}))}));return}if(e(()=>({currentAuth:s.profile==="active"?0:n().currentAuth,authItems:[{id:t.id,type:t.profile,service:t,probeId:r,canAuthenticate:!0,instances:1,isPending:!1,isLoggedIn:!1,session:null},...n().authItems]})),t.profile==="external"){if(!o)throw new Error("Token service not found");Ke(o).then(a=>{e(()=>({authItems:F(t.id,n().authItems,u=>({...u,isLoggedIn:!0,isPending:!1,session:{token:a.accessToken,expires:a.expiresIn}}))}))}).catch(a=>{e(()=>({authItems:F(t.id,n().authItems,u=>({...u,isLoggedIn:!1,isPending:!1,canAuthenticate:!1,error:a.message}))}))})}if(t.profile==="kiosk"){if(!o)throw new Error("Token service not found");e(()=>({authItems:F(t.id,n().authItems,a=>({...a,isPending:!0}))})),It(s).then(()=>{Ke(o).then(a=>{e(()=>({authItems:F(t.id,n().authItems,u=>({...u,isLoggedIn:!0,isPending:!1,session:{token:a.accessToken,expires:a.expiresIn}}))}))}).catch(a=>{e(()=>({authItems:F(t.id,n().authItems,u=>({...u,isLoggedIn:!1,isPending:!1,error:a.message}))}))})})}t.profile},removeService:(t,r)=>{let o=n().currentAuth===n().authItems.findIndex(i=>i.service.id===t.id),s=n().currentAuth;if(o){let i=n().authItems.find(u=>u.service.id===t.id);i&&i.instances>1||(s=n().authItems.findIndex(c=>c.service.id!==t.id&&c.instances>0))}e(()=>({authItems:F(t.id,n().authItems,i=>({...i,instances:i.instances-1})),currentAuth:s}))}})),Et=(e,n)=>Mt((t,r)=>({service:e,status:e?"unknown":"success",shouldRedirect:!1,redirectResource:null,shouldSubstitute:!1,substituteResource:null,error:null,errorHeading:null,errorNote:null,shouldDisplayResource:!1,token:n||null,async probe(){if(!r().service)return;let o=r().service?.id;if(!o){t({status:"error",error:"Service ID not found",errorHeading:{en:["Service ID not found"]}});return}t({status:"probing"});let s=r().token;try{let i=await fetch(o,{headers:s?{Authorization:`Bearer ${r().token}`,Accept:"application/json"}:{Accept:"application/json"}}).then(a=>a.json());if(i.status===200)t({status:"success",shouldDisplayResource:!0,error:null,errorHeading:null,errorNote:null,shouldSubstitute:!1,shouldRedirect:!1});else if(i.status<400&&i.status>=300){if(!i.location)throw new Error("Redirect location not found");t({status:"error",shouldDisplayResource:!1,shouldRedirect:!0,redirectResource:i.location||null})}else if(i.status===401)t({status:"error",shouldDisplayResource:!1,shouldRedirect:!1,shouldSubstitute:!!i.substitute,substituteResource:i.substitute||null,error:"Unauthorized",errorHeading:i.heading||{en:["Unauthorized"]},errorNote:i.note||null});else throw new Error("Unknown error")}catch(i){t({status:"error",error:i.message,errorHeading:{en:["Unknown error"]}})}},setToken(o){t({token:o})}}));function Vt(e){let n=e.service||e.services||[],t={hasAuth:!1,services:{}};for(let r of n)if(r.type==="AuthProbeService2"){t.services.probe=r,t.hasAuth=!0;let o=r.service.filter(s=>s.type==="AuthAccessService2");o[0]&&(t.services.access=o[0])}return t}async function Ke(e,{strict:n=!0}={}){return new Promise((t,r)=>{let o=Math.random().toString(36).substring(7),s=`${e.id}?messageId=${o}&origin=${window.location.origin}`,i=c=>{let l=c.data;if(l.messageId===o){if(n&&l.type!=="AuthAccessToken2"){a(),r("Invalid response, expected type=AuthAccessToken2");return}if(!l.accessToken){a(),r("Invalid response, expected accessToken");return}a(),t(l)}},a=()=>window.removeEventListener("message",i),u=document.createElement("iframe");u.src=s,u.style.display="none",document.body.appendChild(u),window.addEventListener("message",i)})}function kt(e){let n=window.location;if(e){let t=document.createElement("a");return t.href=e,t.protocol+"//"+t.hostname+(t.port?":"+t.port:"")}return n.protocol+"//"+n.hostname+(n.port?":"+n.port:"")}async function It(e){let n=`${e.id}?origin=${kt()}`,t=window.open(n);if(!t)throw new Error("Failed to open window");return new Promise((r,o)=>{let s=setInterval(()=>{t.closed&&(clearInterval(s),r())},500)})}import{useEffect as Nt,useMemo as Lt}from"react";import{useStore as Mr}from"zustand";function zt(e){let n=Lt(()=>Vt(e),[e]),t=Ot(n.services.access?.id),r=Lt(()=>Et(n.services.probe,t),[n.services.probe]),o=Mr(r);return Nt(()=>{o.status==="unknown"&&!t&&o.probe()},[n.services.probe,o.status]),Nt(()=>{t&&(o.setToken(t),o.probe())},[t]),[e,o,n.hasAuth]}import{jsx as Re}from"react/jsx-runtime";var te=Qe(null),Vr=Qe(null);Vr.displayName="CurrentAuth";var kr=Qe(null);kr.displayName="AuthActions";function Ft({children:e}){let n=Er(()=>wt(),[]);return Re(te.Provider,{value:n,children:e})}function $t(){return!!Ht(te)}function fe(){let e=Ht(te);if(!e)throw new Error("useAuthActions must be used within a AuthProvider");return e}function Nr(){let e=fe();return me(e,t=>({login:t.login,logout:t.logout,nextAuth:t.nextAuth,previousAuth:t.previousAuth,setAuth:t.setAuth,addService:t.addService,removeService:t.removeService}))}function gs(){let e=fe();return me(e,n=>n)}function Lr(e){let n=fe();return me(n,r=>r.authItems.find(o=>o.service.id===e))}function Ot(e){let n=fe();return me(n,r=>r.authItems.find(o=>o.id===e)?.session?.token)}function vs(e){let n=fe();return me(n,r=>{let o=r.authItems.find(s=>s.service.id===e);return!o||!o.isLoggedIn||!o.session?null:o.session?.token||null})}function zr(e){let n=Nr(),t=Lr(e.service.id);return wr(()=>(n?.addService(e.service,e.probeId),()=>{n?.removeService(e.service,e.probeId)}),[e.service]),t?(t.error||!t.isLoggedIn,e.children):null}function Ye(){return null}function Dt(e){let[n,t,r]=zt(e.resource),o=e.fallbackComponent||Ye,s=e.loadingComponent||Ye,i=e.errorComponent||Ye,a=t.service,u=null;if(!r||!a)return e.children(n);let c=a.service.filter(l=>l.type==="AuthAccessService2");t.status==="error"&&(u=Re(i,{resource:e.resource,error:t.error||"",heading:t.errorHeading,note:t.errorNote,extra:e.extra})),(t.status==="unknown"||t.status==="probing")&&(u=Re(s,{})),t.status==="success"&&(u=e.children(n));for(let l of c)u=Re(zr,{service:l,probeId:a.id,children:u},l.id);return u}import{createContext as $r,useContext as Rs,useMemo as Dr}from"react";import{createStore as Or}from"zustand/vanilla";var Hr=e=>e.id||e["@id"];function Fr(e){return(Array.isArray(e.service)?e.service:[e.service]).find(t=>t.profile==="http://iiif.io/api/search/0/autocomplete"||t.profile==="http://iiif.io/api/search/1/autocomplete"||t.profile==="AutoCompleteService1")}var Ut=e=>{let n;typeof e=="string"?n={"@context":"http://iiif.io/api/search/1/context.json",profile:"http://iiif.io/api/search/1/search","@id":e,id:e,service:[]}:n=e;let t=n?Hr(n):void 0,r=null;return Or((o,s)=>({service:n,resources:[],lastQuery:{},loading:!1,error:!1,highlight:null,hasSearch:!!n,hasAutocomplete:n?!!Fr(n):!1,errorMessage:"",search(i,a={}){if(!t)throw new Error("No search service found.");r&&!r.signal.aborted&&r.abort(),r=new AbortController;let u=new URLSearchParams;i.q&&u.set("q",i.q),i.motivation&&u.set("motivation",i.motivation),i.date&&u.set("date",i.date),i.user&&u.set("user",i.user),o({loading:!0}),fetch(`${t}?${u.toString()}`,{signal:r.signal,headers:{"Content-Type":"application/json",Accept:"application/json",...a.headers||{}}}).then(async c=>{if(!r?.signal.aborted)if(c.ok){let l=await c.json();o({resources:l.resources,error:!1,errorMessage:""})}else o({resources:[],error:!0,errorMessage:c.statusText})})},clearSearch(){o({resources:[],error:!1,errorMessage:""})},highlightResult(i){let a=s().resources.find(u=>u["@id"]===i);o({highlight:a})},nextResult(){let i=s().resources,a=s().highlight;if(!a){o({highlight:i[0]||null});return}let u=i.findIndex(c=>c["@id"]===a["@id"]);if(u===-1){o({highlight:i[0]||null});return}o({highlight:i[u+1]||i[0]||null})},previousResult(){let i=s().resources,a=s().highlight;if(!a){o({highlight:i[i.length-1]||null});return}let u=i.findIndex(c=>c["@id"]===a["@id"]);if(u===-1){o({highlight:i[i.length-1]||null});return}if(u===0){o({highlight:i[i.length-1]||null});return}o({highlight:i[u-1]||i[i.length-1]||null})}}))};import{useStore as Es}from"zustand";function qt(){let e=E();return e?e.service.find(n=>n.profile==="SearchService1"||n.profile==="http://iiif.io/api/search/1/search"):void 0}import{jsx as We}from"react/jsx-runtime";var ne=$r(null);ne.displayName="Search";function Bt(e){let n=qt();return e.store?We(ne.Provider,{value:e.store,children:e.children}):We(Ur,{service:n,children:e.children})}function Ur({service:e,children:n}){let t=Dr(()=>Ut(e),[e]);return We(ne.Provider,{value:t,children:n})}import{jsx as z}from"react/jsx-runtime";var pe=()=>{},ge=Br({setCurrentCanvasId:pe,setCurrentCanvasIndex:pe,nextCanvas:pe,previousCanvas:pe,items:[],sequence:[],setSequenceIndex:pe,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:h}=Tt({startCanvas:e.startCanvas,disablePaging:e.pagingEnabled===!1}),A=_r(()=>({sequence:s,items:i,setCurrentCanvasId:u,nextCanvas:o,previousCanvas:c,totalCanvases:i.length,setCurrentCanvasIndex:a,setSequenceIndex:l,currentSequenceIndex:t,hasNext:d,hasPrevious:h}),[s,i,u,o,c,i,a,l,t]);return n?r.length===0?null:z(ge.Provider,{value:A,children:z(ee.Provider,{value:r,children:z(q,{canvas:r[0],children:e.children})})}):(console.warn("The manifest passed to the provider is not a valid IIIF manifest."),z("div",{children:"Sorry, something went wrong."}))}function _t(e){let n=X(e.vault),t=Ct(e.manifest);if(!t)return console.warn("The manifest passed to the provider is not a valid IIIF manifest."),z("div",{children:"Sorry, something went wrong."});if(t.error)return z("div",{children:t.error.toString()});if(!t.isLoaded)return z("div",{children:"Loading..."});let r=z(jr,{...e,children:e.children});return z(J,{vault:n,children:z(At,{manifest:t.id,children:z(Ft,{children:z(Bt,{children:e.rangeId?z(bt,{range:e.rangeId,children:r}):r})})})})}function jt(){return qr(ge)}import Kr from"react";import{createContext as Yr,useMemo as Qr}from"react";import Wr from"mitt";import{jsx as Zr}from"react/jsx-runtime";var Gr=Wr(),re=Yr({emitter:Gr});re.displayName="Events";function Kt(){return Kr.useContext(re).emitter}function su({emitter:e,children:n}){return Zr(re.Provider,{value:Qr(()=>({emitter:e}),[e]),children:n})}import{jsx as oe}from"react/jsx-runtime";function Yt(){return{VaultContext:W(Q),ResourceContext:W(Ae),SimpleViewerReactContext:W(ge),VisibleCanvasReactContext:W(ee),AuthRContext:W(te),SearchReactContext:W(ne),ReactEventContext:W(re)}}function Qt(e){return oe(J,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:oe(ee.Provider,{value:e.bridge.VisibleCanvasReactContext,children:oe(ge.Provider,{value:e.bridge.SimpleViewerReactContext,children:oe(re.Provider,{value:e.bridge.ReactEventContext,children:oe(te.Provider,{value:e.bridge.AuthRContext,children:oe(ne.Provider,{value:e.bridge.SearchReactContext,children:e.children})})})})})})}import{createContext as no,useContext as ro,useMemo as oo}from"react";import{useCallback as Gt,useLayoutEffect as Xr,useMemo as eo,useRef as to}from"react";import{entityActions as Ge}from"@iiif/helpers/vault/actions";import{useMemo as Jr}from"react";function Wt(){let n=R().getStore();return Jr(()=>t=>n.dispatch(t),[n])}function Zt(e){return typeof e!="string"&&e&&e.bindToVault}function Jt(){let e=R(),n=to([]),t=Wt(),r=eo(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);Xr(()=>{let a={id:r,type:"AnnotationPage",behavior:[],label:null,thumbnail:[],summary:null,requiredStatement:null,metadata:[],rights:null,provider:[],items:[],seeAlso:[],homepage:[],rendering:[],service:[]};t(Ge.importEntities({entities:{AnnotationPage:{[a.id]:a}}}))},[r]);let o=T(a=>r&&a.iiif.entities.AnnotationPage[r]||null,[r]),s=Gt((a,u)=>{if(r){if(Zt(a)){let d=a;d.__vault||d.bindToVault(e),a=typeof d.source=="string"?d.source:d.source.id,n.current[a]=d}else typeof a!="string"&&(a=a.id);let c=e.get({id:r,type:"AnnotationPage"}),l=e.get({id:a,type:"Annotation"});c&&l&&(c.items.find(d=>d.id===l.id)||t(Ge.addReference({id:r,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"},index:u})))}},[r]),i=Gt(a=>{r&&(Zt(a)?a=typeof a.source=="string"?a.source:a.source.id:typeof a!="string"&&(a=a.id),n.current[a]&&n.current[a].beforeRemove(),e.get({id:r,type:"AnnotationPage"})&&t(Ge.removeReference({id:r,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"}})))},[r]);return[o,{addAnnotation:s,removeAnnotation:i}]}import{jsx as io}from"react/jsx-runtime";var Xt=no(null);function en(){let e=ro(Xt);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function tn({children:e}){let[n,{addAnnotation:t,removeAnnotation:r}]=Jt();return io(Xt.Provider,{value:oo(()=>({fullPage:n,addAnnotation:t,removeAnnotation:r}),[n]),children:e})}import{jsx as Ze,jsxs as ao}from"react/jsx-runtime";function nn({width:e,style:n,height:t,error:r,resetErrorBoundary:o}){return ao("div",{style:{width:e,height:t,minHeight:500,...n||{},background:"#f9f9f9"},children:[Ze("h3",{children:"Error occurred"}),Ze("p",{children:r.message}),Ze("button",{onClick:o,children:"Reset"})]})}import{createContext as so,useContext as uo}from"react";var ve=so(null);function rn(){return uo(ve)}import{createContext as on,useContext as co,useEffect as lo}from"react";var Je=on(()=>{}),Xe=on(()=>{});function O(e,n,t,r,o=[]){let s=co(e==="portal"?Xe:Je);lo(()=>(e!=="none"&&s(n,t,r),()=>{s(n,null)}),[n,e,s,...o])}import{createContext as fo,useContext as po,useEffect as go}from"react";import{useMemo as mo}from"react";function M(e={},n=[]){let{id:t,selector:r}=e,o=H(),s=t||o.canvas,i=T(a=>s?a.iiif.entities.Canvas[s]:void 0,[s]);return mo(()=>{if(i)return r?r(i):i},[i,r,...n])}var et=fo(()=>{});function an(e){let n=M(),t=po(et);go(()=>n&&n.id?(t(n.id,e),()=>t(n.id,-1)):()=>{},[n,e])}import{Fragment as So,jsx as V,jsxs as xo}from"react/jsx-runtime";function cn({children:e,errorFallback:n,outerContainerProps:t={},worldScale:r,...o}){let[s,i]=Te(),a=Yt(),u=n||nn,[c,l]=Te({}),d=Object.entries(c),[h,A]=Te({}),y=Object.entries(h),[g,b]=Te({}),p=un(()=>r||Math.max(...Object.values(g)),[g]),x=un(()=>({maxOverZoom:p||1,...o.runtimeOptions||{}}),[p,o.runtimeOptions]),m=tt((S,P)=>{b(C=>{if(P===-1){let{[S]:_,...f}=C;return f}return{...C,[S]:P}})},[]),v=tt((S,P,C)=>{l(({[S]:_,...f})=>P?{...f,[S]:{element:P,props:C}}:f)},[]),I=tt((S,P,C)=>{A(({[S]:_,...f})=>P?{...f,[S]:{element:P,props:C}}:f)},[]);return xo(yo,{resetKeys:[],fallbackRender:S=>V(u,{...o,...S}),children:[V(vo,{...o,containerProps:{style:{position:"relative"},...o.containerProps||{}},htmlChildren:V(So,{children:d.map(([S,{element:P,props:C}])=>V(sn.Fragment,{children:V(P,{...C||{}})},S))}),onCreated:S=>{i(S),o.onCreated&&o.onCreated(S)},runtimeOptions:x,children:V(ve.Provider,{value:s,children:V(et.Provider,{value:m,children:V(Je.Provider,{value:v,children:V(Xe.Provider,{value:I,children:V(Qt,{bridge:a,children:V(ho.Provider,{value:o.mode||"explore",children:V(tn,{children:e})})})})})})})}),V("div",{children:y.map(([S,{element:P,props:C}])=>V(sn.Fragment,{children:V(P,{...C||{}})},S))})]})}import{mergeStyles as To,RegionHighlight as Io}from"@atlas-viewer/atlas";import{useMemo as ln}from"react";import{createEventsHelper as Co}from"@iiif/helpers/events";function Ie(e,n){let t=R(),r=ln(()=>Co(t),[t]),o=T(()=>e&&e.id?t.getResourceMeta(e.id,"eventManager"):null,[e]);return ln(()=>e?r.getListenersAsProps(e,n):{},[o,e,t,n])}import{useMemo as Ao}from"react";import{createStylesHelper as bo}from"@iiif/helpers/styles";function ie(e,n){let t=R(),r=Ao(()=>bo(t),[t]);return T(()=>{if(!e)return null;let o=r.getAppliedStyles(e.id);return o?n?o[n]:o:void 0},[e,n])}import{useMemo as Mo}from"react";import{useMemo as Po}from"react";import{expandTarget as Ro}from"@iiif/helpers/annotation-targets";function Me(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 we=({id:e,style:n,className:t,interactive:r})=>{let o=Me({id:e}),s=ie(o,"atlas"),i=ie(o,"html"),a=Ie(o,["atlas"]),u=M(),c=Mo(()=>To(n,s),[n,s]);return u&&o&&o.target&&o.target.selector&&o.target.selector.type==="BoxSelector"&&o.target.source&&(o.target.source.id===u.id||o.target.source===u.id)?wo(Io,{id:o.id,isEditing:!0,region:o.target.selector.spatial,style:c,className:i?.className||t,interactive:!!(i?.href||r),href:i?.href||null,title:i?.title||null,hrefTarget:i?.target||null,onClick:()=>{},...a}):null};import{Fragment as Vo}from"react";import{useMemo as Eo}from"react";function dn(e={},n=[]){let{id:t,selector:r}=e,o=H(),s=t||o.annotationPage,i=T(a=>s?a.iiif.entities.AnnotationPage[s]:void 0,[s]);return Eo(()=>{if(i)return r?r(i):i},[i,...n])}import{jsx as mn}from"react/jsx-runtime";var he=({className:e,page:n})=>{let t=dn({id:n.id})||n,r=ie(t,"atlas"),o=ie(t,"html");return T(s=>t.id?s.iiif.entities.AnnotationPage[t.id]:null,[]),mn(Vo,{children:t.items?.map(s=>mn(we,{id:s.id,style:r,className:o?.className||e},s.id))})};import{createStylesHelper as ki}from"@iiif/helpers/styles";import{Fragment as An,useMemo as Bo}from"react";import{HTMLPortal as $o,TileSet as xn}from"@atlas-viewer/atlas";import ae,{useMemo as nt}from"react";import{jsx as $}from"react/jsx-runtime";var pn=ae.createContext("en"),gn=ae.createContext({}),vn=ae.createContext(null);function el(e){return $(gn.Provider,{value:e.translations,children:e.children})}function tl(e){return $(pn.Provider,{value:e.language,children:e.children})}function nl(e){return $(vn.Provider,{value:e.convert,children:e.children})}function hn(){return ae.useContext(vn)}function rt(){return ae.useContext(pn)}function yn(){return ae.useContext(gn)}function fn(e){return e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):e}function ko({as:e,language:n,children:t,viewingDirection:r,...o}){let s=rt();return nt(()=>fn(s)===fn(n),[s,n])?e?$(e,{...o,children:t}):$("span",{...o,children:t}):e?$(e,{...o,lang:n,dir:r,children:t}):$("span",{...o,lang:n,dir:r,children:t})}function 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=hn(),s=No(()=>Object.keys(e||{}),[e]);return[nt(()=>{if(!e)return G(r,n,o)||"";if(typeof e=="string")return G(r,e,o);let i=s?e[s]:void 0;return i?typeof i=="string"?i:i.map(a=>G(r,a,o,s)).join(t):""},[s,n,e]),s]}function rl(){let e=rt(),n=yn(),t=hn();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 ye({as:e,defaultText:n,enableDangerouslySetInnerHTML:t,children:r,separator:o,...s}){let i=yn(),[a,u]=Lo(r,n,o,i);return u?$(ko,{...s,as:e,language:u,title:t?void 0:a,dangerouslySetInnerHTML:t?{__html:a}:void 0,children:t?void 0:a}):e?$(e,{...s,children:a}):$("span",{...s,title:t?void 0:a,dangerouslySetInnerHTML:t?{__html:a}:void 0,children:t?void 0:a})}import{canonicalServiceUrl as Do}from"@iiif/parser/image-3";import zo,{useContext as Oo}from"react";import{ImageServiceLoader as Ho}from"@atlas-viewer/iiif-image-api";var Fo=zo.createContext(new Ho);function se(){return Oo(Fo)}import{jsx as B,jsxs as qo}from"react/jsx-runtime";function Uo({resource:e,heading:n,note:t,extra:r}){return r?B($o,{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:qo("div",{children:[B(ye,{children:n||"Not authorised"}),t&&B("p",{children:B(ye,{children:t})}),B("p",{children:e.id||e["@id"]||"unknown"})]})})}):null}function Cn({image:e,thumbnail:n,crop:t,enableSizes:r,enableThumbnail:o,renderOptions:s}){let i=$t(),a=se(),u=e.service?Do(e.service.id||e.service["@id"]||""):void 0,c=u?!!a.imageServices[u]:void 0,l=n&&n.type==="fixed"&&n.id&&!n.id.includes("/full/full/")&&!n.id.includes("/max/")?n:void 0;if(c===!1)return null;if(!i){let d=e.service,h=d.width||e.width||0,A=d.height||e.height||0;return B(xn,{enableThumbnail:o,renderOptions:s,tiles:{id:d.id||d["@id"]||"unknown",height:A,width:h,imageService:d,thumbnail:l},enableSizes:r,x:0,y:0,width:e.target?.spatial.width,height:e.target?.spatial.height,crop:t})}return B(Dt,{resource:e.service,errorComponent:Uo,extra:e,children:d=>{let h=d.width||e.width||0,A=d.height||e.height||0;return B(xn,{enableThumbnail:o,renderOptions:s,tiles:{id:d.id||d["@id"]||"unknown",height:A,width:h,imageService:d,thumbnail:l},enableSizes:r,x:0,y:0,width:e.target?.spatial.width,height:e.target?.spatial.height,crop:t})}},e.id)}import{jsx as ot,jsxs as bn}from"react/jsx-runtime";function ue({id:e,image:n,thumbnail:t,isStatic:r,x:o=0,y:s=0,children:i,selector:a,onClick:u,enableSizes:c}){let l=Bo(()=>{if(!(!a||a.spatial.x===0&&a.spatial.y===0))return a.spatial},[a]);return ot("world-object",{x:o+n.target.spatial.x,y:s+n.target.spatial.y,width:n.target.spatial.width,height:n.target.spatial.height,onClick:u,children:n.service?bn(An,{children:[ot(Cn,{image:n,thumbnail:t,crop:l,enableSizes:c}),i]},"service"):bn(An,{children:[ot("world-image",{onClick:u,uri:n.id,target:{x:0,y:0,width:n.target.spatial.width,height:n.target.spatial.height},display:n.width&&n.height?{width:n.width,height:n.height}:void 0,crop:l}),i]},"no-service")},e+(n.service?"server":"no-service"))}import{Fragment as Ni,useEffect as Zn,useLayoutEffect as Li,useMemo as Jn}from"react";import{useEffect as Nn,useMemo as Ln}from"react";import{useCallback as Tn,useMemo as jo}from"react";function _o(e,n){let t=e?.iiif?.meta[n];return t?t.annotationPageManager:null}function Pn(e,n){return T(t=>{let r=[];if(!e)return r;let o=Object.keys(t.iiif.entities.AnnotationPage);for(let s of o)if(!n||n.indexOf(s)!==-1){let i=_o(t,s);i&&i.views&&i.views[e]&&r.push(s)}return r},[e,n])}function Rn({canvas:e,manifest:n,all:t,canvases:r}){let o=[];if(n)for(let s of n.annotations)o.indexOf(s.id)===-1&&o.push(s.id);if(t){if(r&&r.length)for(let s of r)for(let i of s.annotations)o.indexOf(i.id)===-1&&o.push(i.id)}else if(e)for(let s of e.annotations)o.indexOf(s.id)===-1&&o.push(s.id);return o}function Ko(e,n){let t=e?.iiif?.meta[n];return t?t.annotationPageManager:null}function In(e,n={}){let t=R(),r=E(),o=M(),s=be(),i=jo(()=>Rn({all:n.all,manifest:r,canvas:o,canvases:s}),[n.all,o,s,r]),a=Pn(e,n.all?void 0:i),u=Tn(l=>{e&&t.setMetaValue([l,"annotationPageManager","views"],d=>d&&!d[e]?d:{...d||{},[e]:!1})},[e,t]),c=Tn((l,d={})=>{if(!e)return;let h=t.getState(),A=[];if(d?.deselectOthers){let y=Object.keys(h.iiif.entities.AnnotationPage);for(let g of y){let b=Ko(h,g);b&&b.views&&b.views[e]&&A.push(g)}}for(let y of A)u(y);t.setMetaValue([l,"annotationPageManager","views"],y=>y&&y[e]?y:{...y||{},[e]:!0})},[e,u,t]);return{availablePageIds:i,enabledPageIds:a,setPageEnabled:c,setPageDisabled:u}}function Mn(e,n){return T((t,r)=>r.get(e.map(o=>({id:o,type:n}))),[e,n])}import{useCallback as Yo,useEffect as Qo,useRef as Wo,useState as Go}from"react";function wn(){let e=se(),[n,t]=Go({}),r=Wo(!1);return Qo(()=>()=>{r.current=!0},[]),[Yo((s,{height:i,width:a})=>{if(s){let u=s.id||s["@id"],c=e.loadServiceSync({id:u,width:s.width||a,height:s.height||i,source:s});c?s=c:n[u]||(r.current||t(l=>({...l,[u]:"loading"})),e.loadService({id:u,width:s.width||a,height:s.height||i}).then(()=>{r.current||t(l=>({...l,[u]:"done"}))}))}return s},[e,n]),n]}import{useCallback as Zo,useMemo as Vn,useState as Jo}from"react";function En(e={}){let n=Me(),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 Xo}from"@iiif/helpers/painting-annotations";function kn(e,n=[]){let t=R(),r=Vn(()=>Xo(t),[]),o=En({enableSingleAnnotation:e?.enableSingleAnnotation}),[s,i]=Jo(e?.defaultChoices||[]),a=Vn(()=>r.getPaintables(o,s),[t,o,s,...n]),c={makeChoice:Zo((l,{deselectOthers:d=!0,deselect:h=!1}={})=>{a.choice&&i(A=>{if(h){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 y=[...A];if(y.length===0&&a.items.length){let g=a.items[0].resource.id;g&&y.push(g)}return A.indexOf(l)!==-1?A:[...A,l]})},[a.choice])};return[a,c]}function zn(e){let n=E(),t=M(),r=R(),o=Kt(),s=e?.emitter||o,[i,a]=wn(),{enabledPageIds:u}=In(e?.annotationPageManagerId||n?.id||t?.id,{all:!1}),c=Mn(u,"AnnotationPage"),l=e?.strategies||["empty","images","media","textual-content","complex-timeline"],[d,h]=kn(e,[a]);Nn(()=>{let y=g=>{h.makeChoice(g.choiceId,{deselectOthers:g.deselectOthers,deselect:g.deselect})};return s.on("make-choice",y),()=>{s.off("make-choice",y)}},[]);let A=Ln(()=>ht({canvas:t,paintables:d,supports:l,loadImageService:i}),[t,d,r,h.makeChoice]);return Nn(()=>{let y=d.allChoices,g={canvasId:t?.id,manifestId:n?.id};y&&s.emit("choice-change",{choice:y,partOf:g})},[t?.id,d.allChoices]),Ln(()=>A.type==="unknown"?[A,vt]:[{...A,annotations:{pages:c}},h],[A,c])}import{useEffect as ti,useMemo as ni,useRef as ri,useState as oi}from"react";import{useEffect as ei}from"react";var On=(e,n=[])=>{let t=R();ei(()=>{e(t)},[t,...n])};import{createThumbnailHelper as ii}from"@iiif/helpers/thumbnail";function Ee(e,n,{canvasId:t,manifestId:r}={}){let o=R(),s=se(),i=ni(()=>ii(o,{imageServiceLoader:s}),[o,s]),[a,u]=oi(),c=E(r?{id:r}:void 0),l=M(t?{id:t}:void 0),d=l||c,h=ri(!1);if(ti(()=>(h.current=!1,()=>{h.current=!0}),[]),!d)throw new Error("Must be called under a manifest or canvas context.");return On(A=>{i.getBestThumbnailAtSize(d,e,n).then(y=>{y.best&&!h.current&&u(y.best)})},[d]),a}import{useCallback as D,useEffect as Hn,useReducer as ai,useRef as Ve}from"react";function si(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function ui(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 ce(e){let[n,t]=ai(ui,si(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"}))},[]),h=D(()=>{r.current&&(r.current.muted=!0,t({type:"MUTE"}))},[]),A=D(()=>{r.current&&(r.current.muted=!1,t({type:"UNMUTE"}))},[]),y=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 x=typeof p=="function"?p(r.current.currentTime):p;r.current.currentTime=Math.max(0,Math.min(x,e.duration)),a()}},[]);return Hn(()=>{let p=setInterval(()=>{a()},350);return()=>clearInterval(p)},[a,e.duration]),Hn(()=>{let p=()=>{t({type:"FINISHED"})},x=r.current;return x?.addEventListener("ended",p),()=>x?.removeEventListener("ended",p)},[]),[{element:r,currentTime:o,progress:s},n,{play:u,pause:l,playPause:c,mute:h,unmute:A,toggleMute:d,setVolume:y,setDurationPercent:g,setTime:b}]}import{createContext as st,useContext as ut}from"react";import{jsx as at}from"react/jsx-runtime";var Fn=st(null),$n=st(null),Dn=st(null);function bd(){let e=ut(Fn);if(!e)throw new Error("Ctx not found");return e}function Pd(){let e=ut($n);if(!e)throw new Error("Ctx not found");return e}function Rd(){let e=ut(Dn);if(!e)throw new Error("Ctx not found");return e}function ke({actions:e,state:n,children:t,currentTime:r,progress:o,element:s}){return at(Dn.Provider,{value:{currentTime:r,progress:o,element:s},children:at($n.Provider,{value:e,children:at(Fn.Provider,{value:n,children:t})})})}import{useMemo as ci}from"react";import{expandTarget as li}from"@iiif/helpers";function Ne(){let e=E(),n=M();return ci(()=>{if(!e||!n||!e.start)return null;let t=li(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 di,jsxs as mi}from"react/jsx-runtime";function ct({media:e,startTime:n,children:t}){let[{element:r,currentTime:o,progress:s},i,a]=ce({duration:e.duration}),u=n?`${e.url}#t=${n}`:e.url;return mi(ke,{state:i,actions:a,currentTime:o,progress:s,element:r,children:[di("audio",{ref:r,src:u}),t]})}function Le({media:e,mediaControlsDeps:n,children:t}){let r=Ne();return O("portal","audio",ct,{media:e,startTime:r?r.startTime:null,children:t},[e,r,...n||[]]),null}import{jsx as Un,jsxs as fi}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 fi(s,{className:"video-container",part:"video-container",onClick:r,children:[Un("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
- `}),Un("video",{poster:o,ref:e,src:i,style:{width:"100%",objectFit:"contain"}})]})}function ze({media:e,mediaControlsDeps:n,children:t,videoComponent:r=lt}){let o=M(),s=Ne(),i=o&&o.placeholderCanvas&&o.placeholderCanvas.id||void 0,a=Ee({},!1,{canvasId:i}),[{element:u,currentTime:c,progress:l},d,h]=ce({duration:e.duration});return O("overlay","video-element",r,{element:u,media:e,playPause:h.playPause,poster:a?.id,startTime:s?s.startTime:null},[a]),O("portal","custom-controls",ke,{state:d,actions:h,currentTime:c,progress:l,element:u,children:t},[c,d,e,...n||[]]),null}import{Fragment as pi,jsx as dt,jsxs as gi}from"react/jsx-runtime";function mt({model:e}){return gi(pi,{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 vi}from"react/jsx-runtime";function He({style:e}){let n=M();return!n||!n.height||!n.width?null:vi("box",{interactive:!1,target:{x:0,y:0,width:Number(n.width),height:Number(n.height)},style:e})}import{jsx as qn}from"react/jsx-runtime";function Fe(e){let n=M();return!n||!n.placeholderCanvas?null:qn(q,{canvas:n.placeholderCanvas.id,children:qn(le,{renderViewerControls:e.renderViewerControls})})}import{useRef as hi}from"react";import{jsx as Bn,jsxs as Si}from"react/jsx-runtime";function yi({element:e,media:n,playPause:t}){let r=hi(null);return n.youTubeId?Si("div",{className:"video-container",part:"video-container",onClick:t,children:[Bn("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
- `}),Bn("iframe",{className:"video-yt",ref:r,src:`https://www.youtube.com/embed/${n.youTubeId}?enablejsapi=1&origin=${window.location.host}`,referrerPolicy:"no-referrer",sandbox:"allow-scripts allow-same-origin allow-presentation"})]}):null}function _n({media:e,mediaControlsDeps:n,children:t}){let[{element:r,currentTime:o,progress:s},i,a]=ce({duration:e.duration});return O("overlay","video-element",yi,{element:r,media:e,playPause:a.playPause}),null}import{useLayoutEffect as Ii,useMemo as Mi}from"react";import xi from"mitt";import{createStore as Ci}from"zustand/vanilla";function jn({currentKeyFrameIndex:e,keyframes:n,targetTime:t,currentTime:r}){if(r<=t){let o=n.findIndex(a=>a.time>t);if(o===-1)return[e,[]];let s={},i=n.slice(e,o);for(let a of i)a.type==="enter"&&(s[a.id]=a),a.type==="exit"&&(s[a.id]?delete s[a.id]:s[a.id]=a);return[o,Object.values(s)]}return[e,[]]}function Kn({complexTimeline:e,startTime:n=0}){let t=xi(),r={},o={progress:null,currentTime:null},s=0,i=null,a=0,u=null;function c(){let x=b.getState().visibleElements,m=r,v=[],I=Object.keys(m);for(let S of I){let P=m[S],C=x[S];P&&C&&v.push(P)}return v}function l(){return Object.keys(r).map(x=>r[x])}function d(p){o.currentTime&&(o.currentTime.innerHTML=it(p),o.progress&&(o.progress.style.width=`${p/e.duration*100}%`))}let h=()=>{let p=b.getState(),x=p.currentPrime;if(!x)return;let m=r,v=p.visibleElements,I=Object.keys(m);for(let S of I){let P=m[S],C=v[S];if(P&&S!==x.id&&C){let _=a-C.time*1e3;Math.abs(a-C.time*1e3-P.currentTime*1e3)>300&&(P.currentTime=_/1e3)}}},A=(p=0)=>{let x=p-s,m=b.getState();if(m.isPlaying){let v=m.currentPrime;if(v){let C=r[v.id];C&&(C.paused?a+=x:a=(v.time+C.currentTime)*1e3)}else a+=x;let I=a/1e3;if(I>m.duration){b.getState().setTime(0),b.setState({isPlaying:!1}),y(),d(0);return}d(I);let[S,P]=jn({currentTime:I,currentKeyFrameIndex:m.nextKeyframeIndex,keyframes:m.complexTimeline.keyframes,targetTime:I});P.length&&m.applyKeyframes(S,P)}s=p,i=requestAnimationFrame(A)},y=()=>{i&&cancelAnimationFrame(i)},g=(p,x)=>{},b=Ci((p,x)=>({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:()=>{x().clockRunning||(A(),u=setInterval(h,500)),p({clockRunning:!0,clockStartRequests:x().clockStartRequests+1})},applyKeyframes(m,v){let I=x(),S={...I.visibleElements},P=I.currentPrime;for(let C of v)C.type==="enter"&&(S[C.id]=C,t.emit("complex-timeline.enter",{id:C.id})),C.type==="exit"&&(S[C.id]=null,t.emit("complex-timeline.exit",{id:C.id})),C.isPrime&&(P=C);p({nextKeyframeIndex:m,visibleElements:S,currentPrime:P})},stopClock:()=>{let m=x().clockStartRequests;if(m!==0){if(m===1){y(),u&&clearInterval(u),p({clockRunning:!1,clockStartRequests:0});return}p({clockStartRequests:m-1})}},setElement:(m,v)=>{r[m]=v;let I=Object.keys(r),S=x().complexTimeline;g(v,m),S.items.filter(C=>C.type!=="Image"&&C.type!=="Text").every(C=>I.includes(C.annotationId))&&!x().isReady&&(t.emit("complex-timeline.ready",{complexTimeline:S}),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(!x().isPlaying){for(let v of c())v.play();p({isPlaying:!0})}},pause(){if(x().isPlaying){for(let v of c())v.pause();p({isPlaying:!1})}},playPause(){let m=x();m.isPlaying?m.pause():m.play()},setDurationPercent(m){let I=x().duration*m;x().setTime(I)},setTime(m){let v=x(),I=a/1e3,S=typeof m=="function"?m(I):m,P=v.nextKeyframeIndex;if(I>S){p({visibleElements:{},currentPrime:null});let L=Object.keys(v.visibleElements);for(let j of L)t.emit("complex-timeline.exit",{id:j});I=0,P=0}let[C,_]=jn({currentTime:I,currentKeyFrameIndex:P,keyframes:v.complexTimeline.keyframes,targetTime:S});v.applyKeyframes(C,_),a=S*1e3;let xe=b.getState().visibleElements,Ce=r,qe=Object.keys(xe);for(let L of qe){let j=xe[L];if(j){let Z=Ce[L];Z&&(Z.currentTime=(a-j.time*1e3)/1e3)}}d(S)},setVolume(m){for(let v of l())v.volume=Math.min(1,Math.max(0,m/100));p({volume:m})},toggleMute(){let m=x();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 x=b.getState(),m=p.id,v=r[m];v&&x.isPlaying&&v.play()}),t.on("complex-timeline.exit",p=>{let x=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 wi}from"@atlas-viewer/atlas";import{useStore as Wn}from"zustand";import{createContext as Ai,useContext as bi}from"react";import{useStore as Pi}from"zustand";import{jsx as Ri}from"react/jsx-runtime";var ft=Ai(null);ft.displayName="ComplexTimeline";function Yn({children:e,store:n}){return Ri(ft.Provider,{value:n,children:e})}function Sm(e){let n=bi(ft);if(!n)throw new Error("useComplexTimeline must be used within a ComplexTimelineProvider");return Pi(n,e)}import{HTMLPortal as Ti}from"@atlas-viewer/atlas";import{Fragment as Qn,jsx as Se}from"react/jsx-runtime";function $e({strategy:e,onClickPaintingAnnotation:n}){return Se(Qn,{children:e.items.map((t,r)=>Se(Qn,{children:Se(Ti,{onClick:n?o=>{o.stopPropagation(),n(t.annotationId,t,o)}:void 0,target:t.target?.spatial||void 0,children:Se("div",{"data-textual-content":!0,children:Se(ye,{enableDangerouslySetInnerHTML:!0,children:t.text})})},r)}))})}import{Fragment as Ei,jsx as De,jsxs as Vi}from"react/jsx-runtime";function Gn({strategy:e,children:n}){let{store:t}=Mi(()=>Kn({complexTimeline:e}),[e]),r=Wn(t,i=>i.isReady),o=Wn(t,i=>i.visibleElements);function s(i){return a=>{a&&t.getState().setElement(i,a)}}return Ii(()=>{if(r){let{startClock:i,stopClock:a}=t.getState();return i(),()=>{a()}}},[e,r]),O("portal","custom-controls",Yn,{store:t,children:n},[r]),Vi(Ei,{children:[e.items.map(i=>i.type!=="Image"||!o[i.annotationId]?null:De(ue,{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(wi,{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 le({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:h,backgroundStyle:A,alwaysShowBackground:y,keepCanvasScale:g=!1,enableSizes:b=!1,enableYouTube:p=!0,onClickPaintingAnnotation:x,children:m}){let v=M(),I=Ie(v,["deep-zoom"]),[S]=en(),P=rn(),C=R(),_=Jn(()=>ki(C),[C]),[f,xe]=zn({strategies:d||["images"],defaultChoices:o?.map(({id:w})=>w)}),Ce=f.type==="images"?f.choice:void 0,qe=Jn(()=>g?1:Math.max(1,...f.type==="images"?f.images.map(w=>(w.width||0)/w.target?.spatial.width):[]),[g,f]);an(qe),Zn(()=>{r&&r(xe)},[f.annotations]),Zn(()=>{if(o)for(let w of o)typeof w.opacity<"u"&&_.applyStyles({id:w.id},"atlas",{opacity:w.opacity})},[o]),Li(()=>{t&&t(Ce)},[Ce]),O(P&&(f.type==="images"||f.type==="empty"||f.type==="textual-content"&&i)?"overlay":"none",`canvas-portal-controls-${v?.id}`,ve.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,de=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(de)return de;if(h)throw new Error(f.reason||"Unknown image strategy");return null}let pt=Y(Ni,{children:[S?k(he,{page:S}):null,f.annotations&&f.annotations.pages?f.annotations.pages.map(w=>k(he,{page:w},w.id)):null,m]}),er=f.type==="images"?f.images.length:0,$i=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"||y?k(He,{style:A}):null,f.type==="complex-timeline"?k(Gn,{strategy:f,children:u?u(f):null}):null,f.type==="textual-content"?Y(Ue,{children:[k($e,{strategy:f,onClickPaintingAnnotation:x}),pt]}):null,f.type==="images"?Y(Ue,{children:[f.images.map((w,gt)=>k(ue,{isStatic:s,image:w,id:w.id,thumbnail:gt===0?L:void 0,selector:w.selector,enableSizes:b,onClick:x?tr=>{x(w.annotationId,w,tr)}:void 0},w.id+gt)),pt]}):null,f.type==="3d-model"?k(Oe,{model:f.model}):null,f.type==="media"?k(Ue,{children:f.media.type==="Sound"?Y(Le,{media:f.media,mediaControlsDeps:l,children:[de,a?a(f):null]}):f.media.type==="Video"?Y(ze,{media:f.media,mediaControlsDeps:l,children:[de,a?a(f):null]}):f.media.type==="VideoYouTube"&&p?Y(_n,{media:f.media,mediaControlsDeps:l,children:[de,a?a(f):null]}):null}):null]},`${v.id}/${f.type}/${er}`),f.type==="media"&&f.media.type==="Sound"&&j?k(q,{canvas:j.id,children:k(le,{renderViewerControls:i})}):null,f.type==="media"&&f.media.type==="Sound"&&Z&&!j?k(q,{canvas:Z.id,children:k(le,{renderViewerControls:i})}):null]})}import{Fragment as Hi,jsx as U,jsxs as Fi}from"react/jsx-runtime";var Oi=Xn(function(n,t){let r=E(),o=be(),s=jt(),{ViewerControls:i,MediaControls:a,ComplexTimelineControls:u}=n.components||{};if(zi(t,()=>s,[s]),!r)return U("div",{});let c=0;return Fi(Hi,{children:[n.header,U(N.Viewer,{height:n.height,mode:n.mode,renderPreset:n.renderPreset,runtimeOptions:n.runtimeOptions,children:o.map((l,d)=>{let h=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:h,...n.canvasProps||{},children:n.annotations},l.id)},l.id)})},n.reuseAtlas?"":s.currentSequenceIndex),n.children]})}),N=Xn(function({children:n,height:t,annotations:r,canvasProps:o,spacing:s,header:i,components:a,mode:u,reuseAtlas:c,renderPreset:l,runtimeOptions:d,...h},A){let y=X();return U(J,{vault:y,children:U(_t,{...h,children:U(Oi,{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=ue;N.RenderCanvas=le;N.RenderAnnotationPage=he;N.RenderAnnotation=we;N.Viewer=cn;N.CanvasBackground=He;N.Audio=Le;N.Video=ze;N.Model=Oe;N.AudioHTML=ct;N.VideoHTML=lt;N.ModelHTML=mt;N.PlaceholderCanvas=Fe;export{Ae as a,H as b,K as c,Q as d,J as e,X as f,xt as g,Ct as h,At as i,q as j,R as k,T as l,ee as m,be as n,E as o,bt as p,br as q,_e as r,za as s,Pt as t,Fa as u,je as v,Rt as w,Tt as x,Za as y,wt as z,Et as A,Vt as B,Ke as C,It as D,te as E,Vr as F,kr as G,Ft as H,$t as I,fe as J,Nr as K,gs as L,Lr as M,Ot as N,vs as O,Dt as P,qt as Q,ge as R,jr as S,_t as T,jt as U,Gr as V,re as W,Kt as X,su as Y,Yt as Z,Qt as _,Wt as $,Jt as aa,en as ba,tn as ca,ve as da,rn as ea,M as fa,Ie as ga,ie as ha,Me as ia,dn as ja,el as ka,tl as la,nl as ma,hn as na,rt as oa,yn as pa,ko as qa,No as ra,Lo as sa,rl as ta,ye as ua,Fo as va,se as wa,Rn as xa,In as ya,Mn as za,wn as Aa,En as Ba,kn as Ca,zn as Da,On as Ea,Ee as Fa,it as Ga,ce as Ha,bd as Ia,Pd as Ja,Rd as Ka,ke as La,Ne as Ma,Yn as Na,Sm as Oa,N as Pa};
@@ -1 +0,0 @@
1
- import{expandTarget as v}from"@iiif/helpers";function M(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function f(e,r){let{selector:a,source:o}=v(r);if(o.id!==e.id)return[null,o];let t={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}};return[a?a.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:a.temporal,spatial:t.spatial}:a:null,o]}var L={makeChoice:()=>{}},S={type:"unknown"},m=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),C=(e,r)=>({type:"empty",width:e,height:r,annotations:{pages:[]},image:null,images:[]});var N=["model/gltf-binary"];function I(e,r){let o=r.items[0].resource;return o.format?N.indexOf(o.format)===-1?m(`3D format: ${o.format} is unsupported`):{type:"3d-model",model:o}:m("Unknown format")}import{getImageServices as z}from"@atlas-viewer/iiif-image-api";import{expandTarget as w}from"@iiif/helpers/annotation-targets";function h(e,r,a){let o=[];for(let t of r.items){let p=t.resource&&t.resource.type==="SpecificResource"?t.resource.source:t.resource;if(!p.id)return m("No resource Identifier");let c;if(p.service){let y=z(p);y[0]&&(c=a(y[0],e))}let d={type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}},[i,n]=f(e,t.target),s=e.id?.split("?")[0]||"";if(!(n.id===e.id||decodeURIComponent(n.id||"")===(e.id||"")||n.id===s||decodeURIComponent(n.id||"")===s))continue;let l=t.resource.width&&t.resource.height?{type:"BoxSelector",spatial:{x:0,y:0,width:t.resource.width,height:t.resource.height}}:void 0,u=t.resource.type==="SpecificResource"?w(t.resource):null;if(t.selector){let y=w({type:"SpecificResource",source:t.resource,selector:t.selector});y&&(u=y)}let g=u&&u.selector&&(u.selector.type==="BoxSelector"||u.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:u.selector.spatial.x,y:u.selector.spatial.y,width:u.selector.spatial.width,height:u.selector.spatial.height}}:void 0;c&&!c.id&&(c.id=c["@id"]);let R={id:p.id,type:"Image",annotationId:t.annotationId,width:Number(i||g?p.width:e.width),height:Number(i||g?p.height:e.height),service:c,sizes:c&&c.sizes?c.sizes:p.width&&p.height?[{width:p.width,height:p.height}]:[],target:i&&i.type!=="PointSelector"?i:d,selector:g||{type:"BoxSelector",spatial:{x:0,y:0,width:Number(e.width),height:Number(e.height)}}};o.push(R)}return{type:"images",image:o[0],images:o,choice:r.choice}}function b(e,r={},a){let o=e.language||a||"none";switch(e.type){case"TextualBody":{typeof e.value<"u"&&(r[o]=[e.value]);break}case"List":case"Composite":case"Choice":e.items&&e.items.forEach(t=>b(t,r,o))}return r}function x(e,r){let a=[];return r.items.forEach(o=>{if(o.resource){let[t]=f(e,o.target);a.push({type:"Text",annotationId:o.annotationId,text:b(o.resource),target:t})}}),{type:"textual-content",items:a}}import{expandTarget as B,parseSelector as D}from"@iiif/helpers";var O=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function T(e,r){let a=r.items.filter(s=>s.type==="video"),o=!1;if(e.duration||(o=!0),a.length>1)return m("Only one video source supported");let t=a[0]?.resource,p=!!(t.service||[]).find(s=>(s.profile||"").includes("youtube.com"));if(!p&&o)return m("Video does not have duration");if(!t)return m("Unknown video");if((!t.format||t.format==="text/html")&&!p)return m("Video does not have format");let c=r.items[0],d={annotationId:r.items[0].annotationId,duration:e.duration,url:t.id,type:"Video",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:t.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},i=B(c.target);i.selector&&i.selector.type==="TemporalBoxSelector"&&(d.target=i.selector);let{selector:n}=D(c.selector);if(n===null){let s=d.target.temporal.startTime,u=(d.target.temporal.endTime||e.duration)-s;d.selector={type:"TemporalSelector",temporal:{startTime:0,endTime:u}}}else n.type==="TemporalSelector"&&(d.selector=n);if(p){d.type="VideoYouTube";let s=t.id.match(O);if(!s[1])return m("Video is not known youtube video");d.youTubeId=s[1]}return{type:"media",media:d,annotations:{pages:[]}}}function P(e,r,a){let o={type:"complex-timeline",items:[],keyframes:[],duration:e.duration||0},t={type:"complex-choice",items:[]};function p(i){i.choice&&(i.choice.type==="complex-choice"?t.items.push(...i.choice.items):t.items.push(i.choice))}for(let i of r.items){if(i.type==="image"){let n=h(e,{choice:null,allChoices:null,types:["image"],items:[i]},a);if(n.type==="images"){p(n),o.items.push(n.image);let s={id:n.image.annotationId,type:"enter",resourceType:"image",time:n.image.target?.temporal?.startTime||0};o.keyframes.push(s);let l={id:n.image.annotationId,type:"exit",resourceType:"image",time:n.image.target?.temporal?.endTime||e.duration||0};o.keyframes.push(l)}}if(i.type==="textualbody"){let n=x(e,{choice:null,allChoices:null,types:["textualbody"],items:[i]});if(n.type==="textual-content"){p(n);let s=n.items[0];o.items.push(s);let l=s.target,u={id:s.annotationId,type:"enter",resourceType:"text",time:l.temporal?.startTime||0};o.keyframes.push(u);let g={id:s.annotationId,type:"exit",resourceType:"text",time:l.temporal?.endTime||e.duration||0};o.keyframes.push(g)}}if(i.type==="video"){let n=T(e,{choice:null,allChoices:null,types:["video"],items:[i]});if(n.type==="media"){p(n);let s=n.media;o.items.push(s);let l={id:s.annotationId,type:"enter",resourceType:"video",time:s.target?.temporal?.startTime||0};o.keyframes.push(l);let u={id:s.annotationId,type:"exit",resourceType:"video",time:s.target?.temporal?.endTime||e.duration||0};o.keyframes.push(u)}}}o.keyframes.sort((i,n)=>i.time-n.time);let c=[],d=[];for(let i of o.keyframes){if(i.resourceType==="image"||i.resourceType==="text"){d.push(i);continue}if(i.type==="enter"){c.length===0&&(i.isPrime=!0),c.push(i),d.push(i);continue}if(i.type==="exit"&&(d.push(i),c=c.filter(n=>n.id!==i.id),c.length!==0)){let n=c[0],s={id:n.id,type:"change",isPrime:!0,resourceType:n.resourceType,time:i.time};d.push(s)}}return o.keyframes=d,t.items.length&&(o.choice=t),o}function k(e,r){if(!e.duration)return m("No duration on canvas");if(r.items.length>1)return m("Only one audio source supported");let a=r.items[0]?.resource;return a?a.format?{type:"media",media:{annotationId:r.items[0].annotationId,duration:e.duration,url:a.id,type:"Sound",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:a.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:m("Audio does not have format"):m("Unknown audio")}function ue({canvas:e,paintables:r,supports:a,loadImageService:o}){if(!e)return S;if(r.types.length===0)return a.indexOf("empty")!==-1?C(e.width,e.height):S;if(r.types.length!==1)if(r.types.length===2&&r.types.indexOf("text")!==-1)r.types=r.types.filter(p=>p!=="text");else return a.indexOf("complex-timeline")===-1?m("Complex timeline not supported"):P(e,r,o);let t=r.types[0];return t==="image"?a.indexOf("images")===-1?m("Image not supported"):h(e,r,o):t==="Model"||t==="model"?a.indexOf("3d-model")===-1?m("3D not supported"):I(e,r):t==="textualbody"?a.indexOf("textual-content")===-1?m("Textual content not supported"):x(e,r):t==="sound"||t==="audio"?a.indexOf("media")===-1?m("Media not supported"):k(e,r):t==="video"?a.indexOf("media")===-1?m("Media not supported"):T(e,r):S}export{M as a,f as b,L as c,S as d,m as e,C as f,I as g,h,x as i,T as j,P as k,ue as l};