react-iiif-vault 0.9.15 → 0.9.16
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/.build/types/canvas-panel/Viewer.d.ts +1 -1
- package/.build/types/canvas-panel/index.d.ts +2 -0
- package/.build/types/canvas-panel/render/Canvas.d.ts +8 -3
- package/.build/types/canvas-panel/render/CanvasBackground.d.ts +4 -0
- package/.build/types/canvas-panel/render/Image.d.ts +2 -2
- package/.build/types/context/ContextBridge.d.ts +1 -9
- package/.build/types/context/PortalContext.d.ts +3 -2
- package/.build/types/features/rendering-strategy/3d-strategy.d.ts +1 -1
- package/.build/types/features/rendering-strategy/rendering-utils.d.ts +5 -1
- package/.build/types/features/rendering-strategy/resource-types.d.ts +3 -0
- package/.build/types/features/rendering-strategy/strategies.d.ts +10 -1
- package/.build/types/features/rendering-strategy/textual-content-strategy.d.ts +17 -0
- package/.build/types/future-helpers/ranges.d.ts +6 -0
- package/.build/types/future-helpers/sequences.d.ts +6 -0
- package/.build/types/hooks/useCanvasSubset.d.ts +2 -0
- package/.build/types/index.d.ts +5 -0
- package/.build/types/viewers/SimpleViewerContext.d.ts +4 -16
- package/.build/types/viewers/SimpleViewerContext.hooks.d.ts +14 -0
- package/.build/types/viewers/SimpleViewerContext.types.d.ts +42 -0
- package/dist/bundle/cjs/index.js +5 -3
- package/dist/bundle/cjs/index.js.map +1 -1
- package/dist/bundle/esm/index.mjs +1020 -214
- package/dist/bundle/esm/index.mjs.map +1 -1
- package/dist/canvas-panel/cjs/canvas-panel.js +5 -3
- package/dist/canvas-panel/cjs/canvas-panel.js.map +1 -1
- package/dist/canvas-panel/esm/canvas-panel.mjs +729 -94
- package/dist/canvas-panel/esm/canvas-panel.mjs.map +1 -1
- package/dist/index.umd.js +22 -20
- package/dist/index.umd.js.map +1 -1
- package/dist/react17/cjs/index.js +30 -0
- package/dist/react17/cjs/index.js.map +1 -0
- package/dist/react17/esm/index.mjs +3186 -0
- package/dist/react17/esm/index.mjs.map +1 -0
- package/package.json +13 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Ae=Object.defineProperty,be=Object.defineProperties;var Te=Object.getOwnPropertyDescriptors;var k=Object.getOwnPropertySymbols;var J=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable;var X=(e,t,r)=>t in e?Ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,y=(e,t)=>{for(var r in t||(t={}))J.call(t,r)&&X(e,r,t[r]);if(k)for(var r of k(t))Z.call(t,r)&&X(e,r,t[r]);return e},E=(e,t)=>be(e,Te(t));var ee=(e,t)=>{var r={};for(var n in e)J.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&k)for(var n of k(e))t.indexOf(n)<0&&Z.call(e,n)&&(r[n]=e[n]);return r};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var c=require("react"),L=require("@atlas-viewer/atlas"),f=require("react/jsx-runtime"),D=require("@iiif/vault"),S=require("typesafe-actions"),Me=require("react-dom"),j=require("@atlas-viewer/iiif-image-api");function ce(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}function we(e){if(e&&e.__esModule)return e;var t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var N=we(c),w=ce(c),_e=ce(Me);function H(e,t){return H=Object.setPrototypeOf||function(n,o){return n.__proto__=o,n},H(e,t)}function je(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,H(e,t)}var Oe=function(t,r){return t===void 0&&(t=[]),r===void 0&&(r=[]),t.length!==r.length||t.some(function(n,o){return!Object.is(n,r[o])})},te={error:null},Ie=function(e){je(t,e);function t(){for(var n,o=arguments.length,i=new Array(o),s=0;s<o;s++)i[s]=arguments[s];return n=e.call.apply(e,[this].concat(i))||this,n.state=te,n.resetErrorBoundary=function(){for(var a,d=arguments.length,u=new Array(d),l=0;l<d;l++)u[l]=arguments[l];n.props.onReset==null||(a=n.props).onReset.apply(a,u),n.reset()},n}t.getDerivedStateFromError=function(o){return{error:o}};var r=t.prototype;return r.reset=function(){this.setState(te)},r.componentDidCatch=function(o,i){var s,a;(s=(a=this.props).onError)==null||s.call(a,o,i)},r.componentDidUpdate=function(o,i){var s=this.state.error,a=this.props.resetKeys;if(s!==null&&i.error!==null&&Oe(o.resetKeys,a)){var d,u;(d=(u=this.props).onResetKeysChange)==null||d.call(u,o.resetKeys,a),this.reset()}},r.render=function(){var o=this.state.error,i=this.props,s=i.fallbackRender,a=i.FallbackComponent,d=i.fallback;if(o!==null){var u={error:o,resetErrorBoundary:this.resetErrorBoundary};if(N.isValidElement(d))return d;if(typeof s=="function")return s(u);if(a)return N.createElement(a,u);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},t}(N.Component);const ke={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0},z=w.default.createContext(ke),U=()=>c.useContext(z);function ue({value:e,children:t}){const r=U(),n=c.useMemo(()=>y(y({},r),e),[e,r]);return f.jsx(z.Provider,{value:n,children:t})}const $=w.default.createContext({vault:null,setVaultInstance:e=>{}});function Fe({vault:e,vaultOptions:t,useGlobal:r,resources:n,children:o}){const[i,s]=c.useState(()=>e||(r?D.globalVault(t):t?new D.Vault(t):new D.Vault));return f.jsx($.Provider,{value:{vault:i,setVaultInstance:s},children:f.jsx(ue,{value:n||{},children:o})})}const R=()=>{const{vault:e}=c.useContext($);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};function Le({canvas:e,children:t}){return f.jsx(ue,{value:{canvas:e},children:t})}function b(e,t=[]){const r=R(),[n,o]=c.useState(()=>e(r.getState(),r));return c.useEffect(()=>r.subscribe(i=>e(i,r),i=>{o(i)},!1),t),n}const q=w.default.createContext([]);function Ve(){const e=c.useContext(q);return b(t=>e.map(r=>t.iiif.entities.Canvas[r]).filter(Boolean),[e])}const F=()=>{},le=c.createContext({setCurrentCanvasId:F,setCurrentCanvasIndex:F,nextCanvas:F,previousCanvas:F,currentCanvasIndex:-1,totalCanvases:0,pagingView:!0});function Ue(){return{VaultContext:c.useContext($),ResourceContext:c.useContext(z),SimpleViewerReactContext:c.useContext(le),VisibleCanvasReactContext:c.useContext(q)}}function De(e){return f.jsx(Fe,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:f.jsx(q.Provider,{value:e.bridge.VisibleCanvasReactContext,children:f.jsx(le.Provider,{value:e.bridge.SimpleViewerReactContext,children:e.children})})})}const Ne="@iiif/IMPORT_ENTITIES",Be="@iiif/MODIFY_ENTITY_FIELD",He="@iiif/REORDER_ENTITY_FIELD",Ye="@iiif/ADD_REFERENCE",Qe="@iiif/REMOVE_REFERENCE",ze=S.createAction(Ne)(),$e=S.createAction(Be)(),qe=S.createAction(He)(),Ge=S.createAction(Ye)(),Ke=S.createAction(Qe)(),B={importEntities:ze,modifyEntityField:$e,reorderEntityField:qe,addReference:Ge,removeReference:Ke},We="@iiif/ADD_MAPPING",Xe="@iiif/ADD_MAPPINGS";S.createAction(We)();S.createAction(Xe)();const Je="@iiif/SET_META_VALUE",Ze="@iiif/SET_META_VALUE_DYNAMIC",et="@iiif/UNSET_META_VALUE";S.createAction(Je)();S.createAction(Ze)();S.createAction(et)();const tt="@iiif/REQUEST_RESOURCE",nt="@iiif/REQUEST_ERROR",rt="@iiif/REQUEST_MISMATCH",ot="@iiif/REQUEST_COMPLETE",it="@iiif/REQUEST_OFFLINE_RESOURCE";S.createAction(tt)();S.createAction(nt)();S.createAction(rt)();S.createAction(ot)();S.createAction(it)();const st="@iiif/BATCH",at="@iiif/BATCH_IMPORT";S.createAction(st)();S.createAction(at)();function ct(){const t=R().getStore();return c.useMemo(()=>r=>t.dispatch(r),[t])}function ne(e){return typeof e!="string"&&e&&e.bindToVault}function ut(){const e=R(),t=c.useRef([]),r=ct(),n=c.useMemo(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);c.useLayoutEffect(()=>{const a={id:n,type:"AnnotationPage",behavior:[],motivation:null,label:null,thumbnail:[],summary:null,requiredStatement:null,metadata:[],rights:null,provider:[],items:[],seeAlso:[],homepage:[],logo:[],rendering:[],service:[]};r(B.importEntities({entities:{AnnotationPage:{[a.id]:a}}}))},[n]);const o=b(a=>n?a.iiif.entities.AnnotationPage[n]:null,[n]),i=c.useCallback((a,d)=>{if(n){if(ne(a)){const p=a;p.__vault||p.bindToVault(e),a=typeof p.source=="string"?p.source:p.source.id,t.current[a]=p}else typeof a!="string"&&(a=a.id);const u=e.get({id:n,type:"AnnotationPage"}),l=e.get({id:a,type:"Annotation"});u&&l&&(u.items.find(p=>p.id===l.id)||r(B.addReference({id:n,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"},index:d})))}},[n]),s=c.useCallback(a=>{n&&(ne(a)?a=typeof a.source=="string"?a.source:a.source.id:typeof a!="string"&&(a=a.id),t.current[a]&&t.current[a].beforeRemove(),e.get({id:n,type:"AnnotationPage"})&&r(B.removeReference({id:n,type:"AnnotationPage",key:"items",reference:{id:a,type:"Annotation"}})))},[n]);return[o,{addAnnotation:i,removeAnnotation:s}]}const fe=c.createContext(null);function lt(){const e=c.useContext(fe);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function ft({children:e}){const[t,{addAnnotation:r,removeAnnotation:n}]=ut();return f.jsx(fe.Provider,{value:c.useMemo(()=>({fullPage:t,addAnnotation:r,removeAnnotation:n}),[t]),children:e})}function dt({width:e,style:t,height:r}){return f.jsx("div",{style:E(y({width:e,height:r,minHeight:500},t||{}),{background:"#f9f9f9"}),children:"Unknown error"})}var de,pt=_e.default;de=pt.createRoot;const G=c.createContext(null);function mt(){return c.useContext(G)}const pe=w.default.createContext(null),me=w.default.createContext(null);function O({children:e,overlay:t}){const r=c.useContext(t?me:pe),n=c.useRef(null),o=mt();return c.useLayoutEffect(()=>{n.current||(n.current=r?de(r):null)},[]),c.useLayoutEffect(()=>()=>{var i;(i=n.current)==null||i.unmount(),n.current=null},[]),c.useLayoutEffect(()=>{n.current&&n.current.render(f.jsx(G.Provider,{value:o,children:e}))},[e,o]),null}function ht(o){var i=o,{children:e,errorFallback:t,outerContainerProps:r={}}=i,n=ee(i,["children","errorFallback","outerContainerProps"]);const s=c.useRef(null),[a,d]=c.useState(),[u,l]=c.useState(),p=c.useRef(null),[m,v]=c.useState(),g=Ue(),h=t||dt;return c.useLayoutEffect(()=>{d(s.current),v(p.current)},[]),f.jsxs(Ie,{fallbackRender:()=>f.jsx(h,y({},n)),children:[f.jsx(L.AtlasAuto,E(y({},n),{containerProps:y({style:{position:"relative"}},n.containerProps||{}),htmlChildren:f.jsx("div",{ref:p}),onCreated:T=>{l(T),n.onCreated&&n.onCreated(T)},children:f.jsx(G.Provider,{value:u,children:f.jsx(pe.Provider,{value:a,children:f.jsx(me.Provider,{value:m,children:f.jsx(De,{bridge:g,children:f.jsx(ft,{children:e})})})})})})),f.jsx("div",{ref:s})]})}function gt(e){return{addEventListener(t,r,n,o){if(!!t)return e.setMetaValue([t.id,"eventManager",r],i=>{const s=i||[];for(const a of s)if(a.callback===n)return s;return[...s,{callback:n,scope:o}]}),n},removeEventListener(t,r,n){!t||e.setMetaValue([t.id,"eventManager",r],o=>(o||[]).filter(i=>i.callback!==n))},getListenersAsProps(t,r){const n=typeof t=="string"?{id:t}:t;if(!n||!n.id)return{};const o=e.getResourceMeta(n.id,"eventManager"),i={};if(o&&n)for(const s of Object.keys(o))i[s]=a=>{const d=e.get(n);for(const{callback:u,scope:l}of o[s]||[])(!l||r&&l.indexOf(r)!==-1)&&u(a,d)};return i}}}function he(e,t){const r=R(),n=c.useMemo(()=>gt(r),[r]),o=b(()=>e&&e.id?r.getResourceMeta(e.id,"eventManager"):null,[e]);return c.useMemo(()=>e?n.getListenersAsProps(e,t):{},[o,e,r,t])}function ge(e){return{applyStyles(t,r,n){const o=typeof t=="string"?t:t.id;return e.setMetaValue([o,"styles",r],n)},getAppliedStyles(t){const r=typeof t=="string"?t:t.id;return e.getResourceMeta(r,"styles")}}}function V(e,t){const r=R(),n=c.useMemo(()=>ge(r),[r]);return b(()=>{if(!e)return null;const o=n.getAppliedStyles(e.id);return o?t?o[t]:o:void 0},[e,t])}var yt=Object.defineProperty,vt=Object.defineProperties,Et=Object.getOwnPropertyDescriptors,re=Object.getOwnPropertySymbols,xt=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable,oe=(e,t,r)=>t in e?yt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ie=(e,t)=>{for(var r in t||(t={}))xt.call(t,r)&&oe(e,r,t[r]);if(re)for(var r of re(t))St.call(t,r)&&oe(e,r,t[r]);return e},se=(e,t)=>vt(e,Et(t));const Pt=/&?(xywh=)?(pixel:|percent:|pct:)?([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?)/,Ct=/&?(t=)(npt:)?([0-9]+(.[0-9]+)?)?(,([0-9]+(.[0-9]+)?))?/;function Y(e){if(Array.isArray(e))return e.reduce((t,r)=>{const{selector:n,selectors:o}=Y(r);return n&&(t.selector||(t.selector=n),t.selectors.push(...o)),t},{selector:null,selectors:[]});if(!e)return{selector:null,selectors:[]};if(typeof e=="string"){const[t,r]=e.split("#");return r?Y({type:"FragmentSelector",value:r}):{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=Pt.exec(e.value);if(t){const n={type:"BoxSelector",spatial:{unit:t[2]==="percent:"||t[2]==="pct:"?"percent":"pixel",x:parseFloat(t[3]),y:parseFloat(t[4]),width:parseFloat(t[5]),height:parseFloat(t[6])}};return{selector:n,selectors:[n]}}const r=e.value.match(Ct);if(r){const n={type:"TemporalSelector",temporal:{startTime:r[4]?parseFloat(r[4]):0,endTime:r[7]?parseFloat(r[7]):void 0}};return{selector:n,selectors:[n]}}return{selector:null,selectors:[]}}return{selector:null,selectors:[]}}function M(e,t={}){if(Array.isArray(e))return M(e[0]);if(typeof e=="string"){const[r,n]=e.split("#");return n?M({type:"SpecificResource",source:{id:r,type:"Unknown"},selector:{type:"FragmentSelector",value:n}}):{type:"SpecificResource",source:{id:r,type:t.typeMap&&t.typeMap[r]||"Unknown"},selector:null,selectors:[]}}if(e.type==="Choice"||e.type==="List"||e.type==="Composite"||e.type==="Independents")return M(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:r,selectors:n}=e.selector?Y(e.selector):{selector:null,selectors:[]};return{type:"SpecificResource",source:e.source,selector:r,selectors:n}}if(e.id){e.type==="Canvas"&&e.partOf&&typeof e.partOf=="string"&&(e.partOf=[{id:e.partOf,type:"Manifest"}]);const[r,n]=e.id.split("#");return n?M({type:"SpecificResource",source:se(ie({},e),{id:r}),selector:{type:"FragmentSelector",value:n}}):{type:"SpecificResource",source:se(ie({},e),{id:r}),selector:null,selectors:[]}}return{type:"SpecificResource",source:e,selector:null,selectors:[]}}function Rt(e={},t=[]){const{id:r,selector:n}=e,o=U(),i=R(),s=r||o.annotation,a=b(u=>s?u.iiif.entities.Annotation[s]:void 0,[s]),d=b(u=>a&&a.body?a.body.map(l=>l?u.iiif.entities[l.type][l.id]:null).filter(Boolean):[],[a]);return c.useMemo(()=>{if(!a)return;const u=E(y({},a),{body:d,target:M(a.target,{typeMap:i.getState().iiif.mapping})});return n?n(u):u},[a,n,d,...t])}function _(e={},t=[]){const{id:r,selector:n}=e,o=U(),i=r||o.canvas,s=b(a=>i?a.iiif.entities.Canvas[i]:void 0,[i]);return c.useMemo(()=>{if(!!s)return n?n(s):s},[s,n,...t])}const ye=({id:e,style:t,className:r,interactive:n})=>{const o=Rt({id:e}),i=V(o,"atlas"),s=V(o,"html"),a=he(o,["atlas"]),d=_(),u=c.useMemo(()=>L.mergeStyles(t,i),[t,i]);return d&&o&&o.target&&o.target.selector&&o.target.selector.type==="BoxSelector"&&o.target.source&&o.target.source.id===d.id?f.jsx(L.RegionHighlight,y({id:o.id,isEditing:!0,region:o.target.selector.spatial,style:u,className:(s==null?void 0:s.className)||r,interactive:!!((s==null?void 0:s.href)||n),href:(s==null?void 0:s.href)||null,title:(s==null?void 0:s.title)||null,hrefTarget:(s==null?void 0:s.target)||null},a)):null},Q=({className:e,page:t})=>{var o;const r=V(t,"atlas"),n=V(t,"html");return b(i=>t.id?i.iiif.entities.AnnotationPage[t.id]:null,[]),f.jsx(c.Fragment,{children:(o=t.items)==null?void 0:o.map(i=>f.jsx(ye,{id:i.id,style:r,className:(n==null?void 0:n.className)||e},i.id))})};function ve({id:e,image:t,thumbnail:r,isStatic:n,x:o=0,y:i=0,annotations:s,children:a}){var d,u,l,p;return f.jsx(c.Fragment,{children:t.service?f.jsxs(c.Fragment,{children:[f.jsx(L.TileSet,{tiles:{id:t.service.id||t.service["@id"]||"unknown",height:t.height,width:t.width,imageService:t.service,thumbnail:r&&r.type==="fixed"?r:void 0},x:((d=t.target)==null?void 0:d.spatial.x)+o,y:((u=t.target)==null?void 0:u.spatial.y)+i,width:(l=t.target)==null?void 0:l.spatial.width,height:(p=t.target)==null?void 0:p.spatial.height}),s,a]},"service"):f.jsxs(c.Fragment,{children:[f.jsx("world-image",{uri:t.id,target:t.target.spatial,display:t.width&&t.height?{width:t.width,height:t.height}:void 0}),s,a]},"no-service")},e)}function At(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function bt(e,t,r){const n=[];let o=null;const i=[];for(const s of t){const a=e.get(s.body);for(const d of a){const[u,{selector:l}]=At(d),p=(u.type||"unknown").toLowerCase();if(p==="choice"){const m=e.get(u.items),v=r.length?r.map(g=>m.find(h=>h.id===g)).filter(Boolean):[m[0]];v.length===0&&v.push(m[0]),o={type:"single-choice",items:m.map(g=>({id:g.id,label:g.label,selected:v.indexOf(g)!==-1})),label:d.label},a.push(...v);continue}n.indexOf(p)===-1&&n.push(p),i.push({type:p,resource:u,target:s.target,selector:l})}}return{types:n,items:i,choice:o}}const Tt={makeChoice:()=>{}},ae={type:"unknown"},x=e=>({type:"unknown",reason:e,annotations:{pages:[]}});function K(e={},t=[]){const{id:r,selector:n}=e,o=U();R();const i=r||o.manifest,s=b(a=>i?a.iiif.entities.Manifest[i]:void 0,[i]);return c.useMemo(()=>{if(!!s)return n?n(s):s},[s,n,...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 wt(e,t){return b(r=>{const n=[];if(!e)return n;const o=Object.keys(r.iiif.entities.AnnotationPage);for(const i of o)if(!t||t.indexOf(i)!==-1){const s=Mt(r,i);s&&s.views&&s.views[e]&&n.push(i)}return n},[e,t])}function _t({canvas:e,manifest:t,all:r,canvases:n}){const o=[];if(t)for(const i of t.annotations)o.indexOf(i.id)===-1&&o.push(i.id);if(r){if(n&&n.length)for(const i of n)for(const s of i.annotations)o.indexOf(s.id)===-1&&o.push(s.id)}else if(e)for(const i of e.annotations)o.indexOf(i.id)===-1&&o.push(i.id);return o}function jt(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 Ot(e,t={}){const r=R(),n=K(),o=_(),i=Ve(),s=c.useMemo(()=>_t({all:t.all,manifest:n,canvas:o,canvases:i}),[t.all,o,i,n]),a=wt(e,t.all?void 0:s),d=c.useCallback(l=>{!e||r.setMetaValue([l,"annotationPageManager","views"],p=>p&&!p[e]?p:E(y({},p||{}),{[e]:!1}))},[e,r]),u=c.useCallback((l,p={})=>{if(!e)return;const m=r.getState(),v=[];if(p!=null&&p.deselectOthers){const g=Object.keys(m.iiif.entities.AnnotationPage);for(const h of g){const T=jt(m,h);T&&T.views&&T.views[e]&&v.push(h)}}for(const g of v)d(g);r.setMetaValue([l,"annotationPageManager","views"],g=>g&&g[e]?g:E(y({},g||{}),{[e]:!0}))},[e,d,r]);return{availablePageIds:s,enabledPageIds:a,setPageEnabled:u,setPageDisabled:d}}function It(e,t){return b((r,n)=>n.get(e.map(o=>({id:o,type:t}))),[e,t])}const kt=w.default.createContext(new j.ImageServiceLoader);function Ee(){return c.useContext(kt)}function Ft(){const e=Ee(),[t,r]=c.useState({}),n=c.useRef(!1);return c.useEffect(()=>()=>{n.current=!0},[]),[c.useCallback((i,{height:s,width:a})=>{if(i){const d=i.id||i["@id"],u=e.loadServiceSync({id:d,width:i.width||a,height:i.height||s,source:i});u?i=u:t[d]||(n.current||r(l=>E(y({},l),{[d]:"loading"})),e.loadService({id:d,width:i.width||a,height:i.height||s}).then(()=>{n.current||r(l=>E(y({},l),{[d]:"done"}))}))}return i},[e,t]),t]}function Lt(e={}){const t=_(e.canvasId?{id:e.canvasId}:void 0);return b((r,n)=>{if(!t)return[];const o=n.get(t.items),i=[];for(const s of o)i.push(...n.get(s.items));return i},[t])}function Vt(e,t=[]){const r=R(),n=Lt(),[o,i]=c.useState((e==null?void 0:e.defaultChoices)||[]),s=c.useMemo(()=>bt(r,n,o),[r,n,o,...t]),d={makeChoice:c.useCallback((u,{deselectOthers:l=!0,deselect:p=!1}={})=>{if(s.choice){if(s.choice.type!=="single-choice")throw new Error("Complex choice not supported yet");i(m=>{if(p){const g=m.filter(h=>h!==u);if(g.length===0){const h=s.items[0].resource.id;return h?[h]:[]}return g}if(l)return[u];const v=[...m];if(v.length===0&&s.items.length){const g=s.items[0].resource.id;g&&v.push(g)}return m.indexOf(u)!==-1?m:[...m,u]})}},[s.choice])};return[s,d]}function Ut(e,t,r){const n=[];for(const o of t.items){const i=o.resource&&o.resource.type==="SpecificResource"?o.resource.source:o.resource;if(!i.id)return x("No resource Identifier");let s;if(i.service){const h=j.getImageServices(i);h[0]&&(s=r(h[0],e))}const{selector:a,source:d}=M(o.target);if(d.id!==e.id)continue;const u={type:"BoxSelector",spatial:{x:0,y:0,width:e.width,height:e.height}},l=a?a.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:a.temporal,spatial:u.spatial}:a:null,p={type:"BoxSelector",spatial:{x:0,y:0,width:e.width,height:e.height}},m=o.resource.type==="SpecificResource"?M(o.resource):null,v=m&&m.selector&&(m.selector.type==="BoxSelector"||m.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:m.selector.spatial.x,y:m.selector.spatial.y,width:m.selector.spatial.width,height:m.selector.spatial.height}}:p;s&&!s.id&&(s.id=s["@id"]);const g={id:i.id,type:"Image",width:l?i.width:e.width,height:l?i.height:e.height,service:s,sizes:s&&s.sizes?s.sizes:i.width&&i.height?[{width:i.width,height:i.height}]:[],target:l&&l.type!=="PointSelector"?l:u,selector:v};n.push(g)}return{type:"images",image:n[0],images:n,choice:t.choice}}const Dt=["model/gltf-binary"];function Nt(e,t){const n=t.items[0].resource;return n.format?Dt.indexOf(n.format)===-1?x(`3D format: ${n.format} is unsupported`):{type:"3d-model",model:n}:x("Unknown format")}function Bt(e,t){var n;if(!e.duration)return x("No duration on canvas");if(t.items.length>1)return x("Only one audio source supported");const r=(n=t.items[0])==null?void 0:n.resource;return r?r.format?{type:"media",media:{duration:e.duration,url:r.id,type:"Sound",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:r.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:x("Audio does not have format"):x("Unknown audio")}function Ht(e,t){var o;const r=t.items.filter(i=>i.type==="video");if(!e.duration)return x("No duration on canvas");if(r.length>1)return x("Only one video source supported");const n=(o=r[0])==null?void 0:o.resource;return n?n.format?{type:"media",media:{duration:e.duration,url:n.id,type:"Video",items:[],target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:n.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:x("Video does not have format"):x("Unknown video")}function Yt(e){const t=K(),r=_(),n=R(),[o,i]=Ft(),{enabledPageIds:s}=Ot((e==null?void 0:e.annotationPageManagerId)||(t==null?void 0:t.id)||(r==null?void 0:r.id),{all:!1}),a=It(s,"AnnotationPage"),d=(e==null?void 0:e.strategies)||["images","media","complex-timeline"],[u,l]=Vt(e,[i]),p=c.useMemo(()=>{if(!r||u.types.length===0)return ae;if(u.types.length!==1)if(u.types.length===2&&u.types.indexOf("text")!==-1)u.types=u.types.filter(v=>v!=="text");else return d.indexOf("complex-timeline")===-1?x("Complex timeline not supported"):x("ComplexTimelineStrategy not yet supported");const m=u.types[0];return m==="image"?d.indexOf("images")===-1?x("Image not supported"):Ut(r,u,o):m==="Model"||m==="model"?d.indexOf("3d-model")===-1?x("3D not supported"):Nt(r,u):m==="sound"||m==="audio"?d.indexOf("media")===-1?x("Media not supported"):Bt(r,u):m==="video"?d.indexOf("media")===-1?x("Media not supported"):Ht(r,u):ae},[r,u,n,l.makeChoice]);return c.useMemo(()=>p.type==="unknown"?[p,Tt]:[E(y({},p),{annotations:{pages:a}}),l],[p,a])}const Qt=(e,t=[])=>{const r=R();c.useEffect(()=>{e(r)},[r,...t])};function zt(e,t={}){const r=t.imageServiceLoader||new j.ImageServiceLoader;async function n(o,i,s,a=[],d){if(typeof o=="string")return{best:j.getFixedSizeFromImage(o),fallback:[],log:[]};const u=e.get(o);if(typeof u=="string")return{best:j.getFixedSizeFromImage(u),fallback:[],log:[]};switch(u.type){case"Annotation":{const l=u.body,p=e.get(l[0]);return d&&!p.width&&(p.width=d.width,p.height=d.height),await r.getThumbnailFromResource(p,i,s,a)}case"Canvas":{const l=u;if(l.thumbnail&&l.thumbnail.length){const p=e.get(l.thumbnail[0]),m=await r.getImageCandidates(p,s);m&&m.length&&a.push(...m)}return n(l.items[0],i,s,a,{width:l.width,height:l.height})}case"AnnotationPage":return n(u.items[0],i,s,a,d);case"Choice":return n(u.items[0],i,s,a,d);case"Collection":{const p=u.items[0];return n(p,i,s,a,d)}case"Manifest":{const p=u.items[0];return n(p,i,s,a,d)}case"SpecificResource":case"Image":case"Dataset":case"Sound":case"Text":case"TextualBody":case"Video":return d&&!u.width&&(u.width=d.width,u.height=d.height),r.getThumbnailFromResource(u,i,s,a);case"Service":case"Range":case"AnnotationCollection":case"CanvasReference":case"ContentResource":return{best:void 0,fallback:[],log:[]}}return{best:void 0,fallback:[],log:[]}}return{getBestThumbnailAtSize:n}}function $t(e,t,{canvasId:r,manifestId:n}={}){const o=R(),i=Ee(),s=c.useMemo(()=>zt(o,{imageServiceLoader:i}),[o,i]),[a,d]=c.useState(),u=K(n?{id:n}:void 0),l=_(r?{id:r}:void 0),p=l||u,m=c.useRef(!1);if(c.useEffect(()=>()=>{m.current=!0},[]),!p)throw new Error("Must be called under a manifest or canvas context.");return Qt(v=>{s.getBestThumbnailAtSize(p,e,t).then(g=>{g.best&&!m.current&&d(g.best)})},[p]),a}function qt(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function Gt(e,t){switch(t.type){case"FINISHED":return E(y({},e),{isFinished:!0,isPlaying:!1,playRequested:!1});case"PLAY_PAUSE":return E(y({},e),{isFinished:!1,isPlaying:!e.isPlaying});case"PLAY_REQUESTED":return E(y({},e),{isFinished:!1,playRequested:!0});case"PAUSE":return E(y({},e),{isPlaying:!1});case"PLAY":return E(y({},e),{isFinished:!1,playRequested:!1,isPlaying:!0});case"MUTE":return E(y({},e),{isMuted:!0});case"SET_VOLUME":return E(y({},e),{volume:t.volume,isMuted:t.volume===0});case"TOGGLE_MUTE":return E(y({},e),{isMuted:!e.isMuted});case"UNMUTE":return E(y({},e),{isMuted:!1})}return e}function Kt(e){const t=Math.round(e);return`${Math.floor(t/60)}:${`${t%60}`.padStart(2,"0")}`}function xe(e){const[t,r]=c.useReducer(Gt,qt(e.duration)),n=c.useRef(null),o=c.useRef(null),i=c.useRef(null),s=c.useRef(!1),a=c.useCallback(()=>{o.current&&n.current&&(o.current.innerHTML=Kt(n.current.currentTime),i.current&&(i.current.style.width=`${n.current.currentTime/e.duration*100}%`),s.current!==n.current.muted&&(s.current=n.current.muted,r(n.current.muted?{type:"MUTE"}:{type:"UNMUTE"})))},[e.duration]),d=c.useCallback(()=>{n.current&&(r({type:"PLAY_REQUESTED"}),n.current.play().then(()=>{r({type:"PLAY"})}),a())},[a]),u=c.useCallback(()=>{n.current&&(n.current.duration>0&&n.current.paused?d():l())},[a]),l=c.useCallback(()=>{n.current&&(n.current.pause(),r({type:"PAUSE"}),a())},[a]),p=c.useCallback(()=>{n.current&&(n.current.muted=!n.current.muted,r(n.current.muted?{type:"MUTE"}:{type:"UNMUTE"}))},[]),m=c.useCallback(()=>{n.current&&(n.current.muted=!0,r({type:"MUTE"}))},[]),v=c.useCallback(()=>{n.current&&(n.current.muted=!1,r({type:"UNMUTE"}))},[]),g=c.useCallback(C=>{n.current&&(n.current.muted=!1,n.current.volume=C/100,r({type:"SET_VOLUME",volume:C}))},[]),h=c.useCallback(C=>{n.current&&(n.current.currentTime=Math.max(0,Math.min(C*e.duration,e.duration)),a())},[]),T=c.useCallback(C=>{n.current&&(n.current.currentTime=Math.max(0,Math.min(C,e.duration)),a())},[]);return c.useEffect(()=>{const C=setInterval(()=>{a()},350);return()=>clearInterval(C)},[a,e.duration]),c.useEffect(()=>{const C=()=>{r({type:"FINISHED"})},P=n.current;return P==null||P.addEventListener("ended",C),()=>P==null?void 0:P.removeEventListener("ended",C)},[]),[{element:n,currentTime:o,progress:i},t,{play:d,pause:l,playPause:u,mute:m,unmute:v,toggleMute:p,setVolume:g,setDurationPercent:h,setTime:T}]}const Wt=c.createContext(null),Xt=c.createContext(null),Jt=c.createContext(null);function Se({actions:e,state:t,children:r,currentTime:n,progress:o,element:i}){return f.jsx(Jt.Provider,{value:{currentTime:n,progress:o,element:i},children:f.jsx(Xt.Provider,{value:e,children:f.jsx(Wt.Provider,{value:t,children:r})})})}function Zt({media:e,children:t}){const[{element:r,currentTime:n,progress:o},i,s]=xe({duration:e.duration});return f.jsx(f.Fragment,{children:f.jsx(O,{children:f.jsxs(Se,{state:i,actions:s,currentTime:n,progress:o,element:r,children:[f.jsx("audio",{ref:r,src:e.url}),t]})})})}function en({media:e,children:t}){const[{element:r,currentTime:n,progress:o},i,s]=xe({duration:e.duration}),a="div";return f.jsxs(f.Fragment,{children:[f.jsxs(O,{overlay:!0,children:[f.jsx("style",{children:`
|
|
1
|
+
"use strict";var qe=Object.defineProperty,Ge=Object.defineProperties;var Ke=Object.getOwnPropertyDescriptors;var $=Object.getOwnPropertySymbols;var le=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable;var ue=(e,t,n)=>t in e?qe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(e,t)=>{for(var n in t||(t={}))le.call(t,n)&&ue(e,n,t[n]);if($)for(var n of $(t))fe.call(t,n)&&ue(e,n,t[n]);return e},x=(e,t)=>Ge(e,Ke(t));var de=(e,t)=>{var n={};for(var r in e)le.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&$)for(var r of $(e))t.indexOf(r)<0&&fe.call(e,r)&&(n[r]=e[r]);return n};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var c=require("react"),B=require("@atlas-viewer/atlas"),f=require("react/jsx-runtime"),K=require("@iiif/vault"),C=require("typesafe-actions"),pe=require("react-dom/client"),We=require("@iiif/vault-helpers"),V=require("@atlas-viewer/iiif-image-api");function Xe(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}function Je(e){if(e&&e.__esModule)return e;var t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});return e&&Object.keys(e).forEach(function(n){if(n!=="default"){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var W=Je(c),L=Xe(c);function ee(e,t){return ee=Object.setPrototypeOf||function(r,i){return r.__proto__=i,r},ee(e,t)}function Ze(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,ee(e,t)}var et=function(t,n){return t===void 0&&(t=[]),n===void 0&&(n=[]),t.length!==n.length||t.some(function(r,i){return!Object.is(r,n[i])})},ge={error:null},tt=function(e){Ze(t,e);function t(){for(var r,i=arguments.length,a=new Array(i),o=0;o<i;o++)a[o]=arguments[o];return r=e.call.apply(e,[this].concat(a))||this,r.state=ge,r.resetErrorBoundary=function(){for(var s,l=arguments.length,u=new Array(l),d=0;d<l;d++)u[d]=arguments[d];r.props.onReset==null||(s=r.props).onReset.apply(s,u),r.reset()},r}t.getDerivedStateFromError=function(i){return{error:i}};var n=t.prototype;return n.reset=function(){this.setState(ge)},n.componentDidCatch=function(i,a){var o,s;(o=(s=this.props).onError)==null||o.call(s,i,a)},n.componentDidUpdate=function(i,a){var o=this.state.error,s=this.props.resetKeys;if(o!==null&&a.error!==null&&et(i.resetKeys,s)){var l,u;(l=(u=this.props).onResetKeysChange)==null||l.call(u,i.resetKeys,s),this.reset()}},n.render=function(){var i=this.state.error,a=this.props,o=a.fallbackRender,s=a.FallbackComponent,l=a.fallback;if(i!==null){var u={error:i,resetErrorBoundary:this.resetErrorBoundary};if(W.isValidElement(l))return l;if(typeof o=="function")return o(u);if(s)return W.createElement(s,u);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},t}(W.Component);const nt={collection:void 0,manifest:void 0,range:void 0,canvas:void 0,annotation:void 0},oe=L.default.createContext(nt),q=()=>c.useContext(oe);function Te({value:e,children:t}){const n=q(),r=c.useMemo(()=>v(v({},n),e),[e,n]);return f.jsx(oe.Provider,{value:r,children:t})}const ie=L.default.createContext({vault:null,setVaultInstance:e=>{}});function rt({vault:e,vaultOptions:t,useGlobal:n,resources:r,children:i}){const[a,o]=c.useState(()=>e||(n?K.globalVault(t):t?new K.Vault(t):new K.Vault));return f.jsx(ie.Provider,{value:{vault:a,setVaultInstance:o},children:f.jsx(Te,{value:r||{},children:i})})}const A=()=>{const{vault:e}=c.useContext(ie);if(e===null)throw new Error("Vault not found. Ensure you have your provider set up correctly.");return e};function ot({canvas:e,children:t}){return f.jsx(Te,{value:{canvas:e},children:t})}function M(e,t=[]){const n=A(),[r,i]=c.useState(()=>e(n.getState(),n));return c.useEffect(()=>n.subscribe(a=>e(a,n),a=>{i(a)},!1),t),r}const ae=L.default.createContext([]);function it(){const e=c.useContext(ae);return M(t=>e.map(n=>t.iiif.entities.Canvas[n]).filter(Boolean),[e])}function se(e={},t=[]){const{id:n,selector:r}=e,i=q();A();const a=n||i.manifest,o=M(s=>a?s.iiif.entities.Manifest[a]:void 0,[a]);return c.useMemo(()=>{if(!!o)return r?r(o):o},[o,r,...t])}const D=()=>{},Oe=c.createContext({setCurrentCanvasId:D,setCurrentCanvasIndex:D,nextCanvas:D,previousCanvas:D,items:[],sequence:[],setSequenceIndex:D,currentSequenceIndex:0});function at(){return{VaultContext:c.useContext(ie),ResourceContext:c.useContext(oe),SimpleViewerReactContext:c.useContext(Oe),VisibleCanvasReactContext:c.useContext(ae)}}function st(e){return f.jsx(rt,{vault:e.bridge.VaultContext.vault||void 0,resources:e.bridge.ResourceContext,children:f.jsx(ae.Provider,{value:e.bridge.VisibleCanvasReactContext,children:f.jsx(Oe.Provider,{value:e.bridge.SimpleViewerReactContext,children:e.children})})})}const ct="@iiif/IMPORT_ENTITIES",ut="@iiif/MODIFY_ENTITY_FIELD",lt="@iiif/REORDER_ENTITY_FIELD",ft="@iiif/ADD_REFERENCE",dt="@iiif/REMOVE_REFERENCE",pt=C.createAction(ct)(),gt=C.createAction(ut)(),mt=C.createAction(lt)(),ht=C.createAction(ft)(),yt=C.createAction(dt)(),X={importEntities:pt,modifyEntityField:gt,reorderEntityField:mt,addReference:ht,removeReference:yt},vt="@iiif/ADD_MAPPING",xt="@iiif/ADD_MAPPINGS";C.createAction(vt)();C.createAction(xt)();const St="@iiif/SET_META_VALUE",Et="@iiif/SET_META_VALUE_DYNAMIC",bt="@iiif/UNSET_META_VALUE";C.createAction(St)();C.createAction(Et)();C.createAction(bt)();const Pt="@iiif/REQUEST_RESOURCE",wt="@iiif/REQUEST_ERROR",Ct="@iiif/REQUEST_MISMATCH",Tt="@iiif/REQUEST_COMPLETE",Ot="@iiif/REQUEST_OFFLINE_RESOURCE";C.createAction(Pt)();C.createAction(wt)();C.createAction(Ct)();C.createAction(Tt)();C.createAction(Ot)();const At="@iiif/BATCH",Rt="@iiif/BATCH_IMPORT";C.createAction(At)();C.createAction(Rt)();function Mt(){const t=A().getStore();return c.useMemo(()=>n=>t.dispatch(n),[t])}function me(e){return typeof e!="string"&&e&&e.bindToVault}function _t(){const e=A(),t=c.useRef([]),n=Mt(),r=c.useMemo(()=>`vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random()*1e9).toString(16)}`,[]);c.useLayoutEffect(()=>{const s={id:r,type:"AnnotationPage",behavior:[],motivation:null,label:null,thumbnail:[],summary:null,requiredStatement:null,metadata:[],rights:null,provider:[],items:[],seeAlso:[],homepage:[],logo:[],rendering:[],service:[]};n(X.importEntities({entities:{AnnotationPage:{[s.id]:s}}}))},[r]);const i=M(s=>r?s.iiif.entities.AnnotationPage[r]:null,[r]),a=c.useCallback((s,l)=>{if(r){if(me(s)){const p=s;p.__vault||p.bindToVault(e),s=typeof p.source=="string"?p.source:p.source.id,t.current[s]=p}else typeof s!="string"&&(s=s.id);const u=e.get({id:r,type:"AnnotationPage"}),d=e.get({id:s,type:"Annotation"});u&&d&&(u.items.find(p=>p.id===d.id)||n(X.addReference({id:r,type:"AnnotationPage",key:"items",reference:{id:s,type:"Annotation"},index:l})))}},[r]),o=c.useCallback(s=>{r&&(me(s)?s=typeof s.source=="string"?s.source:s.source.id:typeof s!="string"&&(s=s.id),t.current[s]&&t.current[s].beforeRemove(),e.get({id:r,type:"AnnotationPage"})&&n(X.removeReference({id:r,type:"AnnotationPage",key:"items",reference:{id:s,type:"Annotation"}})))},[r]);return[i,{addAnnotation:a,removeAnnotation:o}]}const Ae=c.createContext(null);function jt(){const e=c.useContext(Ae);return[e.fullPage,{addAnnotation:e.addAnnotation,removeAnnotation:e.removeAnnotation}]}function It({children:e}){const[t,{addAnnotation:n,removeAnnotation:r}]=_t();return f.jsx(Ae.Provider,{value:c.useMemo(()=>({fullPage:t,addAnnotation:n,removeAnnotation:r}),[t]),children:e})}function Lt({width:e,style:t,height:n}){return f.jsx("div",{style:x(v({width:e,height:n,minHeight:500},t||{}),{background:"#f9f9f9"}),children:"Unknown error"})}const ce=c.createContext(null);function Ft(){return c.useContext(ce)}const Re=L.default.createContext(null),Me=L.default.createContext(null);function H({children:e,overlay:t}){const n=c.useContext(t?Me:Re),r=Ft();return c.useLayoutEffect(()=>{if(n)try{n.render(f.jsx(ce.Provider,{value:r,children:e}))}catch{}},[e,r]),null}function kt(i){var a=i,{children:e,errorFallback:t,outerContainerProps:n={}}=a,r=de(a,["children","errorFallback","outerContainerProps"]);const o=c.useRef(null),[s,l]=c.useState(),[u,d]=c.useState(),p=c.useRef(null),[g,h]=c.useState(),y=at(),P=t||Lt;return c.useLayoutEffect(()=>{const S={};if(o.current){const b=document.createElement("div");o.current.appendChild(b),S.portal=pe.createRoot(b),l(S.portal)}if(p.current){const b=document.createElement("div");p.current.appendChild(b),S.overlayPortal=pe.createRoot(b),h(S.overlayPortal)}return()=>{l(null),h(null),setTimeout(()=>{S.portal&&S.portal.unmount(),S.overlayPortal&&S.overlayPortal.unmount()},0)}},[]),f.jsxs(tt,{fallbackRender:()=>f.jsx(P,v({},r)),children:[f.jsx(B.AtlasAuto,x(v({},r),{containerProps:v({style:{position:"relative"}},r.containerProps||{}),htmlChildren:f.jsx("div",{ref:p}),onCreated:S=>{d(S),r.onCreated&&r.onCreated(S)},children:f.jsx(ce.Provider,{value:u,children:f.jsx(Re.Provider,{value:s,children:f.jsx(Me.Provider,{value:g,children:f.jsx(st,{bridge:y,children:f.jsx(It,{children:e})})})})})})),f.jsx("div",{ref:o})]})}function Nt(e){return{addEventListener(t,n,r,i){if(!!t)return e.setMetaValue([t.id,"eventManager",n],a=>{const o=a||[];for(const s of o)if(s.callback===r)return o;return[...o,{callback:r,scope:i}]}),r},removeEventListener(t,n,r){!t||e.setMetaValue([t.id,"eventManager",n],i=>(i||[]).filter(a=>a.callback!==r))},getListenersAsProps(t,n){const r=typeof t=="string"?{id:t}:t;if(!r||!r.id)return{};const i=e.getResourceMeta(r.id,"eventManager"),a={};if(i&&r)for(const o of Object.keys(i))a[o]=s=>{const l=e.get(r);for(const{callback:u,scope:d}of i[o]||[])(!d||n&&d.indexOf(n)!==-1)&&u(s,l)};return a}}}function _e(e,t){const n=A(),r=c.useMemo(()=>Nt(n),[n]),i=M(()=>e&&e.id?n.getResourceMeta(e.id,"eventManager"):null,[e]);return c.useMemo(()=>e?r.getListenersAsProps(e,t):{},[i,e,n,t])}function je(e){return{applyStyles(t,n,r){const i=typeof t=="string"?t:t.id;return e.setMetaValue([i,"styles",n],r)},getAppliedStyles(t){const n=typeof t=="string"?t:t.id;return e.getResourceMeta(n,"styles")}}}function z(e,t){const n=A(),r=c.useMemo(()=>je(n),[n]);return M(()=>{if(!e)return null;const i=r.getAppliedStyles(e.id);return i?t?i[t]:i:void 0},[e,t])}var Ut=Object.defineProperty,Dt=Object.defineProperties,Vt=Object.getOwnPropertyDescriptors,he=Object.getOwnPropertySymbols,Bt=Object.prototype.hasOwnProperty,Ht=Object.prototype.propertyIsEnumerable,ye=(e,t,n)=>t in e?Ut(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ve=(e,t)=>{for(var n in t||(t={}))Bt.call(t,n)&&ye(e,n,t[n]);if(he)for(var n of he(t))Ht.call(t,n)&&ye(e,n,t[n]);return e},xe=(e,t)=>Dt(e,Vt(t));const $t=/&?(xywh=)?(pixel:|percent:|pct:)?([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?)/,zt=/&?(t=)(npt:)?([0-9]+(.[0-9]+)?)?(,([0-9]+(.[0-9]+)?))?/;function te(e){if(Array.isArray(e))return e.reduce((t,n)=>{const{selector:r,selectors:i}=te(n);return r&&(t.selector||(t.selector=r),t.selectors.push(...i)),t},{selector:null,selectors:[]});if(!e)return{selector:null,selectors:[]};if(typeof e=="string"){const[t,n]=e.split("#");return n?te({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=$t.exec(e.value);if(t){const r={type:"BoxSelector",spatial:{unit:t[2]==="percent:"||t[2]==="pct:"?"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(zt);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:[]}}function k(e,t={}){if(Array.isArray(e))return k(e[0]);if(typeof e=="string"){const[n,r]=e.split("#");return r?k({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 k(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?te(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?k({type:"SpecificResource",source:xe(ve({},e),{id:n}),selector:{type:"FragmentSelector",value:r}}):{type:"SpecificResource",source:xe(ve({},e),{id:n}),selector:null,selectors:[]}}return{type:"SpecificResource",source:e,selector:null,selectors:[]}}function Yt(e={},t=[]){const{id:n,selector:r}=e,i=q(),a=A(),o=n||i.annotation,s=M(u=>o?u.iiif.entities.Annotation[o]:void 0,[o]),l=M(u=>s&&s.body?s.body.map(d=>d?u.iiif.entities[d.type][d.id]:null).filter(Boolean):[],[s]);return c.useMemo(()=>{if(!s)return;const u=x(v({},s),{body:l,target:k(s.target,{typeMap:a.getState().iiif.mapping})});return r?r(u):u},[s,r,l,...t])}function F(e={},t=[]){const{id:n,selector:r}=e,i=q(),a=n||i.canvas,o=M(s=>a?s.iiif.entities.Canvas[a]:void 0,[a]);return c.useMemo(()=>{if(!!o)return r?r(o):o},[o,r,...t])}const Ie=({id:e,style:t,className:n,interactive:r})=>{const i=Yt({id:e}),a=z(i,"atlas"),o=z(i,"html"),s=_e(i,["atlas"]),l=F(),u=c.useMemo(()=>B.mergeStyles(t,a),[t,a]);return l&&i&&i.target&&i.target.selector&&i.target.selector.type==="BoxSelector"&&i.target.source&&i.target.source.id===l.id?f.jsx(B.RegionHighlight,v({id:i.id,isEditing:!0,region:i.target.selector.spatial,style:u,className:(o==null?void 0:o.className)||n,interactive:!!((o==null?void 0:o.href)||r),href:(o==null?void 0:o.href)||null,title:(o==null?void 0:o.title)||null,hrefTarget:(o==null?void 0:o.target)||null},s)):null},ne=({className:e,page:t})=>{var i;const n=z(t,"atlas"),r=z(t,"html");return M(a=>t.id?a.iiif.entities.AnnotationPage[t.id]:null,[]),f.jsx(c.Fragment,{children:(i=t.items)==null?void 0:i.map(a=>f.jsx(Ie,{id:a.id,style:n,className:(r==null?void 0:r.className)||e},a.id))})};function Le({id:e,image:t,thumbnail:n,isStatic:r,x:i=0,y:a=0,children:o,onClick:s}){var l,u,d,p;return f.jsx(c.Fragment,{children:t.service?f.jsxs(c.Fragment,{children:[f.jsx(B.TileSet,{tiles:{id:t.service.id||t.service["@id"]||"unknown",height:t.height,width:t.width,imageService:t.service,thumbnail:n&&n.type==="fixed"?n:void 0},x:((l=t.target)==null?void 0:l.spatial.x)+i,y:((u=t.target)==null?void 0:u.spatial.y)+a,width:(d=t.target)==null?void 0:d.spatial.width,height:(p=t.target)==null?void 0:p.spatial.height,onClick:s}),o]},"service"):f.jsxs(c.Fragment,{children:[f.jsx("world-image",{onClick:s,uri:t.id,target:t.target.spatial,display:t.width&&t.height?{width:t.width,height:t.height}:void 0}),o]},"no-service")},e)}function Qt(e){return e.type==="SpecificResource"?[e.source,{selector:e.selector}]:[e,{selector:null}]}function qt(e,t,n){const r=[];let i=null;const a=[];for(const o of t){const s=e.get(o.body);for(const l of s){const[u,{selector:d}]=Qt(l),p=(u.type||"unknown").toLowerCase();if(p==="choice"){const g=e.get(u.items),h=n.length?n.map(y=>g.find(P=>P.id===y)).filter(Boolean):[g[0]];h.length===0&&h.push(g[0]),i={type:"single-choice",items:g.map(y=>({id:y.id,label:y.label,selected:h.indexOf(y)!==-1})),label:l.label},s.push(...h);continue}r.indexOf(p)===-1&&r.push(p),a.push({annotationId:o.id,type:p,resource:u,target:o.target,selector:d})}}return{types:r,items:a,choice:i}}function Fe(e,t){const{selector:n,source:r}=We.expandTarget(t);if(r.id!==e.id)return[null,r];const i={type:"BoxSelector",spatial:{x:0,y:0,width:e.width,height:e.height}};return[n?n.type==="TemporalSelector"?{type:"TemporalBoxSelector",temporal:n.temporal,spatial:i.spatial}:n:null,r]}const Gt={makeChoice:()=>{}},J={type:"unknown"},w=e=>({type:"unknown",reason:e,annotations:{pages:[]}}),Kt=(e,t)=>({type:"empty",width:e,height:t,annotations:{pages:[]},image:null,images:[]});function Wt(e,t){var r;const n=(r=e==null?void 0:e.iiif)==null?void 0:r.meta[t];return n?n.annotationPageManager:null}function Xt(e,t){return M(n=>{const r=[];if(!e)return r;const i=Object.keys(n.iiif.entities.AnnotationPage);for(const a of i)if(!t||t.indexOf(a)!==-1){const o=Wt(n,a);o&&o.views&&o.views[e]&&r.push(a)}return r},[e,t])}function Jt({canvas:e,manifest:t,all:n,canvases:r}){const i=[];if(t)for(const a of t.annotations)i.indexOf(a.id)===-1&&i.push(a.id);if(n){if(r&&r.length)for(const a of r)for(const o of a.annotations)i.indexOf(o.id)===-1&&i.push(o.id)}else if(e)for(const a of e.annotations)i.indexOf(a.id)===-1&&i.push(a.id);return i}function Zt(e,t){var r;const n=(r=e==null?void 0:e.iiif)==null?void 0:r.meta[t];return n?n.annotationPageManager:null}function en(e,t={}){const n=A(),r=se(),i=F(),a=it(),o=c.useMemo(()=>Jt({all:t.all,manifest:r,canvas:i,canvases:a}),[t.all,i,a,r]),s=Xt(e,t.all?void 0:o),l=c.useCallback(d=>{!e||n.setMetaValue([d,"annotationPageManager","views"],p=>p&&!p[e]?p:x(v({},p||{}),{[e]:!1}))},[e,n]),u=c.useCallback((d,p={})=>{if(!e)return;const g=n.getState(),h=[];if(p!=null&&p.deselectOthers){const y=Object.keys(g.iiif.entities.AnnotationPage);for(const P of y){const S=Zt(g,P);S&&S.views&&S.views[e]&&h.push(P)}}for(const y of h)l(y);n.setMetaValue([d,"annotationPageManager","views"],y=>y&&y[e]?y:x(v({},y||{}),{[e]:!0}))},[e,l,n]);return{availablePageIds:o,enabledPageIds:s,setPageEnabled:u,setPageDisabled:l}}function tn(e,t){return M((n,r)=>r.get(e.map(i=>({id:i,type:t}))),[e,t])}const nn=L.default.createContext(new V.ImageServiceLoader);function ke(){return c.useContext(nn)}function rn(){const e=ke(),[t,n]=c.useState({}),r=c.useRef(!1);return c.useEffect(()=>()=>{r.current=!0},[]),[c.useCallback((a,{height:o,width:s})=>{if(a){const l=a.id||a["@id"],u=e.loadServiceSync({id:l,width:a.width||s,height:a.height||o,source:a});u?a=u:t[l]||(r.current||n(d=>x(v({},d),{[l]:"loading"})),e.loadService({id:l,width:a.width||s,height:a.height||o}).then(()=>{r.current||n(d=>x(v({},d),{[l]:"done"}))}))}return a},[e,t]),t]}function on(e={}){const t=F(e.canvasId?{id:e.canvasId}:void 0);return M((n,r)=>{if(!t)return[];const i=r.get(t.items),a=[];for(const o of i)a.push(...r.get(o.items));return a},[t])}function an(e,t=[]){const n=A(),r=on(),[i,a]=c.useState((e==null?void 0:e.defaultChoices)||[]),o=c.useMemo(()=>qt(n,r,i),[n,r,i,...t]),l={makeChoice:c.useCallback((u,{deselectOthers:d=!0,deselect:p=!1}={})=>{if(o.choice){if(o.choice.type!=="single-choice")throw new Error("Complex choice not supported yet");a(g=>{if(p){const y=g.filter(P=>P!==u);if(y.length===0){const P=o.items[0].resource.id;return P?[P]:[]}return y}if(d)return[u];const h=[...g];if(h.length===0&&o.items.length){const y=o.items[0].resource.id;y&&h.push(y)}return g.indexOf(u)!==-1?g:[...g,u]})}},[o.choice])};return[o,l]}function sn(e,t,n){const r=[];for(const i of t.items){const a=i.resource&&i.resource.type==="SpecificResource"?i.resource.source:i.resource;if(!a.id)return w("No resource Identifier");let o;if(a.service){const y=V.getImageServices(a);y[0]&&(o=n(y[0],e))}const s={type:"BoxSelector",spatial:{x:0,y:0,width:e.width,height:e.height}},[l,u]=Fe(e,i.target);if(u.id!==e.id)continue;const d={type:"BoxSelector",spatial:{x:0,y:0,width:e.width,height:e.height}},p=i.resource.type==="SpecificResource"?k(i.resource):null,g=p&&p.selector&&(p.selector.type==="BoxSelector"||p.selector.type==="TemporalBoxSelector")?{type:"BoxSelector",spatial:{x:p.selector.spatial.x,y:p.selector.spatial.y,width:p.selector.spatial.width,height:p.selector.spatial.height}}:d;o&&!o.id&&(o.id=o["@id"]);const h={id:a.id,type:"Image",annotationId:i.annotationId,width:l?a.width:e.width,height:l?a.height:e.height,service:o,sizes:o&&o.sizes?o.sizes:a.width&&a.height?[{width:a.width,height:a.height}]:[],target:l&&l.type!=="PointSelector"?l:s,selector:g};r.push(h)}return{type:"images",image:r[0],images:r,choice:t.choice}}const cn=["model/gltf-binary"];function un(e,t){const r=t.items[0].resource;return r.format?cn.indexOf(r.format)===-1?w(`3D format: ${r.format} is unsupported`):{type:"3d-model",model:r}:w("Unknown format")}function ln(e,t){var r;if(!e.duration)return w("No duration on canvas");if(t.items.length>1)return w("Only one audio source supported");const n=(r=t.items[0])==null?void 0:r.resource;return n?n.format?{type:"media",media:{annotationId:t.items[0].annotationId,duration:e.duration,url:n.id,type:"Sound",target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:n.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:w("Audio does not have format"):w("Unknown audio")}function fn(e,t){var i;const n=t.items.filter(a=>a.type==="video");if(!e.duration)return w("No duration on canvas");if(n.length>1)return w("Only one video source supported");const r=(i=n[0])==null?void 0:i.resource;return r?r.format?{type:"media",media:{annotationId:t.items[0].annotationId,duration:e.duration,url:r.id,type:"Video",items:[],target:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}},format:r.format,selector:{type:"TemporalSelector",temporal:{startTime:0,endTime:e.duration}}},annotations:{pages:[]}}:w("Video does not have format"):w("Unknown video")}function Ne(e,t={},n){const r=e.language||n||"none";switch(e.type){case"TextualBody":{typeof e.value!="undefined"&&(t[r]=e.value);break}case"List":case"Composite":case"Choice":e.items&&e.items.forEach(i=>Ne(i,t,r))}return t}function dn(e,t){const n=[];return t.items.forEach(r=>{if(r.resource){const[i]=Fe(e,r.target);n.push({annotationId:r.annotationId,text:Ne(r.resource),target:i})}}),{type:"textual-content",items:n}}function pn(e){const t=se(),n=F(),r=A(),[i,a]=rn(),{enabledPageIds:o}=en((e==null?void 0:e.annotationPageManagerId)||(t==null?void 0:t.id)||(n==null?void 0:n.id),{all:!1}),s=tn(o,"AnnotationPage"),l=(e==null?void 0:e.strategies)||["empty","images","media","textual-content","complex-timeline"],[u,d]=an(e,[a]),p=c.useMemo(()=>{if(!n)return J;if(u.types.length===0)return l.indexOf("empty")!==-1?Kt(n.width,n.height):J;if(u.types.length!==1)if(u.types.length===2&&u.types.indexOf("text")!==-1)u.types=u.types.filter(h=>h!=="text");else return l.indexOf("complex-timeline")===-1?w("Complex timeline not supported"):w("ComplexTimelineStrategy not yet supported");const g=u.types[0];return g==="image"?l.indexOf("images")===-1?w("Image not supported"):sn(n,u,i):g==="Model"||g==="model"?l.indexOf("3d-model")===-1?w("3D not supported"):un(n,u):g==="textualbody"?l.indexOf("textual-content")===-1?w("Textual content not supported"):dn(n,u):g==="sound"||g==="audio"?l.indexOf("media")===-1?w("Media not supported"):ln(n,u):g==="video"?l.indexOf("media")===-1?w("Media not supported"):fn(n,u):J},[n,u,r,d.makeChoice]);return c.useMemo(()=>p.type==="unknown"?[p,Gt]:[x(v({},p),{annotations:{pages:s}}),d],[p,s])}const gn=(e,t=[])=>{const n=A();c.useEffect(()=>{e(n)},[n,...t])};function mn(e,t={}){const n=t.imageServiceLoader||new V.ImageServiceLoader;async function r(i,a,o,s=[],l){if(typeof i=="string")return{best:V.getFixedSizeFromImage(i),fallback:[],log:[]};const u=e.get(i);if(typeof u=="string")return{best:V.getFixedSizeFromImage(u),fallback:[],log:[]};switch(u.type){case"Annotation":{const d=u.body,p=e.get(d[0]);return l&&!p.width&&(p.width=l.width,p.height=l.height),await n.getThumbnailFromResource(p,a,o,s)}case"Canvas":{const d=u;if(d.thumbnail&&d.thumbnail.length){const p=e.get(d.thumbnail[0]),g=await n.getImageCandidates(p,o);g&&g.length&&s.push(...g)}return r(d.items[0],a,o,s,{width:d.width,height:d.height})}case"AnnotationPage":return r(u.items[0],a,o,s,l);case"Choice":return r(u.items[0],a,o,s,l);case"Collection":{const p=u.items[0];return r(p,a,o,s,l)}case"Manifest":{const p=u.items[0];return r(p,a,o,s,l)}case"SpecificResource":case"Image":case"Dataset":case"Sound":case"Text":case"TextualBody":case"Video":return l&&!u.width&&(u.width=l.width,u.height=l.height),n.getThumbnailFromResource(u,a,o,s);case"Service":case"Range":case"AnnotationCollection":case"CanvasReference":case"ContentResource":return{best:void 0,fallback:[],log:[]}}return{best:void 0,fallback:[],log:[]}}return{getBestThumbnailAtSize:r}}function hn(e,t,{canvasId:n,manifestId:r}={}){const i=A(),a=ke(),o=c.useMemo(()=>mn(i,{imageServiceLoader:a}),[i,a]),[s,l]=c.useState(),u=se(r?{id:r}:void 0),d=F(n?{id:n}:void 0),p=d||u,g=c.useRef(!1);if(c.useEffect(()=>(g.current=!1,()=>{g.current=!0}),[]),!p)throw new Error("Must be called under a manifest or canvas context.");return gn(h=>{o.getBestThumbnailAtSize(p,e,t).then(y=>{y.best&&!g.current&&l(y.best)})},[p]),s}function yn(e){return{isMuted:!1,playRequested:!1,isPlaying:!1,isFinished:!1,volume:100,duration:e}}function vn(e,t){switch(t.type){case"FINISHED":return x(v({},e),{isFinished:!0,isPlaying:!1,playRequested:!1});case"PLAY_PAUSE":return x(v({},e),{isFinished:!1,isPlaying:!e.isPlaying});case"PLAY_REQUESTED":return x(v({},e),{isFinished:!1,playRequested:!0});case"PAUSE":return x(v({},e),{isPlaying:!1});case"PLAY":return x(v({},e),{isFinished:!1,playRequested:!1,isPlaying:!0});case"MUTE":return x(v({},e),{isMuted:!0});case"SET_VOLUME":return x(v({},e),{volume:t.volume,isMuted:t.volume===0});case"TOGGLE_MUTE":return x(v({},e),{isMuted:!e.isMuted});case"UNMUTE":return x(v({},e),{isMuted:!1})}return e}function xn(e){const t=Math.round(e);return`${Math.floor(t/60)}:${`${t%60}`.padStart(2,"0")}`}function Ue(e){const[t,n]=c.useReducer(vn,yn(e.duration)),r=c.useRef(null),i=c.useRef(null),a=c.useRef(null),o=c.useRef(!1),s=c.useCallback(()=>{i.current&&r.current&&(i.current.innerHTML=xn(r.current.currentTime),a.current&&(a.current.style.width=`${r.current.currentTime/e.duration*100}%`),o.current!==r.current.muted&&(o.current=r.current.muted,n(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"})))},[e.duration]),l=c.useCallback(()=>{r.current&&(n({type:"PLAY_REQUESTED"}),r.current.play().then(()=>{n({type:"PLAY"})}),s())},[s]),u=c.useCallback(()=>{r.current&&(r.current.duration>0&&r.current.paused?l():d())},[s]),d=c.useCallback(()=>{r.current&&(r.current.pause(),n({type:"PAUSE"}),s())},[s]),p=c.useCallback(()=>{r.current&&(r.current.muted=!r.current.muted,n(r.current.muted?{type:"MUTE"}:{type:"UNMUTE"}))},[]),g=c.useCallback(()=>{r.current&&(r.current.muted=!0,n({type:"MUTE"}))},[]),h=c.useCallback(()=>{r.current&&(r.current.muted=!1,n({type:"UNMUTE"}))},[]),y=c.useCallback(b=>{r.current&&(r.current.muted=!1,r.current.volume=b/100,n({type:"SET_VOLUME",volume:b}))},[]),P=c.useCallback(b=>{r.current&&(r.current.currentTime=Math.max(0,Math.min(b*e.duration,e.duration)),s())},[]),S=c.useCallback(b=>{r.current&&(r.current.currentTime=Math.max(0,Math.min(b,e.duration)),s())},[]);return c.useEffect(()=>{const b=setInterval(()=>{s()},350);return()=>clearInterval(b)},[s,e.duration]),c.useEffect(()=>{const b=()=>{n({type:"FINISHED"})},m=r.current;return m==null||m.addEventListener("ended",b),()=>m==null?void 0:m.removeEventListener("ended",b)},[]),[{element:r,currentTime:i,progress:a},t,{play:l,pause:d,playPause:u,mute:g,unmute:h,toggleMute:p,setVolume:y,setDurationPercent:P,setTime:S}]}const Sn=c.createContext(null),En=c.createContext(null),bn=c.createContext(null);function De({actions:e,state:t,children:n,currentTime:r,progress:i,element:a}){return f.jsx(bn.Provider,{value:{currentTime:r,progress:i,element:a},children:f.jsx(En.Provider,{value:e,children:f.jsx(Sn.Provider,{value:t,children:n})})})}function Pn({media:e,children:t}){const[{element:n,currentTime:r,progress:i},a,o]=Ue({duration:e.duration});return f.jsx(f.Fragment,{children:f.jsx(H,{children:f.jsxs(De,{state:a,actions:o,currentTime:r,progress:i,element:n,children:[f.jsx("audio",{ref:n,src:e.url}),t]})})})}function wn({media:e,children:t}){const[{element:n,currentTime:r,progress:i},a,o]=Ue({duration:e.duration}),s="div";return f.jsxs(f.Fragment,{children:[f.jsxs(H,{overlay:!0,children:[f.jsx("style",{children:`
|
|
2
2
|
.video-container {
|
|
3
3
|
position: absolute;
|
|
4
4
|
top: 0;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
justify-content: center;
|
|
12
12
|
pointer-events: visible;
|
|
13
13
|
}
|
|
14
|
-
`}),f.jsx(
|
|
14
|
+
`}),f.jsx(s,{className:"video-container",part:"video-container",onClick:()=>o.playPause(),children:f.jsx("video",{ref:n,src:e.url,style:{width:"100%",objectFit:"contain"}})})]}),f.jsx(H,{children:f.jsx(De,{state:a,actions:o,currentTime:r,progress:i,element:n,children:t})})]})}function Cn({model:e}){return f.jsxs(H,{overlay:!0,children:[f.jsx("style",{children:`
|
|
15
15
|
.model-container {
|
|
16
16
|
position: absolute;
|
|
17
17
|
top: 0;
|
|
@@ -24,5 +24,7 @@
|
|
|
24
24
|
justify-content: center;
|
|
25
25
|
pointer-events: visible;
|
|
26
26
|
}
|
|
27
|
-
`}),f.jsx("div",{className:"model-container",children:f.jsx("model-viewer",{"interaction-prompt":"none",style:{width:"100%",height:"100%"},"camera-controls":"","ar-status":"not-presenting",src:e.id})})]})}function
|
|
27
|
+
`}),f.jsx("div",{className:"model-container",children:f.jsx("model-viewer",{"interaction-prompt":"none",style:{width:"100%",height:"100%"},"camera-controls":"","ar-status":"not-presenting",src:e.id})})]})}function Ve({style:e}){const t=F();return!t||!t.height||!t.width?null:f.jsx("box",{interactive:!1,target:{x:0,y:0,width:t.width,height:t.height},style:e})}var Tn=Object.defineProperty,On=Object.defineProperties,An=Object.getOwnPropertyDescriptors,Y=Object.getOwnPropertySymbols,Be=Object.prototype.hasOwnProperty,He=Object.prototype.propertyIsEnumerable,Se=(e,t,n)=>t in e?Tn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,I=(e,t)=>{for(var n in t||(t={}))Be.call(t,n)&&Se(e,n,t[n]);if(Y)for(var n of Y(t))He.call(t,n)&&Se(e,n,t[n]);return e},Q=(e,t)=>On(e,An(t)),$e=(e,t)=>{var n={};for(var r in e)Be.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Y)for(var r of Y(e))t.indexOf(r)<0&&He.call(e,r)&&(n[r]=e[r]);return n};function Rn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Mn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ee(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _n(e,t,n){return t&&Ee(e.prototype,t),n&&Ee(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}var jn={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0},In,Ln=L.default.createContext();function Fn(){return jn}var kn=function(){function e(){Mn(this,e),this.usedNamespaces={}}return _n(e,[{key:"addUsedNamespaces",value:function(n){var r=this;n.forEach(function(i){r.usedNamespaces[i]||(r.usedNamespaces[i]=!0)})}},{key:"getUsedNamespaces",value:function(){return Object.keys(this.usedNamespaces)}}]),e}();function Nn(){return In}function Un(){if(console&&console.warn){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];typeof n[0]=="string"&&(n[0]="react-i18next:: ".concat(n[0])),(e=console).warn.apply(e,n)}}var be={};function re(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&be[t[0]]||(typeof t[0]=="string"&&(be[t[0]]=new Date),Un.apply(void 0,t))}function Pe(e,t,n){e.loadNamespaces(t,function(){if(e.isInitialized)n();else{var r=function i(){setTimeout(function(){e.off("initialized",i)},0),n()};e.on("initialized",r)}})}function Dn(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!t.languages||!t.languages.length)return re("i18n.languages were undefined or empty",t.languages),!0;var r=t.languages[0],i=t.options?t.options.fallbackLng:!1,a=t.languages[t.languages.length-1];if(r.toLowerCase()==="cimode")return!0;var o=function(l,u){var d=t.services.backendConnector.state["".concat(l,"|").concat(u)];return d===-1||d===2};return n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!o(t.isLanguageChangingTo,e)?!1:!!(t.hasResourceBundle(r,e)||!t.services.backendConnector.backend||o(r,e)&&(!i||o(a,e)))}function Vn(e){if(Array.isArray(e))return e}function Bn(e,t){var n=e==null?null:typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(l){a=!0,s=l}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function we(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Hn(e,t){if(!!e){if(typeof e=="string")return we(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return we(e,t)}}function $n(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
28
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function zn(e,t){return Vn(e)||Bn(e,t)||Hn(e,t)||$n()}function Ce(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Ce(Object(n),!0).forEach(function(r){Rn(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ce(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function ze(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.i18n,r=c.useContext(Ln)||{},i=r.i18n,a=r.defaultNS,o=n||i||Nn();if(o&&!o.reportNamespaces&&(o.reportNamespaces=new kn),!o){re("You will need to pass in an i18next instance by using initReactI18next");var s=function(O){return Array.isArray(O)?O[O.length-1]:O},l=[s,{},!1];return l.t=s,l.i18n={},l.ready=!1,l}o.options.react&&o.options.react.wait!==void 0&&re("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");var u=Z(Z(Z({},Fn()),o.options.react),t),d=u.useSuspense,p=u.keyPrefix,g=e||a||o.options&&o.options.defaultNS;g=typeof g=="string"?[g]:g||["translation"],o.reportNamespaces.addUsedNamespaces&&o.reportNamespaces.addUsedNamespaces(g);var h=(o.isInitialized||o.initializedStoreOnce)&&g.every(function(R){return Dn(R,o,u)});function y(){return o.getFixedT(null,u.nsMode==="fallback"?g:g[0],p)}var P=c.useState(y),S=zn(P,2),b=S[0],m=S[1],_=c.useRef(!0);c.useEffect(function(){var R=u.bindI18n,O=u.bindI18nStore;_.current=!0,!h&&!d&&Pe(o,g,function(){_.current&&m(y)});function j(){_.current&&m(y)}return R&&o&&o.on(R,j),O&&o&&o.store.on(O,j),function(){_.current=!1,R&&o&&R.split(" ").forEach(function(E){return o.off(E,j)}),O&&o&&O.split(" ").forEach(function(E){return o.store.off(E,j)})}},[o,g.join()]);var N=c.useRef(!0);c.useEffect(function(){_.current&&!N.current&&m(y),N.current=!1},[o]);var T=[b,o,h];if(T.t=b,T.i18n=o,T.ready=h,h||!h&&!d)return T;throw new Promise(function(R){Pe(o,g,function(){R()})})}function Yn(e){var t=e,{as:n,language:r,children:i}=t,a=$e(t,["as","language","children"]);const{i18n:o}=ze(),s=c.useMemo(()=>o.dir?o.dir(r):"ltr",[r]);return c.useMemo(()=>o.services?o.services.languageUtils.getLanguagePartFromCode(o.language)===o.services.languageUtils.getLanguagePartFromCode(r):!1,[o.language,r])?n?f.jsx(n,x(v({},I({},a)),{children:i})):f.jsx("span",x(v({},I({},a)),{children:i})):n?f.jsx(n,x(v({},Q(I({},a),{lang:r,dir:s})),{children:i})):f.jsx("span",x(v({},Q(I({},a),{lang:r,dir:s})),{children:i}))}function Ye(e,t,n=[],r=!1){if(!e||!t||t.length===0)return;if(t.length===1)return t[0];if(t.indexOf(e)!==-1)return e;const i=e.indexOf("-")!==-1?e.slice(0,e.indexOf("-")):null;if(i&&t.indexOf(i)!==-1)return i;for(const a of n)if(t.indexOf(a)!==-1)return a;if(!r){const o=t.map(s=>s.indexOf("-")!==-1?s.slice(0,s.indexOf("-")):null).indexOf(e);if(o!==-1)return t[o];for(const s of n){const l=s.indexOf("-")!==-1?s.slice(0,s.indexOf("-")):null,u=l?t.indexOf(l):-1;if(u!==-1)return t[u]}}return t.indexOf("none")!==-1?"none":t.indexOf("@none")!==-1?"@none":t[0]}function Qn(e,t,n={}){const{strictFallback:r=!1,defaultText:i="",separator:a=`
|
|
29
|
+
`,fallbackLanguages:o=[],closest:s}=n,l=Object.keys(e||{}),u=s?t:Ye(t,l,o,r);if(!e)return i;if(typeof e=="string")return e;const d=u?e[u]:void 0;return d?typeof d=="string"?d:d.join(a):""}function qn(e,t=[]){const{i18n:n}=ze(),r=n&&n.languages?n.languages:[],i=n&&n.language?n.language:"en";return c.useMemo(()=>{const a=e();return Ye(i,a,r)},[r,i,...t])}function Gn(e,t){const n=qn(()=>Object.keys(e||{}),[e]);return[c.useMemo(()=>Qn(e,n,{defaultText:t,closest:!0}),[n,t,e]),n]}const Kn=e=>{var t=e,{as:n,defaultText:r,enableDangerouslySetInnerHTML:i,children:a}=t,o=$e(t,["as","defaultText","enableDangerouslySetInnerHTML","children"]);const[s,l]=Gn(a,r);return l?f.jsx(Yn,x(v({},Q(I({},o),{as:n,language:l,title:i?void 0:s,dangerouslySetInnerHTML:i?{__html:s}:void 0})),{children:i?void 0:s})):n?f.jsx(n,x(v({},I({},o)),{children:s})):f.jsx("span",x(v({},Q(I({},o),{title:i?void 0:s,dangerouslySetInnerHTML:i?{__html:s}:void 0})),{children:i?void 0:s}))};function Qe({x:e,y:t,onChoiceChange:n,registerActions:r,defaultChoices:i,isStatic:a,renderViewerControls:o,renderMediaControls:s,strategies:l,backgroundStyle:u,alwaysShowBackground:d,onClickPaintingAnnotation:p,children:g}){const h=F(),y=_e(h,["deep-zoom"]),[P]=jt(),S=A(),b=c.useMemo(()=>je(S),[S]),[m,_]=pn({strategies:l||["images"],defaultChoices:i==null?void 0:i.map(({id:E})=>E)}),N=m.type==="images"?m.choice:void 0;c.useEffect(()=>{r&&r(_)},[m.annotations]),c.useEffect(()=>{if(i)for(const E of i)typeof E.opacity!="undefined"&&b.applyStyles({id:E.id},"atlas",{opacity:E.opacity})},[i]),c.useLayoutEffect(()=>{n&&n(N)},[N]);const T=hn({maxWidth:256,maxHeight:256});if(!h)return null;const R=h.accompanyingCanvas,O=T&&T.type==="fixed"?f.jsx("world-object",{height:h.height,width:h.width,x:e,y:t,children:f.jsx("world-image",{uri:T.id,target:{x:0,y:0,width:h.width,height:h.height},display:T.width&&T.height?{width:T.width,height:T.height}:void 0})}):null;if(m.type==="unknown"){if(O)return O;throw new Error(m.reason||"Unknown image strategy")}const j=f.jsxs(c.Fragment,{children:[P?f.jsx(ne,{page:P}):null,m.annotations&&m.annotations.pages?m.annotations.pages.map(E=>f.jsx(ne,{page:E},E.id)):null,g]});return f.jsxs(f.Fragment,{children:[f.jsxs("world-object",x(v({height:h.height,width:h.width,x:e,y:t},y),{children:[m.type==="empty"||d?f.jsx(Ve,{style:u}):null,m.type==="textual-content"?m.items.map((E,G)=>f.jsxs(f.Fragment,{children:[f.jsx(B.HTMLPortal,{onClick:p?U=>{U.stopPropagation(),p(E.annotationId,E,U)}:void 0,target:E.target.spatial||void 0,children:f.jsx(Kn,{children:E.text})},G),j]})):null,m.type==="images"?f.jsxs(f.Fragment,{children:[m.images.map((E,G)=>f.jsx(Le,{isStatic:a,image:E,id:E.id,thumbnail:G===0?T:void 0,onClick:p?U=>{U.stopPropagation(),p(E.annotationId,E,U)}:void 0},E.id)),j]}):null,(m.type==="images"||m.type==="empty"||m.type==="textual-content")&&o?f.jsx(H,{overlay:!0,children:o(m)}):null,m.type==="3d-model"?f.jsx(Cn,{model:m.model}):null,m.type==="media"?f.jsx(f.Fragment,{children:m.media.type==="Sound"?f.jsxs(Pn,{media:m.media,children:[O,s?s(m):null]}):m.media.type==="Video"?f.jsxs(wn,{media:m.media,children:[O,s?s(m):null]}):null}):null]}),`${h.id}/${m.type}`),m.type==="media"&&m.media.type==="Sound"&&R?f.jsx(ot,{canvas:R.id,children:f.jsx(Qe,{renderViewerControls:o})}):null]})}const Wn={RenderImage:Le,RenderCanvas:Qe,RenderAnnotationPage:ne,RenderAnnotation:Ie,Viewer:kt,CanvasBackground:Ve};exports.CanvasPanel=Wn;
|
|
28
30
|
//# sourceMappingURL=canvas-panel.js.map
|