@manifest-editor/creators 2.2.0 → 2.2.1-cdn.1.2412bf12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -91,8 +91,8 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
91
91
  position: absolute;
92
92
  `,Ee=v.default.label`
93
93
  ${Te}
94
- `;function E(e){let[t,n]=(0,m.useState)(!1),{progress:r,currentTime:i,element:a}=(0,_.useMediaElements)(),{duration:o,isMuted:s,volume:c,isPlaying:l,playRequested:u}=(0,_.useMediaState)(),{setVolume:d,toggleMute:f,play:p,pause:g,setDurationPercent:v}=(0,_.useMediaActions)(),y=s||c===0?fe:c>50?ue:de;return(0,m.useLayoutEffect)(()=>{if(a.current){let t=a.current;if(t.error&&e.onError){e.onError(t.error?.message||`Unknown error`);return}let n=()=>{e.onError&&e.onError(t.error?.message||`Unknown error`)},r=()=>{t.duration&&e.onDuration&&e.onDuration(t.duration),e.onDimensions&&t instanceof HTMLVideoElement&&e.onDimensions(t.videoWidth,t.videoHeight)};return t.addEventListener(`loadedmetadata`,r),t.addEventListener(`error`,n),()=>{t.removeEventListener(`loadedmetadata`,r),t.removeEventListener(`error`,n)}}},[]),(0,h.jsxs)(pe,{children:[(0,h.jsx)(he,{disabled:u,onClick:()=>{l?g():p()},children:u?(0,h.jsx)(we,{stroke:`#999`}):l?(0,h.jsx)(le,{title:`Pause`}):(0,h.jsx)(ce,{title:`Play`})}),(0,h.jsx)(ge,{ref:i,children:`0:00`}),(0,h.jsxs)(_e,{onClick:e=>{let{left:t,width:n}=e.currentTarget.getBoundingClientRect(),r=(e.pageX-t)/n;v(r)},children:[(0,h.jsx)(ye,{}),o?(0,h.jsx)(ve,{ref:r}):null]}),(0,h.jsx)(ge,{children:(0,_.formatTime)(o)}),(0,h.jsxs)(xe,{onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[(0,h.jsx)(Se,{$isOpen:t,children:(0,h.jsxs)(`span`,{children:[(0,h.jsx)(Ee,{htmlFor:`audio-slider`,children:`Change volume`}),(0,h.jsx)(Ce,{id:`audio-slider`,role:`slider`,disabled:s,min:`0`,max:`100`,value:c,onChange:e=>d(Number(e.currentTarget.value))})]})}),(0,h.jsx)(be,{onClick:()=>f(),children:(0,h.jsx)(y,{title:s?`Mute`:`Unmute`})})]})]})}async function D(e,t){let n={id:t.generateId(`annotation`),type:`Annotation`},r=t.options.targetType,i=t.embed({id:e.url,type:`Sound`,format:`audio/mp4`,duration:e.duration||0});if(r===`Annotation`)return t.embed({...n,label:(0,d.getValue)(e.label)&&e.label,motivation:e.motivation||t.options.initialData?.motivation||`painting`,body:i,target:t.getTarget()});if(r===`Canvas`){let r=t.generateId(`canvas`),a=t.generateId(`annotation-page`,{id:r,type:`Canvas`}),o=t.embed({...n,motivation:`painting`,body:i,target:{type:`SpecificResource`,source:{id:r,type:`Canvas`}}}),s=t.embed({id:a,type:`AnnotationPage`,items:[o]});return t.embed({id:r,type:`Canvas`,label:e.label||{en:[`Untitled HTML canvas`]},duration:e.duration||0,items:[s]})}}function O(e){let t=e.options.initialData,[n,r]=(0,m.useState)(t.url||``),[i,a]=(0,m.useState)(0),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)({en:[``]});return(0,m.useEffect)(()=>{if(s(``),a(0),n){let e=n.split(`/`).pop()?.split(`.`).shift();l({en:[e||``]})}},[n]),(0,h.jsxs)(f.PaddedSidebarContainer,{children:[o?(0,h.jsx)(f.ErrorMessage,{children:o}):null,(0,h.jsxs)(p.InputContainer,{$wide:!0,children:[(0,h.jsx)(p.InputLabel,{htmlFor:`audio-url`,children:`URL`}),(0,h.jsx)(p.Input,{type:`text`,id:`audio-url`,value:n,onChange:e=>r(e.target.value)})]}),n&&!o?(0,h.jsx)(`div`,{children:(0,h.jsx)(p.LanguageFieldEditor,{containerId:`label`,focusId:`label_`,label:`Label`,fields:c,onSave:e=>l(e.toInternationalString())},`${n}__${i}`)}):null,n&&!o?(0,h.jsx)(_.CanvasPanel.AudioHTML,{media:{url:n,duration:i,type:`Sound`},children:(0,h.jsx)(E,{onError:e=>s(e),onDuration:e=>a(~~e)},`${n}__${i}`)},`${n}__${i}`):null,i&&!o?(0,h.jsxs)(p.FormFieldWrapper,{children:[(0,h.jsx)(p.InputLabel,{htmlFor:`duration`,children:`Duration`}),(0,h.jsx)(p.Input,{type:`number`,id:`duration`,value:i,onChange:e=>a(e.target.valueAsNumber)})]}):null,(0,h.jsx)(f.ActionButton,{primary:!0,large:!0,type:`button`,onPress:()=>{e.runCreate({url:n,duration:i,label:c})},isDisabled:!n||!!o,children:`Add audio`})]})}const k=(0,u.defineCreator)({id:`@manifest-editor/audio-annotation`,create:D,label:`Audio`,summary:`Audio annotation`,icon:(0,h.jsx)(f.AudioIcon,{}),render(e){return(0,h.jsx)(O,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],async supportsResource(e,t){return x(e)&&((await w(e,t)).startsWith(`audio/`)||T(e,[`.mp3`,`.m4a`,`.wav`,`.ogg`]))?{initialData:{url:e}}:!1},supports:{initialData:!0,onlyPainting:!0,parentTypes:[`AnnotationPage`,`Manifest`],parentFields:[`items`]},staticFields:{type:`Annotation`}});async function A(e,t){let n={id:t.generateId(`annotation`),type:`Annotation`},r=t.options.targetType,i=Object.keys(e.body),a=[];for(let r of i){let i=e.body[r].join(`
95
- `);i&&a.push(await t.create(`@manifest-editor/html-body-creator`,{language:r,body:i},{parent:{resource:n,property:`items`}}))}let o=await t.create(`@manifest-editor/image-url-creator`,{url:e.imageUrl},{parent:{resource:n,property:`body`}});if(o&&a.push(o),r===`Annotation`)return t.embed({...n,motivation:e.motivation||t.options.initialData?.motivation||`painting`,body:a,target:t.getTarget()});if(r===`Canvas`){let r=t.generateId(`canvas`),i=t.generateId(`annotation-page`,{id:r,type:`Canvas`}),o=t.embed({...n,motivation:`painting`,body:a,target:{type:`SpecificResource`,source:{id:r,type:`Canvas`}}}),s=t.embed({id:i,type:`AnnotationPage`,items:[o]});return t.embed({id:r,type:`Canvas`,label:e.label||{en:[`Untitled HTML canvas`]},height:e.height||1e3,width:e.width||1e3,items:[s]})}}function De(e){let[t,n]=(0,y.useAnnotationCreatorState)({key:`bodyValue`,initialValue:{en:[``]},requestId:e.options.initialData?.requestId});return(0,h.jsx)(`form`,{onSubmit:t=>{t.preventDefault();let n=new FormData(t.target),r=Object.fromEntries(n.entries());e.runCreate({body:{en:[r.caption]},imageUrl:r.url})},children:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(p.InputContainer,{$wide:!0,children:[(0,h.jsx)(p.InputLabel,{htmlFor:`url`,children:`URL to Image`}),(0,h.jsx)(p.Input,{id:`url`,name:`url`,defaultValue:``,placeholder:`https://example.org/image.jpg`})]}),(0,h.jsxs)(p.InputContainer,{$wide:!0,children:[(0,h.jsx)(p.InputLabel,{htmlFor:`caption`,children:`Caption`}),(0,h.jsx)(p.Input,{id:`caption`,name:`caption`,placeholder:`Enter a caption`,onChange:e=>n({en:[e.target.value]}),value:t.en?.[0]||``})]}),(0,h.jsx)(f.ActionButton,{primary:!0,type:`submit`,children:`Create`})]})})}const Oe=(0,u.defineCreator)({id:`@manifest-editor/captioned-image-annotation`,create:A,label:`Captioned image`,summary:`Add an image from a URL with caption`,icon:(0,h.jsx)(f.AddImageIcon,{}),render(e){return(0,h.jsx)(De,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],supports:{initialData:!0,disallowPainting:!0,parentTypes:[`AnnotationPage`],parentFields:[`items`]},staticFields:{type:`Annotation`}});async function ke(e,t){let n={id:t.generateId(`annotation`),type:`Annotation`},r=t.options.targetType,i=Object.keys(e.body),a=[];for(let r of i){let i=e.body[r].join(`
96
- `);i&&a.push(await t.create(`@manifest-editor/html-body-creator`,{language:r,body:i},{parent:{resource:n,property:`items`}}))}if(r===`Annotation`)return t.embed({...n,motivation:e.motivation||t.options.initialData?.motivation||`painting`,body:a,target:t.getTarget()});if(r===`Canvas`){let r=t.generateId(`canvas`),i=t.generateId(`annotation-page`,{id:r,type:`Canvas`}),o=t.embed({...n,motivation:`painting`,body:a,target:{type:`SpecificResource`,source:{id:r,type:`Canvas`}}}),s=t.embed({id:i,type:`AnnotationPage`,items:[o]});return t.embed({id:r,type:`Canvas`,label:e.label||{en:[`Untitled HTML canvas`]},height:e.height||1e3,width:e.width||1e3,items:[s]})}}function Ae(e){let[t,n]=(0,y.useAnnotationCreatorState)({key:`bodyValue`,initialValue:{en:[``]},requestId:e.options.initialData?.requestId}),r=(0,d.getValue)(t).trim()===``;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(f.HTMLEditor,{className:`border-none`,value:t.en?.[0]||``,onChange:e=>n({en:[e]})}),(0,h.jsx)(f.ActionButton,{primary:!0,type:`button`,onPress:()=>{e.runCreate({body:t})},isDisabled:r,children:`Create`})]})}const je=(0,u.defineCreator)({id:`@manifest-editor/html-annotation`,create:ke,label:`HTML`,summary:`HTML annotation`,icon:(0,h.jsx)(f.HTMLIcon,{}),render(e){return(0,h.jsx)(Ae,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],supports:{initialData:!0,parentTypes:[`AnnotationPage`,`Manifest`],parentFields:[`items`]},staticFields:{type:`Annotation`}}),j={canvasInteraction:!0,spatial:!0,async run(e,{vault:t,options:n}){if(e&&e.type===`Annotation`&&n.targetType===`Annotation`){let n=t.get(e),r=n.target;if(!(r&&r.source?.type===`Canvas`))return;let i=r.source,a=t.get(i);if(!a.items)return;let o=t.get(a.items[0]);if(!o||o.items.length<2&&!a.behavior.includes(`multi-image`))return;let s=t.get(n.body)[0],c=n.body[0]?.selector,l=(s.service||[]).find(e=>(0,b.isImageService)(e));l&&l.width&&l.height&&(l.width!==s.width&&t.modifyEntityField({id:s.id,type:`ContentResource`},`width`,l.width),l.height!==s.height&&t.modifyEntityField({id:s.id,type:`ContentResource`},`height`,l.height));let u=l?.width||s.width,d=l?.height||s.height;if(c&&(c.type===`iiif:ImageApiSelector`||c.type===`ImageApiSelector`)&&c.region){let[e,t,n,r]=c.region.split(`,`);u=Number(n)||u,d=Number(r)||d}let f=new ee.EditorInstance({vault:t,reference:e}),m=(0,p.centerRectangles)(a,{width:u,height:d},.6);f.annotation.target.setPosition(m)}}},M={canvasInteraction:!0,spatial:!0,async run(e,{vault:t,options:n}){if(e&&e.type===`Annotation`&&n.targetType===`Annotation`){let n=t.get(e),r=n.target;if(!(r&&r.source?.type===`Canvas`))return;let i=r.source,a=t.get(i);if(!a.items||a.behavior.includes(`multi-image`))return;let o=t.get(a.items[0]);if(!o||o.items.length>1)return;let s=t.get(n.body);if(s.length!==1)return;let c=s[0],l=n.body[0]?.selector,u=(c.service||[])[0],d=u?.width||c.width,f=u?.height||c.height,p=c.duration||u?.duration;if(l&&(l.type===`iiif:ImageApiSelector`||l.type===`ImageApiSelector`)&&l.region){let[e,t,n,r]=l.region.split(`,`);d=Number(n)||d,f=Number(r)||f}let m=new ee.EditorInstance({vault:t,reference:i});t.batch(()=>{d!==void 0&&m.technical.width.set(d),f!==void 0&&m.technical.height.set(f),p!==void 0&&m.technical.duration.set(p)})}}};var Me=Object.defineProperty,Ne=(e,t,n)=>t in e?Me(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,N=(e,t,n)=>(Ne(e,typeof t==`symbol`?t:t+``,n),n);function P(e){return e.endsWith(`info.json`)?e:e.endsWith(`/`)?`${e}info.json`:`${e}/info.json`}var Pe=`http://library.stanford.edu/iiif/image-api/compliance.html#level0`,Fe=`http://library.stanford.edu/iiif/image-api/compliance.html#level1`,Ie=`http://library.stanford.edu/iiif/image-api/compliance.html#level2`,Le=`http://library.stanford.edu/iiif/image-api/conformance.html#level0`,Re=`http://library.stanford.edu/iiif/image-api/conformance.html#level1`,ze=`http://library.stanford.edu/iiif/image-api/conformance.html#level2`,Be=`http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0`,Ve=`http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level1`,He=`http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2`,Ue=`http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level0`,We=`http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level1`,Ge=`http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level2`,Ke=`http://iiif.io/api/image/1/level0.json`,qe=`http://iiif.io/api/image/1/profiles/level0.json`,Je=`http://iiif.io/api/image/1/level1.json`,Ye=`http://iiif.io/api/image/1/profiles/level1.json`,Xe=`http://iiif.io/api/image/1/level2.json`,Ze=`http://iiif.io/api/image/1/profiles/level2.json`,Qe=`http://iiif.io/api/image/2/level0.json`,$e=`http://iiif.io/api/image/2/profiles/level0.json`,et=`http://iiif.io/api/image/2/level1.json`,tt=`http://iiif.io/api/image/2/profiles/level1.json`,nt=`http://iiif.io/api/image/2/level2.json`,rt=`http://iiif.io/api/image/2/profiles/level2.json`,it=`level0`,at=`level1`,ot=`level2`,st=`http://iiif.io/api/image/2/level0`,ct=`http://iiif.io/api/image/2/level1`,lt=`http://iiif.io/api/image/2/level2`,ut=[lt,Ie,ze,He,Ge,Xe,Ze,nt,rt,ot],dt=[...ut,ct,Fe,Re,Ve,We,Je,Ye,et,tt,at],ft=[st,ct,lt,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,We,Ge,Ke,qe,Je,Ye,Xe,Ze,Qe,$e,et,tt,nt,rt,it,at,ot],pt={extraFormats:[`jpg`],extraQualities:[`default`],extraFeatures:[`sizeByWhListed`]},mt={extraFormats:[`jpg`],extraQualities:[`default`],extraFeatures:[`baseUriRedirect`,`cors`,`jsonldMediaType`,`regionByPx`,`regionSquare`,`sizeByWhListed`,`sizeByH`,`sizeByW`,`sizeByWh`]},ht={extraFormats:[`jpg`,`png`],extraQualities:[`default`],extraFeatures:[`baseUriRedirect`,`cors`,`jsonldMediaType`,`regionByPct`,`regionByPx`,`regionSquare`,`rotationBy90s`,`sizeByWhListed`,`sizeByConfinedWh`,`sizeByH`,`sizeByPct`,`sizeByW`,`sizeByWh`]};function gt(e){return ut.indexOf(e)===-1?dt.indexOf(e)===-1?pt:mt:ht}function _t(e){let t=e?Array.isArray(e.profile)?e.profile:[e.profile]:[],n={extraQualities:[],extraFormats:[],extraFeatures:[]};for(let e of t)if(typeof e==`string`&&(e=gt(e)),e){if(e.formats)for(let t of e.formats)n.extraFormats.indexOf(t)===-1&&n.extraFormats.push(t);if(e.qualities)for(let t of e.qualities)n.extraQualities.indexOf(t)===-1&&n.extraQualities.push(t);if(e.supports)for(let t of e.supports)n.extraFeatures.indexOf(t)===-1&&n.extraFeatures.push(t);if(e.maxHeight&&(n.maxHeight=e.maxHeight),e.maxWidth&&(n.maxWidth=e.maxWidth),e.maxArea&&(n.maxArea=e.maxArea),e.extraFormats)for(let t of e.extraFormats)n.extraFormats.indexOf(t)===-1&&n.extraFormats.push(t);if(e.extraQualities)for(let t of e.extraQualities)n.extraQualities.indexOf(t)===-1&&n.extraQualities.push(t);if(e.extraFeatures)for(let t of e.extraFeatures)n.extraFeatures.indexOf(t)===-1&&n.extraFeatures.push(t);e.maxHeight&&(n.maxHeight=e.maxHeight),e.maxWidth&&(n.maxWidth=e.maxWidth),e.maxArea&&(n.maxArea=e.maxArea)}if(e.extraFormats)for(let t of e.extraFormats)n.extraFormats.indexOf(t)===-1&&n.extraFormats.push(t);if(e.extraFeatures)for(let t of e.extraFeatures)n.extraFeatures.indexOf(t)===-1&&n.extraFeatures.push(t);if(e.extraQualities)for(let t of e.extraQualities)n.extraQualities.indexOf(t)===-1&&n.extraQualities.push(t);return n}function vt(e){try{if(e===`full`)return{full:!0};if(e===`square`)return{square:!0};let t=e.startsWith(`pct:`),n=e.substr(t?4:0).split(`,`).map(e=>parseFloat(e));return{x:n[0],y:n[1],w:n[2],h:n[3],percent:t}}catch{throw Error(`Expected 'full', 'square' or 'x,y,w,h'. Found `+e)}}function yt(e){let t={upscaled:!1,max:!1,confined:!1};if(e[0]===`^`&&(t.upscaled=!0,e=e.slice(1)),e===`max`||e===`full`)return t.max=!0,t.serialiseAsFull=e===`full`,t;if(e[0]===`!`&&(t.confined=!0,e=e.slice(1)),e[0]===`p`)return t.percentScale=parseFloat(e.slice(4)),t;let n=e.split(`,`).map(e=>e.trim());return n.length&&typeof n[0]<`u`&&(n[0]!==``&&(t.width=parseInt(n[0],10)),typeof n[1]<`u`&&n[1]!==``?(t.height=parseInt(n[1],10),t.version=2):t.version=3),t}function bt(e){let t={angle:0};if(e[0]===`!`&&(t.mirror=!0,e=e.substr(1)),t.angle=parseFloat(e)%360,Number.isNaN(t.angle))throw Error(`Invalid rotation ${e}`);return t}function xt(e,t=``){let n=e.match(/^(([a-zA-Z]+):\/\/([^/]+))?((.*)+)/);if(!n)throw Error(`Invalid or unknown input ${e}`);let r=n[2],i=n[3],a=n[4];if(a[0]===`/`&&(a=a.substring(1)),t.length>0){if(t[0]===`/`&&(t=t.substring(1)),t!==a.substring(0,t.length))throw Error(`Path does not start with prefix (path: ${a}, prefix: ${t})`);a=a.substring(t.length)}return{scheme:r,server:i,path:a,prefix:t}}function St(e,t=``){let{path:n,scheme:r,server:i,prefix:a}=xt(e,t),o=(n||``).split(`/`).reverse(),[s,c,l,u,...d]=o,f=d.reverse().filter(Boolean).join(`/`);if(o.length===1||s===``)return{type:`base`,scheme:r,server:i,prefix:a,identifier:f};if(s===`info.json`){let[,...e]=o;return{type:`info`,scheme:r,server:i,prefix:a,identifier:e.reverse().filter(Boolean).join(`/`)}}let p=(s||``).split(`.`);if(typeof p[1]>`u`||typeof p[0]>`u`||typeof u>`u`||typeof l>`u`||typeof c>`u`)throw Error(`Invalid image request`);return{type:`image`,scheme:r,server:i,prefix:a,identifier:f,originalPath:n,region:vt(u),size:yt(l),rotation:bt(c),quality:p[0],format:p[1]}}function Ct(e){let t=St(P(e.id));if(t.type!==`info`)throw Error(`Invalid service URL`);let n=_t(e);return{identifier:t.identifier,originalPath:``,server:t.server,prefix:t.prefix,scheme:t.scheme,type:`image`,quality:n.extraQualities.indexOf(`default`)===-1?n.extraQualities[0]:`default`,region:{full:!0},size:{max:!0,upscaled:!1,confined:!1},format:`jpg`,rotation:{angle:0}}}function wt(e,t,n){let r=n.length,i=[];for(let t=0;t<r;t++){let r=n[t];if(r){let t=r.width;i.push(e/t)}}return i}function Tt(e,t,n){let r=n.length,i=[];for(let a=0;a<r;a++){let r=n[a];r&&i.push({width:Math.floor(e/r),height:Math.floor(t/r)})}return i}function F(e){if(e[`@id`])return e[`@id`];if(e.id)return e.id}function I(e){if(!e||!e.profile||!F(e))return!1;let t=Array.isArray(e.profile)?e.profile:[e.profile];for(let e of t)if(typeof e==`string`&&ft.indexOf(e)!==-1)return!0;return!1}function Et(e){if(!I(e))return!1;let t=Array.isArray(e.profile)?e.profile:[e.profile];for(let e of t)if(typeof e==`string`){if(dt.indexOf(e)!==-1)return!0}else{let t=[...e.supports||[],...e.extraFeatures||[]];if(t.indexOf(`regionByPx`)!==-1&&(t.indexOf(`sizeByW`)!==-1||t.indexOf(`sizeByWh`)!==-1))return!0}return!1}function L(e,t){if(t&&t.profile){let n=t.profile;if(n){let t=Array.isArray(n)?n:[n];return t.includes(`level${e}`)||t.includes(`http://iiif.io/api/image/2/level${e}.json`)||t.includes(`http://iiif.io/api/image/1/level${e}.json`)||t.includes(`http://iiif.io/api/image/1/profiles/level${e}.json`)}}return!1}function R(e){return I(e)?L(0,e)?0:L(1,e)?1:L(2,e)?2:null:null}function Dt(e){return(e[`@context`]?Array.isArray(e[`@context`])?e[`@context`]:[e[`@context`]]:[]).indexOf(`http://iiif.io/api/image/3/context.json`)!==-1}function Ot(e){if(!Et(e))return[];let t=[],n=Array.isArray(e.profile)?e.profile:[e.profile],r=n.length;for(let t=0;t<r;t++){let r=n[t];if(r&&typeof r!=`string`&&(r.maxHeight||r.maxWidth))return[{id:F(e),type:`variable`,minWidth:0,minHeight:0,maxHeight:r.maxHeight||r.maxWidth,maxWidth:r.maxWidth||r.maxHeight,level:R(e),version:e[`@context`]===`http://iiif.io/api/image/3/context.json`?3:2}]}if(e.tiles){let n=e.tiles.length;for(let r=0;r<n;r++){let n=e.tiles[r];n&&(n.height||n.width)&&t.push({id:F(e),type:`variable`,minHeight:0,minWidth:0,maxHeight:n.height||n.width,maxWidth:n.width,level:R(e),version:Dt(e)?3:2})}}return t}function kt(e){let t=e.match(/^.*\/(full)\/(((\d+),(\d+)?)|max)\/(\d+)\/default\.(jpg|png|jpeg)$/);if(t&&t[4]&&t[5]){let n=t[1],r=parseInt(t[4],10),i=parseInt(t[5],10),a=t[7];if((n===`max`||n===`full`)&&r&&i&&a)return{type:`fixed`,id:e,height:i,width:r}}return{type:`unknown`,id:e}}function At(e){if(e[`@type`])return e[`@type`];if(e.type)return e.type}function jt(e){if(typeof e==`string`)return kt(e);let t=At(e);if(t!==`Image`&&t!==`sc:Image`)return null;let n=e,r=F(n);return r?r&&n.width&&n.height?{id:r,type:`fixed`,width:n.width,height:n.height,unsafe:!0}:kt(r):null}function Mt(e){return I(e)?(e&&e.sizes?e.sizes:[]).map(t=>({id:F(e),type:`fixed-service`,height:t.height,width:t.width,level:R(e),version:Dt(e)?3:2})):[]}function Nt(e){let t=[],n=e.length;for(let r=0;r<n;r++){let n=e[r];if(!n)continue;let i=Mt(n);i.length&&t.push(...i);let a=Ot(n);a.length&&t.push(...a)}return t}function Pt(e){let t=e.service?Array.isArray(e.service)?e.service:[e.service]:[],n=t.length,r=[];for(let e=0;e<n;e++)I(t[e])&&r.push(t[e]);return r}function Ft(e,t=!0,n){let r=[],i=jt(e);if(i===null)return r;let a=e;if(r.push(i),t&&a&&a.width&&a.height){let e=[],t=Pt(a);for(let r of t){let t={id:F(r),width:a.width,height:a.height};if(n.canLoadSync(t)){let r=n.loadServiceSync(t);r&&(r.height||(r.height=a.height),r.width||(r.width=a.width),e.push(...Nt([r])))}}if(e.length)return r.push(...e),r}return a.service&&r.push(...Nt(a.service)),r}function It({x:e=0,y:t=0,w:n,h:r,full:i,square:a,percent:o}){if(i)return`full`;if(a)return`square`;if(typeof n>`u`||typeof r>`u`)throw Error(`RegionParameter: invalid region`);let s=`${e},${t},${n},${r}`;return o?`pct:${s}`:s}function Lt({max:e,percentScale:t,upscaled:n,confined:r,width:i,height:a,serialiseAsFull:o,version:s}){let c=[];return n&&c.push(`^`),e?(c.push(o?`full`:`max`),c.join(``)):(r&&c.push(`!`),t&&c.push(`pct:${t}`),i&&c.push(`${i}`),c.push(`,`),a&&s===3&&c.push(`${a}`),c.join(``))}function Rt(e){return`${e.mirror?`!`:``}${(e.angle||0)%360}`}function zt(e,t){let n=e.prefix.startsWith(`/`)?e.prefix.substr(1):e.prefix,r=`${e.scheme}://${e.server}/${n?`${n}/`:``}${e.identifier}`;if(e.type===`base`)return r;if(e.type===`info`)return`${r}/info.json`;let{size:i}=e,{region:a,rotation:o,format:s,quality:c}=e;if(t){let e=t[`@context`]?Array.isArray(t[`@context`])?t[`@context`]:[t[`@context`]]:[],n=e.indexOf(`http://iiif.io/api/image/2/context.json`)!==-1,r=e.indexOf(`http://iiif.io/api/image/3/context.json`)!==-1;if((i.width===t.width&&!i.height||i.height===t.height&&!i.width||i.width===t.width&&i.height===t.height)&&(i={...i,max:!0}),n&&(i.max&&!i.serialiseAsFull&&(i={...i,serialiseAsFull:!0}),!i.max&&i.width&&i.height&&(i={...i,height:void 0}),i={...i,version:2}),r){if(i.max&&i.serialiseAsFull&&(i={...i,serialiseAsFull:!1}),i.width&&!i.height&&t.width&&t.height){let e=t.height/t.width;i={...i,height:Math.ceil(i.width*e)}}i={...i,version:3}}}return[r,It(a),Lt(i),Rt(o),`${c}.${s}`].filter(Boolean).join(`/`)}function z(e,t,n){let r=Ct({"@context":e.version===3?`http://iiif.io/api/image/3/context.json`:`http://iiif.io/api/image/2/context.json`,id:P(F(e)),profile:e.level===null||typeof e.level>`u`?`level0`:`level${e.level}`,type:e.version===3?`ImageService3`:`ImageService2`});if(r.type!==`image`)throw Error(`Invalid service`);return r.size.max=!1,r.size.width=t,r.size.height=n,{id:zt(r),type:`fixed`,width:t,height:n||e.height/(e.width||1)*t,unsafe:e.width>t}}function B(e){let t=e.replace(/(https?:\/\/)?(www.)?/i,``);return t.indexOf(`/`)===-1?t:t.split(`/`)[0]}function Bt(e,t,n){let r=e.width?e.width:e.maxWidth;return n.height<=e.maxHeight&&n.width<=e.maxWidth&&n.height>=e.minHeight&&n.width>=e.minWidth&&(!t||Math.abs(n.width-r)<Math.abs(t.width-r))}function Vt(e,t){let n=[],r=Object.assign({unsafeImageService:!1,atAnyCost:!0,fallback:!0,minHeight:64,minWidth:64,maxHeight:1/0,maxWidth:1/0,returnAllOptions:!1,preferFixedSize:!1,allowUnsafe:!1,explain:!1,height:0,width:0},e),i=(e,t=0)=>r.explain?n.push(Array(t).fill(0).map(e=>` `).join(``)+e().trim()):void 0,a=[],o=[],s=null;i(()=>`Using configuration: ${JSON.stringify(r,null,2)}`);let c=(e,t)=>{if(i(()=>`Swapping choice`,3),Bt(r,t,e)){if(r.preferFixedSize&&e.unsafe){i(()=>`We found an image that was marked as unsafe, but it was the best size. (${e.id})`,4),o.push(e);return}r.returnAllOptions&&t&&o.push(t),i(()=>`We found a new image that was the best size. (${e.id})`,4),s=e}else r.returnAllOptions&&o.push(e)};i(()=>`The input shows we have ${t.length} list(s) of candidates to choose from.`);let l=t.length;for(let e=0;e<l;e++){let n=t[e]();i(()=>`Candidate group ${e}: ${JSON.stringify(n,null,2)}`,1);let o=n.length;i(()=>`Checking candidate list number ${e} and found ${o} potential ways of creating image(s)`,1);for(let e=0;e<o;e++){let t=n[e];i(()=>`-> Checking candidate ${e}`,1),t.type===`unknown`&&r.atAnyCost&&(i(()=>`We've found an unknown image type, adding this to the "last resort" list`,2),a.push(t)),t.type===`fixed`&&(t.unsafe?(i(()=>`We've found an unsafe fixed image type, adding this to the "last resort" list`,2),a.push(t)):(i(()=>`We've found a fixed size image, checking if it matches the request`,2),c(t,s))),t.type===`fixed-service`&&(r.unsafeImageService?(i(()=>`Checking for an image from the tile source, without calculating the right height and width (unsafeImageService)`,2),c(z(t,r.width,r.height),s)):(i(()=>`Checking for an image from the tile source 3`,2),c(z(t,t.width,t.height),s))),t.type===`variable`&&t.maxWidth&&c(z({id:t.id,type:`fixed-service`,width:t.maxWidth,height:t.maxWidth,level:t.level,version:t.version},t.maxWidth),s)}if(s&&!r.returnAllOptions){if(s.unsafe||r.allowUnsafe)continue;i(()=>`We found a match in choice list number ${e}, no searching any more`);break}}return r.atAnyCost&&o.length===0?(i(()=>s?`We found an image! ${s.id} of type ${s.type}`:`We found no images, but "atAnyCost" is set, so returning that`),{best:s||a[0]||null,fallback:a.slice(1),log:n}):r.returnAllOptions?(i(()=>`Returning all options that we have found`),{best:(r.atAnyCost?s||o[0]||a[0]:s||o[0])||null,fallback:[...o,...a],log:n}):(i(()=>`Returning the best image that we found, and a fallback`),{best:s||o[0]||null,fallback:s?o:o.slice(1),log:n})}function Ht(e,t,n){let r=e>t?e:t,i=n.length,a=[];for(let e=0;e<i;e++){let t=n[e];if(!t||t.scaleFactors.length===0)continue;let i=t.scaleFactors[0];if(!i)continue;let o=r/i,s=[i];for(;o>=t.width;)i*=2,s.push(i),o/=2;a.push({...t,scaleFactors:s})}return a}function Ut(e,t){if(e.length!==t.length)return!1;if(e.length===0&&t.length===0)return!0;let n=e.length,r=!0;for(let i=0;i<n;i++){let n=e[i],a=t[i];if(n.width!==a.width||n.height!==a.height){r=!1;break}}if(r)return!0;let i=0;for(let r=0;r<n;r++)for(let a=0;a<n;a++)if(e[r].width===t[a].width&&e[r].height===t[a].height){i++;break}return i===n}function Wt(e){return L(0,e)}new class{constructor(e={}){N(this,`config`,{verificationsRequired:1,approximateServices:!1,enableFetching:!0,disableThrottling:!1}),N(this,`fetchingCount`,0),N(this,`imageServices`,{}),N(this,`knownImageServers`,{}),this.config=Object.assign(this.config,e)}setConfig(e){Object.assign(this.config,e)}sample(e,t,n=!0){let r=B(F(e)),i=P(F(e)),a=this.knownImageServers[r];return this.imageServices[i]=Object.assign(e,{real:!0}),!a&&e.tiles&&!Wt(e)?(this.knownImageServers[r]={verifications:0,malformed:!1,root:r,preLoaded:n,sampledId:F(e),verified:!1,server:null,result:{context:e[`@context`]||[],sampledProfile:e.profile,resourceServiceRatio:t&&e.height?t.height/e.height:1,sampledSizes:e.sizes||[],sizeRatios:wt(e.width,e.height,e.sizes||[]),sampledTiles:e.tiles||[]}},!0):this.verify(e)}preLoad(e,t=!0){this.knownImageServers[e.root]=e,t&&(this.knownImageServers[e.root].malformed=!1,this.knownImageServers[e.root].verifications=this.config.verificationsRequired)}predict(e,t=!1,n=!1){let r=e?.source,i=B(F(e)),a=this.knownImageServers[i],o=P(F(e));return this.imageServices[o]?this.imageServices[o]||null:!this.config.approximateServices||!a||!a.result||!(r?.height||e.height)||!(r?.width||e.width)||!n&&(a.malformed||a.verifications<this.config.verificationsRequired)||Wt(e.source)?null:(this.imageServices[o]||(this.imageServices[o]={"@context":a.result.context,"@id":F(e),id:F(e),protocol:`http://iiif.io/api/image`,tiles:r?.tiles||Ht(e.width,e.height,a.result.sampledTiles),sizes:r?.sizes||Tt(Math.round(e.width/a.result.resourceServiceRatio),Math.round(e.height/a.result.resourceServiceRatio),a.result.sizeRatios),profile:r?.profile||a.result.sampledProfile,height:r?.height||e.height,width:r?.width||e.width,real:!1}),this.imageServices[o]||null)}async getThumbnailFromResource(e,t,n=!0,r=[]){let i=e?await this.getImageCandidates(e,n):[];return Vt(t,[()=>r,()=>i])}async getImageCandidates(e,t=!0){let n=e;if(t&&n&&n.height&&n.width){let e=Pt(n);for(let t of e){let e={id:F(t),width:t.width?t.width:n.width,height:t.height?t.height:n.height,source:t};await this.loadService(e)}}return Ft(e,t,this)}async verify(e){let t=this.predict(e,!1,!0),n=await this.fetchService(F(e));if(!t)return!1;let r=t.height===n.height&&t.width===n.width&&t[`@context`]===n[`@context`]&&Ut(t.sizes||[],n.sizes||[]);if(r){let t=B(F(e)),n=this.knownImageServers[t];n&&(n.verifications+=1,n.verifications>=this.config.verificationsRequired&&(n.verified=!0))}return r}canLoadSync(e){let t=typeof e==`string`?e:F(e),n=P(t);if(this.imageServices[n])return!0;let r=this.knownImageServers[B(t)];return!!(r&&!r.malformed&&r.verifications>=this.config.verificationsRequired)}async markAsMalformed(e){return this.knownImageServers[B(F(e))].malformed=!0,this.loadService(e,!0)}async fetchService(e,t=!1){let n=P(e),r=this.imageServices[n];if(r&&(!t||r.real))return r;if(!this.config.enableFetching)throw Error(`Fetching is not enabled`);let i=await this.fetch(n).then(e=>e.json());return!i.id&&i[`@id`]&&(i.id=i[`@id`]),i.id!==e&&(i.id=e,i[`@id`]&&(i[`@id`]=e)),this.imageServices[n]=Object.assign(i,{real:!0}),this.imageServices[n]}async fetch(e,t){return fetch(e,t)}async loadService(e,t=!1){if(!this.config.disableThrottling){let e=!0;for(;e;)if(this.fetchingCount>=this.config.verificationsRequired)await new Promise(e=>setTimeout(e,500));else{e=!1;break}}let n=this.knownImageServers[B(F(e))];if(n&&!n.malformed&&!t){await n.result;let t=this.loadServiceSync(e);if(t)return t}this.fetchingCount++;let r=await this.fetchService(F(e),t);return this.fetchingCount--,r.real&&this.sample(r,e),r}loadServiceSync(e){let t=P(F(e));return this.imageServices[t]?this.imageServices[t]:this.config.approximateServices?this.predict(e):null}};const V={canvasInteraction:!0,spatial:!0,async run(e,{vault:t,options:n}){if(e&&e.type===`Annotation`&&n.targetType===`Annotation`){let n=t.get(e),r=n.target;if(!(r&&r.source?.type===`Canvas`))return;let i=r.source,a=t.get(i);if(!a.items||a.behavior.includes(`multi-image`)||!t.get(a.items[0]))return;let o=Array.isArray(n.body)?n.body[0]:n.body;if(o.type===`SpecificResource`&&o.selector)return;let s=t.get(n.body)[0],c=(s.service||[]).find(e=>I(e));c&&c.width&&c.height&&(c.width!==s.width&&t.modifyEntityField({id:s.id,type:`ContentResource`},`width`,c.width),c.height!==s.height&&t.modifyEntityField({id:s.id,type:`ContentResource`},`height`,c.height))}}};async function Gt(e,t){let n={...e.service};n[`@id`]&&(n.id=n[`@id`]),n[`@type`]&&(n.type=n[`@type`]);let r=(0,b.createImageServiceRequest)(n),i=(0,b.imageServiceRequestToString)({identifier:r.identifier,server:r.server,scheme:r.scheme,type:`image`,size:{max:!e.size?.width&&!e.size?.height,confined:!1,upscaled:!1,...e.size||{}},format:`jpg`,region:{full:!0},rotation:{angle:0},quality:`default`,prefix:r.prefix,originalPath:r.originalPath});return t.embed({id:i,type:`Image`,format:e.format||`image/jpeg`,height:e.height||n.height,width:e.width||n.width,service:e.embedService===!1?void 0:[e.service]})}function H(e){return e.endsWith(`default.jpg`)?(0,b.imageServiceRequestToString)({...(0,b.parseImageServiceRequest)(e),type:`info`}):(0,b.canonicalServiceUrl)(e)}function U(e){let t=e.options.initialData,n=t.url?H(t.url):``,[r,i]=(0,m.useState)(n||``);return(0,h.jsx)(f.PaddedSidebarContainer,{children:(0,h.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let n=new FormData(t.target),r=Object.fromEntries(n.entries()),i=r.url;if(i){let t=H(i);if(!t)throw Error(`Invalid image service request`);fetch(t).then(e=>e.json()).then(t=>{e.runCreate({url:r.url,service:t})})}},children:[(0,h.jsx)(`div`,{className:`flex gap-2 items-center`,children:(0,h.jsxs)(p.InputContainer,{$wide:!0,children:[(0,h.jsx)(p.InputLabel,{htmlFor:`id`,children:`Link to image service`}),(0,h.jsx)(p.Input,{id:`url`,name:`url`,defaultValue:t.url||``,onPaste:e=>{let t=e.clipboardData.getData(`text/plain`);i(t?H(t):``)},onBlur:e=>i(e.currentTarget.value?H(e.currentTarget.value):``)})]})}),(0,h.jsx)(`div`,{className:`relative flex z-0 my-5 h-96 min-h-0 min-w-0 overflow-hidden bg-gray-200 rounded items-center justify-center`,children:r.trim()?(0,h.jsx)(te.ErrorBoundary,{fallbackRender:()=>(0,h.jsx)(`div`,{children:`Invalid service`}),children:(0,h.jsx)(Kt,{src:r},r)}):(0,h.jsx)(`div`,{className:`text-grey-600`,children:`Preview`})}),(0,h.jsx)(`div`,{children:(0,h.jsx)(f.ActionButton,{primary:!0,large:!0,type:`submit`,isDisabled:!r,children:`Create`})})]})})}function Kt({src:e}){let t=(0,_.useImage)({id:e},{size:{width:512}});return t?(0,h.jsx)(`div`,{className:`h-full`,children:(0,h.jsx)(`img`,{className:`w-full h-full object-contain`,src:t})}):(0,h.jsx)(we,{})}async function qt(e,t){let n={id:t.generateId(`annotation`),type:`Annotation`},r=t.options.targetType,i=await(0,u.creatorHelper)(t,`Annotation`,`body`,`@manifest-editor/image-service-creator`)(e,{parent:{resource:n,property:`body`}});if(r===`Annotation`)return{...n,body:[i],motivation:e.motivation||`painting`,target:t.getTarget()};if(r===`Canvas`){let r=t.generateId(`canvas`),a=t.generateId(`annotation-page`,{id:r,type:`Canvas`}),o=t.embed({...n,motivation:`painting`,body:[i],target:{type:`SpecificResource`,source:{id:r,type:`Canvas`}}}),s=t.embed({id:a,type:`AnnotationPage`,items:[o]}),c;return e.service?.sizes&&(c=await(0,u.creatorHelper)(t,`Canvas`,`thumbnail`,`@manifest-editor/thumbnail-image`)({service:e.service,width:e.thumbnailSize||400})),t.embed({id:r,type:`Canvas`,label:e.label||{en:[`Untitled canvas`]},height:i.resource.height||1e3,width:i.resource.width||1e3,thumbnail:c?[c]:void 0,items:[s]})}}function Jt(e){return(0,h.jsx)(U,{...e})}const W=(0,u.defineCreator)({id:`@manifest-editor/image-service-creator`,create:Gt,label:`Image Service`,summary:`Add an image from Image Service`,icon:(0,h.jsx)(f.IIIFLogo,{style:{padding:10}}),tags:[`image`,`image-service`],async supportsResource(e,t){if(!x(e))return!1;let n=H(e);if(!n)return!1;let r=await S(n,t);return oe(r)?{initialData:{url:e,service:r}}:!1},render(e){return(0,h.jsx)(U,{...e})},resourceType:`ContentResource`,resourceFields:[`id`,`type`,`height`,`width`,`format`,`service`],supports:{initialData:!0,parentFields:[`logo`,`body`,`thumbnail`,`items`],custom(e,t){return e.property!==`items`||e.resource.type===`ContentResource`&&t.get(e.resource,{skipSelfReturn:!1})?.type===`Choice`}}}),Yt=(0,u.defineCreator)({id:`@manifest-editor/image-service-annotation`,create:qt,label:`IIIF Image`,dependencies:[`@manifest-editor/image-service-creator`],summary:`IIIF Image service`,tags:[`image`,`image-service`],icon:(0,h.jsx)(f.IIIFLogo,{style:{padding:10}}),render(e){return(0,h.jsx)(Jt,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],supportsResource:W.supportsResource,supports:{initialData:!0,onlyPainting:!0,parentTypes:[`AnnotationPage`,`Manifest`],parentFields:[`items`]},sideEffects:[V,M,j],staticFields:{type:`Annotation`}});async function Xt(e,t){if(!e.height||!e.width){let t=await(0,y.getImageDimensions)(e.url);t&&(e.height=t.height,e.width=t.width)}return t.embed({id:e.url,type:`Image`,format:e.format||await(0,y.getFormat)(e.url),height:e.height,width:e.width,service:e.service?Array.isArray(e.service)?e.service:[e.service]:void 0})}function G(e){let t=e.options.initialData;return(0,h.jsx)(f.PaddedSidebarContainer,{children:(0,h.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let n=new FormData(t.target),r=Object.fromEntries(n.entries());r.url&&e.runCreate({url:r.url})},children:[(0,h.jsxs)(p.InputContainer,{$wide:!0,children:[(0,h.jsx)(p.InputLabel,{htmlFor:`id`,children:`Link to Image`}),(0,h.jsx)(p.Input,{id:`url`,name:`url`,defaultValue:t.url||``})]}),(0,h.jsx)(f.ActionButton,{primary:!0,large:!0,type:`submit`,children:`Create`})]})})}async function Zt(e,t){let n={id:t.generateId(`annotation`),type:`Annotation`},r=t.options.targetType,i=await(0,u.creatorHelper)(t,`Annotation`,`body`,`@manifest-editor/image-url-creator`)(e,{parent:{resource:n,property:`body`}});if(r===`Annotation`)return t.embed({...n,body:[i],motivation:e.motivation||`painting`,target:t.getTarget()});if(r===`Canvas`){let r=t.generateId(`canvas`),a=t.generateId(`annotation-page`,{id:r,type:`Canvas`}),o=t.embed({...n,motivation:`painting`,body:[i],target:{type:`SpecificResource`,source:{id:r,type:`Canvas`}}}),s=t.embed({id:a,type:`AnnotationPage`,items:[o]});return t.embed({id:r,type:`Canvas`,label:e.label||{en:[`Untitled canvas`]},height:i.resource.height||1e3,width:i.resource.width||1e3,items:[s]})}throw Error(`Unsupported target type`)}function Qt(e){return(0,h.jsx)(G,{...e})}const K=(0,u.defineCreator)({id:`@manifest-editor/image-url-creator`,create:Xt,label:`Image`,summary:`Image from a URL`,icon:(0,h.jsx)(f.AddImageIcon,{}),tags:[`image`],async supportsResource(e,t){if(!x(e))return!1;let n=H(e);if(n)try{if(oe(await t.json(n)))return!1}catch{}let r=await w(e,t);return r.startsWith(`image/`)||T(e,[`.jpg`,`.jpeg`,`.png`,`.gif`,`.webp`])?{initialData:{url:e,format:r||void 0}}:!1},render(e){return(0,h.jsx)(G,{...e})},resourceType:`ContentResource`,resourceFields:[`format`],supports:{initialData:!0,parentFields:[`logo`,`body`,`thumbnail`,`items`],custom(e,t){return e.property!==`items`||e.resource.type===`ContentResource`&&t.get(e.resource,{skipSelfReturn:!1})?.type===`Choice`}},staticFields:{type:`Image`}}),$t=(0,u.defineCreator)({id:`@manifest-editor/image-url-annotation`,create:Zt,label:`Image`,dependencies:[`@manifest-editor/image-url-creator`],summary:`Image from URL`,tags:[`image`],icon:(0,h.jsx)(f.AddImageIcon,{}),render(e){return(0,h.jsx)(Qt,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],supportsResource:K.supportsResource,supports:{initialData:!0,onlyPainting:!0,parentTypes:[`AnnotationPage`,`Manifest`],parentFields:[`items`]},sideEffects:[V,M,j],staticFields:{type:`Annotation`}});async function en(e,t){let n=[],r=(0,u.creatorHelper)(t,`Annotation`,`body`,`@manifest-editor/image-url-creator`);for(let i of e.images)n.push(await r(i,t.options));return n}function q(e){return(0,h.jsx)(f.PaddedSidebarContainer,{children:(0,h.jsxs)(f.Form.Form,{onSubmit:t=>{t.preventDefault();let n=new FormData(t.target),r=Object.fromEntries(n.entries());r.urls&&e.runCreate({images:r.urls.split(`
97
- `).map(e=>({url:e}))})},children:[(0,h.jsxs)(f.Form.InputContainer,{className:`mb-4`,children:[(0,h.jsx)(f.Form.Label,{children:`Enter a list of URLs (one per line)`}),(0,h.jsx)(f.Form.TextArea,{name:`urls`,rows:`10`})]}),(0,h.jsx)(f.ActionButton,{primary:!0,large:!0,type:`submit`,children:`Create`})]})})}async function tn(e,t){let n=[],r=(0,u.creatorHelper)(t,`AnnotationPage`,`items`,`@manifest-editor/image-url-annotation`);for(let i of e.images)n.push(await r(i,t.options));return n}const nn=(0,u.defineCreator)({id:`@manifest-editor/image-url-list-annotation`,create:tn,label:`List of Images`,dependencies:[`@manifest-editor/image-url-annotation`],summary:`List of Images from URLs`,tags:[`image`],icon:(0,h.jsx)(f.ImageListIcon,{}),render(e){return(0,h.jsx)(q,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],supports:{onlyPainting:!0,parentTypes:[`AnnotationPage`,`Manifest`],parentFields:[`items`]},sideEffects:[V,M,j],staticFields:{type:`Annotation`}}),rn=(0,u.defineCreator)({id:`@manifest-editor/no-body-annotation`,create:an,label:`Annotation without body`,summary:`Add an annotation that only has motivation and target`,icon:(0,h.jsx)(f.EmptyCanvasIcon,{}),resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`target`],supports:{initialData:!0,parentTypes:[`AnnotationPage`],parentFields:[`items`],disallowPainting:!0},actionButton:`Create empty annotation`,sideEffects:[],staticFields:{type:`Annotation`}});function an(e,t){return t.embed({id:t.generateId(`annotation`),type:`Annotation`,label:e?.label,motivation:e.motivation||t.options.initialData?.motivation||`highlighting`,target:t.getTarget()})}function on({media:e,onError:t,duration:n,onDuration:r,onDimensions:i}){let[{element:a,currentTime:o,progress:s},c,l]=(0,_.useSimpleMediaPlayer)({duration:n});return(0,h.jsxs)(_.MediaPlayerProvider,{element:a,state:c,actions:l,currentTime:o,progress:s,children:[(0,h.jsx)(`div`,{style:{maxHeight:400,aspectRatio:`${e.width}/${e.height}`,position:`relative`},children:(0,h.jsx)(_.CanvasPanel.VideoHTML,{element:a,media:e,playPause:l.playPause})}),(0,h.jsx)(E,{onError:t,onDuration:r,onDimensions:i})]})}async function sn(e,t){let n={id:t.generateId(`annotation`),type:`Annotation`},r=t.options.targetType,i=t.embed({id:e.url,type:`Video`,format:`video/mp4`,width:e.width,height:e.height,duration:e.duration||0});if(r===`Annotation`)return t.embed({...n,label:(0,d.getValue)(e.label)&&e.label,motivation:e.motivation||t.options.initialData?.motivation||`painting`,body:i,target:t.getTarget()});if(r===`Canvas`){let r=t.generateId(`canvas`),a=t.generateId(`annotation-page`,{id:r,type:`Canvas`}),o=t.embed({...n,motivation:`painting`,body:i,target:{type:`SpecificResource`,source:{id:r,type:`Canvas`}}}),s=t.embed({id:a,type:`AnnotationPage`,items:[o]});return t.embed({id:r,type:`Canvas`,label:e.label||{en:[`Untitled HTML canvas`]},duration:e.duration||0,width:e.width,height:e.height,items:[s]})}}function cn(e){let t=e.options.initialData,[n,r]=(0,m.useState)(t.url||``),[i,a]=(0,m.useState)(0),[o,s]=(0,m.useState)(0),[c,l]=(0,m.useState)(0),[u,d]=(0,m.useState)(``),[g,_]=(0,m.useState)({en:[``]});return(0,m.useEffect)(()=>{if(d(``),a(0),n){let e=n.split(`/`).pop()?.split(`.`).shift();_({en:[e||``]})}},[n]),(0,h.jsxs)(f.PaddedSidebarContainer,{children:[u?(0,h.jsx)(f.ErrorMessage,{children:u}):null,(0,h.jsxs)(p.InputContainer,{$wide:!0,children:[(0,h.jsx)(p.InputLabel,{htmlFor:`video-url`,children:`URL`}),(0,h.jsx)(p.Input,{type:`text`,id:`video-url`,value:n,onChange:e=>r(e.target.value)})]}),n&&!u?(0,h.jsx)(`div`,{children:(0,h.jsx)(p.LanguageFieldEditor,{containerId:`label`,focusId:`label_`,label:`Label`,fields:g,onSave:e=>_(e.toInternationalString())},`${n}__${i}`)}):null,n&&!u?(0,h.jsx)(`div`,{className:`mb-4 bg-black`,children:(0,h.jsx)(on,{duration:i,onDuration:e=>a(e),onError:e=>d(e),media:{url:n,duration:i,height:c,width:o,type:`Video`},onDimensions:(e,t)=>{s(e||0),l(t||0)}})}):null,!u&&(i||o||c)?(0,h.jsx)(p.InputContainer,{$wide:!0,children:(0,h.jsx)(p.DimensionsTriplet,{widthId:`width`,width:o||0,changeWidth:e=>s(e),heightId:`height`,height:c||0,changeHeight:e=>l(e),durationId:`duration`,duration:i||0,changeDuration:e=>a(e)})}):null,(0,h.jsx)(f.ActionButton,{primary:!0,large:!0,type:`button`,onPress:()=>{e.runCreate({url:n,duration:i,label:g,width:o,height:c})},isDisabled:!n||!!u,children:`Add video`})]})}const ln=(0,u.defineCreator)({id:`@manifest-editor/video-annotation`,create:sn,label:`Video`,summary:`Video annotation`,icon:(0,h.jsx)(f.VideoIcon,{}),render(e){return(0,h.jsx)(cn,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],async supportsResource(e,t){return x(e)&&((await w(e,t)).startsWith(`video/`)||T(e,[`.mp4`,`.m4v`,`.webm`,`.mov`]))?{initialData:{url:e}}:!1},supports:{onlyPainting:!0,initialData:!0,parentTypes:[`AnnotationPage`,`Manifest`],parentFields:[`items`]},staticFields:{type:`Annotation`}}),un=()=>(0,h.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`24px`,viewBox:`0 0 24 24`,width:`24px`,fill:`#000000`,transform:`scale(-1, 1)`,children:(0,h.jsxs)(`g`,{children:[(0,h.jsx)(`rect`,{fill:`none`,height:`24`,width:`24`}),(0,h.jsx)(`path`,{d:`M16,20H2V4h14V20z M18,8h4V4h-4V8z M18,20h4v-4h-4V20z M18,14h4v-4h-4V14z`})]})}),dn=(0,u.defineCreator)({id:`@manifest-editor/empty-annotation-page`,create:(e,t)=>t.embed({id:t.generateId(`annotations`),label:e.label,type:`AnnotationPage`,items:[]}),label:`Empty annotation page`,summary:`AnnotationPage with nothing`,icon:(0,h.jsx)(un,{}),resourceType:`AnnotationPage`,resourceFields:[`id`,`type`,`items`],supports:{parentTypes:[`Manifest`,`Canvas`,`Range`],parentFieldMap:{Manifest:[`annotations`],Canvas:[`items`,`annotations`],Range:[`annotations`]}}}),fn=(0,u.defineCreator)({id:`@manifest-editor/empty-canvas`,create:(e,t)=>{let n=t.generateId(`canvas`),r=t.embed({id:t.generateId(`annotation-page`,{id:n,type:`Canvas`}),type:`AnnotationPage`,items:[]});return{id:n,type:`Canvas`,label:e.label||{en:[``]},height:e.height||1e3,width:e.width||1e3,items:[r]}},label:`Empty canvas`,summary:`No content`,icon:(0,h.jsx)(f.EmptyCanvasIcon,{}),resourceType:`Canvas`,resourceFields:[`id`,`type`,`label`,`height`,`width`,`items`],supports:{parentTypes:[`Manifest`],parentFields:[`items`]}});var pn=process.env.NODE_ENV===`production`,J=`Invariant failed`;function Y(e,t){if(!e){if(pn)throw Error(J);var n=typeof t==`function`?t():t,r=n?`${J}: ${n}`:J;throw Error(r)}}const mn=(0,u.defineCreator)({id:`@manifest-editor/internal-canvas`,create:gn,label:`Internal canvas link`,summary:`Canvas from the same manifest`,icon:(0,h.jsx)(un,{}),resourceType:`Canvas`,resourceFields:[`id`,`type`,`label`],supports:{parentTypes:[`Manifest`],parentFields:[`start`]},render:e=>(0,h.jsx)(hn,{...e})});function hn(e){let t=(0,_.useManifest)(),n=(0,_.useVault)(),r=(0,m.useMemo)(()=>({canSelectCanvas:!1,canSelectCollection:!1,canSelectManifest:!0,canCropImage:!1,alwaysShowNavigationArrow:!1,multiSelect:!1}),[]),i=(0,m.useMemo)(()=>[{type:`callback`,cb:t=>e.runCreate({id:t}),label:`Select canvas`,supportedTypes:[`Canvas`],format:{type:`url`}}],[e.runCreate]),a=(0,m.useMemo)(()=>({saveToLocalStorage:!1,restoreFromLocalStorage:!1,initialHistory:[{url:t?.id,resource:t?.id,route:`/loading?id=${t?.id}`,metadata:{type:`Manifest`}}]}),[t?.id]);return Y(t,`Manifest is not loaded`),(0,h.jsx)(_.VaultProvider,{vault:n,children:(0,h.jsx)(ne.IIIFBrowser,{vault:n,navigation:r,output:i,history:a})})}async function gn(e,t){return t.embed({id:e.id,type:`Canvas`})}const _n=e=>(0,h.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,height:`1em`,width:`1em`,...e,children:[(0,h.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,h.jsx)(`path`,{d:`M5 17v2h14v-2H5zm4.5-4.2h5l.9 2.2h2.1L12.75 4h-1.5L6.5 15h2.1l.9-2.2zM12 5.98 13.87 11h-3.74L12 5.98z`})]});async function vn(e,t){return t.embed({id:t.generateId(`html/${e.language}`),language:e.language,type:`TextualBody`,format:`text/html`,value:e.body||``})}function yn(e){let{i18n:t}=(0,y.useConfig)(),[n,r]=(0,m.useState)(`<p></p>`),[i,a]=(0,m.useState)(t.defaultLanguage);return(0,h.jsxs)(f.PaddedSidebarContainer,{children:[(0,h.jsx)(f.HTMLEditor,{className:`border-none`,value:n,onChange:e=>r(e)}),(0,h.jsx)(f.ActionButton,{primary:!0,large:!0,type:`button`,onPress:()=>{e.runCreate({language:i,body:n})},children:`Create`})]})}const bn=(0,u.defineCreator)({id:`@manifest-editor/html-body-creator`,create:vn,label:`HTML Body`,summary:`Add HTML annotation body`,icon:(0,h.jsx)(_n,{}),render(e){return(0,h.jsx)(yn,{...e})},resourceType:`ContentResource`,resourceFields:[`id`,`language`,`type`,`format`,`value`],supports:{parentTypes:[`Annotation`,`ContentResource`],parentFields:[`body`,`items`],custom(e,t){if(e.resource.type===`Annotation`)return e.property===`body`;let n=t.get(e.resource,{skipSelfReturn:!1});return e.property===`items`&&n?.type===`Choice`}},staticFields:{type:`TextualBody`,format:`text/html`}});function X(e,t,n,r=0){return`${e}/${Math.floor(t.x)},${Math.floor(t.y)},${Math.floor(t.width)},${Math.floor(t.height)}/${n}/${r}/default.jpg`}async function xn(e,t){let n=t.options.targetType,r=e.output,i=[];for(let{resource:a,selector:o,parent:s,rotation:c}of r){let r=a.type,u=new d.Vault;if((n===`Canvas`||n===`Annotation`||n===`ContentResource`)&&r===`Canvas`){let r=a.id,d=s?.type===`Manifest`?s.id:void 0;Y(d,`Could not find Manifest`);let f=u.get({id:d,type:`Manifest`})||await u.loadManifest(d);Y(f,`Manifest not found`);let p=t.config.addManifestMetadataToCanvas!==!1;e.trackManifest?.({requiredStatement:f.requiredStatement,rights:f.rights,...p?{metadata:f.metadata||[]}:{},partOf:[{id:d,type:`Manifest`,label:f.label}]});let m=e=>{if(e.type===`SpecificResource`&&e.source)return{...e,source:m(e.source)};let t=e.type===`Canvas`&&!p?{}:{metadata:f.metadata||[]};return{requiredStatement:f.requiredStatement,rights:f.rights,...t,...e,partOf:[{id:d,type:`Manifest`,label:f.label}]}},h=f.items.find(e=>e.id===r);Y(h,`Canvas not found`);let g=u.get(h),_=l.t(o,c);if(n===`Canvas`&&!_){let e=u.toPresentation3(g);e.label||(e.label={en:[`Untitled canvas`]}),t.vault.loadSync(e.id,m(e)),i.push(t.embed({id:e.id,type:`Canvas`}));continue}let v=u.get(g.items[0]),y=u.get(v.items[0]);if(n===`Annotation`||n===`Canvas`||n===`ContentResource`){let r=u.toPresentation3(y);r.id=t.generateId(`Annotation`);let a=null,s={width:0,height:0};if(r?.body?.service){let t=r?.body.width,n=r?.body.height;a=(0,b.getImageServices)(r?.body)[0],a&&(!a.width||!a.height)&&(a.width=t,a.height=n),s.width=t,s.height=n,e.trackSize&&e.trackSize(s)}if(_){let u={...r.body},d=``;if(a&&o?.type===`BoxSelector`){let e=a.id||a[`@id`]||``;e&&(u.id=X(e,o.spatial,`max`,c),d=X(e,o.spatial,`512,`,c))}r.body={id:t.generateId(`SpecificResource`,y),type:`SpecificResource`,source:u,selector:_};let f=l.n(o?.type===`BoxSelector`?{width:~~o.spatial.width,height:~~o.spatial.height}:s,c);if(e.trackSize&&e.trackSize(f),n===`ContentResource`){i.push(m(r.body));continue}if(n===`Canvas`){let e=t.generateId(`Canvas`,y);r.target=e;let n=t.generateId(`Page`,y),a=t.embed({id:n,type:`AnnotationPage`,items:[r]}),{width:o,height:s}=f;i.push(t.embed(m({id:e,type:`Canvas`,label:{en:[`Untitled canvas`]},width:o,height:s,thumbnail:d?[t.embed({id:d,type:`Image`,format:`image/jpeg`,width:512,height:Math.round(s/o*512)})]:void 0,items:[a]})));continue}i.push(t.embed(m({...r,target:t.getTarget()})));continue}i.push(t.embed(m({...r,target:t.getTarget()})))}}}return i}const Sn=(0,m.lazy)(()=>Promise.resolve().then(()=>require("./iiif-browser-form.lazy-Df2fAM6b.cjs"))),Cn=(0,u.defineCreator)({id:`@manifest-editor/iiif-browser-creator`,create:xn,label:`IIIF Browser`,summary:`Browse IIIF Resources`,icon:(0,h.jsx)(f.IIIFBrowserIcon,{}),configuration:{fields:[{id:`addManifestMetadataToCanvas`,type:`checkbox`,label:`Add manifest metadata to imported canvases`,summary:`Copies metadata from the source Manifest when the IIIF Browser creates a Canvas.`,defaultValue:!0}]},render(e){return(0,h.jsx)(Sn,{...e})},hiddenModal:!0,tags:[`image`,`image-service`],async supportsResource(e,t){let n=C(await S(e,t));return n===`Manifest`||n===`Collection`||await se(e)?{initialData:{url:e}}:!1},resourceType:`ContentResource`,resourceFields:[`id`,`language`,`type`,`format`,`value`],additionalTypes:[`Annotation`,`Canvas`],supports:{initialData:!0,onlyPainting:!0,parentTypes:[`Annotation`,`Manifest`,`AnnotationPage`],parentFields:[`body`,`items`],parentFieldMap:{Annotation:[`body`],Manifest:[`items`],AnnotationPage:[`items`]}},sideEffects:[{canvasInteraction:!0,spatial:!0,async run(e,{vault:t,options:n}){if(!(e&&e.type===`Annotation`&&n.targetType===`Annotation`))return;let r=t.get(e),i=r.target;if(!(i&&i.source?.type===`Canvas`))return;let a=(Array.isArray(r.body)?r.body[0]:r.body)?.selector;if(!(a&&(a.type===`iiif:ImageApiSelector`||a.type===`ImageApiSelector`)&&a.region))return;let[o,s,c,l]=a.region.split(`,`).map(Number);if(![o,s,c,l].every(Number.isFinite)||c<=0||l<=0)return;let[u]=t.get(r.body),d=(u?.service||[]).find(e=>(0,b.isImageService)(e)),f=d?.id||d?.[`@id`];if(!f)return;let p=X(f,{x:o,y:s,width:c,height:l},`512,`);t.loadSync(p,{id:p,type:`Image`,format:`image/jpeg`,width:512,height:Math.round(l/c*512),service:[d]}),t.modifyEntityField(i.source,`thumbnail`,[{id:p,type:`ContentResource`}])}},V,M,j],staticFields:{}}),Z=(0,u.defineCreator)({id:`@manifest-editor/image-url-list`,label:`Image URL List`,summary:`Image from a list of URLs`,create:en,icon:(0,h.jsx)(f.ImageListIcon,{}),render(e){return(0,h.jsx)(q,{...e})},resourceType:`ContentResource`,resourceFields:[`format`],supports:{parentFields:[`logo`,`body`,`thumbnail`]},staticFields:{type:`Image`}});async function wn(e,t){return t.embed({id:e.url,type:`Text`,label:e.label,format:`text/plain`})}function Tn(e){let[t,n]=(0,m.useState)({en:[`View as text`]});return(0,h.jsx)(f.PaddedSidebarContainer,{children:(0,h.jsxs)(`form`,{onSubmit:n=>{n.preventDefault();let r=new FormData(n.target),i=Object.fromEntries(r.entries());i.url&&e.runCreate({url:i.url,label:t})},children:[(0,h.jsx)(p.LanguageFieldEditor,{focusId:`label`,label:`Label`,fields:t,onSave:e=>n(e.toInternationalString())}),(0,h.jsxs)(p.InputContainer,{$wide:!0,children:[(0,h.jsx)(p.InputLabel,{htmlFor:`id`,children:`Link to plaintext`}),(0,h.jsx)(p.Input,{id:`url`,name:`url`,defaultValue:``})]}),(0,h.jsx)(f.ActionButton,{primary:!0,large:!0,type:`submit`,children:`Create`})]})})}const En=(0,u.defineCreator)({id:`@manifest-editor/plaintext-creator`,create:wn,label:`Plaintext`,summary:`Add link to an plaintext`,icon:(0,h.jsx)(_n,{}),render(e){return(0,h.jsx)(Tn,{...e})},resourceType:`ContentResource`,resourceFields:[`label`,`format`],supports:{parentFields:[`seeAlso`,`rendering`]},staticFields:{format:`text/plain`}});function Dn(e,t){e[`@id`]&&(e.id=e[`@id`]),e[`@type`]&&(e.type=e[`@type`]);let n=(0,b.createImageServiceRequest)(e);return(0,b.imageServiceRequestToString)({identifier:n.identifier,server:n.server,scheme:n.scheme,type:`image`,size:{max:!1,confined:!1,upscaled:!1,width:t.width,height:t.height},format:`jpg`,region:{full:!0},rotation:{angle:0},quality:`default`,prefix:n.prefix,originalPath:n.originalPath})}function Q(e){return e.endsWith(`default.jpg`)?(0,b.imageServiceRequestToString)({...(0,b.parseImageServiceRequest)(e),type:`info`}):(0,b.canonicalServiceUrl)(e)}async function On(e,t){let n={...e.service},r=n.sizes;if(n[`@id`]&&(n.id=n[`@id`]),n[`@type`]&&(n.type=n[`@type`]),e.thumbnailUrl)return t.embed({id:e.thumbnailUrl,type:`Image`,format:`image/jpeg`,width:e.width,height:e.height});if(r){let i=e.width||400,a=null;for(let e of r)(!a||Math.abs(e.width-i)<Math.abs(a.width-i))&&(a={width:e.width,height:e.height});if(a){let e=Dn(n,a);return t.embed({id:e,type:`Image`,format:`image/jpeg`,width:a.width,height:a.height})}}return null}function kn(e){let[t,n]=(0,m.useState)(``),[r,i]=(0,m.useState)(null),[a,o]=(0,m.useState)({width:0,height:0}),s=(0,m.useMemo)(()=>!r||!a.width||!a.height?null:Dn(r,a),[a,r]);return r?(0,h.jsxs)(f.PaddedSidebarContainer,{children:[(0,h.jsxs)(`div`,{className:`mb-4`,children:[(0,h.jsx)(`div`,{className:`mb-2`,children:r[`@id`]||r.id}),(0,h.jsx)(`div`,{className:`flex gap-2 mb-4`,children:r.sizes?.map(e=>{let t=e.width===a.width;return(0,h.jsxs)(f.ActionButton,{primary:t,isDisabled:t,large:!0,onPress:()=>o(e),children:[e.width,`x`,e.height]},e.width)})}),s?(0,h.jsx)(`img`,{src:s,alt:`preview of selected resource`}):null]}),(0,h.jsx)(f.ActionButton,{primary:!0,large:!0,isDisabled:!s,onPress:()=>{r&&e.runCreate({service:r,width:a.width,height:a.height})},children:`Add thumbnail`})]}):(0,h.jsx)(f.PaddedSidebarContainer,{children:(0,h.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let t=new FormData(e.target),n=Object.fromEntries(t.entries()).url;if(n){let e=Q(n);if(!e)throw Error(`Invalid image service request`);fetch(e).then(e=>e.json()).then(e=>{i(e);let t=e.sizes?.[0];t&&o(t)})}},children:[(0,h.jsx)(`div`,{className:`flex gap-2 items-center`,children:(0,h.jsxs)(p.InputContainer,{$wide:!0,children:[(0,h.jsx)(p.InputLabel,{htmlFor:`id`,children:`Link to image service`}),(0,h.jsx)(p.Input,{id:`url`,name:`url`,defaultValue:``,onPaste:e=>{let t=e.clipboardData.getData(`text/plain`);n(t?Q(t):``)},onBlur:e=>n(e.currentTarget.value?Q(e.currentTarget.value):``)})]})}),(0,h.jsx)(`div`,{children:(0,h.jsx)(f.ActionButton,{primary:!0,large:!0,type:`submit`,isDisabled:!t,children:`Select size`})})]})})}const An=(0,u.defineCreator)({id:`@manifest-editor/thumbnail-image`,create:On,label:`Thumbnail from service`,summary:`Add thumbnail from an image service`,icon:(0,h.jsx)(f.ScaledImageIcon,{}),render(e){return(0,h.jsx)(kn,{...e})},resourceType:`ContentResource`,resourceFields:[`id`,`type`,`format`],supports:{parentFields:[`thumbnail`]}});function jn(){return(0,h.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`24px`,viewBox:`0 0 24 24`,width:`24px`,fill:`#000000`,children:[(0,h.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,h.jsx)(`path`,{d:`M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z`})]})}async function Mn(e,t){return t.embed({id:e.url,type:`Text`,label:e.label,format:`text/html`})}function Nn(e){let[t,n]=(0,m.useState)({en:[``]});return(0,h.jsx)(f.PaddedSidebarContainer,{children:(0,h.jsxs)(`form`,{onSubmit:n=>{n.preventDefault();let r=new FormData(n.target),i=Object.fromEntries(r.entries());i.url&&e.runCreate({url:i.url,label:t})},children:[(0,h.jsx)(p.LanguageFieldEditor,{focusId:`label`,label:`Label`,fields:t,onSave:e=>n(e.toInternationalString())}),(0,h.jsxs)(p.InputContainer,{$wide:!0,children:[(0,h.jsx)(p.InputLabel,{htmlFor:`id`,children:`Link`}),(0,h.jsx)(p.Input,{id:`url`,name:`url`,defaultValue:``})]}),(0,h.jsx)(f.ActionButton,{primary:!0,large:!0,type:`submit`,children:`Create link`})]})})}const Pn=(0,u.defineCreator)({id:`@manifest-editor/web-page-creator`,create:Mn,label:`Web page`,summary:`Add link to an external web page`,icon:(0,h.jsx)(jn,{}),render(e){return(0,h.jsx)(Nn,{...e})},resourceType:`ContentResource`,resourceFields:[`label`,`format`],supports:{parentFields:[`seeAlso`,`rendering`,`homepage`]}}),Fn=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function $(e){let t=(e||``).match(Fn);return t?t[1]:null}function In(e){return!!$(e.youtubeUrl)}function Ln(e,t){let n=$(e.youtubeUrl);return t.embed({id:`https://www.youtube.com/watch?v=${n}`,type:`Video`,service:[{type:`Service`,profile:`http://digirati.com/objectifier`,params:{data:`https://www.youtube.com/embed/${n}`}},{id:`https://www.youtube.com/watch?v=${n}`,type:`Service`,profile:`https://www.youtube.com`}]})}async function Rn(e,t){let n=Ln(e,t);if(t.options.targetType===`Canvas`){let r=t.generateId(`canvas`),i=t.generateId(`annotation-page`,{id:r,type:`Canvas`}),a=t.embed({id:t.generateId(`annotation`,{id:i,type:`AnnotationPage`}),type:`Annotation`,motivation:`painting`,body:[n],target:{type:`SpecificResource`,source:{id:r,type:`Canvas`}}}),o=t.embed({id:i,type:`AnnotationPage`,items:[a]});return t.embed({id:r,type:`Canvas`,label:e.label||{en:[`Untitled YouTube canvas`]},height:e.height||1e3,width:e.width||1e3,duration:e.duration||1,items:[o]})}return t.options.targetType===`Annotation`?t.embed({id:t.generateId(`annotation`),type:`Annotation`,motivation:`painting`,body:[n],target:t.getTarget()}):n}function zn(e){let t=e.options.initialData;return(0,h.jsx)(f.PaddedSidebarContainer,{children:(0,h.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let n=new FormData(t.target),r=Object.fromEntries(n.entries());r.youtubeUrl&&e.runCreate({youtubeUrl:r.youtubeUrl})},children:[(0,h.jsxs)(p.InputContainer,{$wide:!0,children:[(0,h.jsx)(p.InputLabel,{htmlFor:`id`,children:`Link to YouTube`}),(0,h.jsx)(p.Input,{id:`youtubeUrl`,name:`youtubeUrl`,defaultValue:t.youtubeUrl||``})]}),(0,h.jsx)(f.ActionButton,{primary:!0,large:!0,type:`submit`,children:`Create`})]})})}const Bn=(0,u.defineCreator)({id:`@manifest-editor/youtube`,create:Rn,label:`YouTube`,summary:`Embed YouTube`,icon:(0,h.jsx)(f.YouTubeIcon,{}),resourceType:`ContentResource`,additionalTypes:[`Canvas`,`Annotation`],resourceFields:[`id`,`type`,`service`],supportsResource(e){return $(e)?{initialData:{youtubeUrl:e}}:!1},render:e=>(0,h.jsx)(zn,{...e}),supports:{initialData:!0,onlyPainting:!0,parentTypes:[`Annotation`,`Manifest`,`AnnotationPage`],parentFieldMap:{Annotation:[`body`],Manifest:[`items`],AnnotationPage:[`items`]}},staticFields:{type:`Video`}});async function Vn(e,t){let n=e.output||[],r=[];for(let e of n){let{resource:n,parent:i,selector:a}=e,o=t.getPreviewVault(),s=(0,d.createThumbnailHelper)(o);if(n.type===`Manifest`){let e=n.id;Y(e,`Could not find Manifest ID`);let i=await o.loadManifest(e),a=await s.getBestThumbnailAtSize(i,{width:256,height:256},!1);Y(i,`Manifest not found`),r.push(t.embed({id:n.id,type:`Manifest`,label:i.label,summary:i.summary,thumbnail:a?.best?[{id:a.best.id,type:`Image`}]:void 0}));continue}if(n.type===`Collection`){let e=n.id;Y(e,`Could not find Manifest ID`);let i=await o.loadManifest(e);Y(i,`Collection not found`),r.push(t.embed({id:n.id,type:`Collection`,label:i.label}))}}return r}const Hn=(0,m.lazy)(()=>Promise.resolve().then(()=>Un));var Un=o({default:()=>Wn});function Wn(e){let t=(0,y.usePreviewVault)(),n=(0,m.useMemo)(()=>e.options.initialData||{},[e.options.initialData]),r=(0,m.useMemo)(()=>[{type:`callback`,label:`Select`,supportedTypes:[`Manifest`,`Collection`,`ManifestList`,`CollectionList`,`CollectionItemList`],cb:t=>e.runCreate({output:t}),format:{type:`custom`,format:(e,t,n)=>{let r=Array.isArray(e)?e:[{...e,parent:t}],i=[];for(let e of r)i.push({resource:n.get(e),parent:e.parent,selector:e.selector});return i}}}],[e.runCreate]),i=(0,m.useMemo)(()=>({canCropImage:!1,canSelectCanvas:!1,canSelectManifest:!0,canSelectCollection:!0,multiSelect:!0,...n.iiifBrowserOptions?.navigation||{}}),[n.iiifBrowserOptions?.navigation]),a=(0,m.useMemo)(()=>({buttonClassName:`bg-me-primary-500 text-white hover:bg-me-primary-600`,homeLink:n.url||(typeof e.config?.defaultCollection==`string`?e.config.defaultCollection:void 0),...n.iiifBrowserOptions?.ui||{}}),[n,e.config]),o=(0,m.useMemo)(()=>{let e=n.iiifBrowserOptions?.history||{};return n.url?{...e,restoreFromLocalStorage:!1,saveToLocalStorage:!1,initialHistory:[{url:n.url,resource:null,route:`/loading?id=${encodeURIComponent(n.url)}`}]}:e},[n]);return(0,h.jsx)(y.PreviewVaultBoundary,{children:(0,h.jsx)(ne.IIIFBrowser,{ui:a,vault:t,className:`iiif-browser border-none border-t rounded-none h-[70vh] min-h-[60vh] max-h-full max-w-full`,output:r,navigation:i,customPages:n.iiifBrowserOptions?.customPages||{},history:o})})}const Gn=(0,u.defineCreator)({id:`@manifest-editor/manifest-browser-creator`,configKey:`@manifest-editor/iiif-browser-creator`,create:Vn,label:`IIIF Browser`,summary:`Browse IIIF Resources`,icon:(0,h.jsx)(f.IIIFBrowserIcon,{}),render(e){return(0,h.jsx)(Wn,{...e})},async supportsResource(e,t){let n=C(await S(e,t));return n===`Manifest`||n===`Collection`||await se(e)?{initialData:{url:e}}:!1},resourceType:`Manifest`,resourceFields:[`id`,`label`],additionalTypes:[`Collection`],supports:{initialData:!0,parentTypes:[`Collection`,`Manifest`,`Canvas`],parentFieldMap:{Collection:[`items`],Manifest:[`partOf`],Canvas:[`partOf`]}},sideEffects:[],staticFields:{}});async function Kn(e,t,n){let r=t.generateId(`range`,n?{id:n,type:`Range`}:void 0);return t.embed({id:r,type:`Range`,label:e.label||{en:[`Untitled range`]},items:e.items||[]})}function qn(e){let[t,n]=(0,m.useState)({en:[``]});return(0,h.jsx)(f.PaddedSidebarContainer,{children:(0,h.jsxs)(`form`,{onSubmit:n=>{n.preventDefault(),t&&e.runCreate({type:`Range`,label:t})},children:[(0,h.jsx)(p.LanguageFieldEditor,{focusId:`label`,label:`Label`,fields:t,onSave:e=>n(e.toInternationalString())}),(0,h.jsx)(f.ActionButton,{primary:!0,type:`submit`,children:`Create range`})]})})}const Jn=(0,u.defineCreator)({id:`@manifest-editor/range-with-items`,create:Kn,label:`Range`,summary:`Add a new range`,icon:(0,h.jsx)(f.RangesIcon,{}),render(e){return(0,h.jsx)(qn,{...e})},resourceType:`Range`,resourceFields:[`id`,`label`,`type`],supports:{parentTypes:[`Range`],parentFields:[`items`]},staticFields:{type:`Range`}});async function Yn(e,t,n){let r=t.generateId(`range`,n?{id:n,type:`Range`}:void 0);return t.embed({id:r,type:`Range`,label:e.label||{en:[`Table of Contents`]},items:(e.items||[]).map(e=>t.ref(e))})}function Xn(e){let[t,n]=(0,m.useState)({en:[``]});return(0,h.jsx)(f.PaddedSidebarContainer,{children:(0,h.jsxs)(`form`,{onSubmit:n=>{n.preventDefault(),t&&e.runCreate({type:`Range`,label:t})},children:[(0,h.jsx)(p.LanguageFieldEditor,{focusId:`label`,label:`Label`,fields:t,onSave:e=>n(e.toInternationalString())}),(0,h.jsx)(f.ActionButton,{primary:!0,type:`submit`,children:`Create range`})]})})}const Zn=(0,u.defineCreator)({id:`@manifest-editor/range-top-level`,create:Yn,label:`Top Level Range`,summary:`Add a new top level range`,icon:(0,h.jsx)(f.RangesIcon,{}),render(e){return(0,h.jsx)(Xn,{...e})},resourceType:`Range`,resourceFields:[`id`,`label`,`type`],supports:{parentTypes:[`Manifest`],parentFields:[`structures`]},staticFields:{type:`Range`}}),Qn=[W,Yt,K,$t,ln,k,bn,je,Bn,Cn,fn,En,Pn,dn,rn,mn,Oe,Z,nn,An,Zn,Jn,ae];exports.CreateAudioAnnotationForm=O,exports.CreateCaptionedImageAnnotation=De,exports.CreateHTMLAnnotation=Ae,exports.CreateHTMLBodyForm=yn,exports.CreateImageServerForm=U,exports.CreateImageServiceAnnotationForm=Jt,exports.CreateImageUrlAnnotationForm=Qt,exports.CreateImageUrlForm=G,exports.CreateImageUrlListForm=q,exports.CreatePlaintextForm=Tn,exports.CreateProviderForm=ie,exports.CreateThumbnailForm=kn,exports.CreateVideoAnnotationForm=cn,exports.CreateWebPageForm=Nn,exports.IIIFBrowserCreatorForm=Sn,exports.ManifestBrowserCreatorForm=Hn,exports.RangeWithItemsCreatorForm=qn,exports.TopLevelRangeCreatorForm=Xn,exports.YouTubeForm=zn,exports.allCreators=Qn,exports.audioAnnotation=k,exports.captionedImageAnnotation=Oe,exports.createAudioAnnotation=D,exports.createCaptionedImageAnnotation=A,exports.createFromIIIFBrowserOutput=xn,exports.createFromManifestBrowserOutput=Vn,exports.createHtmlAnnotation=ke,exports.createHtmlBody=vn,exports.createImageServer=Gt,exports.createImageServiceAnnotation=qt,exports.createImageUrl=Xt,exports.createImageUrlAnnotation=Zt,exports.createImageUrlList=en,exports.createImageUrlListAnnotation=tn,exports.createNoBodyAnnotation=an,exports.createPlaintext=wn,exports.createProvider=re,exports.createRangeTopLevel=Yn,exports.createRangeWithItems=Kn,exports.createThumbnail=On,exports.createVideoAnnotation=sn,exports.createWebPage=Mn,exports.createYoutubeBody=Rn,exports.createYoutubeBodyResource=Ln,exports.croppedRegion=X,exports.emptyAnnotationPage=dn,exports.emptyCanvas=fn,exports.getCanonicalUrl=H,exports.getYouTubeId=$,exports.htmlAnnotation=je,exports.htmlBodyCreator=bn,exports.iiifBrowserCreator=Cn,exports.imageServiceAnnotation=Yt,exports.imageServiceCreator=W,exports.imageUrlAnnotation=$t,exports.imageUrlCreator=K,exports.imageUrlListAnnotation=nn,exports.imageUrlListCreator=Z,exports.internalCanvas=mn,exports.manifestBrowserCreator=Gn,exports.noBodyAnnotation=rn,exports.plaintextCreator=En,exports.providerCreator=ae,exports.rangeTopLevel=Zn,exports.rangeWithItems=Jn,exports.validateYouTube=In,exports.videoAnnotation=ln,exports.webPageCreator=Pn,exports.youTubeBodyCreator=Bn;
94
+ `;function E(e){let[t,n]=(0,m.useState)(!1),{progress:r,currentTime:i,element:a}=(0,_.useMediaElements)(),{duration:o,isMuted:s,volume:c,isPlaying:l,playRequested:u}=(0,_.useMediaState)(),{setVolume:d,toggleMute:f,play:p,pause:g,setDurationPercent:v}=(0,_.useMediaActions)(),y=s||c===0?fe:c>50?ue:de;return(0,m.useLayoutEffect)(()=>{if(a.current){let t=a.current;if(t.error&&e.onError){e.onError(t.error?.message||`Unknown error`);return}let n=()=>{e.onError&&e.onError(t.error?.message||`Unknown error`)},r=()=>{t.duration&&e.onDuration&&e.onDuration(t.duration),e.onDimensions&&t instanceof HTMLVideoElement&&e.onDimensions(t.videoWidth,t.videoHeight)};return t.addEventListener(`loadedmetadata`,r),t.addEventListener(`error`,n),()=>{t.removeEventListener(`loadedmetadata`,r),t.removeEventListener(`error`,n)}}},[]),(0,h.jsxs)(pe,{children:[(0,h.jsx)(he,{disabled:u,onClick:()=>{l?g():p()},children:u?(0,h.jsx)(we,{stroke:`#999`}):l?(0,h.jsx)(le,{title:`Pause`}):(0,h.jsx)(ce,{title:`Play`})}),(0,h.jsx)(ge,{ref:i,children:`0:00`}),(0,h.jsxs)(_e,{onClick:e=>{let{left:t,width:n}=e.currentTarget.getBoundingClientRect(),r=(e.pageX-t)/n;v(r)},children:[(0,h.jsx)(ye,{}),o?(0,h.jsx)(ve,{ref:r}):null]}),(0,h.jsx)(ge,{children:(0,_.formatTime)(o)}),(0,h.jsxs)(xe,{onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[(0,h.jsx)(Se,{$isOpen:t,children:(0,h.jsxs)(`span`,{children:[(0,h.jsx)(Ee,{htmlFor:`audio-slider`,children:`Change volume`}),(0,h.jsx)(Ce,{id:`audio-slider`,role:`slider`,disabled:s,min:`0`,max:`100`,value:c,onChange:e=>d(Number(e.currentTarget.value))})]})}),(0,h.jsx)(be,{onClick:()=>f(),children:(0,h.jsx)(y,{title:s?`Mute`:`Unmute`})})]})]})}async function D(e,t){let n={id:t.generateId(`annotation`),type:`Annotation`},r=t.options.targetType,i=t.embed({id:e.url,type:`Sound`,format:`audio/mp4`,duration:e.duration||0});if(r===`Annotation`)return t.embed({...n,label:(0,d.getValue)(e.label)&&e.label,motivation:e.motivation||t.options.initialData?.motivation||`painting`,body:i,target:t.getTarget()});if(r===`Canvas`){let r=t.generateId(`canvas`),a=t.generateId(`annotation-page`,{id:r,type:`Canvas`}),o=t.embed({...n,motivation:`painting`,body:i,target:{type:`SpecificResource`,source:{id:r,type:`Canvas`}}}),s=t.embed({id:a,type:`AnnotationPage`,items:[o]});return t.embed({id:r,type:`Canvas`,label:e.label||{en:[`Untitled HTML canvas`]},duration:e.duration||0,items:[s]})}}function O(e){let t=e.options.initialData,[n,r]=(0,m.useState)(t.url||``),[i,a]=(0,m.useState)(0),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)({en:[``]});return(0,m.useEffect)(()=>{if(s(``),a(0),n){let e=n.split(`/`).pop()?.split(`.`).shift();l({en:[e||``]})}},[n]),(0,h.jsxs)(f.PaddedSidebarContainer,{children:[o?(0,h.jsx)(f.ErrorMessage,{children:o}):null,(0,h.jsxs)(p.InputContainer,{$wide:!0,children:[(0,h.jsx)(p.InputLabel,{htmlFor:`audio-url`,children:`URL`}),(0,h.jsx)(p.Input,{type:`text`,id:`audio-url`,value:n,onChange:e=>r(e.target.value)})]}),n&&!o?(0,h.jsx)(`div`,{children:(0,h.jsx)(p.LanguageFieldEditor,{containerId:`label`,focusId:`label_`,label:`Label`,fields:c,onSave:e=>l(e.toInternationalString())},`${n}__${i}`)}):null,n&&!o?(0,h.jsx)(_.CanvasPanel.AudioHTML,{media:{url:n,duration:i,type:`Sound`},children:(0,h.jsx)(E,{onError:e=>s(e),onDuration:e=>a(~~e)},`${n}__${i}`)},`${n}__${i}`):null,i&&!o?(0,h.jsxs)(p.FormFieldWrapper,{children:[(0,h.jsx)(p.InputLabel,{htmlFor:`duration`,children:`Duration`}),(0,h.jsx)(p.Input,{type:`number`,id:`duration`,value:i,onChange:e=>a(e.target.valueAsNumber)})]}):null,(0,h.jsx)(f.ActionButton,{primary:!0,large:!0,type:`button`,onPress:()=>{e.runCreate({url:n,duration:i,label:c})},isDisabled:!n||!!o,children:`Add audio`})]})}const De=(0,u.defineCreator)({id:`@manifest-editor/audio-annotation`,create:D,label:`Audio`,summary:`Audio annotation`,icon:(0,h.jsx)(f.AudioIcon,{}),render(e){return(0,h.jsx)(O,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],async supportsResource(e,t){return x(e)&&((await w(e,t)).startsWith(`audio/`)||T(e,[`.mp3`,`.m4a`,`.wav`,`.ogg`]))?{initialData:{url:e}}:!1},supports:{initialData:!0,onlyPainting:!0,parentTypes:[`AnnotationPage`,`Manifest`],parentFields:[`items`]},staticFields:{type:`Annotation`}});async function Oe(e,t){let n={id:t.generateId(`annotation`),type:`Annotation`},r=t.options.targetType,i=Object.keys(e.body),a=[];for(let r of i){let i=e.body[r].join(`
95
+ `);i&&a.push(await t.create(`@manifest-editor/html-body-creator`,{language:r,body:i},{parent:{resource:n,property:`items`}}))}let o=await t.create(`@manifest-editor/image-url-creator`,{url:e.imageUrl},{parent:{resource:n,property:`body`}});if(o&&a.push(o),r===`Annotation`)return t.embed({...n,motivation:e.motivation||t.options.initialData?.motivation||`painting`,body:a,target:t.getTarget()});if(r===`Canvas`){let r=t.generateId(`canvas`),i=t.generateId(`annotation-page`,{id:r,type:`Canvas`}),o=t.embed({...n,motivation:`painting`,body:a,target:{type:`SpecificResource`,source:{id:r,type:`Canvas`}}}),s=t.embed({id:i,type:`AnnotationPage`,items:[o]});return t.embed({id:r,type:`Canvas`,label:e.label||{en:[`Untitled HTML canvas`]},height:e.height||1e3,width:e.width||1e3,items:[s]})}}function ke(e){let[t,n]=(0,y.useAnnotationCreatorState)({key:`bodyValue`,initialValue:{en:[``]},requestId:e.options.initialData?.requestId});return(0,h.jsx)(`form`,{onSubmit:t=>{t.preventDefault();let n=new FormData(t.target),r=Object.fromEntries(n.entries());e.runCreate({body:{en:[r.caption]},imageUrl:r.url})},children:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(p.InputContainer,{$wide:!0,children:[(0,h.jsx)(p.InputLabel,{htmlFor:`url`,children:`URL to Image`}),(0,h.jsx)(p.Input,{id:`url`,name:`url`,defaultValue:``,placeholder:`https://example.org/image.jpg`})]}),(0,h.jsxs)(p.InputContainer,{$wide:!0,children:[(0,h.jsx)(p.InputLabel,{htmlFor:`caption`,children:`Caption`}),(0,h.jsx)(p.Input,{id:`caption`,name:`caption`,placeholder:`Enter a caption`,onChange:e=>n({en:[e.target.value]}),value:t.en?.[0]||``})]}),(0,h.jsx)(f.ActionButton,{primary:!0,type:`submit`,children:`Create`})]})})}const Ae=(0,u.defineCreator)({id:`@manifest-editor/captioned-image-annotation`,create:Oe,label:`Captioned image`,summary:`Add an image from a URL with caption`,icon:(0,h.jsx)(f.AddImageIcon,{}),render(e){return(0,h.jsx)(ke,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],supports:{initialData:!0,disallowPainting:!0,parentTypes:[`AnnotationPage`],parentFields:[`items`]},staticFields:{type:`Annotation`}});async function je(e,t){let n={id:t.generateId(`annotation`),type:`Annotation`},r=t.options.targetType,i=Object.keys(e.body),a=[];for(let r of i){let i=e.body[r].join(`
96
+ `);i&&a.push(await t.create(`@manifest-editor/html-body-creator`,{language:r,body:i},{parent:{resource:n,property:`items`}}))}if(r===`Annotation`)return t.embed({...n,motivation:e.motivation||t.options.initialData?.motivation||`painting`,body:a,target:t.getTarget()});if(r===`Canvas`){let r=t.generateId(`canvas`),i=t.generateId(`annotation-page`,{id:r,type:`Canvas`}),o=t.embed({...n,motivation:`painting`,body:a,target:{type:`SpecificResource`,source:{id:r,type:`Canvas`}}}),s=t.embed({id:i,type:`AnnotationPage`,items:[o]});return t.embed({id:r,type:`Canvas`,label:e.label||{en:[`Untitled HTML canvas`]},height:e.height||1e3,width:e.width||1e3,items:[s]})}}function Me(e){let[t,n]=(0,y.useAnnotationCreatorState)({key:`bodyValue`,initialValue:{en:[``]},requestId:e.options.initialData?.requestId}),r=(0,d.getValue)(t).trim()===``;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(f.HTMLEditor,{className:`border-none`,value:t.en?.[0]||``,onChange:e=>n({en:[e]})}),(0,h.jsx)(f.ActionButton,{primary:!0,type:`button`,onPress:()=>{e.runCreate({body:t})},isDisabled:r,children:`Create`})]})}const Ne=(0,u.defineCreator)({id:`@manifest-editor/html-annotation`,create:je,label:`HTML`,summary:`HTML annotation`,icon:(0,h.jsx)(f.HTMLIcon,{}),render(e){return(0,h.jsx)(Me,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],supports:{initialData:!0,parentTypes:[`AnnotationPage`,`Manifest`],parentFields:[`items`]},staticFields:{type:`Annotation`}}),k={canvasInteraction:!0,spatial:!0,async run(e,{vault:t,options:n}){if(e&&e.type===`Annotation`&&n.targetType===`Annotation`){let n=t.get(e),r=n.target;if(!(r&&r.source?.type===`Canvas`))return;let i=r.source,a=t.get(i);if(!a.items)return;let o=t.get(a.items[0]);if(!o||o.items.length<2&&!a.behavior.includes(`multi-image`))return;let s=t.get(n.body)[0],c=n.body[0]?.selector,l=(s.service||[]).find(e=>(0,b.isImageService)(e));l&&l.width&&l.height&&(l.width!==s.width&&t.modifyEntityField({id:s.id,type:`ContentResource`},`width`,l.width),l.height!==s.height&&t.modifyEntityField({id:s.id,type:`ContentResource`},`height`,l.height));let u=l?.width||s.width,d=l?.height||s.height;if(c&&(c.type===`iiif:ImageApiSelector`||c.type===`ImageApiSelector`)&&c.region){let[e,t,n,r]=c.region.split(`,`);u=Number(n)||u,d=Number(r)||d}let f=new ee.EditorInstance({vault:t,reference:e}),m=(0,p.centerRectangles)(a,{width:u,height:d},.6);f.annotation.target.setPosition(m)}}},A={canvasInteraction:!0,spatial:!0,async run(e,{vault:t,options:n}){if(e&&e.type===`Annotation`&&n.targetType===`Annotation`){let n=t.get(e),r=n.target;if(!(r&&r.source?.type===`Canvas`))return;let i=r.source,a=t.get(i);if(!a.items||a.behavior.includes(`multi-image`))return;let o=t.get(a.items[0]);if(!o||o.items.length>1)return;let s=t.get(n.body);if(s.length!==1)return;let c=s[0],l=n.body[0]?.selector,u=(c.service||[])[0],d=u?.width||c.width,f=u?.height||c.height,p=c.duration||u?.duration;if(l&&(l.type===`iiif:ImageApiSelector`||l.type===`ImageApiSelector`)&&l.region){let[e,t,n,r]=l.region.split(`,`);d=Number(n)||d,f=Number(r)||f}let m=new ee.EditorInstance({vault:t,reference:i});t.batch(()=>{d!==void 0&&m.technical.width.set(d),f!==void 0&&m.technical.height.set(f),p!==void 0&&m.technical.duration.set(p)})}}};var Pe=Object.defineProperty,Fe=(e,t,n)=>t in e?Pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,j=(e,t,n)=>(Fe(e,typeof t==`symbol`?t:t+``,n),n);function M(e){return e.endsWith(`info.json`)?e:e.endsWith(`/`)?`${e}info.json`:`${e}/info.json`}var Ie=`http://library.stanford.edu/iiif/image-api/compliance.html#level0`,Le=`http://library.stanford.edu/iiif/image-api/compliance.html#level1`,Re=`http://library.stanford.edu/iiif/image-api/compliance.html#level2`,ze=`http://library.stanford.edu/iiif/image-api/conformance.html#level0`,Be=`http://library.stanford.edu/iiif/image-api/conformance.html#level1`,Ve=`http://library.stanford.edu/iiif/image-api/conformance.html#level2`,He=`http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0`,Ue=`http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level1`,We=`http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2`,Ge=`http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level0`,Ke=`http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level1`,qe=`http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level2`,Je=`http://iiif.io/api/image/1/level0.json`,Ye=`http://iiif.io/api/image/1/profiles/level0.json`,Xe=`http://iiif.io/api/image/1/level1.json`,Ze=`http://iiif.io/api/image/1/profiles/level1.json`,Qe=`http://iiif.io/api/image/1/level2.json`,$e=`http://iiif.io/api/image/1/profiles/level2.json`,et=`http://iiif.io/api/image/2/level0.json`,tt=`http://iiif.io/api/image/2/profiles/level0.json`,nt=`http://iiif.io/api/image/2/level1.json`,rt=`http://iiif.io/api/image/2/profiles/level1.json`,it=`http://iiif.io/api/image/2/level2.json`,at=`http://iiif.io/api/image/2/profiles/level2.json`,ot=`level0`,st=`level1`,ct=`level2`,lt=`http://iiif.io/api/image/2/level0`,ut=`http://iiif.io/api/image/2/level1`,dt=`http://iiif.io/api/image/2/level2`,ft=[dt,Re,Ve,We,qe,Qe,$e,it,at,ct],pt=[...ft,ut,Le,Be,Ue,Ke,Xe,Ze,nt,rt,st],mt=[lt,ut,dt,Ie,Le,Re,ze,Be,Ve,He,Ue,We,Ge,Ke,qe,Je,Ye,Xe,Ze,Qe,$e,et,tt,nt,rt,it,at,ot,st,ct],ht={extraFormats:[`jpg`],extraQualities:[`default`],extraFeatures:[`sizeByWhListed`]},gt={extraFormats:[`jpg`],extraQualities:[`default`],extraFeatures:[`baseUriRedirect`,`cors`,`jsonldMediaType`,`regionByPx`,`regionSquare`,`sizeByWhListed`,`sizeByH`,`sizeByW`,`sizeByWh`]},_t={extraFormats:[`jpg`,`png`],extraQualities:[`default`],extraFeatures:[`baseUriRedirect`,`cors`,`jsonldMediaType`,`regionByPct`,`regionByPx`,`regionSquare`,`rotationBy90s`,`sizeByWhListed`,`sizeByConfinedWh`,`sizeByH`,`sizeByPct`,`sizeByW`,`sizeByWh`]};function vt(e){return ft.indexOf(e)===-1?pt.indexOf(e)===-1?ht:gt:_t}function yt(e){let t=e?Array.isArray(e.profile)?e.profile:[e.profile]:[],n={extraQualities:[],extraFormats:[],extraFeatures:[]};for(let e of t)if(typeof e==`string`&&(e=vt(e)),e){if(e.formats)for(let t of e.formats)n.extraFormats.indexOf(t)===-1&&n.extraFormats.push(t);if(e.qualities)for(let t of e.qualities)n.extraQualities.indexOf(t)===-1&&n.extraQualities.push(t);if(e.supports)for(let t of e.supports)n.extraFeatures.indexOf(t)===-1&&n.extraFeatures.push(t);if(e.maxHeight&&(n.maxHeight=e.maxHeight),e.maxWidth&&(n.maxWidth=e.maxWidth),e.maxArea&&(n.maxArea=e.maxArea),e.extraFormats)for(let t of e.extraFormats)n.extraFormats.indexOf(t)===-1&&n.extraFormats.push(t);if(e.extraQualities)for(let t of e.extraQualities)n.extraQualities.indexOf(t)===-1&&n.extraQualities.push(t);if(e.extraFeatures)for(let t of e.extraFeatures)n.extraFeatures.indexOf(t)===-1&&n.extraFeatures.push(t);e.maxHeight&&(n.maxHeight=e.maxHeight),e.maxWidth&&(n.maxWidth=e.maxWidth),e.maxArea&&(n.maxArea=e.maxArea)}if(e.extraFormats)for(let t of e.extraFormats)n.extraFormats.indexOf(t)===-1&&n.extraFormats.push(t);if(e.extraFeatures)for(let t of e.extraFeatures)n.extraFeatures.indexOf(t)===-1&&n.extraFeatures.push(t);if(e.extraQualities)for(let t of e.extraQualities)n.extraQualities.indexOf(t)===-1&&n.extraQualities.push(t);return n}function bt(e){try{if(e===`full`)return{full:!0};if(e===`square`)return{square:!0};let t=e.startsWith(`pct:`),n=e.substr(t?4:0).split(`,`).map(e=>parseFloat(e));return{x:n[0],y:n[1],w:n[2],h:n[3],percent:t}}catch{throw Error(`Expected 'full', 'square' or 'x,y,w,h'. Found `+e)}}function xt(e){let t={upscaled:!1,max:!1,confined:!1};if(e[0]===`^`&&(t.upscaled=!0,e=e.slice(1)),e===`max`||e===`full`)return t.max=!0,t.serialiseAsFull=e===`full`,t;if(e[0]===`!`&&(t.confined=!0,e=e.slice(1)),e[0]===`p`)return t.percentScale=parseFloat(e.slice(4)),t;let n=e.split(`,`).map(e=>e.trim());return n.length&&typeof n[0]<`u`&&(n[0]!==``&&(t.width=parseInt(n[0],10)),typeof n[1]<`u`&&n[1]!==``?(t.height=parseInt(n[1],10),t.version=2):t.version=3),t}function St(e){let t={angle:0};if(e[0]===`!`&&(t.mirror=!0,e=e.substr(1)),t.angle=parseFloat(e)%360,Number.isNaN(t.angle))throw Error(`Invalid rotation ${e}`);return t}function Ct(e,t=``){let n=e.match(/^(([a-zA-Z]+):\/\/([^/]+))?((.*)+)/);if(!n)throw Error(`Invalid or unknown input ${e}`);let r=n[2],i=n[3],a=n[4];if(a[0]===`/`&&(a=a.substring(1)),t.length>0){if(t[0]===`/`&&(t=t.substring(1)),t!==a.substring(0,t.length))throw Error(`Path does not start with prefix (path: ${a}, prefix: ${t})`);a=a.substring(t.length)}return{scheme:r,server:i,path:a,prefix:t}}function wt(e,t=``){let{path:n,scheme:r,server:i,prefix:a}=Ct(e,t),o=(n||``).split(`/`).reverse(),[s,c,l,u,...d]=o,f=d.reverse().filter(Boolean).join(`/`);if(o.length===1||s===``)return{type:`base`,scheme:r,server:i,prefix:a,identifier:f};if(s===`info.json`){let[,...e]=o;return{type:`info`,scheme:r,server:i,prefix:a,identifier:e.reverse().filter(Boolean).join(`/`)}}let p=(s||``).split(`.`);if(typeof p[1]>`u`||typeof p[0]>`u`||typeof u>`u`||typeof l>`u`||typeof c>`u`)throw Error(`Invalid image request`);return{type:`image`,scheme:r,server:i,prefix:a,identifier:f,originalPath:n,region:bt(u),size:xt(l),rotation:St(c),quality:p[0],format:p[1]}}function Tt(e){let t=wt(M(e.id));if(t.type!==`info`)throw Error(`Invalid service URL`);let n=yt(e);return{identifier:t.identifier,originalPath:``,server:t.server,prefix:t.prefix,scheme:t.scheme,type:`image`,quality:n.extraQualities.indexOf(`default`)===-1?n.extraQualities[0]:`default`,region:{full:!0},size:{max:!0,upscaled:!1,confined:!1},format:`jpg`,rotation:{angle:0}}}function Et(e,t,n){let r=n.length,i=[];for(let t=0;t<r;t++){let r=n[t];if(r){let t=r.width;i.push(e/t)}}return i}function Dt(e,t,n){let r=n.length,i=[];for(let a=0;a<r;a++){let r=n[a];r&&i.push({width:Math.floor(e/r),height:Math.floor(t/r)})}return i}function N(e){if(e[`@id`])return e[`@id`];if(e.id)return e.id}function P(e){if(!e||!e.profile||!N(e))return!1;let t=Array.isArray(e.profile)?e.profile:[e.profile];for(let e of t)if(typeof e==`string`&&mt.indexOf(e)!==-1)return!0;return!1}function Ot(e){if(!P(e))return!1;let t=Array.isArray(e.profile)?e.profile:[e.profile];for(let e of t)if(typeof e==`string`){if(pt.indexOf(e)!==-1)return!0}else{let t=[...e.supports||[],...e.extraFeatures||[]];if(t.indexOf(`regionByPx`)!==-1&&(t.indexOf(`sizeByW`)!==-1||t.indexOf(`sizeByWh`)!==-1))return!0}return!1}function F(e,t){if(t&&t.profile){let n=t.profile;if(n){let t=Array.isArray(n)?n:[n];return t.includes(`level${e}`)||t.includes(`http://iiif.io/api/image/2/level${e}.json`)||t.includes(`http://iiif.io/api/image/1/level${e}.json`)||t.includes(`http://iiif.io/api/image/1/profiles/level${e}.json`)}}return!1}function I(e){return P(e)?F(0,e)?0:F(1,e)?1:F(2,e)?2:null:null}function kt(e){return(e[`@context`]?Array.isArray(e[`@context`])?e[`@context`]:[e[`@context`]]:[]).indexOf(`http://iiif.io/api/image/3/context.json`)!==-1}function At(e){if(!Ot(e))return[];let t=[],n=Array.isArray(e.profile)?e.profile:[e.profile],r=n.length;for(let t=0;t<r;t++){let r=n[t];if(r&&typeof r!=`string`&&(r.maxHeight||r.maxWidth))return[{id:N(e),type:`variable`,minWidth:0,minHeight:0,maxHeight:r.maxHeight||r.maxWidth,maxWidth:r.maxWidth||r.maxHeight,level:I(e),version:e[`@context`]===`http://iiif.io/api/image/3/context.json`?3:2}]}if(e.tiles){let n=e.tiles.length;for(let r=0;r<n;r++){let n=e.tiles[r];n&&(n.height||n.width)&&t.push({id:N(e),type:`variable`,minHeight:0,minWidth:0,maxHeight:n.height||n.width,maxWidth:n.width,level:I(e),version:kt(e)?3:2})}}return t}function jt(e){let t=e.match(/^.*\/(full)\/(((\d+),(\d+)?)|max)\/(\d+)\/default\.(jpg|png|jpeg)$/);if(t&&t[4]&&t[5]){let n=t[1],r=parseInt(t[4],10),i=parseInt(t[5],10),a=t[7];if((n===`max`||n===`full`)&&r&&i&&a)return{type:`fixed`,id:e,height:i,width:r}}return{type:`unknown`,id:e}}function Mt(e){if(e[`@type`])return e[`@type`];if(e.type)return e.type}function Nt(e){if(typeof e==`string`)return jt(e);let t=Mt(e);if(t!==`Image`&&t!==`sc:Image`)return null;let n=e,r=N(n);return r?r&&n.width&&n.height?{id:r,type:`fixed`,width:n.width,height:n.height,unsafe:!0}:jt(r):null}function Pt(e){return P(e)?(e&&e.sizes?e.sizes:[]).map(t=>({id:N(e),type:`fixed-service`,height:t.height,width:t.width,level:I(e),version:kt(e)?3:2})):[]}function Ft(e){let t=[],n=e.length;for(let r=0;r<n;r++){let n=e[r];if(!n)continue;let i=Pt(n);i.length&&t.push(...i);let a=At(n);a.length&&t.push(...a)}return t}function It(e){let t=e.service?Array.isArray(e.service)?e.service:[e.service]:[],n=t.length,r=[];for(let e=0;e<n;e++)P(t[e])&&r.push(t[e]);return r}function Lt(e,t=!0,n){let r=[],i=Nt(e);if(i===null)return r;let a=e;if(r.push(i),t&&a&&a.width&&a.height){let e=[],t=It(a);for(let r of t){let t={id:N(r),width:a.width,height:a.height};if(n.canLoadSync(t)){let r=n.loadServiceSync(t);r&&(r.height||(r.height=a.height),r.width||(r.width=a.width),e.push(...Ft([r])))}}if(e.length)return r.push(...e),r}return a.service&&r.push(...Ft(a.service)),r}function Rt({x:e=0,y:t=0,w:n,h:r,full:i,square:a,percent:o}){if(i)return`full`;if(a)return`square`;if(typeof n>`u`||typeof r>`u`)throw Error(`RegionParameter: invalid region`);let s=`${e},${t},${n},${r}`;return o?`pct:${s}`:s}function zt({max:e,percentScale:t,upscaled:n,confined:r,width:i,height:a,serialiseAsFull:o,version:s}){let c=[];return n&&c.push(`^`),e?(c.push(o?`full`:`max`),c.join(``)):(r&&c.push(`!`),t&&c.push(`pct:${t}`),i&&c.push(`${i}`),c.push(`,`),a&&s===3&&c.push(`${a}`),c.join(``))}function Bt(e){return`${e.mirror?`!`:``}${(e.angle||0)%360}`}function Vt(e,t){let n=e.prefix.startsWith(`/`)?e.prefix.substr(1):e.prefix,r=`${e.scheme}://${e.server}/${n?`${n}/`:``}${e.identifier}`;if(e.type===`base`)return r;if(e.type===`info`)return`${r}/info.json`;let{size:i}=e,{region:a,rotation:o,format:s,quality:c}=e;if(t){let e=t[`@context`]?Array.isArray(t[`@context`])?t[`@context`]:[t[`@context`]]:[],n=e.indexOf(`http://iiif.io/api/image/2/context.json`)!==-1,r=e.indexOf(`http://iiif.io/api/image/3/context.json`)!==-1;if((i.width===t.width&&!i.height||i.height===t.height&&!i.width||i.width===t.width&&i.height===t.height)&&(i={...i,max:!0}),n&&(i.max&&!i.serialiseAsFull&&(i={...i,serialiseAsFull:!0}),!i.max&&i.width&&i.height&&(i={...i,height:void 0}),i={...i,version:2}),r){if(i.max&&i.serialiseAsFull&&(i={...i,serialiseAsFull:!1}),i.width&&!i.height&&t.width&&t.height){let e=t.height/t.width;i={...i,height:Math.ceil(i.width*e)}}i={...i,version:3}}}return[r,Rt(a),zt(i),Bt(o),`${c}.${s}`].filter(Boolean).join(`/`)}function L(e,t,n){let r=Tt({"@context":e.version===3?`http://iiif.io/api/image/3/context.json`:`http://iiif.io/api/image/2/context.json`,id:M(N(e)),profile:e.level===null||typeof e.level>`u`?`level0`:`level${e.level}`,type:e.version===3?`ImageService3`:`ImageService2`});if(r.type!==`image`)throw Error(`Invalid service`);return r.size.max=!1,r.size.width=t,r.size.height=n,{id:Vt(r),type:`fixed`,width:t,height:n||e.height/(e.width||1)*t,unsafe:e.width>t}}function R(e){let t=e.replace(/(https?:\/\/)?(www.)?/i,``);return t.indexOf(`/`)===-1?t:t.split(`/`)[0]}function Ht(e,t,n){let r=e.width?e.width:e.maxWidth;return n.height<=e.maxHeight&&n.width<=e.maxWidth&&n.height>=e.minHeight&&n.width>=e.minWidth&&(!t||Math.abs(n.width-r)<Math.abs(t.width-r))}function Ut(e,t){let n=[],r=Object.assign({unsafeImageService:!1,atAnyCost:!0,fallback:!0,minHeight:64,minWidth:64,maxHeight:1/0,maxWidth:1/0,returnAllOptions:!1,preferFixedSize:!1,allowUnsafe:!1,explain:!1,height:0,width:0},e),i=(e,t=0)=>r.explain?n.push(Array(t).fill(0).map(e=>` `).join(``)+e().trim()):void 0,a=[],o=[],s=null;i(()=>`Using configuration: ${JSON.stringify(r,null,2)}`);let c=(e,t)=>{if(i(()=>`Swapping choice`,3),Ht(r,t,e)){if(r.preferFixedSize&&e.unsafe){i(()=>`We found an image that was marked as unsafe, but it was the best size. (${e.id})`,4),o.push(e);return}r.returnAllOptions&&t&&o.push(t),i(()=>`We found a new image that was the best size. (${e.id})`,4),s=e}else r.returnAllOptions&&o.push(e)};i(()=>`The input shows we have ${t.length} list(s) of candidates to choose from.`);let l=t.length;for(let e=0;e<l;e++){let n=t[e]();i(()=>`Candidate group ${e}: ${JSON.stringify(n,null,2)}`,1);let o=n.length;i(()=>`Checking candidate list number ${e} and found ${o} potential ways of creating image(s)`,1);for(let e=0;e<o;e++){let t=n[e];i(()=>`-> Checking candidate ${e}`,1),t.type===`unknown`&&r.atAnyCost&&(i(()=>`We've found an unknown image type, adding this to the "last resort" list`,2),a.push(t)),t.type===`fixed`&&(t.unsafe?(i(()=>`We've found an unsafe fixed image type, adding this to the "last resort" list`,2),a.push(t)):(i(()=>`We've found a fixed size image, checking if it matches the request`,2),c(t,s))),t.type===`fixed-service`&&(r.unsafeImageService?(i(()=>`Checking for an image from the tile source, without calculating the right height and width (unsafeImageService)`,2),c(L(t,r.width,r.height),s)):(i(()=>`Checking for an image from the tile source 3`,2),c(L(t,t.width,t.height),s))),t.type===`variable`&&t.maxWidth&&c(L({id:t.id,type:`fixed-service`,width:t.maxWidth,height:t.maxWidth,level:t.level,version:t.version},t.maxWidth),s)}if(s&&!r.returnAllOptions){if(s.unsafe||r.allowUnsafe)continue;i(()=>`We found a match in choice list number ${e}, no searching any more`);break}}return r.atAnyCost&&o.length===0?(i(()=>s?`We found an image! ${s.id} of type ${s.type}`:`We found no images, but "atAnyCost" is set, so returning that`),{best:s||a[0]||null,fallback:a.slice(1),log:n}):r.returnAllOptions?(i(()=>`Returning all options that we have found`),{best:(r.atAnyCost?s||o[0]||a[0]:s||o[0])||null,fallback:[...o,...a],log:n}):(i(()=>`Returning the best image that we found, and a fallback`),{best:s||o[0]||null,fallback:s?o:o.slice(1),log:n})}function Wt(e,t,n){let r=e>t?e:t,i=n.length,a=[];for(let e=0;e<i;e++){let t=n[e];if(!t||t.scaleFactors.length===0)continue;let i=t.scaleFactors[0];if(!i)continue;let o=r/i,s=[i];for(;o>=t.width;)i*=2,s.push(i),o/=2;a.push({...t,scaleFactors:s})}return a}function Gt(e,t){if(e.length!==t.length)return!1;if(e.length===0&&t.length===0)return!0;let n=e.length,r=!0;for(let i=0;i<n;i++){let n=e[i],a=t[i];if(n.width!==a.width||n.height!==a.height){r=!1;break}}if(r)return!0;let i=0;for(let r=0;r<n;r++)for(let a=0;a<n;a++)if(e[r].width===t[a].width&&e[r].height===t[a].height){i++;break}return i===n}function Kt(e){return F(0,e)}new class{constructor(e={}){j(this,`config`,{verificationsRequired:1,approximateServices:!1,enableFetching:!0,disableThrottling:!1}),j(this,`fetchingCount`,0),j(this,`imageServices`,{}),j(this,`knownImageServers`,{}),this.config=Object.assign(this.config,e)}setConfig(e){Object.assign(this.config,e)}sample(e,t,n=!0){let r=R(N(e)),i=M(N(e)),a=this.knownImageServers[r];return this.imageServices[i]=Object.assign(e,{real:!0}),!a&&e.tiles&&!Kt(e)?(this.knownImageServers[r]={verifications:0,malformed:!1,root:r,preLoaded:n,sampledId:N(e),verified:!1,server:null,result:{context:e[`@context`]||[],sampledProfile:e.profile,resourceServiceRatio:t&&e.height?t.height/e.height:1,sampledSizes:e.sizes||[],sizeRatios:Et(e.width,e.height,e.sizes||[]),sampledTiles:e.tiles||[]}},!0):this.verify(e)}preLoad(e,t=!0){this.knownImageServers[e.root]=e,t&&(this.knownImageServers[e.root].malformed=!1,this.knownImageServers[e.root].verifications=this.config.verificationsRequired)}predict(e,t=!1,n=!1){let r=e?.source,i=R(N(e)),a=this.knownImageServers[i],o=M(N(e));return this.imageServices[o]?this.imageServices[o]||null:!this.config.approximateServices||!a||!a.result||!(r?.height||e.height)||!(r?.width||e.width)||!n&&(a.malformed||a.verifications<this.config.verificationsRequired)||Kt(e.source)?null:(this.imageServices[o]||(this.imageServices[o]={"@context":a.result.context,"@id":N(e),id:N(e),protocol:`http://iiif.io/api/image`,tiles:r?.tiles||Wt(e.width,e.height,a.result.sampledTiles),sizes:r?.sizes||Dt(Math.round(e.width/a.result.resourceServiceRatio),Math.round(e.height/a.result.resourceServiceRatio),a.result.sizeRatios),profile:r?.profile||a.result.sampledProfile,height:r?.height||e.height,width:r?.width||e.width,real:!1}),this.imageServices[o]||null)}async getThumbnailFromResource(e,t,n=!0,r=[]){let i=e?await this.getImageCandidates(e,n):[];return Ut(t,[()=>r,()=>i])}async getImageCandidates(e,t=!0){let n=e;if(t&&n&&n.height&&n.width){let e=It(n);for(let t of e){let e={id:N(t),width:t.width?t.width:n.width,height:t.height?t.height:n.height,source:t};await this.loadService(e)}}return Lt(e,t,this)}async verify(e){let t=this.predict(e,!1,!0),n=await this.fetchService(N(e));if(!t)return!1;let r=t.height===n.height&&t.width===n.width&&t[`@context`]===n[`@context`]&&Gt(t.sizes||[],n.sizes||[]);if(r){let t=R(N(e)),n=this.knownImageServers[t];n&&(n.verifications+=1,n.verifications>=this.config.verificationsRequired&&(n.verified=!0))}return r}canLoadSync(e){let t=typeof e==`string`?e:N(e),n=M(t);if(this.imageServices[n])return!0;let r=this.knownImageServers[R(t)];return!!(r&&!r.malformed&&r.verifications>=this.config.verificationsRequired)}async markAsMalformed(e){return this.knownImageServers[R(N(e))].malformed=!0,this.loadService(e,!0)}async fetchService(e,t=!1){let n=M(e),r=this.imageServices[n];if(r&&(!t||r.real))return r;if(!this.config.enableFetching)throw Error(`Fetching is not enabled`);let i=await this.fetch(n).then(e=>e.json());return!i.id&&i[`@id`]&&(i.id=i[`@id`]),i.id!==e&&(i.id=e,i[`@id`]&&(i[`@id`]=e)),this.imageServices[n]=Object.assign(i,{real:!0}),this.imageServices[n]}async fetch(e,t){return fetch(e,t)}async loadService(e,t=!1){if(!this.config.disableThrottling){let e=!0;for(;e;)if(this.fetchingCount>=this.config.verificationsRequired)await new Promise(e=>setTimeout(e,500));else{e=!1;break}}let n=this.knownImageServers[R(N(e))];if(n&&!n.malformed&&!t){await n.result;let t=this.loadServiceSync(e);if(t)return t}this.fetchingCount++;let r=await this.fetchService(N(e),t);return this.fetchingCount--,r.real&&this.sample(r,e),r}loadServiceSync(e){let t=M(N(e));return this.imageServices[t]?this.imageServices[t]:this.config.approximateServices?this.predict(e):null}};const z={canvasInteraction:!0,spatial:!0,async run(e,{vault:t,options:n}){if(e&&e.type===`Annotation`&&n.targetType===`Annotation`){let n=t.get(e),r=n.target;if(!(r&&r.source?.type===`Canvas`))return;let i=r.source,a=t.get(i);if(!a.items||a.behavior.includes(`multi-image`)||!t.get(a.items[0]))return;let o=Array.isArray(n.body)?n.body[0]:n.body;if(o.type===`SpecificResource`&&o.selector)return;let s=t.get(n.body)[0],c=(s.service||[]).find(e=>P(e));c&&c.width&&c.height&&(c.width!==s.width&&t.modifyEntityField({id:s.id,type:`ContentResource`},`width`,c.width),c.height!==s.height&&t.modifyEntityField({id:s.id,type:`ContentResource`},`height`,c.height))}}};function B(e){let{"@id":t,"@type":n,...r}=e,i=`${e[`@context`]||``} ${e.profile||``}`.match(/\/(?:image|image-api)\/([123])(?:[./])/);return{...r,id:e.id||t,type:e.type||n||`ImageService${i?.[1]||`2`}`}}function qt(e,t={},n=!1){let r=[];t.compact!==`compact`&&r.push(`width`,`height`),(n||t.includeSizes===!0)&&r.push(`sizes`),(n||t.includeTiles===!0)&&r.push(`tiles`);let i=B(e);return{id:i.id,type:i.type,profile:i.profile,...Object.fromEntries(r.filter(e=>i[e]!==void 0).map(e=>[e,i[e]]))}}async function Jt(e,t){let n=B(e.service),r=(0,b.createImageServiceRequest)(n),i=(0,b.imageServiceRequestToString)({identifier:r.identifier,server:r.server,scheme:r.scheme,type:`image`,size:{max:!e.size?.width&&!e.size?.height,confined:!1,upscaled:!1,...e.size||{}},format:`jpg`,region:{full:!0},rotation:{angle:0},quality:`default`,prefix:r.prefix,originalPath:r.originalPath});return t.embed({id:i,type:`Image`,format:e.format||`image/jpeg`,height:e.height||n.height,width:e.width||n.width,service:e.embedService===!1?void 0:[qt(n,t.config,t.options.parent?.property===`thumbnail`)]})}function V(e){return e.endsWith(`default.jpg`)?(0,b.imageServiceRequestToString)({...(0,b.parseImageServiceRequest)(e),type:`info`}):(0,b.canonicalServiceUrl)(e)}function H(e){let t=e.options.initialData,n=t.url?V(t.url):``,[r,i]=(0,m.useState)(n||``);return(0,h.jsx)(f.PaddedSidebarContainer,{children:(0,h.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let n=new FormData(t.target),r=Object.fromEntries(n.entries()),i=r.url;if(i){let t=V(i);if(!t)throw Error(`Invalid image service request`);fetch(t).then(e=>e.json()).then(t=>{e.runCreate({url:r.url,service:t})})}},children:[(0,h.jsx)(`div`,{className:`flex gap-2 items-center`,children:(0,h.jsxs)(p.InputContainer,{$wide:!0,children:[(0,h.jsx)(p.InputLabel,{htmlFor:`url`,children:`Link to image service`}),(0,h.jsx)(p.Input,{id:`url`,name:`url`,defaultValue:t.url||``,onPaste:e=>{let t=e.clipboardData.getData(`text/plain`);i(t?V(t):``)},onBlur:e=>i(e.currentTarget.value?V(e.currentTarget.value):``)})]})}),(0,h.jsx)(`div`,{className:`relative flex z-0 my-5 h-96 min-h-0 min-w-0 overflow-hidden bg-gray-200 rounded items-center justify-center`,children:r.trim()?(0,h.jsx)(te.ErrorBoundary,{fallbackRender:()=>(0,h.jsx)(`div`,{children:`Invalid service`}),children:(0,h.jsx)(Yt,{src:r},r)}):(0,h.jsx)(`div`,{className:`text-grey-600`,children:`Preview`})}),(0,h.jsx)(`div`,{children:(0,h.jsx)(f.ActionButton,{primary:!0,large:!0,type:`submit`,isDisabled:!r,children:`Create`})})]})})}function Yt({src:e}){let t=(0,_.useImage)({id:e},{size:{width:512}});return t?(0,h.jsx)(`div`,{className:`h-full`,children:(0,h.jsx)(`img`,{className:`w-full h-full object-contain`,src:t})}):(0,h.jsx)(we,{})}async function Xt(e,t){let n={id:t.generateId(`annotation`),type:`Annotation`},r=t.options.targetType,i=await(0,u.creatorHelper)(t,`Annotation`,`body`,`@manifest-editor/image-service-creator`)(e,{parent:{resource:n,property:`body`}});if(r===`Annotation`)return{...n,body:[i],motivation:e.motivation||`painting`,target:t.getTarget()};if(r===`Canvas`){let r=t.generateId(`canvas`),a=t.generateId(`annotation-page`,{id:r,type:`Canvas`}),o=t.embed({...n,motivation:`painting`,body:[i],target:{type:`SpecificResource`,source:{id:r,type:`Canvas`}}}),s=t.embed({id:a,type:`AnnotationPage`,items:[o]}),c;return e.service?.sizes&&(c=await(0,u.creatorHelper)(t,`Canvas`,`thumbnail`,`@manifest-editor/thumbnail-image`)({service:e.service,width:e.thumbnailSize||400})),t.embed({id:r,type:`Canvas`,label:e.label||{en:[`Untitled canvas`]},height:i.resource.height||1e3,width:i.resource.width||1e3,thumbnail:c?[c]:void 0,items:[s]})}}function Zt(e){return(0,h.jsx)(H,{...e})}const U=(0,u.defineCreator)({id:`@manifest-editor/image-service-creator`,configKey:`iiif-image-services`,create:Jt,label:`Image Service`,summary:`Add an image from Image Service`,icon:(0,h.jsx)(f.IIIFLogo,{style:{padding:10}}),tags:[`image`,`image-service`],async supportsResource(e,t){if(!x(e))return!1;let n=V(e);if(!n)return!1;let r=await S(n,t);return oe(r)?{initialData:{url:e,service:r}}:!1},render(e){return(0,h.jsx)(H,{...e})},resourceType:`ContentResource`,resourceFields:[`id`,`type`,`height`,`width`,`format`,`service`],supports:{initialData:!0,parentFields:[`logo`,`body`,`thumbnail`,`items`],custom(e,t){return e.property!==`items`||e.resource.type===`ContentResource`&&t.get(e.resource,{skipSelfReturn:!1})?.type===`Choice`}}}),Qt=(0,u.defineCreator)({id:`@manifest-editor/image-service-annotation`,create:Xt,label:`IIIF Image`,dependencies:[`@manifest-editor/image-service-creator`],summary:`IIIF Image service`,tags:[`image`,`image-service`],icon:(0,h.jsx)(f.IIIFLogo,{style:{padding:10}}),render(e){return(0,h.jsx)(Zt,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],supportsResource:U.supportsResource,supports:{initialData:!0,onlyPainting:!0,parentTypes:[`AnnotationPage`,`Manifest`],parentFields:[`items`]},sideEffects:[z,A,k],staticFields:{type:`Annotation`}});async function $t(e,t){if(!e.height||!e.width){let t=await(0,y.getImageDimensions)(e.url);t&&(e.height=t.height,e.width=t.width)}return t.embed({id:e.url,type:`Image`,format:e.format||await(0,y.getFormat)(e.url),height:e.height,width:e.width,service:e.service?Array.isArray(e.service)?e.service:[e.service]:void 0})}function W(e){let t=e.options.initialData;return(0,h.jsx)(f.PaddedSidebarContainer,{children:(0,h.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let n=new FormData(t.target),r=Object.fromEntries(n.entries());r.url&&e.runCreate({url:r.url})},children:[(0,h.jsxs)(p.InputContainer,{$wide:!0,children:[(0,h.jsx)(p.InputLabel,{htmlFor:`id`,children:`Link to Image`}),(0,h.jsx)(p.Input,{id:`url`,name:`url`,defaultValue:t.url||``})]}),(0,h.jsx)(f.ActionButton,{primary:!0,large:!0,type:`submit`,children:`Create`})]})})}async function en(e,t){let n={id:t.generateId(`annotation`),type:`Annotation`},r=t.options.targetType,i=await(0,u.creatorHelper)(t,`Annotation`,`body`,`@manifest-editor/image-url-creator`)(e,{parent:{resource:n,property:`body`}});if(r===`Annotation`)return t.embed({...n,body:[i],motivation:e.motivation||`painting`,target:t.getTarget()});if(r===`Canvas`){let r=t.generateId(`canvas`),a=t.generateId(`annotation-page`,{id:r,type:`Canvas`}),o=t.embed({...n,motivation:`painting`,body:[i],target:{type:`SpecificResource`,source:{id:r,type:`Canvas`}}}),s=t.embed({id:a,type:`AnnotationPage`,items:[o]});return t.embed({id:r,type:`Canvas`,label:e.label||{en:[`Untitled canvas`]},height:i.resource.height||1e3,width:i.resource.width||1e3,items:[s]})}throw Error(`Unsupported target type`)}function tn(e){return(0,h.jsx)(W,{...e})}const G=(0,u.defineCreator)({id:`@manifest-editor/image-url-creator`,create:$t,label:`Image`,summary:`Image from a URL`,icon:(0,h.jsx)(f.AddImageIcon,{}),tags:[`image`],async supportsResource(e,t){if(!x(e))return!1;let n=V(e);if(n)try{if(oe(await t.json(n)))return!1}catch{}let r=await w(e,t);return r.startsWith(`image/`)||T(e,[`.jpg`,`.jpeg`,`.png`,`.gif`,`.webp`])?{initialData:{url:e,format:r||void 0}}:!1},render(e){return(0,h.jsx)(W,{...e})},resourceType:`ContentResource`,resourceFields:[`format`],supports:{initialData:!0,parentFields:[`logo`,`body`,`thumbnail`,`items`],custom(e,t){return e.property!==`items`||e.resource.type===`ContentResource`&&t.get(e.resource,{skipSelfReturn:!1})?.type===`Choice`}},staticFields:{type:`Image`}}),nn=(0,u.defineCreator)({id:`@manifest-editor/image-url-annotation`,create:en,label:`Image`,dependencies:[`@manifest-editor/image-url-creator`],summary:`Image from URL`,tags:[`image`],icon:(0,h.jsx)(f.AddImageIcon,{}),render(e){return(0,h.jsx)(tn,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],supportsResource:G.supportsResource,supports:{initialData:!0,onlyPainting:!0,parentTypes:[`AnnotationPage`,`Manifest`],parentFields:[`items`]},sideEffects:[z,A,k],staticFields:{type:`Annotation`}});async function rn(e,t){let n=[],r=(0,u.creatorHelper)(t,`Annotation`,`body`,`@manifest-editor/image-url-creator`);for(let i of e.images)n.push(await r(i,t.options));return n}function K(e){return(0,h.jsx)(f.PaddedSidebarContainer,{children:(0,h.jsxs)(f.Form.Form,{onSubmit:t=>{t.preventDefault();let n=new FormData(t.target),r=Object.fromEntries(n.entries());r.urls&&e.runCreate({images:r.urls.split(`
97
+ `).map(e=>({url:e}))})},children:[(0,h.jsxs)(f.Form.InputContainer,{className:`mb-4`,children:[(0,h.jsx)(f.Form.Label,{children:`Enter a list of URLs (one per line)`}),(0,h.jsx)(f.Form.TextArea,{name:`urls`,rows:`10`})]}),(0,h.jsx)(f.ActionButton,{primary:!0,large:!0,type:`submit`,children:`Create`})]})})}async function an(e,t){let n=[],r=(0,u.creatorHelper)(t,`AnnotationPage`,`items`,`@manifest-editor/image-url-annotation`);for(let i of e.images)n.push(await r(i,t.options));return n}const on=(0,u.defineCreator)({id:`@manifest-editor/image-url-list-annotation`,create:an,label:`List of Images`,dependencies:[`@manifest-editor/image-url-annotation`],summary:`List of Images from URLs`,tags:[`image`],icon:(0,h.jsx)(f.ImageListIcon,{}),render(e){return(0,h.jsx)(K,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],supports:{onlyPainting:!0,parentTypes:[`AnnotationPage`,`Manifest`],parentFields:[`items`]},sideEffects:[z,A,k],staticFields:{type:`Annotation`}}),sn=(0,u.defineCreator)({id:`@manifest-editor/no-body-annotation`,create:cn,label:`Annotation without body`,summary:`Add an annotation that only has motivation and target`,icon:(0,h.jsx)(f.EmptyCanvasIcon,{}),resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`target`],supports:{initialData:!0,parentTypes:[`AnnotationPage`],parentFields:[`items`],disallowPainting:!0},actionButton:`Create empty annotation`,sideEffects:[],staticFields:{type:`Annotation`}});function cn(e,t){return t.embed({id:t.generateId(`annotation`),type:`Annotation`,label:e?.label,motivation:e.motivation||t.options.initialData?.motivation||`highlighting`,target:t.getTarget()})}function ln({media:e,onError:t,duration:n,onDuration:r,onDimensions:i}){let[{element:a,currentTime:o,progress:s},c,l]=(0,_.useSimpleMediaPlayer)({duration:n});return(0,h.jsxs)(_.MediaPlayerProvider,{element:a,state:c,actions:l,currentTime:o,progress:s,children:[(0,h.jsx)(`div`,{style:{maxHeight:400,aspectRatio:`${e.width}/${e.height}`,position:`relative`},children:(0,h.jsx)(_.CanvasPanel.VideoHTML,{element:a,media:e,playPause:l.playPause})}),(0,h.jsx)(E,{onError:t,onDuration:r,onDimensions:i})]})}async function un(e,t){let n={id:t.generateId(`annotation`),type:`Annotation`},r=t.options.targetType,i=t.embed({id:e.url,type:`Video`,format:`video/mp4`,width:e.width,height:e.height,duration:e.duration||0});if(r===`Annotation`)return t.embed({...n,label:(0,d.getValue)(e.label)&&e.label,motivation:e.motivation||t.options.initialData?.motivation||`painting`,body:i,target:t.getTarget()});if(r===`Canvas`){let r=t.generateId(`canvas`),a=t.generateId(`annotation-page`,{id:r,type:`Canvas`}),o=t.embed({...n,motivation:`painting`,body:i,target:{type:`SpecificResource`,source:{id:r,type:`Canvas`}}}),s=t.embed({id:a,type:`AnnotationPage`,items:[o]});return t.embed({id:r,type:`Canvas`,label:e.label||{en:[`Untitled HTML canvas`]},duration:e.duration||0,width:e.width,height:e.height,items:[s]})}}function dn(e){let t=e.options.initialData,[n,r]=(0,m.useState)(t.url||``),[i,a]=(0,m.useState)(0),[o,s]=(0,m.useState)(0),[c,l]=(0,m.useState)(0),[u,d]=(0,m.useState)(``),[g,_]=(0,m.useState)({en:[``]});return(0,m.useEffect)(()=>{if(d(``),a(0),n){let e=n.split(`/`).pop()?.split(`.`).shift();_({en:[e||``]})}},[n]),(0,h.jsxs)(f.PaddedSidebarContainer,{children:[u?(0,h.jsx)(f.ErrorMessage,{children:u}):null,(0,h.jsxs)(p.InputContainer,{$wide:!0,children:[(0,h.jsx)(p.InputLabel,{htmlFor:`video-url`,children:`URL`}),(0,h.jsx)(p.Input,{type:`text`,id:`video-url`,value:n,onChange:e=>r(e.target.value)})]}),n&&!u?(0,h.jsx)(`div`,{children:(0,h.jsx)(p.LanguageFieldEditor,{containerId:`label`,focusId:`label_`,label:`Label`,fields:g,onSave:e=>_(e.toInternationalString())},`${n}__${i}`)}):null,n&&!u?(0,h.jsx)(`div`,{className:`mb-4 bg-black`,children:(0,h.jsx)(ln,{duration:i,onDuration:e=>a(e),onError:e=>d(e),media:{url:n,duration:i,height:c,width:o,type:`Video`},onDimensions:(e,t)=>{s(e||0),l(t||0)}})}):null,!u&&(i||o||c)?(0,h.jsx)(p.InputContainer,{$wide:!0,children:(0,h.jsx)(p.DimensionsTriplet,{widthId:`width`,width:o||0,changeWidth:e=>s(e),heightId:`height`,height:c||0,changeHeight:e=>l(e),durationId:`duration`,duration:i||0,changeDuration:e=>a(e)})}):null,(0,h.jsx)(f.ActionButton,{primary:!0,large:!0,type:`button`,onPress:()=>{e.runCreate({url:n,duration:i,label:g,width:o,height:c})},isDisabled:!n||!!u,children:`Add video`})]})}const fn=(0,u.defineCreator)({id:`@manifest-editor/video-annotation`,create:un,label:`Video`,summary:`Video annotation`,icon:(0,h.jsx)(f.VideoIcon,{}),render(e){return(0,h.jsx)(dn,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],async supportsResource(e,t){return x(e)&&((await w(e,t)).startsWith(`video/`)||T(e,[`.mp4`,`.m4v`,`.webm`,`.mov`]))?{initialData:{url:e}}:!1},supports:{onlyPainting:!0,initialData:!0,parentTypes:[`AnnotationPage`,`Manifest`],parentFields:[`items`]},staticFields:{type:`Annotation`}}),pn=()=>(0,h.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`24px`,viewBox:`0 0 24 24`,width:`24px`,fill:`#000000`,transform:`scale(-1, 1)`,children:(0,h.jsxs)(`g`,{children:[(0,h.jsx)(`rect`,{fill:`none`,height:`24`,width:`24`}),(0,h.jsx)(`path`,{d:`M16,20H2V4h14V20z M18,8h4V4h-4V8z M18,20h4v-4h-4V20z M18,14h4v-4h-4V14z`})]})}),mn=(0,u.defineCreator)({id:`@manifest-editor/empty-annotation-page`,create:(e,t)=>t.embed({id:t.generateId(`annotations`),label:e.label,type:`AnnotationPage`,items:[]}),label:`Empty annotation page`,summary:`AnnotationPage with nothing`,icon:(0,h.jsx)(pn,{}),resourceType:`AnnotationPage`,resourceFields:[`id`,`type`,`items`],supports:{parentTypes:[`Manifest`,`Canvas`,`Range`],parentFieldMap:{Manifest:[`annotations`],Canvas:[`items`,`annotations`],Range:[`annotations`]}}}),hn=(0,u.defineCreator)({id:`@manifest-editor/empty-canvas`,create:(e,t)=>{let n=t.generateId(`canvas`),r=t.embed({id:t.generateId(`annotation-page`,{id:n,type:`Canvas`}),type:`AnnotationPage`,items:[]});return{id:n,type:`Canvas`,label:e.label||{en:[``]},height:e.height||1e3,width:e.width||1e3,items:[r]}},label:`Empty canvas`,summary:`No content`,icon:(0,h.jsx)(f.EmptyCanvasIcon,{}),resourceType:`Canvas`,resourceFields:[`id`,`type`,`label`,`height`,`width`,`items`],supports:{parentTypes:[`Manifest`],parentFields:[`items`]}});var gn=process.env.NODE_ENV===`production`,q=`Invariant failed`;function J(e,t){if(!e){if(gn)throw Error(q);var n=typeof t==`function`?t():t,r=n?`${q}: ${n}`:q;throw Error(r)}}const _n=(0,u.defineCreator)({id:`@manifest-editor/internal-canvas`,create:yn,label:`Internal canvas link`,summary:`Canvas from the same manifest`,icon:(0,h.jsx)(pn,{}),resourceType:`Canvas`,resourceFields:[`id`,`type`,`label`],supports:{parentTypes:[`Manifest`],parentFields:[`start`]},render:e=>(0,h.jsx)(vn,{...e})});function vn(e){let t=(0,_.useManifest)(),n=(0,_.useVault)(),r=(0,m.useMemo)(()=>({canSelectCanvas:!1,canSelectCollection:!1,canSelectManifest:!0,canCropImage:!1,alwaysShowNavigationArrow:!1,multiSelect:!1}),[]),i=(0,m.useMemo)(()=>[{type:`callback`,cb:t=>e.runCreate({id:t}),label:`Select canvas`,supportedTypes:[`Canvas`],format:{type:`url`}}],[e.runCreate]),a=(0,m.useMemo)(()=>({saveToLocalStorage:!1,restoreFromLocalStorage:!1,initialHistory:[{url:t?.id,resource:t?.id,route:`/loading?id=${t?.id}`,metadata:{type:`Manifest`}}]}),[t?.id]);return J(t,`Manifest is not loaded`),(0,h.jsx)(_.VaultProvider,{vault:n,children:(0,h.jsx)(ne.IIIFBrowser,{vault:n,navigation:r,output:i,history:a})})}async function yn(e,t){return t.embed({id:e.id,type:`Canvas`})}const bn=e=>(0,h.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,height:`1em`,width:`1em`,...e,children:[(0,h.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,h.jsx)(`path`,{d:`M5 17v2h14v-2H5zm4.5-4.2h5l.9 2.2h2.1L12.75 4h-1.5L6.5 15h2.1l.9-2.2zM12 5.98 13.87 11h-3.74L12 5.98z`})]});async function xn(e,t){return t.embed({id:t.generateId(`html/${e.language}`),language:e.language,type:`TextualBody`,format:`text/html`,value:e.body||``})}function Sn(e){let{i18n:t}=(0,y.useConfig)(),[n,r]=(0,m.useState)(`<p></p>`),[i,a]=(0,m.useState)(t.defaultLanguage);return(0,h.jsxs)(f.PaddedSidebarContainer,{children:[(0,h.jsx)(f.HTMLEditor,{className:`border-none`,value:n,onChange:e=>r(e)}),(0,h.jsx)(f.ActionButton,{primary:!0,large:!0,type:`button`,onPress:()=>{e.runCreate({language:i,body:n})},children:`Create`})]})}const Cn=(0,u.defineCreator)({id:`@manifest-editor/html-body-creator`,create:xn,label:`HTML Body`,summary:`Add HTML annotation body`,icon:(0,h.jsx)(bn,{}),render(e){return(0,h.jsx)(Sn,{...e})},resourceType:`ContentResource`,resourceFields:[`id`,`language`,`type`,`format`,`value`],supports:{parentTypes:[`Annotation`,`ContentResource`],parentFields:[`body`,`items`],custom(e,t){if(e.resource.type===`Annotation`)return e.property===`body`;let n=t.get(e.resource,{skipSelfReturn:!1});return e.property===`items`&&n?.type===`Choice`}},staticFields:{type:`TextualBody`,format:`text/html`}});function Y(e,t,n,r=0){return`${e}/${Math.floor(t.x)},${Math.floor(t.y)},${Math.floor(t.width)},${Math.floor(t.height)}/${n}/${r}/default.jpg`}async function wn(e,t){let n=t.options.targetType,r=e.output,i=[];for(let{resource:a,selector:o,parent:s,rotation:c}of r){let r=a.type,u=new d.Vault;if((n===`Canvas`||n===`Annotation`||n===`ContentResource`)&&r===`Canvas`){let r=a.id,d=s?.type===`Manifest`?s.id:void 0;J(d,`Could not find Manifest`);let f=u.get({id:d,type:`Manifest`})||await u.loadManifest(d);J(f,`Manifest not found`);let p=t.config.addManifestMetadataToCanvas!==!1;e.trackManifest?.({requiredStatement:f.requiredStatement,rights:f.rights,...p?{metadata:f.metadata||[]}:{},partOf:[{id:d,type:`Manifest`,label:f.label}]});let m=e=>{if(e.type===`SpecificResource`&&e.source)return{...e,source:m(e.source)};let t=e.type===`Canvas`&&!p?{}:{metadata:f.metadata||[]};return{requiredStatement:f.requiredStatement,rights:f.rights,...t,...e,partOf:[{id:d,type:`Manifest`,label:f.label}]}},h=f.items.find(e=>e.id===r);J(h,`Canvas not found`);let g=u.get(h),_=l.t(o,c);if(n===`Canvas`&&!_){let e=u.toPresentation3(g);e.label||(e.label={en:[`Untitled canvas`]}),t.vault.loadSync(e.id,m(e)),i.push(t.embed(t.vault.get({id:e.id,type:`Canvas`})));continue}let v=u.get(g.items[0]),y=u.get(v.items[0]);if(n===`Annotation`||n===`Canvas`||n===`ContentResource`){let r=u.toPresentation3(y);r.id=t.generateId(`Annotation`);let a=null,s={width:0,height:0};if(r?.body?.service){let t=r?.body.width,n=r?.body.height;a=(0,b.getImageServices)(r?.body)[0],a&&(!a.width||!a.height)&&(a.width=t,a.height=n),s.width=t,s.height=n,e.trackSize&&e.trackSize(s)}if(_){let u={...r.body},d=``;if(a&&o?.type===`BoxSelector`){let e=a.id||a[`@id`]||``;e&&(u.id=Y(e,o.spatial,`max`,c),d=Y(e,o.spatial,`512,`,c))}r.body={id:t.generateId(`SpecificResource`,y),type:`SpecificResource`,source:u,selector:_};let f=l.n(o?.type===`BoxSelector`?{width:~~o.spatial.width,height:~~o.spatial.height}:s,c);if(e.trackSize&&e.trackSize(f),n===`ContentResource`){i.push(m(r.body));continue}if(n===`Canvas`){let e=t.generateId(`Canvas`,y);r.target=e;let n=t.generateId(`Page`,y),a=t.embed({id:n,type:`AnnotationPage`,items:[r]}),{width:o,height:s}=f;i.push(t.embed(m({id:e,type:`Canvas`,label:{en:[`Untitled canvas`]},width:o,height:s,thumbnail:d?[t.embed({id:d,type:`Image`,format:`image/jpeg`,width:512,height:Math.round(s/o*512)})]:void 0,items:[a]})));continue}i.push(t.embed(m({...r,target:t.getTarget()})));continue}i.push(t.embed(m({...r,target:t.getTarget()})))}}}return i}const Tn=(0,m.lazy)(()=>Promise.resolve().then(()=>require("./iiif-browser-form.lazy-Df2fAM6b.cjs"))),En=(0,u.defineCreator)({id:`@manifest-editor/iiif-browser-creator`,create:wn,label:`IIIF Browser`,summary:`Browse IIIF Resources`,icon:(0,h.jsx)(f.IIIFBrowserIcon,{}),configuration:{fields:[{id:`addManifestMetadataToCanvas`,type:`checkbox`,label:`Add manifest metadata to imported canvases`,summary:`Copies metadata from the source Manifest when the IIIF Browser creates a Canvas.`,defaultValue:!0}]},render(e){return(0,h.jsx)(Tn,{...e})},hiddenModal:!0,tags:[`image`,`image-service`],async supportsResource(e,t){let n=C(await S(e,t));return n===`Manifest`||n===`Collection`||await se(e)?{initialData:{url:e}}:!1},resourceType:`ContentResource`,resourceFields:[`id`,`language`,`type`,`format`,`value`],additionalTypes:[`Annotation`,`Canvas`],supports:{initialData:!0,onlyPainting:!0,parentTypes:[`Annotation`,`Manifest`,`AnnotationPage`],parentFields:[`body`,`items`],parentFieldMap:{Annotation:[`body`],Manifest:[`items`],AnnotationPage:[`items`]}},sideEffects:[{canvasInteraction:!0,spatial:!0,async run(e,{vault:t,options:n}){if(!(e&&e.type===`Annotation`&&n.targetType===`Annotation`))return;let r=t.get(e),i=r.target;if(!(i&&i.source?.type===`Canvas`))return;let a=(Array.isArray(r.body)?r.body[0]:r.body)?.selector;if(!(a&&(a.type===`iiif:ImageApiSelector`||a.type===`ImageApiSelector`)&&a.region))return;let[o,s,c,l]=a.region.split(`,`).map(Number);if(![o,s,c,l].every(Number.isFinite)||c<=0||l<=0)return;let[u]=t.get(r.body),d=(u?.service||[]).find(e=>(0,b.isImageService)(e)),f=d?.id||d?.[`@id`];if(!f)return;let p=Y(f,{x:o,y:s,width:c,height:l},`512,`);t.loadSync(p,{id:p,type:`Image`,format:`image/jpeg`,width:512,height:Math.round(l/c*512),service:[d]}),t.modifyEntityField(i.source,`thumbnail`,[{id:p,type:`ContentResource`}])}},z,A,k],staticFields:{}}),Dn=(0,u.defineCreator)({id:`@manifest-editor/image-url-list`,label:`Image URL List`,summary:`Image from a list of URLs`,create:rn,icon:(0,h.jsx)(f.ImageListIcon,{}),render(e){return(0,h.jsx)(K,{...e})},resourceType:`ContentResource`,resourceFields:[`format`],supports:{parentFields:[`logo`,`body`,`thumbnail`]},staticFields:{type:`Image`}});async function On(e,t){return t.embed({id:e.url,type:`Text`,label:e.label,format:`text/plain`})}function kn(e){let[t,n]=(0,m.useState)({en:[`View as text`]});return(0,h.jsx)(f.PaddedSidebarContainer,{children:(0,h.jsxs)(`form`,{onSubmit:n=>{n.preventDefault();let r=new FormData(n.target),i=Object.fromEntries(r.entries());i.url&&e.runCreate({url:i.url,label:t})},children:[(0,h.jsx)(p.LanguageFieldEditor,{focusId:`label`,label:`Label`,fields:t,onSave:e=>n(e.toInternationalString())}),(0,h.jsxs)(p.InputContainer,{$wide:!0,children:[(0,h.jsx)(p.InputLabel,{htmlFor:`id`,children:`Link to plaintext`}),(0,h.jsx)(p.Input,{id:`url`,name:`url`,defaultValue:``})]}),(0,h.jsx)(f.ActionButton,{primary:!0,large:!0,type:`submit`,children:`Create`})]})})}const An=(0,u.defineCreator)({id:`@manifest-editor/plaintext-creator`,create:On,label:`Plaintext`,summary:`Add link to an plaintext`,icon:(0,h.jsx)(bn,{}),render(e){return(0,h.jsx)(kn,{...e})},resourceType:`ContentResource`,resourceFields:[`label`,`format`],supports:{parentFields:[`seeAlso`,`rendering`]},staticFields:{format:`text/plain`}});function jn(e,t){let n=(0,b.createImageServiceRequest)(B(e));return(0,b.imageServiceRequestToString)({identifier:n.identifier,server:n.server,scheme:n.scheme,type:`image`,size:{max:!1,confined:!1,upscaled:!1,width:t.width,height:t.height},format:`jpg`,region:{full:!0},rotation:{angle:0},quality:`default`,prefix:n.prefix,originalPath:n.originalPath})}function X(e){return e.endsWith(`default.jpg`)?(0,b.imageServiceRequestToString)({...(0,b.parseImageServiceRequest)(e),type:`info`}):(0,b.canonicalServiceUrl)(e)}async function Mn(e,t){let n=B(e.service),r=n.sizes,i=qt(n,t.config,!0);if(e.thumbnailUrl)return t.embed({id:e.thumbnailUrl,type:`Image`,format:`image/jpeg`,width:e.width,height:e.height,service:[i]});if(r){let a=e.width||400,o=null;for(let e of r)(!o||Math.abs(e.width-a)<Math.abs(o.width-a))&&(o={width:e.width,height:e.height});if(o){let e=jn(n,o);return t.embed({id:e,type:`Image`,format:`image/jpeg`,width:o.width,height:o.height,service:[i]})}}return null}function Nn(e){let[t,n]=(0,m.useState)(``),[r,i]=(0,m.useState)(null),[a,o]=(0,m.useState)({width:0,height:0}),s=(0,m.useMemo)(()=>!r||!a.width||!a.height?null:jn(r,a),[a,r]);return r?(0,h.jsxs)(f.PaddedSidebarContainer,{children:[(0,h.jsxs)(`div`,{className:`mb-4`,children:[(0,h.jsx)(`div`,{className:`mb-2`,children:r[`@id`]||r.id}),(0,h.jsx)(`div`,{className:`flex gap-2 mb-4`,children:r.sizes?.map(e=>{let t=e.width===a.width;return(0,h.jsxs)(f.ActionButton,{primary:t,isDisabled:t,large:!0,onPress:()=>o(e),children:[e.width,`x`,e.height]},e.width)})}),s?(0,h.jsx)(`img`,{src:s,alt:`preview of selected resource`}):null]}),(0,h.jsx)(f.ActionButton,{primary:!0,large:!0,isDisabled:!s,onPress:()=>{r&&e.runCreate({service:r,width:a.width,height:a.height})},children:`Add thumbnail`})]}):(0,h.jsx)(f.PaddedSidebarContainer,{children:(0,h.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let t=new FormData(e.target),n=Object.fromEntries(t.entries()).url;if(n){let e=X(n);if(!e)throw Error(`Invalid image service request`);fetch(e).then(e=>e.json()).then(e=>{i(e);let t=e.sizes?.[0];t&&o(t)})}},children:[(0,h.jsx)(`div`,{className:`flex gap-2 items-center`,children:(0,h.jsxs)(p.InputContainer,{$wide:!0,children:[(0,h.jsx)(p.InputLabel,{htmlFor:`url`,children:`Link to image service`}),(0,h.jsx)(p.Input,{id:`url`,name:`url`,defaultValue:``,onPaste:e=>{let t=e.clipboardData.getData(`text/plain`);n(t?X(t):``)},onBlur:e=>n(e.currentTarget.value?X(e.currentTarget.value):``)})]})}),(0,h.jsx)(`div`,{children:(0,h.jsx)(f.ActionButton,{primary:!0,large:!0,type:`submit`,isDisabled:!t,children:`Select size`})})]})})}const Pn=(0,u.defineCreator)({id:`@manifest-editor/thumbnail-image`,configKey:`iiif-image-services`,create:Mn,label:`Thumbnail from service`,summary:`Add thumbnail from an image service`,icon:(0,h.jsx)(f.ScaledImageIcon,{}),render(e){return(0,h.jsx)(Nn,{...e})},resourceType:`ContentResource`,resourceFields:[`id`,`type`,`format`,`width`,`height`,`service`],supports:{parentFields:[`thumbnail`]}});function Fn(){return(0,h.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`24px`,viewBox:`0 0 24 24`,width:`24px`,fill:`#000000`,children:[(0,h.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,h.jsx)(`path`,{d:`M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z`})]})}async function In(e,t){return t.embed({id:e.url,type:`Text`,label:e.label,format:`text/html`})}function Ln(e){let[t,n]=(0,m.useState)({en:[``]});return(0,h.jsx)(f.PaddedSidebarContainer,{children:(0,h.jsxs)(`form`,{onSubmit:n=>{n.preventDefault();let r=new FormData(n.target),i=Object.fromEntries(r.entries());i.url&&e.runCreate({url:i.url,label:t})},children:[(0,h.jsx)(p.LanguageFieldEditor,{focusId:`label`,label:`Label`,fields:t,onSave:e=>n(e.toInternationalString())}),(0,h.jsxs)(p.InputContainer,{$wide:!0,children:[(0,h.jsx)(p.InputLabel,{htmlFor:`id`,children:`Link`}),(0,h.jsx)(p.Input,{id:`url`,name:`url`,defaultValue:``})]}),(0,h.jsx)(f.ActionButton,{primary:!0,large:!0,type:`submit`,children:`Create link`})]})})}const Rn=(0,u.defineCreator)({id:`@manifest-editor/web-page-creator`,create:In,label:`Web page`,summary:`Add link to an external web page`,icon:(0,h.jsx)(Fn,{}),render(e){return(0,h.jsx)(Ln,{...e})},resourceType:`ContentResource`,resourceFields:[`label`,`format`],supports:{parentFields:[`seeAlso`,`rendering`,`homepage`]}}),zn=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function Z(e){let t=(e||``).match(zn);return t?t[1]:null}function Bn(e){return!!Z(e.youtubeUrl)}function Vn(e,t){let n=Z(e.youtubeUrl);return t.embed({id:`https://www.youtube.com/watch?v=${n}`,type:`Video`,service:[{type:`Service`,profile:`http://digirati.com/objectifier`,params:{data:`https://www.youtube.com/embed/${n}`}},{id:`https://www.youtube.com/watch?v=${n}`,type:`Service`,profile:`https://www.youtube.com`}]})}async function Hn(e,t){let n=Vn(e,t);if(t.options.targetType===`Canvas`){let r=t.generateId(`canvas`),i=t.generateId(`annotation-page`,{id:r,type:`Canvas`}),a=t.embed({id:t.generateId(`annotation`,{id:i,type:`AnnotationPage`}),type:`Annotation`,motivation:`painting`,body:[n],target:{type:`SpecificResource`,source:{id:r,type:`Canvas`}}}),o=t.embed({id:i,type:`AnnotationPage`,items:[a]});return t.embed({id:r,type:`Canvas`,label:e.label||{en:[`Untitled YouTube canvas`]},height:e.height||1e3,width:e.width||1e3,duration:e.duration||1,items:[o]})}return t.options.targetType===`Annotation`?t.embed({id:t.generateId(`annotation`),type:`Annotation`,motivation:`painting`,body:[n],target:t.getTarget()}):n}function Un(e){let t=e.options.initialData;return(0,h.jsx)(f.PaddedSidebarContainer,{children:(0,h.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let n=new FormData(t.target),r=Object.fromEntries(n.entries());r.youtubeUrl&&e.runCreate({youtubeUrl:r.youtubeUrl})},children:[(0,h.jsxs)(p.InputContainer,{$wide:!0,children:[(0,h.jsx)(p.InputLabel,{htmlFor:`id`,children:`Link to YouTube`}),(0,h.jsx)(p.Input,{id:`youtubeUrl`,name:`youtubeUrl`,defaultValue:t.youtubeUrl||``})]}),(0,h.jsx)(f.ActionButton,{primary:!0,large:!0,type:`submit`,children:`Create`})]})})}const Wn=(0,u.defineCreator)({id:`@manifest-editor/youtube`,create:Hn,label:`YouTube`,summary:`Embed YouTube`,icon:(0,h.jsx)(f.YouTubeIcon,{}),resourceType:`ContentResource`,additionalTypes:[`Canvas`,`Annotation`],resourceFields:[`id`,`type`,`service`],supportsResource(e){return Z(e)?{initialData:{youtubeUrl:e}}:!1},render:e=>(0,h.jsx)(Un,{...e}),supports:{initialData:!0,onlyPainting:!0,parentTypes:[`Annotation`,`Manifest`,`AnnotationPage`],parentFieldMap:{Annotation:[`body`],Manifest:[`items`],AnnotationPage:[`items`]}},staticFields:{type:`Video`}});async function Gn(e,t){let n=e.output||[],r=[];for(let e of n){let{resource:n,parent:i,selector:a}=e,o=t.getPreviewVault(),s=(0,d.createThumbnailHelper)(o);if(n.type===`Manifest`){let e=n.id;J(e,`Could not find Manifest ID`);let i=await o.loadManifest(e),a=await s.getBestThumbnailAtSize(i,{width:256,height:256},!1);J(i,`Manifest not found`),r.push(t.embed({id:n.id,type:`Manifest`,label:i.label,summary:i.summary,thumbnail:a?.best?[{id:a.best.id,type:`Image`}]:void 0}));continue}if(n.type===`Collection`){let e=n.id;J(e,`Could not find Manifest ID`);let i=await o.loadManifest(e);J(i,`Collection not found`),r.push(t.embed({id:n.id,type:`Collection`,label:i.label}))}}return r}const Kn=(0,m.lazy)(()=>Promise.resolve().then(()=>qn));var qn=o({default:()=>Jn});function Jn(e){let t=(0,y.usePreviewVault)(),n=(0,m.useMemo)(()=>e.options.initialData||{},[e.options.initialData]),r=(0,m.useMemo)(()=>[{type:`callback`,label:`Select`,supportedTypes:[`Manifest`,`Collection`,`ManifestList`,`CollectionList`,`CollectionItemList`],cb:t=>e.runCreate({output:t}),format:{type:`custom`,format:(e,t,n)=>{let r=Array.isArray(e)?e:[{...e,parent:t}],i=[];for(let e of r)i.push({resource:n.get(e),parent:e.parent,selector:e.selector});return i}}}],[e.runCreate]),i=(0,m.useMemo)(()=>({canCropImage:!1,canSelectCanvas:!1,canSelectManifest:!0,canSelectCollection:!0,multiSelect:!0,...n.iiifBrowserOptions?.navigation||{}}),[n.iiifBrowserOptions?.navigation]),a=(0,m.useMemo)(()=>({buttonClassName:`bg-me-primary-500 text-white hover:bg-me-primary-600`,homeLink:n.url||(typeof e.config?.defaultCollection==`string`?e.config.defaultCollection:void 0),...n.iiifBrowserOptions?.ui||{}}),[n,e.config]),o=(0,m.useMemo)(()=>{let e=n.iiifBrowserOptions?.history||{};return n.url?{...e,restoreFromLocalStorage:!1,saveToLocalStorage:!1,initialHistory:[{url:n.url,resource:null,route:`/loading?id=${encodeURIComponent(n.url)}`}]}:e},[n]);return(0,h.jsx)(y.PreviewVaultBoundary,{children:(0,h.jsx)(ne.IIIFBrowser,{ui:a,vault:t,className:`iiif-browser border-none border-t rounded-none h-[70vh] min-h-[60vh] max-h-full max-w-full`,output:r,navigation:i,customPages:n.iiifBrowserOptions?.customPages||{},history:o})})}const Yn=(0,u.defineCreator)({id:`@manifest-editor/manifest-browser-creator`,configKey:`@manifest-editor/iiif-browser-creator`,create:Gn,label:`IIIF Browser`,summary:`Browse IIIF Resources`,icon:(0,h.jsx)(f.IIIFBrowserIcon,{}),render(e){return(0,h.jsx)(Jn,{...e})},async supportsResource(e,t){let n=C(await S(e,t));return n===`Manifest`||n===`Collection`||await se(e)?{initialData:{url:e}}:!1},resourceType:`Manifest`,resourceFields:[`id`,`label`],additionalTypes:[`Collection`],supports:{initialData:!0,parentTypes:[`Collection`,`Manifest`,`Canvas`],parentFieldMap:{Collection:[`items`],Manifest:[`partOf`],Canvas:[`partOf`]}},sideEffects:[],staticFields:{}});async function Xn(e,t,n){let r=t.generateId(`range`,n?{id:n,type:`Range`}:void 0);return t.embed({id:r,type:`Range`,label:e.label||{en:[`Untitled range`]},items:e.items||[]})}function Q(e){let[t,n]=(0,m.useState)({en:[``]});return(0,h.jsx)(f.PaddedSidebarContainer,{children:(0,h.jsxs)(`form`,{onSubmit:n=>{n.preventDefault(),t&&e.runCreate({type:`Range`,label:t})},children:[(0,h.jsx)(p.LanguageFieldEditor,{focusId:`label`,label:`Label`,fields:t,onSave:e=>n(e.toInternationalString())}),(0,h.jsx)(f.ActionButton,{primary:!0,type:`submit`,children:`Create range`})]})})}const Zn=(0,u.defineCreator)({id:`@manifest-editor/range-with-items`,create:Xn,label:`Range`,summary:`Add a new range`,icon:(0,h.jsx)(f.RangesIcon,{}),render(e){return(0,h.jsx)(Q,{...e})},resourceType:`Range`,resourceFields:[`id`,`label`,`type`],supports:{parentTypes:[`Range`],parentFields:[`items`]},staticFields:{type:`Range`}});async function Qn(e,t,n){let r=t.generateId(`range`,n?{id:n,type:`Range`}:void 0);return t.embed({id:r,type:`Range`,label:e.label||{en:[`Table of Contents`]},items:(e.items||[]).map(e=>t.ref(e))})}function $n(e){let[t,n]=(0,m.useState)({en:[``]});return(0,h.jsx)(f.PaddedSidebarContainer,{children:(0,h.jsxs)(`form`,{onSubmit:n=>{n.preventDefault(),t&&e.runCreate({type:`Range`,label:t})},children:[(0,h.jsx)(p.LanguageFieldEditor,{focusId:`label`,label:`Label`,fields:t,onSave:e=>n(e.toInternationalString())}),(0,h.jsx)(f.ActionButton,{primary:!0,type:`submit`,children:`Create range`})]})})}const $=(0,u.defineCreator)({id:`@manifest-editor/range-top-level`,create:Qn,label:`Top Level Range`,summary:`Add a new top level range`,icon:(0,h.jsx)(f.RangesIcon,{}),render(e){return(0,h.jsx)($n,{...e})},resourceType:`Range`,resourceFields:[`id`,`label`,`type`],supports:{parentTypes:[`Manifest`],parentFields:[`structures`]},staticFields:{type:`Range`}}),er=[U,Qt,G,nn,fn,De,Cn,Ne,Wn,En,hn,An,Rn,mn,sn,_n,Ae,Dn,on,Pn,$,Zn,ae];exports.CreateAudioAnnotationForm=O,exports.CreateCaptionedImageAnnotation=ke,exports.CreateHTMLAnnotation=Me,exports.CreateHTMLBodyForm=Sn,exports.CreateImageServerForm=H,exports.CreateImageServiceAnnotationForm=Zt,exports.CreateImageUrlAnnotationForm=tn,exports.CreateImageUrlForm=W,exports.CreateImageUrlListForm=K,exports.CreatePlaintextForm=kn,exports.CreateProviderForm=ie,exports.CreateThumbnailForm=Nn,exports.CreateVideoAnnotationForm=dn,exports.CreateWebPageForm=Ln,exports.IIIFBrowserCreatorForm=Tn,exports.ManifestBrowserCreatorForm=Kn,exports.RangeWithItemsCreatorForm=Q,exports.TopLevelRangeCreatorForm=$n,exports.YouTubeForm=Un,exports.allCreators=er,exports.audioAnnotation=De,exports.captionedImageAnnotation=Ae,exports.createAudioAnnotation=D,exports.createCaptionedImageAnnotation=Oe,exports.createFromIIIFBrowserOutput=wn,exports.createFromManifestBrowserOutput=Gn,exports.createHtmlAnnotation=je,exports.createHtmlBody=xn,exports.createImageServer=Jt,exports.createImageServiceAnnotation=Xt,exports.createImageUrl=$t,exports.createImageUrlAnnotation=en,exports.createImageUrlList=rn,exports.createImageUrlListAnnotation=an,exports.createNoBodyAnnotation=cn,exports.createPlaintext=On,exports.createProvider=re,exports.createRangeTopLevel=Qn,exports.createRangeWithItems=Xn,exports.createThumbnail=Mn,exports.createVideoAnnotation=un,exports.createWebPage=In,exports.createYoutubeBody=Hn,exports.createYoutubeBodyResource=Vn,exports.croppedRegion=Y,exports.emptyAnnotationPage=mn,exports.emptyCanvas=hn,exports.getCanonicalUrl=V,exports.getYouTubeId=Z,exports.htmlAnnotation=Ne,exports.htmlBodyCreator=Cn,exports.iiifBrowserCreator=En,exports.imageServiceAnnotation=Qt,exports.imageServiceCreator=U,exports.imageUrlAnnotation=nn,exports.imageUrlCreator=G,exports.imageUrlListAnnotation=on,exports.imageUrlListCreator=Dn,exports.internalCanvas=_n,exports.manifestBrowserCreator=Yn,exports.noBodyAnnotation=sn,exports.plaintextCreator=An,exports.providerCreator=ae,exports.rangeTopLevel=$,exports.rangeWithItems=Zn,exports.validateYouTube=Bn,exports.videoAnnotation=fn,exports.webPageCreator=Rn,exports.youTubeBodyCreator=Wn;
98
98
  //# sourceMappingURL=index.cjs.map