react-iiif-vault 0.9.3 → 0.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -1 +1,1527 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var u=require("react"),T=require("@iiif/vault"),k=require("react-query"),L=require("@atlas-viewer/iiif-image-api"),b=require("@iiif/vault-helpers"),h=require("typesafe-actions"),je=require("@iiif/parser");function De(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var g=De(u),Fe=Object.defineProperty,z=Object.getOwnPropertySymbols,Ne=Object.prototype.hasOwnProperty,Be=Object.prototype.propertyIsEnumerable,Y=(e,t,n)=>t in e?Fe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,W=(e,t)=>{for(var n in t||(t={}))Ne.call(t,n)&&Y(e,n,t[n]);if(z)for(var n of z(t))Be.call(t,n)&&Y(e,n,t[n]);return e};const Ue={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0},j=g.default.createContext(Ue),C=()=>u.useContext(j),E=({value:e,children:t})=>{const n=C(),r=u.useMemo(()=>W(W({},n),e),[e,n]);return g.default.createElement(j.Provider,{value:r},t)},ke=({annotation:e,children:t})=>g.default.createElement(E,{value:{annotation:e}},t),G=({canvas:e,children:t})=>g.default.createElement(E,{value:{canvas:e}},t),He=({collection:e,children:t})=>g.default.createElement(E,{value:{collection:e}},t),X=({manifest:e,children:t})=>g.default.createElement(E,{value:{manifest:e}},t),Qe=({range:e,children:t})=>g.default.createElement(E,{value:{range:e}},t),A=g.default.createContext({vault:null,setVaultInstance:e=>{}}),J=({vault:e,vaultOptions:t,useGlobal:n,resources:r,children:c})=>{const[i,a]=u.useState(()=>e||(n?T.globalVault(t):t?new T.Vault(t):new T.Vault));return g.default.createElement(A.Provider,{value:{vault:i,setVaultInstance:a}},g.default.createElement(E,{value:r||{}},c))},y=()=>{const{vault:e}=u.useContext(A);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};var qe=Object.defineProperty,K=Object.getOwnPropertySymbols,ze=Object.prototype.hasOwnProperty,Ye=Object.prototype.propertyIsEnumerable,Z=(e,t,n)=>t in e?qe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,We=(e,t)=>{for(var n in t||(t={}))ze.call(t,n)&&Z(e,n,t[n]);if(K)for(var n of K(t))Ye.call(t,n)&&Z(e,n,t[n]);return e},Ge=(e,t,n)=>new Promise((r,c)=>{var i=s=>{try{o(n.next(s))}catch(l){c(l)}},a=s=>{try{o(n.throw(s))}catch(l){c(l)}},o=s=>s.done?r(s.value):Promise.resolve(s.value).then(i,a);o((n=n.apply(e,t)).next())});const ee=(e,t={})=>{const n=y(),[r,c]=u.useState(e),i=u.useMemo(()=>n.get(e)||void 0,[e,n]),{data:a,error:o}=k.useQuery(["manifest",e],()=>Ge(void 0,null,function*(){const s=i||(yield n.load(e));return s&&r!==s.id&&c(s.id),s}),We({refetchIntervalInBackground:!1,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchInterval:!1,retry:!1,initialData:i},t));return{isLoaded:!!a,id:r,error:o,manifest:a}};function P(e,t=[]){const n=y(),[r,c]=u.useState(()=>e(n.getState(),n));return u.useEffect(()=>n.subscribe(i=>e(i,n),i=>{c(i)},!0),t),r}const R=g.default.createContext([]);function te(){const e=u.useContext(R);return P(t=>e.map(n=>t.iiif.entities.Canvas[n]).filter(Boolean),[e])}const D=()=>{},M=u.createContext({setCurrentCanvasId:D,setCurrentCanvasIndex:D,nextCanvas:D,previousCanvas:D,currentCanvasIndex:-1,totalCanvases:0,pagingView:!0}),Xe=e=>{const t=ee(e.manifest),[n,r]=u.useState(""),[c,i]=u.useState([]),a=(typeof e.pagingEnabled>"u"||e.pagingEnabled)&&t.manifest&&t.manifest.behavior&&t.manifest.behavior.includes("paged");u.useEffect(()=>{var f,m;t.manifest&&(r((f=t.manifest.items[0])==null?void 0:f.id),i([(m=t.manifest.items[0])==null?void 0:m.id]))},[t.manifest,e.manifest]);const o=u.useMemo(()=>{var f;return((f=t.manifest)==null?void 0:f.items.map(m=>m.id))||[]},[t.manifest,e.manifest]),s=u.useMemo(()=>o.indexOf(n),[o,n]),l=u.useCallback(()=>{if(o.length&&n){if(s===-1||(o[s+2]?s+2===o.length:s===o.length))return;const f=a&&s!==0?o[s+2]:o[s+1],m=a?s!==0?o[s+3]:o[s+2]:null;f&&(r(f),i(m?[f,m]:[f]))}},[a,o,n,s]),p=u.useCallback(()=>{if(o.length&&n){if(s===0||s===-1)return;const f=a&&s!==1?o[s-2]:o[s-1],m=a&&s!==1?o[s-1]:null;f&&(r(f),i(m?[f,m]:[f]))}},[a,o,n,s]),d=u.useCallback(f=>{const m=a&&f%2===1?f-1:f,w=o[m],q=a&&m!==0?o[m+1]:null;w&&(r(w),i(I=>{const U=q?[w,q]:[w];if(I.length===I.length){for(let V=0;V<I.length;V++)if(I[V]!==U[V])return U;return I}return U}))},[a,o]),v=u.useCallback(f=>{const m=o.indexOf(f);m!==-1&&d(m)},[o,d]),_=u.useMemo(()=>({setCurrentCanvasId:v,nextCanvas:l,previousCanvas:p,currentCanvasIndex:s,totalCanvases:o.length,setCurrentCanvasIndex:d,pagingView:!0}),[l,p,s,o,d,v]);return!t.isLoaded||!t.manifest?g.default.createElement("div",null,"Loading..."):g.default.createElement(M.Provider,{value:_},g.default.createElement(R.Provider,{value:c},g.default.createElement(X,{manifest:t.manifest.id},g.default.createElement(G,{canvas:n},e.children))))};function Je(){return u.useContext(M)}function Ke(){return{VaultContext:u.useContext(A),ResourceContext:u.useContext(j),SimpleViewerReactContext:u.useContext(M),VisibleCanvasReactContext:u.useContext(R)}}const Ze=e=>g.default.createElement(J,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext},g.default.createElement(R.Provider,{value:e.bridge.VisibleCanvasReactContext},g.default.createElement(M.Provider,{value:e.bridge.SimpleViewerReactContext},e.children))),ne=g.default.createContext(new L.ImageServiceLoader);function F(){return u.useContext(ne)}const et=/&?(xywh=)?(pixel:|percent:)?([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?)/,tt=/&?(t=)(npt:)?([0-9]+(.[0-9]+)?)?(,([0-9]+(.[0-9]+)?))?/;function N(e){if(Array.isArray(e))return e.reduce((t,n)=>{const{selector:r,selectors:c}=N(n);return r&&(t.selector||(t.selector=r),t.selectors.push(...c)),t},{selector:null,selectors:[]});if(!e)return{selector:null,selectors:[]};if(typeof e=="string"){const[t,n]=e.split("#");return n?N({type:"FragmentSelector",value:n}):{selector:null,selectors:[]}}if(e.type==="PointSelector"&&(e.t||e.t===0)){const t={type:"TemporalSelector",temporal:{startTime:e.t}};return{selector:t,selectors:[t]}}if(e.type==="FragmentSelector"){const t=et.exec(e.value);if(t){const r={type:"BoxSelector",spatial:{unit:t[2]==="percent:"?"percent":"pixel",x:parseFloat(t[3]),y:parseFloat(t[4]),width:parseFloat(t[5]),height:parseFloat(t[6])}};return{selector:r,selectors:[r]}}const n=e.value.match(tt);if(n){const r={type:"TemporalSelector",temporal:{startTime:n[4]?parseFloat(n[4]):0,endTime:n[7]?parseFloat(n[7]):void 0}};return{selector:r,selectors:[r]}}return{selector:null,selectors:[]}}return{selector:null,selectors:[]}}var nt=Object.defineProperty,rt=Object.defineProperties,ot=Object.getOwnPropertyDescriptors,re=Object.getOwnPropertySymbols,it=Object.prototype.hasOwnProperty,at=Object.prototype.propertyIsEnumerable,oe=(e,t,n)=>t in e?nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ie=(e,t)=>{for(var n in t||(t={}))it.call(t,n)&&oe(e,n,t[n]);if(re)for(var n of re(t))at.call(t,n)&&oe(e,n,t[n]);return e},ae=(e,t)=>rt(e,ot(t));function O(e,t={}){if(Array.isArray(e))return O(e[0]);if(typeof e=="string"){const[n,r]=e.split("#");return r?O({type:"SpecificResource",source:{id:n,type:"Unknown"},selector:{type:"FragmentSelector",value:r}}):{type:"SpecificResource",source:{id:n,type:t.typeMap&&t.typeMap[n]||"Unknown"},selector:null,selectors:[]}}if(e.type==="Choice"||e.type==="List"||e.type==="Composite"||e.type==="Independents")return O(e.items[0]);if(e.type==="SpecificResource"){e.source.type==="Canvas"&&e.source.partOf&&typeof e.source.partOf=="string"&&(e.source.partOf=[{id:e.source.partOf,type:"Manifest"}]);const{selector:n,selectors:r}=e.selector?N(e.selector):{selector:null,selectors:[]};return{type:"SpecificResource",source:e.source,selector:n,selectors:r}}if(e.id){e.type==="Canvas"&&e.partOf&&typeof e.partOf=="string"&&(e.partOf=[{id:e.partOf,type:"Manifest"}]);const[n,r]=e.id.split("#");return r?O({type:"SpecificResource",source:ae(ie({},e),{id:n}),selector:{type:"FragmentSelector",value:r}}):{type:"SpecificResource",source:ae(ie({},e),{id:n}),selector:null,selectors:[]}}return{type:"SpecificResource",source:e,selector:null,selectors:[]}}function se(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function ce(e,t,n){const r=[];let c=null;const i=[];for(const a of t){const o=e.get(a.body);for(const s of o){const[l,{selector:p}]=se(s),d=(l.type||"unknown").toLowerCase();if(d==="choice"){const v=e.get(l.items),_=n.length?n.map(f=>v.find(m=>m.id===f)).filter(Boolean):[v[0]];_.length===0&&_.push(v[0]),c={type:"single-choice",items:v.map(f=>({id:f.id,label:f.label,selected:_.indexOf(f)!==-1})),label:s.label},o.push(..._);continue}r.indexOf(d)===-1&&r.push(d),i.push({type:d,resource:l,target:a.target,selector:p})}}return{types:r,items:i,choice:c}}const ue={makeChoice:()=>{}},H={type:"unknown"},S=e=>({type:"unknown",reason:e,annotations:{pages:[]}});function le(e,t,n){const r=[];for(const c of t.items){const i=c.resource&&c.resource.type==="SpecificResource"?c.resource.source:c.resource;if(!i.id)return S("No resource Identifier");let a;if(i.service){const m=L.getImageServices(i);m[0]&&(a=n(m[0],e))}const{selector:o,source:s}=O(c.target);if(s.id!==e.id)continue;const l={type:"BoxSelector",spatial:{x:0,y:0,width:e.width,height:e.height}},p=o?o.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:o.temporal,spatial:l.spatial}:o:null,d={type:"BoxSelector",spatial:{x:0,y:0,width:e.width,height:e.height}},v=c.resource.type==="SpecificResource"?O(c.resource):null,_=v&&v.selector&&(v.selector.type==="BoxSelector"||v.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:v.selector.spatial.x,y:v.selector.spatial.y,width:v.selector.spatial.width,height:v.selector.spatial.height}}:d,f={id:i.id,type:"Image",width:p?i.width:e.width,height:p?i.height:e.height,service:a,sizes:a&&a.sizes?a.sizes:i.width&&i.height?[{width:i.width,height:i.height}]:[],target:p&&p.type!=="PointSelector"?p:l,selector:_};r.push(f)}return{type:"images",image:r[0],images:r,choice:t.choice}}var st=Object.defineProperty,ct=Object.defineProperties,ut=Object.getOwnPropertyDescriptors,fe=Object.getOwnPropertySymbols,lt=Object.prototype.hasOwnProperty,ft=Object.prototype.propertyIsEnumerable,de=(e,t,n)=>t in e?st(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,dt=(e,t)=>{for(var n in t||(t={}))lt.call(t,n)&&de(e,n,t[n]);if(fe)for(var n of fe(t))ft.call(t,n)&&de(e,n,t[n]);return e},pt=(e,t)=>ct(e,ut(t));function vt(e={},t=[]){const{id:n,selector:r}=e,c=C(),i=y(),a=n||c.annotation,o=P(l=>a?l.iiif.entities.Annotation[a]:void 0,[a]),s=P(l=>o&&o.body?o.body.map(p=>p?l.iiif.entities[p.type][p.id]:null).filter(Boolean):[],[o]);return u.useMemo(()=>{if(!o)return;const l=pt(dt({},o),{body:s,target:O(o.target,{typeMap:i.getState().iiif.mapping})});return r?r(l):l},[o,r,s,...t])}function $(e={},t=[]){const{id:n,selector:r}=e,c=C();y();const i=n||c.manifest,a=P(o=>i?o.iiif.entities.Manifest[i]:void 0,[i]);return u.useMemo(()=>{if(!!a)return r?r(a):a},[a,r,...t])}function x(e={},t=[]){const{id:n,selector:r}=e,c=C(),i=n||c.canvas,a=P(o=>i?o.iiif.entities.Canvas[i]:void 0,[i]);return u.useMemo(()=>{if(!!a)return r?r(a):a},[a,r,...t])}function mt(e,t){var n;const r=(n=e==null?void 0:e.iiif)==null?void 0:n.meta[t];return r?r.annotationPageManager:null}function gt(e,t){return P(n=>{const r=[];if(!e)return r;const c=Object.keys(n.iiif.entities.AnnotationPage);for(const i of c)if(!t||t.indexOf(i)!==-1){const a=mt(n,i);a&&a.views&&a.views[e]&&r.push(i)}return r},[e])}function pe({canvas:e,manifest:t,all:n,canvases:r}){const c=[];if(t)for(const i of t.annotations)c.indexOf(i.id)===-1&&c.push(i.id);if(n){if(r&&r.length)for(const i of r)for(const a of i.annotations)c.indexOf(a.id)===-1&&c.push(a.id)}else if(e)for(const i of e.annotations)c.indexOf(i.id)===-1&&c.push(i.id);return c}var yt=Object.defineProperty,ht=Object.defineProperties,_t=Object.getOwnPropertyDescriptors,ve=Object.getOwnPropertySymbols,Pt=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable,me=(e,t,n)=>t in e?yt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ge=(e,t)=>{for(var n in t||(t={}))Pt.call(t,n)&&me(e,n,t[n]);if(ve)for(var n of ve(t))St.call(t,n)&&me(e,n,t[n]);return e},ye=(e,t)=>ht(e,_t(t));function wt(e,t){var n;const r=(n=e==null?void 0:e.iiif)==null?void 0:n.meta[t];return r?r.annotationPageManager:null}function he(e,t={}){const n=y(),r=$(),c=x(),i=te(),a=u.useMemo(()=>pe({all:t.all,manifest:r,canvas:c,canvases:i}),[t.all,c,i,r]),o=gt(e,t.all?void 0:a),s=u.useCallback(p=>{!e||n.setMetaValue([p,"annotationPageManager","views"],d=>d&&!d[e]?d:ye(ge({},d||{}),{[e]:!1}))},[e,n]),l=u.useCallback((p,d={})=>{if(!e)return;const v=n.getState(),_=[];if(d==null?void 0:d.deselectOthers){const f=Object.keys(v.iiif.entities.AnnotationPage);for(const m of f){const w=wt(v,m);w&&w.views&&w.views[e]&&_.push(m)}}for(const f of _)s(f);n.setMetaValue([p,"annotationPageManager","views"],f=>f&&f[e]?f:ye(ge({},f||{}),{[e]:!0}))},[e,s,n]);return{availablePageIds:a,enabledPageIds:o,setPageEnabled:l,setPageDisabled:s}}function B(e={}){const t=x(e.canvasId?{id:e.canvasId}:void 0);return P((n,r)=>{if(!t)return[];const c=r.get(t.items),i=[];for(const a of c)i.push(...r.get(a.items));return i},[t])}function Ot(e,t={}){return B(t)}function Ct(e,t=!1){}function Et(e,t=[]){const{id:n,selector:r}=e,c=C(),i=n||c.collection,a=P(o=>i?o.iiif.entities.Collection[i]:void 0,[i]);return u.useMemo(()=>{if(!!a)return r?r(a):a},[a,r,...t])}function _e(){const t=y().getStore();return u.useMemo(()=>n=>t.dispatch(n),[t])}function xt(e,t,n,r,c=[]){const i=y(),a=u.useMemo(()=>b.createEventsHelper(i),[i]);u.useEffect(()=>{const o=e;return o?(a.addEventListener(o,t,n,r),()=>{a.removeEventListener(o,t,n)}):()=>{}},[a,e,t,...c])}function It(){const e=u.useContext(A);return e&&e.vault?e.vault:T.globalVault()}var bt=Object.defineProperty,Pe=Object.getOwnPropertySymbols,At=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable,Se=(e,t,n)=>t in e?bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Mt=(e,t)=>{for(var n in t||(t={}))At.call(t,n)&&Se(e,n,t[n]);if(Pe)for(var n of Pe(t))Rt.call(t,n)&&Se(e,n,t[n]);return e},$t=(e,t,n)=>new Promise((r,c)=>{var i=s=>{try{o(n.next(s))}catch(l){c(l)}},a=s=>{try{o(n.throw(s))}catch(l){c(l)}},o=s=>s.done?r(s.value):Promise.resolve(s.value).then(i,a);o((n=n.apply(e,t)).next())});const Vt=(e,t={})=>{const n=y(),[r,c]=u.useState(e),i=u.useMemo(()=>n.get(e),[e,n]),{data:a,isFetching:o}=k.useQuery(`collection:${e}`,()=>$t(void 0,null,function*(){const s=i||(yield n.loadCollection(e));return s&&c(s.id),s}),Mt({refetchIntervalInBackground:!1,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchInterval:!1,initialData:i},t));return{isLoaded:!o,id:r,collection:a}};var Tt=(e,t,n)=>new Promise((r,c)=>{var i=s=>{try{o(n.next(s))}catch(l){c(l)}},a=s=>{try{o(n.throw(s))}catch(l){c(l)}},o=s=>s.done?r(s.value):Promise.resolve(s.value).then(i,a);o((n=n.apply(e,t)).next())});function we(){const e=x(),t=B(),n=y(),r=F();return k.useQuery(`canvas-first-image-service:${e?e.id:"undefined"}`,()=>Tt(this,null,function*(){if(e&&t.length){const c=t[0],i=n.get(c.body[0]),o=L.getImageServices(i)[0];return o&&(yield r.loadService({id:o.id||o["@id"],width:o.width||e.width,height:o.height||e.height}))||void 0}}),{refetchOnWindowFocus:!1,refetchOnMount:!1,refetchIntervalInBackground:!1,refetchInterval:!1,initialData:()=>{if(e&&t.length){const c=t[0],i=n.get(c.body[0]),o=L.getImageServices(i)[0];return o&&r.loadServiceSync({id:o.id||o["@id"],width:o.width||e.width,height:o.height||e.height})||void 0}}})}function Lt(){const e=we();return{isLoading:e.isFetching,tile:e.data?{id:e.data.id||e.data["@id"],width:e.data.width,height:e.data.height,imageService:e.data,thumbnail:void 0}:null}}function Oe(e,t=[]){const n=y(),r=B(),[c,i]=u.useState((e==null?void 0:e.defaultChoices)||[]),a=u.useMemo(()=>ce(n,r,c),[n,r,c,...t]),s={makeChoice:u.useCallback((l,{deselectOthers:p=!0,deselect:d=!1}={})=>{if(a.choice){if(a.choice.type!=="single-choice")throw new Error("Complex choice not supported yet");i(v=>{if(d){const f=v.filter(m=>m!==l);if(f.length===0){const m=a.items[0].resource.id;return m?[m]:[]}return f}if(p)return[l];const _=[...v];if(_.length===0&&a.items.length){const f=a.items[0].resource.id;f&&_.push(f)}return v.indexOf(l)!==-1?v:[...v,l]})}},[a.choice])};return[a,s]}function jt(e={},t=[]){const{id:n,selector:r}=e,c=C(),i=n||c.range,a=P(o=>i?o.iiif.entities.Range[i]:void 0,[i]);return u.useMemo(()=>{if(!!a)return r?r(a):a},[a,r,...t])}function Dt(e,t){const n=y(),r=u.useMemo(()=>b.createEventsHelper(n),[n]),c=P(()=>e&&e.id?n.getResourceMeta(e.id,"eventManager"):null,[e]);return u.useMemo(()=>e?r.getListenersAsProps(e,t):{},[c,e,n,t])}function Ce(e,t){return P((n,r)=>r.get(e.map(c=>({id:c,type:t}))),[e,t])}function Ft(){const e=$();return e?e.service.find(t=>t.profile==="SearchService1"||t.profile==="http://iiif.io/api/search/1/search"):void 0}function Nt(){const e=y();return u.useMemo(()=>b.createStylesHelper(e),[e])}function Bt(e,t){const n=y(),r=u.useMemo(()=>b.createStylesHelper(n),[n]);return P(()=>{if(!e)return null;const c=r.getAppliedStyles(e.id);return c?t?c[t]:c:void 0},[e,t])}const Ee=(e,t=[])=>{const n=y();u.useEffect(()=>{e(n)},[n,...t])};function Ut(e,t,{canvasId:n,manifestId:r}={}){const c=y(),i=F(),a=u.useMemo(()=>b.createThumbnailHelper(c,{imageServiceLoader:i}),[c,i]),[o,s]=u.useState(),l=$(r?{id:r}:void 0),p=x(n?{id:n}:void 0),d=p||l,v=u.useRef(!1);if(u.useEffect(()=>()=>{v.current=!0},[]),!d)throw new Error("Must be called under a manifest or canvas context.");return Ee(_=>{a.getBestThumbnailAtSize(d,e,t).then(f=>{f.best&&!v.current&&s(f.best)})},[d]),o}var kt=Object.defineProperty,Ht=Object.defineProperties,Qt=Object.getOwnPropertyDescriptors,xe=Object.getOwnPropertySymbols,qt=Object.prototype.hasOwnProperty,zt=Object.prototype.propertyIsEnumerable,Ie=(e,t,n)=>t in e?kt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,be=(e,t)=>{for(var n in t||(t={}))qt.call(t,n)&&Ie(e,n,t[n]);if(xe)for(var n of xe(t))zt.call(t,n)&&Ie(e,n,t[n]);return e},Ae=(e,t)=>Ht(e,Qt(t));function Re(){const e=F(),[t,n]=u.useState({}),r=u.useRef(!1);return u.useEffect(()=>()=>{r.current=!0},[]),[u.useCallback((i,{height:a,width:o})=>{if(i){const s=i.id||i["@id"],l=e.loadServiceSync({id:s,width:i.width||o,height:i.height||a});l?i=l:t[s]||(r.current||n(p=>Ae(be({},p),{[s]:"loading"})),e.loadService({id:s,width:i.width||o,height:i.height||a}).then(()=>{r.current||n(p=>Ae(be({},p),{[s]:"done"}))}))}return i},[e,t]),t]}const Yt="@iiif/IMPORT_ENTITIES",Wt="@iiif/MODIFY_ENTITY_FIELD",Gt="@iiif/REORDER_ENTITY_FIELD",Xt="@iiif/ADD_REFERENCE",Jt="@iiif/REMOVE_REFERENCE",Kt=h.createAction(Yt)(),Zt=h.createAction(Wt)(),en=h.createAction(Gt)(),tn=h.createAction(Xt)(),nn=h.createAction(Jt)(),Q={importEntities:Kt,modifyEntityField:Zt,reorderEntityField:en,addReference:tn,removeReference:nn},rn="@iiif/ADD_MAPPING",on="@iiif/ADD_MAPPINGS";h.createAction(rn)(),h.createAction(on)();const an="@iiif/SET_META_VALUE",sn="@iiif/SET_META_VALUE_DYNAMIC",cn="@iiif/UNSET_META_VALUE";h.createAction(an)(),h.createAction(sn)(),h.createAction(cn)();const un="@iiif/REQUEST_RESOURCE",ln="@iiif/REQUEST_ERROR",fn="@iiif/REQUEST_MISMATCH",dn="@iiif/REQUEST_COMPLETE",pn="@iiif/REQUEST_OFFLINE_RESOURCE";h.createAction(un)(),h.createAction(ln)(),h.createAction(fn)(),h.createAction(dn)(),h.createAction(pn)();const vn="@iiif/BATCH";h.createAction(vn)();var mn=Object.defineProperty,gn=Object.defineProperties,yn=Object.getOwnPropertyDescriptors,Me=Object.getOwnPropertySymbols,hn=Object.prototype.hasOwnProperty,_n=Object.prototype.propertyIsEnumerable,$e=(e,t,n)=>t in e?mn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Pn=(e,t)=>{for(var n in t||(t={}))hn.call(t,n)&&$e(e,n,t[n]);if(Me)for(var n of Me(t))_n.call(t,n)&&$e(e,n,t[n]);return e},Sn=(e,t)=>gn(e,yn(t));function Ve(e){return typeof e!="string"&&e&&e.bindToVault}function wn(){const e=y(),t=u.useRef([]),n=_e(),r=u.useMemo(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);u.useLayoutEffect(()=>{const o=Sn(Pn({},je.emptyAnnotationPage),{id:r,items:[]});n(Q.importEntities({entities:{AnnotationPage:{[o.id]:o}}}))},[r]);const c=P(o=>r?o.iiif.entities.AnnotationPage[r]:null,[r]),i=u.useCallback((o,s)=>{if(r){if(Ve(o)){const d=o;d.__vault||d.bindToVault(e),o=typeof d.source=="string"?d.source:d.source.id,t.current[o]=d}else typeof o!="string"&&(o=o.id);const l=e.get({id:r,type:"AnnotationPage"}),p=e.get({id:o,type:"Annotation"});l&&p&&(l.items.find(d=>d.id===p.id)||n(Q.addReference({id:r,type:"AnnotationPage",key:"items",reference:{id:o,type:"Annotation"},index:s})))}},[r]),a=u.useCallback(o=>{r&&(Ve(o)?o=typeof o.source=="string"?o.source:o.source.id:typeof o!="string"&&(o=o.id),t.current[o]&&t.current[o].beforeRemove(),e.get({id:r,type:"AnnotationPage"})&&n(Q.removeReference({id:r,type:"AnnotationPage",key:"items",reference:{id:o,type:"Annotation"}})))},[r]);return[c,{addAnnotation:i,removeAnnotation:a}]}var On=Object.defineProperty,Cn=Object.defineProperties,En=Object.getOwnPropertyDescriptors,Te=Object.getOwnPropertySymbols,xn=Object.prototype.hasOwnProperty,In=Object.prototype.propertyIsEnumerable,Le=(e,t,n)=>t in e?On(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,bn=(e,t)=>{for(var n in t||(t={}))xn.call(t,n)&&Le(e,n,t[n]);if(Te)for(var n of Te(t))In.call(t,n)&&Le(e,n,t[n]);return e},An=(e,t)=>Cn(e,En(t));function Rn(e){const t=$(),n=x(),r=y(),[c,i]=Re(),{enabledPageIds:a}=he((e==null?void 0:e.annotationPageManagerId)||(t==null?void 0:t.id),{all:!1}),o=Ce(a,"AnnotationPage"),s=(e==null?void 0:e.strategies)||["images","media","complex-timeline"],[l,p]=Oe(e,[i]),d=u.useMemo(()=>{if(!n||l.types.length===0)return H;if(l.types.length!==1)return s.indexOf("complex-timeline")===-1?S("Complex timeline not supported"):S("ComplexTimelineStrategy not yet supported");const v=l.types[0];return v==="image"?s.indexOf("images")===-1?S("Image not supported"):le(n,l,c):v==="audio"?s.indexOf("media")===-1?S("Media not supported"):S("Audio strategy not yet supported"):v==="video"?s.indexOf("media")===-1?S("Media not supported"):S("Video strategy not yet supported"):H},[n,l,r,p.makeChoice]);return u.useMemo(()=>d.type==="unknown"?[d,ue]:[An(bn({},d),{annotations:{pages:o}}),p],[d,o])}exports.AnnotationContext=ke,exports.CanvasContext=G,exports.CollectionContext=He,exports.ContextBridge=Ze,exports.ImageServiceLoaderContext=ne,exports.ManifestContext=X,exports.RangeContext=Qe,exports.ReactVaultContext=A,exports.ResourceProvider=E,exports.ResourceReactContext=j,exports.SimpleViewerProvider=Xe,exports.SimpleViewerReactContext=M,exports.VaultProvider=J,exports.VisibleCanvasReactContext=R,exports.emptyActions=ue,exports.expandTarget=O,exports.flattenAnnotationPageIds=pe,exports.getImageStrategy=le,exports.getPaintables=ce,exports.parseSelector=N,exports.parseSpecificResource=se,exports.unknownResponse=H,exports.unsupportedStrategy=S,exports.useAnnotation=vt,exports.useAnnotationPageManager=he,exports.useAnnotationsAtTime=Ot,exports.useCanvas=x,exports.useCanvasClock=Ct,exports.useCollection=Et,exports.useContextBridge=Ke,exports.useDispatch=_e,exports.useEventListener=xt,exports.useExistingVault=It,exports.useExternalCollection=Vt,exports.useExternalManifest=ee,exports.useImageService=we,exports.useImageServiceLoader=F,exports.useImageTile=Lt,exports.useLoadImageService=Re,exports.useManifest=$,exports.usePaintables=Oe,exports.usePaintingAnnotations=B,exports.useRange=jt,exports.useRenderingStrategy=Rn,exports.useResourceContext=C,exports.useResourceEvents=Dt,exports.useResources=Ce,exports.useSearchService=Ft,exports.useSimpleViewer=Je,exports.useStyleHelper=Nt,exports.useStyles=Bt,exports.useThumbnail=Ut,exports.useVault=y,exports.useVaultEffect=Ee,exports.useVaultSelector=P,exports.useVirtualAnnotationPage=wn,exports.useVisibleCanvases=te;
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var vault = require('@iiif/vault');
7
+ var iiifImageApi = require('@atlas-viewer/iiif-image-api');
8
+ var vaultHelpers = require('@iiif/vault-helpers');
9
+ var typesafeActions = require('typesafe-actions');
10
+
11
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
+
13
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
14
+
15
+ var __defProp$5 = Object.defineProperty;
16
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
17
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
18
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
19
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
20
+ var __spreadValues$5 = (a, b) => {
21
+ for (var prop in b || (b = {}))
22
+ if (__hasOwnProp$5.call(b, prop))
23
+ __defNormalProp$5(a, prop, b[prop]);
24
+ if (__getOwnPropSymbols$5)
25
+ for (var prop of __getOwnPropSymbols$5(b)) {
26
+ if (__propIsEnum$5.call(b, prop))
27
+ __defNormalProp$5(a, prop, b[prop]);
28
+ }
29
+ return a;
30
+ };
31
+ const defaultResourceContext = {
32
+ collection: void 0,
33
+ manifest: void 0,
34
+ range: void 0,
35
+ canvas: void 0,
36
+ annotation: void 0
37
+ };
38
+ const ResourceReactContext = React__default["default"].createContext(defaultResourceContext);
39
+ const useResourceContext = () => {
40
+ return React.useContext(ResourceReactContext);
41
+ };
42
+ const ResourceProvider = ({ value, children }) => {
43
+ const parentContext = useResourceContext();
44
+ const newContext = React.useMemo(() => {
45
+ return __spreadValues$5(__spreadValues$5({}, parentContext), value);
46
+ }, [value, parentContext]);
47
+ return /* @__PURE__ */ React__default["default"].createElement(ResourceReactContext.Provider, {
48
+ value: newContext
49
+ }, children);
50
+ };
51
+
52
+ const AnnotationContext = ({ annotation, children }) => {
53
+ return /* @__PURE__ */ React__default["default"].createElement(ResourceProvider, {
54
+ value: { annotation }
55
+ }, children);
56
+ };
57
+
58
+ const CanvasContext = ({ canvas, children }) => {
59
+ return /* @__PURE__ */ React__default["default"].createElement(ResourceProvider, {
60
+ value: { canvas }
61
+ }, children);
62
+ };
63
+
64
+ const CollectionContext = ({ collection, children }) => {
65
+ return /* @__PURE__ */ React__default["default"].createElement(ResourceProvider, {
66
+ value: { collection }
67
+ }, children);
68
+ };
69
+
70
+ const ManifestContext = ({ manifest, children }) => {
71
+ return /* @__PURE__ */ React__default["default"].createElement(ResourceProvider, {
72
+ value: { manifest }
73
+ }, children);
74
+ };
75
+
76
+ const RangeContext = ({ range, children }) => {
77
+ return /* @__PURE__ */ React__default["default"].createElement(ResourceProvider, {
78
+ value: { range }
79
+ }, children);
80
+ };
81
+
82
+ const ReactVaultContext = React__default["default"].createContext({
83
+ vault: null,
84
+ setVaultInstance: (vault) => {
85
+ }
86
+ });
87
+ const VaultProvider = ({ vault: vault$1, vaultOptions, useGlobal, resources, children }) => {
88
+ const [vaultInstance, setVaultInstance] = React.useState(() => {
89
+ if (vault$1) {
90
+ return vault$1;
91
+ }
92
+ if (useGlobal) {
93
+ return vault.globalVault(vaultOptions);
94
+ }
95
+ if (vaultOptions) {
96
+ return new vault.Vault(vaultOptions);
97
+ }
98
+ return new vault.Vault();
99
+ });
100
+ return /* @__PURE__ */ React__default["default"].createElement(ReactVaultContext.Provider, {
101
+ value: { vault: vaultInstance, setVaultInstance }
102
+ }, /* @__PURE__ */ React__default["default"].createElement(ResourceProvider, {
103
+ value: resources || {}
104
+ }, children));
105
+ };
106
+
107
+ const useVault = () => {
108
+ const { vault } = React.useContext(ReactVaultContext);
109
+ if (vault === null) {
110
+ throw new Error("Vault not found. Ensure you have your provider set up correctly.");
111
+ }
112
+ return vault;
113
+ };
114
+
115
+ var __async$1 = (__this, __arguments, generator) => {
116
+ return new Promise((resolve, reject) => {
117
+ var fulfilled = (value) => {
118
+ try {
119
+ step(generator.next(value));
120
+ } catch (e) {
121
+ reject(e);
122
+ }
123
+ };
124
+ var rejected = (value) => {
125
+ try {
126
+ step(generator.throw(value));
127
+ } catch (e) {
128
+ reject(e);
129
+ }
130
+ };
131
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
132
+ step((generator = generator.apply(__this, __arguments)).next());
133
+ });
134
+ };
135
+ function useExternalResource(idOrRef, { noCache = false } = {}) {
136
+ const id = typeof idOrRef === "string" ? idOrRef : idOrRef.id;
137
+ const vault = useVault();
138
+ const [realId, setRealId] = React.useState(id);
139
+ const [error, setError] = React.useState(void 0);
140
+ const initialData = React.useMemo(() => {
141
+ return vault.get(id, { skipSelfReturn: true }) || void 0;
142
+ }, [id, vault]);
143
+ const [resource, setResource] = React.useState(initialData);
144
+ React.useEffect(() => {
145
+ (() => __async$1(this, null, function* () {
146
+ try {
147
+ const fetchedResource = initialData && !noCache ? initialData : yield vault.load(id);
148
+ const _realId = fetchedResource ? fetchedResource.id || fetchedResource["@id"] : null;
149
+ if (fetchedResource && realId !== _realId) {
150
+ setRealId(_realId);
151
+ }
152
+ setResource(fetchedResource);
153
+ } catch (err) {
154
+ setError(err);
155
+ }
156
+ }))();
157
+ }, [id, noCache]);
158
+ return {
159
+ isLoaded: !!resource,
160
+ id: realId,
161
+ requestId: id,
162
+ error,
163
+ resource,
164
+ cached: !!(resource && resource === initialData)
165
+ };
166
+ }
167
+
168
+ function useExternalManifest(idOrRef, options) {
169
+ const { id, isLoaded, error, resource, requestId, cached } = useExternalResource(idOrRef, options);
170
+ return { id, isLoaded, error, manifest: resource, requestId, cached };
171
+ }
172
+
173
+ function useVaultSelector(selector, deps = []) {
174
+ const vault = useVault();
175
+ const [selectedState, setSelectedState] = React.useState(() => selector(vault.getState(), vault));
176
+ React.useEffect(() => {
177
+ return vault.subscribe((s) => selector(s, vault), (state) => {
178
+ setSelectedState(state);
179
+ }, false);
180
+ }, deps);
181
+ return selectedState;
182
+ }
183
+
184
+ const VisibleCanvasReactContext = React__default["default"].createContext([]);
185
+ function useVisibleCanvases() {
186
+ const ids = React.useContext(VisibleCanvasReactContext);
187
+ return useVaultSelector((state) => {
188
+ return ids.map((id) => state.iiif.entities.Canvas[id]).filter(Boolean);
189
+ }, [ids]);
190
+ }
191
+
192
+ const noop = () => {
193
+ };
194
+ const SimpleViewerReactContext = React.createContext({
195
+ setCurrentCanvasId: noop,
196
+ setCurrentCanvasIndex: noop,
197
+ nextCanvas: noop,
198
+ previousCanvas: noop,
199
+ currentCanvasIndex: -1,
200
+ totalCanvases: 0,
201
+ pagingView: true
202
+ });
203
+ const SimpleViewerProvider = (props) => {
204
+ const manifest = useExternalManifest(props.manifest);
205
+ const [currentCanvasId, setCurrentCanvasId] = React.useState("");
206
+ const [visible, setVisible] = React.useState([]);
207
+ const pagingView = (typeof props.pagingEnabled === "undefined" || props.pagingEnabled) && manifest.manifest && manifest.manifest.behavior && manifest.manifest.behavior.includes("paged");
208
+ React.useEffect(() => {
209
+ var _a, _b;
210
+ if (manifest.manifest) {
211
+ setCurrentCanvasId((_a = manifest.manifest.items[0]) == null ? void 0 : _a.id);
212
+ setVisible([(_b = manifest.manifest.items[0]) == null ? void 0 : _b.id]);
213
+ }
214
+ }, [manifest.manifest, props.manifest]);
215
+ const canvasList = React.useMemo(() => {
216
+ var _a;
217
+ return ((_a = manifest.manifest) == null ? void 0 : _a.items.map((c) => c.id)) || [];
218
+ }, [manifest.manifest, props.manifest]);
219
+ const currentCanvasIndex = React.useMemo(() => canvasList.indexOf(currentCanvasId), [canvasList, currentCanvasId]);
220
+ const nextCanvas = React.useCallback(() => {
221
+ if (canvasList.length && currentCanvasId) {
222
+ if (currentCanvasIndex === -1) {
223
+ return;
224
+ }
225
+ if (canvasList[currentCanvasIndex + 2] ? currentCanvasIndex + 2 === canvasList.length : currentCanvasIndex === canvasList.length) {
226
+ return;
227
+ }
228
+ const newCanvas = pagingView && currentCanvasIndex !== 0 ? canvasList[currentCanvasIndex + 2] : canvasList[currentCanvasIndex + 1];
229
+ const pageCanvas = pagingView ? currentCanvasIndex !== 0 ? canvasList[currentCanvasIndex + 3] : canvasList[currentCanvasIndex + 2] : null;
230
+ if (newCanvas) {
231
+ setCurrentCanvasId(newCanvas);
232
+ setVisible(pageCanvas ? [newCanvas, pageCanvas] : [newCanvas]);
233
+ }
234
+ }
235
+ }, [pagingView, canvasList, currentCanvasId, currentCanvasIndex]);
236
+ const previousCanvas = React.useCallback(() => {
237
+ if (canvasList.length && currentCanvasId) {
238
+ if (currentCanvasIndex === 0 || currentCanvasIndex === -1) {
239
+ return;
240
+ }
241
+ const newCanvas = pagingView && currentCanvasIndex !== 1 ? canvasList[currentCanvasIndex - 2] : canvasList[currentCanvasIndex - 1];
242
+ const pageCanvas = pagingView && currentCanvasIndex !== 1 ? canvasList[currentCanvasIndex - 1] : null;
243
+ if (newCanvas) {
244
+ setCurrentCanvasId(newCanvas);
245
+ setVisible(pageCanvas ? [newCanvas, pageCanvas] : [newCanvas]);
246
+ }
247
+ }
248
+ }, [pagingView, canvasList, currentCanvasId, currentCanvasIndex]);
249
+ const setCurrentCanvasIndex = React.useCallback((idx) => {
250
+ const realIdx = pagingView && idx % 2 === 1 ? idx - 1 : idx;
251
+ const newId = canvasList[realIdx];
252
+ const newNextId = pagingView && realIdx !== 0 ? canvasList[realIdx + 1] : null;
253
+ if (newId) {
254
+ setCurrentCanvasId(newId);
255
+ setVisible((prevValue) => {
256
+ const newValue = newNextId ? [newId, newNextId] : [newId];
257
+ if (prevValue.length === prevValue.length) {
258
+ for (let i = 0; i < prevValue.length; i++) {
259
+ if (prevValue[i] !== newValue[i]) {
260
+ return newValue;
261
+ }
262
+ }
263
+ return prevValue;
264
+ }
265
+ return newValue;
266
+ });
267
+ }
268
+ }, [pagingView, canvasList]);
269
+ const internalSetCurrentCanvasId = React.useCallback((nextId) => {
270
+ const idx = canvasList.indexOf(nextId);
271
+ if (idx !== -1) {
272
+ setCurrentCanvasIndex(idx);
273
+ }
274
+ }, [canvasList, setCurrentCanvasIndex]);
275
+ const ctx = React.useMemo(() => ({
276
+ setCurrentCanvasId: internalSetCurrentCanvasId,
277
+ nextCanvas,
278
+ previousCanvas,
279
+ currentCanvasIndex,
280
+ totalCanvases: canvasList.length,
281
+ setCurrentCanvasIndex,
282
+ pagingView: true
283
+ }), [nextCanvas, previousCanvas, currentCanvasIndex, canvasList, setCurrentCanvasIndex, internalSetCurrentCanvasId]);
284
+ if (!manifest.manifest) {
285
+ console.warn("The manifest passed to the provider is not a valid IIIF manifest.");
286
+ return /* @__PURE__ */ React__default["default"].createElement("div", null, "Sorry, something went wrong.");
287
+ }
288
+ if (!manifest.isLoaded) {
289
+ return /* @__PURE__ */ React__default["default"].createElement("div", null, "Loading...");
290
+ }
291
+ return /* @__PURE__ */ React__default["default"].createElement(SimpleViewerReactContext.Provider, {
292
+ value: ctx
293
+ }, /* @__PURE__ */ React__default["default"].createElement(VisibleCanvasReactContext.Provider, {
294
+ value: visible
295
+ }, /* @__PURE__ */ React__default["default"].createElement(ManifestContext, {
296
+ manifest: manifest.manifest.id
297
+ }, /* @__PURE__ */ React__default["default"].createElement(CanvasContext, {
298
+ canvas: currentCanvasId
299
+ }, props.children))));
300
+ };
301
+ function useSimpleViewer() {
302
+ return React.useContext(SimpleViewerReactContext);
303
+ }
304
+
305
+ function useContextBridge() {
306
+ return {
307
+ VaultContext: React.useContext(ReactVaultContext),
308
+ ResourceContext: React.useContext(ResourceReactContext),
309
+ SimpleViewerReactContext: React.useContext(SimpleViewerReactContext),
310
+ VisibleCanvasReactContext: React.useContext(VisibleCanvasReactContext)
311
+ };
312
+ }
313
+ const ContextBridge = (props) => {
314
+ return /* @__PURE__ */ React__default["default"].createElement(VaultProvider, {
315
+ vault: props.bridge.VaultContext.vault || void 0,
316
+ resources: props.bridge.ResourceContext
317
+ }, /* @__PURE__ */ React__default["default"].createElement(VisibleCanvasReactContext.Provider, {
318
+ value: props.bridge.VisibleCanvasReactContext
319
+ }, /* @__PURE__ */ React__default["default"].createElement(SimpleViewerReactContext.Provider, {
320
+ value: props.bridge.SimpleViewerReactContext
321
+ }, props.children)));
322
+ };
323
+
324
+ const ImageServiceLoaderContext = React__default["default"].createContext(new iiifImageApi.ImageServiceLoader());
325
+ function useImageServiceLoader() {
326
+ return React.useContext(ImageServiceLoaderContext);
327
+ }
328
+
329
+ const BOX_SELECTOR = /&?(xywh=)?(pixel:|percent:)?([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?)/;
330
+ const TEMPORAL_SELECTOR = /&?(t=)(npt:)?([0-9]+(.[0-9]+)?)?(,([0-9]+(.[0-9]+)?))?/;
331
+ function parseSelector(source) {
332
+ if (Array.isArray(source)) {
333
+ return source.reduce((data, nextSource) => {
334
+ const { selector, selectors } = parseSelector(nextSource);
335
+ if (selector) {
336
+ if (!data.selector) {
337
+ data.selector = selector;
338
+ }
339
+ data.selectors.push(...selectors);
340
+ }
341
+ return data;
342
+ }, {
343
+ selector: null,
344
+ selectors: []
345
+ });
346
+ }
347
+ if (!source) {
348
+ return {
349
+ selector: null,
350
+ selectors: []
351
+ };
352
+ }
353
+ if (typeof source === "string") {
354
+ const [id, fragment] = source.split("#");
355
+ if (!fragment) {
356
+ return {
357
+ selector: null,
358
+ selectors: []
359
+ };
360
+ }
361
+ return parseSelector({ type: "FragmentSelector", value: fragment });
362
+ }
363
+ if (source.type === "PointSelector" && (source.t || source.t === 0)) {
364
+ const selector = {
365
+ type: "TemporalSelector",
366
+ temporal: {
367
+ startTime: source.t
368
+ }
369
+ };
370
+ return {
371
+ selector,
372
+ selectors: [selector]
373
+ };
374
+ }
375
+ if (source.type === "FragmentSelector") {
376
+ const matchBoxSelector = BOX_SELECTOR.exec(source.value);
377
+ if (matchBoxSelector) {
378
+ const selector = {
379
+ type: "BoxSelector",
380
+ spatial: {
381
+ unit: matchBoxSelector[2] === "percent:" ? "percent" : "pixel",
382
+ x: parseFloat(matchBoxSelector[3]),
383
+ y: parseFloat(matchBoxSelector[4]),
384
+ width: parseFloat(matchBoxSelector[5]),
385
+ height: parseFloat(matchBoxSelector[6])
386
+ }
387
+ };
388
+ return {
389
+ selector,
390
+ selectors: [selector]
391
+ };
392
+ }
393
+ const matchTimeSelector = source.value.match(TEMPORAL_SELECTOR);
394
+ if (matchTimeSelector) {
395
+ const selector = {
396
+ type: "TemporalSelector",
397
+ temporal: {
398
+ startTime: matchTimeSelector[4] ? parseFloat(matchTimeSelector[4]) : 0,
399
+ endTime: matchTimeSelector[7] ? parseFloat(matchTimeSelector[7]) : void 0
400
+ }
401
+ };
402
+ return {
403
+ selector,
404
+ selectors: [selector]
405
+ };
406
+ }
407
+ return {
408
+ selector: null,
409
+ selectors: []
410
+ };
411
+ }
412
+ return {
413
+ selector: null,
414
+ selectors: []
415
+ };
416
+ }
417
+
418
+ var __defProp$4 = Object.defineProperty;
419
+ var __defProps$4 = Object.defineProperties;
420
+ var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
421
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
422
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
423
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
424
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
425
+ var __spreadValues$4 = (a, b) => {
426
+ for (var prop in b || (b = {}))
427
+ if (__hasOwnProp$4.call(b, prop))
428
+ __defNormalProp$4(a, prop, b[prop]);
429
+ if (__getOwnPropSymbols$4)
430
+ for (var prop of __getOwnPropSymbols$4(b)) {
431
+ if (__propIsEnum$4.call(b, prop))
432
+ __defNormalProp$4(a, prop, b[prop]);
433
+ }
434
+ return a;
435
+ };
436
+ var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
437
+ function expandTarget(target, options = {}) {
438
+ if (Array.isArray(target)) {
439
+ return expandTarget(target[0]);
440
+ }
441
+ if (typeof target === "string") {
442
+ const [id, fragment] = target.split("#");
443
+ if (!fragment) {
444
+ return {
445
+ type: "SpecificResource",
446
+ source: { id, type: options.typeMap && options.typeMap[id] || "Unknown" },
447
+ selector: null,
448
+ selectors: []
449
+ };
450
+ }
451
+ return expandTarget({
452
+ type: "SpecificResource",
453
+ source: { id, type: "Unknown" },
454
+ selector: {
455
+ type: "FragmentSelector",
456
+ value: fragment
457
+ }
458
+ });
459
+ }
460
+ if (target.type === "Choice" || target.type === "List" || target.type === "Composite" || target.type === "Independents") {
461
+ return expandTarget(target.items[0]);
462
+ }
463
+ if (target.type === "SpecificResource") {
464
+ if (target.source.type === "Canvas" && target.source.partOf && typeof target.source.partOf === "string") {
465
+ target.source.partOf = [
466
+ {
467
+ id: target.source.partOf,
468
+ type: "Manifest"
469
+ }
470
+ ];
471
+ }
472
+ const { selector, selectors } = target.selector ? parseSelector(target.selector) : { selector: null, selectors: [] };
473
+ return {
474
+ type: "SpecificResource",
475
+ source: target.source,
476
+ selector,
477
+ selectors
478
+ };
479
+ }
480
+ if (target.id) {
481
+ if (target.type === "Canvas" && target.partOf && typeof target.partOf === "string") {
482
+ target.partOf = [
483
+ {
484
+ id: target.partOf,
485
+ type: "Manifest"
486
+ }
487
+ ];
488
+ }
489
+ const [id, fragment] = target.id.split("#");
490
+ if (!fragment) {
491
+ return {
492
+ type: "SpecificResource",
493
+ source: __spreadProps$4(__spreadValues$4({}, target), {
494
+ id
495
+ }),
496
+ selector: null,
497
+ selectors: []
498
+ };
499
+ }
500
+ return expandTarget({
501
+ type: "SpecificResource",
502
+ source: __spreadProps$4(__spreadValues$4({}, target), {
503
+ id
504
+ }),
505
+ selector: {
506
+ type: "FragmentSelector",
507
+ value: fragment
508
+ }
509
+ });
510
+ }
511
+ return {
512
+ type: "SpecificResource",
513
+ source: target,
514
+ selector: null,
515
+ selectors: []
516
+ };
517
+ }
518
+
519
+ function parseSpecificResource(resource) {
520
+ if (resource.type === "SpecificResource") {
521
+ return [resource.source, { selector: resource.selector }];
522
+ }
523
+ return [resource, { selector: null }];
524
+ }
525
+ function getPaintables(vault, paintingAnnotations, enabledChoices) {
526
+ const types = [];
527
+ let choice = null;
528
+ const items = [];
529
+ for (const annotation of paintingAnnotations) {
530
+ const bodies = vault.get(annotation.body);
531
+ for (const unknownBody of bodies) {
532
+ const [body, { selector }] = parseSpecificResource(unknownBody);
533
+ const type = (body.type || "unknown").toLowerCase();
534
+ if (type === "choice") {
535
+ const nestedBodies = vault.get(body.items);
536
+ const selected = enabledChoices.length ? enabledChoices.map((cid) => nestedBodies.find((b) => b.id === cid)).filter(Boolean) : [nestedBodies[0]];
537
+ if (selected.length === 0) {
538
+ selected.push(nestedBodies[0]);
539
+ }
540
+ choice = {
541
+ type: "single-choice",
542
+ items: nestedBodies.map((b) => ({
543
+ id: b.id,
544
+ label: b.label,
545
+ selected: selected.indexOf(b) !== -1
546
+ })),
547
+ label: unknownBody.label
548
+ };
549
+ bodies.push(...selected);
550
+ continue;
551
+ }
552
+ if (types.indexOf(type) === -1) {
553
+ types.push(type);
554
+ }
555
+ items.push({
556
+ type,
557
+ resource: body,
558
+ target: annotation.target,
559
+ selector
560
+ });
561
+ }
562
+ }
563
+ return {
564
+ types,
565
+ items,
566
+ choice
567
+ };
568
+ }
569
+ const emptyActions = {
570
+ makeChoice: () => {
571
+ }
572
+ };
573
+ const unknownResponse = { type: "unknown" };
574
+ const unsupportedStrategy = (reason) => {
575
+ return { type: "unknown", reason, annotations: { pages: [] } };
576
+ };
577
+
578
+ function getImageStrategy(canvas, paintables, loadImageService) {
579
+ const imageTypes = [];
580
+ for (const singleImage of paintables.items) {
581
+ const resource = singleImage.resource && singleImage.resource.type === "SpecificResource" ? singleImage.resource.source : singleImage.resource;
582
+ if (!resource.id) {
583
+ return unsupportedStrategy("No resource Identifier");
584
+ }
585
+ let imageService = void 0;
586
+ if (resource.service) {
587
+ const imageServices = iiifImageApi.getImageServices(resource);
588
+ if (imageServices[0]) {
589
+ imageService = loadImageService(imageServices[0], canvas);
590
+ }
591
+ }
592
+ const { selector: imageTarget, source } = expandTarget(singleImage.target);
593
+ if (source.id !== canvas.id) {
594
+ continue;
595
+ }
596
+ const defaultTarget = {
597
+ type: "BoxSelector",
598
+ spatial: {
599
+ x: 0,
600
+ y: 0,
601
+ width: canvas.width,
602
+ height: canvas.height
603
+ }
604
+ };
605
+ const target = imageTarget ? imageTarget.type === "TemporalSelector" ? {
606
+ type: "TemporalBoxSelector",
607
+ temporal: imageTarget.temporal,
608
+ spatial: defaultTarget.spatial
609
+ } : imageTarget : null;
610
+ const defaultImageSelector = {
611
+ type: "BoxSelector",
612
+ spatial: {
613
+ x: 0,
614
+ y: 0,
615
+ width: canvas.width,
616
+ height: canvas.height
617
+ }
618
+ };
619
+ const imageSelector = singleImage.resource.type === "SpecificResource" ? expandTarget(singleImage.resource) : null;
620
+ const selector = imageSelector && imageSelector.selector && (imageSelector.selector.type === "BoxSelector" || imageSelector.selector.type === "TemporalBoxSelector") ? {
621
+ type: "BoxSelector",
622
+ spatial: {
623
+ x: imageSelector.selector.spatial.x,
624
+ y: imageSelector.selector.spatial.y,
625
+ width: imageSelector.selector.spatial.width,
626
+ height: imageSelector.selector.spatial.height
627
+ }
628
+ } : defaultImageSelector;
629
+ const imageType = {
630
+ id: resource.id,
631
+ type: "Image",
632
+ width: target ? resource.width : canvas.width,
633
+ height: target ? resource.height : canvas.height,
634
+ service: imageService,
635
+ sizes: imageService && imageService.sizes ? imageService.sizes : resource.width && resource.height ? [{ width: resource.width, height: resource.height }] : [],
636
+ target: target && target.type !== "PointSelector" ? target : defaultTarget,
637
+ selector
638
+ };
639
+ imageTypes.push(imageType);
640
+ }
641
+ return {
642
+ type: "images",
643
+ image: imageTypes[0],
644
+ images: imageTypes,
645
+ choice: paintables.choice
646
+ };
647
+ }
648
+
649
+ var __defProp$3 = Object.defineProperty;
650
+ var __defProps$3 = Object.defineProperties;
651
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
652
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
653
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
654
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
655
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
656
+ var __spreadValues$3 = (a, b) => {
657
+ for (var prop in b || (b = {}))
658
+ if (__hasOwnProp$3.call(b, prop))
659
+ __defNormalProp$3(a, prop, b[prop]);
660
+ if (__getOwnPropSymbols$3)
661
+ for (var prop of __getOwnPropSymbols$3(b)) {
662
+ if (__propIsEnum$3.call(b, prop))
663
+ __defNormalProp$3(a, prop, b[prop]);
664
+ }
665
+ return a;
666
+ };
667
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
668
+ function useAnnotation(options = {}, deps = []) {
669
+ const { id, selector } = options;
670
+ const ctx = useResourceContext();
671
+ const vault = useVault();
672
+ const annotationId = id ? id : ctx.annotation;
673
+ const annotation = useVaultSelector((s) => annotationId ? s.iiif.entities.Annotation[annotationId] : void 0, [annotationId]);
674
+ const body = useVaultSelector((s) => annotation && annotation.body ? annotation.body.map((singleBody) => singleBody ? s.iiif.entities[singleBody.type][singleBody.id] : null).filter(Boolean) : [], [annotation]);
675
+ return React.useMemo(() => {
676
+ if (!annotation) {
677
+ return void 0;
678
+ }
679
+ const newAnnotation = __spreadProps$3(__spreadValues$3({}, annotation), {
680
+ body,
681
+ target: expandTarget(annotation.target, { typeMap: vault.getState().iiif.mapping })
682
+ });
683
+ if (selector) {
684
+ return selector(newAnnotation);
685
+ }
686
+ return newAnnotation;
687
+ }, [annotation, selector, body, ...deps]);
688
+ }
689
+
690
+ function useManifest(options = {}, deps = []) {
691
+ const { id, selector } = options;
692
+ const ctx = useResourceContext();
693
+ useVault();
694
+ const manifestId = id ? id : ctx.manifest;
695
+ const manifest = useVaultSelector((s) => manifestId ? s.iiif.entities.Manifest[manifestId] : void 0, [manifestId]);
696
+ return React.useMemo(() => {
697
+ if (!manifest) {
698
+ return void 0;
699
+ }
700
+ if (selector) {
701
+ return selector(manifest);
702
+ }
703
+ return manifest;
704
+ }, [manifest, selector, ...deps]);
705
+ }
706
+
707
+ function useCanvas(options = {}, deps = []) {
708
+ const { id, selector } = options;
709
+ const ctx = useResourceContext();
710
+ const canvasId = id ? id : ctx.canvas;
711
+ const canvas = useVaultSelector((s) => canvasId ? s.iiif.entities.Canvas[canvasId] : void 0, [canvasId]);
712
+ return React.useMemo(() => {
713
+ if (!canvas) {
714
+ return void 0;
715
+ }
716
+ if (selector) {
717
+ return selector(canvas);
718
+ }
719
+ return canvas;
720
+ }, [canvas, selector, ...deps]);
721
+ }
722
+
723
+ function getMeta$1(state, resourceId) {
724
+ var _a;
725
+ const resourceMeta = (_a = state == null ? void 0 : state.iiif) == null ? void 0 : _a.meta[resourceId];
726
+ if (!resourceMeta) {
727
+ return null;
728
+ }
729
+ return resourceMeta.annotationPageManager;
730
+ }
731
+ function useEnabledAnnotationPageIds(resourceId, availablePageIds) {
732
+ return useVaultSelector((state) => {
733
+ const pageIds = [];
734
+ if (!resourceId) {
735
+ return pageIds;
736
+ }
737
+ const allAnnotationListIds = Object.keys(state.iiif.entities.AnnotationPage);
738
+ for (const annotationListId of allAnnotationListIds) {
739
+ if (!availablePageIds || availablePageIds.indexOf(annotationListId) !== -1) {
740
+ const annotationListMeta = getMeta$1(state, annotationListId);
741
+ if (annotationListMeta && annotationListMeta.views && annotationListMeta.views[resourceId]) {
742
+ pageIds.push(annotationListId);
743
+ }
744
+ }
745
+ }
746
+ return pageIds;
747
+ }, [resourceId, availablePageIds]);
748
+ }
749
+
750
+ function flattenAnnotationPageIds({
751
+ canvas,
752
+ manifest,
753
+ all,
754
+ canvases
755
+ }) {
756
+ const foundIds = [];
757
+ if (manifest) {
758
+ for (const page of manifest.annotations) {
759
+ if (foundIds.indexOf(page.id) === -1) {
760
+ foundIds.push(page.id);
761
+ }
762
+ }
763
+ }
764
+ if (all) {
765
+ if (canvases && canvases.length) {
766
+ for (const canvas_ of canvases) {
767
+ for (const page of canvas_.annotations) {
768
+ if (foundIds.indexOf(page.id) === -1) {
769
+ foundIds.push(page.id);
770
+ }
771
+ }
772
+ }
773
+ }
774
+ } else if (canvas) {
775
+ for (const page of canvas.annotations) {
776
+ if (foundIds.indexOf(page.id) === -1) {
777
+ foundIds.push(page.id);
778
+ }
779
+ }
780
+ }
781
+ return foundIds;
782
+ }
783
+
784
+ var __defProp$2 = Object.defineProperty;
785
+ var __defProps$2 = Object.defineProperties;
786
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
787
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
788
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
789
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
790
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
791
+ var __spreadValues$2 = (a, b) => {
792
+ for (var prop in b || (b = {}))
793
+ if (__hasOwnProp$2.call(b, prop))
794
+ __defNormalProp$2(a, prop, b[prop]);
795
+ if (__getOwnPropSymbols$2)
796
+ for (var prop of __getOwnPropSymbols$2(b)) {
797
+ if (__propIsEnum$2.call(b, prop))
798
+ __defNormalProp$2(a, prop, b[prop]);
799
+ }
800
+ return a;
801
+ };
802
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
803
+ function getMeta(state, resourceId) {
804
+ var _a;
805
+ const resourceMeta = (_a = state == null ? void 0 : state.iiif) == null ? void 0 : _a.meta[resourceId];
806
+ if (!resourceMeta) {
807
+ return null;
808
+ }
809
+ return resourceMeta.annotationPageManager;
810
+ }
811
+ function useAnnotationPageManager(resourceId, options = {}) {
812
+ const vault = useVault();
813
+ const manifest = useManifest();
814
+ const canvas = useCanvas();
815
+ const canvases = useVisibleCanvases();
816
+ const availablePageIds = React.useMemo(() => {
817
+ return flattenAnnotationPageIds({
818
+ all: options.all,
819
+ manifest,
820
+ canvas,
821
+ canvases
822
+ });
823
+ }, [options.all, canvas, canvases, manifest]);
824
+ const enabledPageIds = useEnabledAnnotationPageIds(resourceId, options.all ? void 0 : availablePageIds);
825
+ const setPageDisabled = React.useCallback((deselectId) => {
826
+ if (!resourceId) {
827
+ return;
828
+ }
829
+ vault.setMetaValue([deselectId, "annotationPageManager", "views"], (existingResources) => {
830
+ if (existingResources && !existingResources[resourceId]) {
831
+ return existingResources;
832
+ }
833
+ return __spreadProps$2(__spreadValues$2({}, existingResources || {}), {
834
+ [resourceId]: false
835
+ });
836
+ });
837
+ }, [resourceId, vault]);
838
+ const setPageEnabled = React.useCallback((id, opt = {}) => {
839
+ if (!resourceId) {
840
+ return;
841
+ }
842
+ const state = vault.getState();
843
+ const toDeselect = [];
844
+ if (opt == null ? void 0 : opt.deselectOthers) {
845
+ const allAnnotationListIds = Object.keys(state.iiif.entities.AnnotationPage);
846
+ for (const annotationPageId of allAnnotationListIds) {
847
+ const annotationListMeta = getMeta(state, annotationPageId);
848
+ if (annotationListMeta && annotationListMeta.views && annotationListMeta.views[resourceId]) {
849
+ toDeselect.push(annotationPageId);
850
+ }
851
+ }
852
+ }
853
+ for (const deselectId of toDeselect) {
854
+ setPageDisabled(deselectId);
855
+ }
856
+ vault.setMetaValue([id, "annotationPageManager", "views"], (existingResources) => {
857
+ if (existingResources && existingResources[resourceId]) {
858
+ return existingResources;
859
+ }
860
+ return __spreadProps$2(__spreadValues$2({}, existingResources || {}), {
861
+ [resourceId]: true
862
+ });
863
+ });
864
+ }, [resourceId, setPageDisabled, vault]);
865
+ return {
866
+ availablePageIds,
867
+ enabledPageIds,
868
+ setPageEnabled,
869
+ setPageDisabled
870
+ };
871
+ }
872
+
873
+ function usePaintingAnnotations(options = {}) {
874
+ const canvas = useCanvas(options.canvasId ? { id: options.canvasId } : void 0);
875
+ return useVaultSelector((state, vault) => {
876
+ if (!canvas) {
877
+ return [];
878
+ }
879
+ const annotationPages = vault.get(canvas.items);
880
+ const flatAnnotations = [];
881
+ for (const page of annotationPages) {
882
+ flatAnnotations.push(...vault.get(page.items));
883
+ }
884
+ return flatAnnotations;
885
+ }, [canvas]);
886
+ }
887
+
888
+ function useAnnotationsAtTime(time, options = {}) {
889
+ const allAnnotations = usePaintingAnnotations(options);
890
+ return allAnnotations;
891
+ }
892
+
893
+ function useCanvasClock(canvasId, autoplay = false) {
894
+ }
895
+
896
+ function useCollection(options, deps = []) {
897
+ const { id, selector } = options;
898
+ const ctx = useResourceContext();
899
+ const collectionId = id ? id : ctx.collection;
900
+ const collection = useVaultSelector((s) => collectionId ? s.iiif.entities.Collection[collectionId] : void 0, [collectionId]);
901
+ return React.useMemo(() => {
902
+ if (!collection) {
903
+ return void 0;
904
+ }
905
+ if (selector) {
906
+ return selector(collection);
907
+ }
908
+ return collection;
909
+ }, [collection, selector, ...deps]);
910
+ }
911
+
912
+ function useDispatch() {
913
+ const vault = useVault();
914
+ const store = vault.getStore();
915
+ return React.useMemo(() => {
916
+ return (action) => store.dispatch(action);
917
+ }, [store]);
918
+ }
919
+
920
+ function useEventListener(resource, name, listener, scope, deps = []) {
921
+ const vault = useVault();
922
+ const helper = React.useMemo(() => vaultHelpers.createEventsHelper(vault), [vault]);
923
+ React.useEffect(() => {
924
+ const currentResource = resource;
925
+ if (!currentResource) {
926
+ return () => {
927
+ };
928
+ }
929
+ helper.addEventListener(currentResource, name, listener, scope);
930
+ return () => {
931
+ helper.removeEventListener(currentResource, name, listener);
932
+ };
933
+ }, [helper, resource, name, ...deps]);
934
+ }
935
+
936
+ function useExistingVault() {
937
+ const oldContext = React.useContext(ReactVaultContext);
938
+ return oldContext && oldContext.vault ? oldContext.vault : vault.globalVault();
939
+ }
940
+
941
+ function useExternalCollection(idOrRef, options) {
942
+ const { id, isLoaded, error, resource, requestId, cached } = useExternalResource(idOrRef, options);
943
+ return { id, isLoaded, error, manifest: resource, requestId, cached };
944
+ }
945
+
946
+ var __async = (__this, __arguments, generator) => {
947
+ return new Promise((resolve, reject) => {
948
+ var fulfilled = (value) => {
949
+ try {
950
+ step(generator.next(value));
951
+ } catch (e) {
952
+ reject(e);
953
+ }
954
+ };
955
+ var rejected = (value) => {
956
+ try {
957
+ step(generator.throw(value));
958
+ } catch (e) {
959
+ reject(e);
960
+ }
961
+ };
962
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
963
+ step((generator = generator.apply(__this, __arguments)).next());
964
+ });
965
+ };
966
+ function useImageService({ cacheKey } = {}) {
967
+ const canvas = useCanvas();
968
+ const annotations = usePaintingAnnotations();
969
+ const vault = useVault();
970
+ const imageService = useImageServiceLoader();
971
+ const [_data, setData] = React.useState(void 0);
972
+ const [isFetching, setIsFetching] = React.useState(false);
973
+ const [status, setStatus] = React.useState("idle");
974
+ const [error, setError] = React.useState(void 0);
975
+ const key = canvas ? canvas.id : "undefined";
976
+ const initialData = React.useMemo(() => {
977
+ try {
978
+ if (canvas && annotations.length) {
979
+ const annotation = annotations[0];
980
+ const resource = vault.get(annotation.body[0]);
981
+ const imageServices = iiifImageApi.getImageServices(resource);
982
+ const firstImageService = imageServices[0];
983
+ if (!firstImageService) {
984
+ return void 0;
985
+ }
986
+ return imageService.loadServiceSync({
987
+ id: firstImageService.id || firstImageService["@id"],
988
+ width: firstImageService.width || canvas.width,
989
+ height: firstImageService.height || canvas.height
990
+ }) || void 0;
991
+ }
992
+ } catch (e) {
993
+ console.error(e);
994
+ }
995
+ return void 0;
996
+ }, [key, cacheKey, canvas]);
997
+ const data = status === "success" && _data ? _data : initialData;
998
+ React.useEffect(() => {
999
+ (() => __async(this, null, function* () {
1000
+ try {
1001
+ if (canvas && annotations.length) {
1002
+ const annotation = annotations[0];
1003
+ const resource = vault.get(annotation.body[0]);
1004
+ const imageServices = iiifImageApi.getImageServices(resource);
1005
+ const firstImageService = imageServices[0];
1006
+ if (!firstImageService) {
1007
+ return;
1008
+ }
1009
+ setIsFetching(true);
1010
+ setStatus("loading");
1011
+ try {
1012
+ const loadedService = (yield imageService.loadService({
1013
+ id: firstImageService.id || firstImageService["@id"],
1014
+ width: firstImageService.width || canvas.width,
1015
+ height: firstImageService.height || canvas.height
1016
+ })) || void 0;
1017
+ setData(loadedService);
1018
+ setStatus("success");
1019
+ setIsFetching(false);
1020
+ } catch (err) {
1021
+ setStatus("error");
1022
+ setError(err);
1023
+ }
1024
+ }
1025
+ } catch (err) {
1026
+ setStatus("error");
1027
+ setError(err);
1028
+ }
1029
+ }))();
1030
+ }, [key, cacheKey]);
1031
+ return React.useMemo(() => {
1032
+ return {
1033
+ data,
1034
+ isFetching,
1035
+ status,
1036
+ error
1037
+ };
1038
+ }, [data, isFetching, status, error]);
1039
+ }
1040
+
1041
+ function useImageTile() {
1042
+ const imageService = useImageService();
1043
+ return {
1044
+ isLoading: imageService.isFetching,
1045
+ tile: imageService.data ? {
1046
+ id: imageService.data.id || imageService.data["@id"],
1047
+ width: imageService.data.width,
1048
+ height: imageService.data.height,
1049
+ imageService: imageService.data,
1050
+ thumbnail: void 0
1051
+ } : null
1052
+ };
1053
+ }
1054
+
1055
+ function usePaintables(options, deps = []) {
1056
+ const vault = useVault();
1057
+ const paintingAnnotations = usePaintingAnnotations();
1058
+ const [enabledChoices, setEnabledChoices] = React.useState((options == null ? void 0 : options.defaultChoices) || []);
1059
+ const paintables = React.useMemo(() => getPaintables(vault, paintingAnnotations, enabledChoices), [vault, paintingAnnotations, enabledChoices, ...deps]);
1060
+ const makeChoice = React.useCallback((id, { deselectOthers = true, deselect = false } = {}) => {
1061
+ if (paintables.choice) {
1062
+ if (paintables.choice.type !== "single-choice") {
1063
+ throw new Error("Complex choice not supported yet");
1064
+ }
1065
+ setEnabledChoices((prevChoices) => {
1066
+ if (deselect) {
1067
+ const without = prevChoices.filter((e) => e !== id);
1068
+ if (without.length === 0) {
1069
+ const defaultId = paintables.items[0].resource.id;
1070
+ if (defaultId) {
1071
+ return [defaultId];
1072
+ } else {
1073
+ return [];
1074
+ }
1075
+ }
1076
+ return without;
1077
+ }
1078
+ if (deselectOthers) {
1079
+ return [id];
1080
+ }
1081
+ const newChoices = [...prevChoices];
1082
+ if (newChoices.length === 0 && paintables.items.length) {
1083
+ const defaultId = paintables.items[0].resource.id;
1084
+ if (defaultId) {
1085
+ newChoices.push(defaultId);
1086
+ }
1087
+ }
1088
+ if (prevChoices.indexOf(id) !== -1) {
1089
+ return prevChoices;
1090
+ }
1091
+ return [...prevChoices, id];
1092
+ });
1093
+ }
1094
+ }, [paintables.choice]);
1095
+ const actions = { makeChoice };
1096
+ return [paintables, actions];
1097
+ }
1098
+
1099
+ function useRange(options = {}, deps = []) {
1100
+ const { id, selector } = options;
1101
+ const ctx = useResourceContext();
1102
+ const rangeId = id ? id : ctx.range;
1103
+ const range = useVaultSelector((s) => rangeId ? s.iiif.entities.Range[rangeId] : void 0, [rangeId]);
1104
+ return React.useMemo(() => {
1105
+ if (!range) {
1106
+ return void 0;
1107
+ }
1108
+ if (selector) {
1109
+ return selector(range);
1110
+ }
1111
+ return range;
1112
+ }, [range, selector, ...deps]);
1113
+ }
1114
+
1115
+ function useResourceEvents(resource, scope) {
1116
+ const vault = useVault();
1117
+ const helper = React.useMemo(() => vaultHelpers.createEventsHelper(vault), [vault]);
1118
+ const hooks = useVaultSelector(() => {
1119
+ if (resource && resource.id) {
1120
+ return vault.getResourceMeta(resource.id, "eventManager");
1121
+ }
1122
+ return null;
1123
+ }, [resource]);
1124
+ return React.useMemo(() => {
1125
+ return resource ? helper.getListenersAsProps(resource, scope) : {};
1126
+ }, [hooks, resource, vault, scope]);
1127
+ }
1128
+
1129
+ function useResources(ids, type) {
1130
+ return useVaultSelector((state, vault) => vault.get(ids.map((id) => ({ id, type }))), [ids, type]);
1131
+ }
1132
+
1133
+ function useSearchService() {
1134
+ const manifest = useManifest();
1135
+ return manifest ? manifest.service.find((service) => service.profile === "SearchService1" || service.profile === "http://iiif.io/api/search/1/search") : void 0;
1136
+ }
1137
+
1138
+ function useStyleHelper() {
1139
+ const vault = useVault();
1140
+ return React.useMemo(() => vaultHelpers.createStylesHelper(vault), [vault]);
1141
+ }
1142
+
1143
+ function useStyles(resource, scope) {
1144
+ const vault = useVault();
1145
+ const helper = React.useMemo(() => vaultHelpers.createStylesHelper(vault), [vault]);
1146
+ return useVaultSelector(() => {
1147
+ if (!resource) {
1148
+ return null;
1149
+ }
1150
+ const styles = helper.getAppliedStyles(resource.id);
1151
+ return styles ? scope ? styles[scope] : styles : void 0;
1152
+ }, [resource, scope]);
1153
+ }
1154
+
1155
+ const useVaultEffect = (callback, deps = []) => {
1156
+ const vault = useVault();
1157
+ React.useEffect(() => {
1158
+ callback(vault);
1159
+ }, [vault, ...deps]);
1160
+ };
1161
+
1162
+ function useThumbnail(request, dereference, { canvasId, manifestId } = {}) {
1163
+ const vault = useVault();
1164
+ const loader = useImageServiceLoader();
1165
+ const helper = React.useMemo(() => vaultHelpers.createThumbnailHelper(vault, { imageServiceLoader: loader }), [vault, loader]);
1166
+ const [thumbnail, setThumbnail] = React.useState();
1167
+ const manifest = useManifest(manifestId ? { id: manifestId } : void 0);
1168
+ const canvas = useCanvas(canvasId ? { id: canvasId } : void 0);
1169
+ const subject = canvas ? canvas : manifest;
1170
+ const didUnmount = React.useRef(false);
1171
+ React.useEffect(() => {
1172
+ return () => {
1173
+ didUnmount.current = true;
1174
+ };
1175
+ }, []);
1176
+ if (!subject) {
1177
+ throw new Error("Must be called under a manifest or canvas context.");
1178
+ }
1179
+ useVaultEffect((v) => {
1180
+ helper.getBestThumbnailAtSize(subject, request, dereference).then((thumb) => {
1181
+ if (thumb.best && !didUnmount.current) {
1182
+ setThumbnail(thumb.best);
1183
+ }
1184
+ });
1185
+ }, [subject]);
1186
+ return thumbnail;
1187
+ }
1188
+
1189
+ var __defProp$1 = Object.defineProperty;
1190
+ var __defProps$1 = Object.defineProperties;
1191
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
1192
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
1193
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
1194
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
1195
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1196
+ var __spreadValues$1 = (a, b) => {
1197
+ for (var prop in b || (b = {}))
1198
+ if (__hasOwnProp$1.call(b, prop))
1199
+ __defNormalProp$1(a, prop, b[prop]);
1200
+ if (__getOwnPropSymbols$1)
1201
+ for (var prop of __getOwnPropSymbols$1(b)) {
1202
+ if (__propIsEnum$1.call(b, prop))
1203
+ __defNormalProp$1(a, prop, b[prop]);
1204
+ }
1205
+ return a;
1206
+ };
1207
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
1208
+ function useLoadImageService() {
1209
+ const loader = useImageServiceLoader();
1210
+ const [imageServiceStatus, setImageServiceStatus] = React.useState({});
1211
+ const didUnmount = React.useRef(false);
1212
+ React.useEffect(() => {
1213
+ return () => {
1214
+ didUnmount.current = true;
1215
+ };
1216
+ }, []);
1217
+ const loadImageService = React.useCallback((imageService, { height, width }) => {
1218
+ if (imageService) {
1219
+ const imageServiceId = imageService.id || imageService["@id"];
1220
+ const syncLoaded = loader.loadServiceSync({
1221
+ id: imageServiceId,
1222
+ width: imageService.width || width,
1223
+ height: imageService.height || height
1224
+ });
1225
+ if (syncLoaded) {
1226
+ imageService = syncLoaded;
1227
+ } else if (!imageServiceStatus[imageServiceId]) {
1228
+ if (!didUnmount.current) {
1229
+ setImageServiceStatus((r) => {
1230
+ return __spreadProps$1(__spreadValues$1({}, r), {
1231
+ [imageServiceId]: "loading"
1232
+ });
1233
+ });
1234
+ }
1235
+ loader.loadService({
1236
+ id: imageServiceId,
1237
+ width: imageService.width || width,
1238
+ height: imageService.height || height
1239
+ }).then(() => {
1240
+ if (!didUnmount.current) {
1241
+ setImageServiceStatus((r) => {
1242
+ return __spreadProps$1(__spreadValues$1({}, r), {
1243
+ [imageServiceId]: "done"
1244
+ });
1245
+ });
1246
+ }
1247
+ });
1248
+ }
1249
+ }
1250
+ return imageService;
1251
+ }, [loader, imageServiceStatus]);
1252
+ return [loadImageService, imageServiceStatus];
1253
+ }
1254
+
1255
+ const IMPORT_ENTITIES = "@iiif/IMPORT_ENTITIES";
1256
+ const MODIFY_ENTITY_FIELD = "@iiif/MODIFY_ENTITY_FIELD";
1257
+ const REORDER_ENTITY_FIELD = "@iiif/REORDER_ENTITY_FIELD";
1258
+ const ADD_REFERENCE = "@iiif/ADD_REFERENCE";
1259
+ const REMOVE_REFERENCE = "@iiif/REMOVE_REFERENCE";
1260
+ const importEntities = typesafeActions.createAction(IMPORT_ENTITIES)();
1261
+ const modifyEntityField = typesafeActions.createAction(MODIFY_ENTITY_FIELD)();
1262
+ const reorderEntityField = typesafeActions.createAction(REORDER_ENTITY_FIELD)();
1263
+ const addReference = typesafeActions.createAction(ADD_REFERENCE)();
1264
+ const removeReference = typesafeActions.createAction(REMOVE_REFERENCE)();
1265
+ const entityActions = { importEntities, modifyEntityField, reorderEntityField, addReference, removeReference };
1266
+
1267
+ const ADD_MAPPING = "@iiif/ADD_MAPPING";
1268
+ const ADD_MAPPINGS = "@iiif/ADD_MAPPINGS";
1269
+ typesafeActions.createAction(ADD_MAPPING)();
1270
+ typesafeActions.createAction(ADD_MAPPINGS)();
1271
+
1272
+ const SET_META_VALUE = "@iiif/SET_META_VALUE";
1273
+ const SET_META_VALUE_DYNAMIC = "@iiif/SET_META_VALUE_DYNAMIC";
1274
+ const UNSET_META_VALUE = "@iiif/UNSET_META_VALUE";
1275
+ typesafeActions.createAction(SET_META_VALUE)();
1276
+ typesafeActions.createAction(SET_META_VALUE_DYNAMIC)();
1277
+ typesafeActions.createAction(UNSET_META_VALUE)();
1278
+ const REQUEST_RESOURCE = "@iiif/REQUEST_RESOURCE";
1279
+ const REQUEST_ERROR = "@iiif/REQUEST_ERROR";
1280
+ const REQUEST_MISMATCH = "@iiif/REQUEST_MISMATCH";
1281
+ const REQUEST_COMPLETE = "@iiif/REQUEST_COMPLETE";
1282
+ const REQUEST_OFFLINE_RESOURCE = "@iiif/REQUEST_OFFLINE_RESOURCE";
1283
+ typesafeActions.createAction(REQUEST_RESOURCE)();
1284
+ typesafeActions.createAction(REQUEST_ERROR)();
1285
+ typesafeActions.createAction(REQUEST_MISMATCH)();
1286
+ typesafeActions.createAction(REQUEST_COMPLETE)();
1287
+ typesafeActions.createAction(REQUEST_OFFLINE_RESOURCE)();
1288
+
1289
+ const BATCH_ACTIONS = "@iiif/BATCH";
1290
+ const BATCH_IMPORT = "@iiif/BATCH_IMPORT";
1291
+ typesafeActions.createAction(BATCH_ACTIONS)();
1292
+ typesafeActions.createAction(BATCH_IMPORT)();
1293
+
1294
+ function isVaultActivated(obj) {
1295
+ return typeof obj !== "string" && obj && obj.bindToVault;
1296
+ }
1297
+ function useVirtualAnnotationPage() {
1298
+ const vault = useVault();
1299
+ const sources = React.useRef([]);
1300
+ const dispatch = useDispatch();
1301
+ const virtualId = React.useMemo(() => {
1302
+ return `vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random() * 1e9).toString(16)}`;
1303
+ }, []);
1304
+ React.useLayoutEffect(() => {
1305
+ const page = {
1306
+ id: virtualId,
1307
+ type: "AnnotationPage",
1308
+ behavior: [],
1309
+ motivation: null,
1310
+ label: null,
1311
+ thumbnail: [],
1312
+ summary: null,
1313
+ requiredStatement: null,
1314
+ metadata: [],
1315
+ rights: null,
1316
+ provider: [],
1317
+ items: [],
1318
+ seeAlso: [],
1319
+ homepage: [],
1320
+ logo: [],
1321
+ rendering: [],
1322
+ service: []
1323
+ };
1324
+ dispatch(entityActions.importEntities({
1325
+ entities: {
1326
+ AnnotationPage: {
1327
+ [page.id]: page
1328
+ }
1329
+ }
1330
+ }));
1331
+ }, [virtualId]);
1332
+ const fullPage = useVaultSelector((state) => virtualId ? state.iiif.entities.AnnotationPage[virtualId] : null, [virtualId]);
1333
+ const addAnnotation = React.useCallback((id, atIndex) => {
1334
+ if (virtualId) {
1335
+ if (isVaultActivated(id)) {
1336
+ const display = id;
1337
+ if (!display.__vault) {
1338
+ display.bindToVault(vault);
1339
+ }
1340
+ id = typeof display.source === "string" ? display.source : display.source.id;
1341
+ sources.current[id] = display;
1342
+ } else if (typeof id !== "string") {
1343
+ id = id.id;
1344
+ }
1345
+ const full = vault.get({ id: virtualId, type: "AnnotationPage" });
1346
+ const annotation = vault.get({ id, type: "Annotation" });
1347
+ if (full && annotation) {
1348
+ if (!full.items.find((r) => r.id === annotation.id)) {
1349
+ dispatch(entityActions.addReference({
1350
+ id: virtualId,
1351
+ type: "AnnotationPage",
1352
+ key: "items",
1353
+ reference: {
1354
+ id,
1355
+ type: "Annotation"
1356
+ },
1357
+ index: atIndex
1358
+ }));
1359
+ }
1360
+ }
1361
+ }
1362
+ }, [virtualId]);
1363
+ const removeAnnotation = React.useCallback((id) => {
1364
+ if (virtualId) {
1365
+ if (isVaultActivated(id)) {
1366
+ id = typeof id.source === "string" ? id.source : id.source.id;
1367
+ } else if (typeof id !== "string") {
1368
+ id = id.id;
1369
+ }
1370
+ if (sources.current[id]) {
1371
+ sources.current[id].beforeRemove();
1372
+ }
1373
+ const full = vault.get({ id: virtualId, type: "AnnotationPage" });
1374
+ if (full) {
1375
+ dispatch(entityActions.removeReference({
1376
+ id: virtualId,
1377
+ type: "AnnotationPage",
1378
+ key: "items",
1379
+ reference: {
1380
+ id,
1381
+ type: "Annotation"
1382
+ }
1383
+ }));
1384
+ }
1385
+ }
1386
+ }, [virtualId]);
1387
+ return [
1388
+ fullPage,
1389
+ {
1390
+ addAnnotation,
1391
+ removeAnnotation
1392
+ }
1393
+ ];
1394
+ }
1395
+
1396
+ var __defProp = Object.defineProperty;
1397
+ var __defProps = Object.defineProperties;
1398
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
1399
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
1400
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
1401
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
1402
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1403
+ var __spreadValues = (a, b) => {
1404
+ for (var prop in b || (b = {}))
1405
+ if (__hasOwnProp.call(b, prop))
1406
+ __defNormalProp(a, prop, b[prop]);
1407
+ if (__getOwnPropSymbols)
1408
+ for (var prop of __getOwnPropSymbols(b)) {
1409
+ if (__propIsEnum.call(b, prop))
1410
+ __defNormalProp(a, prop, b[prop]);
1411
+ }
1412
+ return a;
1413
+ };
1414
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1415
+ function useRenderingStrategy(options) {
1416
+ const manifest = useManifest();
1417
+ const canvas = useCanvas();
1418
+ const vault = useVault();
1419
+ const [loadImageService, imageServiceStatus] = useLoadImageService();
1420
+ const { enabledPageIds } = useAnnotationPageManager((options == null ? void 0 : options.annotationPageManagerId) || (manifest == null ? void 0 : manifest.id) || (canvas == null ? void 0 : canvas.id), {
1421
+ all: false
1422
+ });
1423
+ const enabledPages = useResources(enabledPageIds, "AnnotationPage");
1424
+ const supports = (options == null ? void 0 : options.strategies) || ["images", "media", "complex-timeline"];
1425
+ const [paintables, actions] = usePaintables(options, [imageServiceStatus]);
1426
+ const strategy = React.useMemo(() => {
1427
+ if (!canvas || paintables.types.length === 0) {
1428
+ return unknownResponse;
1429
+ }
1430
+ if (paintables.types.length !== 1) {
1431
+ if (supports.indexOf("complex-timeline") === -1) {
1432
+ return unsupportedStrategy("Complex timeline not supported");
1433
+ }
1434
+ return unsupportedStrategy("ComplexTimelineStrategy not yet supported");
1435
+ }
1436
+ const mainType = paintables.types[0];
1437
+ if (mainType === "image") {
1438
+ if (supports.indexOf("images") === -1) {
1439
+ return unsupportedStrategy("Image not supported");
1440
+ }
1441
+ return getImageStrategy(canvas, paintables, loadImageService);
1442
+ }
1443
+ if (mainType === "audio") {
1444
+ if (supports.indexOf("media") === -1) {
1445
+ return unsupportedStrategy("Media not supported");
1446
+ }
1447
+ return unsupportedStrategy("Audio strategy not yet supported");
1448
+ }
1449
+ if (mainType === "video") {
1450
+ if (supports.indexOf("media") === -1) {
1451
+ return unsupportedStrategy("Media not supported");
1452
+ }
1453
+ return unsupportedStrategy("Video strategy not yet supported");
1454
+ }
1455
+ return unknownResponse;
1456
+ }, [canvas, paintables, vault, actions.makeChoice]);
1457
+ return React.useMemo(() => {
1458
+ if (strategy.type === "unknown") {
1459
+ return [strategy, emptyActions];
1460
+ }
1461
+ return [
1462
+ __spreadProps(__spreadValues({}, strategy), {
1463
+ annotations: { pages: enabledPages }
1464
+ }),
1465
+ actions
1466
+ ];
1467
+ }, [strategy, enabledPages]);
1468
+ }
1469
+
1470
+ exports.AnnotationContext = AnnotationContext;
1471
+ exports.CanvasContext = CanvasContext;
1472
+ exports.CollectionContext = CollectionContext;
1473
+ exports.ContextBridge = ContextBridge;
1474
+ exports.ImageServiceLoaderContext = ImageServiceLoaderContext;
1475
+ exports.ManifestContext = ManifestContext;
1476
+ exports.RangeContext = RangeContext;
1477
+ exports.ReactVaultContext = ReactVaultContext;
1478
+ exports.ResourceProvider = ResourceProvider;
1479
+ exports.ResourceReactContext = ResourceReactContext;
1480
+ exports.SimpleViewerProvider = SimpleViewerProvider;
1481
+ exports.SimpleViewerReactContext = SimpleViewerReactContext;
1482
+ exports.VaultProvider = VaultProvider;
1483
+ exports.VisibleCanvasReactContext = VisibleCanvasReactContext;
1484
+ exports.emptyActions = emptyActions;
1485
+ exports.expandTarget = expandTarget;
1486
+ exports.flattenAnnotationPageIds = flattenAnnotationPageIds;
1487
+ exports.getImageStrategy = getImageStrategy;
1488
+ exports.getPaintables = getPaintables;
1489
+ exports.parseSelector = parseSelector;
1490
+ exports.parseSpecificResource = parseSpecificResource;
1491
+ exports.unknownResponse = unknownResponse;
1492
+ exports.unsupportedStrategy = unsupportedStrategy;
1493
+ exports.useAnnotation = useAnnotation;
1494
+ exports.useAnnotationPageManager = useAnnotationPageManager;
1495
+ exports.useAnnotationsAtTime = useAnnotationsAtTime;
1496
+ exports.useCanvas = useCanvas;
1497
+ exports.useCanvasClock = useCanvasClock;
1498
+ exports.useCollection = useCollection;
1499
+ exports.useContextBridge = useContextBridge;
1500
+ exports.useDispatch = useDispatch;
1501
+ exports.useEventListener = useEventListener;
1502
+ exports.useExistingVault = useExistingVault;
1503
+ exports.useExternalCollection = useExternalCollection;
1504
+ exports.useExternalManifest = useExternalManifest;
1505
+ exports.useExternalResource = useExternalResource;
1506
+ exports.useImageService = useImageService;
1507
+ exports.useImageServiceLoader = useImageServiceLoader;
1508
+ exports.useImageTile = useImageTile;
1509
+ exports.useLoadImageService = useLoadImageService;
1510
+ exports.useManifest = useManifest;
1511
+ exports.usePaintables = usePaintables;
1512
+ exports.usePaintingAnnotations = usePaintingAnnotations;
1513
+ exports.useRange = useRange;
1514
+ exports.useRenderingStrategy = useRenderingStrategy;
1515
+ exports.useResourceContext = useResourceContext;
1516
+ exports.useResourceEvents = useResourceEvents;
1517
+ exports.useResources = useResources;
1518
+ exports.useSearchService = useSearchService;
1519
+ exports.useSimpleViewer = useSimpleViewer;
1520
+ exports.useStyleHelper = useStyleHelper;
1521
+ exports.useStyles = useStyles;
1522
+ exports.useThumbnail = useThumbnail;
1523
+ exports.useVault = useVault;
1524
+ exports.useVaultEffect = useVaultEffect;
1525
+ exports.useVaultSelector = useVaultSelector;
1526
+ exports.useVirtualAnnotationPage = useVirtualAnnotationPage;
1527
+ exports.useVisibleCanvases = useVisibleCanvases;