@manifest-editor/exhibition-preset 2.2.2-next.0.903673e → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});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,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("@manifest-editor/manifest-preset");c=s(c,1);let l=require("@manifest-editor/shell"),u=require("@manifest-editor/editors"),d=require("react-iiif-vault"),f=require("zustand"),p=require("react/jsx-runtime"),m=require("react");m=s(m,1);let h=require("@manifest-editor/components"),g=require("exhibition-viewer"),_=require("exhibition-viewer/library"),v=require("react-aria-components"),y=require("tailwind-merge"),b=require("@manifest-editor/manifest-preset/components"),x=require("tiny-invariant");x=s(x,1);let S=require("@iiif/parser/image-3"),C=require("@dnd-kit/core"),w=require("@dnd-kit/modifiers"),T=require("@dnd-kit/sortable"),E=require("@dnd-kit/utilities"),D=require("@iiif/helpers/vault/actions"),O=require("@manifest-editor/creator-api"),k=require("@manifest-editor/creators"),A=require("@iiif/parser"),j=require("@iiif/helpers"),M=require("@atlas-viewer/atlas");const N={id:`@exhibition/tour-step-annotations`,label:`Tour steps`,render:()=>(0,p.jsx)(F,{})},P={border:`2px solid rgba(255, 255, 255, 0.3)`,":hover":{borderColor:`#4B67E1`,backgroundColor:`rgba(255, 255, 255, 0.2)`}};function F(){let e=(0,d.useCanvas)(),t=(0,l.useAtlasStore)(),n=(0,f.useStore)(t,e=>e.tool.enabled),{rightPanel:r}=(0,l.useLayoutState)(),i=r.current===`@manifest-editor/editor`&&r.state?.currentTab?.startsWith(`@exhibition/tour-steps`),a=e?.annotations[0];return!i||!e||n||!a?null:(0,p.jsx)(p.Fragment,{children:(0,p.jsx)(d.AnnotationPageContext,{annotationPage:a.id,children:(0,p.jsx)(u.ViewerAnnotationPage,{showAnnotationNumber:!0,style:P})})})}const I=`https://exhibitionviewer.org/iiif/theme-service`,ee={en:[`Exhibition viewer theme`]},L={fontSans:`"Tahoma", "Fira Sans", sans-serif`,fontMono:`"Fira Mono", monospace`,titleTransform:`uppercase`},R={backgroundPrimary:`#e5e7eb`,backgroundSecondary:`#fff`,backgroundOverlay:`rgba(0, 0, 0, 0.3)`,textPrimary:`#fff`,textSecondary:`#000`,imageCaption:`#fff`,annotationSelected:`#facc15`,controlBar:`#6d6e70`,controlBarBorder:`#5a5b5d`,controlHover:`rgba(0, 0, 0, 0.1)`,progressBar:`#fff`,closeBackground:`#000`,closeBackgroundHover:`#373737`,closeText:`#fff`,titleCard:`#facc15`,titleCardText:`#000`,infoBlock:`#000`,infoBlockText:`#fff`,viewerBackground:`#373737`},te={...R,backgroundPrimary:`#fff`,backgroundSecondary:`#fff`,textPrimary:`#000`,textSecondary:`#000`,imageCaption:`#000`,annotationSelected:`#303f9f`,controlBar:`#f9f9f9`,controlBarBorder:`#000`,closeBackground:`#fff`,closeBackgroundHover:`#eee`,closeText:`#000`,progressBar:`#000000`,titleCard:`#fff`,titleCardText:`#000`,infoBlock:`#fff`,infoBlockText:`#000`,viewerBackground:`#e9e9e9`},ne={titleBackground:`#fff`,titleColor:`#444`,annotationBackground:`#fff`,annotationColor:`#333`,annotationRadius:`0px`,annotationMaxWidth:`30em`,infoBlockBackground:`#fff`,infoBlockColor:`#444`},z={cutCorners:!0,fullTitleBar:!1,fullWidthGrid:!1,hideTableOfContents:!1,tableOfContentsPlacement:`footer`,showProgressBar:!0,showProgressTableOfContents:!0,showNavigationControls:!0,disablePresentation:!1,hideTitle:!1,hideTitleCard:!1,alternativeImageMode:!0,transitionScale:!1,imageInfoIcon:!1,coverImages:!1,ignoreCanvasBackgrounds:!1},re={cutCorners:!1,isFloating:!1,floatingPosition:`bottom-left`,labelOnlyFloating:!0,ignoreCanvasBackgrounds:!1},ie={alternativeImageMode:!0,transitionScale:!1,imageInfoIcon:!1,coverImages:!1,ignoreCanvasBackgrounds:!1},ae={showTitleBlock:!0,showTableOfContents:!1,tableOfContentsPlacement:`header`,showProgressBar:!0,showProgressTableOfContents:!0,showScrollToTop:!0,showNavigationControls:!0,ignoreCanvasBackgrounds:!1,titleBlock:{fullHeight:!0}},oe={version:1,preset:`delft`,shared:L,delft:{tokens:R,exhibition:z,presentation:re,slideshow:ie},scroll:{tokens:ne,options:ae}},se={delft:oe,minimal:{...oe,preset:`minimal`,shared:{...L,titleTransform:`none`},delft:{...oe.delft,tokens:te}},gallery:{version:1,preset:`gallery`,shared:{fontSans:`"Gill Sans", "Trebuchet MS", sans-serif`,fontMono:`"Courier Prime", "Courier New", monospace`,titleTransform:`capitalize`},delft:{tokens:{...R,backgroundPrimary:`#f3ecdf`,backgroundSecondary:`#fff8ee`,backgroundOverlay:`rgba(20, 26, 32, 0.45)`,textPrimary:`#fff8ee`,textSecondary:`#2b2118`,imageCaption:`#f8efe1`,annotationSelected:`#f08c2e`,controlBar:`#1f3a5f`,controlBarBorder:`#162b47`,controlHover:`rgba(255, 255, 255, 0.14)`,progressBar:`#f4a261`,closeBackground:`#1f3a5f`,closeBackgroundHover:`#335c8a`,closeText:`#fff8ee`,titleCard:`#c7522a`,titleCardText:`#fff8ee`,infoBlock:`#22313f`,infoBlockText:`#f8efe1`,viewerBackground:`#30414d`},exhibition:{...z,cutCorners:!1,fullTitleBar:!0,fullWidthGrid:!0,alternativeImageMode:!1,transitionScale:!0,imageInfoIcon:!0,coverImages:!0},presentation:{...re,isFloating:!0,floatingPosition:`bottom-right`},slideshow:{...ie,alternativeImageMode:!1,transitionScale:!0,imageInfoIcon:!0,coverImages:!0}},scroll:{tokens:{...ne,titleBackground:`#f8efe1`,titleColor:`#2a2119`,annotationBackground:`#22313f`,annotationColor:`#f8efe1`,annotationRadius:`18px`,annotationMaxWidth:`34em`,infoBlockBackground:`#fff8ee`,infoBlockColor:`#2a2119`},options:{...ae,showTableOfContents:!0,tableOfContentsPlacement:`header`,titleBlock:{fullHeight:!1}}}}};function ce(e){return JSON.parse(JSON.stringify(e))}function le(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function ue(e,t){if(!t)return ce(e);let n=ce(e);for(let[e,r]of Object.entries(t)){if(r===void 0)continue;let t=n[e];if(le(t)&&le(r)){n[e]=ue(t,r);continue}n[e]=r}return n}function de(e){return typeof e==`string`&&e in se}function fe(e=`delft`){return ce(se[e]||oe)}function pe(e){let t=de(e?.preset)?e.preset:`delft`,n=ue(fe(t),e||{});return n.version=1,n.preset=t,n}function me(e){return`${e}#exhibition-viewer-theme`}function he(e,t){return{id:me(e),type:`Service`,profile:I,label:ee,theme:pe(t)}}function ge(e){if(!e?.length)return null;let t=e.findIndex(e=>e?.profile===`https://exhibitionviewer.org/iiif/theme-service`||e?.theme);return t===-1?null:{index:t,service:e[t]}}function _e(e){return ge(e)?.service?.theme}function ve(e,t){let n=[...e||[]],r=ge(n);return r?t?(n[r.index]=t,n):(n.splice(r.index,1),n):(t&&n.push(t),n)}function ye(e){return{"--f-font":e.shared.fontSans,"--f-mono-font":e.shared.fontMono,"--delft-title-transform":e.shared.titleTransform,"--delft-bg-primary":e.delft.tokens.backgroundPrimary,"--delft-bg-secondary":e.delft.tokens.backgroundSecondary,"--delft-bg-overlay":e.delft.tokens.backgroundOverlay,"--delft-text-primary":e.delft.tokens.textPrimary,"--delft-text-secondary":e.delft.tokens.textSecondary,"--delft-image-caption":e.delft.tokens.imageCaption,"--delft-annotation-selected":e.delft.tokens.annotationSelected,"--delft-control-bar":e.delft.tokens.controlBar,"--delft-control-bar-border":e.delft.tokens.controlBarBorder,"--delft-control-hover":e.delft.tokens.controlHover,"--delft-progress-bar":e.delft.tokens.progressBar,"--delft-close-background":e.delft.tokens.closeBackground,"--delft-close-background-hover":e.delft.tokens.closeBackgroundHover,"--delft-close-text":e.delft.tokens.closeText,"--delft-title-card":e.delft.tokens.titleCard,"--delft-title-card-text":e.delft.tokens.titleCardText,"--delft-info-block":e.delft.tokens.infoBlock,"--delft-info-block-text":e.delft.tokens.infoBlockText,"--delft-viewer-background":e.delft.tokens.viewerBackground,"--exv-scroll-title-background":e.scroll.tokens.titleBackground,"--exv-scroll-title-color":e.scroll.tokens.titleColor,"--exv-scroll-annotation-background":e.scroll.tokens.annotationBackground,"--exv-scroll-annotation-color":e.scroll.tokens.annotationColor,"--exv-scroll-annotation-radius":e.scroll.tokens.annotationRadius,"--exv-scroll-annotation-max-width":e.scroll.tokens.annotationMaxWidth,"--exv-scroll-info-block-background":e.scroll.tokens.infoBlockBackground,"--exv-scroll-info-block-color":e.scroll.tokens.infoBlockColor}}const be={id:`@exhibitions/center-panel`,label:`Exhibition editor`,icon:null,render:()=>(0,p.jsx)(xe,{}),options:{minWidth:350,maxWidth:350}};function xe(){let e=(0,d.useManifest)(),t=(0,d.useVault)(),[n,r]=(0,m.useState)(.8),i=(0,m.useRef)(null),{edit:a,leftPanel:o}=(0,l.useLayoutActions)(),s=(0,m.useMemo)(()=>e?pe(_e(e.service||e.services)):null,[e]),c=(0,m.useMemo)(()=>({localeStringEditor:e=>(0,p.jsxs)(`span`,{className:`inline-flex items-center hover:ring-4 hover:ring-me-primary-500`,children:[e.original,(0,p.jsx)(v.Button,{className:`py-1 px-2 inline-block`,onPress:()=>a(e.resource),children:(0,p.jsx)(h.EditTextIcon,{className:`text-xl`})})]}),canvasPreviewEditor:e=>(0,p.jsxs)(`div`,{className:`w-full h-full flex-1 flex relative`,children:[e.original,(0,p.jsx)(`button`,{onClick:t=>{t.preventDefault(),t.stopPropagation(),a(e.resource),o.open({id:`canvas-listing`})},className:`absolute top-5 right-5 bg-white text-black p-2 rounded z-40`,children:`EDIT`})]})}),[]);return(0,m.useEffect)(()=>{for(let n of e?.items||[]){let e=t.get(n);e&&!Array.isArray(e.items)&&t.modifyEntityField(e,`items`,[]);for(let n of[...e?.items||[],...e?.annotations||[]]){let e=t.get(n);e&&!Array.isArray(e.items)&&t.modifyEntityField(e,`items`,[])}}},[e,t]),(0,m.useLayoutEffect)(()=>{if(i.current){let e=i.current.offsetWidth/1200;r(Math.max(1,e))}},[]),e?(0,p.jsx)(`div`,{ref:i,className:`overflow-y-auto delft-exhibition exhibition-viewer`,style:s?ye(s):void 0,children:(0,p.jsx)(_.EditorHooksProvider,{hooks:c,children:(0,p.jsx)(g.DelftExhibition,{skipLoadManifest:!0,customVault:t,manifest:e.id,options:{...s?.delft.exhibition||{},disablePresentation:!0,hideTableOfContents:!0,hideTitle:!0}},n)})}):null}function Se(e,t){let n=new URLSearchParams;switch(we(n,`manifest`,t.manifest),we(n,`canvas`,t.canvas),e){case`delft`:case`exhibition`:{let e=t;B(n,`cut-corners`,e.cutCorners),B(n,`full-title-bar`,e.fullTitleBar),B(n,`hide-toc`,e.hideTableOfContents),B(n,`show-navigation-controls`,e.showNavigationControls),B(n,`show-progress-bar`,e.showProgressBar),we(n,`toc-placement`,e.tableOfContentsPlacement),B(n,`ignore-canvas-backgrounds`,e.ignoreCanvasBackgrounds);break}case`minimal`:{let e=t;n.set(`minimal`,`true`),B(n,`cut-corners`,e.cutCorners),B(n,`full-title-bar`,e.fullTitleBar),we(n,`toc-placement`,e.tableOfContentsPlacement),B(n,`ignore-canvas-backgrounds`,e.ignoreCanvasBackgrounds);break}case`presentation`:{let e=t;n.set(`type`,`presentation`),B(n,`cut-corners`,e.cutCorners),B(n,`floating`,e.floating??e.isFloating),we(n,`floating-position`,e.floatingPosition),B(n,`label-only-floating`,e.labelOnlyFloating),B(n,`ignore-canvas-backgrounds`,e.ignoreCanvasBackgrounds);break}case`scroll`:{let e=t;n.set(`type`,`scroll`),Te(n,`minimal`,e.minimal),we(n,`toc-placement`,e.tableOfContentsPlacement),B(n,`ignore-canvas-backgrounds`,e.ignoreCanvasBackgrounds),Te(n,`manifest-editor-preview`,e.manifestEditorPreview),we(n,`manifest-editor-preview-origin`,e.manifestEditorPreviewOrigin);break}case`slideshow`:{let e=t;n.set(`type`,`slideshow`),Te(n,`minimal`,e.minimal),B(n,`floating`,e.floating),we(n,`floating-position`,e.floatingPosition),B(n,`label-only-floating`,e.labelOnlyFloating),B(n,`ignore-canvas-backgrounds`,e.ignoreCanvasBackgrounds);break}}return n}function Ce(e,t,n){let r=Se(e,t||{}),i=new URL(n||`https://preview.exhibitionviewer.org/preview/${e}`);return!n&&(window.location.hostname===`localhost`||window.location.hostname===`127.0.0.1`)&&window.location.port===`3000`&&(i.protocol=`http:`,i.host=`localhost:5174`),r.forEach((e,t)=>{i.searchParams.set(t,e)}),i.searchParams.set(`manifest-editor-preview`,`true`),i.searchParams.set(`manifest-editor-preview-origin`,window.location.origin),i}function we(e,t,n){n&&e.set(t,n)}function B(e,t,n){typeof n==`boolean`&&e.set(t,String(n))}function Te(e,t,n){n&&e.set(t,`true`)}function Ee(e){return e===`exhibition-slideshow-editor`?`slideshow`:e===`exhibition-scrolling-editor`?`scroll`:`fullpage`}function De(e,t=[]){let n=t.find(e=>e.startsWith(`template-`))?.slice(9);return e.find(e=>e.id===n)||e.find(e=>t.includes(e.type))||null}function Oe(e,t,n){return t?e.filter(e=>e.type===t.type||e.id===n?.id):e}function V(){let e=(0,l.useApp)(),t=e.preset?.templates||[],n=(0,d.useManifest)(),{selectedTemplate:r}=(0,l.usePresetTemplateSelection)();return De(t,n?.behavior)||r||t.find(t=>t.type===Ee(e.metadata.id))||null}const H=(0,f.create)(e=>({selectedAnnotationId:null,repositioningAnnotationId:null,selectedTextRegion:null,repositioningTextRegion:null,selectedTourStepId:null,repositioningTourStepId:null,selectAnnotation:t=>e({selectedAnnotationId:t,repositioningAnnotationId:null,selectedTextRegion:null,repositioningTextRegion:null}),startRepositioning:t=>e({selectedAnnotationId:t,repositioningAnnotationId:t,selectedTextRegion:null,repositioningTextRegion:null}),stopRepositioning:()=>e({repositioningAnnotationId:null}),selectTextRegion:t=>e({selectedAnnotationId:null,repositioningAnnotationId:null,selectedTextRegion:t,repositioningTextRegion:null}),startTextRepositioning:t=>e({selectedAnnotationId:null,repositioningAnnotationId:null,selectedTextRegion:t,repositioningTextRegion:t}),stopTextRepositioning:()=>e({repositioningTextRegion:null}),selectTourStep:t=>e({selectedTourStepId:t,repositioningTourStepId:null}),startTourStepRepositioning:t=>e({selectedTourStepId:t,repositioningTourStepId:t}),stopTourStepRepositioning:()=>e({repositioningTourStepId:null}),clear:()=>e({selectedAnnotationId:null,repositioningAnnotationId:null,selectedTextRegion:null,repositioningTextRegion:null,selectedTourStepId:null,repositioningTourStepId:null})})),U=(0,f.create)(e=>({requestedTab:null,showTourSteps:!1,centerPanelMode:`preview`,requestTab:t=>e({requestedTab:t}),clearRequestedTab:()=>e({requestedTab:null}),setShowTourSteps:t=>e({showTourSteps:t}),setCenterPanelMode:t=>e({centerPanelMode:t})}));function ke(e){let t=Number(e?.width)||1920,n=Number(e?.height)||1080,r=ze(e);return r.content?r.content:{x:Math.round(t*.1),y:Math.round(n*.1),width:Math.round(t*.8),height:Math.round(n*.8)}}function Ae(e,t){return{type:`SpecificResource`,source:{id:e.id,type:`Canvas`},selector:{type:`FragmentSelector`,value:`xywh=${Math.round(t.x)},${Math.round(t.y)},${Math.round(t.width)},${Math.round(t.height)}`}}}function je(e){return Ae(e,ke(e))}function W(e,t){return Pe(e,t?.items||[]).filter(e=>(Array.isArray(e?.motivation)?e.motivation:[e?.motivation]).includes(`painting`))}function Me(e,t){return Pe(e,t?.annotations||[])}function Ne(e,t){return!t||(Array.isArray(t?.behavior)?t.behavior:[]).includes(`info`)?!1:!W(e,t).some(t=>{let n=Ve(e,t);return!!(qe(n)||Je(n))})}function Pe(e,t){let n=[];for(let r of t){let t=e.get(r,{skipSelfReturn:!1});for(let r of t?.items||[]){let t=e.get(r,{skipSelfReturn:!1});t&&n.push(t)}}return n}function Fe(e,t){return W(e,t).map(n=>{let r=Ve(e,n);return{annotation:n,box:Ie(n,t),html:Ge(r),imageUrl:We(e,r),videoUrl:qe(r),youtubeId:Je(r)}})}function Ie(e,t){let n=Number(t?.width)||1920,r=Number(t?.height)||1080,i=e?.target;if(typeof i==`string`&&i.includes(`#xywh=`)){let e=He(i.split(`#xywh=`)[1]);if(e)return e}let a=i?.selector,o=Array.isArray(a)?a.find(e=>e?.spatial||e?.points):a;if(o?.spatial)return o.spatial;if(Array.isArray(o?.points)){let e=o.points.filter(e=>Array.isArray(e)&&Number.isFinite(e[0])&&Number.isFinite(e[1]));if(e.length){let t=e.map(e=>e[0]),n=e.map(e=>e[1]),r=Math.min(...t),i=Math.min(...n);return{x:r,y:i,width:Math.max(1,Math.max(...t)-r),height:Math.max(1,Math.max(...n)-i)}}}let s=Array.isArray(a)?a.find(e=>e?.value?.startsWith?.(`xywh=`))?.value:a?.value;if(typeof s==`string`&&s.includes(`xywh=`)){let e=He(s.split(`xywh=`)[1]);if(e)return e}return{x:0,y:0,width:n,height:r}}function Le(e,t,n,r){e.modifyEntityField({id:n,type:`Annotation`},`target`,Ae(t,Be(t,r)))}function Re(e,t,n){let r=Be(t,n),i=Array.isArray(t?.behavior)?t.behavior:[];e.modifyEntityField(t,`behavior`,i.filter(e=>!e.startsWith(`text-xywh=`)).concat(`text-xywh=${Math.round(r.x)},${Math.round(r.y)},${Math.round(r.width)},${Math.round(r.height)}`))}function ze(e){let t=Number(e?.width)||1920,n=Number(e?.height)||1080,r=Array.isArray(e?.behavior)?e.behavior:[],i=Ue(r);return r.includes(`right`)?{content:{x:0,y:0,width:Math.round(t*2/3),height:n},text:i||{x:Math.round(t*2/3),y:0,width:Math.round(t/3),height:n}}:r.includes(`left`)?{content:{x:Math.round(t/3),y:0,width:Math.round(t*2/3),height:n},text:i||{x:0,y:0,width:Math.round(t/3),height:n}}:r.includes(`bottom`)?{content:{x:0,y:0,width:t,height:Math.round(n*2/3)},text:i||{x:0,y:Math.round(n*2/3),width:t,height:Math.round(n/3)}}:r.includes(`top`)?{content:{x:0,y:Math.round(n/3),width:t,height:Math.round(n*2/3)},text:i||{x:0,y:0,width:t,height:Math.round(n/3)}}:r.includes(`info`)?{content:null,text:i||{x:0,y:0,width:t,height:n}}:r.includes(`image`)?{content:{x:0,y:0,width:t,height:n},text:i}:{content:null,text:i}}function Be(e,t){let n=Number(e?.width)||1920,r=Number(e?.height)||1080,i=Math.max(1,Math.min(t.width,n)),a=Math.max(1,Math.min(t.height,r)),o=Math.max(0,Math.min(t.x,n-i)),s=Math.max(0,Math.min(t.y,r-a));return{x:Math.round(o),y:Math.round(s),width:Math.round(i),height:Math.round(a)}}function Ve(e,t){let n=Array.isArray(t?.body)?t.body[0]:t?.body,r=n?e.get(n,{skipSelfReturn:!1}):null;return r?.type===`SpecificResource`?r.source:r||n||null}function He(e){let t=e?e.split(/[,&]/).slice(0,4).map(Number):[];if(t.length===4&&t.every(e=>Number.isFinite(e))){let[e,n,r,i]=t;return{x:e,y:n,width:r,height:i}}return null}function Ue(e){let t=e.find(e=>e.startsWith(`text-xywh=`))?.replace(`text-xywh=`,``);return He(t)}function We(e,t){let n=Ke(e,t);if(n?.type===`Choice`){let t=Array.isArray(n.items)?n.items:[];for(let n of t){let t=We(e,n);if(t)return t}}if(n?.type===`Canvas`){let t=e.get({id:n.id,type:`Canvas`},{skipSelfReturn:!1})||n,r=Array.isArray(t.thumbnail)?t.thumbnail[0]:t.thumbnail;if(r?.id)return r.id;for(let n of W(e,t)){let t=We(e,Ve(e,n));if(t)return t}}let r=Array.isArray(n?.service)?n.service[0]:n?.service,i=r?.id||r?.[`@id`];return i?`${i.replace(/\/$/,``)}/full/1000,/0/default.jpg`:n?.type===`Image`&&n.id?n.id:null}function Ge(e){let t=e?.type===`SpecificResource`?e.source:e;return t?.type===`Text`||t?.type===`TextualBody`||t?.format===`text/html`||t?.format===`text/plain`?t.value||``:null}function Ke(e,t){return t?.type===`SpecificResource`?Ke(e,t.source):t?.id&&t?.type===`ContentResource`?e.get({id:t.id,type:`ContentResource`},{skipSelfReturn:!1})||t:t?.id&&!t.items&&!t.value&&!t.service&&!t.format&&!t.width&&!t.height&&e.get(t,{skipSelfReturn:!1})||t}function qe(e){let t=e?.type===`SpecificResource`?e.source:e;return t?.type===`Video`&&!Je(t)?t.id:null}function Je(e){let t=e?.type===`SpecificResource`?e.source:e,n=((t?.service||[]).find(e=>e?.profile===`https://www.youtube.com`)?.id||t?.id||``).match(/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/);return n?n[1]:null}function Ye(e,t){return JSON.stringify([e.id,e.type,...(t||[]).map(e=>[e.id,e.type])])}function Xe(e,t){let n=[];for(let r of t||[]){let t=e.get(r,{skipSelfReturn:!1});for(let r of W(e,t)){let t=Array.isArray(r.body)?r.body:r.body?[r.body]:[];for(let i of t){let t=i?.id&&e.get(i,{preserveSpecificResources:!0,skipSelfReturn:!1})||i,a=Array.isArray(t?.selector)?t.selector:t?.selector?[t.selector]:[];for(let e of a)(e?.type===`ImageApiSelector`||e?.type===`iiif:ImageApiSelector`)&&n.push([r.id,e.region??null,e.rotation??null])}}}return JSON.stringify(n)}const Ze=1024,Qe=.5;function $e({preset:e,presetOptions:t,focusSelectedCanvas:n=!0}){let r=et({preset:e,presetOptions:t,focusSelectedCanvas:n}),i=(0,d.useVault)(),a=(0,l.useAppResource)(),o=(0,d.useManifest)(),s=V(),c=(0,u.useInStack)(`Canvas`),f=(0,m.useRef)(null),h=(0,m.useRef)(null),g=(0,m.useRef)(null),_=(0,m.useRef)(a),v=(0,m.useRef)(null),b=(0,m.useRef)(null),[x,S]=(0,m.useState)(`waiting`),[C,w]=(0,m.useState)(0),[T,E]=(0,m.useState)(!1),[D,O]=(0,m.useState)(!1),k=H(e=>e.selectedTourStepId),A=n&&(c?.resource.source.id||o?.items?.[0]?.id)||null,j=Ye(a,o?.items),M=(0,d.useVaultSelector)((e,t)=>Xe(t,o?.items),[j]),N=(0,m.useRef)(j),P=(0,m.useMemo)(()=>Ce(e,t,s?.previewUrl).toString(),[e,t,s?.previewUrl]),F=(0,m.useMemo)(()=>new URL(P).origin,[P]),I=D?440:C?Math.round(C/(T?Qe:1)):0,ee=I>0&&I<=Ze;_.current=a,v.current=A,b.current=k;let L=(0,m.useCallback)(()=>{let e=f.current;if(!e?.contentWindow)return;g.current?.(),S(`waiting`);let t=new MessageChannel;g.current=(0,l.createIframeVaultBridge)(i,t.port1);try{e.contentWindow.postMessage({_type:`manifest-editor:iframe-preview:connect`,resource:_.current,canvasId:v.current,annotationId:b.current||void 0},F,[t.port2]),S(`connected`)}catch{g.current?.(),g.current=null,S(`error`)}},[F,i]);(0,m.useEffect)(()=>{function e(e){e.origin===F&&e.source===f.current?.contentWindow&&e.data?._type===`manifest-editor:iframe-preview:ready`&&L()}return window.addEventListener(`message`,e),()=>{window.removeEventListener(`message`,e),g.current?.(),g.current=null}},[L,F]),(0,m.useEffect)(()=>{let e=f.current?.contentWindow;!e||x!==`connected`||e.postMessage({_type:`manifest-editor:iframe-preview:selection`,resource:a,canvasId:A,annotationId:k||void 0},F)},[x,a,A,k,F]),(0,m.useEffect)(()=>{let e=N.current!==j;N.current=j,e&&x===`connected`&&L()},[L,x,j]),(0,m.useEffect)(()=>{let e=h.current;if(!e)return;let t=()=>{w(e.getBoundingClientRect().width)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,m.useEffect)(()=>{if(C){if(C>Ze){E(!1);return}O(!1)}},[C]);let R=(0,m.useCallback)(e=>{E(e),e&&O(!1)},[]),te=(0,m.useCallback)(e=>{O(e),e&&E(!1)},[]);return(0,p.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-zinc-950`,children:[x===`connected`?null:(0,p.jsx)(`div`,{className:`border-b border-zinc-800 bg-zinc-900 px-3 py-2 text-sm text-zinc-300`,children:x===`error`?`Preview connection failed.`:`Connecting to exhibition viewer...`}),(0,p.jsx)(tt,{iframeViewportWidth:I,isMobileViewport:ee,showScaleOption:C>0&&C<=Ze,showMobileWidthOption:C>Ze,useScaledPreview:T,useMobileWidthPreview:D,onUseScaledPreviewChange:R,onUseMobileWidthPreviewChange:te,previewWindow:r}),(0,p.jsx)(`div`,{ref:h,className:(0,y.twMerge)(`flex min-h-0 flex-1 overflow-hidden bg-white`,T?`justify-start`:`justify-center`),children:(0,p.jsx)(`iframe`,{ref:f,src:P,title:`Exhibition preview`,className:(0,y.twMerge)(`block h-full shrink-0 border-0 bg-white`,D?`shadow-2xl shadow-black/40`:``),style:{width:D?440:T?`${100/Qe}%`:`100%`,maxWidth:D?`100%`:void 0,height:T?`${100/Qe}%`:`100%`,transform:T?`scale(${Qe})`:void 0,transformOrigin:`top left`},onLoad:()=>S(`waiting`)},M)})]})}function et({preset:e,presetOptions:t,focusSelectedCanvas:n=!0}){let{open:r,update:i,focus:a,isClosed:o}=(0,l.usePreviewWindow)(),s=(0,l.useAppResource)(),c=(0,d.useManifest)(),f=V(),p=(0,u.useInStack)(`Canvas`),h=H(e=>e.selectedTourStepId),g=n&&(p?.resource.source.id||c?.items?.[0]?.id)||null,_=Ye(s,c?.items),v=(0,d.useVaultSelector)((e,t)=>Xe(t,c?.items),[_]),y=(0,m.useMemo)(()=>Ce(e,t,f?.previewUrl).toString(),[e,t,f?.previewUrl]),b=(0,m.useMemo)(()=>({url:y,resource:s,canvasId:g,annotationId:h,name:`manifest-editor-exhibition-preview`,reloadKey:`${_}:${v}`}),[g,v,s,h,_,y]);return(0,m.useEffect)(()=>i(b),[b,i]),(0,m.useMemo)(()=>({open:()=>r(b),focus:a,isClosed:o}),[a,o,r,b])}function tt({iframeViewportWidth:e,isMobileViewport:t,showScaleOption:n,showMobileWidthOption:r,useScaledPreview:i,useMobileWidthPreview:a,onUseScaledPreviewChange:o,onUseMobileWidthPreviewChange:s,previewWindow:c}){return e?(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-zinc-800/80 bg-zinc-900 px-3 py-2 text-xs text-zinc-200`,children:[(0,p.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,p.jsx)(`span`,{className:(0,y.twMerge)(`shrink-0 rounded-full px-2 py-1 font-semibold ring-1 ring-inset`,t?`bg-amber-300/90 text-amber-950 ring-amber-200/50`:`bg-emerald-300/90 text-emerald-950 ring-emerald-200/50`),children:t?`Mobile view`:`Desktop view`}),(0,p.jsxs)(`span`,{className:`truncate text-zinc-400`,children:[`Iframe viewport: `,e,`px. Mobile starts at `,Ze,`px and below.`]})]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,p.jsx)(nt,{label:`50% scale`,checked:i,onChange:o}):null,r?(0,p.jsx)(nt,{label:`Mobile width`,checked:a,onChange:s}):null,(0,p.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md border border-zinc-700 bg-zinc-950/70 px-2.5 py-1.5 font-semibold text-zinc-200 shadow-sm shadow-black/20 transition-colors hover:border-zinc-600 hover:bg-zinc-950`,onClick:c.isClosed?c.open:c.focus,children:c.isClosed?`Open in new window`:`Focus preview window`})]})]}):null}function nt({label:e,checked:t,onChange:n}){return(0,p.jsxs)(`label`,{className:`flex shrink-0 cursor-pointer items-center gap-2 rounded-md border border-zinc-800 bg-zinc-950/70 px-2.5 py-1.5 font-semibold text-zinc-200 shadow-sm shadow-black/20 transition-colors hover:border-zinc-700 hover:bg-zinc-950`,children:[(0,p.jsx)(`span`,{children:e}),(0,p.jsx)(`input`,{type:`checkbox`,className:`peer sr-only`,checked:t,onChange:e=>n(e.currentTarget.checked)}),(0,p.jsx)(`span`,{className:`relative h-5 w-9 rounded-full bg-zinc-700/80 transition-colors after:absolute after:left-0.5 after:top-0.5 after:h-4 after:w-4 after:rounded-full after:bg-zinc-100 after:shadow after:shadow-black/20 after:transition-transform peer-checked:bg-me-primary-500 peer-checked:after:translate-x-4`})]})}function rt(){switch(V()?.type){case`slideshow`:return`slideshow`;case`scroll`:return`scroll`;default:return`exhibition`}}function it(e){return(0,p.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,...e,children:[(0,p.jsx)(`title`,{children:`Preview`}),(0,p.jsx)(`path`,{fill:`currentColor`,d:`M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5M12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5s5 2.24 5 5s-2.24 5-5 5m0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3s3-1.34 3-3s-1.34-3-3-3`})]})}const at={id:`@exhibitions/remote-preview-panel`,label:`Exhibition preview`,icon:(0,p.jsx)(it,{}),render:()=>(0,p.jsx)(ot,{}),options:{minWidth:350}};function ot(){let e=rt(),t=(0,d.useManifest)(),n=pe(_e(t?.service)||_e(t?.services)),r;return r=e===`scroll`?{ignoreCanvasBackgrounds:n.scroll.options.ignoreCanvasBackgrounds,tableOfContentsPlacement:n.scroll.options.tableOfContentsPlacement}:e===`slideshow`?{ignoreCanvasBackgrounds:n.delft.slideshow.ignoreCanvasBackgrounds}:{cutCorners:n.delft.exhibition.cutCorners,fullTitleBar:n.delft.exhibition.fullTitleBar,hideTableOfContents:n.delft.exhibition.hideTableOfContents,ignoreCanvasBackgrounds:n.delft.exhibition.ignoreCanvasBackgrounds,showNavigationControls:n.delft.exhibition.showNavigationControls,showProgressBar:n.delft.exhibition.showProgressBar,tableOfContentsPlacement:n.delft.exhibition.tableOfContentsPlacement},(0,p.jsx)($e,{preset:e,presetOptions:r,focusSelectedCanvas:!1})}function st({children:e}){let t=(0,d.useManifest)(),{edit:n}=(0,l.useLayoutActions)();return(0,p.jsxs)(`div`,{className:`grid auto-rows-auto grid-cols-12 content-center justify-center gap-2 p-2`,children:[(0,p.jsx)(`div`,{className:`col-span-12 row-span-2 text-black flex flex-col items-center justify-center`,children:(0,p.jsx)(v.Button,{onPress:()=>t&&n(t,void 0,{forceOpen:!0,selectedTab:`@manifest-editor/descriptive-properties`}),className:`col-span-4 row-span-4 text-md text-left text-black hover:bg-slate-100 w-full flex items-center justify-center`,children:(0,p.jsx)(d.LocaleString,{className:`block w-full text-left`,children:t?.label})})}),e]})}const ct={"h-1":`lg:min-h-[100px] row-span-1`,"h-2":`lg:min-h-[200px] row-span-2`,"h-3":`lg:min-h-[300px] row-span-3`,"h-4":`lg:min-h-[400px] row-span-4`,"h-5":`lg:min-h-[500px] row-span-5`,"h-6":`lg:min-h-[600px] row-span-6`,"h-7":`lg:min-h-[700px] row-span-7`,"h-8":`lg:min-h-[800px] row-span-8`,"h-9":`lg:min-h-[900px] row-span-9`,"h-10":`lg:min-h-[1000px] row-span-10`,"h-11":`lg:min-h-[1100px] row-span-11`,"h-12":`lg:min-h-[1200px] row-span-12`},lt={"h-1":`lg:min-h-[25px] row-span-1`,"h-2":`lg:min-h-[50px] row-span-2`,"h-3":`lg:min-h-[75px] row-span-3`,"h-4":`lg:min-h-[100px] row-span-4`,"h-5":`lg:min-h-[125px] row-span-5`,"h-6":`lg:min-h-[150px] row-span-6`,"h-7":`lg:min-h-[175px] row-span-7`,"h-8":`lg:min-h-[200px] row-span-8`,"h-9":`lg:min-h-[225px] row-span-9`,"h-10":`lg:min-h-[250px] row-span-10`,"h-11":`lg:min-h-[275px] row-span-11`,"h-12":`lg:min-h-[300px] row-span-12`},ut={"w-1":`col-span-1`,"w-2":`col-span-2`,"w-3":`col-span-3`,"w-4":`col-span-4`,"w-5":`col-span-5`,"w-6":`col-span-6`,"w-7":`col-span-7`,"w-8":`col-span-8`,"w-9":`col-span-9`,"w-10":`col-span-10`,"w-11":`col-span-11`,"w-12":`col-span-12`};function dt(e){let{isLeft:t,isRight:n,isBottom:r}=pt(e),i=e?.find(e=>e.includes(`h-`)),a=e?.find(e=>e.includes(`w-`));if(!i||!a)return{h:0,w:0,ratio:1};let o={h:Number.parseInt(i.split(`-`)[1]),w:Number.parseInt(a.split(`-`)[1]),ratio:1};return(t||n)&&(o.w*=2/3),r&&(o.h*=2/3),o.h&&o.w&&(o.ratio=o.w/o.h),o}function ft(e,t=!1,n=!0){(!e||e.length===0)&&(e=[`h-8`,`w-8`,`image`]);let r=e.find(e=>e.includes(`h-`)),i=e.find(e=>e.includes(`w-`)),a=[];return t&&r===`h-4`&&(r=`h-8`),a.push(n?lt[r]:ct[r]),a.push(ut[i]),a.join(` `)}function pt(e){let t=e?.includes(`right`),n=e?.includes(`left`),r=e?.includes(`bottom`),i=e?.includes(`top`),a=e?.includes(`image`)||!n&&!t&&!r&&!i;return{isRight:t,isLeft:n,isBottom:r,isTop:i,isInfo:e?.includes(`info`),isImage:a}}function mt(e,t){return t.get(e)?.type===`Canvas`}function ht(e,t){let n=e.source?.id,r=e.source?.type;if(!n||!r)return!1;try{return(t.get({id:n,type:r})?.behavior||[]).includes(`info`)}catch{return!1}}function gt(e,t){let n=e.source?.id,r=e.source?.type;if(!n||!r)return!1;try{let e=t.get({id:n,type:r}),i=Array.isArray(e?.items)?e.items:[];for(let e of i){let n=t.get(e,{skipSelfReturn:!1}),r=Array.isArray(n?.items)?n.items:[];for(let e of r){let n=t.get(e,{skipSelfReturn:!1}),r=Array.isArray(n?.body)?n.body[0]:n?.body,i=r?.id&&t.get(r,{skipSelfReturn:!1})||r,a=i?.type===`SpecificResource`?i.source:i,o=Array.isArray(a?.service)?a.service:a?.service?[a.service]:[];if(a?.type===`Video`||o.some(e=>e?.profile===`https://www.youtube.com`))return!0}}}catch{return!1}return!1}function _t(e){if(!e)return!1;let t=e.behavior||[];if(t.includes(`image`)||t.includes(`info`)||t.includes(`splash`))return!0;for(let e of t)if(e.startsWith(`w-`)||e.startsWith(`h-`))return!0;return!1}function vt(){let e=(0,d.useCanvas)();(0,x.default)(e);let t=e.width&&e.height?e.width/e.height:0,n=dt(e.behavior||[]);return Math.abs(t-n.ratio)<.01?null:(0,p.jsxs)(`div`,{className:`exhibition-aspect-warning p-2 rounded bg-me-100`,children:[(0,p.jsx)(`div`,{className:`font-semibold text-me-700`,children:`Aspect ratio warning`}),(0,p.jsxs)(`div`,{className:`text-sm text-black/60`,children:[`The aspect ratio of this canvas is `,t.toFixed(2),` but the target aspect ratio is `,n.ratio.toFixed(2),`. Some parts of this image may be cropped.`,(0,p.jsx)(`div`,{className:`relative h-32 w-full mt-2`,children:(0,p.jsx)(`div`,{className:`bg-[red] left-0 top-0 z-2 opacity-50 max-w-32 max-h-32`,style:{aspectRatio:t.toFixed(2)},children:(0,p.jsx)(`div`,{className:`asbolute bg-[white] left-0 top-0 z-1 opacity-50 max-w-32 max-h-32`,style:{aspectRatio:n.ratio}})})})]})]})}const yt=[{value:`float-top-left`,label:`Top left`},{value:`float-top`,label:`Top centre`},{value:`float-top-right`,label:`Top right`},{value:`float-left`,label:`Centre left`},{value:`float-right`,label:`Centre right`},{value:`float-bottom-left`,label:`Bottom left`},{value:`float-bottom`,label:`Bottom centre`},{value:`float-bottom-right`,label:`Bottom right`}],bt={"float-top-left":{x:2,y:2},"float-top":{x:8.5,y:2},"float-top-right":{x:15,y:2},"float-left":{x:2,y:8.5},"float-right":{x:15,y:8.5},"float-bottom-left":{x:2,y:15},"float-bottom":{x:8.5,y:15},"float-bottom-right":{x:15,y:15}};function xt({position:e}){return(0,p.jsxs)(`svg`,{width:`1.6em`,height:`1.6em`,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,children:[(0,p.jsx)(`rect`,{x:`2`,y:`2`,width:`20`,height:`20`,rx:`3`,stroke:`currentColor`,strokeWidth:`1.5`,opacity:`0.4`}),e?(0,p.jsx)(`rect`,{...bt[e],width:`7`,height:`7`,rx:`1.5`,fill:`currentColor`}):(0,p.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`,stroke:`currentColor`,strokeWidth:`1.5`,opacity:`0.7`})]})}function St({value:e,onChange:t}){let n=Ct();return(0,p.jsx)(`div`,{className:`grid w-fit grid-cols-3 gap-2`,children:n.map(n=>{let r=e===n.value;return(0,p.jsxs)(`button`,{type:`button`,title:n.label,"aria-pressed":r,className:`flex min-h-11 items-center justify-center rounded-md border px-3 py-2 transition-colors`,style:{backgroundColor:r?`var(--exhibition-primary, #b84c74)`:`#fff`,borderColor:r?`var(--exhibition-primary, #b84c74)`:`#dcd5ce`,color:r?`#fff`:`#332f2c`},onClick:()=>t(n.value),children:[(0,p.jsx)(xt,{position:n.value}),(0,p.jsx)(`span`,{className:`sr-only`,children:n.label})]},n.value||`off`)})})}function Ct(e=`No overlay`){return[...yt.slice(0,4),{value:``,label:e},...yt.slice(4)]}function wt(){let e=(0,d.useCanvas)(),t=(0,l.useEditingResource)(),n=(0,l.useInlineCreator)(),[r,i]=(0,l.useCreator)(t?.resource.source,`thumbnail`,`ContentResource`),{descriptive:a}=(0,l.useEditor)(),{thumbnail:o}=a,s=o.get()||[],c=(0,d.useVault)(),f=(0,m.useMemo)(()=>e?Dt(c,e):[],[e,c]);return!e||!t?null:!s.length&&f.length?(0,p.jsx)(Tt,{candidates:f,canCreateThumbnail:r,onCreateThumbnail:()=>i.create(),onAddThumbnail:({service:t,width:r,height:i})=>n.create(`@manifest-editor/thumbnail-image`,{service:t,width:r,height:i},Et(e))}):(0,p.jsx)(u.LinkingPropertyList,{containerId:o.containerId(),label:`Thumbnail`,property:`thumbnail`,items:s,singleMode:!0,reorder:e=>o.reorder(e.startIndex,e.endIndex),createActions:(0,u.createAppActions)(o),creationType:`ContentResource`,emptyLabel:`No thumbnail`,parent:t.resource})}function Tt({candidates:e,canCreateThumbnail:t,onCreateThumbnail:n,onAddThumbnail:r}){let[i,a]=(0,m.useState)(null),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)({}),d=e.find(e=>e.id===i)||e[0],f=d?c[d.id]:void 0,g=d?f===null?null:f||d.service:null,_=g?Nt(g):[],v=Ft(_,350),y=_.find(e=>Pt(e)===o)||v,b=g&&y?It(g,y):null,x=d&&!d.service.sizes?.length&&!(d.id in c);return(0,m.useEffect)(()=>{!i&&e[0]&&a(e[0].id)},[e,i]),(0,m.useEffect)(()=>{let t=e.filter(e=>{let t=e.service;return!t.sizes?.length&&jt(t)&&!(e.id in c)});for(let e of t){let t=jt(e.service);t&&fetch(Mt(t)).then(e=>e.ok?e.json():null).then(t=>{l(n=>({...n,[e.id]:t?{...e.service,...t}:null}))}).catch(()=>{l(t=>({...t,[e.id]:null}))})}},[e,c]),(0,m.useEffect)(()=>{v&&!_.some(e=>Pt(e)===o)&&s(Pt(v))},[v,o,_]),(0,p.jsx)(u.InputContainer,{$wide:!0,children:(0,p.jsxs)(`div`,{className:`rounded-md border border-[#dcd5ce] bg-[#f8f6f3] p-4`,children:[(0,p.jsx)(`div`,{className:`text-sm font-semibold text-[#25211f]`,children:`Thumbnail`}),(0,p.jsx)(`div`,{className:`mt-1 text-sm text-[#6a625c]`,children:`Use an image service from this canvas to add a thumbnail.`}),e.length>1?(0,p.jsxs)(`div`,{className:`mt-3`,children:[(0,p.jsx)(`label`,{className:`text-xs font-semibold uppercase text-[#6a625c]`,htmlFor:`thumbnail-source-image`,children:`Image`}),(0,p.jsx)(`select`,{id:`thumbnail-source-image`,className:`mt-1 w-full rounded-md border border-[#dcd5ce] bg-white px-3 py-2 text-sm`,value:d?.id||``,onChange:e=>{a(e.currentTarget.value),s(``)},children:e.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}):null,_.length?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:_.map(e=>{let t=Pt(e),n=y?t===Pt(y):!1;return(0,p.jsxs)(`button`,{type:`button`,className:`rounded-md border px-2 py-1 text-xs font-semibold`,style:{backgroundColor:n?`#b84c74`:`#ffffff`,borderColor:n?`#b84c74`:`#dcd5ce`,color:n?`#ffffff`:`#332f2c`},onClick:()=>s(t),children:[e.width,`x`,e.height]},t)})}),b?(0,p.jsx)(`div`,{className:`mt-3 overflow-hidden rounded-md border border-[#dcd5ce] bg-white`,children:(0,p.jsx)(`img`,{src:b,alt:``,className:`max-h-40 w-full object-contain`})}):null,(0,p.jsx)(`button`,{type:`button`,className:`mt-3 rounded-md px-3 py-2 text-sm font-semibold shadow-sm`,style:{backgroundColor:`#b84c74`,border:`1px solid #a13e63`,color:`#ffffff`},disabled:!b||!y,onClick:()=>{!g||!y||r({service:g,width:y.width,height:y.height})},children:`Add thumbnail from image`})]}):x?(0,p.jsx)(`div`,{className:`mt-3 text-sm text-[#6a625c]`,children:`Finding available sizes...`}):(0,p.jsx)(`div`,{className:`mt-3 text-sm text-[#6a625c]`,children:`No fixed thumbnail sizes were found for this image service.`}),t?(0,p.jsx)(`div`,{className:`mt-4 border-t border-[#dcd5ce] pt-3`,children:(0,p.jsxs)(h.ActionButton,{onPress:n,children:[(0,p.jsx)(h.AddIcon,{}),` Create thumbnail`]})}):null]})})}function Et(e){return{parent:{property:`thumbnail`,resource:{id:e.id,type:`Canvas`}}}}function Dt(e,t){let n=[],r=new Set;return W(e,t).forEach((t,i)=>{Ot(e,Ve(e,t)).forEach((e,a)=>{let o=At(e),s=o?jt(o):``;!o||!s||r.has(s)||(r.add(s),n.push({id:`${t.id||i}-${e.id||s}-${a}`,label:Lt(e.label)||Lt(t.label)||`Image ${n.length+1}`,imageId:e.id,service:o}))})}),n}function Ot(e,t){let n=kt(e,t);return n?n.type===`Choice`&&Array.isArray(n.items)?n.items.flatMap(t=>Ot(e,t)):n.type===`SpecificResource`?Ot(e,n.source):n.type===`Canvas`?W(e,n).flatMap(t=>Ot(e,Ve(e,t))):At(n)?[n]:[]:[]}function kt(e,t){return t?t.id&&!t.service&&!t.items&&!t.value&&e.get(t,{skipSelfReturn:!1})||t:null}function At(e){return(Array.isArray(e?.service)?e.service:e?.service?[e.service]:[]).find(e=>{let t=Array.isArray(e.profile)?e.profile.join(` `):e.profile||``;return(e.type||e[`@type`]||``).includes(`ImageService`)||t.includes(`level`)||t.includes(`iiif.io/api/image`)})||null}function jt(e){return(e.id||e[`@id`]||``).replace(/\/info\.json$/,``)}function Mt(e){return e.endsWith(`/info.json`)?e:`${e.replace(/\/$/,``)}/info.json`}function Nt(e){let t=Array.isArray(e.sizes)?e.sizes.filter(e=>Number(e.width)&&Number(e.height)).map(e=>({width:Number(e.width),height:Number(e.height)})):[];if(t.length)return t.sort((e,t)=>e.width-t.width).slice(0,8);let n=Number(e.width),r=Number(e.height);return!n||!r?[]:[256,512,1024].filter(e=>e<n).map(e=>({width:e,height:Math.round(r/n*e)})).concat([{width:n,height:r}]).slice(0,4)}function Pt(e){return`${e.width},${e.height||``}`}function Ft(e,t){return e.reduce((e,n)=>e?Math.hypot(n.width-t,n.height-t)<Math.hypot(e.width-t,e.height-t)?n:e:n,void 0)}function It(e,t){let n={...e};n[`@id`]&&(n.id=n[`@id`]),n[`@type`]&&(n.type=n[`@type`]);let r=(0,S.createImageServiceRequest)(n);return(0,S.imageServiceRequestToString)({identifier:r.identifier,server:r.server,scheme:r.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:r.prefix,originalPath:r.originalPath})}function Lt(e){return e?typeof e==`string`?e:Array.isArray(e)?e.filter(Boolean).join(` `):typeof e==`object`?Object.values(e).flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).join(` `):``:``}const Rt=new Set([`left`,`right`,`bottom`,`top`]),zt=new Set([...Rt,`image`]),Bt=new Set([`cover`,`image-cover`]);function Vt(e,t,n){let r=e.findIndex(e=>t.has(e)),i=e.filter(e=>!t.has(e));return i.splice(r<0?i.length:r,0,n),i}function Ht(e,t,n,r){let i=e.findIndex(e=>t.has(e)),a=e.filter(e=>!t.has(e));return r&&a.splice(i<0?a.length:i,0,n),a}function Ut(e,t){return Vt(e,t===`image`?zt:Rt,t)}const Wt=new Set([`scroll`,`page-scroll`]),Gt=new Set([`splash`,`fixed`,`invert`,`backdrop-light`,`backdrop-dark`,`compact-deck`]),Kt=[{value:`image`,label:`Image only`},{value:`top`,label:`Text above image`},{value:`bottom`,label:`Text below image`},{value:`left`,label:`Text left of image`},{value:`right`,label:`Text right of image`}],G={primary:`var(--exhibition-primary, #b84c74)`,fieldBorder:`var(--exhibition-field-border, #dcd5ce)`,fieldBackground:`var(--exhibition-field-bg, #f8f6f3)`,text:`var(--exhibition-text, #25211f)`,muted:`var(--exhibition-muted, #6a625c)`,buttonBackground:`var(--exhibition-button-bg, #ffffff)`,buttonText:`var(--exhibition-button-text, #ffffff)`,inactiveButtonText:`var(--exhibition-inactive-button-text, #332f2c)`},qt=[{value:12,label:`Full width`},{value:8,label:`2/3 width`},{value:6,label:`Half width`},{value:4,label:`1/3 width`}],Jt=new Set(yt.map(e=>e.value));function Yt(e){return e.some(e=>Wt.has(e))}function Xt(e){return e.some(e=>Bt.has(e))}function Zt(e,t){return e===`slideshow`||e===`scroll`||e===`fullpage`?e:t===`exhibition-slideshow-editor`?`slideshow`:t===`exhibition-scrolling-editor`?`scroll`:`fullpage`}function Qt(e,t=!1,n=!0,r=!1,i=!0){let a=e===`scroll`||t;return{showGridSizing:e===`fullpage`&&!t&&!r,isSlideshow:e===`slideshow`,showFloating:!r&&(e===`slideshow`||e===`scroll`||t),showImageCover:i&&!r&&(e===`fullpage`&&!t||a&&n),showScrollToggle:!r&&e===`fullpage`,showScrollDisplay:e===`slideshow`||e===`scroll`,showFixedCover:e===`scroll`,showCoverBackdrop:!1,scrollContext:a,layoutOptions:r?[]:a?n?[{value:`left`,label:`Annotations on left`},{value:`right`,label:`Annotations on right`}]:[]:Kt}}function $t(e=[],t=!0){let n=(0,l.useApp)();return Qt(Zt(V()?.type,n.metadata.id),Yt(e),t,e.includes(`splash`))}const en={component:()=>(0,p.jsx)(ln,{}),supports:{edit:!0,resourceTypes:[`Canvas`],properties:[`behavior`],custom:({resource:e},t)=>mt(e,t)?!ht(e,t):!1},id:`slide-behaviors`,label:`Layout`,tabs:{showTitle:!0}},tn={id:`floating`,type:`choice`,label:{en:[`Floating`]},initialOpen:!1,addNone:!0,groupBehavior:`floating`,items:yt.map(e=>({label:{en:[`Float ${e.label.toLowerCase()}`]},value:e.value}))},nn={id:`size`,component:(e,t)=>(0,p.jsx)(cn,{behaviors:e,setBehaviors:t}),label:{en:[`Size`]},type:`custom`,initialOpen:!0,supports:e=>e.startsWith(`w-`)||e.startsWith(`h-`)};function rn({behaviors:e,setBehaviors:t,flags:n}){let r=(n,r)=>{let i=Ht(e,new Set([n.value,...n.aliases||[],...n.group||[]]),n.value,r);t(n.clean?n.clean(i,r):i)};return(0,p.jsx)(`div`,{className:`flex flex-col gap-2`,children:n.map(t=>(0,p.jsx)(_n,{checked:e.includes(t.value)||!!t.aliases?.some(t=>e.includes(t)),label:t.label,onChange:e=>r(t,e)},t.value))})}function an({behaviors:e,setBehaviors:t,options:n}){let r=yn(e);return(0,p.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:n.map(n=>(0,p.jsx)(gn,{selected:r===n.value&&(n.value===`image`||e.includes(n.value)),onClick:()=>t(Ut(e,n.value)),children:n.label},n.value))})}function on(e,t=[],n=!0,r=!0,i=!0){let a=Qt(e,Yt(t),r,t.includes(`splash`)&&n,i),o=a.showScrollDisplay&&n,s=[];return a.layoutOptions.length&&!(a.isSlideshow&&Sn(t))&&s.push({id:`layout`,type:`custom`,label:{en:[`Layout`]},initialOpen:!0,supports:e=>zt.has(e),component:(e,t)=>(0,p.jsx)(an,{behaviors:e,setBehaviors:t,options:a.layoutOptions})}),a.showScrollToggle&&s.push({id:`scroll`,type:`custom`,label:{en:[`Scrolling section`]},initialOpen:!1,supports:e=>Wt.has(e),component:(e,t)=>(0,p.jsx)(rn,{behaviors:e,setBehaviors:t,flags:[{value:`scroll`,label:`Show as a scrolling section`,aliases:[`page-scroll`],clean:(e,t)=>t?e.filter(e=>!En(e)):e}]})}),a.showImageCover&&s.push({id:`display`,type:`custom`,label:{en:[`Display`]},initialOpen:!1,supports:e=>Bt.has(e),component:(e,t)=>(0,p.jsx)(rn,{behaviors:e,setBehaviors:t,flags:[{value:`cover`,label:`Crop image to fill its frame`,aliases:[`image-cover`]}]})}),o&&s.push({id:`cover`,type:`custom`,label:{en:[`Cover`]},initialOpen:!1,supports:e=>Gt.has(e),component:(e,t)=>(0,p.jsx)(rn,{behaviors:e,setBehaviors:t,flags:[{value:`splash`,label:`Use as opening cover`},...a.showFixedCover?[{value:`fixed`,label:`Keep image fixed while scrolling`}]:[],{value:`invert`,label:`Use light text`}]})}),a.showFloating&&s.push(tn),a.showGridSizing&&s.push(nn),s}function sn(e){let t=0,n=0;for(let r of e)r.startsWith(`w-`)&&(t=Number.parseInt(r.slice(2))),r.startsWith(`h-`)&&(n=Number.parseInt(r.slice(2)));return{width:t,height:n}}function cn({behaviors:e,setBehaviors:t}){let{width:n,height:r}=sn(e),[i,a]=(0,m.useState)({x:-1,y:-1}),o=(n,r)=>{let i=e.filter(e=>!e.startsWith(`w-`)&&!e.startsWith(`h-`));i.push(`w-${n}`),i.push(`h-${r}`),t(i)},s=Array.from({length:144},(e,t)=>{let s=t%12,c=Math.floor(t/12),l=i.x>=s&&i.y>=c,u=s<n&&c<r,d=l&&u,f=`bg-gray-200`;return l&&(f=`bg-me-200`),u&&(f=`bg-me-500`),d&&(f=`bg-me-400`),(0,p.jsx)(`div`,{className:`flex aspect-square rounded cursor-se-resize items-center justify-center ${f}`,onClick:()=>o(s+1,c+1),onMouseUp:()=>o(s+1,c+1),onMouseEnter:()=>a({x:s,y:c})},t)});return(0,p.jsx)(`div`,{className:`grid grid-cols-12 grid-rows-12 gap-1`,onMouseLeave:()=>a({x:-1,y:-1}),children:s})}function ln(){let[e,t]=(0,l.useLocalStorage)(`exhibition-layout-panel-mode`,`simple`),n=U(e=>e.setCenterPanelMode);return(0,m.useEffect)(()=>{n(`preview`)},[n]),(0,p.jsx)(h.Sidebar,{children:(0,p.jsxs)(h.SidebarContent,{className:`bg-white px-6 pt-5 pb-20`,children:[(0,p.jsx)(`div`,{className:`mb-6 flex justify-center`,children:(0,p.jsx)(vn,{value:e,onChange:t})}),(0,p.jsx)(un,{mode:e})]})})}function un({mode:e=`advanced`,layoutContext:t=`default`}){let n=(0,u.useInStack)(`Canvas`),r=(0,d.useCanvas)(),i=(0,l.useEditor)(),a=(0,l.useApp)(),o=(0,d.useVault)(),s=(0,d.useManifest)(),c=Zt(V()?.type,t===`slideshow`?`exhibition-slideshow-editor`:a.metadata.id),{width:f,height:m}=i.technical,h=i.technical.behavior.get()||[],g=(0,d.useVaultSelector)((e,t)=>r?Me(t,r).length>0:!1,[r?.id,r?.annotations?.[0]?.id]),_=!!(r&&On(o,r)),v=!!(r&&Dn(s)===r.id&&_),y=Qt(c,Yt(h),g,h.includes(`splash`)&&v,_);return!n||i.technical.type!==`Canvas`?(0,p.jsx)(`div`,{className:`p-4`,children:`Please select canvas`}):e===`simple`?(0,p.jsx)(dn,{behavior:i.technical.behavior.get()||[],controls:y,canvasWidth:f.get()||0,canvasHeight:m.get()||0,onChange:e=>{i.technical.behavior.set(e)}}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`px-2`,children:(0,p.jsxs)(u.InputContainer,{$wide:!0,children:[(0,p.jsx)(u.DimensionsTriplet,{widthId:f.containerId(),width:f.get()||0,changeWidth:e=>f.set(e),heightId:m.containerId(),height:m.get()||0,changeHeight:e=>m.set(e)}),(0,p.jsx)(`div`,{children:(0,p.jsx)(vt,{})})]})}),(0,p.jsx)(u.BehaviorEditor,{behavior:i.technical.behavior.get()||[],onChange:e=>{i.technical.behavior.set(e)},configs:on(c,h,v,g,_)}),(0,p.jsx)(wt,{})]})}function dn({behavior:e,controls:t,canvasWidth:n,canvasHeight:r,onChange:i}){let a=yn(e),o=t.showGridSizing?xn(e):12,s=Sn(e),c=Cn(e),l=Xt(e),u=Yt(e),f=e.includes(`splash`),m=e.includes(`fixed`),h=e.includes(`invert`),g=e.includes(`backdrop-dark`)?`backdrop-dark`:e.includes(`backdrop-light`)?`backdrop-light`:``,_=U(e=>e.requestTab),v=(0,d.useCanvas)(),y=(0,d.useVault)(),b=(0,d.useManifest)(),x=t.showGridSizing?o:12,S=kn({canvasWidth:n,canvasHeight:r,layoutPreset:a,displayWidth:x}),C=t.showGridSizing&&b?.items&&v?Mn(v.id,b.items,y):null,w=!!(v&&Dn(b)===v.id&&On(y,v)),T=d=>{let p=t.layoutOptions.length?d.layoutPreset??a:void 0,_=t.showGridSizing?d.displayWidth??o:12,b=d.floating??s,x=d.floatingBehavior??c,S=d.cover??l,C=d.scrollEnabled??u,T=d.splash??f,E=d.fixed??m,D=d.invert??h,O=d.backdrop??g;i(Tn({behavior:e,layoutPreset:p,displayWidth:_,canvasWidth:n,canvasHeight:r,floating:b,floatingBehavior:x,cover:S,scrollEnabled:C,splash:T,fixed:t.showFixedCover&&E,invert:D,backdrop:t.showCoverBackdrop?O:``,showGridSizing:t.showGridSizing&&!C,showFloating:t.showFloating,showImageCover:t.showImageCover,showScrollToggle:t.showScrollToggle,showScrollDisplay:t.showScrollDisplay&&w})),v&&p&&Pn(y,v,p)};return(0,p.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,p.jsx)(fn,{layoutPreset:a,cover:l,floating:s,width:x,height:S,showGridSizing:t.showGridSizing,onTextClick:()=>_(`summary`)}),t.layoutOptions.length&&!(t.isSlideshow&&s)?(0,p.jsxs)(K,{children:[(0,p.jsx)(q,{children:`Text placement`}),(0,p.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:t.layoutOptions.map(e=>(0,p.jsx)(pn,{preset:e.value,label:e.label,selected:a===e.value,onClick:()=>T({layoutPreset:e.value})},e.value))})]}):null,t.showGridSizing?(0,p.jsxs)(K,{children:[(0,p.jsx)(q,{children:`Width`}),(0,p.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:qt.map(e=>(0,p.jsx)(gn,{selected:o===e.value,onClick:()=>T({displayWidth:e.value}),children:e.label},e.value))})]}):null,C?(0,p.jsxs)(K,{children:[(0,p.jsxs)(q,{children:[`Fit alongside `,C.neighbour,` slide`]}),(0,p.jsx)(`div`,{className:`mt-3`,children:(0,p.jsxs)(gn,{selected:o===C.width,onClick:()=>T({displayWidth:C.width}),children:[`w-`,C.width,` — fills remaining space`]})})]}):null,(0,p.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t.showScrollToggle?(0,p.jsx)(_n,{checked:u,label:`Show as a scrolling section`,onChange:e=>T({scrollEnabled:e})}):null,t.showFloating?(0,p.jsx)(_n,{checked:s,label:`Overlay text on the image`,onChange:e=>T({floating:e})}):null,t.isSlideshow&&s?(0,p.jsxs)(K,{children:[(0,p.jsx)(q,{children:`Text overlay position`}),(0,p.jsx)(`div`,{className:`mt-3`,children:(0,p.jsx)(St,{value:c,onChange:e=>{T(e?{floatingBehavior:e}:{floating:!1})}})})]}):null,t.showImageCover?(0,p.jsx)(_n,{checked:l,label:`Crop image to fill its frame`,onChange:e=>T({cover:e})}):null,t.showScrollDisplay&&w?(0,p.jsxs)(K,{children:[(0,p.jsx)(q,{children:`Cover`}),(0,p.jsxs)(`div`,{className:`mt-3 flex flex-col gap-3`,children:[(0,p.jsx)(_n,{checked:f,label:`Use as opening cover`,onChange:e=>T({splash:e})}),t.showFixedCover?(0,p.jsx)(_n,{checked:m,label:`Keep image fixed while scrolling`,onChange:e=>T({fixed:e})}):null,(0,p.jsx)(_n,{checked:h,label:`Use light text`,onChange:e=>T({invert:e})}),t.showCoverBackdrop?(0,p.jsxs)(K,{children:[(0,p.jsx)(q,{children:`Backdrop`}),(0,p.jsx)(`div`,{className:`mt-3 grid grid-cols-3 gap-2`,children:[{value:``,label:`Default`},{value:`backdrop-light`,label:`Light`},{value:`backdrop-dark`,label:`Dark`}].map(e=>(0,p.jsx)(gn,{selected:g===e.value,onClick:()=>T({backdrop:e.value}),children:e.label},e.value||`default`))})]}):null]})]}):null]})]})}function fn({layoutPreset:e,cover:t,floating:n,width:r,height:i,showGridSizing:a,onTextClick:o}){let s=e===`bottom`,c=e===`image`,l=e===`left`;return(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`relative mx-auto overflow-hidden rounded-md border bg-[#f8f6f3] shadow-sm`,style:{width:`${Math.max(33,Math.round(r/12*100))}%`,aspectRatio:`${r} / ${i}`,borderColor:G.fieldBorder},children:[(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`flex h-full w-full min-h-0`,l?`flex-row-reverse`:s?`flex-col`:`flex-row`),children:[(0,p.jsx)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden bg-white`,children:(0,p.jsx)(`div`,{className:`absolute inset-0`,children:(0,p.jsx)(h.LazyThumbnail,{cover:t,fade:!1})})}),c?null:(0,p.jsx)(`button`,{type:`button`,"aria-label":`Edit slide text`,className:(0,y.twMerge)(`flex-shrink-0 border-0 bg-[#25211f] p-3 text-left text-white transition-colors hover:bg-[#332f2c] focus:outline-none focus:ring-2 focus:ring-me-primary-500 focus:ring-offset-2`,s?`h-1/3 w-full`:`h-full w-1/3`),onClick:o,children:(0,p.jsx)(hn,{tone:`light`})})]}),n?(0,p.jsx)(`div`,{className:`absolute right-2 top-2 h-7 w-10 rounded bg-white/90 shadow ring-1 ring-black/10`}):null]}),a?(0,p.jsxs)(`div`,{className:`mt-2 text-center text-xs`,style:{color:G.muted},children:[`w-`,r,` h-`,i]}):null]})}function pn({preset:e,label:t,selected:n,onClick:r}){return(0,p.jsxs)(`button`,{type:`button`,"aria-pressed":n,className:`flex min-h-[112px] flex-col items-center justify-center gap-3 rounded-md border px-3 py-4 text-center text-sm font-semibold transition-colors`,style:{backgroundColor:n?G.primary:G.buttonText,borderColor:n?G.primary:G.fieldBorder,color:n?G.buttonText:G.inactiveButtonText},onClick:r,children:[(0,p.jsx)(mn,{preset:e,selected:n}),(0,p.jsx)(`span`,{className:`leading-tight`,children:t})]})}function mn({preset:e,selected:t}){let n=e===`image`,r=e===`bottom`,i=e===`top`,a=e===`left`,o=t?`bg-white/80`:`bg-[#25211f]`,s=t?`bg-white/25 ring-white/70`:`bg-[#f8f6f3] ring-[#dcd5ce]`;return(0,p.jsxs)(`span`,{className:(0,y.twMerge)(`flex h-12 w-16 gap-1 overflow-hidden rounded border p-1`,t?`border-white/70 bg-white/15`:`border-[#dcd5ce] bg-white`,a?`flex-row-reverse`:r?`flex-col`:i?`flex-col-reverse`:`flex-row`),"aria-hidden":`true`,children:[(0,p.jsx)(`span`,{className:(0,y.twMerge)(`flex-1 rounded-sm ring-1`,s)}),n?null:(0,p.jsx)(`span`,{className:(0,y.twMerge)(`flex flex-shrink-0 flex-col justify-center gap-0.5 rounded-sm px-0.5`,o,r||i?`h-3 w-full`:`h-full w-4`),children:(0,p.jsx)(hn,{compact:!0,tone:t?`dark`:`light`})})]})}function hn({compact:e=!1,tone:t=`light`}){let n=t===`light`?`bg-white/70`:`bg-[#8b3f61]/70`;return(0,p.jsxs)(`span`,{className:(0,y.twMerge)(`block space-y-1.5`,e?`space-y-0.5`:`mt-1`),"aria-hidden":`true`,children:[(0,p.jsx)(`span`,{className:(0,y.twMerge)(`block rounded`,n,e?`h-0.5 w-full`:`h-1.5 w-3/4`)}),(0,p.jsx)(`span`,{className:(0,y.twMerge)(`block rounded`,n,e?`h-0.5 w-4/5`:`h-1.5 w-full`)}),(0,p.jsx)(`span`,{className:(0,y.twMerge)(`block rounded`,n,e?`h-0.5 w-2/3`:`h-1.5 w-2/3`)})]})}function gn({selected:e,onClick:t,children:n,title:r}){return(0,p.jsx)(`button`,{type:`button`,title:r,"aria-pressed":e,className:`flex min-h-11 items-center justify-center gap-1.5 rounded-md border px-3 py-2 text-sm font-semibold transition-colors`,style:{backgroundColor:e?G.primary:G.buttonText,borderColor:e?G.primary:G.fieldBorder,color:e?G.buttonText:G.inactiveButtonText,boxShadow:e?`0 0 0 2px ${G.primary}33`:void 0},onClick:t,children:n})}function _n({checked:e,label:t,onChange:n}){return(0,p.jsxs)(`label`,{className:`flex items-center justify-between rounded-md border px-4 py-3 text-sm font-semibold`,style:{backgroundColor:G.fieldBackground,borderColor:G.fieldBorder,color:G.text},children:[t,(0,p.jsx)(`input`,{type:`checkbox`,className:`h-4 w-4 accent-me-primary-500`,checked:e,onChange:e=>n(e.currentTarget.checked)})]})}function vn({value:e,onChange:t}){return(0,p.jsx)(`div`,{role:`group`,"aria-label":`Editing mode`,className:`grid w-full max-w-[240px] grid-cols-2 rounded-full bg-[#f5eaf0] p-1`,children:[`simple`,`advanced`].map(n=>{let r=e===n;return(0,p.jsx)(v.Button,{"aria-pressed":r,className:`border-none rounded-full bg-transparent px-4 py-2 text-sm font-semibold capitalize transition-colors`,style:{backgroundColor:r?G.primary:`transparent`,color:r?`#ffffff`:`#8b3f61`,boxShadow:r?`0 1px 3px rgba(15, 23, 42, 0.18)`:`none`},onPress:()=>t(n),children:n},n)})})}function K({children:e}){return(0,p.jsx)(`div`,{children:e})}function q({children:e}){return(0,p.jsx)(`div`,{className:`text-sm font-semibold`,style:{color:G.muted},children:e})}function yn(e){return e.includes(`left`)?`left`:e.includes(`top`)?`top`:e.includes(`bottom`)?`bottom`:e.includes(`right`)?`right`:(e.includes(`image`),`image`)}function bn(e,t,n){let r=Ut(e,t);if(n?.width&&n?.height){let{width:i}=sn(e),a=i?i<=4?4:i<=6?6:i<=8?8:12:12,o=kn({canvasWidth:n.width,canvasHeight:n.height,layoutPreset:t,displayWidth:a}),s=r.filter(e=>!e.startsWith(`h-`));return s.push(`h-${o}`),s}return r}function xn(e){let{width:t}=sn(e);return t?t<=4?4:t<=6?6:t<=8?8:12:12}function Sn(e){return e.includes(`floating`)||e.some(e=>Jt.has(e))}function Cn(e){return e.find(e=>Jt.has(e))||`float-top-right`}function wn(e,t){let n=e.filter(e=>e!==`floating`&&!Jt.has(e));return t?[...n,t]:n}function Tn({behavior:e,layoutPreset:t,displayWidth:n,canvasWidth:r,canvasHeight:i,floating:a,floatingBehavior:o,cover:s,scrollEnabled:c,splash:l,fixed:u,invert:d,backdrop:f,showGridSizing:p,showFloating:m,showImageCover:h,showScrollToggle:g,showScrollDisplay:_}){let v=e.filter(e=>!((p||c)&&En(e)||m&&(e===`floating`||Jt.has(e))||h&&Bt.has(e)||g&&Wt.has(e)||_&&Gt.has(e)));if(t&&(v=Ut(v,t)),g&&c&&v.push(`scroll`),p){let e=kn({canvasWidth:r,canvasHeight:i,layoutPreset:t||`image`,displayWidth:n});v.push(`w-${n}`,`h-${e}`)}return m&&a&&v.push(o||`float-top-right`),h&&s&&v.push(`cover`),_&&(l&&v.push(`splash`),u&&v.push(`fixed`),d&&v.push(`invert`),f&&v.push(f)),v}function En(e){return e.startsWith(`w-`)||e.startsWith(`h-`)||e.startsWith(`start-`)}function Dn(e){return e?.items?.[0]?.id}function On(e,t){return!t||t.behavior?.includes(`info`)?!1:W(e,t).some(t=>{let n=Ve(e,t),r=n?.type===`SpecificResource`?n.source:n,i=Array.isArray(r?.service)?r.service:r?.service?[r.service]:[];return r?.type===`Image`||i.length>0})}function kn({canvasWidth:e,canvasHeight:t,layoutPreset:n,displayWidth:r}){let i=e&&t?e/t:1.5,a=n===`left`||n===`right`?2/3*r:r,o=n===`bottom`?3/2:1,s=Math.round(a/i*o);return Math.max(1,Math.min(12,s))}const An=[{value:4,label:`1/3 width`},{value:6,label:`Half width`},{value:8,label:`2/3 width`},{value:12,label:`Full width`}];function jn(e){let{width:t}=sn(e);return t}function Mn(e,t,n){let r=t.findIndex(t=>t.id===e);if(r===-1)return null;let i=e=>{if(!e)return 0;try{return jn(n.get(e)?.behavior||[])}catch{return 0}},a=i(t[r-1]),o=i(t[r+1]);if(a>0&&a<12){let e=12-a;if(e>=4)return{width:e,neighbour:`previous`}}if(o>0&&o<12){let e=12-o;if(e>=4)return{width:e,neighbour:`next`}}return null}const Nn=new Set([`left`,`right`,`bottom`,`top`]);function Pn(e,t,n){Nn.has(n)&&((0,u.getInternationalStringText)(t.label)||e.modifyEntityField(t,`label`,{en:[`Untitled`]}),(0,u.getInternationalStringText)(t.summary)||e.modifyEntityField(t,`summary`,{en:[`Add a description for this slide.`]}))}const Fn=`non-linear-tour`,In=`tour-marker-pin`,Ln=`editorial-text`;function Rn({className:e,editable:t=!1,mode:n=`edit`,showTourSteps:r=!1}){let i=(0,d.useCanvas)(),a=(0,d.useVault)(),o=(0,u.useInStack)(`Annotation`),s=(0,m.useRef)(null),[c,l]=(0,m.useState)(null),f=U(e=>e.requestTab),{selectedAnnotationId:h,repositioningAnnotationId:g,selectedTextRegion:_,repositioningTextRegion:v,selectedTourStepId:b,selectAnnotation:x,startRepositioning:S,selectTextRegion:C,selectTourStep:w}=H(),T=(0,d.useVaultSelector)((e,t)=>i?Fe(t,i):[],[i?.id,i?.items?.[0]?.id]),E=(0,d.useVaultSelector)((e,t)=>i?Me(t,i):[],[i?.id,i?.annotations?.[0]?.id]),D=o?.resource.source.id,O=n===`edit`&&r,k=Array.isArray(i?.behavior)?i.behavior:[],A=k.includes(Fn),j=k.includes(`tour-marker-pin`)?`pin`:`circle`,M=n===`edit`&&!r,N=E.find(e=>e.id===c);if((0,m.useEffect)(()=>{l(null)},[i?.id,r]),(0,m.useEffect)(()=>{A&&O&&b&&l(b)},[A,b,O]),!i)return null;let P=Number(i.width)||1920,F=Number(i.height)||1080,I=ze(i);return(0,p.jsxs)(`div`,{ref:s,className:(0,y.twMerge)(`relative h-full w-full overflow-hidden`,n===`edit`&&`bg-white`,e),style:{aspectRatio:`${P} / ${F}`},children:[T.length?T.map(e=>{let r=D===e.annotation.id,o=r||h===e.annotation.id,c=g===e.annotation.id;return(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`absolute overflow-hidden`,M&&o&&`ring-4 ring-me-primary-500 ring-offset-2 ring-offset-white`,(c||r)&&M&&`cursor-move select-none touch-none`),style:{left:`${e.box.x/P*100}%`,top:`${e.box.y/F*100}%`,width:`${e.box.width/P*100}%`,height:`${e.box.height/F*100}%`},onPointerDown:M&&(c||r)?t=>Kn({event:t,mode:`move`,canvas:i,annotation:e.annotation,vault:a,startBox:e.box,stage:s.current}):M&&t?t=>{x(e.annotation.id),S(e.annotation.id),f(`content`),Kn({event:t,mode:`move`,canvas:i,annotation:e.annotation,vault:a,startBox:e.box,stage:s.current})}:void 0,children:[(0,p.jsx)(Gn,{layer:e,mode:n,cover:k.includes(`cover`)||k.includes(`image-cover`)}),M&&(c||r)?(0,p.jsx)(`div`,{className:`absolute bottom-0 right-0 h-4 w-4 cursor-se-resize rounded-tl bg-me-primary-500`,onPointerDown:t=>{t.stopPropagation(),Kn({event:t,mode:`resize`,canvas:i,annotation:e.annotation,vault:a,startBox:e.box,stage:s.current})}}):null]},e.annotation.id)}):(0,p.jsx)(`div`,{className:(0,y.twMerge)(`flex h-full w-full items-center justify-center text-sm font-semibold`,n===`preview`?`text-white/70`:`bg-white text-slate-600`),children:n===`preview`?`This slide has no content yet`:`Empty slide`}),I.text?(0,p.jsx)(Wn,{canvas:i,box:I.text,editable:t&&M,mode:n,repositioning:v===Ln,selected:_===Ln,stage:s,onSelect:()=>{C(Ln),f(`content`)}}):null,O?E.map((e,t)=>(0,p.jsx)(zn,{annotation:e,canvas:i,index:t,active:c===e.id,markerStyle:j,nonLinear:A,selected:b===e.id,onSelect:()=>{w(e.id),A&&l(e.id)}},e.id)):null,O&&A&&N?(0,p.jsx)(Hn,{annotation:N,onExit:()=>l(null)}):null]})}function zn({active:e,annotation:t,canvas:n,index:r,markerStyle:i,nonLinear:a,selected:o,onSelect:s}){let c=Ie(t,n),l=Array.isArray(n.behavior)?n.behavior:[],u=Array.isArray(t.behavior)?t.behavior:[],d=Sn(l)?Cn(u.length?u:l):null,f=Number(n.width)||1920,m=Number(n.height)||1080,h=`#6d5aa8`;return a?(0,p.jsx)(`button`,{type:`button`,className:(0,y.twMerge)(`absolute z-30 border-none bg-transparent p-0 transition-transform hover:scale-110 focus:outline-none focus:ring-4 focus:ring-white/80`,e&&`z-40 scale-110`),style:{left:`${(c.x+c.width/2)/f*100}%`,top:`${(c.y+c.height/2)/m*100}%`,transform:`translate(-50%, -50%)`},onClick:e=>{e.stopPropagation(),s()},children:(0,p.jsx)(Bn,{index:r+1,style:i})}):(0,p.jsxs)(`button`,{type:`button`,"aria-label":`Select tour step ${r+1}`,className:(0,y.twMerge)(`absolute select-none border-2 border-me-primary-500 bg-me-primary-500/10 touch-none`,o?`z-40`:`z-30`,`cursor-pointer`,o?`border-4`:`ring-2 ring-white`),style:{left:`${c.x/f*100}%`,top:`${c.y/m*100}%`,width:`${c.width/f*100}%`,height:`${c.height/m*100}%`,...o?{backgroundColor:`rgba(109, 90, 168, 0.2)`,borderColor:h,boxShadow:`0 0 0 4px rgba(109, 90, 168, 0.22), 0 0 0 8px rgba(109, 90, 168, 0.14)`}:{}},onClick:e=>{e.stopPropagation(),s()},children:[(0,p.jsx)(`span`,{className:`absolute left-1 top-1`,children:(0,p.jsx)(Vn,{index:r+1})}),(0,p.jsxs)(`span`,{className:(0,y.twMerge)(`absolute rounded px-1.5 py-0.5 text-xs font-semibold text-white`,Un(d),!o&&`bg-me-primary-500`),style:o?{backgroundColor:h}:void 0,children:[`Step `,r+1]})]})}function Bn({index:e,style:t}){return(0,p.jsxs)(`span`,{className:(0,y.twMerge)(`inline-flex items-center justify-center border-2 border-white bg-black text-white shadow-lg ring-1 ring-black/40`,t===`pin`?`h-10 w-10 rounded-full`:`h-8 min-w-8 rounded px-2 text-xs font-semibold`),children:[t===`pin`?(0,p.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full bg-white`,"aria-hidden":`true`}):e,(0,p.jsxs)(`span`,{className:`sr-only`,children:[`Tour step `,e]})]})}function Vn({index:e}){return(0,p.jsxs)(`span`,{className:`inline-flex h-10 w-10 items-center justify-center rounded-full border-2 border-white bg-black shadow-lg ring-1 ring-black/40`,children:[(0,p.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full bg-white`,"aria-hidden":`true`}),e?(0,p.jsxs)(`span`,{className:`sr-only`,children:[`Tour step `,e]}):null]})}function Hn({annotation:e,onExit:t}){let n=Jn(e.label),r=Jn(e.summary);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`absolute right-4 top-4 z-50`,children:(0,p.jsx)(`button`,{type:`button`,className:`rounded bg-white px-4 py-2 text-sm font-semibold text-slate-900 shadow ring-1 ring-black/10`,onClick:t,children:`Exit`})}),(0,p.jsxs)(`div`,{className:`absolute left-4 top-4 z-50 max-h-[calc(100%-2rem)] w-[min(26rem,calc(100%-2rem))] overflow-y-auto rounded bg-white p-5 text-slate-900 shadow-2xl ring-1 ring-black/10`,children:[(0,p.jsxs)(`div`,{className:`mb-4 flex items-start justify-between gap-3`,children:[(0,p.jsx)(`h3`,{className:`text-xl font-bold leading-tight`,children:n||`Tour step`}),(0,p.jsx)(`button`,{type:`button`,className:`text-2xl leading-none text-slate-900`,"aria-label":`Close`,onClick:t,children:`x`})]}),r?(0,p.jsx)(`p`,{className:`mb-4 text-sm leading-relaxed text-slate-700`,children:r}):null,(0,p.jsx)(d.AnnotationContext,{annotation:e.id,children:(0,p.jsx)(h.HTMLAnnotationBodyRender,{className:`prose prose-sm max-w-none text-slate-800`,locale:`en`})})]})]})}function Un(e){switch(e){case`float-top`:return`left-1/2 top-1 -translate-x-1/2`;case`float-top-right`:return`right-1 top-1`;case`float-left`:return`left-1 top-1/2 -translate-y-1/2`;case`float-right`:return`right-1 top-1/2 -translate-y-1/2`;case`float-bottom-left`:return`bottom-1 left-1`;case`float-bottom`:return`bottom-1 left-1/2 -translate-x-1/2`;case`float-bottom-right`:return`bottom-1 right-1`;default:return`left-1 top-1`}}function Wn({canvas:e,box:t,editable:n,mode:r,onSelect:i,repositioning:a,selected:o,stage:s}){let c=Number(e.width)||1920,l=Number(e.height)||1080,u=(0,d.useVault)();return(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`absolute flex flex-col overflow-hidden bg-black text-white`,r===`preview`?`font-mono`:`p-[3%]`,n&&o&&`ring-4 ring-me-primary-500 ring-offset-2`,n&&a&&`cursor-move select-none touch-none`),style:{left:`${t.x/c*100}%`,top:`${t.y/l*100}%`,width:`${t.width/c*100}%`,height:`${t.height/l*100}%`,...r===`preview`?{containerType:`inline-size`,padding:`3% 4%`}:{}},onPointerDown:n?n=>{i(),a&&qn({event:n,mode:`move`,canvas:e,vault:u,startBox:t,stage:s.current})}:void 0,children:[r===`edit`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`block cursor-text text-xl font-semibold uppercase leading-tight outline-none focus:ring-2 focus:ring-white/70`,contentEditable:!0,suppressContentEditableWarning:!0,onBlur:t=>u.modifyEntityField(e,`label`,{en:[t.currentTarget.textContent||``]}),children:Jn(e.label)||`Untitled`}),(0,p.jsx)(`div`,{className:`mt-4 block min-h-0 cursor-text overflow-y-auto whitespace-pre-wrap text-sm leading-relaxed opacity-90 outline-none focus:ring-2 focus:ring-white/70`,contentEditable:!0,suppressContentEditableWarning:!0,onBlur:t=>u.modifyEntityField(e,`summary`,{en:[t.currentTarget.textContent||``]}),children:Jn(e.summary)||`Add editorial text`})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(d.LocaleString,{className:`block font-semibold uppercase leading-tight`,style:{fontSize:`clamp(13px, 5cqw, 26px)`},children:e.label}),(0,p.jsx)(d.LocaleString,{className:`block min-h-0 overflow-y-auto whitespace-pre-wrap opacity-90 leading-[1.45]`,style:{fontSize:`clamp(11px, 3.5cqw, 18px)`,marginTop:`5%`,paddingRight:`2%`},children:e.summary})]}),n&&a?(0,p.jsx)(`div`,{className:`absolute bottom-0 right-0 h-4 w-4 cursor-se-resize rounded-tl bg-me-primary-500`,onPointerDown:n=>{n.stopPropagation(),qn({event:n,mode:`resize`,canvas:e,vault:u,startBox:t,stage:s.current})}}):null]})}function Gn({layer:e,mode:t,cover:n}){return e.imageUrl?(0,p.jsx)(`img`,{src:e.imageUrl,alt:``,className:(0,y.twMerge)(`h-full w-full`,n?`object-cover`:`object-contain`)}):e.html===null?e.youtubeId?(0,p.jsx)(`iframe`,{className:`h-full w-full border-0`,title:`YouTube slide content`,src:`https://www.youtube.com/embed/${e.youtubeId}?modestbranding=1&rel=0`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0}):e.videoUrl?(0,p.jsx)(`video`,{className:`h-full w-full bg-black object-contain`,controls:!0,children:(0,p.jsx)(`source`,{src:e.videoUrl})}):(0,p.jsx)(`div`,{className:`flex h-full w-full items-center justify-center rounded bg-slate-100 text-sm font-semibold text-slate-500`,children:`Media`}):e.html?(0,p.jsx)(`div`,{className:`h-full w-full overflow-hidden bg-white p-4 text-slate-900`,dangerouslySetInnerHTML:{__html:e.html}}):t===`preview`?null:(0,p.jsx)(`div`,{className:`h-full w-full overflow-hidden bg-white p-4 text-slate-900`,children:(0,p.jsx)(`div`,{className:`flex h-full items-center justify-center rounded border border-dashed border-slate-300 text-sm font-semibold text-slate-400`,children:`Empty text`})})}function Kn({event:e,mode:t,canvas:n,annotation:r,vault:i,startBox:a,stage:o}){if(!o)return;e.preventDefault();let s=o.getBoundingClientRect(),c=(Number(n?.width)||1920)/s.width,l=(Number(n?.height)||1080)/s.height,u=e.clientX,d=e.clientY,f=e=>{let o=(e.clientX-u)*c,s=(e.clientY-d)*l,f=t===`move`?{...a,x:a.x+o,y:a.y+s}:{...a,width:a.width+o,height:a.height+s};Le(i,n,r.id,f)},p=()=>{window.removeEventListener(`pointermove`,f),window.removeEventListener(`pointerup`,p),window.removeEventListener(`pointercancel`,p)};window.addEventListener(`pointermove`,f),window.addEventListener(`pointerup`,p),window.addEventListener(`pointercancel`,p)}function qn({event:e,mode:t,canvas:n,vault:r,startBox:i,stage:a}){if(!a)return;e.preventDefault(),e.stopPropagation();let o=a.getBoundingClientRect(),s=(Number(n?.width)||1920)/o.width,c=(Number(n?.height)||1080)/o.height,l=e.clientX,u=e.clientY,d=e=>{let a=(e.clientX-l)*s,o=(e.clientY-u)*c;Re(r,n,t===`move`?{...i,x:i.x+a,y:i.y+o}:{...i,width:i.width+a,height:i.height+o})},f=()=>{window.removeEventListener(`pointermove`,d),window.removeEventListener(`pointerup`,f),window.removeEventListener(`pointercancel`,f)};window.addEventListener(`pointermove`,d),window.addEventListener(`pointerup`,f),window.addEventListener(`pointercancel`,f)}function Jn(e){if(!e)return``;if(typeof e==`string`)return e;if(Array.isArray(e))return e.filter(Boolean).join(` `);let t=Object.values(e)[0];return Array.isArray(t)?t.filter(Boolean).join(` `):typeof t==`string`?t:``}const Yn=(0,m.forwardRef)(function({isFirst:e,item:t,children:n,onClick:r,...i},a){let o=(0,d.useCanvas)(),s=(0,h.useCanvasRenderingStrategy)(),c=o?.behavior||[],l=(0,u.useInStack)(`Canvas`),f=ft(o?.behavior,e),{isBottom:m,isImage:g,isInfo:_,isLeft:v}=pt(o?.behavior),b=l?.resource.source?.id===o?.id,x=(0,u.getInternationalStringText)(o?.label,`Untitled`),S=c.includes(`w-12`)&&c.includes(`h-8`),C=null;return C=S?(0,p.jsx)(Rn,{className:`pointer-events-none h-full w-full`,mode:`preview`}):_?(0,p.jsx)(`div`,{className:`bg-black w-full h-full text-white max-h-40`,children:(0,p.jsx)(`div`,{className:`p-1.5 text-[4px]`,children:s.type===`textual-content`?(0,p.jsx)(d.LocaleString,{enableDangerouslySetInnerHTML:!0,children:s.items[0]?.text}):null})}):(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`flex h-full max-h-full min-h-0`,v?`flex-row-reverse`:m?`flex-col`:`flex-row`),children:[(0,p.jsx)(`div`,{className:`flex-1 overflow-hidden relative justify-self-stretch`,children:(0,p.jsx)(`div`,{className:`absolute inset-0 w-full h-full`,children:(0,p.jsx)(h.LazyThumbnail,{cover:c.includes(`cover`)||c.includes(`image-cover`),fade:!1})})}),g?null:(0,p.jsx)(`div`,{className:`${m?`min-h-3 w-full`:`w-1/3`} flex-shrink-0 self-stretch p-2 text-white bg-black rounded`,children:(0,p.jsxs)(`div`,{className:`p-1.5 text-[4px]`,children:[(0,p.jsx)(d.LocaleString,{className:`block mb-1 text-[5px]`,children:o?.label}),(0,p.jsx)(d.LocaleString,{children:o?.summary})]})})]}),(0,p.jsxs)(`div`,{ref:a,className:(0,y.twMerge)(f,`bg-me-gray-700 overflow-hidden hover:ring-2 ring-me-primary-500 relative`,b?`ring-2 ring-me-primary-500`:``),...i,children:[C,(0,p.jsx)(`button`,{type:`button`,className:`absolute inset-0 z-20 cursor-pointer bg-transparent focus:outline focus:outline-2 focus:outline-offset-[-2px] focus:outline-me-primary-500`,"aria-label":`Edit slide ${x}`,onClick:r}),n]})});function Xn(){let{open:e}=(0,l.useLayoutActions)(),{structural:t,technical:n}=(0,l.useManifestEditor)(),[,r]=(0,l.useCreator)({id:n.id.get(),type:`Manifest`},`items`,`Canvas`),i=t.items.get();return(0,p.jsx)(st,{children:i.map((t,n)=>(0,p.jsx)(d.CanvasContext,{canvas:t.id,children:(0,p.jsx)(Yn,{isFirst:n===0,item:t,onClick:()=>{e({id:`current-canvas`}),r.edit(t,n)}})},n))})}const Zn=new Set([`a`,`blockquote`,`br`,`code`,`em`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`hr`,`i`,`img`,`li`,`ol`,`p`,`pre`,`s`,`span`,`strong`,`u`,`ul`]),Qn={a:new Set([`href`,`rel`,`target`,`title`]),img:new Set([`alt`,`data-iiif-image`,`loading`,`src`,`title`])};function $n(e){let t=ir(e),n={};for(let[e,r]of Object.entries(t)){let t=r.filter(e=>typeof e==`string`).map(e=>ar(e)?nr(e):or(e)).filter(Boolean).join(``);t&&(n[e]=[t])}return n}function er(e){let t={};for(let[n,r]of Object.entries(e||{})){let e=(r||[]).filter(e=>typeof e==`string`).map(e=>ar(e)?nr(e):or(e)).filter(Boolean).join(``);e&&(t[n]=[e])}return Object.keys(t).length?t:{none:[``]}}function tr(e){return Object.values($n(e)).flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).join(``)}function nr(e){if(typeof document>`u`)return cr(e);let t=document.createElement(`template`);return t.innerHTML=e||``,rr(t.content),t.innerHTML}function rr(e){for(let t of Array.from(e.childNodes)){if(t.nodeType===Node.ELEMENT_NODE){let e=t,n=e.tagName.toLowerCase();if(!Zn.has(n)){rr(e),e.replaceWith(...Array.from(e.childNodes));continue}for(let t of Array.from(e.attributes))lr(n,t.name.toLowerCase(),t.value)||e.removeAttribute(t.name);n===`a`&&e.getAttribute(`target`)?.toLowerCase()===`_blank`&&e.setAttribute(`rel`,`noopener noreferrer`)}rr(t)}}function ir(e){if(!e)return{};if(typeof e==`string`)return{none:[e]};if(Array.isArray(e))return{none:e.filter(e=>typeof e==`string`)};if(typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))t[n]=(Array.isArray(r)?r:[r]).filter(e=>typeof e==`string`);return t}return{}}function ar(e){return e.trimStart().startsWith(`<`)}function or(e){return e.replace(/\r\n?/g,`
2
- `).split(/\n+/).map(e=>e.trim()).filter(Boolean).map(e=>`<p>${sr(e)}</p>`).join(``)}function sr(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function cr(e){return(e||``).replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,``).replace(/<style\b[^<]*(?:(?!<\/style>)<[^<]*)*<\/style>/gi,``).replace(/<\s*(\/?)\s*([a-z0-9]+)([^>]*)>/gi,(e,t,n,r)=>{let i=n.toLowerCase();if(!Zn.has(i))return``;if(t)return`</${i}>`;let a=new Map;for(let e of r.matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g)){let t=e[1].toLowerCase(),n=e[2]??e[3]??e[4];n!==void 0&&lr(i,t,n)&&a.set(t,n)}return i===`a`&&a.get(`target`)?.toLowerCase()===`_blank`&&a.set(`rel`,`noopener noreferrer`),`<${i}${Array.from(a,([e,t])=>` ${e}="${dr(t)}"`).join(``)}${/\/\s*$/.test(r)?` /`:``}>`})}function lr(e,t,n){return Qn[e]?.has(t)?t===`data-iiif-image`?n===`true`:!((t===`href`||t===`src`)&&ur(n)):!1}function ur(e){let t=e.search(/[/?#]/);if(e.slice(0,t===-1?void 0:t).includes(`&`))return!0;let n=e.indexOf(`:`);if(n===-1)return!1;let r=e.slice(0,n).replace(/[\u0000-\u0020]/g,``).toLowerCase();return r.includes(`&`)||r===`javascript`||r===`data`}function dr(e){return e.replace(/&(?!(?:#\d+|#x[\da-f]+|[a-z][\w-]*);)/gi,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function fr(e){let t=e||``;if(typeof document<`u`){let e=document.createElement(`template`);e.innerHTML=t;let n=Array.from(e.content.childNodes).find(e=>e.nodeType===Node.ELEMENT_NODE||e.nodeType===Node.TEXT_NODE&&e.textContent?.trim());if(n?.nodeType===Node.ELEMENT_NODE&&/^h[1-6]$/i.test(n.tagName)){let t=n.textContent?.trim()||``;return n.remove(),{label:t,summary:nr(e.innerHTML.trim())}}return{label:void 0,summary:nr(t)}}let n=t.match(/^(?:\s|<!--[\s\S]*?-->)*<h[1-6][^>]*>([\s\S]*?)<\/h[1-6]>\s*/i);return n?{label:hr(mr(n[1]||``)).trim(),summary:nr(t.slice(n[0].length).trim())}:{label:void 0,summary:nr(t)}}function pr(e,t){return`${e===void 0?``:e.trim()?`<h2>${gr(e.trim())}</h2>`:`<h2></h2>`}${nr(t||``)}`}function mr(e){return e.replace(/<[^>]*>/g,``)}function hr(e){let t={amp:`&`,apos:`'`,gt:`>`,lt:`<`,nbsp:`\xA0`,quot:`"`};return e.replace(/&(?:#(\d+)|#x([\da-f]+)|([a-z]+));/gi,(e,n,r,i)=>{if(i)return t[i.toLowerCase()]??e;let a=Number.parseInt(n||r||``,n?10:16);return a>0&&a<=1114111&&!(a>=55296&&a<=57343)?String.fromCodePoint(a):e})}function gr(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function _r({mode:e}){let{open:t}=(0,l.useLayoutActions)(),{structural:n,technical:r}=(0,l.useManifestEditor)(),[,i]=(0,l.useCreator)({id:r.id.get(),type:`Manifest`},`items`,`Canvas`),a=n.items.get();return(0,p.jsx)(vr,{children:a.map((n,r)=>(0,p.jsx)(d.CanvasContext,{canvas:n.id,children:(0,p.jsx)(yr,{mode:e,onClick:()=>{t({id:`current-canvas`}),i.edit(n,r)}})},n.id))})}function vr({children:e}){let t=(0,d.useManifest)(),{edit:n}=(0,l.useLayoutActions)();return(0,p.jsxs)(`div`,{className:`flex flex-col gap-3 p-2`,children:[(0,p.jsx)(`button`,{type:`button`,onClick:()=>t&&n(t,void 0,{forceOpen:!0,selectedTab:`@manifest-editor/descriptive-properties`}),className:`w-full rounded border border-slate-200 bg-white p-2 text-left text-sm font-semibold text-slate-800 hover:bg-slate-50`,children:(0,p.jsx)(d.LocaleString,{children:t?.label})}),e]})}function yr({mode:e,onClick:t}){let n=(0,d.useCanvas)(),r=(0,d.useManifest)(),i=(0,u.useInStack)(`Canvas`)?.resource.source?.id===n?.id,[a,o]=(0,m.useState)(!1),s=(0,m.useId)(),c=(n?.behavior||[]).includes(`info`),l=e===`scroll`&&c,f=(0,d.useVaultSelector)((e,t)=>!!(r?.items?.[0]?.id===n?.id&&n&&Cr(t,n)),[r?.items?.[0]?.id,n?.id,n?.items?.[0]?.id]),h=(0,d.useVaultSelector)((e,t)=>n?Me(t,n):[],[n?.id,n?.annotations?.[0]?.id]);return n?(0,p.jsxs)(`article`,{className:(0,y.twMerge)(`overflow-hidden rounded border bg-white shadow-sm`,i?`border-me-primary-500 ring-2 ring-me-primary-100`:`border-slate-200`),children:[(0,p.jsxs)(`button`,{type:`button`,className:`block w-full text-left`,onClick:t,children:[(0,p.jsx)(`div`,{className:`border-b border-slate-100 px-2 py-1.5 text-xs font-semibold text-slate-700`,children:(0,p.jsx)(d.LocaleString,{children:n.label})}),f&&n.behavior?.includes(`splash`)?(0,p.jsx)(xr,{height:180}):e===`slideshow`?c?(0,p.jsx)(Sr,{height:180}):(0,p.jsx)(`div`,{style:{height:180,backgroundColor:`#303030`},children:(0,p.jsx)(Rn,{className:`pointer-events-none h-full w-full`,mode:`preview`})}):(0,p.jsx)(br,{})]}),h.length&&!l?(0,p.jsxs)(`div`,{className:`border-t border-slate-100`,children:[(0,p.jsxs)(`button`,{type:`button`,"aria-expanded":a,"aria-controls":s,className:`flex w-full items-center justify-between px-2 py-1.5 text-xs font-semibold text-slate-600 hover:bg-slate-50`,onClick:e=>{e.stopPropagation(),o(e=>!e)},children:[(0,p.jsx)(`span`,{children:a?`Hide steps`:`Show steps`}),(0,p.jsx)(`span`,{children:h.length})]}),a?(0,p.jsx)(`div`,{id:s,className:`flex flex-col gap-2 border-t border-slate-100 p-2`,children:h.map((e,r)=>(0,p.jsx)(wr,{annotation:e,canvas:n,onClick:t},e.id||r))}):null]}):null]}):null}function br(){let e=(0,d.useCanvas)(),t=e?.behavior||[],{isInfo:n}=pt(t);if(!e)return null;let r=Number(e.width)||1920,i=Number(e.height)||1080,a=Math.max(80,Math.round(332/r*i));return n?(0,p.jsx)(Sr,{}):(0,p.jsx)(`div`,{className:`min-h-0`,style:{height:a,backgroundColor:`#303030`},children:(0,p.jsx)(`div`,{className:`relative h-full min-h-0 overflow-hidden`,style:{backgroundColor:`#303030`},children:(0,p.jsx)(`div`,{className:`absolute inset-0`,children:(0,p.jsx)(h.LazyThumbnail,{cover:t.includes(`cover`)||t.includes(`image-cover`),fade:!1})})})})}function xr({height:e=180}){let t=(0,d.useManifest)(),n=(0,d.useCanvas)(),r=(0,u.getInternationalStringText)(t?.summary,``),i=(0,u.getInternationalStringText)(t?.requiredStatement?.label,``),a=(0,u.getInternationalStringText)(t?.requiredStatement?.value,``),o=(n?.behavior||[]).includes(`invert`),s=typeof n?.backgroundColor==`string`?n.backgroundColor:null;return(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`relative overflow-hidden bg-black p-4`,o?`text-white`:`text-black`),style:{height:e},children:[(0,p.jsx)(`div`,{className:`absolute inset-0`,children:(0,p.jsx)(h.LazyThumbnail,{cover:!0,fade:!1})}),(0,p.jsx)(`div`,{className:`absolute inset-0 z-10 opacity-35`,style:{background:s||`transparent`}}),(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`relative z-20 flex h-full flex-col justify-end p-3`,s?``:o?`bg-black/25 backdrop-blur-sm`:`bg-white/25 backdrop-blur-sm`),children:[(0,p.jsx)(d.LocaleString,{className:`block text-base font-semibold leading-tight`,children:t?.label}),r?(0,p.jsx)(`div`,{className:`mt-2 line-clamp-3 text-xs leading-relaxed opacity-75`,children:r}):null,a?(0,p.jsxs)(`div`,{className:`mt-3 border-t border-current/20 pt-2 text-[11px] leading-snug opacity-75`,children:[i?(0,p.jsx)(`div`,{className:`font-semibold opacity-85`,children:i}):null,(0,p.jsx)(`div`,{children:a})]}):null]})]})}function Sr({height:e}){let t=(0,d.useCanvas)(),n=(0,d.useVaultSelector)((e,n)=>t?Dr(n,t.annotations?.[0]):``,[t?.id,t?.annotations?.[0]?.id]);return t?(0,p.jsxs)(`div`,{className:`overflow-y-auto bg-white p-3 text-black`,style:e?{height:e}:void 0,children:[(0,p.jsx)(d.LocaleString,{className:`mb-2 block text-sm font-semibold uppercase leading-tight`,children:t.label}),(0,p.jsx)(`div`,{className:`prose prose-sm max-w-none text-xs leading-relaxed`,dangerouslySetInnerHTML:{__html:n||(0,u.getInternationalStringText)(t.summary,``)}})]}):null}function Cr(e,t){return!t||t.behavior?.includes(`info`)?!1:W(e,t).some(t=>{let n=Ve(e,t),r=n?.type===`SpecificResource`?n.source:n,i=Array.isArray(r?.service)?r.service:r?.service?[r.service]:[];return r?.type===`Image`||i.length>0})}function wr({annotation:e,canvas:t,onClick:n}){let{edit:r}=(0,l.useLayoutActions)(),i=H(e=>e.selectTourStep),a=H(e=>e.stopRepositioning),o=H(e=>e.stopTextRepositioning),s=U(e=>e.requestTab),c=U(e=>e.setShowTourSteps),u=U(e=>e.setCenterPanelMode),f=(0,d.useVaultSelector)((n,r)=>Er(r,e,t),[e?.id,e?.target,t?.id]),m=(0,d.useVaultSelector)((t,n)=>Tr(n,e),[e?.id,e?.body,e?.label,e?.summary]);return(0,p.jsxs)(`button`,{type:`button`,className:`flex gap-2 rounded border border-slate-200 bg-white p-1.5 text-left hover:bg-slate-50`,onClick:()=>{n(),r({id:t.id,type:`Canvas`},void 0,{selectedTab:`@exhibition/tour-steps`,forceOpen:!0}),e?.id&&i(e.id),a(),o(),c(!0),u(`edit`),s(`tour`)},children:[(0,p.jsx)(`div`,{className:`relative h-12 w-16 shrink-0 overflow-hidden rounded bg-slate-100`,children:(0,p.jsx)(h.LazyThumbnail,{cover:!0,fade:!1,region:f.region,singleImage:f.singleImage})}),(0,p.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,p.jsx)(`div`,{className:`truncate text-xs font-semibold text-slate-800`,children:m.label}),(0,p.jsx)(`div`,{className:`line-clamp-1 text-xs text-slate-500 [&_*]:m-0 [&_*]:inline`,dangerouslySetInnerHTML:{__html:m.summary}})]})]})}function Tr(e,t){let n=Ve(e,t);if(typeof n?.value==`string`){let{label:e,summary:r}=fr(n.value);return{label:e||(0,u.getInternationalStringText)(t.label,`Step`),summary:r}}return{label:(0,u.getInternationalStringText)(t.label,`Step`),summary:nr((0,u.getInternationalStringText)(t.summary,``))}}function Er(e,t,n){let r=t?.target,i=typeof r==`string`?null:r?.source,a=typeof i==`string`?i:i?.id||r?.id;if((typeof i==`string`?null:i?.type||r?.type)===`Annotation`&&a){let t=e.get({id:a,type:`Annotation`},{skipSelfReturn:!1});return{region:t?Ie(t,n):void 0,singleImage:!0}}let o=Ie(t,n),s=Number(n?.width)||1920,c=Number(n?.height)||1080;return{region:o.x===0&&o.y===0&&o.width===s&&o.height===c?void 0:o,singleImage:!1}}function Dr(e,t){let n=t?e.get(t,{skipSelfReturn:!1}):null;for(let t of n?.items||[]){let n=e.get(t,{skipSelfReturn:!1})||t,r=Array.isArray(n?.body)?n.body:[n?.body];for(let t of r){let n=t?e.get(t,{skipSelfReturn:!1})||t:null;if(typeof n?.value==`string`&&n.value)return n.value}}return``}function Or(e,t,n){if(t!==n)return t;let r=e.findIndex(e=>e.id===n);return r===-1?t:e[r+1]?.id||e[r-1]?.id}function kr(e){return(0,p.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,height:`1em`,width:`1em`,...e,children:[(0,p.jsx)(`title`,{children:`Rearrange`}),(0,p.jsx)(`path`,{fill:`none`,d:`M0 0h24v24H0z`}),(0,p.jsx)(`path`,{d:`M20 9H4v2h16V9zM4 15h16v-2H4v2z`,fill:`currentColor`})]})}function Ar({isFirst:e,onClick:t,item:n,actions:r,mode:i}){let{attributes:a,listeners:o,setActivatorNodeRef:s,setNodeRef:c,transform:l,transition:d}=(0,T.useSortable)({id:n.id,transition:{duration:150,easing:`cubic-bezier(0.25, 1, 0.5, 1)`}}),f={transform:E.CSS.Translate.toString(l),transition:d},m=(0,p.jsxs)(`div`,{className:`absolute right-0.5 top-0.5 z-30 flex items-stretch gap-0.5`,onClick:e=>e.stopPropagation(),children:[r?.length?(0,p.jsx)(u.AppDropdown,{as:v.Button,className:`bg-white p-1 text-2xl hover:text-me-500 aria-expanded:text-me-600 aria-expanded:bg-me-200 hover:bg-me-100 rounded-sm`,"aria-label":`Action menu`,items:r,children:(0,p.jsx)(h.MoreMenu,{})}):null,(0,p.jsx)(v.Button,{ref:s,...a,...o,"aria-label":`Reorder item`,className:`flex h-8 cursor-grab items-center rounded-sm bg-white p-1 text-2xl hover:bg-me-100 hover:text-me-500 focus:outline focus:outline-2 focus:outline-me-primary-500 active:cursor-grabbing`,children:(0,p.jsx)(kr,{"aria-hidden":`true`})})]});return i?(0,p.jsxs)(`div`,{ref:c,style:f,className:`relative`,children:[(0,p.jsx)(yr,{mode:i,onClick:t}),m]}):(0,p.jsx)(Yn,{ref:c,style:f,onClick:t,isFirst:e,item:n,children:m})}function jr({mode:e=`grid`}){let t=(0,d.useManifest)(),{structural:n,technical:r}=(0,l.useManifestEditor)(),i=(0,l.useEditingStack)(),a=(0,u.useInStack)(`Canvas`),o=n.items.get(),{open:s}=(0,l.useLayoutActions)(),c=(0,C.useSensors)((0,C.useSensor)(C.PointerSensor,{activationConstraint:{distance:5}}),(0,C.useSensor)(C.KeyboardSensor,{coordinateGetter:T.sortableKeyboardCoordinates})),[,f]=(0,l.useCreator)({id:r.id.get(),type:`Manifest`},`items`,`Canvas`),h=(0,m.useCallback)(e=>{let{active:t,over:r}=e;r&&t.id!==r.id&&n.items.reorder(o.findIndex(e=>e.id===t.id),o.findIndex(e=>e.id===r.id))},[o,n.items]),g=a?.resource.source.id;function _(e){if(g!==e)return;let t=Or(o,g,e);if(i.close(),t){let e=n.items.getWithoutTracking(),r=e.findIndex(e=>e.id===t),i=e[r];i&&f.edit(i,r)}}let v=o.map((r,i)=>r?(0,p.jsx)(d.CanvasContext,{canvas:r.id,children:(0,p.jsx)(Ar,{item:r,isFirst:i===0,mode:e===`grid`?void 0:e,onClick:()=>{s({id:`current-canvas`}),f.edit(r,i)},actions:(0,u.createAppActions)(n.items,()=>_(r.id))(r,i,t)})},r.id):null);return(0,p.jsx)(C.DndContext,{sensors:c,collisionDetection:C.closestCenter,onDragEnd:h,modifiers:[w.restrictToParentElement],children:(0,p.jsx)(T.SortableContext,{items:o,strategy:e===`grid`?T.rectSortingStrategy:T.verticalListSortingStrategy,children:e===`grid`?(0,p.jsx)(st,{children:v}):(0,p.jsx)(vr,{children:v})})})}function Mr(e){return e.length===0?{imageSlideBehavior:[`splash`]}:void 0}function Nr(e,t){return!!(e&&t?.[0]?.id===e.id&&e.behavior?.includes(`splash`))}function Pr(e,t){return Nr(t.get(e.resource),(e.parent?t.get(e.parent):void 0)?.items)}const Fr=Rr({label:`Exhibition grid`,creatorFilter:`exhibition-slide`,previewMode:`configured`}),Ir=Rr({label:`Slideshow`,creatorFilter:`exhibition-slideshow-slide`,previewMode:`slideshow`}),Lr=Rr({label:`Scroll`,creatorFilter:`exhibition-slide`,previewMode:`scroll`});function Rr({label:e,creatorFilter:t,previewMode:n}){return{id:`canvas-listing`,label:e,icon:(0,p.jsx)(Vr,{}),render:()=>(0,p.jsx)(zr,{creatorFilter:t,previewMode:n}),options:{minWidth:350,maxWidth:350}}}function zr({creatorFilter:e,previewMode:t}){let{structural:n,technical:r}=(0,l.useManifestEditor)(),i=Br(t,V()?.type),a=i===`slideshow`?`exhibition-slideshow-slide`:e,o={id:r.id.get(),type:`Manifest`},s=n.items.get()||[],c=(0,u.useInStack)(`Canvas`),d=(0,l.useEditingStack)(),f=c?.resource.source.id,m=f?s.findIndex(e=>e.id===f):-1,g=m>=0?m+1:void 0,_=i===`scroll`?Mr(s):void 0,[v,y]=(0,l.useCreator)(o,`items`,`Canvas`,void 0,{isPainting:!0}),[x,S]=(0,u.useToggleList)(),C=()=>y.createFiltered(a,g,_),w=i===`scroll`?`section`:`slide`;return(0,p.jsxs)(h.Sidebar,{children:[(0,p.jsx)(h.SidebarHeader,{title:`Exhibition`,actions:[{icon:x.list?(0,p.jsx)(b.CanvasListingIcon,{className:`text-2xl`}):(0,p.jsx)(Vr,{}),title:x.list?`List view`:`Grid view`,onClick:()=>S(`list`)},{icon:(0,p.jsx)(Hr,{}),title:`Edit ${w}s`,toggled:x.editing,onClick:()=>S(`editing`)},{icon:(0,p.jsx)(Ur,{}),title:`Add new ${w}`,disabled:!v,onClick:C}]}),(0,p.jsxs)(h.SidebarContent,{children:[x.editing?(0,p.jsx)(jr,{mode:i}):x.list?(0,p.jsx)(b.CanvasListView,{isEditing:x.editing,onDelete:e=>{if(f!==e)return;let t=Or(s,f,e);if(d.close(),t){let e=n.items.getWithoutTracking(),r=e.findIndex(e=>e.id===t),i=e[r];i&&y.edit(i,r)}}}):i===`slideshow`||i===`scroll`?(0,p.jsx)(_r,{mode:i}):(0,p.jsx)(Xn,{}),(0,p.jsx)(`div`,{className:`flex justify-center p-4`,children:(0,p.jsxs)(h.ActionButton,{primary:!0,large:!0,isDisabled:!v,onPress:C,children:[`Create new `,w]})})]})]})}function Br(e,t){return e===`configured`?t===`slideshow`||t===`scroll`?t:`grid`:e}function Vr(){return(0,p.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,fill:`currentColor`,viewBox:`0 -960 960 960`,children:[(0,p.jsx)(`title`,{children:`Exhibition grid`}),(0,p.jsx)(`path`,{d:`M600-160v-280h280v280H600ZM440-520v-280h440v280H440ZM80-160v-280h440v280H80Zm0-360v-280h280v280H80Zm440-80h280v-120H520v120ZM160-240h280v-120H160v120Zm520 0h120v-120H680v120ZM160-600h120v-120H160v120Zm360 0Zm-80 240Zm240 0ZM280-600Z`})]})}function Hr(){return(0,p.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`24`,viewBox:`0 0 24 24`,width:`24`,children:[(0,p.jsx)(`title`,{children:`Edit slides`}),(0,p.jsx)(`path`,{d:`M0 0h24v24H0V0z`,fill:`none`}),(0,p.jsx)(`path`,{d:`M14.06 9.02l.92.92L5.92 19H5v-.92l9.06-9.06M17.66 3c-.25 0-.51.1-.7.29l-1.83 1.83 3.75 3.75 1.83-1.83c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.2-.2-.45-.29-.71-.29zm-3.6 3.19L3 17.25V21h3.75L17.81 9.94l-3.75-3.75z`})]})}function Ur(){return(0,p.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,fill:`currentColor`,viewBox:`0 -960 960 960`,children:[(0,p.jsx)(`title`,{children:`Add new slide`}),(0,p.jsx)(`path`,{d:`M160-240v-480 480Zm80-80v-200h360v200H240Zm-80 160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h640q33 0 56.5 23.5T880-720v240h-80v-240H160v480h360v80H160Zm500-320v-100H360v-60h360v160h-60Zm60 400v-120H600v-80h120v-120h80v120h120v80H800v120h-80Z`})]})}const Wr={id:`@exhibitions/overview-panel`,label:`Preview`,icon:(0,p.jsx)(it,{}),render:()=>(0,p.jsx)(Gr,{})};function Gr(){return(0,d.useManifest)()?(0,p.jsx)(`div`,{children:`Coming soon.`}):null}const Kr=({rotate:e=0,...t})=>(0,p.jsx)(`svg`,{version:`1.2`,xmlns:`http://www.w3.org/2000/svg`,overflow:`visible`,preserveAspectRatio:`none`,viewBox:`0 0 24 24`,width:`1em`,height:`1em`,style:{fill:`rgba(0, 0, 0, 0.6)`,transform:`rotate(${e}deg)`,transition:`transform 0.2s`},...t,children:(0,p.jsx)(`path`,{d:`M8.12 9.29 12 13.17l3.88-3.88a.996.996 0 1 1 1.41 1.41l-4.59 4.59a.996.996 0 0 1-1.41 0L6.7 10.7a.996.996 0 0 1 0-1.41c.39-.38 1.03-.39 1.42 0z`,fill:`currentColor`})}),J=(e,t,n)=>({id:e,label:t,type:`boolean`,defaultValue:n}),qr=[{id:`exhibition-fullpage`,label:`Delft exhibition`,summary:`A guided exhibition layout with full-page scenes and focused narrative steps.`,type:`fullpage`,previewUrl:`https://preview.exhibitionviewer.org/preview/delft/full-page`,thumbnailUrl:`https://manifest-editor-docs.netlify.app/exhibition-fullpage.png`,configuration:[J(`delft.exhibition.cutCorners`,`Cut corners`,!0),J(`delft.exhibition.hideTableOfContents`,`Hide table of contents`,!1),J(`delft.exhibition.showNavigationControls`,`Show navigation controls`,!1),J(`delft.exhibition.hideTitle`,`Hide title`,!1)]},{id:`exhibition-slideshow`,label:`Slideshow`,summary:`A slide-based exhibition for linear presentations and teaching material.`,type:`slideshow`,previewUrl:`https://preview.exhibitionviewer.org/preview/delft/slideshow`,thumbnailUrl:`https://manifest-editor-docs.netlify.app/exhibition-slideshow.png`,configuration:[J(`delft.presentation.cutCorners`,`Cut corners`,!1),J(`delft.presentation.isFloating`,`Floating controls`,!1),{id:`delft.presentation.floatingPosition`,label:`Floating position`,type:`select`,defaultValue:`top-left`,options:[{label:`Top left`,value:`top-left`},{label:`Top right`,value:`top-right`},{label:`Bottom left`,value:`bottom-left`},{label:`Bottom right`,value:`bottom-right`}]},J(`delft.presentation.labelOnlyFloating`,`Only float labels`,!0)]},{id:`exhibition-scroll`,label:`Scrolling story`,summary:`A vertical reading experience for essays, object stories, and long-form interpretation.`,type:`scroll`,previewUrl:`https://preview.exhibitionviewer.org/preview/delft/scroll`,thumbnailUrl:`https://manifest-editor-docs.netlify.app/exhibition-scroll.png`,configuration:[J(`scroll.options.showTitleBlock`,`Show title block`,!0),J(`scroll.options.titleBlock.fullHeight`,`Full-height title block`,!0),J(`scroll.options.showTableOfContents`,`Show table of contents`,!1),J(`scroll.options.showProgressBar`,`Show progress bar`,!0),J(`scroll.options.showProgressTableOfContents`,`Show contents in progress bar`,!0),J(`scroll.options.showScrollToTop`,`Show scroll-to-top button`,!0),J(`scroll.options.showNavigationControls`,`Show navigation controls`,!0)]},{id:`leeds-exhibition`,label:`Leeds exhibition`,summary:`A full-page exhibition template for the Leeds University Library.`,type:`fullpage`,previewUrl:`https://preview.exhibitionviewer.org/preview/leeds/full-page`,thumbnailUrl:`https://manifest-editor-docs.netlify.app/exhibition-fullpage-leeds.png`,configuration:[]},{id:`leeds-exhibition-slideshow`,label:`Leeds exhibition slideshow`,summary:`A slideshow exhibition template for the Leeds University Library.`,type:`slideshow`,previewUrl:`https://preview.exhibitionviewer.org/preview/leeds/slideshow`,thumbnailUrl:`https://manifest-editor-docs.netlify.app/exhibition-slideshow-leeds.png`,configuration:[]},{id:`leeds-exhibition-scroll`,label:`Leeds exhibition scroll`,summary:`A scroll exhibition template for the Leeds University Library.`,type:`scroll`,previewUrl:`https://preview.exhibitionviewer.org/preview/leeds/scroll`,thumbnailUrl:`https://manifest-editor-docs.netlify.app/exhibition-scroll-leeds.png`,configuration:[]}];function Jr(e,t){let n=e;for(let e of t.split(`.`))n=n?.[e];return n}function Yr(e,t,n){var r;let i=structuredClone(e),a=t.split(`.`),o=i;for(let e of a.slice(0,-1))o=(r=o)[e]||(r[e]={});return o[a.at(-1)]=n,i}const Xr={id:`@exhibitions/theme-panel`,label:`Preview`,icon:(0,p.jsx)(it,{}),render:()=>(0,p.jsx)(Zr,{}),options:{minWidth:360,maxWidth:440}};function Zr(){let e=(0,d.useManifest)(),t=(0,d.useVault)(),n=V(),r=(0,l.useOpenPresetOnboarding)(),i=e?.service||[],a=e?.services||[],o=ge(i)||ge(a),s=n?.configuration||[],c=o?.service?.theme||{},u=s.reduce((e,t)=>Yr(e,t.id,Jr(c,t.id)??t.defaultValue??Qr(t)),{});if(!e||!n)return null;let f=n=>{let r=n?{id:`${e.id}#exhibition-viewer-theme`,type:`Service`,profile:I,label:ee,theme:n}:null,o={id:e.id,type:`Manifest`};t.batch(t=>{t.modifyEntityField(o,`service`,ve(i,r)),(e.services||ge(a))&&t.modifyEntityField(o,`services`,ve(a,null))})};return(0,p.jsx)(h.Sidebar,{children:(0,p.jsxs)(h.SidebarContent,{padding:!0,children:[(0,p.jsxs)(Y,{title:n.label,description:n.summary,children:[(0,p.jsx)(`img`,{src:n.thumbnailUrl,alt:``,className:`aspect-video w-full rounded border border-slate-200 object-cover`}),(0,p.jsx)(v.Button,{className:`rounded border border-slate-300 px-3 py-2 text-sm hover:bg-slate-50`,onPress:r,children:`Change template`})]}),(0,p.jsxs)(Y,{title:`Preview configuration`,description:`These settings are defined by the selected template and stored as a service on the Manifest.`,children:[s.map(e=>(0,p.jsx)($r,{field:e,value:Jr(c,e.id)??e.defaultValue??Qr(e),onChange:t=>f(Yr(u,e.id,t))},e.id)),s.length?null:(0,p.jsx)(`p`,{className:`text-sm text-slate-500`,children:`This template has no configurable settings.`}),o?(0,p.jsx)(v.Button,{className:`rounded border border-slate-300 px-3 py-2 text-sm hover:bg-slate-50`,onPress:()=>f(null),children:`Remove preview service`}):(0,p.jsx)(v.Button,{className:`rounded bg-me-primary-600 px-3 py-2 text-sm text-white hover:bg-me-primary-700`,onPress:()=>f(u),children:`Add preview service`})]}),(0,p.jsx)(si,{})]})})}function Qr(e){return e.type===`boolean`?!1:e.type===`number`?0:``}function $r({field:e,value:t,onChange:n}){return e.type===`boolean`?(0,p.jsx)(X,{label:e.label,checked:!!t,onChange:n}):e.type===`select`?(0,p.jsx)(ni,{label:e.label,value:String(t),onChange:n,options:(e.options||[]).map(e=>({label:e.label,value:String(e.value)}))}):(0,p.jsxs)(u.InputContainer,{$wide:!0,children:[(0,p.jsx)(u.InputLabel,{children:e.label}),e.type===`textarea`?(0,p.jsx)(`textarea`,{"aria-label":e.label,className:`w-full rounded border border-slate-300 bg-slate-50 px-3 py-2 text-sm`,value:String(t),onChange:e=>n(e.target.value)}):(0,p.jsx)(u.Input,{"aria-label":e.label,type:e.type===`number`?`number`:`text`,value:String(t),onChange:t=>n(e.type===`number`?t.target.valueAsNumber:t.target.value)})]})}function Y({title:e,description:t,children:n,collapsible:r=!1}){let[i,a]=(0,m.useState)(!0);return r?(0,p.jsxs)(`section`,{className:`mb-3 rounded-md border border-slate-200 bg-white last:mb-0`,children:[(0,p.jsxs)(v.Button,{className:`flex w-full items-center justify-between gap-3 px-3 py-3 text-left hover:bg-slate-50`,"aria-expanded":i,onPress:()=>a(e=>!e),children:[(0,p.jsxs)(`span`,{className:`min-w-0`,children:[(0,p.jsx)(`span`,{className:`block text-sm font-semibold`,children:e}),t?(0,p.jsx)(`span`,{className:`mt-1 block text-xs text-slate-500`,children:t}):null]}),(0,p.jsx)(Kr,{className:`shrink-0 text-base text-slate-500`,rotate:i?0:-90,"aria-hidden":!0})]}),i&&n?(0,p.jsx)(`div`,{className:`space-y-3 border-t border-slate-200 px-3 py-3`,children:n}):null]}):(0,p.jsxs)(`section`,{className:`mb-5 border-b border-slate-200 pb-5 last:mb-0 last:border-b-0`,children:[(0,p.jsxs)(`div`,{className:`mb-3`,children:[(0,p.jsx)(`h3`,{className:`text-sm font-semibold`,children:e}),t?(0,p.jsx)(`p`,{className:`mt-1 text-xs text-slate-500`,children:t}):null]}),n?(0,p.jsx)(`div`,{className:`space-y-3`,children:n}):null]})}function ei({label:e,value:t,onChange:n,options:r}){return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`mb-2 text-xs font-medium text-slate-500`,children:e}),(0,p.jsx)(`div`,{className:`flex flex-wrap gap-1 rounded-md border border-slate-200 bg-slate-100 p-1`,children:r.map(e=>{let r=e.value===t;return(0,p.jsx)(v.Button,{className:[`rounded px-2 py-1.5 text-sm transition-colors`,r?`bg-white font-semibold text-slate-950 shadow-sm`:`text-slate-600 hover:bg-white/70 hover:text-slate-900`].join(` `),"aria-pressed":r,onPress:()=>n(e.value),children:e.label},e.value)})})]})}function X({label:e,checked:t,disabled:n=!1,onChange:r}){return(0,p.jsxs)(`label`,{className:`flex items-center gap-3 text-sm ${n?`opacity-50`:``}`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:t,disabled:n,onChange:e=>r(e.target.checked)}),(0,p.jsx)(`span`,{children:e})]})}function Z({label:e,value:t,onChange:n}){return(0,p.jsxs)(`div`,{className:`items-center`,style:{display:`grid`,gap:`0.5rem`,gridTemplateColumns:`minmax(0, 1fr) 3rem 100px`},children:[(0,p.jsx)(`label`,{className:`min-w-0 truncate whitespace-nowrap text-sm`,children:e}),(0,p.jsx)(`input`,{"aria-label":`${e} colour picker`,className:`h-9 w-12 shrink-0 cursor-pointer rounded border border-slate-300 bg-white p-1`,type:`color`,value:ri(t),onChange:e=>n(e.target.value)}),(0,p.jsx)(`div`,{className:`min-w-0`,children:(0,p.jsx)(u.Input,{"aria-label":`${e} colour value`,style:{width:`100%`},value:t,onChange:e=>n(e.target.value)})})]})}function ti({label:e,value:t,onChange:n}){return(0,p.jsxs)(u.InputContainer,{$wide:!0,children:[(0,p.jsx)(u.InputLabel,{children:e}),(0,p.jsx)(u.Input,{"aria-label":e,value:t,onChange:e=>n(e.target.value)})]})}function ni({label:e,value:t,disabled:n=!1,onChange:r,options:i}){return(0,p.jsxs)(u.InputContainer,{$wide:!0,children:[(0,p.jsx)(u.InputLabel,{children:e}),(0,p.jsx)(`select`,{"aria-label":e,className:`w-full rounded border border-slate-300 bg-slate-50 px-3 py-2 text-sm disabled:cursor-not-allowed disabled:opacity-50`,value:t,disabled:n,onChange:e=>r(e.target.value),children:i.map(e=>(0,p.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})}function ri(e){let t=e.trim();if(/^#[0-9a-fA-F]{6}$/.test(t))return t;if(/^#[0-9a-fA-F]{3}$/.test(t)){let[e,n,r]=t.slice(1);return`#${e}${e}${n}${n}${r}${r}`}return`#ffffff`}function ii(e){return JSON.parse(JSON.stringify(e))}function ai(e,t,n){let r=ii(e),i=r;for(let e of t.slice(0,-1)){var a;(a=i)[e]||(a[e]={}),i=i[e]}let o=t[t.length-1];return o&&(i[o]=n),r}function oi(e,t){let n=ii(e);for(let e of t){let t=n;for(let n of e.path.slice(0,-1)){var r;(r=t)[n]||(r[n]={}),t=t[n]}let i=e.path[e.path.length-1];i&&(t[i]=e.value)}return n}function si(){let e=(0,d.useManifest)(),t=(0,d.useVault)(),n=rt(),[r,i]=(0,m.useState)(`simple`),a=n===`scroll`?`scroll`:n===`slideshow`?`slideshow`:`presentation`,o=e?.service||[],s=e?.services||[],c=(0,m.useMemo)(()=>{let e=ge(o);if(e)return{service:e.service};let t=ge(s);return t?{service:t.service}:null},[o,s]),l=(0,m.useMemo)(()=>c?pe(c.service.theme):null,[c])||fe(`delft`);if(!e)return null;let u=n=>{let r=n?he(e.id,n):null,i=ve(o,r),a=ve(s,null),c={id:e.id,type:`Manifest`};t.batch(t=>{t.modifyEntityField(c,`service`,i),(e.services||a.length!==s.length)&&t.modifyEntityField(c,`services`,a)})},f=(e,t)=>{u(ai(l,e,t))},h=e=>{u(oi(l,e))},g=e=>{let t=[{path:[`delft`,`tokens`,`backgroundPrimary`],value:e},{path:[`delft`,`tokens`,`backgroundSecondary`],value:e},{path:[`delft`,`tokens`,`backgroundOverlay`],value:e},{path:[`delft`,`tokens`,`controlBar`],value:e},{path:[`delft`,`tokens`,`controlBarBorder`],value:e},{path:[`delft`,`tokens`,`closeBackground`],value:e},{path:[`delft`,`tokens`,`closeBackgroundHover`],value:e},{path:[`delft`,`tokens`,`infoBlock`],value:e},{path:[`delft`,`tokens`,`viewerBackground`],value:e}],n=a===`presentation`?[{path:[`delft`,`tokens`,`titleCard`],value:e}]:[];if(a===`scroll`){h([...t,{path:[`scroll`,`tokens`,`titleBackground`],value:e},{path:[`scroll`,`tokens`,`annotationBackground`],value:e},{path:[`scroll`,`tokens`,`infoBlockBackground`],value:e}]);return}h([...t,...n])},_=e=>{let t=[{path:[`delft`,`tokens`,`textPrimary`],value:e},{path:[`delft`,`tokens`,`textSecondary`],value:e},{path:[`delft`,`tokens`,`imageCaption`],value:e},{path:[`delft`,`tokens`,`closeText`],value:e},{path:[`delft`,`tokens`,`infoBlockText`],value:e}],n=a===`presentation`?[{path:[`delft`,`tokens`,`titleCardText`],value:e}]:[];if(a===`scroll`){h([...t,{path:[`scroll`,`tokens`,`titleColor`],value:e},{path:[`scroll`,`tokens`,`annotationColor`],value:e},{path:[`scroll`,`tokens`,`infoBlockColor`],value:e}]);return}h([...t,...n])},y=e=>{if(a===`scroll`){f([`scroll`,`options`,`showTableOfContents`],e);return}f([`delft`,`exhibition`,`hideTableOfContents`],!e)},b=e=>{if(a===`scroll`){f([`scroll`,`options`,`tableOfContentsPlacement`],e);return}f([`delft`,`exhibition`,`tableOfContentsPlacement`],e)},x=e=>{f(a===`slideshow`?[`delft`,`slideshow`,`alternativeImageMode`]:[`delft`,`exhibition`,`alternativeImageMode`],e===`alternative`)},S=e=>{f(a===`slideshow`?[`delft`,`slideshow`,`coverImages`]:[`delft`,`exhibition`,`coverImages`],e)},C=a===`scroll`?l.scroll.options.showTableOfContents:!l.delft.exhibition.hideTableOfContents,w=a===`scroll`?l.scroll.options.tableOfContentsPlacement:l.delft.exhibition.tableOfContentsPlacement,T=(a===`slideshow`?l.delft.slideshow.alternativeImageMode:l.delft.exhibition.alternativeImageMode)?`alternative`:`default`,E=a===`slideshow`?l.delft.slideshow.coverImages:l.delft.exhibition.coverImages,D=a===`scroll`?l.scroll.options.showProgressBar:l.delft.exhibition.showProgressBar;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(Y,{title:`Saved Theme`,description:`Save custom exhibition styling and viewer defaults on the Manifest.`,children:[(0,p.jsx)(X,{label:`Save custom theme`,checked:!!c,onChange:e=>{if(!e){u(null);return}u(fe(`delft`))}}),(0,p.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,p.jsx)(v.Button,{className:`rounded border border-slate-300 px-3 py-2 text-sm hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50`,onPress:()=>{u(fe(l.preset))},isDisabled:!c,children:`Reset selected theme`}),(0,p.jsx)(v.Button,{className:`rounded border border-slate-300 px-3 py-2 text-sm hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50`,onPress:()=>u(null),isDisabled:!c,children:`Clear saved settings`})]}),(0,p.jsx)(ei,{label:`Preset`,value:l.preset,onChange:e=>{u(fe(e))},options:[{label:`Delft`,value:`delft`},{label:`Gallery`,value:`gallery`},{label:`Minimal`,value:`minimal`}]})]}),(0,p.jsx)(Y,{title:`Theme Options`,description:`Choose a shorter or more detailed set of theme controls.`,children:(0,p.jsx)(ei,{label:`Editing mode`,value:r,onChange:i,options:[{label:`Simple`,value:`simple`},{label:`Advanced`,value:`advanced`}]})}),r===`simple`?(0,p.jsxs)(Y,{title:`Key Settings`,description:a===`scroll`?`Main background updates the opening title, annotation cards, info blocks, and viewer background.`:`The main controls most people need for this theme.`,children:[(0,p.jsx)(Z,{label:`Main background`,value:a===`scroll`?l.scroll.tokens.titleBackground:l.delft.tokens.viewerBackground,onChange:g}),(0,p.jsx)(Z,{label:`Text colour`,value:a===`scroll`?l.scroll.tokens.titleColor:l.delft.tokens.textSecondary,onChange:_}),(0,p.jsx)(ti,{label:`Heading font`,value:l.shared.fontSans,onChange:e=>f([`shared`,`fontSans`],e)}),(0,p.jsx)(ti,{label:`Body font`,value:l.shared.fontMono,onChange:e=>f([`shared`,`fontMono`],e)}),a===`scroll`?null:(0,p.jsx)(ni,{label:`Title capitalisation`,value:l.shared.titleTransform,onChange:e=>f([`shared`,`titleTransform`],e),options:[{label:`Uppercase`,value:`uppercase`},{label:`None`,value:`none`},{label:`Capitalize`,value:`capitalize`}]}),a===`presentation`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(X,{label:`Table of Contents bar`,checked:C,onChange:y}),(0,p.jsx)(X,{label:`Full-width title bar`,checked:l.delft.exhibition.fullTitleBar,onChange:e=>f([`delft`,`exhibition`,`fullTitleBar`],e)}),(0,p.jsx)(ni,{label:`Image layout`,value:T,onChange:x,options:[{label:`Standard`,value:`default`},{label:`Feature image`,value:`alternative`}]}),(0,p.jsx)(X,{label:`Fill image area`,checked:E,onChange:S})]}):null,a===`slideshow`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(ni,{label:`Image layout`,value:T,onChange:x,options:[{label:`Standard`,value:`default`},{label:`Feature image`,value:`alternative`}]}),(0,p.jsx)(X,{label:`Fill image area`,checked:E,onChange:S}),(0,p.jsx)(X,{label:`Zoom effect`,checked:l.delft.slideshow.transitionScale,onChange:e=>f([`delft`,`slideshow`,`transitionScale`],e)})]}):null,a===`scroll`?(0,p.jsx)(p.Fragment,{children:(0,p.jsx)(X,{label:`Full-height title`,checked:l.scroll.options.titleBlock.fullHeight,onChange:e=>f([`scroll`,`options`,`titleBlock`,`fullHeight`],e)})}):null]}):(0,p.jsxs)(p.Fragment,{children:[a===`presentation`?(0,p.jsxs)(Y,{title:`Opening Title`,collapsible:!0,children:[(0,p.jsx)(Z,{label:`Card background`,value:l.delft.tokens.titleCard,onChange:e=>f([`delft`,`tokens`,`titleCard`],e)}),(0,p.jsx)(Z,{label:`Card text`,value:l.delft.tokens.titleCardText,onChange:e=>f([`delft`,`tokens`,`titleCardText`],e)}),(0,p.jsx)(X,{label:`Hide title`,checked:l.delft.exhibition.hideTitle,onChange:e=>f([`delft`,`exhibition`,`hideTitle`],e)}),(0,p.jsx)(X,{label:`Hide title card`,checked:l.delft.exhibition.hideTitleCard,onChange:e=>f([`delft`,`exhibition`,`hideTitleCard`],e)})]}):null,a===`scroll`?(0,p.jsxs)(Y,{title:`Opening Title`,collapsible:!0,children:[(0,p.jsx)(X,{label:`Show opening title`,checked:l.scroll.options.showTitleBlock,onChange:e=>f([`scroll`,`options`,`showTitleBlock`],e)}),(0,p.jsx)(X,{label:`Show table of contents`,checked:C,onChange:y}),(0,p.jsx)(Z,{label:`Background`,value:l.scroll.tokens.titleBackground,onChange:e=>f([`scroll`,`tokens`,`titleBackground`],e)}),(0,p.jsx)(Z,{label:`Text`,value:l.scroll.tokens.titleColor,onChange:e=>f([`scroll`,`tokens`,`titleColor`],e)}),(0,p.jsx)(X,{label:`Full-height title`,checked:l.scroll.options.titleBlock.fullHeight,onChange:e=>f([`scroll`,`options`,`titleBlock`,`fullHeight`],e)})]}):null,(0,p.jsxs)(Y,{title:`Page & Viewer`,description:a===`scroll`?`Shared backgrounds around the Scroll view. Opening title, annotation, and info block colours are controlled below.`:void 0,collapsible:!0,children:[(0,p.jsx)(Z,{label:`Viewer background`,value:l.delft.tokens.viewerBackground,onChange:e=>f([`delft`,`tokens`,`viewerBackground`],e)}),(0,p.jsx)(Z,{label:`Main`,value:l.delft.tokens.backgroundPrimary,onChange:e=>f([`delft`,`tokens`,`backgroundPrimary`],e)}),(0,p.jsx)(Z,{label:`Secondary`,value:l.delft.tokens.backgroundSecondary,onChange:e=>f([`delft`,`tokens`,`backgroundSecondary`],e)}),(0,p.jsx)(Z,{label:`Overlay`,value:l.delft.tokens.backgroundOverlay,onChange:e=>f([`delft`,`tokens`,`backgroundOverlay`],e)}),a===`scroll`?(0,p.jsx)(X,{label:`Use theme background instead of canvas colours`,checked:l.scroll.options.ignoreCanvasBackgrounds,onChange:e=>f([`scroll`,`options`,`ignoreCanvasBackgrounds`],e)}):null]}),a===`scroll`?null:(0,p.jsxs)(Y,{title:`Text Colours`,description:`General fallback text colours. Captions, info blocks, and controls have their own options below.`,collapsible:!0,children:[(0,p.jsx)(Z,{label:`Dark text`,value:l.delft.tokens.textPrimary,onChange:e=>f([`delft`,`tokens`,`textPrimary`],e)}),(0,p.jsx)(Z,{label:`Light text`,value:l.delft.tokens.textSecondary,onChange:e=>f([`delft`,`tokens`,`textSecondary`],e)})]}),(0,p.jsx)(Y,{title:`Info Blocks`,collapsible:!0,children:a===`scroll`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Z,{label:`Background`,value:l.scroll.tokens.infoBlockBackground,onChange:e=>f([`scroll`,`tokens`,`infoBlockBackground`],e)}),(0,p.jsx)(Z,{label:`Text`,value:l.scroll.tokens.infoBlockColor,onChange:e=>f([`scroll`,`tokens`,`infoBlockColor`],e)})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Z,{label:`Background`,value:l.delft.tokens.infoBlock,onChange:e=>f([`delft`,`tokens`,`infoBlock`],e)}),(0,p.jsx)(Z,{label:`Text`,value:l.delft.tokens.infoBlockText,onChange:e=>f([`delft`,`tokens`,`infoBlockText`],e)})]})}),(0,p.jsxs)(Y,{title:`Images & Annotations`,collapsible:!0,children:[a===`scroll`?null:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Z,{label:`Image caption`,value:l.delft.tokens.imageCaption,onChange:e=>f([`delft`,`tokens`,`imageCaption`],e)}),(0,p.jsx)(Z,{label:`Selected hotspot`,value:l.delft.tokens.annotationSelected,onChange:e=>f([`delft`,`tokens`,`annotationSelected`],e)}),(0,p.jsx)(ni,{label:`Image layout`,value:T,onChange:x,options:[{label:`Standard`,value:`default`},{label:`Feature image`,value:`alternative`}]}),(0,p.jsx)(X,{label:`Info button`,checked:a===`slideshow`?l.delft.slideshow.imageInfoIcon:l.delft.exhibition.imageInfoIcon,onChange:e=>f(a===`slideshow`?[`delft`,`slideshow`,`imageInfoIcon`]:[`delft`,`exhibition`,`imageInfoIcon`],e)}),(0,p.jsx)(X,{label:`Fill image area`,checked:E,onChange:S}),(0,p.jsx)(X,{label:`Use theme background instead of canvas colours`,checked:a===`slideshow`?l.delft.slideshow.ignoreCanvasBackgrounds:l.delft.exhibition.ignoreCanvasBackgrounds,onChange:e=>f(a===`slideshow`?[`delft`,`slideshow`,`ignoreCanvasBackgrounds`]:[`delft`,`exhibition`,`ignoreCanvasBackgrounds`],e)})]}),a===`scroll`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Z,{label:`Annotation background`,value:l.scroll.tokens.annotationBackground,onChange:e=>f([`scroll`,`tokens`,`annotationBackground`],e)}),(0,p.jsx)(Z,{label:`Annotation text`,value:l.scroll.tokens.annotationColor,onChange:e=>f([`scroll`,`tokens`,`annotationColor`],e)}),(0,p.jsx)(ti,{label:`Corner radius`,value:l.scroll.tokens.annotationRadius,onChange:e=>f([`scroll`,`tokens`,`annotationRadius`],e)}),(0,p.jsx)(ti,{label:`Max width`,value:l.scroll.tokens.annotationMaxWidth,onChange:e=>f([`scroll`,`tokens`,`annotationMaxWidth`],e)})]}):null]}),(0,p.jsxs)(Y,{title:`Navigation & Controls`,description:a===`scroll`?`Scroll contents navigation, placement, dropdown text, and progress colours.`:a===`slideshow`?`Slideshow controls, progress, and overlay buttons. Contents controls only apply to Full page and Scroll.`:`Contents, viewer controls, progress, and overlay buttons.`,collapsible:!0,children:[a===`presentation`||a===`scroll`?(0,p.jsx)(X,{label:`Progress bar`,checked:D,onChange:e=>f(a===`scroll`?[`scroll`,`options`,`showProgressBar`]:[`delft`,`exhibition`,`showProgressBar`],e)}):null,a===`presentation`||a===`scroll`?(0,p.jsx)(X,{label:`Previous/next side controls`,checked:a===`scroll`?l.scroll.options.showNavigationControls:l.delft.exhibition.showNavigationControls,onChange:e=>f(a===`scroll`?[`scroll`,`options`,`showNavigationControls`]:[`delft`,`exhibition`,`showNavigationControls`],e)}):null,a===`presentation`?(0,p.jsx)(X,{label:`Table of Contents bar`,checked:C,onChange:y}):null,a===`presentation`||a===`scroll`?(0,p.jsx)(ni,{label:`Contents position`,value:w,disabled:!C,onChange:b,options:[{label:`Header`,value:`header`},{label:`Footer`,value:`footer`}]}):null,a===`scroll`?(0,p.jsx)(X,{label:`Back to top button`,checked:l.scroll.options.showScrollToTop,onChange:e=>f([`scroll`,`options`,`showScrollToTop`],e)}):null,(0,p.jsx)(Z,{label:`Navigation bar background`,value:l.delft.tokens.controlBar,onChange:e=>h([{path:[`delft`,`tokens`,`controlBar`],value:e},{path:[`delft`,`tokens`,`controlBarBorder`],value:e}])}),(0,p.jsx)(Z,{label:`Navigation text colour`,value:l.delft.tokens.closeText,onChange:e=>f([`delft`,`tokens`,`closeText`],e)}),(0,p.jsx)(Z,{label:`Progress bar colour`,value:l.delft.tokens.progressBar,onChange:e=>f([`delft`,`tokens`,`progressBar`],e)}),a===`scroll`?(0,p.jsx)(Z,{label:`Back to top button background`,value:l.delft.tokens.closeBackground,onChange:e=>f([`delft`,`tokens`,`closeBackground`],e)}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Z,{label:`Close button background`,value:l.delft.tokens.closeBackground,onChange:e=>f([`delft`,`tokens`,`closeBackground`],e)}),(0,p.jsx)(Z,{label:`Close button hover`,value:l.delft.tokens.closeBackgroundHover,onChange:e=>f([`delft`,`tokens`,`closeBackgroundHover`],e)})]})]}),a===`presentation`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(Y,{title:`Display & Layout`,collapsible:!0,children:[(0,p.jsx)(X,{label:`Angled corners`,checked:l.delft.exhibition.cutCorners,onChange:e=>f([`delft`,`exhibition`,`cutCorners`],e)}),(0,p.jsx)(X,{label:`Full-width title bar`,checked:l.delft.exhibition.fullTitleBar,onChange:e=>f([`delft`,`exhibition`,`fullTitleBar`],e)}),(0,p.jsx)(X,{label:`Full-width item grid`,checked:l.delft.exhibition.fullWidthGrid,onChange:e=>f([`delft`,`exhibition`,`fullWidthGrid`],e)}),(0,p.jsx)(X,{label:`Use theme background instead of canvas colours`,checked:l.delft.exhibition.ignoreCanvasBackgrounds,onChange:e=>f([`delft`,`exhibition`,`ignoreCanvasBackgrounds`],e)})]}),(0,p.jsxs)(Y,{title:`Interaction Behaviour`,collapsible:!0,children:[(0,p.jsx)(ni,{label:`Presentation mode`,value:l.delft.exhibition.disablePresentation?`disabled`:`available`,onChange:e=>f([`delft`,`exhibition`,`disablePresentation`],e===`disabled`),options:[{label:`Available`,value:`available`},{label:`Disabled`,value:`disabled`}]}),(0,p.jsx)(X,{label:`Zoom effect`,checked:l.delft.exhibition.transitionScale,onChange:e=>f([`delft`,`exhibition`,`transitionScale`],e)}),(0,p.jsx)(X,{label:`Floating panels`,checked:l.delft.presentation.isFloating,onChange:e=>f([`delft`,`presentation`,`isFloating`],e)}),l.delft.presentation.isFloating?(0,p.jsx)(X,{label:`Label-only floating`,checked:l.delft.presentation.labelOnlyFloating,onChange:e=>f([`delft`,`presentation`,`labelOnlyFloating`],e)}):null,l.delft.presentation.isFloating?(0,p.jsx)(ni,{label:`Panel position`,value:l.delft.presentation.floatingPosition,onChange:e=>f([`delft`,`presentation`,`floatingPosition`],e),options:[{label:`Top left`,value:`top-left`},{label:`Top right`,value:`top-right`},{label:`Bottom left`,value:`bottom-left`},{label:`Bottom right`,value:`bottom-right`},{label:`Top`,value:`top`},{label:`Bottom`,value:`bottom`},{label:`Left`,value:`left`},{label:`Right`,value:`right`}]}):null,(0,p.jsx)(X,{label:`Angled panel corners`,checked:l.delft.presentation.cutCorners,onChange:e=>f([`delft`,`presentation`,`cutCorners`],e)}),(0,p.jsx)(X,{label:`Use theme background instead of canvas colours`,checked:l.delft.presentation.ignoreCanvasBackgrounds,onChange:e=>f([`delft`,`presentation`,`ignoreCanvasBackgrounds`],e)})]})]}):null,a===`slideshow`?(0,p.jsx)(Y,{title:`Interaction Behaviour`,collapsible:!0,children:(0,p.jsx)(X,{label:`Zoom effect`,checked:l.delft.slideshow.transitionScale,onChange:e=>f([`delft`,`slideshow`,`transitionScale`],e)})}):null]})]})}function ci(e){return e===`left-panel-manifest`||e===Fr.id}const li={id:`exhibition-background-task`,label:`Query string`,render:()=>(0,p.jsx)(ui,{})};function ui(){let e=(0,d.useManifest)(),{leftPanel:t,rightPanel:n}=(0,l.useLayoutState)(),{edit:r,centerPanel:i,rightPanel:a}=(0,l.useLayoutActions)(),[o,s]=(0,m.useState)(!1),c=(0,m.useRef)(null),u=(0,m.useRef)(null);return(0,m.useEffect)(()=>{let l=e?.id||null,d=c.current!==t.current,f=u.current!==l,p=c.current;if(c.current=t.current,u.current=l,!(!e||!d&&!f)){if(t.current===Wr.id){r(e),i.open({id:be.id}),s(!1);return}if(t.current===Xr.id){r(e),n.open?(a.close(),s(!0)):s(!1),i.open({id:at.id});return}!n.open&&n.current&&ci(t.current)&&(p===null||p===Xr.id&&o)&&(a.open(),s(!1))}},[i,r,t.current,e?.id,n.current,n.open,a,o]),null}const di={id:`image-block-editor`,label:`Image Block Editor`,component:e=>(0,p.jsx)(fi,{strategy:e}),supports:{strategy:(e,t,n)=>{if(e.type!==`images`)return!1;let r=n.get(t.resource);if(r.type!==`Canvas`)return!1;let i=r.behavior||[],a=!1;for(let e of i)(e.startsWith(`w-`)||e.startsWith(`h-`)||e===`image`)&&(a=!0);return a}}};function fi({strategy:e}){let[t,n]=(0,l.useLocalStorage)(`exhibition-preview-mode`),r=U(e=>e.centerPanelMode),i=U(e=>e.setCenterPanelMode),a=rt(),o=(0,u.useInStack)(`Canvas`);return(0,m.useEffect)(()=>{r===`edit`&&t?n(!1):r===`preview`&&!t&&n(!0)},[r,t,n]),o?(0,p.jsx)(d.CanvasContext,{canvas:o.resource.source?.id,children:(0,p.jsx)(pi,{isPreview:!!t,previewPreset:a,onModeChange:e=>{i(e?`preview`:`edit`),n(e)}})}):null}function pi({isPreview:e,previewPreset:t,onModeChange:n}){let r=(0,d.useCanvas)();return(0,p.jsxs)(`div`,{className:`relative z-0 flex h-full min-h-0 w-full min-w-0 max-w-full flex-col overflow-hidden bg-white`,children:[(0,p.jsxs)(`div`,{className:`exhibition-slideshow-current-toolbar flex items-center gap-3 border-b border-slate-200 bg-white px-4 py-3 shadow-sm`,children:[(0,p.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,p.jsx)(d.LocaleString,{className:`block truncate text-sm font-semibold text-slate-800`,children:r?.label})}),(0,p.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,p.jsxs)(`div`,{className:`flex shrink-0 overflow-hidden rounded-md border border-slate-200 bg-slate-50 text-xs font-semibold`,children:[(0,p.jsx)(mi,{selected:!e,onPress:()=>n(!1),children:`Edit`}),(0,p.jsx)(mi,{selected:e,onPress:()=>n(!0),children:`Preview`})]})})]}),e?(0,p.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,p.jsx)($e,{preset:t})}):(0,p.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,p.jsx)(u.CanvasPanelEditor,{asFallback:!0})})]})}function mi({children:e,selected:t,onPress:n}){return(0,p.jsx)(v.Button,{className:(0,y.twMerge)(`px-3 py-2 text-xs font-semibold transition`,t?`bg-me-primary-500 text-white shadow-sm`:`text-slate-500 hover:text-slate-700`),onPress:n,children:e})}const hi={id:`info-block-editor`,label:`info Block Editor`,component:e=>(0,p.jsx)(yi,{strategy:e}),supports:{strategy:(e,t,n)=>e.type===`textual-content`}};function gi(e){if(e===`@none`||e===`none`)return null;try{let t=new Intl.DisplayNames([e],{type:`language`});return e===`cy`?{key:e,language:e,label:`Cymraeg`}:{key:e,language:e,label:t.of(e)}}catch{return{key:e,language:e,label:e}}}function _i({selectedLanguage:e,languages:t,availableLanguages:n,onSelectLanguage:r,onAddLanguage:i}){let[a,o]=(0,m.useState)(!1),s=(0,m.useRef)(null);(0,m.useEffect)(()=>{if(!a)return;let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]);let c=n.filter(e=>!t.includes(e)),l=gi(e);return(0,p.jsxs)(`div`,{ref:s,className:`relative`,children:[(0,p.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 rounded-md border border-slate-200 bg-white px-3 py-2 text-xs font-semibold text-slate-700 shadow-sm transition hover:bg-slate-50`,onClick:()=>o(e=>!e),children:[(0,p.jsx)(`span`,{className:``,children:l?.label||e}),(0,p.jsx)(`svg`,{className:`h-3 w-3 text-slate-400`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:2,children:(0,p.jsx)(`path`,{d:`M2 4l4 4 4-4`})})]}),a&&(0,p.jsxs)(`div`,{className:`absolute right-0 top-full z-50 mt-1 min-w-[14rem] rounded-md border border-slate-200 bg-white py-1 shadow-lg`,children:[t.length>0&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`px-3 py-1 text-[10px] font-semibold uppercase tracking-wider text-slate-400`,children:`Language`}),t.map(t=>{let n=gi(t);return(0,p.jsxs)(`button`,{type:`button`,className:(0,y.twMerge)(`flex w-full items-center gap-2 px-3 py-1.5 text-xs hover:bg-slate-50`,t===e?`font-semibold text-slate-900`:`text-slate-600`),onClick:()=>{r(t),o(!1)},children:[t===e?(0,p.jsx)(`svg`,{className:`h-3 w-3 shrink-0 text-slate-500`,viewBox:`0 0 12 12`,fill:`currentColor`,children:(0,p.jsx)(`path`,{d:`M2 6l3 3 5-5`,stroke:`currentColor`,strokeWidth:2,fill:`none`})}):(0,p.jsx)(`div`,{className:`h-3 w-3 shrink-0 text-slate-500`}),(0,p.jsx)(`span`,{children:n?.label||t})]},t)})]}),c.length>0&&(0,p.jsxs)(p.Fragment,{children:[t.length>0&&(0,p.jsx)(`div`,{className:`my-1 border-t border-slate-100`}),(0,p.jsx)(`div`,{className:`px-3 py-1 text-[10px] font-semibold uppercase tracking-wider text-slate-400`,children:`Add language`}),c.map(e=>{let t=gi(e);return(0,p.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-1.5 text-xs text-slate-600 hover:bg-slate-50`,onClick:()=>{i(e),o(!1)},children:[(0,p.jsx)(`svg`,{className:`h-3 w-3 shrink-0 text-slate-400`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:2,children:(0,p.jsx)(`path`,{d:`M6 2v8M2 6h8`})}),t?.label||e]},e)})]}),c.length===0&&t.length===0&&(0,p.jsx)(`div`,{className:`px-3 py-2 text-xs text-slate-400`,children:`No languages available`})]})]})}function vi(e,t){if(!e)return[];let n=e.items||[],r=new Set;for(let e of n){let n=Q(e,t);if(!n)continue;let i=Ai(n.body);for(let e of i){let n=Q(e,t);n?.language&&r.add(n.language)}}return Array.from(r)}function yi({strategy:e}){let t=(0,d.useCanvas)(),n=t?.behavior||[],r=dt(n),i=!!(r.h&&r.w),{isBottom:a,isLeft:o,isRight:s}=pt(n),c=i&&r.w<=6,u=(0,d.useVaultSelector)((e,n)=>t?.items[0]?n.get(t.items[0]):null),f=(0,d.useVaultSelector)((e,n)=>t?.annotations[0]?n.get(t?.annotations[0]):null),{i18n:{availableLanguages:h,defaultLanguage:g}}=(0,l.useConfig)(),[_,v]=(0,l.useLocalStorage)(`exhibition-info-block-mode`,`edit`),b=rt(),x=b===`exhibition`,S=x,C=x?`Read more text in modal`:`Summary`,w=(0,d.useVaultSelector)((e,t)=>{let n=vi(u,t),r=vi(f,t),i=new Set([...n,...r]);return i.size===0&&i.add(g||`en`),Array.from(i)},[u?.id,f?.id,g]),[T,E]=(0,m.useState)(),D=T||(w.includes(g)?g:w[0]||g||`en`),O=e=>{E(e)},k=c?`30rem`:void 0;return(0,p.jsxs)(`div`,{className:`relative z-0 flex h-full min-h-0 w-full min-w-0 max-w-full flex-col overflow-hidden bg-white`,children:[(0,p.jsxs)(`div`,{className:`exhibition-slideshow-current-toolbar relative z-[70] flex items-center gap-3 border-b border-slate-200 bg-white px-4 py-3 shadow-sm`,children:[(0,p.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,p.jsx)(d.LocaleString,{className:`block truncate text-sm font-semibold text-slate-800`,children:t?.label})}),(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[_===`edit`&&(0,p.jsx)(_i,{selectedLanguage:D,languages:w,availableLanguages:h,onSelectLanguage:E,onAddLanguage:O}),(0,p.jsxs)(`div`,{className:`flex shrink-0 overflow-hidden rounded-md border border-slate-200 bg-slate-50 text-xs font-semibold`,children:[(0,p.jsx)(bi,{selected:_===`edit`,onPress:()=>v(`edit`),children:`Edit`}),(0,p.jsx)(bi,{selected:_===`preview`,onPress:()=>v(`preview`),children:`Preview`})]})]})]}),_===`preview`?(0,p.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,p.jsx)($e,{preset:b})}):(0,p.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto`,children:[S?(0,p.jsx)(xi,{annotationPage:u,compact:c,editorMaxWidth:k,fallbackText:e.items[0]?.text,heading:`Short text in info box`,panelClassName:(0,y.twMerge)(`border-b border-gray-100`,c?`p-3`:`p-5`,i&&(o||s)?`max-w-xl`:``,i&&a?`max-w-4xl`:``),parentProperty:`items`,selectedLanguage:D,onLanguageAdded:O}):null,(0,p.jsx)(xi,{annotationPage:f,compact:c,heading:C,panelClassName:(0,y.twMerge)(c?`p-3`:`p-5`),parentProperty:`annotations`,selectedLanguage:D,onLanguageAdded:O})]})]})}function bi({children:e,selected:t,onPress:n}){return(0,p.jsx)(v.Button,{className:(0,y.twMerge)(`px-3 py-2 text-xs font-semibold transition`,t?`bg-white text-slate-900 shadow-sm`:`text-slate-500 hover:text-slate-700`),onPress:n,children:e})}function xi({annotationPage:e,compact:t,editorMaxWidth:n,fallbackText:r,heading:i,panelClassName:a,parentProperty:o,selectedLanguage:s,onLanguageAdded:c}){let u=(0,d.useCanvas)(),f=(0,l.useInlineCreator)(),m=(0,d.useVault)(),{i18n:{defaultLanguage:g}}=(0,l.useConfig)(),_=e||null,v=_?.items||[],b=wi(v,m),x=()=>{u&&f.create(`@manifest-editor/empty-annotation-page`,{label:{en:[i]}},{target:{id:u.id,type:`Canvas`},targetType:`AnnotationPage`,parent:{property:o,resource:{id:u.id,type:`Canvas`}}})},S=()=>{if(u){if(!_){x();return}f.create(`@manifest-editor/html-annotation`,{label:{en:[i]},body:{[s||g||`en`]:[``]},motivation:o===`annotations`?`tagging`:`painting`},{target:{id:u.id,type:`Canvas`},targetType:`Annotation`,parent:{property:`items`,resource:{id:_.id,type:`AnnotationPage`}},initialData:{}})}},C=()=>{if(!_){S(),c(s);return}let e=!1;for(let t of v){let n=Q(t,m);if(!n)continue;let r=Ai(n.body);if(r.some(e=>Q(e,m)?.language===s))continue;let i=r[0],a=i?Q(i,m):null,o=`${n.id}-body-${s}-${Date.now()}`;m.batch(()=>{m.dispatch((0,D.importEntities)({entities:{ContentResource:{[o]:{id:o,type:a?.type||`TextualBody`,language:s,value:``,format:a?.format||`text/html`}}}})),m.dispatch((0,D.addMappings)({mapping:{[o]:`ContentResource`}})),m.modifyEntityField({id:n.id,type:`Annotation`},`body`,[...r,{id:o,type:`ContentResource`}])}),e=!0}e||S(),c(s)},w=(0,d.useVaultSelector)((e,t)=>{if(!_)return!1;for(let e of v){let n=Q(e,t);if(!n)continue;let r=Ai(n.body);for(let e of r)if(Q(e,t)?.language===s)return!0}return!1},[_?.id,v,s]);return(0,p.jsxs)(`section`,{className:(0,y.twMerge)(`min-w-0 max-w-full`,a),children:[(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`flex items-center justify-between gap-3`,b.length?`mb-3`:`mb-0`),children:[(0,p.jsx)(`h2`,{className:(0,y.twMerge)(`font-semibold tracking-tight text-gray-700`,t?`text-xs uppercase`:`text-sm uppercase tracking-wide`),children:i}),!w&&(0,p.jsx)(h.ActionButton,{primary:!0,onPress:C,children:_?`Add text`:`Add`})]}),!_&&r?(0,p.jsx)(`div`,{className:`mt-2 text-sm text-gray-600`,children:(0,p.jsx)(d.LocaleString,{enableDangerouslySetInnerHTML:!0,children:r})}):null,b.length?(0,p.jsx)(`div`,{className:`min-w-0 max-w-full`,children:b.map(({item:e,index:t})=>(0,p.jsx)(d.AnnotationContext,{annotation:e.id,children:(0,p.jsx)(Si,{editorMaxWidth:n,pageItems:v,pageRef:{id:_.id,type:`AnnotationPage`},selectedLanguage:s,onRemoveAnnotation:()=>{m.modifyEntityField({id:_.id,type:`AnnotationPage`},`items`,v.filter((e,n)=>n!==t))}})},e.id+t))}):_&&w?(0,p.jsx)(`div`,{className:(0,y.twMerge)(`mt-2 text-sm text-gray-400 italic`,``),children:`No text added yet.`}):null]})}function Si({editorMaxWidth:e,onRemoveAnnotation:t,pageItems:n,pageRef:r,selectedLanguage:i}){let a=(0,d.useAnnotation)(),o=(0,d.useVault)(),s=a?.body||[],c=(0,l.useGenericEditor)(a);if(!a)return null;let u=s.map((e,t)=>({item:e,index:t})).filter(({item:e})=>Q(e,o)?.language===i),f=u.length>0?u:[],h=(0,m.useCallback)(e=>{let t=Ei(s,o,e);t.length!==s.length&&o.modifyEntityField({id:a.id,type:`Annotation`},`body`,t);let i=Ti(n,o,a.id);i.length!==n.length&&o.modifyEntityField(r,`items`,i)},[a.id,r.id,n,o]);return f.length?(0,p.jsx)(`div`,{className:`min-w-0 max-w-full overflow-hidden`,children:f.map(({item:t,index:n})=>(0,p.jsx)(Ci,{resourceId:t.id,onRemove:()=>c.annotation.body.deleteAtIndex(n),onUpdate:()=>h(t.id),editorMaxWidth:e},t.id||n))}):null}function Ci({editorMaxWidth:e,resourceId:t,onRemove:n,onUpdate:r}){let i=(0,m.useMemo)(()=>({id:t,type:`ContentResource`}),[t]),a=(0,l.useGenericEditor)(i),{i18n:{advancedLanguageMode:o,availableLanguages:s,defaultLanguage:c}}=(0,l.useConfig)(),{language:u,value:d}=a.descriptive,f=u.get(),g=Array.isArray(f)?f[0]||c||`en`:f||c||`en`;return(0,m.useEffect)(()=>{let e=Array.isArray(u.get())?u.get()[0]:u.get();!o&&e!==g&&u.set(g)},[o,g]),(0,p.jsxs)(`div`,{className:`min-w-0 max-w-full overflow-hidden`,style:e?{maxWidth:e}:void 0,children:[o?(0,p.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,p.jsx)(`select`,{"aria-label":`Language`,className:`rounded border border-slate-200 bg-white px-2 py-1 text-sm`,value:g,onChange:e=>u.set(e.currentTarget.value),children:s.map(e=>(0,p.jsx)(`option`,{value:e,children:e},e))}),(0,p.jsx)(`button`,{type:`button`,className:`text-sm text-slate-600 hover:text-slate-900`,onClick:n,children:`Remove`})]}):null,(0,p.jsx)(h.HTMLEditor,{value:d.get()||``,onChange:e=>{d.set(e),r()}},`${t}:${g}`)]})}function wi(e,t){let n=e.map((e,t)=>({item:e,index:t})),r=n.filter(({item:e})=>!Di(e,t));return r.length?r:n.slice(0,1)}function Ti(e,t,n){let r=e.filter(e=>e?.id===n||!Di(e,t));return r.length?r:e.slice(0,1)}function Ei(e,t,n){let r=e.filter(e=>e?.id===n||!Oi(e,t));return r.length?r:e.slice(0,1)}function Di(e,t){let n=Ai(Q(e,t)?.body);return!n.length||n.every(e=>Oi(e,t))}function Oi(e,t){let n=Q(e,t);return!n||ki(n.value||``)}function ki(e){let t=String(e||``);return!/<img\b/i.test(t)&&t.replace(/<[^>]*>/g,``).replace(/&nbsp;/gi,` `).replace(/\s+/g,``).trim()===``}function Q(e,t){return!e?.id||e.value||e.items||e.body?e:t.get(e,{skipSelfReturn:!1})||e}function Ai(e){return Array.isArray(e)?e:e==null?[]:[e]}const ji={id:`youtube-main-editor`,label:`YouTube main editor`,component:e=>e.type===`media`?(0,p.jsx)(Mi,{strategy:e,video:e.media}):null,supports:{strategy:(e,t,n)=>e.type===`media`&&e.media.type===`VideoYouTube`}};function Mi({strategy:e,video:t}){let{edit:n}=(0,l.useLayoutActions)(),r=(0,d.useCanvas)(),i=(0,d.useVaultSelector)((e,t)=>t.get(r?.items[0]).items[0]);(0,x.default)(r&&i);let a=(0,m.useRef)(null),o=(0,l.useGenericEditor)(i),s=t,c=(r.width||1)/(r.height||1);return`${s.youTubeId}`,(0,p.jsxs)(`div`,{className:`overflow-y-auto`,children:[(0,p.jsx)(`div`,{className:`p-8`,children:(0,p.jsx)(`div`,{className:`bg-black z-20 flex p-8 rounded-lg max-w-full max-h-[70vh] mx-auto`,style:{aspectRatio:c},children:(0,p.jsx)(`iframe`,{title:`YouTube video`,className:`border-none w-full h-full object-contain`,ref:a,src:`https://www.youtube.com/embed/${s.youTubeId}?enablejsapi=1&origin=${window.location.host}&modestbranding=1&rel=0`,referrerPolicy:`no-referrer compute-pressure`,sandbox:`allow-scripts allow-same-origin allow-presentation`})})}),(0,p.jsxs)(`div`,{className:`bg-white shadow w-full p-8 flex gap-8`,children:[(0,p.jsx)(`div`,{children:(0,p.jsx)(`div`,{className:`w-64 bg-black flex-shrink-0 flex items-center justify-center rounded overflow-clip`,style:{aspectRatio:c},children:r.thumbnail?.length?(0,p.jsx)(h.LazyThumbnail,{cover:!0}):(0,p.jsx)(`div`,{className:`text-white/50 text-center py-16`,children:`No thumbnail`})})}),(0,p.jsxs)(`div`,{className:`flex-1`,children:[(0,p.jsx)(d.LocaleString,{as:`h3`,className:`text-2xl font-bold mt-4`,defaultText:(0,p.jsx)(`span`,{className:`text-black/30`,children:`No Label`}),children:o.descriptive.label.get()}),(0,p.jsx)(d.LocaleString,{as:`p`,className:`mt-2 mb-8`,defaultText:(0,p.jsx)(`span`,{className:`text-black/30`,children:`No summary`}),children:o.descriptive.summary.get()}),(0,p.jsx)(h.ActionButton,{onPress:()=>n(o.ref()),children:`Edit properties`})]})]})]})}const Ni=(0,O.defineCreator)({...k.iiifBrowserCreator,id:`@exhibitions/browser-creator`,configKey:k.iiifBrowserCreator.id,create:Fi,sideEffects:[],tags:[`image`,`exhibition-slide`,`exhibition-slideshow-slide`],label:`IIIF Browser`,summary:`Browse IIIF Resources`,resourceType:`Canvas`,resourceFields:[`id`,`language`,`type`,`format`,`value`],additionalTypes:[],supports:{initialData:!0,onlyPainting:!0,parentTypes:[`Manifest`],parentFields:[`items`],parentFieldMap:{Manifest:[`items`]}}});function Pi(e){return{...e,additionalTypes:e.additionalTypes?.filter(e=>e!==`Canvas`),supports:{...e.supports,parentTypes:[`Annotation`,`AnnotationPage`],parentFieldMap:{Annotation:[`body`],AnnotationPage:[`items`]}}}}async function Fi(e,t){let n=t.generateId(`canvas`),r=t.generateId(`annotation-page`,{id:n,type:`Canvas`}),i={width:0,height:0},a,o=await(0,O.creatorHelper)(t,{id:r,type:`AnnotationPage`},`items`,`@manifest-editor/iiif-browser-creator`)({...e,trackSize({width:e,height:t}){i.height=t,i.width=e},trackManifest(e){a=e}},{targetType:`Annotation`,target:{id:n,type:`Canvas`}});return await(0,O.creatorHelper)(t,`Manifest`,`items`,`@exhibitions/image-slide-creator`)({canvasId:n,width:i.width,height:i.height,type:`default`,items:o,imageSlideBehavior:t.options.initialData?.imageSlideBehavior,...a})}const Ii=(0,O.defineCreator)({...k.imageServiceCreator,id:`@exhibitions/image-service-creator`,create:Li,tags:[`image`,`exhibition-slide`,`exhibition-slideshow-slide`],label:`IIIF Image`,summary:`IIIF Image service`,resourceType:`Canvas`,supports:{initialData:!0,parentTypes:[`Manifest`],parentFields:[`items`]}});async function Li(e,t){let n=t.generateId(`canvas`);t.generateId(`annotation-page`,{id:n,type:`Canvas`});let r=t.generateId(`annotation`),i=await(0,O.creatorHelper)(t,{id:r,type:`Annotation`},`body`,`@manifest-editor/image-service-creator`)(e,{target:{id:n,type:`Canvas`}}),{width:a,height:o}=i.get(),s=t.embed({id:t.generateId(`annotation`),type:`Annotation`,motivation:`painting`,body:[i],target:{type:`SpecificResource`,source:{id:n,type:`Canvas`}}});return await(0,O.creatorHelper)(t,`Manifest`,`items`,`@exhibitions/image-slide-creator`)({canvasId:n,width:a,height:o,type:e.slideType??`default`,items:[s],imageSlideBehavior:e.imageSlideBehavior??t.options.initialData?.imageSlideBehavior})}const Ri=(0,O.defineCreator)({id:`@exhibitions/image-slide-creator`,create:Vi,label:`Empty slide`,summary:`An empty image slide.`,icon:(0,p.jsx)(h.EmptyCanvasIcon,{}),tags:[`exhibition-slide`],resourceType:`Canvas`,resourceFields:[`id`,`type`,`label`,`height`,`width`,`items`],supports:{initialData:!0,parentTypes:[`Manifest`],parentFields:[`items`]}});(0,O.defineCreator)({...Ri,id:`@exhibitions/image-slide-creator-left`,label:`Image (Left)`,summary:`An image with text on the left.`,icon:(0,p.jsx)(`div`,{children:`IMAGE (LEFT)`}),create:(e,t)=>Vi({...e,type:`left`},t)}),(0,O.defineCreator)({...Ri,id:`@exhibitions/image-slide-creator-right`,label:`Image (Right)`,summary:`An image with text on the right.`,icon:(0,p.jsx)(`div`,{children:`IMAGE (RIGHT)`}),create:(e,t)=>Vi({...e,type:`right`},t)}),(0,O.defineCreator)({...Ri,id:`@exhibitions/image-slide-creator-bottom`,label:`Image (Bottom)`,summary:`An image with text at the bottom.`,icon:(0,p.jsx)(`div`,{children:`IMAGE (BOTTOM)`}),create:(e,t)=>Vi({...e,type:`bottom`},t)});const zi=(0,O.defineCreator)({...Ri,id:`@exhibitions/slideshow-image-only-creator`,label:`Multiple images`,summary:`An empty slideshow slide`,tags:[`exhibition-slideshow-slide`],create:(e,t)=>Vi({...e,behavior:[`w-12`,`h-8`,`image`],height:e.height||1080,width:e.width||1920,type:`default`},t)}),Bi=(0,O.defineCreator)({...Ri,id:`@exhibitions/slideshow-image-text-creator`,label:`Multiple images with text`,summary:`An empty slideshow slide, with text`,tags:[`exhibition-slideshow-slide`],create:(e,t)=>Vi({...e,behavior:[`w-12`,`h-8`,`right`],height:e.height||1080,width:e.width||1920,type:`right`},t)});(0,O.defineCreator)({...Ri,id:`@exhibitions/scroll-compact-deck-creator`,label:`Compact image deck`,summary:`A scrolling section with compact annotation-led image slides.`,tags:[`exhibition-scroll-section`,`exhibition-slide`],create:(e,t)=>Vi({...e,behavior:[`w-12`,`h-8`,`compact-deck`],height:e.height||1080,width:e.width||1920,type:`default`},t)});function Vi(e,t){let n=e.canvasId||t.generateId(`Canvas`),r=t.generateId(`AnnotationPage`,{id:n,type:`Canvas`}),i=t.generateId(`AnnotationPage`,{id:n,type:`Canvas`}),a=[],o=6e3,s=e.imageSlideBehavior||t.options.initialData?.imageSlideBehavior;if(e.behavior)a.push(...e.behavior);else if(s)a.push(...s);else if(e.width&&e.height){let t=e.type??`default`,n=t===`left`||t===`right`,r=t===`bottom`,i=e.width/e.height,o=n?8:12,s=r?3/2:1,c=Math.max(1,Math.min(12,Math.round(o/i*s)));a.push(`w-12`,`h-${c}`)}else a.push(`w-12`,`h-4`);if(!e.behavior)switch(e.type){case`left`:a.push(`left`),o*=2/3;break;case`right`:a.push(`right`),o*=2/3;break;case`bottom`:a.push(`bottom`)}e.items?.length||a.push(`multi-image`);let c={...e.metadata?{metadata:e.metadata}:{},...e.requiredStatement?{requiredStatement:e.requiredStatement}:{},...e.rights?{rights:e.rights}:{},...e.partOf?{partOf:e.partOf}:{}};return t.embed({...A.emptyCanvas,id:n,behavior:a,label:e.label||{en:[`Untitled`]},...c,height:e.height||4e3,duration:e.duration,width:e.width||o,items:[t.embed({...A.emptyAnnotationPage,id:r,type:`AnnotationPage`,items:e.items?e.items:[]})],annotations:[t.embed({...A.emptyAnnotationPage,id:i,type:`AnnotationPage`,items:[]})]})}const Hi=(0,O.defineCreator)({...k.imageUrlCreator,id:`@exhibitions/image-url-creator`,create:Ui,tags:[`exhibition-slide`,`exhibition-slideshow-slide`],label:`Image from URL`,summary:`Image from URL`,resourceType:`Canvas`,supports:{initialData:!0,parentTypes:[`Manifest`],parentFields:[`items`]}});async function Ui(e,t){let n=t.generateId(`canvas`);t.generateId(`annotation-page`,{id:n,type:`Canvas`});let r=t.generateId(`annotation`),i=await(0,O.creatorHelper)(t,{id:r,type:`Annotation`},`body`,`@manifest-editor/image-url-creator`)(e,{target:{id:n,type:`Canvas`},targetType:`Annotation`}),{width:a,height:o}=i.get(),s=t.embed({id:r,type:`Annotation`,motivation:`painting`,body:[i],target:{type:`SpecificResource`,source:{id:n,type:`Canvas`}}});return await(0,O.creatorHelper)(t,`Manifest`,`items`,`@exhibitions/image-slide-creator`)({canvasId:n,width:a,height:o,type:`default`,items:[s],imageSlideBehavior:t.options.initialData?.imageSlideBehavior})}const Wi={fullpage:`Full page`,slideshow:`Slideshow`,scroll:`Scroll`},Gi={templates:qr,onboarding:{id:`exhibition-template-selection`,mode:`per-resource`,title:`Choose exhibition format`,summary:`Pick a starting point for this exhibition.`,openLabel:`Exhibition formats`,dismissLabel:`Skip for now`,primaryLabel:`Start building`,renderPreviewButton:e=>(0,p.jsx)(qi,{...e}),renderBody:({templates:e,selectedTemplateId:t,setSelectedTemplateId:n,dismiss:r})=>(0,p.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:e.length?e.map(e=>{let i=t===e.id;return(0,p.jsxs)(`article`,{className:[`relative overflow-hidden rounded border-2 bg-white`,i?`border-me-primary-500`:`border-gray-200`].join(` `),children:[(0,p.jsx)(v.Button,{"aria-label":`Use ${e.label} format`,"aria-pressed":i,className:`absolute inset-0 z-10 cursor-pointer rounded outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-me-primary-500`,onPress:()=>{n(e.id),r()}}),(0,p.jsx)(`img`,{src:e.thumbnailUrl,alt:``,className:`aspect-video w-full bg-gray-100 object-cover`}),(0,p.jsxs)(`div`,{className:`pointer-events-none flex flex-col gap-2 p-3`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h3`,{className:`text-sm font-semibold text-gray-900`,children:e.label}),(0,p.jsx)(`p`,{className:`mt-1 text-xs uppercase tracking-normal text-gray-500`,children:e.type})]}),(0,p.jsx)(`p`,{className:`text-sm text-gray-600`,children:e.summary}),(0,p.jsx)(`a`,{href:e.previewUrl,target:`_blank`,rel:`noreferrer`,className:`pointer-events-auto relative z-20 inline-flex w-fit items-center rounded py-0.5 text-sm font-medium text-me-700 hover:text-me-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-me-primary-500 focus-visible:ring-offset-2`,children:`Preview`})]})]},e.id)}):(0,p.jsx)(`p`,{className:`text-sm text-gray-600`,children:`No exhibition formats are available for this editor.`})})}};function Ki(e,t){let n=new URL(e);return n.searchParams.set(`manifest`,t),n.toString()}function qi({downloadEnabled:e,fileName:t,preview:n,showOnboardingPreviewHint:r,onOnboardingPreviewHintClose:i}){let{actions:a,configs:o,active:s}=(0,l.usePreviewContext)(),c=(0,d.useVault)(),u=(0,l.useConfig)(),f=(0,l.useAppResource)(),m=(0,l.useLayoutActions)(),g=(0,l.useOpenPresetOnboarding)(),{selectedTemplate:_,templates:y}=(0,l.usePresetTemplateSelection)(),b=V(),x=o.filter(e=>e.type===`external-manifest-preview`),S=Oe(y,_,b),C=x.find(e=>e.id===u.defaultPreview)||x.find(e=>!e.id.includes(`theseus`)&&e.id!==`raw-manifest`)||x[0],w=x.find(e=>e.id===`theseus`||e.id===`theseus-viewer`),T=x.find(e=>e.id===`raw-manifest`);async function E(e){let t=await a.getPreviewLink();t&&window.open(Ki(e.previewUrl,t),e.id)}function D(e){a.selectPreview(e)}function O(){m.leftPanel.open({id:`@exhibitions/theme-panel`})}return!S.length&&!n?.mainAction&&!n?.actions?.length?null:(0,p.jsxs)(p.Fragment,{children:[e?(0,p.jsx)(`div`,{className:`mr-4`,children:(0,p.jsx)(h.DownloadButton,{fileName:t||`manifest.json`,label:`Download manifest`,getData:()=>u.export&&u.export.version===2?JSON.stringify(c.toPresentation2(f),null,2):JSON.stringify(c.toPresentation3(f),null,2)})}):null,(0,p.jsxs)(l.ButtonContainer,{style:{width:`auto`,minWidth:`10em`},children:[(0,p.jsxs)(l.ButtonMain,{as:v.Button,"data-preview-action":n?.mainAction?.id,isDisabled:n?.mainAction?.disabled,onPress:n?.mainAction?.onClick||O,children:[n?.mainAction?.label||`Preview`,b?(0,p.jsxs)(`span`,{className:`ml-1 whitespace-nowrap opacity-75`,children:[`· `,Wi[b.type]]}):null]}),(0,p.jsxs)(v.MenuTrigger,{children:[(0,p.jsx)(l.ButtonChange,{as:v.Button,$open:!1,"aria-label":`Choose preview`,className:`exhibition-preview-preset-menu`,children:(0,p.jsx)(Kr,{})}),(0,p.jsx)(v.Popover,{placement:`bottom right`,className:`z-50`,children:(0,p.jsxs)(l.MenuContainer,{as:v.Menu,$open:!0,className:`outline-none`,style:{position:`relative`,top:`auto`,left:`auto`,marginTop:0,width:`15em`},children:[(0,p.jsxs)(v.MenuItem,{className:`flex cursor-pointer items-center border-b border-gray-100 p-1 outline-none hover:bg-gray-50 focus:bg-gray-50`,onAction:g,children:[(0,p.jsx)(`span`,{className:`mx-2 flex h-4 w-8 shrink-0 items-center justify-center`,children:(0,p.jsx)(Ji,{className:`h-4 w-4 text-gray-500`})}),(0,p.jsx)(l.MenuItemLabel,{children:`Change exhibition format`})]}),S.map(e=>{let t=b?.id===e.id;return(0,p.jsxs)(v.MenuItem,{"aria-current":t?`true`:void 0,className:`flex cursor-pointer items-center p-1 outline-none hover:bg-gray-50 focus:bg-gray-50`,onAction:()=>E(e),children:[(0,p.jsx)(l.MenuItemStatus,{$status:t?`active`:`available`}),(0,p.jsxs)(l.MenuItemLabel,{children:[e.label,t?` (current)`:``]})]},e.id)}),n?.actions?.map(e=>(0,p.jsxs)(v.MenuItem,{className:`flex cursor-pointer items-center p-1 outline-none hover:bg-gray-50 focus:bg-gray-50`,isDisabled:e.disabled,onAction:e.onClick,children:[(0,p.jsx)(l.MenuItemStatus,{$status:e.status||`available`}),(0,p.jsx)(l.MenuItemLabel,{children:e.label})]},e.id)),w&&w.id!==C?.id?(0,p.jsxs)(v.MenuItem,{className:`flex cursor-pointer items-center p-1 outline-none hover:bg-gray-50 focus:bg-gray-50`,onAction:()=>D(w.id),children:[(0,p.jsx)(l.MenuItemStatus,{$status:s.includes(w.id)?`configured`:`available`}),(0,p.jsx)(l.MenuItemLabel,{children:w.label})]}):null,T&&T.id!==C?.id?(0,p.jsxs)(v.MenuItem,{className:`flex cursor-pointer items-center p-1 outline-none hover:bg-gray-50 focus:bg-gray-50`,onAction:()=>D(T.id),children:[(0,p.jsx)(l.MenuItemStatus,{$status:s.includes(T.id)?`configured`:`available`}),(0,p.jsx)(l.MenuItemLabel,{children:T.label})]}):null]})})]})]}),(0,p.jsx)(h.OnboardingTour,{id:`exhibition-preview-preset-menu`,forceStart:r,onClose:i,lastButtonLabel:`Dismiss`,steps:[{target:`.exhibition-preview-preset-menu`,placement:`bottom`,disableBeacon:!0,content:`You can change the exhibition format again from this preview menu.`}]})]})}function Ji(e){return(0,p.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,...e,children:(0,p.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,children:[(0,p.jsx)(`path`,{d:`M3 17h2.397a5 5 0 0 0 4.096-2.133l.177-.253m3.66-5.227l.177-.254A5 5 0 0 1 17.603 7H21`}),(0,p.jsx)(`path`,{d:`m18 4l3 3l-3 3M3 7h2.397a5 5 0 0 1 4.096 2.133l4.014 5.734A5 5 0 0 0 17.603 17H21`}),(0,p.jsx)(`path`,{d:`m18 20l3-3l-3-3`})]})})}const Yi=(0,O.defineCreator)({id:`@exhibitions/info-box-creator`,create:Zi,label:`Info box`,summary:`A text panel for an exhibition`,icon:(0,p.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,children:[(0,p.jsx)(`title`,{children:`Info box`}),(0,p.jsx)(`path`,{fill:`currentColor`,d:`M11 17h2v-6h-2zm1-8q.425 0 .713-.288T13 8t-.288-.712T12 7t-.712.288T11 8t.288.713T12 9m0 13q-2.075 0-3.9-.788t-3.175-2.137T2.788 15.9T2 12t.788-3.9t2.137-3.175T8.1 2.788T12 2t3.9.788t3.175 2.137T21.213 8.1T22 12t-.788 3.9t-2.137 3.175t-3.175 2.138T12 22`})]}),tags:[`exhibition-slide`],resourceType:`Canvas`,resourceFields:[`id`,`type`,`label`,`height`,`width`,`items`],supports:{initialData:!0,parentTypes:[`Manifest`],parentFields:[`items`]}}),Xi=(0,O.defineCreator)({...Yi,id:`@exhibitions/slideshow-long-editorial-creator`,label:`Long editorial`,summary:`A text-led slideshow slide.`,tags:[`exhibition-slideshow-slide`],create:(e,t)=>Zi({...e,behavior:[`w-12`,`h-8`,`info`],height:e.height||1080,width:e.width||1920},t)});async function Zi(e,t){let n=t.generateId(`canvas`),r=t.generateId(`annotation-page`,{id:n,type:`Canvas`}),i=t.generateId(`annotation-page`,{id:n,type:`Canvas`}),a={...A.emptyAnnotation,id:t.generateId(`annotation`,{id:n,type:`Canvas`}),type:`Annotation`},o=[await t.create(`@manifest-editor/html-body-creator`,{language:`en`,body:``},{parent:{resource:a,property:`body`}})],s=t.embed({...a,motivation:`painting`,body:o,target:{type:`SpecificResource`,source:{id:n,type:`Canvas`}}}),c=t.generateId(`annotation`,{id:n,type:`Canvas`}),l=t.embed({id:c,type:`Annotation`,motivation:`tagging`,body:[await t.create(`@manifest-editor/html-body-creator`,{language:`en`,body:``},{parent:{resource:{id:c,type:`Annotation`},property:`body`}})],target:{type:`SpecificResource`,source:{id:n,type:`Canvas`}}}),u=t.embed({id:r,type:`AnnotationPage`,items:[s]}),d=t.embed({id:i,type:`AnnotationPage`,items:[l]});return t.embed({...A.emptyCanvas,id:n,type:`Canvas`,behavior:e.behavior||[`w-4`,`h-4`,`info`],label:e.label||void 0,height:e.height||1e3,width:e.width||1e3,items:[u],annotations:[d]})}const Qi=(0,O.defineCreator)({...k.videoAnnotation,id:`@exhibitions/video-creator`,create:ea,tags:[`video`,`exhibition-slide`],label:`Video`,summary:`A video for an exhibition`,resourceType:`Canvas`,resourceFields:[`id`,`type`,`label`,`height`,`width`,`items`],supports:{initialData:!0,parentTypes:[`Manifest`],parentFields:[`items`]}}),$i=(0,O.defineCreator)({...Qi,id:`@exhibitions/slideshow-video-creator`,label:`Video`,summary:`A video slide for a slideshow exhibition.`,tags:[`exhibition-slideshow-slide`],create:(e,t)=>ea({...e,behavior:[`w-12`,`h-8`,`image`],height:e.height||1080,slideType:`default`,width:e.width||1920},t)});async function ea(e,t){let n=t.generateId(`canvas`),r=t.generateId(`annotation-page`,{id:n,type:`Canvas`}),i=await t.create(`@manifest-editor/video-annotation`,e,{target:{id:n,type:`Canvas`},targetType:`Annotation`,parent:{resource:{id:r,type:`AnnotationPage`},property:`items`}});return t.embed({id:r,type:`AnnotationPage`,items:[i]}),await(0,O.creatorHelper)(t,`Manifest`,`items`,`@exhibitions/image-slide-creator`)({canvasId:n,behavior:e.behavior,height:e.height||1080,width:e.width||1920,duration:e.duration,type:e.slideType||`bottom`,items:[i]})}const ta=(0,O.defineCreator)({...k.youTubeBodyCreator,id:`@exhibitions/youtube-creator`,create:ra,tags:[`video`,`exhibition-slide`],label:`YouTube`,summary:`A YouTube for an exhibition`}),na=(0,O.defineCreator)({...ta,id:`@exhibitions/slideshow-youtube-creator`,label:`YouTube`,summary:`A YouTube slide for a slideshow exhibition.`,tags:[`exhibition-slideshow-slide`]});async function ra(e,t){let n=(0,u.getYouTubeId)(e.youtubeUrl),r=t.generateId(`canvas`),i=t.generateId(`annotation-page`,{id:r,type:`Canvas`}),a=t.embed({id:t.generateId(`annotation`,{id:i,type:`AnnotationPage`}),type:`Annotation`,motivation:`painting`,body:[(0,k.createYoutubeBodyResource)(e,t)],target:{type:`SpecificResource`,source:{id:r,type:`Canvas`}}}),o=t.embed({id:i,type:`AnnotationPage`,items:[a]}),s=t.embed({id:`https://img.youtube.com/vi/${n}/maxresdefault.jpg`,type:`Image`,format:`image/jpeg`,width:640,height:360});return t.embed({...A.emptyCanvas,id:r,type:`Canvas`,behavior:[`w-12`,`h-8`],label:e.label||{en:[`Untitled YouTube Video`]},height:e.height||1080,width:e.width||1920,thumbnail:[s],items:[o]})}function ia(e){return!(0,j.getValue)(e)}function aa(e,t,n){let r=t>0&&n>0?Math.max(1,Math.min(12,Math.round(t/n*12))):4;return[...e.filter(e=>!e.startsWith(`w-`)&&!e.startsWith(`h-`)),`w-12`,`h-${r}`]}function oa({misplacedSplash:e=!1}){let t=(0,l.useEditor)(),n=()=>{let n=t.technical.width.get(),r=t.technical.height.get(),i=t.descriptive.summary,a=t.technical.behavior,o=a.get(),s=aa(e?o.filter(e=>e!==`splash`):o,n,r);ia(i.get())&&i.set({en:[`Summary of image`]}),(s.length!==o.length||s.some((e,t)=>e!==o[t]))&&a.set(s)};return(0,p.jsxs)(`div`,{className:`flex flex-col items-center gap-4 border-me-100 border-2 p-4 rounded`,children:[e?`Opening cover canvases must be first. Apply defaults to use this canvas as a regular exhibition slide.`:`This canvas was not created in the exhibition editor. Do you want to apply default settings?`,(0,p.jsx)(h.ActionButton,{onPress:()=>n(),children:`Apply defaults`})]})}function sa({editor:e}){let t=e.get()||``;return(0,p.jsxs)(u.InputContainer,{$wide:!0,id:e.containerId(),children:[(0,p.jsx)(u.InputLabel,{htmlFor:e.focusId(),children:`Background colour`}),(0,p.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,p.jsx)(`input`,{id:e.focusId(),"aria-label":`Choose background colour`,className:`h-9 w-12 shrink-0 cursor-pointer rounded border border-[#dcd5ce] bg-white p-1`,type:`color`,value:ca(t),onChange:t=>e.set(t.target.value)}),(0,p.jsx)(u.Input,{"aria-label":`Background colour value`,placeholder:`No colour`,value:t,onChange:t=>e.set(t.target.value||null)}),t?(0,p.jsx)(`button`,{type:`button`,className:`rounded border border-[#dcd5ce] bg-white px-3 py-2 text-sm font-semibold text-[#332f2c]`,onClick:()=>e.set(null),children:`Remove`}):null]}),(0,p.jsx)(`p`,{className:`mt-1 text-xs text-[#6a625c]`,children:`Shown behind the image and text for this section.`})]})}function ca(e){let t=e.trim();if(/^#[0-9a-fA-F]{6}$/.test(t))return t;if(/^#[0-9a-fA-F]{3}$/.test(t)){let[e,n,r]=t.slice(1);return`#${e}${e}${n}${n}${r}${r}`}return`#ffffff`}function la(e,t){if(!t?.behavior?.includes(`multi-image`))return null;let n=W(e,t);if(n.length!==1)return null;let r=n[0],i=Array.isArray(r?.body)?r.body[0]:r?.body,a=i?.type===`SpecificResource`?i.selector:null,o=a?.region?.split(`,`).map(Number);return r?.target?.selector&&Ve(e,r)?.type===`Image`&&[`ImageApiSelector`,`iiif:ImageApiSelector`].includes(a?.type)&&o?.length===4&&o.every(Number.isFinite)&&o[2]>0&&o[3]>0?r:null}function ua(){let e=(0,d.useCanvas)(),t=(0,d.useVault)(),n=(0,d.useVaultSelector)((t,n)=>la(n,e),[e?.id,e?.items]),r=(0,l.useGenericEditor)(n?{id:n.id,type:`Annotation`}:void 0,{allowNull:!0});return!e||!n||!r?.annotation?null:(0,p.jsxs)(`div`,{className:`mb-6 rounded-md border border-amber-300 bg-amber-50 p-4 text-sm text-amber-950`,children:[(0,p.jsx)(`p`,{className:`mb-3`,children:`This slide has one image positioned for a multi-image layout. Rescale the slide to fit it.`}),(0,p.jsx)(v.Button,{className:`rounded-md bg-amber-900 px-3 py-2 font-semibold text-white hover:bg-amber-800`,onPress:()=>(0,u.targetWholeCanvas)(t,e,r.annotation),children:`Rescale for current image`})]})}const da={id:`@exhibition/summary-editor`,supports:{edit:!0,properties:[`summary`,`requiredStatement`],resourceTypes:[`Canvas`],custom:(e,t)=>{let{resource:n}=e;return mt(n,t)?!Pr(e,t)&&!ht(n,t):!1}},label:`Text content`,component:()=>(0,p.jsx)(fa,{})};function fa(){return(0,p.jsx)(h.Sidebar,{children:(0,p.jsx)(h.SidebarContent,{padding:!0,children:(0,p.jsx)(pa,{})})})}function pa(){let e=U(e=>e.setCenterPanelMode),t=(0,d.useCanvas)();return(0,m.useEffect)(()=>{e(`preview`)},[e]),t?(0,p.jsxs)(l.ResourceEditingProvider,{resource:t,children:[(0,p.jsx)(u.LanguageMapEditor,{dispatchType:`label`}),(0,p.jsx)(ha,{resource:t}),(0,p.jsx)(ma,{})]}):null}function ma(){let{descriptive:e}=(0,l.useEditor)(),{requiredStatement:t}=e,n=t.get();return(0,p.jsxs)(u.InputContainer,{$wide:!0,id:t.containerId(),children:[(0,p.jsx)(u.InputLabel,{htmlFor:t.focusId(),children:`Required statement`}),(0,p.jsxs)(u.InputFieldset,{id:t.focusId(),children:[(0,p.jsx)(u.LanguageFieldEditor,{focusId:`${t.focusId()}_label`,label:`Label`,fields:n?.label||{none:[]},onSave:e=>t.updateLabel(e.toInternationalString())}),(0,p.jsx)(u.LanguageFieldEditor,{focusId:`${t.focusId()}_value`,label:`Value`,fields:n?.value||{none:[]},onSave:e=>t.update(e.toInternationalString())})]})]})}function ha({resource:e}){let t=(0,d.useVault)(),n=(0,m.useMemo)(()=>$n(e.summary),[e.summary]);return(0,p.jsx)(u.TiptapLanguageFieldEditor,{label:`summary`,metadataKey:`summary`,fields:n,onSave:n=>{t.modifyEntityField(e,`summary`,er(n.toInternationalString()))}},e.id)}const ga={id:`@exhibition/right-panel-editor`,supports:{edit:!0,properties:[`label`,`summary`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>mt(e,t)?!ht(e,t):!1},label:`Exhibition`,component:()=>(0,p.jsx)(_a,{})};function _a(){return(0,p.jsx)(h.Sidebar,{children:(0,p.jsx)(h.SidebarContent,{padding:!0,children:(0,p.jsx)(va,{})})})}function va(){let e=U(e=>e.setCenterPanelMode),t=(0,d.useCanvas)(),n=(0,d.useVault)(),r=(0,l.useManifestEditor)(),i=(0,l.useEditingResource)(),{structural:a,technical:o}=(0,l.useEditor)(),{items:s}=a,c=o.behavior.get()||[],f=s.get()[0],[,h]=(0,l.useCreator)(f?{id:f.id,type:`AnnotationPage`}:void 0,`items`,`Annotation`,t?{id:t.id,type:`Canvas`}:void 0,{isPainting:!0}),g=_t(t),_=c.includes(`info`),v=Nr(t,r.structural.items.get()),y=c.includes(`splash`)&&!v,b=Ne(n,t),x=$t(c,(0,d.useVaultSelector)((e,n)=>t?Me(n,t).length>0:!1,[t?.id,t?.annotations?.[0]?.id]));return(0,m.useEffect)(()=>{e(`preview`)},[e]),!t||!f||!i?(0,p.jsx)(`div`,{className:`p-8`,children:`Canvas, page, or resource not found`}):_?(0,p.jsxs)(l.ResourceEditingProvider,{resource:t,children:[!g||y?(0,p.jsx)(oa,{misplacedSplash:y}):null,(0,p.jsx)(ba,{canvas:t}),b?(0,p.jsx)(xa,{canvas:t}):null]}):(0,p.jsxs)(l.ResourceEditingProvider,{resource:t,children:[!g||y?(0,p.jsx)(oa,{misplacedSplash:y}):null,(0,p.jsx)(ua,{}),v?(0,p.jsx)(ya,{manifestEditor:r}):(0,p.jsx)(ba,{canvas:t}),(0,p.jsx)(sa,{editor:o.backgroundColor}),x.layoutOptions.length||x.isSlideshow&&Sn(c)?(0,p.jsx)(u.InputContainer,{$wide:!0,children:(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`exhibition-workbench-muted mb-3 text-sm font-semibold`,children:x.isSlideshow&&Sn(c)?`Text overlay position`:`Text placement`}),x.isSlideshow&&Sn(c)?(0,p.jsx)(St,{value:Cn(c),onChange:e=>o.behavior.set(wn(c,e))}):(0,p.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:x.layoutOptions.map(e=>(0,p.jsx)(pn,{preset:e.value,label:e.label,selected:yn(c)===e.value,onClick:()=>{o.behavior.set(bn(c,e.value,t?{width:t.width,height:t.height}:void 0)),t&&Pn(n,t,e.value)}},e.value))}),(0,p.jsx)(Sa,{canvas:t,tabId:`slide-behaviors`,label:`More display options`})]})}):null,b&&!v?(0,p.jsx)(xa,{canvas:t}):null,(0,p.jsx)(d.AnnotationPageContext,{annotationPage:f.id,children:(0,p.jsx)(u.PaintingAnnotationList,{onCreate:()=>{e(`edit`),h.createFiltered(`image`,void 0,{skipEditingOnCreate:!0})}})})]})}function ya({manifestEditor:e}){let t={...e.ref(),summary:e.descriptive.summary.get()};return(0,p.jsxs)(l.ResourceEditingProvider,{resource:t,children:[(0,p.jsx)(u.LanguageMapEditor,{dispatchType:`label`}),(0,p.jsx)(ha,{resource:t})]})}function ba({canvas:e}){let{edit:t}=(0,l.useLayoutActions)(),n=(0,m.useRef)(null),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(!1),s=Ca(e.label)||`Untitled`,c=tr(e.summary);return(0,m.useEffect)(()=>{let e=n.current;if(!e){o(!1);return}o(e.scrollHeight>e.clientHeight+1)},[c,r]),(0,p.jsx)(u.InputContainer,{$wide:!0,children:(0,p.jsxs)(`div`,{className:`rounded-md border border-[#dcd5ce] bg-[#f8f6f3] p-4`,children:[(0,p.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,p.jsxs)(`div`,{className:`min-w-0`,children:[(0,p.jsx)(`div`,{className:`text-xs font-semibold uppercase text-[#6a625c]`,children:`Label`}),(0,p.jsx)(`div`,{className:`mt-1 break-words text-base font-semibold text-[#25211f]`,children:s})]}),(0,p.jsx)(`button`,{type:`button`,className:`flex-shrink-0 rounded-md px-3 py-2 text-sm font-semibold shadow-sm`,style:{backgroundColor:`#b84c74`,border:`1px solid #a13e63`,color:`#ffffff`},onClick:()=>{t({id:e.id,type:`Canvas`},void 0,{selectedTab:`@exhibition/summary-editor`,forceOpen:!0})},children:`Edit`})]}),(0,p.jsxs)(`div`,{className:`mt-5`,children:[(0,p.jsx)(`div`,{className:`text-xs font-semibold uppercase text-[#6a625c]`,children:`Summary`}),(0,p.jsx)(`div`,{ref:n,className:[`mt-2 whitespace-pre-wrap break-words text-sm leading-relaxed text-[#332f2c]`,r?``:`max-h-32 overflow-hidden`].join(` `),children:c?(0,p.jsx)(`div`,{className:`prose prose-sm max-w-none prose-p:my-2 prose-headings:my-2 prose-ul:my-2 prose-ol:my-2`,dangerouslySetInnerHTML:{__html:c}}):(0,p.jsx)(`span`,{className:`text-[#6a625c]`,children:`No summary added.`})}),a||r?(0,p.jsx)(`button`,{type:`button`,className:`mt-2 text-sm font-semibold text-[#b84c74]`,onClick:()=>i(e=>!e),children:r?`Read less`:`Read more`}):null]})]})})}function xa({canvas:e}){let t=(0,d.useVault)(),n=e.annotations?.[0],r=n?t.get(n,{skipSelfReturn:!1}):null,i=Array.isArray(r?.items)?r.items.length:0,a=i===0?`There are no tour steps yet.`:`${i} tour step${i===1?``:`s`} on this canvas.`;return(0,p.jsx)(u.InputContainer,{$wide:!0,children:(0,p.jsxs)(`div`,{className:`rounded-md border border-[#dcd5ce] bg-white p-4`,children:[(0,p.jsx)(`div`,{className:`text-sm font-semibold text-[#25211f]`,children:`Tour steps`}),(0,p.jsx)(`div`,{className:`mt-1 text-sm text-[#6a625c]`,children:a}),(0,p.jsx)(Sa,{canvas:e,tabId:`@exhibition/tour-steps`,label:i===0?`Open Tour steps tab to add one`:`Open Tour steps tab`})]})})}function Sa({canvas:e,tabId:t,label:n}){let{edit:r}=(0,l.useLayoutActions)();return(0,p.jsxs)(`button`,{type:`button`,onClick:()=>r({id:e.id,type:`Canvas`},void 0,{selectedTab:t,forceOpen:!0}),className:`flex gap-2 items-center justify-between mt-3 text-me-primary-600 bg-gray-50 py-2 px-4 rounded-full hover:bg-gray-100`,children:[(0,p.jsx)(`span`,{className:`text-left text-sm font-semibold`,children:n}),(0,p.jsx)(h.ArrowRightIcon,{})]})}function Ca(e){return e?typeof e==`string`?e:Array.isArray(e)?e.filter(Boolean).join(` `):typeof e==`object`?Object.values(e).flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).join(` `):``:``}function wa(e,t=e=>e){let n=Array.isArray(e?.motivation)?e.motivation:[e?.motivation],r=Array.isArray(e?.body)?e.body:e?.body?[e.body]:[];if(!n.includes(`painting`)||r.length!==1)return null;let i=r[0];if(!e?.id||i?.type===`Choice`||i?.source?.type===`Choice`)return null;let a=i?.type===`SpecificResource`,o=a?i.selector:void 0;if(o&&![`ImageApiSelector`,`iiif:ImageApiSelector`].includes(o.type))return null;let s=a?i.source:i,c=t(s)||s;if(c?.type!==`Image`)return null;let l=(Array.isArray(c.service)?c.service:c.service?[c.service]:[]).map(e=>t(e)||e).find(e=>(0,S.isImageService)(e)&&(e.id||e[`@id`]));return l?{annotation:e,annotationRef:{id:e.id,type:`Annotation`},body:a?i:{type:`SpecificResource`,source:s},selector:o||{type:`ImageApiSelector`},source:c,service:l}:null}function Ta(e){if(typeof e!=`string`)return null;let t=e.split(`,`).map(Number);if(t.length!==4||!t.every(Number.isFinite))return null;let n=t[0],r=t[1],i=t[2],a=t[3];return i<=0||a<=0?null:{x:n,y:r,width:i,height:a}}function Ea(e){let t={x:Math.max(0,Math.round(e.x)),y:Math.max(0,Math.round(e.y)),width:Math.round(e.width),height:Math.round(e.height)};if(t.width<=0||t.height<=0)throw Error(`The crop must have a positive width and height`);return t}function Da(e,t){return ka(e,Ea(t),e.selector.rotation)}function Oa(e,t){let n=Ta(e.selector.region),r=n||za(e.service);if(!r)throw Error(`The image service did not provide full image dimensions`);return ka(e,n,Ja(t),r)}function ka(e,t,n,r=t){let i={...e.selector,...n===void 0?{}:{rotation:String(n)}};t?i.region=Ha(t):delete i.region;let a=Ga(e,t,n),o=Math.min(512,r.width),s=Ga(e,t,n,o),c=Fa(r.width,r.height,n);return{region:t,imageDimensions:c,thumbnailDimensions:Fa(o,Math.round(r.height/r.width*o),n),selector:i,source:{...e.source,id:a,...e.source[`@id`]?{"@id":a}:{},width:c.width,height:c.height},sourceId:a,thumbnailId:s}}function Aa(e,t,n,r){return!r||r.cancelled||!r.boundingBox?null:Ma(e,t,n,r.boundingBox)}function ja(e,t,n){let r=Array.isArray(e?.behavior)?e.behavior:e?.behavior?[e.behavior]:[];return(Array.isArray(t?.target)?t.target:t?.target?[t.target]:[]).some(t=>Ua(t,e))&&n===1&&!r.includes(`multi-image`)}function Ma(e,t,n,r){return Pa(e,t,n,Da(t,r))}function Na(e,t,n,r){return Pa(e,t,n,Oa(t,r))}function Pa(e,t,n,r){let i=Xa(e,n),a=ja(n,t.annotation,i);return e.batch(()=>{e.dispatch((0,D.importEntities)({entities:{ContentResource:{[r.sourceId]:r.source,[r.thumbnailId]:{id:r.thumbnailId,type:`Image`,format:`image/jpeg`,width:r.thumbnailDimensions.width,height:r.thumbnailDimensions.height,service:[t.service]}}}})),e.dispatch((0,D.addMappings)({mapping:{[r.sourceId]:`ContentResource`,[r.thumbnailId]:`ContentResource`}})),e.modifyEntityField(t.annotationRef,`body`,[{...t.body,selector:r.selector,source:{id:r.sourceId,type:`ContentResource`}}]),e.modifyEntityField({id:n.id,type:`Canvas`},`thumbnail`,[{id:r.thumbnailId,type:`ContentResource`}]),a&&(e.modifyEntityField({id:n.id,type:`Canvas`},`width`,r.imageDimensions.width),e.modifyEntityField({id:n.id,type:`Canvas`},`height`,r.imageDimensions.height),e.modifyEntityField(t.annotationRef,`target`,Wa(t.annotation.target,n)))}),r}function Fa(e,t,n){let r=Number(String(n??0).replace(/^!/,``)),i=Number.isFinite(r)?(r%360+360)%360:0;return i===90||i===270?{width:t,height:e}:{width:e,height:t}}function Ia(e,t,n){switch(Ja(n)){case 90:return{x:t.height-e.y-e.height,y:e.x,width:e.height,height:e.width};case 180:return{x:t.width-e.x-e.width,y:t.height-e.y-e.height,width:e.width,height:e.height};case 270:return{x:e.y,y:t.width-e.x-e.width,width:e.height,height:e.width};default:return{...e}}}function La(e,t,n){return Ia(String(n??``).startsWith(`!`)?{...e,x:t.width-e.x-e.width}:e,t,n)}function Ra(e,t,n){let r=Ia(e,Fa(t.width,t.height,n),360-Ja(n));return String(n??``).startsWith(`!`)?{...r,x:t.width-r.x-r.width}:r}function za(e){let t=Number(e?.width),n=Number(e?.height);return t>0&&n>0?{width:t,height:n}:null}async function Ba(e,t=fetch){if(za(e))return e;let n=e?.id||e?.[`@id`];if(!n)throw Error(`The image service has no identifier`);let r=await t((0,S.canonicalServiceUrl)(n));if(!r.ok)throw Error(`The image service returned ${r.status}`);let i=await r.json(),a={...e,...i,id:i.id||i[`@id`]||n};if(!za(a))throw Error(`The image service did not provide full image dimensions`);return a}function Va(e,t=0){let n=(0,S.createImageServiceRequest)(Ya(e));return(0,S.imageServiceRequestToString)({...n,type:`image`,region:{full:!0},size:{max:!0,confined:!1,upscaled:!1},rotation:qa(t),quality:`default`,format:`jpg`})}function Ha(e){return`${e.x},${e.y},${e.width},${e.height}`}function Ua(e,t){let n=e?.type===`SpecificResource`?e.source:e,r=typeof n==`string`?n:n?.id;if(typeof r!=`string`)return!1;let[i,a]=r.split(`#`,2);if(i!==t.id)return!1;let o=Array.isArray(e?.selector)?e.selector:e?.selector?[e.selector]:[];if(!o.length&&!a)return!0;let s=o.find(e=>e?.spatial||typeof e?.value==`string`&&e.value.startsWith(`xywh=`)),c=s?.spatial,l=a||s?.value;if(!c&&typeof l==`string`&&l.startsWith(`xywh=`)){let[e,t,n,r]=l.replace(/^xywh=(?:pixel:)?/,``).split(/[,&]/).slice(0,4).map(Number);c={x:e,y:t,width:n,height:r}}return c?Number(c?.x)===0&&Number(c?.y)===0&&Number(c?.width)===Number(t?.width)&&Number(c?.height)===Number(t?.height):!1}function Wa(e,t){return Array.isArray(e)?e.map(e=>Ua(e,t)?Wa(e,t):e):typeof e==`string`?t.id:e?.type===`SpecificResource`?{...e,source:typeof e.source==`string`?t.id:e.source?.id?.includes(`#`)?{...e.source,id:t.id}:e.source,selector:void 0}:e}function Ga(e,t,n,r){let i=Ka(e.source.id),a=i||(0,S.createImageServiceRequest)(Ya(e.service)),o=n===void 0?i?.rotation||{angle:0}:qa(n);return(0,S.imageServiceRequestToString)({...a,type:`image`,region:t?{x:t.x,y:t.y,w:t.width,h:t.height}:{full:!0},size:r?{max:!1,confined:!1,upscaled:!1,width:r}:{max:!0,confined:!1,upscaled:!1},rotation:o,quality:i?.quality||`default`,format:i?.format||`jpg`})}function Ka(e){if(typeof e!=`string`)return null;try{let t=(0,S.parseImageServiceRequest)(e);return t.type===`image`?t:null}catch{return null}}function qa(e){let t=String(e??0),n=Number(t.replace(/^!/,``));return{angle:Number.isFinite(n)?n:0,...t.startsWith(`!`)?{mirror:!0}:{}}}function Ja(e){let t=Number(String(e??0).replace(/^!/,``)),n=Number.isFinite(t)?(t%360+360)%360:0;return[0,90,180,270].includes(n)?n:0}function Ya(e){return{...e,id:e.id||e[`@id`],type:e.type||e[`@type`]}}function Xa(e,t){let n=0;for(let r of t?.items||[]){let t=e.get(r,{skipSelfReturn:!1})||r;for(let r of t?.items||[]){let t=e.get(r,{skipSelfReturn:!1})||r;(Array.isArray(t?.motivation)?t.motivation:[t?.motivation]).includes(`painting`)&&n++}}return n}const Za={id:`@exhibition/image-crop-editor`,label:`Media`,supports:{edit:!0,sortKey:`annotation-target`,properties:[`body`],resourceTypes:[`Annotation`],custom:({resource:e},t)=>{let n=t.get(e,{skipSelfReturn:!1});return!!(n&&wa(n,e=>oo(t,e)))}},component:()=>(0,p.jsx)(Qa,{})};function Qa(){let e=(0,d.useVault)(),t=(0,l.useEditor)(),n=(0,d.useCanvas)({id:t.annotation.target.getSourceId()}),r=e.get(t.ref(),{skipSelfReturn:!1}),i=r?wa(r,t=>oo(e,t)):null,a=Ta(i?.selector.region),o=(0,m.useRef)(null),[s,c]=(0,m.useState)(!1),[f,g]=(0,m.useState)(!1),[_,v]=(0,m.useState)(null),y=Ja(i?.selector.rotation),b=async t=>{if(!(!i||!n||t===y)){g(!0),v(null);try{let r=await Ba(i.service);Na(e,{...i,service:r},n,t)}catch(e){v(e instanceof Error?e.message:`The rotation could not be saved`)}finally{g(!1)}}},x=()=>{c(!1),requestAnimationFrame(()=>o.current?.querySelector(`button`)?.focus())};if(!i||!n)return null;let S=(0,p.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[a?(0,p.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 rounded border border-gray-200 bg-gray-50 p-3 text-sm`,children:[(0,p.jsx)(`dt`,{className:`font-semibold text-gray-700`,children:`Position`}),(0,p.jsxs)(`dd`,{className:`text-gray-600`,children:[a.x,`, `,a.y]}),(0,p.jsx)(`dt`,{className:`font-semibold text-gray-700`,children:`Size`}),(0,p.jsxs)(`dd`,{className:`text-gray-600`,children:[a.width,` × `,a.height]})]}):(0,p.jsx)(`p`,{className:`rounded border border-gray-200 bg-gray-50 p-3 text-sm text-gray-600`,children:`This image currently uses the full image. Create a crop to select a smaller visible region.`}),(0,p.jsx)(`span`,{ref:o,children:(0,p.jsx)(h.ActionButton,{onPress:()=>c(!0),children:a?`Edit crop`:`Create crop`})})]}),C=(0,p.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,p.jsx)(`div`,{className:`grid grid-cols-4 gap-2`,"aria-label":`Image rotation`,children:[0,90,180,270].map(e=>(0,p.jsxs)(h.ActionButton,{"aria-pressed":e===y,primary:e===y,isDisabled:f,onPress:()=>b(e),children:[e,`°`]},e))}),_?(0,p.jsx)(`p`,{className:`text-sm text-red-700`,children:_}):null]});return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(u.MediaEditor,{additionalSections:[{label:`Image crop`,initialOpen:!!a,children:S},{label:`Image rotation`,initialOpen:y!==0,children:C}]}),s?(0,p.jsx)($a,{crop:i,canvas:n,onClose:x,vault:e}):null]})}function $a({crop:e,canvas:t,vault:n,onClose:r}){let[i,a]=(0,m.useState)(()=>za(e.service)?e.service:null),[o,s]=(0,m.useState)(null),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1);(0,m.useEffect)(()=>{let t=!0;return Ba(e.service).then(e=>{t&&a(e)}).catch(e=>{t&&s(e instanceof Error?e.message:`Unable to load the image service`)}),()=>{t=!1}},[e.service]);let f=za(i),g=Ta(e.selector.region)||(f?{x:0,y:0,width:f.width,height:f.height}:null),_=f?Fa(f.width,f.height,e.selector.rotation):null,v=f&&g?La(g,f,e.selector.rotation):null,y=i?.id||i?.[`@id`],b=(0,m.useCallback)(async a=>{if(a.cancelled||!a.boundingBox||!f)return l(!1);d(!0),s(null);try{Aa(n,{...e,service:i},t,{...a,boundingBox:Ra(a.boundingBox,f,e.selector.rotation)}),r()}catch(e){s(e instanceof Error?e.message:`The crop could not be saved`),d(!1)}},[t,e,r,i,n]),x=(0,m.useCallback)(e=>s(e),[]);return(0,p.jsx)(h.Modal,{title:Ta(e.selector.region)?`Edit image crop`:`Create image crop`,onClose:r,className:`max-w-5xl`,height:`80vh`,disableAnimation:!0,children:(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col p-4`,children:[o?(0,p.jsx)(ao,{message:o}):f&&_&&v&&y?(0,p.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden rounded border border-gray-200 bg-gray-950`,children:[(0,p.jsx)(eo,{crop:e,service:i,dimensions:_,initialRegion:v,editing:c,onEditingChange:l,onResolve:b,onError:x}),u?(0,p.jsx)(`div`,{className:`absolute inset-0 z-20 grid place-items-center bg-black/40 text-sm font-semibold text-white`,children:`Saving crop…`}):null]}):(0,p.jsx)(`div`,{className:`grid min-h-[20rem] flex-1 place-items-center text-sm text-gray-500`,children:`Loading full image…`}),(0,p.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,p.jsx)(h.ActionButton,{onPress:r,children:`Cancel`})})]})})}function eo({crop:e,service:t,dimensions:n,initialRegion:r,editing:i,onEditingChange:a,onResolve:o,onError:s}){let c=(0,m.useRef)(()=>void 0),l=(0,m.useMemo)(()=>to(e,t,n,e.selector.rotation),[e.annotationRef.id,e.selector.rotation,n.height,n.width,t]),u=(0,m.useMemo)(()=>{let e=new j.Vault;return e.loadManifestSync(l.id,l),e},[l]),f=(0,m.useMemo)(()=>function(){return(0,p.jsx)(no,{bounds:{x:0,y:0,width:n.width,height:n.height},initialRegion:r,changeCropRef:c,onEditingChange:a,onResolve:o,onError:s})},[n.height,n.width,r.height,r.width,r.x,r.y,a,s,o]);return(0,p.jsx)(d.VaultProvider,{vault:u,children:(0,p.jsx)(d.AtlasStoreReactContext.Provider,{value:null,children:(0,p.jsx)(d.CanvasPanel,{manifest:l.id,startCanvas:l.items[0].id,pagingEnabled:!1,padding:0,components:{ViewerControls:f},annotations:i?null:(0,p.jsx)(ro,{region:r,onChange:()=>c.current()})})})})}function to(e,t,n,r){let i=`${e.annotationRef.id}/crop-editor/manifest`,a=`${i}/canvas`,o=`${a}/painting-page`;return{"@context":`http://iiif.io/api/presentation/3/context.json`,id:i,type:`Manifest`,label:{en:[`Image crop editor`]},items:[{id:a,type:`Canvas`,width:n.width,height:n.height,items:[{id:o,type:`AnnotationPage`,items:[{id:`${o}/painting`,type:`Annotation`,motivation:`painting`,target:a,body:{id:Va(t,r),type:`Image`,format:`image/jpeg`,width:n.width,height:n.height}}]}]}]}}function no({bounds:e,initialRegion:t,changeCropRef:n,onEditingChange:r,onResolve:i,onError:a}){let o=(0,m.useMemo)(()=>(0,p.jsx)(io,{}),[]),{requestAnnotation:s,cancelRequest:c,requestId:l,isActive:u,busy:f}=(0,d.useRequestAnnotation)(),g=(0,m.useRef)(c);g.current=c,(0,m.useEffect)(()=>()=>g.current(),[]);let _=()=>{r(!0),s({type:`box`,bounds:e,selector:t,annotationPopup:o}).then(e=>{if(e)return i(e);r(!1)}).catch(e=>{r(!1),a(e instanceof Error?e.message:`The crop editor could not be opened`)})};return n.current=_,u?null:(0,p.jsx)(`div`,{className:`absolute bottom-3 right-3 z-20 rounded bg-white p-2 shadow-lg`,children:(0,p.jsx)(h.ActionButton,{primary:!0,isDisabled:!l||f,onPress:_,children:`Change crop`})})}function ro({region:e,onChange:t}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`box`,{html:!0,relativeStyle:!0,interactive:!1,target:e,style:{backgroundColor:`rgba(250, 204, 21, 0.18)`,border:`6px solid #facc15`,boxShadow:`inset 0 0 0 2px #111827, inset 0 0 20px rgba(250, 204, 21, 0.65)`,boxSizing:`border-box`}}),(0,p.jsx)(M.HTMLPortal,{target:e,relative:!0,interactive:!0,children:(0,p.jsx)(`button`,{type:`button`,"aria-label":`Change crop`,title:`Change crop`,onClick:t,className:`absolute inset-0 cursor-pointer bg-transparent text-left`,style:{border:0,padding:0},children:(0,p.jsx)(`span`,{className:`absolute left-2 top-2 rounded px-3 py-1.5 text-sm font-semibold shadow-lg`,style:{background:`rgba(17, 24, 39, 0.94)`,border:`2px solid #fde047`,color:`#fde047`},children:`Change crop`})})})]})}function io(){let{saveAnnotation:e,cancelRequest:t}=(0,d.useCurrentAnnotationActions)();return(0,p.jsxs)(`div`,{className:`flex gap-2 rounded bg-white p-2 shadow-lg`,children:[(0,p.jsx)(h.ActionButton,{onPress:()=>t(),children:`Discard`}),(0,p.jsx)(h.ActionButton,{primary:!0,onPress:e,children:`Confirm`})]})}function ao({message:e}){return(0,p.jsx)(`div`,{role:`alert`,className:`grid min-h-[20rem] place-items-center rounded border border-red-200 bg-red-50 p-6 text-center text-sm text-red-800`,children:(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`font-semibold`,children:`The full image could not be loaded`}),(0,p.jsx)(`div`,{className:`mt-1`,children:e})]})})}function oo(e,t){return t?.id&&e.get(t,{preserveSpecificResources:!0,skipSelfReturn:!1})||t}function so(e){return(0,p.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,...e,children:(0,p.jsx)(`path`,{fill:`currentColor`,d:`M9 16.17L4.83 12l-1.42 1.41L9 19L21 7l-1.41-1.41z`})})}function co({value:e,onChange:t}){let[n]=(0,m.useState)(()=>fr(e)),r=(0,m.useRef)(e);return(0,p.jsx)(lo,{label:n.label??``,summary:n.summary,onChange:({label:e,summary:n})=>{r.current=pr(e,n),t(r.current)}})}function lo({label:e,summary:t,onChange:n}){let[r,i]=(0,m.useState)(e),a=(0,m.useRef)(e),o=(0,m.useRef)(t),s=(e,t)=>{n({label:e,summary:t})};return(0,p.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,p.jsxs)(`label`,{className:`block text-sm font-medium text-slate-700`,children:[`Label`,(0,p.jsx)(`input`,{className:`mt-1 w-full rounded border border-slate-200 bg-white px-3 py-2 text-sm text-slate-900 outline-none focus:border-me-primary-400 focus:ring-1 focus:ring-me-primary-100`,value:r,onChange:e=>{let t=e.currentTarget.value;a.current=t,i(t),s(t,o.current)}})]}),(0,p.jsxs)(`div`,{className:`block text-sm font-medium text-slate-700`,children:[`Summary`,(0,p.jsx)(`div`,{className:`mt-1`,children:(0,p.jsx)(h.HTMLEditor,{value:o.current,onChange:e=>{o.current=e,s(a.current,e)}})})]})]})}function uo({value:e}){let{label:t,summary:n}=fr(e);return(0,p.jsx)(fo,{label:t??``,summary:n})}function fo({label:e,summary:t}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`whitespace-nowrap overflow-ellipsis w-full overflow-x-hidden`,children:e||(0,p.jsx)(`span`,{className:`opacity-50`,children:`Untitled`})}),(0,p.jsx)(`div`,{className:`exhibition-tour-step-body text-gray-500 text-sm bg-white line-clamp-2 prose-headings:mt-1 prose-headings:mb-1 prose-sm`,dangerouslySetInnerHTML:{__html:nr(t)}})]})}function po(){let e=(0,l.useAtlasStore)(),t=(0,f.useStore)(e,e=>e.polygon),[n,r]=(0,d.useCurrentAnnotationMetadata)(),{cancelRequest:i,saveAnnotation:a}=(0,d.useCurrentAnnotationActions)();return(0,p.jsxs)(`div`,{className:`border border-gray-300 hover:border-me-500 shadow-sm rounded bg-white relative`,children:[(0,p.jsxs)(`div`,{className:`bg-me-primary-500 text-white p-2 m-1 rounded flex gap-2`,children:[(0,p.jsx)(h.TargetIcon,{}),`Draw a box on the canvas`]}),(0,p.jsx)(`div`,{className:`p-3`,children:(0,p.jsx)(co,{value:n.bodyValue??`<p>Description</p>`,onChange:e=>r({bodyValue:e})})}),(0,p.jsxs)(`div`,{className:`flex gap-2 p-3`,children:[(0,p.jsxs)(h.ActionButton,{isDisabled:t?.points.length===0,onPress:()=>a(),children:[(0,p.jsx)(so,{}),` Finish editing`]}),(0,p.jsxs)(h.ActionButton,{className:`gap-2 flex`,onPress:()=>i(),children:[(0,p.jsx)(h.DeleteIcon,{}),` Delete`]})]})]})}const mo=[{name:`Black`,value:`#121212`},{name:`Red`,value:`#E5484D`},{name:`Orange`,value:`#F76B15`},{name:`Amber`,value:`#FFB224`},{name:`Green`,value:`#46A758`},{name:`Teal`,value:`#12A594`},{name:`Blue`,value:`#0091FF`},{name:`Indigo`,value:`#3E63DD`},{name:`Purple`,value:`#8E4EC6`},{name:`Pink`,value:`#E93D82`}];function ho(e){if(!e)return;let t=e.match(/#[0-9a-fA-F]{3,8}|rgba?\([^)]*\)|hsla?\([^)]*\)/);return t?t[0]:void 0}function go(e,t){return!e||!t?!1:e.toLowerCase()===t.toLowerCase()}function _o(){let e=(0,d.useAnnotation)(),t=(0,l.useGenericEditor)(e)?.annotation?.target;if(!e||!t)return null;let n=t.getBoxStyle(),r=ho(n.border)??n.borderColor,i=e=>{e?t.setBorder(`3px solid ${e}`):t.setBorder(void 0)};return(0,p.jsx)(`span`,{title:`Choose a border colour for this tour step's highlight`,className:`inline-flex`,children:(0,p.jsxs)(v.DialogTrigger,{children:[(0,p.jsx)(v.Button,{"aria-label":`Tour step border colour`,className:`flex-none w-6 h-6 rounded-full border border-gray-300 shadow-sm cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-me-500`,style:r?{backgroundColor:r}:{backgroundImage:`linear-gradient(45deg, transparent 45%, #d1d5db 45%, #d1d5db 55%, transparent 55%)`}}),(0,p.jsx)(v.Popover,{placement:`bottom`,style:{zIndex:1000010},children:(0,p.jsx)(`div`,{className:`manifest-editor`,children:(0,p.jsx)(v.Dialog,{className:`outline-none bg-white rounded-lg shadow-lg border border-gray-200 p-2`,children:({close:e})=>(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`text-[11px] font-semibold text-gray-500 px-1 pb-1.5`,children:`Border colour`}),(0,p.jsx)(`div`,{className:`grid grid-cols-5 gap-1.5`,children:mo.map(t=>{let n=go(r,t.value);return(0,p.jsx)(`button`,{type:`button`,"aria-label":t.name,title:t.name,onClick:()=>{i(t.value),e()},className:`w-6 h-6 rounded-full border cursor-pointer outline-none transition-transform hover:scale-110 focus-visible:ring-2 focus-visible:ring-me-500 ${n?`ring-2 ring-offset-1 ring-me-500 border-transparent`:`border-gray-300`}`,style:{backgroundColor:t.value}},t.value)})}),(0,p.jsx)(`button`,{type:`button`,title:`Remove the border colour`,onClick:()=>{i(null),e()},className:`mt-2 w-full text-[11px] text-gray-500 hover:text-me-500 rounded px-1 py-1 cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-me-500`,children:`None`})]})})})})]})})}function vo(e){let t=Array.isArray(e)?e:[];return t.includes(`left`)?`left`:t.includes(`right`)?`right`:``}function yo(e,t){let n=(Array.isArray(e)?e:[]).filter(e=>e!==`left`&&e!==`right`);return t&&n.push(t),n}function bo(e,t){let n=new Set(yt.map(e=>e.value)),r=(Array.isArray(e)?e:[]).filter(e=>!n.has(e));return t&&r.push(t),r}function xo({annotation:e}){let t=(0,d.useVault)(),n=(0,d.useCanvas)(),r=H(e=>e.selectTourStep),i=vo(e?.behavior),a=Sn(Array.isArray(n?.behavior)?n.behavior:[]),o=Array.isArray(e?.behavior)?e.behavior:[],s=o.some(e=>e.startsWith(`float-`)),c=Cn(o);if(!e?.id)return null;let l=()=>{r(e.id)},u=n=>{t.modifyEntityField({id:e.id,type:`Annotation`},`behavior`,yo(e.behavior,n)),l()};return(0,p.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[a?null:(0,p.jsx)(`div`,{className:`grid grid-cols-3 overflow-hidden rounded border border-slate-200 text-xs font-semibold`,children:[{value:``,label:`Default`},{value:`left`,label:`Left`},{value:`right`,label:`Right`}].map(e=>(0,p.jsx)(`button`,{type:`button`,className:i===e.value?`bg-me-primary-500 px-2 py-1 text-white`:`bg-white px-2 py-1 text-slate-700`,onClick:()=>u(e.value),children:e.label},e.label))}),a?(0,p.jsx)(So,{value:s?c:``,onChange:n=>{t.modifyEntityField({id:e.id,type:`Annotation`},`behavior`,bo(e.behavior,n)),l()}}):null]})}function So({value:e,onChange:t}){let n=!!e;return(0,p.jsx)(`span`,{title:`Floating position override`,className:`inline-flex`,children:(0,p.jsxs)(v.DialogTrigger,{children:[(0,p.jsxs)(v.Button,{"aria-label":`Floating position override`,className:`relative inline-grid h-8 w-8 place-items-center rounded-md border bg-white shadow-sm outline-none transition-colors hover:border-me-primary-400 focus-visible:ring-2 focus-visible:ring-me-500 ${n?`border-me-primary-500 text-me-primary-600`:`border-slate-200 text-slate-500`}`,children:[(0,p.jsx)(xt,{position:e}),n?(0,p.jsx)(`span`,{className:`absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full bg-me-primary-500 ring-2 ring-white`}):null]}),(0,p.jsx)(v.Popover,{placement:`bottom`,style:{zIndex:1000010},children:(0,p.jsx)(`div`,{className:`manifest-editor`,children:(0,p.jsx)(v.Dialog,{className:`rounded-lg border border-slate-200 bg-white p-2 shadow-lg outline-none`,children:({close:n})=>(0,p.jsx)(`div`,{className:`grid grid-cols-3 gap-1`,children:Ct(`No override`).map(r=>(0,p.jsx)(`button`,{type:`button`,"aria-label":r.label,title:r.label,onClick:()=>{t(r.value),n()},className:`grid h-8 w-8 place-items-center rounded-md border outline-none transition-colors hover:border-me-primary-400 hover:bg-me-primary-50 focus-visible:ring-2 focus-visible:ring-me-500 ${e===r.value?`border-me-primary-500 bg-me-primary-50 text-me-primary-600`:`border-slate-200 bg-white text-slate-500`}`,children:(0,p.jsx)(xt,{position:r.value})},r.value||`none`))})})})})]})})}function Co({editAlignment:e=!1,highlightProps:t,index:n=0,tourStyle:r=`linear`,useSlideshowWorkbench:i=!1}){let a=(0,d.useAnnotation)(),o=(0,d.useVault)(),s=wo(a?.body||[],o),c=(0,m.useRef)(s?.resource?.value||``),l=H(e=>e.startTourStepRepositioning),f=H(e=>e.selectTourStep),g=U(e=>e.requestTab),_=U(e=>e.setShowTourSteps),{target:v,isPending:y,cancelRequest:b,busy:x,requestAnnotationFromTarget:S,deleteAnnotation:C}=(0,u.useAnnotationEditor)(),w=!v,[T,E]=(0,m.useState)(!1),D=()=>(a?.id&&f(a.id),!i||!a?.id?!1:(_(!0),l(a.id),g(`tour`),!0));return(0,m.useEffect)(()=>{T||(c.current=s?.resource?.value||``)},[s?.resource?.value,T]),(0,m.useEffect)(()=>{T&&!y&&E(!0)},[y,T]),(0,p.jsxs)(`div`,{...t,className:`exhibition-tour-step-card border shadow-sm rounded bg-white relative ${r===`non-linear`?`border-gray-900 hover:border-black`:`border-gray-300 hover:border-me-500`}`,onClick:D,children:[(0,p.jsx)(`div`,{className:`absolute right-3 top-3 z-10 rounded-full px-2 py-1 text-xs font-semibold`,style:{backgroundColor:`#f5f5f5`,color:`#b84c74`},children:r===`non-linear`?`Point ${n+1}`:`Step ${n+1}`}),(0,p.jsxs)(`div`,{className:`relative`,children:[w?(0,p.jsx)(`div`,{className:`mx-3 mt-3 rounded border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-900`,children:`Invalid region. Select Edit to draw a new region.`}):null,T?(0,p.jsx)(`div`,{className:`p-3`,children:(0,p.jsx)(co,{value:s?.resource?.value||``,onChange:e=>c.current=e})}):(0,p.jsx)(`div`,{className:`px-3 pt-3`,children:(0,p.jsx)(uo,{value:s?.resource?.value||``})})]}),(0,p.jsxs)(`div`,{className:`flex gap-2 p-2`,onClick:e=>e.stopPropagation(),children:[T&&y?(0,p.jsx)(p.Fragment,{children:(0,p.jsxs)(h.ActionButton,{primary:!0,onPress:()=>{Eo(o,a,s,c.current),E(!1),b()},children:[(0,p.jsx)(so,{}),` Finish editing`]})}):(0,p.jsxs)(h.ActionButton,{isDisabled:x,onPress:()=>{i&&a?.id&&(_(!0),l(a.id),g(`tour`)),E(!0),S().then(()=>{E(!1)})},children:[(0,p.jsx)(h.EditTextIcon,{}),` Edit`]}),(0,p.jsxs)(h.ActionButton,{className:`gap-2 flex`,onPress:()=>C(),children:[(0,p.jsx)(h.DeleteIcon,{}),` Delete`]}),(0,p.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[e?(0,p.jsx)(xo,{annotation:a}):null,(0,p.jsx)(_o,{})]})]}),r===`linear`?(0,p.jsx)(`div`,{className:`absolute -bottom-5 left-5 h-5 border-l-2 border-gray-300 w-0`}):null]})}function wo(e,t){for(let n=0;n<e.length;n++){let r=e[n],i=To(r,t);if(i?.type===`TextualBody`||i?.type===`Text`||i?.format===`text/html`)return{ref:r?.id?{id:r.id,type:`ContentResource`}:null,resource:i,bodyIndex:n}}return null}function To(e,t){return!e?.id||e.value?e:t.get(e,{skipSelfReturn:!1})||e}function Eo(e,t,n,r){if(!t||!n)return;if(n.ref?.id){e.modifyEntityField(n.ref,`value`,r);return}let i=Array.isArray(t.body)?t.body:[];e.modifyEntityField({id:t.id,type:`Annotation`},`body`,[...i.slice(0,n.bodyIndex),{...n.resource,value:r},...i.slice(n.bodyIndex+1)])}function Do({editAlignment:e=!1,originalAnnotationId:t,highlightProps:n,index:r=0,tourStyle:i=`linear`,useSlideshowWorkbench:a=!1}){let o=(0,d.useAnnotationPage)(),s=(0,l.useGenericEditor)(o),c=(0,d.useAnnotation)(),u=(0,d.useCanvas)(),f=(0,d.useVault)(),{edit:g}=(0,l.useLayoutActions)(),[_,v]=(0,m.useState)(!1),y=(0,m.useRef)(Oo(c?.label)),b=(0,m.useRef)(Oo(c?.summary)),x=H(e=>e.selectTourStep),S=H(e=>e.startTourStepRepositioning),C=U(e=>e.requestTab),w=U(e=>e.setShowTourSteps),T=u?.items?.[0],E=T?.id&&c?.id?(f.get(T)?.items||[]).findIndex(e=>e.id===c.id):-1,D=()=>{if(t&&confirm(`Are you sure you want to delete this annotation?`)){let e=s.structural.items.getWithoutTracking().findIndex(e=>e.id===t);s.structural.items.deleteAtIndex(e)}},O=()=>(t&&x(t),!a||!t?!1:(w(!0),S(t),C(`tour`),!0)),k=()=>{c&&(f.modifyEntityField({id:c.id,type:`Annotation`},`label`,{en:[y.current]}),f.modifyEntityField({id:c.id,type:`Annotation`},`summary`,er({en:[b.current]})))};return(0,p.jsxs)(`div`,{...n,className:`exhibition-tour-step-card border shadow-sm rounded bg-white relative ${i===`non-linear`?`border-gray-900 hover:border-black`:`border-gray-300 hover:border-me-500`}`,onClick:O,children:[(0,p.jsx)(`div`,{className:`absolute right-3 top-3 z-10 rounded-full px-2 py-1 text-xs font-semibold`,style:{backgroundColor:`#f5f5f5`,color:`#b84c74`},children:i===`non-linear`?`Point ${r+1}`:`Step ${r+1}`}),(0,p.jsx)(`div`,{className:`flex gap-2 mb-2 p-3`,children:(0,p.jsx)(`div`,{className:`flex-1 min-w-0`,children:_?(0,p.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,p.jsx)(lo,{label:y.current,summary:b.current,onChange:({label:e,summary:t})=>{y.current=e,b.current=t}})}):(0,p.jsx)(fo,{label:Oo(c?.label),summary:Oo(c?.summary)})})}),(0,p.jsxs)(`div`,{className:`flex gap-2 p-2`,onClick:e=>e.stopPropagation(),children:[_?(0,p.jsxs)(h.ActionButton,{primary:!0,onPress:()=>{k(),v(!1)},children:[(0,p.jsx)(so,{}),` Finish editing`]}):(0,p.jsxs)(h.ActionButton,{onPress:()=>v(!0),children:[(0,p.jsx)(h.EditTextIcon,{}),` Edit`]}),(0,p.jsxs)(h.ActionButton,{className:`gap-2 flex`,onPress:()=>D(),children:[(0,p.jsx)(h.DeleteIcon,{}),` Delete`]}),(0,p.jsx)(h.ActionButton,{onPress:()=>{O()||c&&g({id:c.id,type:`Annotation`},T?{parent:T,property:`items`,index:E}:void 0,{forceOpen:!0})},children:`Edit annotation`}),e?(0,p.jsx)(`div`,{className:`ml-auto flex items-center`,children:(0,p.jsx)(xo,{annotation:c})}):null]}),i===`linear`?(0,p.jsx)(`div`,{className:`absolute -bottom-5 left-5 h-5 border-l-2 border-gray-300 w-0`}):null]})}function Oo(e){if(!e)return``;if(typeof e==`string`)return e;if(Array.isArray(e))return e.find(e=>typeof e==`string`)||``;let t=e.en||Object.values(e)[0];return Array.isArray(t)&&t.find(e=>typeof e==`string`)||``}function ko({editAlignment:e=!1,index:t=0,tourStyle:n=`linear`,useSlideshowWorkbench:r=!1}){let[i,{annotationTarget:a,highlightProps:o}]=(0,u.useAnnotationInfo)(),s=(0,m.useMemo)(()=>a?{id:a,type:`Annotation`}:{id:i?.id,type:`Annotation`},[i?.id,a]);return a?(0,p.jsx)(l.ResourceEditingProvider,{resource:s,children:(0,p.jsx)(d.AnnotationContext,{annotation:a,children:(0,p.jsx)(Do,{editAlignment:e,originalAnnotationId:i?.id,highlightProps:o,index:t,tourStyle:n,useSlideshowWorkbench:r})})}):(0,p.jsx)(l.ResourceEditingProvider,{resource:s,children:(0,p.jsx)(Co,{editAlignment:e,highlightProps:o,index:t,tourStyle:n,useSlideshowWorkbench:r})})}function Ao({editAlignment:e=!1,reorderable:t=!1,tourStyle:n=`linear`,useSlideshowWorkbench:r=!1}){let i=(0,d.useAnnotationPage)(),a=(0,l.useGenericEditor)(i);return i?t?(0,p.jsx)(p.Fragment,{children:(0,p.jsx)(u.ReorderList,{id:i.id,marginBottom:`0.5em`,items:i.items||[],inlineHandle:!1,reorder:({startIndex:e,endIndex:t})=>a.structural.items.reorder(e,t),renderItem:(t,i)=>(0,p.jsx)(d.AnnotationContext,{annotation:t.id,children:(0,p.jsx)(ko,{index:i,tourStyle:n,editAlignment:e,useSlideshowWorkbench:r})})})}):(0,p.jsx)(p.Fragment,{children:i.items.map((t,i)=>(0,p.jsx)(d.AnnotationContext,{annotation:t.id,children:(0,p.jsx)(ko,{index:i,tourStyle:n,editAlignment:e,useSlideshowWorkbench:r})},t.id))}):null}function jo(e){return e&&[e.x,e.y,e.width,e.height].every(Number.isFinite)&&e.width>0&&e.height>0}function Mo(e){return!e||Array.isArray(e.points)&&e.points.length&&e.points.every(e=>Array.isArray(e)&&Number.isFinite(e[0])&&Number.isFinite(e[1]))}function No(e){if(e?.type===`FragmentSelector`){let t=e.value?.replace(/^xywh=/,``).split(`,`).map(Number);return t?.length===4&&t.every(Number.isFinite)&&t[2]>0&&t[3]>0}return e?.type===`SvgSelector`&&typeof e.value==`string`&&!/\b(?:NaN|Infinity|undefined)\b/.test(e.value)}function Po(e,t){let n=Number(t?.width)||1920,r=Number(t?.height)||1080,i=e?.boundingBox;if(Mo(e?.polygon)&&jo(i)&&i.x>=0&&i.y>=0&&i.x+i.width<=n&&i.y+i.height<=r&&No(e?.target))return e;let a=Be(t,jo(e?.boundingBox)?e.boundingBox:{x:0,y:0,width:n,height:r});return{...e,polygon:null,boundingBox:a,target:{type:`FragmentSelector`,value:`xywh=${a.x},${a.y},${a.width},${a.height}`}}}const Fo={id:`@exhibition/tour-steps`,supports:{edit:!0,properties:[`annotations`,`behavior`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>mt(e,t)?!t.get(e)?.behavior?.includes(`splash`)&&!ht(e,t)&&!gt(e,t):!1},label:`Tour steps`,component:()=>(0,p.jsx)(Io,{})};function Io({mode:e=`advanced`}){let t=(0,d.useCanvas)(),n=t?.annotations[0],r=t?.items[0];return!n||!t||!r?(0,p.jsx)(Lo,{}):(0,p.jsx)(h.Sidebar,{children:(0,p.jsx)(h.SidebarContent,{padding:!0,children:(0,p.jsx)(Ro,{mode:e})})})}function Lo(){let e=(0,d.useCanvas)(),t=(0,l.useInlineCreator)(),n=()=>{e&&t.create(`@manifest-editor/empty-annotation-page`,{label:{en:[`Tour steps`]}},{target:{id:e.id,type:`Canvas`},targetType:`AnnotationPage`,parent:{property:`annotations`,resource:{id:e.id,type:`Canvas`}}})};return(0,p.jsxs)(`div`,{className:`flex flex-col items-center justify-center p-4`,children:[(0,p.jsx)(`div`,{className:`p-4 opacity-50 text-center`,children:`This image does not yet have a tour.`}),(0,p.jsx)(v.Button,{className:`border w-full disabled:opacity-50 border-gray-300 hover:border-me-500 hover:bg-me-50 cursor-pointer shadow-sm rounded p-4 bg-white relative text-[#6a625c] hover:text-me-500`,onPress:()=>n(),children:`Create Tour`})]})}function Ro({mode:e,useSlideshowWorkbench:t=!1}){let n=(0,d.useCanvas)(),r=(0,l.useEditor)(),i=n?.annotations?.[0],a=n?.items?.[0],[o,s]=(0,m.useState)(!1),[c,f]=(0,m.useState)(!1),g=(0,l.useApp)(),_=Zt(V()?.type,g.metadata.id),y=_===`slideshow`,b=Array.isArray(n?.behavior)?n.behavior:[],x=_===`scroll`||Sn(b),S=U(e=>e.setShowTourSteps),C=U(e=>e.setCenterPanelMode),w=H(e=>e.stopRepositioning),T=H(e=>e.stopTextRepositioning);(0,m.useEffect)(()=>{S(!0),C(`edit`),w(),T()},[C,S,w,T]);let{requestTourStep:E,isPending:D,busy:O}=Bo({onBeforeRequest:t?()=>{S(!0),C(`edit`),w(),T()}:void 0}),k=()=>{f(e=>{let t=!e;return C(t?`preview`:`edit`),t})};if(!n)return null;if(!i)return(0,p.jsx)(Lo,{});let A=e===`advanced`&&!!a,j=r.technical.type===`Canvas`&&r.technical.behavior.get()||[],M=y&&j.includes(`non-linear-tour`),N=j.includes(`tour-marker-pin`)?`pin`:`circle`,P=M?`non-linear`:`linear`,F=e=>{if(r.technical.type!==`Canvas`)return;let t=j.filter(e=>e!==Fn);r.technical.behavior.set(e?[...t,Fn]:t)},I=e=>{if(r.technical.type!==`Canvas`)return;let t=j.filter(e=>e!==In);r.technical.behavior.set(e===`pin`?[...t,In]:t)};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`flex gap-4 border-b pt-4 pb-2 mb-2`,children:[(0,p.jsx)(`h2`,{className:`text-lg font-semibold flex-1`,children:`Tour steps`}),e===`advanced`&&!M?(0,p.jsx)(h.ActionButton,{onPress:()=>s(e=>!e),children:o?`Done`:`Reorder`}):null,e===`advanced`&&x?(0,p.jsx)(h.ActionButton,{onPress:k,children:c?`Done`:`Edit alignment`}):null]}),y?(0,p.jsxs)(`div`,{className:`mb-4 rounded border border-gray-200 bg-white p-3`,children:[(0,p.jsx)(`div`,{className:`mb-2 text-sm font-semibold text-gray-700`,children:`Tour style`}),(0,p.jsx)(_n,{checked:M,label:`Let visitors choose map points`,onChange:F}),(0,p.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-gray-500`,children:`Shows all tour steps as markers that visitors can open in any order.`}),M?(0,p.jsxs)(`div`,{className:`mt-4 space-y-3 border-t border-gray-100 pt-3`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,p.jsx)(`div`,{className:`text-sm font-semibold text-gray-700`,children:`Marker`}),(0,p.jsxs)(`div`,{role:`group`,"aria-label":`Tour marker style`,className:`inline-flex rounded-md border border-gray-200 bg-gray-50 p-0.5`,children:[(0,p.jsx)(zo,{selected:N===`circle`,onPress:()=>I(`circle`),children:`Circle`}),(0,p.jsx)(zo,{selected:N===`pin`,onPress:()=>I(`pin`),children:`Pin`})]})]}),(0,p.jsx)(`p`,{className:`text-xs leading-relaxed text-gray-500`,children:`Marker colour follows the exhibition theme annotation text colour.`})]}):null]}):null,(0,p.jsx)(l.ResourceEditingProvider,{resource:n,children:(0,p.jsxs)(d.AnnotationPageContext,{annotationPage:i.id,children:[(0,p.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,p.jsx)(`div`,{className:`text-sm font-semibold text-gray-700`,children:M?`Map points`:`Linear step list`}),(0,p.jsx)(Ao,{reorderable:e===`advanced`&&!M&&o,tourStyle:P,editAlignment:x&&c,useSlideshowWorkbench:t}),O?null:D?(0,p.jsx)(po,{}):(0,p.jsx)(v.Button,{onPress:E,className:`border disabled:opacity-50 border-gray-300 hover:border-me-500 hover:bg-me-50 cursor-pointer shadow-sm rounded p-4 bg-white relative text-[#6a625c] hover:text-me-500`,children:M?`+ Add map point`:`+ Add new step`})]}),A&&a?(0,p.jsx)(p.Fragment,{children:(0,p.jsx)(u.PromptToAddPaintingAnnotations,{title:(0,p.jsx)(`h3`,{className:`text-md border-b pt-4 pb-2 mb-2`,children:`Available tour steps from images`}),painting:a,page:i,canvasId:n.id})}):null]})})]})}function zo({children:e,selected:t,onPress:n}){return(0,p.jsx)(v.Button,{"aria-pressed":t,className:`rounded px-2.5 py-1 text-xs font-semibold transition-colors ${t?`bg-white text-me-primary-600 shadow-sm`:`text-gray-500 hover:text-gray-800`}`,onPress:n,children:e})}function Bo({onBeforeRequest:e}={}){let t=(0,d.useCanvas)(),n=t?.annotations?.[0],r=(0,l.useInlineCreator)(),{requestAnnotation:i,isPending:a,busy:o}=(0,d.useRequestAnnotation)({onSuccess:e=>{let i=e.metadata.bodyValue??`<p>Description</p>`;if(!e.cancelled&&e.target&&t&&n){let a=Po(e,t);r.create(`@manifest-editor/html-annotation`,{label:{en:[`Tour step`]},body:{en:[i]},motivation:`tagging`},{target:{id:t.id,type:`Canvas`},targetType:`Annotation`,parent:{property:`items`,resource:{id:n.id,type:`AnnotationPage`}},initialData:{selector:a}})}}});return{requestTourStep:()=>{e?.(),i({type:`box`})},isPending:a,busy:o,canRequestTourStep:!!(t&&n)}}function Vo(){let e=V(),t=(0,l.useEditor)(),n=t.technical.duration;return e?.type!==`slideshow`||t.technical.type!==`Canvas`?null:(0,p.jsxs)(u.InputContainer,{$wide:!0,id:n.containerId(),children:[(0,p.jsx)(u.InputLabel,{htmlFor:n.focusId(),children:`Slide duration`}),(0,p.jsx)(u.Input,{id:n.focusId(),min:0,type:`number`,value:n.get()||0,onChange:e=>{let t=e.currentTarget.valueAsNumber;Number.isFinite(t)&&n.set(t)}})]})}const Ho={id:`@exhibition/info-box-editor`,supports:{edit:!0,properties:[`label`,`behavior`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>mt(e,t)?ht(e,t):!1},label:`Text box`,component:()=>(0,p.jsx)(Uo,{})};function Uo(){let[e,t]=(0,l.useLocalStorage)(`exhibition-info-box-mode`,`simple`),n=(0,d.useCanvas)(),r=(0,d.useVault)(),i=(0,d.useManifest)(),a=(0,l.useEditor)(),o=$t();if(!n||a.technical.type!==`Canvas`)return null;let s=a.technical.behavior.get()||[],c=jn(s)||12,f=e=>{let t=s.filter(e=>!e.startsWith(`w-`)&&!e.startsWith(`h-`)),n=s.find(e=>e.startsWith(`h-`));t.push(`w-${e}`),n||t.push(`h-4`),a.technical.behavior.set(t)},m=o.showGridSizing&&i?.items&&n?Mn(n.id,i.items,r):null;return(0,p.jsx)(h.Sidebar,{children:(0,p.jsxs)(h.SidebarContent,{className:`bg-white px-6 pt-5 pb-20`,children:[(0,p.jsx)(`div`,{className:`flex justify-center`,children:(0,p.jsx)(vn,{value:e,onChange:t})}),(0,p.jsxs)(`div`,{className:`mt-8 flex flex-col gap-7`,children:[(0,p.jsx)(Vo,{}),(0,p.jsx)(l.ResourceEditingProvider,{resource:n,children:e===`simple`?(0,p.jsxs)(K,{children:[(0,p.jsx)(q,{children:`Title`}),(0,p.jsx)(`div`,{className:`mt-2`,children:(0,p.jsx)(u.LanguageMapEditor,{dispatchType:`label`,disableMultiline:!0,disallowHTML:!0})})]}):(0,p.jsxs)(K,{children:[(0,p.jsx)(q,{children:`Label & summary`}),(0,p.jsxs)(`div`,{className:`mt-2 flex flex-col gap-3`,children:[(0,p.jsx)(u.LanguageMapEditor,{dispatchType:`label`,disableMultiline:!0,disallowHTML:!0}),(0,p.jsx)(ha,{resource:n})]})]})}),e===`simple`&&o.showGridSizing?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(K,{children:[(0,p.jsx)(q,{children:`Width`}),(0,p.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:An.map(e=>(0,p.jsx)(gn,{selected:c===e.value,onClick:()=>f(e.value),children:e.label},e.value))})]}),m?(0,p.jsxs)(K,{children:[(0,p.jsxs)(q,{children:[`Fit alongside `,m.neighbour,` slide`]}),(0,p.jsx)(`div`,{className:`mt-3`,children:(0,p.jsxs)(gn,{selected:c===m.width,onClick:()=>f(m.width),children:[`w-`,m.width,` — fills remaining space`]})})]}):null,(0,p.jsxs)(`div`,{className:`text-center text-xs`,style:{color:G.muted},children:[`w-`,c]})]}):e===`advanced`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`px-2`,children:(0,p.jsx)(u.InputContainer,{$wide:!0,children:(0,p.jsx)(u.DimensionsTriplet,{widthId:a.technical.width.containerId(),width:a.technical.width.get()||0,changeWidth:e=>a.technical.width.set(e),heightId:a.technical.height.containerId(),height:a.technical.height.get()||0,changeHeight:e=>a.technical.height.set(e)})})}),o.showGridSizing?(0,p.jsx)(u.BehaviorEditor,{behavior:s,onChange:e=>a.technical.behavior.set(e),configs:[{id:`size`,component:(e,t)=>(0,p.jsx)(cn,{behaviors:e,setBehaviors:t}),label:{en:[`Size`]},type:`custom`,initialOpen:!0,supports:e=>e.startsWith(`w-`)||e.startsWith(`h-`)}]}):null]}):null]})]})})}const Wo=`editorial-text`;function Go(){let e=(0,d.useCanvas)(),t=e?.items?.[0]?{id:e.items[0].id,type:`AnnotationPage`}:void 0,[,n]=(0,l.useCreator)(t,`items`,`Annotation`,e?{id:e.id,type:`Canvas`}:void 0,{isPainting:!0}),{selectedAnnotationId:r,repositioningAnnotationId:i,selectedTextRegion:a,repositioningTextRegion:o,selectAnnotation:s,startRepositioning:c,stopRepositioning:u,selectTextRegion:f,startTextRepositioning:m,stopTextRepositioning:h}=H(),g=U(e=>e.setShowTourSteps),_=(0,d.useVaultSelector)((t,n)=>e?Fe(n,e):[],[e?.id,t?.id]),v=ze(e).text,y=_.length||v;return!e||!t?(0,p.jsxs)(`div`,{children:[(0,p.jsx)(es,{children:`Content on this slide`}),(0,p.jsx)(`p`,{className:`exhibition-workbench-muted mt-2 text-sm leading-relaxed`,children:`This slide does not have a content layer yet.`})]}):(0,p.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(es,{children:`Content on this slide`}),(0,p.jsx)(`p`,{className:`exhibition-workbench-muted mt-2 text-sm leading-relaxed`,children:`Select a painting annotation to highlight it in the workbench. Use the centre panel to add, position, and edit slide content.`})]}),y?(0,p.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[v?(0,p.jsx)(qo,{box:v,selected:a===Wo,repositioning:o===Wo,onSelect:()=>{g(!1),f(Wo)},onReposition:()=>{g(!1),m(Wo)},onStopReposition:h}):null,_.map((e,t)=>(0,p.jsx)(Ko,{layer:e,index:t,selected:r===e.annotation.id,repositioning:i===e.annotation.id,onSelect:()=>{g(!1),s(e.annotation.id)},onReposition:()=>{g(!1),c(e.annotation.id)},onStopReposition:u,onAdvancedEdit:()=>n.edit({id:e.annotation.id,type:`Annotation`},t)},e.annotation.id))]}):(0,p.jsx)(`div`,{className:`exhibition-slideshow-content-empty rounded-lg border border-dashed border-slate-200 bg-slate-50 p-4 text-sm`,children:`No painting annotations on this slide yet.`})]})}function Ko({layer:e,index:t,selected:n,repositioning:r,onSelect:i,onReposition:a,onStopReposition:o,onAdvancedEdit:s}){let c=(0,d.useVault)(),l=(0,u.useAnnotationThumbnail)({annotationId:e.annotation.id,options:{maxWidth:96,maxHeight:96}}),f=Qo(e.annotation,c),m=Yo(e,f),h=Xo(e,f,t),g=Zo(e,f,m);return(0,p.jsxs)(`div`,{className:[`exhibition-slideshow-content-item rounded-lg border bg-white p-3 transition`,n?`exhibition-slideshow-content-item-selected border-me-primary-500 bg-me-primary-50 ring-2 ring-me-primary-100`:`border-slate-200`].join(` `),children:[(0,p.jsxs)(v.Button,{className:`flex w-full items-center gap-3 border-none bg-transparent p-0 text-left`,onPress:i,children:[(0,p.jsx)(Jo,{thumbnailUrl:l?.id,type:m}),(0,p.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,p.jsx)(`span`,{className:`block text-[11px] font-semibold uppercase tracking-wide text-me-primary-500`,children:m}),(0,p.jsx)(`span`,{className:`mt-0.5 block truncate text-sm font-semibold`,children:h}),(0,p.jsx)(`span`,{className:`exhibition-workbench-muted mt-0.5 block truncate text-xs`,children:g})]})]}),(0,p.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3`,children:[(0,p.jsx)(`span`,{className:`exhibition-workbench-muted text-xs`,children:r?`Drag or resize in the workbench`:n?`Selected in workbench`:`Click to select on slide`}),(0,p.jsxs)(`div`,{className:`flex gap-2`,children:[(0,p.jsx)(v.Button,{className:`rounded-md border border-me-primary-200 bg-me-primary-50 px-3 py-1.5 text-xs font-semibold text-me-primary-600 transition hover:bg-me-primary-100`,onPress:r?o:a,children:r?`Done moving`:`Reposition`}),(0,p.jsx)(v.Button,{className:`rounded-md border border-slate-200 bg-white px-3 py-1.5 text-xs font-semibold text-slate-700 transition hover:bg-slate-50`,onPress:s,children:`Advanced edit`})]})]})]})}function qo({box:e,selected:t,repositioning:n,onSelect:r,onReposition:i,onStopReposition:a}){return(0,p.jsxs)(`div`,{className:[`exhibition-slideshow-content-item rounded-lg border bg-white p-3 transition`,t?`exhibition-slideshow-content-item-selected border-me-primary-500 bg-me-primary-50 ring-2 ring-me-primary-100`:`border-slate-200`].join(` `),children:[(0,p.jsxs)(v.Button,{className:`flex w-full items-center gap-3 border-none bg-transparent p-0 text-left`,onPress:r,children:[(0,p.jsx)(Jo,{type:`Text`}),(0,p.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,p.jsx)(`span`,{className:`block text-[11px] font-semibold uppercase tracking-wide text-me-primary-500`,children:`Editorial text`}),(0,p.jsx)(`span`,{className:`mt-0.5 block truncate text-sm font-semibold`,children:`Slide label and summary`}),(0,p.jsxs)(`span`,{className:`exhibition-workbench-muted mt-0.5 block truncate text-xs`,children:[`Position `,Math.round(e.x),`, `,Math.round(e.y),` ·`,` `,Math.round(e.width),` x `,Math.round(e.height)]})]})]}),(0,p.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3`,children:[(0,p.jsx)(`span`,{className:`exhibition-workbench-muted text-xs`,children:n?`Drag or resize in the workbench`:t?`Selected in workbench`:`Click to select on slide`}),(0,p.jsx)(v.Button,{className:`rounded-md border border-me-primary-200 bg-me-primary-50 px-3 py-1.5 text-xs font-semibold text-me-primary-600 transition hover:bg-me-primary-100`,onPress:n?a:i,children:n?`Done moving`:`Reposition`})]})]})}function Jo({thumbnailUrl:e,type:t}){return(0,p.jsx)(`div`,{className:`flex h-16 w-16 shrink-0 items-center justify-center overflow-hidden rounded-md bg-[#f8f6f3] text-xs font-semibold text-black/60 ring-1 ring-slate-200`,children:e?(0,p.jsx)(`img`,{alt:``,className:`h-full w-full object-cover`,src:e}):(0,p.jsx)(`span`,{children:t})})}function Yo(e,t){return e.imageUrl?`Image`:e.youtubeId?`YouTube`:e.videoUrl?`Video`:e.html===null?t?.type===`Canvas`?`Canvas`:t?.type?String(t.type):`Media`:`Text`}function Xo(e,t,n){let r=(0,u.getInternationalStringText)(t?.label,``),i=(0,u.getInternationalStringText)(e.annotation.label,``),a=e.html?$o(e.html).slice(0,80):``;return r||i||a||`${Yo(e,t)} layer ${n+1}`}function Zo(e,t,n){let r=`${Math.round(e.box.x)}, ${Math.round(e.box.y)} · ${Math.round(e.box.width)} x ${Math.round(e.box.height)}`;return[t?.format||t?.profile||t?.type||`${n} painting annotation`,`Position ${r}`].filter(Boolean).join(` · `)}function Qo(e,t){let n=Array.isArray(e?.body)?e.body[0]:e?.body;return(0,u.resolveContentResource)(t,n)}function $o(e){return e.replace(/<br\s*\/?>/gi,` `).replace(/<\/p>/gi,` `).replace(/<[^>]+>/g,` `).replace(/\s+/g,` `).trim()}function es({children:e}){return(0,p.jsx)(`div`,{className:`exhibition-workbench-muted text-sm font-semibold`,children:e})}const ts=[{id:`layout`,label:`Layout`},{id:`summary`,label:`Text content`},{id:`tour`,label:`Tour steps`}],ns=[{id:`layout`,label:`Layout`},{id:`content`,label:`Content`},{id:`summary`,label:`Text content`},{id:`tour`,label:`Tour steps`}],rs=[{value:`simple`,label:`Simple`},{value:`advanced`,label:`Advanced`}],is={track:`#f5eaf0`,active:`#b84c74`,inactiveText:`#8b3f61`,activeText:`#ffffff`,activeShadow:`0 1px 3px rgba(15, 23, 42, 0.18)`},as={id:`@exhibition/workbench-editor`,supports:{edit:!0,properties:[`label`,`summary`,`requiredStatement`,`behavior`,`annotations`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>mt(e,t)?ht(e,t):!1},label:`Canvas`,component:()=>(0,p.jsx)(ss,{})},os={...as,id:`@exhibition/slideshow-workbench-editor`,supports:{...as.supports,custom:({resource:e},t)=>mt(e,t)},component:()=>(0,p.jsx)(ss,{preset:`slideshow`})};function ss({preset:e=`default`}){let[t,n]=(0,l.useLocalStorage)(`exhibition-right-panel-mode`,`simple`),r=(0,d.useCanvas)(),i=(0,d.useVault)(),a=!!r?.behavior?.includes(`info`),o=Ne(i,r),s=(0,m.useMemo)(()=>(e===`slideshow`?ns:ts).filter(e=>e.id!==`tour`||o),[e,o]),[c,u]=(0,m.useState)(`layout`),f=U(e=>e.requestedTab),g=U(e=>e.clearRequestedTab),_=U(e=>e.setShowTourSteps),v=U(e=>e.setCenterPanelMode);(0,m.useEffect)(()=>{c===`tour`?v(`edit`):(c===`layout`||c===`summary`)&&v(`preview`)},[]),(0,m.useEffect)(()=>{if(f&&s.some(e=>e.id===f)){let e=f;u(e),_(e===`tour`),e===`tour`?v(`edit`):(e===`layout`||e===`summary`)&&v(`preview`),g()}},[g,f,v,_,s]),(0,m.useEffect)(()=>{c===`tour`&&!o&&(u(`layout`),_(!1))},[c,_,o]);let y=e=>{u(e),_(e===`tour`),e===`tour`?v(`edit`):(e===`layout`||e===`summary`)&&v(`preview`)};return a?(0,p.jsx)(Uo,{}):(0,p.jsx)(h.Sidebar,{children:(0,p.jsxs)(h.SidebarContent,{className:`bg-white px-6 pt-5 pb-20`,children:[(0,p.jsx)(`div`,{className:`flex justify-center`,children:(0,p.jsx)(cs,{value:t,options:rs,onChange:n})}),(0,p.jsx)(`div`,{role:`tablist`,"aria-label":`Canvas editing sections`,className:[`mt-5 grid border-b border-[#e4ddd6]`,s.length===4?`grid-cols-4`:`grid-cols-3`].join(` `),children:s.map(e=>(0,p.jsx)(`button`,{type:`button`,id:`exhibition-workbench-tab-${e.id}`,role:`tab`,"aria-selected":c===e.id,"aria-controls":`exhibition-workbench-panel-${e.id}`,className:[`exhibition-workbench-tab`,`-mb-px border-b-[3px] border-transparent px-1 pb-3 text-center text-sm font-semibold`,c===e.id?`border-me-primary-500 text-me-primary-500`:`exhibition-workbench-muted`].join(` `),onClick:()=>y(e.id),children:e.label},e.id))}),(0,p.jsxs)(`div`,{id:`exhibition-workbench-panel-${c}`,role:`tabpanel`,"aria-labelledby":`exhibition-workbench-tab-${c}`,className:`mt-8 px-4`,children:[c===`layout`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(ua,{}),(0,p.jsx)(Vo,{}),(0,p.jsx)(un,{mode:t,layoutContext:e===`slideshow`?`slideshow`:`default`})]}):null,c===`content`?(0,p.jsx)(Go,{}):null,c===`summary`?t===`simple`?(0,p.jsx)(ls,{}):(0,p.jsx)(pa,{}):null,c===`tour`?(0,p.jsx)(Ro,{mode:t,useSlideshowWorkbench:e===`slideshow`}):null]})]})})}function cs({value:e,options:t,onChange:n}){return(0,p.jsx)(`div`,{role:`group`,"aria-label":`Editing mode`,className:`grid w-full max-w-[240px] grid-cols-2 rounded-full p-1`,style:{backgroundColor:is.track},children:t.map(t=>{let r=e===t.value;return(0,p.jsx)(v.Button,{"aria-pressed":r,className:`border-none rounded-full bg-transparent px-4 py-2 text-sm font-semibold transition-colors`,style:{backgroundColor:r?is.active:`transparent`,color:r?is.activeText:is.inactiveText,boxShadow:r?is.activeShadow:`none`},onPress:()=>n(t.value),children:t.label},t.value)})})}function ls(){let e=(0,d.useCanvas)();return e?(0,p.jsx)(l.ResourceEditingProvider,{resource:e,children:(0,p.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(us,{children:`Slide title`}),(0,p.jsx)(`div`,{className:`mt-2`,children:(0,p.jsx)(u.LanguageMapEditor,{dispatchType:`label`,disableMultiline:!0,disallowHTML:!0})})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(us,{children:`Slide summary`}),(0,p.jsx)(`div`,{className:`mt-2`,children:(0,p.jsx)(ha,{resource:e})})]}),(0,p.jsx)(ma,{})]})}):null}function us({children:e}){return(0,p.jsx)(`div`,{className:`exhibition-workbench-muted text-sm font-semibold`,children:e})}const ds=e=>(0,p.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 15 15`,...e,children:(0,p.jsx)(`path`,{fill:`currentColor`,d:`M4.5 1a2.5 2.5 0 0 0-2.45 2H0v1h2.05a2.5 2.5 0 0 0 4.9 0H15V3H6.95A2.5 2.5 0 0 0 4.5 1m6 8a2.5 2.5 0 0 0-2.45 2H0v1h8.05a2.5 2.5 0 0 0 4.9 0H15v-1h-2.05a2.5 2.5 0 0 0-2.45-2`})}),fs=(0,l.extendApp)((0,l.mapApp)(c,e=>({...e,layout:{...e.layout,creators:e.layout.creators?.map(e=>e.id===`@manifest-editor/iiif-browser-creator`?Pi(e):e)}})),{id:`exhibition-scrolling-editor`,title:`Exhibition Editor (scrolling)`,project:!0,projectType:`Manifest`},{preset:Gi,config:{editorConfig:{}},leftPanels:[Lr,Xr],leftPanelIds:[`left-panel-manifest`],centerPanels:[],annotations:[],background:[],canvasEditors:[],editors:[Ho,as,ga,en,da,Fo],creators:[Yi,ta,Ii,Ni,Ri,Hi,Qi]}),ps={id:`slideshow-canvas-editor`,label:`Slideshow canvas editor`,component:()=>(0,p.jsx)(ms,{}),supports:{strategy:(e,t,n)=>{let r=n.get(t.resource);return r?.type===`Canvas`&&_t(r)}}};function ms(){let e=(0,d.useCanvas)(),t=(0,d.useManifest)(),{edit:n}=(0,l.useLayoutActions)(),{rightPanel:r}=(0,l.useLayoutState)(),i=U(e=>e.centerPanelMode),a=(0,d.useCurrentAnnotationRequest)(),o=(0,u.useAnnotationEditing)(e=>e.annotationId),[s,c]=(0,m.useState)(1),f=t?.items?.findIndex(t=>t.id===e?.id),h=typeof f==`number`?t?.items?.[f-1]:void 0,g=typeof f==`number`?t?.items?.[f+1]:void 0;return e?a||o||i===`edit`||r.current===`@manifest-editor/editor`&&r.state?.currentTab?.startsWith(`@exhibition/tour-steps`)?(0,p.jsx)(u.CanvasPanelEditor,{asFallback:!0}):(0,p.jsxs)(`div`,{className:`exhibition-slideshow-current-canvas flex h-full min-h-0 flex-col bg-slate-100`,children:[(0,p.jsxs)(`div`,{className:`exhibition-slideshow-current-toolbar flex items-center gap-3 border-b border-slate-200 bg-white px-4 py-3 shadow-sm`,children:[(0,p.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,p.jsx)(d.LocaleString,{className:`block truncate text-sm font-semibold text-slate-800`,children:e.label})}),(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(hs,{onPress:()=>c(1),children:`Home`}),(0,p.jsx)(hs,{onPress:()=>c(e=>Math.max(.25,e-.25)),children:`-`}),(0,p.jsx)(hs,{onPress:()=>c(e=>Math.min(3,e+.25)),children:`+`}),(0,p.jsx)(hs,{isDisabled:!h,onPress:()=>h&&n({id:h.id,type:`Canvas`},void 0,{forceOpen:!1}),children:`Previous`}),(0,p.jsx)(hs,{isDisabled:!g,onPress:()=>g&&n({id:g.id,type:`Canvas`},void 0,{forceOpen:!1}),children:`Next`})]})]}),(0,p.jsx)(`div`,{className:`exhibition-slideshow-current-viewport min-h-0 flex-1 overflow-auto p-8`,children:(0,p.jsx)(`div`,{className:`exhibition-slideshow-current-preview mx-auto origin-top overflow-hidden rounded-md bg-white shadow-xl ring-1 ring-black/10`,style:{width:`min(100%, 1200px)`,aspectRatio:`${e.width||1920} / ${e.height||1080}`,transform:`scale(${s})`,transformOrigin:`top center`},children:(0,p.jsx)(d.CanvasContext,{canvas:e.id,children:(0,p.jsx)(Rn,{})})})})]}):null}function hs({children:e,isDisabled:t,onPress:n}){return(0,p.jsx)(v.Button,{className:`exhibition-slideshow-current-control rounded-md border border-slate-200 bg-white px-3 py-2 text-sm font-semibold text-slate-700 shadow-sm transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-40`,isDisabled:t,onPress:n,children:e})}const gs=e=>(0,p.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 48 48`,...e,children:(0,p.jsxs)(`g`,{fill:`none`,stroke:`#000`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:4,children:[(0,p.jsx)(`path`,{d:`m20 8 4-4m0 0 4 4m-4-4v12M20 40l4 4m0 0 4-4m-4 4V32M40 20l4 4m0 0-4 4m4-4H32M8 20l-4 4m0 0 4 4m-4-4h12`}),(0,p.jsx)(`circle`,{cx:24,cy:24,r:2})]})}),_s=e=>(0,p.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,...e,children:(0,p.jsx)(`path`,{fill:`currentColor`,d:`M20 22H4q-.825 0-1.413-.588T2 20V8q0-.825.588-1.413T4 6h5.975v2H4v12h16v-3.975h2V20q0 .825-.588 1.413T20 22ZM4 20V8v8.025-.675V20Zm13-5.975-1.55-3.475L11.975 9l3.475-1.55L17 4l1.55 3.45L22 9l-3.45 1.55L17 14.025Z`})}),vs={skipEditingOnCreate:!0},ys={id:`@exhibitions/slideshow-center-panel`,label:`Slideshow workbench`,icon:(0,p.jsx)(_s,{}),render:()=>(0,p.jsx)(bs,{})};function bs(){let{structural:e,technical:t}=(0,l.useManifestEditor)(),n=e.items.get(),r={id:t.id.get(),type:`Manifest`};(0,d.useVault)();let[,i]=(0,l.useCreator)(r,`items`,`Canvas`,void 0,{isPainting:!0}),a=(0,u.useInStack)(`Canvas`),o=(0,l.useEditingStack)(),{edit:s}=(0,l.useLayoutActions)(),c=H(e=>e.clear),f=a?.resource.source.id||n[0]?.id,m=f?n.findIndex(e=>e.id===f):-1,g=m>=0?m:0,_=m>=0?n[m]:n[0]||null,v=()=>{i.createFiltered(`exhibition-slideshow-slide`,n.length?g+1:void 0)},y=(e,t,n=!1)=>{s({id:e.id,type:`Canvas`},{parent:r,property:`items`,index:t},{forceOpen:n})},b=(e,t)=>{c(),y(e,t)},x=t=>{let r=n[t];if(!r||!confirm(`Are you sure you want to delete this slide?`))return;let i=Or(n,_?.id,r.id);if(e.items.deleteAtIndex(t),_?.id!==r.id||(c(),o.close(),!i))return;let a=e.items.getWithoutTracking(),s=a.findIndex(e=>e.id===i),l=a[s];l&&y(l,s)},S=g>0?n[g-1]:void 0,C=g<n.length-1?n[g+1]:void 0;return n.length?(0,p.jsx)(xs,{children:(0,p.jsxs)(`div`,{className:`exhibition-slideshow-main flex min-h-full flex-col gap-6 pb-12 pt-16`,children:[(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 px-8`,style:{paddingInlineStart:`calc(2rem + var(--manifest-editor-layout-left-sidebar-small, 0px))`,paddingInlineEnd:`calc(2rem + var(--manifest-editor-layout-right-sidebar-small, 0px))`},children:[(0,p.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,p.jsx)(`p`,{className:`text-sm font-semibold uppercase tracking-wider text-me-primary-500`,children:`Slideshow workbench`}),(0,p.jsx)(`h2`,{className:`exhibition-slideshow-heading truncate text-2xl font-bold text-slate-900`,children:_?(0,p.jsx)(d.CanvasContext,{canvas:_.id,children:(0,p.jsx)(Ss,{})}):`Slides`}),(0,p.jsxs)(`p`,{className:`exhibition-slideshow-muted mt-1 text-sm font-semibold text-slate-500`,children:[`Slide `,g+1,` of `,n.length]})]}),(0,p.jsx)(Cs,{current:g+1,total:n.length,onPrevious:S?()=>b(S,g-1):void 0,onNext:C?()=>b(C,g+1):void 0}),(0,p.jsx)(`div`,{children:(0,p.jsx)(h.ActionButton,{primary:!0,onPress:v,children:`Add new slide`})})]}),(0,p.jsxs)(`div`,{className:`flex flex-1 flex-col gap-5 px-8`,style:{paddingInlineStart:`calc(1.5rem + var(--manifest-editor-layout-left-sidebar-small, 0px))`,paddingInlineEnd:`calc(1.5rem + var(--manifest-editor-layout-right-sidebar-small, 0px))`},children:[(0,p.jsx)(`div`,{className:`exhibition-slideshow-preview-frame flex items-center justify-center overflow-hidden rounded-lg bg-slate-100`,children:_?(0,p.jsx)(d.CanvasContext,{canvas:_.id,children:(0,p.jsx)(Ts,{})}):null}),(0,p.jsxs)(`aside`,{className:`exhibition-slideshow-slide-strip overflow-hidden rounded-lg border border-slate-200 bg-white p-4`,children:[(0,p.jsx)(`div`,{className:`exhibition-slideshow-heading mb-3 text-sm font-semibold text-slate-700`,children:`Slides`}),(0,p.jsx)(`div`,{className:`flex gap-3 overflow-x-auto pb-2`,children:n.map((e,t)=>(0,p.jsx)(d.CanvasContext,{canvas:e.id,children:(0,p.jsx)(Hs,{index:t,selected:_?.id===e.id,onPress:()=>b(e,t),onDelete:()=>x(t)})},e.id))})]})]})]})}):(0,p.jsx)(xs,{children:(0,p.jsx)(`div`,{className:`flex min-h-full items-center justify-center px-24 py-12`,children:(0,p.jsxs)(`div`,{className:`w-full max-w-4xl`,children:[(0,p.jsx)(`p`,{className:`text-sm font-semibold uppercase tracking-wider text-me-primary-500`,children:`Slideshow exhibition`}),(0,p.jsx)(`h2`,{className:`mt-2 text-3xl font-bold text-slate-900`,children:`Create your first slideshow slide`}),(0,p.jsx)(`p`,{className:`mt-3 max-w-2xl text-sm text-slate-600`,children:`Add a new slide and choose one of the supported slideshow slide types. You can add images, text, media, and tour steps after the slide is created.`}),(0,p.jsx)(`div`,{className:`mt-8`,children:(0,p.jsx)(h.ActionButton,{primary:!0,large:!0,onPress:v,children:`Add new slide`})})]})})})}function xs({children:e}){return(0,p.jsx)(h.SidebarContent,{className:`exhibition-slideshow-workbench h-full overflow-x-hidden overflow-y-auto bg-[#f8f6f3]`,children:e})}function Ss(){let e=Bs((0,d.useCanvas)()?.label,`Untitled slide`);return(0,p.jsx)(p.Fragment,{children:e||`Untitled slide`})}function Cs({current:e,total:t,onPrevious:n,onNext:r}){return(0,p.jsxs)(`div`,{className:`exhibition-slideshow-navigation flex items-stretch overflow-hidden rounded-lg border border-slate-200 bg-white text-sm text-slate-800 shadow-sm`,children:[(0,p.jsx)(v.Button,{className:`border-none bg-white px-5 py-3 font-semibold transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:text-slate-300`,isDisabled:!n,onPress:n,children:`Previous`}),(0,p.jsxs)(`span`,{className:`exhibition-slideshow-navigation-current flex min-w-[96px] items-center justify-center border-x border-slate-200 bg-slate-50 px-4 font-bold text-slate-900`,children:[e,` of `,t]}),(0,p.jsx)(v.Button,{className:`border-none bg-white px-5 py-3 font-semibold transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:text-slate-300`,isDisabled:!r,onPress:r,children:`Next`})]})}function ws({current:e,total:t,onPrevious:n,onNext:r}){return(0,p.jsxs)(`div`,{className:`exhibition-slideshow-navigation flex items-stretch overflow-hidden rounded-md border border-slate-200 bg-white text-xs text-slate-800 shadow-sm`,children:[(0,p.jsx)(v.Button,{className:`border-none bg-white px-3 py-2 font-semibold transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:text-slate-300`,isDisabled:!n,onPress:n,children:`Previous step`}),(0,p.jsx)(`span`,{className:`exhibition-slideshow-navigation-current flex min-w-[84px] items-center justify-center border-x border-slate-200 bg-slate-50 px-3 font-bold text-slate-900`,children:t?`${e} of ${t}`:`0 of 0`}),(0,p.jsx)(v.Button,{className:`border-none bg-white px-3 py-2 font-semibold transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:text-slate-300`,isDisabled:!r,onPress:r,children:`Next step`})]})}function Ts(){let e=(0,d.useCanvas)(),t=(0,d.useManifest)(),n=(0,d.useVault)(),r=(0,l.useInlineCreator)(),i=U(e=>e.centerPanelMode),a=U(e=>e.setCenterPanelMode),o=i,s=a,[c,u]=(0,m.useState)(null),[f,h]=(0,m.useState)(`box`),g=(0,m.useRef)(null),_=e?.annotations?.[0]?.id,b=e?.items?.[0]?{id:e.items[0].id,type:`AnnotationPage`}:void 0,[,x]=(0,l.useCreator)(b,`items`,`Annotation`,e?je(e):void 0,{isPainting:!0}),{selectedAnnotationId:S,repositioningAnnotationId:C,selectedTextRegion:w,repositioningTextRegion:T,selectedTourStepId:E,selectAnnotation:D,startRepositioning:O,stopRepositioning:k,startTextRepositioning:A,stopTextRepositioning:j,selectTourStep:M,stopTourStepRepositioning:N}=H(),P=U(e=>e.showTourSteps),F=U(e=>e.setShowTourSteps),I=(0,d.useVaultSelector)((t,n)=>e?W(n,e):[],[e?.id,b?.id]).find(e=>e.id===S),ee=w===`editorial-text`?ze(e).text:null,L=(0,d.useVaultSelector)((t,n)=>e?Me(n,e):[],[e?.id,_]),R=L.find(e=>e.id===E)||L[0],te=R?Math.max(0,L.findIndex(e=>e.id===R.id)):-1,ne=Ne(n,e),z=P&&ne,re=e=>{let t=L[e];t?.id&&M(t.id)};(0,m.useEffect)(()=>{g.current=null,u(null),h(`box`)},[e?.id]),(0,m.useEffect)(()=>{!ne&&P&&(F(!1),N(),u(null))},[F,P,N,ne]),(0,m.useEffect)(()=>{z&&s(`edit`)},[z]),(0,m.useEffect)(()=>{if(g.current===null){g.current=L.length;return}let e=L[L.length-1];L.length>g.current&&e?.id&&(M(e.id),k(),j(),F(!0)),g.current=L.length},[M,F,k,j,L]);let ie=()=>{let e=!P;F(e),e?(k(),j(),R?.id&&M(R.id)):N()},ae=()=>{e&&r.create(`@manifest-editor/empty-annotation-page`,{label:{en:[`Tour steps`]}},{target:{id:e.id,type:`Canvas`},targetType:`AnnotationPage`,parent:{property:`annotations`,resource:{id:e.id,type:`Canvas`}}})},oe=()=>{!e||!_||(F(!0),k(),j(),h(`box`),u({type:`add`}))},se=()=>{R?.id&&(F(!0),k(),j(),h(Rs(R)),u({type:`edit`,annotationId:R.id}))};return(0,p.jsxs)(`div`,{className:`exhibition-slideshow-preview-card group relative flex max-h-full flex-col overflow-hidden rounded-md bg-white shadow-xl ring-1 ring-black/10`,style:{width:`100%`,height:`min(68vh, 760px)`,minHeight:420},children:[(0,p.jsxs)(`div`,{className:`exhibition-slideshow-toolbar flex flex-wrap items-center justify-between gap-3 border-b border-slate-200 bg-white px-4 py-3`,children:[(0,p.jsx)(`span`,{className:`exhibition-slideshow-muted text-xs font-semibold text-slate-500`,children:o===`edit`?`Click content to edit or reposition it`:`Live slideshow preview`}),(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[o===`edit`?(0,p.jsxs)(p.Fragment,{children:[ne?(0,p.jsx)(v.Button,{className:(0,y.twMerge)(`rounded-md border px-3 py-2 text-xs font-semibold shadow-sm transition`,z?`border-me-primary-500 bg-me-primary-50 text-me-primary-600`:`border-slate-200 bg-white text-slate-700 hover:border-me-primary-300`),onPress:ie,children:z?`Hide tour steps`:`Show tour steps`}):null,z?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(ws,{current:te+1,total:L.length,onPrevious:te>0?()=>re(te-1):void 0,onNext:te>=0&&te<L.length-1?()=>re(te+1):void 0}),_?(0,p.jsx)(v.Button,{className:`rounded-md bg-me-primary-500 px-3 py-2 text-xs font-semibold text-white shadow-sm transition hover:bg-me-primary-600`,onPress:oe,children:`Add tour step`}):(0,p.jsx)(v.Button,{className:`rounded-md bg-me-primary-500 px-3 py-2 text-xs font-semibold text-white shadow-sm transition hover:bg-me-primary-600`,onPress:ae,children:`Create tour`})]}):(0,p.jsx)(v.Button,{className:`rounded-md bg-me-primary-500 px-3 py-2 text-xs font-semibold text-white shadow-sm transition hover:bg-me-primary-600`,onPress:()=>{s(`edit`),D(null),F(!1),N(),x.create(void 0,vs)},children:`Add content`})]}):null,(0,p.jsxs)(`div`,{className:`flex shrink-0 overflow-hidden rounded-md border border-slate-200 bg-slate-50 text-xs font-semibold`,children:[(0,p.jsx)(Vs,{selected:o===`edit`,onPress:()=>s(`edit`),children:`Edit`}),(0,p.jsx)(Vs,{selected:o===`preview`,onPress:()=>s(`preview`),children:`Preview`})]})]})]}),(0,p.jsxs)(`div`,{className:`relative min-h-0 flex-1 bg-black`,children:[o===`preview`?(0,p.jsx)($e,{preset:`slideshow`,presetOptions:{manifest:t?.id||``,canvas:e?.id,minimal:!0}}):(0,p.jsx)(Rn,{editable:!0,mode:o,showTourSteps:z}),o===`edit`&&c&&e&&_?(0,p.jsx)(Ns,{annotationPageId:_,canvas:e,mode:c,selectedTool:f,setSelectedTool:h,vault:n,onCancel:()=>u(null),onComplete:e=>{e&&M(e),F(!0),u(null)}}):null,!c&&o===`edit`&&!z&&I&&e?(0,p.jsx)(ks,{annotation:I,canvas:e,isRepositioning:C===I.id,onStartReposition:()=>O(I.id),onStopReposition:k,vault:n}):null,!c&&o===`edit`&&!z&&ee&&e?(0,p.jsx)(ks,{canvas:e,currentBox:ee,isRepositioning:T===w,label:`Editorial text`,onStartReposition:()=>A(`editorial-text`),onStopReposition:j,setBox:t=>Re(n,e,t),vault:n}):null,!c&&o===`edit`&&z&&e?R?(0,p.jsx)(ks,{annotation:R,canvas:e,isRepositioning:!1,label:`Selected tour step target`,onStopReposition:N,showBoxFields:!0,showRepositionButton:!1,vault:n,children:_?(0,p.jsx)(Es,{annotationPageId:_,canvas:e,onAddTourStep:oe,onEditTarget:se,selectedTourStepId:R?.id}):null}):(0,p.jsx)(Os,{label:`Tour steps`,children:_?(0,p.jsx)(Es,{annotationPageId:_,canvas:e,onAddTourStep:oe,onEditTarget:se,selectedTourStepId:R?.id}):(0,p.jsx)(Ds,{onCreate:ae})}):null]})]})}function Es({annotationPageId:e,canvas:t,onAddTourStep:n,onEditTarget:r,selectedTourStepId:i}){return(0,p.jsx)(l.ResourceEditingProvider,{resource:t,children:(0,p.jsx)(d.AnnotationPageContext,{annotationPage:e,children:(0,p.jsxs)(`div`,{className:`space-y-3 text-slate-800`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,p.jsx)(`h3`,{className:`text-sm font-semibold text-slate-800`,children:`Tour steps`}),(0,p.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[i?(0,p.jsx)($,{label:`Edit target`,onPress:r}):null,(0,p.jsx)($,{primary:!0,label:`Add step`,onPress:n})]})]}),(0,p.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Select a step below. Use the quick box controls here, or edit the target with the Atlas drawing tools.`}),(0,p.jsx)(`div`,{className:`max-h-72 overflow-y-auto pr-1`,children:(0,p.jsx)(Ao,{reorderable:!1,useSlideshowWorkbench:!0})})]})})})}function Ds({onCreate:e}){return(0,p.jsxs)(`div`,{className:`space-y-3 text-slate-800`,children:[(0,p.jsx)(`p`,{className:`text-xs text-slate-600`,children:`This slide does not have a tour annotation page yet.`}),(0,p.jsx)($,{primary:!0,label:`Create tour`,onPress:e})]})}function Os({children:e,label:t}){return(0,p.jsxs)(`div`,{className:`absolute bottom-4 left-4 z-40 max-w-[min(34rem,calc(100%-2rem))] rounded-lg bg-white/95 p-3 text-xs shadow-lg ring-1 ring-black/10`,children:[(0,p.jsx)(`div`,{className:`mb-2 font-semibold text-slate-700`,children:t}),e]})}function ks({annotation:e,canvas:t,children:n,currentBox:r,isRepositioning:i,label:a=`Selected content`,onStartReposition:o,onStopReposition:s,setBox:c,vault:l,hidePositionControls:u=!1,showBoxFields:d=!1,showRepositionButton:f=!0}){let h=(0,m.useRef)(null),g=(0,m.useRef)(null),[_,v]=(0,m.useState)(null),b=Number(t?.width)||1920,x=Number(t?.height)||1080,S=r||Ie(e,t),C=c||(n=>Le(l,t,e.id,n)),w=Math.round(b/2),T=Math.round(x/2),E=e=>{let t=h.current,n=t?.offsetParent,r=t?.getBoundingClientRect(),i=n?.getBoundingClientRect();!t||!r||!i||(e.currentTarget.setPointerCapture(e.pointerId),g.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,panelX:r.left-i.left,panelY:r.top-i.top,maxX:Math.max(16,i.width-r.width-16),maxY:Math.max(16,i.height-r.height-16)})},D=e=>{let t=g.current;!t||t.pointerId!==e.pointerId||v({x:Math.min(t.maxX,Math.max(16,t.panelX+e.clientX-t.startX)),y:Math.min(t.maxY,Math.max(16,t.panelY+e.clientY-t.startY))})},O=e=>{g.current?.pointerId===e.pointerId&&(g.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))};return(0,p.jsx)(`div`,{ref:h,className:(0,y.twMerge)(`absolute z-40 w-[min(30rem,calc(100%-2rem))] rounded-lg bg-white/95 p-3 text-xs shadow-lg ring-1 ring-black/10`,_?null:`bottom-4 left-4`),style:_?{left:_.x,top:_.y}:void 0,children:(0,p.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,p.jsxs)(`div`,{className:`min-w-[280px]`,children:[(0,p.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,p.jsx)(`span`,{className:`font-semibold text-slate-700`,children:a}),(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`button`,{className:`cursor-move rounded border border-slate-200 bg-white px-2 py-1 text-[11px] font-semibold text-slate-600 transition hover:border-me-primary-300 hover:text-me-primary-600`,type:`button`,onPointerDown:E,onPointerMove:D,onPointerUp:O,onPointerCancel:O,children:(0,p.jsx)(gs,{})}),(0,p.jsxs)(`span`,{className:`text-slate-400`,children:[Math.round(S.width),` x `,Math.round(S.height)]})]})]}),u?null:(0,p.jsxs)(`div`,{className:`space-y-2`,children:[(0,p.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[f&&o?(0,p.jsx)($,{onPress:o,label:`Reposition`,primary:!0}):null,i&&s?(0,p.jsx)($,{onPress:s,label:`Stop moving`}):null,(0,p.jsx)($,{onPress:()=>C({x:0,y:0,width:b,height:x}),label:`Fill`}),(0,p.jsx)($,{onPress:()=>C({x:Math.round(b*.1),y:Math.round(x*.1),width:Math.round(b*.8),height:Math.round(x*.8)}),label:`Centre`}),(0,p.jsx)($,{onPress:()=>C({x:0,y:0,width:w,height:x}),label:`Left`}),(0,p.jsx)($,{onPress:()=>C({x:w,y:0,width:w,height:x}),label:`Right`}),(0,p.jsx)($,{onPress:()=>C({x:0,y:0,width:b,height:T}),label:`Top`}),(0,p.jsx)($,{onPress:()=>C({x:0,y:T,width:b,height:T}),label:`Bottom`})]}),d?(0,p.jsx)(As,{box:S,onChange:C}):null]})]}),n?(0,p.jsx)(`div`,{className:`w-full border-t border-slate-200 pt-3`,children:n}):null]})})}function As({box:e,onChange:t}){let n=(n,r)=>{let i=Number(r);Number.isFinite(i)&&t({...e,[n]:Math.round(i)})};return(0,p.jsxs)(`div`,{className:`grid grid-cols-4 gap-2 pt-1`,children:[(0,p.jsx)(js,{label:`X`,value:e.x,onChange:e=>n(`x`,e)}),(0,p.jsx)(js,{label:`Y`,value:e.y,onChange:e=>n(`y`,e)}),(0,p.jsx)(js,{label:`W`,value:e.width,onChange:e=>n(`width`,e)}),(0,p.jsx)(js,{label:`H`,value:e.height,onChange:e=>n(`height`,e)})]})}function js({label:e,value:t,onChange:n}){return(0,p.jsxs)(`label`,{className:`block text-[11px] font-semibold text-slate-500`,children:[e,(0,p.jsx)(`input`,{className:`mt-1 w-full rounded border border-slate-200 bg-white px-1.5 py-1 text-xs text-slate-900 outline-none focus:border-me-primary-400 focus:ring-1 focus:ring-me-primary-100`,type:`number`,value:Math.round(t),onChange:e=>n(e.target.value)})]})}function Ms(e,t,n,r){let i=`${n}/tour-step/${Date.now()}-${Math.random().toString(36).slice(2,8)}`,a=`${i}/body/en`,o=e.get?.({id:n,type:`AnnotationPage`})||{},s=Array.isArray(o?.items)?o.items:[],c=()=>{e.dispatch((0,D.importEntities)({entities:{ContentResource:{[a]:{id:a,type:`TextualBody`,language:`en`,format:`text/html`,value:`<p>Description</p>`}},Annotation:{[i]:{id:i,type:`Annotation`,motivation:`tagging`,body:[{id:a,type:`ContentResource`}],target:r}}}})),e.dispatch((0,D.addMappings)({mapping:{[a]:`ContentResource`,[i]:`Annotation`}})),e.modifyEntityField({id:n,type:`AnnotationPage`},`items`,[...s,{id:i,type:`Annotation`}])};return e.batch?e.batch(c):c(),i}function Ns({annotationPageId:e,canvas:t,mode:n,selectedTool:r,setSelectedTool:i,vault:a,onCancel:o,onComplete:s}){let c=(0,m.useRef)(null),[l,u]=(0,m.useState)(null),[d,f]=(0,m.useState)(null),[h,g]=(0,m.useState)([]),_=Number(t?.width)||1920,v=Number(t?.height)||1080,y=e=>{let t=c.current;if(!t)return{x:0,y:0};let n=t.createSVGPoint();n.x=e.clientX,n.y=e.clientY;let r=t.getScreenCTM()?.inverse(),i=r?n.matrixTransform(r):n;return{x:zs(Math.round(i.x),0,_),y:zs(Math.round(i.y),0,v)}},b=e=>{if(e.preventDefault(),r===`polygon`){let t=y(e);g(e=>[...e,t]);return}let t=y(e);u(t),f(null)},x=e=>{if(!l||r===`polygon`)return;let t=y(e);r===`box`&&f({type:`box`,x:Math.min(l.x,t.x),y:Math.min(l.y,t.y),width:Math.abs(t.x-l.x),height:Math.abs(t.y-l.y)}),r===`circle`&&f({type:`circle`,cx:l.x,cy:l.y,r:Math.round(Math.sqrt((t.x-l.x)**2+(t.y-l.y)**2))}),r===`line`&&f({type:`line`,x1:l.x,y1:l.y,x2:t.x,y2:t.y})},S=()=>{u(null)},C=r===`polygon`&&h.length?{type:`polygon`,points:h}:d,w=()=>{u(null),f(null),g([])};return(0,p.jsxs)(`div`,{className:`absolute inset-0 z-30`,children:[(0,p.jsxs)(`svg`,{ref:c,className:`absolute inset-0 h-full w-full cursor-crosshair touch-none`,preserveAspectRatio:`xMidYMid meet`,viewBox:`0 0 ${_} ${v}`,onPointerDown:b,onPointerMove:x,onPointerUp:S,onPointerCancel:S,children:[(0,p.jsx)(`rect`,{x:0,y:0,width:_,height:v,fill:`transparent`}),C?(0,p.jsx)(Fs,{shape:C}):null,h.map((e,t)=>(0,p.jsx)(`circle`,{cx:e.x,cy:e.y,r:8,fill:`white`,stroke:`#be4778`,strokeWidth:4},`${e.x}-${e.y}-${t}`))]}),(0,p.jsxs)(`div`,{className:`absolute left-4 top-4 z-40 flex flex-wrap items-center gap-2 rounded-lg bg-white/95 p-2 text-xs shadow-lg ring-1 ring-black/10`,children:[(0,p.jsx)(`span`,{className:`mr-2 font-semibold text-slate-700`,children:n.type===`add`?`Draw new tour step`:`Edit target`}),(0,p.jsx)(Ps,{active:r===`box`,label:`Box`,onPress:()=>{w(),i(`box`)}}),(0,p.jsx)(Ps,{active:r===`circle`,label:`Circle`,onPress:()=>{w(),i(`circle`)}}),(0,p.jsx)(Ps,{active:r===`line`,label:`Line`,onPress:()=>{w(),i(`line`)}}),(0,p.jsx)(Ps,{active:r===`polygon`,label:`Polygon`,onPress:()=>{w(),i(`polygon`)}}),(0,p.jsx)($,{primary:!0,label:n.type===`add`?`Create step`:`Save target`,onPress:()=>{if(!C)return;let r=Is(t.id,C);if(n.type===`edit`){a.modifyEntityField({id:n.annotationId,type:`Annotation`},`target`,r),s(n.annotationId);return}s(Ms(a,t,e,r))}}),(0,p.jsx)($,{label:`Clear`,onPress:w}),(0,p.jsx)($,{label:`Cancel`,onPress:o})]})]})}function Ps({active:e,label:t,onPress:n}){return(0,p.jsx)(v.Button,{className:(0,y.twMerge)(`rounded-md border px-2.5 py-1.5 font-semibold transition`,e?`border-me-primary-500 bg-me-primary-500 text-white`:`border-slate-200 bg-white text-slate-700 hover:border-me-primary-300 hover:bg-me-primary-50`),onPress:n,children:t})}function Fs({shape:e}){let t={fill:`rgba(190, 71, 120, 0.18)`,stroke:`#be4778`,strokeWidth:6,vectorEffect:`non-scaling-stroke`};return e.type===`box`?(0,p.jsx)(`rect`,{...t,x:e.x,y:e.y,width:e.width,height:e.height}):e.type===`circle`?(0,p.jsx)(`circle`,{...t,cx:e.cx,cy:e.cy,r:e.r}):e.type===`line`?(0,p.jsx)(`line`,{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:`#be4778`,strokeWidth:6,vectorEffect:`non-scaling-stroke`}):(0,p.jsx)(`polygon`,{...t,points:e.points.map(e=>`${e.x},${e.y}`).join(` `)})}function Is(e,t){return t.type===`box`?`${e}#xywh=${Math.round(t.x)},${Math.round(t.y)},${Math.round(t.width)},${Math.round(t.height)}`:{source:e,selector:{type:`SvgSelector`,value:Ls(t)}}}function Ls(e){return e.type===`circle`?`<svg xmlns="http://www.w3.org/2000/svg"><circle cx="${Math.round(e.cx)}" cy="${Math.round(e.cy)}" r="${Math.round(e.r)}" /></svg>`:e.type===`line`?`<svg xmlns="http://www.w3.org/2000/svg"><line x1="${Math.round(e.x1)}" y1="${Math.round(e.y1)}" x2="${Math.round(e.x2)}" y2="${Math.round(e.y2)}" /></svg>`:`<svg xmlns="http://www.w3.org/2000/svg"><polygon points="${e.points.map(e=>`${Math.round(e.x)},${Math.round(e.y)}`).join(` `)}" /></svg>`}function Rs(e){let t=Array.isArray(e?.target?.selector)?e.target.selector.find(e=>e?.type===`SvgSelector`):e?.target?.selector;return t?.type===`SvgSelector`&&(Array.isArray(t.points)&&t.svgShape!==`polyline`||typeof t.value==`string`&&/<polygon\b/i.test(t.value))?`polygon`:`box`}function zs(e,t,n){return Math.min(n,Math.max(t,e))}function Bs(e,t=``){if(!e)return t;if(typeof e==`string`)return e;let n=e.en||e.none||Object.values(e).flat();return Array.isArray(n)&&n.length?String(n[0]):t}function $({label:e,onPress:t,primary:n}){return(0,p.jsx)(v.Button,{className:(0,y.twMerge)(`rounded-md border px-2.5 py-1.5 font-semibold transition`,n?`border-me-primary-500 bg-me-primary-500 text-white hover:bg-me-primary-600`:`border-slate-200 bg-white text-slate-700 hover:border-me-primary-300 hover:bg-me-primary-50`),onPress:t,children:e})}function Vs({children:e,selected:t,onPress:n}){return(0,p.jsx)(v.Button,{className:(0,y.twMerge)(`border-none px-3 py-2 transition`,t?`bg-me-primary-500 text-white`:`bg-transparent text-slate-600 hover:bg-white`),onPress:n,children:e})}function Hs({index:e,selected:t,onPress:n,onDelete:r}){let i=(0,d.useCanvas)();return(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`exhibition-slideshow-slide-card relative w-44 shrink-0 rounded-md border bg-white p-2 text-left transition`,t?`border-me-primary-500 ring-2 ring-me-primary-200`:`border-slate-200 hover:border-me-primary-300`),children:[(0,p.jsxs)(v.Button,{className:`block w-full border-none bg-transparent p-0 text-left`,onPress:n,children:[(0,p.jsx)(`div`,{className:`aspect-video overflow-hidden rounded`,style:{backgroundColor:`#0e0d12`},children:(0,p.jsx)(Rn,{className:`pointer-events-none h-full w-full`,mode:`preview`})}),(0,p.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 pr-7`,children:[(0,p.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded bg-slate-100 text-xs font-semibold text-slate-600`,children:e+1}),(0,p.jsx)(d.LocaleString,{className:`min-w-0 truncate text-sm font-medium text-slate-800`,children:i?.label})]})]}),(0,p.jsx)(v.Button,{className:`absolute bottom-2 right-2 flex items-center gap-1 rounded border border-me-primary-100 bg-white px-2 py-1 text-xs font-semibold text-me-primary-500 shadow-sm transition hover:bg-me-primary-50`,"aria-label":`Delete slide ${e+1}`,onPress:r,children:`Delete`})]})}const Us=(0,l.extendApp)((0,l.mapApp)(c),{id:`exhibition-slideshow-editor`,title:`Exhibition Editor (slideshow)`,project:!0,projectType:`Manifest`},{preset:Gi,config:{editorConfig:{Canvas:{singleTab:`@exhibition/slideshow-workbench-editor`,hideTabs:[`@manifest-editor/overview`,`@manifest-editor/technical-properties`,`@manifest-editor/linking-properties`,`@manifest-editor/nav-place-editor`,`@manifest-editor/canvas-structural`,`@manifest-editor/descriptive-properties`,`@manifest-editor/overview-canvas-editor`,`@manifest-editor/metadata`]}}},leftPanels:[Ir,Xr],centerPanels:[ys],annotations:[N],leftPanelIds:[`left-panel-manifest`],background:[li],canvasEditors:[ps],editors:[os,Ho,ga,en,da,Fo],creators:[Ni,Ii,Hi,zi,Bi,$i,na,Xi]}),Ws=(0,l.extendApp)((0,l.mapApp)(c,e=>({...e,layout:{...e.layout,leftPanels:[Fr,...e.layout.leftPanels.filter(e=>e.id===`left-panel-manifest`)]}})),{id:`exhibition-editor`,title:`Exhibition Editor`,project:!0,projectType:`Manifest`},{preset:Gi,config:{editorConfig:{Canvas:{hideTabs:[`@manifest-editor/overview`,`@manifest-editor/technical-properties`,`@manifest-editor/linking-properties`,`@manifest-editor/nav-place-editor`,`@manifest-editor/canvas-structural`,`@manifest-editor/descriptive-properties`,`@manifest-editor/overview-canvas-editor`,`@manifest-editor/metadata`]}}},leftPanels:[Xr],centerPanels:[be,at],annotations:[N],leftPanelIds:[`canvas-listing`,`left-panel-manifest`],background:[li],canvasEditors:[di,ji,hi],editors:[Ho,as,ga,Za,en,da,Fo],creators:[Yi,ta,Ii,Ni,Ri,Hi,Qi,zi,Bi,$i,na,Xi]});exports.PresetIcon=ds,exports.exhibitionEditorPreset=Ws,exports.exhibitionEditorScrollingPreset=fs,exports.exhibitionEditorSlideshowPreset=Us,exports.imageServiceSlideCreator=Ii,exports.useExhibitionPreviewWindow=et;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});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,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("@manifest-editor/manifest-preset");c=s(c,1);let l=require("@manifest-editor/shell"),u=require("@manifest-editor/editors"),d=require("react-iiif-vault"),f=require("zustand"),p=require("react/jsx-runtime"),m=require("react");m=s(m,1);let h=require("@manifest-editor/components"),g=require("exhibition-viewer"),_=require("exhibition-viewer/library"),v=require("react-aria-components"),y=require("tailwind-merge"),b=require("@manifest-editor/manifest-preset/components"),x=require("@iiif/parser/image-3"),S=require("@dnd-kit/core"),C=require("@dnd-kit/modifiers"),w=require("@dnd-kit/sortable"),T=require("@dnd-kit/utilities"),E=require("@manifest-editor/editor-api"),D=require("@iiif/helpers/vault/actions"),O=require("tiny-invariant");O=s(O,1);let k=require("@manifest-editor/creator-api"),A=require("@manifest-editor/creators"),j=require("@iiif/parser"),M=require("@iiif/helpers"),N=require("@atlas-viewer/atlas");const P={enabled:!0,browserCreatorId:`@exhibitions/browser-creator`,canvasActionLabel:`Add to exhibition`},F={id:`@exhibition/tour-step-annotations`,label:`Tour steps`,render:()=>(0,p.jsx)(ee,{})},I={border:`2px solid rgba(255, 255, 255, 0.3)`,":hover":{borderColor:`#4B67E1`,backgroundColor:`rgba(255, 255, 255, 0.2)`}};function ee(){let e=(0,d.useCanvas)(),t=(0,l.useAtlasStore)(),n=(0,f.useStore)(t,e=>e.tool.enabled),{rightPanel:r}=(0,l.useLayoutState)(),i=r.current===`@manifest-editor/editor`&&r.state?.currentTab?.startsWith(`@exhibition/tour-steps`),a=e?.annotations[0];return!i||!e||n||!a?null:(0,p.jsx)(p.Fragment,{children:(0,p.jsx)(d.AnnotationPageContext,{annotationPage:a.id,children:(0,p.jsx)(u.ViewerAnnotationPage,{showAnnotationNumber:!0,style:I})})})}const L={"h-1":`lg:min-h-[100px] row-span-1`,"h-2":`lg:min-h-[200px] row-span-2`,"h-3":`lg:min-h-[300px] row-span-3`,"h-4":`lg:min-h-[400px] row-span-4`,"h-5":`lg:min-h-[500px] row-span-5`,"h-6":`lg:min-h-[600px] row-span-6`,"h-7":`lg:min-h-[700px] row-span-7`,"h-8":`lg:min-h-[800px] row-span-8`,"h-9":`lg:min-h-[900px] row-span-9`,"h-10":`lg:min-h-[1000px] row-span-10`,"h-11":`lg:min-h-[1100px] row-span-11`,"h-12":`lg:min-h-[1200px] row-span-12`},R={"h-1":`lg:min-h-[25px] row-span-1`,"h-2":`lg:min-h-[50px] row-span-2`,"h-3":`lg:min-h-[75px] row-span-3`,"h-4":`lg:min-h-[100px] row-span-4`,"h-5":`lg:min-h-[125px] row-span-5`,"h-6":`lg:min-h-[150px] row-span-6`,"h-7":`lg:min-h-[175px] row-span-7`,"h-8":`lg:min-h-[200px] row-span-8`,"h-9":`lg:min-h-[225px] row-span-9`,"h-10":`lg:min-h-[250px] row-span-10`,"h-11":`lg:min-h-[275px] row-span-11`,"h-12":`lg:min-h-[300px] row-span-12`},te={"w-1":`col-span-1`,"w-2":`col-span-2`,"w-3":`col-span-3`,"w-4":`col-span-4`,"w-5":`col-span-5`,"w-6":`col-span-6`,"w-7":`col-span-7`,"w-8":`col-span-8`,"w-9":`col-span-9`,"w-10":`col-span-10`,"w-11":`col-span-11`,"w-12":`col-span-12`};function ne(e){let{isLeft:t,isRight:n,isBottom:r}=re(e),i=e?.find(e=>e.includes(`h-`)),a=e?.find(e=>e.includes(`w-`));if(!i||!a)return{h:0,w:0,ratio:1};let o={h:Number.parseInt(i.split(`-`)[1]),w:Number.parseInt(a.split(`-`)[1]),ratio:1};return(t||n)&&(o.w*=2/3),r&&(o.h*=2/3),o.h&&o.w&&(o.ratio=o.w/o.h),o}function z(e,t=!1,n=!0){(!e||e.length===0)&&(e=[`h-8`,`w-8`,`image`]);let r=e.find(e=>e.includes(`h-`)),i=e.find(e=>e.includes(`w-`)),a=[];return t&&r===`h-4`&&(r=`h-8`),a.push(n?R[r]:L[r]),a.push(te[i]),a.join(` `)}function re(e){let t=e?.includes(`right`),n=e?.includes(`left`),r=e?.includes(`bottom`),i=e?.includes(`top`),a=e?.includes(`image`)||!n&&!t&&!r&&!i;return{isRight:t,isLeft:n,isBottom:r,isTop:i,isInfo:e?.includes(`info`),isImage:a}}function ie(e,t){return t.get(e)?.type===`Canvas`}function ae(e,t){let n=e.source?.id,r=e.source?.type;if(!n||!r)return!1;try{return(t.get({id:n,type:r})?.behavior||[]).includes(`info`)}catch{return!1}}function oe(e,t){let n=e.source?.id,r=e.source?.type;if(!n||!r)return!1;try{let e=t.get({id:n,type:r}),i=Array.isArray(e?.items)?e.items:[];for(let e of i){let n=t.get(e,{skipSelfReturn:!1}),r=Array.isArray(n?.items)?n.items:[];for(let e of r){let n=t.get(e,{skipSelfReturn:!1}),r=Array.isArray(n?.body)?n.body[0]:n?.body,i=r?.id&&t.get(r,{skipSelfReturn:!1})||r,a=i?.type===`SpecificResource`?i.source:i,o=Array.isArray(a?.service)?a.service:a?.service?[a.service]:[];if(a?.type===`Video`||o.some(e=>e?.profile===`https://www.youtube.com`))return!0}}}catch{return!1}return!1}function se(e){if(!e)return!1;let t=e.behavior||[];if(t.includes(`image`)||t.includes(`info`)||t.includes(`splash`))return!0;for(let e of t)if(e.startsWith(`w-`)||e.startsWith(`h-`))return!0;return!1}function ce(e,t,n){if(!(t>0&&n>0&&Number.isFinite(t/n)))return e;let{isLeft:r,isRight:i,isBottom:a}=re(e),o=Number(e.find(e=>/^w-([1-9]|1[0-2])$/.test(e))?.slice(2))||12,s=r||i?2/3:1,c=a?2/3:1,l=t/n,u=o*s/(l*c)>12?Math.max(1,Math.min(o,Math.round(12*l*c/s))):o,d=Math.max(1,Math.min(12,Math.round(u*s/(l*c))));return[...e.filter(e=>!/^[wh]-\d+$/.test(e)),`w-${u}`,`h-${d}`]}const le=`https://exhibitionviewer.org/iiif/theme-service`,ue={en:[`Exhibition viewer theme`]},de={fontSans:`"Tahoma", "Fira Sans", sans-serif`,fontMono:`"Fira Mono", monospace`,titleTransform:`uppercase`},fe={backgroundPrimary:`#e5e7eb`,backgroundSecondary:`#fff`,backgroundOverlay:`rgba(0, 0, 0, 0.3)`,textPrimary:`#fff`,textSecondary:`#000`,imageCaption:`#fff`,annotationSelected:`#facc15`,controlBar:`#6d6e70`,controlBarBorder:`#5a5b5d`,controlHover:`rgba(0, 0, 0, 0.1)`,progressBar:`#fff`,closeBackground:`#000`,closeBackgroundHover:`#373737`,closeText:`#fff`,titleCard:`#facc15`,titleCardText:`#000`,infoBlock:`#000`,infoBlockText:`#fff`,viewerBackground:`#373737`},pe={...fe,backgroundPrimary:`#fff`,backgroundSecondary:`#fff`,textPrimary:`#000`,textSecondary:`#000`,imageCaption:`#000`,annotationSelected:`#303f9f`,controlBar:`#f9f9f9`,controlBarBorder:`#000`,closeBackground:`#fff`,closeBackgroundHover:`#eee`,closeText:`#000`,progressBar:`#000000`,titleCard:`#fff`,titleCardText:`#000`,infoBlock:`#fff`,infoBlockText:`#000`,viewerBackground:`#e9e9e9`},me={titleBackground:`#fff`,titleColor:`#444`,annotationBackground:`#fff`,annotationColor:`#333`,annotationRadius:`0px`,annotationMaxWidth:`30em`,infoBlockBackground:`#fff`,infoBlockColor:`#444`},he={cutCorners:!0,fullTitleBar:!1,fullWidthGrid:!1,hideTableOfContents:!1,tableOfContentsPlacement:`footer`,showProgressBar:!0,showProgressTableOfContents:!0,showNavigationControls:!0,disablePresentation:!1,hideTitle:!1,hideTitleCard:!1,alternativeImageMode:!0,transitionScale:!1,imageInfoIcon:!1,coverImages:!1,ignoreCanvasBackgrounds:!1},ge={cutCorners:!1,isFloating:!1,floatingPosition:`bottom-left`,labelOnlyFloating:!0,ignoreCanvasBackgrounds:!1},_e={alternativeImageMode:!0,transitionScale:!1,imageInfoIcon:!1,coverImages:!1,ignoreCanvasBackgrounds:!1},ve={showTitleBlock:!0,showTableOfContents:!1,tableOfContentsPlacement:`header`,showProgressBar:!0,showProgressTableOfContents:!0,showScrollToTop:!0,showNavigationControls:!0,ignoreCanvasBackgrounds:!1,titleBlock:{fullHeight:!0}},ye={version:1,preset:`delft`,shared:de,delft:{tokens:fe,exhibition:he,presentation:ge,slideshow:_e},scroll:{tokens:me,options:ve}},be={delft:ye,minimal:{...ye,preset:`minimal`,shared:{...de,titleTransform:`none`},delft:{...ye.delft,tokens:pe}},gallery:{version:1,preset:`gallery`,shared:{fontSans:`"Gill Sans", "Trebuchet MS", sans-serif`,fontMono:`"Courier Prime", "Courier New", monospace`,titleTransform:`capitalize`},delft:{tokens:{...fe,backgroundPrimary:`#f3ecdf`,backgroundSecondary:`#fff8ee`,backgroundOverlay:`rgba(20, 26, 32, 0.45)`,textPrimary:`#fff8ee`,textSecondary:`#2b2118`,imageCaption:`#f8efe1`,annotationSelected:`#f08c2e`,controlBar:`#1f3a5f`,controlBarBorder:`#162b47`,controlHover:`rgba(255, 255, 255, 0.14)`,progressBar:`#f4a261`,closeBackground:`#1f3a5f`,closeBackgroundHover:`#335c8a`,closeText:`#fff8ee`,titleCard:`#c7522a`,titleCardText:`#fff8ee`,infoBlock:`#22313f`,infoBlockText:`#f8efe1`,viewerBackground:`#30414d`},exhibition:{...he,cutCorners:!1,fullTitleBar:!0,fullWidthGrid:!0,alternativeImageMode:!1,transitionScale:!0,imageInfoIcon:!0,coverImages:!0},presentation:{...ge,isFloating:!0,floatingPosition:`bottom-right`},slideshow:{..._e,alternativeImageMode:!1,transitionScale:!0,imageInfoIcon:!0,coverImages:!0}},scroll:{tokens:{...me,titleBackground:`#f8efe1`,titleColor:`#2a2119`,annotationBackground:`#22313f`,annotationColor:`#f8efe1`,annotationRadius:`18px`,annotationMaxWidth:`34em`,infoBlockBackground:`#fff8ee`,infoBlockColor:`#2a2119`},options:{...ve,showTableOfContents:!0,tableOfContentsPlacement:`header`,titleBlock:{fullHeight:!1}}}}};function xe(e){return JSON.parse(JSON.stringify(e))}function Se(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Ce(e,t){if(!t)return xe(e);let n=xe(e);for(let[e,r]of Object.entries(t)){if(r===void 0)continue;let t=n[e];if(Se(t)&&Se(r)){n[e]=Ce(t,r);continue}n[e]=r}return n}function we(e){return typeof e==`string`&&e in be}function Te(e=`delft`){return xe(be[e]||ye)}function Ee(e){let t=we(e?.preset)?e.preset:`delft`,n=Ce(Te(t),e||{});return n.version=1,n.preset=t,n}function De(e){return`${e}#exhibition-viewer-theme`}function Oe(e,t){return{id:De(e),type:`Service`,profile:le,label:ue,theme:Ee(t)}}function ke(e){if(!e?.length)return null;let t=e.findIndex(e=>e?.profile===`https://exhibitionviewer.org/iiif/theme-service`||e?.theme);return t===-1?null:{index:t,service:e[t]}}function Ae(e){return ke(e)?.service?.theme}function je(e,t){let n=[...e||[]],r=ke(n);return r?t?(n[r.index]=t,n):(n.splice(r.index,1),n):(t&&n.push(t),n)}function Me(e){return{"--f-font":e.shared.fontSans,"--f-mono-font":e.shared.fontMono,"--delft-title-transform":e.shared.titleTransform,"--delft-bg-primary":e.delft.tokens.backgroundPrimary,"--delft-bg-secondary":e.delft.tokens.backgroundSecondary,"--delft-bg-overlay":e.delft.tokens.backgroundOverlay,"--delft-text-primary":e.delft.tokens.textPrimary,"--delft-text-secondary":e.delft.tokens.textSecondary,"--delft-image-caption":e.delft.tokens.imageCaption,"--delft-annotation-selected":e.delft.tokens.annotationSelected,"--delft-control-bar":e.delft.tokens.controlBar,"--delft-control-bar-border":e.delft.tokens.controlBarBorder,"--delft-control-hover":e.delft.tokens.controlHover,"--delft-progress-bar":e.delft.tokens.progressBar,"--delft-close-background":e.delft.tokens.closeBackground,"--delft-close-background-hover":e.delft.tokens.closeBackgroundHover,"--delft-close-text":e.delft.tokens.closeText,"--delft-title-card":e.delft.tokens.titleCard,"--delft-title-card-text":e.delft.tokens.titleCardText,"--delft-info-block":e.delft.tokens.infoBlock,"--delft-info-block-text":e.delft.tokens.infoBlockText,"--delft-viewer-background":e.delft.tokens.viewerBackground,"--exv-scroll-title-background":e.scroll.tokens.titleBackground,"--exv-scroll-title-color":e.scroll.tokens.titleColor,"--exv-scroll-annotation-background":e.scroll.tokens.annotationBackground,"--exv-scroll-annotation-color":e.scroll.tokens.annotationColor,"--exv-scroll-annotation-radius":e.scroll.tokens.annotationRadius,"--exv-scroll-annotation-max-width":e.scroll.tokens.annotationMaxWidth,"--exv-scroll-info-block-background":e.scroll.tokens.infoBlockBackground,"--exv-scroll-info-block-color":e.scroll.tokens.infoBlockColor}}const Ne={id:`@exhibitions/center-panel`,label:`Exhibition editor`,icon:null,render:()=>(0,p.jsx)(Pe,{}),options:{minWidth:350,maxWidth:350}};function Pe(){let e=(0,d.useManifest)(),t=(0,d.useVault)(),[n,r]=(0,m.useState)(.8),i=(0,m.useRef)(null),{edit:a,leftPanel:o}=(0,l.useLayoutActions)(),s=(0,m.useMemo)(()=>e?Ee(Ae(e.service||e.services)):null,[e]),c=(0,m.useMemo)(()=>({localeStringEditor:e=>(0,p.jsxs)(`span`,{className:`inline-flex items-center hover:ring-4 hover:ring-me-primary-500`,children:[e.original,(0,p.jsx)(v.Button,{className:`py-1 px-2 inline-block`,onPress:()=>a(e.resource),children:(0,p.jsx)(h.EditTextIcon,{className:`text-xl`})})]}),canvasPreviewEditor:e=>(0,p.jsxs)(`div`,{className:`w-full h-full flex-1 flex relative`,children:[e.original,(0,p.jsx)(`button`,{onClick:t=>{t.preventDefault(),t.stopPropagation(),a(e.resource),o.open({id:`canvas-listing`})},className:`absolute top-5 right-5 bg-white text-black p-2 rounded z-40`,children:`EDIT`})]})}),[]);return(0,m.useEffect)(()=>{for(let n of e?.items||[]){let e=t.get(n);e&&!Array.isArray(e.items)&&t.modifyEntityField(e,`items`,[]);for(let n of[...e?.items||[],...e?.annotations||[]]){let e=t.get(n);e&&!Array.isArray(e.items)&&t.modifyEntityField(e,`items`,[])}}},[e,t]),(0,m.useLayoutEffect)(()=>{if(i.current){let e=i.current.offsetWidth/1200;r(Math.max(1,e))}},[]),e?(0,p.jsx)(`div`,{ref:i,className:`overflow-y-auto delft-exhibition exhibition-viewer`,style:s?Me(s):void 0,children:(0,p.jsx)(_.EditorHooksProvider,{hooks:c,children:(0,p.jsx)(g.DelftExhibition,{skipLoadManifest:!0,customVault:t,manifest:e.id,options:{...s?.delft.exhibition||{},disablePresentation:!0,hideTableOfContents:!0,hideTitle:!0}},n)})}):null}function Fe(e,t){let n=new URLSearchParams;switch(Le(n,`manifest`,t.manifest),Le(n,`canvas`,t.canvas),e){case`delft`:case`exhibition`:{let e=t;B(n,`cut-corners`,e.cutCorners),B(n,`full-title-bar`,e.fullTitleBar),B(n,`hide-toc`,e.hideTableOfContents),B(n,`show-navigation-controls`,e.showNavigationControls),B(n,`show-progress-bar`,e.showProgressBar),Le(n,`toc-placement`,e.tableOfContentsPlacement),B(n,`ignore-canvas-backgrounds`,e.ignoreCanvasBackgrounds);break}case`minimal`:{let e=t;n.set(`minimal`,`true`),B(n,`cut-corners`,e.cutCorners),B(n,`full-title-bar`,e.fullTitleBar),Le(n,`toc-placement`,e.tableOfContentsPlacement),B(n,`ignore-canvas-backgrounds`,e.ignoreCanvasBackgrounds);break}case`presentation`:{let e=t;n.set(`type`,`presentation`),B(n,`cut-corners`,e.cutCorners),B(n,`floating`,e.floating??e.isFloating),Le(n,`floating-position`,e.floatingPosition),B(n,`label-only-floating`,e.labelOnlyFloating),B(n,`ignore-canvas-backgrounds`,e.ignoreCanvasBackgrounds);break}case`scroll`:{let e=t;n.set(`type`,`scroll`),Re(n,`minimal`,e.minimal),Le(n,`toc-placement`,e.tableOfContentsPlacement),B(n,`ignore-canvas-backgrounds`,e.ignoreCanvasBackgrounds),Re(n,`manifest-editor-preview`,e.manifestEditorPreview),Le(n,`manifest-editor-preview-origin`,e.manifestEditorPreviewOrigin);break}case`slideshow`:{let e=t;n.set(`type`,`slideshow`),Re(n,`minimal`,e.minimal),B(n,`floating`,e.floating),Le(n,`floating-position`,e.floatingPosition),B(n,`label-only-floating`,e.labelOnlyFloating),B(n,`ignore-canvas-backgrounds`,e.ignoreCanvasBackgrounds);break}}return n}function Ie(e,t,n){let r=Fe(e,t||{}),i=new URL(n||`https://preview.exhibitionviewer.org/preview/${e}`);return!n&&(window.location.hostname===`localhost`||window.location.hostname===`127.0.0.1`)&&window.location.port===`3000`&&(i.protocol=`http:`,i.host=`localhost:5174`),r.forEach((e,t)=>{i.searchParams.set(t,e)}),i.searchParams.set(`manifest-editor-preview`,`true`),i.searchParams.set(`manifest-editor-preview-origin`,window.location.origin),i}function Le(e,t,n){n&&e.set(t,n)}function B(e,t,n){typeof n==`boolean`&&e.set(t,String(n))}function Re(e,t,n){n&&e.set(t,`true`)}function ze(e){return e===`exhibition-slideshow-editor`?`slideshow`:e===`exhibition-scrolling-editor`?`scroll`:`fullpage`}function Be(e,t=[]){let n=t.find(e=>e.startsWith(`template-`))?.slice(9);return e.find(e=>e.id===n)||e.find(e=>t.includes(e.type))||null}function Ve(e,t,n){return t?e.filter(e=>e.type===t.type||e.id===n?.id):e}function V(){let e=(0,l.useApp)(),t=e.preset?.templates||[],n=(0,d.useManifest)(),{selectedTemplate:r}=(0,l.usePresetTemplateSelection)();return Be(t,n?.behavior)||r||t.find(t=>t.type===ze(e.metadata.id))||null}const H=(0,f.create)(e=>({selectedAnnotationId:null,repositioningAnnotationId:null,selectedTextRegion:null,repositioningTextRegion:null,selectedTourStepId:null,repositioningTourStepId:null,selectAnnotation:t=>e({selectedAnnotationId:t,repositioningAnnotationId:null,selectedTextRegion:null,repositioningTextRegion:null}),startRepositioning:t=>e({selectedAnnotationId:t,repositioningAnnotationId:t,selectedTextRegion:null,repositioningTextRegion:null}),stopRepositioning:()=>e({repositioningAnnotationId:null}),selectTextRegion:t=>e({selectedAnnotationId:null,repositioningAnnotationId:null,selectedTextRegion:t,repositioningTextRegion:null}),startTextRepositioning:t=>e({selectedAnnotationId:null,repositioningAnnotationId:null,selectedTextRegion:t,repositioningTextRegion:t}),stopTextRepositioning:()=>e({repositioningTextRegion:null}),selectTourStep:t=>e({selectedTourStepId:t,repositioningTourStepId:null}),startTourStepRepositioning:t=>e({selectedTourStepId:t,repositioningTourStepId:t}),stopTourStepRepositioning:()=>e({repositioningTourStepId:null}),clear:()=>e({selectedAnnotationId:null,repositioningAnnotationId:null,selectedTextRegion:null,repositioningTextRegion:null,selectedTourStepId:null,repositioningTourStepId:null})})),U=(0,f.create)(e=>({requestedTab:null,showTourSteps:!1,centerPanelMode:`preview`,requestTab:t=>e({requestedTab:t}),clearRequestedTab:()=>e({requestedTab:null}),setShowTourSteps:t=>e({showTourSteps:t}),setCenterPanelMode:t=>e({centerPanelMode:t})}));function He(e){let t=Number(e?.width)||1920,n=Number(e?.height)||1080,r=Qe(e);return r.content?r.content:{x:Math.round(t*.1),y:Math.round(n*.1),width:Math.round(t*.8),height:Math.round(n*.8)}}function Ue(e,t){return{type:`SpecificResource`,source:{id:e.id,type:`Canvas`},selector:{type:`FragmentSelector`,value:`xywh=${Math.round(t.x)},${Math.round(t.y)},${Math.round(t.width)},${Math.round(t.height)}`}}}function We(e){return Ue(e,He(e))}function W(e,t){return qe(e,t?.items||[]).filter(e=>(Array.isArray(e?.motivation)?e.motivation:[e?.motivation]).includes(`painting`))}function Ge(e,t){return qe(e,t?.annotations||[])}function Ke(e,t){return!t||(Array.isArray(t?.behavior)?t.behavior:[]).includes(`info`)?!1:!W(e,t).some(t=>{let n=et(e,t);return!!(ot(n)||st(n))})}function qe(e,t){let n=[];for(let r of t){let t=e.get(r,{skipSelfReturn:!1});for(let r of t?.items||[]){let t=e.get(r,{skipSelfReturn:!1});t&&n.push(t)}}return n}function Je(e,t){return W(e,t).map(n=>{let r=et(e,n);return{annotation:n,box:Ye(n,t),html:it(r),imageUrl:rt(e,r),videoUrl:ot(r),youtubeId:st(r)}})}function Ye(e,t){let n=Number(t?.width)||1920,r=Number(t?.height)||1080,i=e?.target;if(typeof i==`string`&&i.includes(`#xywh=`)){let e=tt(i.split(`#xywh=`)[1]);if(e)return e}let a=i?.selector,o=Array.isArray(a)?a.find(e=>e?.spatial||e?.points):a;if(o?.spatial)return o.spatial;if(Array.isArray(o?.points)){let e=o.points.filter(e=>Array.isArray(e)&&Number.isFinite(e[0])&&Number.isFinite(e[1]));if(e.length){let t=e.map(e=>e[0]),n=e.map(e=>e[1]),r=Math.min(...t),i=Math.min(...n);return{x:r,y:i,width:Math.max(1,Math.max(...t)-r),height:Math.max(1,Math.max(...n)-i)}}}let s=Array.isArray(a)?a.find(e=>e?.value?.startsWith?.(`xywh=`))?.value:a?.value;if(typeof s==`string`&&s.includes(`xywh=`)){let e=tt(s.split(`xywh=`)[1]);if(e)return e}return{x:0,y:0,width:n,height:r}}function Xe(e,t,n,r){e.modifyEntityField({id:n,type:`Annotation`},`target`,Ue(t,$e(t,r)))}function Ze(e,t,n){let r=$e(t,n),i=Array.isArray(t?.behavior)?t.behavior:[];e.modifyEntityField(t,`behavior`,i.filter(e=>!e.startsWith(`text-xywh=`)).concat(`text-xywh=${Math.round(r.x)},${Math.round(r.y)},${Math.round(r.width)},${Math.round(r.height)}`))}function Qe(e){let t=Number(e?.width)||1920,n=Number(e?.height)||1080,r=Array.isArray(e?.behavior)?e.behavior:[],i=nt(r);return r.includes(`right`)?{content:{x:0,y:0,width:Math.round(t*2/3),height:n},text:i||{x:Math.round(t*2/3),y:0,width:Math.round(t/3),height:n}}:r.includes(`left`)?{content:{x:Math.round(t/3),y:0,width:Math.round(t*2/3),height:n},text:i||{x:0,y:0,width:Math.round(t/3),height:n}}:r.includes(`bottom`)?{content:{x:0,y:0,width:t,height:Math.round(n*2/3)},text:i||{x:0,y:Math.round(n*2/3),width:t,height:Math.round(n/3)}}:r.includes(`top`)?{content:{x:0,y:Math.round(n/3),width:t,height:Math.round(n*2/3)},text:i||{x:0,y:0,width:t,height:Math.round(n/3)}}:r.includes(`info`)?{content:null,text:i||{x:0,y:0,width:t,height:n}}:r.includes(`image`)?{content:{x:0,y:0,width:t,height:n},text:i}:{content:null,text:i}}function $e(e,t){let n=Number(e?.width)||1920,r=Number(e?.height)||1080,i=Math.max(1,Math.min(t.width,n)),a=Math.max(1,Math.min(t.height,r)),o=Math.max(0,Math.min(t.x,n-i)),s=Math.max(0,Math.min(t.y,r-a));return{x:Math.round(o),y:Math.round(s),width:Math.round(i),height:Math.round(a)}}function et(e,t){let n=Array.isArray(t?.body)?t.body[0]:t?.body,r=n?e.get(n,{skipSelfReturn:!1}):null;return r?.type===`SpecificResource`?r.source:r||n||null}function tt(e){let t=e?e.split(/[,&]/).slice(0,4).map(Number):[];if(t.length===4&&t.every(e=>Number.isFinite(e))){let[e,n,r,i]=t;return{x:e,y:n,width:r,height:i}}return null}function nt(e){let t=e.find(e=>e.startsWith(`text-xywh=`))?.replace(`text-xywh=`,``);return tt(t)}function rt(e,t){let n=at(e,t);if(n?.type===`Choice`){let t=Array.isArray(n.items)?n.items:[];for(let n of t){let t=rt(e,n);if(t)return t}}if(n?.type===`Canvas`){let t=e.get({id:n.id,type:`Canvas`},{skipSelfReturn:!1})||n,r=Array.isArray(t.thumbnail)?t.thumbnail[0]:t.thumbnail;if(r?.id)return r.id;for(let n of W(e,t)){let t=rt(e,et(e,n));if(t)return t}}let r=Array.isArray(n?.service)?n.service[0]:n?.service,i=r?.id||r?.[`@id`];return i?`${i.replace(/\/$/,``)}/full/1000,/0/default.jpg`:n?.type===`Image`&&n.id?n.id:null}function it(e){let t=e?.type===`SpecificResource`?e.source:e;return t?.type===`Text`||t?.type===`TextualBody`||t?.format===`text/html`||t?.format===`text/plain`?t.value||``:null}function at(e,t){return t?.type===`SpecificResource`?at(e,t.source):t?.id&&t?.type===`ContentResource`?e.get({id:t.id,type:`ContentResource`},{skipSelfReturn:!1})||t:t?.id&&!t.items&&!t.value&&!t.service&&!t.format&&!t.width&&!t.height&&e.get(t,{skipSelfReturn:!1})||t}function ot(e){let t=e?.type===`SpecificResource`?e.source:e;return t?.type===`Video`&&!st(t)?t.id:null}function st(e){let t=e?.type===`SpecificResource`?e.source:e,n=((t?.service||[]).find(e=>e?.profile===`https://www.youtube.com`)?.id||t?.id||``).match(/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/);return n?n[1]:null}function ct(e,t){return JSON.stringify([e.id,e.type,...(t||[]).map(e=>[e.id,e.type])])}function lt(e,t){let n=[];for(let r of t||[]){let t=e.get(r,{skipSelfReturn:!1});for(let r of W(e,t)){let t=Array.isArray(r.body)?r.body:r.body?[r.body]:[];for(let i of t){let t=i?.id&&e.get(i,{preserveSpecificResources:!0,skipSelfReturn:!1})||i,a=Array.isArray(t?.selector)?t.selector:t?.selector?[t.selector]:[];for(let e of a)(e?.type===`ImageApiSelector`||e?.type===`iiif:ImageApiSelector`)&&n.push([r.id,e.region??null,e.rotation??null])}}}return JSON.stringify(n)}const ut=1024,dt=.5;function ft({preset:e,presetOptions:t,focusSelectedCanvas:n=!0}){let r=pt({preset:e,presetOptions:t,focusSelectedCanvas:n}),i=(0,d.useVault)(),a=(0,l.useAppResource)(),o=(0,d.useManifest)(),s=V(),c=(0,u.useInStack)(`Canvas`),f=(0,m.useRef)(null),h=(0,m.useRef)(null),g=(0,m.useRef)(null),_=(0,m.useRef)(a),v=(0,m.useRef)(null),b=(0,m.useRef)(null),[x,S]=(0,m.useState)(`waiting`),[C,w]=(0,m.useState)(0),[T,E]=(0,m.useState)(!1),[D,O]=(0,m.useState)(!1),k=H(e=>e.selectedTourStepId),A=n&&(c?.resource.source.id||o?.items?.[0]?.id)||null,j=ct(a,o?.items),M=(0,d.useVaultSelector)((e,t)=>lt(t,o?.items),[j]),N=(0,m.useRef)(j),P=(0,m.useMemo)(()=>Ie(e,t,s?.previewUrl).toString(),[e,t,s?.previewUrl]),F=(0,m.useMemo)(()=>new URL(P).origin,[P]),I=D?440:C?Math.round(C/(T?dt:1)):0,ee=I>0&&I<=ut;_.current=a,v.current=A,b.current=k;let L=(0,m.useCallback)(()=>{let e=f.current;if(!e?.contentWindow)return;g.current?.(),S(`waiting`);let t=new MessageChannel;g.current=(0,l.createIframeVaultBridge)(i,t.port1);try{e.contentWindow.postMessage({_type:`manifest-editor:iframe-preview:connect`,resource:_.current,canvasId:v.current,annotationId:b.current||void 0},F,[t.port2]),S(`connected`)}catch{g.current?.(),g.current=null,S(`error`)}},[F,i]);(0,m.useEffect)(()=>{function e(e){e.origin===F&&e.source===f.current?.contentWindow&&e.data?._type===`manifest-editor:iframe-preview:ready`&&L()}return window.addEventListener(`message`,e),()=>{window.removeEventListener(`message`,e),g.current?.(),g.current=null}},[L,F]),(0,m.useEffect)(()=>{let e=f.current?.contentWindow;!e||x!==`connected`||e.postMessage({_type:`manifest-editor:iframe-preview:selection`,resource:a,canvasId:A,annotationId:k||void 0},F)},[x,a,A,k,F]),(0,m.useEffect)(()=>{let e=N.current!==j;N.current=j,e&&x===`connected`&&L()},[L,x,j]),(0,m.useEffect)(()=>{let e=h.current;if(!e)return;let t=()=>{w(e.getBoundingClientRect().width)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,m.useEffect)(()=>{if(C){if(C>ut){E(!1);return}O(!1)}},[C]);let R=(0,m.useCallback)(e=>{E(e),e&&O(!1)},[]),te=(0,m.useCallback)(e=>{O(e),e&&E(!1)},[]);return(0,p.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-zinc-950`,children:[x===`connected`?null:(0,p.jsx)(`div`,{className:`border-b border-zinc-800 bg-zinc-900 px-3 py-2 text-sm text-zinc-300`,children:x===`error`?`Preview connection failed.`:`Connecting to exhibition viewer...`}),(0,p.jsx)(mt,{iframeViewportWidth:I,isMobileViewport:ee,showScaleOption:C>0&&C<=ut,showMobileWidthOption:C>ut,useScaledPreview:T,useMobileWidthPreview:D,onUseScaledPreviewChange:R,onUseMobileWidthPreviewChange:te,previewWindow:r}),(0,p.jsx)(`div`,{ref:h,className:(0,y.twMerge)(`flex min-h-0 flex-1 overflow-hidden bg-white`,T?`justify-start`:`justify-center`),children:(0,p.jsx)(`iframe`,{ref:f,src:P,title:`Exhibition preview`,className:(0,y.twMerge)(`block h-full shrink-0 border-0 bg-white`,D?`shadow-2xl shadow-black/40`:``),style:{width:D?440:T?`${100/dt}%`:`100%`,maxWidth:D?`100%`:void 0,height:T?`${100/dt}%`:`100%`,transform:T?`scale(${dt})`:void 0,transformOrigin:`top left`},onLoad:()=>S(`waiting`)},M)})]})}function pt({preset:e,presetOptions:t,focusSelectedCanvas:n=!0}){let{open:r,update:i,focus:a,isClosed:o}=(0,l.usePreviewWindow)(),s=(0,l.useAppResource)(),c=(0,d.useManifest)(),f=V(),p=(0,u.useInStack)(`Canvas`),h=H(e=>e.selectedTourStepId),g=n&&(p?.resource.source.id||c?.items?.[0]?.id)||null,_=ct(s,c?.items),v=(0,d.useVaultSelector)((e,t)=>lt(t,c?.items),[_]),y=(0,m.useMemo)(()=>Ie(e,t,f?.previewUrl).toString(),[e,t,f?.previewUrl]),b=(0,m.useMemo)(()=>({url:y,resource:s,canvasId:g,annotationId:h,name:`manifest-editor-exhibition-preview`,reloadKey:`${_}:${v}`}),[g,v,s,h,_,y]);return(0,m.useEffect)(()=>i(b),[b,i]),(0,m.useMemo)(()=>({open:()=>r(b),focus:a,isClosed:o}),[a,o,r,b])}function mt({iframeViewportWidth:e,isMobileViewport:t,showScaleOption:n,showMobileWidthOption:r,useScaledPreview:i,useMobileWidthPreview:a,onUseScaledPreviewChange:o,onUseMobileWidthPreviewChange:s,previewWindow:c}){return e?(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-zinc-800/80 bg-zinc-900 px-3 py-2 text-xs text-zinc-200`,children:[(0,p.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,p.jsx)(`span`,{className:(0,y.twMerge)(`shrink-0 rounded-full px-2 py-1 font-semibold ring-1 ring-inset`,t?`bg-amber-300/90 text-amber-950 ring-amber-200/50`:`bg-emerald-300/90 text-emerald-950 ring-emerald-200/50`),children:t?`Mobile view`:`Desktop view`}),(0,p.jsxs)(`span`,{className:`truncate text-zinc-400`,children:[`Iframe viewport: `,e,`px. Mobile starts at `,ut,`px and below.`]})]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,p.jsx)(ht,{label:`50% scale`,checked:i,onChange:o}):null,r?(0,p.jsx)(ht,{label:`Mobile width`,checked:a,onChange:s}):null,(0,p.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md border border-zinc-700 bg-zinc-950/70 px-2.5 py-1.5 font-semibold text-zinc-200 shadow-sm shadow-black/20 transition-colors hover:border-zinc-600 hover:bg-zinc-950`,onClick:c.isClosed?c.open:c.focus,children:c.isClosed?`Open in new window`:`Focus preview window`})]})]}):null}function ht({label:e,checked:t,onChange:n}){return(0,p.jsxs)(`label`,{className:`flex shrink-0 cursor-pointer items-center gap-2 rounded-md border border-zinc-800 bg-zinc-950/70 px-2.5 py-1.5 font-semibold text-zinc-200 shadow-sm shadow-black/20 transition-colors hover:border-zinc-700 hover:bg-zinc-950`,children:[(0,p.jsx)(`span`,{children:e}),(0,p.jsx)(`input`,{type:`checkbox`,className:`peer sr-only`,checked:t,onChange:e=>n(e.currentTarget.checked)}),(0,p.jsx)(`span`,{className:`relative h-5 w-9 rounded-full bg-zinc-700/80 transition-colors after:absolute after:left-0.5 after:top-0.5 after:h-4 after:w-4 after:rounded-full after:bg-zinc-100 after:shadow after:shadow-black/20 after:transition-transform peer-checked:bg-me-primary-500 peer-checked:after:translate-x-4`})]})}function gt(){switch(V()?.type){case`slideshow`:return`slideshow`;case`scroll`:return`scroll`;default:return`exhibition`}}function _t(e){return(0,p.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,...e,children:[(0,p.jsx)(`title`,{children:`Preview`}),(0,p.jsx)(`path`,{fill:`currentColor`,d:`M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5M12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5s5 2.24 5 5s-2.24 5-5 5m0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3s3-1.34 3-3s-1.34-3-3-3`})]})}const vt={id:`@exhibitions/remote-preview-panel`,label:`Exhibition preview`,icon:(0,p.jsx)(_t,{}),render:()=>(0,p.jsx)(yt,{}),options:{minWidth:350}};function yt(){let e=gt(),t=(0,d.useManifest)(),n=Ee(Ae(t?.service)||Ae(t?.services)),r;return r=e===`scroll`?{ignoreCanvasBackgrounds:n.scroll.options.ignoreCanvasBackgrounds,tableOfContentsPlacement:n.scroll.options.tableOfContentsPlacement}:e===`slideshow`?{ignoreCanvasBackgrounds:n.delft.slideshow.ignoreCanvasBackgrounds}:{cutCorners:n.delft.exhibition.cutCorners,fullTitleBar:n.delft.exhibition.fullTitleBar,hideTableOfContents:n.delft.exhibition.hideTableOfContents,ignoreCanvasBackgrounds:n.delft.exhibition.ignoreCanvasBackgrounds,showNavigationControls:n.delft.exhibition.showNavigationControls,showProgressBar:n.delft.exhibition.showProgressBar,tableOfContentsPlacement:n.delft.exhibition.tableOfContentsPlacement},(0,p.jsx)(ft,{preset:e,presetOptions:r,focusSelectedCanvas:!1})}function bt({children:e}){let t=(0,d.useManifest)(),{edit:n}=(0,l.useLayoutActions)();return(0,p.jsxs)(`div`,{className:`grid auto-rows-auto grid-cols-12 content-center justify-center gap-2 p-2`,children:[(0,p.jsx)(`div`,{className:`col-span-12 row-span-2 text-black flex flex-col items-center justify-center`,children:(0,p.jsx)(v.Button,{onPress:()=>t&&n(t,void 0,{forceOpen:!0,selectedTab:`@manifest-editor/descriptive-properties`}),className:`col-span-4 row-span-4 text-md text-left text-black hover:bg-slate-100 w-full flex items-center justify-center`,children:(0,p.jsx)(d.LocaleString,{className:`block w-full text-left`,children:t?.label})})}),e]})}const xt=[{value:`float-top-left`,label:`Top left`},{value:`float-top`,label:`Top centre`},{value:`float-top-right`,label:`Top right`},{value:`float-left`,label:`Centre left`},{value:`float-right`,label:`Centre right`},{value:`float-bottom-left`,label:`Bottom left`},{value:`float-bottom`,label:`Bottom centre`},{value:`float-bottom-right`,label:`Bottom right`}],St={"float-top-left":{x:2,y:2},"float-top":{x:8.5,y:2},"float-top-right":{x:15,y:2},"float-left":{x:2,y:8.5},"float-right":{x:15,y:8.5},"float-bottom-left":{x:2,y:15},"float-bottom":{x:8.5,y:15},"float-bottom-right":{x:15,y:15}};function Ct({position:e}){return(0,p.jsxs)(`svg`,{width:`1.6em`,height:`1.6em`,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,children:[(0,p.jsx)(`rect`,{x:`2`,y:`2`,width:`20`,height:`20`,rx:`3`,stroke:`currentColor`,strokeWidth:`1.5`,opacity:`0.4`}),e?(0,p.jsx)(`rect`,{...St[e],width:`7`,height:`7`,rx:`1.5`,fill:`currentColor`}):(0,p.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`,stroke:`currentColor`,strokeWidth:`1.5`,opacity:`0.7`})]})}function wt({value:e,onChange:t}){let n=Tt();return(0,p.jsx)(`div`,{className:`grid w-fit grid-cols-3 gap-2`,children:n.map(n=>{let r=e===n.value;return(0,p.jsxs)(`button`,{type:`button`,title:n.label,"aria-pressed":r,className:`flex min-h-11 items-center justify-center rounded-md border px-3 py-2 transition-colors`,style:{backgroundColor:r?`var(--exhibition-primary, #b84c74)`:`#fff`,borderColor:r?`var(--exhibition-primary, #b84c74)`:`#dcd5ce`,color:r?`#fff`:`#332f2c`},onClick:()=>t(n.value),children:[(0,p.jsx)(Ct,{position:n.value}),(0,p.jsx)(`span`,{className:`sr-only`,children:n.label})]},n.value||`off`)})})}function Tt(e=`No overlay`){return[...xt.slice(0,4),{value:``,label:e},...xt.slice(4)]}function Et(){let e=(0,d.useCanvas)(),t=(0,l.useEditingResource)(),n=(0,l.useInlineCreator)(),[r,i]=(0,l.useCreator)(t?.resource.source,`thumbnail`,`ContentResource`),{descriptive:a}=(0,l.useEditor)(),{thumbnail:o}=a,s=o.get()||[],c=(0,d.useVault)(),f=(0,m.useMemo)(()=>e?kt(c,e):[],[e,c]);return!e||!t?null:!s.length&&f.length?(0,p.jsx)(Dt,{candidates:f,canCreateThumbnail:r,onCreateThumbnail:()=>i.create(),onAddThumbnail:({service:t,width:r,height:i})=>n.create(`@manifest-editor/thumbnail-image`,{service:t,width:r,height:i},Ot(e))}):(0,p.jsx)(u.LinkingPropertyList,{containerId:o.containerId(),label:`Thumbnail`,property:`thumbnail`,items:s,singleMode:!0,reorder:e=>o.reorder(e.startIndex,e.endIndex),createActions:(0,u.createAppActions)(o),creationType:`ContentResource`,emptyLabel:`No thumbnail`,parent:t.resource})}function Dt({candidates:e,canCreateThumbnail:t,onCreateThumbnail:n,onAddThumbnail:r}){let[i,a]=(0,m.useState)(null),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)({}),d=e.find(e=>e.id===i)||e[0],f=d?c[d.id]:void 0,g=d?f===null?null:f||d.service:null,_=g?Ft(g):[],v=Lt(_,350),y=_.find(e=>It(e)===o)||v,b=g&&y?Rt(g,y):null,x=d&&!d.service.sizes?.length&&!(d.id in c);return(0,m.useEffect)(()=>{!i&&e[0]&&a(e[0].id)},[e,i]),(0,m.useEffect)(()=>{let t=e.filter(e=>{let t=e.service;return!t.sizes?.length&&Nt(t)&&!(e.id in c)});for(let e of t){let t=Nt(e.service);t&&fetch(Pt(t)).then(e=>e.ok?e.json():null).then(t=>{l(n=>({...n,[e.id]:t?{...e.service,...t}:null}))}).catch(()=>{l(t=>({...t,[e.id]:null}))})}},[e,c]),(0,m.useEffect)(()=>{v&&!_.some(e=>It(e)===o)&&s(It(v))},[v,o,_]),(0,p.jsx)(u.InputContainer,{$wide:!0,children:(0,p.jsxs)(`div`,{className:`rounded-md border border-[#dcd5ce] bg-[#f8f6f3] p-4`,children:[(0,p.jsx)(`div`,{className:`text-sm font-semibold text-[#25211f]`,children:`Thumbnail`}),(0,p.jsx)(`div`,{className:`mt-1 text-sm text-[#6a625c]`,children:`Use an image service from this canvas to add a thumbnail.`}),e.length>1?(0,p.jsxs)(`div`,{className:`mt-3`,children:[(0,p.jsx)(`label`,{className:`text-xs font-semibold uppercase text-[#6a625c]`,htmlFor:`thumbnail-source-image`,children:`Image`}),(0,p.jsx)(`select`,{id:`thumbnail-source-image`,className:`mt-1 w-full rounded-md border border-[#dcd5ce] bg-white px-3 py-2 text-sm`,value:d?.id||``,onChange:e=>{a(e.currentTarget.value),s(``)},children:e.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}):null,_.length?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:_.map(e=>{let t=It(e),n=y?t===It(y):!1;return(0,p.jsxs)(`button`,{type:`button`,className:`rounded-md border px-2 py-1 text-xs font-semibold`,style:{backgroundColor:n?`#b84c74`:`#ffffff`,borderColor:n?`#b84c74`:`#dcd5ce`,color:n?`#ffffff`:`#332f2c`},onClick:()=>s(t),children:[e.width,`x`,e.height]},t)})}),b?(0,p.jsx)(`div`,{className:`mt-3 overflow-hidden rounded-md border border-[#dcd5ce] bg-white`,children:(0,p.jsx)(`img`,{src:b,alt:``,className:`max-h-40 w-full object-contain`})}):null,(0,p.jsx)(`button`,{type:`button`,className:`mt-3 rounded-md px-3 py-2 text-sm font-semibold shadow-sm`,style:{backgroundColor:`#b84c74`,border:`1px solid #a13e63`,color:`#ffffff`},disabled:!b||!y,onClick:()=>{!g||!y||r({service:g,width:y.width,height:y.height})},children:`Add thumbnail from image`})]}):x?(0,p.jsx)(`div`,{className:`mt-3 text-sm text-[#6a625c]`,children:`Finding available sizes...`}):(0,p.jsx)(`div`,{className:`mt-3 text-sm text-[#6a625c]`,children:`No fixed thumbnail sizes were found for this image service.`}),t?(0,p.jsx)(`div`,{className:`mt-4 border-t border-[#dcd5ce] pt-3`,children:(0,p.jsxs)(h.ActionButton,{onPress:n,children:[(0,p.jsx)(h.AddIcon,{}),` Create thumbnail`]})}):null]})})}function Ot(e){return{parent:{property:`thumbnail`,resource:{id:e.id,type:`Canvas`}}}}function kt(e,t){let n=[],r=new Set;return W(e,t).forEach((t,i)=>{At(e,et(e,t)).forEach((e,a)=>{let o=Mt(e),s=o?Nt(o):``;!o||!s||r.has(s)||(r.add(s),n.push({id:`${t.id||i}-${e.id||s}-${a}`,label:zt(e.label)||zt(t.label)||`Image ${n.length+1}`,imageId:e.id,service:o}))})}),n}function At(e,t){let n=jt(e,t);return n?n.type===`Choice`&&Array.isArray(n.items)?n.items.flatMap(t=>At(e,t)):n.type===`SpecificResource`?At(e,n.source):n.type===`Canvas`?W(e,n).flatMap(t=>At(e,et(e,t))):Mt(n)?[n]:[]:[]}function jt(e,t){return t?t.id&&!t.service&&!t.items&&!t.value&&e.get(t,{skipSelfReturn:!1})||t:null}function Mt(e){return(Array.isArray(e?.service)?e.service:e?.service?[e.service]:[]).find(e=>{let t=Array.isArray(e.profile)?e.profile.join(` `):e.profile||``;return(e.type||e[`@type`]||``).includes(`ImageService`)||t.includes(`level`)||t.includes(`iiif.io/api/image`)})||null}function Nt(e){return(e.id||e[`@id`]||``).replace(/\/info\.json$/,``)}function Pt(e){return e.endsWith(`/info.json`)?e:`${e.replace(/\/$/,``)}/info.json`}function Ft(e){let t=Array.isArray(e.sizes)?e.sizes.filter(e=>Number(e.width)&&Number(e.height)).map(e=>({width:Number(e.width),height:Number(e.height)})):[];if(t.length)return t.sort((e,t)=>e.width-t.width).slice(0,8);let n=Number(e.width),r=Number(e.height);return!n||!r?[]:[256,512,1024].filter(e=>e<n).map(e=>({width:e,height:Math.round(r/n*e)})).concat([{width:n,height:r}]).slice(0,4)}function It(e){return`${e.width},${e.height||``}`}function Lt(e,t){return e.reduce((e,n)=>e?Math.hypot(n.width-t,n.height-t)<Math.hypot(e.width-t,e.height-t)?n:e:n,void 0)}function Rt(e,t){let n={...e};n[`@id`]&&(n.id=n[`@id`]),n[`@type`]&&(n.type=n[`@type`]);let r=(0,x.createImageServiceRequest)(n);return(0,x.imageServiceRequestToString)({identifier:r.identifier,server:r.server,scheme:r.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:r.prefix,originalPath:r.originalPath})}function zt(e){return e?typeof e==`string`?e:Array.isArray(e)?e.filter(Boolean).join(` `):typeof e==`object`?Object.values(e).flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).join(` `):``:``}const Bt=new Set([`left`,`right`,`bottom`,`top`]),Vt=new Set([...Bt,`image`]),Ht=new Set([`cover`,`image-cover`]);function Ut(e,t,n){let r=e.findIndex(e=>t.has(e)),i=e.filter(e=>!t.has(e));return i.splice(r<0?i.length:r,0,n),i}function Wt(e,t,n,r){let i=e.findIndex(e=>t.has(e)),a=e.filter(e=>!t.has(e));return r&&a.splice(i<0?a.length:i,0,n),a}function Gt(e,t){return Ut(e,t===`image`?Vt:Bt,t)}const Kt=new Set([`scroll`,`page-scroll`]),qt=new Set([`splash`,`fixed`,`invert`,`backdrop-light`,`backdrop-dark`,`compact-deck`]),Jt=[{value:`image`,label:`Image only`},{value:`top`,label:`Text above image`},{value:`bottom`,label:`Text below image`},{value:`left`,label:`Text left of image`},{value:`right`,label:`Text right of image`}],G={primary:`var(--exhibition-primary, #b84c74)`,fieldBorder:`var(--exhibition-field-border, #dcd5ce)`,fieldBackground:`var(--exhibition-field-bg, #f8f6f3)`,text:`var(--exhibition-text, #25211f)`,muted:`var(--exhibition-muted, #6a625c)`,buttonBackground:`var(--exhibition-button-bg, #ffffff)`,buttonText:`var(--exhibition-button-text, #ffffff)`,inactiveButtonText:`var(--exhibition-inactive-button-text, #332f2c)`},Yt=[{value:12,label:`Full width`},{value:8,label:`2/3 width`},{value:6,label:`Half width`},{value:4,label:`1/3 width`}],Xt=new Set(xt.map(e=>e.value));function Zt(e){return e.some(e=>Kt.has(e))}function Qt(e){return e.some(e=>Ht.has(e))}function $t(e,t){return e===`slideshow`||e===`scroll`||e===`fullpage`?e:t===`exhibition-slideshow-editor`?`slideshow`:t===`exhibition-scrolling-editor`?`scroll`:`fullpage`}function en(e,t=!1,n=!0,r=!1,i=!0){let a=e===`scroll`||t;return{showGridSizing:e===`fullpage`&&!t&&!r,isSlideshow:e===`slideshow`,showFloating:!r&&(e===`slideshow`||e===`scroll`||t),showImageCover:i&&!r&&(e===`fullpage`&&!t||a&&n),showScrollToggle:!r&&e===`fullpage`,showScrollDisplay:e===`slideshow`||e===`scroll`,showFixedCover:e===`scroll`,showCoverBackdrop:!1,scrollContext:a,layoutOptions:r?[]:a?n?[{value:`left`,label:`Annotations on left`},{value:`right`,label:`Annotations on right`}]:[]:Jt}}function tn(e=[],t=!0){let n=(0,l.useApp)();return en($t(V()?.type,n.metadata.id),Zt(e),t,e.includes(`splash`))}const nn={component:()=>(0,p.jsx)(dn,{}),supports:{edit:!0,resourceTypes:[`Canvas`],properties:[`behavior`],custom:({resource:e},t)=>ie(e,t)?!ae(e,t):!1},id:`slide-behaviors`,label:`Layout`,tabs:{showTitle:!0}},rn={id:`floating`,type:`choice`,label:{en:[`Floating`]},initialOpen:!1,addNone:!0,groupBehavior:`floating`,items:xt.map(e=>({label:{en:[`Float ${e.label.toLowerCase()}`]},value:e.value}))},an={id:`size`,component:(e,t)=>(0,p.jsx)(un,{behaviors:e,setBehaviors:t}),label:{en:[`Size`]},type:`custom`,initialOpen:!0,supports:e=>e.startsWith(`w-`)||e.startsWith(`h-`)};function on({behaviors:e,setBehaviors:t,flags:n}){let r=(n,r)=>{let i=Wt(e,new Set([n.value,...n.aliases||[],...n.group||[]]),n.value,r);t(n.clean?n.clean(i,r):i)};return(0,p.jsx)(`div`,{className:`flex flex-col gap-2`,children:n.map(t=>(0,p.jsx)(yn,{checked:e.includes(t.value)||!!t.aliases?.some(t=>e.includes(t)),label:t.label,onChange:e=>r(t,e)},t.value))})}function sn({behaviors:e,setBehaviors:t,options:n}){let r=xn(e);return(0,p.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:n.map(n=>(0,p.jsx)(vn,{selected:r===n.value&&(n.value===`image`||e.includes(n.value)),onClick:()=>t(Gt(e,n.value)),children:n.label},n.value))})}function cn(e,t=[],n=!0,r=!0,i=!0){let a=en(e,Zt(t),r,t.includes(`splash`)&&n,i),o=a.showScrollDisplay&&n,s=[];return a.layoutOptions.length&&!(a.isSlideshow&&wn(t))&&s.push({id:`layout`,type:`custom`,label:{en:[`Layout`]},initialOpen:!0,supports:e=>Vt.has(e),component:(e,t)=>(0,p.jsx)(sn,{behaviors:e,setBehaviors:t,options:a.layoutOptions})}),a.showScrollToggle&&s.push({id:`scroll`,type:`custom`,label:{en:[`Scrolling section`]},initialOpen:!1,supports:e=>Kt.has(e),component:(e,t)=>(0,p.jsx)(on,{behaviors:e,setBehaviors:t,flags:[{value:`scroll`,label:`Show as a scrolling section`,aliases:[`page-scroll`],clean:(e,t)=>t?e.filter(e=>!On(e)):e}]})}),a.showImageCover&&s.push({id:`display`,type:`custom`,label:{en:[`Display`]},initialOpen:!1,supports:e=>Ht.has(e),component:(e,t)=>(0,p.jsx)(on,{behaviors:e,setBehaviors:t,flags:[{value:`cover`,label:`Crop image to fill its frame`,aliases:[`image-cover`]}]})}),o&&s.push({id:`cover`,type:`custom`,label:{en:[`Cover`]},initialOpen:!1,supports:e=>qt.has(e),component:(e,t)=>(0,p.jsx)(on,{behaviors:e,setBehaviors:t,flags:[{value:`splash`,label:`Use as opening cover`},...a.showFixedCover?[{value:`fixed`,label:`Keep image fixed while scrolling`}]:[],{value:`invert`,label:`Use light text`}]})}),a.showFloating&&s.push(rn),a.showGridSizing&&s.push(an),s}function ln(e){let t=0,n=0;for(let r of e)r.startsWith(`w-`)&&(t=Number.parseInt(r.slice(2))),r.startsWith(`h-`)&&(n=Number.parseInt(r.slice(2)));return{width:t,height:n}}function un({behaviors:e,setBehaviors:t}){let{width:n,height:r}=ln(e),[i,a]=(0,m.useState)({x:-1,y:-1}),o=(n,r)=>{let i=e.filter(e=>!e.startsWith(`w-`)&&!e.startsWith(`h-`));i.push(`w-${n}`),i.push(`h-${r}`),t(i)},s=Array.from({length:144},(e,t)=>{let s=t%12,c=Math.floor(t/12),l=i.x>=s&&i.y>=c,u=s<n&&c<r,d=l&&u,f=`bg-gray-200`;return l&&(f=`bg-me-200`),u&&(f=`bg-me-500`),d&&(f=`bg-me-400`),(0,p.jsx)(`div`,{className:`flex aspect-square rounded cursor-se-resize items-center justify-center ${f}`,onClick:()=>o(s+1,c+1),onMouseUp:()=>o(s+1,c+1),onMouseEnter:()=>a({x:s,y:c})},t)});return(0,p.jsx)(`div`,{className:`grid grid-cols-12 grid-rows-12 gap-1`,onMouseLeave:()=>a({x:-1,y:-1}),children:s})}function dn(){let[e,t]=(0,l.useLocalStorage)(`exhibition-layout-panel-mode`,`simple`);return(0,p.jsx)(h.Sidebar,{children:(0,p.jsxs)(h.SidebarContent,{className:`bg-white px-6 pt-5 pb-20`,children:[(0,p.jsx)(`div`,{className:`mb-6 flex justify-center`,children:(0,p.jsx)(bn,{value:e,onChange:t})}),(0,p.jsx)(fn,{mode:e})]})})}function fn({mode:e=`advanced`,layoutContext:t=`default`}){let n=(0,u.useInStack)(`Canvas`),r=(0,d.useCanvas)(),i=(0,l.useEditor)(),a=(0,l.useApp)(),o=(0,d.useVault)(),s=(0,d.useManifest)(),c=$t(V()?.type,t===`slideshow`?`exhibition-slideshow-editor`:a.metadata.id),{width:f,height:m}=i.technical,h=i.technical.behavior.get()||[],g=(0,d.useVaultSelector)((e,t)=>r?Ge(t,r).length>0:!1,[r?.id,r?.annotations?.[0]?.id]),_=!!(r&&An(o,r)),v=!!(r&&kn(s)===r.id&&_),y=en(c,Zt(h),g,h.includes(`splash`)&&v,_);return!n||i.technical.type!==`Canvas`?(0,p.jsx)(`div`,{className:`p-4`,children:`Please select canvas`}):e===`simple`?(0,p.jsx)(p.Fragment,{children:(0,p.jsx)(pn,{behavior:i.technical.behavior.get()||[],controls:y,canvasWidth:f.get()||0,canvasHeight:m.get()||0,onChange:e=>{i.technical.behavior.set(e)}})}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(u.BehaviorEditor,{behavior:i.technical.behavior.get()||[],onChange:e=>{i.technical.behavior.set(e)},configs:cn(c,h,v,g,_)}),(0,p.jsx)(Et,{})]})}function pn({behavior:e,controls:t,canvasWidth:n,canvasHeight:r,onChange:i}){let a=xn(e),o=t.showGridSizing?Cn(e):12,s=wn(e),c=Tn(e),l=Qt(e),u=Zt(e),f=e.includes(`splash`),m=e.includes(`fixed`),h=e.includes(`invert`),g=e.includes(`backdrop-dark`)?`backdrop-dark`:e.includes(`backdrop-light`)?`backdrop-light`:``,_=U(e=>e.requestTab),v=(0,d.useCanvas)(),y=(0,d.useVault)(),b=(0,d.useManifest)(),x=t.showGridSizing?o:12,S=jn({canvasWidth:n,canvasHeight:r,layoutPreset:a,displayWidth:x}),C=t.showGridSizing&&b?.items&&v?Pn(v.id,b.items,y):null,w=!!(v&&kn(b)===v.id&&An(y,v)),T=d=>{let p=t.layoutOptions.length?d.layoutPreset??a:void 0,_=t.showGridSizing?d.displayWidth??o:12,b=d.floating??s,x=d.floatingBehavior??c,S=d.cover??l,C=d.scrollEnabled??u,T=d.splash??f,E=d.fixed??m,D=d.invert??h,O=d.backdrop??g;i(Dn({behavior:e,layoutPreset:p,displayWidth:_,canvasWidth:n,canvasHeight:r,floating:b,floatingBehavior:x,cover:S,scrollEnabled:C,splash:T,fixed:t.showFixedCover&&E,invert:D,backdrop:t.showCoverBackdrop?O:``,showGridSizing:t.showGridSizing&&!C,showFloating:t.showFloating,showImageCover:t.showImageCover,showScrollToggle:t.showScrollToggle,showScrollDisplay:t.showScrollDisplay&&w})),v&&p&&In(y,v,p)};return(0,p.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,p.jsx)(mn,{layoutPreset:a,cover:l,floating:s,width:x,height:S,showGridSizing:t.showGridSizing,onTextClick:()=>_(`summary`)}),t.layoutOptions.length&&!(t.isSlideshow&&s)?(0,p.jsxs)(K,{children:[(0,p.jsx)(q,{children:`Text placement`}),(0,p.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:t.layoutOptions.map(e=>(0,p.jsx)(hn,{preset:e.value,label:e.label,selected:a===e.value,onClick:()=>T({layoutPreset:e.value})},e.value))})]}):null,t.showGridSizing?(0,p.jsxs)(K,{children:[(0,p.jsx)(q,{children:`Width`}),(0,p.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:Yt.map(e=>(0,p.jsx)(vn,{selected:o===e.value,onClick:()=>T({displayWidth:e.value}),children:e.label},e.value))})]}):null,C?(0,p.jsxs)(K,{children:[(0,p.jsxs)(q,{children:[`Fit alongside `,C.neighbour,` slide`]}),(0,p.jsx)(`div`,{className:`mt-3`,children:(0,p.jsxs)(vn,{selected:o===C.width,onClick:()=>T({displayWidth:C.width}),children:[`w-`,C.width,` — fills remaining space`]})})]}):null,(0,p.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t.showScrollToggle?(0,p.jsx)(yn,{checked:u,label:`Show as a scrolling section`,onChange:e=>T({scrollEnabled:e})}):null,t.showFloating?(0,p.jsx)(yn,{checked:s,label:`Overlay text on the image`,onChange:e=>T({floating:e})}):null,t.isSlideshow&&s?(0,p.jsxs)(K,{children:[(0,p.jsx)(q,{children:`Text overlay position`}),(0,p.jsx)(`div`,{className:`mt-3`,children:(0,p.jsx)(wt,{value:c,onChange:e=>{T(e?{floatingBehavior:e}:{floating:!1})}})})]}):null,t.showImageCover?(0,p.jsx)(yn,{checked:l,label:`Crop image to fill its frame`,onChange:e=>T({cover:e})}):null,t.showScrollDisplay&&w?(0,p.jsxs)(K,{children:[(0,p.jsx)(q,{children:`Cover`}),(0,p.jsxs)(`div`,{className:`mt-3 flex flex-col gap-3`,children:[(0,p.jsx)(yn,{checked:f,label:`Use as opening cover`,onChange:e=>T({splash:e})}),t.showFixedCover?(0,p.jsx)(yn,{checked:m,label:`Keep image fixed while scrolling`,onChange:e=>T({fixed:e})}):null,(0,p.jsx)(yn,{checked:h,label:`Use light text`,onChange:e=>T({invert:e})}),t.showCoverBackdrop?(0,p.jsxs)(K,{children:[(0,p.jsx)(q,{children:`Backdrop`}),(0,p.jsx)(`div`,{className:`mt-3 grid grid-cols-3 gap-2`,children:[{value:``,label:`Default`},{value:`backdrop-light`,label:`Light`},{value:`backdrop-dark`,label:`Dark`}].map(e=>(0,p.jsx)(vn,{selected:g===e.value,onClick:()=>T({backdrop:e.value}),children:e.label},e.value||`default`))})]}):null]})]}):null]})]})}function mn({layoutPreset:e,cover:t,floating:n,width:r,height:i,showGridSizing:a,onTextClick:o}){let s=e===`bottom`,c=e===`image`,l=e===`left`;return(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`relative mx-auto overflow-hidden rounded-md border bg-[#f8f6f3] shadow-sm`,style:{width:`${Math.max(33,Math.round(r/12*100))}%`,aspectRatio:`${r} / ${i}`,borderColor:G.fieldBorder},children:[(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`flex h-full w-full min-h-0`,l?`flex-row-reverse`:s?`flex-col`:`flex-row`),children:[(0,p.jsx)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden bg-white`,children:(0,p.jsx)(`div`,{className:`absolute inset-0`,children:(0,p.jsx)(h.LazyThumbnail,{cover:t,fade:!1})})}),c?null:(0,p.jsx)(`button`,{type:`button`,"aria-label":`Edit slide text`,className:(0,y.twMerge)(`flex-shrink-0 border-0 bg-[#25211f] p-3 text-left text-white transition-colors hover:bg-[#332f2c] focus:outline-none focus:ring-2 focus:ring-me-primary-500 focus:ring-offset-2`,s?`h-1/3 w-full`:`h-full w-1/3`),onClick:o,children:(0,p.jsx)(_n,{tone:`light`})})]}),n?(0,p.jsx)(`div`,{className:`absolute right-2 top-2 h-7 w-10 rounded bg-white/90 shadow ring-1 ring-black/10`}):null]}),a?(0,p.jsxs)(`div`,{className:`mt-2 text-center text-xs`,style:{color:G.muted},children:[`w-`,r,` h-`,i]}):null]})}function hn({preset:e,label:t,selected:n,onClick:r}){return(0,p.jsxs)(`button`,{type:`button`,"aria-pressed":n,className:`flex min-h-[112px] flex-col items-center justify-center gap-3 rounded-md border px-3 py-4 text-center text-sm font-semibold transition-colors`,style:{backgroundColor:n?G.primary:G.buttonText,borderColor:n?G.primary:G.fieldBorder,color:n?G.buttonText:G.inactiveButtonText},onClick:r,children:[(0,p.jsx)(gn,{preset:e,selected:n}),(0,p.jsx)(`span`,{className:`leading-tight`,children:t})]})}function gn({preset:e,selected:t}){let n=e===`image`,r=e===`bottom`,i=e===`top`,a=e===`left`,o=t?`bg-white/80`:`bg-[#25211f]`,s=t?`bg-white/25 ring-white/70`:`bg-[#f8f6f3] ring-[#dcd5ce]`;return(0,p.jsxs)(`span`,{className:(0,y.twMerge)(`flex h-12 w-16 gap-1 overflow-hidden rounded border p-1`,t?`border-white/70 bg-white/15`:`border-[#dcd5ce] bg-white`,a?`flex-row-reverse`:r?`flex-col`:i?`flex-col-reverse`:`flex-row`),"aria-hidden":`true`,children:[(0,p.jsx)(`span`,{className:(0,y.twMerge)(`flex-1 rounded-sm ring-1`,s)}),n?null:(0,p.jsx)(`span`,{className:(0,y.twMerge)(`flex flex-shrink-0 flex-col justify-center gap-0.5 rounded-sm px-0.5`,o,r||i?`h-3 w-full`:`h-full w-4`),children:(0,p.jsx)(_n,{compact:!0,tone:t?`dark`:`light`})})]})}function _n({compact:e=!1,tone:t=`light`}){let n=t===`light`?`bg-white/70`:`bg-[#8b3f61]/70`;return(0,p.jsxs)(`span`,{className:(0,y.twMerge)(`block space-y-1.5`,e?`space-y-0.5`:`mt-1`),"aria-hidden":`true`,children:[(0,p.jsx)(`span`,{className:(0,y.twMerge)(`block rounded`,n,e?`h-0.5 w-full`:`h-1.5 w-3/4`)}),(0,p.jsx)(`span`,{className:(0,y.twMerge)(`block rounded`,n,e?`h-0.5 w-4/5`:`h-1.5 w-full`)}),(0,p.jsx)(`span`,{className:(0,y.twMerge)(`block rounded`,n,e?`h-0.5 w-2/3`:`h-1.5 w-2/3`)})]})}function vn({selected:e,onClick:t,children:n,title:r}){return(0,p.jsx)(`button`,{type:`button`,title:r,"aria-pressed":e,className:`flex min-h-11 items-center justify-center gap-1.5 rounded-md border px-3 py-2 text-sm font-semibold transition-colors`,style:{backgroundColor:e?G.primary:G.buttonText,borderColor:e?G.primary:G.fieldBorder,color:e?G.buttonText:G.inactiveButtonText,boxShadow:e?`0 0 0 2px ${G.primary}33`:void 0},onClick:t,children:n})}function yn({checked:e,label:t,onChange:n}){return(0,p.jsxs)(`label`,{className:`flex items-center justify-between rounded-md border px-4 py-3 text-sm font-semibold`,style:{backgroundColor:G.fieldBackground,borderColor:G.fieldBorder,color:G.text},children:[t,(0,p.jsx)(`input`,{type:`checkbox`,className:`h-4 w-4 accent-me-primary-500`,checked:e,onChange:e=>n(e.currentTarget.checked)})]})}function bn({value:e,onChange:t}){return(0,p.jsx)(`div`,{role:`group`,"aria-label":`Editing mode`,className:`grid w-full max-w-[240px] grid-cols-2 rounded-full bg-[#f5eaf0] p-1`,children:[`simple`,`advanced`].map(n=>{let r=e===n;return(0,p.jsx)(v.Button,{"aria-pressed":r,className:`border-none rounded-full bg-transparent px-4 py-2 text-sm font-semibold capitalize transition-colors`,style:{backgroundColor:r?G.primary:`transparent`,color:r?`#ffffff`:`#8b3f61`,boxShadow:r?`0 1px 3px rgba(15, 23, 42, 0.18)`:`none`},onPress:()=>t(n),children:n},n)})})}function K({children:e}){return(0,p.jsx)(`div`,{children:e})}function q({children:e}){return(0,p.jsx)(`div`,{className:`text-sm font-semibold`,style:{color:G.muted},children:e})}function xn(e){return e.includes(`left`)?`left`:e.includes(`top`)?`top`:e.includes(`bottom`)?`bottom`:e.includes(`right`)?`right`:(e.includes(`image`),`image`)}function Sn(e,t,n){let r=Gt(e,t);if(n?.width&&n?.height){let{width:i}=ln(e),a=i?i<=4?4:i<=6?6:i<=8?8:12:12,o=jn({canvasWidth:n.width,canvasHeight:n.height,layoutPreset:t,displayWidth:a}),s=r.filter(e=>!e.startsWith(`h-`));return s.push(`h-${o}`),s}return r}function Cn(e){let{width:t}=ln(e);return t?t<=4?4:t<=6?6:t<=8?8:12:12}function wn(e){return e.includes(`floating`)||e.some(e=>Xt.has(e))}function Tn(e){return e.find(e=>Xt.has(e))||`float-top-right`}function En(e,t){let n=e.filter(e=>e!==`floating`&&!Xt.has(e));return t?[...n,t]:n}function Dn({behavior:e,layoutPreset:t,displayWidth:n,canvasWidth:r,canvasHeight:i,floating:a,floatingBehavior:o,cover:s,scrollEnabled:c,splash:l,fixed:u,invert:d,backdrop:f,showGridSizing:p,showFloating:m,showImageCover:h,showScrollToggle:g,showScrollDisplay:_}){let v=e.filter(e=>!((p||c)&&On(e)||m&&(e===`floating`||Xt.has(e))||h&&Ht.has(e)||g&&Kt.has(e)||_&&qt.has(e)));if(t&&(v=Gt(v,t)),g&&c&&v.push(`scroll`),p){let e=jn({canvasWidth:r,canvasHeight:i,layoutPreset:t||`image`,displayWidth:n});v.push(`w-${n}`,`h-${e}`)}return m&&a&&v.push(o||`float-top-right`),h&&s&&v.push(`cover`),_&&(l&&v.push(`splash`),u&&v.push(`fixed`),d&&v.push(`invert`),f&&v.push(f)),v}function On(e){return e.startsWith(`w-`)||e.startsWith(`h-`)||e.startsWith(`start-`)}function kn(e){return e?.items?.[0]?.id}function An(e,t){return!t||t.behavior?.includes(`info`)?!1:t.behavior?.includes(`multi-image`)?!0:W(e,t).some(t=>{let n=et(e,t),r=n?.type===`SpecificResource`?n.source:n,i=Array.isArray(r?.service)?r.service:r?.service?[r.service]:[];return r?.type===`Image`||i.length>0})}function jn({canvasWidth:e,canvasHeight:t,layoutPreset:n,displayWidth:r}){let i=e&&t?e/t:1.5,a=n===`left`||n===`right`?2/3*r:r,o=n===`bottom`?3/2:1,s=Math.round(a/i*o);return Math.max(1,Math.min(12,s))}const Mn=[{value:4,label:`1/3 width`},{value:6,label:`Half width`},{value:8,label:`2/3 width`},{value:12,label:`Full width`}];function Nn(e){let{width:t}=ln(e);return t}function Pn(e,t,n){let r=t.findIndex(t=>t.id===e);if(r===-1)return null;let i=e=>{if(!e)return 0;try{return Nn(n.get(e)?.behavior||[])}catch{return 0}},a=i(t[r-1]),o=i(t[r+1]);if(a>0&&a<12){let e=12-a;if(e>=4)return{width:e,neighbour:`previous`}}if(o>0&&o<12){let e=12-o;if(e>=4)return{width:e,neighbour:`next`}}return null}const Fn=new Set([`left`,`right`,`bottom`,`top`]);function In(e,t,n){Fn.has(n)&&((0,u.getInternationalStringText)(t.label)||e.modifyEntityField(t,`label`,{en:[`Untitled`]}),(0,u.getInternationalStringText)(t.summary)||e.modifyEntityField(t,`summary`,{en:[`Add a description for this slide.`]}))}const Ln=`non-linear-tour`,Rn=`tour-marker-pin`,zn=`editorial-text`;function Bn({className:e,editable:t=!1,mode:n=`edit`,showTourSteps:r=!1}){let i=(0,d.useCanvas)(),a=(0,d.useVault)(),o=(0,u.useInStack)(`Annotation`),s=(0,m.useRef)(null),[c,l]=(0,m.useState)(null),f=U(e=>e.requestTab),{selectedAnnotationId:h,repositioningAnnotationId:g,selectedTextRegion:_,repositioningTextRegion:v,selectedTourStepId:b,selectAnnotation:x,startRepositioning:S,selectTextRegion:C,selectTourStep:w}=H(),T=(0,d.useVaultSelector)((e,t)=>i?Je(t,i):[],[i?.id,i?.items?.[0]?.id]),E=(0,d.useVaultSelector)((e,t)=>i?Ge(t,i):[],[i?.id,i?.annotations?.[0]?.id]),D=o?.resource.source.id,O=n===`edit`&&r,k=Array.isArray(i?.behavior)?i.behavior:[],A=k.includes(Ln),j=k.includes(`tour-marker-pin`)?`pin`:`circle`,M=n===`edit`&&!r,N=E.find(e=>e.id===c);if((0,m.useEffect)(()=>{l(null)},[i?.id,r]),(0,m.useEffect)(()=>{A&&O&&b&&l(b)},[A,b,O]),!i)return null;let P=Number(i.width)||1920,F=Number(i.height)||1080,I=Qe(i);return(0,p.jsxs)(`div`,{ref:s,className:(0,y.twMerge)(`relative h-full w-full overflow-hidden`,n===`edit`&&`bg-white`,e),style:{aspectRatio:`${P} / ${F}`,backgroundColor:i.backgroundColor||(n===`edit`?`#fff`:void 0)},children:[T.length?T.map(e=>{let r=D===e.annotation.id,o=r||h===e.annotation.id,c=g===e.annotation.id;return(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`absolute overflow-hidden`,M&&o&&`ring-4 ring-me-primary-500 ring-offset-2 ring-offset-white`,(c||r)&&M&&`cursor-move select-none touch-none`),style:{left:`${e.box.x/P*100}%`,top:`${e.box.y/F*100}%`,width:`${e.box.width/P*100}%`,height:`${e.box.height/F*100}%`},onPointerDown:M&&(c||r)?t=>Jn({event:t,mode:`move`,canvas:i,annotation:e.annotation,vault:a,startBox:e.box,stage:s.current}):M&&t?t=>{x(e.annotation.id),S(e.annotation.id),f(`content`),Jn({event:t,mode:`move`,canvas:i,annotation:e.annotation,vault:a,startBox:e.box,stage:s.current})}:void 0,children:[(0,p.jsx)(qn,{layer:e,mode:n,cover:k.includes(`cover`)||k.includes(`image-cover`)}),M&&(c||r)?(0,p.jsx)(`div`,{className:`absolute bottom-0 right-0 h-4 w-4 cursor-se-resize rounded-tl bg-me-primary-500`,onPointerDown:t=>{t.stopPropagation(),Jn({event:t,mode:`resize`,canvas:i,annotation:e.annotation,vault:a,startBox:e.box,stage:s.current})}}):null]},e.annotation.id)}):(0,p.jsx)(`div`,{className:(0,y.twMerge)(`flex h-full w-full items-center justify-center text-sm font-semibold`,n===`preview`?`text-white/70`:`bg-white text-slate-600`),children:n===`preview`?`This slide has no content yet`:`Empty slide`}),I.text?(0,p.jsx)(Kn,{canvas:i,box:I.text,editable:t&&M,mode:n,repositioning:v===zn,selected:_===zn,stage:s,onSelect:()=>{C(zn),f(`content`)}}):null,O?E.map((e,t)=>(0,p.jsx)(Vn,{annotation:e,canvas:i,index:t,active:c===e.id,markerStyle:j,nonLinear:A,selected:b===e.id,onSelect:()=>{w(e.id),A&&l(e.id)}},e.id)):null,O&&A&&N?(0,p.jsx)(Wn,{annotation:N,onExit:()=>l(null)}):null]})}function Vn({active:e,annotation:t,canvas:n,index:r,markerStyle:i,nonLinear:a,selected:o,onSelect:s}){let c=Ye(t,n),l=Array.isArray(n.behavior)?n.behavior:[],u=Array.isArray(t.behavior)?t.behavior:[],d=wn(l)?Tn(u.length?u:l):null,f=Number(n.width)||1920,m=Number(n.height)||1080,h=`#6d5aa8`;return a?(0,p.jsx)(`button`,{type:`button`,className:(0,y.twMerge)(`absolute z-30 border-none bg-transparent p-0 transition-transform hover:scale-110 focus:outline-none focus:ring-4 focus:ring-white/80`,e&&`z-40 scale-110`),style:{left:`${(c.x+c.width/2)/f*100}%`,top:`${(c.y+c.height/2)/m*100}%`,transform:`translate(-50%, -50%)`},onClick:e=>{e.stopPropagation(),s()},children:(0,p.jsx)(Hn,{index:r+1,style:i})}):(0,p.jsxs)(`button`,{type:`button`,"aria-label":`Select tour step ${r+1}`,className:(0,y.twMerge)(`absolute select-none border-2 border-me-primary-500 bg-me-primary-500/10 touch-none`,o?`z-40`:`z-30`,`cursor-pointer`,o?`border-4`:`ring-2 ring-white`),style:{left:`${c.x/f*100}%`,top:`${c.y/m*100}%`,width:`${c.width/f*100}%`,height:`${c.height/m*100}%`,...o?{backgroundColor:`rgba(109, 90, 168, 0.2)`,borderColor:h,boxShadow:`0 0 0 4px rgba(109, 90, 168, 0.22), 0 0 0 8px rgba(109, 90, 168, 0.14)`}:{}},onClick:e=>{e.stopPropagation(),s()},children:[(0,p.jsx)(`span`,{className:`absolute left-1 top-1`,children:(0,p.jsx)(Un,{index:r+1})}),(0,p.jsxs)(`span`,{className:(0,y.twMerge)(`absolute rounded px-1.5 py-0.5 text-xs font-semibold text-white`,Gn(d),!o&&`bg-me-primary-500`),style:o?{backgroundColor:h}:void 0,children:[`Step `,r+1]})]})}function Hn({index:e,style:t}){return(0,p.jsxs)(`span`,{className:(0,y.twMerge)(`inline-flex items-center justify-center border-2 border-white bg-black text-white shadow-lg ring-1 ring-black/40`,t===`pin`?`h-10 w-10 rounded-full`:`h-8 min-w-8 rounded px-2 text-xs font-semibold`),children:[t===`pin`?(0,p.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full bg-white`,"aria-hidden":`true`}):e,(0,p.jsxs)(`span`,{className:`sr-only`,children:[`Tour step `,e]})]})}function Un({index:e}){return(0,p.jsxs)(`span`,{className:`inline-flex h-10 w-10 items-center justify-center rounded-full border-2 border-white bg-black shadow-lg ring-1 ring-black/40`,children:[(0,p.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full bg-white`,"aria-hidden":`true`}),e?(0,p.jsxs)(`span`,{className:`sr-only`,children:[`Tour step `,e]}):null]})}function Wn({annotation:e,onExit:t}){let n=Xn(e.label),r=Xn(e.summary);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`absolute right-4 top-4 z-50`,children:(0,p.jsx)(`button`,{type:`button`,className:`rounded bg-white px-4 py-2 text-sm font-semibold text-slate-900 shadow ring-1 ring-black/10`,onClick:t,children:`Exit`})}),(0,p.jsxs)(`div`,{className:`absolute left-4 top-4 z-50 max-h-[calc(100%-2rem)] w-[min(26rem,calc(100%-2rem))] overflow-y-auto rounded bg-white p-5 text-slate-900 shadow-2xl ring-1 ring-black/10`,children:[(0,p.jsxs)(`div`,{className:`mb-4 flex items-start justify-between gap-3`,children:[(0,p.jsx)(`h3`,{className:`text-xl font-bold leading-tight`,children:n||`Tour step`}),(0,p.jsx)(`button`,{type:`button`,className:`text-2xl leading-none text-slate-900`,"aria-label":`Close`,onClick:t,children:`x`})]}),r?(0,p.jsx)(`p`,{className:`mb-4 text-sm leading-relaxed text-slate-700`,children:r}):null,(0,p.jsx)(d.AnnotationContext,{annotation:e.id,children:(0,p.jsx)(h.HTMLAnnotationBodyRender,{className:`prose prose-sm max-w-none text-slate-800`,locale:`en`})})]})]})}function Gn(e){switch(e){case`float-top`:return`left-1/2 top-1 -translate-x-1/2`;case`float-top-right`:return`right-1 top-1`;case`float-left`:return`left-1 top-1/2 -translate-y-1/2`;case`float-right`:return`right-1 top-1/2 -translate-y-1/2`;case`float-bottom-left`:return`bottom-1 left-1`;case`float-bottom`:return`bottom-1 left-1/2 -translate-x-1/2`;case`float-bottom-right`:return`bottom-1 right-1`;default:return`left-1 top-1`}}function Kn({canvas:e,box:t,editable:n,mode:r,onSelect:i,repositioning:a,selected:o,stage:s}){let c=Number(e.width)||1920,l=Number(e.height)||1080,u=(0,d.useVault)();return(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`absolute flex flex-col overflow-hidden bg-black text-white`,r===`preview`?`font-mono`:`p-[3%]`,n&&o&&`ring-4 ring-me-primary-500 ring-offset-2`,n&&a&&`cursor-move select-none touch-none`),style:{left:`${t.x/c*100}%`,top:`${t.y/l*100}%`,width:`${t.width/c*100}%`,height:`${t.height/l*100}%`,...r===`preview`?{containerType:`inline-size`,padding:`3% 4%`}:{}},onPointerDown:n?n=>{i(),a&&Yn({event:n,mode:`move`,canvas:e,vault:u,startBox:t,stage:s.current})}:void 0,children:[r===`edit`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`block cursor-text text-xl font-semibold uppercase leading-tight outline-none focus:ring-2 focus:ring-white/70`,contentEditable:!0,suppressContentEditableWarning:!0,onBlur:t=>u.modifyEntityField(e,`label`,{en:[t.currentTarget.textContent||``]}),children:Xn(e.label)||`Untitled`}),(0,p.jsx)(`div`,{className:`mt-4 block min-h-0 cursor-text overflow-y-auto whitespace-pre-wrap text-sm leading-relaxed opacity-90 outline-none focus:ring-2 focus:ring-white/70`,contentEditable:!0,suppressContentEditableWarning:!0,onBlur:t=>u.modifyEntityField(e,`summary`,{en:[t.currentTarget.textContent||``]}),children:Xn(e.summary)||`Add editorial text`})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(d.LocaleString,{className:`block font-semibold uppercase leading-tight`,style:{fontSize:`clamp(13px, 5cqw, 26px)`},children:e.label}),(0,p.jsx)(d.LocaleString,{className:`block min-h-0 overflow-y-auto whitespace-pre-wrap opacity-90 leading-[1.45]`,style:{fontSize:`clamp(11px, 3.5cqw, 18px)`,marginTop:`5%`,paddingRight:`2%`},children:e.summary})]}),n&&a?(0,p.jsx)(`div`,{className:`absolute bottom-0 right-0 h-4 w-4 cursor-se-resize rounded-tl bg-me-primary-500`,onPointerDown:n=>{n.stopPropagation(),Yn({event:n,mode:`resize`,canvas:e,vault:u,startBox:t,stage:s.current})}}):null]})}function qn({layer:e,mode:t,cover:n}){return e.imageUrl?(0,p.jsx)(`img`,{src:e.imageUrl,alt:``,className:(0,y.twMerge)(`h-full w-full`,n?`object-cover`:`object-contain`)}):e.html===null?e.youtubeId?(0,p.jsx)(`iframe`,{className:`h-full w-full border-0`,title:`YouTube slide content`,src:`https://www.youtube.com/embed/${e.youtubeId}?modestbranding=1&rel=0`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0}):e.videoUrl?(0,p.jsx)(`video`,{className:`h-full w-full bg-black object-contain`,controls:!0,children:(0,p.jsx)(`source`,{src:e.videoUrl})}):(0,p.jsx)(`div`,{className:`flex h-full w-full items-center justify-center rounded bg-slate-100 text-sm font-semibold text-slate-500`,children:`Media`}):e.html?(0,p.jsx)(`div`,{className:`h-full w-full overflow-hidden bg-white p-4 text-slate-900`,dangerouslySetInnerHTML:{__html:e.html}}):t===`preview`?null:(0,p.jsx)(`div`,{className:`h-full w-full overflow-hidden bg-white p-4 text-slate-900`,children:(0,p.jsx)(`div`,{className:`flex h-full items-center justify-center rounded border border-dashed border-slate-300 text-sm font-semibold text-slate-400`,children:`Empty text`})})}function Jn({event:e,mode:t,canvas:n,annotation:r,vault:i,startBox:a,stage:o}){if(!o)return;e.preventDefault();let s=o.getBoundingClientRect(),c=(Number(n?.width)||1920)/s.width,l=(Number(n?.height)||1080)/s.height,u=e.clientX,d=e.clientY,f=e=>{let o=(e.clientX-u)*c,s=(e.clientY-d)*l,f=t===`move`?{...a,x:a.x+o,y:a.y+s}:{...a,width:a.width+o,height:a.height+s};Xe(i,n,r.id,f)},p=()=>{window.removeEventListener(`pointermove`,f),window.removeEventListener(`pointerup`,p),window.removeEventListener(`pointercancel`,p)};window.addEventListener(`pointermove`,f),window.addEventListener(`pointerup`,p),window.addEventListener(`pointercancel`,p)}function Yn({event:e,mode:t,canvas:n,vault:r,startBox:i,stage:a}){if(!a)return;e.preventDefault(),e.stopPropagation();let o=a.getBoundingClientRect(),s=(Number(n?.width)||1920)/o.width,c=(Number(n?.height)||1080)/o.height,l=e.clientX,u=e.clientY,d=e=>{let a=(e.clientX-l)*s,o=(e.clientY-u)*c;Ze(r,n,t===`move`?{...i,x:i.x+a,y:i.y+o}:{...i,width:i.width+a,height:i.height+o})},f=()=>{window.removeEventListener(`pointermove`,d),window.removeEventListener(`pointerup`,f),window.removeEventListener(`pointercancel`,f)};window.addEventListener(`pointermove`,d),window.addEventListener(`pointerup`,f),window.addEventListener(`pointercancel`,f)}function Xn(e){if(!e)return``;if(typeof e==`string`)return e;if(Array.isArray(e))return e.filter(Boolean).join(` `);let t=Object.values(e)[0];return Array.isArray(t)?t.filter(Boolean).join(` `):typeof t==`string`?t:``}const Zn=(0,m.forwardRef)(function({isFirst:e,item:t,children:n,onClick:r,...i},a){let o=(0,d.useCanvas)(),s=(0,h.useCanvasRenderingStrategy)(),c=o?.behavior||[],l=(0,u.useInStack)(`Canvas`),f=z(o?.behavior,e),{isBottom:m,isImage:g,isInfo:_,isLeft:v}=re(o?.behavior),b=l?.resource.source?.id===o?.id,x=(0,u.getInternationalStringText)(o?.label,`Untitled`),S=c.includes(`w-12`)&&c.includes(`h-8`),C=null;return C=S?(0,p.jsx)(Bn,{className:`pointer-events-none h-full w-full`,mode:`preview`}):_?(0,p.jsx)(`div`,{className:`bg-black w-full h-full text-white max-h-40`,children:(0,p.jsx)(`div`,{className:`p-1.5 text-[4px]`,children:s.type===`textual-content`?(0,p.jsx)(d.LocaleString,{enableDangerouslySetInnerHTML:!0,children:s.items[0]?.text}):null})}):(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`flex h-full max-h-full min-h-0`,v?`flex-row-reverse`:m?`flex-col`:`flex-row`),children:[(0,p.jsx)(`div`,{className:`flex-1 overflow-hidden relative justify-self-stretch`,style:{backgroundColor:o?.backgroundColor},children:(0,p.jsx)(`div`,{className:`absolute inset-0 w-full h-full`,children:(0,p.jsx)(h.LazyThumbnail,{cover:c.includes(`cover`)||c.includes(`image-cover`),fade:!1})})}),g?null:(0,p.jsx)(`div`,{className:`${m?`min-h-3 w-full`:`w-1/3`} flex-shrink-0 self-stretch p-2 text-white bg-black rounded`,children:(0,p.jsxs)(`div`,{className:`p-1.5 text-[4px]`,children:[(0,p.jsx)(d.LocaleString,{className:`block mb-1 text-[5px]`,children:o?.label}),(0,p.jsx)(d.LocaleString,{children:o?.summary})]})})]}),(0,p.jsxs)(`div`,{ref:a,className:(0,y.twMerge)(f,`bg-me-gray-700 overflow-hidden hover:ring-2 ring-me-primary-500 relative`,b?`ring-2 ring-me-primary-500`:``),...i,children:[C,(0,p.jsx)(`button`,{type:`button`,className:`absolute inset-0 z-20 cursor-pointer bg-transparent focus:outline focus:outline-2 focus:outline-offset-[-2px] focus:outline-me-primary-500`,"aria-label":`Edit slide ${x}`,onClick:r}),n]})});function Qn(){let{open:e}=(0,l.useLayoutActions)(),{structural:t,technical:n}=(0,l.useManifestEditor)(),[,r]=(0,l.useCreator)({id:n.id.get(),type:`Manifest`},`items`,`Canvas`),i=t.items.get();return(0,p.jsx)(bt,{children:i.map((t,n)=>(0,p.jsx)(d.CanvasContext,{canvas:t.id,children:(0,p.jsx)(Zn,{isFirst:n===0,item:t,onClick:()=>{e({id:`current-canvas`}),r.edit(t,n)}})},n))})}const $n=new Set([`a`,`blockquote`,`br`,`code`,`em`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`hr`,`i`,`img`,`li`,`ol`,`p`,`pre`,`s`,`span`,`strong`,`u`,`ul`]),er={a:new Set([`href`,`rel`,`target`,`title`]),img:new Set([`alt`,`data-iiif-image`,`loading`,`src`,`title`])};function tr(e){let t=or(e),n={};for(let[e,r]of Object.entries(t)){let t=r.filter(e=>typeof e==`string`).map(e=>sr(e)?ir(e):cr(e)).filter(Boolean).join(``);t&&(n[e]=[t])}return n}function nr(e){let t={};for(let[n,r]of Object.entries(e||{})){let e=(r||[]).filter(e=>typeof e==`string`).map(e=>sr(e)?ir(e):cr(e)).filter(Boolean).join(``);e&&(t[n]=[e])}return Object.keys(t).length?t:{none:[``]}}function rr(e){return Object.values(tr(e)).flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).join(``)}function ir(e){if(typeof document>`u`)return ur(e);let t=document.createElement(`template`);return t.innerHTML=e||``,ar(t.content),t.innerHTML}function ar(e){for(let t of Array.from(e.childNodes)){if(t.nodeType===Node.ELEMENT_NODE){let e=t,n=e.tagName.toLowerCase();if(!$n.has(n)){ar(e),e.replaceWith(...Array.from(e.childNodes));continue}for(let t of Array.from(e.attributes))dr(n,t.name.toLowerCase(),t.value)||e.removeAttribute(t.name);n===`a`&&e.getAttribute(`target`)?.toLowerCase()===`_blank`&&e.setAttribute(`rel`,`noopener noreferrer`)}ar(t)}}function or(e){if(!e)return{};if(typeof e==`string`)return{none:[e]};if(Array.isArray(e))return{none:e.filter(e=>typeof e==`string`)};if(typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))t[n]=(Array.isArray(r)?r:[r]).filter(e=>typeof e==`string`);return t}return{}}function sr(e){return e.trimStart().startsWith(`<`)}function cr(e){return e.replace(/\r\n?/g,`
2
+ `).split(/\n+/).map(e=>e.trim()).filter(Boolean).map(e=>`<p>${lr(e)}</p>`).join(``)}function lr(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function ur(e){return(e||``).replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,``).replace(/<style\b[^<]*(?:(?!<\/style>)<[^<]*)*<\/style>/gi,``).replace(/<\s*(\/?)\s*([a-z0-9]+)([^>]*)>/gi,(e,t,n,r)=>{let i=n.toLowerCase();if(!$n.has(i))return``;if(t)return`</${i}>`;let a=new Map;for(let e of r.matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g)){let t=e[1].toLowerCase(),n=e[2]??e[3]??e[4];n!==void 0&&dr(i,t,n)&&a.set(t,n)}return i===`a`&&a.get(`target`)?.toLowerCase()===`_blank`&&a.set(`rel`,`noopener noreferrer`),`<${i}${Array.from(a,([e,t])=>` ${e}="${pr(t)}"`).join(``)}${/\/\s*$/.test(r)?` /`:``}>`})}function dr(e,t,n){return er[e]?.has(t)?t===`data-iiif-image`?n===`true`:!((t===`href`||t===`src`)&&fr(n)):!1}function fr(e){let t=e.search(/[/?#]/);if(e.slice(0,t===-1?void 0:t).includes(`&`))return!0;let n=e.indexOf(`:`);if(n===-1)return!1;let r=e.slice(0,n).replace(/[\u0000-\u0020]/g,``).toLowerCase();return r.includes(`&`)||r===`javascript`||r===`data`}function pr(e){return e.replace(/&(?!(?:#\d+|#x[\da-f]+|[a-z][\w-]*);)/gi,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function mr(e){let t=e||``;if(typeof document<`u`){let e=document.createElement(`template`);e.innerHTML=t;let n=Array.from(e.content.childNodes).find(e=>e.nodeType===Node.ELEMENT_NODE||e.nodeType===Node.TEXT_NODE&&e.textContent?.trim());if(n?.nodeType===Node.ELEMENT_NODE&&/^h[1-6]$/i.test(n.tagName)){let t=n.textContent?.trim()||``;return n.remove(),{label:t,summary:ir(e.innerHTML.trim())}}return{label:void 0,summary:ir(t)}}let n=t.match(/^(?:\s|<!--[\s\S]*?-->)*<h[1-6][^>]*>([\s\S]*?)<\/h[1-6]>\s*/i);return n?{label:_r(gr(n[1]||``)).trim(),summary:ir(t.slice(n[0].length).trim())}:{label:void 0,summary:ir(t)}}function hr(e,t){return`${e===void 0?``:e.trim()?`<h2>${vr(e.trim())}</h2>`:`<h2></h2>`}${ir(t||``)}`}function gr(e){return e.replace(/<[^>]*>/g,``)}function _r(e){let t={amp:`&`,apos:`'`,gt:`>`,lt:`<`,nbsp:`\xA0`,quot:`"`};return e.replace(/&(?:#(\d+)|#x([\da-f]+)|([a-z]+));/gi,(e,n,r,i)=>{if(i)return t[i.toLowerCase()]??e;let a=Number.parseInt(n||r||``,n?10:16);return a>0&&a<=1114111&&!(a>=55296&&a<=57343)?String.fromCodePoint(a):e})}function vr(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function yr({mode:e}){let{open:t}=(0,l.useLayoutActions)(),{structural:n,technical:r}=(0,l.useManifestEditor)(),[,i]=(0,l.useCreator)({id:r.id.get(),type:`Manifest`},`items`,`Canvas`),a=n.items.get();return(0,p.jsx)(br,{children:a.map((n,r)=>(0,p.jsx)(d.CanvasContext,{canvas:n.id,children:(0,p.jsx)(xr,{mode:e,onClick:()=>{t({id:`current-canvas`}),i.edit(n,r)}})},n.id))})}function br({children:e}){let t=(0,d.useManifest)(),{edit:n}=(0,l.useLayoutActions)();return(0,p.jsxs)(`div`,{className:`flex flex-col gap-3 p-2`,children:[(0,p.jsx)(`button`,{type:`button`,onClick:()=>t&&n(t,void 0,{forceOpen:!0,selectedTab:`@manifest-editor/descriptive-properties`}),className:`w-full rounded border border-slate-200 bg-white p-2 text-left text-sm font-semibold text-slate-800 hover:bg-slate-50`,children:(0,p.jsx)(d.LocaleString,{children:t?.label})}),e]})}function xr({mode:e,onClick:t}){let n=(0,d.useCanvas)(),r=(0,d.useManifest)(),i=(0,u.useInStack)(`Canvas`)?.resource.source?.id===n?.id,[a,o]=(0,m.useState)(!1),s=(0,m.useId)(),c=(n?.behavior||[]).includes(`info`),l=e===`scroll`&&c,f=(0,d.useVaultSelector)((e,t)=>!!(r?.items?.[0]?.id===n?.id&&n&&Tr(t,n)),[r?.items?.[0]?.id,n?.id,n?.items?.[0]?.id]),h=(0,d.useVaultSelector)((e,t)=>n?Ge(t,n):[],[n?.id,n?.annotations?.[0]?.id]);return n?(0,p.jsxs)(`article`,{className:(0,y.twMerge)(`overflow-hidden rounded border bg-white shadow-sm`,i?`border-me-primary-500 ring-2 ring-me-primary-100`:`border-slate-200`),children:[(0,p.jsxs)(`button`,{type:`button`,className:`block w-full text-left`,onClick:t,children:[(0,p.jsx)(`div`,{className:`border-b border-slate-100 px-2 py-1.5 text-xs font-semibold text-slate-700`,children:(0,p.jsx)(d.LocaleString,{children:n.label})}),f&&n.behavior?.includes(`splash`)?(0,p.jsx)(Cr,{height:180}):e===`slideshow`?c?(0,p.jsx)(wr,{height:180}):(0,p.jsx)(`div`,{style:{height:180,backgroundColor:n?.backgroundColor||`#303030`},children:(0,p.jsx)(Bn,{className:`pointer-events-none h-full w-full`,mode:`preview`})}):(0,p.jsx)(Sr,{})]}),h.length&&!l?(0,p.jsxs)(`div`,{className:`border-t border-slate-100`,children:[(0,p.jsxs)(`button`,{type:`button`,"aria-expanded":a,"aria-controls":s,className:`flex w-full items-center justify-between px-2 py-1.5 text-xs font-semibold text-slate-600 hover:bg-slate-50`,onClick:e=>{e.stopPropagation(),o(e=>!e)},children:[(0,p.jsx)(`span`,{children:a?`Hide steps`:`Show steps`}),(0,p.jsx)(`span`,{children:h.length})]}),a?(0,p.jsx)(`div`,{id:s,className:`flex flex-col gap-2 border-t border-slate-100 p-2`,children:h.map((e,r)=>(0,p.jsx)(Er,{annotation:e,canvas:n,onClick:t},e.id||r))}):null]}):null]}):null}function Sr(){let e=(0,d.useCanvas)(),t=e?.behavior||[],{isInfo:n}=re(t);if(!e)return null;let r=Number(e.width)||1920,i=Number(e.height)||1080,a=Math.max(80,Math.round(332/r*i));return n?(0,p.jsx)(wr,{}):(0,p.jsx)(`div`,{className:`min-h-0`,style:{height:a,backgroundColor:e?.backgroundColor||`#303030`},children:(0,p.jsx)(`div`,{className:`relative h-full min-h-0 overflow-hidden`,style:{backgroundColor:e?.backgroundColor||`#303030`},children:(0,p.jsx)(`div`,{className:`absolute inset-0`,children:(0,p.jsx)(h.LazyThumbnail,{cover:t.includes(`cover`)||t.includes(`image-cover`),fade:!1})})})})}function Cr({height:e=180}){let t=(0,d.useManifest)(),n=(0,d.useCanvas)(),r=(0,u.getInternationalStringText)(t?.summary,``),i=(0,u.getInternationalStringText)(t?.requiredStatement?.label,``),a=(0,u.getInternationalStringText)(t?.requiredStatement?.value,``),o=(n?.behavior||[]).includes(`invert`),s=typeof n?.backgroundColor==`string`?n.backgroundColor:null;return(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`relative overflow-hidden bg-black p-4`,o?`text-white`:`text-black`),style:{height:e},children:[(0,p.jsx)(`div`,{className:`absolute inset-0`,children:(0,p.jsx)(h.LazyThumbnail,{cover:!0,fade:!1})}),(0,p.jsx)(`div`,{className:`absolute inset-0 z-10 opacity-35`,style:{background:s||`transparent`}}),(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`relative z-20 flex h-full flex-col justify-end p-3`,s?``:o?`bg-black/25 backdrop-blur-sm`:`bg-white/25 backdrop-blur-sm`),children:[(0,p.jsx)(d.LocaleString,{className:`block text-base font-semibold leading-tight`,children:t?.label}),r?(0,p.jsx)(`div`,{className:`mt-2 line-clamp-3 text-xs leading-relaxed opacity-75`,children:r}):null,a?(0,p.jsxs)(`div`,{className:`mt-3 border-t border-current/20 pt-2 text-[11px] leading-snug opacity-75`,children:[i?(0,p.jsx)(`div`,{className:`font-semibold opacity-85`,children:i}):null,(0,p.jsx)(`div`,{children:a})]}):null]})]})}function wr({height:e}){let t=(0,d.useCanvas)(),n=(0,d.useVaultSelector)((e,n)=>t?kr(n,t.annotations?.[0]):``,[t?.id,t?.annotations?.[0]?.id]);return t?(0,p.jsxs)(`div`,{className:`overflow-y-auto bg-white p-3 text-black`,style:e?{height:e}:void 0,children:[(0,p.jsx)(d.LocaleString,{className:`mb-2 block text-sm font-semibold uppercase leading-tight`,children:t.label}),(0,p.jsx)(`div`,{className:`prose prose-sm max-w-none text-xs leading-relaxed`,dangerouslySetInnerHTML:{__html:n||(0,u.getInternationalStringText)(t.summary,``)}})]}):null}function Tr(e,t){return!t||t.behavior?.includes(`info`)?!1:W(e,t).some(t=>{let n=et(e,t),r=n?.type===`SpecificResource`?n.source:n,i=Array.isArray(r?.service)?r.service:r?.service?[r.service]:[];return r?.type===`Image`||i.length>0})}function Er({annotation:e,canvas:t,onClick:n}){let{edit:r}=(0,l.useLayoutActions)(),i=H(e=>e.selectTourStep),a=H(e=>e.stopRepositioning),o=H(e=>e.stopTextRepositioning),s=U(e=>e.requestTab),c=U(e=>e.setShowTourSteps),u=U(e=>e.setCenterPanelMode),f=(0,d.useVaultSelector)((n,r)=>Or(r,e,t),[e?.id,e?.target,t?.id]),m=(0,d.useVaultSelector)((t,n)=>Dr(n,e),[e?.id,e?.body,e?.label,e?.summary]);return(0,p.jsxs)(`button`,{type:`button`,className:`flex gap-2 rounded border border-slate-200 bg-white p-1.5 text-left hover:bg-slate-50`,onClick:()=>{n(),r({id:t.id,type:`Canvas`},void 0,{selectedTab:`@exhibition/tour-steps`,forceOpen:!0}),e?.id&&i(e.id),a(),o(),c(!0),u(`edit`),s(`tour`)},children:[(0,p.jsx)(`div`,{className:`relative h-12 w-16 shrink-0 overflow-hidden rounded bg-slate-100`,children:(0,p.jsx)(h.LazyThumbnail,{cover:!0,fade:!1,region:f.region,singleImage:f.singleImage})}),(0,p.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,p.jsx)(`div`,{className:`truncate text-xs font-semibold text-slate-800`,children:m.label}),(0,p.jsx)(`div`,{className:`line-clamp-1 text-xs text-slate-500 [&_*]:m-0 [&_*]:inline`,dangerouslySetInnerHTML:{__html:m.summary}})]})]})}function Dr(e,t){let n=et(e,t);if(typeof n?.value==`string`){let{label:e,summary:r}=mr(n.value);return{label:e||(0,u.getInternationalStringText)(t.label,`Step`),summary:r}}return{label:(0,u.getInternationalStringText)(t.label,`Step`),summary:ir((0,u.getInternationalStringText)(t.summary,``))}}function Or(e,t,n){let r=t?.target,i=typeof r==`string`?null:r?.source,a=typeof i==`string`?i:i?.id||r?.id;if((typeof i==`string`?null:i?.type||r?.type)===`Annotation`&&a){let t=e.get({id:a,type:`Annotation`},{skipSelfReturn:!1});return{region:t?Ye(t,n):void 0,singleImage:!0}}let o=Ye(t,n),s=Number(n?.width)||1920,c=Number(n?.height)||1080;return{region:o.x===0&&o.y===0&&o.width===s&&o.height===c?void 0:o,singleImage:!1}}function kr(e,t){let n=t?e.get(t,{skipSelfReturn:!1}):null;for(let t of n?.items||[]){let n=e.get(t,{skipSelfReturn:!1})||t,r=Array.isArray(n?.body)?n.body:[n?.body];for(let t of r){let n=t?e.get(t,{skipSelfReturn:!1})||t:null;if(typeof n?.value==`string`&&n.value)return n.value}}return``}function Ar(e,t,n){if(t!==n)return t;let r=e.findIndex(e=>e.id===n);return r===-1?t:e[r+1]?.id||e[r-1]?.id}function jr(e){return(0,p.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,height:`1em`,width:`1em`,...e,children:[(0,p.jsx)(`title`,{children:`Rearrange`}),(0,p.jsx)(`path`,{fill:`none`,d:`M0 0h24v24H0z`}),(0,p.jsx)(`path`,{d:`M20 9H4v2h16V9zM4 15h16v-2H4v2z`,fill:`currentColor`})]})}function Mr({isFirst:e,onClick:t,item:n,actions:r,mode:i}){let{attributes:a,listeners:o,setActivatorNodeRef:s,setNodeRef:c,transform:l,transition:d}=(0,w.useSortable)({id:n.id,transition:{duration:150,easing:`cubic-bezier(0.25, 1, 0.5, 1)`}}),f={transform:T.CSS.Translate.toString(l),transition:d},m=(0,p.jsxs)(`div`,{className:`absolute right-0.5 top-0.5 z-30 flex items-stretch gap-0.5`,onClick:e=>e.stopPropagation(),children:[r?.length?(0,p.jsx)(u.AppDropdown,{as:v.Button,className:`bg-white p-1 text-2xl hover:text-me-500 aria-expanded:text-me-600 aria-expanded:bg-me-200 hover:bg-me-100 rounded-sm`,"aria-label":`Action menu`,items:r,children:(0,p.jsx)(h.MoreMenu,{})}):null,(0,p.jsx)(v.Button,{ref:s,...a,...o,"aria-label":`Reorder item`,className:`flex h-8 cursor-grab items-center rounded-sm bg-white p-1 text-2xl hover:bg-me-100 hover:text-me-500 focus:outline focus:outline-2 focus:outline-me-primary-500 active:cursor-grabbing`,children:(0,p.jsx)(jr,{"aria-hidden":`true`})})]});return i?(0,p.jsxs)(`div`,{ref:c,style:f,className:`relative`,children:[(0,p.jsx)(xr,{mode:i,onClick:t}),m]}):(0,p.jsx)(Zn,{ref:c,style:f,onClick:t,isFirst:e,item:n,children:m})}function Nr({mode:e=`grid`}){let t=(0,d.useManifest)(),{structural:n,technical:r}=(0,l.useManifestEditor)(),i=(0,l.useEditingStack)(),a=(0,u.useInStack)(`Canvas`),o=n.items.get(),{open:s}=(0,l.useLayoutActions)(),c=(0,S.useSensors)((0,S.useSensor)(S.PointerSensor,{activationConstraint:{distance:5}}),(0,S.useSensor)(S.KeyboardSensor,{coordinateGetter:w.sortableKeyboardCoordinates})),[,f]=(0,l.useCreator)({id:r.id.get(),type:`Manifest`},`items`,`Canvas`),h=(0,m.useCallback)(e=>{let{active:t,over:r}=e;r&&t.id!==r.id&&n.items.reorder(o.findIndex(e=>e.id===t.id),o.findIndex(e=>e.id===r.id))},[o,n.items]),g=a?.resource.source.id;function _(e){if(g!==e)return;let t=Ar(o,g,e);if(i.close(),t){let e=n.items.getWithoutTracking(),r=e.findIndex(e=>e.id===t),i=e[r];i&&f.edit(i,r)}}let v=o.map((r,i)=>r?(0,p.jsx)(d.CanvasContext,{canvas:r.id,children:(0,p.jsx)(Mr,{item:r,isFirst:i===0,mode:e===`grid`?void 0:e,onClick:()=>{s({id:`current-canvas`}),f.edit(r,i)},actions:(0,u.createAppActions)(n.items,()=>_(r.id))(r,i,t)})},r.id):null);return(0,p.jsx)(S.DndContext,{sensors:c,collisionDetection:S.closestCenter,onDragEnd:h,modifiers:[C.restrictToParentElement],children:(0,p.jsx)(w.SortableContext,{items:o,strategy:e===`grid`?w.rectSortingStrategy:w.verticalListSortingStrategy,children:e===`grid`?(0,p.jsx)(bt,{children:v}):(0,p.jsx)(br,{children:v})})})}function Pr(e){return e.length===0?{imageSlideBehavior:[`splash`]}:void 0}function Fr(e,t){return!!(e&&t?.[0]?.id===e.id&&e.behavior?.includes(`splash`))}function Ir(e,t){return Fr(t.get(e.resource),(e.parent?t.get(e.parent):void 0)?.items)}const Lr=Br({label:`Exhibition grid`,creatorFilter:`exhibition-slide`,previewMode:`configured`}),Rr=Br({label:`Slideshow`,creatorFilter:`exhibition-slideshow-slide`,previewMode:`slideshow`}),zr=Br({label:`Scroll`,creatorFilter:`exhibition-slide`,previewMode:`scroll`});function Br({label:e,creatorFilter:t,previewMode:n}){return{id:`canvas-listing`,label:e,icon:(0,p.jsx)(Ur,{}),render:()=>(0,p.jsx)(Vr,{creatorFilter:t,previewMode:n}),options:{minWidth:350,maxWidth:350}}}function Vr({creatorFilter:e,previewMode:t}){let{structural:n,technical:r}=(0,l.useManifestEditor)(),i=Hr(t,V()?.type),a=i===`slideshow`?`exhibition-slideshow-slide`:e,o={id:r.id.get(),type:`Manifest`},s=n.items.get()||[],c=(0,u.useInStack)(`Canvas`),d=(0,l.useEditingStack)(),f=c?.resource.source.id,m=f?s.findIndex(e=>e.id===f):-1,g=m>=0?m+1:void 0,_=i===`scroll`?Pr(s):void 0,[v,y]=(0,l.useCreator)(o,`items`,`Canvas`,void 0,{isPainting:!0}),[x,S]=(0,u.useToggleList)(),C=()=>y.createFiltered(a,g,_),w=()=>y.createFiltered(a,void 0,_),T=i===`scroll`?`section`:`slide`;return(0,p.jsxs)(h.Sidebar,{children:[(0,p.jsx)(h.SidebarHeader,{title:`Exhibition`,actions:[{icon:x.list?(0,p.jsx)(b.CanvasListingIcon,{className:`text-2xl`}):(0,p.jsx)(Ur,{}),title:x.list?`List view`:`Grid view`,onClick:()=>S(`list`)},{icon:(0,p.jsx)(Wr,{}),title:`Edit ${T}s`,toggled:x.editing,onClick:()=>S(`editing`)},{icon:(0,p.jsx)(Gr,{}),title:`Add new ${T}`,disabled:!v,onClick:C}]}),(0,p.jsxs)(h.SidebarContent,{children:[x.editing?(0,p.jsx)(Nr,{mode:i}):x.list?(0,p.jsx)(b.CanvasListView,{isEditing:x.editing,onDelete:e=>{if(f!==e)return;let t=Ar(s,f,e);if(d.close(),t){let e=n.items.getWithoutTracking(),r=e.findIndex(e=>e.id===t),i=e[r];i&&y.edit(i,r)}}}):i===`slideshow`||i===`scroll`?(0,p.jsx)(yr,{mode:i}):(0,p.jsx)(Qn,{}),(0,p.jsx)(`div`,{className:`flex justify-center p-4`,children:(0,p.jsxs)(h.ActionButton,{primary:!0,large:!0,isDisabled:!v,onPress:w,children:[`Create new `,T]})})]})]})}function Hr(e,t){return e===`configured`?t===`slideshow`||t===`scroll`?t:`grid`:e}function Ur(){return(0,p.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,fill:`currentColor`,viewBox:`0 -960 960 960`,children:[(0,p.jsx)(`title`,{children:`Exhibition grid`}),(0,p.jsx)(`path`,{d:`M600-160v-280h280v280H600ZM440-520v-280h440v280H440ZM80-160v-280h440v280H80Zm0-360v-280h280v280H80Zm440-80h280v-120H520v120ZM160-240h280v-120H160v120Zm520 0h120v-120H680v120ZM160-600h120v-120H160v120Zm360 0Zm-80 240Zm240 0ZM280-600Z`})]})}function Wr(){return(0,p.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`24`,viewBox:`0 0 24 24`,width:`24`,children:[(0,p.jsx)(`title`,{children:`Edit slides`}),(0,p.jsx)(`path`,{d:`M0 0h24v24H0V0z`,fill:`none`}),(0,p.jsx)(`path`,{d:`M14.06 9.02l.92.92L5.92 19H5v-.92l9.06-9.06M17.66 3c-.25 0-.51.1-.7.29l-1.83 1.83 3.75 3.75 1.83-1.83c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.2-.2-.45-.29-.71-.29zm-3.6 3.19L3 17.25V21h3.75L17.81 9.94l-3.75-3.75z`})]})}function Gr(){return(0,p.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,fill:`currentColor`,viewBox:`0 -960 960 960`,children:[(0,p.jsx)(`title`,{children:`Add new slide`}),(0,p.jsx)(`path`,{d:`M160-240v-480 480Zm80-80v-200h360v200H240Zm-80 160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h640q33 0 56.5 23.5T880-720v240h-80v-240H160v480h360v80H160Zm500-320v-100H360v-60h360v160h-60Zm60 400v-120H600v-80h120v-120h80v120h120v80H800v120h-80Z`})]})}const Kr={id:`@exhibitions/overview-panel`,label:`Preview`,icon:(0,p.jsx)(_t,{}),render:()=>(0,p.jsx)(qr,{})};function qr(){return(0,d.useManifest)()?(0,p.jsx)(`div`,{children:`Coming soon.`}):null}const Jr=({rotate:e=0,...t})=>(0,p.jsx)(`svg`,{version:`1.2`,xmlns:`http://www.w3.org/2000/svg`,overflow:`visible`,preserveAspectRatio:`none`,viewBox:`0 0 24 24`,width:`1em`,height:`1em`,style:{fill:`rgba(0, 0, 0, 0.6)`,transform:`rotate(${e}deg)`,transition:`transform 0.2s`},...t,children:(0,p.jsx)(`path`,{d:`M8.12 9.29 12 13.17l3.88-3.88a.996.996 0 1 1 1.41 1.41l-4.59 4.59a.996.996 0 0 1-1.41 0L6.7 10.7a.996.996 0 0 1 0-1.41c.39-.38 1.03-.39 1.42 0z`,fill:`currentColor`})}),J=(e,t,n)=>({id:e,label:t,type:`boolean`,defaultValue:n}),Yr=[{id:`exhibition-fullpage`,label:`Delft exhibition`,summary:`A guided exhibition layout with full-page scenes and focused narrative steps.`,type:`fullpage`,previewUrl:`https://preview.exhibitionviewer.org/preview/delft/full-page`,thumbnailUrl:`https://manifest-editor-docs.netlify.app/exhibition-fullpage.png`,configuration:[J(`delft.exhibition.cutCorners`,`Cut corners`,!0),J(`delft.exhibition.hideTableOfContents`,`Hide table of contents`,!1),J(`delft.exhibition.showNavigationControls`,`Show navigation controls`,!1),J(`delft.exhibition.hideTitle`,`Hide title`,!1)]},{id:`exhibition-slideshow`,label:`Slideshow`,summary:`A slide-based exhibition for linear presentations and teaching material.`,type:`slideshow`,previewUrl:`https://preview.exhibitionviewer.org/preview/delft/slideshow`,thumbnailUrl:`https://manifest-editor-docs.netlify.app/exhibition-slideshow.png`,configuration:[J(`delft.presentation.cutCorners`,`Cut corners`,!1),J(`delft.presentation.isFloating`,`Floating controls`,!1),{id:`delft.presentation.floatingPosition`,label:`Floating position`,type:`select`,defaultValue:`top-left`,options:[{label:`Top left`,value:`top-left`},{label:`Top right`,value:`top-right`},{label:`Bottom left`,value:`bottom-left`},{label:`Bottom right`,value:`bottom-right`}]},J(`delft.presentation.labelOnlyFloating`,`Only float labels`,!0)]},{id:`exhibition-scroll`,label:`Scrolling story`,summary:`A vertical reading experience for essays, object stories, and long-form interpretation.`,type:`scroll`,previewUrl:`https://preview.exhibitionviewer.org/preview/delft/scroll`,thumbnailUrl:`https://manifest-editor-docs.netlify.app/exhibition-scroll.png`,configuration:[J(`scroll.options.showTitleBlock`,`Show title block`,!0),J(`scroll.options.titleBlock.fullHeight`,`Full-height title block`,!0),J(`scroll.options.showTableOfContents`,`Show table of contents`,!1),J(`scroll.options.showProgressBar`,`Show progress bar`,!0),J(`scroll.options.showProgressTableOfContents`,`Show contents in progress bar`,!0),J(`scroll.options.showScrollToTop`,`Show scroll-to-top button`,!0),J(`scroll.options.showNavigationControls`,`Show navigation controls`,!0)]},{id:`leeds-exhibition`,label:`Leeds exhibition`,summary:`A full-page exhibition template for the Leeds University Library.`,type:`fullpage`,previewUrl:`https://preview.exhibitionviewer.org/preview/leeds/full-page`,thumbnailUrl:`https://manifest-editor-docs.netlify.app/exhibition-fullpage-leeds.png`,configuration:[]},{id:`leeds-exhibition-slideshow`,label:`Leeds exhibition slideshow`,summary:`A slideshow exhibition template for the Leeds University Library.`,type:`slideshow`,previewUrl:`https://preview.exhibitionviewer.org/preview/leeds/slideshow`,thumbnailUrl:`https://manifest-editor-docs.netlify.app/exhibition-slideshow-leeds.png`,configuration:[]},{id:`leeds-exhibition-scroll`,label:`Leeds exhibition scroll`,summary:`A scroll exhibition template for the Leeds University Library.`,type:`scroll`,previewUrl:`https://preview.exhibitionviewer.org/preview/leeds/scroll`,thumbnailUrl:`https://manifest-editor-docs.netlify.app/exhibition-scroll-leeds.png`,configuration:[]}];function Xr(e,t){let n=e;for(let e of t.split(`.`))n=n?.[e];return n}function Zr(e,t,n){var r;let i=structuredClone(e),a=t.split(`.`),o=i;for(let e of a.slice(0,-1))o=(r=o)[e]||(r[e]={});return o[a.at(-1)]=n,i}const Qr={id:`@exhibitions/theme-panel`,label:`Preview`,icon:(0,p.jsx)(_t,{}),render:()=>(0,p.jsx)($r,{}),options:{minWidth:360,maxWidth:440}};function $r(){let e=(0,d.useManifest)(),t=(0,d.useVault)(),n=V(),r=(0,l.useOpenPresetOnboarding)(),i=e?.service||[],a=e?.services||[],o=ke(i)||ke(a),s=n?.configuration||[],c=o?.service?.theme||{},u=s.reduce((e,t)=>Zr(e,t.id,Xr(c,t.id)??t.defaultValue??ei(t)),{});if(!e||!n)return null;let f=n=>{let r=n?{id:`${e.id}#exhibition-viewer-theme`,type:`Service`,profile:le,label:ue,theme:n}:null,o={id:e.id,type:`Manifest`};t.batch(t=>{t.modifyEntityField(o,`service`,je(i,r)),(e.services||ke(a))&&t.modifyEntityField(o,`services`,je(a,null))})};return(0,p.jsx)(h.Sidebar,{children:(0,p.jsxs)(h.SidebarContent,{padding:!0,children:[(0,p.jsxs)(Y,{title:n.label,description:n.summary,children:[(0,p.jsx)(`img`,{src:n.thumbnailUrl,alt:``,className:`aspect-video w-full rounded border border-slate-200 object-cover`}),(0,p.jsx)(v.Button,{className:`rounded border border-slate-300 px-3 py-2 text-sm hover:bg-slate-50`,onPress:r,children:`Change template`})]}),(0,p.jsxs)(Y,{title:`Preview configuration`,description:`These settings are defined by the selected template and stored as a service on the Manifest.`,children:[s.map(e=>(0,p.jsx)(ti,{field:e,value:Xr(c,e.id)??e.defaultValue??ei(e),onChange:t=>f(Zr(u,e.id,t))},e.id)),s.length?null:(0,p.jsx)(`p`,{className:`text-sm text-slate-500`,children:`This template has no configurable settings.`}),o?(0,p.jsx)(v.Button,{className:`rounded border border-slate-300 px-3 py-2 text-sm hover:bg-slate-50`,onPress:()=>f(null),children:`Remove preview service`}):(0,p.jsx)(v.Button,{className:`rounded bg-me-primary-600 px-3 py-2 text-sm text-white hover:bg-me-primary-700`,onPress:()=>f(u),children:`Add preview service`})]}),(0,p.jsx)(li,{})]})})}function ei(e){return e.type===`boolean`?!1:e.type===`number`?0:``}function ti({field:e,value:t,onChange:n}){return e.type===`boolean`?(0,p.jsx)(X,{label:e.label,checked:!!t,onChange:n}):e.type===`select`?(0,p.jsx)(ii,{label:e.label,value:String(t),onChange:n,options:(e.options||[]).map(e=>({label:e.label,value:String(e.value)}))}):(0,p.jsxs)(u.InputContainer,{$wide:!0,children:[(0,p.jsx)(u.InputLabel,{children:e.label}),e.type===`textarea`?(0,p.jsx)(`textarea`,{"aria-label":e.label,className:`w-full rounded border border-slate-300 bg-slate-50 px-3 py-2 text-sm`,value:String(t),onChange:e=>n(e.target.value)}):(0,p.jsx)(u.Input,{"aria-label":e.label,type:e.type===`number`?`number`:`text`,value:String(t),onChange:t=>n(e.type===`number`?t.target.valueAsNumber:t.target.value)})]})}function Y({title:e,description:t,children:n,collapsible:r=!1}){let[i,a]=(0,m.useState)(!0);return r?(0,p.jsxs)(`section`,{className:`mb-3 rounded-md border border-slate-200 bg-white last:mb-0`,children:[(0,p.jsxs)(v.Button,{className:`flex w-full items-center justify-between gap-3 px-3 py-3 text-left hover:bg-slate-50`,"aria-expanded":i,onPress:()=>a(e=>!e),children:[(0,p.jsxs)(`span`,{className:`min-w-0`,children:[(0,p.jsx)(`span`,{className:`block text-sm font-semibold`,children:e}),t?(0,p.jsx)(`span`,{className:`mt-1 block text-xs text-slate-500`,children:t}):null]}),(0,p.jsx)(Jr,{className:`shrink-0 text-base text-slate-500`,rotate:i?0:-90,"aria-hidden":!0})]}),i&&n?(0,p.jsx)(`div`,{className:`space-y-3 border-t border-slate-200 px-3 py-3`,children:n}):null]}):(0,p.jsxs)(`section`,{className:`mb-5 border-b border-slate-200 pb-5 last:mb-0 last:border-b-0`,children:[(0,p.jsxs)(`div`,{className:`mb-3`,children:[(0,p.jsx)(`h3`,{className:`text-sm font-semibold`,children:e}),t?(0,p.jsx)(`p`,{className:`mt-1 text-xs text-slate-500`,children:t}):null]}),n?(0,p.jsx)(`div`,{className:`space-y-3`,children:n}):null]})}function ni({label:e,value:t,onChange:n,options:r}){return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`mb-2 text-xs font-medium text-slate-500`,children:e}),(0,p.jsx)(`div`,{className:`flex flex-wrap gap-1 rounded-md border border-slate-200 bg-slate-100 p-1`,children:r.map(e=>{let r=e.value===t;return(0,p.jsx)(v.Button,{className:[`rounded px-2 py-1.5 text-sm transition-colors`,r?`bg-white font-semibold text-slate-950 shadow-sm`:`text-slate-600 hover:bg-white/70 hover:text-slate-900`].join(` `),"aria-pressed":r,onPress:()=>n(e.value),children:e.label},e.value)})})]})}function X({label:e,checked:t,disabled:n=!1,onChange:r}){return(0,p.jsxs)(`label`,{className:`flex items-center gap-3 text-sm ${n?`opacity-50`:``}`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:t,disabled:n,onChange:e=>r(e.target.checked)}),(0,p.jsx)(`span`,{children:e})]})}function Z({label:e,value:t,onChange:n}){return(0,p.jsxs)(`div`,{className:`items-center`,style:{display:`grid`,gap:`0.5rem`,gridTemplateColumns:`minmax(0, 1fr) 3rem 100px`},children:[(0,p.jsx)(`label`,{className:`min-w-0 truncate whitespace-nowrap text-sm`,children:e}),(0,p.jsx)(`input`,{"aria-label":`${e} colour picker`,className:`h-9 w-12 shrink-0 cursor-pointer rounded border border-slate-300 bg-white p-1`,type:`color`,value:ai(t),onChange:e=>n(e.target.value)}),(0,p.jsx)(`div`,{className:`min-w-0`,children:(0,p.jsx)(u.Input,{"aria-label":`${e} colour value`,style:{width:`100%`},value:t,onChange:e=>n(e.target.value)})})]})}function ri({label:e,value:t,onChange:n}){return(0,p.jsxs)(u.InputContainer,{$wide:!0,children:[(0,p.jsx)(u.InputLabel,{children:e}),(0,p.jsx)(u.Input,{"aria-label":e,value:t,onChange:e=>n(e.target.value)})]})}function ii({label:e,value:t,disabled:n=!1,onChange:r,options:i}){return(0,p.jsxs)(u.InputContainer,{$wide:!0,children:[(0,p.jsx)(u.InputLabel,{children:e}),(0,p.jsx)(`select`,{"aria-label":e,className:`w-full rounded border border-slate-300 bg-slate-50 px-3 py-2 text-sm disabled:cursor-not-allowed disabled:opacity-50`,value:t,disabled:n,onChange:e=>r(e.target.value),children:i.map(e=>(0,p.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})}function ai(e){let t=e.trim();if(/^#[0-9a-fA-F]{6}$/.test(t))return t;if(/^#[0-9a-fA-F]{3}$/.test(t)){let[e,n,r]=t.slice(1);return`#${e}${e}${n}${n}${r}${r}`}return`#ffffff`}function oi(e){return JSON.parse(JSON.stringify(e))}function si(e,t,n){let r=oi(e),i=r;for(let e of t.slice(0,-1)){var a;(a=i)[e]||(a[e]={}),i=i[e]}let o=t[t.length-1];return o&&(i[o]=n),r}function ci(e,t){let n=oi(e);for(let e of t){let t=n;for(let n of e.path.slice(0,-1)){var r;(r=t)[n]||(r[n]={}),t=t[n]}let i=e.path[e.path.length-1];i&&(t[i]=e.value)}return n}function li(){let e=(0,d.useManifest)(),t=(0,d.useVault)(),n=gt(),[r,i]=(0,m.useState)(`simple`),a=n===`scroll`?`scroll`:n===`slideshow`?`slideshow`:`presentation`,o=e?.service||[],s=e?.services||[],c=(0,m.useMemo)(()=>{let e=ke(o);if(e)return{service:e.service};let t=ke(s);return t?{service:t.service}:null},[o,s]),l=(0,m.useMemo)(()=>c?Ee(c.service.theme):null,[c])||Te(`delft`);if(!e)return null;let u=n=>{let r=n?Oe(e.id,n):null,i=je(o,r),a=je(s,null),c={id:e.id,type:`Manifest`};t.batch(t=>{t.modifyEntityField(c,`service`,i),(e.services||a.length!==s.length)&&t.modifyEntityField(c,`services`,a)})},f=(e,t)=>{u(si(l,e,t))},h=e=>{u(ci(l,e))},g=e=>{let t=[{path:[`delft`,`tokens`,`backgroundPrimary`],value:e},{path:[`delft`,`tokens`,`backgroundSecondary`],value:e},{path:[`delft`,`tokens`,`backgroundOverlay`],value:e},{path:[`delft`,`tokens`,`controlBar`],value:e},{path:[`delft`,`tokens`,`controlBarBorder`],value:e},{path:[`delft`,`tokens`,`closeBackground`],value:e},{path:[`delft`,`tokens`,`closeBackgroundHover`],value:e},{path:[`delft`,`tokens`,`infoBlock`],value:e},{path:[`delft`,`tokens`,`viewerBackground`],value:e}],n=a===`presentation`?[{path:[`delft`,`tokens`,`titleCard`],value:e}]:[];if(a===`scroll`){h([...t,{path:[`scroll`,`tokens`,`titleBackground`],value:e},{path:[`scroll`,`tokens`,`annotationBackground`],value:e},{path:[`scroll`,`tokens`,`infoBlockBackground`],value:e}]);return}h([...t,...n])},_=e=>{let t=[{path:[`delft`,`tokens`,`textPrimary`],value:e},{path:[`delft`,`tokens`,`textSecondary`],value:e},{path:[`delft`,`tokens`,`imageCaption`],value:e},{path:[`delft`,`tokens`,`closeText`],value:e},{path:[`delft`,`tokens`,`infoBlockText`],value:e}],n=a===`presentation`?[{path:[`delft`,`tokens`,`titleCardText`],value:e}]:[];if(a===`scroll`){h([...t,{path:[`scroll`,`tokens`,`titleColor`],value:e},{path:[`scroll`,`tokens`,`annotationColor`],value:e},{path:[`scroll`,`tokens`,`infoBlockColor`],value:e}]);return}h([...t,...n])},y=e=>{if(a===`scroll`){f([`scroll`,`options`,`showTableOfContents`],e);return}f([`delft`,`exhibition`,`hideTableOfContents`],!e)},b=e=>{if(a===`scroll`){f([`scroll`,`options`,`tableOfContentsPlacement`],e);return}f([`delft`,`exhibition`,`tableOfContentsPlacement`],e)},x=e=>{f(a===`slideshow`?[`delft`,`slideshow`,`alternativeImageMode`]:[`delft`,`exhibition`,`alternativeImageMode`],e===`alternative`)},S=e=>{f(a===`slideshow`?[`delft`,`slideshow`,`coverImages`]:[`delft`,`exhibition`,`coverImages`],e)},C=a===`scroll`?l.scroll.options.showTableOfContents:!l.delft.exhibition.hideTableOfContents,w=a===`scroll`?l.scroll.options.tableOfContentsPlacement:l.delft.exhibition.tableOfContentsPlacement,T=(a===`slideshow`?l.delft.slideshow.alternativeImageMode:l.delft.exhibition.alternativeImageMode)?`alternative`:`default`,E=a===`slideshow`?l.delft.slideshow.coverImages:l.delft.exhibition.coverImages,D=a===`scroll`?l.scroll.options.showProgressBar:l.delft.exhibition.showProgressBar;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(Y,{title:`Saved Theme`,description:`Save custom exhibition styling and viewer defaults on the Manifest.`,children:[(0,p.jsx)(X,{label:`Save custom theme`,checked:!!c,onChange:e=>{if(!e){u(null);return}u(Te(`delft`))}}),(0,p.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,p.jsx)(v.Button,{className:`rounded border border-slate-300 px-3 py-2 text-sm hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50`,onPress:()=>{u(Te(l.preset))},isDisabled:!c,children:`Reset selected theme`}),(0,p.jsx)(v.Button,{className:`rounded border border-slate-300 px-3 py-2 text-sm hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50`,onPress:()=>u(null),isDisabled:!c,children:`Clear saved settings`})]}),(0,p.jsx)(ni,{label:`Preset`,value:l.preset,onChange:e=>{u(Te(e))},options:[{label:`Delft`,value:`delft`},{label:`Gallery`,value:`gallery`},{label:`Minimal`,value:`minimal`}]})]}),(0,p.jsx)(Y,{title:`Theme Options`,description:`Choose a shorter or more detailed set of theme controls.`,children:(0,p.jsx)(ni,{label:`Editing mode`,value:r,onChange:i,options:[{label:`Simple`,value:`simple`},{label:`Advanced`,value:`advanced`}]})}),r===`simple`?(0,p.jsxs)(Y,{title:`Key Settings`,description:a===`scroll`?`Main background updates the opening title, annotation cards, info blocks, and viewer background.`:`The main controls most people need for this theme.`,children:[(0,p.jsx)(Z,{label:`Main background`,value:a===`scroll`?l.scroll.tokens.titleBackground:l.delft.tokens.viewerBackground,onChange:g}),(0,p.jsx)(Z,{label:`Text colour`,value:a===`scroll`?l.scroll.tokens.titleColor:l.delft.tokens.textSecondary,onChange:_}),(0,p.jsx)(ri,{label:`Heading font`,value:l.shared.fontSans,onChange:e=>f([`shared`,`fontSans`],e)}),(0,p.jsx)(ri,{label:`Body font`,value:l.shared.fontMono,onChange:e=>f([`shared`,`fontMono`],e)}),a===`scroll`?null:(0,p.jsx)(ii,{label:`Title capitalisation`,value:l.shared.titleTransform,onChange:e=>f([`shared`,`titleTransform`],e),options:[{label:`Uppercase`,value:`uppercase`},{label:`None`,value:`none`},{label:`Capitalize`,value:`capitalize`}]}),a===`presentation`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(X,{label:`Table of Contents bar`,checked:C,onChange:y}),(0,p.jsx)(X,{label:`Full-width title bar`,checked:l.delft.exhibition.fullTitleBar,onChange:e=>f([`delft`,`exhibition`,`fullTitleBar`],e)}),(0,p.jsx)(ii,{label:`Image layout`,value:T,onChange:x,options:[{label:`Standard`,value:`default`},{label:`Feature image`,value:`alternative`}]}),(0,p.jsx)(X,{label:`Fill image area`,checked:E,onChange:S})]}):null,a===`slideshow`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(ii,{label:`Image layout`,value:T,onChange:x,options:[{label:`Standard`,value:`default`},{label:`Feature image`,value:`alternative`}]}),(0,p.jsx)(X,{label:`Fill image area`,checked:E,onChange:S}),(0,p.jsx)(X,{label:`Zoom effect`,checked:l.delft.slideshow.transitionScale,onChange:e=>f([`delft`,`slideshow`,`transitionScale`],e)})]}):null,a===`scroll`?(0,p.jsx)(p.Fragment,{children:(0,p.jsx)(X,{label:`Full-height title`,checked:l.scroll.options.titleBlock.fullHeight,onChange:e=>f([`scroll`,`options`,`titleBlock`,`fullHeight`],e)})}):null]}):(0,p.jsxs)(p.Fragment,{children:[a===`presentation`?(0,p.jsxs)(Y,{title:`Opening Title`,collapsible:!0,children:[(0,p.jsx)(Z,{label:`Card background`,value:l.delft.tokens.titleCard,onChange:e=>f([`delft`,`tokens`,`titleCard`],e)}),(0,p.jsx)(Z,{label:`Card text`,value:l.delft.tokens.titleCardText,onChange:e=>f([`delft`,`tokens`,`titleCardText`],e)}),(0,p.jsx)(X,{label:`Hide title`,checked:l.delft.exhibition.hideTitle,onChange:e=>f([`delft`,`exhibition`,`hideTitle`],e)}),(0,p.jsx)(X,{label:`Hide title card`,checked:l.delft.exhibition.hideTitleCard,onChange:e=>f([`delft`,`exhibition`,`hideTitleCard`],e)})]}):null,a===`scroll`?(0,p.jsxs)(Y,{title:`Opening Title`,collapsible:!0,children:[(0,p.jsx)(X,{label:`Show opening title`,checked:l.scroll.options.showTitleBlock,onChange:e=>f([`scroll`,`options`,`showTitleBlock`],e)}),(0,p.jsx)(X,{label:`Show table of contents`,checked:C,onChange:y}),(0,p.jsx)(Z,{label:`Background`,value:l.scroll.tokens.titleBackground,onChange:e=>f([`scroll`,`tokens`,`titleBackground`],e)}),(0,p.jsx)(Z,{label:`Text`,value:l.scroll.tokens.titleColor,onChange:e=>f([`scroll`,`tokens`,`titleColor`],e)}),(0,p.jsx)(X,{label:`Full-height title`,checked:l.scroll.options.titleBlock.fullHeight,onChange:e=>f([`scroll`,`options`,`titleBlock`,`fullHeight`],e)})]}):null,(0,p.jsxs)(Y,{title:`Page & Viewer`,description:a===`scroll`?`Shared backgrounds around the Scroll view. Opening title, annotation, and info block colours are controlled below.`:void 0,collapsible:!0,children:[(0,p.jsx)(Z,{label:`Viewer background`,value:l.delft.tokens.viewerBackground,onChange:e=>f([`delft`,`tokens`,`viewerBackground`],e)}),(0,p.jsx)(Z,{label:`Main`,value:l.delft.tokens.backgroundPrimary,onChange:e=>f([`delft`,`tokens`,`backgroundPrimary`],e)}),(0,p.jsx)(Z,{label:`Secondary`,value:l.delft.tokens.backgroundSecondary,onChange:e=>f([`delft`,`tokens`,`backgroundSecondary`],e)}),(0,p.jsx)(Z,{label:`Overlay`,value:l.delft.tokens.backgroundOverlay,onChange:e=>f([`delft`,`tokens`,`backgroundOverlay`],e)}),a===`scroll`?(0,p.jsx)(X,{label:`Use theme background instead of canvas colours`,checked:l.scroll.options.ignoreCanvasBackgrounds,onChange:e=>f([`scroll`,`options`,`ignoreCanvasBackgrounds`],e)}):null]}),a===`scroll`?null:(0,p.jsxs)(Y,{title:`Text Colours`,description:`General fallback text colours. Captions, info blocks, and controls have their own options below.`,collapsible:!0,children:[(0,p.jsx)(Z,{label:`Dark text`,value:l.delft.tokens.textPrimary,onChange:e=>f([`delft`,`tokens`,`textPrimary`],e)}),(0,p.jsx)(Z,{label:`Light text`,value:l.delft.tokens.textSecondary,onChange:e=>f([`delft`,`tokens`,`textSecondary`],e)})]}),(0,p.jsx)(Y,{title:`Info Blocks`,collapsible:!0,children:a===`scroll`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Z,{label:`Background`,value:l.scroll.tokens.infoBlockBackground,onChange:e=>f([`scroll`,`tokens`,`infoBlockBackground`],e)}),(0,p.jsx)(Z,{label:`Text`,value:l.scroll.tokens.infoBlockColor,onChange:e=>f([`scroll`,`tokens`,`infoBlockColor`],e)})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Z,{label:`Background`,value:l.delft.tokens.infoBlock,onChange:e=>f([`delft`,`tokens`,`infoBlock`],e)}),(0,p.jsx)(Z,{label:`Text`,value:l.delft.tokens.infoBlockText,onChange:e=>f([`delft`,`tokens`,`infoBlockText`],e)})]})}),(0,p.jsxs)(Y,{title:`Images & Annotations`,collapsible:!0,children:[a===`scroll`?null:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Z,{label:`Image caption`,value:l.delft.tokens.imageCaption,onChange:e=>f([`delft`,`tokens`,`imageCaption`],e)}),(0,p.jsx)(Z,{label:`Selected hotspot`,value:l.delft.tokens.annotationSelected,onChange:e=>f([`delft`,`tokens`,`annotationSelected`],e)}),(0,p.jsx)(ii,{label:`Image layout`,value:T,onChange:x,options:[{label:`Standard`,value:`default`},{label:`Feature image`,value:`alternative`}]}),(0,p.jsx)(X,{label:`Info button`,checked:a===`slideshow`?l.delft.slideshow.imageInfoIcon:l.delft.exhibition.imageInfoIcon,onChange:e=>f(a===`slideshow`?[`delft`,`slideshow`,`imageInfoIcon`]:[`delft`,`exhibition`,`imageInfoIcon`],e)}),(0,p.jsx)(X,{label:`Fill image area`,checked:E,onChange:S}),(0,p.jsx)(X,{label:`Use theme background instead of canvas colours`,checked:a===`slideshow`?l.delft.slideshow.ignoreCanvasBackgrounds:l.delft.exhibition.ignoreCanvasBackgrounds,onChange:e=>f(a===`slideshow`?[`delft`,`slideshow`,`ignoreCanvasBackgrounds`]:[`delft`,`exhibition`,`ignoreCanvasBackgrounds`],e)})]}),a===`scroll`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Z,{label:`Annotation background`,value:l.scroll.tokens.annotationBackground,onChange:e=>f([`scroll`,`tokens`,`annotationBackground`],e)}),(0,p.jsx)(Z,{label:`Annotation text`,value:l.scroll.tokens.annotationColor,onChange:e=>f([`scroll`,`tokens`,`annotationColor`],e)}),(0,p.jsx)(ri,{label:`Corner radius`,value:l.scroll.tokens.annotationRadius,onChange:e=>f([`scroll`,`tokens`,`annotationRadius`],e)}),(0,p.jsx)(ri,{label:`Max width`,value:l.scroll.tokens.annotationMaxWidth,onChange:e=>f([`scroll`,`tokens`,`annotationMaxWidth`],e)})]}):null]}),(0,p.jsxs)(Y,{title:`Navigation & Controls`,description:a===`scroll`?`Scroll contents navigation, placement, dropdown text, and progress colours.`:a===`slideshow`?`Slideshow controls, progress, and overlay buttons. Contents controls only apply to Full page and Scroll.`:`Contents, viewer controls, progress, and overlay buttons.`,collapsible:!0,children:[a===`presentation`||a===`scroll`?(0,p.jsx)(X,{label:`Progress bar`,checked:D,onChange:e=>f(a===`scroll`?[`scroll`,`options`,`showProgressBar`]:[`delft`,`exhibition`,`showProgressBar`],e)}):null,a===`presentation`||a===`scroll`?(0,p.jsx)(X,{label:`Previous/next side controls`,checked:a===`scroll`?l.scroll.options.showNavigationControls:l.delft.exhibition.showNavigationControls,onChange:e=>f(a===`scroll`?[`scroll`,`options`,`showNavigationControls`]:[`delft`,`exhibition`,`showNavigationControls`],e)}):null,a===`presentation`?(0,p.jsx)(X,{label:`Table of Contents bar`,checked:C,onChange:y}):null,a===`presentation`||a===`scroll`?(0,p.jsx)(ii,{label:`Contents position`,value:w,disabled:!C,onChange:b,options:[{label:`Header`,value:`header`},{label:`Footer`,value:`footer`}]}):null,a===`scroll`?(0,p.jsx)(X,{label:`Back to top button`,checked:l.scroll.options.showScrollToTop,onChange:e=>f([`scroll`,`options`,`showScrollToTop`],e)}):null,(0,p.jsx)(Z,{label:`Navigation bar background`,value:l.delft.tokens.controlBar,onChange:e=>h([{path:[`delft`,`tokens`,`controlBar`],value:e},{path:[`delft`,`tokens`,`controlBarBorder`],value:e}])}),(0,p.jsx)(Z,{label:`Navigation text colour`,value:l.delft.tokens.closeText,onChange:e=>f([`delft`,`tokens`,`closeText`],e)}),(0,p.jsx)(Z,{label:`Progress bar colour`,value:l.delft.tokens.progressBar,onChange:e=>f([`delft`,`tokens`,`progressBar`],e)}),a===`scroll`?(0,p.jsx)(Z,{label:`Back to top button background`,value:l.delft.tokens.closeBackground,onChange:e=>f([`delft`,`tokens`,`closeBackground`],e)}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Z,{label:`Close button background`,value:l.delft.tokens.closeBackground,onChange:e=>f([`delft`,`tokens`,`closeBackground`],e)}),(0,p.jsx)(Z,{label:`Close button hover`,value:l.delft.tokens.closeBackgroundHover,onChange:e=>f([`delft`,`tokens`,`closeBackgroundHover`],e)})]})]}),a===`presentation`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(Y,{title:`Display & Layout`,collapsible:!0,children:[(0,p.jsx)(X,{label:`Angled corners`,checked:l.delft.exhibition.cutCorners,onChange:e=>f([`delft`,`exhibition`,`cutCorners`],e)}),(0,p.jsx)(X,{label:`Full-width title bar`,checked:l.delft.exhibition.fullTitleBar,onChange:e=>f([`delft`,`exhibition`,`fullTitleBar`],e)}),(0,p.jsx)(X,{label:`Full-width item grid`,checked:l.delft.exhibition.fullWidthGrid,onChange:e=>f([`delft`,`exhibition`,`fullWidthGrid`],e)}),(0,p.jsx)(X,{label:`Use theme background instead of canvas colours`,checked:l.delft.exhibition.ignoreCanvasBackgrounds,onChange:e=>f([`delft`,`exhibition`,`ignoreCanvasBackgrounds`],e)})]}),(0,p.jsxs)(Y,{title:`Interaction Behaviour`,collapsible:!0,children:[(0,p.jsx)(ii,{label:`Presentation mode`,value:l.delft.exhibition.disablePresentation?`disabled`:`available`,onChange:e=>f([`delft`,`exhibition`,`disablePresentation`],e===`disabled`),options:[{label:`Available`,value:`available`},{label:`Disabled`,value:`disabled`}]}),(0,p.jsx)(X,{label:`Zoom effect`,checked:l.delft.exhibition.transitionScale,onChange:e=>f([`delft`,`exhibition`,`transitionScale`],e)}),(0,p.jsx)(X,{label:`Floating panels`,checked:l.delft.presentation.isFloating,onChange:e=>f([`delft`,`presentation`,`isFloating`],e)}),l.delft.presentation.isFloating?(0,p.jsx)(X,{label:`Label-only floating`,checked:l.delft.presentation.labelOnlyFloating,onChange:e=>f([`delft`,`presentation`,`labelOnlyFloating`],e)}):null,l.delft.presentation.isFloating?(0,p.jsx)(ii,{label:`Panel position`,value:l.delft.presentation.floatingPosition,onChange:e=>f([`delft`,`presentation`,`floatingPosition`],e),options:[{label:`Top left`,value:`top-left`},{label:`Top right`,value:`top-right`},{label:`Bottom left`,value:`bottom-left`},{label:`Bottom right`,value:`bottom-right`},{label:`Top`,value:`top`},{label:`Bottom`,value:`bottom`},{label:`Left`,value:`left`},{label:`Right`,value:`right`}]}):null,(0,p.jsx)(X,{label:`Angled panel corners`,checked:l.delft.presentation.cutCorners,onChange:e=>f([`delft`,`presentation`,`cutCorners`],e)}),(0,p.jsx)(X,{label:`Use theme background instead of canvas colours`,checked:l.delft.presentation.ignoreCanvasBackgrounds,onChange:e=>f([`delft`,`presentation`,`ignoreCanvasBackgrounds`],e)})]})]}):null,a===`slideshow`?(0,p.jsx)(Y,{title:`Interaction Behaviour`,collapsible:!0,children:(0,p.jsx)(X,{label:`Zoom effect`,checked:l.delft.slideshow.transitionScale,onChange:e=>f([`delft`,`slideshow`,`transitionScale`],e)})}):null]})]})}function ui(e){return e===`left-panel-manifest`||e===Lr.id}const di={id:`exhibition-background-task`,label:`Query string`,render:()=>(0,p.jsx)(fi,{})};function fi(){let{metadata:e}=(0,l.useApp)(),t=V(),n=(0,d.useManifest)(),r=(0,u.useInStack)(`Canvas`)?.resource.source.id,i=(0,d.useVault)(),a=n?.id;(0,m.useEffect)(()=>{if(!a)return;let e=i.getState().iiif.entities.Canvas;return i.subscribe(()=>{let t=i.getState().iiif.entities.Canvas;if(t===e)return;let n=e;e=t;for(let e of i.get({id:a,type:`Manifest`})?.items||[]){let r=t[e.id],a=n[e.id];if(!r||!a||a.width===r.width&&a.height===r.height||r.behavior?.includes(`info`)||JSON.stringify(a.behavior)!==JSON.stringify(r.behavior))continue;let o=ce(r.behavior||[],r.width,r.height);JSON.stringify(o)!==JSON.stringify(r.behavior)&&i.modifyEntityField(e,`behavior`,o)}})},[i,a]);let{leftPanel:o,rightPanel:s}=(0,l.useLayoutState)(),{edit:c,centerPanel:f,rightPanel:p}=(0,l.useLayoutActions)(),[h,g]=(0,m.useState)(!1),_=(0,m.useRef)(null),v=(0,m.useRef)(null);return(0,m.useEffect)(()=>{(e.id===`exhibition-slideshow-editor`||t?.type===`slideshow`)&&r&&f.open({id:`current-canvas`})},[e.id,t?.type,r,f]),(0,m.useEffect)(()=>{let e=n?.id||null,t=_.current!==o.current,r=v.current!==e,i=_.current;if(_.current=o.current,v.current=e,!(!n||!t&&!r)){if(o.current===Kr.id){c(n),f.open({id:Ne.id}),g(!1);return}if(o.current===Qr.id){c(n),s.open?(p.close(),g(!0)):g(!1),f.open({id:vt.id});return}!s.open&&s.current&&ui(o.current)&&(i===null||i===Qr.id&&h)&&(p.open(),g(!1))}},[f,c,o.current,n?.id,s.current,s.open,p,h]),null}const pi={id:`image-block-editor`,label:`Exhibition canvas editor`,component:e=>(0,p.jsx)(mi,{strategy:e}),supports:{strategy:(e,t,n)=>e.type!==`images`&&e.type!==`empty`?!1:n.get(t.resource)?.type===`Canvas`}};function mi({strategy:e}){let t=U(e=>e.centerPanelMode),n=U(e=>e.setCenterPanelMode),r=gt(),i=(0,u.useInStack)(`Canvas`),a=i?.resource.source?.id,o=(0,d.useVaultSelector)((e,t)=>{if(!a)return!1;let n=t.get({id:a,type:`Canvas`});return!!(0,E.getCanvasLayout)(t,a)&&!(0,E.getPaintingAnnotations)(t,n).length},[a]);return(0,m.useEffect)(()=>{o&&n(`edit`)},[a,o,n]),i?(0,p.jsx)(d.CanvasContext,{canvas:i.resource.source?.id,children:(0,p.jsx)(hi,{isPreview:t===`preview`,previewPreset:r,onModeChange:e=>{n(e?`preview`:`edit`)}})}):null}function hi({isPreview:e,previewPreset:t,onModeChange:n}){let r=(0,d.useCanvas)();return(0,p.jsxs)(`div`,{className:`relative z-0 flex h-full min-h-0 w-full min-w-0 max-w-full flex-col overflow-hidden bg-white`,children:[(0,p.jsxs)(`div`,{className:`exhibition-slideshow-current-toolbar flex items-center gap-3 border-b border-slate-200 bg-white px-4 py-3 shadow-sm`,children:[(0,p.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,p.jsx)(d.LocaleString,{className:`block truncate text-sm font-semibold text-slate-800`,children:r?.label})}),(0,p.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,p.jsxs)(`div`,{className:`flex shrink-0 overflow-hidden rounded-md border border-slate-200 bg-slate-50 text-xs font-semibold`,children:[(0,p.jsx)(gi,{selected:!e,onPress:()=>n(!1),children:`Edit`}),(0,p.jsx)(gi,{selected:e,onPress:()=>n(!0),children:`Preview`})]})})]}),e?(0,p.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,p.jsx)(ft,{preset:t})}):(0,p.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,p.jsx)(u.CanvasPanelEditor,{enableAddMedia:!0,asFallback:!0,moveMode:!0})})]})}function gi({children:e,selected:t,onPress:n}){return(0,p.jsx)(v.Button,{className:(0,y.twMerge)(`px-3 py-2 text-xs font-semibold transition`,t?`bg-me-primary-500 text-white shadow-sm`:`text-slate-500 hover:text-slate-700`),onPress:n,children:e})}const _i={id:`info-block-editor`,label:`info Block Editor`,component:e=>(0,p.jsx)(xi,{strategy:e}),supports:{strategy:(e,t,n)=>e.type===`textual-content`}};function vi(e){if(e===`@none`||e===`none`)return null;try{let t=new Intl.DisplayNames([e],{type:`language`});return e===`cy`?{key:e,language:e,label:`Cymraeg`}:{key:e,language:e,label:t.of(e)}}catch{return{key:e,language:e,label:e}}}function yi({selectedLanguage:e,languages:t,availableLanguages:n,onSelectLanguage:r,onAddLanguage:i}){let[a,o]=(0,m.useState)(!1),s=(0,m.useRef)(null);(0,m.useEffect)(()=>{if(!a)return;let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]);let c=n.filter(e=>!t.includes(e)),l=vi(e);return(0,p.jsxs)(`div`,{ref:s,className:`relative`,children:[(0,p.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 rounded-md border border-slate-200 bg-white px-3 py-2 text-xs font-semibold text-slate-700 shadow-sm transition hover:bg-slate-50`,onClick:()=>o(e=>!e),children:[(0,p.jsx)(`span`,{className:``,children:l?.label||e}),(0,p.jsx)(`svg`,{className:`h-3 w-3 text-slate-400`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:2,children:(0,p.jsx)(`path`,{d:`M2 4l4 4 4-4`})})]}),a&&(0,p.jsxs)(`div`,{className:`absolute right-0 top-full z-50 mt-1 min-w-[14rem] rounded-md border border-slate-200 bg-white py-1 shadow-lg`,children:[t.length>0&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`px-3 py-1 text-[10px] font-semibold uppercase tracking-wider text-slate-400`,children:`Language`}),t.map(t=>{let n=vi(t);return(0,p.jsxs)(`button`,{type:`button`,className:(0,y.twMerge)(`flex w-full items-center gap-2 px-3 py-1.5 text-xs hover:bg-slate-50`,t===e?`font-semibold text-slate-900`:`text-slate-600`),onClick:()=>{r(t),o(!1)},children:[t===e?(0,p.jsx)(`svg`,{className:`h-3 w-3 shrink-0 text-slate-500`,viewBox:`0 0 12 12`,fill:`currentColor`,children:(0,p.jsx)(`path`,{d:`M2 6l3 3 5-5`,stroke:`currentColor`,strokeWidth:2,fill:`none`})}):(0,p.jsx)(`div`,{className:`h-3 w-3 shrink-0 text-slate-500`}),(0,p.jsx)(`span`,{children:n?.label||t})]},t)})]}),c.length>0&&(0,p.jsxs)(p.Fragment,{children:[t.length>0&&(0,p.jsx)(`div`,{className:`my-1 border-t border-slate-100`}),(0,p.jsx)(`div`,{className:`px-3 py-1 text-[10px] font-semibold uppercase tracking-wider text-slate-400`,children:`Add language`}),c.map(e=>{let t=vi(e);return(0,p.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-1.5 text-xs text-slate-600 hover:bg-slate-50`,onClick:()=>{i(e),o(!1)},children:[(0,p.jsx)(`svg`,{className:`h-3 w-3 shrink-0 text-slate-400`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:2,children:(0,p.jsx)(`path`,{d:`M6 2v8M2 6h8`})}),t?.label||e]},e)})]}),c.length===0&&t.length===0&&(0,p.jsx)(`div`,{className:`px-3 py-2 text-xs text-slate-400`,children:`No languages available`})]})]})}function bi(e,t){if(!e)return[];let n=e.items||[],r=new Set;for(let e of n){let n=Q(e,t);if(!n)continue;let i=Mi(n.body);for(let e of i){let n=Q(e,t);n?.language&&r.add(n.language)}}return Array.from(r)}function xi({strategy:e}){let t=(0,d.useCanvas)(),n=t?.behavior||[],r=ne(n),i=!!(r.h&&r.w),{isBottom:a,isLeft:o,isRight:s}=re(n),c=i&&r.w<=6,u=(0,d.useVaultSelector)((e,n)=>t?.items[0]?n.get(t.items[0]):null),f=(0,d.useVaultSelector)((e,n)=>t?.annotations[0]?n.get(t?.annotations[0]):null),{i18n:{availableLanguages:h,defaultLanguage:g}}=(0,l.useConfig)(),[_,v]=(0,l.useLocalStorage)(`exhibition-info-block-mode`,`edit`),b=gt(),x=b===`exhibition`,S=x,C=x?`Read more text in modal`:`Summary`,w=(0,d.useVaultSelector)((e,t)=>{let n=bi(u,t),r=bi(f,t),i=new Set([...n,...r]);return i.size===0&&i.add(g||`en`),Array.from(i)},[u?.id,f?.id,g]),[T,E]=(0,m.useState)(),D=T||(w.includes(g)?g:w[0]||g||`en`),O=e=>{E(e)},k=c?`30rem`:void 0;return(0,p.jsxs)(`div`,{className:`relative z-0 flex h-full min-h-0 w-full min-w-0 max-w-full flex-col overflow-hidden bg-white`,children:[(0,p.jsxs)(`div`,{className:`exhibition-slideshow-current-toolbar relative z-[70] flex items-center gap-3 border-b border-slate-200 bg-white px-4 py-3 shadow-sm`,children:[(0,p.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,p.jsx)(d.LocaleString,{className:`block truncate text-sm font-semibold text-slate-800`,children:t?.label})}),(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[_===`edit`&&(0,p.jsx)(yi,{selectedLanguage:D,languages:w,availableLanguages:h,onSelectLanguage:E,onAddLanguage:O}),(0,p.jsxs)(`div`,{className:`flex shrink-0 overflow-hidden rounded-md border border-slate-200 bg-slate-50 text-xs font-semibold`,children:[(0,p.jsx)(Si,{selected:_===`edit`,onPress:()=>v(`edit`),children:`Edit`}),(0,p.jsx)(Si,{selected:_===`preview`,onPress:()=>v(`preview`),children:`Preview`})]})]})]}),_===`preview`?(0,p.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,p.jsx)(ft,{preset:b})}):(0,p.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto`,children:[S?(0,p.jsx)(Ci,{annotationPage:u,compact:c,editorMaxWidth:k,fallbackText:e.items[0]?.text,heading:`Short text in info box`,panelClassName:(0,y.twMerge)(`border-b border-gray-100`,c?`p-3`:`p-5`,i&&(o||s)?`max-w-xl`:``,i&&a?`max-w-4xl`:``),parentProperty:`items`,selectedLanguage:D,onLanguageAdded:O}):null,(0,p.jsx)(Ci,{annotationPage:f,compact:c,heading:C,panelClassName:(0,y.twMerge)(c?`p-3`:`p-5`),parentProperty:`annotations`,selectedLanguage:D,onLanguageAdded:O})]})]})}function Si({children:e,selected:t,onPress:n}){return(0,p.jsx)(v.Button,{className:(0,y.twMerge)(`px-3 py-2 text-xs font-semibold transition`,t?`bg-white text-slate-900 shadow-sm`:`text-slate-500 hover:text-slate-700`),onPress:n,children:e})}function Ci({annotationPage:e,compact:t,editorMaxWidth:n,fallbackText:r,heading:i,panelClassName:a,parentProperty:o,selectedLanguage:s,onLanguageAdded:c}){let u=(0,d.useCanvas)(),f=(0,l.useInlineCreator)(),m=(0,d.useVault)(),{i18n:{defaultLanguage:g}}=(0,l.useConfig)(),_=e||null,v=_?.items||[],b=Ei(v,m),x=()=>{u&&f.create(`@manifest-editor/empty-annotation-page`,{label:{en:[i]}},{target:{id:u.id,type:`Canvas`},targetType:`AnnotationPage`,parent:{property:o,resource:{id:u.id,type:`Canvas`}}})},S=()=>{if(u){if(!_){x();return}f.create(`@manifest-editor/html-annotation`,{label:{en:[i]},body:{[s||g||`en`]:[``]},motivation:o===`annotations`?`tagging`:`painting`},{target:{id:u.id,type:`Canvas`},targetType:`Annotation`,parent:{property:`items`,resource:{id:_.id,type:`AnnotationPage`}},initialData:{}})}},C=()=>{if(!_){S(),c(s);return}let e=!1;for(let t of v){let n=Q(t,m);if(!n)continue;let r=Mi(n.body);if(r.some(e=>Q(e,m)?.language===s))continue;let i=r[0],a=i?Q(i,m):null,o=`${n.id}-body-${s}-${Date.now()}`;m.batch(()=>{m.dispatch((0,D.importEntities)({entities:{ContentResource:{[o]:{id:o,type:a?.type||`TextualBody`,language:s,value:``,format:a?.format||`text/html`}}}})),m.dispatch((0,D.addMappings)({mapping:{[o]:`ContentResource`}})),m.modifyEntityField({id:n.id,type:`Annotation`},`body`,[...r,{id:o,type:`ContentResource`}])}),e=!0}e||S(),c(s)},w=(0,d.useVaultSelector)((e,t)=>{if(!_)return!1;for(let e of v){let n=Q(e,t);if(!n)continue;let r=Mi(n.body);for(let e of r)if(Q(e,t)?.language===s)return!0}return!1},[_?.id,v,s]);return(0,p.jsxs)(`section`,{className:(0,y.twMerge)(`min-w-0 max-w-full`,a),children:[(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`flex items-center justify-between gap-3`,b.length?`mb-3`:`mb-0`),children:[(0,p.jsx)(`h2`,{className:(0,y.twMerge)(`font-semibold tracking-tight text-gray-700`,t?`text-xs uppercase`:`text-sm uppercase tracking-wide`),children:i}),!w&&(0,p.jsx)(h.ActionButton,{primary:!0,onPress:C,children:_?`Add text`:`Add`})]}),!_&&r?(0,p.jsx)(`div`,{className:`mt-2 text-sm text-gray-600`,children:(0,p.jsx)(d.LocaleString,{enableDangerouslySetInnerHTML:!0,children:r})}):null,b.length?(0,p.jsx)(`div`,{className:`min-w-0 max-w-full`,children:b.map(({item:e,index:t})=>(0,p.jsx)(d.AnnotationContext,{annotation:e.id,children:(0,p.jsx)(wi,{editorMaxWidth:n,pageItems:v,pageRef:{id:_.id,type:`AnnotationPage`},selectedLanguage:s,onRemoveAnnotation:()=>{m.modifyEntityField({id:_.id,type:`AnnotationPage`},`items`,v.filter((e,n)=>n!==t))}})},e.id+t))}):_&&w?(0,p.jsx)(`div`,{className:(0,y.twMerge)(`mt-2 text-sm text-gray-400 italic`,``),children:`No text added yet.`}):null]})}function wi({editorMaxWidth:e,onRemoveAnnotation:t,pageItems:n,pageRef:r,selectedLanguage:i}){let a=(0,d.useAnnotation)(),o=(0,d.useVault)(),s=a?.body||[],c=(0,l.useGenericEditor)(a);if(!a)return null;let u=s.map((e,t)=>({item:e,index:t})).filter(({item:e})=>Q(e,o)?.language===i),f=u.length>0?u:[],h=(0,m.useCallback)(e=>{let t=Oi(s,o,e);t.length!==s.length&&o.modifyEntityField({id:a.id,type:`Annotation`},`body`,t);let i=Di(n,o,a.id);i.length!==n.length&&o.modifyEntityField(r,`items`,i)},[a.id,r.id,n,o]);return f.length?(0,p.jsx)(`div`,{className:`min-w-0 max-w-full overflow-hidden`,children:f.map(({item:t,index:n})=>(0,p.jsx)(Ti,{resourceId:t.id,onRemove:()=>c.annotation.body.deleteAtIndex(n),onUpdate:()=>h(t.id),editorMaxWidth:e},t.id||n))}):null}function Ti({editorMaxWidth:e,resourceId:t,onRemove:n,onUpdate:r}){let i=(0,m.useMemo)(()=>({id:t,type:`ContentResource`}),[t]),a=(0,l.useGenericEditor)(i),{i18n:{advancedLanguageMode:o,availableLanguages:s,defaultLanguage:c}}=(0,l.useConfig)(),{language:u,value:d}=a.descriptive,f=u.get(),g=Array.isArray(f)?f[0]||c||`en`:f||c||`en`;return(0,m.useEffect)(()=>{let e=Array.isArray(u.get())?u.get()[0]:u.get();!o&&e!==g&&u.set(g)},[o,g]),(0,p.jsxs)(`div`,{className:`min-w-0 max-w-full overflow-hidden`,style:e?{maxWidth:e}:void 0,children:[o?(0,p.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,p.jsx)(`select`,{"aria-label":`Language`,className:`rounded border border-slate-200 bg-white px-2 py-1 text-sm`,value:g,onChange:e=>u.set(e.currentTarget.value),children:s.map(e=>(0,p.jsx)(`option`,{value:e,children:e},e))}),(0,p.jsx)(`button`,{type:`button`,className:`text-sm text-slate-600 hover:text-slate-900`,onClick:n,children:`Remove`})]}):null,(0,p.jsx)(h.HTMLEditor,{value:d.get()||``,onChange:e=>{d.set(e),r()}},`${t}:${g}`)]})}function Ei(e,t){let n=e.map((e,t)=>({item:e,index:t})),r=n.filter(({item:e})=>!ki(e,t));return r.length?r:n.slice(0,1)}function Di(e,t,n){let r=e.filter(e=>e?.id===n||!ki(e,t));return r.length?r:e.slice(0,1)}function Oi(e,t,n){let r=e.filter(e=>e?.id===n||!Ai(e,t));return r.length?r:e.slice(0,1)}function ki(e,t){let n=Mi(Q(e,t)?.body);return!n.length||n.every(e=>Ai(e,t))}function Ai(e,t){let n=Q(e,t);return!n||ji(n.value||``)}function ji(e){let t=String(e||``);return!/<img\b/i.test(t)&&t.replace(/<[^>]*>/g,``).replace(/&nbsp;/gi,` `).replace(/\s+/g,``).trim()===``}function Q(e,t){return!e?.id||e.value||e.items||e.body?e:t.get(e,{skipSelfReturn:!1})||e}function Mi(e){return Array.isArray(e)?e:e==null?[]:[e]}const Ni={id:`youtube-main-editor`,label:`YouTube main editor`,component:e=>e.type===`media`?(0,p.jsx)(Pi,{strategy:e,video:e.media}):null,supports:{strategy:(e,t,n)=>e.type===`media`&&e.media.type===`VideoYouTube`}};function Pi({strategy:e,video:t}){let{edit:n}=(0,l.useLayoutActions)(),r=(0,d.useCanvas)(),i=(0,d.useVaultSelector)((e,t)=>t.get(r?.items[0]).items[0]);(0,O.default)(r&&i);let a=(0,m.useRef)(null),o=(0,l.useGenericEditor)(i),s=t,c=(r.width||1)/(r.height||1);return`${s.youTubeId}`,(0,p.jsxs)(`div`,{className:`overflow-y-auto`,children:[(0,p.jsx)(`div`,{className:`p-8`,children:(0,p.jsx)(`div`,{className:`bg-black z-20 flex p-8 rounded-lg max-w-full max-h-[70vh] mx-auto`,style:{aspectRatio:c},children:(0,p.jsx)(`iframe`,{title:`YouTube video`,className:`border-none w-full h-full object-contain`,ref:a,src:`https://www.youtube.com/embed/${s.youTubeId}?enablejsapi=1&origin=${window.location.host}&modestbranding=1&rel=0`,referrerPolicy:`no-referrer compute-pressure`,sandbox:`allow-scripts allow-same-origin allow-presentation`})})}),(0,p.jsxs)(`div`,{className:`bg-white shadow w-full p-8 flex gap-8`,children:[(0,p.jsx)(`div`,{children:(0,p.jsx)(`div`,{className:`w-64 bg-black flex-shrink-0 flex items-center justify-center rounded overflow-clip`,style:{aspectRatio:c},children:r.thumbnail?.length?(0,p.jsx)(h.LazyThumbnail,{cover:!0}):(0,p.jsx)(`div`,{className:`text-white/50 text-center py-16`,children:`No thumbnail`})})}),(0,p.jsxs)(`div`,{className:`flex-1`,children:[(0,p.jsx)(d.LocaleString,{as:`h3`,className:`text-2xl font-bold mt-4`,defaultText:(0,p.jsx)(`span`,{className:`text-black/30`,children:`No Label`}),children:o.descriptive.label.get()}),(0,p.jsx)(d.LocaleString,{as:`p`,className:`mt-2 mb-8`,defaultText:(0,p.jsx)(`span`,{className:`text-black/30`,children:`No summary`}),children:o.descriptive.summary.get()}),(0,p.jsx)(h.ActionButton,{onPress:()=>n(o.ref()),children:`Edit properties`})]})]})]})}const Fi=(0,k.defineCreator)({...A.iiifBrowserCreator,id:`@exhibitions/browser-creator`,configKey:A.iiifBrowserCreator.id,create:Li,sideEffects:[],tags:[`image`,`exhibition-slide`,`exhibition-slideshow-slide`],label:`Browse IIIF content`,summary:`Browse an IIIF manifest, collection, or supported collection webpage and choose content to add.`,resourceType:`Canvas`,resourceFields:[`id`,`language`,`type`,`format`,`value`],additionalTypes:[],supports:{initialData:!0,onlyPainting:!0,parentTypes:[`Manifest`],parentFields:[`items`],parentFieldMap:{Manifest:[`items`]}}});function Ii(e){return{...e,additionalTypes:e.additionalTypes?.filter(e=>e!==`Canvas`),supports:{...e.supports,parentTypes:[`Annotation`,`AnnotationPage`],parentFieldMap:{Annotation:[`body`],AnnotationPage:[`items`]}}}}async function Li(e,t){let n=t.generateId(`canvas`),r=t.generateId(`annotation-page`,{id:n,type:`Canvas`}),i={width:0,height:0},a,o=await(0,k.creatorHelper)(t,{id:r,type:`AnnotationPage`},`items`,`@manifest-editor/iiif-browser-creator`)({...e,trackSize({width:e,height:t}){i.height=t,i.width=e},trackManifest(e){a=e}},{targetType:`Annotation`,target:{id:n,type:`Canvas`}});return await(0,k.creatorHelper)(t,`Manifest`,`items`,`@exhibitions/image-slide-creator`)({canvasId:n,width:i.width,height:i.height,type:`default`,items:o,imageSlideBehavior:t.options.initialData?.imageSlideBehavior,...a})}const Ri=(0,k.defineCreator)({...A.imageServiceCreator,id:`@exhibitions/image-service-creator`,create:zi,tags:[`image`,`exhibition-slide`,`exhibition-slideshow-slide`],label:`IIIF image`,summary:`Add a zoomable image using an IIIF image service or info.json link.`,resourceType:`Canvas`,supports:{initialData:!0,parentTypes:[`Manifest`],parentFields:[`items`]}});async function zi(e,t){let n=t.generateId(`canvas`);t.generateId(`annotation-page`,{id:n,type:`Canvas`});let r=t.generateId(`annotation`),i=await(0,k.creatorHelper)(t,{id:r,type:`Annotation`},`body`,`@manifest-editor/image-service-creator`)(e,{target:{id:n,type:`Canvas`}}),{width:a,height:o}=i.get(),s=t.embed({id:t.generateId(`annotation`),type:`Annotation`,motivation:`painting`,body:[i],target:{type:`SpecificResource`,source:{id:n,type:`Canvas`}}});return await(0,k.creatorHelper)(t,`Manifest`,`items`,`@exhibitions/image-slide-creator`)({canvasId:n,width:a,height:o,type:e.slideType??`default`,items:[s],imageSlideBehavior:e.imageSlideBehavior??t.options.initialData?.imageSlideBehavior})}const Bi=(0,k.defineCreator)({id:`@exhibitions/image-slide-creator`,create:Ui,render:e=>(0,p.jsx)(u.CanvasLayoutForm,{runCreate:t=>e.runCreate({...t,type:`default`})}),initialEditor:`@exhibition/images`,label:`Multiple images`,summary:`Choose an image layout or start with a blank canvas.`,icon:(0,p.jsx)(h.EmptyCanvasIcon,{}),tags:[`exhibition-slide`],resourceType:`Canvas`,resourceFields:[`id`,`type`,`label`,`height`,`width`,`items`],supports:{initialData:!0,parentTypes:[`Manifest`],parentFields:[`items`]}});(0,k.defineCreator)({...Bi,id:`@exhibitions/image-slide-creator-left`,label:`Image with text on left`,summary:`An image with text on the left.`,icon:(0,p.jsx)(Wi,{position:`left`}),create:(e,t)=>Ui({...e,type:`left`},t)}),(0,k.defineCreator)({...Bi,id:`@exhibitions/image-slide-creator-right`,label:`Image with text on right`,summary:`An image with text on the right.`,icon:(0,p.jsx)(Wi,{position:`right`}),create:(e,t)=>Ui({...e,type:`right`},t)}),(0,k.defineCreator)({...Bi,id:`@exhibitions/image-slide-creator-bottom`,label:`Image with text below`,summary:`An image with text at the bottom.`,icon:(0,p.jsx)(Wi,{position:`bottom`}),create:(e,t)=>Ui({...e,type:`bottom`},t)});const Vi=(0,k.defineCreator)({...Bi,id:`@exhibitions/slideshow-image-only-creator`,label:`Multiple images`,icon:(0,p.jsx)(h.ImageListIcon,{}),summary:`Create a slide and arrange multiple images on it.`,tags:[`exhibition-slideshow-slide`],create:(e,t)=>Ui({...e,behavior:[`w-${e.columns||12}`,`h-${e.rows||8}`,`image`],height:e.height||2e3,width:e.width||3e3,type:`default`},t)}),Hi=(0,k.defineCreator)({...Bi,id:`@exhibitions/slideshow-image-text-creator`,label:`Multiple images with text`,icon:(0,p.jsx)(Wi,{position:`right`}),summary:`Create a slide with space for multiple images and text.`,tags:[`exhibition-slideshow-slide`],create:(e,t)=>Ui({...e,behavior:[`w-${e.columns||12}`,`h-${e.rows||8}`,`right`],height:e.height||2e3,width:e.width||3e3,type:`right`},t)});(0,k.defineCreator)({...Bi,id:`@exhibitions/scroll-compact-deck-creator`,label:`Compact image deck`,icon:(0,p.jsx)(h.ImageListIcon,{}),summary:`A scrolling section with compact annotation-led image slides.`,tags:[`exhibition-scroll-section`,`exhibition-slide`],create:(e,t)=>Ui({...e,behavior:[`w-${e.columns||12}`,`h-${e.rows||8}`,`compact-deck`],height:e.height||2e3,width:e.width||3e3,type:`default`},t)});function Ui(e,t){let n=e.canvasId||t.generateId(`Canvas`),r=t.generateId(`AnnotationPage`,{id:n,type:`Canvas`}),i=t.generateId(`AnnotationPage`,{id:n,type:`Canvas`}),a=[],o=6e3,s=e.imageSlideBehavior||t.options.initialData?.imageSlideBehavior;if(e.behavior)a.push(...e.behavior);else if(s)a.push(...s);else if(e.columns&&e.rows)a.push(`w-${e.columns}`,`h-${e.rows}`);else if(e.width&&e.height){let t=e.type??`default`,n=t===`left`||t===`right`,r=t===`bottom`,i=e.width/e.height,o=n?8:12,s=r?3/2:1,c=Math.max(1,Math.min(12,Math.round(o/i*s)));a.push(`w-12`,`h-${c}`)}else a.push(`w-${e.columns||12}`,`h-${e.rows||8}`);if(!e.behavior)switch(e.type){case`left`:a.push(`left`),o*=2/3;break;case`right`:a.push(`right`),o*=2/3;break;case`bottom`:a.push(`bottom`)}e.items?.length||a.push(`multi-image`);let c={...e.metadata?{metadata:e.metadata}:{},...e.requiredStatement?{requiredStatement:e.requiredStatement}:{},...e.rights?{rights:e.rights}:{},...e.partOf?{partOf:e.partOf}:{}},l=t.embed({...j.emptyCanvas,id:n,behavior:a,label:e.label||{en:[`Untitled`]},...c,height:e.height||4e3,duration:e.duration,width:e.width||o,items:[t.embed({...j.emptyAnnotationPage,id:r,type:`AnnotationPage`,items:e.items?e.items:[]})],annotations:[t.embed({...j.emptyAnnotationPage,id:i,type:`AnnotationPage`,items:[]})]}),u=E.canvasLayouts.find(t=>t.id===e.layoutId);return u&&(l.meta[E.CANVAS_LAYOUT_META]={state:(0,E.createCanvasLayoutState)(u)}),l}function Wi({position:e}){return(0,p.jsxs)(`svg`,{width:`1em`,height:`1em`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:[(0,p.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`16`,rx:`2`}),e===`bottom`?(0,p.jsx)(`path`,{d:`M3 14h18M7 17h10`}):(0,p.jsx)(p.Fragment,{children:(0,p.jsx)(`path`,{d:e===`left`?`M11 4v16M6 9h2M6 12h2M6 15h2`:`M13 4v16M16 9h2M16 12h2M16 15h2`})})]})}const Gi=(0,k.defineCreator)({...A.imageUrlCreator,id:`@exhibitions/image-url-creator`,create:Ki,tags:[`exhibition-slide`,`exhibition-slideshow-slide`],label:`Image from a link`,summary:`Add an image slide using a direct image-file link.`,resourceType:`Canvas`,supports:{initialData:!0,parentTypes:[`Manifest`],parentFields:[`items`]}});async function Ki(e,t){let n=t.generateId(`canvas`);t.generateId(`annotation-page`,{id:n,type:`Canvas`});let r=t.generateId(`annotation`),i=await(0,k.creatorHelper)(t,{id:r,type:`Annotation`},`body`,`@manifest-editor/image-url-creator`)(e,{target:{id:n,type:`Canvas`},targetType:`Annotation`}),{width:a,height:o}=i.get(),s=t.embed({id:r,type:`Annotation`,motivation:`painting`,body:[i],target:{type:`SpecificResource`,source:{id:n,type:`Canvas`}}});return await(0,k.creatorHelper)(t,`Manifest`,`items`,`@exhibitions/image-slide-creator`)({canvasId:n,width:a,height:o,type:`default`,items:[s],imageSlideBehavior:t.options.initialData?.imageSlideBehavior})}const qi={fullpage:`Full page`,slideshow:`Slideshow`,scroll:`Scroll`},Ji={templates:Yr,onboarding:{id:`exhibition-template-selection`,mode:`per-resource`,title:`Choose exhibition format`,summary:`Pick a starting point for this exhibition.`,openLabel:`Exhibition formats`,dismissLabel:`Skip for now`,primaryLabel:`Start building`,renderPreviewButton:e=>(0,p.jsx)(Xi,{...e}),renderBody:({templates:e,selectedTemplateId:t,setSelectedTemplateId:n,dismiss:r})=>(0,p.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:e.length?e.map(e=>{let i=t===e.id;return(0,p.jsxs)(`article`,{className:[`relative overflow-hidden rounded border-2 bg-white`,i?`border-me-primary-500`:`border-gray-200`].join(` `),children:[(0,p.jsx)(v.Button,{"aria-label":`Use ${e.label} format`,"aria-pressed":i,className:`absolute inset-0 z-10 cursor-pointer rounded outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-me-primary-500`,onPress:()=>{n(e.id),r()}}),(0,p.jsx)(`img`,{src:e.thumbnailUrl,alt:``,className:`aspect-video w-full bg-gray-100 object-cover`}),(0,p.jsxs)(`div`,{className:`pointer-events-none flex flex-col gap-2 p-3`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h3`,{className:`text-sm font-semibold text-gray-900`,children:e.label}),(0,p.jsx)(`p`,{className:`mt-1 text-xs uppercase tracking-normal text-gray-500`,children:e.type})]}),(0,p.jsx)(`p`,{className:`text-sm text-gray-600`,children:e.summary}),(0,p.jsx)(`a`,{href:e.previewUrl,target:`_blank`,rel:`noreferrer`,className:`pointer-events-auto relative z-20 inline-flex w-fit items-center rounded py-0.5 text-sm font-medium text-me-700 hover:text-me-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-me-primary-500 focus-visible:ring-offset-2`,children:`Preview`})]})]},e.id)}):(0,p.jsx)(`p`,{className:`text-sm text-gray-600`,children:`No exhibition formats are available for this editor.`})})}};function Yi(e,t){let n=new URL(e);return n.searchParams.set(`manifest`,t),n.toString()}function Xi({downloadEnabled:e,fileName:t,preview:n,showOnboardingPreviewHint:r,onOnboardingPreviewHintClose:i}){let{actions:a,configs:o,active:s}=(0,l.usePreviewContext)(),c=(0,d.useVault)(),u=(0,l.useConfig)(),f=(0,l.useAppResource)(),m=(0,l.useLayoutActions)(),g=(0,l.useOpenPresetOnboarding)(),{selectedTemplate:_,templates:y}=(0,l.usePresetTemplateSelection)(),b=V(),x=o.filter(e=>e.type===`external-manifest-preview`),S=Ve(y,_,b),C=x.find(e=>e.id===u.defaultPreview)||x.find(e=>!e.id.includes(`theseus`)&&e.id!==`raw-manifest`)||x[0],w=x.find(e=>e.id===`theseus`||e.id===`theseus-viewer`),T=x.find(e=>e.id===`raw-manifest`);async function E(e){let t=await a.getPreviewLink();t&&window.open(Yi(e.previewUrl,t),e.id)}function D(e){a.selectPreview(e)}function O(){m.leftPanel.open({id:`@exhibitions/theme-panel`})}return!S.length&&!n?.mainAction&&!n?.actions?.length?null:(0,p.jsxs)(p.Fragment,{children:[e?(0,p.jsx)(`div`,{className:`mr-4`,children:(0,p.jsx)(h.DownloadButton,{fileName:t||`manifest.json`,label:`Download manifest`,getData:()=>u.export&&u.export.version===2?JSON.stringify(c.toPresentation2(f),null,2):JSON.stringify(c.toPresentation3(f),null,2)})}):null,(0,p.jsxs)(l.ButtonContainer,{style:{width:`max-content`,minWidth:`10em`,flexShrink:0},children:[(0,p.jsxs)(l.ButtonMain,{as:v.Button,style:{whiteSpace:`nowrap`},"data-preview-action":n?.mainAction?.id,isDisabled:n?.mainAction?.disabled,onPress:n?.mainAction?.onClick||O,children:[n?.mainAction?.label||`Preview`,b?(0,p.jsxs)(`span`,{className:`ml-1 whitespace-nowrap opacity-75`,children:[`· `,qi[b.type]]}):null]}),(0,p.jsxs)(v.MenuTrigger,{children:[(0,p.jsx)(l.ButtonChange,{as:v.Button,$open:!1,"aria-label":`Choose preview`,className:`exhibition-preview-preset-menu`,children:(0,p.jsx)(Jr,{})}),(0,p.jsx)(v.Popover,{placement:`bottom right`,className:`z-50`,children:(0,p.jsxs)(l.MenuContainer,{as:v.Menu,$open:!0,className:`outline-none`,style:{position:`relative`,top:`auto`,left:`auto`,marginTop:0,width:`15em`},children:[(0,p.jsxs)(v.MenuItem,{className:`flex cursor-pointer items-center border-b border-gray-100 p-1 outline-none hover:bg-gray-50 focus:bg-gray-50`,onAction:g,children:[(0,p.jsx)(`span`,{className:`mx-2 flex h-4 w-8 shrink-0 items-center justify-center`,children:(0,p.jsx)(Zi,{className:`h-4 w-4 text-gray-500`})}),(0,p.jsx)(l.MenuItemLabel,{children:`Change exhibition format`})]}),S.map(e=>{let t=b?.id===e.id;return(0,p.jsxs)(v.MenuItem,{"aria-current":t?`true`:void 0,className:`flex cursor-pointer items-center p-1 outline-none hover:bg-gray-50 focus:bg-gray-50`,onAction:()=>E(e),children:[(0,p.jsx)(l.MenuItemStatus,{$status:t?`active`:`available`}),(0,p.jsxs)(l.MenuItemLabel,{children:[e.label,t?` (current)`:``]})]},e.id)}),n?.actions?.map(e=>(0,p.jsxs)(v.MenuItem,{className:`flex cursor-pointer items-center p-1 outline-none hover:bg-gray-50 focus:bg-gray-50`,isDisabled:e.disabled,onAction:e.onClick,children:[(0,p.jsx)(l.MenuItemStatus,{$status:e.status||`available`}),(0,p.jsx)(l.MenuItemLabel,{children:e.label})]},e.id)),w&&w.id!==C?.id?(0,p.jsxs)(v.MenuItem,{className:`flex cursor-pointer items-center p-1 outline-none hover:bg-gray-50 focus:bg-gray-50`,onAction:()=>D(w.id),children:[(0,p.jsx)(l.MenuItemStatus,{$status:s.includes(w.id)?`configured`:`available`}),(0,p.jsx)(l.MenuItemLabel,{children:w.label})]}):null,T&&T.id!==C?.id?(0,p.jsxs)(v.MenuItem,{className:`flex cursor-pointer items-center p-1 outline-none hover:bg-gray-50 focus:bg-gray-50`,onAction:()=>D(T.id),children:[(0,p.jsx)(l.MenuItemStatus,{$status:s.includes(T.id)?`configured`:`available`}),(0,p.jsx)(l.MenuItemLabel,{children:T.label})]}):null]})})]})]}),(0,p.jsx)(h.OnboardingTour,{id:`exhibition-preview-preset-menu`,forceStart:r,onClose:i,lastButtonLabel:`Dismiss`,steps:[{target:`.exhibition-preview-preset-menu`,placement:`bottom`,disableBeacon:!0,content:`You can change the exhibition format again from this preview menu.`}]})]})}function Zi(e){return(0,p.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,...e,children:(0,p.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,children:[(0,p.jsx)(`path`,{d:`M3 17h2.397a5 5 0 0 0 4.096-2.133l.177-.253m3.66-5.227l.177-.254A5 5 0 0 1 17.603 7H21`}),(0,p.jsx)(`path`,{d:`m18 4l3 3l-3 3M3 7h2.397a5 5 0 0 1 4.096 2.133l4.014 5.734A5 5 0 0 0 17.603 17H21`}),(0,p.jsx)(`path`,{d:`m18 20l3-3l-3-3`})]})})}const Qi=(0,k.defineCreator)({id:`@exhibitions/info-box-creator`,create:ea,label:`Text panel`,summary:`Create a panel for text. No link is needed.`,icon:(0,p.jsx)(h.TextIcon,{}),tags:[`exhibition-slide`],resourceType:`Canvas`,resourceFields:[`id`,`type`,`label`,`height`,`width`,`items`],supports:{initialData:!0,parentTypes:[`Manifest`],parentFields:[`items`]}}),$i=(0,k.defineCreator)({...Qi,id:`@exhibitions/slideshow-long-editorial-creator`,label:`Text slide`,summary:`Create a slide for longer text. No link is needed.`,tags:[`exhibition-slideshow-slide`],create:(e,t)=>ea({...e,behavior:[`w-12`,`h-8`,`info`],height:e.height||1080,width:e.width||1920},t)});async function ea(e,t){let n=t.generateId(`canvas`),r=t.generateId(`annotation-page`,{id:n,type:`Canvas`}),i=t.generateId(`annotation-page`,{id:n,type:`Canvas`}),a={...j.emptyAnnotation,id:t.generateId(`annotation`,{id:n,type:`Canvas`}),type:`Annotation`},o=[await t.create(`@manifest-editor/html-body-creator`,{language:`en`,body:``},{parent:{resource:a,property:`body`}})],s=t.embed({...a,motivation:`painting`,body:o,target:{type:`SpecificResource`,source:{id:n,type:`Canvas`}}}),c=t.generateId(`annotation`,{id:n,type:`Canvas`}),l=t.embed({id:c,type:`Annotation`,motivation:`tagging`,body:[await t.create(`@manifest-editor/html-body-creator`,{language:`en`,body:``},{parent:{resource:{id:c,type:`Annotation`},property:`body`}})],target:{type:`SpecificResource`,source:{id:n,type:`Canvas`}}}),u=t.embed({id:r,type:`AnnotationPage`,items:[s]}),d=t.embed({id:i,type:`AnnotationPage`,items:[l]});return t.embed({...j.emptyCanvas,id:n,type:`Canvas`,behavior:e.behavior||[`w-4`,`h-4`,`info`],label:e.label||void 0,height:e.height||1e3,width:e.width||1e3,items:[u],annotations:[d]})}const ta=(0,k.defineCreator)({...A.videoAnnotation,id:`@exhibitions/video-creator`,create:ra,tags:[`video`,`exhibition-slide`],label:`Video`,summary:`Add a video slide using a direct video-file link. Use YouTube for YouTube videos.`,resourceType:`Canvas`,resourceFields:[`id`,`type`,`label`,`height`,`width`,`items`],supports:{initialData:!0,parentTypes:[`Manifest`],parentFields:[`items`]}}),na=(0,k.defineCreator)({...ta,id:`@exhibitions/slideshow-video-creator`,label:`Video`,summary:`Add a video slide using a direct video-file link. Use YouTube for YouTube videos.`,tags:[`exhibition-slideshow-slide`],create:(e,t)=>ra({...e,behavior:[`w-12`,`h-8`,`image`],height:e.height||1080,slideType:`default`,width:e.width||1920},t)});async function ra(e,t){let n=t.generateId(`canvas`),r=t.generateId(`annotation-page`,{id:n,type:`Canvas`}),i=await t.create(`@manifest-editor/video-annotation`,e,{target:{id:n,type:`Canvas`},targetType:`Annotation`,parent:{resource:{id:r,type:`AnnotationPage`},property:`items`}});return t.embed({id:r,type:`AnnotationPage`,items:[i]}),await(0,k.creatorHelper)(t,`Manifest`,`items`,`@exhibitions/image-slide-creator`)({canvasId:n,behavior:e.behavior,height:e.height||1080,width:e.width||1920,duration:e.duration,type:e.slideType||`bottom`,items:[i]})}const ia=(0,k.defineCreator)({...A.youTubeBodyCreator,id:`@exhibitions/youtube-creator`,create:oa,tags:[`video`,`exhibition-slide`],label:`YouTube`,summary:`Embed a video using its YouTube link.`}),aa=(0,k.defineCreator)({...ia,id:`@exhibitions/slideshow-youtube-creator`,label:`YouTube`,summary:`Embed a video using its YouTube link.`,tags:[`exhibition-slideshow-slide`]});async function oa(e,t){let n=(0,u.getYouTubeId)(e.youtubeUrl),r=t.generateId(`canvas`),i=t.generateId(`annotation-page`,{id:r,type:`Canvas`}),a=t.embed({id:t.generateId(`annotation`,{id:i,type:`AnnotationPage`}),type:`Annotation`,motivation:`painting`,body:[(0,A.createYoutubeBodyResource)(e,t)],target:{type:`SpecificResource`,source:{id:r,type:`Canvas`}}}),o=t.embed({id:i,type:`AnnotationPage`,items:[a]}),s=t.embed({id:`https://img.youtube.com/vi/${n}/maxresdefault.jpg`,type:`Image`,format:`image/jpeg`,width:640,height:360});return t.embed({...j.emptyCanvas,id:r,type:`Canvas`,behavior:[`w-12`,`h-8`],label:e.label||{en:[`Untitled YouTube Video`]},height:e.height||1080,width:e.width||1920,thumbnail:[s],items:[o]})}function sa(e){return!(0,M.getValue)(e)}function ca(e,t,n){let r=t>0&&n>0?Math.max(1,Math.min(12,Math.round(t/n*12))):4;return[...e.filter(e=>!e.startsWith(`w-`)&&!e.startsWith(`h-`)),`w-12`,`h-${r}`]}function la({misplacedSplash:e=!1}){let t=(0,l.useEditor)(),n=()=>{let n=t.technical.width.get(),r=t.technical.height.get(),i=t.descriptive.summary,a=t.technical.behavior,o=a.get(),s=ca(e?o.filter(e=>e!==`splash`):o,n,r);sa(i.get())&&i.set({en:[`Summary of image`]}),(s.length!==o.length||s.some((e,t)=>e!==o[t]))&&a.set(s)};return(0,p.jsxs)(`div`,{className:`flex flex-col items-center gap-4 border-me-100 border-2 p-4 rounded`,children:[e?`Opening cover canvases must be first. Apply defaults to use this canvas as a regular exhibition slide.`:`This canvas was not created in the exhibition editor. Do you want to apply default settings?`,(0,p.jsx)(h.ActionButton,{onPress:()=>n(),children:`Apply defaults`})]})}function ua({editor:e}){let t=e.get()||``;return(0,p.jsxs)(u.InputContainer,{$wide:!0,id:e.containerId(),children:[(0,p.jsx)(u.InputLabel,{htmlFor:e.focusId(),children:`Background colour`}),(0,p.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,p.jsx)(`input`,{id:e.focusId(),"aria-label":`Choose background colour`,className:`h-9 w-12 shrink-0 cursor-pointer rounded border border-[#dcd5ce] bg-white p-1`,type:`color`,value:da(t),onChange:t=>e.set(t.target.value)}),(0,p.jsx)(u.Input,{"aria-label":`Background colour value`,placeholder:`No colour`,value:t,onChange:t=>e.set(t.target.value||null)}),t?(0,p.jsx)(`button`,{type:`button`,className:`rounded border border-[#dcd5ce] bg-white px-3 py-2 text-sm font-semibold text-[#332f2c]`,onClick:()=>e.set(null),children:`Remove`}):null]}),(0,p.jsx)(`p`,{className:`mt-1 text-xs text-[#6a625c]`,children:`Shown behind the image and text for this section.`})]})}function da(e){let t=e.trim();if(/^#[0-9a-fA-F]{6}$/.test(t))return t;if(/^#[0-9a-fA-F]{3}$/.test(t)){let[e,n,r]=t.slice(1);return`#${e}${e}${n}${n}${r}${r}`}return`#ffffff`}function fa(e,t){if(!t?.behavior?.includes(`multi-image`))return null;let n=W(e,t);if(n.length!==1)return null;let r=n[0],i=Array.isArray(r?.body)?r.body[0]:r?.body,a=i?.type===`SpecificResource`?i.selector:null,o=a?.region?.split(`,`).map(Number);return r?.target?.selector&&et(e,r)?.type===`Image`&&[`ImageApiSelector`,`iiif:ImageApiSelector`].includes(a?.type)&&o?.length===4&&o.every(Number.isFinite)&&o[2]>0&&o[3]>0?r:null}function pa(){let e=(0,d.useCanvas)(),t=(0,d.useVault)(),n=(0,d.useVaultSelector)((t,n)=>fa(n,e),[e?.id,e?.items]),r=(0,l.useGenericEditor)(n?{id:n.id,type:`Annotation`}:void 0,{allowNull:!0});return!e||!n||!r?.annotation?null:(0,p.jsxs)(`div`,{className:`mb-6 rounded-md border border-amber-300 bg-amber-50 p-4 text-sm text-amber-950`,children:[(0,p.jsx)(`p`,{className:`mb-3`,children:`This slide has one image positioned for a multi-image layout. Rescale the slide to fit it.`}),(0,p.jsx)(v.Button,{className:`rounded-md bg-amber-900 px-3 py-2 font-semibold text-white hover:bg-amber-800`,onPress:()=>(0,u.targetWholeCanvas)(t,e,r.annotation),children:`Rescale for current image`})]})}const ma={id:`@exhibition/summary-editor`,supports:{edit:!0,properties:[`summary`,`requiredStatement`],resourceTypes:[`Canvas`],custom:(e,t)=>{let{resource:n}=e;return ie(n,t)?!Ir(e,t)&&!ae(n,t):!1}},label:`Text content`,component:()=>(0,p.jsx)(ha,{})};function ha(){return(0,p.jsx)(h.Sidebar,{children:(0,p.jsx)(h.SidebarContent,{padding:!0,children:(0,p.jsx)(ga,{})})})}function ga(){let e=U(e=>e.setCenterPanelMode),t=(0,d.useCanvas)();return(0,m.useEffect)(()=>{e(`preview`)},[e]),t?(0,p.jsxs)(l.ResourceEditingProvider,{resource:t,children:[(0,p.jsx)(u.LanguageMapEditor,{dispatchType:`label`}),(0,p.jsx)(va,{resource:t}),(0,p.jsx)(_a,{})]}):null}function _a(){let{descriptive:e}=(0,l.useEditor)(),{requiredStatement:t}=e,n=t.get();return(0,p.jsxs)(u.InputContainer,{$wide:!0,id:t.containerId(),children:[(0,p.jsx)(u.InputLabel,{htmlFor:t.focusId(),children:`Required statement`}),(0,p.jsxs)(u.InputFieldset,{id:t.focusId(),children:[(0,p.jsx)(u.LanguageFieldEditor,{focusId:`${t.focusId()}_label`,label:`Label`,fields:n?.label||{none:[]},onSave:e=>t.updateLabel(e.toInternationalString())}),(0,p.jsx)(u.LanguageFieldEditor,{focusId:`${t.focusId()}_value`,label:`Value`,disallowHTML:!1,fields:n?.value||{none:[]},onSave:e=>t.update(e.toInternationalString())})]})]})}function va({resource:e}){let t=(0,d.useVault)(),n=(0,m.useMemo)(()=>tr(e.summary),[e.summary]);return(0,p.jsx)(u.TiptapLanguageFieldEditor,{label:`summary`,disallowHTML:!1,metadataKey:`summary`,fields:n,onSave:n=>{t.modifyEntityField(e,`summary`,nr(n.toInternationalString()))}},e.id)}const ya={id:`@exhibition/right-panel-editor`,supports:{edit:!0,properties:[`label`,`summary`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>ie(e,t)?!ae(e,t):!1},label:`Exhibition`,component:()=>(0,p.jsx)(ba,{})};function ba(){return(0,p.jsx)(h.Sidebar,{children:(0,p.jsx)(h.SidebarContent,{padding:!0,children:(0,p.jsx)(xa,{})})})}function xa(){let e=(0,d.useCanvas)(),t=(0,d.useVault)(),n=(0,l.useManifestEditor)(),r=(0,l.useEditingResource)(),{technical:i}=(0,l.useEditor)(),a=i.behavior.get()||[],o=se(e),s=a.includes(`info`),c=Fr(e,n.structural.items.get()),f=a.includes(`splash`)&&!c,m=Ke(t,e),h=tn(a,(0,d.useVaultSelector)((t,n)=>e?Ge(n,e).length>0:!1,[e?.id,e?.annotations?.[0]?.id]));return!e||!r?(0,p.jsx)(`div`,{className:`p-8`,children:`Canvas or resource not found`}):s?(0,p.jsxs)(l.ResourceEditingProvider,{resource:e,children:[!o||f?(0,p.jsx)(la,{misplacedSplash:f}):null,(0,p.jsx)(Ca,{canvas:e}),m?(0,p.jsx)(wa,{canvas:e}):null]}):(0,p.jsxs)(l.ResourceEditingProvider,{resource:e,children:[!o||f?(0,p.jsx)(la,{misplacedSplash:f}):null,(0,p.jsx)(pa,{}),c?(0,p.jsx)(Sa,{manifestEditor:n}):(0,p.jsx)(Ca,{canvas:e}),(0,p.jsx)(ua,{editor:i.backgroundColor}),h.layoutOptions.length||h.isSlideshow&&wn(a)?(0,p.jsx)(u.InputContainer,{$wide:!0,children:(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`exhibition-workbench-muted mb-3 text-sm font-semibold`,children:h.isSlideshow&&wn(a)?`Text overlay position`:`Text placement`}),h.isSlideshow&&wn(a)?(0,p.jsx)(wt,{value:Tn(a),onChange:e=>i.behavior.set(En(a,e))}):(0,p.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:h.layoutOptions.map(n=>(0,p.jsx)(hn,{preset:n.value,label:n.label,selected:xn(a)===n.value,onClick:()=>{i.behavior.set(Sn(a,n.value,e?{width:e.width,height:e.height}:void 0)),e&&In(t,e,n.value)}},n.value))}),(0,p.jsx)(Ta,{canvas:e,tabId:`slide-behaviors`,label:`More display options`})]})}):null,m&&!c?(0,p.jsx)(wa,{canvas:e}):null]})}function Sa({manifestEditor:e}){let t={...e.ref(),summary:e.descriptive.summary.get()};return(0,p.jsxs)(l.ResourceEditingProvider,{resource:t,children:[(0,p.jsx)(u.LanguageMapEditor,{dispatchType:`label`}),(0,p.jsx)(va,{resource:t})]})}function Ca({canvas:e}){let{edit:t}=(0,l.useLayoutActions)(),n=(0,m.useRef)(null),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(!1),s=Ea(e.label)||`Untitled`,c=rr(e.summary);return(0,m.useEffect)(()=>{let e=n.current;if(!e){o(!1);return}o(e.scrollHeight>e.clientHeight+1)},[c,r]),(0,p.jsx)(u.InputContainer,{$wide:!0,children:(0,p.jsxs)(`div`,{className:`rounded-md border border-[#dcd5ce] bg-[#f8f6f3] p-4`,children:[(0,p.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,p.jsxs)(`div`,{className:`min-w-0`,children:[(0,p.jsx)(`div`,{className:`text-xs font-semibold uppercase text-[#6a625c]`,children:`Label`}),(0,p.jsx)(`div`,{className:`mt-1 break-words text-base font-semibold text-[#25211f]`,children:s})]}),(0,p.jsx)(`button`,{type:`button`,className:`flex-shrink-0 rounded-md px-3 py-2 text-sm font-semibold shadow-sm`,style:{backgroundColor:`#b84c74`,border:`1px solid #a13e63`,color:`#ffffff`},onClick:()=>{t({id:e.id,type:`Canvas`},void 0,{selectedTab:`@exhibition/summary-editor`,forceOpen:!0})},children:`Edit`})]}),(0,p.jsxs)(`div`,{className:`mt-5`,children:[(0,p.jsx)(`div`,{className:`text-xs font-semibold uppercase text-[#6a625c]`,children:`Summary`}),(0,p.jsx)(`div`,{ref:n,className:[`mt-2 whitespace-pre-wrap break-words text-sm leading-relaxed text-[#332f2c]`,r?``:`max-h-32 overflow-hidden`].join(` `),children:c?(0,p.jsx)(`div`,{className:`prose prose-sm max-w-none prose-p:my-2 prose-headings:my-2 prose-ul:my-2 prose-ol:my-2`,dangerouslySetInnerHTML:{__html:c}}):(0,p.jsx)(`span`,{className:`text-[#6a625c]`,children:`No summary added.`})}),a||r?(0,p.jsx)(`button`,{type:`button`,className:`mt-2 text-sm font-semibold text-[#b84c74]`,onClick:()=>i(e=>!e),children:r?`Read less`:`Read more`}):null]})]})})}function wa({canvas:e}){let t=(0,d.useVault)(),n=e.annotations?.[0],r=n?t.get(n,{skipSelfReturn:!1}):null,i=Array.isArray(r?.items)?r.items.length:0,a=i===0?`There are no tour steps yet.`:`${i} tour step${i===1?``:`s`} on this canvas.`;return(0,p.jsx)(u.InputContainer,{$wide:!0,children:(0,p.jsxs)(`div`,{className:`rounded-md border border-[#dcd5ce] bg-white p-4`,children:[(0,p.jsx)(`div`,{className:`text-sm font-semibold text-[#25211f]`,children:`Tour steps`}),(0,p.jsx)(`div`,{className:`mt-1 text-sm text-[#6a625c]`,children:a}),(0,p.jsx)(Ta,{canvas:e,tabId:`@exhibition/tour-steps`,label:i===0?`Open Tour steps tab to add one`:`Open Tour steps tab`})]})})}function Ta({canvas:e,tabId:t,label:n}){let{edit:r}=(0,l.useLayoutActions)();return(0,p.jsxs)(`button`,{type:`button`,onClick:()=>r({id:e.id,type:`Canvas`},void 0,{selectedTab:t,forceOpen:!0}),className:`flex gap-2 items-center justify-between mt-3 text-me-primary-600 bg-gray-50 py-2 px-4 rounded-full hover:bg-gray-100`,children:[(0,p.jsx)(`span`,{className:`text-left text-sm font-semibold`,children:n}),(0,p.jsx)(h.ArrowRightIcon,{})]})}function Ea(e){return e?typeof e==`string`?e:Array.isArray(e)?e.filter(Boolean).join(` `):typeof e==`object`?Object.values(e).flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).join(` `):``:``}const Da={id:`@exhibition/images`,label:`Images`,supports:{edit:!0,resourceTypes:[`Canvas`],properties:[`items`,`width`,`height`],custom:({resource:e},t)=>ie(e,t)&&!ae(e,t)},component:()=>(0,p.jsx)(h.Sidebar,{children:(0,p.jsx)(h.SidebarContent,{padding:!0,children:(0,p.jsx)(Oa,{})})})};function Oa(){let e=(0,d.useCanvas)(),t=(0,d.useVault)(),n=(0,u.useAddCanvasImage)(),{technical:r}=(0,l.useEditor)(),{edit:i}=(0,l.useLayoutActions)(),a=(0,d.useAtlasStore)(),o=(0,d.useVaultSelector)((t,n)=>e?(0,E.getPaintingImages)(n,e):[],[e]),s=U(e=>e.setCenterPanelMode);if(!e)return null;let c=e.items[0],f=ne(e.behavior).ratio,m=Math.abs(e.width/e.height-f)>=.01,h=!(0,E.canResizeCanvas)(t,e);function g(){let e=a.getState();e.tool.requestId&&e.requests[e.tool.requestId]?.arguments?.canvasComposition&&e.cancelRequest(e.tool.requestId)}let _=()=>(s(`edit`),n());return(0,p.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:24},children:[(0,p.jsxs)(u.CanvasImageMode,{singleImage:h,canReturnToSingle:o.length===1,onSwitchToMulti:()=>{(0,E.beginCanvasComposition)(t,e),o[0]&&(0,E.targetPaintingImageRegion)(t,e,o[0].id),s(`edit`)},onSwitchToSingle:()=>{g(),(0,E.switchToSingleImage)(t,e),i(e,void 0,{selectedTab:`@exhibition/images`,forceOpen:!0})},children:[(0,p.jsx)(u.CanvasLayoutSection,{}),(0,p.jsx)(u.SmartCanvasSize,{templateAware:!0,children:({resize:t})=>m?(0,p.jsxs)(`p`,{style:{margin:0,display:`flex`,flexWrap:`wrap`,alignItems:`center`,justifyContent:`space-between`,gap:8,padding:`8px 10px`,borderRadius:8,background:`#fffaeb`,border:`1px solid #fedf89`,color:`#93370d`},children:[(0,p.jsx)(`span`,{children:`Slide proportions differ from the slide format.`}),(0,p.jsx)(u.ActionPill,{variant:`secondary`,onClick:()=>t({x:0,y:0,width:e.width,height:Math.round(e.width/f)}),children:`Match slide`})]}):null})]}),h&&(0,p.jsx)(u.CanvasCompositionSession,{}),(0,p.jsx)(ua,{editor:r.backgroundColor}),(0,E.isTemplateManaged)(t,e)?null:c?(0,p.jsx)(d.AnnotationPageContext,{annotationPage:c.id,children:(0,p.jsx)(u.PaintingAnnotationList,{onCreate:()=>void _()})}):(0,p.jsx)(`button`,{type:`button`,onClick:()=>void _(),className:`rounded px-3 py-2 text-sm`,style:{background:`#b84c74`,color:`white`},children:`+ Add image`})]})}function ka(e,t=e=>e){let n=Array.isArray(e?.motivation)?e.motivation:[e?.motivation],r=Array.isArray(e?.body)?e.body:e?.body?[e.body]:[];if(!n.includes(`painting`)||r.length!==1)return null;let i=r[0];if(!e?.id||i?.type===`Choice`||i?.source?.type===`Choice`)return null;let a=i?.type===`SpecificResource`,o=a?i.selector:void 0;if(o&&![`ImageApiSelector`,`iiif:ImageApiSelector`].includes(o.type))return null;let s=a?i.source:i,c=t(s)||s;if(c?.type!==`Image`)return null;let l=(Array.isArray(c.service)?c.service:c.service?[c.service]:[]).map(e=>t(e)||e).find(e=>(0,x.isImageService)(e)&&(e.id||e[`@id`]));return l?{annotation:e,annotationRef:{id:e.id,type:`Annotation`},body:a?i:{type:`SpecificResource`,source:s},selector:o||{type:`ImageApiSelector`},source:c,service:l}:null}function Aa(e){if(typeof e!=`string`)return null;let t=e.split(`,`).map(Number);if(t.length!==4||!t.every(Number.isFinite))return null;let n=t[0],r=t[1],i=t[2],a=t[3];return i<=0||a<=0?null:{x:n,y:r,width:i,height:a}}function ja(e){let t={x:Math.max(0,Math.round(e.x)),y:Math.max(0,Math.round(e.y)),width:Math.round(e.width),height:Math.round(e.height)};if(t.width<=0||t.height<=0)throw Error(`The crop must have a positive width and height`);return t}function Ma(e,t){return Pa(e,ja(t),e.selector.rotation)}function Na(e,t){let n=Aa(e.selector.region),r=n||Wa(e.service);if(!r)throw Error(`The image service did not provide full image dimensions`);return Pa(e,n,$a(t),r)}function Pa(e,t,n,r=t){let i={...e.selector,...n===void 0?{}:{rotation:String(n)}};t?i.region=qa(t):delete i.region;let a=Xa(e,t,n),o=Math.min(512,r.width),s=Xa(e,t,n,o),c=Ba(r.width,r.height,n);return{region:t,imageDimensions:c,thumbnailDimensions:Ba(o,Math.round(r.height/r.width*o),n),selector:i,source:{...e.source,id:a,...e.source[`@id`]?{"@id":a}:{},width:c.width,height:c.height},sourceId:a,thumbnailId:s}}function Fa(e,t,n,r){return!r||r.cancelled||!r.boundingBox?null:La(e,t,n,r.boundingBox)}function Ia(e,t,n){let r=Array.isArray(e?.behavior)?e.behavior:e?.behavior?[e.behavior]:[];return(Array.isArray(t?.target)?t.target:t?.target?[t.target]:[]).some(t=>Ja(t,e))&&n===1&&!r.includes(`multi-image`)}function La(e,t,n,r){return za(e,t,n,Ma(t,r))}function Ra(e,t,n,r){return za(e,t,n,Na(t,r))}function za(e,t,n,r){let i=to(e,n),a=Ia(n,t.annotation,i);return e.batch(()=>{e.dispatch((0,D.importEntities)({entities:{ContentResource:{[r.sourceId]:r.source,[r.thumbnailId]:{id:r.thumbnailId,type:`Image`,format:`image/jpeg`,width:r.thumbnailDimensions.width,height:r.thumbnailDimensions.height,service:[t.service]}}}})),e.dispatch((0,D.addMappings)({mapping:{[r.sourceId]:`ContentResource`,[r.thumbnailId]:`ContentResource`}})),e.modifyEntityField(t.annotationRef,`body`,[{...t.body,selector:r.selector,source:{id:r.sourceId,type:`ContentResource`}}]),e.modifyEntityField({id:n.id,type:`Canvas`},`thumbnail`,[{id:r.thumbnailId,type:`ContentResource`}]),a&&(e.modifyEntityField({id:n.id,type:`Canvas`},`width`,r.imageDimensions.width),e.modifyEntityField({id:n.id,type:`Canvas`},`height`,r.imageDimensions.height),e.modifyEntityField(t.annotationRef,`target`,Ya(t.annotation.target,n)))}),r}function Ba(e,t,n){let r=Number(String(n??0).replace(/^!/,``)),i=Number.isFinite(r)?(r%360+360)%360:0;return i===90||i===270?{width:t,height:e}:{width:e,height:t}}function Va(e,t,n){switch($a(n)){case 90:return{x:t.height-e.y-e.height,y:e.x,width:e.height,height:e.width};case 180:return{x:t.width-e.x-e.width,y:t.height-e.y-e.height,width:e.width,height:e.height};case 270:return{x:e.y,y:t.width-e.x-e.width,width:e.height,height:e.width};default:return{...e}}}function Ha(e,t,n){return Va(String(n??``).startsWith(`!`)?{...e,x:t.width-e.x-e.width}:e,t,n)}function Ua(e,t,n){let r=Va(e,Ba(t.width,t.height,n),360-$a(n));return String(n??``).startsWith(`!`)?{...r,x:t.width-r.x-r.width}:r}function Wa(e){let t=Number(e?.width),n=Number(e?.height);return t>0&&n>0?{width:t,height:n}:null}async function Ga(e,t=fetch){if(Wa(e))return e;let n=e?.id||e?.[`@id`];if(!n)throw Error(`The image service has no identifier`);let r=await t((0,x.canonicalServiceUrl)(n));if(!r.ok)throw Error(`The image service returned ${r.status}`);let i=await r.json(),a={...e,...i,id:i.id||i[`@id`]||n};if(!Wa(a))throw Error(`The image service did not provide full image dimensions`);return a}function Ka(e,t=0){let n=(0,x.createImageServiceRequest)(eo(e));return(0,x.imageServiceRequestToString)({...n,type:`image`,region:{full:!0},size:{max:!0,confined:!1,upscaled:!1},rotation:Qa(t),quality:`default`,format:`jpg`})}function qa(e){return`${e.x},${e.y},${e.width},${e.height}`}function Ja(e,t){let n=e?.type===`SpecificResource`?e.source:e,r=typeof n==`string`?n:n?.id;if(typeof r!=`string`)return!1;let[i,a]=r.split(`#`,2);if(i!==t.id)return!1;let o=Array.isArray(e?.selector)?e.selector:e?.selector?[e.selector]:[];if(!o.length&&!a)return!0;let s=o.find(e=>e?.spatial||typeof e?.value==`string`&&e.value.startsWith(`xywh=`)),c=s?.spatial,l=a||s?.value;if(!c&&typeof l==`string`&&l.startsWith(`xywh=`)){let[e,t,n,r]=l.replace(/^xywh=(?:pixel:)?/,``).split(/[,&]/).slice(0,4).map(Number);c={x:e,y:t,width:n,height:r}}return c?Number(c?.x)===0&&Number(c?.y)===0&&Number(c?.width)===Number(t?.width)&&Number(c?.height)===Number(t?.height):!1}function Ya(e,t){return Array.isArray(e)?e.map(e=>Ja(e,t)?Ya(e,t):e):typeof e==`string`?t.id:e?.type===`SpecificResource`?{...e,source:typeof e.source==`string`?t.id:e.source?.id?.includes(`#`)?{...e.source,id:t.id}:e.source,selector:void 0}:e}function Xa(e,t,n,r){let i=Za(e.source.id),a=i||(0,x.createImageServiceRequest)(eo(e.service)),o=n===void 0?i?.rotation||{angle:0}:Qa(n);return(0,x.imageServiceRequestToString)({...a,type:`image`,region:t?{x:t.x,y:t.y,w:t.width,h:t.height}:{full:!0},size:r?{max:!1,confined:!1,upscaled:!1,width:r}:{max:!0,confined:!1,upscaled:!1},rotation:o,quality:i?.quality||`default`,format:i?.format||`jpg`})}function Za(e){if(typeof e!=`string`)return null;try{let t=(0,x.parseImageServiceRequest)(e);return t.type===`image`?t:null}catch{return null}}function Qa(e){let t=String(e??0),n=Number(t.replace(/^!/,``));return{angle:Number.isFinite(n)?n:0,...t.startsWith(`!`)?{mirror:!0}:{}}}function $a(e){let t=Number(String(e??0).replace(/^!/,``)),n=Number.isFinite(t)?(t%360+360)%360:0;return[0,90,180,270].includes(n)?n:0}function eo(e){return{...e,id:e.id||e[`@id`],type:e.type||e[`@type`]}}function to(e,t){let n=0;for(let r of t?.items||[]){let t=e.get(r,{skipSelfReturn:!1})||r;for(let r of t?.items||[]){let t=e.get(r,{skipSelfReturn:!1})||r;(Array.isArray(t?.motivation)?t.motivation:[t?.motivation]).includes(`painting`)&&n++}}return n}const no={id:`@exhibition/image-crop-editor`,label:`Media`,supports:{edit:!0,sortKey:`annotation-target`,properties:[`body`],resourceTypes:[`Annotation`],custom:({resource:e},t)=>{let n=t.get(e,{skipSelfReturn:!1});return!!(n&&ka(n,e=>fo(t,e)))}},component:()=>(0,p.jsx)(ro,{})};function ro(){let e=(0,d.useVault)(),t=(0,l.useEditor)(),n=(0,d.useCanvas)({id:t.annotation.target.getSourceId()}),r=e.get(t.ref(),{skipSelfReturn:!1}),i=r?ka(r,t=>fo(e,t)):null,a=Aa(i?.selector.region),o=(0,m.useRef)(null),[s,c]=(0,m.useState)(!1),[f,g]=(0,m.useState)(!1),[_,v]=(0,m.useState)(null),y=$a(i?.selector.rotation),b=async t=>{if(!(!i||!n||t===y)){g(!0),v(null);try{let r=await Ga(i.service);Ra(e,{...i,service:r},n,t)}catch(e){v(e instanceof Error?e.message:`The rotation could not be saved`)}finally{g(!1)}}},x=()=>{c(!1),requestAnimationFrame(()=>o.current?.querySelector(`button`)?.focus())};if(!i||!n)return null;let S=(0,p.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[a?(0,p.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 rounded border border-gray-200 bg-gray-50 p-3 text-sm`,children:[(0,p.jsx)(`dt`,{className:`font-semibold text-gray-700`,children:`Position`}),(0,p.jsxs)(`dd`,{className:`text-gray-600`,children:[a.x,`, `,a.y]}),(0,p.jsx)(`dt`,{className:`font-semibold text-gray-700`,children:`Size`}),(0,p.jsxs)(`dd`,{className:`text-gray-600`,children:[a.width,` × `,a.height]})]}):(0,p.jsx)(`p`,{className:`rounded border border-gray-200 bg-gray-50 p-3 text-sm text-gray-600`,children:`This image currently uses the full image. Create a crop to select a smaller visible region.`}),(0,p.jsx)(`span`,{ref:o,children:(0,p.jsx)(h.ActionButton,{onPress:()=>c(!0),children:a?`Edit crop`:`Create crop`})})]}),C=(0,p.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,p.jsx)(`div`,{className:`grid grid-cols-4 gap-2`,"aria-label":`Image rotation`,children:[0,90,180,270].map(e=>(0,p.jsxs)(h.ActionButton,{"aria-pressed":e===y,primary:e===y,isDisabled:f,onPress:()=>b(e),children:[e,`°`]},e))}),_?(0,p.jsx)(`p`,{className:`text-sm text-red-700`,children:_}):null]});return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(u.MediaEditor,{additionalSections:[{label:`Image crop`,initialOpen:!!a,children:S},{label:`Image rotation`,initialOpen:y!==0,children:C}]}),s?(0,p.jsx)(io,{crop:i,canvas:n,onClose:x,vault:e}):null]})}function io({crop:e,canvas:t,vault:n,onClose:r}){let[i,a]=(0,m.useState)(()=>Wa(e.service)?e.service:null),[o,s]=(0,m.useState)(null),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1);(0,m.useEffect)(()=>{let t=!0;return Ga(e.service).then(e=>{t&&a(e)}).catch(e=>{t&&s(e instanceof Error?e.message:`Unable to load the image service`)}),()=>{t=!1}},[e.service]);let f=Wa(i),g=Aa(e.selector.region)||(f?{x:0,y:0,width:f.width,height:f.height}:null),_=f?Ba(f.width,f.height,e.selector.rotation):null,v=f&&g?Ha(g,f,e.selector.rotation):null,y=i?.id||i?.[`@id`],b=(0,m.useCallback)(async a=>{if(a.cancelled||!a.boundingBox||!f)return l(!1);d(!0),s(null);try{Fa(n,{...e,service:i},t,{...a,boundingBox:Ua(a.boundingBox,f,e.selector.rotation)}),r()}catch(e){s(e instanceof Error?e.message:`The crop could not be saved`),d(!1)}},[t,e,r,i,n]),x=(0,m.useCallback)(e=>s(e),[]);return(0,p.jsx)(h.Modal,{title:Aa(e.selector.region)?`Edit image crop`:`Create image crop`,onClose:r,className:`max-w-5xl`,height:`80vh`,disableAnimation:!0,children:(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col p-4`,children:[o?(0,p.jsx)(uo,{message:o}):f&&_&&v&&y?(0,p.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden rounded border border-gray-200 bg-gray-950`,children:[(0,p.jsx)(ao,{crop:e,service:i,dimensions:_,initialRegion:v,editing:c,onEditingChange:l,onResolve:b,onError:x}),u?(0,p.jsx)(`div`,{className:`absolute inset-0 z-20 grid place-items-center bg-black/40 text-sm font-semibold text-white`,children:`Saving crop…`}):null]}):(0,p.jsx)(`div`,{className:`grid min-h-[20rem] flex-1 place-items-center text-sm text-gray-500`,children:`Loading full image…`}),(0,p.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,p.jsx)(h.ActionButton,{onPress:r,children:`Cancel`})})]})})}function ao({crop:e,service:t,dimensions:n,initialRegion:r,editing:i,onEditingChange:a,onResolve:o,onError:s}){let c=(0,m.useRef)(()=>void 0),l=(0,m.useMemo)(()=>oo(e,t,n,e.selector.rotation),[e.annotationRef.id,e.selector.rotation,n.height,n.width,t]),u=(0,m.useMemo)(()=>{let e=new M.Vault;return e.loadManifestSync(l.id,l),e},[l]),f=(0,m.useMemo)(()=>function(){return(0,p.jsx)(so,{bounds:{x:0,y:0,width:n.width,height:n.height},initialRegion:r,changeCropRef:c,onEditingChange:a,onResolve:o,onError:s})},[n.height,n.width,r.height,r.width,r.x,r.y,a,s,o]);return(0,p.jsx)(d.VaultProvider,{vault:u,children:(0,p.jsx)(d.AtlasStoreReactContext.Provider,{value:null,children:(0,p.jsx)(d.CanvasPanel,{manifest:l.id,startCanvas:l.items[0].id,pagingEnabled:!1,padding:0,components:{ViewerControls:f},annotations:i?null:(0,p.jsx)(co,{region:r,onChange:()=>c.current()})})})})}function oo(e,t,n,r){let i=`${e.annotationRef.id}/crop-editor/manifest`,a=`${i}/canvas`,o=`${a}/painting-page`;return{"@context":`http://iiif.io/api/presentation/3/context.json`,id:i,type:`Manifest`,label:{en:[`Image crop editor`]},items:[{id:a,type:`Canvas`,width:n.width,height:n.height,items:[{id:o,type:`AnnotationPage`,items:[{id:`${o}/painting`,type:`Annotation`,motivation:`painting`,target:a,body:{id:Ka(t,r),type:`Image`,format:`image/jpeg`,width:n.width,height:n.height}}]}]}]}}function so({bounds:e,initialRegion:t,changeCropRef:n,onEditingChange:r,onResolve:i,onError:a}){let o=(0,m.useMemo)(()=>(0,p.jsx)(lo,{}),[]),{requestAnnotation:s,cancelRequest:c,requestId:l,isActive:u,busy:f}=(0,d.useRequestAnnotation)(),g=(0,m.useRef)(c);g.current=c,(0,m.useEffect)(()=>()=>g.current(),[]);let _=()=>{r(!0),s({type:`box`,bounds:e,selector:t,annotationPopup:o}).then(e=>{if(e)return i(e);r(!1)}).catch(e=>{r(!1),a(e instanceof Error?e.message:`The crop editor could not be opened`)})};return n.current=_,u?null:(0,p.jsx)(`div`,{className:`absolute bottom-3 right-3 z-20 rounded bg-white p-2 shadow-lg`,children:(0,p.jsx)(h.ActionButton,{primary:!0,isDisabled:!l||f,onPress:_,children:`Change crop`})})}function co({region:e,onChange:t}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`box`,{html:!0,relativeStyle:!0,interactive:!1,target:e,style:{backgroundColor:`rgba(250, 204, 21, 0.18)`,border:`6px solid #facc15`,boxShadow:`inset 0 0 0 2px #111827, inset 0 0 20px rgba(250, 204, 21, 0.65)`,boxSizing:`border-box`}}),(0,p.jsx)(N.HTMLPortal,{target:e,relative:!0,interactive:!0,children:(0,p.jsx)(`button`,{type:`button`,"aria-label":`Change crop`,title:`Change crop`,onClick:t,className:`absolute inset-0 cursor-pointer bg-transparent text-left`,style:{border:0,padding:0},children:(0,p.jsx)(`span`,{className:`absolute left-2 top-2 rounded px-3 py-1.5 text-sm font-semibold shadow-lg`,style:{background:`rgba(17, 24, 39, 0.94)`,border:`2px solid #fde047`,color:`#fde047`},children:`Change crop`})})})]})}function lo(){let{saveAnnotation:e,cancelRequest:t}=(0,d.useCurrentAnnotationActions)();return(0,p.jsxs)(`div`,{className:`flex gap-2 rounded bg-white p-2 shadow-lg`,children:[(0,p.jsx)(h.ActionButton,{onPress:()=>t(),children:`Discard`}),(0,p.jsx)(h.ActionButton,{primary:!0,onPress:e,children:`Confirm`})]})}function uo({message:e}){return(0,p.jsx)(`div`,{role:`alert`,className:`grid min-h-[20rem] place-items-center rounded border border-red-200 bg-red-50 p-6 text-center text-sm text-red-800`,children:(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`font-semibold`,children:`The full image could not be loaded`}),(0,p.jsx)(`div`,{className:`mt-1`,children:e})]})})}function fo(e,t){return t?.id&&e.get(t,{preserveSpecificResources:!0,skipSelfReturn:!1})||t}function po(e){return(0,p.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,...e,children:(0,p.jsx)(`path`,{fill:`currentColor`,d:`M9 16.17L4.83 12l-1.42 1.41L9 19L21 7l-1.41-1.41z`})})}function mo({value:e,onChange:t}){let[n]=(0,m.useState)(()=>mr(e)),r=(0,m.useRef)(e);return(0,p.jsx)(ho,{label:n.label??``,summary:n.summary,onChange:({label:e,summary:n})=>{r.current=hr(e,n),t(r.current)}})}function ho({label:e,summary:t,onChange:n}){let[r,i]=(0,m.useState)(e),a=(0,m.useRef)(e),o=(0,m.useRef)(t),s=(e,t)=>{n({label:e,summary:t})};return(0,p.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,p.jsxs)(`label`,{className:`block text-sm font-medium text-slate-700`,children:[`Label`,(0,p.jsx)(`input`,{className:`mt-1 w-full rounded border border-slate-200 bg-white px-3 py-2 text-sm text-slate-900 outline-none focus:border-me-primary-400 focus:ring-1 focus:ring-me-primary-100`,value:r,onChange:e=>{let t=e.currentTarget.value;a.current=t,i(t),s(t,o.current)}})]}),(0,p.jsxs)(`div`,{className:`block text-sm font-medium text-slate-700`,children:[`Summary`,(0,p.jsx)(`div`,{className:`mt-1`,children:(0,p.jsx)(h.HTMLEditor,{value:o.current,onChange:e=>{o.current=e,s(a.current,e)}})})]})]})}function go({value:e}){let{label:t,summary:n}=mr(e);return(0,p.jsx)(_o,{label:t??``,summary:n})}function _o({label:e,summary:t}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`whitespace-nowrap overflow-ellipsis w-full overflow-x-hidden`,children:e||(0,p.jsx)(`span`,{className:`opacity-50`,children:`Untitled`})}),(0,p.jsx)(`div`,{className:`exhibition-tour-step-body text-gray-500 text-sm bg-white line-clamp-2 prose-headings:mt-1 prose-headings:mb-1 prose-sm`,dangerouslySetInnerHTML:{__html:ir(t)}})]})}function vo(){let e=(0,l.useAtlasStore)(),t=(0,f.useStore)(e,e=>e.polygon),[n,r]=(0,d.useCurrentAnnotationMetadata)(),{cancelRequest:i,saveAnnotation:a}=(0,d.useCurrentAnnotationActions)();return(0,p.jsxs)(`div`,{className:`border border-gray-300 hover:border-me-500 shadow-sm rounded bg-white relative`,children:[(0,p.jsxs)(`div`,{className:`bg-me-primary-500 text-white p-2 m-1 rounded flex gap-2`,children:[(0,p.jsx)(h.TargetIcon,{}),`Draw a box on the canvas`]}),(0,p.jsx)(`div`,{className:`p-3`,children:(0,p.jsx)(mo,{value:n.bodyValue??`<p>Description</p>`,onChange:e=>r({bodyValue:e})})}),(0,p.jsxs)(`div`,{className:`flex gap-2 p-3`,children:[(0,p.jsxs)(h.ActionButton,{isDisabled:t?.points.length===0,onPress:()=>a(),children:[(0,p.jsx)(po,{}),` Finish editing`]}),(0,p.jsxs)(h.ActionButton,{className:`gap-2 flex`,onPress:()=>i(),children:[(0,p.jsx)(h.DeleteIcon,{}),` Delete`]})]})]})}const yo=[{name:`Black`,value:`#121212`},{name:`Red`,value:`#E5484D`},{name:`Orange`,value:`#F76B15`},{name:`Amber`,value:`#FFB224`},{name:`Green`,value:`#46A758`},{name:`Teal`,value:`#12A594`},{name:`Blue`,value:`#0091FF`},{name:`Indigo`,value:`#3E63DD`},{name:`Purple`,value:`#8E4EC6`},{name:`Pink`,value:`#E93D82`}];function bo(e){if(!e)return;let t=e.match(/#[0-9a-fA-F]{3,8}|rgba?\([^)]*\)|hsla?\([^)]*\)/);return t?t[0]:void 0}function xo(e,t){return!e||!t?!1:e.toLowerCase()===t.toLowerCase()}function So(){let e=(0,d.useAnnotation)(),t=(0,l.useGenericEditor)(e)?.annotation?.target;if(!e||!t)return null;let n=t.getBoxStyle(),r=bo(n.border)??n.borderColor,i=e=>{e?t.setBorder(`3px solid ${e}`):t.setBorder(void 0)};return(0,p.jsx)(`span`,{title:`Choose a border colour for this tour step's highlight`,className:`inline-flex`,children:(0,p.jsxs)(v.DialogTrigger,{children:[(0,p.jsx)(v.Button,{"aria-label":`Tour step border colour`,className:`flex-none w-6 h-6 rounded-full border border-gray-300 shadow-sm cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-me-500`,style:r?{backgroundColor:r}:{backgroundImage:`linear-gradient(45deg, transparent 45%, #d1d5db 45%, #d1d5db 55%, transparent 55%)`}}),(0,p.jsx)(v.Popover,{placement:`bottom`,style:{zIndex:1000010},children:(0,p.jsx)(`div`,{className:`manifest-editor`,children:(0,p.jsx)(v.Dialog,{className:`outline-none bg-white rounded-lg shadow-lg border border-gray-200 p-2`,children:({close:e})=>(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`text-[11px] font-semibold text-gray-500 px-1 pb-1.5`,children:`Border colour`}),(0,p.jsx)(`div`,{className:`grid grid-cols-5 gap-1.5`,children:yo.map(t=>{let n=xo(r,t.value);return(0,p.jsx)(`button`,{type:`button`,"aria-label":t.name,title:t.name,onClick:()=>{i(t.value),e()},className:`w-6 h-6 rounded-full border cursor-pointer outline-none transition-transform hover:scale-110 focus-visible:ring-2 focus-visible:ring-me-500 ${n?`ring-2 ring-offset-1 ring-me-500 border-transparent`:`border-gray-300`}`,style:{backgroundColor:t.value}},t.value)})}),(0,p.jsx)(`button`,{type:`button`,title:`Remove the border colour`,onClick:()=>{i(null),e()},className:`mt-2 w-full text-[11px] text-gray-500 hover:text-me-500 rounded px-1 py-1 cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-me-500`,children:`None`})]})})})})]})})}function Co(e){let t=Array.isArray(e)?e:[];return t.includes(`left`)?`left`:t.includes(`right`)?`right`:``}function wo(e,t){let n=(Array.isArray(e)?e:[]).filter(e=>e!==`left`&&e!==`right`);return t&&n.push(t),n}function To(e,t){let n=new Set(xt.map(e=>e.value)),r=(Array.isArray(e)?e:[]).filter(e=>!n.has(e));return t&&r.push(t),r}function Eo({annotation:e}){let t=(0,d.useVault)(),n=(0,d.useCanvas)(),r=H(e=>e.selectTourStep),i=Co(e?.behavior),a=wn(Array.isArray(n?.behavior)?n.behavior:[]),o=Array.isArray(e?.behavior)?e.behavior:[],s=o.some(e=>e.startsWith(`float-`)),c=Tn(o);if(!e?.id)return null;let l=()=>{r(e.id)},u=n=>{t.modifyEntityField({id:e.id,type:`Annotation`},`behavior`,wo(e.behavior,n)),l()};return(0,p.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[a?null:(0,p.jsx)(`div`,{className:`grid grid-cols-3 overflow-hidden rounded border border-slate-200 text-xs font-semibold`,children:[{value:``,label:`Default`},{value:`left`,label:`Left`},{value:`right`,label:`Right`}].map(e=>(0,p.jsx)(`button`,{type:`button`,className:i===e.value?`bg-me-primary-500 px-2 py-1 text-white`:`bg-white px-2 py-1 text-slate-700`,onClick:()=>u(e.value),children:e.label},e.label))}),a?(0,p.jsx)(Do,{value:s?c:``,onChange:n=>{t.modifyEntityField({id:e.id,type:`Annotation`},`behavior`,To(e.behavior,n)),l()}}):null]})}function Do({value:e,onChange:t}){let n=!!e;return(0,p.jsx)(`span`,{title:`Floating position override`,className:`inline-flex`,children:(0,p.jsxs)(v.DialogTrigger,{children:[(0,p.jsxs)(v.Button,{"aria-label":`Floating position override`,className:`relative inline-grid h-8 w-8 place-items-center rounded-md border bg-white shadow-sm outline-none transition-colors hover:border-me-primary-400 focus-visible:ring-2 focus-visible:ring-me-500 ${n?`border-me-primary-500 text-me-primary-600`:`border-slate-200 text-slate-500`}`,children:[(0,p.jsx)(Ct,{position:e}),n?(0,p.jsx)(`span`,{className:`absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full bg-me-primary-500 ring-2 ring-white`}):null]}),(0,p.jsx)(v.Popover,{placement:`bottom`,style:{zIndex:1000010},children:(0,p.jsx)(`div`,{className:`manifest-editor`,children:(0,p.jsx)(v.Dialog,{className:`rounded-lg border border-slate-200 bg-white p-2 shadow-lg outline-none`,children:({close:n})=>(0,p.jsx)(`div`,{className:`grid grid-cols-3 gap-1`,children:Tt(`No override`).map(r=>(0,p.jsx)(`button`,{type:`button`,"aria-label":r.label,title:r.label,onClick:()=>{t(r.value),n()},className:`grid h-8 w-8 place-items-center rounded-md border outline-none transition-colors hover:border-me-primary-400 hover:bg-me-primary-50 focus-visible:ring-2 focus-visible:ring-me-500 ${e===r.value?`border-me-primary-500 bg-me-primary-50 text-me-primary-600`:`border-slate-200 bg-white text-slate-500`}`,children:(0,p.jsx)(Ct,{position:r.value})},r.value||`none`))})})})})]})})}function Oo({editAlignment:e=!1,highlightProps:t,index:n=0,tourStyle:r=`linear`,useSlideshowWorkbench:i=!1}){let a=(0,d.useAnnotation)(),o=(0,d.useVault)(),s=ko(a?.body||[],o),c=(0,m.useRef)(s?.resource?.value||``),l=H(e=>e.startTourStepRepositioning),f=H(e=>e.selectTourStep),g=U(e=>e.requestTab),_=U(e=>e.setShowTourSteps),{target:v,isPending:y,cancelRequest:b,busy:x,requestAnnotationFromTarget:S,deleteAnnotation:C}=(0,u.useAnnotationEditor)(),w=!v,[T,E]=(0,m.useState)(!1),D=()=>(a?.id&&f(a.id),!i||!a?.id?!1:(_(!0),l(a.id),g(`tour`),!0));return(0,m.useEffect)(()=>{T||(c.current=s?.resource?.value||``)},[s?.resource?.value,T]),(0,m.useEffect)(()=>{T&&!y&&E(!0)},[y,T]),(0,p.jsxs)(`div`,{...t,className:`exhibition-tour-step-card border shadow-sm rounded bg-white relative ${r===`non-linear`?`border-gray-900 hover:border-black`:`border-gray-300 hover:border-me-500`}`,onClick:D,children:[(0,p.jsx)(`div`,{className:`absolute right-3 top-3 z-10 rounded-full px-2 py-1 text-xs font-semibold`,style:{backgroundColor:`#f5f5f5`,color:`#b84c74`},children:r===`non-linear`?`Point ${n+1}`:`Step ${n+1}`}),(0,p.jsxs)(`div`,{className:`relative`,children:[w?(0,p.jsx)(`div`,{className:`mx-3 mt-3 rounded border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-900`,children:`Invalid region. Select Edit to draw a new region.`}):null,T?(0,p.jsx)(`div`,{className:`p-3`,children:(0,p.jsx)(mo,{value:s?.resource?.value||``,onChange:e=>c.current=e})}):(0,p.jsx)(`div`,{className:`px-3 pt-3`,children:(0,p.jsx)(go,{value:s?.resource?.value||``})})]}),(0,p.jsxs)(`div`,{className:`flex gap-2 p-2`,onClick:e=>e.stopPropagation(),children:[T&&y?(0,p.jsx)(p.Fragment,{children:(0,p.jsxs)(h.ActionButton,{primary:!0,onPress:()=>{jo(o,a,s,c.current),E(!1),b()},children:[(0,p.jsx)(po,{}),` Finish editing`]})}):(0,p.jsxs)(h.ActionButton,{isDisabled:x,onPress:()=>{i&&a?.id&&(_(!0),l(a.id),g(`tour`)),E(!0),S().then(()=>{E(!1)})},children:[(0,p.jsx)(h.EditTextIcon,{}),` Edit`]}),(0,p.jsxs)(h.ActionButton,{className:`gap-2 flex`,onPress:()=>C(),children:[(0,p.jsx)(h.DeleteIcon,{}),` Delete`]}),(0,p.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[e?(0,p.jsx)(Eo,{annotation:a}):null,(0,p.jsx)(So,{})]})]}),r===`linear`?(0,p.jsx)(`div`,{className:`absolute -bottom-5 left-5 h-5 border-l-2 border-gray-300 w-0`}):null]})}function ko(e,t){for(let n=0;n<e.length;n++){let r=e[n],i=Ao(r,t);if(i?.type===`TextualBody`||i?.type===`Text`||i?.format===`text/html`)return{ref:r?.id?{id:r.id,type:`ContentResource`}:null,resource:i,bodyIndex:n}}return null}function Ao(e,t){return!e?.id||e.value?e:t.get(e,{skipSelfReturn:!1})||e}function jo(e,t,n,r){if(!t||!n)return;if(n.ref?.id){e.modifyEntityField(n.ref,`value`,r);return}let i=Array.isArray(t.body)?t.body:[];e.modifyEntityField({id:t.id,type:`Annotation`},`body`,[...i.slice(0,n.bodyIndex),{...n.resource,value:r},...i.slice(n.bodyIndex+1)])}function Mo({editAlignment:e=!1,originalAnnotationId:t,highlightProps:n,index:r=0,tourStyle:i=`linear`,useSlideshowWorkbench:a=!1}){let o=(0,d.useAnnotationPage)(),s=(0,l.useGenericEditor)(o),c=(0,d.useAnnotation)(),u=(0,d.useCanvas)(),f=(0,d.useVault)(),{edit:g}=(0,l.useLayoutActions)(),[_,v]=(0,m.useState)(!1),y=(0,m.useRef)(No(c?.label)),b=(0,m.useRef)(No(c?.summary)),x=H(e=>e.selectTourStep),S=H(e=>e.startTourStepRepositioning),C=U(e=>e.requestTab),w=U(e=>e.setShowTourSteps),T=u?.items?.[0],E=T?.id&&c?.id?(f.get(T)?.items||[]).findIndex(e=>e.id===c.id):-1,D=()=>{if(t&&confirm(`Are you sure you want to delete this annotation?`)){let e=s.structural.items.getWithoutTracking().findIndex(e=>e.id===t);s.structural.items.deleteAtIndex(e)}},O=()=>(t&&x(t),!a||!t?!1:(w(!0),S(t),C(`tour`),!0)),k=()=>{c&&(f.modifyEntityField({id:c.id,type:`Annotation`},`label`,{en:[y.current]}),f.modifyEntityField({id:c.id,type:`Annotation`},`summary`,nr({en:[b.current]})))};return(0,p.jsxs)(`div`,{...n,className:`exhibition-tour-step-card border shadow-sm rounded bg-white relative ${i===`non-linear`?`border-gray-900 hover:border-black`:`border-gray-300 hover:border-me-500`}`,onClick:O,children:[(0,p.jsx)(`div`,{className:`absolute right-3 top-3 z-10 rounded-full px-2 py-1 text-xs font-semibold`,style:{backgroundColor:`#f5f5f5`,color:`#b84c74`},children:i===`non-linear`?`Point ${r+1}`:`Step ${r+1}`}),(0,p.jsx)(`div`,{className:`flex gap-2 mb-2 p-3`,children:(0,p.jsx)(`div`,{className:`flex-1 min-w-0`,children:_?(0,p.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,p.jsx)(ho,{label:y.current,summary:b.current,onChange:({label:e,summary:t})=>{y.current=e,b.current=t}})}):(0,p.jsx)(_o,{label:No(c?.label),summary:No(c?.summary)})})}),(0,p.jsxs)(`div`,{className:`flex gap-2 p-2`,onClick:e=>e.stopPropagation(),children:[_?(0,p.jsxs)(h.ActionButton,{primary:!0,onPress:()=>{k(),v(!1)},children:[(0,p.jsx)(po,{}),` Finish editing`]}):(0,p.jsxs)(h.ActionButton,{onPress:()=>v(!0),children:[(0,p.jsx)(h.EditTextIcon,{}),` Edit`]}),(0,p.jsxs)(h.ActionButton,{className:`gap-2 flex`,onPress:()=>D(),children:[(0,p.jsx)(h.DeleteIcon,{}),` Delete`]}),(0,p.jsx)(h.ActionButton,{onPress:()=>{O()||c&&g({id:c.id,type:`Annotation`},T?{parent:T,property:`items`,index:E}:void 0,{forceOpen:!0})},children:`Edit annotation`}),e?(0,p.jsx)(`div`,{className:`ml-auto flex items-center`,children:(0,p.jsx)(Eo,{annotation:c})}):null]}),i===`linear`?(0,p.jsx)(`div`,{className:`absolute -bottom-5 left-5 h-5 border-l-2 border-gray-300 w-0`}):null]})}function No(e){if(!e)return``;if(typeof e==`string`)return e;if(Array.isArray(e))return e.find(e=>typeof e==`string`)||``;let t=e.en||Object.values(e)[0];return Array.isArray(t)&&t.find(e=>typeof e==`string`)||``}function Po({editAlignment:e=!1,index:t=0,tourStyle:n=`linear`,useSlideshowWorkbench:r=!1}){let[i,{annotationTarget:a,highlightProps:o}]=(0,u.useAnnotationInfo)(),s=(0,m.useMemo)(()=>a?{id:a,type:`Annotation`}:{id:i?.id,type:`Annotation`},[i?.id,a]);return a?(0,p.jsx)(l.ResourceEditingProvider,{resource:s,children:(0,p.jsx)(d.AnnotationContext,{annotation:a,children:(0,p.jsx)(Mo,{editAlignment:e,originalAnnotationId:i?.id,highlightProps:o,index:t,tourStyle:n,useSlideshowWorkbench:r})})}):(0,p.jsx)(l.ResourceEditingProvider,{resource:s,children:(0,p.jsx)(Oo,{editAlignment:e,highlightProps:o,index:t,tourStyle:n,useSlideshowWorkbench:r})})}function Fo({editAlignment:e=!1,reorderable:t=!1,tourStyle:n=`linear`,useSlideshowWorkbench:r=!1}){let i=(0,d.useAnnotationPage)(),a=(0,l.useGenericEditor)(i);return i?t?(0,p.jsx)(p.Fragment,{children:(0,p.jsx)(u.ReorderList,{id:i.id,marginBottom:`0.5em`,items:i.items||[],inlineHandle:!1,reorder:({startIndex:e,endIndex:t})=>a.structural.items.reorder(e,t),renderItem:(t,i)=>(0,p.jsx)(d.AnnotationContext,{annotation:t.id,children:(0,p.jsx)(Po,{index:i,tourStyle:n,editAlignment:e,useSlideshowWorkbench:r})})})}):(0,p.jsx)(p.Fragment,{children:i.items.map((t,i)=>(0,p.jsx)(d.AnnotationContext,{annotation:t.id,children:(0,p.jsx)(Po,{index:i,tourStyle:n,editAlignment:e,useSlideshowWorkbench:r})},t.id))}):null}function Io(e){return e&&[e.x,e.y,e.width,e.height].every(Number.isFinite)&&e.width>0&&e.height>0}function Lo(e){return!e||Array.isArray(e.points)&&e.points.length&&e.points.every(e=>Array.isArray(e)&&Number.isFinite(e[0])&&Number.isFinite(e[1]))}function Ro(e){if(e?.type===`FragmentSelector`){let t=e.value?.replace(/^xywh=/,``).split(`,`).map(Number);return t?.length===4&&t.every(Number.isFinite)&&t[2]>0&&t[3]>0}return e?.type===`SvgSelector`&&typeof e.value==`string`&&!/\b(?:NaN|Infinity|undefined)\b/.test(e.value)}function zo(e,t){let n=Number(t?.width)||1920,r=Number(t?.height)||1080,i=e?.boundingBox;if(Lo(e?.polygon)&&Io(i)&&i.x>=0&&i.y>=0&&i.x+i.width<=n&&i.y+i.height<=r&&Ro(e?.target))return e;let a=$e(t,Io(e?.boundingBox)?e.boundingBox:{x:0,y:0,width:n,height:r});return{...e,polygon:null,boundingBox:a,target:{type:`FragmentSelector`,value:`xywh=${a.x},${a.y},${a.width},${a.height}`}}}const Bo={id:`@exhibition/tour-steps`,supports:{edit:!0,properties:[`annotations`,`behavior`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>ie(e,t)?!t.get(e)?.behavior?.includes(`splash`)&&!ae(e,t)&&!oe(e,t):!1},label:`Tour steps`,component:()=>(0,p.jsx)(Vo,{})};function Vo({mode:e=`advanced`}){let t=(0,d.useCanvas)(),n=t?.annotations[0],r=t?.items[0];return!n||!t||!r?(0,p.jsx)(Ho,{}):(0,p.jsx)(h.Sidebar,{children:(0,p.jsx)(h.SidebarContent,{padding:!0,className:`pb-3`,children:(0,p.jsx)(Uo,{mode:e})})})}function Ho(){let e=(0,d.useCanvas)(),t=(0,l.useInlineCreator)(),n=()=>{e&&t.create(`@manifest-editor/empty-annotation-page`,{label:{en:[`Tour steps`]}},{target:{id:e.id,type:`Canvas`},targetType:`AnnotationPage`,parent:{property:`annotations`,resource:{id:e.id,type:`Canvas`}}})};return(0,p.jsxs)(`div`,{className:`flex flex-col items-center justify-center p-4`,children:[(0,p.jsx)(`div`,{className:`p-4 opacity-50 text-center`,children:`This image does not yet have a tour.`}),(0,p.jsx)(v.Button,{className:`border w-full disabled:opacity-50 border-gray-300 hover:border-me-500 hover:bg-me-50 cursor-pointer shadow-sm rounded p-4 bg-white relative text-[#6a625c] hover:text-me-500`,onPress:()=>n(),children:`Create Tour`})]})}function Uo({mode:e,useSlideshowWorkbench:t=!1}){let n=(0,d.useCanvas)(),r=(0,l.useEditor)(),i=n?.annotations?.[0],a=n?.items?.[0],[o,s]=(0,m.useState)(!1),[c,f]=(0,m.useState)(!1),g=(0,l.useApp)(),_=$t(V()?.type,g.metadata.id),y=_===`slideshow`,b=Array.isArray(n?.behavior)?n.behavior:[],x=_===`scroll`||wn(b),S=U(e=>e.setShowTourSteps),C=U(e=>e.setCenterPanelMode),w=H(e=>e.stopRepositioning),T=H(e=>e.stopTextRepositioning);(0,m.useEffect)(()=>{S(!0),C(`edit`),w(),T()},[C,S,w,T]);let{requestTourStep:E,isPending:D,busy:O}=Go({onBeforeRequest:t?()=>{S(!0),C(`edit`),w(),T()}:void 0}),k=()=>{f(e=>{let t=!e;return C(t?`preview`:`edit`),t})};if(!n)return null;if(!i)return(0,p.jsx)(Ho,{});let A=e===`advanced`&&!!a,j=r.technical.type===`Canvas`&&r.technical.behavior.get()||[],M=y&&j.includes(`non-linear-tour`),N=j.includes(`tour-marker-pin`)?`pin`:`circle`,P=M?`non-linear`:`linear`,F=e=>{if(r.technical.type!==`Canvas`)return;let t=j.filter(e=>e!==Ln);r.technical.behavior.set(e?[...t,Ln]:t)},I=e=>{if(r.technical.type!==`Canvas`)return;let t=j.filter(e=>e!==Rn);r.technical.behavior.set(e===`pin`?[...t,Rn]:t)};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`flex gap-4 border-b pt-4 pb-2 mb-2`,children:[(0,p.jsx)(`h2`,{className:`text-lg font-semibold flex-1`,children:`Tour steps`}),e===`advanced`&&!M?(0,p.jsx)(h.ActionButton,{onPress:()=>s(e=>!e),children:o?`Done`:`Reorder`}):null,e===`advanced`&&x?(0,p.jsx)(h.ActionButton,{onPress:k,children:c?`Done`:`Edit alignment`}):null]}),y?(0,p.jsxs)(`div`,{className:`mb-4 rounded border border-gray-200 bg-white p-3`,children:[(0,p.jsx)(`div`,{className:`mb-2 text-sm font-semibold text-gray-700`,children:`Tour style`}),(0,p.jsx)(yn,{checked:M,label:`Let visitors choose map points`,onChange:F}),(0,p.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-gray-500`,children:`Shows all tour steps as markers that visitors can open in any order.`}),M?(0,p.jsxs)(`div`,{className:`mt-4 space-y-3 border-t border-gray-100 pt-3`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,p.jsx)(`div`,{className:`text-sm font-semibold text-gray-700`,children:`Marker`}),(0,p.jsxs)(`div`,{role:`group`,"aria-label":`Tour marker style`,className:`inline-flex rounded-md border border-gray-200 bg-gray-50 p-0.5`,children:[(0,p.jsx)(Wo,{selected:N===`circle`,onPress:()=>I(`circle`),children:`Circle`}),(0,p.jsx)(Wo,{selected:N===`pin`,onPress:()=>I(`pin`),children:`Pin`})]})]}),(0,p.jsx)(`p`,{className:`text-xs leading-relaxed text-gray-500`,children:`Marker colour follows the exhibition theme annotation text colour.`})]}):null]}):null,(0,p.jsx)(l.ResourceEditingProvider,{resource:n,children:(0,p.jsxs)(d.AnnotationPageContext,{annotationPage:i.id,children:[(0,p.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,p.jsx)(`div`,{className:`text-sm font-semibold text-gray-700`,children:M?`Map points`:`Linear step list`}),(0,p.jsx)(Fo,{reorderable:e===`advanced`&&!M&&o,tourStyle:P,editAlignment:x&&c,useSlideshowWorkbench:t}),O?null:D?(0,p.jsx)(vo,{}):(0,p.jsx)(v.Button,{onPress:E,className:`border disabled:opacity-50 border-gray-300 hover:border-me-500 hover:bg-me-50 cursor-pointer shadow-sm rounded p-4 bg-white relative text-[#6a625c] hover:text-me-500`,children:M?`+ Add map point`:`+ Add new step`})]}),A&&a?(0,p.jsx)(p.Fragment,{children:(0,p.jsx)(u.PromptToAddPaintingAnnotations,{title:(0,p.jsx)(`h3`,{className:`text-md border-b pt-4 pb-2 mb-2`,children:`Available tour steps from images`}),painting:a,page:i,canvasId:n.id})}):null]})})]})}function Wo({children:e,selected:t,onPress:n}){return(0,p.jsx)(v.Button,{"aria-pressed":t,className:`rounded px-2.5 py-1 text-xs font-semibold transition-colors ${t?`bg-white text-me-primary-600 shadow-sm`:`text-gray-500 hover:text-gray-800`}`,onPress:n,children:e})}function Go({onBeforeRequest:e}={}){let t=(0,d.useCanvas)(),n=t?.annotations?.[0],r=(0,l.useInlineCreator)(),{requestAnnotation:i,isPending:a,busy:o}=(0,d.useRequestAnnotation)({onSuccess:e=>{let i=e.metadata.bodyValue??`<p>Description</p>`;if(!e.cancelled&&e.target&&t&&n){let a=zo(e,t);r.create(`@manifest-editor/html-annotation`,{label:{en:[`Tour step`]},body:{en:[i]},motivation:`tagging`},{target:{id:t.id,type:`Canvas`},targetType:`Annotation`,parent:{property:`items`,resource:{id:n.id,type:`AnnotationPage`}},initialData:{selector:a}})}}});return{requestTourStep:()=>{e?.(),i({type:`box`})},isPending:a,busy:o,canRequestTourStep:!!(t&&n)}}function Ko(){let e=V(),t=(0,l.useEditor)(),n=t.technical.duration;return e?.type!==`slideshow`||t.technical.type!==`Canvas`?null:(0,p.jsxs)(u.InputContainer,{$wide:!0,id:n.containerId(),children:[(0,p.jsx)(u.InputLabel,{htmlFor:n.focusId(),children:`Slide duration`}),(0,p.jsx)(u.Input,{id:n.focusId(),min:0,type:`number`,value:n.get()||0,onChange:e=>{let t=e.currentTarget.valueAsNumber;Number.isFinite(t)&&n.set(t)}})]})}const qo={id:`@exhibition/info-box-editor`,supports:{edit:!0,properties:[`label`,`behavior`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>ie(e,t)?ae(e,t):!1},label:`Text box`,component:()=>(0,p.jsx)(Jo,{})};function Jo(){let[e,t]=(0,l.useLocalStorage)(`exhibition-info-box-mode`,`simple`),n=(0,d.useCanvas)(),r=(0,d.useVault)(),i=(0,d.useManifest)(),a=(0,l.useEditor)(),o=tn();if(!n||a.technical.type!==`Canvas`)return null;let s=a.technical.behavior.get()||[],c=Nn(s)||12,f=e=>{let t=s.filter(e=>!e.startsWith(`w-`)&&!e.startsWith(`h-`)),n=s.find(e=>e.startsWith(`h-`));t.push(`w-${e}`),n||t.push(`h-4`),a.technical.behavior.set(t)},m=o.showGridSizing&&i?.items&&n?Pn(n.id,i.items,r):null;return(0,p.jsx)(h.Sidebar,{children:(0,p.jsxs)(h.SidebarContent,{className:`bg-white px-6 pt-5 pb-20`,children:[(0,p.jsx)(`div`,{className:`flex justify-center`,children:(0,p.jsx)(bn,{value:e,onChange:t})}),(0,p.jsxs)(`div`,{className:`mt-8 flex flex-col gap-7`,children:[(0,p.jsx)(Ko,{}),(0,p.jsx)(l.ResourceEditingProvider,{resource:n,children:e===`simple`?(0,p.jsxs)(K,{children:[(0,p.jsx)(q,{children:`Title`}),(0,p.jsx)(`div`,{className:`mt-2`,children:(0,p.jsx)(u.LanguageMapEditor,{dispatchType:`label`,disableMultiline:!0,disallowHTML:!0})})]}):(0,p.jsxs)(K,{children:[(0,p.jsx)(q,{children:`Label & summary`}),(0,p.jsxs)(`div`,{className:`mt-2 flex flex-col gap-3`,children:[(0,p.jsx)(u.LanguageMapEditor,{dispatchType:`label`,disableMultiline:!0,disallowHTML:!0}),(0,p.jsx)(va,{resource:n})]})]})}),e===`simple`&&o.showGridSizing?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(K,{children:[(0,p.jsx)(q,{children:`Width`}),(0,p.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:Mn.map(e=>(0,p.jsx)(vn,{selected:c===e.value,onClick:()=>f(e.value),children:e.label},e.value))})]}),m?(0,p.jsxs)(K,{children:[(0,p.jsxs)(q,{children:[`Fit alongside `,m.neighbour,` slide`]}),(0,p.jsx)(`div`,{className:`mt-3`,children:(0,p.jsxs)(vn,{selected:c===m.width,onClick:()=>f(m.width),children:[`w-`,m.width,` — fills remaining space`]})})]}):null,(0,p.jsxs)(`div`,{className:`text-center text-xs`,style:{color:G.muted},children:[`w-`,c]})]}):e===`advanced`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`px-2`,children:(0,p.jsx)(u.InputContainer,{$wide:!0,children:(0,p.jsx)(u.DimensionsTriplet,{widthId:a.technical.width.containerId(),width:a.technical.width.get()||0,changeWidth:e=>a.technical.width.set(e),heightId:a.technical.height.containerId(),height:a.technical.height.get()||0,changeHeight:e=>a.technical.height.set(e)})})}),o.showGridSizing?(0,p.jsx)(u.BehaviorEditor,{behavior:s,onChange:e=>a.technical.behavior.set(e),configs:[{id:`size`,component:(e,t)=>(0,p.jsx)(un,{behaviors:e,setBehaviors:t}),label:{en:[`Size`]},type:`custom`,initialOpen:!0,supports:e=>e.startsWith(`w-`)||e.startsWith(`h-`)}]}):null]}):null]})]})})}const Yo=`editorial-text`;function Xo(){let e=(0,d.useCanvas)(),t=e?.items?.[0]?{id:e.items[0].id,type:`AnnotationPage`}:void 0,[,n]=(0,l.useCreator)(t,`items`,`Annotation`,e?{id:e.id,type:`Canvas`}:void 0,{isPainting:!0}),{selectedAnnotationId:r,repositioningAnnotationId:i,selectedTextRegion:a,repositioningTextRegion:o,selectAnnotation:s,startRepositioning:c,stopRepositioning:u,selectTextRegion:f,startTextRepositioning:m,stopTextRepositioning:h}=H(),g=U(e=>e.setShowTourSteps),_=(0,d.useVaultSelector)((t,n)=>e?Je(n,e):[],[e?.id,t?.id]),v=Qe(e).text,y=_.length||v;return!e||!t?(0,p.jsxs)(`div`,{children:[(0,p.jsx)(as,{children:`Content on this slide`}),(0,p.jsx)(`p`,{className:`exhibition-workbench-muted mt-2 text-sm leading-relaxed`,children:`This slide does not have a content layer yet.`})]}):(0,p.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(as,{children:`Content on this slide`}),(0,p.jsx)(`p`,{className:`exhibition-workbench-muted mt-2 text-sm leading-relaxed`,children:`Select a painting annotation to highlight it in the workbench. Use the centre panel to add, position, and edit slide content.`})]}),y?(0,p.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[v?(0,p.jsx)(Qo,{box:v,selected:a===Yo,repositioning:o===Yo,onSelect:()=>{g(!1),f(Yo)},onReposition:()=>{g(!1),m(Yo)},onStopReposition:h}):null,_.map((e,t)=>(0,p.jsx)(Zo,{layer:e,index:t,selected:r===e.annotation.id,repositioning:i===e.annotation.id,onSelect:()=>{g(!1),s(e.annotation.id)},onReposition:()=>{g(!1),c(e.annotation.id)},onStopReposition:u,onAdvancedEdit:()=>n.edit({id:e.annotation.id,type:`Annotation`},t)},e.annotation.id))]}):(0,p.jsx)(`div`,{className:`exhibition-slideshow-content-empty rounded-lg border border-dashed border-slate-200 bg-slate-50 p-4 text-sm`,children:`No painting annotations on this slide yet.`})]})}function Zo({layer:e,index:t,selected:n,repositioning:r,onSelect:i,onReposition:a,onStopReposition:o,onAdvancedEdit:s}){let c=(0,d.useVault)(),l=(0,u.useAnnotationThumbnail)({annotationId:e.annotation.id,options:{maxWidth:96,maxHeight:96}}),f=rs(e.annotation,c),m=es(e,f),h=ts(e,f,t),g=ns(e,f,m);return(0,p.jsxs)(`div`,{className:[`exhibition-slideshow-content-item rounded-lg border bg-white p-3 transition`,n?`exhibition-slideshow-content-item-selected border-me-primary-500 bg-me-primary-50 ring-2 ring-me-primary-100`:`border-slate-200`].join(` `),children:[(0,p.jsxs)(v.Button,{className:`flex w-full items-center gap-3 border-none bg-transparent p-0 text-left`,onPress:i,children:[(0,p.jsx)($o,{thumbnailUrl:l?.id,type:m}),(0,p.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,p.jsx)(`span`,{className:`block text-[11px] font-semibold uppercase tracking-wide text-me-primary-500`,children:m}),(0,p.jsx)(`span`,{className:`mt-0.5 block truncate text-sm font-semibold`,children:h}),(0,p.jsx)(`span`,{className:`exhibition-workbench-muted mt-0.5 block truncate text-xs`,children:g})]})]}),(0,p.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3`,children:[(0,p.jsx)(`span`,{className:`exhibition-workbench-muted text-xs`,children:r?`Drag or resize in the workbench`:n?`Selected in workbench`:`Click to select on slide`}),(0,p.jsxs)(`div`,{className:`flex gap-2`,children:[(0,p.jsx)(v.Button,{className:`rounded-md border border-me-primary-200 bg-me-primary-50 px-3 py-1.5 text-xs font-semibold text-me-primary-600 transition hover:bg-me-primary-100`,onPress:r?o:a,children:r?`Done moving`:`Reposition`}),(0,p.jsx)(v.Button,{className:`rounded-md border border-slate-200 bg-white px-3 py-1.5 text-xs font-semibold text-slate-700 transition hover:bg-slate-50`,onPress:s,children:`Advanced edit`})]})]})]})}function Qo({box:e,selected:t,repositioning:n,onSelect:r,onReposition:i,onStopReposition:a}){return(0,p.jsxs)(`div`,{className:[`exhibition-slideshow-content-item rounded-lg border bg-white p-3 transition`,t?`exhibition-slideshow-content-item-selected border-me-primary-500 bg-me-primary-50 ring-2 ring-me-primary-100`:`border-slate-200`].join(` `),children:[(0,p.jsxs)(v.Button,{className:`flex w-full items-center gap-3 border-none bg-transparent p-0 text-left`,onPress:r,children:[(0,p.jsx)($o,{type:`Text`}),(0,p.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,p.jsx)(`span`,{className:`block text-[11px] font-semibold uppercase tracking-wide text-me-primary-500`,children:`Editorial text`}),(0,p.jsx)(`span`,{className:`mt-0.5 block truncate text-sm font-semibold`,children:`Slide label and summary`}),(0,p.jsxs)(`span`,{className:`exhibition-workbench-muted mt-0.5 block truncate text-xs`,children:[`Position `,Math.round(e.x),`, `,Math.round(e.y),` ·`,` `,Math.round(e.width),` x `,Math.round(e.height)]})]})]}),(0,p.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3`,children:[(0,p.jsx)(`span`,{className:`exhibition-workbench-muted text-xs`,children:n?`Drag or resize in the workbench`:t?`Selected in workbench`:`Click to select on slide`}),(0,p.jsx)(v.Button,{className:`rounded-md border border-me-primary-200 bg-me-primary-50 px-3 py-1.5 text-xs font-semibold text-me-primary-600 transition hover:bg-me-primary-100`,onPress:n?a:i,children:n?`Done moving`:`Reposition`})]})]})}function $o({thumbnailUrl:e,type:t}){return(0,p.jsx)(`div`,{className:`flex h-16 w-16 shrink-0 items-center justify-center overflow-hidden rounded-md bg-[#f8f6f3] text-xs font-semibold text-black/60 ring-1 ring-slate-200`,children:e?(0,p.jsx)(`img`,{alt:``,className:`h-full w-full object-cover`,src:e}):(0,p.jsx)(`span`,{children:t})})}function es(e,t){return e.imageUrl?`Image`:e.youtubeId?`YouTube`:e.videoUrl?`Video`:e.html===null?t?.type===`Canvas`?`Canvas`:t?.type?String(t.type):`Media`:`Text`}function ts(e,t,n){let r=(0,u.getInternationalStringText)(t?.label,``),i=(0,u.getInternationalStringText)(e.annotation.label,``),a=e.html?is(e.html).slice(0,80):``;return r||i||a||`${es(e,t)} layer ${n+1}`}function ns(e,t,n){let r=`${Math.round(e.box.x)}, ${Math.round(e.box.y)} · ${Math.round(e.box.width)} x ${Math.round(e.box.height)}`;return[t?.format||t?.profile||t?.type||`${n} painting annotation`,`Position ${r}`].filter(Boolean).join(` · `)}function rs(e,t){let n=Array.isArray(e?.body)?e.body[0]:e?.body;return(0,u.resolveContentResource)(t,n)}function is(e){return e.replace(/<br\s*\/?>/gi,` `).replace(/<\/p>/gi,` `).replace(/<[^>]+>/g,` `).replace(/\s+/g,` `).trim()}function as({children:e}){return(0,p.jsx)(`div`,{className:`exhibition-workbench-muted text-sm font-semibold`,children:e})}const os=[{id:`layout`,label:`Layout`},{id:`images`,label:`Images`},{id:`summary`,label:`Text content`},{id:`tour`,label:`Tour steps`}],ss=[{id:`layout`,label:`Layout`},{id:`images`,label:`Images`},{id:`content`,label:`Content`},{id:`summary`,label:`Text content`},{id:`tour`,label:`Tour steps`}],cs=[{value:`simple`,label:`Simple`},{value:`advanced`,label:`Advanced`}],ls={track:`#f5eaf0`,active:`#b84c74`,inactiveText:`#8b3f61`,activeText:`#ffffff`,activeShadow:`0 1px 3px rgba(15, 23, 42, 0.18)`},us={id:`@exhibition/workbench-editor`,supports:{edit:!0,properties:[`label`,`summary`,`requiredStatement`,`behavior`,`annotations`],resourceTypes:[`Canvas`],custom:({resource:e},t)=>ie(e,t)?ae(e,t):!1},label:`Canvas`,component:()=>(0,p.jsx)(fs,{})},ds={...us,id:`@exhibition/slideshow-workbench-editor`,supports:{...us.supports,custom:({resource:e},t)=>ie(e,t)},component:()=>(0,p.jsx)(fs,{preset:`slideshow`})};function fs({preset:e=`default`}){let[t,n]=(0,l.useLocalStorage)(`exhibition-right-panel-mode`,`simple`),r=(0,d.useCanvas)(),i=(0,d.useVault)(),a=!!r?.behavior?.includes(`info`),o=Ke(i,r),s=(0,m.useMemo)(()=>(e===`slideshow`?ss:os).filter(e=>e.id!==`tour`||o),[e,o]),[c,u]=(0,m.useState)(`layout`),f=U(e=>e.requestedTab),g=U(e=>e.clearRequestedTab),_=U(e=>e.setShowTourSteps),v=U(e=>e.setCenterPanelMode),y=(0,m.useRef)(null);(0,m.useEffect)(()=>{!r||y.current===r.id||(y.current=r.id,r&&(0,E.getCanvasLayout)(i,r.id)?.customised===!1&&!(0,E.getPaintingImages)(i,r).length&&(u(`images`),v(`edit`)))},[r,i,v]),(0,m.useEffect)(()=>{c===`tour`?v(`edit`):c===`summary`&&v(`preview`)},[]),(0,m.useEffect)(()=>{if(f&&s.some(e=>e.id===f)){let e=f;u(e),_(e===`tour`),e===`tour`?v(`edit`):e===`summary`&&v(`preview`),g()}},[g,f,v,_,s]),(0,m.useEffect)(()=>{c===`tour`&&!o&&(u(`layout`),_(!1))},[c,_,o]);let b=e=>{u(e),_(e===`tour`),e===`tour`?v(`edit`):e===`summary`&&v(`preview`)};return a?(0,p.jsx)(Jo,{}):(0,p.jsx)(h.Sidebar,{children:(0,p.jsxs)(h.SidebarContent,{className:`bg-white px-6 pt-5 pb-20`,children:[(0,p.jsx)(`div`,{className:`flex justify-center`,children:(0,p.jsx)(ps,{value:t,options:cs,onChange:n})}),(0,p.jsx)(`div`,{role:`tablist`,"aria-label":`Canvas editing sections`,className:[`mt-5 grid border-b border-[#e4ddd6]`,s.length===5?`grid-cols-5`:`grid-cols-4`].join(` `),children:s.map(e=>(0,p.jsx)(`button`,{type:`button`,id:`exhibition-workbench-tab-${e.id}`,role:`tab`,"aria-selected":c===e.id,"aria-controls":`exhibition-workbench-panel-${e.id}`,className:[`exhibition-workbench-tab`,`-mb-px border-b-[3px] border-transparent px-1 pb-3 text-center text-sm font-semibold`,c===e.id?`border-me-primary-500 text-me-primary-500`:`exhibition-workbench-muted`].join(` `),onClick:()=>b(e.id),children:e.label},e.id))}),(0,p.jsxs)(`div`,{id:`exhibition-workbench-panel-${c}`,role:`tabpanel`,"aria-labelledby":`exhibition-workbench-tab-${c}`,className:`mt-8 px-4`,children:[c===`layout`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(pa,{}),(0,p.jsx)(Ko,{}),(0,p.jsx)(fn,{mode:t,layoutContext:e===`slideshow`?`slideshow`:`default`})]}):null,c===`images`?(0,p.jsx)(Oa,{}):null,c===`content`?(0,p.jsx)(Xo,{}):null,c===`summary`?t===`simple`?(0,p.jsx)(ms,{}):(0,p.jsx)(ga,{}):null,c===`tour`?(0,p.jsx)(Uo,{mode:t,useSlideshowWorkbench:e===`slideshow`}):null]})]})})}function ps({value:e,options:t,onChange:n}){return(0,p.jsx)(`div`,{role:`group`,"aria-label":`Editing mode`,className:`grid w-full max-w-[240px] grid-cols-2 rounded-full p-1`,style:{backgroundColor:ls.track},children:t.map(t=>{let r=e===t.value;return(0,p.jsx)(v.Button,{"aria-pressed":r,className:`border-none rounded-full bg-transparent px-4 py-2 text-sm font-semibold transition-colors`,style:{backgroundColor:r?ls.active:`transparent`,color:r?ls.activeText:ls.inactiveText,boxShadow:r?ls.activeShadow:`none`},onPress:()=>n(t.value),children:t.label},t.value)})})}function ms(){let e=(0,d.useCanvas)();return e?(0,p.jsx)(l.ResourceEditingProvider,{resource:e,children:(0,p.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(hs,{children:`Slide title`}),(0,p.jsx)(`div`,{className:`mt-2`,children:(0,p.jsx)(u.LanguageMapEditor,{dispatchType:`label`,disableMultiline:!0,disallowHTML:!0})})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(hs,{children:`Slide summary`}),(0,p.jsx)(`div`,{className:`mt-2`,children:(0,p.jsx)(va,{resource:e})})]}),(0,p.jsx)(_a,{})]})}):null}function hs({children:e}){return(0,p.jsx)(`div`,{className:`exhibition-workbench-muted text-sm font-semibold`,children:e})}const gs=e=>(0,p.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 15 15`,...e,children:(0,p.jsx)(`path`,{fill:`currentColor`,d:`M4.5 1a2.5 2.5 0 0 0-2.45 2H0v1h2.05a2.5 2.5 0 0 0 4.9 0H15V3H6.95A2.5 2.5 0 0 0 4.5 1m6 8a2.5 2.5 0 0 0-2.45 2H0v1h8.05a2.5 2.5 0 0 0 4.9 0H15v-1h-2.05a2.5 2.5 0 0 0-2.45-2`})}),_s=(0,l.extendApp)((0,l.mapApp)(c,e=>({...e,layout:{...e.layout,creators:e.layout.creators?.map(e=>e.id===`@manifest-editor/iiif-browser-creator`?Ii(e):e)}})),{id:`exhibition-scrolling-editor`,title:`Exhibition Editor (scrolling)`,project:!0,projectType:`Manifest`},{preset:Ji,config:{notebook:P,editorConfig:{}},leftPanels:[zr,Qr],leftPanelIds:[`left-panel-manifest`,l.NOTEBOOK_PANEL_ID],centerPanels:[],annotations:[],background:[],canvasEditors:[],editors:[qo,us,ya,Da,nn,ma,Bo],creators:[Qi,ia,Ri,Fi,Bi,Gi,ta]}),vs={id:`slideshow-canvas-editor`,label:`Slideshow canvas editor`,component:()=>(0,p.jsx)(ys,{}),supports:{strategy:(e,t,n)=>n.get(t.resource)?.type===`Canvas`}};function ys(){let e=(0,d.useCanvas)(),t=(0,d.useManifest)(),n=(0,d.useVault)(),r=U(e=>e.setCenterPanelMode),i=e?.id;(0,m.useEffect)(()=>{if(!i)return;let e=n.get({id:i,type:`Canvas`});(0,E.getCanvasLayout)(n,i)&&!(0,E.getPaintingAnnotations)(n,e).length&&r(`edit`)},[i,n,r]);let{edit:a}=(0,l.useLayoutActions)(),{rightPanel:o}=(0,l.useLayoutState)(),s=U(e=>e.centerPanelMode),c=(0,d.useCurrentAnnotationRequest)(),f=(0,u.useAnnotationEditing)(e=>e.annotationId),[h,g]=(0,m.useState)(1),_=t?.items?.findIndex(t=>t.id===e?.id),v=typeof _==`number`?t?.items?.[_-1]:void 0,y=typeof _==`number`?t?.items?.[_+1]:void 0;if(!e)return null;let b=!!(c||f||s===`edit`||o.current===`@manifest-editor/editor`&&o.state?.currentTab?.startsWith(`@exhibition/tour-steps`));return(0,p.jsxs)(`div`,{className:`exhibition-slideshow-current-canvas flex h-full min-h-0 flex-col bg-slate-100`,children:[(0,p.jsxs)(`div`,{className:`exhibition-slideshow-current-toolbar flex items-center gap-3 border-b border-slate-200 bg-white px-4 py-3 shadow-sm`,children:[(0,p.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,p.jsx)(d.LocaleString,{className:`block truncate text-sm font-semibold text-slate-800`,children:e.label})}),(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(bs,{onPress:()=>r(b?`preview`:`edit`),children:b?`Preview`:`Edit`}),(0,p.jsx)(bs,{onPress:()=>g(1),children:`Home`}),(0,p.jsx)(bs,{onPress:()=>g(e=>Math.max(.25,e-.25)),children:`-`}),(0,p.jsx)(bs,{onPress:()=>g(e=>Math.min(3,e+.25)),children:`+`}),(0,p.jsx)(bs,{isDisabled:!v,onPress:()=>v&&a({id:v.id,type:`Canvas`},void 0,{forceOpen:!1}),children:`Previous`}),(0,p.jsx)(bs,{isDisabled:!y,onPress:()=>y&&a({id:y.id,type:`Canvas`},void 0,{forceOpen:!1}),children:`Next`})]})]}),b?(0,p.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,p.jsx)(u.CanvasPanelEditor,{enableAddMedia:!0,asFallback:!0,moveMode:s===`edit`&&!f&&!o.state?.currentTab?.startsWith(`@exhibition/tour-steps`)})}):(0,p.jsx)(`div`,{className:`exhibition-slideshow-current-viewport min-h-0 flex-1 overflow-auto p-8`,children:(0,p.jsx)(`div`,{className:`exhibition-slideshow-current-preview mx-auto origin-top overflow-hidden rounded-md bg-white shadow-xl ring-1 ring-black/10`,style:{width:`min(100%, 1200px)`,aspectRatio:`${e.width||1920} / ${e.height||1080}`,transform:`scale(${h})`,transformOrigin:`top center`},children:(0,p.jsx)(d.CanvasContext,{canvas:e.id,children:(0,p.jsx)(Bn,{})})})})]})}function bs({children:e,isDisabled:t,onPress:n}){return(0,p.jsx)(v.Button,{className:`exhibition-slideshow-current-control rounded-md border border-slate-200 bg-white px-3 py-2 text-sm font-semibold text-slate-700 shadow-sm transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-40`,isDisabled:t,onPress:n,children:e})}const xs=e=>(0,p.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 48 48`,...e,children:(0,p.jsxs)(`g`,{fill:`none`,stroke:`#000`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:4,children:[(0,p.jsx)(`path`,{d:`m20 8 4-4m0 0 4 4m-4-4v12M20 40l4 4m0 0 4-4m-4 4V32M40 20l4 4m0 0-4 4m4-4H32M8 20l-4 4m0 0 4 4m-4-4h12`}),(0,p.jsx)(`circle`,{cx:24,cy:24,r:2})]})}),Ss=e=>(0,p.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,...e,children:(0,p.jsx)(`path`,{fill:`currentColor`,d:`M20 22H4q-.825 0-1.413-.588T2 20V8q0-.825.588-1.413T4 6h5.975v2H4v12h16v-3.975h2V20q0 .825-.588 1.413T20 22ZM4 20V8v8.025-.675V20Zm13-5.975-1.55-3.475L11.975 9l3.475-1.55L17 4l1.55 3.45L22 9l-3.45 1.55L17 14.025Z`})}),Cs={skipEditingOnCreate:!0},ws={id:`@exhibitions/slideshow-center-panel`,label:`Slideshow workbench`,icon:(0,p.jsx)(Ss,{}),render:()=>(0,p.jsx)(Ts,{})};function Ts(){let{structural:e,technical:t}=(0,l.useManifestEditor)(),n=e.items.get(),r={id:t.id.get(),type:`Manifest`};(0,d.useVault)();let[,i]=(0,l.useCreator)(r,`items`,`Canvas`,void 0,{isPainting:!0}),a=(0,u.useInStack)(`Canvas`),o=(0,l.useEditingStack)(),{edit:s}=(0,l.useLayoutActions)(),c=H(e=>e.clear),f=a?.resource.source.id||n[0]?.id,m=f?n.findIndex(e=>e.id===f):-1,g=m>=0?m:0,_=m>=0?n[m]:n[0]||null,v=()=>{i.createFiltered(`exhibition-slideshow-slide`,n.length?g+1:void 0)},y=(e,t,n=!1)=>{s({id:e.id,type:`Canvas`},{parent:r,property:`items`,index:t},{forceOpen:n})},b=(e,t)=>{c(),y(e,t)},x=t=>{let r=n[t];if(!r||!confirm(`Are you sure you want to delete this slide?`))return;let i=Ar(n,_?.id,r.id);if(e.items.deleteAtIndex(t),_?.id!==r.id||(c(),o.close(),!i))return;let a=e.items.getWithoutTracking(),s=a.findIndex(e=>e.id===i),l=a[s];l&&y(l,s)},S=g>0?n[g-1]:void 0,C=g<n.length-1?n[g+1]:void 0;return n.length?(0,p.jsx)(Es,{children:(0,p.jsxs)(`div`,{className:`exhibition-slideshow-main flex min-h-full flex-col gap-6 pb-12 pt-16`,children:[(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 px-8`,style:{paddingInlineStart:`calc(2rem + var(--manifest-editor-layout-left-sidebar-small, 0px))`,paddingInlineEnd:`calc(2rem + var(--manifest-editor-layout-right-sidebar-small, 0px))`},children:[(0,p.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,p.jsx)(`p`,{className:`text-sm font-semibold uppercase tracking-wider text-me-primary-500`,children:`Slideshow workbench`}),(0,p.jsx)(`h2`,{className:`exhibition-slideshow-heading truncate text-2xl font-bold text-slate-900`,children:_?(0,p.jsx)(d.CanvasContext,{canvas:_.id,children:(0,p.jsx)(Ds,{})}):`Slides`}),(0,p.jsxs)(`p`,{className:`exhibition-slideshow-muted mt-1 text-sm font-semibold text-slate-500`,children:[`Slide `,g+1,` of `,n.length]})]}),(0,p.jsx)(Os,{current:g+1,total:n.length,onPrevious:S?()=>b(S,g-1):void 0,onNext:C?()=>b(C,g+1):void 0}),(0,p.jsx)(`div`,{children:(0,p.jsx)(h.ActionButton,{primary:!0,onPress:v,children:`Add new slide`})})]}),(0,p.jsxs)(`div`,{className:`flex flex-1 flex-col gap-5 px-8`,style:{paddingInlineStart:`calc(1.5rem + var(--manifest-editor-layout-left-sidebar-small, 0px))`,paddingInlineEnd:`calc(1.5rem + var(--manifest-editor-layout-right-sidebar-small, 0px))`},children:[(0,p.jsx)(`div`,{className:`exhibition-slideshow-preview-frame flex items-center justify-center overflow-hidden rounded-lg bg-slate-100`,children:_?(0,p.jsx)(d.CanvasContext,{canvas:_.id,children:(0,p.jsx)(As,{})}):null}),(0,p.jsxs)(`aside`,{className:`exhibition-slideshow-slide-strip overflow-hidden rounded-lg border border-slate-200 bg-white p-4`,children:[(0,p.jsx)(`div`,{className:`exhibition-slideshow-heading mb-3 text-sm font-semibold text-slate-700`,children:`Slides`}),(0,p.jsx)(`div`,{className:`flex gap-3 overflow-x-auto pb-2`,children:n.map((e,t)=>(0,p.jsx)(d.CanvasContext,{canvas:e.id,children:(0,p.jsx)(qs,{index:t,selected:_?.id===e.id,onPress:()=>b(e,t),onDelete:()=>x(t)})},e.id))})]})]})]})}):(0,p.jsx)(Es,{children:(0,p.jsx)(`div`,{className:`flex min-h-full items-center justify-center px-24 py-12`,children:(0,p.jsxs)(`div`,{className:`w-full max-w-4xl`,children:[(0,p.jsx)(`p`,{className:`text-sm font-semibold uppercase tracking-wider text-me-primary-500`,children:`Slideshow exhibition`}),(0,p.jsx)(`h2`,{className:`mt-2 text-3xl font-bold text-slate-900`,children:`Create your first slideshow slide`}),(0,p.jsx)(`p`,{className:`mt-3 max-w-2xl text-sm text-slate-600`,children:`Add a new slide and choose one of the supported slideshow slide types. You can add images, text, media, and tour steps after the slide is created.`}),(0,p.jsx)(`div`,{className:`mt-8`,children:(0,p.jsx)(h.ActionButton,{primary:!0,large:!0,onPress:v,children:`Add new slide`})})]})})})}function Es({children:e}){return(0,p.jsx)(h.SidebarContent,{className:`exhibition-slideshow-workbench h-full overflow-x-hidden overflow-y-auto bg-[#f8f6f3]`,children:e})}function Ds(){let e=Gs((0,d.useCanvas)()?.label,`Untitled slide`);return(0,p.jsx)(p.Fragment,{children:e||`Untitled slide`})}function Os({current:e,total:t,onPrevious:n,onNext:r}){return(0,p.jsxs)(`div`,{className:`exhibition-slideshow-navigation flex items-stretch overflow-hidden rounded-lg border border-slate-200 bg-white text-sm text-slate-800 shadow-sm`,children:[(0,p.jsx)(v.Button,{className:`border-none bg-white px-5 py-3 font-semibold transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:text-slate-300`,isDisabled:!n,onPress:n,children:`Previous`}),(0,p.jsxs)(`span`,{className:`exhibition-slideshow-navigation-current flex min-w-[96px] items-center justify-center border-x border-slate-200 bg-slate-50 px-4 font-bold text-slate-900`,children:[e,` of `,t]}),(0,p.jsx)(v.Button,{className:`border-none bg-white px-5 py-3 font-semibold transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:text-slate-300`,isDisabled:!r,onPress:r,children:`Next`})]})}function ks({current:e,total:t,onPrevious:n,onNext:r}){return(0,p.jsxs)(`div`,{className:`exhibition-slideshow-navigation flex items-stretch overflow-hidden rounded-md border border-slate-200 bg-white text-xs text-slate-800 shadow-sm`,children:[(0,p.jsx)(v.Button,{className:`border-none bg-white px-3 py-2 font-semibold transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:text-slate-300`,isDisabled:!n,onPress:n,children:`Previous step`}),(0,p.jsx)(`span`,{className:`exhibition-slideshow-navigation-current flex min-w-[84px] items-center justify-center border-x border-slate-200 bg-slate-50 px-3 font-bold text-slate-900`,children:t?`${e} of ${t}`:`0 of 0`}),(0,p.jsx)(v.Button,{className:`border-none bg-white px-3 py-2 font-semibold transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:text-slate-300`,isDisabled:!r,onPress:r,children:`Next step`})]})}function As(){let e=(0,d.useCanvas)(),t=(0,d.useManifest)(),n=(0,d.useVault)(),r=(0,l.useInlineCreator)(),i=U(e=>e.centerPanelMode),a=U(e=>e.setCenterPanelMode),o=i,s=a,[c,u]=(0,m.useState)(null),[f,h]=(0,m.useState)(`box`),g=(0,m.useRef)(null),_=e?.annotations?.[0]?.id,b=e?.items?.[0]?{id:e.items[0].id,type:`AnnotationPage`}:void 0,[,x]=(0,l.useCreator)(b,`items`,`Annotation`,e?We(e):void 0,{isPainting:!0}),{selectedAnnotationId:S,repositioningAnnotationId:C,selectedTextRegion:w,repositioningTextRegion:T,selectedTourStepId:E,selectAnnotation:D,startRepositioning:O,stopRepositioning:k,startTextRepositioning:A,stopTextRepositioning:j,selectTourStep:M,stopTourStepRepositioning:N}=H(),P=U(e=>e.showTourSteps),F=U(e=>e.setShowTourSteps),I=(0,d.useVaultSelector)((t,n)=>e?W(n,e):[],[e?.id,b?.id]).find(e=>e.id===S),ee=w===`editorial-text`?Qe(e).text:null,L=(0,d.useVaultSelector)((t,n)=>e?Ge(n,e):[],[e?.id,_]),R=L.find(e=>e.id===E)||L[0],te=R?Math.max(0,L.findIndex(e=>e.id===R.id)):-1,ne=Ke(n,e),z=P&&ne,re=e=>{let t=L[e];t?.id&&M(t.id)};(0,m.useEffect)(()=>{g.current=null,u(null),h(`box`)},[e?.id]),(0,m.useEffect)(()=>{!ne&&P&&(F(!1),N(),u(null))},[F,P,N,ne]),(0,m.useEffect)(()=>{z&&s(`edit`)},[z]),(0,m.useEffect)(()=>{if(g.current===null){g.current=L.length;return}let e=L[L.length-1];L.length>g.current&&e?.id&&(M(e.id),k(),j(),F(!0)),g.current=L.length},[M,F,k,j,L]);let ie=()=>{let e=!P;F(e),e?(k(),j(),R?.id&&M(R.id)):N()},ae=()=>{e&&r.create(`@manifest-editor/empty-annotation-page`,{label:{en:[`Tour steps`]}},{target:{id:e.id,type:`Canvas`},targetType:`AnnotationPage`,parent:{property:`annotations`,resource:{id:e.id,type:`Canvas`}}})},oe=()=>{!e||!_||(F(!0),k(),j(),h(`box`),u({type:`add`}))},se=()=>{R?.id&&(F(!0),k(),j(),h(Us(R)),u({type:`edit`,annotationId:R.id}))};return(0,p.jsxs)(`div`,{className:`exhibition-slideshow-preview-card group relative flex max-h-full flex-col overflow-hidden rounded-md bg-white shadow-xl ring-1 ring-black/10`,style:{width:`100%`,height:`min(68vh, 760px)`,minHeight:420},children:[(0,p.jsxs)(`div`,{className:`exhibition-slideshow-toolbar flex flex-wrap items-center justify-between gap-3 border-b border-slate-200 bg-white px-4 py-3`,children:[(0,p.jsx)(`span`,{className:`exhibition-slideshow-muted text-xs font-semibold text-slate-500`,children:o===`edit`?`Click content to edit or reposition it`:`Live slideshow preview`}),(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[o===`edit`?(0,p.jsxs)(p.Fragment,{children:[ne?(0,p.jsx)(v.Button,{className:(0,y.twMerge)(`rounded-md border px-3 py-2 text-xs font-semibold shadow-sm transition`,z?`border-me-primary-500 bg-me-primary-50 text-me-primary-600`:`border-slate-200 bg-white text-slate-700 hover:border-me-primary-300`),onPress:ie,children:z?`Hide tour steps`:`Show tour steps`}):null,z?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(ks,{current:te+1,total:L.length,onPrevious:te>0?()=>re(te-1):void 0,onNext:te>=0&&te<L.length-1?()=>re(te+1):void 0}),_?(0,p.jsx)(v.Button,{className:`rounded-md bg-me-primary-500 px-3 py-2 text-xs font-semibold text-white shadow-sm transition hover:bg-me-primary-600`,onPress:oe,children:`Add tour step`}):(0,p.jsx)(v.Button,{className:`rounded-md bg-me-primary-500 px-3 py-2 text-xs font-semibold text-white shadow-sm transition hover:bg-me-primary-600`,onPress:ae,children:`Create tour`})]}):(0,p.jsx)(v.Button,{className:`rounded-md bg-me-primary-500 px-3 py-2 text-xs font-semibold text-white shadow-sm transition hover:bg-me-primary-600`,onPress:()=>{s(`edit`),D(null),F(!1),N(),x.create(void 0,Cs)},children:`Add content`})]}):null,(0,p.jsxs)(`div`,{className:`flex shrink-0 overflow-hidden rounded-md border border-slate-200 bg-slate-50 text-xs font-semibold`,children:[(0,p.jsx)(Ks,{selected:o===`edit`,onPress:()=>s(`edit`),children:`Edit`}),(0,p.jsx)(Ks,{selected:o===`preview`,onPress:()=>s(`preview`),children:`Preview`})]})]})]}),(0,p.jsxs)(`div`,{className:`relative min-h-0 flex-1 bg-black`,children:[o===`preview`?(0,p.jsx)(ft,{preset:`slideshow`,presetOptions:{manifest:t?.id||``,canvas:e?.id,minimal:!0}}):(0,p.jsx)(Bn,{editable:!0,mode:o,showTourSteps:z}),o===`edit`&&c&&e&&_?(0,p.jsx)(Rs,{annotationPageId:_,canvas:e,mode:c,selectedTool:f,setSelectedTool:h,vault:n,onCancel:()=>u(null),onComplete:e=>{e&&M(e),F(!0),u(null)}}):null,!c&&o===`edit`&&!z&&I&&e?(0,p.jsx)(Ps,{annotation:I,canvas:e,isRepositioning:C===I.id,onStartReposition:()=>O(I.id),onStopReposition:k,vault:n}):null,!c&&o===`edit`&&!z&&ee&&e?(0,p.jsx)(Ps,{canvas:e,currentBox:ee,isRepositioning:T===w,label:`Editorial text`,onStartReposition:()=>A(`editorial-text`),onStopReposition:j,setBox:t=>Ze(n,e,t),vault:n}):null,!c&&o===`edit`&&z&&e?R?(0,p.jsx)(Ps,{annotation:R,canvas:e,isRepositioning:!1,label:`Selected tour step target`,onStopReposition:N,showBoxFields:!0,showRepositionButton:!1,vault:n,children:_?(0,p.jsx)(js,{annotationPageId:_,canvas:e,onAddTourStep:oe,onEditTarget:se,selectedTourStepId:R?.id}):null}):(0,p.jsx)(Ns,{label:`Tour steps`,children:_?(0,p.jsx)(js,{annotationPageId:_,canvas:e,onAddTourStep:oe,onEditTarget:se,selectedTourStepId:R?.id}):(0,p.jsx)(Ms,{onCreate:ae})}):null]})]})}function js({annotationPageId:e,canvas:t,onAddTourStep:n,onEditTarget:r,selectedTourStepId:i}){return(0,p.jsx)(l.ResourceEditingProvider,{resource:t,children:(0,p.jsx)(d.AnnotationPageContext,{annotationPage:e,children:(0,p.jsxs)(`div`,{className:`space-y-3 text-slate-800`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,p.jsx)(`h3`,{className:`text-sm font-semibold text-slate-800`,children:`Tour steps`}),(0,p.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[i?(0,p.jsx)($,{label:`Edit target`,onPress:r}):null,(0,p.jsx)($,{primary:!0,label:`Add step`,onPress:n})]})]}),(0,p.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Select a step below. Use the quick box controls here, or edit the target with the Atlas drawing tools.`}),(0,p.jsx)(`div`,{className:`max-h-72 overflow-y-auto pr-1`,children:(0,p.jsx)(Fo,{reorderable:!1,useSlideshowWorkbench:!0})})]})})})}function Ms({onCreate:e}){return(0,p.jsxs)(`div`,{className:`space-y-3 text-slate-800`,children:[(0,p.jsx)(`p`,{className:`text-xs text-slate-600`,children:`This slide does not have a tour annotation page yet.`}),(0,p.jsx)($,{primary:!0,label:`Create tour`,onPress:e})]})}function Ns({children:e,label:t}){return(0,p.jsxs)(`div`,{className:`absolute bottom-4 left-4 z-40 max-w-[min(34rem,calc(100%-2rem))] rounded-lg bg-white/95 p-3 text-xs shadow-lg ring-1 ring-black/10`,children:[(0,p.jsx)(`div`,{className:`mb-2 font-semibold text-slate-700`,children:t}),e]})}function Ps({annotation:e,canvas:t,children:n,currentBox:r,isRepositioning:i,label:a=`Selected content`,onStartReposition:o,onStopReposition:s,setBox:c,vault:l,hidePositionControls:u=!1,showBoxFields:d=!1,showRepositionButton:f=!0}){let h=(0,m.useRef)(null),g=(0,m.useRef)(null),[_,v]=(0,m.useState)(null),b=Number(t?.width)||1920,x=Number(t?.height)||1080,S=r||Ye(e,t),C=c||(n=>Xe(l,t,e.id,n)),w=Math.round(b/2),T=Math.round(x/2),E=e=>{let t=h.current,n=t?.offsetParent,r=t?.getBoundingClientRect(),i=n?.getBoundingClientRect();!t||!r||!i||(e.currentTarget.setPointerCapture(e.pointerId),g.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,panelX:r.left-i.left,panelY:r.top-i.top,maxX:Math.max(16,i.width-r.width-16),maxY:Math.max(16,i.height-r.height-16)})},D=e=>{let t=g.current;!t||t.pointerId!==e.pointerId||v({x:Math.min(t.maxX,Math.max(16,t.panelX+e.clientX-t.startX)),y:Math.min(t.maxY,Math.max(16,t.panelY+e.clientY-t.startY))})},O=e=>{g.current?.pointerId===e.pointerId&&(g.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))};return(0,p.jsx)(`div`,{ref:h,className:(0,y.twMerge)(`absolute z-40 w-[min(30rem,calc(100%-2rem))] rounded-lg bg-white/95 p-3 text-xs shadow-lg ring-1 ring-black/10`,_?null:`bottom-4 left-4`),style:_?{left:_.x,top:_.y}:void 0,children:(0,p.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,p.jsxs)(`div`,{className:`min-w-[280px]`,children:[(0,p.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,p.jsx)(`span`,{className:`font-semibold text-slate-700`,children:a}),(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`button`,{className:`cursor-move rounded border border-slate-200 bg-white px-2 py-1 text-[11px] font-semibold text-slate-600 transition hover:border-me-primary-300 hover:text-me-primary-600`,type:`button`,onPointerDown:E,onPointerMove:D,onPointerUp:O,onPointerCancel:O,children:(0,p.jsx)(xs,{})}),(0,p.jsxs)(`span`,{className:`text-slate-400`,children:[Math.round(S.width),` x `,Math.round(S.height)]})]})]}),u?null:(0,p.jsxs)(`div`,{className:`space-y-2`,children:[(0,p.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[f&&o?(0,p.jsx)($,{onPress:o,label:`Reposition`,primary:!0}):null,i&&s?(0,p.jsx)($,{onPress:s,label:`Stop moving`}):null,(0,p.jsx)($,{onPress:()=>C({x:0,y:0,width:b,height:x}),label:`Fill`}),(0,p.jsx)($,{onPress:()=>C({x:Math.round(b*.1),y:Math.round(x*.1),width:Math.round(b*.8),height:Math.round(x*.8)}),label:`Centre`}),(0,p.jsx)($,{onPress:()=>C({x:0,y:0,width:w,height:x}),label:`Left`}),(0,p.jsx)($,{onPress:()=>C({x:w,y:0,width:w,height:x}),label:`Right`}),(0,p.jsx)($,{onPress:()=>C({x:0,y:0,width:b,height:T}),label:`Top`}),(0,p.jsx)($,{onPress:()=>C({x:0,y:T,width:b,height:T}),label:`Bottom`})]}),d?(0,p.jsx)(Fs,{box:S,onChange:C}):null]})]}),n?(0,p.jsx)(`div`,{className:`w-full border-t border-slate-200 pt-3`,children:n}):null]})})}function Fs({box:e,onChange:t}){let n=(n,r)=>{let i=Number(r);Number.isFinite(i)&&t({...e,[n]:Math.round(i)})};return(0,p.jsxs)(`div`,{className:`grid grid-cols-4 gap-2 pt-1`,children:[(0,p.jsx)(Is,{label:`X`,value:e.x,onChange:e=>n(`x`,e)}),(0,p.jsx)(Is,{label:`Y`,value:e.y,onChange:e=>n(`y`,e)}),(0,p.jsx)(Is,{label:`W`,value:e.width,onChange:e=>n(`width`,e)}),(0,p.jsx)(Is,{label:`H`,value:e.height,onChange:e=>n(`height`,e)})]})}function Is({label:e,value:t,onChange:n}){return(0,p.jsxs)(`label`,{className:`block text-[11px] font-semibold text-slate-500`,children:[e,(0,p.jsx)(`input`,{className:`mt-1 w-full rounded border border-slate-200 bg-white px-1.5 py-1 text-xs text-slate-900 outline-none focus:border-me-primary-400 focus:ring-1 focus:ring-me-primary-100`,type:`number`,value:Math.round(t),onChange:e=>n(e.target.value)})]})}function Ls(e,t,n,r){let i=`${n}/tour-step/${Date.now()}-${Math.random().toString(36).slice(2,8)}`,a=`${i}/body/en`,o=e.get?.({id:n,type:`AnnotationPage`})||{},s=Array.isArray(o?.items)?o.items:[],c=()=>{e.dispatch((0,D.importEntities)({entities:{ContentResource:{[a]:{id:a,type:`TextualBody`,language:`en`,format:`text/html`,value:`<p>Description</p>`}},Annotation:{[i]:{id:i,type:`Annotation`,motivation:`tagging`,body:[{id:a,type:`ContentResource`}],target:r}}}})),e.dispatch((0,D.addMappings)({mapping:{[a]:`ContentResource`,[i]:`Annotation`}})),e.modifyEntityField({id:n,type:`AnnotationPage`},`items`,[...s,{id:i,type:`Annotation`}])};return e.batch?e.batch(c):c(),i}function Rs({annotationPageId:e,canvas:t,mode:n,selectedTool:r,setSelectedTool:i,vault:a,onCancel:o,onComplete:s}){let c=(0,m.useRef)(null),[l,u]=(0,m.useState)(null),[d,f]=(0,m.useState)(null),[h,g]=(0,m.useState)([]),_=Number(t?.width)||1920,v=Number(t?.height)||1080,y=e=>{let t=c.current;if(!t)return{x:0,y:0};let n=t.createSVGPoint();n.x=e.clientX,n.y=e.clientY;let r=t.getScreenCTM()?.inverse(),i=r?n.matrixTransform(r):n;return{x:Ws(Math.round(i.x),0,_),y:Ws(Math.round(i.y),0,v)}},b=e=>{if(e.preventDefault(),r===`polygon`){let t=y(e);g(e=>[...e,t]);return}let t=y(e);u(t),f(null)},x=e=>{if(!l||r===`polygon`)return;let t=y(e);r===`box`&&f({type:`box`,x:Math.min(l.x,t.x),y:Math.min(l.y,t.y),width:Math.abs(t.x-l.x),height:Math.abs(t.y-l.y)}),r===`circle`&&f({type:`circle`,cx:l.x,cy:l.y,r:Math.round(Math.sqrt((t.x-l.x)**2+(t.y-l.y)**2))}),r===`line`&&f({type:`line`,x1:l.x,y1:l.y,x2:t.x,y2:t.y})},S=()=>{u(null)},C=r===`polygon`&&h.length?{type:`polygon`,points:h}:d,w=()=>{u(null),f(null),g([])};return(0,p.jsxs)(`div`,{className:`absolute inset-0 z-30`,children:[(0,p.jsxs)(`svg`,{ref:c,className:`absolute inset-0 h-full w-full cursor-crosshair touch-none`,preserveAspectRatio:`xMidYMid meet`,viewBox:`0 0 ${_} ${v}`,onPointerDown:b,onPointerMove:x,onPointerUp:S,onPointerCancel:S,children:[(0,p.jsx)(`rect`,{x:0,y:0,width:_,height:v,fill:`transparent`}),C?(0,p.jsx)(Bs,{shape:C}):null,h.map((e,t)=>(0,p.jsx)(`circle`,{cx:e.x,cy:e.y,r:8,fill:`white`,stroke:`#be4778`,strokeWidth:4},`${e.x}-${e.y}-${t}`))]}),(0,p.jsxs)(`div`,{className:`absolute left-4 top-4 z-40 flex flex-wrap items-center gap-2 rounded-lg bg-white/95 p-2 text-xs shadow-lg ring-1 ring-black/10`,children:[(0,p.jsx)(`span`,{className:`mr-2 font-semibold text-slate-700`,children:n.type===`add`?`Draw new tour step`:`Edit target`}),(0,p.jsx)(zs,{active:r===`box`,label:`Box`,onPress:()=>{w(),i(`box`)}}),(0,p.jsx)(zs,{active:r===`circle`,label:`Circle`,onPress:()=>{w(),i(`circle`)}}),(0,p.jsx)(zs,{active:r===`line`,label:`Line`,onPress:()=>{w(),i(`line`)}}),(0,p.jsx)(zs,{active:r===`polygon`,label:`Polygon`,onPress:()=>{w(),i(`polygon`)}}),(0,p.jsx)($,{primary:!0,label:n.type===`add`?`Create step`:`Save target`,onPress:()=>{if(!C)return;let r=Vs(t.id,C);if(n.type===`edit`){a.modifyEntityField({id:n.annotationId,type:`Annotation`},`target`,r),s(n.annotationId);return}s(Ls(a,t,e,r))}}),(0,p.jsx)($,{label:`Clear`,onPress:w}),(0,p.jsx)($,{label:`Cancel`,onPress:o})]})]})}function zs({active:e,label:t,onPress:n}){return(0,p.jsx)(v.Button,{className:(0,y.twMerge)(`rounded-md border px-2.5 py-1.5 font-semibold transition`,e?`border-me-primary-500 bg-me-primary-500 text-white`:`border-slate-200 bg-white text-slate-700 hover:border-me-primary-300 hover:bg-me-primary-50`),onPress:n,children:t})}function Bs({shape:e}){let t={fill:`rgba(190, 71, 120, 0.18)`,stroke:`#be4778`,strokeWidth:6,vectorEffect:`non-scaling-stroke`};return e.type===`box`?(0,p.jsx)(`rect`,{...t,x:e.x,y:e.y,width:e.width,height:e.height}):e.type===`circle`?(0,p.jsx)(`circle`,{...t,cx:e.cx,cy:e.cy,r:e.r}):e.type===`line`?(0,p.jsx)(`line`,{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:`#be4778`,strokeWidth:6,vectorEffect:`non-scaling-stroke`}):(0,p.jsx)(`polygon`,{...t,points:e.points.map(e=>`${e.x},${e.y}`).join(` `)})}function Vs(e,t){return t.type===`box`?`${e}#xywh=${Math.round(t.x)},${Math.round(t.y)},${Math.round(t.width)},${Math.round(t.height)}`:{source:e,selector:{type:`SvgSelector`,value:Hs(t)}}}function Hs(e){return e.type===`circle`?`<svg xmlns="http://www.w3.org/2000/svg"><circle cx="${Math.round(e.cx)}" cy="${Math.round(e.cy)}" r="${Math.round(e.r)}" /></svg>`:e.type===`line`?`<svg xmlns="http://www.w3.org/2000/svg"><line x1="${Math.round(e.x1)}" y1="${Math.round(e.y1)}" x2="${Math.round(e.x2)}" y2="${Math.round(e.y2)}" /></svg>`:`<svg xmlns="http://www.w3.org/2000/svg"><polygon points="${e.points.map(e=>`${Math.round(e.x)},${Math.round(e.y)}`).join(` `)}" /></svg>`}function Us(e){let t=Array.isArray(e?.target?.selector)?e.target.selector.find(e=>e?.type===`SvgSelector`):e?.target?.selector;return t?.type===`SvgSelector`&&(Array.isArray(t.points)&&t.svgShape!==`polyline`||typeof t.value==`string`&&/<polygon\b/i.test(t.value))?`polygon`:`box`}function Ws(e,t,n){return Math.min(n,Math.max(t,e))}function Gs(e,t=``){if(!e)return t;if(typeof e==`string`)return e;let n=e.en||e.none||Object.values(e).flat();return Array.isArray(n)&&n.length?String(n[0]):t}function $({label:e,onPress:t,primary:n}){return(0,p.jsx)(v.Button,{className:(0,y.twMerge)(`rounded-md border px-2.5 py-1.5 font-semibold transition`,n?`border-me-primary-500 bg-me-primary-500 text-white hover:bg-me-primary-600`:`border-slate-200 bg-white text-slate-700 hover:border-me-primary-300 hover:bg-me-primary-50`),onPress:t,children:e})}function Ks({children:e,selected:t,onPress:n}){return(0,p.jsx)(v.Button,{className:(0,y.twMerge)(`border-none px-3 py-2 transition`,t?`bg-me-primary-500 text-white`:`bg-transparent text-slate-600 hover:bg-white`),onPress:n,children:e})}function qs({index:e,selected:t,onPress:n,onDelete:r}){let i=(0,d.useCanvas)();return(0,p.jsxs)(`div`,{className:(0,y.twMerge)(`exhibition-slideshow-slide-card relative w-44 shrink-0 rounded-md border bg-white p-2 text-left transition`,t?`border-me-primary-500 ring-2 ring-me-primary-200`:`border-slate-200 hover:border-me-primary-300`),children:[(0,p.jsxs)(v.Button,{className:`block w-full border-none bg-transparent p-0 text-left`,onPress:n,children:[(0,p.jsx)(`div`,{className:`aspect-video overflow-hidden rounded`,style:{backgroundColor:`#0e0d12`},children:(0,p.jsx)(Bn,{className:`pointer-events-none h-full w-full`,mode:`preview`})}),(0,p.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 pr-7`,children:[(0,p.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded bg-slate-100 text-xs font-semibold text-slate-600`,children:e+1}),(0,p.jsx)(d.LocaleString,{className:`min-w-0 truncate text-sm font-medium text-slate-800`,children:i?.label})]})]}),(0,p.jsx)(v.Button,{className:`absolute bottom-2 right-2 flex items-center gap-1 rounded border border-me-primary-100 bg-white px-2 py-1 text-xs font-semibold text-me-primary-500 shadow-sm transition hover:bg-me-primary-50`,"aria-label":`Delete slide ${e+1}`,onPress:r,children:`Delete`})]})}const Js=(0,l.extendApp)((0,l.mapApp)(c),{id:`exhibition-slideshow-editor`,title:`Exhibition Editor (slideshow)`,project:!0,projectType:`Manifest`},{preset:Ji,config:{notebook:P,editorConfig:{Canvas:{singleTab:`@exhibition/slideshow-workbench-editor`,hideTabs:[`@manifest-editor/overview`,`@manifest-editor/technical-properties`,`@manifest-editor/linking-properties`,`@manifest-editor/nav-place-editor`,`@manifest-editor/canvas-structural`,`@manifest-editor/descriptive-properties`,`@manifest-editor/overview-canvas-editor`,`@manifest-editor/metadata`]}}},leftPanels:[Rr,Qr],centerPanels:[ws],annotations:[F],leftPanelIds:[`left-panel-manifest`,l.NOTEBOOK_PANEL_ID],background:[di],canvasEditors:[vs],editors:[ds,qo,ya,nn,ma,Bo],creators:[Fi,Ri,Gi,Vi,Hi,na,aa,$i]}),Ys=(0,l.extendApp)((0,l.mapApp)(c,e=>({...e,layout:{...e.layout,leftPanels:[Lr,...e.layout.leftPanels.filter(e=>e.id===`left-panel-manifest`||e.id===l.NOTEBOOK_PANEL_ID)]}})),{id:`exhibition-editor`,title:`Exhibition Editor`,project:!0,projectType:`Manifest`},{preset:Ji,config:{notebook:P,editorConfig:{Canvas:{hideTabs:[`@manifest-editor/overview`,`@manifest-editor/technical-properties`,`@manifest-editor/linking-properties`,`@manifest-editor/nav-place-editor`,`@manifest-editor/canvas-structural`,`@manifest-editor/descriptive-properties`,`@manifest-editor/overview-canvas-editor`,`@manifest-editor/metadata`]}}},leftPanels:[Qr],centerPanels:[Ne,vt],annotations:[F],leftPanelIds:[`canvas-listing`,`left-panel-manifest`,l.NOTEBOOK_PANEL_ID],background:[di],canvasEditors:[Ni,_i,pi],editors:[qo,us,ya,Da,no,nn,ma,Bo],creators:[Qi,ia,Ri,Fi,Bi,Gi,ta,Vi,Hi,na,aa,$i]});exports.PresetIcon=gs,exports.exhibitionEditorPreset=Ys,exports.exhibitionEditorScrollingPreset=_s,exports.exhibitionEditorSlideshowPreset=Js,exports.imageServiceSlideCreator=Ri,exports.useExhibitionPreviewWindow=pt;
3
3
  //# sourceMappingURL=index.cjs.map