@manifest-editor/creators 2.0.3-next.0.e92a6d7 → 2.0.3-next.0.f58cbd8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
  import{useMemo as e}from"react";import{jsx as t}from"react/jsx-runtime";import{PreviewVaultBoundary as n,usePreviewVault as r}from"@manifest-editor/shell";import{IIIFBrowser as i}from"iiif-browser";function a(a){let o=e(()=>a.options.initialData||{},[a.options.initialData]),s=r(),c=e(()=>[{type:`callback`,label:`Select`,supportedTypes:[`Canvas`,`CanvasList`,`CanvasRegion`,`ImageService`,`ImageServiceRegion`],cb:e=>a.runCreate({output:e}),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}}}],[a.runCreate]),l=e(()=>({canCropImage:!0,canSelectCanvas:!0,canSelectManifest:!1,canSelectCollection:!1,multiSelect:!0,...o.iiifBrowserOptions?.navigation||{}}),[o]);return t(n,{children:t(i,{ui:e(()=>({buttonClassName:`bg-me-primary-500 text-white hover:bg-me-primary-600`,homeLink:`${window.location.origin}/collection.json`,...o.iiifBrowserOptions?.ui||{}}),[o]),vault:s,className:`iiif-browser border-none border-t rounded-none h-[70vh] min-h-[60vh] max-h-full max-w-full`,output:c,navigation:l,customPages:o.iiifBrowserOptions?.customPages||{},history:o.iiifBrowserOptions?.history||{}})})}export{a as default};
2
- //# sourceMappingURL=iiif-browser-form.lazy-B7Lg0pEn.js.map
2
+ //# sourceMappingURL=iiif-browser-form.lazy-B46fXhwH.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"iiif-browser-form.lazy-B7Lg0pEn.js","names":["initialData: IIIFBrowserCreatorInitialData","resource","vault"],"sources":["../src/ContentResource/IIIFBrowserCreator/iiif-browser-form.lazy.tsx"],"sourcesContent":["import type { CreatorContext } from \"@manifest-editor/creator-api\";\nimport { PreviewVaultBoundary, usePreviewVault } from \"@manifest-editor/shell\";\nimport { IIIFBrowser, type IIIFBrowserProps } from \"iiif-browser\";\nimport { useMemo } from \"react\";\n\nexport interface IIIFBrowserCreatorInitialData {\n iiifBrowserOptions?: Partial<IIIFBrowserProps>;\n}\n\nexport default function IIIFBrowserCreatorForm(props: CreatorContext) {\n const initialData: IIIFBrowserCreatorInitialData = useMemo(() => {\n return props.options.initialData || {};\n }, [props.options.initialData]);\n\n const vault = usePreviewVault();\n const output = useMemo(() => {\n return [\n {\n type: \"callback\",\n label: \"Select\",\n supportedTypes: [\"Canvas\", \"CanvasList\", \"CanvasRegion\", \"ImageService\", \"ImageServiceRegion\"],\n cb: (resource) => props.runCreate({ output: resource }),\n format: {\n type: \"custom\",\n format: (resource, parent, vault) => {\n const resourcesAsArray = Array.isArray(resource) ? resource : [{ ...resource, parent }];\n const resources = [];\n for (const resource of resourcesAsArray) {\n resources.push({\n resource: vault.get(resource),\n parent: resource.parent,\n selector: resource.selector,\n });\n }\n return resources;\n },\n },\n },\n ] as IIIFBrowserProps[\"output\"];\n }, [props.runCreate]);\n\n const navigationOptions = useMemo(() => {\n return {\n canCropImage: true,\n canSelectCanvas: true,\n canSelectManifest: false,\n canSelectCollection: false,\n // @todo fix the output so this one works.\n multiSelect: true,\n ...(initialData.iiifBrowserOptions?.navigation || {}),\n } as IIIFBrowserProps[\"navigation\"];\n }, [initialData]);\n\n const uiOptions = useMemo(() => {\n return {\n buttonClassName: \"bg-me-primary-500 text-white hover:bg-me-primary-600\",\n homeLink: `${window.location.origin}/collection.json`,\n // /collection.json\n ...(initialData.iiifBrowserOptions?.ui || {}),\n } as IIIFBrowserProps[\"ui\"];\n }, [initialData]);\n\n return (\n <PreviewVaultBoundary>\n <IIIFBrowser\n ui={uiOptions}\n vault={vault}\n className=\"iiif-browser border-none border-t rounded-none h-[70vh] min-h-[60vh] max-h-full max-w-full\"\n output={output}\n navigation={navigationOptions}\n customPages={initialData.iiifBrowserOptions?.customPages || {}}\n history={initialData.iiifBrowserOptions?.history || {}}\n />\n </PreviewVaultBoundary>\n );\n}\n"],"mappings":"sMASA,SAAwB,EAAuB,EAAuB,CACpE,IAAMA,EAA6C,MAC1C,EAAM,QAAQ,aAAe,EAAE,CACrC,CAAC,EAAM,QAAQ,YAAY,CAAC,CAEzB,EAAQ,GAAiB,CACzB,EAAS,MACN,CACL,CACE,KAAM,WACN,MAAO,SACP,eAAgB,CAAC,SAAU,aAAc,eAAgB,eAAgB,qBAAqB,CAC9F,GAAK,GAAa,EAAM,UAAU,CAAE,OAAQ,EAAU,CAAC,CACvD,OAAQ,CACN,KAAM,SACN,QAAS,EAAU,EAAQ,IAAU,CACnC,IAAM,EAAmB,MAAM,QAAQ,EAAS,CAAG,EAAW,CAAC,CAAE,GAAG,EAAU,SAAQ,CAAC,CACjF,EAAY,EAAE,CACpB,IAAK,IAAMC,KAAY,EACrB,EAAU,KAAK,CACb,SAAUC,EAAM,IAAID,EAAS,CAC7B,OAAQA,EAAS,OACjB,SAAUA,EAAS,SACpB,CAAC,CAEJ,OAAO,GAEV,CACF,CACF,CACA,CAAC,EAAM,UAAU,CAAC,CAEf,EAAoB,OACjB,CACL,aAAc,GACd,gBAAiB,GACjB,kBAAmB,GACnB,oBAAqB,GAErB,YAAa,GACb,GAAI,EAAY,oBAAoB,YAAc,EAAE,CACrD,EACA,CAAC,EAAY,CAAC,CAWjB,OACE,EAAC,EAAA,CAAA,SACC,EAAC,EAAA,CACC,GAZY,OACT,CACL,gBAAiB,uDACjB,SAAU,GAAG,OAAO,SAAS,OAAO,kBAEpC,GAAI,EAAY,oBAAoB,IAAM,EAAE,CAC7C,EACA,CAAC,EAAY,CAAC,CAMJ,QACP,UAAU,6FACF,SACR,WAAY,EACZ,YAAa,EAAY,oBAAoB,aAAe,EAAE,CAC9D,QAAS,EAAY,oBAAoB,SAAW,EAAE,EACtD,CAAA,CACmB"}
1
+ {"version":3,"file":"iiif-browser-form.lazy-B46fXhwH.js","names":["initialData: IIIFBrowserCreatorInitialData","resource","vault"],"sources":["../src/ContentResource/IIIFBrowserCreator/iiif-browser-form.lazy.tsx"],"sourcesContent":["import type { CreatorContext } from \"@manifest-editor/creator-api\";\nimport { PreviewVaultBoundary, usePreviewVault } from \"@manifest-editor/shell\";\nimport { IIIFBrowser, type IIIFBrowserProps } from \"iiif-browser\";\nimport { useMemo } from \"react\";\n\nexport interface IIIFBrowserCreatorInitialData {\n iiifBrowserOptions?: Partial<IIIFBrowserProps>;\n}\n\nexport default function IIIFBrowserCreatorForm(props: CreatorContext) {\n const initialData: IIIFBrowserCreatorInitialData = useMemo(() => {\n return props.options.initialData || {};\n }, [props.options.initialData]);\n\n const vault = usePreviewVault();\n const output = useMemo(() => {\n return [\n {\n type: \"callback\",\n label: \"Select\",\n supportedTypes: [\"Canvas\", \"CanvasList\", \"CanvasRegion\", \"ImageService\", \"ImageServiceRegion\"],\n cb: (resource) => props.runCreate({ output: resource }),\n format: {\n type: \"custom\",\n format: (resource, parent, vault) => {\n const resourcesAsArray = Array.isArray(resource) ? resource : [{ ...resource, parent }];\n const resources = [];\n for (const resource of resourcesAsArray) {\n resources.push({\n resource: vault.get(resource),\n parent: resource.parent,\n selector: resource.selector,\n });\n }\n return resources;\n },\n },\n },\n ] as IIIFBrowserProps[\"output\"];\n }, [props.runCreate]);\n\n const navigationOptions = useMemo(() => {\n return {\n canCropImage: true,\n canSelectCanvas: true,\n canSelectManifest: false,\n canSelectCollection: false,\n // @todo fix the output so this one works.\n multiSelect: true,\n ...(initialData.iiifBrowserOptions?.navigation || {}),\n } as IIIFBrowserProps[\"navigation\"];\n }, [initialData]);\n\n const uiOptions = useMemo(() => {\n return {\n buttonClassName: \"bg-me-primary-500 text-white hover:bg-me-primary-600\",\n homeLink: `${window.location.origin}/collection.json`,\n // /collection.json\n ...(initialData.iiifBrowserOptions?.ui || {}),\n } as IIIFBrowserProps[\"ui\"];\n }, [initialData]);\n\n return (\n <PreviewVaultBoundary>\n <IIIFBrowser\n ui={uiOptions}\n vault={vault}\n className=\"iiif-browser border-none border-t rounded-none h-[70vh] min-h-[60vh] max-h-full max-w-full\"\n output={output}\n navigation={navigationOptions}\n customPages={initialData.iiifBrowserOptions?.customPages || {}}\n history={initialData.iiifBrowserOptions?.history || {}}\n />\n </PreviewVaultBoundary>\n );\n}\n"],"mappings":"sMASA,SAAwB,EAAuB,EAAuB,CACpE,IAAMA,EAA6C,MAC1C,EAAM,QAAQ,aAAe,EAAE,CACrC,CAAC,EAAM,QAAQ,YAAY,CAAC,CAEzB,EAAQ,GAAiB,CACzB,EAAS,MACN,CACL,CACE,KAAM,WACN,MAAO,SACP,eAAgB,CAAC,SAAU,aAAc,eAAgB,eAAgB,qBAAqB,CAC9F,GAAK,GAAa,EAAM,UAAU,CAAE,OAAQ,EAAU,CAAC,CACvD,OAAQ,CACN,KAAM,SACN,QAAS,EAAU,EAAQ,IAAU,CACnC,IAAM,EAAmB,MAAM,QAAQ,EAAS,CAAG,EAAW,CAAC,CAAE,GAAG,EAAU,SAAQ,CAAC,CACjF,EAAY,EAAE,CACpB,IAAK,IAAMC,KAAY,EACrB,EAAU,KAAK,CACb,SAAUC,EAAM,IAAID,EAAS,CAC7B,OAAQA,EAAS,OACjB,SAAUA,EAAS,SACpB,CAAC,CAEJ,OAAO,GAEV,CACF,CACF,CACA,CAAC,EAAM,UAAU,CAAC,CAEf,EAAoB,OACjB,CACL,aAAc,GACd,gBAAiB,GACjB,kBAAmB,GACnB,oBAAqB,GAErB,YAAa,GACb,GAAI,EAAY,oBAAoB,YAAc,EAAE,CACrD,EACA,CAAC,EAAY,CAAC,CAWjB,OACE,EAAC,EAAA,CAAA,SACC,EAAC,EAAA,CACC,GAZY,OACT,CACL,gBAAiB,uDACjB,SAAU,GAAG,OAAO,SAAS,OAAO,kBAEpC,GAAI,EAAY,oBAAoB,IAAM,EAAE,CAC7C,EACA,CAAC,EAAY,CAAC,CAMJ,QACP,UAAU,6FACF,SACR,WAAY,EACZ,YAAa,EAAY,oBAAoB,aAAe,EAAE,CAC9D,QAAS,EAAY,oBAAoB,SAAW,EAAE,EACtD,CAAA,CACmB"}
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=require(`./manifest-browser-form.lazy-DqPd_M1o.cjs`);let l=require(`@manifest-editor/creator-api`),u=require(`@iiif/helpers`),d=require(`@manifest-editor/components`),f=require(`@manifest-editor/editors`),p=require(`react`);p=s(p);let m=require(`react/jsx-runtime`),h=require(`react-iiif-vault`),g=require(`styled-components`);g=s(g);let _=require(`@manifest-editor/shell`),v=require(`@iiif/parser/image-3`),y=require(`@manifest-editor/editor-api`),ee=require(`react-error-boundary`),te=require(`iiif-browser`);async function b(e,t){let n={id:e.url||t.generateId(`provider`),label:e.label,type:`Agent`,homepage:[],logo:[]};return e.homepage&&(n.homepage=[t.embed({id:e.url,label:(0,u.getValue)(e.homepageLabel)?e.homepageLabel:{en:[`Homepage`]},type:`Text`,format:`text/html`,language:[`en`]})]),e.logo&&(n.logo=[t.embed({id:e.logo,type:`Image`})]),t.embed(n)}function x(e){let t=e.options.initialData,[n,r]=(0,p.useState)(t.url||``),[i,a]=(0,p.useState)(t.label||{en:[``]}),[o,s]=(0,p.useState)(t.homepage||``),[c,l]=(0,p.useState)(t.logo||``),[u,h]=(0,p.useState)(t.homepageLabel||{en:[``]});return(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.jsxs)(`div`,{className:`max-w-xl`,children:[(0,m.jsx)(f.LanguageFieldEditor,{containerId:`label`,focusId:`label_`,label:`Label`,fields:i,onSave:e=>a(e.toInternationalString())}),(0,m.jsxs)(f.InputContainer,{$fluid:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`provider-logo`,children:`Logo`}),(0,m.jsx)(f.Input,{placeholder:`https://example.org/logo.png`,type:`text`,id:`provider-logo`,value:c,onChange:e=>l(e.target.value)})]}),(0,m.jsxs)(f.InputContainer,{$fluid:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`provider-homepage`,children:`Homepage`}),(0,m.jsx)(f.Input,{placeholder:`https://example.org/homepage`,type:`text`,id:`provider-homepage`,value:o,onChange:e=>s(e.target.value)})]}),o?(0,m.jsx)(`div`,{children:(0,m.jsx)(f.LanguageFieldEditor,{containerId:`homepageLabel`,focusId:`homepageLabel_`,label:`Homepage label`,fields:u,onSave:e=>h(e.toInternationalString())})}):null,(0,m.jsxs)(f.InputContainer,{$fluid:!0,children:[(0,m.jsx)(f.InputLabel,{$margin:!1,htmlFor:`provider-url`,children:`Provider ID`}),(0,m.jsx)(`span`,{className:`text-gray-500 text-sm mb-2`,children:`Will be generated if not specified, this is not a URL that the user can follow`}),(0,m.jsx)(f.Input,{placeholder:`https://id.loc.gov/authorities/abc123`,type:`text`,id:`provider-url`,value:n,onChange:e=>r(e.target.value)})]}),(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`button`,onPress:()=>{e.runCreate({url:n,label:i,homepage:o,homepageLabel:u,logo:c})},children:`Add provider`})]})})}const ne=(0,l.defineCreator)({id:`@manifest-editor/provider`,label:`Provider`,summary:`Create a new provider`,resourceType:`Agent`,resourceFields:[`id`,`type`,`label`],supports:{parentTypes:[`Manifest`,`Collection`],parentFields:[`provider`],initialData:!0},create:b,render(e){return(0,m.jsx)(x,{...e})}}),re=e=>(0,m.jsxs)(`svg`,{...e,viewBox:`4 4 16 16`,xmlns:`http://www.w3.org/2000/svg`,height:`1em`,width:`1em`,children:[e.title?(0,m.jsx)(`title`,{children:e.title}):null,(0,m.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,m.jsx)(`path`,{d:`M8 5v14l11-7z`,fill:`currentColor`})]}),ie=e=>(0,m.jsxs)(`svg`,{...e,viewBox:`4 4 16 16`,xmlns:`http://www.w3.org/2000/svg`,height:`1em`,width:`1em`,children:[e.title?(0,m.jsx)(`title`,{children:e.title}):null,(0,m.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,m.jsx)(`path`,{fill:`currentColor`,d:`M6 19h4V5H6v14zm8-14v14h4V5h-4z`})]}),ae=({title:e,...t})=>(0,m.jsxs)(`svg`,{...t,xmlns:`http://www.w3.org/2000/svg`,height:`1em`,width:`1em`,viewBox:`2 2 20 20`,children:[e?(0,m.jsx)(`title`,{children:e}):null,(0,m.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,m.jsx)(`path`,{fill:`currentColor`,d:`M3 9v6h4l5 5V4L7 9H3zm13.5 3A4.5 4.5 0 0 0 14 7.97v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z`})]}),oe=({title:e,...t})=>(0,m.jsxs)(`svg`,{...t,xmlns:`http://www.w3.org/2000/svg`,height:`1em`,width:`1em`,viewBox:`2 2 20 20`,children:[e?(0,m.jsx)(`title`,{children:e}):null,(0,m.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,m.jsx)(`path`,{fill:`currentColor`,d:`M18.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM5 9v6h4l5 5V4L9 9H5z`})]}),se=({title:e,...t})=>(0,m.jsxs)(`svg`,{...t,xmlns:`http://www.w3.org/2000/svg`,height:`1em`,width:`1em`,viewBox:`2 2 20 20`,children:[e?(0,m.jsx)(`title`,{children:e}):null,(0,m.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,m.jsx)(`path`,{fill:`currentColor`,d:`M16.5 12A4.5 4.5 0 0 0 14 7.97v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51A8.796 8.796 0 0 0 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3 3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06a8.99 8.99 0 0 0 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4 9.91 6.09 12 8.18V4z`})]}),ce=g.default.div`
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=require(`./manifest-browser-form.lazy-CMV49j5Z.cjs`);let l=require(`@manifest-editor/creator-api`),u=require(`@iiif/helpers`),d=require(`@manifest-editor/components`),f=require(`@manifest-editor/editors`),p=require(`react`);p=s(p);let m=require(`react/jsx-runtime`),h=require(`react-iiif-vault`),g=require(`styled-components`);g=s(g);let _=require(`@manifest-editor/shell`),v=require(`@iiif/parser/image-3`),y=require(`@manifest-editor/editor-api`),ee=require(`react-error-boundary`),te=require(`iiif-browser`);async function b(e,t){let n={id:e.url||t.generateId(`provider`),label:e.label,type:`Agent`,homepage:[],logo:[]};return e.homepage&&(n.homepage=[t.embed({id:e.url,label:(0,u.getValue)(e.homepageLabel)?e.homepageLabel:{en:[`Homepage`]},type:`Text`,format:`text/html`,language:[`en`]})]),e.logo&&(n.logo=[t.embed({id:e.logo,type:`Image`})]),t.embed(n)}function x(e){let t=e.options.initialData,[n,r]=(0,p.useState)(t.url||``),[i,a]=(0,p.useState)(t.label||{en:[``]}),[o,s]=(0,p.useState)(t.homepage||``),[c,l]=(0,p.useState)(t.logo||``),[u,h]=(0,p.useState)(t.homepageLabel||{en:[``]});return(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.jsxs)(`div`,{className:`max-w-xl`,children:[(0,m.jsx)(f.LanguageFieldEditor,{containerId:`label`,focusId:`label_`,label:`Label`,fields:i,onSave:e=>a(e.toInternationalString())}),(0,m.jsxs)(f.InputContainer,{$fluid:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`provider-logo`,children:`Logo`}),(0,m.jsx)(f.Input,{placeholder:`https://example.org/logo.png`,type:`text`,id:`provider-logo`,value:c,onChange:e=>l(e.target.value)})]}),(0,m.jsxs)(f.InputContainer,{$fluid:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`provider-homepage`,children:`Homepage`}),(0,m.jsx)(f.Input,{placeholder:`https://example.org/homepage`,type:`text`,id:`provider-homepage`,value:o,onChange:e=>s(e.target.value)})]}),o?(0,m.jsx)(`div`,{children:(0,m.jsx)(f.LanguageFieldEditor,{containerId:`homepageLabel`,focusId:`homepageLabel_`,label:`Homepage label`,fields:u,onSave:e=>h(e.toInternationalString())})}):null,(0,m.jsxs)(f.InputContainer,{$fluid:!0,children:[(0,m.jsx)(f.InputLabel,{$margin:!1,htmlFor:`provider-url`,children:`Provider ID`}),(0,m.jsx)(`span`,{className:`text-gray-500 text-sm mb-2`,children:`Will be generated if not specified, this is not a URL that the user can follow`}),(0,m.jsx)(f.Input,{placeholder:`https://id.loc.gov/authorities/abc123`,type:`text`,id:`provider-url`,value:n,onChange:e=>r(e.target.value)})]}),(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`button`,onPress:()=>{e.runCreate({url:n,label:i,homepage:o,homepageLabel:u,logo:c})},children:`Add provider`})]})})}const ne=(0,l.defineCreator)({id:`@manifest-editor/provider`,label:`Provider`,summary:`Create a new provider`,resourceType:`Agent`,resourceFields:[`id`,`type`,`label`],supports:{parentTypes:[`Manifest`,`Collection`],parentFields:[`provider`],initialData:!0},create:b,render(e){return(0,m.jsx)(x,{...e})}}),re=e=>(0,m.jsxs)(`svg`,{...e,viewBox:`4 4 16 16`,xmlns:`http://www.w3.org/2000/svg`,height:`1em`,width:`1em`,children:[e.title?(0,m.jsx)(`title`,{children:e.title}):null,(0,m.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,m.jsx)(`path`,{d:`M8 5v14l11-7z`,fill:`currentColor`})]}),ie=e=>(0,m.jsxs)(`svg`,{...e,viewBox:`4 4 16 16`,xmlns:`http://www.w3.org/2000/svg`,height:`1em`,width:`1em`,children:[e.title?(0,m.jsx)(`title`,{children:e.title}):null,(0,m.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,m.jsx)(`path`,{fill:`currentColor`,d:`M6 19h4V5H6v14zm8-14v14h4V5h-4z`})]}),ae=({title:e,...t})=>(0,m.jsxs)(`svg`,{...t,xmlns:`http://www.w3.org/2000/svg`,height:`1em`,width:`1em`,viewBox:`2 2 20 20`,children:[e?(0,m.jsx)(`title`,{children:e}):null,(0,m.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,m.jsx)(`path`,{fill:`currentColor`,d:`M3 9v6h4l5 5V4L7 9H3zm13.5 3A4.5 4.5 0 0 0 14 7.97v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z`})]}),oe=({title:e,...t})=>(0,m.jsxs)(`svg`,{...t,xmlns:`http://www.w3.org/2000/svg`,height:`1em`,width:`1em`,viewBox:`2 2 20 20`,children:[e?(0,m.jsx)(`title`,{children:e}):null,(0,m.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,m.jsx)(`path`,{fill:`currentColor`,d:`M18.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM5 9v6h4l5 5V4L9 9H5z`})]}),se=({title:e,...t})=>(0,m.jsxs)(`svg`,{...t,xmlns:`http://www.w3.org/2000/svg`,height:`1em`,width:`1em`,viewBox:`2 2 20 20`,children:[e?(0,m.jsx)(`title`,{children:e}):null,(0,m.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,m.jsx)(`path`,{fill:`currentColor`,d:`M16.5 12A4.5 4.5 0 0 0 14 7.97v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51A8.796 8.796 0 0 0 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3 3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06a8.99 8.99 0 0 0 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4 9.91 6.09 12 8.18V4z`})]}),ce=g.default.div`
2
2
  background: #ededed; // Not in variable.
3
3
  display: flex;
4
4
  padding: 0.5em;
@@ -94,4 +94,4 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
94
94
  `;function S(e){let[t,n]=(0,p.useState)(!1),{progress:r,currentTime:i,element:a}=(0,h.useMediaElements)(),{duration:o,isMuted:s,volume:c,isPlaying:l,playRequested:u}=(0,h.useMediaState)(),{setVolume:d,toggleMute:f,play:g,pause:_,setDurationPercent:v}=(0,h.useMediaActions)(),y=s||c===0?se:c>50?ae:oe;return(0,p.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,m.jsxs)(ce,{children:[(0,m.jsx)(ue,{disabled:u,onClick:()=>{l?_():g()},children:u?(0,m.jsx)(ye,{stroke:`#999`}):l?(0,m.jsx)(ie,{title:`Pause`}):(0,m.jsx)(re,{title:`Play`})}),(0,m.jsx)(de,{ref:i,children:`0:00`}),(0,m.jsxs)(fe,{onClick:e=>{let{left:t,width:n}=e.currentTarget.getBoundingClientRect();v((e.pageX-t)/n)},children:[(0,m.jsx)(me,{}),o?(0,m.jsx)(pe,{ref:r}):null]}),(0,m.jsx)(de,{children:(0,h.formatTime)(o)}),(0,m.jsxs)(ge,{onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[(0,m.jsx)(_e,{$isOpen:t,children:(0,m.jsxs)(`span`,{children:[(0,m.jsx)(xe,{htmlFor:`audio-slider`,children:`Change volume`}),(0,m.jsx)(ve,{id:`audio-slider`,role:`slider`,disabled:s,min:`0`,max:`100`,value:c,onChange:e=>d(Number(e.currentTarget.value))})]})}),(0,m.jsx)(he,{onClick:()=>f(),children:(0,m.jsx)(y,{title:s?`Mute`:`Unmute`})})]})]})}async function C(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,u.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 w(e){let[t,n]=(0,p.useState)(``),[r,i]=(0,p.useState)(0),[a,o]=(0,p.useState)(``),[s,c]=(0,p.useState)({en:[``]});return(0,p.useEffect)(()=>{if(o(``),i(0),t){let e=t.split(`/`).pop()?.split(`.`).shift();c({en:[e||``]})}},[t]),(0,m.jsxs)(d.PaddedSidebarContainer,{children:[a?(0,m.jsx)(d.ErrorMessage,{children:a}):null,(0,m.jsxs)(f.InputContainer,{$wide:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`audio-url`,children:`URL`}),(0,m.jsx)(f.Input,{type:`text`,id:`audio-url`,value:t,onChange:e=>n(e.target.value)})]}),t&&!a?(0,m.jsx)(`div`,{children:(0,m.jsx)(f.LanguageFieldEditor,{containerId:`label`,focusId:`label_`,label:`Label`,fields:s,onSave:e=>c(e.toInternationalString())},`${t}__${r}`)}):null,t&&!a?(0,m.jsx)(h.CanvasPanel.AudioHTML,{media:{url:t,duration:r,type:`Sound`},children:(0,m.jsx)(S,{onError:e=>o(e),onDuration:e=>i(~~e)},`${t}__${r}`)},`${t}__${r}`):null,r&&!a?(0,m.jsxs)(f.FormFieldWrapper,{children:[(0,m.jsx)(f.InputLabel,{htmlFor:`duration`,children:`Duration`}),(0,m.jsx)(f.Input,{type:`number`,id:`duration`,value:r,onChange:e=>i(e.target.valueAsNumber)})]}):null,(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`button`,onPress:()=>{e.runCreate({url:t,duration:r,label:s})},isDisabled:!t||!!a,children:`Add audio`})]})}const T=(0,l.defineCreator)({id:`@manifest-editor/audio-annotation`,create:C,label:`Audio`,summary:`Audio annotation`,icon:(0,m.jsx)(d.AudioIcon,{}),render(e){return(0,m.jsx)(w,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],supports:{initialData:!0,onlyPainting:!0,parentTypes:[`AnnotationPage`,`Manifest`],parentFields:[`items`]},staticFields:{type:`Annotation`}});async function E(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
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 D(e){let[t,n]=(0,_.useAnnotationCreatorState)({key:`bodyValue`,initialValue:{en:[``]},requestId:e.options.initialData?.requestId});return(0,m.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,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(f.InputContainer,{$wide:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`url`,children:`URL to Image`}),(0,m.jsx)(f.Input,{id:`url`,name:`url`,defaultValue:``,placeholder:`https://example.org/image.jpg`})]}),(0,m.jsxs)(f.InputContainer,{$wide:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`caption`,children:`Caption`}),(0,m.jsx)(f.Input,{id:`caption`,name:`caption`,placeholder:`Enter a caption`,onChange:e=>n({en:[e.target.value]}),value:t.en?.[0]||``})]}),(0,m.jsx)(d.ActionButton,{primary:!0,type:`submit`,children:`Create`})]})})}const O=(0,l.defineCreator)({id:`@manifest-editor/captioned-image-annotation`,create:E,label:`Captioned image`,summary:`Add an image from a URL with caption`,icon:(0,m.jsx)(d.AddImageIcon,{}),render(e){return(0,m.jsx)(D,{...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 k(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
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 A(e){let[t,n]=(0,_.useAnnotationCreatorState)({key:`bodyValue`,initialValue:{en:[``]},requestId:e.options.initialData?.requestId}),r=(0,u.getValue)(t).trim()===``;return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.HTMLEditor,{className:`border-none`,value:t.en?.[0]||``,onChange:e=>n({en:[e]})}),(0,m.jsx)(d.ActionButton,{primary:!0,type:`button`,onPress:()=>{e.runCreate({body:t})},isDisabled:r,children:`Create`})]})}const j=(0,l.defineCreator)({id:`@manifest-editor/html-annotation`,create:k,label:`HTML`,summary:`HTML annotation`,icon:(0,m.jsx)(d.HTMLIcon,{}),render(e){return(0,m.jsx)(A,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],supports:{initialData:!0,parentTypes:[`AnnotationPage`,`Manifest`],parentFields:[`items`]},staticFields:{type:`Annotation`}}),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)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,v.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 p=new y.EditorInstance({vault:t,reference:e}),m=(0,f.centerRectangles)(a,{width:u,height:d},.6);p.annotation.target.setPosition(m)}}},N={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 y.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 Se=Object.defineProperty,Ce=(e,t,n)=>t in e?Se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,P=(e,t,n)=>(Ce(e,typeof t==`symbol`?t:t+``,n),n);function F(e){return e.endsWith(`info.json`)?e:e.endsWith(`/`)?`${e}info.json`:`${e}/info.json`}var we=`http://library.stanford.edu/iiif/image-api/compliance.html#level0`,I=`http://library.stanford.edu/iiif/image-api/compliance.html#level1`,L=`http://library.stanford.edu/iiif/image-api/compliance.html#level2`,Te=`http://library.stanford.edu/iiif/image-api/conformance.html#level0`,Ee=`http://library.stanford.edu/iiif/image-api/conformance.html#level1`,De=`http://library.stanford.edu/iiif/image-api/conformance.html#level2`,Oe=`http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0`,ke=`http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level1`,Ae=`http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2`,je=`http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level0`,Me=`http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level1`,Ne=`http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level2`,Pe=`http://iiif.io/api/image/1/level0.json`,Fe=`http://iiif.io/api/image/1/profiles/level0.json`,Ie=`http://iiif.io/api/image/1/level1.json`,Le=`http://iiif.io/api/image/1/profiles/level1.json`,Re=`http://iiif.io/api/image/1/level2.json`,ze=`http://iiif.io/api/image/1/profiles/level2.json`,Be=`http://iiif.io/api/image/2/level0.json`,Ve=`http://iiif.io/api/image/2/profiles/level0.json`,He=`http://iiif.io/api/image/2/level1.json`,Ue=`http://iiif.io/api/image/2/profiles/level1.json`,We=`http://iiif.io/api/image/2/level2.json`,Ge=`http://iiif.io/api/image/2/profiles/level2.json`,Ke=`level0`,qe=`level1`,Je=`level2`,Ye=`http://iiif.io/api/image/2/level0`,Xe=`http://iiif.io/api/image/2/level1`,Ze=`http://iiif.io/api/image/2/level2`,Qe=[Ze,L,De,Ae,Ne,Re,ze,We,Ge,Je],$e=[...Qe,Xe,I,Ee,ke,Me,Ie,Le,He,Ue,qe],et=[Ye,Xe,Ze,we,I,L,Te,Ee,De,Oe,ke,Ae,je,Me,Ne,Pe,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,We,Ge,Ke,qe,Je],tt=et,nt={extraFormats:[`jpg`],extraQualities:[`default`],extraFeatures:[`sizeByWhListed`]},rt={extraFormats:[`jpg`],extraQualities:[`default`],extraFeatures:[`baseUriRedirect`,`cors`,`jsonldMediaType`,`regionByPx`,`regionSquare`,`sizeByWhListed`,`sizeByH`,`sizeByW`,`sizeByWh`]},it={extraFormats:[`jpg`,`png`],extraQualities:[`default`],extraFeatures:[`baseUriRedirect`,`cors`,`jsonldMediaType`,`regionByPct`,`regionByPx`,`regionSquare`,`rotationBy90s`,`sizeByWhListed`,`sizeByConfinedWh`,`sizeByH`,`sizeByPct`,`sizeByW`,`sizeByWh`]},at=[`baseUriRedirect`,`canonicalLinkHeader`,`cors`,`jsonldMediaType`,`mirroring`,`profileLinkHeader`,`regionByPct`,`regionByPx`,`regionSquare`,`rotationArbitrary`,`rotationBy90s`,`sizeByConfinedWh`,`sizeByH`,`sizeByPct`,`sizeByW`,`sizeByWh`,`sizeUpscaling`,`sizeByWhListed`,`sizeByDistortedWh`,`sizeByForcedWh`];function ot(e){return Qe.indexOf(e)===-1?$e.indexOf(e)===-1?nt:rt:it}function st(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=ot(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 ct(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 lt(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 ut(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 dt(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 ft(e,t=``){let{path:n,scheme:r,server:i,prefix:a}=dt(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:ct(u),size:lt(l),rotation:ut(c),quality:p[0],format:p[1]}}function pt(e){let t=ft(F(e.id));if(t.type!==`info`)throw Error(`Invalid service URL`);let n=st(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 mt(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 ht(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 R(e){if(e[`@id`])return e[`@id`];if(e.id)return e.id}function z(e){if(!e||!e.profile||!R(e))return!1;let t=Array.isArray(e.profile)?e.profile:[e.profile];for(let e of t)if(typeof e==`string`&&et.indexOf(e)!==-1)return!0;return!1}function gt(e){if(!z(e))return!1;let t=Array.isArray(e.profile)?e.profile:[e.profile];for(let e of t)if(typeof e==`string`){if($e.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 B(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 V(e){return z(e)?B(0,e)?0:B(1,e)?1:B(2,e)?2:null:null}function _t(e){return(e[`@context`]?Array.isArray(e[`@context`])?e[`@context`]:[e[`@context`]]:[]).indexOf(`http://iiif.io/api/image/3/context.json`)!==-1}function vt(e){if(!gt(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:R(e),type:`variable`,minWidth:0,minHeight:0,maxHeight:r.maxHeight||r.maxWidth,maxWidth:r.maxWidth||r.maxHeight,level:V(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:R(e),type:`variable`,minHeight:0,minWidth:0,maxHeight:n.height||n.width,maxWidth:n.width,level:V(e),version:_t(e)?3:2})}}return t}function yt(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 bt(e){if(e[`@type`])return e[`@type`];if(e.type)return e.type}function xt(e){if(typeof e==`string`)return yt(e);let t=bt(e);if(t!==`Image`&&t!==`sc:Image`)return null;let n=e,r=R(n);return r?r&&n.width&&n.height?{id:r,type:`fixed`,width:n.width,height:n.height,unsafe:!0}:yt(r):null}function St(e){return z(e)?(e&&e.sizes?e.sizes:[]).map(t=>({id:R(e),type:`fixed-service`,height:t.height,width:t.width,level:V(e),version:_t(e)?3:2})):[]}function Ct(e){let t=[],n=e.length;for(let r=0;r<n;r++){let n=e[r];if(!n)continue;let i=St(n);i.length&&t.push(...i);let a=vt(n);a.length&&t.push(...a)}return t}function wt(e){let t=e.service?Array.isArray(e.service)?e.service:[e.service]:[],n=t.length,r=[];for(let e=0;e<n;e++)z(t[e])&&r.push(t[e]);return r}function Tt(e,t=!0,n){let r=[],i=xt(e);if(i===null)return r;let a=e;if(r.push(i),t&&a&&a.width&&a.height){let e=[],t=wt(a);for(let r of t){let t={id:R(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(...Ct([r])))}}if(e.length)return r.push(...e),r}return a.service&&r.push(...Ct(a.service)),r}function Et({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 Dt({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 Ot(e){return`${e.mirror?`!`:``}${(e.angle||0)%360}`}function kt(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,Et(a),Dt(i),Ot(o),`${c}.${s}`].filter(Boolean).join(`/`)}function H(e,t,n){let r=pt({"@context":e.version===3?`http://iiif.io/api/image/3/context.json`:`http://iiif.io/api/image/2/context.json`,id:F(R(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:kt(r),type:`fixed`,width:t,height:n||e.height/(e.width||1)*t,unsafe:e.width>t}}function U(e){let t=e.replace(/(https?:\/\/)?(www.)?/i,``);return t.indexOf(`/`)===-1?t:t.split(`/`)[0]}function At(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 jt(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),At(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(H(t,r.width,r.height),s)):(i(()=>`Checking for an image from the tile source 3`,2),c(H(t,t.width,t.height),s))),t.type===`variable`&&t.maxWidth&&c(H({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 Mt(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 Nt(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 Pt(e){return B(0,e)}var Ft=class{constructor(e={}){P(this,`config`,{verificationsRequired:1,approximateServices:!1,enableFetching:!0,disableThrottling:!1}),P(this,`fetchingCount`,0),P(this,`imageServices`,{}),P(this,`knownImageServers`,{}),this.config=Object.assign(this.config,e)}setConfig(e){Object.assign(this.config,e)}sample(e,t,n=!0){let r=U(R(e)),i=F(R(e)),a=this.knownImageServers[r];return this.imageServices[i]=Object.assign(e,{real:!0}),!a&&e.tiles&&!Pt(e)?(this.knownImageServers[r]={verifications:0,malformed:!1,root:r,preLoaded:n,sampledId:R(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:mt(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=U(R(e)),a=this.knownImageServers[i],o=F(R(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)||Pt(e.source)?null:(this.imageServices[o]||(this.imageServices[o]={"@context":a.result.context,"@id":R(e),id:R(e),protocol:`http://iiif.io/api/image`,tiles:r?.tiles||Mt(e.width,e.height,a.result.sampledTiles),sizes:r?.sizes||ht(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 jt(t,[()=>r,()=>i])}async getImageCandidates(e,t=!0){let n=e;if(t&&n&&n.height&&n.width){let e=wt(n);for(let t of e){let e={id:R(t),width:t.width?t.width:n.width,height:t.height?t.height:n.height,source:t};await this.loadService(e)}}return Tt(e,t,this)}async verify(e){let t=this.predict(e,!1,!0),n=await this.fetchService(R(e));if(!t)return!1;let r=t.height===n.height&&t.width===n.width&&t[`@context`]===n[`@context`]&&Nt(t.sizes||[],n.sizes||[]);if(r){let t=U(R(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:R(e),n=F(t);if(this.imageServices[n])return!0;let r=this.knownImageServers[U(t)];return!!(r&&!r.malformed&&r.verifications>=this.config.verificationsRequired)}async markAsMalformed(e){return this.knownImageServers[U(R(e))].malformed=!0,this.loadService(e,!0)}async fetchService(e,t=!1){let n=F(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[U(R(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(R(e),t);return this.fetchingCount--,r.real&&this.sample(r,e),r}loadServiceSync(e){let t=F(R(e));return this.imageServices[t]?this.imageServices[t]:this.config.approximateServices?this.predict(e):null}},It=new Ft;const W={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=>z(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 Lt(e,t){let n={...e.service};n[`@id`]&&(n.id=n[`@id`]),n[`@type`]&&(n.type=n[`@type`]);let r=(0,v.createImageServiceRequest)(n),i=(0,v.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 G(e){return e.endsWith(`default.jpg`)?(0,v.imageServiceRequestToString)({...(0,v.parseImageServiceRequest)(e),type:`info`}):(0,v.canonicalServiceUrl)(e)}function K(e){let[t,n]=(0,p.useState)(``);return(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let n=new FormData(t.target),r=Object.fromEntries(n.entries()),i=r.url;if(i){let t=G(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,m.jsx)(`div`,{className:`flex gap-2 items-center`,children:(0,m.jsxs)(f.InputContainer,{$wide:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`id`,children:`Link to image service`}),(0,m.jsx)(f.Input,{id:`url`,name:`url`,defaultValue:``,onPaste:e=>{let t=e.clipboardData.getData(`text/plain`);n(t?G(t):``)},onBlur:e=>n(e.currentTarget.value?G(e.currentTarget.value):``)})]})}),(0,m.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:t.trim()?(0,m.jsx)(ee.ErrorBoundary,{fallbackRender:()=>(0,m.jsx)(`div`,{children:`Invalid service`}),children:(0,m.jsx)(Rt,{src:t},t)}):(0,m.jsx)(`div`,{className:`text-grey-600`,children:`Preview`})}),(0,m.jsx)(`div`,{children:(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`submit`,isDisabled:!t,children:`Create`})})]})})}function Rt({src:e}){let t=(0,h.useImage)({id:e},{size:{width:512}});return t?(0,m.jsx)(`div`,{className:`h-full`,children:(0,m.jsx)(`img`,{className:`w-full h-full object-contain`,src:t})}):(0,m.jsx)(ye,{})}async function zt(e,t){let n={id:t.generateId(`annotation`),type:`Annotation`},r=t.options.targetType,i=await(0,l.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,l.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 Bt(e){return(0,m.jsx)(K,{...e})}const Vt=(0,l.defineCreator)({id:`@manifest-editor/image-service-annotation`,create:zt,label:`IIIF Image`,dependencies:[`@manifest-editor/image-service-creator`],summary:`IIIF Image service`,tags:[`image`,`image-service`],icon:(0,m.jsx)(d.IIIFLogo,{style:{padding:10}}),render(e){return(0,m.jsx)(Bt,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],supports:{onlyPainting:!0,parentTypes:[`AnnotationPage`,`Manifest`],parentFields:[`items`]},sideEffects:[W,N,M],staticFields:{type:`Annotation`}});async function Ht(e,t){if(!e.height||!e.width){let t=await(0,_.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,_.getFormat)(e.url),height:e.height,width:e.width,service:e.service?Array.isArray(e.service)?e.service:[e.service]:void 0})}function q(e){return(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.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,m.jsxs)(f.InputContainer,{$wide:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`id`,children:`Link to Image`}),(0,m.jsx)(f.Input,{id:`url`,name:`url`,defaultValue:``})]}),(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`submit`,children:`Create`})]})})}async function Ut(e,t){let n={id:t.generateId(`annotation`),type:`Annotation`},r=t.options.targetType,i=await(0,l.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 Wt(e){return(0,m.jsx)(q,{...e})}const Gt=(0,l.defineCreator)({id:`@manifest-editor/image-url-annotation`,create:Ut,label:`Image`,dependencies:[`@manifest-editor/image-url-creator`],summary:`Image from URL`,tags:[`image`],icon:(0,m.jsx)(d.AddImageIcon,{}),render(e){return(0,m.jsx)(Wt,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],supports:{onlyPainting:!0,parentTypes:[`AnnotationPage`,`Manifest`],parentFields:[`items`]},sideEffects:[W,N,M],staticFields:{type:`Annotation`}});async function Kt(e,t){let n=[],r=(0,l.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 J(e){return(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.jsxs)(d.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,m.jsxs)(d.Form.InputContainer,{className:`mb-4`,children:[(0,m.jsx)(d.Form.Label,{children:`Enter a list of URLs (one per line)`}),(0,m.jsx)(d.Form.TextArea,{name:`urls`,rows:`10`})]}),(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`submit`,children:`Create`})]})})}async function qt(e,t){let n=[],r=(0,l.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 Jt=(0,l.defineCreator)({id:`@manifest-editor/image-url-list-annotation`,create:qt,label:`List of Images`,dependencies:[`@manifest-editor/image-url-annotation`],summary:`List of Images from URLs`,tags:[`image`],icon:(0,m.jsx)(d.ImageListIcon,{}),render(e){return(0,m.jsx)(J,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],supports:{onlyPainting:!0,parentTypes:[`AnnotationPage`,`Manifest`],parentFields:[`items`]},sideEffects:[W,N,M],staticFields:{type:`Annotation`}}),Yt=(0,l.defineCreator)({id:`@manifest-editor/no-body-annotation`,create:Xt,label:`Annotation without body`,summary:`Add an annotation that only has motivation and target`,icon:(0,m.jsx)(d.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 Xt(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 Zt({media:e,onError:t,duration:n,onDuration:r,onDimensions:i}){let[{element:a,currentTime:o,progress:s},c,l]=(0,h.useSimpleMediaPlayer)({duration:n});return(0,m.jsxs)(h.MediaPlayerProvider,{element:a,state:c,actions:l,currentTime:o,progress:s,children:[(0,m.jsx)(`div`,{style:{maxHeight:400,aspectRatio:`${e.width}/${e.height}`,position:`relative`},children:(0,m.jsx)(h.CanvasPanel.VideoHTML,{element:a,media:e,playPause:l.playPause})}),(0,m.jsx)(S,{onError:t,onDuration:r,onDimensions:i})]})}async function Qt(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,u.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 $t(e){let[t,n]=(0,p.useState)(``),[r,i]=(0,p.useState)(0),[a,o]=(0,p.useState)(0),[s,c]=(0,p.useState)(0),[l,u]=(0,p.useState)(``),[h,g]=(0,p.useState)({en:[``]});return(0,p.useEffect)(()=>{if(u(``),i(0),t){let e=t.split(`/`).pop()?.split(`.`).shift();g({en:[e||``]})}},[t]),(0,m.jsxs)(d.PaddedSidebarContainer,{children:[l?(0,m.jsx)(d.ErrorMessage,{children:l}):null,(0,m.jsxs)(f.InputContainer,{$wide:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`video-url`,children:`URL`}),(0,m.jsx)(f.Input,{type:`text`,id:`video-url`,value:t,onChange:e=>n(e.target.value)})]}),t&&!l?(0,m.jsx)(`div`,{children:(0,m.jsx)(f.LanguageFieldEditor,{containerId:`label`,focusId:`label_`,label:`Label`,fields:h,onSave:e=>g(e.toInternationalString())},`${t}__${r}`)}):null,t&&!l?(0,m.jsx)(`div`,{className:`mb-4 bg-black`,children:(0,m.jsx)(Zt,{duration:r,onDuration:e=>i(e),onError:e=>u(e),media:{url:t,duration:r,height:s,width:a,type:`Video`},onDimensions:(e,t)=>{o(e||0),c(t||0)}})}):null,!l&&(r||a||s)?(0,m.jsx)(f.InputContainer,{$wide:!0,children:(0,m.jsx)(f.DimensionsTriplet,{widthId:`width`,width:a||0,changeWidth:e=>o(e),heightId:`height`,height:s||0,changeHeight:e=>c(e),durationId:`duration`,duration:r||0,changeDuration:e=>i(e)})}):null,(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`button`,onPress:()=>{e.runCreate({url:t,duration:r,label:h,width:a,height:s})},isDisabled:!t||!!l,children:`Add video`})]})}const en=(0,l.defineCreator)({id:`@manifest-editor/video-annotation`,create:Qt,label:`Video`,summary:`Video annotation`,icon:(0,m.jsx)(d.VideoIcon,{}),render(e){return(0,m.jsx)($t,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],supports:{onlyPainting:!0,initialData:!0,parentTypes:[`AnnotationPage`,`Manifest`],parentFields:[`items`]},staticFields:{type:`Annotation`}}),tn=()=>(0,m.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,m.jsxs)(`g`,{children:[(0,m.jsx)(`rect`,{fill:`none`,height:`24`,width:`24`}),(0,m.jsx)(`path`,{d:`M16,20H2V4h14V20z M18,8h4V4h-4V8z M18,20h4v-4h-4V20z M18,14h4v-4h-4V14z`})]})}),nn=(0,l.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,m.jsx)(tn,{}),resourceType:`AnnotationPage`,resourceFields:[`id`,`type`,`items`],supports:{parentTypes:[`Manifest`,`Canvas`,`Range`],parentFieldMap:{Manifest:[`annotations`],Canvas:[`items`,`annotations`],Range:[`annotations`]}}}),rn=(0,l.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,m.jsx)(d.EmptyCanvasIcon,{}),resourceType:`Canvas`,resourceFields:[`id`,`type`,`label`,`height`,`width`,`items`],supports:{parentTypes:[`Manifest`],parentFields:[`items`]}});var an=process.env.NODE_ENV===`production`,Y=`Invariant failed`;function X(e,t){if(!e){if(an)throw Error(Y);var n=typeof t==`function`?t():t,r=n?`${Y}: ${n}`:Y;throw Error(r)}}const on=(0,l.defineCreator)({id:`@manifest-editor/internal-canvas`,create:cn,label:`Internal canvas link`,summary:`Canvas from the same manifest`,icon:(0,m.jsx)(tn,{}),resourceType:`Canvas`,resourceFields:[`id`,`type`,`label`],supports:{parentTypes:[`Manifest`],parentFields:[`start`]},render:e=>(0,m.jsx)(sn,{...e})});function sn(e){let t=(0,h.useManifest)(),n=(0,h.useVault)(),r=(0,p.useMemo)(()=>({canSelectCanvas:!1,canSelectCollection:!1,canSelectManifest:!0,canCropImage:!1,alwaysShowNavigationArrow:!1,multiSelect:!1}),[]),i=(0,p.useMemo)(()=>[{type:`callback`,cb:t=>e.runCreate({id:t}),label:`Select canvas`,supportedTypes:[`Canvas`],format:{type:`url`}}],[e.runCreate]),a=(0,p.useMemo)(()=>({saveToLocalStorage:!1,restoreFromLocalStorage:!1,initialHistory:[{url:t?.id,resource:t?.id,route:`/loading?id=${t?.id}`,metadata:{type:`Manifest`}}]}),[t?.id]);return X(t,`Manifest is not loaded`),(0,m.jsx)(h.VaultProvider,{vault:n,children:(0,m.jsx)(te.IIIFBrowser,{vault:n,navigation:r,output:i,history:a})})}async function cn(e,t){return t.embed({id:e.id,type:`Canvas`})}const ln=e=>(0,m.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,height:`1em`,width:`1em`,...e,children:[(0,m.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,m.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 un(e,t){return t.embed({id:t.generateId(`html/${e.language}`),language:e.language,type:`TextualBody`,format:`text/html`,value:e.body||``})}function dn(e){let{i18n:t}=(0,_.useConfig)(),[n,r]=(0,p.useState)(`<p></p>`),[i,a]=(0,p.useState)(t.defaultLanguage);return(0,m.jsxs)(d.PaddedSidebarContainer,{children:[(0,m.jsx)(d.HTMLEditor,{className:`border-none`,value:n,onChange:e=>r(e)}),(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`button`,onPress:()=>{e.runCreate({language:i,body:n})},children:`Create`})]})}const fn=(0,l.defineCreator)({id:`@manifest-editor/html-body-creator`,create:un,label:`HTML Body`,summary:`Add HTML annotation body`,icon:(0,m.jsx)(ln,{}),render(e){return(0,m.jsx)(dn,{...e})},resourceType:`ContentResource`,resourceFields:[`id`,`language`,`type`,`format`,`value`],supports:{parentTypes:[`Annotation`],parentFields:[`body`]},staticFields:{type:`TextualBody`,format:`text/html`}});function pn(e,t,n){return`${e}/${Math.floor(t.x)},${Math.floor(t.y)},${Math.floor(t.width)},${Math.floor(t.height)}/${n}/0/default.jpg`}async function mn(e,t){let n=t.options.targetType,r=e.output,i=[];for(let{resource:a,selector:o,parent:s}of r){let r=a.type,c=new u.Vault;if((n===`Canvas`||n===`Annotation`||n===`ContentResource`)&&r===`Canvas`){let r=a.id,l=s?.type===`Manifest`?s.id:void 0;X(l,`Could not find Manifest`);let u=c.get({id:l,type:`Manifest`})||await c.loadManifest(l);X(u,`Manifest not found`);let d=u.items.find(e=>e.id===r);X(d,`Canvas not found`);let f=c.get(d);if(n===`Canvas`&&o?.type!==`BoxSelector`){let e=c.toPresentation3(f);e.label||(e.label={en:[`Untitled canvas`]}),console.log(`loading full canvas`,e),t.vault.loadSync(e.id,e),i.push(t.embed({id:e.id,type:`Canvas`}));continue}let p=c.get(f.items[0]),m=c.get(p.items[0]);if(n===`Annotation`||n===`Canvas`||n===`ContentResource`){let r=c.toPresentation3(m);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,v.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(o?.type===`BoxSelector`){let s={type:`ImageApiSelector`,region:[~~o.spatial.x,~~o.spatial.y,~~o.spatial.width,~~o.spatial.height].join(`,`)},c={...r.body},l=``;if(a){let e=a.id||a[`@id`]||``;e&&(c.id=pn(e,o.spatial,`max`),l=pn(e,o.spatial,`512,`))}if(r.body={id:t.generateId(`SpecificResource`,m),type:`SpecificResource`,source:c,selector:s},e.trackSize&&e.trackSize({width:~~o.spatial.width,height:~~o.spatial.height}),n===`ContentResource`){i.push(r.body);continue}if(n===`Canvas`){let e=t.generateId(`Canvas`,m);r.target=e;let n=t.generateId(`Page`,m),a=t.embed({id:n,type:`AnnotationPage`,items:[r]});i.push(t.embed({id:e,type:`Canvas`,label:{en:[`Untitled canvas`]},width:~~o.spatial.width,height:~~o.spatial.height,thumbnail:l?[t.embed({id:l,type:`Image`,format:`image/jpeg`,width:512,height:Math.round(o.spatial.height/o.spatial.width*512)})]:void 0,items:[a]}));continue}i.push(t.embed({...r,target:t.getTarget()}));continue}i.push(t.embed({...r,target:t.getTarget()}))}}}return i}const hn=(0,p.lazy)(()=>Promise.resolve().then(()=>require(`./iiif-browser-form.lazy-ByLpHski.cjs`))),gn=(0,l.defineCreator)({id:`@manifest-editor/iiif-browser-creator`,create:mn,label:`IIIF Browser`,summary:`Browse IIIF Resources`,icon:(0,m.jsx)(d.IIIFBrowserIcon,{}),render(e){return(0,m.jsx)(hn,{...e})},hiddenModal:!0,tags:[`image`,`image-service`],resourceType:`ContentResource`,resourceFields:[`id`,`language`,`type`,`format`,`value`],additionalTypes:[`Annotation`,`Canvas`],supports:{onlyPainting:!0,parentTypes:[`Annotation`,`Manifest`,`AnnotationPage`],parentFields:[`body`,`items`],parentFieldMap:{Annotation:[`body`],Manifest:[`items`],AnnotationPage:[`items`]}},sideEffects:[W,N,M],staticFields:{}}),_n=(0,l.defineCreator)({id:`@manifest-editor/image-service-creator`,create:Lt,label:`Image Service`,summary:`Add an image from Image Service`,icon:(0,m.jsx)(d.IIIFLogo,{style:{padding:10}}),render(e){return(0,m.jsx)(K,{...e})},resourceType:`ContentResource`,resourceFields:[`id`,`type`,`height`,`width`,`format`,`service`],supports:{parentFields:[`logo`,`body`,`thumbnail`]}}),vn=(0,l.defineCreator)({id:`@manifest-editor/image-url-creator`,create:Ht,label:`Image`,summary:`Image from a URL`,icon:(0,m.jsx)(d.AddImageIcon,{}),render(e){return(0,m.jsx)(q,{...e})},resourceType:`ContentResource`,resourceFields:[`format`],supports:{parentFields:[`logo`,`body`,`thumbnail`]},staticFields:{type:`Image`}}),yn=(0,l.defineCreator)({id:`@manifest-editor/image-url-list`,label:`Image URL List`,summary:`Image from a list of URLs`,create:Kt,icon:(0,m.jsx)(d.ImageListIcon,{}),render(e){return(0,m.jsx)(J,{...e})},resourceType:`ContentResource`,resourceFields:[`format`],supports:{parentFields:[`logo`,`body`,`thumbnail`]},staticFields:{type:`Image`}});async function bn(e,t){return t.embed({id:e.url,type:`Text`,label:e.label,format:`text/plain`})}function xn(e){let[t,n]=(0,p.useState)({en:[`View as text`]});return(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.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,m.jsx)(f.LanguageFieldEditor,{focusId:`label`,label:`Label`,fields:t,onSave:e=>n(e.toInternationalString())}),(0,m.jsxs)(f.InputContainer,{$wide:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`id`,children:`Link to plaintext`}),(0,m.jsx)(f.Input,{id:`url`,name:`url`,defaultValue:``})]}),(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`submit`,children:`Create`})]})})}const Sn=(0,l.defineCreator)({id:`@manifest-editor/plaintext-creator`,create:bn,label:`Plaintext`,summary:`Add link to an plaintext`,icon:(0,m.jsx)(ln,{}),render(e){return(0,m.jsx)(xn,{...e})},resourceType:`ContentResource`,resourceFields:[`label`,`format`],supports:{parentFields:[`seeAlso`,`rendering`,`homepage`]},staticFields:{format:`text/plain`}});function Cn(e,t){e[`@id`]&&(e.id=e[`@id`]),e[`@type`]&&(e.type=e[`@type`]);let n=(0,v.createImageServiceRequest)(e);return(0,v.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 Z(e){return e.endsWith(`default.jpg`)?(0,v.imageServiceRequestToString)({...(0,v.parseImageServiceRequest)(e),type:`info`}):(0,v.canonicalServiceUrl)(e)}async function wn(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=Cn(n,a);return t.embed({id:e,type:`Image`,format:`image/jpeg`,width:a.width,height:a.height})}}return null}function Tn(e){let[t,n]=(0,p.useState)(``),[r,i]=(0,p.useState)(null),[a,o]=(0,p.useState)({width:0,height:0}),s=(0,p.useMemo)(()=>!r||!a.width||!a.height?null:Cn(r,a),[a,r]);return r?(0,m.jsxs)(d.PaddedSidebarContainer,{children:[(0,m.jsxs)(`div`,{className:`mb-4`,children:[(0,m.jsx)(`div`,{className:`mb-2`,children:r[`@id`]||r.id}),(0,m.jsx)(`div`,{className:`flex gap-2 mb-4`,children:r.sizes?.map(e=>{let t=e.width===a.width;return(0,m.jsxs)(d.ActionButton,{primary:t,isDisabled:t,large:!0,onPress:()=>o(e),children:[e.width,`x`,e.height]},e.width)})}),s?(0,m.jsx)(`img`,{src:s,alt:`preview of selected resource`}):null]}),(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,isDisabled:!s,onPress:()=>{r&&e.runCreate({service:r,width:a.width,height:a.height})},children:`Add thumbnail`})]}):(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let t=new FormData(e.target),n=Object.fromEntries(t.entries()).url;if(n){let e=Z(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,m.jsx)(`div`,{className:`flex gap-2 items-center`,children:(0,m.jsxs)(f.InputContainer,{$wide:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`id`,children:`Link to image service`}),(0,m.jsx)(f.Input,{id:`url`,name:`url`,defaultValue:``,onPaste:e=>{let t=e.clipboardData.getData(`text/plain`);n(t?Z(t):``)},onBlur:e=>n(e.currentTarget.value?Z(e.currentTarget.value):``)})]})}),(0,m.jsx)(`div`,{children:(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`submit`,isDisabled:!t,children:`Select size`})})]})})}const En=(0,l.defineCreator)({id:`@manifest-editor/thumbnail-image`,create:wn,label:`Thumbnail from service`,summary:`Add thumbnail from an image service`,icon:(0,m.jsx)(d.ScaledImageIcon,{}),render(e){return(0,m.jsx)(Tn,{...e})},resourceType:`ContentResource`,resourceFields:[`id`,`type`,`format`],supports:{parentFields:[`thumbnail`]}});function Dn(){return(0,m.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`24px`,viewBox:`0 0 24 24`,width:`24px`,fill:`#000000`,children:[(0,m.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,m.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 Q(e,t){return t.embed({id:e.url,type:`Text`,label:e.label,format:`text/html`})}function On(e){let[t,n]=(0,p.useState)({en:[``]});return(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.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,m.jsx)(f.LanguageFieldEditor,{focusId:`label`,label:`Label`,fields:t,onSave:e=>n(e.toInternationalString())}),(0,m.jsxs)(f.InputContainer,{$wide:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`id`,children:`Link`}),(0,m.jsx)(f.Input,{id:`url`,name:`url`,defaultValue:``})]}),(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`submit`,children:`Create link`})]})})}const kn=(0,l.defineCreator)({id:`@manifest-editor/web-page-creator`,create:Q,label:`Web page`,summary:`Add link to an external web page`,icon:(0,m.jsx)(Dn,{}),render(e){return(0,m.jsx)(On,{...e})},resourceType:`ContentResource`,resourceFields:[`label`,`format`],supports:{parentFields:[`seeAlso`,`rendering`,`homepage`]}}),An=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function $(e){let t=(e||``).match(An);return t?t[1]:null}function jn(e){return!!$(e.youtubeUrl)}async function Mn(e,t){let n=$(e.youtubeUrl),r=t.embed({id:`https://www.youtube.com/watch?v=${n}`,type:`Video`,service:[{profile:`http://digirati.com/objectifier`,params:{data:`https://www.youtube.com/embed/${n}`}},{id:`https://www.youtube.com/watch?v=${n}`,profile:`https://www.youtube.com`}]});if(t.options.targetType===`Canvas`){let n=t.generateId(`canvas`),i=t.generateId(`annotation-page`,{id:n,type:`Canvas`}),a=t.embed({id:t.generateId(`annotation`,{id:i,type:`AnnotationPage`}),type:`Annotation`,motivation:`painting`,body:[r],target:{type:`SpecificResource`,source:{id:n,type:`Canvas`}}}),o=t.embed({id:i,type:`AnnotationPage`,items:[a]});return t.embed({id:n,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:[r],target:t.getTarget()}):r}function Nn(e){return(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.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,m.jsxs)(f.InputContainer,{$wide:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`id`,children:`Link to YouTube`}),(0,m.jsx)(f.Input,{id:`youtubeUrl`,name:`youtubeUrl`,defaultValue:``})]}),(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`submit`,children:`Create`})]})})}const Pn=(0,l.defineCreator)({id:`@manifest-editor/youtube`,create:Mn,label:`YouTube`,summary:`Embed YouTube`,icon:(0,m.jsx)(d.YouTubeIcon,{}),resourceType:`ContentResource`,additionalTypes:[`Canvas`,`Annotation`],resourceFields:[`id`,`type`,`service`],render:e=>(0,m.jsx)(Nn,{...e}),supports:{onlyPainting:!0,parentTypes:[`Annotation`,`Manifest`,`AnnotationPage`],parentFieldMap:{Annotation:[`body`],Manifest:[`items`],AnnotationPage:[`items`]}},staticFields:{type:`Video`}});async function Fn(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,u.createThumbnailHelper)(o);if(n.type===`Manifest`){let e=n.id;X(e,`Could not find Manifest ID`);let i=await o.loadManifest(e),a=await s.getBestThumbnailAtSize(i,{width:256,height:256},!1);X(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;X(e,`Could not find Manifest ID`);let i=await o.loadManifest(e);X(i,`Collection not found`),r.push(t.embed({id:n.id,type:`Collection`,label:i.label}))}}return r}const In=(0,p.lazy)(()=>Promise.resolve().then(()=>require(`./manifest-browser-form.lazy-BJxkvzpe.cjs`))),Ln=(0,l.defineCreator)({id:`@manifest-editor/manifest-browser-creator`,create:Fn,label:`IIIF Browser`,summary:`Browse IIIF Resources`,icon:(0,m.jsx)(d.IIIFBrowserIcon,{}),render(e){return(0,m.jsx)(c.t,{...e})},resourceType:`Manifest`,resourceFields:[`id`,`label`],additionalTypes:[`Collection`],supports:{parentTypes:[`Collection`],parentFieldMap:{Collection:[`items`]}},sideEffects:[],staticFields:{}});async function Rn(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 zn(e){let[t,n]=(0,p.useState)({en:[``]});return(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.jsxs)(`form`,{onSubmit:n=>{n.preventDefault(),t&&e.runCreate({type:`Range`,label:t})},children:[(0,m.jsx)(f.LanguageFieldEditor,{focusId:`label`,label:`Label`,fields:t,onSave:e=>n(e.toInternationalString())}),(0,m.jsx)(d.ActionButton,{primary:!0,type:`submit`,children:`Create range`})]})})}const Bn=(0,l.defineCreator)({id:`@manifest-editor/range-with-items`,create:Rn,label:`Range`,summary:`Add a new range`,icon:(0,m.jsx)(d.RangesIcon,{}),render(e){return(0,m.jsx)(zn,{...e})},resourceType:`Range`,resourceFields:[`id`,`label`,`type`],supports:{parentTypes:[`Range`],parentFields:[`items`]},staticFields:{type:`Range`}});async function Vn(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 Hn(e){let[t,n]=(0,p.useState)({en:[``]});return(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.jsxs)(`form`,{onSubmit:n=>{n.preventDefault(),t&&e.runCreate({type:`Range`,label:t})},children:[(0,m.jsx)(f.LanguageFieldEditor,{focusId:`label`,label:`Label`,fields:t,onSave:e=>n(e.toInternationalString())}),(0,m.jsx)(d.ActionButton,{primary:!0,type:`submit`,children:`Create range`})]})})}const Un=(0,l.defineCreator)({id:`@manifest-editor/range-top-level`,create:Vn,label:`Top Level Range`,summary:`Add a new top level range`,icon:(0,m.jsx)(d.RangesIcon,{}),render(e){return(0,m.jsx)(Hn,{...e})},resourceType:`Range`,resourceFields:[`id`,`label`,`type`],supports:{parentTypes:[`Manifest`],parentFields:[`structures`]},staticFields:{type:`Range`}}),Wn=[_n,Vt,vn,Gt,en,T,fn,j,Pn,gn,rn,Sn,kn,nn,Yt,on,O,yn,Jt,En,Un,Bn,ne];exports.CreateAudioAnnotationForm=w,exports.CreateCaptionedImageAnnotation=D,exports.CreateHTMLAnnotation=A,exports.CreateHTMLBodyForm=dn,exports.CreateImageServerForm=K,exports.CreateImageServiceAnnotationForm=Bt,exports.CreateImageUrlAnnotationForm=Wt,exports.CreateImageUrlForm=q,exports.CreateImageUrlListForm=J,exports.CreatePlaintextForm=xn,exports.CreateProviderForm=x,exports.CreateThumbnailForm=Tn,exports.CreateVideoAnnotationForm=$t,exports.CreateWebPageForm=On,exports.IIIFBrowserCreatorForm=hn,exports.ManifestBrowserCreatorForm=In,exports.RangeWithItemsCreatorForm=zn,exports.TopLevelRangeCreatorForm=Hn,exports.YouTubeForm=Nn,exports.allCreators=Wn,exports.audioAnnotation=T,exports.captionedImageAnnotation=O,exports.createAudioAnnotation=C,exports.createCaptionedImageAnnotation=E,exports.createFromIIIFBrowserOutput=mn,exports.createFromManifestBrowserOutput=Fn,exports.createHtmlAnnotation=k,exports.createHtmlBody=un,exports.createImageServer=Lt,exports.createImageServiceAnnotation=zt,exports.createImageUrl=Ht,exports.createImageUrlAnnotation=Ut,exports.createImageUrlList=Kt,exports.createImageUrlListAnnotation=qt,exports.createNoBodyAnnotation=Xt,exports.createPlaintext=bn,exports.createProvider=b,exports.createRangeTopLevel=Vn,exports.createRangeWithItems=Rn,exports.createThumbnail=wn,exports.createVideoAnnotation=Qt,exports.createWebPage=Q,exports.createYoutubeBody=Mn,exports.emptyAnnotationPage=nn,exports.emptyCanvas=rn,exports.getYouTubeId=$,exports.htmlAnnotation=j,exports.htmlBodyCreator=fn,exports.iiifBrowserCreator=gn,exports.imageServiceAnnotation=Vt,exports.imageServiceCreator=_n,exports.imageUrlAnnotation=Gt,exports.imageUrlCreator=vn,exports.imageUrlListAnnotation=Jt,exports.imageUrlListCreator=yn,exports.internalCanvas=on,exports.manifestBrowserCreator=Ln,exports.noBodyAnnotation=Yt,exports.plaintextCreator=Sn,exports.providerCreator=ne,exports.rangeTopLevel=Un,exports.rangeWithItems=Bn,exports.t=s,exports.validateYouTube=jn,exports.videoAnnotation=en,exports.webPageCreator=kn,exports.youTubeBodyCreator=Pn;
97
+ `).map(e=>({url:e}))})},children:[(0,m.jsxs)(d.Form.InputContainer,{className:`mb-4`,children:[(0,m.jsx)(d.Form.Label,{children:`Enter a list of URLs (one per line)`}),(0,m.jsx)(d.Form.TextArea,{name:`urls`,rows:`10`})]}),(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`submit`,children:`Create`})]})})}async function qt(e,t){let n=[],r=(0,l.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 Jt=(0,l.defineCreator)({id:`@manifest-editor/image-url-list-annotation`,create:qt,label:`List of Images`,dependencies:[`@manifest-editor/image-url-annotation`],summary:`List of Images from URLs`,tags:[`image`],icon:(0,m.jsx)(d.ImageListIcon,{}),render(e){return(0,m.jsx)(J,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],supports:{onlyPainting:!0,parentTypes:[`AnnotationPage`,`Manifest`],parentFields:[`items`]},sideEffects:[W,N,M],staticFields:{type:`Annotation`}}),Yt=(0,l.defineCreator)({id:`@manifest-editor/no-body-annotation`,create:Xt,label:`Annotation without body`,summary:`Add an annotation that only has motivation and target`,icon:(0,m.jsx)(d.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 Xt(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 Zt({media:e,onError:t,duration:n,onDuration:r,onDimensions:i}){let[{element:a,currentTime:o,progress:s},c,l]=(0,h.useSimpleMediaPlayer)({duration:n});return(0,m.jsxs)(h.MediaPlayerProvider,{element:a,state:c,actions:l,currentTime:o,progress:s,children:[(0,m.jsx)(`div`,{style:{maxHeight:400,aspectRatio:`${e.width}/${e.height}`,position:`relative`},children:(0,m.jsx)(h.CanvasPanel.VideoHTML,{element:a,media:e,playPause:l.playPause})}),(0,m.jsx)(S,{onError:t,onDuration:r,onDimensions:i})]})}async function Qt(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,u.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 $t(e){let[t,n]=(0,p.useState)(``),[r,i]=(0,p.useState)(0),[a,o]=(0,p.useState)(0),[s,c]=(0,p.useState)(0),[l,u]=(0,p.useState)(``),[h,g]=(0,p.useState)({en:[``]});return(0,p.useEffect)(()=>{if(u(``),i(0),t){let e=t.split(`/`).pop()?.split(`.`).shift();g({en:[e||``]})}},[t]),(0,m.jsxs)(d.PaddedSidebarContainer,{children:[l?(0,m.jsx)(d.ErrorMessage,{children:l}):null,(0,m.jsxs)(f.InputContainer,{$wide:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`video-url`,children:`URL`}),(0,m.jsx)(f.Input,{type:`text`,id:`video-url`,value:t,onChange:e=>n(e.target.value)})]}),t&&!l?(0,m.jsx)(`div`,{children:(0,m.jsx)(f.LanguageFieldEditor,{containerId:`label`,focusId:`label_`,label:`Label`,fields:h,onSave:e=>g(e.toInternationalString())},`${t}__${r}`)}):null,t&&!l?(0,m.jsx)(`div`,{className:`mb-4 bg-black`,children:(0,m.jsx)(Zt,{duration:r,onDuration:e=>i(e),onError:e=>u(e),media:{url:t,duration:r,height:s,width:a,type:`Video`},onDimensions:(e,t)=>{o(e||0),c(t||0)}})}):null,!l&&(r||a||s)?(0,m.jsx)(f.InputContainer,{$wide:!0,children:(0,m.jsx)(f.DimensionsTriplet,{widthId:`width`,width:a||0,changeWidth:e=>o(e),heightId:`height`,height:s||0,changeHeight:e=>c(e),durationId:`duration`,duration:r||0,changeDuration:e=>i(e)})}):null,(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`button`,onPress:()=>{e.runCreate({url:t,duration:r,label:h,width:a,height:s})},isDisabled:!t||!!l,children:`Add video`})]})}const en=(0,l.defineCreator)({id:`@manifest-editor/video-annotation`,create:Qt,label:`Video`,summary:`Video annotation`,icon:(0,m.jsx)(d.VideoIcon,{}),render(e){return(0,m.jsx)($t,{...e})},resourceType:`Annotation`,resourceFields:[`id`,`type`,`motivation`,`body`,`target`],additionalTypes:[`Canvas`],supports:{onlyPainting:!0,initialData:!0,parentTypes:[`AnnotationPage`,`Manifest`],parentFields:[`items`]},staticFields:{type:`Annotation`}}),tn=()=>(0,m.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,m.jsxs)(`g`,{children:[(0,m.jsx)(`rect`,{fill:`none`,height:`24`,width:`24`}),(0,m.jsx)(`path`,{d:`M16,20H2V4h14V20z M18,8h4V4h-4V8z M18,20h4v-4h-4V20z M18,14h4v-4h-4V14z`})]})}),nn=(0,l.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,m.jsx)(tn,{}),resourceType:`AnnotationPage`,resourceFields:[`id`,`type`,`items`],supports:{parentTypes:[`Manifest`,`Canvas`,`Range`],parentFieldMap:{Manifest:[`annotations`],Canvas:[`items`,`annotations`],Range:[`annotations`]}}}),rn=(0,l.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,m.jsx)(d.EmptyCanvasIcon,{}),resourceType:`Canvas`,resourceFields:[`id`,`type`,`label`,`height`,`width`,`items`],supports:{parentTypes:[`Manifest`],parentFields:[`items`]}});var an=process.env.NODE_ENV===`production`,Y=`Invariant failed`;function X(e,t){if(!e){if(an)throw Error(Y);var n=typeof t==`function`?t():t,r=n?`${Y}: ${n}`:Y;throw Error(r)}}const on=(0,l.defineCreator)({id:`@manifest-editor/internal-canvas`,create:cn,label:`Internal canvas link`,summary:`Canvas from the same manifest`,icon:(0,m.jsx)(tn,{}),resourceType:`Canvas`,resourceFields:[`id`,`type`,`label`],supports:{parentTypes:[`Manifest`],parentFields:[`start`]},render:e=>(0,m.jsx)(sn,{...e})});function sn(e){let t=(0,h.useManifest)(),n=(0,h.useVault)(),r=(0,p.useMemo)(()=>({canSelectCanvas:!1,canSelectCollection:!1,canSelectManifest:!0,canCropImage:!1,alwaysShowNavigationArrow:!1,multiSelect:!1}),[]),i=(0,p.useMemo)(()=>[{type:`callback`,cb:t=>e.runCreate({id:t}),label:`Select canvas`,supportedTypes:[`Canvas`],format:{type:`url`}}],[e.runCreate]),a=(0,p.useMemo)(()=>({saveToLocalStorage:!1,restoreFromLocalStorage:!1,initialHistory:[{url:t?.id,resource:t?.id,route:`/loading?id=${t?.id}`,metadata:{type:`Manifest`}}]}),[t?.id]);return X(t,`Manifest is not loaded`),(0,m.jsx)(h.VaultProvider,{vault:n,children:(0,m.jsx)(te.IIIFBrowser,{vault:n,navigation:r,output:i,history:a})})}async function cn(e,t){return t.embed({id:e.id,type:`Canvas`})}const ln=e=>(0,m.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,height:`1em`,width:`1em`,...e,children:[(0,m.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,m.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 un(e,t){return t.embed({id:t.generateId(`html/${e.language}`),language:e.language,type:`TextualBody`,format:`text/html`,value:e.body||``})}function dn(e){let{i18n:t}=(0,_.useConfig)(),[n,r]=(0,p.useState)(`<p></p>`),[i,a]=(0,p.useState)(t.defaultLanguage);return(0,m.jsxs)(d.PaddedSidebarContainer,{children:[(0,m.jsx)(d.HTMLEditor,{className:`border-none`,value:n,onChange:e=>r(e)}),(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`button`,onPress:()=>{e.runCreate({language:i,body:n})},children:`Create`})]})}const fn=(0,l.defineCreator)({id:`@manifest-editor/html-body-creator`,create:un,label:`HTML Body`,summary:`Add HTML annotation body`,icon:(0,m.jsx)(ln,{}),render(e){return(0,m.jsx)(dn,{...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 pn(e,t,n){return`${e}/${Math.floor(t.x)},${Math.floor(t.y)},${Math.floor(t.width)},${Math.floor(t.height)}/${n}/0/default.jpg`}async function mn(e,t){let n=t.options.targetType,r=e.output,i=[];for(let{resource:a,selector:o,parent:s}of r){let r=a.type,c=new u.Vault;if((n===`Canvas`||n===`Annotation`||n===`ContentResource`)&&r===`Canvas`){let r=a.id,l=s?.type===`Manifest`?s.id:void 0;X(l,`Could not find Manifest`);let u=c.get({id:l,type:`Manifest`})||await c.loadManifest(l);X(u,`Manifest not found`);let d=u.items.find(e=>e.id===r);X(d,`Canvas not found`);let f=c.get(d);if(n===`Canvas`&&o?.type!==`BoxSelector`){let e=c.toPresentation3(f);e.label||(e.label={en:[`Untitled canvas`]}),t.vault.loadSync(e.id,e),i.push(t.embed({id:e.id,type:`Canvas`}));continue}let p=c.get(f.items[0]),m=c.get(p.items[0]);if(n===`Annotation`||n===`Canvas`||n===`ContentResource`){let r=c.toPresentation3(m);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,v.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(o?.type===`BoxSelector`){let s={type:`ImageApiSelector`,region:[~~o.spatial.x,~~o.spatial.y,~~o.spatial.width,~~o.spatial.height].join(`,`)},c={...r.body},l=``;if(a){let e=a.id||a[`@id`]||``;e&&(c.id=pn(e,o.spatial,`max`),l=pn(e,o.spatial,`512,`))}if(r.body={id:t.generateId(`SpecificResource`,m),type:`SpecificResource`,source:c,selector:s},e.trackSize&&e.trackSize({width:~~o.spatial.width,height:~~o.spatial.height}),n===`ContentResource`){i.push(r.body);continue}if(n===`Canvas`){let e=t.generateId(`Canvas`,m);r.target=e;let n=t.generateId(`Page`,m),a=t.embed({id:n,type:`AnnotationPage`,items:[r]});i.push(t.embed({id:e,type:`Canvas`,label:{en:[`Untitled canvas`]},width:~~o.spatial.width,height:~~o.spatial.height,thumbnail:l?[t.embed({id:l,type:`Image`,format:`image/jpeg`,width:512,height:Math.round(o.spatial.height/o.spatial.width*512)})]:void 0,items:[a]}));continue}i.push(t.embed({...r,target:t.getTarget()}));continue}i.push(t.embed({...r,target:t.getTarget()}))}}}return i}const hn=(0,p.lazy)(()=>Promise.resolve().then(()=>require(`./iiif-browser-form.lazy-CR8KA-qD.cjs`))),gn=(0,l.defineCreator)({id:`@manifest-editor/iiif-browser-creator`,create:mn,label:`IIIF Browser`,summary:`Browse IIIF Resources`,icon:(0,m.jsx)(d.IIIFBrowserIcon,{}),render(e){return(0,m.jsx)(hn,{...e})},hiddenModal:!0,tags:[`image`,`image-service`],resourceType:`ContentResource`,resourceFields:[`id`,`language`,`type`,`format`,`value`],additionalTypes:[`Annotation`,`Canvas`],supports:{onlyPainting:!0,parentTypes:[`Annotation`,`Manifest`,`AnnotationPage`],parentFields:[`body`,`items`],parentFieldMap:{Annotation:[`body`],Manifest:[`items`],AnnotationPage:[`items`]}},sideEffects:[W,N,M],staticFields:{}}),_n=(0,l.defineCreator)({id:`@manifest-editor/image-service-creator`,create:Lt,label:`Image Service`,summary:`Add an image from Image Service`,icon:(0,m.jsx)(d.IIIFLogo,{style:{padding:10}}),tags:[`image`,`image-service`],render(e){return(0,m.jsx)(K,{...e})},resourceType:`ContentResource`,resourceFields:[`id`,`type`,`height`,`width`,`format`,`service`],supports:{parentFields:[`logo`,`body`,`thumbnail`,`items`],custom(e,t){return e.property===`items`?e.resource.type===`ContentResource`?t.get(e.resource,{skipSelfReturn:!1})?.type===`Choice`:!1:!0}}}),vn=(0,l.defineCreator)({id:`@manifest-editor/image-url-creator`,create:Ht,label:`Image`,summary:`Image from a URL`,icon:(0,m.jsx)(d.AddImageIcon,{}),tags:[`image`],render(e){return(0,m.jsx)(q,{...e})},resourceType:`ContentResource`,resourceFields:[`format`],supports:{parentFields:[`logo`,`body`,`thumbnail`,`items`],custom(e,t){return e.property===`items`?e.resource.type===`ContentResource`?t.get(e.resource,{skipSelfReturn:!1})?.type===`Choice`:!1:!0}},staticFields:{type:`Image`}}),yn=(0,l.defineCreator)({id:`@manifest-editor/image-url-list`,label:`Image URL List`,summary:`Image from a list of URLs`,create:Kt,icon:(0,m.jsx)(d.ImageListIcon,{}),render(e){return(0,m.jsx)(J,{...e})},resourceType:`ContentResource`,resourceFields:[`format`],supports:{parentFields:[`logo`,`body`,`thumbnail`]},staticFields:{type:`Image`}});async function bn(e,t){return t.embed({id:e.url,type:`Text`,label:e.label,format:`text/plain`})}function xn(e){let[t,n]=(0,p.useState)({en:[`View as text`]});return(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.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,m.jsx)(f.LanguageFieldEditor,{focusId:`label`,label:`Label`,fields:t,onSave:e=>n(e.toInternationalString())}),(0,m.jsxs)(f.InputContainer,{$wide:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`id`,children:`Link to plaintext`}),(0,m.jsx)(f.Input,{id:`url`,name:`url`,defaultValue:``})]}),(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`submit`,children:`Create`})]})})}const Sn=(0,l.defineCreator)({id:`@manifest-editor/plaintext-creator`,create:bn,label:`Plaintext`,summary:`Add link to an plaintext`,icon:(0,m.jsx)(ln,{}),render(e){return(0,m.jsx)(xn,{...e})},resourceType:`ContentResource`,resourceFields:[`label`,`format`],supports:{parentFields:[`seeAlso`,`rendering`,`homepage`]},staticFields:{format:`text/plain`}});function Cn(e,t){e[`@id`]&&(e.id=e[`@id`]),e[`@type`]&&(e.type=e[`@type`]);let n=(0,v.createImageServiceRequest)(e);return(0,v.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 Z(e){return e.endsWith(`default.jpg`)?(0,v.imageServiceRequestToString)({...(0,v.parseImageServiceRequest)(e),type:`info`}):(0,v.canonicalServiceUrl)(e)}async function wn(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=Cn(n,a);return t.embed({id:e,type:`Image`,format:`image/jpeg`,width:a.width,height:a.height})}}return null}function Tn(e){let[t,n]=(0,p.useState)(``),[r,i]=(0,p.useState)(null),[a,o]=(0,p.useState)({width:0,height:0}),s=(0,p.useMemo)(()=>!r||!a.width||!a.height?null:Cn(r,a),[a,r]);return r?(0,m.jsxs)(d.PaddedSidebarContainer,{children:[(0,m.jsxs)(`div`,{className:`mb-4`,children:[(0,m.jsx)(`div`,{className:`mb-2`,children:r[`@id`]||r.id}),(0,m.jsx)(`div`,{className:`flex gap-2 mb-4`,children:r.sizes?.map(e=>{let t=e.width===a.width;return(0,m.jsxs)(d.ActionButton,{primary:t,isDisabled:t,large:!0,onPress:()=>o(e),children:[e.width,`x`,e.height]},e.width)})}),s?(0,m.jsx)(`img`,{src:s,alt:`preview of selected resource`}):null]}),(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,isDisabled:!s,onPress:()=>{r&&e.runCreate({service:r,width:a.width,height:a.height})},children:`Add thumbnail`})]}):(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let t=new FormData(e.target),n=Object.fromEntries(t.entries()).url;if(n){let e=Z(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,m.jsx)(`div`,{className:`flex gap-2 items-center`,children:(0,m.jsxs)(f.InputContainer,{$wide:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`id`,children:`Link to image service`}),(0,m.jsx)(f.Input,{id:`url`,name:`url`,defaultValue:``,onPaste:e=>{let t=e.clipboardData.getData(`text/plain`);n(t?Z(t):``)},onBlur:e=>n(e.currentTarget.value?Z(e.currentTarget.value):``)})]})}),(0,m.jsx)(`div`,{children:(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`submit`,isDisabled:!t,children:`Select size`})})]})})}const En=(0,l.defineCreator)({id:`@manifest-editor/thumbnail-image`,create:wn,label:`Thumbnail from service`,summary:`Add thumbnail from an image service`,icon:(0,m.jsx)(d.ScaledImageIcon,{}),render(e){return(0,m.jsx)(Tn,{...e})},resourceType:`ContentResource`,resourceFields:[`id`,`type`,`format`],supports:{parentFields:[`thumbnail`]}});function Dn(){return(0,m.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`24px`,viewBox:`0 0 24 24`,width:`24px`,fill:`#000000`,children:[(0,m.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,m.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 Q(e,t){return t.embed({id:e.url,type:`Text`,label:e.label,format:`text/html`})}function On(e){let[t,n]=(0,p.useState)({en:[``]});return(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.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,m.jsx)(f.LanguageFieldEditor,{focusId:`label`,label:`Label`,fields:t,onSave:e=>n(e.toInternationalString())}),(0,m.jsxs)(f.InputContainer,{$wide:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`id`,children:`Link`}),(0,m.jsx)(f.Input,{id:`url`,name:`url`,defaultValue:``})]}),(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`submit`,children:`Create link`})]})})}const kn=(0,l.defineCreator)({id:`@manifest-editor/web-page-creator`,create:Q,label:`Web page`,summary:`Add link to an external web page`,icon:(0,m.jsx)(Dn,{}),render(e){return(0,m.jsx)(On,{...e})},resourceType:`ContentResource`,resourceFields:[`label`,`format`],supports:{parentFields:[`seeAlso`,`rendering`,`homepage`]}}),An=/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;function $(e){let t=(e||``).match(An);return t?t[1]:null}function jn(e){return!!$(e.youtubeUrl)}async function Mn(e,t){let n=$(e.youtubeUrl),r=t.embed({id:`https://www.youtube.com/watch?v=${n}`,type:`Video`,service:[{profile:`http://digirati.com/objectifier`,params:{data:`https://www.youtube.com/embed/${n}`}},{id:`https://www.youtube.com/watch?v=${n}`,profile:`https://www.youtube.com`}]});if(t.options.targetType===`Canvas`){let n=t.generateId(`canvas`),i=t.generateId(`annotation-page`,{id:n,type:`Canvas`}),a=t.embed({id:t.generateId(`annotation`,{id:i,type:`AnnotationPage`}),type:`Annotation`,motivation:`painting`,body:[r],target:{type:`SpecificResource`,source:{id:n,type:`Canvas`}}}),o=t.embed({id:i,type:`AnnotationPage`,items:[a]});return t.embed({id:n,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:[r],target:t.getTarget()}):r}function Nn(e){return(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.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,m.jsxs)(f.InputContainer,{$wide:!0,children:[(0,m.jsx)(f.InputLabel,{htmlFor:`id`,children:`Link to YouTube`}),(0,m.jsx)(f.Input,{id:`youtubeUrl`,name:`youtubeUrl`,defaultValue:``})]}),(0,m.jsx)(d.ActionButton,{primary:!0,large:!0,type:`submit`,children:`Create`})]})})}const Pn=(0,l.defineCreator)({id:`@manifest-editor/youtube`,create:Mn,label:`YouTube`,summary:`Embed YouTube`,icon:(0,m.jsx)(d.YouTubeIcon,{}),resourceType:`ContentResource`,additionalTypes:[`Canvas`,`Annotation`],resourceFields:[`id`,`type`,`service`],render:e=>(0,m.jsx)(Nn,{...e}),supports:{onlyPainting:!0,parentTypes:[`Annotation`,`Manifest`,`AnnotationPage`],parentFieldMap:{Annotation:[`body`],Manifest:[`items`],AnnotationPage:[`items`]}},staticFields:{type:`Video`}});async function Fn(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,u.createThumbnailHelper)(o);if(n.type===`Manifest`){let e=n.id;X(e,`Could not find Manifest ID`);let i=await o.loadManifest(e),a=await s.getBestThumbnailAtSize(i,{width:256,height:256},!1);X(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;X(e,`Could not find Manifest ID`);let i=await o.loadManifest(e);X(i,`Collection not found`),r.push(t.embed({id:n.id,type:`Collection`,label:i.label}))}}return r}const In=(0,p.lazy)(()=>Promise.resolve().then(()=>require(`./manifest-browser-form.lazy-CvCmoUcV.cjs`))),Ln=(0,l.defineCreator)({id:`@manifest-editor/manifest-browser-creator`,create:Fn,label:`IIIF Browser`,summary:`Browse IIIF Resources`,icon:(0,m.jsx)(d.IIIFBrowserIcon,{}),render(e){return(0,m.jsx)(c.t,{...e})},resourceType:`Manifest`,resourceFields:[`id`,`label`],additionalTypes:[`Collection`],supports:{parentTypes:[`Collection`],parentFieldMap:{Collection:[`items`]}},sideEffects:[],staticFields:{}});async function Rn(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 zn(e){let[t,n]=(0,p.useState)({en:[``]});return(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.jsxs)(`form`,{onSubmit:n=>{n.preventDefault(),t&&e.runCreate({type:`Range`,label:t})},children:[(0,m.jsx)(f.LanguageFieldEditor,{focusId:`label`,label:`Label`,fields:t,onSave:e=>n(e.toInternationalString())}),(0,m.jsx)(d.ActionButton,{primary:!0,type:`submit`,children:`Create range`})]})})}const Bn=(0,l.defineCreator)({id:`@manifest-editor/range-with-items`,create:Rn,label:`Range`,summary:`Add a new range`,icon:(0,m.jsx)(d.RangesIcon,{}),render(e){return(0,m.jsx)(zn,{...e})},resourceType:`Range`,resourceFields:[`id`,`label`,`type`],supports:{parentTypes:[`Range`],parentFields:[`items`]},staticFields:{type:`Range`}});async function Vn(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 Hn(e){let[t,n]=(0,p.useState)({en:[``]});return(0,m.jsx)(d.PaddedSidebarContainer,{children:(0,m.jsxs)(`form`,{onSubmit:n=>{n.preventDefault(),t&&e.runCreate({type:`Range`,label:t})},children:[(0,m.jsx)(f.LanguageFieldEditor,{focusId:`label`,label:`Label`,fields:t,onSave:e=>n(e.toInternationalString())}),(0,m.jsx)(d.ActionButton,{primary:!0,type:`submit`,children:`Create range`})]})})}const Un=(0,l.defineCreator)({id:`@manifest-editor/range-top-level`,create:Vn,label:`Top Level Range`,summary:`Add a new top level range`,icon:(0,m.jsx)(d.RangesIcon,{}),render(e){return(0,m.jsx)(Hn,{...e})},resourceType:`Range`,resourceFields:[`id`,`label`,`type`],supports:{parentTypes:[`Manifest`],parentFields:[`structures`]},staticFields:{type:`Range`}}),Wn=[_n,Vt,vn,Gt,en,T,fn,j,Pn,gn,rn,Sn,kn,nn,Yt,on,O,yn,Jt,En,Un,Bn,ne];exports.CreateAudioAnnotationForm=w,exports.CreateCaptionedImageAnnotation=D,exports.CreateHTMLAnnotation=A,exports.CreateHTMLBodyForm=dn,exports.CreateImageServerForm=K,exports.CreateImageServiceAnnotationForm=Bt,exports.CreateImageUrlAnnotationForm=Wt,exports.CreateImageUrlForm=q,exports.CreateImageUrlListForm=J,exports.CreatePlaintextForm=xn,exports.CreateProviderForm=x,exports.CreateThumbnailForm=Tn,exports.CreateVideoAnnotationForm=$t,exports.CreateWebPageForm=On,exports.IIIFBrowserCreatorForm=hn,exports.ManifestBrowserCreatorForm=In,exports.RangeWithItemsCreatorForm=zn,exports.TopLevelRangeCreatorForm=Hn,exports.YouTubeForm=Nn,exports.allCreators=Wn,exports.audioAnnotation=T,exports.captionedImageAnnotation=O,exports.createAudioAnnotation=C,exports.createCaptionedImageAnnotation=E,exports.createFromIIIFBrowserOutput=mn,exports.createFromManifestBrowserOutput=Fn,exports.createHtmlAnnotation=k,exports.createHtmlBody=un,exports.createImageServer=Lt,exports.createImageServiceAnnotation=zt,exports.createImageUrl=Ht,exports.createImageUrlAnnotation=Ut,exports.createImageUrlList=Kt,exports.createImageUrlListAnnotation=qt,exports.createNoBodyAnnotation=Xt,exports.createPlaintext=bn,exports.createProvider=b,exports.createRangeTopLevel=Vn,exports.createRangeWithItems=Rn,exports.createThumbnail=wn,exports.createVideoAnnotation=Qt,exports.createWebPage=Q,exports.createYoutubeBody=Mn,exports.emptyAnnotationPage=nn,exports.emptyCanvas=rn,exports.getYouTubeId=$,exports.htmlAnnotation=j,exports.htmlBodyCreator=fn,exports.iiifBrowserCreator=gn,exports.imageServiceAnnotation=Vt,exports.imageServiceCreator=_n,exports.imageUrlAnnotation=Gt,exports.imageUrlCreator=vn,exports.imageUrlListAnnotation=Jt,exports.imageUrlListCreator=yn,exports.internalCanvas=on,exports.manifestBrowserCreator=Ln,exports.noBodyAnnotation=Yt,exports.plaintextCreator=Sn,exports.providerCreator=ne,exports.rangeTopLevel=Un,exports.rangeWithItems=Bn,exports.t=s,exports.validateYouTube=jn,exports.videoAnnotation=en,exports.webPageCreator=kn,exports.youTubeBodyCreator=Pn;