react-iiif-vault 1.0.10 → 1.0.11

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.
@@ -1 +1 @@
1
- {"version":3,"file":"canvas-panel.js","sources":["../../../node_modules/react-error-boundary/dist/react-error-boundary.esm.js","../../../src/context/ResourceContext.tsx","../../../src/context/VaultContext.tsx","../../../src/hooks/useExistingVault.ts","../../../src/hooks/useExternalResource.ts","../../../src/hooks/useExternalManifest.ts","../../../src/context/ManifestContext.tsx","../../../src/context/CanvasContext.tsx","../../../src/hooks/useVault.ts","../../../src/hooks/useVaultSelector.ts","../../../src/context/VisibleCanvasContext.tsx","../../../src/hooks/useManifest.ts","../../../src/context/RangeContext.tsx","../../../src/future-helpers/ranges.ts","../../../src/future-helpers/sequences.ts","../../../src/hooks/useRange.ts","../../../src/viewers/SimpleViewerContext.hooks.ts","../../../src/viewers/SimpleViewerContext.tsx","../../../src/context/ContextBridge.tsx","../../../node_modules/@iiif/helpers/dist/vault-actions/esm/vault-actions.mjs","../../../src/hooks/useDispatch.ts","../../../src/hooks/useVirtualAnnotationPage.ts","../../../src/hooks/useVirtualAnnotationPageContext.tsx","../../../src/canvas-panel/render/DefaultCanvasFallback.tsx","../../../src/context/ViewerPresetContext.tsx","../../../src/canvas-panel/context/overlays.tsx","../../../src/hooks/useCanvas.ts","../../../src/canvas-panel/context/world-size.ts","../../../src/canvas-panel/Viewer.tsx","../../../node_modules/@iiif/helpers/dist/events/esm/events.mjs","../../../src/hooks/useResourceEvents.ts","../../../src/hooks/useStyles.ts","../../../src/hooks/useAnnotation.ts","../../../src/canvas-panel/render/Annotation.tsx","../../../src/hooks/useAnnotationPage.ts","../../../src/canvas-panel/render/AnnotationPage.tsx","../../../src/canvas-panel/render/Image.tsx","../../../src/features/rendering-strategy/rendering-utils.ts","../../../src/hooks/useEnabledAnnotationPageIds.ts","../../../src/utility/flatten-annotation-page-ids.ts","../../../src/hooks/useAnnotationPageManager.ts","../../../src/hooks/useResources.ts","../../../src/context/ImageServiceLoaderContext.tsx","../../../src/hooks/useLoadImageService.ts","../../../src/hooks/usePaintingAnnotations.ts","../../../node_modules/@iiif/helpers/dist/painting-annotations/esm/painting-annotations.mjs","../../../src/hooks/usePaintables.ts","../../../src/features/rendering-strategy/3d-strategy.ts","../../../src/features/rendering-strategy/audio-strategy.ts","../../../src/features/rendering-strategy/image-strategy.ts","../../../src/features/rendering-strategy/textual-content-strategy.ts","../../../src/features/rendering-strategy/video-strategy.ts","../../../src/features/rendering-strategy/get-rendering-strategy.ts","../../../src/hooks/useRenderingStrategy.ts","../../../src/hooks/useVaultEffect.ts","../../../src/hooks/useThumbnail.ts","../../../src/hooks/useSimpleMediaPlayer.ts","../../../src/context/MediaContext.tsx","../../../src/canvas-panel/render/Audio.tsx","../../../src/canvas-panel/render/Video.tsx","../../../src/canvas-panel/render/Model.tsx","../../../src/canvas-panel/render/CanvasBackground.tsx","../../../src/utility/i18n-utils.tsx","../../../src/canvas-panel/render/VideoYouTube.tsx","../../../src/canvas-panel/render/Canvas.tsx","../../../src/canvas-panel/index.tsx"],"sourcesContent":["'use client';\nimport { createContext, Component, createElement, isValidElement, useContext, useState, useMemo, forwardRef } from 'react';\n\nconst ErrorBoundaryContext = createContext(null);\n\nconst initialState = {\n didCatch: false,\n error: null\n};\nclass ErrorBoundary extends Component {\n constructor(props) {\n super(props);\n this.resetErrorBoundary = this.resetErrorBoundary.bind(this);\n this.state = initialState;\n }\n static getDerivedStateFromError(error) {\n return {\n didCatch: true,\n error\n };\n }\n resetErrorBoundary() {\n const {\n error\n } = this.state;\n if (error !== null) {\n var _this$props$onReset, _this$props;\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n (_this$props$onReset = (_this$props = this.props).onReset) === null || _this$props$onReset === void 0 ? void 0 : _this$props$onReset.call(_this$props, {\n args,\n reason: \"imperative-api\"\n });\n this.setState(initialState);\n }\n }\n componentDidCatch(error, info) {\n var _this$props$onError, _this$props2;\n (_this$props$onError = (_this$props2 = this.props).onError) === null || _this$props$onError === void 0 ? void 0 : _this$props$onError.call(_this$props2, error, info);\n }\n componentDidUpdate(prevProps, prevState) {\n const {\n didCatch\n } = this.state;\n const {\n resetKeys\n } = this.props;\n\n // There's an edge case where if the thing that triggered the error happens to *also* be in the resetKeys array,\n // we'd end up resetting the error boundary immediately.\n // This would likely trigger a second error to be thrown.\n // So we make sure that we don't check the resetKeys on the first call of cDU after the error is set.\n\n if (didCatch && prevState.error !== null && hasArrayChanged(prevProps.resetKeys, resetKeys)) {\n var _this$props$onReset2, _this$props3;\n (_this$props$onReset2 = (_this$props3 = this.props).onReset) === null || _this$props$onReset2 === void 0 ? void 0 : _this$props$onReset2.call(_this$props3, {\n next: resetKeys,\n prev: prevProps.resetKeys,\n reason: \"keys\"\n });\n this.setState(initialState);\n }\n }\n render() {\n const {\n children,\n fallbackRender,\n FallbackComponent,\n fallback\n } = this.props;\n const {\n didCatch,\n error\n } = this.state;\n let childToRender = children;\n if (didCatch) {\n const props = {\n error,\n resetErrorBoundary: this.resetErrorBoundary\n };\n if (typeof fallbackRender === \"function\") {\n childToRender = fallbackRender(props);\n } else if (FallbackComponent) {\n childToRender = createElement(FallbackComponent, props);\n } else if (fallback === null || isValidElement(fallback)) {\n childToRender = fallback;\n } else {\n throw error;\n }\n }\n return createElement(ErrorBoundaryContext.Provider, {\n value: {\n didCatch,\n error,\n resetErrorBoundary: this.resetErrorBoundary\n }\n }, childToRender);\n }\n}\nfunction hasArrayChanged() {\n let a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n let b = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n return a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]));\n}\n\nfunction assertErrorBoundaryContext(value) {\n if (value == null || typeof value.didCatch !== \"boolean\" || typeof value.resetErrorBoundary !== \"function\") {\n throw new Error(\"ErrorBoundaryContext not found\");\n }\n}\n\nfunction useErrorBoundary() {\n const context = useContext(ErrorBoundaryContext);\n assertErrorBoundaryContext(context);\n const [state, setState] = useState({\n error: null,\n hasError: false\n });\n const memoized = useMemo(() => ({\n resetBoundary: () => {\n context.resetErrorBoundary();\n setState({\n error: null,\n hasError: false\n });\n },\n showBoundary: error => setState({\n error,\n hasError: true\n })\n }), [context.resetErrorBoundary]);\n if (state.hasError) {\n throw state.error;\n }\n return memoized;\n}\n\nfunction withErrorBoundary(component, errorBoundaryProps) {\n const Wrapped = forwardRef((props, ref) => createElement(ErrorBoundary, errorBoundaryProps, createElement(component, {\n ...props,\n ref\n })));\n\n // Format for display in DevTools\n const name = component.displayName || component.name || \"Unknown\";\n Wrapped.displayName = \"withErrorBoundary(\".concat(name, \")\");\n return Wrapped;\n}\n\nexport { ErrorBoundary, ErrorBoundaryContext, useErrorBoundary, withErrorBoundary };\n","import React, { ReactNode, useContext, useMemo } from 'react';\n\nconst defaultResourceContext = {\n collection: undefined,\n manifest: undefined,\n range: undefined,\n canvas: undefined,\n annotation: undefined,\n annotationPage: undefined,\n};\n\nexport type ResourceContextType = {\n collection?: string;\n manifest?: string;\n range?: string;\n canvas?: string;\n annotation?: string;\n annotationPage?: string;\n};\n\nexport const ResourceReactContext = React.createContext<ResourceContextType>(defaultResourceContext);\n\nexport const useResourceContext = () => {\n return useContext(ResourceReactContext);\n};\n\nexport function ResourceProvider({ value, children }: { value: ResourceContextType; children: ReactNode }) {\n const parentContext = useResourceContext();\n const newContext = useMemo(() => {\n return {\n ...parentContext,\n ...value,\n };\n }, [value, parentContext]);\n\n return <ResourceReactContext.Provider value={newContext}>{children}</ResourceReactContext.Provider>;\n}\n","import React, { ReactElement, ReactNode, useState } from 'react';\nimport { Vault, VaultOptions, globalVault } from '@iiif/helpers/vault';\nimport { ResourceContextType, ResourceProvider } from './ResourceContext';\n\nexport const ReactVaultContext = React.createContext<{\n vault: Vault | null;\n setVaultInstance: (vault: Vault) => void;\n}>({\n vault: null,\n setVaultInstance: (vault: Vault) => {\n // Do nothing.\n },\n});\n\nexport function VaultProvider({\n vault,\n vaultOptions,\n useGlobal,\n resources,\n children,\n}: {\n vault?: Vault;\n useGlobal?: boolean;\n vaultOptions?: VaultOptions;\n resources?: ResourceContextType;\n children: ReactNode;\n}) {\n const [vaultInstance, setVaultInstance] = useState<Vault>(() => {\n if (vault) {\n return vault;\n }\n if (useGlobal) {\n return globalVault(vaultOptions);\n }\n if (vaultOptions) {\n return new Vault(vaultOptions);\n }\n return new Vault();\n });\n\n return (\n <ReactVaultContext.Provider value={{ vault: vaultInstance, setVaultInstance }}>\n <ResourceProvider value={resources || {}}>{children}</ResourceProvider>\n </ReactVaultContext.Provider>\n );\n}\n","import { globalVault, Vault } from '@iiif/helpers/vault';\nimport { useContext } from 'react';\nimport { ReactVaultContext } from '../context/VaultContext';\n\nexport function useExistingVault(vault?: Vault): Vault {\n const oldContext: any = useContext(ReactVaultContext);\n\n if (vault) {\n return vault;\n }\n\n return oldContext && oldContext.vault ? (oldContext.vault as any) : globalVault();\n}\n","import { useExistingVault } from './useExistingVault';\nimport { useEffect, useMemo, useState } from 'react';\n\nexport type ResourceRequestOptions = {\n noCache?: boolean;\n};\n\nexport function useExternalResource<T extends { id: string }>(\n idOrRef: string | { id: string; type: string },\n { noCache = false }: ResourceRequestOptions = {}\n): {\n id: string;\n requestId: string;\n isLoaded: boolean;\n error: any;\n cached: boolean;\n resource?: T;\n} {\n const id = typeof idOrRef === 'string' ? idOrRef : idOrRef.id;\n const vault = useExistingVault();\n const [realId, setRealId] = useState(id);\n const [error, setError] = useState<Error | undefined>(undefined);\n const initialData = useMemo(() => {\n return vault.get(id, { skipSelfReturn: true }) || undefined;\n }, [id, vault]);\n const [resource, setResource] = useState<T | undefined>(initialData);\n\n useEffect(() => {\n (async () => {\n try {\n const fetchedResource = initialData && !noCache ? initialData : await vault.load<T>(id);\n const _realId = fetchedResource ? fetchedResource.id || (fetchedResource as any)['@id'] : null;\n if (fetchedResource && realId !== _realId) {\n setRealId(_realId);\n }\n\n setResource(fetchedResource);\n } catch (err) {\n setError(err as Error);\n }\n })();\n }, [id, noCache]);\n\n return {\n isLoaded: !!resource,\n id: realId,\n requestId: id,\n error,\n resource,\n cached: !!(resource && resource === initialData),\n };\n}\n","import { ManifestNormalized } from '@iiif/presentation-3-normalized';\nimport { ResourceRequestOptions, useExternalResource } from './useExternalResource';\n\nexport function useExternalManifest(\n idOrRef: string | { id: string; type: string },\n options?: ResourceRequestOptions\n): {\n id: string;\n requestId: string;\n isLoaded: boolean;\n cached?: boolean;\n error: any;\n manifest?: ManifestNormalized;\n} {\n const { id, isLoaded, error, resource, requestId, cached } = useExternalResource<ManifestNormalized>(\n idOrRef,\n options\n );\n\n return { id, isLoaded, error, manifest: resource, requestId, cached };\n}\n","import { ResourceProvider } from './ResourceContext';\nimport React, { ReactNode } from 'react';\n\nexport function ManifestContext({ manifest, children }: { manifest: string; children: ReactNode }) {\n return <ResourceProvider value={{ manifest }}>{children}</ResourceProvider>;\n}\n","import { ResourceProvider } from './ResourceContext';\nimport React, { ReactNode } from 'react';\n\nexport function CanvasContext({ canvas, children }: { canvas: string; children: ReactNode }) {\n return <ResourceProvider value={{ canvas }}>{children}</ResourceProvider>;\n}\n","import { ReactVaultContext } from '../context/VaultContext';\nimport { useContext } from 'react';\nimport { Vault } from '@iiif/helpers/vault';\n\nexport const useVault = (): Vault => {\n const { vault } = useContext(ReactVaultContext);\n\n if (vault === null) {\n throw new Error('Vault not found. Ensure you have your provider set up correctly.');\n }\n\n return vault as Vault;\n};\n","import { useVault } from './useVault';\nimport { IIIFStore, Vault } from '@iiif/helpers/vault';\nimport { useEffect, useState } from 'react';\n\nexport function useVaultSelector<T>(selector: (state: IIIFStore, vault: Vault) => T, deps: any[] = []) {\n const vault = useVault();\n const [selectedState, setSelectedState] = useState<T>(() => selector(vault.getState(), vault));\n\n useEffect(() => {\n return vault.subscribe(\n (s) => selector(s, vault),\n (s) => {\n setSelectedState(s);\n },\n false\n );\n }, deps);\n\n return selectedState as T;\n}\n","import { useContext } from 'react';\nimport React from 'react';\nimport { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { useVaultSelector } from '../hooks/useVaultSelector';\n\nexport const VisibleCanvasReactContext = React.createContext<string[]>([]);\n\nexport function useVisibleCanvases(): CanvasNormalized[] {\n const ids = useContext(VisibleCanvasReactContext);\n\n return useVaultSelector<CanvasNormalized[]>(\n (state) => {\n return ids.map((id) => state.iiif.entities.Canvas[id]).filter(Boolean);\n },\n [ids]\n );\n}\n","import { useResourceContext } from '../context/ResourceContext';\nimport { ManifestNormalized } from '@iiif/presentation-3-normalized';\nimport { useVault } from './useVault';\nimport { useMemo } from 'react';\nimport { useVaultSelector } from './useVaultSelector';\n\nexport function useManifest(options?: { id: string }): ManifestNormalized | undefined;\nexport function useManifest<T>(\n options?: { id: string; selector: (manifest: ManifestNormalized) => T },\n deps?: any[]\n): T | undefined;\nexport function useManifest<T = ManifestNormalized>(\n options: {\n id?: string;\n selector?: (manifest: ManifestNormalized) => T;\n } = {},\n deps: any[] = []\n): ManifestNormalized | T | undefined {\n const { id, selector } = options;\n const ctx = useResourceContext();\n const vault = useVault();\n const manifestId = id ? id : ctx.manifest;\n\n const manifest = useVaultSelector(\n (s) => (manifestId ? s.iiif.entities.Manifest[manifestId] : undefined),\n [manifestId]\n );\n\n return useMemo(() => {\n if (!manifest) {\n return undefined;\n }\n if (selector) {\n return selector(manifest);\n }\n return manifest;\n }, [manifest, selector, ...deps]);\n}\n","import { ResourceProvider } from './ResourceContext';\nimport React, { ReactNode } from 'react';\n\nexport function RangeContext({ range, children }: { range: string; children: ReactNode }) {\n return <ResourceProvider value={{ range }}>{children}</ResourceProvider>;\n}\n","import { Vault } from '@iiif/helpers/vault';\nimport { ManifestNormalized, RangeNormalized } from '@iiif/presentation-3-normalized';\nimport { Reference } from '@iiif/presentation-3';\n\nexport function findFirstCanvasFromRange(vault: Vault, range: RangeNormalized): null | Reference<'Canvas'> {\n for (const inner of range.items) {\n if ((inner as any).type === 'Canvas') {\n return inner as any as Reference<'Canvas'>;\n }\n if (inner.type === 'SpecificResource') {\n return inner.source as Reference<'Canvas'>;\n }\n if (inner.type === 'Range') {\n const found = findFirstCanvasFromRange(vault, vault.get(inner));\n if (found) {\n return found;\n }\n }\n }\n return null;\n}\n\nexport function findAllCanvasesInRange(vault: Vault, range: RangeNormalized): Array<Reference<'Canvas'>> {\n const found: Reference<'Canvas'>[] = [];\n for (const inner of range.items) {\n if (inner.type === 'SpecificResource' && inner.source?.type === 'Canvas') {\n if (inner.source.id.indexOf('#') !== -1) {\n found.push({ id: inner.source.id.split('#')[0], type: 'Canvas' });\n } else {\n found.push(inner.source as Reference<'Canvas'>);\n }\n }\n if (inner.type === 'Range') {\n found.push(...findAllCanvasesInRange(vault, vault.get(inner)));\n }\n if ((inner as any).type === 'SpecificResource') {\n const sourceId = typeof (inner as any).source === 'string' ? (inner as any).source : (inner as any).source.id;\n found.push({ id: sourceId, type: 'Canvas' });\n }\n }\n return found;\n}\n\nexport function findManifestSelectedRange(\n vault: Vault,\n manifest: ManifestNormalized,\n canvasId: string\n): null | RangeNormalized {\n for (const range of manifest.structures) {\n const found = findSelectedRange(vault, vault.get(range), canvasId);\n if (found) {\n return found;\n }\n }\n\n return null;\n}\n\nexport function findSelectedRange(vault: Vault, range: RangeNormalized, canvasId: string): null | RangeNormalized {\n for (const inner of range.items) {\n const parsedId = (inner as any)?.source?.id?.split('#')[0];\n if ((inner as any).type === 'SpecificResource' && (inner as any).source === canvasId) {\n return range;\n }\n if (inner.type === 'SpecificResource' && inner.source?.type === 'Canvas' && canvasId === parsedId) {\n return range;\n }\n if (inner.type === 'Range') {\n const found = findSelectedRange(vault, vault.get(inner), canvasId);\n if (found) {\n return found;\n }\n }\n }\n return null;\n}\n","import { CanvasNormalized, ManifestNormalized, RangeNormalized } from '@iiif/presentation-3-normalized';\nimport { Reference } from '@iiif/presentation-3';\nimport { Vault } from '@iiif/helpers/vault';\nimport { findAllCanvasesInRange } from './ranges';\n\n/**\n * Get visible canvases from canvas ID\n *\n * This function returns a list of canvas references that should all be displayed\n * when the passed canvasId is visible. This should work for individual items,\n * 2-up paged view and continuous (scrolls).\n *\n * The options are listed below (from IIIF docs)\n *\n * - `unordered` - Valid on Collections, Manifests and Ranges. The Canvases included in resources that have this behavior\n * have no inherent order, and user interfaces should avoid implying an order to the user. Disjoint with individuals,\n * continuous, and paged.\n *\n * - `individuals` - Valid on Collections, Manifests, and Ranges. For Collections that have this behavior, each of the\n * included Manifests are distinct objects in the given order. For Manifests and Ranges, the included Canvases are\n * distinct views, and should not be presented in a page-turning interface. This is the default layout behavior if\n * not specified. Disjoint with unordered, continuous, and paged.\n *\n * - `continuous` Valid on Collections, Manifests and Ranges, which include Canvases that have at least height and\n * width dimensions. Canvases included in resources that have this behavior are partial views and an appropriate\n * rendering might display all of the Canvases virtually stitched together, such as a long scroll split into\n * sections. This behavior has no implication for audio resources. The viewingDirection of the Manifest will\n * determine the appropriate arrangement of the Canvases. Disjoint with unordered, individuals and paged.\n *\n * - `paged` Valid on Collections, Manifests and Ranges, which include Canvases that have at least height and width\n * dimensions. Canvases included in resources that have this behavior represent views that should be presented in\n * a page-turning interface if one is available. The first canvas is a single view (the first recto) and thus the\n * second canvas likely represents the back of the object in the first canvas. If this is not the case, see the\n * behavior value non-paged. Disjoint with unordered, individuals, continuous, facing-pages and non-paged.\n *\n */\nexport function getVisibleCanvasesFromCanvasId(\n vault: Vault,\n manifestOrRange: ManifestNormalized | RangeNormalized,\n canvasId: string | null,\n preventPaged = false\n): Reference<'Canvas'>[] {\n const behavior = manifestOrRange.behavior;\n const fullCanvas = canvasId ? vault.get<CanvasNormalized>(canvasId) : null;\n if (!fullCanvas) {\n return [];\n }\n\n const canvasBehavior = fullCanvas.behavior;\n const isPaged = preventPaged ? false : behavior.includes('paged');\n const isContinuous = isPaged ? false : behavior.includes('continuous');\n const isIndividuals = isPaged || isContinuous ? false : behavior.includes('individuals');\n const isCanvasFacingPages = canvasBehavior.includes('facing-pages');\n const isCanvasNonPaged = canvasBehavior.includes('non-paged');\n\n // Individuals should just be the default.\n if (isCanvasFacingPages || isCanvasNonPaged || isIndividuals || preventPaged) {\n return [{ id: fullCanvas.id, type: 'Canvas' }];\n }\n\n const [manifestItems, ordering] = getManifestSequence(vault, manifestOrRange);\n\n // Continuous should just return all items together.\n if (isContinuous) {\n return manifestItems;\n }\n\n const canvasIndex = manifestItems.findIndex((r) => r.id === canvasId);\n if (canvasIndex === -1) {\n return [];\n }\n\n for (const indexes of ordering) {\n if (indexes.includes(canvasIndex)) {\n return indexes.map((index) => manifestItems[index]);\n }\n }\n\n return [{ id: fullCanvas.id, type: 'Canvas' }];\n}\n\nexport function getManifestSequence(\n vault: Vault,\n manifestOrRange: ManifestNormalized | RangeNormalized,\n { disablePaging, skipNonPaged }: { disablePaging?: boolean; skipNonPaged?: boolean } = {}\n): [Reference<'Canvas'>[], number[][]] {\n const behavior = manifestOrRange.behavior;\n const isPaged = behavior.includes('paged');\n const isContinuous = isPaged ? false : behavior.includes('continuous');\n const isIndividuals = isPaged || isContinuous ? false : behavior.includes('individuals');\n const manifestItems =\n manifestOrRange.type === 'Manifest' ? manifestOrRange.items : findAllCanvasesInRange(vault, manifestOrRange);\n\n // Continuous should just return all items together.\n if (isContinuous) {\n return [manifestItems, [manifestItems.map((_, index) => index)]];\n }\n\n // Individuals should just be the default.\n if (isIndividuals || !isPaged || disablePaging) {\n return [manifestItems, manifestItems.map((_, index) => [index])];\n }\n\n // This is the tricky case.\n const ordering: number[][] = [];\n let currentOrdering: number[] = [];\n\n const flush = () => {\n if (currentOrdering.length) {\n ordering.push([...currentOrdering]);\n currentOrdering = [];\n }\n };\n\n let offset = 0;\n let flushNextPaged = false;\n for (let i = 0; i < manifestItems.length; i++) {\n const canvas = vault.get<CanvasNormalized>(manifestItems[i]);\n if (canvas.behavior.includes('non-paged')) {\n if (i === offset) {\n offset++;\n }\n if (!skipNonPaged) {\n flush();\n ordering.push([i]);\n flush();\n }\n continue;\n }\n\n if (i === offset || canvas.behavior.includes('facing-pages')) {\n // Flush and push a single.\n if (currentOrdering.length) {\n flushNextPaged = true;\n }\n flush();\n ordering.push([i]);\n flush();\n continue;\n }\n\n currentOrdering.push(i);\n\n if (flushNextPaged) {\n flush();\n flushNextPaged = false;\n continue;\n }\n\n if (currentOrdering.length > 1) {\n flush();\n }\n }\n\n if (currentOrdering.length) {\n flush();\n }\n\n return [manifestItems, ordering];\n}\n","// This is valid under a range context.\nimport { useResourceContext } from '../context/ResourceContext';\nimport { RangeNormalized } from '@iiif/presentation-3-normalized';\nimport { useMemo } from 'react';\nimport { useVaultSelector } from './useVaultSelector';\n\nexport function useRange(options?: { id: string }): RangeNormalized | undefined;\nexport function useRange<T>(\n options?: { id: string; selector: (range: RangeNormalized) => T },\n deps?: any[]\n): T | undefined;\nexport function useRange<T = RangeNormalized>(\n options: {\n id?: string;\n selector?: (range: RangeNormalized) => T;\n } = {},\n deps: any[] = []\n): RangeNormalized | T | undefined {\n const { id, selector } = options;\n const ctx = useResourceContext();\n const rangeId = id ? id : ctx.range;\n\n const range = useVaultSelector((s) => (rangeId ? s.iiif.entities.Range[rangeId] : undefined), [rangeId]);\n\n return useMemo(() => {\n if (!range) {\n return undefined;\n }\n if (selector) {\n return selector(range);\n }\n return range;\n }, [range, selector, ...deps]);\n}\n","import { getManifestSequence } from '../future-helpers/sequences';\nimport { useManifest } from '../hooks/useManifest';\nimport { useCallback, useMemo, useState } from 'react';\nimport { useRange } from '../hooks/useRange';\nimport { useVault } from '../hooks/useVault';\n\nexport function useCanvasSequence({ startCanvas, disablePaging }: { startCanvas?: string; disablePaging?: boolean }) {\n const vault = useVault();\n const manifest = useManifest();\n const range = useRange();\n const [cursor, setCursor] = useState<number>(undefined as any);\n const rangeOrManifest = range ? range : manifest;\n\n if (!rangeOrManifest) {\n throw new Error('Nothing selected');\n }\n\n const [items, initialSequence] = useMemo(\n () => getManifestSequence(vault, rangeOrManifest, { disablePaging }),\n [vault, rangeOrManifest, disablePaging]\n );\n\n const setCanvasIndex = useCallback(\n (index: number) => {\n const foundSequence = initialSequence.findIndex((i) => i.includes(index));\n setCursor(foundSequence === -1 ? 0 : foundSequence);\n },\n [items, initialSequence]\n );\n\n const setCanvasId = useCallback(\n (id: string) => {\n const foundIndex = items.findIndex((i) => i.id === id);\n if (foundIndex !== -1) {\n setCanvasIndex(foundIndex);\n } else {\n setCursor(0);\n }\n },\n [items, initialSequence]\n );\n\n const next = useCallback(() => {\n setCursor((i) => {\n if (i >= initialSequence.length - 1) {\n return i;\n }\n return i + 1;\n });\n }, [initialSequence]);\n\n const previous = useCallback(() => {\n setCursor((i) => {\n if (i <= 0) {\n return 0;\n }\n return i - 1;\n });\n }, [initialSequence]);\n\n // Need to set an initial cursor from the canvasId (if it's valid)\n if (typeof cursor === 'undefined') {\n if (startCanvas) {\n setCanvasId(startCanvas);\n } else {\n setCursor(0);\n }\n }\n\n return {\n visibleItems: initialSequence[cursor]?.map((idx) => items[idx].id) || [],\n cursor,\n items,\n sequence: initialSequence,\n hasPrevious: cursor > 0,\n hasNext: cursor < initialSequence.length - 1,\n setSequenceIndex: setCursor,\n setCanvasIndex,\n setCanvasId,\n next,\n previous,\n };\n}\n","import React, { ReactNode, useCallback, useContext, useEffect } from 'react';\n/**\n * Simple viewer context\n * *****************************************************************************\n *\n * This will be the context to use to get a basic IIIF viewer up and running.\n * It will not focus on having compatibility with the full range of IIIF\n * resources, instead offering a viewer for a Manifest, cycling through canvases\n * while ignoring the paged/facing-pages/continuous behaviors.\n *\n * There will not be support for canvas-on-canvas annotations. Annotations will\n * be filtered, giving details of the canvas space and images to be annotated\n * onto that space. The demo implementation of this viewer will use\n * OpenSeadragon to display.\n *\n * Navigation functions will include the basics:\n * - nextCanvas()\n * - previousCanvas()\n * - goToCanvas(id)\n * - goToCanvasIndex(idx)\n * - goToFirstCanvas()\n * - goToLastCanvas()\n *\n * It will take in only a Manifest ID and will load that Manifest when the\n * context loads.\n *\n * There will be no support for external or embedded annotation lists, although\n * you can set up a nested context to support this.\n *\n * There will be no support for ranges in this view.\n *\n * To use this component, first you will need the provider:\n * import { SimpleViewerProvider } from '...';\n *\n * <SimpleViewerProvider id=\"http://example.org/manifest.json\">\n * <CustomComponent />\n * </SimpleViewerProvider>\n *\n * This is in addition to the core Vault context further up the tree.\n *\n * In components that you want to use parts of the state you can grab the hooks\n * from this file.\n *\n * import { useSimpleViewer } from '...';\n *\n * And use them in your components to get the actions.\n *\n * function NextButton() {\n * const { nextCanvas } = useSimpleViewer();\n *\n * return <button onClick={nextCanvas}>Next</button>;\n * }\n *\n * Since this is a single-context, there is only ever one manifest, canvas and\n * annotation list. You can access the current resource using the normal hooks.\n *\n * function CanvasMetadata() {\n * const metadata = useCanvas(metadataSelector);\n *\n * return <div> ... </div>\n * }\n *\n * So long as this is inside the provider, it will have the correct context.\n */\nimport { createContext, FC, useMemo, useState } from 'react';\nimport { useExternalManifest } from '../hooks/useExternalManifest';\nimport { ManifestContext } from '../context/ManifestContext';\nimport { CanvasContext } from '../context/CanvasContext';\nimport { VisibleCanvasReactContext } from '../context/VisibleCanvasContext';\nimport { useManifest } from '../hooks/useManifest';\nimport { SimpleViewerContext, SimpleViewerProps } from './SimpleViewerContext.types';\nimport { RangeContext } from '../context/RangeContext';\nimport { useCanvasSequence } from './SimpleViewerContext.hooks';\nimport { VaultProvider } from '../context/VaultContext';\nimport { useExistingVault } from '../hooks/useExistingVault';\n\nconst noop = () => {\n //\n};\n\nexport const SimpleViewerReactContext = createContext<SimpleViewerContext>({\n setCurrentCanvasId: noop,\n setCurrentCanvasIndex: noop,\n nextCanvas: noop,\n previousCanvas: noop,\n items: [],\n sequence: [],\n setSequenceIndex: noop,\n currentSequenceIndex: 0,\n hasNext: false,\n hasPrevious: false,\n});\n\nexport function InnerViewerProvider(props: SimpleViewerProps) {\n const manifest = useManifest();\n const {\n cursor,\n visibleItems,\n next,\n sequence,\n items,\n setCanvasIndex,\n setCanvasId,\n previous,\n setSequenceIndex,\n hasNext,\n hasPrevious,\n } = useCanvasSequence({\n startCanvas: props.startCanvas,\n disablePaging: props.pagingEnabled === false,\n });\n\n const ctx = useMemo(\n () =>\n ({\n sequence,\n items,\n // Extra functions.\n setCurrentCanvasId: setCanvasId,\n nextCanvas: next,\n previousCanvas: previous,\n totalCanvases: items.length,\n setCurrentCanvasIndex: setCanvasIndex,\n setSequenceIndex: setSequenceIndex,\n currentSequenceIndex: cursor,\n hasNext,\n hasPrevious,\n } as SimpleViewerContext),\n [sequence, items, setCanvasId, next, previous, items, setCanvasIndex, setSequenceIndex, cursor]\n );\n\n if (!manifest) {\n console.warn('The manifest passed to the provider is not a valid IIIF manifest.');\n return <div>Sorry, something went wrong.</div>;\n }\n\n if (visibleItems.length === 0) {\n return null;\n }\n\n return (\n <SimpleViewerReactContext.Provider value={ctx}>\n <VisibleCanvasReactContext.Provider value={visibleItems}>\n <CanvasContext canvas={visibleItems[0]}>{props.children}</CanvasContext>\n </VisibleCanvasReactContext.Provider>\n </SimpleViewerReactContext.Provider>\n );\n}\n\nexport function SimpleViewerProvider(props: SimpleViewerProps) {\n const vault = useExistingVault(props.vault);\n const manifest = useExternalManifest(props.manifest);\n\n if (!manifest) {\n console.warn('The manifest passed to the provider is not a valid IIIF manifest.');\n return <div>Sorry, something went wrong.</div>;\n }\n\n if (manifest.error) {\n return <div>{manifest.error.toString()}</div>;\n }\n\n if (!manifest.isLoaded) {\n return <div>Loading...</div>;\n }\n\n const inner = <InnerViewerProvider {...props}>{props.children}</InnerViewerProvider>;\n\n return (\n <VaultProvider vault={vault}>\n <ManifestContext manifest={manifest.id}>\n {props.rangeId ? <RangeContext range={props.rangeId}>{inner}</RangeContext> : inner}\n </ManifestContext>\n </VaultProvider>\n );\n}\n\nexport function useSimpleViewer() {\n return useContext(SimpleViewerReactContext);\n}\n","import React, { ReactNode, useContext } from 'react';\nimport { ResourceReactContext } from './ResourceContext';\nimport { ReactVaultContext, VaultProvider } from './VaultContext';\nimport { SimpleViewerReactContext } from '../viewers/SimpleViewerContext';\nimport { VisibleCanvasReactContext } from './VisibleCanvasContext';\n\nexport function useContextBridge() {\n return {\n VaultContext: useContext(ReactVaultContext),\n ResourceContext: useContext(ResourceReactContext),\n SimpleViewerReactContext: useContext(SimpleViewerReactContext),\n VisibleCanvasReactContext: useContext(VisibleCanvasReactContext),\n };\n}\n\nexport function ContextBridge(props: { bridge: ReturnType<typeof useContextBridge>; children: ReactNode }) {\n return (\n <VaultProvider vault={props.bridge.VaultContext.vault || undefined} resources={props.bridge.ResourceContext}>\n <VisibleCanvasReactContext.Provider value={props.bridge.VisibleCanvasReactContext}>\n <SimpleViewerReactContext.Provider value={props.bridge.SimpleViewerReactContext}>\n {props.children}\n </SimpleViewerReactContext.Provider>\n </VisibleCanvasReactContext.Provider>\n </VaultProvider>\n );\n}\n","const E = function(t) {\n return function() {\n const n = { type: t, getType: () => t, toString: () => t };\n return (i, R) => ({\n ...n,\n ...i !== void 0 && { payload: i },\n ...R !== void 0 && { meta: R }\n });\n };\n}, o = \"@iiif/IMPORT_ENTITIES\", c = \"@iiif/MODIFY_ENTITY_FIELD\", s = \"@iiif/REORDER_ENTITY_FIELD\", A = \"@iiif/ADD_REFERENCE\", T = \"@iiif/UPDATE_REFERENCE\", e = \"@iiif/REMOVE_REFERENCE\", _ = \"@iiif/ADD_METADATA\", M = \"@iiif/REMOVE_METADATA\", D = \"@iiif/UPDATE_METADATA\", O = \"@iiif/REORDER_METADATA\", S = E(o)(), a = E(c)(), r = E(s)(), I = E(A)(), U = E(e)(), f = E(T)(), C = E(_)(), N = E(D)(), d = E(M)(), u = E(O)(), J = {\n importEntities: S,\n modifyEntityField: a,\n reorderEntityField: r,\n addReference: I,\n removeReference: U,\n updateReference: f,\n addMetadata: C,\n removeMetadata: d,\n updateMetadata: N,\n reorderMetadata: u\n}, F = \"@iiif/ADD_MAPPING\", P = \"@iiif/ADD_MAPPINGS\", L = E(F)(), V = E(P)(), K = { addMapping: L, addMappings: V }, p = \"@iiif/SET_META_VALUE\", Q = \"@iiif/SET_META_VALUE_DYNAMIC\", Y = \"@iiif/UNSET_META_VALUE\", m = E(p)(), l = E(Q)(), q = E(Y)(), W = {\n setMetaValue: m,\n setMetaValueDynamic: l,\n unsetMetaValue: q\n}, X = \"RESOURCE_ERROR\", Z = \"RESOURCE_LOADING\", $ = \"RESOURCE_READY\", G = \"@iiif/REQUEST_RESOURCE\", H = \"@iiif/REQUEST_ERROR\", g = \"@iiif/REQUEST_MISMATCH\", v = \"@iiif/REQUEST_COMPLETE\", B = \"@iiif/REQUEST_OFFLINE_RESOURCE\", b = E(G)(), h = E(H)(), y = E(g)(), x = E(v)(), j = E(B)(), EE = {\n requestResource: b,\n requestError: h,\n requestMismatch: y,\n requestComplete: x,\n requestOfflineResource: j\n}, k = \"@iiif/BATCH\", w = \"@iiif/BATCH_IMPORT\", tE = E(k)(), iE = E(w)();\nexport {\n F as ADD_MAPPING,\n P as ADD_MAPPINGS,\n _ as ADD_METADATA,\n A as ADD_REFERENCE,\n k as BATCH_ACTIONS,\n w as BATCH_IMPORT,\n o as IMPORT_ENTITIES,\n c as MODIFY_ENTITY_FIELD,\n M as REMOVE_METADATA,\n e as REMOVE_REFERENCE,\n s as REORDER_ENTITY_FIELD,\n O as REORDER_METADATA,\n v as REQUEST_COMPLETE,\n H as REQUEST_ERROR,\n g as REQUEST_MISMATCH,\n B as REQUEST_OFFLINE_RESOURCE,\n G as REQUEST_RESOURCE,\n X as RESOURCE_ERROR,\n Z as RESOURCE_LOADING,\n $ as RESOURCE_READY,\n p as SET_META_VALUE,\n Q as SET_META_VALUE_DYNAMIC,\n Y as UNSET_META_VALUE,\n D as UPDATE_METADATA,\n T as UPDATE_REFERENCE,\n L as addMapping,\n V as addMappings,\n C as addMetadata,\n I as addReference,\n tE as batchActions,\n iE as batchImport,\n J as entityActions,\n S as importEntities,\n K as mappingActions,\n W as metaActions,\n a as modifyEntityField,\n d as removeMetadata,\n U as removeReference,\n r as reorderEntityField,\n u as reorderMetadata,\n EE as requestActions,\n x as requestComplete,\n h as requestError,\n y as requestMismatch,\n j as requestOfflineResource,\n b as requestResource,\n N as updateMetadata,\n f as updateReference\n};\n//# sourceMappingURL=vault-actions.mjs.map\n","import { useVault } from './useVault';\nimport { useMemo } from 'react';\nimport { VaultZustandStore } from '@iiif/helpers/vault/store';\n\nexport function useDispatch(): VaultZustandStore['dispatch'] {\n const vault = useVault();\n const store = vault.getStore();\n\n return useMemo(() => {\n return (action: any) => store.dispatch(action);\n }, [store]);\n}\n","import { useCallback, useLayoutEffect, useMemo, useRef } from 'react';\nimport { Annotation } from '@iiif/presentation-3';\nimport { AnnotationNormalized, AnnotationPageNormalized } from '@iiif/presentation-3-normalized';\nimport { useVault } from './useVault';\nimport { useVaultSelector } from './useVaultSelector';\nimport { entityActions } from '@iiif/helpers/vault/actions';\nimport { useDispatch } from './useDispatch';\nimport { Vault } from '@iiif/helpers/vault';\n\nexport interface VaultActivatedAnnotation {\n __vault?: Vault;\n bindToVault(vault: Vault): void;\n source: string | { id: string };\n}\n\nfunction isVaultActivated(obj: any): obj is VaultActivatedAnnotation {\n return typeof obj !== 'string' && obj && obj.bindToVault;\n}\n\nexport function useVirtualAnnotationPage() {\n const vault = useVault();\n const sources = useRef<Record<any, any>>([]);\n const dispatch = useDispatch();\n const virtualId = useMemo(() => {\n return `vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random() * 1000000000).toString(16)}`;\n }, []);\n\n useLayoutEffect(() => {\n const page: AnnotationPageNormalized = {\n id: virtualId,\n type: 'AnnotationPage',\n behavior: [],\n label: null,\n thumbnail: [],\n summary: null,\n requiredStatement: null,\n metadata: [],\n rights: null,\n provider: [],\n items: [],\n seeAlso: [],\n homepage: [],\n rendering: [],\n service: [],\n };\n\n dispatch(\n entityActions.importEntities({\n entities: {\n AnnotationPage: {\n [page.id]: page,\n },\n },\n })\n );\n }, [virtualId]);\n\n const fullPage: AnnotationPageNormalized | null = useVaultSelector(\n (state) => (virtualId ? state.iiif.entities.AnnotationPage[virtualId] : null),\n [virtualId]\n );\n\n const addAnnotation = useCallback(\n (id: string | Annotation | VaultActivatedAnnotation | AnnotationNormalized, atIndex?: number) => {\n if (virtualId) {\n if (isVaultActivated(id)) {\n const display = id;\n if (!display.__vault) {\n // First bind to vault.\n display.bindToVault(vault);\n }\n id = typeof display.source === 'string' ? display.source : display.source.id;\n sources.current[id] = display;\n } else if (typeof id !== 'string') {\n id = id.id;\n }\n\n const full: AnnotationPageNormalized = vault.get({ id: virtualId, type: 'AnnotationPage' });\n const annotation: AnnotationNormalized = vault.get({ id, type: 'Annotation' });\n if (full && annotation) {\n if (!full.items.find((r: any) => r.id === annotation.id)) {\n dispatch(\n entityActions.addReference({\n id: virtualId,\n type: 'AnnotationPage',\n key: 'items',\n reference: {\n id,\n type: 'Annotation',\n },\n index: atIndex,\n })\n );\n }\n }\n }\n },\n [virtualId]\n );\n const removeAnnotation = useCallback(\n (id: string | Annotation | VaultActivatedAnnotation | AnnotationNormalized) => {\n if (virtualId) {\n if (isVaultActivated(id)) {\n id = typeof id.source === 'string' ? id.source : id.source.id;\n } else if (typeof id !== 'string') {\n id = id.id;\n }\n\n if (sources.current[id]) {\n sources.current[id].beforeRemove();\n }\n\n const full: AnnotationPageNormalized = vault.get({ id: virtualId, type: 'AnnotationPage' });\n if (full) {\n dispatch(\n entityActions.removeReference({\n id: virtualId,\n type: 'AnnotationPage',\n key: 'items',\n reference: {\n id,\n type: 'Annotation',\n },\n })\n );\n }\n }\n },\n [virtualId]\n );\n\n return [\n fullPage,\n {\n addAnnotation,\n removeAnnotation,\n },\n ] as const;\n}\n","import { Annotation } from '@iiif/presentation-3';\nimport { AnnotationNormalized, AnnotationPageNormalized } from '@iiif/presentation-3-normalized';\nimport React, { createContext, useContext, useMemo } from 'react';\nimport { useVirtualAnnotationPage, VaultActivatedAnnotation } from './useVirtualAnnotationPage';\n\nconst VirtualAnnotationPageContext = createContext<{\n fullPage: AnnotationPageNormalized | null;\n addAnnotation: (\n id: string | Annotation | VaultActivatedAnnotation | AnnotationNormalized,\n atIndex?: number | undefined\n ) => void;\n removeAnnotation: (id: string | Annotation | VaultActivatedAnnotation | AnnotationNormalized) => void;\n} | null>(null);\n\nexport function useVirtualAnnotationPageContext() {\n const ctx = useContext(VirtualAnnotationPageContext);\n\n return [\n ctx!.fullPage,\n {\n addAnnotation: ctx!.addAnnotation,\n removeAnnotation: ctx!.removeAnnotation,\n },\n ] as const;\n}\n\nexport function VirtualAnnotationProvider({ children }: { children: any }) {\n const [fullPage, { addAnnotation, removeAnnotation }] = useVirtualAnnotationPage();\n\n return (\n <VirtualAnnotationPageContext.Provider\n value={useMemo(() => ({ fullPage, addAnnotation, removeAnnotation }), [fullPage])}\n >\n {children}\n </VirtualAnnotationPageContext.Provider>\n );\n}\n","import React from 'react';\nimport { FallbackProps } from 'react-error-boundary';\n\nexport function DefaultCanvasFallback({\n width,\n style,\n height,\n error,\n resetErrorBoundary,\n}: { width?: number; height?: number; style?: any } & FallbackProps) {\n return (\n <div style={{ width, height, minHeight: 500, ...(style || {}), background: '#f9f9f9' }}>\n <h3>Error occurred</h3>\n <p>{error.message}</p>\n <button onClick={resetErrorBoundary}>Reset</button>\n </div>\n );\n}\n","import { createContext, useContext } from 'react';\nimport { Preset } from '@atlas-viewer/atlas';\n\nexport const ViewerPresetContext = createContext<Preset | null | undefined>(null);\n\nexport function useViewerPreset() {\n return useContext(ViewerPresetContext);\n}\n","import { createContext, useContext, useEffect } from 'react';\n\nexport const SetOverlaysReactContext = createContext<(key: string, element: any | null, props?: any) => void>(\n () => void 0\n);\nexport const SetPortalReactContext = createContext<(key: string, element: any | null, props?: any) => void>(\n () => void 0\n);\n\nexport function useOverlay(\n type: 'portal' | 'overlay' | 'none',\n key: string,\n element: any,\n props: any,\n deps: any[] = []\n) {\n const setOverlay = useContext(type === 'portal' ? SetPortalReactContext : SetOverlaysReactContext);\n\n useEffect(() => {\n if (type !== 'none') {\n setOverlay(key, element, props);\n }\n return () => {\n setOverlay(key, null);\n };\n }, [key, type, setOverlay, ...deps]);\n}\n","import { useResourceContext } from '../context/ResourceContext';\nimport { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { useMemo } from 'react';\nimport { useVaultSelector } from './useVaultSelector';\n\nexport function useCanvas(options?: { id: string }): CanvasNormalized | undefined;\nexport function useCanvas<T>(\n options?: { id: string; selector: (canvas: CanvasNormalized) => T },\n deps?: any[]\n): T | undefined;\nexport function useCanvas<T = CanvasNormalized>(\n options: {\n id?: string;\n selector?: (canvas: CanvasNormalized) => T;\n } = {},\n deps: any[] = []\n): CanvasNormalized | T | undefined {\n const { id, selector } = options;\n const ctx = useResourceContext();\n const canvasId = id ? id : ctx.canvas;\n\n const canvas = useVaultSelector((s) => (canvasId ? s.iiif.entities.Canvas[canvasId] : undefined), [canvasId]);\n\n return useMemo(() => {\n if (!canvas) {\n return undefined;\n }\n if (selector) {\n return selector(canvas);\n }\n return canvas;\n }, [canvas, selector, ...deps]);\n}\n","import { createContext, useContext, useEffect } from 'react';\nimport { useCanvas } from '../../hooks/useCanvas';\n\nexport const WorldSizeContext = createContext<(canvasId: string, size: number) => void>(() => void 0);\n\nexport function useWorldSize(size: number) {\n const canvas = useCanvas();\n const fn = useContext(WorldSizeContext);\n\n useEffect(() => {\n if (canvas && canvas.id) {\n fn(canvas.id, size);\n\n return () => fn(canvas.id, -1);\n }\n\n return () => void 0;\n }, [canvas, size]);\n}\n","import React, { ReactNode, useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react';\nimport { AtlasAuto, Preset, AtlasProps, ModeContext } from '@atlas-viewer/atlas';\nimport { ErrorBoundary } from 'react-error-boundary';\nimport { ContextBridge, useContextBridge } from '../context/ContextBridge';\nimport { VirtualAnnotationProvider } from '../hooks/useVirtualAnnotationPageContext';\nimport { DefaultCanvasFallback } from './render/DefaultCanvasFallback';\nimport { ViewerPresetContext } from '../context/ViewerPresetContext';\nimport { SetOverlaysReactContext, SetPortalReactContext } from './context/overlays';\nimport { WorldSizeContext } from './context/world-size';\nimport { useCanvas } from '../hooks/useCanvas';\n\nexport function Viewer({\n children,\n errorFallback,\n outerContainerProps = {},\n worldScale: _worldScale,\n ...props\n}: AtlasProps & {\n height?: number | string;\n width?: number | string;\n resizeHash?: number;\n containerProps?: any;\n outerContainerProps?: any;\n aspectRatio?: number;\n errorFallback?: any;\n worldScale?: number;\n} & { children: ReactNode }) {\n const [viewerPreset, setViewerPreset] = useState<Preset | null>();\n const bridge = useContextBridge();\n const ErrorFallback: any = errorFallback || DefaultCanvasFallback;\n const [overlays, setOverlays] = useState<Record<string, any>>({});\n const overlayComponents = Object.entries(overlays);\n const [portals, setPortals] = useState<Record<string, any>>({});\n const portalComponents = Object.entries(portals);\n const [worldSizes, setWorldSizes] = useState<Record<string, number>>({});\n const worldScale = useMemo(() => {\n return _worldScale || Math.max(...Object.values(worldSizes));\n }, [worldSizes]);\n const runtimeOptions = useMemo(() => {\n return { maxOverZoom: worldScale || 1, ...(props.runtimeOptions || {}) };\n }, [worldScale, props.runtimeOptions]);\n\n const updateWorldSize = useCallback((canvasId: string, size: number) => {\n setWorldSizes((sizes) => {\n if (size === -1) {\n const { [canvasId]: _, ...rest } = sizes;\n return rest;\n }\n return { ...sizes, [canvasId]: size };\n });\n }, []);\n\n const updateOverlay = useCallback((key: string, element: ReactNode, props: any) => {\n setOverlays(({ [key]: _, ...prev }) => {\n if (!element) {\n return prev;\n }\n\n return {\n ...prev,\n [key]: { element, props },\n };\n });\n }, []);\n\n const updatePortal = useCallback((key: string, element: ReactNode, props: any) => {\n setPortals(({ [key]: _, ...prev }) => {\n if (!element) {\n return prev;\n }\n\n return {\n ...prev,\n [key]: { element, props },\n };\n });\n }, []);\n\n return (\n <ErrorBoundary resetKeys={[]} fallbackRender={(fallbackProps) => <ErrorFallback {...props} {...fallbackProps} />}>\n <AtlasAuto\n {...props}\n containerProps={{ style: { position: 'relative' }, ...(props.containerProps || {}) }}\n htmlChildren={\n <>\n {overlayComponents.map(([key, { element: Element, props }]) => (\n <React.Fragment key={key}>\n <Element {...(props || {})} />\n </React.Fragment>\n ))}\n </>\n }\n onCreated={(preset: any) => {\n setViewerPreset(preset);\n if (props.onCreated) {\n props.onCreated(preset);\n }\n }}\n runtimeOptions={runtimeOptions}\n >\n <ViewerPresetContext.Provider value={viewerPreset}>\n <WorldSizeContext.Provider value={updateWorldSize}>\n <SetOverlaysReactContext.Provider value={updateOverlay}>\n <SetPortalReactContext.Provider value={updatePortal}>\n <ContextBridge bridge={bridge}>\n <ModeContext.Provider value={props.mode || 'explore'}>\n <VirtualAnnotationProvider>{children}</VirtualAnnotationProvider>\n </ModeContext.Provider>\n </ContextBridge>\n </SetPortalReactContext.Provider>\n </SetOverlaysReactContext.Provider>\n </WorldSizeContext.Provider>\n </ViewerPresetContext.Provider>\n </AtlasAuto>\n <div>\n {portalComponents.map(([key, { element: Element, props }]) => (\n <React.Fragment key={key}>\n <Element {...(props || {})} />\n </React.Fragment>\n ))}\n </div>\n </ErrorBoundary>\n );\n}\n","const a = {}, i = {\n get(n) {\n return n;\n },\n setMetaValue([n, e, r], t) {\n const o = i.getResourceMeta(n, e), c = o ? o[r] : void 0, s = typeof t == \"function\" ? t(c) : t;\n a[n] = {\n ...a[n] || {},\n [e]: {\n ...(a[n] || {})[e] || {},\n [r]: s\n }\n };\n },\n getResourceMeta: (n, e) => {\n const r = a[n];\n if (r)\n return e ? r[e] : r;\n }\n};\nfunction M(n = i) {\n return {\n addEventListener(e, r, t, o) {\n if (e)\n return n.setMetaValue(\n [e.id, \"eventManager\", r],\n (c) => {\n const s = c || [];\n for (const f of s)\n if (f.callback === t)\n return s;\n return [...s, { callback: t, scope: o }];\n }\n ), t;\n },\n removeEventListener(e, r, t) {\n e && n.setMetaValue(\n [e.id, \"eventManager\", r],\n (o) => (o || []).filter((c) => c.callback !== t)\n );\n },\n getListenersAsProps(e, r) {\n const t = typeof e == \"string\" ? { id: e } : e;\n if (!t || !t.id)\n return {};\n const o = n.getResourceMeta(t.id, \"eventManager\"), c = {};\n if (o && t)\n for (const s of Object.keys(o))\n c[s] = (f) => {\n const l = n.get(t);\n for (const { callback: g, scope: u } of o[s] || [])\n (!u || r && u.indexOf(r) !== -1) && g(f, l);\n };\n return c;\n }\n };\n}\nexport {\n M as createEventsHelper\n};\n//# sourceMappingURL=events.mjs.map\n","import { useVault } from './useVault';\nimport { useVaultSelector } from './useVaultSelector';\nimport { useMemo } from 'react';\nimport { NormalizedEntity } from '@iiif/helpers/vault';\nimport { Reference } from '@iiif/presentation-3';\nimport { createEventsHelper } from '@iiif/helpers/events';\n\nexport function useResourceEvents<T extends NormalizedEntity>(resource?: Reference, scope?: string[]) {\n const vault = useVault();\n const helper = useMemo(() => createEventsHelper(vault), [vault]);\n\n const hooks = useVaultSelector(() => {\n if (resource && resource.id) {\n return vault.getResourceMeta(resource.id, 'eventManager');\n }\n return null;\n }, [resource]);\n\n return useMemo(() => {\n return resource ? helper.getListenersAsProps(resource, scope) : {};\n }, [hooks, resource, vault, scope]);\n}\n","import { useVault } from './useVault';\nimport { useMemo } from 'react';\nimport { Reference } from '@iiif/presentation-3';\nimport { createStylesHelper } from '@iiif/helpers/styles';\nimport { useVaultSelector } from './useVaultSelector';\n\nexport function useStyles<Style extends Record<string, Record<string, any>>>(\n resource: undefined | Reference<any>\n): Style;\nexport function useStyles<Style extends Record<string, any>>(\n resource: undefined | Reference<any>,\n scope: string\n): Style;\nexport function useStyles<Style>(resource?: Reference, scope?: string): Style {\n const vault = useVault();\n const helper = useMemo(() => createStylesHelper(vault), [vault]);\n\n return useVaultSelector(() => {\n if (!resource) {\n return null;\n }\n\n const styles = helper.getAppliedStyles(resource.id);\n return styles ? (scope ? styles[scope] : styles) : undefined;\n }, [resource, scope]) as Style;\n}\n","import { useResourceContext } from '../context/ResourceContext';\nimport { AnnotationNormalized } from '@iiif/presentation-3-normalized';\nimport { useMemo } from 'react';\nimport { useVaultSelector } from './useVaultSelector';\nimport { expandTarget } from '@iiif/helpers/annotation-targets';\nimport { useVault } from './useVault';\n\nexport function useAnnotation(options?: { id: string }): AnnotationNormalized | undefined;\nexport function useAnnotation<T>(\n options?: { id: string; selector: (annotation: AnnotationNormalized) => T },\n deps?: any[]\n): T | undefined;\nexport function useAnnotation<T = AnnotationNormalized>(\n options: {\n id?: string;\n selector?: (annotation: AnnotationNormalized) => T;\n } = {},\n deps: any[] = []\n): AnnotationNormalized | T | undefined {\n const { id, selector } = options;\n const ctx = useResourceContext();\n const vault = useVault();\n const annotationId = id ? id : ctx.annotation;\n\n const annotation = useVaultSelector(\n (s) => (annotationId ? s.iiif.entities.Annotation[annotationId] : undefined),\n [annotationId]\n );\n\n const body = useVaultSelector(\n (s) =>\n annotation && annotation.body\n ? annotation.body\n .map((singleBody) => {\n if (!singleBody) {\n return null;\n }\n\n if ((singleBody as any).type === 'SpecificResource') {\n return {\n ...singleBody,\n source: vault.get(singleBody),\n };\n }\n\n return singleBody ? s.iiif.entities[singleBody.type][singleBody.id] : null;\n })\n .filter(Boolean)\n : [],\n [annotation]\n );\n\n return useMemo(() => {\n if (!annotation) {\n return undefined;\n }\n\n const newAnnotation: any = {\n ...annotation,\n body,\n target: expandTarget(annotation.target as any, { typeMap: vault.getState().iiif.mapping }),\n };\n\n if (selector) {\n return selector(newAnnotation);\n }\n return newAnnotation;\n }, [annotation, selector, body, ...deps]);\n}\n","import { BoxStyle, HTMLPortal, mergeStyles, RegionHighlight } from '@atlas-viewer/atlas';\nimport { useResourceEvents } from '../../hooks/useResourceEvents';\nimport { useStyles } from '../../hooks/useStyles';\nimport React, { FC, useMemo } from 'react';\nimport { useAnnotation } from '../../hooks/useAnnotation';\nimport { useCanvas } from '../../hooks/useCanvas';\n\nexport const RenderAnnotation: FC<{ id: string; className?: string; style?: BoxStyle; interactive?: boolean }> = ({\n id,\n style: defaultStyle,\n className,\n interactive,\n}) => {\n const annotation = useAnnotation({ id });\n const style = useStyles<BoxStyle>(annotation, 'atlas');\n const html = useStyles<{ className?: string; href?: string; title?: string; target?: string }>(annotation, 'html');\n const events = useResourceEvents(annotation as any, ['atlas']);\n const canvas = useCanvas();\n\n const allStyles = useMemo(() => {\n return mergeStyles(defaultStyle, style);\n }, [defaultStyle, style]);\n\n const isValid =\n canvas &&\n annotation &&\n annotation.target &&\n (annotation.target as any).selector &&\n (annotation.target as any).selector.type === 'BoxSelector' &&\n (annotation.target as any).source &&\n ((annotation.target as any).source.id === canvas.id || (annotation.target as any).source === canvas.id);\n\n if (!isValid) {\n return null;\n }\n\n return (\n <RegionHighlight\n id={annotation.id}\n isEditing={true}\n region={(annotation.target as any).selector.spatial}\n style={allStyles}\n className={html?.className || className}\n interactive={!!(html?.href || interactive)}\n href={html?.href || null}\n title={html?.title || null}\n hrefTarget={html?.target || null}\n onClick={() => void 0}\n {...events}\n />\n );\n};\n","import { useResourceContext } from '../context/ResourceContext';\nimport { AnnotationPageNormalized } from '@iiif/presentation-3-normalized';\nimport { useMemo } from 'react';\nimport { useVaultSelector } from './useVaultSelector';\n\nexport function useAnnotationPage(options?: { id: string }): AnnotationPageNormalized | undefined;\nexport function useAnnotationPage<T>(\n options?: { id: string; selector: (annotation: AnnotationPageNormalized) => T },\n deps?: any[]\n): T | undefined;\nexport function useAnnotationPage<T = AnnotationPageNormalized>(\n options: {\n id?: string;\n selector?: (annotation: AnnotationPageNormalized) => T;\n } = {},\n deps: any[] = []\n): AnnotationPageNormalized | T | undefined {\n const { id, selector } = options;\n const ctx = useResourceContext();\n const annotationPageId = id ? id : ctx.annotationPage;\n\n const annotationPage = useVaultSelector(\n (s) => (annotationPageId ? s.iiif.entities.AnnotationPage[annotationPageId] : undefined),\n [annotationPageId]\n );\n\n return useMemo(() => {\n if (!annotationPage) {\n return undefined;\n }\n\n if (selector) {\n return selector(annotationPage);\n }\n return annotationPage;\n }, [annotationPage, ...deps]);\n}\n","import { AnnotationPage } from '@iiif/presentation-3';\nimport { AnnotationPageNormalized } from '@iiif/presentation-3-normalized';\nimport { RenderAnnotation } from './Annotation';\nimport { BoxStyle } from '@atlas-viewer/atlas';\nimport { useStyles } from '../../hooks/useStyles';\nimport { useVaultSelector } from '../../hooks/useVaultSelector';\nimport React, { FC, Fragment } from 'react';\nimport { useAnnotationPage } from '../../hooks/useAnnotationPage';\n\nexport const RenderAnnotationPage: FC<{ page: AnnotationPage | AnnotationPageNormalized; className?: string }> = ({\n className,\n page: _page,\n}) => {\n const page = useAnnotationPage({ id: _page.id }) || _page;\n const style = useStyles<BoxStyle>(page, 'atlas');\n const html = useStyles<{ className?: string }>(page, 'html');\n\n useVaultSelector((state) => (page.id ? state.iiif.entities.AnnotationPage[page.id] : null), []);\n\n return (\n <Fragment>\n {page.items?.map((annotation) => {\n return (\n <RenderAnnotation\n key={annotation.id}\n id={annotation.id}\n style={style}\n className={html?.className || className}\n />\n );\n })}\n </Fragment>\n );\n};\n","import { ImageCandidate } from '@atlas-viewer/iiif-image-api';\nimport React, { Fragment, ReactNode, useMemo } from 'react';\nimport { TileSet } from '@atlas-viewer/atlas';\nimport { ImageWithOptionalService } from '../../features/rendering-strategy/resource-types';\nimport { BoxSelector } from '@iiif/helpers';\n\nexport function RenderImage({\n id,\n image,\n thumbnail,\n isStatic,\n x = 0,\n y = 0,\n children,\n selector,\n onClick,\n enableSizes,\n}: {\n id: string;\n image: ImageWithOptionalService;\n thumbnail?: ImageCandidate;\n isStatic?: boolean;\n enableSizes?: boolean;\n selector?: BoxSelector;\n x?: number;\n y?: number;\n children?: ReactNode;\n onClick?: (e: any) => void;\n}) {\n const crop = useMemo(() => {\n // @todo crops only work if x is not zero due to bug in selector parsing\n // setting the spatial width to canvas - which isn't correct.\n if (!selector || (selector.spatial.x === 0 && selector.spatial.y === 0)) {\n return undefined;\n }\n return selector.spatial;\n }, [selector]);\n\n return (\n <world-object\n key={id + (image.service ? 'server' : 'no-service')}\n x={x + image.target.spatial.x}\n y={y + image.target.spatial.y}\n width={image.target.spatial.width}\n height={image.target.spatial.height}\n onClick={onClick}\n >\n {!image.service ? (\n <Fragment key=\"no-service\">\n <world-image\n onClick={onClick}\n uri={image.id}\n target={{ x: 0, y: 0, width: image.target.spatial.width, height: image.target.spatial.height }}\n display={\n image.width && image.height\n ? {\n width: image.width,\n height: image.height,\n }\n : undefined\n }\n crop={crop}\n />\n {children}\n </Fragment>\n ) : (\n <Fragment key=\"service\">\n <TileSet\n tiles={{\n id: image.service.id || image.service['@id'] || 'unknown',\n height: image.height as number,\n width: image.width as number,\n imageService: image.service as any,\n thumbnail: thumbnail && thumbnail.type === 'fixed' ? thumbnail : undefined,\n }}\n enableSizes={enableSizes}\n x={0}\n y={0}\n width={image.target?.spatial.width}\n height={image.target?.spatial.height}\n crop={crop}\n />\n {children}\n </Fragment>\n )}\n </world-object>\n );\n}\n","import { ContentResource, PointSelector, W3CAnnotationTarget } from '@iiif/presentation-3';\nimport { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { UseRenderingStrategy } from '../../hooks/useRenderingStrategy';\nimport { BoxSelector, expandTarget, SupportedTarget, TemporalBoxSelector } from '@iiif/helpers';\n\n/**\n * Parse specific resource.\n *\n * This could be expanded to support pulling out more from the specific resource.\n *\n * @param resource\n */\nexport function parseSpecificResource(resource: ContentResource) {\n if (resource.type === 'SpecificResource') {\n return [resource.source, { selector: resource.selector }];\n }\n\n return [resource, { selector: null }];\n}\n\nexport function getParsedTargetSelector(\n canvas: CanvasNormalized,\n target: W3CAnnotationTarget | W3CAnnotationTarget[]\n): [TemporalBoxSelector | BoxSelector | PointSelector | null, SupportedTarget['source']] {\n const { selector: imageTarget, source } = expandTarget(target);\n\n if (source.id !== canvas.id) {\n // Skip invalid targets.\n return [null, source];\n }\n\n // Target is where it should be painted.\n const defaultTarget: BoxSelector = {\n type: 'BoxSelector',\n spatial: {\n x: 0,\n y: 0,\n width: Number(canvas.width),\n height: Number(canvas.height),\n },\n };\n\n return [\n imageTarget\n ? imageTarget.type === 'TemporalSelector'\n ? ({\n type: 'TemporalBoxSelector',\n temporal: imageTarget.temporal,\n spatial: defaultTarget.spatial,\n } as any)\n : imageTarget\n : null,\n source,\n ];\n}\n\nexport const emptyActions = {\n makeChoice: () => {\n // no-op\n },\n};\n\nexport const unknownResponse: UseRenderingStrategy[0] = { type: 'unknown' };\n\nexport const unsupportedStrategy = (reason: string): UseRenderingStrategy[0] => {\n return { type: 'unknown', reason, annotations: { pages: [] } };\n};\n\nexport const emptyStrategy = (width: number, height: number): UseRenderingStrategy[0] => {\n return { type: 'empty', width, height, annotations: { pages: [] }, image: null, images: [] };\n};\n","import { useVaultSelector } from './useVaultSelector';\nimport { IIIFStore } from '@iiif/helpers/vault';\n\nfunction getMeta(state: IIIFStore, resourceId: string) {\n const resourceMeta = state?.iiif?.meta[resourceId];\n if (!resourceMeta) {\n return null;\n }\n return resourceMeta.annotationPageManager as any;\n}\n\nexport function useEnabledAnnotationPageIds(resourceId?: string, availablePageIds?: string[]) {\n return useVaultSelector(\n (state) => {\n const pageIds: string[] = [];\n if (!resourceId) {\n return pageIds;\n }\n const allAnnotationListIds = Object.keys(state.iiif.entities.AnnotationPage);\n for (const annotationListId of allAnnotationListIds) {\n if (!availablePageIds || availablePageIds.indexOf(annotationListId) !== -1) {\n const annotationListMeta = getMeta(state, annotationListId);\n if (annotationListMeta && annotationListMeta.views && annotationListMeta.views[resourceId]) {\n pageIds.push(annotationListId);\n }\n }\n }\n\n return pageIds;\n },\n [resourceId, availablePageIds]\n );\n}\n","import { CanvasNormalized, ManifestNormalized } from '@iiif/presentation-3-normalized';\n\nexport function flattenAnnotationPageIds({\n canvas,\n manifest,\n all,\n canvases,\n}: {\n manifest?: ManifestNormalized;\n canvas?: CanvasNormalized;\n canvases?: CanvasNormalized[];\n all?: boolean;\n}) {\n const foundIds: string[] = [];\n\n if (manifest) {\n for (const page of manifest.annotations) {\n if (foundIds.indexOf(page.id) === -1) {\n foundIds.push(page.id);\n }\n }\n }\n\n if (all) {\n if (canvases && canvases.length) {\n for (const canvas_ of canvases) {\n for (const page of canvas_.annotations) {\n if (foundIds.indexOf(page.id) === -1) {\n foundIds.push(page.id);\n }\n }\n }\n }\n } else if (canvas) {\n for (const page of canvas.annotations) {\n if (foundIds.indexOf(page.id) === -1) {\n foundIds.push(page.id);\n }\n }\n }\n\n // Remove enabled page IDs for now.\n // for (const enabledPage of enabledPageIds) {\n // if (foundIds.indexOf(enabledPage) === -1) {\n // foundIds.push(enabledPage);\n // }\n // }\n\n return foundIds;\n}\n","import { useCallback, useMemo } from 'react';\nimport { useVault } from './useVault';\nimport { useManifest } from './useManifest';\nimport { useCanvas } from './useCanvas';\nimport { useVisibleCanvases } from '../context/VisibleCanvasContext';\nimport { useEnabledAnnotationPageIds } from './useEnabledAnnotationPageIds';\nimport { flattenAnnotationPageIds } from '../utility/flatten-annotation-page-ids';\nimport { IIIFStore } from '@iiif/helpers/vault';\n\ntype AnnotationPageResourceMap = {\n [id: string]: boolean;\n};\n\ntype AnnotationPageManager = {\n views: AnnotationPageResourceMap;\n};\n\nfunction getMeta(state: IIIFStore, resourceId: string) {\n const resourceMeta = state?.iiif?.meta[resourceId];\n if (!resourceMeta) {\n return null;\n }\n return resourceMeta.annotationPageManager as AnnotationPageManager;\n}\n\nexport function useAnnotationPageManager(resourceId?: string, options: { all?: boolean } = {}) {\n const vault = useVault();\n const manifest = useManifest();\n const canvas = useCanvas();\n const canvases = useVisibleCanvases();\n const availablePageIds = useMemo(() => {\n return flattenAnnotationPageIds({\n all: options.all,\n manifest,\n canvas,\n canvases,\n });\n }, [options.all, canvas, canvases, manifest]);\n const enabledPageIds = useEnabledAnnotationPageIds(resourceId, options.all ? undefined : availablePageIds);\n\n const setPageDisabled = useCallback(\n (deselectId: string) => {\n if (!resourceId) {\n return;\n }\n vault.setMetaValue<AnnotationPageResourceMap>(\n [deselectId, 'annotationPageManager', 'views'],\n (existingResources: AnnotationPageResourceMap | undefined) => {\n if (existingResources && !existingResources[resourceId]) {\n return existingResources;\n }\n\n return {\n ...(existingResources || {}),\n [resourceId]: false,\n };\n }\n );\n },\n [resourceId, vault]\n );\n\n const setPageEnabled = useCallback(\n (id: string, opt: { deselectOthers?: boolean } = {}) => {\n if (!resourceId) {\n return;\n }\n const state = vault.getState();\n const toDeselect = [];\n\n // Deselect these.\n if (opt?.deselectOthers) {\n const allAnnotationListIds = Object.keys(state.iiif.entities.AnnotationPage);\n for (const annotationPageId of allAnnotationListIds) {\n const annotationListMeta = getMeta(state, annotationPageId);\n if (annotationListMeta && annotationListMeta.views && annotationListMeta.views[resourceId]) {\n toDeselect.push(annotationPageId);\n }\n }\n }\n\n // Disable first.\n for (const deselectId of toDeselect) {\n setPageDisabled(deselectId);\n }\n\n // Then enable.\n vault.setMetaValue<AnnotationPageResourceMap>(\n [id, 'annotationPageManager', 'views'],\n (existingResources: AnnotationPageResourceMap | undefined) => {\n if (existingResources && existingResources[resourceId]) {\n return existingResources;\n }\n return {\n ...(existingResources || {}),\n [resourceId]: true,\n };\n }\n );\n },\n [resourceId, setPageDisabled, vault]\n );\n\n return {\n availablePageIds,\n enabledPageIds,\n setPageEnabled,\n setPageDisabled,\n };\n}\n","import { useVaultSelector } from './useVaultSelector';\n\nexport function useResources<Type>(ids: string[], type: string): Type[] {\n return useVaultSelector((state, vault) => vault.get(ids.map((id) => ({ id, type }))) as any, [ids, type]);\n}\n","import React, { useContext } from 'react';\nimport { ImageServiceLoader } from '@atlas-viewer/iiif-image-api';\n\nexport const ImageServiceLoaderContext = React.createContext<ImageServiceLoader>(new ImageServiceLoader());\n\nexport function useImageServiceLoader() {\n return useContext(ImageServiceLoaderContext);\n}\n","import { ImageService } from '@iiif/presentation-3';\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport { useImageServiceLoader } from '../context/ImageServiceLoaderContext';\n\nexport type ImageServiceLoaderType = (\n imageService: any | undefined,\n { height, width }: { height: number; width: number }\n) => ImageService | undefined;\n\nexport function useLoadImageService() {\n const loader = useImageServiceLoader();\n const [imageServiceStatus, setImageServiceStatus] = useState<Record<string, string>>({});\n const didUnmount = useRef(false);\n useEffect(() => {\n return () => {\n didUnmount.current = true;\n };\n }, []);\n const loadImageService = useCallback<ImageServiceLoaderType>(\n (imageService, { height, width }) => {\n if (imageService) {\n const imageServiceId = imageService.id || (imageService['@id'] as string);\n // We want to kick this off.\n const syncLoaded = loader.loadServiceSync({\n id: imageServiceId,\n width: imageService.width || width,\n height: imageService.height || height,\n source: imageService,\n });\n\n if (syncLoaded) {\n imageService = syncLoaded;\n } else if (!imageServiceStatus[imageServiceId]) {\n if (!didUnmount.current) {\n setImageServiceStatus((r) => {\n return {\n ...r,\n [imageServiceId]: 'loading',\n };\n });\n }\n loader\n .loadService({\n id: imageServiceId,\n width: imageService.width || width,\n height: imageService.height || height,\n })\n .then(() => {\n if (!didUnmount.current) {\n setImageServiceStatus((r) => {\n return {\n ...r,\n [imageServiceId]: 'done',\n };\n });\n }\n });\n }\n }\n return imageService;\n },\n [loader, imageServiceStatus]\n );\n\n return [loadImageService, imageServiceStatus] as const;\n}\n","// This is valid under a canvas context.\nimport { AnnotationNormalized, AnnotationPageNormalized } from '@iiif/presentation-3-normalized';\nimport { useCanvas } from './useCanvas';\nimport { useVaultSelector } from './useVaultSelector';\nimport { useAnnotation } from './useAnnotation';\n\nexport function usePaintingAnnotations(\n options: { canvasId?: string; enableSingleAnnotation?: boolean } = {}\n): AnnotationNormalized[] {\n const annotation = useAnnotation();\n const canvas = useCanvas(options.canvasId ? { id: options.canvasId } : undefined);\n\n return useVaultSelector(\n (state, vault) => {\n if (!canvas) {\n return [];\n }\n if (annotation && options.enableSingleAnnotation) {\n return [annotation];\n }\n const annotationPages = vault.get(canvas.items);\n const flatAnnotations: AnnotationNormalized[] = [];\n for (const page of annotationPages) {\n flatAnnotations.push(...vault.get(page.items));\n }\n return flatAnnotations;\n },\n [canvas]\n );\n}\n","function x(t) {\n return t.type === \"SpecificResource\" ? [t.source, { selector: t.selector }] : [t, { selector: null }];\n}\nconst d = {}, b = {\n get(t) {\n return t;\n },\n setMetaValue([t, o, r], i) {\n const e = b.getResourceMeta(t, o), n = e ? e[r] : void 0, a = typeof i == \"function\" ? i(n) : i;\n d[t] = {\n ...d[t] || {},\n [o]: {\n ...(d[t] || {})[o] || {},\n [r]: a\n }\n };\n },\n getResourceMeta: (t, o) => {\n const r = d[t];\n if (r)\n return o ? r[o] : r;\n }\n};\nfunction M(t = b) {\n function o(e) {\n const n = e ? typeof e == \"string\" ? t.get(e) : e : null;\n if (!n)\n return [];\n const a = t.get(n.items, { parent: n }), c = [];\n for (const f of a)\n c.push(...t.get(f.items, { parent: f }));\n return c;\n }\n function r(e, n = []) {\n const a = Array.isArray(e) ? e : o(e), c = [];\n let f = null;\n const h = [];\n for (const s of a) {\n if (s.type !== \"Annotation\")\n throw new Error(\"getPaintables() accept either a canvas or list of annotations\");\n const A = Array.from(Array.isArray(s.body) ? s.body : [s.body]);\n for (const w of A) {\n const [m, { selector: P }] = x(w), u = t.get(m), p = (u.type || \"unknown\").toLowerCase();\n if (p === \"choice\") {\n const g = t.get(u.items, { parent: u.id }), y = n.length ? n.map((l) => g.find((V) => V.id === l)).filter(Boolean) : [g[0]];\n y.length === 0 && y.push(g[0]), f = {\n type: \"single-choice\",\n items: g.map((l) => ({\n id: l.id,\n label: l.label,\n selected: y.indexOf(l) !== -1\n })),\n label: m.label\n }, A.push(...y);\n continue;\n }\n c.indexOf(p) === -1 && c.push(p), h.push({\n type: p,\n annotationId: s.id,\n resource: u,\n target: s.target,\n selector: P\n });\n }\n }\n return {\n types: c,\n items: h,\n choice: f\n };\n }\n function i(e) {\n const { choice: n } = r(e);\n return n;\n }\n return {\n getAllPaintingAnnotations: o,\n getPaintables: r,\n extractChoices: i\n };\n}\nexport {\n M as createPaintingAnnotationsHelper,\n x as parseSpecificResource\n};\n//# sourceMappingURL=painting-annotations.mjs.map\n","import { useCallback, useMemo, useState } from 'react';\nimport { useVault } from './useVault';\nimport { usePaintingAnnotations } from './usePaintingAnnotations';\nimport { createPaintingAnnotationsHelper } from '@iiif/helpers/painting-annotations';\n\nexport function usePaintables(\n options?: { defaultChoices?: string[]; enableSingleAnnotation?: boolean },\n deps: any[] = []\n) {\n const vault = useVault();\n const helper = useMemo(() => {\n return createPaintingAnnotationsHelper(vault);\n }, []);\n const paintingAnnotations = usePaintingAnnotations({ enableSingleAnnotation: options?.enableSingleAnnotation });\n const [enabledChoices, setEnabledChoices] = useState<string[]>(options?.defaultChoices || []);\n\n const paintables = useMemo(\n () => helper.getPaintables(paintingAnnotations, enabledChoices),\n [vault, paintingAnnotations, enabledChoices, ...deps]\n );\n\n const makeChoice = useCallback(\n (\n id: string,\n { deselectOthers = true, deselect = false }: { deselectOthers?: boolean; deselect?: boolean } = {}\n ) => {\n if (paintables.choice) {\n // Don't support multiple choice yet.\n if (paintables.choice.type !== 'single-choice') {\n throw new Error('Complex choice not supported yet');\n }\n\n setEnabledChoices((prevChoices) => {\n if (deselect) {\n const without = prevChoices.filter((e) => e !== id);\n\n if (without.length === 0) {\n const defaultId = paintables.items[0].resource.id;\n if (defaultId) {\n return [defaultId];\n } else {\n return [];\n }\n }\n\n return without;\n }\n\n if (deselectOthers) {\n return [id];\n }\n\n const newChoices = [...prevChoices];\n\n // Add the default ID.\n if (newChoices.length === 0 && paintables.items.length) {\n const defaultId = paintables.items[0].resource.id;\n if (defaultId) {\n newChoices.push(defaultId);\n }\n }\n\n if (prevChoices.indexOf(id) !== -1) {\n return prevChoices;\n }\n\n return [...prevChoices, id];\n });\n }\n },\n [paintables.choice]\n );\n\n const actions = { makeChoice };\n\n return [paintables, actions] as const;\n}\n","import { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { unsupportedStrategy } from './rendering-utils';\nimport { AnnotationPageDescription } from './resource-types';\nimport { ExternalWebResource } from '@iiif/presentation-3';\nimport { RenderingStrategy } from './strategies';\nimport { ChoiceDescription, Paintables } from '@iiif/helpers';\n\nexport type Single3DModelStrategy = {\n type: '3d-model';\n model: ExternalWebResource;\n choice?: ChoiceDescription; // future\n annotations?: AnnotationPageDescription; // future\n};\n\nconst supportedFormats = ['model/gltf-binary'];\n\nexport function get3dStrategy(canvas: CanvasNormalized, paintables: Paintables): RenderingStrategy {\n const first = paintables.items[0];\n const resource = first.resource as ExternalWebResource;\n\n if (!resource.format) {\n return unsupportedStrategy('Unknown format');\n }\n\n if (supportedFormats.indexOf(resource.format) === -1) {\n return unsupportedStrategy(`3D format: ${resource.format} is unsupported`);\n }\n\n return {\n type: '3d-model',\n model: resource as any,\n } as Single3DModelStrategy;\n}\n","import { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { unsupportedStrategy } from './rendering-utils';\nimport { MediaStrategy } from './strategies';\nimport { Paintables } from '@iiif/helpers';\n\nexport function getAudioStrategy(canvas: CanvasNormalized, paintables: Paintables) {\n if (!canvas.duration) {\n return unsupportedStrategy('No duration on canvas');\n }\n\n if (paintables.items.length > 1) {\n return unsupportedStrategy('Only one audio source supported');\n }\n\n const audioResource = paintables.items[0]?.resource as any; // @todo stronger type for what this might be.\n\n if (!audioResource) {\n return unsupportedStrategy('Unknown audio');\n }\n\n if (!audioResource.format) {\n return unsupportedStrategy('Audio does not have format');\n }\n\n return {\n type: 'media',\n media: {\n annotationId: paintables.items[0].annotationId,\n duration: canvas.duration,\n url: audioResource.id,\n type: 'Sound',\n target: {\n type: 'TemporalSelector',\n temporal: {\n startTime: 0,\n endTime: canvas.duration,\n },\n },\n format: audioResource.format,\n selector: {\n type: 'TemporalSelector',\n temporal: {\n startTime: 0,\n endTime: canvas.duration,\n },\n },\n },\n annotations: {\n pages: [],\n },\n } as MediaStrategy;\n}\n","import { IIIFExternalWebResource } from '@iiif/presentation-3';\nimport { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { ImageServiceLoaderType } from '../../hooks/useLoadImageService';\nimport { AnnotationPageDescription, ImageWithOptionalService } from './resource-types';\nimport { getImageServices } from '@atlas-viewer/iiif-image-api';\nimport { getParsedTargetSelector, unsupportedStrategy } from './rendering-utils';\nimport { expandTarget } from '@iiif/helpers/annotation-targets';\nimport { BoxSelector, ChoiceDescription, Paintables } from '@iiif/helpers';\n\nexport type SingleImageStrategy = {\n type: 'images';\n image: ImageWithOptionalService;\n images: Array<ImageWithOptionalService>;\n choice?: ChoiceDescription;\n annotations?: AnnotationPageDescription;\n};\n\nexport function getImageStrategy(\n canvas: CanvasNormalized,\n paintables: Paintables,\n loadImageService: ImageServiceLoaderType\n) {\n const imageTypes: ImageWithOptionalService[] = [];\n for (const singleImage of paintables.items) {\n // SingleImageStrategy\n const resource: IIIFExternalWebResource =\n singleImage.resource && singleImage.resource.type === 'SpecificResource'\n ? singleImage.resource.source\n : singleImage.resource;\n\n // Validation.\n if (!resource.id) {\n // @todo we could skip this?\n return unsupportedStrategy('No resource Identifier');\n }\n\n let imageService = undefined;\n if (resource.service) {\n const imageServices = getImageServices(resource as any) as any[];\n if (imageServices[0]) {\n imageService = loadImageService(imageServices[0], canvas);\n }\n }\n\n // Target is where it should be painted.\n const defaultTarget: BoxSelector = {\n type: 'BoxSelector',\n spatial: {\n x: 0,\n y: 0,\n width: Number(canvas.width),\n height: Number(canvas.height),\n },\n };\n\n const [target, source] = getParsedTargetSelector(canvas, singleImage.target);\n if (!(source.id === canvas.id || decodeURIComponent(source.id || '') === (canvas.id || ''))) {\n // Skip invalid targets.\n continue;\n }\n\n // Support for cropping before painting an annotation.\n // @todo this isn't working.\n const defaultImageSelector =\n (singleImage.resource as any).width && (singleImage.resource as any).height\n ? ({\n type: 'BoxSelector',\n spatial: {\n x: 0,\n y: 0,\n width: (singleImage.resource as any).width,\n height: (singleImage.resource as any).height,\n },\n } as BoxSelector)\n : undefined;\n\n let imageSelector = singleImage.resource.type === 'SpecificResource' ? expandTarget(singleImage.resource) : null;\n\n if (singleImage.selector) {\n const found = expandTarget({\n type: 'SpecificResource',\n source: singleImage.resource,\n selector: singleImage.selector,\n });\n\n if (found) {\n imageSelector = found;\n }\n }\n\n const selector: undefined | BoxSelector =\n imageSelector &&\n imageSelector.selector &&\n (imageSelector.selector.type === 'BoxSelector' || imageSelector.selector.type === 'TemporalBoxSelector')\n ? {\n type: 'BoxSelector',\n spatial: {\n x: imageSelector.selector.spatial.x,\n y: imageSelector.selector.spatial.y,\n width: imageSelector.selector.spatial.width,\n height: imageSelector.selector.spatial.height,\n },\n }\n : undefined;\n\n if (imageService && !imageService.id) {\n (imageService as any).id = imageService['@id'];\n }\n\n const imageType: ImageWithOptionalService = {\n id: resource.id,\n type: 'Image',\n annotationId: (singleImage as any).annotationId,\n width: Number(target || selector ? resource.width : canvas.width),\n height: Number(target || selector ? resource.height : canvas.height),\n service: imageService,\n sizes:\n imageService && imageService.sizes\n ? imageService.sizes\n : resource.width && resource.height\n ? [{ width: resource.width, height: resource.height }]\n : [],\n target: target && target.type !== 'PointSelector' ? target : defaultTarget,\n selector: selector,\n };\n\n imageTypes.push(imageType);\n }\n\n return {\n type: 'images',\n image: imageTypes[0],\n images: imageTypes,\n choice: paintables.choice,\n } as SingleImageStrategy;\n}\n","import { InternationalString } from '@iiif/presentation-3';\nimport { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { AnnotationPageDescription } from './resource-types';\nimport { getParsedTargetSelector } from './rendering-utils';\nimport { RenderingStrategy } from './strategies';\nimport { ChoiceDescription, Paintables, SupportedTarget } from '@iiif/helpers';\n\nexport type TextualContentStrategy = {\n type: 'textual-content';\n items: { annotationId: string; text: InternationalString; target: SupportedTarget | null }[];\n choice?: ChoiceDescription; // future\n annotations?: AnnotationPageDescription; // future\n};\n\nfunction parseType(item: any, languageMap: InternationalString = {}, lang?: string) {\n const language = item.language || lang || 'none';\n switch (item.type) {\n case 'TextualBody': {\n if (typeof item.value !== 'undefined') {\n languageMap[language] = item.value;\n }\n break;\n }\n case 'List':\n case 'Composite':\n case 'Choice': {\n if (item.items) {\n item.items.forEach((inner: any) => parseType(inner, languageMap, language));\n }\n }\n }\n return languageMap;\n}\n\nexport function getTextualContentStrategy(canvas: CanvasNormalized, paintables: Paintables): RenderingStrategy {\n const items: TextualContentStrategy['items'] = [];\n\n paintables.items.forEach((item) => {\n if (item.resource) {\n const [target] = getParsedTargetSelector(canvas, item.target);\n items.push({ annotationId: item.annotationId, text: parseType(item.resource), target: target as any });\n }\n });\n\n return {\n type: 'textual-content',\n items,\n } as TextualContentStrategy;\n}\n","import { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { unsupportedStrategy } from './rendering-utils';\nimport { MediaStrategy } from './strategies';\nimport { Paintables } from '@iiif/helpers';\n\n// https://stackoverflow.com/a/27728417\nconst ytRegex = /^.*(?:(?:youtu\\.be\\/|v\\/|vi\\/|u\\/\\w\\/|embed\\/|shorts\\/)|(?:(?:watch)?\\?vi?=|&vi?=))([^#&?]*).*/;\n\nexport function getVideoStrategy(canvas: CanvasNormalized, paintables: Paintables) {\n const videoPaintables = paintables.items.filter((t) => t.type === 'video');\n\n let noDuration = false;\n\n if (!canvas.duration) {\n noDuration = true;\n }\n\n if (videoPaintables.length > 1) {\n return unsupportedStrategy('Only one video source supported');\n }\n\n const videoResource = videoPaintables[0]?.resource as any; // @todo stronger type for what this might be.\n const isYouTube = !!(videoResource.service || []).find((service: any) =>\n (service.profile || '').includes('youtube.com')\n );\n\n if (!isYouTube && noDuration) {\n return unsupportedStrategy('Video does not have duration');\n }\n\n if (!videoResource) {\n return unsupportedStrategy('Unknown video');\n }\n\n if (!videoResource.format || videoResource.format === 'text/html') {\n if (!isYouTube) {\n return unsupportedStrategy('Video does not have format');\n }\n }\n\n const media = {\n annotationId: (paintables.items[0] as any).annotationId,\n duration: canvas.duration,\n url: videoResource.id,\n type: 'Video',\n items: [],\n target: {\n type: 'TemporalSelector',\n temporal: {\n startTime: 0,\n endTime: canvas.duration,\n },\n },\n format: videoResource.format,\n selector: {\n type: 'TemporalSelector',\n temporal: {\n startTime: 0,\n endTime: canvas.duration,\n },\n },\n };\n\n if (isYouTube) {\n media.type = 'VideoYouTube';\n const id = videoResource.id.match(ytRegex);\n if (!id[1]) {\n return unsupportedStrategy('Video is not known youtube video');\n }\n (media as any).youTubeId = id[1];\n }\n\n // @todo support VTT\n\n return {\n type: 'media',\n media,\n annotations: {\n pages: [],\n },\n } as MediaStrategy;\n}\n","import { get3dStrategy } from './3d-strategy';\nimport { getAudioStrategy } from './audio-strategy';\nimport { getImageStrategy } from './image-strategy';\nimport { emptyStrategy, unknownResponse, unsupportedStrategy } from './rendering-utils';\nimport { getTextualContentStrategy } from './textual-content-strategy';\nimport { getVideoStrategy } from './video-strategy';\nimport type { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport type { Paintables } from '@iiif/helpers/painting-annotations';\nimport type { ImageServiceLoaderType } from '../../hooks/useLoadImageService';\n\ninterface GetRenderStrategyOptions {\n canvas: CanvasNormalized | null | undefined;\n paintables: Paintables;\n supports: string[];\n loadImageService: ImageServiceLoaderType;\n}\n\nexport function getRenderingStrategy({ canvas, paintables, supports, loadImageService }: GetRenderStrategyOptions) {\n if (!canvas) {\n console.log('No canvas');\n return unknownResponse;\n }\n\n if (paintables.types.length === 0) {\n if (supports.indexOf('empty') !== -1) {\n return emptyStrategy(canvas.width, canvas.height);\n }\n console.log('No paintables');\n return unknownResponse;\n }\n\n if (paintables.types.length !== 1) {\n if (paintables.types.length === 2 && paintables.types.indexOf('text') !== -1) {\n paintables.types = paintables.types.filter((t) => t !== 'text');\n } else {\n if (supports.indexOf('complex-timeline') === -1) {\n return unsupportedStrategy('Complex timeline not supported');\n }\n return unsupportedStrategy('ComplexTimelineStrategy not yet supported');\n }\n }\n\n const mainType = paintables.types[0];\n\n // Image\n if (mainType === 'image') {\n if (supports.indexOf('images') === -1) {\n return unsupportedStrategy('Image not supported');\n }\n\n return getImageStrategy(canvas, paintables, loadImageService);\n }\n\n // 3D\n if (mainType === 'Model' || mainType === 'model') {\n if (supports.indexOf('3d-model') === -1) {\n return unsupportedStrategy('3D not supported');\n }\n\n return get3dStrategy(canvas, paintables);\n }\n\n if (mainType === 'textualbody') {\n if (supports.indexOf('textual-content') === -1) {\n return unsupportedStrategy('Textual content not supported');\n }\n\n return getTextualContentStrategy(canvas, paintables);\n }\n\n if (mainType === 'sound' || mainType === 'audio') {\n if (supports.indexOf('media') === -1) {\n return unsupportedStrategy('Media not supported');\n }\n\n // Media Strategy with audio or audio sequence.\n return getAudioStrategy(canvas, paintables);\n }\n\n if (mainType === 'video') {\n if (supports.indexOf('media') === -1) {\n return unsupportedStrategy('Media not supported');\n }\n\n // Media Strategy with video or video sequence.\n return getVideoStrategy(canvas, paintables);\n }\n\n // Unknown fallback.\n return unknownResponse;\n}\n","import { AnnotationPageNormalized } from '@iiif/presentation-3-normalized';\nimport { useCanvas } from './useCanvas';\nimport { useMemo } from 'react';\nimport { useVault } from './useVault';\nimport { RenderingStrategy } from '../features/rendering-strategy/strategies';\nimport {\n emptyActions,\n emptyStrategy,\n unknownResponse,\n unsupportedStrategy,\n} from '../features/rendering-strategy/rendering-utils';\nimport { useAnnotationPageManager } from './useAnnotationPageManager';\nimport { useManifest } from './useManifest';\nimport { useResources } from './useResources';\nimport { useLoadImageService } from './useLoadImageService';\nimport { usePaintables } from './usePaintables';\nimport { getRenderingStrategy } from '../features/rendering-strategy/get-rendering-strategy';\n\n// @todo we may not have any actions returned from the rendering strategy.\nexport type StrategyActions = {\n makeChoice: (id: string, options?: { deselectOthers?: boolean; deselect?: boolean }) => void;\n};\n\nexport type UseRenderingStrategy = [RenderingStrategy, StrategyActions];\n\nexport type UseRenderingStrategyOptions = {\n strategies?: Array<RenderingStrategy['type']>;\n annotationPageManagerId?: string;\n enableSingleAnnotation?: boolean;\n defaultChoices?: string[];\n};\n\nexport function useRenderingStrategy(options?: UseRenderingStrategyOptions): UseRenderingStrategy {\n const manifest = useManifest();\n const canvas = useCanvas();\n const vault = useVault();\n const [loadImageService, imageServiceStatus] = useLoadImageService();\n const { enabledPageIds } = useAnnotationPageManager(options?.annotationPageManagerId || manifest?.id || canvas?.id, {\n all: false,\n });\n const enabledPages = useResources<AnnotationPageNormalized>(enabledPageIds, 'AnnotationPage');\n\n const supports: RenderingStrategy['type'][] = options?.strategies || [\n 'empty',\n 'images',\n 'media',\n 'textual-content',\n 'complex-timeline',\n ];\n\n const [paintables, actions] = usePaintables(options, [imageServiceStatus]);\n\n const strategy = useMemo(() => {\n return getRenderingStrategy({ canvas, paintables, supports, loadImageService });\n }, [canvas, paintables, vault, actions.makeChoice]);\n\n return useMemo(() => {\n if (strategy.type === 'unknown') {\n return [strategy, emptyActions];\n }\n\n return [\n {\n ...strategy,\n annotations: { pages: enabledPages },\n },\n actions,\n ];\n }, [strategy, enabledPages]);\n}\n","import { Vault } from '@iiif/helpers/vault';\nimport { useVault } from './useVault';\nimport { useEffect } from 'react';\n\nexport const useVaultEffect = (callback: (vault: Vault) => void, deps: any[] = []): void => {\n const vault = useVault();\n\n useEffect(() => {\n callback(vault);\n }, [vault, ...deps]);\n};\n","import { useEffect, useMemo, useRef, useState } from 'react';\nimport { useManifest } from './useManifest';\nimport { useCanvas } from './useCanvas';\nimport { useVaultEffect } from './useVaultEffect';\nimport { ImageCandidate, ImageCandidateRequest } from '@atlas-viewer/iiif-image-api';\nimport { useImageServiceLoader } from '../context/ImageServiceLoaderContext';\nimport { createThumbnailHelper } from '@iiif/helpers/thumbnail';\nimport { useVault } from './useVault';\n\nexport function useThumbnail(\n request: ImageCandidateRequest,\n dereference?: boolean,\n { canvasId, manifestId }: { canvasId?: string; manifestId?: string } = {}\n) {\n const vault = useVault();\n const loader = useImageServiceLoader();\n const helper = useMemo(() => createThumbnailHelper(vault, { imageServiceLoader: loader }), [vault, loader]);\n\n const [thumbnail, setThumbnail] = useState<ImageCandidate | undefined>();\n const manifest = useManifest(manifestId ? { id: manifestId } : undefined);\n const canvas = useCanvas(canvasId ? { id: canvasId } : undefined);\n const subject = canvas ? canvas : manifest;\n const didUnmount = useRef(false);\n\n useEffect(() => {\n didUnmount.current = false;\n return () => {\n didUnmount.current = true;\n };\n }, []);\n\n if (!subject) {\n throw new Error('Must be called under a manifest or canvas context.');\n }\n\n useVaultEffect(\n (v) => {\n helper.getBestThumbnailAtSize(subject, request, dereference).then((thumb) => {\n if (thumb.best && !didUnmount.current) {\n setThumbnail(thumb.best);\n }\n });\n },\n [subject]\n );\n\n return thumbnail;\n}\n","import { RefObject, useCallback, useEffect, useReducer, useRef } from 'react';\n\ntype MediaPlayerAction =\n | { type: 'PLAY_PAUSE' }\n | { type: 'TOGGLE_MUTE' }\n | { type: 'MUTE' }\n | { type: 'UNMUTE' }\n | { type: 'SET_VOLUME'; volume: number }\n | { type: 'PLAY' }\n | { type: 'PLAY_REQUESTED' }\n | { type: 'PAUSE' }\n | { type: 'FINISHED' };\n\nexport type MediaPlayerState = {\n isPlaying: boolean;\n isMuted: boolean;\n playRequested: boolean;\n volume: number;\n isFinished: boolean;\n duration: number;\n};\n\nexport type MediaPlayerActions = {\n play(): void;\n pause(): void;\n playPause(): void;\n mute(): void;\n unmute(): void;\n toggleMute(): void;\n setVolume(volume: number): void;\n setDurationPercent(percent: number): void;\n setTime(time: number): void;\n};\n\nfunction getDefaultState(duration: number): MediaPlayerState {\n return { isMuted: false, playRequested: false, isPlaying: false, isFinished: false, volume: 100, duration };\n}\n\nfunction reducer(state: MediaPlayerState, action: MediaPlayerAction) {\n switch (action.type) {\n case 'FINISHED':\n return { ...state, isFinished: true, isPlaying: false, playRequested: false };\n case 'PLAY_PAUSE':\n return { ...state, isFinished: false, isPlaying: !state.isPlaying };\n case 'PLAY_REQUESTED':\n return { ...state, isFinished: false, playRequested: true };\n case 'PAUSE':\n return { ...state, isPlaying: false };\n case 'PLAY':\n return { ...state, isFinished: false, playRequested: false, isPlaying: true };\n case 'MUTE':\n return { ...state, isMuted: true };\n case 'SET_VOLUME':\n return { ...state, volume: action.volume, isMuted: action.volume === 0 };\n case 'TOGGLE_MUTE':\n return { ...state, isMuted: !state.isMuted };\n case 'UNMUTE':\n return { ...state, isMuted: false };\n }\n return state;\n}\n\nexport function formatTime(time: number) {\n const seconds = Math.round(time);\n return `${Math.floor(seconds / 60)}:${`${seconds % 60}`.padStart(2, '0')}`;\n}\n\nexport function useSimpleMediaPlayer(props: { duration: number }): readonly [\n {\n element: RefObject<HTMLAudioElement | HTMLVideoElement>;\n currentTime: RefObject<HTMLDivElement>;\n progress: RefObject<HTMLDivElement>;\n },\n MediaPlayerState,\n MediaPlayerActions\n] {\n const [state, dispatch] = useReducer(reducer, getDefaultState(props.duration));\n\n const media = useRef<HTMLAudioElement | HTMLVideoElement>(null);\n const currentTime = useRef<HTMLDivElement>(null);\n const progress = useRef<HTMLDivElement>(null);\n const _isMuted = useRef(false);\n\n const _updateCurrentTime = useCallback(() => {\n if (currentTime.current && media.current) {\n currentTime.current.innerHTML = formatTime(media.current.currentTime);\n if (progress.current) {\n progress.current.style.width = `${(media.current.currentTime / props.duration) * 100}%`;\n }\n if (_isMuted.current !== media.current.muted) {\n _isMuted.current = media.current.muted;\n dispatch(media.current.muted ? { type: 'MUTE' } : { type: 'UNMUTE' });\n }\n }\n }, [props.duration]);\n\n const play = useCallback(() => {\n if (media.current) {\n dispatch({ type: 'PLAY_REQUESTED' });\n media.current.play().then(() => {\n dispatch({ type: 'PLAY' });\n });\n _updateCurrentTime();\n }\n }, [_updateCurrentTime]);\n\n const playPause = useCallback(() => {\n if (media.current) {\n if (media.current.duration > 0 && media.current.paused) {\n play();\n } else {\n pause();\n }\n }\n }, [_updateCurrentTime]);\n\n const pause = useCallback(() => {\n if (media.current) {\n media.current.pause();\n dispatch({ type: 'PAUSE' });\n _updateCurrentTime();\n }\n }, [_updateCurrentTime]);\n\n const toggleMute = useCallback(() => {\n if (media.current) {\n media.current.muted = !media.current.muted;\n dispatch(media.current.muted ? { type: 'MUTE' } : { type: 'UNMUTE' });\n }\n }, []);\n\n const mute = useCallback(() => {\n if (media.current) {\n media.current.muted = true;\n dispatch({ type: 'MUTE' });\n }\n }, []);\n\n const unmute = useCallback(() => {\n if (media.current) {\n media.current.muted = false;\n dispatch({ type: 'UNMUTE' });\n }\n }, []);\n\n const setVolume = useCallback((newVolume: number) => {\n if (media.current) {\n media.current.muted = false;\n media.current.volume = newVolume / 100;\n dispatch({ type: 'SET_VOLUME', volume: newVolume });\n }\n }, []);\n\n const setDurationPercent = useCallback((percent: number) => {\n if (media.current) {\n media.current.currentTime = Math.max(0, Math.min(percent * props.duration, props.duration));\n _updateCurrentTime();\n }\n }, []);\n\n const setTime = useCallback((time: number) => {\n if (media.current) {\n media.current.currentTime = Math.max(0, Math.min(time, props.duration));\n _updateCurrentTime();\n }\n }, []);\n\n useEffect(() => {\n const interval = setInterval(() => {\n _updateCurrentTime();\n }, 350);\n\n return () => clearInterval(interval);\n }, [_updateCurrentTime, props.duration]);\n\n useEffect(() => {\n const ended = () => {\n dispatch({ type: 'FINISHED' });\n };\n const _media = media.current;\n\n _media?.addEventListener('ended', ended);\n\n return () => _media?.removeEventListener('ended', ended);\n }, []);\n\n return [\n { element: media, currentTime, progress },\n state,\n {\n play,\n pause,\n playPause,\n mute,\n unmute,\n toggleMute,\n setVolume,\n setDurationPercent,\n setTime,\n },\n ];\n}\n","import { createContext, ReactNode, RefObject, useContext } from 'react';\nimport { MediaPlayerActions, MediaPlayerState } from '../hooks/useSimpleMediaPlayer';\n\nconst MediaReactContextState = createContext<MediaPlayerState | null>(null);\nconst MediaReactContextActions = createContext<MediaPlayerActions | null>(null);\nconst MediaReactContextElements = createContext<{\n element: RefObject<HTMLAudioElement | HTMLVideoElement>;\n currentTime: RefObject<HTMLDivElement>;\n progress: RefObject<HTMLDivElement>;\n} | null>(null);\n\nexport function useMediaState() {\n const ctx = useContext(MediaReactContextState);\n if (!ctx) {\n throw new Error('Ctx not found');\n }\n return ctx;\n}\n\nexport function useMediaActions() {\n const ctx = useContext(MediaReactContextActions);\n if (!ctx) {\n throw new Error('Ctx not found');\n }\n return ctx;\n}\n\nexport function useMediaElements() {\n const ctx = useContext(MediaReactContextElements);\n if (!ctx) {\n throw new Error('Ctx not found');\n }\n return ctx;\n}\n\nexport function MediaPlayerProvider({\n actions,\n state,\n children,\n currentTime,\n progress,\n element,\n}: {\n actions: MediaPlayerActions;\n state: MediaPlayerState;\n children: ReactNode;\n currentTime: RefObject<HTMLDivElement>;\n progress: RefObject<HTMLDivElement>;\n element: RefObject<HTMLAudioElement | HTMLVideoElement>;\n}) {\n return (\n <MediaReactContextElements.Provider value={{ currentTime, progress, element }}>\n <MediaReactContextActions.Provider value={actions}>\n <MediaReactContextState.Provider value={state}>{children}</MediaReactContextState.Provider>\n </MediaReactContextActions.Provider>\n </MediaReactContextElements.Provider>\n );\n}\n","import { ReactNode } from 'react';\nimport { useSimpleMediaPlayer } from '../../hooks/useSimpleMediaPlayer';\nimport { SingleAudio } from '../../features/rendering-strategy/resource-types';\nimport { MediaPlayerProvider } from '../../context/MediaContext';\nimport { useOverlay } from '../context/overlays';\n\nexport function AudioHTML({ media, children }: { media: SingleAudio; children: ReactNode }) {\n const [{ element, currentTime, progress }, state, actions] = useSimpleMediaPlayer({ duration: media.duration });\n\n return (\n <MediaPlayerProvider\n state={state}\n actions={actions}\n currentTime={currentTime}\n progress={progress}\n element={element}\n >\n <audio ref={element} src={media.url} />\n {children}\n </MediaPlayerProvider>\n );\n}\n\nexport function Audio({\n media,\n mediaControlsDeps,\n children,\n}: {\n media: SingleAudio;\n mediaControlsDeps?: any[];\n children: ReactNode;\n}) {\n useOverlay('portal', 'audio', AudioHTML, { media, children }, [media, ...(mediaControlsDeps || [])]);\n\n return null;\n}\n","import { ReactNode, RefObject } from 'react';\nimport { useSimpleMediaPlayer } from '../../hooks/useSimpleMediaPlayer';\nimport { SingleVideo } from '../../features/rendering-strategy/resource-types';\nimport { MediaPlayerProvider } from '../../context/MediaContext';\nimport { useOverlay } from '../context/overlays';\n\nexport function VideoHTML({\n element,\n media,\n playPause,\n}: {\n element: RefObject<any>;\n media: SingleVideo;\n playPause: () => void;\n}) {\n const Component = 'div' as any;\n return (\n <Component className=\"video-container\" part=\"video-container\" onClick={playPause}>\n <style>\n {`\n .video-container {\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n background: #000;\n z-index: 13;\n display: flex;\n justify-content: center;\n pointer-events: visible;\n }\n `}\n </style>\n <video ref={element as any} src={media.url} style={{ width: '100%', objectFit: 'contain' }} />\n </Component>\n );\n}\n\nexport function Video({\n media,\n mediaControlsDeps,\n children,\n}: {\n media: SingleVideo;\n mediaControlsDeps?: any[];\n children: ReactNode;\n}) {\n const [{ element, currentTime, progress }, state, actions] = useSimpleMediaPlayer({ duration: media.duration });\n\n useOverlay('overlay', 'video-element', VideoHTML, {\n element,\n media,\n playPause: actions.playPause,\n });\n\n useOverlay(\n 'portal',\n 'custom-controls',\n MediaPlayerProvider,\n {\n state: state,\n actions: actions,\n currentTime: currentTime,\n progress: progress,\n element: element,\n children,\n },\n [currentTime, state, media, ...(mediaControlsDeps || [])]\n );\n\n return null;\n}\n","// @ts-ignore\nimport ModelViewer from 'react-model-viewer';\nimport { useOverlay } from '../context/overlays';\n\nexport function ModelHTML({ model }: { model: any }) {\n return (\n <>\n <style>\n {`\n .model-container {\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n background: #000;\n z-index: 13;\n display: flex;\n justify-content: center;\n pointer-events: visible;\n }\n `}\n </style>\n <div className=\"model-container\">\n {/*@ts-ignore*/}\n <model-viewer\n interaction-prompt=\"none\"\n style={{ width: '100%', height: '100%' }}\n camera-controls=\"\"\n ar-status=\"not-presenting\"\n src={model.id}\n />\n </div>\n </>\n );\n}\n\nexport function Model({ model, name }: { model: any; name?: string }) {\n useOverlay('overlay', `model-${name}`, ModelHTML, { model }, [model]);\n\n return null;\n}\n","import { BoxStyle } from '@atlas-viewer/atlas';\nimport { useCanvas } from '../../hooks/useCanvas';\n\nexport function CanvasBackground({ style }: { style?: BoxStyle }) {\n const canvas = useCanvas();\n\n if (!canvas || !canvas.height || !canvas.width) {\n return null;\n }\n\n return (\n <box\n interactive={false}\n target={{ x: 0, y: 0, width: Number(canvas.width), height: Number(canvas.height) }}\n style={style}\n />\n );\n}\n","import { InternationalString } from '@iiif/presentation-3';\nimport React, { ReactNode, useMemo } from 'react';\n\nconst LanguageContext = React.createContext<string>('en');\n\nexport function LanguageProvider(props: { language: string; children: ReactNode }) {\n return <LanguageContext.Provider value={props.language}>{props.children}</LanguageContext.Provider>;\n}\n\nexport function useIIIFLanguage() {\n return React.useContext(LanguageContext);\n}\n\nfunction getLanguagePartFromCode(code: string) {\n return code.indexOf('-') !== -1 ? code.slice(0, code.indexOf('-')) : code;\n}\n\ntype LanguageStringProps = {\n [key: string]: any;\n} & { as?: string | React.FC<any>; language: string; viewingDirection?: 'rtl' | 'rtl' };\n\nexport function LanguageString({ as: Component, language, children, viewingDirection, ...props }: LanguageStringProps) {\n const i18nLanguage = useIIIFLanguage();\n\n const isSame = useMemo(() => {\n return getLanguagePartFromCode(i18nLanguage) === getLanguagePartFromCode(language);\n }, [i18nLanguage, language]);\n\n if (isSame) {\n if (Component) {\n return <Component {...props}>{children}</Component>;\n }\n\n return <span {...props}>{children}</span>;\n }\n\n if (Component) {\n return (\n <Component {...props} lang={language} dir={viewingDirection}>\n {children}\n </Component>\n );\n }\n\n return (\n <span {...props} lang={language} dir={viewingDirection}>\n {children}\n </span>\n );\n}\n\nfunction getClosestLanguage(i18nLanguage: string, languages: string[], i18nLanguages: string[]) {\n if (languages.length === 0) {\n return undefined;\n }\n\n // Only one option.\n if (languages.length === 1) {\n return languages[0];\n }\n\n // Exact match.\n if (languages.indexOf(i18nLanguage) !== -1) {\n return i18nLanguage;\n }\n\n // Root match (en-us === en)\n const root = i18nLanguage.indexOf('-') !== -1 ? i18nLanguage.slice(0, i18nLanguage.indexOf('-')) : null;\n if (root && languages.indexOf(root) !== -1) {\n return root;\n }\n\n // All of the fall backs.\n for (const lang of i18nLanguages) {\n if (languages.indexOf(lang) !== -1) {\n return lang;\n }\n }\n\n if (languages.indexOf('none') !== -1) {\n return 'none';\n }\n\n if (languages.indexOf('@none') !== -1) {\n return '@none';\n }\n\n // Finally, fall back to the first.\n return languages[0];\n}\n\nexport const useClosestLanguage = (getLanguages: () => string[], deps: any[] = []): string | undefined => {\n const i18nLanguage = useIIIFLanguage();\n\n return useMemo(() => {\n const languages = getLanguages();\n\n return getClosestLanguage(i18nLanguage, languages, []);\n }, [i18nLanguage, ...deps]);\n};\n\nexport function useLocaleString(\n inputText: InternationalString | string | null | undefined,\n defaultText?: string,\n separator = '\\n'\n) {\n const language = useClosestLanguage(() => Object.keys(inputText || {}), [inputText]);\n return [\n useMemo(() => {\n if (!inputText) {\n return defaultText || '';\n }\n if (typeof inputText === 'string') {\n return inputText;\n }\n\n const candidateText = language ? inputText[language] : undefined;\n if (candidateText) {\n if (typeof candidateText === 'string') {\n return candidateText;\n }\n return candidateText.join(separator);\n }\n\n return '';\n }, [language, defaultText, inputText]),\n language,\n ] as const;\n}\n\nexport function useCreateLocaleString() {\n const i18nLanguage = useIIIFLanguage();\n\n return function createLocaleString(\n inputText: InternationalString | string | null | undefined,\n defaultText?: string,\n separator?: string\n ) {\n const languages = Object.keys(inputText || {});\n const language = getClosestLanguage(i18nLanguage, languages, []);\n\n if (!inputText) {\n return defaultText || '';\n }\n if (typeof inputText === 'string') {\n return inputText;\n }\n\n const candidateText = language ? inputText[language] : undefined;\n if (candidateText) {\n if (typeof candidateText === 'string') {\n return candidateText;\n }\n return candidateText.join(typeof separator !== 'undefined' ? separator : '\\n');\n }\n\n return '';\n };\n}\n\ntype LocaleStringProps = {\n as?: string | React.FC<any>;\n defaultText?: string;\n to?: string;\n separator?: string;\n enableDangerouslySetInnerHTML?: boolean;\n children: InternationalString | string | null | undefined;\n style?: React.CSSProperties;\n extraProps?: any;\n} & Record<string, any>;\n\nexport function LocaleString({\n as: Component,\n defaultText,\n enableDangerouslySetInnerHTML,\n children,\n separator,\n ...props\n}: LocaleStringProps) {\n const [text, language] = useLocaleString(children, defaultText, separator);\n\n if (language) {\n return (\n <LanguageString\n {...props}\n as={Component}\n language={language}\n title={enableDangerouslySetInnerHTML ? undefined : text}\n dangerouslySetInnerHTML={\n enableDangerouslySetInnerHTML\n ? {\n __html: text,\n }\n : undefined\n }\n >\n {enableDangerouslySetInnerHTML ? undefined : text}\n </LanguageString>\n );\n }\n\n if (Component) {\n return <Component {...props}>{text}</Component>;\n }\n\n return (\n <span\n {...props}\n title={enableDangerouslySetInnerHTML ? undefined : text}\n dangerouslySetInnerHTML={\n enableDangerouslySetInnerHTML\n ? {\n __html: text,\n }\n : undefined\n }\n >\n {enableDangerouslySetInnerHTML ? undefined : text}\n </span>\n );\n}\n","import { useSimpleMediaPlayer } from '../../hooks/useSimpleMediaPlayer';\nimport { useOverlay } from '../context/overlays';\nimport { SingleYouTubeVideo } from '../../features/rendering-strategy/resource-types';\nimport { ReactNode, RefObject, useRef } from 'react';\n\nexport function VideoYouTubeHTML({\n element,\n media,\n playPause,\n}: {\n element: RefObject<any>;\n media: SingleYouTubeVideo;\n playPause: () => void;\n}) {\n const player = useRef<HTMLIFrameElement>(null);\n\n if (!media.youTubeId) {\n return null;\n }\n\n const Component = 'div' as any;\n return (\n <Component className=\"video-container\" part=\"video-container\" onClick={playPause}>\n <style>\n {`\n .video-container {\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n background: #000;\n z-index: 13;\n display: flex;\n justify-content: center;\n pointer-events: visible;\n }\n .video-yt {\n border: none;\n width: 100%;\n object-fit: contain;\n }\n `}\n </style>\n <iframe\n className=\"video-yt\"\n ref={player}\n src={`https://www.youtube.com/embed/${media.youTubeId}?enablejsapi=1&origin=${window.location.host}`}\n referrerPolicy=\"no-referrer\"\n sandbox=\"allow-scripts allow-same-origin allow-presentation\"\n ></iframe>\n </Component>\n );\n}\n\nexport function VideoYouTube({\n media,\n mediaControlsDeps,\n children,\n}: {\n media: SingleYouTubeVideo;\n mediaControlsDeps?: any[];\n children: ReactNode;\n}) {\n const [{ element, currentTime, progress }, state, actions] = useSimpleMediaPlayer({ duration: media.duration });\n\n useOverlay('overlay', 'video-element', VideoYouTubeHTML, {\n element,\n media,\n playPause: actions.playPause,\n });\n\n return null;\n}\n","import { createStylesHelper } from '@iiif/helpers/styles';\nimport { RenderImage } from './Image';\nimport React, { Fragment, ReactNode, useEffect, useLayoutEffect, useMemo } from 'react';\nimport { BoxStyle, HTMLPortal } from '@atlas-viewer/atlas';\nimport { useVirtualAnnotationPageContext } from '../../hooks/useVirtualAnnotationPageContext';\nimport { StrategyActions, useRenderingStrategy } from '../../hooks/useRenderingStrategy';\nimport { useVault } from '../../hooks/useVault';\nimport { useResourceEvents } from '../../hooks/useResourceEvents';\nimport { useThumbnail } from '../../hooks/useThumbnail';\nimport { useCanvas } from '../../hooks/useCanvas';\nimport { RenderAnnotationPage } from './AnnotationPage';\nimport { Audio } from './Audio';\nimport { EmptyStrategy, MediaStrategy, RenderingStrategy } from '../../features/rendering-strategy/strategies';\nimport { Video } from './Video';\nimport { Model } from './Model';\nimport { CanvasContext } from '../../context/CanvasContext';\nimport { SingleImageStrategy } from '../../features/rendering-strategy/image-strategy';\nimport { CanvasBackground } from './CanvasBackground';\nimport { ImageWithOptionalService } from '../../features/rendering-strategy/resource-types';\nimport { LocaleString } from '../../utility/i18n-utils';\nimport { useOverlay } from '../context/overlays';\nimport { useViewerPreset, ViewerPresetContext } from '../../context/ViewerPresetContext';\nimport { ChoiceDescription } from '@iiif/helpers';\nimport { useWorldSize } from '../context/world-size';\nimport { VideoYouTube } from './VideoYouTube';\n\nexport type CanvasProps = {\n x?: number;\n y?: number;\n onCreated?: any;\n onChoiceChange?: (choice?: ChoiceDescription) => void;\n registerActions?: (actions: StrategyActions) => void;\n defaultChoices?: Array<{ id: string; opacity?: number }>;\n isStatic?: boolean;\n keepCanvasScale?: boolean;\n children?: ReactNode;\n renderViewerControls?: (strategy: SingleImageStrategy | EmptyStrategy) => ReactNode;\n viewControlsDeps?: any[];\n renderMediaControls?: (strategy: MediaStrategy) => ReactNode;\n mediaControlsDeps?: any[];\n strategies?: Array<RenderingStrategy['type']>;\n backgroundStyle?: BoxStyle;\n alwaysShowBackground?: boolean;\n enableSizes?: boolean;\n enableYouTube?: boolean;\n ignoreSize?: boolean;\n throwOnUnknown?: boolean;\n onClickPaintingAnnotation?: (id: string, image: ImageWithOptionalService, e: any) => void;\n};\n\nexport function RenderCanvas({\n x,\n y,\n onChoiceChange,\n registerActions,\n defaultChoices,\n isStatic,\n renderViewerControls,\n renderMediaControls,\n viewControlsDeps,\n mediaControlsDeps,\n strategies,\n throwOnUnknown,\n backgroundStyle,\n alwaysShowBackground,\n keepCanvasScale = false,\n enableSizes = false,\n enableYouTube = true,\n onClickPaintingAnnotation,\n children,\n}: CanvasProps) {\n const canvas = useCanvas();\n const elementProps = useResourceEvents(canvas, ['deep-zoom']);\n const [virtualPage] = useVirtualAnnotationPageContext();\n const preset = useViewerPreset();\n const vault = useVault();\n const helper = useMemo(() => createStylesHelper(vault), [vault]);\n const [strategy, actions] = useRenderingStrategy({\n strategies: strategies || ['images'],\n defaultChoices: defaultChoices?.map(({ id }) => id),\n });\n const choice = strategy.type === 'images' ? strategy.choice : undefined;\n const bestScale = useMemo(() => {\n if (keepCanvasScale) {\n return 1;\n }\n return Math.max(\n 1,\n ...(strategy.type === 'images'\n ? strategy.images.map((i) => {\n return (i.width || 0) / i.target?.spatial.width;\n })\n : [])\n );\n }, [keepCanvasScale, strategy]);\n\n useWorldSize(bestScale);\n\n useEffect(() => {\n if (registerActions) {\n registerActions(actions);\n }\n }, [strategy.annotations]);\n\n useEffect(() => {\n if (defaultChoices) {\n for (const choice of defaultChoices) {\n if (typeof choice.opacity !== 'undefined') {\n helper.applyStyles({ id: choice.id }, 'atlas', {\n opacity: choice.opacity,\n });\n }\n }\n }\n }, [defaultChoices]);\n\n useLayoutEffect(() => {\n if (onChoiceChange) {\n onChoiceChange(choice);\n }\n }, [choice]);\n\n useOverlay(\n preset &&\n (strategy.type === 'images' ||\n strategy.type === 'empty' ||\n (strategy.type === 'textual-content' && renderViewerControls))\n ? 'overlay'\n : 'none',\n `canvas-portal-controls-${canvas?.id}`,\n ViewerPresetContext.Provider,\n renderViewerControls\n ? {\n value: preset || null,\n children: renderViewerControls(strategy as any),\n }\n : {},\n [canvas, preset, strategy, ...(viewControlsDeps || [])]\n );\n\n const thumbnail = useThumbnail({ maxWidth: 256, maxHeight: 256 });\n\n if (!canvas) {\n return null;\n }\n\n // accompanyingCanvas\n const accompanyingCanvas = canvas.accompanyingCanvas;\n\n const thumbnailFallbackImage =\n thumbnail && thumbnail.type === 'fixed' ? (\n <world-object height={canvas.height} width={canvas.width} x={x} y={y}>\n <world-image\n uri={thumbnail.id}\n target={{ x: 0, y: 0, width: canvas.width, height: canvas.height }}\n display={\n thumbnail.width && thumbnail.height\n ? {\n width: thumbnail.width,\n height: thumbnail.height,\n }\n : undefined\n }\n crop={undefined}\n />\n </world-object>\n ) : null;\n\n if (strategy.type === 'unknown') {\n if (thumbnailFallbackImage) {\n return thumbnailFallbackImage;\n }\n\n if (throwOnUnknown) {\n throw new Error(strategy.reason || 'Unknown image strategy');\n }\n\n return null;\n }\n\n const annotations = (\n <Fragment>\n {virtualPage ? <RenderAnnotationPage page={virtualPage} /> : null}\n {strategy.annotations && strategy.annotations.pages\n ? strategy.annotations.pages.map((page) => {\n return <RenderAnnotationPage key={page.id} page={page} />;\n })\n : null}\n {children}\n </Fragment>\n );\n\n const totalKey = strategy.type === 'images' ? strategy.images.length : 0;\n\n return (\n <>\n <world-object\n key={`${canvas.id}/${strategy.type}/${totalKey}`}\n height={canvas.height}\n width={canvas.width}\n // scale={bestScale}\n x={x}\n y={y}\n {...elementProps}\n >\n {strategy.type === 'empty' || alwaysShowBackground ? <CanvasBackground style={backgroundStyle} /> : null}\n {strategy.type === 'textual-content'\n ? strategy.items.map((item, n) => {\n return (\n <>\n <HTMLPortal\n key={n}\n // @ts-ignore\n onClick={\n onClickPaintingAnnotation\n ? (e: any) => {\n e.stopPropagation();\n onClickPaintingAnnotation(item.annotationId, item as any, e);\n }\n : undefined\n }\n target={(item.target as any)?.spatial || undefined}\n >\n <div data-textual-content={true}>\n <LocaleString enableDangerouslySetInnerHTML>{item.text}</LocaleString>\n </div>\n </HTMLPortal>\n {annotations}\n </>\n );\n })\n : null}\n {strategy.type === 'images' ? (\n <>\n {strategy.images.map((image, idx) => (\n <RenderImage\n isStatic={isStatic}\n key={image.id + idx}\n image={image}\n id={image.id}\n thumbnail={idx === 0 ? thumbnail : undefined}\n selector={image.selector}\n enableSizes={enableSizes}\n onClick={\n onClickPaintingAnnotation\n ? (e) => {\n e.stopPropagation();\n onClickPaintingAnnotation(image.annotationId, image, e);\n }\n : undefined\n }\n />\n ))}\n {annotations}\n </>\n ) : null}\n {strategy.type === '3d-model' ? <Model model={strategy.model} /> : null}\n {strategy.type === 'media' ? (\n <>\n {strategy.media.type === 'Sound' ? (\n <Audio media={strategy.media} mediaControlsDeps={mediaControlsDeps}>\n {thumbnailFallbackImage}\n {renderMediaControls ? renderMediaControls(strategy) : null}\n </Audio>\n ) : strategy.media.type === 'Video' ? (\n <Video media={strategy.media} mediaControlsDeps={mediaControlsDeps}>\n {thumbnailFallbackImage}\n {renderMediaControls ? renderMediaControls(strategy) : null}\n </Video>\n ) : strategy.media.type === 'VideoYouTube' && enableYouTube ? (\n <VideoYouTube media={strategy.media} mediaControlsDeps={mediaControlsDeps}>\n {thumbnailFallbackImage}\n {renderMediaControls ? renderMediaControls(strategy) : null}\n </VideoYouTube>\n ) : null}\n </>\n ) : null}\n {/* This is required to fix a race condition. */}\n </world-object>\n {strategy.type === 'media' && strategy.media.type === 'Sound' && accompanyingCanvas ? (\n <CanvasContext canvas={accompanyingCanvas.id}>\n <RenderCanvas renderViewerControls={renderViewerControls} />\n </CanvasContext>\n ) : null}\n </>\n );\n}\n","import { FC, forwardRef, ForwardRefExoticComponent, ReactNode, RefAttributes, useImperativeHandle } from 'react';\nimport { Viewer } from './Viewer';\nimport { RenderAnnotation } from './render/Annotation';\nimport { RenderAnnotationPage } from './render/AnnotationPage';\nimport { CanvasProps, RenderCanvas } from './render/Canvas';\nimport { RenderImage } from './render/Image';\nimport { CanvasBackground } from './render/CanvasBackground';\nimport { SimpleViewerProvider, useSimpleViewer } from '../viewers/SimpleViewerContext';\nimport { VaultProvider } from '../context/VaultContext';\nimport { useManifest } from '../hooks/useManifest';\nimport { useVisibleCanvases } from '../context/VisibleCanvasContext';\nimport { CanvasContext } from '../context/CanvasContext';\nimport { useExistingVault } from '../hooks/useExistingVault';\nimport { SimpleViewerContext } from '../viewers/SimpleViewerContext.types';\nimport { Audio, AudioHTML } from './render/Audio';\nimport { Video, VideoHTML } from './render/Video';\nimport { Model, ModelHTML } from './render/Model';\nimport { ViewerMode } from '@atlas-viewer/atlas';\n\ninterface CanvasPanelProps {\n manifest: string;\n startCanvas?: string;\n rangeId?: string;\n pagingEnabled?: boolean;\n header?: ReactNode;\n children?: ReactNode;\n mode?: ViewerMode;\n reuseAtlas?: boolean;\n\n // Inner props\n height?: number;\n spacing?: number;\n components?: {\n ViewerControls?: FC;\n MediaControls?: FC;\n };\n\n // Other components\n canvasProps?: Omit<Partial<CanvasProps>, 'x'>;\n annotations?: ReactNode;\n}\n\ninterface InnerProps {\n height?: number;\n canvasProps?: CanvasPanelProps['canvasProps'];\n spacing?: number;\n components?: CanvasPanelProps['components'];\n children?: ReactNode;\n annotations?: ReactNode;\n header?: ReactNode;\n reuseAtlas?: boolean;\n mode?: ViewerMode;\n}\n\nconst Inner = forwardRef<SimpleViewerContext, InnerProps>(function Inner(props, ref) {\n const manifest = useManifest();\n const canvases = useVisibleCanvases();\n const viewer = useSimpleViewer();\n const { ViewerControls, MediaControls } = props.components || {};\n\n useImperativeHandle(ref, () => viewer, [viewer]);\n\n if (!manifest) {\n return <div />;\n }\n\n let accumulator = 0;\n\n return (\n <>\n {props.header}\n <CanvasPanel.Viewer\n key={props.reuseAtlas ? '' : viewer.currentSequenceIndex}\n height={props.height}\n mode={props.mode}\n >\n {canvases.map((canvas, idx) => {\n const margin = accumulator;\n accumulator += canvas.width + (props.spacing || 0);\n return (\n <CanvasContext canvas={canvas.id} key={canvas.id}>\n <CanvasPanel.RenderCanvas\n key={canvas.id}\n strategies={['3d-model', 'media', 'images', 'empty', 'textual-content']}\n renderViewerControls={idx === 0 && ViewerControls ? () => <ViewerControls /> : undefined}\n renderMediaControls={idx === 0 && MediaControls ? () => <MediaControls /> : undefined}\n x={margin}\n {...(props.canvasProps || {})}\n >\n {props.annotations}\n </CanvasPanel.RenderCanvas>\n </CanvasContext>\n );\n })}\n </CanvasPanel.Viewer>\n {props.children}\n </>\n );\n});\n\ntype CanvasPanelType = ForwardRefExoticComponent<CanvasPanelProps & RefAttributes<SimpleViewerContext>> & {\n RenderImage: typeof RenderImage;\n RenderCanvas: typeof RenderCanvas;\n RenderAnnotationPage: typeof RenderAnnotationPage;\n RenderAnnotation: typeof RenderAnnotation;\n Viewer: typeof Viewer;\n CanvasBackground: typeof CanvasBackground;\n Audio: typeof Audio;\n Video: typeof Video;\n Model: typeof Model;\n AudioHTML: typeof AudioHTML;\n VideoHTML: typeof VideoHTML;\n ModelHTML: typeof ModelHTML;\n};\n\nexport const CanvasPanel = forwardRef<SimpleViewerContext, CanvasPanelProps>(function CanvasPanel(\n { children, height, annotations, canvasProps, spacing, header, components, mode, reuseAtlas, ...props },\n ref\n) {\n const vault = useExistingVault();\n\n return (\n <VaultProvider vault={vault}>\n <SimpleViewerProvider {...props}>\n <Inner\n ref={ref}\n height={height}\n components={components}\n spacing={spacing}\n canvasProps={canvasProps}\n annotations={annotations}\n header={header}\n mode={mode}\n reuseAtlas={reuseAtlas}\n >\n {children}\n </Inner>\n </SimpleViewerProvider>\n </VaultProvider>\n );\n}) as CanvasPanelType;\n\nCanvasPanel.RenderImage = RenderImage;\nCanvasPanel.RenderCanvas = RenderCanvas;\nCanvasPanel.RenderAnnotationPage = RenderAnnotationPage;\nCanvasPanel.RenderAnnotation = RenderAnnotation;\nCanvasPanel.Viewer = Viewer;\nCanvasPanel.CanvasBackground = CanvasBackground;\nCanvasPanel.Audio = Audio;\nCanvasPanel.Video = Video;\nCanvasPanel.Model = Model;\nCanvasPanel.AudioHTML = AudioHTML;\nCanvasPanel.VideoHTML = VideoHTML;\nCanvasPanel.ModelHTML = ModelHTML;\n"],"names":["ErrorBoundaryContext","createContext","initialState","ErrorBoundary","Component","props","error","_this$props$onReset","_this$props","_len","args","_key","info","_this$props$onError","_this$props2","prevProps","prevState","didCatch","resetKeys","hasArrayChanged","_this$props$onReset2","_this$props3","children","fallbackRender","FallbackComponent","fallback","childToRender","createElement","isValidElement","a","b","item","index","defaultResourceContext","ResourceReactContext","React","useResourceContext","useContext","ResourceProvider","value","parentContext","newContext","useMemo","ReactVaultContext","vault","VaultProvider","vaultOptions","useGlobal","resources","vaultInstance","setVaultInstance","useState","globalVault","Vault","useExistingVault","oldContext","useExternalResource","idOrRef","noCache","id","realId","setRealId","setError","initialData","resource","setResource","useEffect","fetchedResource","_realId","err","useExternalManifest","options","isLoaded","requestId","cached","ManifestContext","manifest","CanvasContext","canvas","useVault","useVaultSelector","selector","deps","selectedState","setSelectedState","s","VisibleCanvasReactContext","useVisibleCanvases","ids","state","useManifest","ctx","manifestId","RangeContext","range","findAllCanvasesInRange","found","inner","_a","sourceId","getManifestSequence","manifestOrRange","disablePaging","skipNonPaged","behavior","isPaged","isContinuous","isIndividuals","manifestItems","_","ordering","currentOrdering","flush","offset","flushNextPaged","i","useRange","rangeId","useCanvasSequence","startCanvas","cursor","setCursor","rangeOrManifest","items","initialSequence","setCanvasIndex","useCallback","foundSequence","setCanvasId","foundIndex","next","previous","idx","noop","SimpleViewerReactContext","InnerViewerProvider","visibleItems","sequence","setSequenceIndex","hasNext","hasPrevious","jsx","SimpleViewerProvider","useSimpleViewer","useContextBridge","ContextBridge","E","t","n","R","o","c","A","T","e","M","D","O","S","r","I","U","f","C","N","d","u","J","useDispatch","store","action","isVaultActivated","obj","useVirtualAnnotationPage","sources","useRef","dispatch","virtualId","useLayoutEffect","page","entityActions","fullPage","addAnnotation","atIndex","display","full","annotation","removeAnnotation","VirtualAnnotationPageContext","useVirtualAnnotationPageContext","VirtualAnnotationProvider","DefaultCanvasFallback","width","style","height","resetErrorBoundary","jsxs","ViewerPresetContext","useViewerPreset","SetOverlaysReactContext","SetPortalReactContext","useOverlay","type","key","element","setOverlay","useCanvas","canvasId","WorldSizeContext","useWorldSize","size","fn","Viewer","errorFallback","outerContainerProps","_worldScale","viewerPreset","setViewerPreset","bridge","ErrorFallback","overlays","setOverlays","overlayComponents","portals","setPortals","portalComponents","worldSizes","setWorldSizes","worldScale","runtimeOptions","updateWorldSize","sizes","rest","updateOverlay","prev","updatePortal","fallbackProps","AtlasAuto","Fragment","Element","preset","ModeContext","g","useResourceEvents","scope","helper","createEventsHelper","hooks","useStyles","createStylesHelper","styles","useAnnotation","annotationId","body","singleBody","newAnnotation","expandTarget","RenderAnnotation","defaultStyle","className","interactive","html","events","allStyles","mergeStyles","RegionHighlight","useAnnotationPage","annotationPageId","annotationPage","RenderAnnotationPage","_page","RenderImage","image","thumbnail","isStatic","x","y","onClick","enableSizes","crop","TileSet","_b","getParsedTargetSelector","target","imageTarget","source","defaultTarget","emptyActions","unknownResponse","unsupportedStrategy","reason","emptyStrategy","getMeta","resourceId","resourceMeta","useEnabledAnnotationPageIds","availablePageIds","pageIds","allAnnotationListIds","annotationListId","annotationListMeta","flattenAnnotationPageIds","all","canvases","foundIds","canvas_","useAnnotationPageManager","enabledPageIds","setPageDisabled","deselectId","existingResources","setPageEnabled","opt","toDeselect","useResources","ImageServiceLoaderContext","ImageServiceLoader","useImageServiceLoader","useLoadImageService","loader","imageServiceStatus","setImageServiceStatus","didUnmount","imageService","imageServiceId","syncLoaded","usePaintingAnnotations","annotationPages","flatAnnotations","h","w","m","P","p","l","V","usePaintables","createPaintingAnnotationsHelper","paintingAnnotations","enabledChoices","setEnabledChoices","paintables","actions","deselectOthers","deselect","prevChoices","without","defaultId","newChoices","supportedFormats","get3dStrategy","getAudioStrategy","audioResource","getImageStrategy","loadImageService","imageTypes","singleImage","imageServices","getImageServices","imageSelector","imageType","parseType","languageMap","lang","language","getTextualContentStrategy","ytRegex","getVideoStrategy","videoPaintables","noDuration","videoResource","isYouTube","service","media","getRenderingStrategy","supports","mainType","useRenderingStrategy","enabledPages","strategy","useVaultEffect","callback","useThumbnail","request","dereference","createThumbnailHelper","setThumbnail","subject","v","thumb","getDefaultState","duration","reducer","formatTime","time","seconds","useSimpleMediaPlayer","useReducer","currentTime","progress","_isMuted","_updateCurrentTime","play","playPause","pause","toggleMute","mute","unmute","setVolume","newVolume","setDurationPercent","percent","setTime","interval","ended","_media","MediaReactContextState","MediaReactContextActions","MediaReactContextElements","MediaPlayerProvider","AudioHTML","Audio","mediaControlsDeps","VideoHTML","Video","ModelHTML","model","Model","name","CanvasBackground","LanguageContext","useIIIFLanguage","getLanguagePartFromCode","code","LanguageString","viewingDirection","i18nLanguage","getClosestLanguage","languages","i18nLanguages","root","useClosestLanguage","getLanguages","useLocaleString","inputText","defaultText","separator","candidateText","LocaleString","enableDangerouslySetInnerHTML","text","VideoYouTubeHTML","player","VideoYouTube","RenderCanvas","onChoiceChange","registerActions","defaultChoices","renderViewerControls","renderMediaControls","viewControlsDeps","strategies","throwOnUnknown","backgroundStyle","alwaysShowBackground","keepCanvasScale","enableYouTube","onClickPaintingAnnotation","elementProps","virtualPage","choice","bestScale","accompanyingCanvas","thumbnailFallbackImage","annotations","totalKey","HTMLPortal","Inner","forwardRef","ref","viewer","ViewerControls","MediaControls","useImperativeHandle","accumulator","CanvasPanel","margin","canvasProps","spacing","header","components","mode","reuseAtlas"],"mappings":"yYAGMA,GAAuBC,EAAAA,cAAc,IAAI,EAEzCC,EAAe,CACnB,SAAU,GACV,MAAO,IACT,EACA,MAAMC,WAAsBC,EAAAA,SAAU,CACpC,YAAYC,EAAO,CACjB,MAAMA,CAAK,EACX,KAAK,mBAAqB,KAAK,mBAAmB,KAAK,IAAI,EAC3D,KAAK,MAAQH,CACd,CACD,OAAO,yBAAyBI,EAAO,CACrC,MAAO,CACL,SAAU,GACV,MAAAA,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,GAAA,CAAsB,GAAGzI,EACxB,SAAAwI,EAAA,IAACgV,GAAA,CACC,IAAAE,EACA,OAAA7R,EACA,WAAAwS,EACA,QAAAF,EACA,YAAAD,EACA,YAAAb,EACA,OAAAe,EACA,KAAAE,EACA,WAAAC,EAEC,SAAAtd,CAAA,CAAA,CAEL,CAAA,CACF,CAAA,CAEJ,CAAC,EAED+c,EAAY,YAActN,GAC1BsN,EAAY,aAAe/B,GAC3B+B,EAAY,qBAAuBxN,GACnCwN,EAAY,iBAAmBpO,GAC/BoO,EAAY,OAASjR,GACrBiR,EAAY,iBAAmBxD,GAC/BwD,EAAY,MAAQhE,GACpBgE,EAAY,MAAQ7D,GACpB6D,EAAY,MAAQ1D,GACpB0D,EAAY,UAAYjE,GACxBiE,EAAY,UAAY9D,GACxB8D,EAAY,UAAY5D","x_google_ignoreList":[0,19,29,45]}
1
+ {"version":3,"file":"canvas-panel.js","sources":["../../../node_modules/react-error-boundary/dist/react-error-boundary.esm.js","../../../src/context/ResourceContext.tsx","../../../src/context/VaultContext.tsx","../../../src/hooks/useExistingVault.ts","../../../src/hooks/useExternalResource.ts","../../../src/hooks/useExternalManifest.ts","../../../src/context/ManifestContext.tsx","../../../src/context/CanvasContext.tsx","../../../src/hooks/useVault.ts","../../../src/hooks/useVaultSelector.ts","../../../src/context/VisibleCanvasContext.tsx","../../../src/hooks/useManifest.ts","../../../src/context/RangeContext.tsx","../../../src/future-helpers/ranges.ts","../../../src/future-helpers/sequences.ts","../../../src/hooks/useRange.ts","../../../src/viewers/SimpleViewerContext.hooks.ts","../../../src/viewers/SimpleViewerContext.tsx","../../../src/context/ContextBridge.tsx","../../../node_modules/@iiif/helpers/dist/vault-actions/esm/vault-actions.mjs","../../../src/hooks/useDispatch.ts","../../../src/hooks/useVirtualAnnotationPage.ts","../../../src/hooks/useVirtualAnnotationPageContext.tsx","../../../src/canvas-panel/render/DefaultCanvasFallback.tsx","../../../src/context/ViewerPresetContext.tsx","../../../src/canvas-panel/context/overlays.tsx","../../../src/hooks/useCanvas.ts","../../../src/canvas-panel/context/world-size.ts","../../../src/canvas-panel/Viewer.tsx","../../../node_modules/@iiif/helpers/dist/events/esm/events.mjs","../../../src/hooks/useResourceEvents.ts","../../../src/hooks/useStyles.ts","../../../src/hooks/useAnnotation.ts","../../../src/canvas-panel/render/Annotation.tsx","../../../src/hooks/useAnnotationPage.ts","../../../src/canvas-panel/render/AnnotationPage.tsx","../../../src/canvas-panel/render/Image.tsx","../../../src/features/rendering-strategy/rendering-utils.ts","../../../src/hooks/useEnabledAnnotationPageIds.ts","../../../src/utility/flatten-annotation-page-ids.ts","../../../src/hooks/useAnnotationPageManager.ts","../../../src/hooks/useResources.ts","../../../src/context/ImageServiceLoaderContext.tsx","../../../src/hooks/useLoadImageService.ts","../../../src/hooks/usePaintingAnnotations.ts","../../../node_modules/@iiif/helpers/dist/painting-annotations/esm/painting-annotations.mjs","../../../src/hooks/usePaintables.ts","../../../src/features/rendering-strategy/3d-strategy.ts","../../../src/features/rendering-strategy/audio-strategy.ts","../../../src/features/rendering-strategy/image-strategy.ts","../../../src/features/rendering-strategy/textual-content-strategy.ts","../../../src/features/rendering-strategy/video-strategy.ts","../../../src/features/rendering-strategy/get-rendering-strategy.ts","../../../src/hooks/useRenderingStrategy.ts","../../../src/hooks/useVaultEffect.ts","../../../src/hooks/useThumbnail.ts","../../../src/hooks/useSimpleMediaPlayer.ts","../../../src/context/MediaContext.tsx","../../../src/canvas-panel/render/Audio.tsx","../../../src/canvas-panel/render/Video.tsx","../../../src/canvas-panel/render/Model.tsx","../../../src/canvas-panel/render/CanvasBackground.tsx","../../../src/utility/i18n-utils.tsx","../../../src/canvas-panel/render/VideoYouTube.tsx","../../../src/canvas-panel/render/Canvas.tsx","../../../src/canvas-panel/index.tsx"],"sourcesContent":["'use client';\nimport { createContext, Component, createElement, isValidElement, useContext, useState, useMemo, forwardRef } from 'react';\n\nconst ErrorBoundaryContext = createContext(null);\n\nconst initialState = {\n didCatch: false,\n error: null\n};\nclass ErrorBoundary extends Component {\n constructor(props) {\n super(props);\n this.resetErrorBoundary = this.resetErrorBoundary.bind(this);\n this.state = initialState;\n }\n static getDerivedStateFromError(error) {\n return {\n didCatch: true,\n error\n };\n }\n resetErrorBoundary() {\n const {\n error\n } = this.state;\n if (error !== null) {\n var _this$props$onReset, _this$props;\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n (_this$props$onReset = (_this$props = this.props).onReset) === null || _this$props$onReset === void 0 ? void 0 : _this$props$onReset.call(_this$props, {\n args,\n reason: \"imperative-api\"\n });\n this.setState(initialState);\n }\n }\n componentDidCatch(error, info) {\n var _this$props$onError, _this$props2;\n (_this$props$onError = (_this$props2 = this.props).onError) === null || _this$props$onError === void 0 ? void 0 : _this$props$onError.call(_this$props2, error, info);\n }\n componentDidUpdate(prevProps, prevState) {\n const {\n didCatch\n } = this.state;\n const {\n resetKeys\n } = this.props;\n\n // There's an edge case where if the thing that triggered the error happens to *also* be in the resetKeys array,\n // we'd end up resetting the error boundary immediately.\n // This would likely trigger a second error to be thrown.\n // So we make sure that we don't check the resetKeys on the first call of cDU after the error is set.\n\n if (didCatch && prevState.error !== null && hasArrayChanged(prevProps.resetKeys, resetKeys)) {\n var _this$props$onReset2, _this$props3;\n (_this$props$onReset2 = (_this$props3 = this.props).onReset) === null || _this$props$onReset2 === void 0 ? void 0 : _this$props$onReset2.call(_this$props3, {\n next: resetKeys,\n prev: prevProps.resetKeys,\n reason: \"keys\"\n });\n this.setState(initialState);\n }\n }\n render() {\n const {\n children,\n fallbackRender,\n FallbackComponent,\n fallback\n } = this.props;\n const {\n didCatch,\n error\n } = this.state;\n let childToRender = children;\n if (didCatch) {\n const props = {\n error,\n resetErrorBoundary: this.resetErrorBoundary\n };\n if (typeof fallbackRender === \"function\") {\n childToRender = fallbackRender(props);\n } else if (FallbackComponent) {\n childToRender = createElement(FallbackComponent, props);\n } else if (fallback === null || isValidElement(fallback)) {\n childToRender = fallback;\n } else {\n throw error;\n }\n }\n return createElement(ErrorBoundaryContext.Provider, {\n value: {\n didCatch,\n error,\n resetErrorBoundary: this.resetErrorBoundary\n }\n }, childToRender);\n }\n}\nfunction hasArrayChanged() {\n let a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n let b = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n return a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]));\n}\n\nfunction assertErrorBoundaryContext(value) {\n if (value == null || typeof value.didCatch !== \"boolean\" || typeof value.resetErrorBoundary !== \"function\") {\n throw new Error(\"ErrorBoundaryContext not found\");\n }\n}\n\nfunction useErrorBoundary() {\n const context = useContext(ErrorBoundaryContext);\n assertErrorBoundaryContext(context);\n const [state, setState] = useState({\n error: null,\n hasError: false\n });\n const memoized = useMemo(() => ({\n resetBoundary: () => {\n context.resetErrorBoundary();\n setState({\n error: null,\n hasError: false\n });\n },\n showBoundary: error => setState({\n error,\n hasError: true\n })\n }), [context.resetErrorBoundary]);\n if (state.hasError) {\n throw state.error;\n }\n return memoized;\n}\n\nfunction withErrorBoundary(component, errorBoundaryProps) {\n const Wrapped = forwardRef((props, ref) => createElement(ErrorBoundary, errorBoundaryProps, createElement(component, {\n ...props,\n ref\n })));\n\n // Format for display in DevTools\n const name = component.displayName || component.name || \"Unknown\";\n Wrapped.displayName = \"withErrorBoundary(\".concat(name, \")\");\n return Wrapped;\n}\n\nexport { ErrorBoundary, ErrorBoundaryContext, useErrorBoundary, withErrorBoundary };\n","import React, { ReactNode, useContext, useMemo } from 'react';\n\nconst defaultResourceContext = {\n collection: undefined,\n manifest: undefined,\n range: undefined,\n canvas: undefined,\n annotation: undefined,\n annotationPage: undefined,\n};\n\nexport type ResourceContextType = {\n collection?: string;\n manifest?: string;\n range?: string;\n canvas?: string;\n annotation?: string;\n annotationPage?: string;\n};\n\nexport const ResourceReactContext = React.createContext<ResourceContextType>(defaultResourceContext);\n\nexport const useResourceContext = () => {\n return useContext(ResourceReactContext);\n};\n\nexport function ResourceProvider({ value, children }: { value: ResourceContextType; children: ReactNode }) {\n const parentContext = useResourceContext();\n const newContext = useMemo(() => {\n return {\n ...parentContext,\n ...value,\n };\n }, [value, parentContext]);\n\n return <ResourceReactContext.Provider value={newContext}>{children}</ResourceReactContext.Provider>;\n}\n","import React, { ReactElement, ReactNode, useState } from 'react';\nimport { Vault, VaultOptions, globalVault } from '@iiif/helpers/vault';\nimport { ResourceContextType, ResourceProvider } from './ResourceContext';\n\nexport const ReactVaultContext = React.createContext<{\n vault: Vault | null;\n setVaultInstance: (vault: Vault) => void;\n}>({\n vault: null,\n setVaultInstance: (vault: Vault) => {\n // Do nothing.\n },\n});\n\nexport function VaultProvider({\n vault,\n vaultOptions,\n useGlobal,\n resources,\n children,\n}: {\n vault?: Vault;\n useGlobal?: boolean;\n vaultOptions?: VaultOptions;\n resources?: ResourceContextType;\n children: ReactNode;\n}) {\n const [vaultInstance, setVaultInstance] = useState<Vault>(() => {\n if (vault) {\n return vault;\n }\n if (useGlobal) {\n return globalVault(vaultOptions);\n }\n if (vaultOptions) {\n return new Vault(vaultOptions);\n }\n return new Vault();\n });\n\n return (\n <ReactVaultContext.Provider value={{ vault: vaultInstance, setVaultInstance }}>\n <ResourceProvider value={resources || {}}>{children}</ResourceProvider>\n </ReactVaultContext.Provider>\n );\n}\n","import { globalVault, Vault } from '@iiif/helpers/vault';\nimport { useContext } from 'react';\nimport { ReactVaultContext } from '../context/VaultContext';\n\nexport function useExistingVault(vault?: Vault): Vault {\n const oldContext: any = useContext(ReactVaultContext);\n\n if (vault) {\n return vault;\n }\n\n return oldContext && oldContext.vault ? (oldContext.vault as any) : globalVault();\n}\n","import { useExistingVault } from './useExistingVault';\nimport { useEffect, useMemo, useState } from 'react';\n\nexport type ResourceRequestOptions = {\n noCache?: boolean;\n};\n\nexport function useExternalResource<T extends { id: string }>(\n idOrRef: string | { id: string; type: string },\n { noCache = false }: ResourceRequestOptions = {}\n): {\n id: string;\n requestId: string;\n isLoaded: boolean;\n error: any;\n cached: boolean;\n resource?: T;\n} {\n const id = typeof idOrRef === 'string' ? idOrRef : idOrRef.id;\n const vault = useExistingVault();\n const [realId, setRealId] = useState(id);\n const [error, setError] = useState<Error | undefined>(undefined);\n const initialData = useMemo(() => {\n return vault.get(id, { skipSelfReturn: true }) || undefined;\n }, [id, vault]);\n const [resource, setResource] = useState<T | undefined>(initialData);\n\n useEffect(() => {\n (async () => {\n try {\n const fetchedResource = initialData && !noCache ? initialData : await vault.load<T>(id);\n const _realId = fetchedResource ? fetchedResource.id || (fetchedResource as any)['@id'] : null;\n if (fetchedResource && realId !== _realId) {\n setRealId(_realId);\n }\n\n setResource(fetchedResource);\n } catch (err) {\n setError(err as Error);\n }\n })();\n }, [id, noCache]);\n\n return {\n isLoaded: !!resource,\n id: realId,\n requestId: id,\n error,\n resource,\n cached: !!(resource && resource === initialData),\n };\n}\n","import { ManifestNormalized } from '@iiif/presentation-3-normalized';\nimport { ResourceRequestOptions, useExternalResource } from './useExternalResource';\n\nexport function useExternalManifest(\n idOrRef: string | { id: string; type: string },\n options?: ResourceRequestOptions\n): {\n id: string;\n requestId: string;\n isLoaded: boolean;\n cached?: boolean;\n error: any;\n manifest?: ManifestNormalized;\n} {\n const { id, isLoaded, error, resource, requestId, cached } = useExternalResource<ManifestNormalized>(\n idOrRef,\n options\n );\n\n return { id, isLoaded, error, manifest: resource, requestId, cached };\n}\n","import { ResourceProvider } from './ResourceContext';\nimport React, { ReactNode } from 'react';\n\nexport function ManifestContext({ manifest, children }: { manifest: string; children: ReactNode }) {\n return <ResourceProvider value={{ manifest }}>{children}</ResourceProvider>;\n}\n","import { ResourceProvider } from './ResourceContext';\nimport React, { ReactNode } from 'react';\n\nexport function CanvasContext({ canvas, children }: { canvas: string; children: ReactNode }) {\n return <ResourceProvider value={{ canvas }}>{children}</ResourceProvider>;\n}\n","import { ReactVaultContext } from '../context/VaultContext';\nimport { useContext } from 'react';\nimport { Vault } from '@iiif/helpers/vault';\n\nexport const useVault = (): Vault => {\n const { vault } = useContext(ReactVaultContext);\n\n if (vault === null) {\n throw new Error('Vault not found. Ensure you have your provider set up correctly.');\n }\n\n return vault as Vault;\n};\n","import { useVault } from './useVault';\nimport { IIIFStore, Vault } from '@iiif/helpers/vault';\nimport { useEffect, useState } from 'react';\n\nexport function useVaultSelector<T>(selector: (state: IIIFStore, vault: Vault) => T, deps: any[] = []) {\n const vault = useVault();\n const [selectedState, setSelectedState] = useState<T>(() => selector(vault.getState(), vault));\n\n useEffect(() => {\n return vault.subscribe(\n (s) => selector(s, vault),\n (s) => {\n setSelectedState(s);\n },\n false\n );\n }, deps);\n\n return selectedState as T;\n}\n","import { useContext } from 'react';\nimport React from 'react';\nimport { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { useVaultSelector } from '../hooks/useVaultSelector';\n\nexport const VisibleCanvasReactContext = React.createContext<string[]>([]);\n\nexport function useVisibleCanvases(): CanvasNormalized[] {\n const ids = useContext(VisibleCanvasReactContext);\n\n return useVaultSelector<CanvasNormalized[]>(\n (state) => {\n return ids.map((id) => state.iiif.entities.Canvas[id]).filter(Boolean);\n },\n [ids]\n );\n}\n","import { useResourceContext } from '../context/ResourceContext';\nimport { ManifestNormalized } from '@iiif/presentation-3-normalized';\nimport { useVault } from './useVault';\nimport { useMemo } from 'react';\nimport { useVaultSelector } from './useVaultSelector';\n\nexport function useManifest(options?: { id: string }): ManifestNormalized | undefined;\nexport function useManifest<T>(\n options?: { id: string; selector: (manifest: ManifestNormalized) => T },\n deps?: any[]\n): T | undefined;\nexport function useManifest<T = ManifestNormalized>(\n options: {\n id?: string;\n selector?: (manifest: ManifestNormalized) => T;\n } = {},\n deps: any[] = []\n): ManifestNormalized | T | undefined {\n const { id, selector } = options;\n const ctx = useResourceContext();\n const vault = useVault();\n const manifestId = id ? id : ctx.manifest;\n\n const manifest = useVaultSelector(\n (s) => (manifestId ? s.iiif.entities.Manifest[manifestId] : undefined),\n [manifestId]\n );\n\n return useMemo(() => {\n if (!manifest) {\n return undefined;\n }\n if (selector) {\n return selector(manifest);\n }\n return manifest;\n }, [manifest, selector, ...deps]);\n}\n","import { ResourceProvider } from './ResourceContext';\nimport React, { ReactNode } from 'react';\n\nexport function RangeContext({ range, children }: { range: string; children: ReactNode }) {\n return <ResourceProvider value={{ range }}>{children}</ResourceProvider>;\n}\n","import { Vault } from '@iiif/helpers/vault';\nimport { ManifestNormalized, RangeNormalized } from '@iiif/presentation-3-normalized';\nimport { Reference } from '@iiif/presentation-3';\n\nexport function findFirstCanvasFromRange(vault: Vault, range: RangeNormalized): null | Reference<'Canvas'> {\n for (const inner of range.items) {\n if ((inner as any).type === 'Canvas') {\n return inner as any as Reference<'Canvas'>;\n }\n if (inner.type === 'SpecificResource') {\n return inner.source as Reference<'Canvas'>;\n }\n if (inner.type === 'Range') {\n const found = findFirstCanvasFromRange(vault, vault.get(inner));\n if (found) {\n return found;\n }\n }\n }\n return null;\n}\n\nexport function findAllCanvasesInRange(vault: Vault, range: RangeNormalized): Array<Reference<'Canvas'>> {\n const found: Reference<'Canvas'>[] = [];\n for (const inner of range.items) {\n if (inner.type === 'SpecificResource' && inner.source?.type === 'Canvas') {\n if (inner.source.id.indexOf('#') !== -1) {\n found.push({ id: inner.source.id.split('#')[0], type: 'Canvas' });\n } else {\n found.push(inner.source as Reference<'Canvas'>);\n }\n }\n if (inner.type === 'Range') {\n found.push(...findAllCanvasesInRange(vault, vault.get(inner)));\n }\n if ((inner as any).type === 'SpecificResource') {\n const sourceId = typeof (inner as any).source === 'string' ? (inner as any).source : (inner as any).source.id;\n found.push({ id: sourceId, type: 'Canvas' });\n }\n }\n return found;\n}\n\nexport function findManifestSelectedRange(\n vault: Vault,\n manifest: ManifestNormalized,\n canvasId: string\n): null | RangeNormalized {\n for (const range of manifest.structures) {\n const found = findSelectedRange(vault, vault.get(range), canvasId);\n if (found) {\n return found;\n }\n }\n\n return null;\n}\n\nexport function findSelectedRange(vault: Vault, range: RangeNormalized, canvasId: string): null | RangeNormalized {\n for (const inner of range.items) {\n const parsedId = (inner as any)?.source?.id?.split('#')[0];\n if ((inner as any).type === 'SpecificResource' && (inner as any).source === canvasId) {\n return range;\n }\n if (inner.type === 'SpecificResource' && inner.source?.type === 'Canvas' && canvasId === parsedId) {\n return range;\n }\n if (inner.type === 'Range') {\n const found = findSelectedRange(vault, vault.get(inner), canvasId);\n if (found) {\n return found;\n }\n }\n }\n return null;\n}\n","import { CanvasNormalized, ManifestNormalized, RangeNormalized } from '@iiif/presentation-3-normalized';\nimport { Reference } from '@iiif/presentation-3';\nimport { Vault } from '@iiif/helpers/vault';\nimport { findAllCanvasesInRange } from './ranges';\n\n/**\n * Get visible canvases from canvas ID\n *\n * This function returns a list of canvas references that should all be displayed\n * when the passed canvasId is visible. This should work for individual items,\n * 2-up paged view and continuous (scrolls).\n *\n * The options are listed below (from IIIF docs)\n *\n * - `unordered` - Valid on Collections, Manifests and Ranges. The Canvases included in resources that have this behavior\n * have no inherent order, and user interfaces should avoid implying an order to the user. Disjoint with individuals,\n * continuous, and paged.\n *\n * - `individuals` - Valid on Collections, Manifests, and Ranges. For Collections that have this behavior, each of the\n * included Manifests are distinct objects in the given order. For Manifests and Ranges, the included Canvases are\n * distinct views, and should not be presented in a page-turning interface. This is the default layout behavior if\n * not specified. Disjoint with unordered, continuous, and paged.\n *\n * - `continuous` Valid on Collections, Manifests and Ranges, which include Canvases that have at least height and\n * width dimensions. Canvases included in resources that have this behavior are partial views and an appropriate\n * rendering might display all of the Canvases virtually stitched together, such as a long scroll split into\n * sections. This behavior has no implication for audio resources. The viewingDirection of the Manifest will\n * determine the appropriate arrangement of the Canvases. Disjoint with unordered, individuals and paged.\n *\n * - `paged` Valid on Collections, Manifests and Ranges, which include Canvases that have at least height and width\n * dimensions. Canvases included in resources that have this behavior represent views that should be presented in\n * a page-turning interface if one is available. The first canvas is a single view (the first recto) and thus the\n * second canvas likely represents the back of the object in the first canvas. If this is not the case, see the\n * behavior value non-paged. Disjoint with unordered, individuals, continuous, facing-pages and non-paged.\n *\n */\nexport function getVisibleCanvasesFromCanvasId(\n vault: Vault,\n manifestOrRange: ManifestNormalized | RangeNormalized,\n canvasId: string | null,\n preventPaged = false\n): Reference<'Canvas'>[] {\n const behavior = manifestOrRange.behavior;\n const fullCanvas = canvasId ? vault.get<CanvasNormalized>(canvasId) : null;\n if (!fullCanvas) {\n return [];\n }\n\n const canvasBehavior = fullCanvas.behavior;\n const isPaged = preventPaged ? false : behavior.includes('paged');\n const isContinuous = isPaged ? false : behavior.includes('continuous');\n const isIndividuals = isPaged || isContinuous ? false : behavior.includes('individuals');\n const isCanvasFacingPages = canvasBehavior.includes('facing-pages');\n const isCanvasNonPaged = canvasBehavior.includes('non-paged');\n\n // Individuals should just be the default.\n if (isCanvasFacingPages || isCanvasNonPaged || isIndividuals || preventPaged) {\n return [{ id: fullCanvas.id, type: 'Canvas' }];\n }\n\n const [manifestItems, ordering] = getManifestSequence(vault, manifestOrRange);\n\n // Continuous should just return all items together.\n if (isContinuous) {\n return manifestItems;\n }\n\n const canvasIndex = manifestItems.findIndex((r) => r.id === canvasId);\n if (canvasIndex === -1) {\n return [];\n }\n\n for (const indexes of ordering) {\n if (indexes.includes(canvasIndex)) {\n return indexes.map((index) => manifestItems[index]);\n }\n }\n\n return [{ id: fullCanvas.id, type: 'Canvas' }];\n}\n\nexport function getManifestSequence(\n vault: Vault,\n manifestOrRange: ManifestNormalized | RangeNormalized,\n { disablePaging, skipNonPaged }: { disablePaging?: boolean; skipNonPaged?: boolean } = {}\n): [Reference<'Canvas'>[], number[][]] {\n const behavior = manifestOrRange.behavior;\n const isPaged = behavior.includes('paged');\n const isContinuous = isPaged ? false : behavior.includes('continuous');\n const isIndividuals = isPaged || isContinuous ? false : behavior.includes('individuals');\n const manifestItems =\n manifestOrRange.type === 'Manifest' ? manifestOrRange.items : findAllCanvasesInRange(vault, manifestOrRange);\n\n // Continuous should just return all items together.\n if (isContinuous) {\n return [manifestItems, [manifestItems.map((_, index) => index)]];\n }\n\n // Individuals should just be the default.\n if (isIndividuals || !isPaged || disablePaging) {\n return [manifestItems, manifestItems.map((_, index) => [index])];\n }\n\n // This is the tricky case.\n const ordering: number[][] = [];\n let currentOrdering: number[] = [];\n\n const flush = () => {\n if (currentOrdering.length) {\n ordering.push([...currentOrdering]);\n currentOrdering = [];\n }\n };\n\n let offset = 0;\n let flushNextPaged = false;\n for (let i = 0; i < manifestItems.length; i++) {\n const canvas = vault.get<CanvasNormalized>(manifestItems[i]);\n if (canvas.behavior.includes('non-paged')) {\n if (i === offset) {\n offset++;\n }\n if (!skipNonPaged) {\n flush();\n ordering.push([i]);\n flush();\n }\n continue;\n }\n\n if (i === offset || canvas.behavior.includes('facing-pages')) {\n // Flush and push a single.\n if (currentOrdering.length) {\n flushNextPaged = true;\n }\n flush();\n ordering.push([i]);\n flush();\n continue;\n }\n\n currentOrdering.push(i);\n\n if (flushNextPaged) {\n flush();\n flushNextPaged = false;\n continue;\n }\n\n if (currentOrdering.length > 1) {\n flush();\n }\n }\n\n if (currentOrdering.length) {\n flush();\n }\n\n return [manifestItems, ordering];\n}\n","// This is valid under a range context.\nimport { useResourceContext } from '../context/ResourceContext';\nimport { RangeNormalized } from '@iiif/presentation-3-normalized';\nimport { useMemo } from 'react';\nimport { useVaultSelector } from './useVaultSelector';\n\nexport function useRange(options?: { id: string }): RangeNormalized | undefined;\nexport function useRange<T>(\n options?: { id: string; selector: (range: RangeNormalized) => T },\n deps?: any[]\n): T | undefined;\nexport function useRange<T = RangeNormalized>(\n options: {\n id?: string;\n selector?: (range: RangeNormalized) => T;\n } = {},\n deps: any[] = []\n): RangeNormalized | T | undefined {\n const { id, selector } = options;\n const ctx = useResourceContext();\n const rangeId = id ? id : ctx.range;\n\n const range = useVaultSelector((s) => (rangeId ? s.iiif.entities.Range[rangeId] : undefined), [rangeId]);\n\n return useMemo(() => {\n if (!range) {\n return undefined;\n }\n if (selector) {\n return selector(range);\n }\n return range;\n }, [range, selector, ...deps]);\n}\n","import { getManifestSequence } from '../future-helpers/sequences';\nimport { useManifest } from '../hooks/useManifest';\nimport { useCallback, useMemo, useRef, useState } from 'react';\nimport { useRange } from '../hooks/useRange';\nimport { useVault } from '../hooks/useVault';\n\nexport function useCanvasSequence({ startCanvas, disablePaging }: { startCanvas?: string; disablePaging?: boolean }) {\n const vault = useVault();\n const manifest = useManifest();\n const range = useRange();\n const [cursor, setCursor] = useState<number>(undefined as any);\n const rangeOrManifest = range ? range : manifest;\n\n if (!rangeOrManifest) {\n throw new Error('Nothing selected');\n }\n\n const [items, initialSequence] = useMemo(\n () => getManifestSequence(vault, rangeOrManifest, { disablePaging }),\n [vault, rangeOrManifest, disablePaging]\n );\n const lastSequence = useRef(initialSequence);\n\n if (lastSequence.current !== initialSequence) {\n const prev = lastSequence.current;\n const prevItem = prev[cursor][0];\n const nextItem = initialSequence.findIndex((i) => i.includes(prevItem));\n lastSequence.current = initialSequence;\n setCursor(nextItem);\n }\n\n const setCanvasIndex = useCallback(\n (index: number) => {\n const foundSequence = initialSequence.findIndex((i) => i.includes(index));\n setCursor(foundSequence === -1 ? 0 : foundSequence);\n },\n [items, initialSequence]\n );\n\n const setCanvasId = useCallback(\n (id: string) => {\n const foundIndex = items.findIndex((i) => i.id === id);\n if (foundIndex !== -1) {\n setCanvasIndex(foundIndex);\n } else {\n setCursor(0);\n }\n },\n [items, initialSequence]\n );\n\n const next = useCallback(() => {\n setCursor((i) => {\n if (i >= initialSequence.length - 1) {\n return i;\n }\n return i + 1;\n });\n }, [initialSequence]);\n\n const previous = useCallback(() => {\n setCursor((i) => {\n if (i <= 0) {\n return 0;\n }\n return i - 1;\n });\n }, [initialSequence]);\n\n // Need to set an initial cursor from the canvasId (if it's valid)\n if (typeof cursor === 'undefined') {\n if (startCanvas) {\n setCanvasId(startCanvas);\n } else {\n setCursor(0);\n }\n }\n\n return {\n visibleItems: initialSequence[cursor]?.map((idx) => items[idx].id) || [],\n cursor,\n items,\n sequence: initialSequence,\n hasPrevious: cursor > 0,\n hasNext: cursor < initialSequence.length - 1,\n setSequenceIndex: setCursor,\n setCanvasIndex,\n setCanvasId,\n next,\n previous,\n };\n}\n","import React, { ReactNode, useCallback, useContext, useEffect, useRef } from 'react';\n/**\n * Simple viewer context\n * *****************************************************************************\n *\n * This will be the context to use to get a basic IIIF viewer up and running.\n * It will not focus on having compatibility with the full range of IIIF\n * resources, instead offering a viewer for a Manifest, cycling through canvases\n * while ignoring the paged/facing-pages/continuous behaviors.\n *\n * There will not be support for canvas-on-canvas annotations. Annotations will\n * be filtered, giving details of the canvas space and images to be annotated\n * onto that space. The demo implementation of this viewer will use\n * OpenSeadragon to display.\n *\n * Navigation functions will include the basics:\n * - nextCanvas()\n * - previousCanvas()\n * - goToCanvas(id)\n * - goToCanvasIndex(idx)\n * - goToFirstCanvas()\n * - goToLastCanvas()\n *\n * It will take in only a Manifest ID and will load that Manifest when the\n * context loads.\n *\n * There will be no support for external or embedded annotation lists, although\n * you can set up a nested context to support this.\n *\n * There will be no support for ranges in this view.\n *\n * To use this component, first you will need the provider:\n * import { SimpleViewerProvider } from '...';\n *\n * <SimpleViewerProvider id=\"http://example.org/manifest.json\">\n * <CustomComponent />\n * </SimpleViewerProvider>\n *\n * This is in addition to the core Vault context further up the tree.\n *\n * In components that you want to use parts of the state you can grab the hooks\n * from this file.\n *\n * import { useSimpleViewer } from '...';\n *\n * And use them in your components to get the actions.\n *\n * function NextButton() {\n * const { nextCanvas } = useSimpleViewer();\n *\n * return <button onClick={nextCanvas}>Next</button>;\n * }\n *\n * Since this is a single-context, there is only ever one manifest, canvas and\n * annotation list. You can access the current resource using the normal hooks.\n *\n * function CanvasMetadata() {\n * const metadata = useCanvas(metadataSelector);\n *\n * return <div> ... </div>\n * }\n *\n * So long as this is inside the provider, it will have the correct context.\n */\nimport { createContext, FC, useMemo, useState } from 'react';\nimport { useExternalManifest } from '../hooks/useExternalManifest';\nimport { ManifestContext } from '../context/ManifestContext';\nimport { CanvasContext } from '../context/CanvasContext';\nimport { VisibleCanvasReactContext } from '../context/VisibleCanvasContext';\nimport { useManifest } from '../hooks/useManifest';\nimport { SimpleViewerContext, SimpleViewerProps } from './SimpleViewerContext.types';\nimport { RangeContext } from '../context/RangeContext';\nimport { useCanvasSequence } from './SimpleViewerContext.hooks';\nimport { VaultProvider } from '../context/VaultContext';\nimport { useExistingVault } from '../hooks/useExistingVault';\n\nconst noop = () => {\n //\n};\n\nexport const SimpleViewerReactContext = createContext<SimpleViewerContext>({\n setCurrentCanvasId: noop,\n setCurrentCanvasIndex: noop,\n nextCanvas: noop,\n previousCanvas: noop,\n items: [],\n sequence: [],\n setSequenceIndex: noop,\n currentSequenceIndex: 0,\n hasNext: false,\n hasPrevious: false,\n});\n\nexport function InnerViewerProvider(props: SimpleViewerProps) {\n const manifest = useManifest();\n const {\n cursor,\n visibleItems,\n next,\n sequence,\n items,\n setCanvasIndex,\n setCanvasId,\n previous,\n setSequenceIndex,\n hasNext,\n hasPrevious,\n } = useCanvasSequence({\n startCanvas: props.startCanvas,\n disablePaging: props.pagingEnabled === false,\n });\n\n const ctx = useMemo(\n () =>\n ({\n sequence,\n items,\n // Extra functions.\n setCurrentCanvasId: setCanvasId,\n nextCanvas: next,\n previousCanvas: previous,\n totalCanvases: items.length,\n setCurrentCanvasIndex: setCanvasIndex,\n setSequenceIndex: setSequenceIndex,\n currentSequenceIndex: cursor,\n hasNext,\n hasPrevious,\n } as SimpleViewerContext),\n [sequence, items, setCanvasId, next, previous, items, setCanvasIndex, setSequenceIndex, cursor]\n );\n\n if (!manifest) {\n console.warn('The manifest passed to the provider is not a valid IIIF manifest.');\n return <div>Sorry, something went wrong.</div>;\n }\n\n if (visibleItems.length === 0) {\n return null;\n }\n\n return (\n <SimpleViewerReactContext.Provider value={ctx}>\n <VisibleCanvasReactContext.Provider value={visibleItems}>\n <CanvasContext canvas={visibleItems[0]}>{props.children}</CanvasContext>\n </VisibleCanvasReactContext.Provider>\n </SimpleViewerReactContext.Provider>\n );\n}\n\nexport function SimpleViewerProvider(props: SimpleViewerProps) {\n const vault = useExistingVault(props.vault);\n const manifest = useExternalManifest(props.manifest);\n\n if (!manifest) {\n console.warn('The manifest passed to the provider is not a valid IIIF manifest.');\n return <div>Sorry, something went wrong.</div>;\n }\n\n if (manifest.error) {\n return <div>{manifest.error.toString()}</div>;\n }\n\n if (!manifest.isLoaded) {\n return <div>Loading...</div>;\n }\n\n const inner = <InnerViewerProvider {...props}>{props.children}</InnerViewerProvider>;\n\n return (\n <VaultProvider vault={vault}>\n <ManifestContext manifest={manifest.id}>\n {props.rangeId ? <RangeContext range={props.rangeId}>{inner}</RangeContext> : inner}\n </ManifestContext>\n </VaultProvider>\n );\n}\n\nexport function useSimpleViewer() {\n return useContext(SimpleViewerReactContext);\n}\n","import React, { ReactNode, useContext } from 'react';\nimport { ResourceReactContext } from './ResourceContext';\nimport { ReactVaultContext, VaultProvider } from './VaultContext';\nimport { SimpleViewerReactContext } from '../viewers/SimpleViewerContext';\nimport { VisibleCanvasReactContext } from './VisibleCanvasContext';\n\nexport function useContextBridge() {\n return {\n VaultContext: useContext(ReactVaultContext),\n ResourceContext: useContext(ResourceReactContext),\n SimpleViewerReactContext: useContext(SimpleViewerReactContext),\n VisibleCanvasReactContext: useContext(VisibleCanvasReactContext),\n };\n}\n\nexport function ContextBridge(props: { bridge: ReturnType<typeof useContextBridge>; children: ReactNode }) {\n return (\n <VaultProvider vault={props.bridge.VaultContext.vault || undefined} resources={props.bridge.ResourceContext}>\n <VisibleCanvasReactContext.Provider value={props.bridge.VisibleCanvasReactContext}>\n <SimpleViewerReactContext.Provider value={props.bridge.SimpleViewerReactContext}>\n {props.children}\n </SimpleViewerReactContext.Provider>\n </VisibleCanvasReactContext.Provider>\n </VaultProvider>\n );\n}\n","const E = function(t) {\n return function() {\n const n = { type: t, getType: () => t, toString: () => t };\n return (i, R) => ({\n ...n,\n ...i !== void 0 && { payload: i },\n ...R !== void 0 && { meta: R }\n });\n };\n}, o = \"@iiif/IMPORT_ENTITIES\", c = \"@iiif/MODIFY_ENTITY_FIELD\", s = \"@iiif/REORDER_ENTITY_FIELD\", A = \"@iiif/ADD_REFERENCE\", T = \"@iiif/UPDATE_REFERENCE\", e = \"@iiif/REMOVE_REFERENCE\", _ = \"@iiif/ADD_METADATA\", M = \"@iiif/REMOVE_METADATA\", D = \"@iiif/UPDATE_METADATA\", O = \"@iiif/REORDER_METADATA\", S = E(o)(), a = E(c)(), r = E(s)(), I = E(A)(), U = E(e)(), f = E(T)(), C = E(_)(), N = E(D)(), d = E(M)(), u = E(O)(), J = {\n importEntities: S,\n modifyEntityField: a,\n reorderEntityField: r,\n addReference: I,\n removeReference: U,\n updateReference: f,\n addMetadata: C,\n removeMetadata: d,\n updateMetadata: N,\n reorderMetadata: u\n}, F = \"@iiif/ADD_MAPPING\", P = \"@iiif/ADD_MAPPINGS\", L = E(F)(), V = E(P)(), K = { addMapping: L, addMappings: V }, p = \"@iiif/SET_META_VALUE\", Q = \"@iiif/SET_META_VALUE_DYNAMIC\", Y = \"@iiif/UNSET_META_VALUE\", m = E(p)(), l = E(Q)(), q = E(Y)(), W = {\n setMetaValue: m,\n setMetaValueDynamic: l,\n unsetMetaValue: q\n}, X = \"RESOURCE_ERROR\", Z = \"RESOURCE_LOADING\", $ = \"RESOURCE_READY\", G = \"@iiif/REQUEST_RESOURCE\", H = \"@iiif/REQUEST_ERROR\", g = \"@iiif/REQUEST_MISMATCH\", v = \"@iiif/REQUEST_COMPLETE\", B = \"@iiif/REQUEST_OFFLINE_RESOURCE\", b = E(G)(), h = E(H)(), y = E(g)(), x = E(v)(), j = E(B)(), EE = {\n requestResource: b,\n requestError: h,\n requestMismatch: y,\n requestComplete: x,\n requestOfflineResource: j\n}, k = \"@iiif/BATCH\", w = \"@iiif/BATCH_IMPORT\", tE = E(k)(), iE = E(w)();\nexport {\n F as ADD_MAPPING,\n P as ADD_MAPPINGS,\n _ as ADD_METADATA,\n A as ADD_REFERENCE,\n k as BATCH_ACTIONS,\n w as BATCH_IMPORT,\n o as IMPORT_ENTITIES,\n c as MODIFY_ENTITY_FIELD,\n M as REMOVE_METADATA,\n e as REMOVE_REFERENCE,\n s as REORDER_ENTITY_FIELD,\n O as REORDER_METADATA,\n v as REQUEST_COMPLETE,\n H as REQUEST_ERROR,\n g as REQUEST_MISMATCH,\n B as REQUEST_OFFLINE_RESOURCE,\n G as REQUEST_RESOURCE,\n X as RESOURCE_ERROR,\n Z as RESOURCE_LOADING,\n $ as RESOURCE_READY,\n p as SET_META_VALUE,\n Q as SET_META_VALUE_DYNAMIC,\n Y as UNSET_META_VALUE,\n D as UPDATE_METADATA,\n T as UPDATE_REFERENCE,\n L as addMapping,\n V as addMappings,\n C as addMetadata,\n I as addReference,\n tE as batchActions,\n iE as batchImport,\n J as entityActions,\n S as importEntities,\n K as mappingActions,\n W as metaActions,\n a as modifyEntityField,\n d as removeMetadata,\n U as removeReference,\n r as reorderEntityField,\n u as reorderMetadata,\n EE as requestActions,\n x as requestComplete,\n h as requestError,\n y as requestMismatch,\n j as requestOfflineResource,\n b as requestResource,\n N as updateMetadata,\n f as updateReference\n};\n//# sourceMappingURL=vault-actions.mjs.map\n","import { useVault } from './useVault';\nimport { useMemo } from 'react';\nimport { VaultZustandStore } from '@iiif/helpers/vault/store';\n\nexport function useDispatch(): VaultZustandStore['dispatch'] {\n const vault = useVault();\n const store = vault.getStore();\n\n return useMemo(() => {\n return (action: any) => store.dispatch(action);\n }, [store]);\n}\n","import { useCallback, useLayoutEffect, useMemo, useRef } from 'react';\nimport { Annotation } from '@iiif/presentation-3';\nimport { AnnotationNormalized, AnnotationPageNormalized } from '@iiif/presentation-3-normalized';\nimport { useVault } from './useVault';\nimport { useVaultSelector } from './useVaultSelector';\nimport { entityActions } from '@iiif/helpers/vault/actions';\nimport { useDispatch } from './useDispatch';\nimport { Vault } from '@iiif/helpers/vault';\n\nexport interface VaultActivatedAnnotation {\n __vault?: Vault;\n bindToVault(vault: Vault): void;\n source: string | { id: string };\n}\n\nfunction isVaultActivated(obj: any): obj is VaultActivatedAnnotation {\n return typeof obj !== 'string' && obj && obj.bindToVault;\n}\n\nexport function useVirtualAnnotationPage() {\n const vault = useVault();\n const sources = useRef<Record<any, any>>([]);\n const dispatch = useDispatch();\n const virtualId = useMemo(() => {\n return `vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random() * 1000000000).toString(16)}`;\n }, []);\n\n useLayoutEffect(() => {\n const page: AnnotationPageNormalized = {\n id: virtualId,\n type: 'AnnotationPage',\n behavior: [],\n label: null,\n thumbnail: [],\n summary: null,\n requiredStatement: null,\n metadata: [],\n rights: null,\n provider: [],\n items: [],\n seeAlso: [],\n homepage: [],\n rendering: [],\n service: [],\n };\n\n dispatch(\n entityActions.importEntities({\n entities: {\n AnnotationPage: {\n [page.id]: page,\n },\n },\n })\n );\n }, [virtualId]);\n\n const fullPage: AnnotationPageNormalized | null = useVaultSelector(\n (state) => (virtualId ? state.iiif.entities.AnnotationPage[virtualId] : null),\n [virtualId]\n );\n\n const addAnnotation = useCallback(\n (id: string | Annotation | VaultActivatedAnnotation | AnnotationNormalized, atIndex?: number) => {\n if (virtualId) {\n if (isVaultActivated(id)) {\n const display = id;\n if (!display.__vault) {\n // First bind to vault.\n display.bindToVault(vault);\n }\n id = typeof display.source === 'string' ? display.source : display.source.id;\n sources.current[id] = display;\n } else if (typeof id !== 'string') {\n id = id.id;\n }\n\n const full: AnnotationPageNormalized = vault.get({ id: virtualId, type: 'AnnotationPage' });\n const annotation: AnnotationNormalized = vault.get({ id, type: 'Annotation' });\n if (full && annotation) {\n if (!full.items.find((r: any) => r.id === annotation.id)) {\n dispatch(\n entityActions.addReference({\n id: virtualId,\n type: 'AnnotationPage',\n key: 'items',\n reference: {\n id,\n type: 'Annotation',\n },\n index: atIndex,\n })\n );\n }\n }\n }\n },\n [virtualId]\n );\n const removeAnnotation = useCallback(\n (id: string | Annotation | VaultActivatedAnnotation | AnnotationNormalized) => {\n if (virtualId) {\n if (isVaultActivated(id)) {\n id = typeof id.source === 'string' ? id.source : id.source.id;\n } else if (typeof id !== 'string') {\n id = id.id;\n }\n\n if (sources.current[id]) {\n sources.current[id].beforeRemove();\n }\n\n const full: AnnotationPageNormalized = vault.get({ id: virtualId, type: 'AnnotationPage' });\n if (full) {\n dispatch(\n entityActions.removeReference({\n id: virtualId,\n type: 'AnnotationPage',\n key: 'items',\n reference: {\n id,\n type: 'Annotation',\n },\n })\n );\n }\n }\n },\n [virtualId]\n );\n\n return [\n fullPage,\n {\n addAnnotation,\n removeAnnotation,\n },\n ] as const;\n}\n","import { Annotation } from '@iiif/presentation-3';\nimport { AnnotationNormalized, AnnotationPageNormalized } from '@iiif/presentation-3-normalized';\nimport React, { createContext, useContext, useMemo } from 'react';\nimport { useVirtualAnnotationPage, VaultActivatedAnnotation } from './useVirtualAnnotationPage';\n\nconst VirtualAnnotationPageContext = createContext<{\n fullPage: AnnotationPageNormalized | null;\n addAnnotation: (\n id: string | Annotation | VaultActivatedAnnotation | AnnotationNormalized,\n atIndex?: number | undefined\n ) => void;\n removeAnnotation: (id: string | Annotation | VaultActivatedAnnotation | AnnotationNormalized) => void;\n} | null>(null);\n\nexport function useVirtualAnnotationPageContext() {\n const ctx = useContext(VirtualAnnotationPageContext);\n\n return [\n ctx!.fullPage,\n {\n addAnnotation: ctx!.addAnnotation,\n removeAnnotation: ctx!.removeAnnotation,\n },\n ] as const;\n}\n\nexport function VirtualAnnotationProvider({ children }: { children: any }) {\n const [fullPage, { addAnnotation, removeAnnotation }] = useVirtualAnnotationPage();\n\n return (\n <VirtualAnnotationPageContext.Provider\n value={useMemo(() => ({ fullPage, addAnnotation, removeAnnotation }), [fullPage])}\n >\n {children}\n </VirtualAnnotationPageContext.Provider>\n );\n}\n","import React from 'react';\nimport { FallbackProps } from 'react-error-boundary';\n\nexport function DefaultCanvasFallback({\n width,\n style,\n height,\n error,\n resetErrorBoundary,\n}: { width?: number; height?: number; style?: any } & FallbackProps) {\n return (\n <div style={{ width, height, minHeight: 500, ...(style || {}), background: '#f9f9f9' }}>\n <h3>Error occurred</h3>\n <p>{error.message}</p>\n <button onClick={resetErrorBoundary}>Reset</button>\n </div>\n );\n}\n","import { createContext, useContext } from 'react';\nimport { Preset } from '@atlas-viewer/atlas';\n\nexport const ViewerPresetContext = createContext<Preset | null | undefined>(null);\n\nexport function useViewerPreset() {\n return useContext(ViewerPresetContext);\n}\n","import { createContext, useContext, useEffect } from 'react';\n\nexport const SetOverlaysReactContext = createContext<(key: string, element: any | null, props?: any) => void>(\n () => void 0\n);\nexport const SetPortalReactContext = createContext<(key: string, element: any | null, props?: any) => void>(\n () => void 0\n);\n\nexport function useOverlay(\n type: 'portal' | 'overlay' | 'none',\n key: string,\n element: any,\n props: any,\n deps: any[] = []\n) {\n const setOverlay = useContext(type === 'portal' ? SetPortalReactContext : SetOverlaysReactContext);\n\n useEffect(() => {\n if (type !== 'none') {\n setOverlay(key, element, props);\n }\n return () => {\n setOverlay(key, null);\n };\n }, [key, type, setOverlay, ...deps]);\n}\n","import { useResourceContext } from '../context/ResourceContext';\nimport { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { useMemo } from 'react';\nimport { useVaultSelector } from './useVaultSelector';\n\nexport function useCanvas(options?: { id: string }): CanvasNormalized | undefined;\nexport function useCanvas<T>(\n options?: { id: string; selector: (canvas: CanvasNormalized) => T },\n deps?: any[]\n): T | undefined;\nexport function useCanvas<T = CanvasNormalized>(\n options: {\n id?: string;\n selector?: (canvas: CanvasNormalized) => T;\n } = {},\n deps: any[] = []\n): CanvasNormalized | T | undefined {\n const { id, selector } = options;\n const ctx = useResourceContext();\n const canvasId = id ? id : ctx.canvas;\n\n const canvas = useVaultSelector((s) => (canvasId ? s.iiif.entities.Canvas[canvasId] : undefined), [canvasId]);\n\n return useMemo(() => {\n if (!canvas) {\n return undefined;\n }\n if (selector) {\n return selector(canvas);\n }\n return canvas;\n }, [canvas, selector, ...deps]);\n}\n","import { createContext, useContext, useEffect } from 'react';\nimport { useCanvas } from '../../hooks/useCanvas';\n\nexport const WorldSizeContext = createContext<(canvasId: string, size: number) => void>(() => void 0);\n\nexport function useWorldSize(size: number) {\n const canvas = useCanvas();\n const fn = useContext(WorldSizeContext);\n\n useEffect(() => {\n if (canvas && canvas.id) {\n fn(canvas.id, size);\n\n return () => fn(canvas.id, -1);\n }\n\n return () => void 0;\n }, [canvas, size]);\n}\n","import React, { ReactNode, useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react';\nimport { AtlasAuto, Preset, AtlasProps, ModeContext } from '@atlas-viewer/atlas';\nimport { ErrorBoundary } from 'react-error-boundary';\nimport { ContextBridge, useContextBridge } from '../context/ContextBridge';\nimport { VirtualAnnotationProvider } from '../hooks/useVirtualAnnotationPageContext';\nimport { DefaultCanvasFallback } from './render/DefaultCanvasFallback';\nimport { ViewerPresetContext } from '../context/ViewerPresetContext';\nimport { SetOverlaysReactContext, SetPortalReactContext } from './context/overlays';\nimport { WorldSizeContext } from './context/world-size';\nimport { useCanvas } from '../hooks/useCanvas';\n\nexport function Viewer({\n children,\n errorFallback,\n outerContainerProps = {},\n worldScale: _worldScale,\n ...props\n}: AtlasProps & {\n height?: number | string;\n width?: number | string;\n resizeHash?: number;\n containerProps?: any;\n outerContainerProps?: any;\n aspectRatio?: number;\n errorFallback?: any;\n worldScale?: number;\n} & { children: ReactNode }) {\n const [viewerPreset, setViewerPreset] = useState<Preset | null>();\n const bridge = useContextBridge();\n const ErrorFallback: any = errorFallback || DefaultCanvasFallback;\n const [overlays, setOverlays] = useState<Record<string, any>>({});\n const overlayComponents = Object.entries(overlays);\n const [portals, setPortals] = useState<Record<string, any>>({});\n const portalComponents = Object.entries(portals);\n const [worldSizes, setWorldSizes] = useState<Record<string, number>>({});\n const worldScale = useMemo(() => {\n return _worldScale || Math.max(...Object.values(worldSizes));\n }, [worldSizes]);\n const runtimeOptions = useMemo(() => {\n return { maxOverZoom: worldScale || 1, ...(props.runtimeOptions || {}) };\n }, [worldScale, props.runtimeOptions]);\n\n const updateWorldSize = useCallback((canvasId: string, size: number) => {\n setWorldSizes((sizes) => {\n if (size === -1) {\n const { [canvasId]: _, ...rest } = sizes;\n return rest;\n }\n return { ...sizes, [canvasId]: size };\n });\n }, []);\n\n const updateOverlay = useCallback((key: string, element: ReactNode, props: any) => {\n setOverlays(({ [key]: _, ...prev }) => {\n if (!element) {\n return prev;\n }\n\n return {\n ...prev,\n [key]: { element, props },\n };\n });\n }, []);\n\n const updatePortal = useCallback((key: string, element: ReactNode, props: any) => {\n setPortals(({ [key]: _, ...prev }) => {\n if (!element) {\n return prev;\n }\n\n return {\n ...prev,\n [key]: { element, props },\n };\n });\n }, []);\n\n return (\n <ErrorBoundary resetKeys={[]} fallbackRender={(fallbackProps) => <ErrorFallback {...props} {...fallbackProps} />}>\n <AtlasAuto\n {...props}\n containerProps={{ style: { position: 'relative' }, ...(props.containerProps || {}) }}\n htmlChildren={\n <>\n {overlayComponents.map(([key, { element: Element, props }]) => (\n <React.Fragment key={key}>\n <Element {...(props || {})} />\n </React.Fragment>\n ))}\n </>\n }\n onCreated={(preset: any) => {\n setViewerPreset(preset);\n if (props.onCreated) {\n props.onCreated(preset);\n }\n }}\n runtimeOptions={runtimeOptions}\n >\n <ViewerPresetContext.Provider value={viewerPreset}>\n <WorldSizeContext.Provider value={updateWorldSize}>\n <SetOverlaysReactContext.Provider value={updateOverlay}>\n <SetPortalReactContext.Provider value={updatePortal}>\n <ContextBridge bridge={bridge}>\n <ModeContext.Provider value={props.mode || 'explore'}>\n <VirtualAnnotationProvider>{children}</VirtualAnnotationProvider>\n </ModeContext.Provider>\n </ContextBridge>\n </SetPortalReactContext.Provider>\n </SetOverlaysReactContext.Provider>\n </WorldSizeContext.Provider>\n </ViewerPresetContext.Provider>\n </AtlasAuto>\n <div>\n {portalComponents.map(([key, { element: Element, props }]) => (\n <React.Fragment key={key}>\n <Element {...(props || {})} />\n </React.Fragment>\n ))}\n </div>\n </ErrorBoundary>\n );\n}\n","const a = {}, i = {\n get(n) {\n return n;\n },\n setMetaValue([n, e, r], t) {\n const o = i.getResourceMeta(n, e), c = o ? o[r] : void 0, s = typeof t == \"function\" ? t(c) : t;\n a[n] = {\n ...a[n] || {},\n [e]: {\n ...(a[n] || {})[e] || {},\n [r]: s\n }\n };\n },\n getResourceMeta: (n, e) => {\n const r = a[n];\n if (r)\n return e ? r[e] : r;\n }\n};\nfunction M(n = i) {\n return {\n addEventListener(e, r, t, o) {\n if (e)\n return n.setMetaValue(\n [e.id, \"eventManager\", r],\n (c) => {\n const s = c || [];\n for (const f of s)\n if (f.callback === t)\n return s;\n return [...s, { callback: t, scope: o }];\n }\n ), t;\n },\n removeEventListener(e, r, t) {\n e && n.setMetaValue(\n [e.id, \"eventManager\", r],\n (o) => (o || []).filter((c) => c.callback !== t)\n );\n },\n getListenersAsProps(e, r) {\n const t = typeof e == \"string\" ? { id: e } : e;\n if (!t || !t.id)\n return {};\n const o = n.getResourceMeta(t.id, \"eventManager\"), c = {};\n if (o && t)\n for (const s of Object.keys(o))\n c[s] = (f) => {\n const l = n.get(t);\n for (const { callback: g, scope: u } of o[s] || [])\n (!u || r && u.indexOf(r) !== -1) && g(f, l);\n };\n return c;\n }\n };\n}\nexport {\n M as createEventsHelper\n};\n//# sourceMappingURL=events.mjs.map\n","import { useVault } from './useVault';\nimport { useVaultSelector } from './useVaultSelector';\nimport { useMemo } from 'react';\nimport { NormalizedEntity } from '@iiif/helpers/vault';\nimport { Reference } from '@iiif/presentation-3';\nimport { createEventsHelper } from '@iiif/helpers/events';\n\nexport function useResourceEvents<T extends NormalizedEntity>(resource?: Reference, scope?: string[]) {\n const vault = useVault();\n const helper = useMemo(() => createEventsHelper(vault), [vault]);\n\n const hooks = useVaultSelector(() => {\n if (resource && resource.id) {\n return vault.getResourceMeta(resource.id, 'eventManager');\n }\n return null;\n }, [resource]);\n\n return useMemo(() => {\n return resource ? helper.getListenersAsProps(resource, scope) : {};\n }, [hooks, resource, vault, scope]);\n}\n","import { useVault } from './useVault';\nimport { useMemo } from 'react';\nimport { Reference } from '@iiif/presentation-3';\nimport { createStylesHelper } from '@iiif/helpers/styles';\nimport { useVaultSelector } from './useVaultSelector';\n\nexport function useStyles<Style extends Record<string, Record<string, any>>>(\n resource: undefined | Reference<any>\n): Style;\nexport function useStyles<Style extends Record<string, any>>(\n resource: undefined | Reference<any>,\n scope: string\n): Style;\nexport function useStyles<Style>(resource?: Reference, scope?: string): Style {\n const vault = useVault();\n const helper = useMemo(() => createStylesHelper(vault), [vault]);\n\n return useVaultSelector(() => {\n if (!resource) {\n return null;\n }\n\n const styles = helper.getAppliedStyles(resource.id);\n return styles ? (scope ? styles[scope] : styles) : undefined;\n }, [resource, scope]) as Style;\n}\n","import { useResourceContext } from '../context/ResourceContext';\nimport { AnnotationNormalized } from '@iiif/presentation-3-normalized';\nimport { useMemo } from 'react';\nimport { useVaultSelector } from './useVaultSelector';\nimport { expandTarget } from '@iiif/helpers/annotation-targets';\nimport { useVault } from './useVault';\n\nexport function useAnnotation(options?: { id: string }): AnnotationNormalized | undefined;\nexport function useAnnotation<T>(\n options?: { id: string; selector: (annotation: AnnotationNormalized) => T },\n deps?: any[]\n): T | undefined;\nexport function useAnnotation<T = AnnotationNormalized>(\n options: {\n id?: string;\n selector?: (annotation: AnnotationNormalized) => T;\n } = {},\n deps: any[] = []\n): AnnotationNormalized | T | undefined {\n const { id, selector } = options;\n const ctx = useResourceContext();\n const vault = useVault();\n const annotationId = id ? id : ctx.annotation;\n\n const annotation = useVaultSelector(\n (s) => (annotationId ? s.iiif.entities.Annotation[annotationId] : undefined),\n [annotationId]\n );\n\n const body = useVaultSelector(\n (s) =>\n annotation && annotation.body\n ? annotation.body\n .map((singleBody) => {\n if (!singleBody) {\n return null;\n }\n\n if ((singleBody as any).type === 'SpecificResource') {\n return {\n ...singleBody,\n source: vault.get(singleBody),\n };\n }\n\n return singleBody ? s.iiif.entities[singleBody.type][singleBody.id] : null;\n })\n .filter(Boolean)\n : [],\n [annotation]\n );\n\n return useMemo(() => {\n if (!annotation) {\n return undefined;\n }\n\n const newAnnotation: any = {\n ...annotation,\n body,\n target: expandTarget(annotation.target as any, { typeMap: vault.getState().iiif.mapping }),\n };\n\n if (selector) {\n return selector(newAnnotation);\n }\n return newAnnotation;\n }, [annotation, selector, body, ...deps]);\n}\n","import { BoxStyle, HTMLPortal, mergeStyles, RegionHighlight } from '@atlas-viewer/atlas';\nimport { useResourceEvents } from '../../hooks/useResourceEvents';\nimport { useStyles } from '../../hooks/useStyles';\nimport React, { FC, useMemo } from 'react';\nimport { useAnnotation } from '../../hooks/useAnnotation';\nimport { useCanvas } from '../../hooks/useCanvas';\n\nexport const RenderAnnotation: FC<{ id: string; className?: string; style?: BoxStyle; interactive?: boolean }> = ({\n id,\n style: defaultStyle,\n className,\n interactive,\n}) => {\n const annotation = useAnnotation({ id });\n const style = useStyles<BoxStyle>(annotation, 'atlas');\n const html = useStyles<{ className?: string; href?: string; title?: string; target?: string }>(annotation, 'html');\n const events = useResourceEvents(annotation as any, ['atlas']);\n const canvas = useCanvas();\n\n const allStyles = useMemo(() => {\n return mergeStyles(defaultStyle, style);\n }, [defaultStyle, style]);\n\n const isValid =\n canvas &&\n annotation &&\n annotation.target &&\n (annotation.target as any).selector &&\n (annotation.target as any).selector.type === 'BoxSelector' &&\n (annotation.target as any).source &&\n ((annotation.target as any).source.id === canvas.id || (annotation.target as any).source === canvas.id);\n\n if (!isValid) {\n return null;\n }\n\n return (\n <RegionHighlight\n id={annotation.id}\n isEditing={true}\n region={(annotation.target as any).selector.spatial}\n style={allStyles}\n className={html?.className || className}\n interactive={!!(html?.href || interactive)}\n href={html?.href || null}\n title={html?.title || null}\n hrefTarget={html?.target || null}\n onClick={() => void 0}\n {...events}\n />\n );\n};\n","import { useResourceContext } from '../context/ResourceContext';\nimport { AnnotationPageNormalized } from '@iiif/presentation-3-normalized';\nimport { useMemo } from 'react';\nimport { useVaultSelector } from './useVaultSelector';\n\nexport function useAnnotationPage(options?: { id: string }): AnnotationPageNormalized | undefined;\nexport function useAnnotationPage<T>(\n options?: { id: string; selector: (annotation: AnnotationPageNormalized) => T },\n deps?: any[]\n): T | undefined;\nexport function useAnnotationPage<T = AnnotationPageNormalized>(\n options: {\n id?: string;\n selector?: (annotation: AnnotationPageNormalized) => T;\n } = {},\n deps: any[] = []\n): AnnotationPageNormalized | T | undefined {\n const { id, selector } = options;\n const ctx = useResourceContext();\n const annotationPageId = id ? id : ctx.annotationPage;\n\n const annotationPage = useVaultSelector(\n (s) => (annotationPageId ? s.iiif.entities.AnnotationPage[annotationPageId] : undefined),\n [annotationPageId]\n );\n\n return useMemo(() => {\n if (!annotationPage) {\n return undefined;\n }\n\n if (selector) {\n return selector(annotationPage);\n }\n return annotationPage;\n }, [annotationPage, ...deps]);\n}\n","import { AnnotationPage } from '@iiif/presentation-3';\nimport { AnnotationPageNormalized } from '@iiif/presentation-3-normalized';\nimport { RenderAnnotation } from './Annotation';\nimport { BoxStyle } from '@atlas-viewer/atlas';\nimport { useStyles } from '../../hooks/useStyles';\nimport { useVaultSelector } from '../../hooks/useVaultSelector';\nimport React, { FC, Fragment } from 'react';\nimport { useAnnotationPage } from '../../hooks/useAnnotationPage';\n\nexport const RenderAnnotationPage: FC<{ page: AnnotationPage | AnnotationPageNormalized; className?: string }> = ({\n className,\n page: _page,\n}) => {\n const page = useAnnotationPage({ id: _page.id }) || _page;\n const style = useStyles<BoxStyle>(page, 'atlas');\n const html = useStyles<{ className?: string }>(page, 'html');\n\n useVaultSelector((state) => (page.id ? state.iiif.entities.AnnotationPage[page.id] : null), []);\n\n return (\n <Fragment>\n {page.items?.map((annotation) => {\n return (\n <RenderAnnotation\n key={annotation.id}\n id={annotation.id}\n style={style}\n className={html?.className || className}\n />\n );\n })}\n </Fragment>\n );\n};\n","import { ImageCandidate } from '@atlas-viewer/iiif-image-api';\nimport React, { Fragment, ReactNode, useMemo } from 'react';\nimport { TileSet } from '@atlas-viewer/atlas';\nimport { ImageWithOptionalService } from '../../features/rendering-strategy/resource-types';\nimport { BoxSelector } from '@iiif/helpers';\n\nexport function RenderImage({\n id,\n image,\n thumbnail,\n isStatic,\n x = 0,\n y = 0,\n children,\n selector,\n onClick,\n enableSizes,\n}: {\n id: string;\n image: ImageWithOptionalService;\n thumbnail?: ImageCandidate;\n isStatic?: boolean;\n enableSizes?: boolean;\n selector?: BoxSelector;\n x?: number;\n y?: number;\n children?: ReactNode;\n onClick?: (e: any) => void;\n}) {\n const crop = useMemo(() => {\n // @todo crops only work if x is not zero due to bug in selector parsing\n // setting the spatial width to canvas - which isn't correct.\n if (!selector || (selector.spatial.x === 0 && selector.spatial.y === 0)) {\n return undefined;\n }\n return selector.spatial;\n }, [selector]);\n\n return (\n <world-object\n key={id + (image.service ? 'server' : 'no-service')}\n x={x + image.target.spatial.x}\n y={y + image.target.spatial.y}\n width={image.target.spatial.width}\n height={image.target.spatial.height}\n onClick={onClick}\n >\n {!image.service ? (\n <Fragment key=\"no-service\">\n <world-image\n onClick={onClick}\n uri={image.id}\n target={{ x: 0, y: 0, width: image.target.spatial.width, height: image.target.spatial.height }}\n display={\n image.width && image.height\n ? {\n width: image.width,\n height: image.height,\n }\n : undefined\n }\n crop={crop}\n />\n {children}\n </Fragment>\n ) : (\n <Fragment key=\"service\">\n <TileSet\n tiles={{\n id: image.service.id || image.service['@id'] || 'unknown',\n height: image.height as number,\n width: image.width as number,\n imageService: image.service as any,\n thumbnail: thumbnail && thumbnail.type === 'fixed' ? thumbnail : undefined,\n }}\n enableSizes={enableSizes}\n x={0}\n y={0}\n width={image.target?.spatial.width}\n height={image.target?.spatial.height}\n crop={crop}\n />\n {children}\n </Fragment>\n )}\n </world-object>\n );\n}\n","import { ContentResource, PointSelector, W3CAnnotationTarget } from '@iiif/presentation-3';\nimport { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { UseRenderingStrategy } from '../../hooks/useRenderingStrategy';\nimport { BoxSelector, expandTarget, SupportedTarget, TemporalBoxSelector } from '@iiif/helpers';\n\n/**\n * Parse specific resource.\n *\n * This could be expanded to support pulling out more from the specific resource.\n *\n * @param resource\n */\nexport function parseSpecificResource(resource: ContentResource) {\n if (resource.type === 'SpecificResource') {\n return [resource.source, { selector: resource.selector }];\n }\n\n return [resource, { selector: null }];\n}\n\nexport function getParsedTargetSelector(\n canvas: CanvasNormalized,\n target: W3CAnnotationTarget | W3CAnnotationTarget[]\n): [TemporalBoxSelector | BoxSelector | PointSelector | null, SupportedTarget['source']] {\n const { selector: imageTarget, source } = expandTarget(target);\n\n if (source.id !== canvas.id) {\n // Skip invalid targets.\n return [null, source];\n }\n\n // Target is where it should be painted.\n const defaultTarget: BoxSelector = {\n type: 'BoxSelector',\n spatial: {\n x: 0,\n y: 0,\n width: Number(canvas.width),\n height: Number(canvas.height),\n },\n };\n\n return [\n imageTarget\n ? imageTarget.type === 'TemporalSelector'\n ? ({\n type: 'TemporalBoxSelector',\n temporal: imageTarget.temporal,\n spatial: defaultTarget.spatial,\n } as any)\n : imageTarget\n : null,\n source,\n ];\n}\n\nexport const emptyActions = {\n makeChoice: () => {\n // no-op\n },\n};\n\nexport const unknownResponse: UseRenderingStrategy[0] = { type: 'unknown' };\n\nexport const unsupportedStrategy = (reason: string): UseRenderingStrategy[0] => {\n return { type: 'unknown', reason, annotations: { pages: [] } };\n};\n\nexport const emptyStrategy = (width: number, height: number): UseRenderingStrategy[0] => {\n return { type: 'empty', width, height, annotations: { pages: [] }, image: null, images: [] };\n};\n","import { useVaultSelector } from './useVaultSelector';\nimport { IIIFStore } from '@iiif/helpers/vault';\n\nfunction getMeta(state: IIIFStore, resourceId: string) {\n const resourceMeta = state?.iiif?.meta[resourceId];\n if (!resourceMeta) {\n return null;\n }\n return resourceMeta.annotationPageManager as any;\n}\n\nexport function useEnabledAnnotationPageIds(resourceId?: string, availablePageIds?: string[]) {\n return useVaultSelector(\n (state) => {\n const pageIds: string[] = [];\n if (!resourceId) {\n return pageIds;\n }\n const allAnnotationListIds = Object.keys(state.iiif.entities.AnnotationPage);\n for (const annotationListId of allAnnotationListIds) {\n if (!availablePageIds || availablePageIds.indexOf(annotationListId) !== -1) {\n const annotationListMeta = getMeta(state, annotationListId);\n if (annotationListMeta && annotationListMeta.views && annotationListMeta.views[resourceId]) {\n pageIds.push(annotationListId);\n }\n }\n }\n\n return pageIds;\n },\n [resourceId, availablePageIds]\n );\n}\n","import { CanvasNormalized, ManifestNormalized } from '@iiif/presentation-3-normalized';\n\nexport function flattenAnnotationPageIds({\n canvas,\n manifest,\n all,\n canvases,\n}: {\n manifest?: ManifestNormalized;\n canvas?: CanvasNormalized;\n canvases?: CanvasNormalized[];\n all?: boolean;\n}) {\n const foundIds: string[] = [];\n\n if (manifest) {\n for (const page of manifest.annotations) {\n if (foundIds.indexOf(page.id) === -1) {\n foundIds.push(page.id);\n }\n }\n }\n\n if (all) {\n if (canvases && canvases.length) {\n for (const canvas_ of canvases) {\n for (const page of canvas_.annotations) {\n if (foundIds.indexOf(page.id) === -1) {\n foundIds.push(page.id);\n }\n }\n }\n }\n } else if (canvas) {\n for (const page of canvas.annotations) {\n if (foundIds.indexOf(page.id) === -1) {\n foundIds.push(page.id);\n }\n }\n }\n\n // Remove enabled page IDs for now.\n // for (const enabledPage of enabledPageIds) {\n // if (foundIds.indexOf(enabledPage) === -1) {\n // foundIds.push(enabledPage);\n // }\n // }\n\n return foundIds;\n}\n","import { useCallback, useMemo } from 'react';\nimport { useVault } from './useVault';\nimport { useManifest } from './useManifest';\nimport { useCanvas } from './useCanvas';\nimport { useVisibleCanvases } from '../context/VisibleCanvasContext';\nimport { useEnabledAnnotationPageIds } from './useEnabledAnnotationPageIds';\nimport { flattenAnnotationPageIds } from '../utility/flatten-annotation-page-ids';\nimport { IIIFStore } from '@iiif/helpers/vault';\n\ntype AnnotationPageResourceMap = {\n [id: string]: boolean;\n};\n\ntype AnnotationPageManager = {\n views: AnnotationPageResourceMap;\n};\n\nfunction getMeta(state: IIIFStore, resourceId: string) {\n const resourceMeta = state?.iiif?.meta[resourceId];\n if (!resourceMeta) {\n return null;\n }\n return resourceMeta.annotationPageManager as AnnotationPageManager;\n}\n\nexport function useAnnotationPageManager(resourceId?: string, options: { all?: boolean } = {}) {\n const vault = useVault();\n const manifest = useManifest();\n const canvas = useCanvas();\n const canvases = useVisibleCanvases();\n const availablePageIds = useMemo(() => {\n return flattenAnnotationPageIds({\n all: options.all,\n manifest,\n canvas,\n canvases,\n });\n }, [options.all, canvas, canvases, manifest]);\n const enabledPageIds = useEnabledAnnotationPageIds(resourceId, options.all ? undefined : availablePageIds);\n\n const setPageDisabled = useCallback(\n (deselectId: string) => {\n if (!resourceId) {\n return;\n }\n vault.setMetaValue<AnnotationPageResourceMap>(\n [deselectId, 'annotationPageManager', 'views'],\n (existingResources: AnnotationPageResourceMap | undefined) => {\n if (existingResources && !existingResources[resourceId]) {\n return existingResources;\n }\n\n return {\n ...(existingResources || {}),\n [resourceId]: false,\n };\n }\n );\n },\n [resourceId, vault]\n );\n\n const setPageEnabled = useCallback(\n (id: string, opt: { deselectOthers?: boolean } = {}) => {\n if (!resourceId) {\n return;\n }\n const state = vault.getState();\n const toDeselect = [];\n\n // Deselect these.\n if (opt?.deselectOthers) {\n const allAnnotationListIds = Object.keys(state.iiif.entities.AnnotationPage);\n for (const annotationPageId of allAnnotationListIds) {\n const annotationListMeta = getMeta(state, annotationPageId);\n if (annotationListMeta && annotationListMeta.views && annotationListMeta.views[resourceId]) {\n toDeselect.push(annotationPageId);\n }\n }\n }\n\n // Disable first.\n for (const deselectId of toDeselect) {\n setPageDisabled(deselectId);\n }\n\n // Then enable.\n vault.setMetaValue<AnnotationPageResourceMap>(\n [id, 'annotationPageManager', 'views'],\n (existingResources: AnnotationPageResourceMap | undefined) => {\n if (existingResources && existingResources[resourceId]) {\n return existingResources;\n }\n return {\n ...(existingResources || {}),\n [resourceId]: true,\n };\n }\n );\n },\n [resourceId, setPageDisabled, vault]\n );\n\n return {\n availablePageIds,\n enabledPageIds,\n setPageEnabled,\n setPageDisabled,\n };\n}\n","import { useVaultSelector } from './useVaultSelector';\n\nexport function useResources<Type>(ids: string[], type: string): Type[] {\n return useVaultSelector((state, vault) => vault.get(ids.map((id) => ({ id, type }))) as any, [ids, type]);\n}\n","import React, { useContext } from 'react';\nimport { ImageServiceLoader } from '@atlas-viewer/iiif-image-api';\n\nexport const ImageServiceLoaderContext = React.createContext<ImageServiceLoader>(new ImageServiceLoader());\n\nexport function useImageServiceLoader() {\n return useContext(ImageServiceLoaderContext);\n}\n","import { ImageService } from '@iiif/presentation-3';\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport { useImageServiceLoader } from '../context/ImageServiceLoaderContext';\n\nexport type ImageServiceLoaderType = (\n imageService: any | undefined,\n { height, width }: { height: number; width: number }\n) => ImageService | undefined;\n\nexport function useLoadImageService() {\n const loader = useImageServiceLoader();\n const [imageServiceStatus, setImageServiceStatus] = useState<Record<string, string>>({});\n const didUnmount = useRef(false);\n useEffect(() => {\n return () => {\n didUnmount.current = true;\n };\n }, []);\n const loadImageService = useCallback<ImageServiceLoaderType>(\n (imageService, { height, width }) => {\n if (imageService) {\n const imageServiceId = imageService.id || (imageService['@id'] as string);\n // We want to kick this off.\n const syncLoaded = loader.loadServiceSync({\n id: imageServiceId,\n width: imageService.width || width,\n height: imageService.height || height,\n source: imageService,\n });\n\n if (syncLoaded) {\n imageService = syncLoaded;\n } else if (!imageServiceStatus[imageServiceId]) {\n if (!didUnmount.current) {\n setImageServiceStatus((r) => {\n return {\n ...r,\n [imageServiceId]: 'loading',\n };\n });\n }\n loader\n .loadService({\n id: imageServiceId,\n width: imageService.width || width,\n height: imageService.height || height,\n })\n .then(() => {\n if (!didUnmount.current) {\n setImageServiceStatus((r) => {\n return {\n ...r,\n [imageServiceId]: 'done',\n };\n });\n }\n });\n }\n }\n return imageService;\n },\n [loader, imageServiceStatus]\n );\n\n return [loadImageService, imageServiceStatus] as const;\n}\n","// This is valid under a canvas context.\nimport { AnnotationNormalized, AnnotationPageNormalized } from '@iiif/presentation-3-normalized';\nimport { useCanvas } from './useCanvas';\nimport { useVaultSelector } from './useVaultSelector';\nimport { useAnnotation } from './useAnnotation';\n\nexport function usePaintingAnnotations(\n options: { canvasId?: string; enableSingleAnnotation?: boolean } = {}\n): AnnotationNormalized[] {\n const annotation = useAnnotation();\n const canvas = useCanvas(options.canvasId ? { id: options.canvasId } : undefined);\n\n return useVaultSelector(\n (state, vault) => {\n if (!canvas) {\n return [];\n }\n if (annotation && options.enableSingleAnnotation) {\n return [annotation];\n }\n const annotationPages = vault.get(canvas.items);\n const flatAnnotations: AnnotationNormalized[] = [];\n for (const page of annotationPages) {\n flatAnnotations.push(...vault.get(page.items));\n }\n return flatAnnotations;\n },\n [canvas]\n );\n}\n","function x(t) {\n return t.type === \"SpecificResource\" ? [t.source, { selector: t.selector }] : [t, { selector: null }];\n}\nconst d = {}, b = {\n get(t) {\n return t;\n },\n setMetaValue([t, o, r], i) {\n const e = b.getResourceMeta(t, o), n = e ? e[r] : void 0, a = typeof i == \"function\" ? i(n) : i;\n d[t] = {\n ...d[t] || {},\n [o]: {\n ...(d[t] || {})[o] || {},\n [r]: a\n }\n };\n },\n getResourceMeta: (t, o) => {\n const r = d[t];\n if (r)\n return o ? r[o] : r;\n }\n};\nfunction M(t = b) {\n function o(e) {\n const n = e ? typeof e == \"string\" ? t.get(e) : e : null;\n if (!n)\n return [];\n const a = t.get(n.items, { parent: n }), c = [];\n for (const f of a)\n c.push(...t.get(f.items, { parent: f }));\n return c;\n }\n function r(e, n = []) {\n const a = Array.isArray(e) ? e : o(e), c = [];\n let f = null;\n const h = [];\n for (const s of a) {\n if (s.type !== \"Annotation\")\n throw new Error(\"getPaintables() accept either a canvas or list of annotations\");\n const A = Array.from(Array.isArray(s.body) ? s.body : [s.body]);\n for (const w of A) {\n const [m, { selector: P }] = x(w), u = t.get(m), p = (u.type || \"unknown\").toLowerCase();\n if (p === \"choice\") {\n const g = t.get(u.items, { parent: u.id }), y = n.length ? n.map((l) => g.find((V) => V.id === l)).filter(Boolean) : [g[0]];\n y.length === 0 && y.push(g[0]), f = {\n type: \"single-choice\",\n items: g.map((l) => ({\n id: l.id,\n label: l.label,\n selected: y.indexOf(l) !== -1\n })),\n label: m.label\n }, A.push(...y);\n continue;\n }\n c.indexOf(p) === -1 && c.push(p), h.push({\n type: p,\n annotationId: s.id,\n resource: u,\n target: s.target,\n selector: P\n });\n }\n }\n return {\n types: c,\n items: h,\n choice: f\n };\n }\n function i(e) {\n const { choice: n } = r(e);\n return n;\n }\n return {\n getAllPaintingAnnotations: o,\n getPaintables: r,\n extractChoices: i\n };\n}\nexport {\n M as createPaintingAnnotationsHelper,\n x as parseSpecificResource\n};\n//# sourceMappingURL=painting-annotations.mjs.map\n","import { useCallback, useMemo, useState } from 'react';\nimport { useVault } from './useVault';\nimport { usePaintingAnnotations } from './usePaintingAnnotations';\nimport { createPaintingAnnotationsHelper } from '@iiif/helpers/painting-annotations';\n\nexport function usePaintables(\n options?: { defaultChoices?: string[]; enableSingleAnnotation?: boolean },\n deps: any[] = []\n) {\n const vault = useVault();\n const helper = useMemo(() => {\n return createPaintingAnnotationsHelper(vault);\n }, []);\n const paintingAnnotations = usePaintingAnnotations({ enableSingleAnnotation: options?.enableSingleAnnotation });\n const [enabledChoices, setEnabledChoices] = useState<string[]>(options?.defaultChoices || []);\n\n const paintables = useMemo(\n () => helper.getPaintables(paintingAnnotations, enabledChoices),\n [vault, paintingAnnotations, enabledChoices, ...deps]\n );\n\n const makeChoice = useCallback(\n (\n id: string,\n { deselectOthers = true, deselect = false }: { deselectOthers?: boolean; deselect?: boolean } = {}\n ) => {\n if (paintables.choice) {\n // Don't support multiple choice yet.\n if (paintables.choice.type !== 'single-choice') {\n throw new Error('Complex choice not supported yet');\n }\n\n setEnabledChoices((prevChoices) => {\n if (deselect) {\n const without = prevChoices.filter((e) => e !== id);\n\n if (without.length === 0) {\n const defaultId = paintables.items[0].resource.id;\n if (defaultId) {\n return [defaultId];\n } else {\n return [];\n }\n }\n\n return without;\n }\n\n if (deselectOthers) {\n return [id];\n }\n\n const newChoices = [...prevChoices];\n\n // Add the default ID.\n if (newChoices.length === 0 && paintables.items.length) {\n const defaultId = paintables.items[0].resource.id;\n if (defaultId) {\n newChoices.push(defaultId);\n }\n }\n\n if (prevChoices.indexOf(id) !== -1) {\n return prevChoices;\n }\n\n return [...prevChoices, id];\n });\n }\n },\n [paintables.choice]\n );\n\n const actions = { makeChoice };\n\n return [paintables, actions] as const;\n}\n","import { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { unsupportedStrategy } from './rendering-utils';\nimport { AnnotationPageDescription } from './resource-types';\nimport { ExternalWebResource } from '@iiif/presentation-3';\nimport { RenderingStrategy } from './strategies';\nimport { ChoiceDescription, Paintables } from '@iiif/helpers';\n\nexport type Single3DModelStrategy = {\n type: '3d-model';\n model: ExternalWebResource;\n choice?: ChoiceDescription; // future\n annotations?: AnnotationPageDescription; // future\n};\n\nconst supportedFormats = ['model/gltf-binary'];\n\nexport function get3dStrategy(canvas: CanvasNormalized, paintables: Paintables): RenderingStrategy {\n const first = paintables.items[0];\n const resource = first.resource as ExternalWebResource;\n\n if (!resource.format) {\n return unsupportedStrategy('Unknown format');\n }\n\n if (supportedFormats.indexOf(resource.format) === -1) {\n return unsupportedStrategy(`3D format: ${resource.format} is unsupported`);\n }\n\n return {\n type: '3d-model',\n model: resource as any,\n } as Single3DModelStrategy;\n}\n","import { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { unsupportedStrategy } from './rendering-utils';\nimport { MediaStrategy } from './strategies';\nimport { Paintables } from '@iiif/helpers';\n\nexport function getAudioStrategy(canvas: CanvasNormalized, paintables: Paintables) {\n if (!canvas.duration) {\n return unsupportedStrategy('No duration on canvas');\n }\n\n if (paintables.items.length > 1) {\n return unsupportedStrategy('Only one audio source supported');\n }\n\n const audioResource = paintables.items[0]?.resource as any; // @todo stronger type for what this might be.\n\n if (!audioResource) {\n return unsupportedStrategy('Unknown audio');\n }\n\n if (!audioResource.format) {\n return unsupportedStrategy('Audio does not have format');\n }\n\n return {\n type: 'media',\n media: {\n annotationId: paintables.items[0].annotationId,\n duration: canvas.duration,\n url: audioResource.id,\n type: 'Sound',\n target: {\n type: 'TemporalSelector',\n temporal: {\n startTime: 0,\n endTime: canvas.duration,\n },\n },\n format: audioResource.format,\n selector: {\n type: 'TemporalSelector',\n temporal: {\n startTime: 0,\n endTime: canvas.duration,\n },\n },\n },\n annotations: {\n pages: [],\n },\n } as MediaStrategy;\n}\n","import { IIIFExternalWebResource } from '@iiif/presentation-3';\nimport { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { ImageServiceLoaderType } from '../../hooks/useLoadImageService';\nimport { AnnotationPageDescription, ImageWithOptionalService } from './resource-types';\nimport { getImageServices } from '@atlas-viewer/iiif-image-api';\nimport { getParsedTargetSelector, unsupportedStrategy } from './rendering-utils';\nimport { expandTarget } from '@iiif/helpers/annotation-targets';\nimport { BoxSelector, ChoiceDescription, Paintables } from '@iiif/helpers';\n\nexport type SingleImageStrategy = {\n type: 'images';\n image: ImageWithOptionalService;\n images: Array<ImageWithOptionalService>;\n choice?: ChoiceDescription;\n annotations?: AnnotationPageDescription;\n};\n\nexport function getImageStrategy(\n canvas: CanvasNormalized,\n paintables: Paintables,\n loadImageService: ImageServiceLoaderType\n) {\n const imageTypes: ImageWithOptionalService[] = [];\n for (const singleImage of paintables.items) {\n // SingleImageStrategy\n const resource: IIIFExternalWebResource =\n singleImage.resource && singleImage.resource.type === 'SpecificResource'\n ? singleImage.resource.source\n : singleImage.resource;\n\n // Validation.\n if (!resource.id) {\n // @todo we could skip this?\n return unsupportedStrategy('No resource Identifier');\n }\n\n let imageService = undefined;\n if (resource.service) {\n const imageServices = getImageServices(resource as any) as any[];\n if (imageServices[0]) {\n imageService = loadImageService(imageServices[0], canvas);\n }\n }\n\n // Target is where it should be painted.\n const defaultTarget: BoxSelector = {\n type: 'BoxSelector',\n spatial: {\n x: 0,\n y: 0,\n width: Number(canvas.width),\n height: Number(canvas.height),\n },\n };\n\n const [target, source] = getParsedTargetSelector(canvas, singleImage.target);\n if (!(source.id === canvas.id || decodeURIComponent(source.id || '') === (canvas.id || ''))) {\n // Skip invalid targets.\n continue;\n }\n\n // Support for cropping before painting an annotation.\n // @todo this isn't working.\n const defaultImageSelector =\n (singleImage.resource as any).width && (singleImage.resource as any).height\n ? ({\n type: 'BoxSelector',\n spatial: {\n x: 0,\n y: 0,\n width: (singleImage.resource as any).width,\n height: (singleImage.resource as any).height,\n },\n } as BoxSelector)\n : undefined;\n\n let imageSelector = singleImage.resource.type === 'SpecificResource' ? expandTarget(singleImage.resource) : null;\n\n if (singleImage.selector) {\n const found = expandTarget({\n type: 'SpecificResource',\n source: singleImage.resource,\n selector: singleImage.selector,\n });\n\n if (found) {\n imageSelector = found;\n }\n }\n\n const selector: undefined | BoxSelector =\n imageSelector &&\n imageSelector.selector &&\n (imageSelector.selector.type === 'BoxSelector' || imageSelector.selector.type === 'TemporalBoxSelector')\n ? {\n type: 'BoxSelector',\n spatial: {\n x: imageSelector.selector.spatial.x,\n y: imageSelector.selector.spatial.y,\n width: imageSelector.selector.spatial.width,\n height: imageSelector.selector.spatial.height,\n },\n }\n : undefined;\n\n if (imageService && !imageService.id) {\n (imageService as any).id = imageService['@id'];\n }\n\n const imageType: ImageWithOptionalService = {\n id: resource.id,\n type: 'Image',\n annotationId: (singleImage as any).annotationId,\n width: Number(target || selector ? resource.width : canvas.width),\n height: Number(target || selector ? resource.height : canvas.height),\n service: imageService,\n sizes:\n imageService && imageService.sizes\n ? imageService.sizes\n : resource.width && resource.height\n ? [{ width: resource.width, height: resource.height }]\n : [],\n target: target && target.type !== 'PointSelector' ? target : defaultTarget,\n selector: selector,\n };\n\n imageTypes.push(imageType);\n }\n\n return {\n type: 'images',\n image: imageTypes[0],\n images: imageTypes,\n choice: paintables.choice,\n } as SingleImageStrategy;\n}\n","import { InternationalString } from '@iiif/presentation-3';\nimport { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { AnnotationPageDescription } from './resource-types';\nimport { getParsedTargetSelector } from './rendering-utils';\nimport { RenderingStrategy } from './strategies';\nimport { ChoiceDescription, Paintables, SupportedTarget } from '@iiif/helpers';\n\nexport type TextualContentStrategy = {\n type: 'textual-content';\n items: { annotationId: string; text: InternationalString; target: SupportedTarget | null }[];\n choice?: ChoiceDescription; // future\n annotations?: AnnotationPageDescription; // future\n};\n\nfunction parseType(item: any, languageMap: InternationalString = {}, lang?: string) {\n const language = item.language || lang || 'none';\n switch (item.type) {\n case 'TextualBody': {\n if (typeof item.value !== 'undefined') {\n languageMap[language] = item.value;\n }\n break;\n }\n case 'List':\n case 'Composite':\n case 'Choice': {\n if (item.items) {\n item.items.forEach((inner: any) => parseType(inner, languageMap, language));\n }\n }\n }\n return languageMap;\n}\n\nexport function getTextualContentStrategy(canvas: CanvasNormalized, paintables: Paintables): RenderingStrategy {\n const items: TextualContentStrategy['items'] = [];\n\n paintables.items.forEach((item) => {\n if (item.resource) {\n const [target] = getParsedTargetSelector(canvas, item.target);\n items.push({ annotationId: item.annotationId, text: parseType(item.resource), target: target as any });\n }\n });\n\n return {\n type: 'textual-content',\n items,\n } as TextualContentStrategy;\n}\n","import { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport { unsupportedStrategy } from './rendering-utils';\nimport { MediaStrategy } from './strategies';\nimport { Paintables } from '@iiif/helpers';\n\n// https://stackoverflow.com/a/27728417\nconst ytRegex = /^.*(?:(?:youtu\\.be\\/|v\\/|vi\\/|u\\/\\w\\/|embed\\/|shorts\\/)|(?:(?:watch)?\\?vi?=|&vi?=))([^#&?]*).*/;\n\nexport function getVideoStrategy(canvas: CanvasNormalized, paintables: Paintables) {\n const videoPaintables = paintables.items.filter((t) => t.type === 'video');\n\n let noDuration = false;\n\n if (!canvas.duration) {\n noDuration = true;\n }\n\n if (videoPaintables.length > 1) {\n return unsupportedStrategy('Only one video source supported');\n }\n\n const videoResource = videoPaintables[0]?.resource as any; // @todo stronger type for what this might be.\n const isYouTube = !!(videoResource.service || []).find((service: any) =>\n (service.profile || '').includes('youtube.com')\n );\n\n if (!isYouTube && noDuration) {\n return unsupportedStrategy('Video does not have duration');\n }\n\n if (!videoResource) {\n return unsupportedStrategy('Unknown video');\n }\n\n if (!videoResource.format || videoResource.format === 'text/html') {\n if (!isYouTube) {\n return unsupportedStrategy('Video does not have format');\n }\n }\n\n const media = {\n annotationId: (paintables.items[0] as any).annotationId,\n duration: canvas.duration,\n url: videoResource.id,\n type: 'Video',\n items: [],\n target: {\n type: 'TemporalSelector',\n temporal: {\n startTime: 0,\n endTime: canvas.duration,\n },\n },\n format: videoResource.format,\n selector: {\n type: 'TemporalSelector',\n temporal: {\n startTime: 0,\n endTime: canvas.duration,\n },\n },\n };\n\n if (isYouTube) {\n media.type = 'VideoYouTube';\n const id = videoResource.id.match(ytRegex);\n if (!id[1]) {\n return unsupportedStrategy('Video is not known youtube video');\n }\n (media as any).youTubeId = id[1];\n }\n\n // @todo support VTT\n\n return {\n type: 'media',\n media,\n annotations: {\n pages: [],\n },\n } as MediaStrategy;\n}\n","import { get3dStrategy } from './3d-strategy';\nimport { getAudioStrategy } from './audio-strategy';\nimport { getImageStrategy } from './image-strategy';\nimport { emptyStrategy, unknownResponse, unsupportedStrategy } from './rendering-utils';\nimport { getTextualContentStrategy } from './textual-content-strategy';\nimport { getVideoStrategy } from './video-strategy';\nimport type { CanvasNormalized } from '@iiif/presentation-3-normalized';\nimport type { Paintables } from '@iiif/helpers/painting-annotations';\nimport type { ImageServiceLoaderType } from '../../hooks/useLoadImageService';\n\ninterface GetRenderStrategyOptions {\n canvas: CanvasNormalized | null | undefined;\n paintables: Paintables;\n supports: string[];\n loadImageService: ImageServiceLoaderType;\n}\n\nexport function getRenderingStrategy({ canvas, paintables, supports, loadImageService }: GetRenderStrategyOptions) {\n if (!canvas) {\n console.log('No canvas');\n return unknownResponse;\n }\n\n if (paintables.types.length === 0) {\n if (supports.indexOf('empty') !== -1) {\n return emptyStrategy(canvas.width, canvas.height);\n }\n console.log('No paintables');\n return unknownResponse;\n }\n\n if (paintables.types.length !== 1) {\n if (paintables.types.length === 2 && paintables.types.indexOf('text') !== -1) {\n paintables.types = paintables.types.filter((t) => t !== 'text');\n } else {\n if (supports.indexOf('complex-timeline') === -1) {\n return unsupportedStrategy('Complex timeline not supported');\n }\n return unsupportedStrategy('ComplexTimelineStrategy not yet supported');\n }\n }\n\n const mainType = paintables.types[0];\n\n // Image\n if (mainType === 'image') {\n if (supports.indexOf('images') === -1) {\n return unsupportedStrategy('Image not supported');\n }\n\n return getImageStrategy(canvas, paintables, loadImageService);\n }\n\n // 3D\n if (mainType === 'Model' || mainType === 'model') {\n if (supports.indexOf('3d-model') === -1) {\n return unsupportedStrategy('3D not supported');\n }\n\n return get3dStrategy(canvas, paintables);\n }\n\n if (mainType === 'textualbody') {\n if (supports.indexOf('textual-content') === -1) {\n return unsupportedStrategy('Textual content not supported');\n }\n\n return getTextualContentStrategy(canvas, paintables);\n }\n\n if (mainType === 'sound' || mainType === 'audio') {\n if (supports.indexOf('media') === -1) {\n return unsupportedStrategy('Media not supported');\n }\n\n // Media Strategy with audio or audio sequence.\n return getAudioStrategy(canvas, paintables);\n }\n\n if (mainType === 'video') {\n if (supports.indexOf('media') === -1) {\n return unsupportedStrategy('Media not supported');\n }\n\n // Media Strategy with video or video sequence.\n return getVideoStrategy(canvas, paintables);\n }\n\n // Unknown fallback.\n return unknownResponse;\n}\n","import { AnnotationPageNormalized } from '@iiif/presentation-3-normalized';\nimport { useCanvas } from './useCanvas';\nimport { useMemo } from 'react';\nimport { useVault } from './useVault';\nimport { RenderingStrategy } from '../features/rendering-strategy/strategies';\nimport {\n emptyActions,\n emptyStrategy,\n unknownResponse,\n unsupportedStrategy,\n} from '../features/rendering-strategy/rendering-utils';\nimport { useAnnotationPageManager } from './useAnnotationPageManager';\nimport { useManifest } from './useManifest';\nimport { useResources } from './useResources';\nimport { useLoadImageService } from './useLoadImageService';\nimport { usePaintables } from './usePaintables';\nimport { getRenderingStrategy } from '../features/rendering-strategy/get-rendering-strategy';\n\n// @todo we may not have any actions returned from the rendering strategy.\nexport type StrategyActions = {\n makeChoice: (id: string, options?: { deselectOthers?: boolean; deselect?: boolean }) => void;\n};\n\nexport type UseRenderingStrategy = [RenderingStrategy, StrategyActions];\n\nexport type UseRenderingStrategyOptions = {\n strategies?: Array<RenderingStrategy['type']>;\n annotationPageManagerId?: string;\n enableSingleAnnotation?: boolean;\n defaultChoices?: string[];\n};\n\nexport function useRenderingStrategy(options?: UseRenderingStrategyOptions): UseRenderingStrategy {\n const manifest = useManifest();\n const canvas = useCanvas();\n const vault = useVault();\n const [loadImageService, imageServiceStatus] = useLoadImageService();\n const { enabledPageIds } = useAnnotationPageManager(options?.annotationPageManagerId || manifest?.id || canvas?.id, {\n all: false,\n });\n const enabledPages = useResources<AnnotationPageNormalized>(enabledPageIds, 'AnnotationPage');\n\n const supports: RenderingStrategy['type'][] = options?.strategies || [\n 'empty',\n 'images',\n 'media',\n 'textual-content',\n 'complex-timeline',\n ];\n\n const [paintables, actions] = usePaintables(options, [imageServiceStatus]);\n\n const strategy = useMemo(() => {\n return getRenderingStrategy({ canvas, paintables, supports, loadImageService });\n }, [canvas, paintables, vault, actions.makeChoice]);\n\n return useMemo(() => {\n if (strategy.type === 'unknown') {\n return [strategy, emptyActions];\n }\n\n return [\n {\n ...strategy,\n annotations: { pages: enabledPages },\n },\n actions,\n ];\n }, [strategy, enabledPages]);\n}\n","import { Vault } from '@iiif/helpers/vault';\nimport { useVault } from './useVault';\nimport { useEffect } from 'react';\n\nexport const useVaultEffect = (callback: (vault: Vault) => void, deps: any[] = []): void => {\n const vault = useVault();\n\n useEffect(() => {\n callback(vault);\n }, [vault, ...deps]);\n};\n","import { useEffect, useMemo, useRef, useState } from 'react';\nimport { useManifest } from './useManifest';\nimport { useCanvas } from './useCanvas';\nimport { useVaultEffect } from './useVaultEffect';\nimport { ImageCandidate, ImageCandidateRequest } from '@atlas-viewer/iiif-image-api';\nimport { useImageServiceLoader } from '../context/ImageServiceLoaderContext';\nimport { createThumbnailHelper } from '@iiif/helpers/thumbnail';\nimport { useVault } from './useVault';\n\nexport function useThumbnail(\n request: ImageCandidateRequest,\n dereference?: boolean,\n { canvasId, manifestId }: { canvasId?: string; manifestId?: string } = {}\n) {\n const vault = useVault();\n const loader = useImageServiceLoader();\n const helper = useMemo(() => createThumbnailHelper(vault, { imageServiceLoader: loader }), [vault, loader]);\n\n const [thumbnail, setThumbnail] = useState<ImageCandidate | undefined>();\n const manifest = useManifest(manifestId ? { id: manifestId } : undefined);\n const canvas = useCanvas(canvasId ? { id: canvasId } : undefined);\n const subject = canvas ? canvas : manifest;\n const didUnmount = useRef(false);\n\n useEffect(() => {\n didUnmount.current = false;\n return () => {\n didUnmount.current = true;\n };\n }, []);\n\n if (!subject) {\n throw new Error('Must be called under a manifest or canvas context.');\n }\n\n useVaultEffect(\n (v) => {\n helper.getBestThumbnailAtSize(subject, request, dereference).then((thumb) => {\n if (thumb.best && !didUnmount.current) {\n setThumbnail(thumb.best);\n }\n });\n },\n [subject]\n );\n\n return thumbnail;\n}\n","import { RefObject, useCallback, useEffect, useReducer, useRef } from 'react';\n\ntype MediaPlayerAction =\n | { type: 'PLAY_PAUSE' }\n | { type: 'TOGGLE_MUTE' }\n | { type: 'MUTE' }\n | { type: 'UNMUTE' }\n | { type: 'SET_VOLUME'; volume: number }\n | { type: 'PLAY' }\n | { type: 'PLAY_REQUESTED' }\n | { type: 'PAUSE' }\n | { type: 'FINISHED' };\n\nexport type MediaPlayerState = {\n isPlaying: boolean;\n isMuted: boolean;\n playRequested: boolean;\n volume: number;\n isFinished: boolean;\n duration: number;\n};\n\nexport type MediaPlayerActions = {\n play(): void;\n pause(): void;\n playPause(): void;\n mute(): void;\n unmute(): void;\n toggleMute(): void;\n setVolume(volume: number): void;\n setDurationPercent(percent: number): void;\n setTime(time: number): void;\n};\n\nfunction getDefaultState(duration: number): MediaPlayerState {\n return { isMuted: false, playRequested: false, isPlaying: false, isFinished: false, volume: 100, duration };\n}\n\nfunction reducer(state: MediaPlayerState, action: MediaPlayerAction) {\n switch (action.type) {\n case 'FINISHED':\n return { ...state, isFinished: true, isPlaying: false, playRequested: false };\n case 'PLAY_PAUSE':\n return { ...state, isFinished: false, isPlaying: !state.isPlaying };\n case 'PLAY_REQUESTED':\n return { ...state, isFinished: false, playRequested: true };\n case 'PAUSE':\n return { ...state, isPlaying: false };\n case 'PLAY':\n return { ...state, isFinished: false, playRequested: false, isPlaying: true };\n case 'MUTE':\n return { ...state, isMuted: true };\n case 'SET_VOLUME':\n return { ...state, volume: action.volume, isMuted: action.volume === 0 };\n case 'TOGGLE_MUTE':\n return { ...state, isMuted: !state.isMuted };\n case 'UNMUTE':\n return { ...state, isMuted: false };\n }\n return state;\n}\n\nexport function formatTime(time: number) {\n const seconds = Math.round(time);\n return `${Math.floor(seconds / 60)}:${`${seconds % 60}`.padStart(2, '0')}`;\n}\n\nexport function useSimpleMediaPlayer(props: { duration: number }): readonly [\n {\n element: RefObject<HTMLAudioElement | HTMLVideoElement>;\n currentTime: RefObject<HTMLDivElement>;\n progress: RefObject<HTMLDivElement>;\n },\n MediaPlayerState,\n MediaPlayerActions\n] {\n const [state, dispatch] = useReducer(reducer, getDefaultState(props.duration));\n\n const media = useRef<HTMLAudioElement | HTMLVideoElement>(null);\n const currentTime = useRef<HTMLDivElement>(null);\n const progress = useRef<HTMLDivElement>(null);\n const _isMuted = useRef(false);\n\n const _updateCurrentTime = useCallback(() => {\n if (currentTime.current && media.current) {\n currentTime.current.innerHTML = formatTime(media.current.currentTime);\n if (progress.current) {\n progress.current.style.width = `${(media.current.currentTime / props.duration) * 100}%`;\n }\n if (_isMuted.current !== media.current.muted) {\n _isMuted.current = media.current.muted;\n dispatch(media.current.muted ? { type: 'MUTE' } : { type: 'UNMUTE' });\n }\n }\n }, [props.duration]);\n\n const play = useCallback(() => {\n if (media.current) {\n dispatch({ type: 'PLAY_REQUESTED' });\n media.current.play().then(() => {\n dispatch({ type: 'PLAY' });\n });\n _updateCurrentTime();\n }\n }, [_updateCurrentTime]);\n\n const playPause = useCallback(() => {\n if (media.current) {\n if (media.current.duration > 0 && media.current.paused) {\n play();\n } else {\n pause();\n }\n }\n }, [_updateCurrentTime]);\n\n const pause = useCallback(() => {\n if (media.current) {\n media.current.pause();\n dispatch({ type: 'PAUSE' });\n _updateCurrentTime();\n }\n }, [_updateCurrentTime]);\n\n const toggleMute = useCallback(() => {\n if (media.current) {\n media.current.muted = !media.current.muted;\n dispatch(media.current.muted ? { type: 'MUTE' } : { type: 'UNMUTE' });\n }\n }, []);\n\n const mute = useCallback(() => {\n if (media.current) {\n media.current.muted = true;\n dispatch({ type: 'MUTE' });\n }\n }, []);\n\n const unmute = useCallback(() => {\n if (media.current) {\n media.current.muted = false;\n dispatch({ type: 'UNMUTE' });\n }\n }, []);\n\n const setVolume = useCallback((newVolume: number) => {\n if (media.current) {\n media.current.muted = false;\n media.current.volume = newVolume / 100;\n dispatch({ type: 'SET_VOLUME', volume: newVolume });\n }\n }, []);\n\n const setDurationPercent = useCallback((percent: number) => {\n if (media.current) {\n media.current.currentTime = Math.max(0, Math.min(percent * props.duration, props.duration));\n _updateCurrentTime();\n }\n }, []);\n\n const setTime = useCallback((time: number) => {\n if (media.current) {\n media.current.currentTime = Math.max(0, Math.min(time, props.duration));\n _updateCurrentTime();\n }\n }, []);\n\n useEffect(() => {\n const interval = setInterval(() => {\n _updateCurrentTime();\n }, 350);\n\n return () => clearInterval(interval);\n }, [_updateCurrentTime, props.duration]);\n\n useEffect(() => {\n const ended = () => {\n dispatch({ type: 'FINISHED' });\n };\n const _media = media.current;\n\n _media?.addEventListener('ended', ended);\n\n return () => _media?.removeEventListener('ended', ended);\n }, []);\n\n return [\n { element: media, currentTime, progress },\n state,\n {\n play,\n pause,\n playPause,\n mute,\n unmute,\n toggleMute,\n setVolume,\n setDurationPercent,\n setTime,\n },\n ];\n}\n","import { createContext, ReactNode, RefObject, useContext } from 'react';\nimport { MediaPlayerActions, MediaPlayerState } from '../hooks/useSimpleMediaPlayer';\n\nconst MediaReactContextState = createContext<MediaPlayerState | null>(null);\nconst MediaReactContextActions = createContext<MediaPlayerActions | null>(null);\nconst MediaReactContextElements = createContext<{\n element: RefObject<HTMLAudioElement | HTMLVideoElement>;\n currentTime: RefObject<HTMLDivElement>;\n progress: RefObject<HTMLDivElement>;\n} | null>(null);\n\nexport function useMediaState() {\n const ctx = useContext(MediaReactContextState);\n if (!ctx) {\n throw new Error('Ctx not found');\n }\n return ctx;\n}\n\nexport function useMediaActions() {\n const ctx = useContext(MediaReactContextActions);\n if (!ctx) {\n throw new Error('Ctx not found');\n }\n return ctx;\n}\n\nexport function useMediaElements() {\n const ctx = useContext(MediaReactContextElements);\n if (!ctx) {\n throw new Error('Ctx not found');\n }\n return ctx;\n}\n\nexport function MediaPlayerProvider({\n actions,\n state,\n children,\n currentTime,\n progress,\n element,\n}: {\n actions: MediaPlayerActions;\n state: MediaPlayerState;\n children: ReactNode;\n currentTime: RefObject<HTMLDivElement>;\n progress: RefObject<HTMLDivElement>;\n element: RefObject<HTMLAudioElement | HTMLVideoElement>;\n}) {\n return (\n <MediaReactContextElements.Provider value={{ currentTime, progress, element }}>\n <MediaReactContextActions.Provider value={actions}>\n <MediaReactContextState.Provider value={state}>{children}</MediaReactContextState.Provider>\n </MediaReactContextActions.Provider>\n </MediaReactContextElements.Provider>\n );\n}\n","import { ReactNode } from 'react';\nimport { useSimpleMediaPlayer } from '../../hooks/useSimpleMediaPlayer';\nimport { SingleAudio } from '../../features/rendering-strategy/resource-types';\nimport { MediaPlayerProvider } from '../../context/MediaContext';\nimport { useOverlay } from '../context/overlays';\n\nexport function AudioHTML({ media, children }: { media: SingleAudio; children: ReactNode }) {\n const [{ element, currentTime, progress }, state, actions] = useSimpleMediaPlayer({ duration: media.duration });\n\n return (\n <MediaPlayerProvider\n state={state}\n actions={actions}\n currentTime={currentTime}\n progress={progress}\n element={element}\n >\n <audio ref={element} src={media.url} />\n {children}\n </MediaPlayerProvider>\n );\n}\n\nexport function Audio({\n media,\n mediaControlsDeps,\n children,\n}: {\n media: SingleAudio;\n mediaControlsDeps?: any[];\n children: ReactNode;\n}) {\n useOverlay('portal', 'audio', AudioHTML, { media, children }, [media, ...(mediaControlsDeps || [])]);\n\n return null;\n}\n","import { ReactNode, RefObject } from 'react';\nimport { useSimpleMediaPlayer } from '../../hooks/useSimpleMediaPlayer';\nimport { SingleVideo } from '../../features/rendering-strategy/resource-types';\nimport { MediaPlayerProvider } from '../../context/MediaContext';\nimport { useOverlay } from '../context/overlays';\n\nexport function VideoHTML({\n element,\n media,\n playPause,\n}: {\n element: RefObject<any>;\n media: SingleVideo;\n playPause: () => void;\n}) {\n const Component = 'div' as any;\n return (\n <Component className=\"video-container\" part=\"video-container\" onClick={playPause}>\n <style>\n {`\n .video-container {\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n background: #000;\n z-index: 13;\n display: flex;\n justify-content: center;\n pointer-events: visible;\n }\n `}\n </style>\n <video ref={element as any} src={media.url} style={{ width: '100%', objectFit: 'contain' }} />\n </Component>\n );\n}\n\nexport function Video({\n media,\n mediaControlsDeps,\n children,\n}: {\n media: SingleVideo;\n mediaControlsDeps?: any[];\n children: ReactNode;\n}) {\n const [{ element, currentTime, progress }, state, actions] = useSimpleMediaPlayer({ duration: media.duration });\n\n useOverlay('overlay', 'video-element', VideoHTML, {\n element,\n media,\n playPause: actions.playPause,\n });\n\n useOverlay(\n 'portal',\n 'custom-controls',\n MediaPlayerProvider,\n {\n state: state,\n actions: actions,\n currentTime: currentTime,\n progress: progress,\n element: element,\n children,\n },\n [currentTime, state, media, ...(mediaControlsDeps || [])]\n );\n\n return null;\n}\n","// @ts-ignore\nimport ModelViewer from 'react-model-viewer';\nimport { useOverlay } from '../context/overlays';\n\nexport function ModelHTML({ model }: { model: any }) {\n return (\n <>\n <style>\n {`\n .model-container {\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n background: #000;\n z-index: 13;\n display: flex;\n justify-content: center;\n pointer-events: visible;\n }\n `}\n </style>\n <div className=\"model-container\">\n {/*@ts-ignore*/}\n <model-viewer\n interaction-prompt=\"none\"\n style={{ width: '100%', height: '100%' }}\n camera-controls=\"\"\n ar-status=\"not-presenting\"\n src={model.id}\n />\n </div>\n </>\n );\n}\n\nexport function Model({ model, name }: { model: any; name?: string }) {\n useOverlay('overlay', `model-${name}`, ModelHTML, { model }, [model]);\n\n return null;\n}\n","import { BoxStyle } from '@atlas-viewer/atlas';\nimport { useCanvas } from '../../hooks/useCanvas';\n\nexport function CanvasBackground({ style }: { style?: BoxStyle }) {\n const canvas = useCanvas();\n\n if (!canvas || !canvas.height || !canvas.width) {\n return null;\n }\n\n return (\n <box\n interactive={false}\n target={{ x: 0, y: 0, width: Number(canvas.width), height: Number(canvas.height) }}\n style={style}\n />\n );\n}\n","import { InternationalString } from '@iiif/presentation-3';\nimport React, { ReactNode, useMemo } from 'react';\n\nconst LanguageContext = React.createContext<string>('en');\n\nexport function LanguageProvider(props: { language: string; children: ReactNode }) {\n return <LanguageContext.Provider value={props.language}>{props.children}</LanguageContext.Provider>;\n}\n\nexport function useIIIFLanguage() {\n return React.useContext(LanguageContext);\n}\n\nfunction getLanguagePartFromCode(code: string) {\n return code.indexOf('-') !== -1 ? code.slice(0, code.indexOf('-')) : code;\n}\n\ntype LanguageStringProps = {\n [key: string]: any;\n} & { as?: string | React.FC<any>; language: string; viewingDirection?: 'rtl' | 'rtl' };\n\nexport function LanguageString({ as: Component, language, children, viewingDirection, ...props }: LanguageStringProps) {\n const i18nLanguage = useIIIFLanguage();\n\n const isSame = useMemo(() => {\n return getLanguagePartFromCode(i18nLanguage) === getLanguagePartFromCode(language);\n }, [i18nLanguage, language]);\n\n if (isSame) {\n if (Component) {\n return <Component {...props}>{children}</Component>;\n }\n\n return <span {...props}>{children}</span>;\n }\n\n if (Component) {\n return (\n <Component {...props} lang={language} dir={viewingDirection}>\n {children}\n </Component>\n );\n }\n\n return (\n <span {...props} lang={language} dir={viewingDirection}>\n {children}\n </span>\n );\n}\n\nfunction getClosestLanguage(i18nLanguage: string, languages: string[], i18nLanguages: string[]) {\n if (languages.length === 0) {\n return undefined;\n }\n\n // Only one option.\n if (languages.length === 1) {\n return languages[0];\n }\n\n // Exact match.\n if (languages.indexOf(i18nLanguage) !== -1) {\n return i18nLanguage;\n }\n\n // Root match (en-us === en)\n const root = i18nLanguage.indexOf('-') !== -1 ? i18nLanguage.slice(0, i18nLanguage.indexOf('-')) : null;\n if (root && languages.indexOf(root) !== -1) {\n return root;\n }\n\n // All of the fall backs.\n for (const lang of i18nLanguages) {\n if (languages.indexOf(lang) !== -1) {\n return lang;\n }\n }\n\n if (languages.indexOf('none') !== -1) {\n return 'none';\n }\n\n if (languages.indexOf('@none') !== -1) {\n return '@none';\n }\n\n // Finally, fall back to the first.\n return languages[0];\n}\n\nexport const useClosestLanguage = (getLanguages: () => string[], deps: any[] = []): string | undefined => {\n const i18nLanguage = useIIIFLanguage();\n\n return useMemo(() => {\n const languages = getLanguages();\n\n return getClosestLanguage(i18nLanguage, languages, []);\n }, [i18nLanguage, ...deps]);\n};\n\nexport function useLocaleString(\n inputText: InternationalString | string | null | undefined,\n defaultText?: string,\n separator = '\\n'\n) {\n const language = useClosestLanguage(() => Object.keys(inputText || {}), [inputText]);\n return [\n useMemo(() => {\n if (!inputText) {\n return defaultText || '';\n }\n if (typeof inputText === 'string') {\n return inputText;\n }\n\n const candidateText = language ? inputText[language] : undefined;\n if (candidateText) {\n if (typeof candidateText === 'string') {\n return candidateText;\n }\n return candidateText.join(separator);\n }\n\n return '';\n }, [language, defaultText, inputText]),\n language,\n ] as const;\n}\n\nexport function useCreateLocaleString() {\n const i18nLanguage = useIIIFLanguage();\n\n return function createLocaleString(\n inputText: InternationalString | string | null | undefined,\n defaultText?: string,\n separator?: string\n ) {\n const languages = Object.keys(inputText || {});\n const language = getClosestLanguage(i18nLanguage, languages, []);\n\n if (!inputText) {\n return defaultText || '';\n }\n if (typeof inputText === 'string') {\n return inputText;\n }\n\n const candidateText = language ? inputText[language] : undefined;\n if (candidateText) {\n if (typeof candidateText === 'string') {\n return candidateText;\n }\n return candidateText.join(typeof separator !== 'undefined' ? separator : '\\n');\n }\n\n return '';\n };\n}\n\ntype LocaleStringProps = {\n as?: string | React.FC<any>;\n defaultText?: string;\n to?: string;\n separator?: string;\n enableDangerouslySetInnerHTML?: boolean;\n children: InternationalString | string | null | undefined;\n style?: React.CSSProperties;\n extraProps?: any;\n} & Record<string, any>;\n\nexport function LocaleString({\n as: Component,\n defaultText,\n enableDangerouslySetInnerHTML,\n children,\n separator,\n ...props\n}: LocaleStringProps) {\n const [text, language] = useLocaleString(children, defaultText, separator);\n\n if (language) {\n return (\n <LanguageString\n {...props}\n as={Component}\n language={language}\n title={enableDangerouslySetInnerHTML ? undefined : text}\n dangerouslySetInnerHTML={\n enableDangerouslySetInnerHTML\n ? {\n __html: text,\n }\n : undefined\n }\n >\n {enableDangerouslySetInnerHTML ? undefined : text}\n </LanguageString>\n );\n }\n\n if (Component) {\n return <Component {...props}>{text}</Component>;\n }\n\n return (\n <span\n {...props}\n title={enableDangerouslySetInnerHTML ? undefined : text}\n dangerouslySetInnerHTML={\n enableDangerouslySetInnerHTML\n ? {\n __html: text,\n }\n : undefined\n }\n >\n {enableDangerouslySetInnerHTML ? undefined : text}\n </span>\n );\n}\n","import { useSimpleMediaPlayer } from '../../hooks/useSimpleMediaPlayer';\nimport { useOverlay } from '../context/overlays';\nimport { SingleYouTubeVideo } from '../../features/rendering-strategy/resource-types';\nimport { ReactNode, RefObject, useRef } from 'react';\n\nexport function VideoYouTubeHTML({\n element,\n media,\n playPause,\n}: {\n element: RefObject<any>;\n media: SingleYouTubeVideo;\n playPause: () => void;\n}) {\n const player = useRef<HTMLIFrameElement>(null);\n\n if (!media.youTubeId) {\n return null;\n }\n\n const Component = 'div' as any;\n return (\n <Component className=\"video-container\" part=\"video-container\" onClick={playPause}>\n <style>\n {`\n .video-container {\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n background: #000;\n z-index: 13;\n display: flex;\n justify-content: center;\n pointer-events: visible;\n }\n .video-yt {\n border: none;\n width: 100%;\n object-fit: contain;\n }\n `}\n </style>\n <iframe\n className=\"video-yt\"\n ref={player}\n src={`https://www.youtube.com/embed/${media.youTubeId}?enablejsapi=1&origin=${window.location.host}`}\n referrerPolicy=\"no-referrer\"\n sandbox=\"allow-scripts allow-same-origin allow-presentation\"\n ></iframe>\n </Component>\n );\n}\n\nexport function VideoYouTube({\n media,\n mediaControlsDeps,\n children,\n}: {\n media: SingleYouTubeVideo;\n mediaControlsDeps?: any[];\n children: ReactNode;\n}) {\n const [{ element, currentTime, progress }, state, actions] = useSimpleMediaPlayer({ duration: media.duration });\n\n useOverlay('overlay', 'video-element', VideoYouTubeHTML, {\n element,\n media,\n playPause: actions.playPause,\n });\n\n return null;\n}\n","import { createStylesHelper } from '@iiif/helpers/styles';\nimport { RenderImage } from './Image';\nimport React, { Fragment, ReactNode, useEffect, useLayoutEffect, useMemo } from 'react';\nimport { BoxStyle, HTMLPortal } from '@atlas-viewer/atlas';\nimport { useVirtualAnnotationPageContext } from '../../hooks/useVirtualAnnotationPageContext';\nimport { StrategyActions, useRenderingStrategy } from '../../hooks/useRenderingStrategy';\nimport { useVault } from '../../hooks/useVault';\nimport { useResourceEvents } from '../../hooks/useResourceEvents';\nimport { useThumbnail } from '../../hooks/useThumbnail';\nimport { useCanvas } from '../../hooks/useCanvas';\nimport { RenderAnnotationPage } from './AnnotationPage';\nimport { Audio } from './Audio';\nimport { EmptyStrategy, MediaStrategy, RenderingStrategy } from '../../features/rendering-strategy/strategies';\nimport { Video } from './Video';\nimport { Model } from './Model';\nimport { CanvasContext } from '../../context/CanvasContext';\nimport { SingleImageStrategy } from '../../features/rendering-strategy/image-strategy';\nimport { CanvasBackground } from './CanvasBackground';\nimport { ImageWithOptionalService } from '../../features/rendering-strategy/resource-types';\nimport { LocaleString } from '../../utility/i18n-utils';\nimport { useOverlay } from '../context/overlays';\nimport { useViewerPreset, ViewerPresetContext } from '../../context/ViewerPresetContext';\nimport { ChoiceDescription } from '@iiif/helpers';\nimport { useWorldSize } from '../context/world-size';\nimport { VideoYouTube } from './VideoYouTube';\n\nexport type CanvasProps = {\n x?: number;\n y?: number;\n onCreated?: any;\n onChoiceChange?: (choice?: ChoiceDescription) => void;\n registerActions?: (actions: StrategyActions) => void;\n defaultChoices?: Array<{ id: string; opacity?: number }>;\n isStatic?: boolean;\n keepCanvasScale?: boolean;\n children?: ReactNode;\n renderViewerControls?: (strategy: SingleImageStrategy | EmptyStrategy) => ReactNode;\n viewControlsDeps?: any[];\n renderMediaControls?: (strategy: MediaStrategy) => ReactNode;\n mediaControlsDeps?: any[];\n strategies?: Array<RenderingStrategy['type']>;\n backgroundStyle?: BoxStyle;\n alwaysShowBackground?: boolean;\n enableSizes?: boolean;\n enableYouTube?: boolean;\n ignoreSize?: boolean;\n throwOnUnknown?: boolean;\n onClickPaintingAnnotation?: (id: string, image: ImageWithOptionalService, e: any) => void;\n};\n\nexport function RenderCanvas({\n x,\n y,\n onChoiceChange,\n registerActions,\n defaultChoices,\n isStatic,\n renderViewerControls,\n renderMediaControls,\n viewControlsDeps,\n mediaControlsDeps,\n strategies,\n throwOnUnknown,\n backgroundStyle,\n alwaysShowBackground,\n keepCanvasScale = false,\n enableSizes = false,\n enableYouTube = true,\n onClickPaintingAnnotation,\n children,\n}: CanvasProps) {\n const canvas = useCanvas();\n const elementProps = useResourceEvents(canvas, ['deep-zoom']);\n const [virtualPage] = useVirtualAnnotationPageContext();\n const preset = useViewerPreset();\n const vault = useVault();\n const helper = useMemo(() => createStylesHelper(vault), [vault]);\n const [strategy, actions] = useRenderingStrategy({\n strategies: strategies || ['images'],\n defaultChoices: defaultChoices?.map(({ id }) => id),\n });\n const choice = strategy.type === 'images' ? strategy.choice : undefined;\n const bestScale = useMemo(() => {\n if (keepCanvasScale) {\n return 1;\n }\n return Math.max(\n 1,\n ...(strategy.type === 'images'\n ? strategy.images.map((i) => {\n return (i.width || 0) / i.target?.spatial.width;\n })\n : [])\n );\n }, [keepCanvasScale, strategy]);\n\n useWorldSize(bestScale);\n\n useEffect(() => {\n if (registerActions) {\n registerActions(actions);\n }\n }, [strategy.annotations]);\n\n useEffect(() => {\n if (defaultChoices) {\n for (const choice of defaultChoices) {\n if (typeof choice.opacity !== 'undefined') {\n helper.applyStyles({ id: choice.id }, 'atlas', {\n opacity: choice.opacity,\n });\n }\n }\n }\n }, [defaultChoices]);\n\n useLayoutEffect(() => {\n if (onChoiceChange) {\n onChoiceChange(choice);\n }\n }, [choice]);\n\n useOverlay(\n preset &&\n (strategy.type === 'images' ||\n strategy.type === 'empty' ||\n (strategy.type === 'textual-content' && renderViewerControls))\n ? 'overlay'\n : 'none',\n `canvas-portal-controls-${canvas?.id}`,\n ViewerPresetContext.Provider,\n renderViewerControls\n ? {\n value: preset || null,\n children: renderViewerControls(strategy as any),\n }\n : {},\n [canvas, preset, strategy, ...(viewControlsDeps || [])]\n );\n\n const thumbnail = useThumbnail({ maxWidth: 256, maxHeight: 256 });\n\n if (!canvas) {\n return null;\n }\n\n // accompanyingCanvas\n const accompanyingCanvas = canvas.accompanyingCanvas;\n\n const thumbnailFallbackImage =\n thumbnail && thumbnail.type === 'fixed' ? (\n <world-object height={canvas.height} width={canvas.width} x={x} y={y}>\n <world-image\n uri={thumbnail.id}\n target={{ x: 0, y: 0, width: canvas.width, height: canvas.height }}\n display={\n thumbnail.width && thumbnail.height\n ? {\n width: thumbnail.width,\n height: thumbnail.height,\n }\n : undefined\n }\n crop={undefined}\n />\n </world-object>\n ) : null;\n\n if (strategy.type === 'unknown') {\n if (thumbnailFallbackImage) {\n return thumbnailFallbackImage;\n }\n\n if (throwOnUnknown) {\n throw new Error(strategy.reason || 'Unknown image strategy');\n }\n\n return null;\n }\n\n const annotations = (\n <Fragment>\n {virtualPage ? <RenderAnnotationPage page={virtualPage} /> : null}\n {strategy.annotations && strategy.annotations.pages\n ? strategy.annotations.pages.map((page) => {\n return <RenderAnnotationPage key={page.id} page={page} />;\n })\n : null}\n {children}\n </Fragment>\n );\n\n const totalKey = strategy.type === 'images' ? strategy.images.length : 0;\n\n return (\n <>\n <world-object\n key={`${canvas.id}/${strategy.type}/${totalKey}`}\n height={canvas.height}\n width={canvas.width}\n // scale={bestScale}\n x={x}\n y={y}\n {...elementProps}\n >\n {strategy.type === 'empty' || alwaysShowBackground ? <CanvasBackground style={backgroundStyle} /> : null}\n {strategy.type === 'textual-content'\n ? strategy.items.map((item, n) => {\n return (\n <>\n <HTMLPortal\n key={n}\n // @ts-ignore\n onClick={\n onClickPaintingAnnotation\n ? (e: any) => {\n e.stopPropagation();\n onClickPaintingAnnotation(item.annotationId, item as any, e);\n }\n : undefined\n }\n target={(item.target as any)?.spatial || undefined}\n >\n <div data-textual-content={true}>\n <LocaleString enableDangerouslySetInnerHTML>{item.text}</LocaleString>\n </div>\n </HTMLPortal>\n {annotations}\n </>\n );\n })\n : null}\n {strategy.type === 'images' ? (\n <>\n {strategy.images.map((image, idx) => (\n <RenderImage\n isStatic={isStatic}\n key={image.id + idx}\n image={image}\n id={image.id}\n thumbnail={idx === 0 ? thumbnail : undefined}\n selector={image.selector}\n enableSizes={enableSizes}\n onClick={\n onClickPaintingAnnotation\n ? (e) => {\n e.stopPropagation();\n onClickPaintingAnnotation(image.annotationId, image, e);\n }\n : undefined\n }\n />\n ))}\n {annotations}\n </>\n ) : null}\n {strategy.type === '3d-model' ? <Model model={strategy.model} /> : null}\n {strategy.type === 'media' ? (\n <>\n {strategy.media.type === 'Sound' ? (\n <Audio media={strategy.media} mediaControlsDeps={mediaControlsDeps}>\n {thumbnailFallbackImage}\n {renderMediaControls ? renderMediaControls(strategy) : null}\n </Audio>\n ) : strategy.media.type === 'Video' ? (\n <Video media={strategy.media} mediaControlsDeps={mediaControlsDeps}>\n {thumbnailFallbackImage}\n {renderMediaControls ? renderMediaControls(strategy) : null}\n </Video>\n ) : strategy.media.type === 'VideoYouTube' && enableYouTube ? (\n <VideoYouTube media={strategy.media} mediaControlsDeps={mediaControlsDeps}>\n {thumbnailFallbackImage}\n {renderMediaControls ? renderMediaControls(strategy) : null}\n </VideoYouTube>\n ) : null}\n </>\n ) : null}\n {/* This is required to fix a race condition. */}\n </world-object>\n {strategy.type === 'media' && strategy.media.type === 'Sound' && accompanyingCanvas ? (\n <CanvasContext canvas={accompanyingCanvas.id}>\n <RenderCanvas renderViewerControls={renderViewerControls} />\n </CanvasContext>\n ) : null}\n </>\n );\n}\n","import { FC, forwardRef, ForwardRefExoticComponent, ReactNode, RefAttributes, useImperativeHandle } from 'react';\nimport { Viewer } from './Viewer';\nimport { RenderAnnotation } from './render/Annotation';\nimport { RenderAnnotationPage } from './render/AnnotationPage';\nimport { CanvasProps, RenderCanvas } from './render/Canvas';\nimport { RenderImage } from './render/Image';\nimport { CanvasBackground } from './render/CanvasBackground';\nimport { SimpleViewerProvider, useSimpleViewer } from '../viewers/SimpleViewerContext';\nimport { VaultProvider } from '../context/VaultContext';\nimport { useManifest } from '../hooks/useManifest';\nimport { useVisibleCanvases } from '../context/VisibleCanvasContext';\nimport { CanvasContext } from '../context/CanvasContext';\nimport { useExistingVault } from '../hooks/useExistingVault';\nimport { SimpleViewerContext } from '../viewers/SimpleViewerContext.types';\nimport { Audio, AudioHTML } from './render/Audio';\nimport { Video, VideoHTML } from './render/Video';\nimport { Model, ModelHTML } from './render/Model';\nimport { ViewerMode } from '@atlas-viewer/atlas';\n\ninterface CanvasPanelProps {\n manifest: string;\n startCanvas?: string;\n rangeId?: string;\n pagingEnabled?: boolean;\n header?: ReactNode;\n children?: ReactNode;\n mode?: ViewerMode;\n reuseAtlas?: boolean;\n\n // Inner props\n height?: number;\n spacing?: number;\n components?: {\n ViewerControls?: FC;\n MediaControls?: FC;\n };\n\n // Other components\n canvasProps?: Omit<Partial<CanvasProps>, 'x'>;\n annotations?: ReactNode;\n}\n\ninterface InnerProps {\n height?: number;\n canvasProps?: CanvasPanelProps['canvasProps'];\n spacing?: number;\n components?: CanvasPanelProps['components'];\n children?: ReactNode;\n annotations?: ReactNode;\n header?: ReactNode;\n reuseAtlas?: boolean;\n mode?: ViewerMode;\n}\n\nconst Inner = forwardRef<SimpleViewerContext, InnerProps>(function Inner(props, ref) {\n const manifest = useManifest();\n const canvases = useVisibleCanvases();\n const viewer = useSimpleViewer();\n const { ViewerControls, MediaControls } = props.components || {};\n\n useImperativeHandle(ref, () => viewer, [viewer]);\n\n if (!manifest) {\n return <div />;\n }\n\n let accumulator = 0;\n\n return (\n <>\n {props.header}\n <CanvasPanel.Viewer\n key={props.reuseAtlas ? '' : viewer.currentSequenceIndex}\n height={props.height}\n mode={props.mode}\n >\n {canvases.map((canvas, idx) => {\n const margin = accumulator;\n accumulator += canvas.width + (props.spacing || 0);\n return (\n <CanvasContext canvas={canvas.id} key={canvas.id}>\n <CanvasPanel.RenderCanvas\n key={canvas.id}\n strategies={['3d-model', 'media', 'images', 'empty', 'textual-content']}\n renderViewerControls={idx === 0 && ViewerControls ? () => <ViewerControls /> : undefined}\n renderMediaControls={idx === 0 && MediaControls ? () => <MediaControls /> : undefined}\n x={margin}\n {...(props.canvasProps || {})}\n >\n {props.annotations}\n </CanvasPanel.RenderCanvas>\n </CanvasContext>\n );\n })}\n </CanvasPanel.Viewer>\n {props.children}\n </>\n );\n});\n\ntype CanvasPanelType = ForwardRefExoticComponent<CanvasPanelProps & RefAttributes<SimpleViewerContext>> & {\n RenderImage: typeof RenderImage;\n RenderCanvas: typeof RenderCanvas;\n RenderAnnotationPage: typeof RenderAnnotationPage;\n RenderAnnotation: typeof RenderAnnotation;\n Viewer: typeof Viewer;\n CanvasBackground: typeof CanvasBackground;\n Audio: typeof Audio;\n Video: typeof Video;\n Model: typeof Model;\n AudioHTML: typeof AudioHTML;\n VideoHTML: typeof VideoHTML;\n ModelHTML: typeof ModelHTML;\n};\n\nexport const CanvasPanel = forwardRef<SimpleViewerContext, CanvasPanelProps>(function CanvasPanel(\n { children, height, annotations, canvasProps, spacing, header, components, mode, reuseAtlas, ...props },\n ref\n) {\n const vault = useExistingVault();\n\n return (\n <VaultProvider vault={vault}>\n <SimpleViewerProvider {...props}>\n <Inner\n ref={ref}\n height={height}\n components={components}\n spacing={spacing}\n canvasProps={canvasProps}\n annotations={annotations}\n header={header}\n mode={mode}\n reuseAtlas={reuseAtlas}\n >\n {children}\n </Inner>\n </SimpleViewerProvider>\n </VaultProvider>\n );\n}) as CanvasPanelType;\n\nCanvasPanel.RenderImage = RenderImage;\nCanvasPanel.RenderCanvas = RenderCanvas;\nCanvasPanel.RenderAnnotationPage = RenderAnnotationPage;\nCanvasPanel.RenderAnnotation = RenderAnnotation;\nCanvasPanel.Viewer = Viewer;\nCanvasPanel.CanvasBackground = CanvasBackground;\nCanvasPanel.Audio = Audio;\nCanvasPanel.Video = Video;\nCanvasPanel.Model = Model;\nCanvasPanel.AudioHTML = AudioHTML;\nCanvasPanel.VideoHTML = VideoHTML;\nCanvasPanel.ModelHTML = ModelHTML;\n"],"names":["ErrorBoundaryContext","createContext","initialState","ErrorBoundary","Component","props","error","_this$props$onReset","_this$props","_len","args","_key","info","_this$props$onError","_this$props2","prevProps","prevState","didCatch","resetKeys","hasArrayChanged","_this$props$onReset2","_this$props3","children","fallbackRender","FallbackComponent","fallback","childToRender","createElement","isValidElement","a","b","item","index","defaultResourceContext","ResourceReactContext","React","useResourceContext","useContext","ResourceProvider","value","parentContext","newContext","useMemo","ReactVaultContext","vault","VaultProvider","vaultOptions","useGlobal","resources","vaultInstance","setVaultInstance","useState","globalVault","Vault","useExistingVault","oldContext","useExternalResource","idOrRef","noCache","id","realId","setRealId","setError","initialData","resource","setResource","useEffect","fetchedResource","_realId","err","useExternalManifest","options","isLoaded","requestId","cached","ManifestContext","manifest","CanvasContext","canvas","useVault","useVaultSelector","selector","deps","selectedState","setSelectedState","s","VisibleCanvasReactContext","useVisibleCanvases","ids","state","useManifest","ctx","manifestId","RangeContext","range","findAllCanvasesInRange","found","inner","_a","sourceId","getManifestSequence","manifestOrRange","disablePaging","skipNonPaged","behavior","isPaged","isContinuous","isIndividuals","manifestItems","_","ordering","currentOrdering","flush","offset","flushNextPaged","i","useRange","rangeId","useCanvasSequence","startCanvas","cursor","setCursor","rangeOrManifest","items","initialSequence","lastSequence","useRef","prevItem","nextItem","setCanvasIndex","useCallback","foundSequence","setCanvasId","foundIndex","next","previous","idx","noop","SimpleViewerReactContext","InnerViewerProvider","visibleItems","sequence","setSequenceIndex","hasNext","hasPrevious","jsx","SimpleViewerProvider","useSimpleViewer","useContextBridge","ContextBridge","E","t","n","R","o","c","A","T","e","M","D","O","S","r","I","U","f","C","N","d","u","J","useDispatch","store","action","isVaultActivated","obj","useVirtualAnnotationPage","sources","dispatch","virtualId","useLayoutEffect","page","entityActions","fullPage","addAnnotation","atIndex","display","full","annotation","removeAnnotation","VirtualAnnotationPageContext","useVirtualAnnotationPageContext","VirtualAnnotationProvider","DefaultCanvasFallback","width","style","height","resetErrorBoundary","jsxs","ViewerPresetContext","useViewerPreset","SetOverlaysReactContext","SetPortalReactContext","useOverlay","type","key","element","setOverlay","useCanvas","canvasId","WorldSizeContext","useWorldSize","size","fn","Viewer","errorFallback","outerContainerProps","_worldScale","viewerPreset","setViewerPreset","bridge","ErrorFallback","overlays","setOverlays","overlayComponents","portals","setPortals","portalComponents","worldSizes","setWorldSizes","worldScale","runtimeOptions","updateWorldSize","sizes","rest","updateOverlay","prev","updatePortal","fallbackProps","AtlasAuto","Fragment","Element","preset","ModeContext","g","useResourceEvents","scope","helper","createEventsHelper","hooks","useStyles","createStylesHelper","styles","useAnnotation","annotationId","body","singleBody","newAnnotation","expandTarget","RenderAnnotation","defaultStyle","className","interactive","html","events","allStyles","mergeStyles","RegionHighlight","useAnnotationPage","annotationPageId","annotationPage","RenderAnnotationPage","_page","RenderImage","image","thumbnail","isStatic","x","y","onClick","enableSizes","crop","TileSet","_b","getParsedTargetSelector","target","imageTarget","source","defaultTarget","emptyActions","unknownResponse","unsupportedStrategy","reason","emptyStrategy","getMeta","resourceId","resourceMeta","useEnabledAnnotationPageIds","availablePageIds","pageIds","allAnnotationListIds","annotationListId","annotationListMeta","flattenAnnotationPageIds","all","canvases","foundIds","canvas_","useAnnotationPageManager","enabledPageIds","setPageDisabled","deselectId","existingResources","setPageEnabled","opt","toDeselect","useResources","ImageServiceLoaderContext","ImageServiceLoader","useImageServiceLoader","useLoadImageService","loader","imageServiceStatus","setImageServiceStatus","didUnmount","imageService","imageServiceId","syncLoaded","usePaintingAnnotations","annotationPages","flatAnnotations","h","w","m","P","l","V","usePaintables","createPaintingAnnotationsHelper","paintingAnnotations","enabledChoices","setEnabledChoices","paintables","actions","deselectOthers","deselect","prevChoices","without","defaultId","newChoices","supportedFormats","get3dStrategy","getAudioStrategy","audioResource","getImageStrategy","loadImageService","imageTypes","singleImage","imageServices","getImageServices","imageSelector","imageType","parseType","languageMap","lang","language","getTextualContentStrategy","ytRegex","getVideoStrategy","videoPaintables","noDuration","videoResource","isYouTube","service","media","getRenderingStrategy","supports","mainType","useRenderingStrategy","enabledPages","strategy","useVaultEffect","callback","useThumbnail","request","dereference","createThumbnailHelper","setThumbnail","subject","v","thumb","getDefaultState","duration","reducer","formatTime","time","seconds","useSimpleMediaPlayer","useReducer","currentTime","progress","_isMuted","_updateCurrentTime","play","playPause","pause","toggleMute","mute","unmute","setVolume","newVolume","setDurationPercent","percent","setTime","interval","ended","_media","MediaReactContextState","MediaReactContextActions","MediaReactContextElements","MediaPlayerProvider","AudioHTML","Audio","mediaControlsDeps","VideoHTML","Video","ModelHTML","model","Model","name","CanvasBackground","LanguageContext","useIIIFLanguage","getLanguagePartFromCode","code","LanguageString","viewingDirection","i18nLanguage","getClosestLanguage","languages","i18nLanguages","root","useClosestLanguage","getLanguages","useLocaleString","inputText","defaultText","separator","candidateText","LocaleString","enableDangerouslySetInnerHTML","text","VideoYouTubeHTML","player","VideoYouTube","RenderCanvas","onChoiceChange","registerActions","defaultChoices","renderViewerControls","renderMediaControls","viewControlsDeps","strategies","throwOnUnknown","backgroundStyle","alwaysShowBackground","keepCanvasScale","enableYouTube","onClickPaintingAnnotation","elementProps","virtualPage","choice","bestScale","accompanyingCanvas","thumbnailFallbackImage","annotations","totalKey","HTMLPortal","Inner","forwardRef","ref","viewer","ViewerControls","MediaControls","useImperativeHandle","accumulator","CanvasPanel","margin","canvasProps","spacing","header","components","mode","reuseAtlas"],"mappings":"yYAGMA,GAAuBC,EAAAA,cAAc,IAAI,EAEzCC,EAAe,CACnB,SAAU,GACV,MAAO,IACT,EACA,MAAMC,WAAsBC,EAAAA,SAAU,CACpC,YAAYC,EAAO,CACjB,MAAMA,CAAK,EACX,KAAK,mBAAqB,KAAK,mBAAmB,KAAK,IAAI,EAC3D,KAAK,MAAQH,CACd,CACD,OAAO,yBAAyBI,EAAO,CACrC,MAAO,CACL,SAAU,GACV,MAAAA,CACN,CACG,CACD,oBAAqB,CACnB,KAAM,CACJ,MAAAA,CACN,EAAQ,KAAK,MACT,GAAIA,IAAU,KAAM,CAElB,QADIC,EAAqBC,EAChBC,EAAO,UAAU,OAAQC,EAAO,IAAI,MAAMD,CAAI,EAAGE,EAAO,EAAGA,EAAOF,EAAME,IAC/ED,EAAKC,CAAI,EAAI,UAAUA,CAAI,GAE5BJ,GAAuBC,EAAc,KAAK,OAAO,WAAa,MAAQD,IAAwB,QAAkBA,EAAoB,KAAKC,EAAa,CACrJ,KAAAE,EACA,OAAQ,gBAChB,CAAO,EACD,KAAK,SAASR,CAAY,CAC3B,CACF,CACD,kBAAkBI,EAAOM,EAAM,CAC7B,IAAIC,EAAqBC,GACxBD,GAAuBC,EAAe,KAAK,OAAO,WAAa,MAAQD,IAAwB,QAAkBA,EAAoB,KAAKC,EAAcR,EAAOM,CAAI,CACrK,CACD,mBAAmBG,EAAWC,EAAW,CACvC,KAAM,CACJ,SAAAC,CACN,EAAQ,KAAK,MACH,C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