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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuButton as r,BackgroundActionMenuDivider as i,BackgroundActionMenuInfoButton as a,BackgroundActionMenuInlineAction as o,BackgroundActionMenuItem as s,BackgroundActionMenuLabel as c,BackgroundActionMenuMeta as l,BackgroundActionMenuPanel as u,BackgroundActionMenuProgressBar as d,BackgroundActionMenuRoot as f,BackgroundActionMenuSection as p,BackgroundActionMenuText as m,BackgroundActionMenuTrigger as h,CheckIcon as g,CreatorGrid as _,DefaultTooltipContent as v,DownloadButton as y,EmptyState as b,ErrorMessage as x,Form as S,GridIcon as C,IconButton as w,IconHandle as T,ManifestEditorLogo as E,Modal as ee,ModalBackSlot as D,PaddedSidebarContainer as O,PanelSideMenu as k,ResetIcon as te,ResizeHandle as ne,Sidebar as re,SidebarContent as ie,SidebarHeader as ae,SidebarTabs as oe,Spinner as A,Tab as se,TabList as ce,TabPanel as le,Tabs as ue,ToastRegion as de,Tooltip as fe,TooltipTrigger as pe,useLocalStorage as me,useOptionalLocalStorage as he,useOptionalLocalStorage as ge}from"@manifest-editor/components";import*as _e from"react";import{Component as ve,Fragment as ye,Suspense as be,createContext as j,createElement as xe,createRef as Se,forwardRef as Ce,memo as we,useCallback as M,useContext as N,useEffect as P,useImperativeHandle as Te,useLayoutEffect as F,useMemo as I,useReducer as Ee,useRef as L,useState as R}from"react";import{Fragment as z,jsx as B,jsxs as V}from"react/jsx-runtime";import{create as De,createStore as Oe,useStore as ke}from"zustand";import Ae from"localforage";import{AtlasStoreProvider as je,AtlasStoreProvider as Me,AtlasStoreReactContext as Ne,CollectionContext as Pe,ImageServiceLoaderContext as Fe,ManifestContext as Ie,ReactVaultContext as Le,ResourceReactContext as Re,VaultProvider as ze,useAtlasStore as Be,useCurrentAnnotationMetadata as Ve,useExistingVault as He,useManifest as Ue,useResourceContext as We,useVault as H,useVaultSelector as Ge}from"react-iiif-vault";import{isSpecificResource as Ke,toRef as qe}from"@iiif/parser";import U,{ThemeProvider as Je,css as W}from"styled-components";import{original as Ye,produce as Xe}from"immer";import{EditorInstance as Ze}from"@manifest-editor/editor-api";import{useToastState as Qe}from"@react-stately/toast";import{getValue as $e}from"@iiif/helpers";import*as et from"@iiif/helpers/vault";import{Vault as tt}from"@iiif/helpers/vault";import{Creator as nt,getCreatorConfigKey as rt,matchBasedOnResource as it}from"@manifest-editor/creator-api";import{ErrorBoundary as at}from"react-error-boundary";import{addReference as ot,batchActions as st,modifyEntityField as ct,reorderEntityField as lt,requestResource as ut}from"@iiif/helpers/vault/actions";import{actionListFromResource as dt}from"@iiif/helpers/vault/utility";import ft from"mitt";import{useDebounce as pt}from"tiny-use-debounce";import{Transition as mt}from"react-transition-group";import ht from"shallowequal";import{ImageServiceLoader as gt}from"@atlas-viewer/iiif-image-api";import{MessagePortClientVault as _t}from"@manifest-editor/client-vault";var vt=Object.create,yt=Object.defineProperty,bt=Object.getOwnPropertyDescriptor,xt=Object.getOwnPropertyNames,St=Object.getPrototypeOf,Ct=Object.prototype.hasOwnProperty,wt=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Tt=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=xt(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Ct.call(e,s)&&s!==n&&yt(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=bt(t,s))||r.enumerable});return e},Et=(e,t,n)=>(n=e==null?{}:vt(St(e)),Tt(t||!e||!e.__esModule||!Ct.call(e,`default`)?yt(n,`default`,{value:e,enumerable:!0}):n,e)),Dt=`Invariant failed`;function G(e,t){if(!e)throw Error(Dt)}const Ot={previews:[],behaviorPresets:[`auto-advance`,`no-auto-advance`,`repeat`,`no-repeat`,`unordered`,`individuals`,`continuous`,`paged`,`non-paged`,`facing-pages`,`multi-part`,`together`,`sequence`,`thumbnail-nav`,`no-nav`,`hidden`],defaultPreview:null,editorConfig:{},newTemplates:null,i18n:{advancedLanguageMode:!1,availableLanguages:[`en`,`cy`,`nl`,`fr`],defaultLanguage:`en`},editorFeatureFlags:{enableMultiImageCanvases:!0,enableMultiMediaCanvases:!0,annotationPopups:!1,rememberCanvasId:!0,manifestGridOptions:!1,rememberLeftPanelId:!1},uploadBackends:[],plugins:{apps:{}},export:{baseIdentifier:null,version:3},creators:{}};function kt(e,t){if(!e&&!t)return;let n={...e||{}};for(let[e,r]of Object.entries(t||{}))n[e]={...n[e]||{},...r||{}};return n}function At(e,t){if(!e&&!t)return;let n={...e?.apps||{}};for(let[e,r]of Object.entries(t?.apps||{})){let t=n[e]||{};n[e]={...t,...r,settings:{...t.settings||{},...r.settings||{}}}}return{apps:n}}function jt(e,t){if(!e&&!t)return;let n={...e||{}};for(let[e,r]of Object.entries(t||{}))n[e]={...n[e]||{},...r||{}};return n}function Mt(...e){let t={};for(let n of e)n&&(t={...t,...n,editorConfig:kt(t.editorConfig,n.editorConfig),editorFeatureFlags:t.editorFeatureFlags||n.editorFeatureFlags?{...t.editorFeatureFlags||{},...n.editorFeatureFlags||{}}:void 0,i18n:t.i18n||n.i18n?{...t.i18n||{},...n.i18n||{}}:void 0,export:t.export||n.export?{...t.export||{},...n.export||{}}:void 0,creators:jt(t.creators,n.creators),plugins:At(t.plugins,n.plugins)});return t}function Nt(...e){return Mt(Ot,...e)}const Pt=j(Ot),Ft=j(()=>{});function It(){return N(Pt)}function Lt(){return N(Ft)}function Rt({children:e,config:t,saveConfig:n}){let[r,i]=R(null),a=I(()=>Nt(t,r),[t,r]),o=M(e=>{i(t=>Mt(t,e)),n&&n(e)},[n]);return B(Ft.Provider,{value:o,children:B(Pt.Provider,{value:a,children:e})})}const zt=`@manifest-editor/canvas-progress`,Bt=`status`,Vt=new Set([`queued`,`pending`,`done`]);function Ht(e){return typeof e==`string`?e:e?.id||null}function Ut(e){return typeof e==`string`&&Vt.has(e)?e:`none`}function Wt(e){return typeof e==`string`&&Vt.has(e)}function Gt(e,t){let n=Ht(t);return n?Ut(e.getResourceMeta(n,zt)?.[Bt]):`none`}function Kt(e,t){let n=Ht(t);return n?Ut(e?.iiif?.meta?.[n]?.[zt]?.[Bt]):`none`}function qt(e,t,n){let r=Ht(t);if(!r)return`none`;let i=Wt(n)?n:void 0;return e.setMetaValue([r,zt,Bt],i),i||`none`}function Jt(e,t){return qt(e,t,`none`)}function Yt(e,t,n){let r={};for(let i of t){let t=Ht(i);t&&(r[t]=qt(e,i,n))}return r}function Xt(e,t){return Yt(e,t,`none`)}function Zt(e){return{getStatus(t){return Gt(e,t)},setStatus(t,n){return qt(e,t,n)},clearStatus(t){return Jt(e,t)},setStatuses(t,n){return Yt(e,t,n)},clearStatuses(t){return Xt(e,t)}}}function Qt(e,t=new Set){function n(e){let n=Ht(e);n&&t.add(n)}function r(e){for(let t of e)n(t)}return{trackedResourceIds:t,getStatus(t){return e.getStatus(t)},setStatus(t,r){return n(t),e.setStatus(t,r)},clearStatus(t){return n(t),e.clearStatus(t)},setStatuses(t,n){return r(t),e.setStatuses(t,n)},clearStatuses(t){return r(t),e.clearStatuses(t)},clearTrackedStatuses(){e.clearStatuses(Array.from(t).map(e=>({id:e,type:`Canvas`}))),t.clear()}}}function $t(e){let t=Ht(e);return Ge(e=>t?Kt(e,t):`none`,[t])}function en(e){let t=H(),n=Ht(e),r=I(()=>Zt(t),[t]);return I(()=>({setStatus(e){return r.setStatus(n,e)},clearStatus(){return r.clearStatus(n)},getStatus(){return r.getStatus(n)}}),[r,n])}const tn={queued:{label:`Queued`,stripClass:`bg-zinc-400/80`,badgeClass:`bg-zinc-500`,dimOverlay:!0},pending:{label:`In progress`,stripClass:`bg-amber-400/90 animate-pulse`,badgeClass:`bg-amber-500`},done:{label:`Done`,stripClass:`bg-me-primary-500`,badgeClass:`bg-me-primary-500`}};function nn({className:e}){return V(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[B(`circle`,{cx:`12`,cy:`12`,r:`9`}),B(`path`,{d:`M12 7v5l2.5 2.5`})]})}function rn({className:e}){return V(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,children:[B(`circle`,{cx:`12`,cy:`12`,r:`9`,stroke:`currentColor`,strokeWidth:`2.5`,strokeOpacity:`0.3`}),B(`path`,{d:`M12 3a9 9 0 0 1 9 9`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`})]})}function an({className:e}){return B(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:B(`path`,{d:`M5 12l4 4 8-8`})})}function on({resource:e,status:t,className:n}){return t?B(cn,{status:t,className:n}):B(sn,{resource:e,className:n})}function sn({resource:e,className:t}){let n=$t(e);return B(cn,{status:n,className:t})}function cn({status:e,className:t}){if(e===`none`)return null;let n=tn[e];return V(z,{children:[n.dimOverlay&&B(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 z-10 bg-white/40`}),B(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-x-0 top-0 z-10 h-[3px] rounded-t-sm ${n.stripClass} ${t||``}`}),V(`div`,{className:`pointer-events-none absolute right-1.5 top-1.5 z-10 flex h-[18px] w-[18px] items-center justify-center rounded-full ${n.badgeClass} shadow-md ring-2 ring-white/70`,title:n.label,children:[B(`span`,{className:`sr-only`,children:n.label}),e===`queued`&&B(nn,{className:`h-2.5 w-2.5 text-white`}),e===`pending`&&B(rn,{className:`h-2.5 w-2.5 animate-spin text-white`}),e===`done`&&B(an,{className:`h-2.5 w-2.5 text-white`})]})]})}function ln(e,t){return`${e}::${t.type}::${t.id}`}function un(e=[],t=[]){let n=[],r=new Set;for(let e=t.length-1;e>=0;--e){let i=t[e];i&&!r.has(i.id)&&(r.add(i.id),n.unshift(i))}return[...e.filter(e=>!r.has(e.id)),...n]}function dn(e){return[...e].sort((e,t)=>{let n=(e.section||``).localeCompare(t.section||``);if(n!==0)return n;let r=(e.order||0)-(t.order||0);if(r!==0)return r;let i=e.label.localeCompare(t.label);return i===0?e.id.localeCompare(t.id):i})}function fn(e){return e instanceof Error?{message:e.message,stack:e.stack,detail:e}:{message:typeof e==`string`?e:`Background action failed`,detail:e}}function pn(e){return e&&typeof e==`object`&&typeof e.message==`string`?{message:e.message,stack:typeof e.stack==`string`?e.stack:void 0,detail:e.detail}:fn(e)}function mn(e,t){return!e.resourceTypes?.length||e.resourceTypes.includes(t.type)}function hn({definitions:e,instances:t,systemContext:n,targets:r,onSupportsError:i}){let a=dn(e),o=[];for(let e of r){let r=[];for(let o of a){if(!mn(o,e))continue;let a=ln(o.id,e),s={...n,definition:o,target:e,instanceKey:a,instance:t[a]};try{if(o.supports&&!o.supports(s))continue}catch(e){i?.(o,e);continue}r.push({definition:o,target:e,instanceKey:a,instance:t[a],context:s})}r.length&&o.push({id:`${e.scope}:${e.type}:${e.id}`,label:e.label,target:e,actions:r})}return o}let gn=0;function _n(e){return gn+=1,`${e}-${Date.now()}-${gn}`}function vn(e,t,n,r=Date.now()){return{id:_n(`event`),createdAt:r,type:e,message:t,data:n}}function K(e,t,n,r,i=Date.now()){return{...e,events:[...e.events,vn(t,n,r,i)]}}function yn(e){return e.filter(e=>String(e.type)!==`progress`)}function bn(e){return{...e,logs:[...e.logs],events:yn(e.events),progress:e.progress?{...e.progress}:void 0}}function xn(e,t,n){if(!En(n.status))return e;let r=e[t]||[],i=bn(n),a=r.findIndex(e=>e.runId===n.runId),o=a>=0?r.map((e,t)=>t===a?i:e):[...r,i];return{...e,[t]:o}}function Sn(e,t,n){let r=e.instances[t];if(!r)return{instances:e.instances,histories:e.histories};let i=n(r);return{instances:{...e.instances,[t]:i},histories:xn(e.histories,t,i)}}function Cn(e){return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}function wn(e){let t=e,n=typeof t.current==`number`&&Number.isFinite(t.current)?t.current:void 0,r=typeof t.total==`number`&&Number.isFinite(t.total)?t.total:void 0;return{percent:Cn(typeof t.percent==`number`&&Number.isFinite(t.percent)?t.percent:typeof n==`number`&&typeof r==`number`&&r>0?n/r*100:0),current:n,total:r,label:t.label}}function Tn(e){return e===`preparing`||e===`running`}function En(e){return e===`complete`||e===`error`||e===`cancelled`}function Dn(e){return e===`queued`||e===`running`||e===`complete`||e===`skipped`||e===`error`||e===`cancelled`}function On(e){return!e||e===`queued`||e===`running`}function kn(e){return e===`complete`||e===`skipped`||e===`error`||e===`cancelled`}function An(e){if(e!==void 0)try{return JSON.parse(JSON.stringify(e))}catch{return}}function jn(e){return e&&{message:e.message,stack:e.stack,detail:An(e.detail)}}function Mn(e){return{...e,error:jn(e.error)||null,result:An(e.result),logs:e.logs.map(e=>({...e,data:An(e.data)})),events:yn(e.events).map(e=>({...e,data:An(e.data)})),progress:e.progress?{...e.progress}:void 0}}function Nn(e){return{...e,status:zn(e.status),input:An(e.input),result:An(e.result),error:jn(e.error)||null}}function Pn(e){return{version:1,data:An(e.data),tasks:e.tasks.map(Nn)}}function Fn(e){return{version:1,savedAt:Date.now(),instances:Object.fromEntries(Object.entries(e.instances).map(([e,t])=>[e,Mn(t)])),histories:Object.fromEntries(Object.entries(e.histories).map(([e,t])=>[e,t.map(Mn)])),plans:Object.fromEntries(Object.entries(e.plans).map(([e,t])=>[e,Pn(t)]))}}function In(){return{version:1,savedAt:Date.now(),instances:{},histories:{},plans:{}}}function Ln(e,t){return{version:1,savedAt:t.savedAt,instances:{...e.instances,...t.instances},histories:{...e.histories,...t.histories},plans:{...e.plans,...t.plans}}}function Rn(e){return!Object.keys(e.instances).length&&!Object.keys(e.histories).length&&!Object.keys(e.plans).length}function zn(e){return Dn(e)?e:`queued`}function Bn(e,t){let n=Date.now(),r=typeof e.id==`string`&&e.id?e.id:`task-${t+1}`;return{...e,id:r,label:typeof e.label==`string`&&e.label?e.label:r,status:zn(e.status),error:e.error?pn(e.error):null,createdAt:typeof e.createdAt==`number`?e.createdAt:n}}function Vn(e){return!e||e.version!==1||!Array.isArray(e.tasks)?null:{version:1,data:e.data,tasks:e.tasks.map(Bn)}}function Hn(e){return{...e,tasks:e.tasks.map(e=>e.status===`running`?{...e,status:`queued`,statusText:`Queued after reload`,startedAt:void 0}:e)}}function Un(e,t=Date.now()){return{...e,tasks:e.tasks.map(e=>On(e.status)?{...e,status:`cancelled`,statusText:`Cancelled`,error:null,completedAt:t}:e)}}function Wn(e){return{...e,error:e.error?pn(e.error):null,logs:Array.isArray(e.logs)?e.logs:[],events:yn(Array.isArray(e.events)?e.events:[]),resultsAvailable:e.resultsAvailable===!0}}function Gn(e){return!e||e.version!==1?In():{version:1,savedAt:typeof e.savedAt==`number`?e.savedAt:Date.now(),instances:e.instances||{},histories:e.histories||{},plans:e.plans||{}}}function Kn(e,t,n){let r=e,i=t;if(Tn(e.status)){if(e.cancelRequestedAt){let t=Date.now();i=i&&Un(i,t),r=K({...e,status:`cancelled`,statusText:`Cancelled`,completedAt:t,cancelledAt:t},`status`,`Cancelled`,{status:`cancelled`},t)}else if(n.resumable&&i)i=Hn(i),r=K({...e,status:`running`,statusText:`Resuming`,completedAt:void 0,cancelledAt:void 0},`status`,`Resuming`,{status:`running`});else{let t=Date.now();r=K({...e,status:`cancelled`,statusText:`Interrupted by page reload`,completedAt:t,cancelledAt:t},`status`,`Interrupted by page reload`,{status:`cancelled`},t)}}return{instance:r,plan:i}}function qn(e,t){let n=Gn(e),r=new Map(t.map(e=>[e.id,e])),i={},a={},o={},s=In();for(let[e,t]of Object.entries(n.histories)){let n=(Array.isArray(t)?t:[]).map(Wn),i=n.filter(e=>r.has(e.actionId)),o=n.filter(e=>!r.has(e.actionId));i.length&&(a[e]=i),o.length&&(s.histories[e]=o)}for(let[e,t]of Object.entries(n.instances)){let c=Wn(t),l=Vn(n.plans[e]),u=r.get(c.actionId);if(!u){s.instances[e]=Mn(c),l&&(s.plans[e]=Pn(l));continue}let d=Kn(c,l,u);i[e]=d.instance,a=xn(a,e,d.instance),d.plan&&(o[e]=d.plan)}return{instances:i,histories:a,plans:o,deferred:s}}function Jn(e,t){let n=e.tasks.length;if(!n)return;let r=e.tasks.filter(e=>kn(e.status)).length;return wn({current:r,total:n,label:t})}function Yn(e){return e&&typeof e==`object`&&`taskStatus`in e&&(e.taskStatus===`complete`||e.taskStatus===`skipped`)?{taskStatus:e.taskStatus,result:e.result,statusText:e.statusText}:{taskStatus:`complete`,result:e}}function Xn(e,t){for(let n of t.tasks)!n.target||n.target.type!==`Canvas`||(n.status===`running`?e.setStatus(n.target,`pending`):n.status===`queued`&&e.setStatus(n.target,`queued`))}function Zn(e,t,n){let{store:r,context:i}=e,{instanceKey:a}=i;function o(){return r.getState().plans[a]}function s(){return o()?.tasks||[]}function c(e=[`queued`,`running`]){let t=new Set(e);return s().filter(e=>t.has(zn(e.status)))}function l(e,t,n=!1){r.getState().updateActionTask(a,e,t,n)}async function u(e,i={}){let u=c(i.statuses||[`queued`,`running`]),d=s().length,f=u.length,p=i.yieldEveryMs===!1?!1:i.yieldEveryMs??16,m=0;for(let[c,h]of u.entries()){if(t.aborted||Qn(m,p)&&(await $n(),m=Date.now(),t.aborted))throw Error(`Background action cancelled.`);let u=s().find(e=>e.id===h.id)||h,g=s().findIndex(e=>e.id===u.id),_=i.progressLabel?.(u,g,d)||u.label||`Task ${g+1}/${d}`;u.target?.type===`Canvas`&&n.setStatus(u.target,`pending`),l(u.id,{status:`running`,statusText:_,error:null,startedAt:Date.now(),completedAt:void 0},!0),r.getState().setActionStatus(a,`running`,_),r.getState().setActionProgress(a,{current:s().filter(e=>kn(e.status)).length,total:d,label:_});try{let r=await e(u,{index:g,total:d,pendingIndex:c,pendingTotal:f});if(t.aborted)throw Error(`Background action cancelled.`);let i=Yn(r);l(u.id,{status:i.taskStatus,statusText:i.statusText||(i.taskStatus===`skipped`?`Skipped`:`Complete`),result:i.result,error:null,completedAt:Date.now()},!0),u.target?.type===`Canvas`&&n.setStatus(u.target,`done`)}catch(e){if(t.aborted||ir(e))throw l(u.id,{status:`cancelled`,statusText:`Cancelled`,error:null,completedAt:Date.now()},!0),e;let n=fn(e);l(u.id,{status:`error`,statusText:n.message,error:n,completedAt:Date.now()},!0),r.getState().appendActionLog(a,`Task failed: ${u.label}`,`warn`,{taskId:u.id,error:n.message})}finally{let e=o();e&&r.getState().setActionProgress(a,{current:e.tasks.filter(e=>kn(e.status)).length,total:d,label:_})}}return s()}return{getAll:s,getPending:()=>c(),update:l,runEach:u}}function Qn(e,t){return t!==!1&&(!e||Date.now()-e>=t)}function $n(){return new Promise(e=>{setTimeout(e,0)})}function er(e=[]){let t=null,n=null,r=null,i=In();return Oe((a,o)=>{function s(e,t){let n=un([],t),r=qn(i,n);return i=r.deferred,{definitions:n,instances:{...e.instances,...r.instances},histories:{...e.histories,...r.histories},plans:{...e.plans,...r.plans},controllers:Object.fromEntries(Object.entries(e.controllers).filter(([t,n])=>n&&e.instances[t]?.status&&Tn(e.instances[t].status)))}}async function c(){if(r&&(clearTimeout(r),r=null),!t||!n||!o().hasHydrated)return;let e=Ln(i,Fn(o()));if(Rn(e)){await t.clear(n);return}await t.save(n,e)}function l(e=!1){if(!(!t||!n||!o().hasHydrated)){if(e){c();return}r&&clearTimeout(r),r=setTimeout(()=>{c()},300)}}return{definitions:un([],e),instances:{},histories:{},plans:{},controllers:{},hasHydrated:!0,setDefinitions(e){a(t=>s(t,e)),l()},setPersistence(e,r){t=e,n=e&&r?r:null,a({hasHydrated:!t})},hydrate(e){let t=qn(Gn(e),o().definitions);i=t.deferred,a({instances:t.instances,histories:t.histories,plans:t.plans,controllers:{},hasHydrated:!0}),l(!0)},persist(e=!1){l(e)},flushPersistence:c,registerAction(e){return a(t=>s(t,un(t.definitions,[e]))),l(),()=>o().unregisterAction(e.id)},unregisterAction(e){a(t=>{let n={};for(let[r,i]of Object.entries(t.instances))i.actionId!==e&&(n[r]=i);let r={};for(let[n,i]of Object.entries(t.histories)){let t=i.filter(t=>t.actionId!==e);t.length&&(r[n]=t)}let i={...t.plans},a={...t.controllers};for(let[n,r]of Object.entries(t.instances))r.actionId===e&&(a[n]?.abort(),delete a[n],delete i[n]);return{definitions:t.definitions.filter(t=>t.id!==e),instances:n,histories:r,plans:i,controllers:a}}),l(!0)},resetAction(e){a(t=>{t.controllers[e]?.abort();let n={...t.instances},r={...t.histories},i={...t.plans},a={...t.controllers};return delete n[e],delete r[e],delete i[e],delete a[e],{instances:n,histories:r,plans:i,controllers:a}}),l(!0)},startAction(e,t,n,r){let i=Date.now();a(a=>{let o={...a.plans};return delete o[e],{instances:{...a.instances,[e]:{id:e,runId:_n(`run`),actionId:t.id,target:n,label:t.label,status:`preparing`,statusText:`Preparing`,error:null,result:void 0,resultsAvailable:!1,logs:[],events:[vn(`started`,`Preparing`,{status:`preparing`},i)],progress:void 0,startedAt:i,completedAt:void 0,cancelRequestedAt:void 0,cancelledAt:void 0}},plans:o,controllers:r?{...a.controllers,[e]:r}:a.controllers}}),l(!0)},resumeAction(e,t){let n=Date.now();a(r=>({...Sn(r,e,e=>K({...e,status:`running`,statusText:`Resuming`,completedAt:void 0,cancelledAt:void 0},`status`,`Resuming`,{status:`running`},n)),controllers:{...r.controllers,[e]:t}})),l(!0)},cancelAction(e){let t=o().controllers[e],n=o().instances[e];if(!n||!Tn(n.status))return;let r=Date.now();a(t=>{let n=Sn(t,e,e=>K(K({...e,status:`cancelled`,statusText:`Cancelled`,completedAt:r,cancelledAt:r,cancelRequestedAt:e.cancelRequestedAt||r},`cancel-requested`,`Cancelling`,void 0,r),`status`,`Cancelled`,{status:`cancelled`},r)),i=t.plans[e];return{...n,plans:i?{...t.plans,[e]:Un(i,r)}:t.plans,controllers:Object.fromEntries(Object.entries(t.controllers).filter(([t])=>t!==e))}}),l(!0),t?.abort()},setActionLabel(e,t){let n=Date.now();a(r=>({...Sn(r,e,e=>K({...e,label:t},`label`,t,{label:t},n))})),l()},setActionStatus(e,t,n){let r=Date.now(),i=En(t)?r:void 0;a(a=>({...Sn(a,e,e=>K({...e,status:t,statusText:n,completedAt:i,cancelledAt:t===`cancelled`?r:void 0},`status`,n||t,{status:t},r)),controllers:Tn(t)?a.controllers:Object.fromEntries(Object.entries(a.controllers).filter(([t])=>t!==e))})),l(En(t))},setActionError(e,t,n){let r=Date.now(),i=fn(t);a(t=>({...Sn(t,e,e=>K({...e,status:`error`,statusText:n,error:i,completedAt:r,cancelledAt:void 0},`error`,n||i.message,i,r)),controllers:Object.fromEntries(Object.entries(t.controllers).filter(([t])=>t!==e))})),l(!0)},appendActionLog(e,t,n=`info`,r){let i=Date.now(),o={id:_n(`log`),createdAt:i,level:n,message:t,data:r};a(a=>({...Sn(a,e,e=>K({...e,logs:[...e.logs,o]},`log`,t,{level:n,data:r},i))})),l()},setActionProgress(e,t){let n=t?wn(t):void 0;a(t=>({...Sn(t,e,e=>({...e,progress:n}))}))},setResult(e,t){let n=Date.now();a(r=>({...Sn(r,e,e=>K({...e,result:t},`result`,`Result recorded`,void 0,n))})),l(!0)},setResultsAvailable(e,t){let n=Date.now();a(r=>({...Sn(r,e,e=>K({...e,resultsAvailable:t},`results-available`,t?`Results available`:`Results hidden`,{available:t},n))})),l(!0)},setActionPlan(e,t){let n=Vn(t);n&&(a(t=>({...Sn(t,e,e=>({...e,progress:Jn(n,`Queued`)})),plans:{...t.plans,[e]:n}})),l(!0))},updateActionTask(e,t,n,r=!1){a(r=>{let i=r.plans[e];if(!i)return r;let a=i.tasks.map(e=>e.id===t?Bn({...e,...n,status:n.status?zn(n.status):e.status,error:n.error?pn(n.error):n.error===null?null:e.error},0):e),o={...i,tasks:a};return{...Sn(r,e,e=>({...e,progress:Jn(o,n.statusText||n.label)})),plans:{...r.plans,[e]:o}}}),l(r)}}})}function tr(e,t,n){let{store:r,context:i}=e,{instanceKey:a}=i,o=Zn(e,t,n);return{...i,canvasProgress:n,instance:r.getState().instances[a],plan:r.getState().plans[a],tasks:o,signal:t,prepareData:e.prepareData,setActionLabel(e){r.getState().setActionLabel(a,e)},setActionStatus(e,t){r.getState().setActionStatus(a,e,t)},setActionError(e,t){r.getState().setActionError(a,e,t)},appendActionLog(e,t,n){r.getState().appendActionLog(a,e,t,n)},setActionProgress(e){r.getState().setActionProgress(a,e)},setResult(e){r.getState().setResult(a,e)},setResultsAvailable(e){r.getState().setResultsAvailable(a,e)}}}function nr(e){return!!e&&typeof e==`object`&&e.version===1&&Array.isArray(e.tasks)}async function rr(e){let{store:t,context:n}=e,{definition:r,instanceKey:i,target:a}=n,o=t.getState().instances[i],s=t.getState().controllers[i];if((o?.status===`preparing`||o?.status===`running`)&&(!e.resume||s))return o;let c=new AbortController,l=c.signal,u=Qt(n.canvasProgress),d=()=>c.abort();e.signal&&(e.signal.aborted?c.abort():e.signal.addEventListener(`abort`,d,{once:!0})),e.resume&&o&&Tn(o.status)?t.getState().resumeAction(i,c):t.getState().startAction(i,r,a,c);let f=()=>{let e=t.getState().instances[i];e&&!En(e.status)&&t.getState().setActionStatus(i,`cancelled`,`Cancelled`)};try{if(!e.resume&&r.prepare){let n=await r.prepare(tr(e,l,u));if(l.aborted)return f(),t.getState().instances[i];if(n===!1)return t.getState().setActionStatus(i,`idle`),t.getState().instances[i];nr(n)&&t.getState().setActionPlan(i,n)}if(l.aborted)return f(),t.getState().instances[i];let n=t.getState().plans[i];n&&Xn(u,n),t.getState().setActionStatus(i,`running`,e.resume?`Resuming`:`Running`);let a=await r.run(tr(e,l,u));if(l.aborted)return f(),t.getState().instances[i];let o=t.getState().instances[i];a!==void 0&&o&&!En(o.status)&&t.getState().setResult(i,a),o=t.getState().instances[i],o&&Tn(o.status)&&((a!==void 0||o?.resultsAvailable)&&t.getState().setResultsAvailable(i,!0),t.getState().setActionStatus(i,`complete`,`Complete`))}catch(e){l.aborted||ir(e)?f():t.getState().setActionError(i,e,`Error`)}finally{u.clearTrackedStatuses(),e.signal?.removeEventListener(`abort`,d),await t.getState().flushPersistence()}return t.getState().instances[i]}function ir(e){return e instanceof Error&&(e.name===`AbortError`||e.message.toLowerCase().includes(`aborted`))}function ar(e){return JSON.stringify([e.appId,e.instanceId,e.rootResource.type,e.rootResource.id])}let or;function sr(){if(typeof window>`u`)return null;let e=Ae.createInstance({name:`manifest-editor-background-actions-v1`,storeName:`background-actions`});return{async load(t){return e.getItem(ar(t))},async save(t,n){await e.setItem(ar(t),n)},async clear(t){await e.removeItem(ar(t))}}}function cr(){return or===void 0&&(or=sr()),or}const lr=j(null);function ur({children:e,persistence:t,persistenceKey:n}){let r=J(),i=Si(),a=I(()=>er(),[]),o=r.layout.backgroundActions||[],s=I(()=>t===!1?null:t||cr(),[t]),c=I(()=>n||null,[n]);return P(()=>{a.getState().setDefinitions(o)},[a,o]),P(()=>{let e=c||{appId:i.appId,instanceId:i.instanceId,rootResource:{id:`global`,type:`Manifest`}},t=!1;return a.getState().setPersistence(s,e),s?(s.load(e).then(e=>{t||a.getState().hydrate(e)}).catch(e=>{console.warn(`[manifest-editor/background-actions] Failed to load persisted actions`,e),t||a.getState().hydrate(null)}),()=>{t=!0,a.getState().flushPersistence()}):(a.getState().hydrate(null),()=>void 0)},[i.appId,i.instanceId,s,c?.appId,c?.instanceId,c?.rootResource.id,c?.rootResource.type,a]),P(()=>{let e=()=>{a.getState().flushPersistence()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[a]),xe(lr.Provider,{value:a},e)}function dr(){let e=N(lr);if(!e)throw Error(`useBackgroundActionsStore must be used within a BackgroundActionsProvider`);return e}function q(e=e=>e){return ke(dr(),e)}function fr(e){return q(t=>t.instances[e])}function pr(e){return q(t=>t.histories[e]||[])}async function mr(e){let t;try{await fetch(e).then(e=>e.json().catch(e=>{console.error(`'${e}' happened!`)})).then(e=>{t={...e}})}catch(e){console.log(e)}return t}function hr(e,t,n){return`create_${e}_${t}_${qe(n)?.type||`unknown`}`}function gr(e,t,n=`text/json`){let r=e instanceof Blob?e:new Blob([e],{type:n}),i=document.createElement(`a`);i.download=t,i.href=window.URL.createObjectURL(r);let a=new MouseEvent(`click`,{view:window,bubbles:!0,cancelable:!0});i.dispatchEvent(a),i.remove()}async function _r(e){return navigator.clipboard.writeText(typeof e==`string`?e:JSON.stringify(e,null,2))}function vr(){return`${Math.random().toString(36).substr(2)}-${Date.now().toString(36)}`}function yr(e,t){let{default:n,config:r,preset:i,...a}=e,o={metadata:n,layout:{leftPanels:[],rightPanels:[],centerPanels:[],...a},config:r,preset:i},s=t?t(o):o;return{...s,preset:br(void 0,s.preset)}}function br(e,t){if(!e&&!t)return;let n=e?.templateFilter&&t?.templateFilter?n=>e.templateFilter(n)&&t.templateFilter(n):t?.templateFilter||e?.templateFilter,r=t?.templateStrategy===`replace`?t.templates||[]:[...e?.templates||[],...t?.templates||[]],i=e?.preview||t?.preview?{...e?.preview||{},...t?.preview||{},actions:[...e?.preview?.actions||[],...t?.preview?.actions||[]]}:void 0;return{...e||{},...t||{},templateFilter:n,templates:n?r.filter(n):r,preview:i}}function xr(e,t,n){return{...e,metadata:t,config:Mt(e.config||{},n.config||{}),preset:br(e.preset,n.preset),layout:{...e.layout,leftPanels:[...(e.layout.leftPanels||[]).filter(e=>!n?.leftPanelIds||n.leftPanelIds.includes(e.id)),...n?.leftPanels||[]],annotations:[...n?.annotations||[],...e.layout.annotations||[]],canvasEditors:[...n?.canvasEditors||[],...e.layout.canvasEditors||[]],creators:[...n?.creators||[],...e.layout.creators||[]],background:[...e.layout?.background||[],...n?.background||[]],backgroundActions:un(e.layout?.backgroundActions||[],n?.backgroundActions||[]),editors:[...n?.editors||[],...e.layout.editors||[]],rightPanels:[...e.layout.rightPanels||[],...n?.rightPanels||[]],centerPanels:[...e.layout.centerPanels||[],...n?.centerPanels||[]],modals:[...e.layout.modals||[],...n?.modalPanels||[]]}}}const Sr=[`leftPanels`,`centerPanels`,`rightPanels`,`modalPanels`,`annotations`,`canvasEditors`,`editors`,`creators`,`background`,`backgroundActions`],Cr={plugins:[],enabled:[],disabled:[],globalApps:{},apps:{}};function wr(){return Cr}function Tr(e=[]){return Array.from(new Set(e.filter(Boolean)))}function Er(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Dr(e={}){return{...e,enabled:Tr(e.enabled||[]),disabled:Tr(e.disabled||[]),settings:e.settings?{...e.settings}:void 0}}function Or(e){let t={};for(let[n,r]of Object.entries(e?.apps||{}))t[n]=Dr(r);return t}function kr(e={},t){return{...e,enabled:Tr([...(e.enabled||[]).filter(e=>e!==t),t]),disabled:(e.disabled||[]).filter(e=>e!==t)}}function Ar(e={},t){return{...e,enabled:(e.enabled||[]).filter(e=>e!==t),disabled:Tr([...(e.disabled||[]).filter(e=>e!==t),t])}}function jr(e={},t){return{...e,enabled:(e.enabled||[]).filter(e=>e!==t),disabled:(e.disabled||[]).filter(e=>e!==t)}}function Mr(e={},t={}){let n=e.enabled||[],r=t.enabled||[],i=e.disabled||[],a=t.disabled||[];return n.length===r.length&&n.every((e,t)=>e===r[t])&&i.length===a.length&&i.every((e,t)=>e===a[t])&&JSON.stringify(e.settings||{})===JSON.stringify(t.settings||{})}function Nr(e,t){let{default:n,config:r,settings:i,...a}=e,o={metadata:n,extension:{...a,config:r},settings:i};return t?t(o):o}function Pr(e){return{metadata:e.default,extension:{},settings:e.settings,load:e.load,loadStatus:`idle`}}function Fr(e){return!!e&&`metadata`in e&&`extension`in e}function Ir(e){return!!e&&`load`in e&&`default`in e}function Lr(e){return Fr(e)?e:Ir(e)?Pr(e):Nr(e)}function Rr(e=[]){return e.map(Lr)}function zr(e,t){let n=new Map(e.map(e=>[e.metadata.id,e]));return t.map(e=>{let t=n.get(e.metadata.id);return t?t.loadStatus===`loaded`&&e.load?{...t,metadata:e.metadata,load:e.load}:t.loadStatus===`loading`&&e.load?{...e,loadStatus:`loading`}:t.loadStatus===`error`&&e.load?{...e,loadStatus:`error`,loadError:t.loadError}:e:e})}function Br(e,t,n){let r=e.metadata.supports;if(!r)return!0;if(r.apps?.length){let e=new Set([n,t?.metadata.id].filter(Boolean));if(!r.apps.some(t=>e.has(t)))return!1}if(r.projectTypes?.length){let e=t?.metadata.projectType;if(!e||!r.projectTypes.includes(e))return!1}return!0}function Vr(e,t,n){let r=e.metadata.supports;if(!r)return null;if(r.apps?.length){let e=new Set([n,t?.metadata.id].filter(Boolean));if(!r.apps.some(t=>e.has(t)))return`This plugin does not support the current app.`}if(r.projectTypes?.length){let e=t?.metadata.projectType;if(!e||!r.projectTypes.includes(e))return`This plugin does not support the current project type.`}return null}function Hr(e,t,n){let r=n?t.apps[n]:void 0,i=n?t.globalApps[n]:void 0,a=e.metadata.id;return r?.disabled?.includes(a)?!1:r?.enabled?.includes(a)?!0:i?.disabled?.includes(a)?!1:i?.enabled?.includes(a)?!0:t.disabled.includes(a)?!1:t.enabled.includes(a)?!0:e.metadata.defaultEnabled===!0}function Ur(e,t,n){let r=n?t.apps[n]:void 0,i=n?t.globalApps[n]:void 0,a=e.metadata.id;return r?.disabled?.includes(a)||r?.enabled?.includes(a)?`workspace`:i?.disabled?.includes(a)||i?.enabled?.includes(a)?`global`:t.disabled.includes(a)||t.enabled.includes(a)?`provider`:`default`}function Wr(e,t,n){let r=[],i=new Set,a=new Set,o=new Set(e.plugins.filter(r=>Br(r,t,n)&&Hr(r,e,n)).map(e=>e.metadata.id)),s=new Map(e.plugins.map(e=>[e.metadata.id,e])),c=new Set;function l(e){let u=e.metadata.id;if(i.has(u))return!0;if(a.has(u))return!1;if(c.has(u))return $r(`Plugin "${u}" was not enabled because its dependency graph contains a cycle.`),a.add(u),!1;c.add(u);for(let r of e.metadata.dependencies||[]){let e=s.get(r);if(!e||!o.has(r))return $r(`Plugin "${u}" was not enabled because dependency "${r}" is not enabled.`),c.delete(u),a.add(u),!1;if(!Br(e,t,n))return $r(`Plugin "${u}" was not enabled because dependency "${r}" is not compatible.`),c.delete(u),a.add(u),!1;if(!l(e))return c.delete(u),a.add(u),!1}return c.delete(u),r.push(e),i.add(u),!0}for(let r of e.plugins)Br(r,t,n)&&Hr(r,e,n)&&l(r);return r}function Gr(e,t){let n=e?.settings?.[t];return Er(n)?n:{}}function Kr(e={},t,n){return{...e,settings:{...e.settings||{},[t]:n}}}function qr(e={},t){let n={...e.settings||{}};return delete n[t],{...e,settings:n}}function Jr(e){return{...e?.settings?.defaults||{}}}function Yr(e,t,n){let r=e.plugins.find(e=>e.metadata.id===t),i=n?e.globalApps[n]:void 0,a=n?e.apps[n]:void 0;return{...Jr(r),...Gr(i,t),...Gr(a,t)}}function Xr(e,t){return{getSettings(n){return Yr(e,n,t)}}}function Zr(e,t,n,r,i){let a=new Map(t.plugins.map(e=>[e.metadata.id,e])),o=[],s=[],c=new Set,l=e;function u(e){let t=e.metadata.id;if(!o.includes(t)){if(c.has(t)){s.push(`${t} has a circular dependency`);return}c.add(t);for(let t of e.metadata.dependencies||[]){let e=a.get(t);if(!e){s.push(`${t} is not available`);continue}if(!Br(e,r,i)){s.push(`${e.metadata.label} is not compatible`);continue}u(e)}c.delete(t),l=kr(l,t),o.push(t)}}return u(n),s.length?{config:e,enabledIds:[],blocked:s}:{config:l,enabledIds:o,blocked:s}}function Qr(e,t){return t===`modalPanels`?e.layout.modals||[]:e.layout[t]||[]}function $r(e){globalThis.process?.env?.NODE_ENV!==`production`&&console.warn(`[manifest-editor/plugin] ${e}`)}function ei(e,t,n,r){if(!r?.length)return;let i=[];for(let a of r){if(n.has(a.id)){$r(`Plugin "${e.metadata.id}" contribution "${a.id}" for "${t}" was skipped because that id already exists.`);continue}n.add(a.id),i.push(a)}return i.length?i:void 0}function ti(e,t){let n=t.extension,r={config:n.config,preset:n.preset,disableSideEffects:n.disableSideEffects};for(let i of Sr){let a=ei(t,i,new Set(Qr(e,i).map(e=>e.id)),n[i]);a&&(r[i]=a)}return r}function ni(e,t,n){if(!t.length)return e;let r=e,i=new Set;for(let a of t){if(!Br(a,e,n))continue;let t=(a.metadata.dependencies||[]).filter(e=>!i.has(e));if(t.length){$r(`Plugin "${a.metadata.id}" was not applied because dependencies are missing or later in the plugin order: ${t.join(`, `)}`);continue}let o=ti(r,a);r=xr(r,r.metadata,o),i.add(a.metadata.id)}let a=new Set(e.layout.leftPanels.map(e=>e.id)),o=r.layout.leftPanels.filter(e=>e.divide),s=r.layout.leftPanels.filter(e=>!e.divide),c=!1,l=s.map(e=>!c&&!a.has(e.id)?(c=!0,{...e,separator:!0}):e);return{...r,config:Mt(e.config||{},...t.filter(e=>i.has(e.metadata.id)).map(e=>e.extension.config||{}),r.config||{}),layout:{...r.layout,leftPanels:[...l,...o],backgroundActions:un([],r.layout.backgroundActions||[])}}}function ri({plugins:e=[],enabled:t=[],disabled:n=[],globalPluginConfig:r}={}){let i=(e=[])=>Array.from(new Set(e.filter(Boolean)));return Oe(a=>({plugins:e,enabled:i(t),disabled:i(n),globalApps:Or(r),apps:{},setProviderState(e){a(t=>({...t,plugins:zr(t.plugins,e.plugins||[]),enabled:i(e.enabled||[]),disabled:i(e.disabled||[]),globalApps:Or(e.globalPluginConfig)}))},setPluginLoading(e){a(t=>({...t,plugins:t.plugins.map(t=>t.metadata.id===e?{...t,loadStatus:`loading`,loadError:void 0}:t)}))},setPluginLoaded(e,t){a(n=>({...n,plugins:n.plugins.map(n=>n.metadata.id===e?{...t,metadata:{...n.metadata,...t.metadata},settings:t.settings||n.settings,load:n.load,loadStatus:`loaded`,loadError:void 0}:n)}))},setPluginLoadError(e,t){a(n=>({...n,plugins:n.plugins.map(n=>n.metadata.id===e?{...n,loadStatus:`error`,loadError:t}:n)}))},setAppConfig(e,t){let n=Dr(t);a(t=>Mr(t.apps[e],n)?t:{...t,apps:{...t.apps,[e]:n}})},setGlobalConfig(e){a(t=>({...t,globalApps:Or(e)}))},setGlobalAppConfig(e,t){let n=Dr(t);a(t=>Mr(t.globalApps[e],n)?t:{...t,globalApps:{...t.globalApps,[e]:n}})},enable(e,t,n=`workspace`){a(r=>({...r,plugins:r.plugins.map(e=>e.metadata.id===t&&e.loadStatus===`error`?{...e,loadStatus:`idle`,loadError:void 0}:e),...n===`global`?{globalApps:{...r.globalApps,[e]:kr(r.globalApps[e],t)}}:{apps:{...r.apps,[e]:kr(r.apps[e],t)}}}))},disable(e,t,n=`workspace`){a(r=>({...r,...n===`global`?{globalApps:{...r.globalApps,[e]:Ar(r.globalApps[e],t)}}:{apps:{...r.apps,[e]:Ar(r.apps[e],t)}}}))}}))}const ii=j(null),ai=j({});function oi({plugins:e,enabled:t,disabled:n,globalPluginConfig:r,saveGlobalPluginConfig:i,children:a}){let o=I(()=>Rr(e),[e]),s=I(()=>ri({plugins:o,enabled:t,disabled:n,globalPluginConfig:r}),[]);P(()=>{s.getState().setProviderState({plugins:o,enabled:t,disabled:n,globalPluginConfig:r})},[s,o,t,n,r]);let c=I(()=>({globalPluginConfig:r,saveGlobalPluginConfig:i}),[r,i]);return xe(ai.Provider,{value:c},xe(ii.Provider,{value:s},a))}function si(){return N(ii)}function ci(){let e=si();if(!e)throw Error(`usePluginStoreApi must be used within <PluginProvider />`);return e}function li(e){let t=si();return t?ke(t,e):e(wr())}function ui(){return li(e=>({plugins:e.plugins,enabled:e.enabled,disabled:e.disabled,globalApps:e.globalApps,apps:e.apps}))}function di(e){let t=N(bi),n=N(yi),r=ui(),i=e||t?.appId;return I(()=>Wr(r,n,i),[r,n,i])}function fi(){let e=si();return I(()=>e?{enable(t,n,r){e.getState().enable(t,n,r||`workspace`)},disable(t,n,r){e.getState().disable(t,n,r||`workspace`)},setAppConfig(t,n){e.getState().setAppConfig(t,n)},setGlobalAppConfig(t,n){e.getState().setGlobalAppConfig(t,n)}}:{enable(){},disable(){},setAppConfig(){},setGlobalAppConfig(){}},[e])}function pi(e){let t=N(bi),n=ui(),r=e||t?.appId;return I(()=>Xr(n,r),[n,r])}function mi(e,t){let n=N(bi),r=ui(),i=t||n?.appId;return I(()=>Yr(r,e,i),[r,e,i])}function hi(e,t){let n=N(bi),r=si(),i=ui(),a=It(),o=Lt(),{saveGlobalPluginConfig:s}=N(ai),c=t||n?.appId||``,l=i.plugins.find(t=>t.metadata.id===e)||null,u=c?i.globalApps[c]:void 0,d=c?i.apps[c]:void 0,f=I(()=>Jr(l||void 0),[l]),p=I(()=>Gr(u,e),[u,e]),m=I(()=>Gr(d,e),[d,e]),h=I(()=>Yr(i,e,c),[i,e,c]),g=M(e=>{c&&(r?.getState().setAppConfig(c,e),o({plugins:{...a.plugins||{},apps:{...a.plugins?.apps||{},[c]:e}}}))},[a.plugins,c,o,r]),_=M(t=>{g(Kr(d||{},e,t))},[g,e,d]),v=M(()=>{g(qr(d||{},e))},[g,e,d]),y=M(async e=>{if(!c||!s)return;let t=i.globalApps[c]||{},n={apps:{...i.globalApps,[c]:e}};r?.getState().setGlobalAppConfig(c,e);try{await s(n)}catch(e){throw r?.getState().setGlobalAppConfig(c,t),e}},[c,s,i.globalApps,r]),b=M(async t=>{await y(Kr(u||{},e,t))},[u,y,e]),x=M(async()=>{await y(qr(u||{},e))},[u,y,e]);return{plugin:l,appId:c,defaults:f,global:p,workspace:m,effective:h,canSaveGlobal:!!s,setWorkspaceSettings:_,resetWorkspaceSettings:v,setGlobalSettings:b,resetGlobalSettings:x}}function gi(e,t){let n=ui(),r=si(),i=I(()=>Wr(n,e,t),[n,e,t]);return P(()=>{if(r)for(let e of i)!e.load||e.loadStatus===`loading`||e.loadStatus===`loaded`||e.loadStatus===`error`||(r.getState().setPluginLoading(e.metadata.id),e.load().then(t=>{r.getState().setPluginLoaded(e.metadata.id,Lr(t))}).catch(t=>{r.getState().setPluginLoadError(e.metadata.id,_i(t))}))},[r,i]),I(()=>ni(e,i.filter(e=>!e.load||e.loadStatus===`loaded`),t),[e,i,t])}function _i(e){return e instanceof Error?e.message:typeof e==`string`?e:`Plugin failed to load.`}function vi({config:e}){let t=N(bi),n=si(),r=t?.appId,i=r?e?.plugins?.apps?.[r]:void 0;return P(()=>{!n||!r||n.getState().setAppConfig(r,i||{})},[n,r,i]),null}const yi=j(null),bi=j(null),xi=j({state:null,setState:()=>{}});function Si(){let e=N(bi);return G(e,`Hook useAppInstance must be used inside <AppProvider />`),e}function J(){let e=N(yi);return G(e,`Hook useApp must be used inside <AppProvider />`),e}function Ci(){return N(xi)}function wi(e,t){return e.find(e=>e.id===t)||null}function Ti(){let e=J(),{state:t,setState:n}=Ci(),r=e.preset?.templates||[],i=typeof t?.presetTemplateId==`string`?t.presetTemplateId:null;return{templates:r,selectedTemplateId:i,selectedTemplate:I(()=>wi(r,i),[i,r]),setSelectedTemplateId:M(e=>n({presetTemplateId:e}),[n])}}function Ei(e){let[t,n,r]=me(`app-state/${e.appId}/${e.instanceId}`,e.initialState||{}),i=M(e=>{let t=r.current?JSON.parse(r.current||`{}`):{},i=(typeof e==`function`?e(t):e)||{};n({...t,...i})},[]);P(()=>{e.args&&i(e.args)},[e.appId]);let a=I(()=>({state:t||{},setState:i}),[i,t]);return B(xi.Provider,{value:a,children:e.children})}function Di({instanceId:e,appId:t,args:n,definition:r,children:i,initialState:a}){let o=I(()=>({instanceId:e,appId:t,args:n}),[e,t,n]),s=I(()=>a||{},[e]),c=gi(r,t);return B(Rt,{config:c.config||{},children:B(yi.Provider,{value:c,children:B(bi.Provider,{value:o,children:B(Ei,{instanceId:o.instanceId,appId:o.appId,args:o.args,initialState:s,children:i})})})})}const Oi=j(null);function ki(){let e=N(Oi);return G(e,`Hook useApps must be used inside <MultiAppProvider />`),e}function Ai(e,t=!1){let[n,r]=ge(`SelectedApplication`,e||{id:`splash`},!t);return[n,r]}function ji({apps:e,initialApp:t,saveCurrentApp:n=!0,instanceId:r,children:i,config:a={}}){let{defaultApp:o=`splash`,collectionApp:s=`collection-editor`,manifestApp:c=`manifest-editor`}=a,[l,u]=Ai(t,n),d=e=>{e===`Manifest`&&u({id:c}),e===`Collection`&&u({id:s})},f=I(()=>({currentApp:l||{id:o},initialApp:t||{id:o},apps:e,changeApp:u,changeProjectType:d}),[t,e,l]),p=e[f.currentApp.id];return!l||!p?null:B(Di,{appId:l.id,definition:p,instanceId:l.id+r,args:l.args,children:B(Oi.Provider,{value:f,children:i})})}const Mi=U.div`
1
+ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuButton as r,BackgroundActionMenuDivider as i,BackgroundActionMenuInfoButton as a,BackgroundActionMenuInlineAction as o,BackgroundActionMenuItem as s,BackgroundActionMenuLabel as c,BackgroundActionMenuMeta as l,BackgroundActionMenuPanel as u,BackgroundActionMenuProgressBar as d,BackgroundActionMenuRoot as f,BackgroundActionMenuSection as p,BackgroundActionMenuText as m,BackgroundActionMenuTrigger as h,CheckIcon as g,CreatorGrid as _,DefaultTooltipContent as v,DownloadButton as y,EmptyState as b,ErrorMessage as x,Form as S,GridIcon as C,IconButton as w,IconHandle as T,ManifestEditorLogo as E,Modal as ee,ModalBackSlot as D,PaddedSidebarContainer as O,PanelSideMenu as k,ResetIcon as te,ResizeHandle as ne,Sidebar as re,SidebarContent as ie,SidebarHeader as ae,SidebarTabs as oe,Spinner as A,Tab as se,TabList as ce,TabPanel as le,Tabs as ue,ToastRegion as de,Tooltip as fe,TooltipTrigger as pe,useLocalStorage as me,useOptionalLocalStorage as he,useOptionalLocalStorage as ge}from"@manifest-editor/components";import*as _e from"react";import{Component as ve,Fragment as ye,Suspense as be,createContext as j,createElement as xe,createRef as Se,forwardRef as Ce,memo as we,useCallback as M,useContext as N,useEffect as P,useImperativeHandle as Te,useLayoutEffect as F,useMemo as I,useReducer as Ee,useRef as L,useState as R}from"react";import{Fragment as z,jsx as B,jsxs as V}from"react/jsx-runtime";import{create as De,createStore as Oe,useStore as ke}from"zustand";import Ae from"localforage";import{AtlasStoreProvider as je,AtlasStoreProvider as Me,AtlasStoreReactContext as Ne,CollectionContext as Pe,ImageServiceLoaderContext as Fe,ManifestContext as Ie,ReactVaultContext as Le,ResourceReactContext as Re,VaultProvider as ze,useAtlasStore as Be,useCurrentAnnotationMetadata as Ve,useExistingVault as He,useManifest as Ue,useResourceContext as We,useVault as H,useVaultSelector as Ge}from"react-iiif-vault";import{isSpecificResource as Ke,toRef as qe}from"@iiif/parser";import U,{ThemeProvider as Je,css as W}from"styled-components";import{original as Ye,produce as Xe}from"immer";import{EditorInstance as Ze}from"@manifest-editor/editor-api";import{useToastState as Qe}from"@react-stately/toast";import{getValue as $e}from"@iiif/helpers";import*as et from"@iiif/helpers/vault";import{Vault as tt}from"@iiif/helpers/vault";import{Creator as nt,getCreatorConfigKey as rt,matchBasedOnResource as it}from"@manifest-editor/creator-api";import{ErrorBoundary as at}from"react-error-boundary";import{addReference as ot,batchActions as st,modifyEntityField as ct,reorderEntityField as lt,requestResource as ut}from"@iiif/helpers/vault/actions";import{actionListFromResource as dt}from"@iiif/helpers/vault/utility";import ft from"mitt";import{useDebounce as pt}from"tiny-use-debounce";import{Transition as mt}from"react-transition-group";import ht from"shallowequal";import{ImageServiceLoader as gt}from"@atlas-viewer/iiif-image-api";import{MessagePortClientVault as _t}from"@manifest-editor/client-vault";var vt=Object.create,yt=Object.defineProperty,bt=Object.getOwnPropertyDescriptor,xt=Object.getOwnPropertyNames,St=Object.getPrototypeOf,Ct=Object.prototype.hasOwnProperty,wt=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Tt=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=xt(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Ct.call(e,s)&&s!==n&&yt(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=bt(t,s))||r.enumerable});return e},Et=(e,t,n)=>(n=e==null?{}:vt(St(e)),Tt(t||!e||!e.__esModule||!Ct.call(e,`default`)?yt(n,`default`,{value:e,enumerable:!0}):n,e)),Dt=`Invariant failed`;function G(e,t){if(!e)throw Error(Dt)}const Ot={previews:[],behaviorPresets:[`auto-advance`,`no-auto-advance`,`repeat`,`no-repeat`,`unordered`,`individuals`,`continuous`,`paged`,`non-paged`,`facing-pages`,`multi-part`,`together`,`sequence`,`thumbnail-nav`,`no-nav`,`hidden`],defaultPreview:null,editorConfig:{},newTemplates:null,i18n:{advancedLanguageMode:!1,availableLanguages:[`en`,`cy`,`nl`,`fr`],defaultLanguage:`en`},editorFeatureFlags:{enableMultiImageCanvases:!0,enableMultiMediaCanvases:!0,annotationPopups:!1,rememberCanvasId:!0,manifestGridOptions:!1,rememberLeftPanelId:!1},uploadBackends:[],plugins:{apps:{}},export:{baseIdentifier:null,version:3},creators:{"iiif-image-services":{compact:`with-dimensions`,includeSizes:!1,includeTiles:!1}}};function kt(e,t){if(!e&&!t)return;let n={...e||{}};for(let[e,r]of Object.entries(t||{}))n[e]={...n[e]||{},...r||{}};return n}function At(e,t){if(!e&&!t)return;let n={...e?.apps||{}};for(let[e,r]of Object.entries(t?.apps||{})){let t=n[e]||{};n[e]={...t,...r,settings:{...t.settings||{},...r.settings||{}}}}return{apps:n}}function jt(e,t){if(!e&&!t)return;let n={...e||{}};for(let[e,r]of Object.entries(t||{}))n[e]={...n[e]||{},...r||{}};return n}function Mt(...e){let t={};for(let n of e)n&&(t={...t,...n,editorConfig:kt(t.editorConfig,n.editorConfig),editorFeatureFlags:t.editorFeatureFlags||n.editorFeatureFlags?{...t.editorFeatureFlags||{},...n.editorFeatureFlags||{}}:void 0,i18n:t.i18n||n.i18n?{...t.i18n||{},...n.i18n||{}}:void 0,export:t.export||n.export?{...t.export||{},...n.export||{}}:void 0,creators:jt(t.creators,n.creators),plugins:At(t.plugins,n.plugins)});return t}function Nt(...e){return Mt(Ot,...e)}const Pt=j(Ot),Ft=j(()=>{});function K(){return N(Pt)}function It(){return N(Ft)}function Lt({children:e,config:t,saveConfig:n}){let[r,i]=R(null),a=I(()=>Nt(t,r),[t,r]),o=M(e=>{i(t=>Mt(t,e)),n&&n(e)},[n]);return B(Ft.Provider,{value:o,children:B(Pt.Provider,{value:a,children:e})})}const Rt=`@manifest-editor/canvas-progress`,zt=`status`,Bt=new Set([`queued`,`pending`,`done`]);function Vt(e){return typeof e==`string`?e:e?.id||null}function Ht(e){return typeof e==`string`&&Bt.has(e)?e:`none`}function Ut(e){return typeof e==`string`&&Bt.has(e)}function Wt(e,t){let n=Vt(t);return n?Ht(e.getResourceMeta(n,Rt)?.[zt]):`none`}function Gt(e,t){let n=Vt(t);return n?Ht(e?.iiif?.meta?.[n]?.[Rt]?.[zt]):`none`}function Kt(e,t,n){let r=Vt(t);if(!r)return`none`;let i=Ut(n)?n:void 0;return e.setMetaValue([r,Rt,zt],i),i||`none`}function qt(e,t){return Kt(e,t,`none`)}function Jt(e,t,n){let r={};for(let i of t){let t=Vt(i);t&&(r[t]=Kt(e,i,n))}return r}function Yt(e,t){return Jt(e,t,`none`)}function Xt(e){return{getStatus(t){return Wt(e,t)},setStatus(t,n){return Kt(e,t,n)},clearStatus(t){return qt(e,t)},setStatuses(t,n){return Jt(e,t,n)},clearStatuses(t){return Yt(e,t)}}}function Zt(e,t=new Set){function n(e){let n=Vt(e);n&&t.add(n)}function r(e){for(let t of e)n(t)}return{trackedResourceIds:t,getStatus(t){return e.getStatus(t)},setStatus(t,r){return n(t),e.setStatus(t,r)},clearStatus(t){return n(t),e.clearStatus(t)},setStatuses(t,n){return r(t),e.setStatuses(t,n)},clearStatuses(t){return r(t),e.clearStatuses(t)},clearTrackedStatuses(){e.clearStatuses(Array.from(t).map(e=>({id:e,type:`Canvas`}))),t.clear()}}}function Qt(e){let t=Vt(e);return Ge(e=>t?Gt(e,t):`none`,[t])}function $t(e){let t=H(),n=Vt(e),r=I(()=>Xt(t),[t]);return I(()=>({setStatus(e){return r.setStatus(n,e)},clearStatus(){return r.clearStatus(n)},getStatus(){return r.getStatus(n)}}),[r,n])}const en={queued:{label:`Queued`,stripClass:`bg-zinc-400/80`,badgeClass:`bg-zinc-500`,dimOverlay:!0},pending:{label:`In progress`,stripClass:`bg-amber-400/90 animate-pulse`,badgeClass:`bg-amber-500`},done:{label:`Done`,stripClass:`bg-me-primary-500`,badgeClass:`bg-me-primary-500`}};function tn({className:e}){return V(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[B(`circle`,{cx:`12`,cy:`12`,r:`9`}),B(`path`,{d:`M12 7v5l2.5 2.5`})]})}function nn({className:e}){return V(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,children:[B(`circle`,{cx:`12`,cy:`12`,r:`9`,stroke:`currentColor`,strokeWidth:`2.5`,strokeOpacity:`0.3`}),B(`path`,{d:`M12 3a9 9 0 0 1 9 9`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`})]})}function rn({className:e}){return B(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:B(`path`,{d:`M5 12l4 4 8-8`})})}function an({resource:e,status:t,className:n}){return t?B(sn,{status:t,className:n}):B(on,{resource:e,className:n})}function on({resource:e,className:t}){let n=Qt(e);return B(sn,{status:n,className:t})}function sn({status:e,className:t}){if(e===`none`)return null;let n=en[e];return V(z,{children:[n.dimOverlay&&B(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 z-10 bg-white/40`}),B(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-x-0 top-0 z-10 h-[3px] rounded-t-sm ${n.stripClass} ${t||``}`}),V(`div`,{className:`pointer-events-none absolute right-1.5 top-1.5 z-10 flex h-[18px] w-[18px] items-center justify-center rounded-full ${n.badgeClass} shadow-md ring-2 ring-white/70`,title:n.label,children:[B(`span`,{className:`sr-only`,children:n.label}),e===`queued`&&B(tn,{className:`h-2.5 w-2.5 text-white`}),e===`pending`&&B(nn,{className:`h-2.5 w-2.5 animate-spin text-white`}),e===`done`&&B(rn,{className:`h-2.5 w-2.5 text-white`})]})]})}function cn(e,t){return`${e}::${t.type}::${t.id}`}function ln(e=[],t=[]){let n=[],r=new Set;for(let e=t.length-1;e>=0;--e){let i=t[e];i&&!r.has(i.id)&&(r.add(i.id),n.unshift(i))}return[...e.filter(e=>!r.has(e.id)),...n]}function un(e){return[...e].sort((e,t)=>{let n=(e.section||``).localeCompare(t.section||``);if(n!==0)return n;let r=(e.order||0)-(t.order||0);if(r!==0)return r;let i=e.label.localeCompare(t.label);return i===0?e.id.localeCompare(t.id):i})}function dn(e){return e instanceof Error?{message:e.message,stack:e.stack,detail:e}:{message:typeof e==`string`?e:`Background action failed`,detail:e}}function fn(e){return e&&typeof e==`object`&&typeof e.message==`string`?{message:e.message,stack:typeof e.stack==`string`?e.stack:void 0,detail:e.detail}:dn(e)}function pn(e,t){return!e.resourceTypes?.length||e.resourceTypes.includes(t.type)}function mn({definitions:e,instances:t,systemContext:n,targets:r,onSupportsError:i}){let a=un(e),o=[];for(let e of r){let r=[];for(let o of a){if(!pn(o,e))continue;let a=cn(o.id,e),s={...n,definition:o,target:e,instanceKey:a,instance:t[a]};try{if(o.supports&&!o.supports(s))continue}catch(e){i?.(o,e);continue}r.push({definition:o,target:e,instanceKey:a,instance:t[a],context:s})}r.length&&o.push({id:`${e.scope}:${e.type}:${e.id}`,label:e.label,target:e,actions:r})}return o}let hn=0;function gn(e){return hn+=1,`${e}-${Date.now()}-${hn}`}function _n(e,t,n,r=Date.now()){return{id:gn(`event`),createdAt:r,type:e,message:t,data:n}}function q(e,t,n,r,i=Date.now()){return{...e,events:[...e.events,_n(t,n,r,i)]}}function vn(e){return e.filter(e=>String(e.type)!==`progress`)}function yn(e){return{...e,logs:[...e.logs],events:vn(e.events),progress:e.progress?{...e.progress}:void 0}}function bn(e,t,n){if(!Tn(n.status))return e;let r=e[t]||[],i=yn(n),a=r.findIndex(e=>e.runId===n.runId),o=a>=0?r.map((e,t)=>t===a?i:e):[...r,i];return{...e,[t]:o}}function xn(e,t,n){let r=e.instances[t];if(!r)return{instances:e.instances,histories:e.histories};let i=n(r);return{instances:{...e.instances,[t]:i},histories:bn(e.histories,t,i)}}function Sn(e){return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}function Cn(e){let t=e,n=typeof t.current==`number`&&Number.isFinite(t.current)?t.current:void 0,r=typeof t.total==`number`&&Number.isFinite(t.total)?t.total:void 0;return{percent:Sn(typeof t.percent==`number`&&Number.isFinite(t.percent)?t.percent:typeof n==`number`&&typeof r==`number`&&r>0?n/r*100:0),current:n,total:r,label:t.label}}function wn(e){return e===`preparing`||e===`running`}function Tn(e){return e===`complete`||e===`error`||e===`cancelled`}function En(e){return e===`queued`||e===`running`||e===`complete`||e===`skipped`||e===`error`||e===`cancelled`}function Dn(e){return!e||e===`queued`||e===`running`}function On(e){return e===`complete`||e===`skipped`||e===`error`||e===`cancelled`}function kn(e){if(e!==void 0)try{return JSON.parse(JSON.stringify(e))}catch{return}}function An(e){return e&&{message:e.message,stack:e.stack,detail:kn(e.detail)}}function jn(e){return{...e,error:An(e.error)||null,result:kn(e.result),logs:e.logs.map(e=>({...e,data:kn(e.data)})),events:vn(e.events).map(e=>({...e,data:kn(e.data)})),progress:e.progress?{...e.progress}:void 0}}function Mn(e){return{...e,status:Rn(e.status),input:kn(e.input),result:kn(e.result),error:An(e.error)||null}}function Nn(e){return{version:1,data:kn(e.data),tasks:e.tasks.map(Mn)}}function Pn(e){return{version:1,savedAt:Date.now(),instances:Object.fromEntries(Object.entries(e.instances).map(([e,t])=>[e,jn(t)])),histories:Object.fromEntries(Object.entries(e.histories).map(([e,t])=>[e,t.map(jn)])),plans:Object.fromEntries(Object.entries(e.plans).map(([e,t])=>[e,Nn(t)]))}}function Fn(){return{version:1,savedAt:Date.now(),instances:{},histories:{},plans:{}}}function In(e,t){return{version:1,savedAt:t.savedAt,instances:{...e.instances,...t.instances},histories:{...e.histories,...t.histories},plans:{...e.plans,...t.plans}}}function Ln(e){return!Object.keys(e.instances).length&&!Object.keys(e.histories).length&&!Object.keys(e.plans).length}function Rn(e){return En(e)?e:`queued`}function zn(e,t){let n=Date.now(),r=typeof e.id==`string`&&e.id?e.id:`task-${t+1}`;return{...e,id:r,label:typeof e.label==`string`&&e.label?e.label:r,status:Rn(e.status),error:e.error?fn(e.error):null,createdAt:typeof e.createdAt==`number`?e.createdAt:n}}function Bn(e){return!e||e.version!==1||!Array.isArray(e.tasks)?null:{version:1,data:e.data,tasks:e.tasks.map(zn)}}function Vn(e){return{...e,tasks:e.tasks.map(e=>e.status===`running`?{...e,status:`queued`,statusText:`Queued after reload`,startedAt:void 0}:e)}}function Hn(e,t=Date.now()){return{...e,tasks:e.tasks.map(e=>Dn(e.status)?{...e,status:`cancelled`,statusText:`Cancelled`,error:null,completedAt:t}:e)}}function Un(e){return{...e,error:e.error?fn(e.error):null,logs:Array.isArray(e.logs)?e.logs:[],events:vn(Array.isArray(e.events)?e.events:[]),resultsAvailable:e.resultsAvailable===!0}}function Wn(e){return!e||e.version!==1?Fn():{version:1,savedAt:typeof e.savedAt==`number`?e.savedAt:Date.now(),instances:e.instances||{},histories:e.histories||{},plans:e.plans||{}}}function Gn(e,t,n){let r=e,i=t;if(wn(e.status)){if(e.cancelRequestedAt){let t=Date.now();i=i&&Hn(i,t),r=q({...e,status:`cancelled`,statusText:`Cancelled`,completedAt:t,cancelledAt:t},`status`,`Cancelled`,{status:`cancelled`},t)}else if(n.resumable&&i)i=Vn(i),r=q({...e,status:`running`,statusText:`Resuming`,completedAt:void 0,cancelledAt:void 0},`status`,`Resuming`,{status:`running`});else{let t=Date.now();r=q({...e,status:`cancelled`,statusText:`Interrupted by page reload`,completedAt:t,cancelledAt:t},`status`,`Interrupted by page reload`,{status:`cancelled`},t)}}return{instance:r,plan:i}}function Kn(e,t){let n=Wn(e),r=new Map(t.map(e=>[e.id,e])),i={},a={},o={},s=Fn();for(let[e,t]of Object.entries(n.histories)){let n=(Array.isArray(t)?t:[]).map(Un),i=n.filter(e=>r.has(e.actionId)),o=n.filter(e=>!r.has(e.actionId));i.length&&(a[e]=i),o.length&&(s.histories[e]=o)}for(let[e,t]of Object.entries(n.instances)){let c=Un(t),l=Bn(n.plans[e]),u=r.get(c.actionId);if(!u){s.instances[e]=jn(c),l&&(s.plans[e]=Nn(l));continue}let d=Gn(c,l,u);i[e]=d.instance,a=bn(a,e,d.instance),d.plan&&(o[e]=d.plan)}return{instances:i,histories:a,plans:o,deferred:s}}function qn(e,t){let n=e.tasks.length;if(!n)return;let r=e.tasks.filter(e=>On(e.status)).length;return Cn({current:r,total:n,label:t})}function Jn(e){return e&&typeof e==`object`&&`taskStatus`in e&&(e.taskStatus===`complete`||e.taskStatus===`skipped`)?{taskStatus:e.taskStatus,result:e.result,statusText:e.statusText}:{taskStatus:`complete`,result:e}}function Yn(e,t){for(let n of t.tasks)!n.target||n.target.type!==`Canvas`||(n.status===`running`?e.setStatus(n.target,`pending`):n.status===`queued`&&e.setStatus(n.target,`queued`))}function Xn(e,t,n){let{store:r,context:i}=e,{instanceKey:a}=i;function o(){return r.getState().plans[a]}function s(){return o()?.tasks||[]}function c(e=[`queued`,`running`]){let t=new Set(e);return s().filter(e=>t.has(Rn(e.status)))}function l(e,t,n=!1){r.getState().updateActionTask(a,e,t,n)}async function u(e,i={}){let u=c(i.statuses||[`queued`,`running`]),d=s().length,f=u.length,p=i.yieldEveryMs===!1?!1:i.yieldEveryMs??16,m=0;for(let[c,h]of u.entries()){if(t.aborted||Zn(m,p)&&(await Qn(),m=Date.now(),t.aborted))throw Error(`Background action cancelled.`);let u=s().find(e=>e.id===h.id)||h,g=s().findIndex(e=>e.id===u.id),_=i.progressLabel?.(u,g,d)||u.label||`Task ${g+1}/${d}`;u.target?.type===`Canvas`&&n.setStatus(u.target,`pending`),l(u.id,{status:`running`,statusText:_,error:null,startedAt:Date.now(),completedAt:void 0},!0),r.getState().setActionStatus(a,`running`,_),r.getState().setActionProgress(a,{current:s().filter(e=>On(e.status)).length,total:d,label:_});try{let r=await e(u,{index:g,total:d,pendingIndex:c,pendingTotal:f});if(t.aborted)throw Error(`Background action cancelled.`);let i=Jn(r);l(u.id,{status:i.taskStatus,statusText:i.statusText||(i.taskStatus===`skipped`?`Skipped`:`Complete`),result:i.result,error:null,completedAt:Date.now()},!0),u.target?.type===`Canvas`&&n.setStatus(u.target,`done`)}catch(e){if(t.aborted||rr(e))throw l(u.id,{status:`cancelled`,statusText:`Cancelled`,error:null,completedAt:Date.now()},!0),e;let n=dn(e);l(u.id,{status:`error`,statusText:n.message,error:n,completedAt:Date.now()},!0),r.getState().appendActionLog(a,`Task failed: ${u.label}`,`warn`,{taskId:u.id,error:n.message})}finally{let e=o();e&&r.getState().setActionProgress(a,{current:e.tasks.filter(e=>On(e.status)).length,total:d,label:_})}}return s()}return{getAll:s,getPending:()=>c(),update:l,runEach:u}}function Zn(e,t){return t!==!1&&(!e||Date.now()-e>=t)}function Qn(){return new Promise(e=>{setTimeout(e,0)})}function $n(e=[]){let t=null,n=null,r=null,i=Fn();return Oe((a,o)=>{function s(e,t){let n=ln([],t),r=Kn(i,n);return i=r.deferred,{definitions:n,instances:{...e.instances,...r.instances},histories:{...e.histories,...r.histories},plans:{...e.plans,...r.plans},controllers:Object.fromEntries(Object.entries(e.controllers).filter(([t,n])=>n&&e.instances[t]?.status&&wn(e.instances[t].status)))}}async function c(){if(r&&(clearTimeout(r),r=null),!t||!n||!o().hasHydrated)return;let e=In(i,Pn(o()));if(Ln(e)){await t.clear(n);return}await t.save(n,e)}function l(e=!1){if(!(!t||!n||!o().hasHydrated)){if(e){c();return}r&&clearTimeout(r),r=setTimeout(()=>{c()},300)}}return{definitions:ln([],e),instances:{},histories:{},plans:{},controllers:{},hasHydrated:!0,setDefinitions(e){a(t=>s(t,e)),l()},setPersistence(e,r){t=e,n=e&&r?r:null,a({hasHydrated:!t})},hydrate(e){let t=Kn(Wn(e),o().definitions);i=t.deferred,a({instances:t.instances,histories:t.histories,plans:t.plans,controllers:{},hasHydrated:!0}),l(!0)},persist(e=!1){l(e)},flushPersistence:c,registerAction(e){return a(t=>s(t,ln(t.definitions,[e]))),l(),()=>o().unregisterAction(e.id)},unregisterAction(e){a(t=>{let n={};for(let[r,i]of Object.entries(t.instances))i.actionId!==e&&(n[r]=i);let r={};for(let[n,i]of Object.entries(t.histories)){let t=i.filter(t=>t.actionId!==e);t.length&&(r[n]=t)}let i={...t.plans},a={...t.controllers};for(let[n,r]of Object.entries(t.instances))r.actionId===e&&(a[n]?.abort(),delete a[n],delete i[n]);return{definitions:t.definitions.filter(t=>t.id!==e),instances:n,histories:r,plans:i,controllers:a}}),l(!0)},resetAction(e){a(t=>{t.controllers[e]?.abort();let n={...t.instances},r={...t.histories},i={...t.plans},a={...t.controllers};return delete n[e],delete r[e],delete i[e],delete a[e],{instances:n,histories:r,plans:i,controllers:a}}),l(!0)},startAction(e,t,n,r){let i=Date.now();a(a=>{let o={...a.plans};return delete o[e],{instances:{...a.instances,[e]:{id:e,runId:gn(`run`),actionId:t.id,target:n,label:t.label,status:`preparing`,statusText:`Preparing`,error:null,result:void 0,resultsAvailable:!1,logs:[],events:[_n(`started`,`Preparing`,{status:`preparing`},i)],progress:void 0,startedAt:i,completedAt:void 0,cancelRequestedAt:void 0,cancelledAt:void 0}},plans:o,controllers:r?{...a.controllers,[e]:r}:a.controllers}}),l(!0)},resumeAction(e,t){let n=Date.now();a(r=>({...xn(r,e,e=>q({...e,status:`running`,statusText:`Resuming`,completedAt:void 0,cancelledAt:void 0},`status`,`Resuming`,{status:`running`},n)),controllers:{...r.controllers,[e]:t}})),l(!0)},cancelAction(e){let t=o().controllers[e],n=o().instances[e];if(!n||!wn(n.status))return;let r=Date.now();a(t=>{let n=xn(t,e,e=>q(q({...e,status:`cancelled`,statusText:`Cancelled`,completedAt:r,cancelledAt:r,cancelRequestedAt:e.cancelRequestedAt||r},`cancel-requested`,`Cancelling`,void 0,r),`status`,`Cancelled`,{status:`cancelled`},r)),i=t.plans[e];return{...n,plans:i?{...t.plans,[e]:Hn(i,r)}:t.plans,controllers:Object.fromEntries(Object.entries(t.controllers).filter(([t])=>t!==e))}}),l(!0),t?.abort()},setActionLabel(e,t){let n=Date.now();a(r=>({...xn(r,e,e=>q({...e,label:t},`label`,t,{label:t},n))})),l()},setActionStatus(e,t,n){let r=Date.now(),i=Tn(t)?r:void 0;a(a=>({...xn(a,e,e=>q({...e,status:t,statusText:n,completedAt:i,cancelledAt:t===`cancelled`?r:void 0},`status`,n||t,{status:t},r)),controllers:wn(t)?a.controllers:Object.fromEntries(Object.entries(a.controllers).filter(([t])=>t!==e))})),l(Tn(t))},setActionError(e,t,n){let r=Date.now(),i=dn(t);a(t=>({...xn(t,e,e=>q({...e,status:`error`,statusText:n,error:i,completedAt:r,cancelledAt:void 0},`error`,n||i.message,i,r)),controllers:Object.fromEntries(Object.entries(t.controllers).filter(([t])=>t!==e))})),l(!0)},appendActionLog(e,t,n=`info`,r){let i=Date.now(),o={id:gn(`log`),createdAt:i,level:n,message:t,data:r};a(a=>({...xn(a,e,e=>q({...e,logs:[...e.logs,o]},`log`,t,{level:n,data:r},i))})),l()},setActionProgress(e,t){let n=t?Cn(t):void 0;a(t=>({...xn(t,e,e=>({...e,progress:n}))}))},setResult(e,t){let n=Date.now();a(r=>({...xn(r,e,e=>q({...e,result:t},`result`,`Result recorded`,void 0,n))})),l(!0)},setResultsAvailable(e,t){let n=Date.now();a(r=>({...xn(r,e,e=>q({...e,resultsAvailable:t},`results-available`,t?`Results available`:`Results hidden`,{available:t},n))})),l(!0)},setActionPlan(e,t){let n=Bn(t);n&&(a(t=>({...xn(t,e,e=>({...e,progress:qn(n,`Queued`)})),plans:{...t.plans,[e]:n}})),l(!0))},updateActionTask(e,t,n,r=!1){a(r=>{let i=r.plans[e];if(!i)return r;let a=i.tasks.map(e=>e.id===t?zn({...e,...n,status:n.status?Rn(n.status):e.status,error:n.error?fn(n.error):n.error===null?null:e.error},0):e),o={...i,tasks:a};return{...xn(r,e,e=>({...e,progress:qn(o,n.statusText||n.label)})),plans:{...r.plans,[e]:o}}}),l(r)}}})}function er(e,t,n){let{store:r,context:i}=e,{instanceKey:a}=i,o=Xn(e,t,n);return{...i,canvasProgress:n,instance:r.getState().instances[a],plan:r.getState().plans[a],tasks:o,signal:t,prepareData:e.prepareData,setActionLabel(e){r.getState().setActionLabel(a,e)},setActionStatus(e,t){r.getState().setActionStatus(a,e,t)},setActionError(e,t){r.getState().setActionError(a,e,t)},appendActionLog(e,t,n){r.getState().appendActionLog(a,e,t,n)},setActionProgress(e){r.getState().setActionProgress(a,e)},setResult(e){r.getState().setResult(a,e)},setResultsAvailable(e){r.getState().setResultsAvailable(a,e)}}}function tr(e){return!!e&&typeof e==`object`&&e.version===1&&Array.isArray(e.tasks)}async function nr(e){let{store:t,context:n}=e,{definition:r,instanceKey:i,target:a}=n,o=t.getState().instances[i],s=t.getState().controllers[i];if((o?.status===`preparing`||o?.status===`running`)&&(!e.resume||s))return o;let c=new AbortController,l=c.signal,u=Zt(n.canvasProgress),d=()=>c.abort();e.signal&&(e.signal.aborted?c.abort():e.signal.addEventListener(`abort`,d,{once:!0})),e.resume&&o&&wn(o.status)?t.getState().resumeAction(i,c):t.getState().startAction(i,r,a,c);let f=()=>{let e=t.getState().instances[i];e&&!Tn(e.status)&&t.getState().setActionStatus(i,`cancelled`,`Cancelled`)};try{if(!e.resume&&r.prepare){let n=await r.prepare(er(e,l,u));if(l.aborted)return f(),t.getState().instances[i];if(n===!1)return t.getState().setActionStatus(i,`idle`),t.getState().instances[i];tr(n)&&t.getState().setActionPlan(i,n)}if(l.aborted)return f(),t.getState().instances[i];let n=t.getState().plans[i];n&&Yn(u,n),t.getState().setActionStatus(i,`running`,e.resume?`Resuming`:`Running`);let a=await r.run(er(e,l,u));if(l.aborted)return f(),t.getState().instances[i];let o=t.getState().instances[i];a!==void 0&&o&&!Tn(o.status)&&t.getState().setResult(i,a),o=t.getState().instances[i],o&&wn(o.status)&&((a!==void 0||o?.resultsAvailable)&&t.getState().setResultsAvailable(i,!0),t.getState().setActionStatus(i,`complete`,`Complete`))}catch(e){l.aborted||rr(e)?f():t.getState().setActionError(i,e,`Error`)}finally{u.clearTrackedStatuses(),e.signal?.removeEventListener(`abort`,d),await t.getState().flushPersistence()}return t.getState().instances[i]}function rr(e){return e instanceof Error&&(e.name===`AbortError`||e.message.toLowerCase().includes(`aborted`))}function ir(e){return JSON.stringify([e.appId,e.instanceId,e.rootResource.type,e.rootResource.id])}let ar;function or(){if(typeof window>`u`)return null;let e=Ae.createInstance({name:`manifest-editor-background-actions-v1`,storeName:`background-actions`});return{async load(t){return e.getItem(ir(t))},async save(t,n){await e.setItem(ir(t),n)},async clear(t){await e.removeItem(ir(t))}}}function sr(){return ar===void 0&&(ar=or()),ar}const cr=j(null);function lr({children:e,persistence:t,persistenceKey:n}){let r=Y(),i=xi(),a=I(()=>$n(),[]),o=r.layout.backgroundActions||[],s=I(()=>t===!1?null:t||sr(),[t]),c=I(()=>n||null,[n]);return P(()=>{a.getState().setDefinitions(o)},[a,o]),P(()=>{let e=c||{appId:i.appId,instanceId:i.instanceId,rootResource:{id:`global`,type:`Manifest`}},t=!1;return a.getState().setPersistence(s,e),s?(s.load(e).then(e=>{t||a.getState().hydrate(e)}).catch(e=>{console.warn(`[manifest-editor/background-actions] Failed to load persisted actions`,e),t||a.getState().hydrate(null)}),()=>{t=!0,a.getState().flushPersistence()}):(a.getState().hydrate(null),()=>void 0)},[i.appId,i.instanceId,s,c?.appId,c?.instanceId,c?.rootResource.id,c?.rootResource.type,a]),P(()=>{let e=()=>{a.getState().flushPersistence()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[a]),xe(cr.Provider,{value:a},e)}function ur(){let e=N(cr);if(!e)throw Error(`useBackgroundActionsStore must be used within a BackgroundActionsProvider`);return e}function J(e=e=>e){return ke(ur(),e)}function dr(e){return J(t=>t.instances[e])}function fr(e){return J(t=>t.histories[e]||[])}async function pr(e){let t;try{await fetch(e).then(e=>e.json().catch(e=>{console.error(`'${e}' happened!`)})).then(e=>{t={...e}})}catch(e){console.log(e)}return t}function mr(e,t,n){return`create_${e}_${t}_${qe(n)?.type||`unknown`}`}function hr(e,t,n=`text/json`){let r=e instanceof Blob?e:new Blob([e],{type:n}),i=document.createElement(`a`);i.download=t,i.href=window.URL.createObjectURL(r);let a=new MouseEvent(`click`,{view:window,bubbles:!0,cancelable:!0});i.dispatchEvent(a),i.remove()}async function gr(e){return navigator.clipboard.writeText(typeof e==`string`?e:JSON.stringify(e,null,2))}function _r(){return`${Math.random().toString(36).substr(2)}-${Date.now().toString(36)}`}function vr(e,t){let{default:n,config:r,preset:i,...a}=e,o={metadata:n,layout:{leftPanels:[],rightPanels:[],centerPanels:[],...a},config:r,preset:i},s=t?t(o):o;return{...s,preset:yr(void 0,s.preset)}}function yr(e,t){if(!e&&!t)return;let n=e?.templateFilter&&t?.templateFilter?n=>e.templateFilter(n)&&t.templateFilter(n):t?.templateFilter||e?.templateFilter,r=t?.templateStrategy===`replace`?t.templates||[]:[...e?.templates||[],...t?.templates||[]],i=e?.preview||t?.preview?{...e?.preview||{},...t?.preview||{},actions:[...e?.preview?.actions||[],...t?.preview?.actions||[]]}:void 0;return{...e||{},...t||{},templateFilter:n,templates:n?r.filter(n):r,preview:i}}function br(e,t,n){return{...e,metadata:t,config:Mt(e.config||{},n.config||{}),preset:yr(e.preset,n.preset),layout:{...e.layout,leftPanels:[...(e.layout.leftPanels||[]).filter(e=>!n?.leftPanelIds||n.leftPanelIds.includes(e.id)),...n?.leftPanels||[]],annotations:[...n?.annotations||[],...e.layout.annotations||[]],canvasEditors:[...n?.canvasEditors||[],...e.layout.canvasEditors||[]],creators:[...n?.creators||[],...e.layout.creators||[]],background:[...e.layout?.background||[],...n?.background||[]],backgroundActions:ln(e.layout?.backgroundActions||[],n?.backgroundActions||[]),editors:[...n?.editors||[],...e.layout.editors||[]],rightPanels:[...e.layout.rightPanels||[],...n?.rightPanels||[]],centerPanels:[...e.layout.centerPanels||[],...n?.centerPanels||[]],modals:[...e.layout.modals||[],...n?.modalPanels||[]]}}}const xr=[`leftPanels`,`centerPanels`,`rightPanels`,`modalPanels`,`annotations`,`canvasEditors`,`editors`,`creators`,`background`,`backgroundActions`],Sr={plugins:[],enabled:[],disabled:[],globalApps:{},apps:{}};function Cr(){return Sr}function wr(e=[]){return Array.from(new Set(e.filter(Boolean)))}function Tr(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Er(e={}){return{...e,enabled:wr(e.enabled||[]),disabled:wr(e.disabled||[]),settings:e.settings?{...e.settings}:void 0}}function Dr(e){let t={};for(let[n,r]of Object.entries(e?.apps||{}))t[n]=Er(r);return t}function Or(e={},t){return{...e,enabled:wr([...(e.enabled||[]).filter(e=>e!==t),t]),disabled:(e.disabled||[]).filter(e=>e!==t)}}function kr(e={},t){return{...e,enabled:(e.enabled||[]).filter(e=>e!==t),disabled:wr([...(e.disabled||[]).filter(e=>e!==t),t])}}function Ar(e={},t){return{...e,enabled:(e.enabled||[]).filter(e=>e!==t),disabled:(e.disabled||[]).filter(e=>e!==t)}}function jr(e={},t={}){let n=e.enabled||[],r=t.enabled||[],i=e.disabled||[],a=t.disabled||[];return n.length===r.length&&n.every((e,t)=>e===r[t])&&i.length===a.length&&i.every((e,t)=>e===a[t])&&JSON.stringify(e.settings||{})===JSON.stringify(t.settings||{})}function Mr(e,t){let{default:n,config:r,settings:i,...a}=e,o={metadata:n,extension:{...a,config:r},settings:i};return t?t(o):o}function Nr(e){return{metadata:e.default,extension:{},settings:e.settings,load:e.load,loadStatus:`idle`}}function Pr(e){return!!e&&`metadata`in e&&`extension`in e}function Fr(e){return!!e&&`load`in e&&`default`in e}function Ir(e){return Pr(e)?e:Fr(e)?Nr(e):Mr(e)}function Lr(e=[]){return e.map(Ir)}function Rr(e,t){let n=new Map(e.map(e=>[e.metadata.id,e]));return t.map(e=>{let t=n.get(e.metadata.id);return t?t.loadStatus===`loaded`&&e.load?{...t,metadata:e.metadata,load:e.load}:t.loadStatus===`loading`&&e.load?{...e,loadStatus:`loading`}:t.loadStatus===`error`&&e.load?{...e,loadStatus:`error`,loadError:t.loadError}:e:e})}function zr(e,t,n){let r=e.metadata.supports;if(!r)return!0;if(r.apps?.length){let e=new Set([n,t?.metadata.id].filter(Boolean));if(!r.apps.some(t=>e.has(t)))return!1}if(r.projectTypes?.length){let e=t?.metadata.projectType;if(!e||!r.projectTypes.includes(e))return!1}return!0}function Br(e,t,n){let r=e.metadata.supports;if(!r)return null;if(r.apps?.length){let e=new Set([n,t?.metadata.id].filter(Boolean));if(!r.apps.some(t=>e.has(t)))return`This plugin does not support the current app.`}if(r.projectTypes?.length){let e=t?.metadata.projectType;if(!e||!r.projectTypes.includes(e))return`This plugin does not support the current project type.`}return null}function Vr(e,t,n){let r=n?t.apps[n]:void 0,i=n?t.globalApps[n]:void 0,a=e.metadata.id;return r?.disabled?.includes(a)?!1:r?.enabled?.includes(a)?!0:i?.disabled?.includes(a)?!1:i?.enabled?.includes(a)?!0:t.disabled.includes(a)?!1:t.enabled.includes(a)?!0:e.metadata.defaultEnabled===!0}function Hr(e,t,n){let r=n?t.apps[n]:void 0,i=n?t.globalApps[n]:void 0,a=e.metadata.id;return r?.disabled?.includes(a)||r?.enabled?.includes(a)?`workspace`:i?.disabled?.includes(a)||i?.enabled?.includes(a)?`global`:t.disabled.includes(a)||t.enabled.includes(a)?`provider`:`default`}function Ur(e,t,n){let r=[],i=new Set,a=new Set,o=new Set(e.plugins.filter(r=>zr(r,t,n)&&Vr(r,e,n)).map(e=>e.metadata.id)),s=new Map(e.plugins.map(e=>[e.metadata.id,e])),c=new Set;function l(e){let u=e.metadata.id;if(i.has(u))return!0;if(a.has(u))return!1;if(c.has(u))return Qr(`Plugin "${u}" was not enabled because its dependency graph contains a cycle.`),a.add(u),!1;c.add(u);for(let r of e.metadata.dependencies||[]){let e=s.get(r);if(!e||!o.has(r))return Qr(`Plugin "${u}" was not enabled because dependency "${r}" is not enabled.`),c.delete(u),a.add(u),!1;if(!zr(e,t,n))return Qr(`Plugin "${u}" was not enabled because dependency "${r}" is not compatible.`),c.delete(u),a.add(u),!1;if(!l(e))return c.delete(u),a.add(u),!1}return c.delete(u),r.push(e),i.add(u),!0}for(let r of e.plugins)zr(r,t,n)&&Vr(r,e,n)&&l(r);return r}function Wr(e,t){let n=e?.settings?.[t];return Tr(n)?n:{}}function Gr(e={},t,n){return{...e,settings:{...e.settings||{},[t]:n}}}function Kr(e={},t){let n={...e.settings||{}};return delete n[t],{...e,settings:n}}function qr(e){return{...e?.settings?.defaults||{}}}function Jr(e,t,n){let r=e.plugins.find(e=>e.metadata.id===t),i=n?e.globalApps[n]:void 0,a=n?e.apps[n]:void 0;return{...qr(r),...Wr(i,t),...Wr(a,t)}}function Yr(e,t){return{getSettings(n){return Jr(e,n,t)}}}function Xr(e,t,n,r,i){let a=new Map(t.plugins.map(e=>[e.metadata.id,e])),o=[],s=[],c=new Set,l=e;function u(e){let t=e.metadata.id;if(!o.includes(t)){if(c.has(t)){s.push(`${t} has a circular dependency`);return}c.add(t);for(let t of e.metadata.dependencies||[]){let e=a.get(t);if(!e){s.push(`${t} is not available`);continue}if(!zr(e,r,i)){s.push(`${e.metadata.label} is not compatible`);continue}u(e)}c.delete(t),l=Or(l,t),o.push(t)}}return u(n),s.length?{config:e,enabledIds:[],blocked:s}:{config:l,enabledIds:o,blocked:s}}function Zr(e,t){return t===`modalPanels`?e.layout.modals||[]:e.layout[t]||[]}function Qr(e){globalThis.process?.env?.NODE_ENV!==`production`&&console.warn(`[manifest-editor/plugin] ${e}`)}function $r(e,t,n,r){if(!r?.length)return;let i=[];for(let a of r){if(n.has(a.id)){Qr(`Plugin "${e.metadata.id}" contribution "${a.id}" for "${t}" was skipped because that id already exists.`);continue}n.add(a.id),i.push(a)}return i.length?i:void 0}function ei(e,t){let n=t.extension,r={config:n.config,preset:n.preset,disableSideEffects:n.disableSideEffects};for(let i of xr){let a=$r(t,i,new Set(Zr(e,i).map(e=>e.id)),n[i]);a&&(r[i]=a)}return r}function ti(e,t,n){if(!t.length)return e;let r=e,i=new Set;for(let a of t){if(!zr(a,e,n))continue;let t=(a.metadata.dependencies||[]).filter(e=>!i.has(e));if(t.length){Qr(`Plugin "${a.metadata.id}" was not applied because dependencies are missing or later in the plugin order: ${t.join(`, `)}`);continue}let o=ei(r,a);r=br(r,r.metadata,o),i.add(a.metadata.id)}let a=new Set(e.layout.leftPanels.map(e=>e.id)),o=r.layout.leftPanels.filter(e=>e.divide),s=r.layout.leftPanels.filter(e=>!e.divide),c=!1,l=s.map(e=>!c&&!a.has(e.id)?(c=!0,{...e,separator:!0}):e);return{...r,config:Mt(e.config||{},...t.filter(e=>i.has(e.metadata.id)).map(e=>e.extension.config||{}),r.config||{}),layout:{...r.layout,leftPanels:[...l,...o],backgroundActions:ln([],r.layout.backgroundActions||[])}}}function ni({plugins:e=[],enabled:t=[],disabled:n=[],globalPluginConfig:r}={}){let i=(e=[])=>Array.from(new Set(e.filter(Boolean)));return Oe(a=>({plugins:e,enabled:i(t),disabled:i(n),globalApps:Dr(r),apps:{},setProviderState(e){a(t=>({...t,plugins:Rr(t.plugins,e.plugins||[]),enabled:i(e.enabled||[]),disabled:i(e.disabled||[]),globalApps:Dr(e.globalPluginConfig)}))},setPluginLoading(e){a(t=>({...t,plugins:t.plugins.map(t=>t.metadata.id===e?{...t,loadStatus:`loading`,loadError:void 0}:t)}))},setPluginLoaded(e,t){a(n=>({...n,plugins:n.plugins.map(n=>n.metadata.id===e?{...t,metadata:{...n.metadata,...t.metadata},settings:t.settings||n.settings,load:n.load,loadStatus:`loaded`,loadError:void 0}:n)}))},setPluginLoadError(e,t){a(n=>({...n,plugins:n.plugins.map(n=>n.metadata.id===e?{...n,loadStatus:`error`,loadError:t}:n)}))},setAppConfig(e,t){let n=Er(t);a(t=>jr(t.apps[e],n)?t:{...t,apps:{...t.apps,[e]:n}})},setGlobalConfig(e){a(t=>({...t,globalApps:Dr(e)}))},setGlobalAppConfig(e,t){let n=Er(t);a(t=>jr(t.globalApps[e],n)?t:{...t,globalApps:{...t.globalApps,[e]:n}})},enable(e,t,n=`workspace`){a(r=>({...r,plugins:r.plugins.map(e=>e.metadata.id===t&&e.loadStatus===`error`?{...e,loadStatus:`idle`,loadError:void 0}:e),...n===`global`?{globalApps:{...r.globalApps,[e]:Or(r.globalApps[e],t)}}:{apps:{...r.apps,[e]:Or(r.apps[e],t)}}}))},disable(e,t,n=`workspace`){a(r=>({...r,...n===`global`?{globalApps:{...r.globalApps,[e]:kr(r.globalApps[e],t)}}:{apps:{...r.apps,[e]:kr(r.apps[e],t)}}}))}}))}const ri=j(null),ii=j({});function ai({plugins:e,enabled:t,disabled:n,globalPluginConfig:r,saveGlobalPluginConfig:i,children:a}){let o=I(()=>Lr(e),[e]),s=I(()=>ni({plugins:o,enabled:t,disabled:n,globalPluginConfig:r}),[]);P(()=>{s.getState().setProviderState({plugins:o,enabled:t,disabled:n,globalPluginConfig:r})},[s,o,t,n,r]);let c=I(()=>({globalPluginConfig:r,saveGlobalPluginConfig:i}),[r,i]);return xe(ii.Provider,{value:c},xe(ri.Provider,{value:s},a))}function oi(){return N(ri)}function si(){let e=oi();if(!e)throw Error(`usePluginStoreApi must be used within <PluginProvider />`);return e}function ci(e){let t=oi();return t?ke(t,e):e(Cr())}function li(){return ci(e=>({plugins:e.plugins,enabled:e.enabled,disabled:e.disabled,globalApps:e.globalApps,apps:e.apps}))}function ui(e){let t=N(yi),n=N(vi),r=li(),i=e||t?.appId;return I(()=>Ur(r,n,i),[r,n,i])}function di(){let e=oi();return I(()=>e?{enable(t,n,r){e.getState().enable(t,n,r||`workspace`)},disable(t,n,r){e.getState().disable(t,n,r||`workspace`)},setAppConfig(t,n){e.getState().setAppConfig(t,n)},setGlobalAppConfig(t,n){e.getState().setGlobalAppConfig(t,n)}}:{enable(){},disable(){},setAppConfig(){},setGlobalAppConfig(){}},[e])}function fi(e){let t=N(yi),n=li(),r=e||t?.appId;return I(()=>Yr(n,r),[n,r])}function pi(e,t){let n=N(yi),r=li(),i=t||n?.appId;return I(()=>Jr(r,e,i),[r,e,i])}function mi(e,t){let n=N(yi),r=oi(),i=li(),a=K(),o=It(),{saveGlobalPluginConfig:s}=N(ii),c=t||n?.appId||``,l=i.plugins.find(t=>t.metadata.id===e)||null,u=c?i.globalApps[c]:void 0,d=c?i.apps[c]:void 0,f=I(()=>qr(l||void 0),[l]),p=I(()=>Wr(u,e),[u,e]),m=I(()=>Wr(d,e),[d,e]),h=I(()=>Jr(i,e,c),[i,e,c]),g=M(e=>{c&&(r?.getState().setAppConfig(c,e),o({plugins:{...a.plugins||{},apps:{...a.plugins?.apps||{},[c]:e}}}))},[a.plugins,c,o,r]),_=M(t=>{g(Gr(d||{},e,t))},[g,e,d]),v=M(()=>{g(Kr(d||{},e))},[g,e,d]),y=M(async e=>{if(!c||!s)return;let t=i.globalApps[c]||{},n={apps:{...i.globalApps,[c]:e}};r?.getState().setGlobalAppConfig(c,e);try{await s(n)}catch(e){throw r?.getState().setGlobalAppConfig(c,t),e}},[c,s,i.globalApps,r]),b=M(async t=>{await y(Gr(u||{},e,t))},[u,y,e]),x=M(async()=>{await y(Kr(u||{},e))},[u,y,e]);return{plugin:l,appId:c,defaults:f,global:p,workspace:m,effective:h,canSaveGlobal:!!s,setWorkspaceSettings:_,resetWorkspaceSettings:v,setGlobalSettings:b,resetGlobalSettings:x}}function hi(e,t){let n=li(),r=oi(),i=I(()=>Ur(n,e,t),[n,e,t]);return P(()=>{if(r)for(let e of i)!e.load||e.loadStatus===`loading`||e.loadStatus===`loaded`||e.loadStatus===`error`||(r.getState().setPluginLoading(e.metadata.id),e.load().then(t=>{r.getState().setPluginLoaded(e.metadata.id,Ir(t))}).catch(t=>{r.getState().setPluginLoadError(e.metadata.id,gi(t))}))},[r,i]),I(()=>ti(e,i.filter(e=>!e.load||e.loadStatus===`loaded`),t),[e,i,t])}function gi(e){return e instanceof Error?e.message:typeof e==`string`?e:`Plugin failed to load.`}function _i({config:e}){let t=N(yi),n=oi(),r=t?.appId,i=r?e?.plugins?.apps?.[r]:void 0;return P(()=>{!n||!r||n.getState().setAppConfig(r,i||{})},[n,r,i]),null}const vi=j(null),yi=j(null),bi=j({state:null,setState:()=>{}});function xi(){let e=N(yi);return G(e,`Hook useAppInstance must be used inside <AppProvider />`),e}function Y(){let e=N(vi);return G(e,`Hook useApp must be used inside <AppProvider />`),e}function Si(){return N(bi)}function Ci(e,t){return e.find(e=>e.id===t)||null}function wi(){let e=Y(),{state:t,setState:n}=Si(),r=e.preset?.templates||[],i=typeof t?.presetTemplateId==`string`?t.presetTemplateId:null;return{templates:r,selectedTemplateId:i,selectedTemplate:I(()=>Ci(r,i),[i,r]),setSelectedTemplateId:M(e=>n({presetTemplateId:e}),[n])}}function Ti(e){let[t,n,r]=me(`app-state/${e.appId}/${e.instanceId}`,e.initialState||{}),i=M(e=>{let t=r.current?JSON.parse(r.current||`{}`):{},i=(typeof e==`function`?e(t):e)||{};n({...t,...i})},[]);P(()=>{e.args&&i(e.args)},[e.appId]);let a=I(()=>({state:t||{},setState:i}),[i,t]);return B(bi.Provider,{value:a,children:e.children})}function Ei({instanceId:e,appId:t,args:n,definition:r,children:i,initialState:a}){let o=I(()=>({instanceId:e,appId:t,args:n}),[e,t,n]),s=I(()=>a||{},[e]),c=hi(r,t);return B(Lt,{config:c.config||{},children:B(vi.Provider,{value:c,children:B(yi.Provider,{value:o,children:B(Ti,{instanceId:o.instanceId,appId:o.appId,args:o.args,initialState:s,children:i})})})})}const Di=j(null);function Oi(){let e=N(Di);return G(e,`Hook useApps must be used inside <MultiAppProvider />`),e}function ki(e,t=!1){let[n,r]=ge(`SelectedApplication`,e||{id:`splash`},!t);return[n,r]}function Ai({apps:e,initialApp:t,saveCurrentApp:n=!0,instanceId:r,children:i,config:a={}}){let{defaultApp:o=`splash`,collectionApp:s=`collection-editor`,manifestApp:c=`manifest-editor`}=a,[l,u]=ki(t,n),d=e=>{e===`Manifest`&&u({id:c}),e===`Collection`&&u({id:s})},f=I(()=>({currentApp:l||{id:o},initialApp:t||{id:o},apps:e,changeApp:u,changeProjectType:d}),[t,e,l]),p=e[f.currentApp.id];return!l||!p?null:B(Ei,{appId:l.id,definition:p,instanceId:l.id+r,args:l.args,children:B(Di.Provider,{value:f,children:i})})}const ji=U.div`
2
2
  display: flex;
3
3
  align-items: center;
4
4
  height: 3em;
5
5
  padding: 0.5em;
6
- `,Ni=U.div`
6
+ `,Mi=U.div`
7
7
  display: flex;
8
8
  padding: 0.25em;
9
9
  flex-direction: column;
@@ -28,7 +28,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
28
28
  }
29
29
  `,U.div`
30
30
  flex: 1;
31
- `;const Pi=U.div`
31
+ `;const Ni=U.div`
32
32
  color: #6e6e6e;
33
33
  display: flex;
34
34
  align-items: center;
@@ -60,7 +60,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
60
60
  color: #666666;
61
61
  padding: 0.35em 0.7em;
62
62
  letter-spacing: -0.42px;
63
- `;const Fi=({height:e=16})=>V(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:e,viewBox:`0 0 24 24`,width:`24px`,fill:`currentColor`,children:[B(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),B(`path`,{d:`M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z`})]}),Ii=({rotate:e=0,...t})=>B(`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:B(`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`})});var Li=wt(((e,t)=>{t.exports={..._e}})),Ri=Et(wt((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Li();function n(e,n){let[r,i]=(0,t.useState)(!1),a=(0,t.useRef)(null),o=(0,t.useRef)(!0),s=(0,t.useRef)(!1),c=(0,t.useRef)(null),l=(0,t.useMemo)(()=>Array.from({length:e},()=>(0,t.createRef)()),[e]),u=e=>e.key!==void 0,d=e=>{var t;a.current=e,(t=l[e].current)==null||t.focus()};(0,t.useEffect)(()=>{if(o.current){o.current=!1;return}r&&(!s.current||n?.focusFirstItemOnClick)?d(0):r||(s.current=!1)},[r]),(0,t.useEffect)(()=>{if(!r)return;let e={removed:!1},t=e=>{setTimeout(()=>{e.target instanceof Element&&(e.target.closest(`[role="menu"]`)instanceof Element||i(!1))},10)};return setTimeout(()=>{e.removed||document.addEventListener(`click`,t)},1),()=>{e.removed=!0,document.removeEventListener(`click`,t)}},[r]),(0,t.useEffect)(()=>{let e=e=>{r&&(e.key===`ArrowDown`||e.key===`ArrowUp`)&&e.preventDefault()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r]);let f=e=>{if(u(e)){let{key:t}=e;if(![`Enter`,` `,`Tab`,`ArrowDown`,`Escape`].includes(t))return;(t===`Tab`||t===`ArrowDown`)&&s.current&&r&&(e.preventDefault(),d(0)),(t===`Enter`||t===` `)&&(e.preventDefault(),i(!0)),t===`Escape`&&(e.preventDefault(),i(!1))}else n?.focusFirstItemOnClick||(s.current=!r),i(!r)},p=e=>{var t;let{key:n}=e;if([`Tab`,`Shift`,`Enter`,`Escape`,`ArrowUp`,`ArrowDown`,` `].includes(n)){let r=a.current;if(n===`Escape`){i(!1),(t=c.current)==null||t.focus();return}if(n===`Tab`){i(!1);return}if(n===`Enter`||n===` `){e.currentTarget.href||e.currentTarget.click(),i(!1);return}r!==null&&(n===`ArrowUp`?--r:n===`ArrowDown`&&(r+=1),r>l.length-1?r=0:r<0&&(r=l.length-1)),r!==null&&d(r);return}if(/[a-zA-Z0-9./<>?;:"'`!@#$%^&*()\\[\]{}_+=|\\-~,]/.test(n)){let e=l.findIndex(e=>(e.current?.innerText)?.toLowerCase().startsWith(n.toLowerCase())||(e.current?.textContent)?.toLowerCase().startsWith(n.toLowerCase())||(e.current?.getAttribute(`aria-label`))?.toLowerCase().startsWith(n.toLowerCase()));e!==-1&&d(e)}};return{buttonProps:{onKeyDown:f,onClick:f,tabIndex:0,ref:c,role:`button`,"aria-haspopup":!0,"aria-expanded":r},itemProps:Array.from({length:e},(e,t)=>({onKeyDown:p,tabIndex:-1,role:`menuitem`,ref:l[t]})),isOpen:r,setIsOpen:i,moveFocus:d}}e.default=n}))(),1);const zi=typeof Ri.default==`object`&&Ri.default!==null&&`default`in Ri.default?Ri.default.default:Ri.default,Bi=j(null),Vi=j(null);function Hi(){let e=N(Vi),t=N(Bi),n=e||t?.id;return G(n,`useResourceInstance can only be called from inside <ResourceProvider />`),n}function Y(){let e=N(Bi);return G(e,`useResource can only be called from inside <ResourceProvider />`),e}function Ui({id:e,children:t}){return e?B(Vi.Provider,{value:e,children:t}):t}function Wi({resource:e,children:t}){let n=He(),r=t;return e&&e.type===`Manifest`&&(r=B(ze,{vault:n||void 0,children:B(Ie,{manifest:e.id||``,children:t})})),e&&e.type===`Collection`&&(r=B(ze,{vault:n||void 0,children:B(Pe,{collection:e.id||``,children:t})})),B(Bi.Provider,{value:e,children:r})}function Gi(e){"@babel/helpers - typeof";return Gi=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Gi(e)}function Ki(e,t){if(Gi(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Gi(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function qi(e){var t=Ki(e,`string`);return Gi(t)==`symbol`?t:t+``}function X(e,t,n){return(t=qi(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ji=class{constructor({id:e,config:t,label:n}){X(this,`id`,void 0),X(this,`label`,void 0),X(this,`type`,`external-manifest-preview`),X(this,`focusable`,!0),X(this,`serviceUrl`,void 0),X(this,`windows`,{}),this.id=e,this.label=n,this.serviceUrl=t.url}isPreviewValid(e){let t=this.windows[e];return!!(t&&t.window&&!t.window.closed)}getRequires(){return[`readOnlyManifest`]}getProvides(){return[]}async createPreview(e,t,n,r){let i=`${this.serviceUrl}`.replace(/\{manifestId}/,r.readOnlyManifest).replace(/\{time}/,`${Date.now()}`),a=window.open(i,this.id);return this.windows[e]={location:i,window:a},{id:this.id,type:`external-manifest-preview`,data:{url:i}}}async focus(e){let t=this.windows[e];t&&t.window&&t.window.focus()}async updatePreview(e,t,n,r){let i=this.windows[e];if(i)try{i.window?.close()}catch{}return this.createPreview(e,t,n,r)}async deletePreview(e){let t=this.windows[e];t&&t.window&&(t.window.close(),delete this.windows[e])}},Yi=class{constructor({id:e,config:t,label:n}){X(this,`id`,void 0),X(this,`label`,void 0),X(this,`type`,`iiif-preview-service`),X(this,`focusable`,!1),X(this,`serviceUrl`,void 0),X(this,`cache`,{}),this.id=e,this.label=n,this.serviceUrl=t.url}getRequires(){return[]}getProvides(){return[`readOnlyManifest`]}async isPreviewValid(e,t){if(this.cache[e])return!0;if(!t||!t.data||!t.data.readOnlyManifest)return!1;let n=t.data.readOnlyManifest;try{return(await fetch(n,{cache:`no-cache`})).ok}catch{return!1}}async createPreview(e,t,n){let r=n.toPresentation3(t),i=await fetch(this.serviceUrl,{method:`POST`,headers:{"Content-Type":`application/json`,Origin:`*`},body:JSON.stringify(r)});G(i.ok,`Unknown error creating preview`);let a=await i.json();return G(a.location,`Missing IIIF location while creating preview`),this.cache[e]={...a,time:Date.now()},{id:this.id,type:`external-manifest-preview`,data:{readOnlyManifest:`${a.location}/${Date.now()}`}}}async focus(){}async updatePreview(e,t,n){let r=this.cache[e];if(!r||Date.now()>r.expirationTtl+r.time||!r.updateLocation)return this.createPreview(e,t,n);let i=r.updateLocation,a=n.toPresentation3(t),o=await fetch(i,{method:`PUT`,headers:{"Content-Type":`application/json`,Origin:`*`},body:JSON.stringify(a)});G(o.ok,`Unknown error updating preview`);let s=await o.json();G(s.location),s.updateLocation&&(r.updateLocation=s.updateLocation);let c=`${s.location}/${Date.now()}`;return await fetch(c,{cache:`no-cache`}),{id:this.id,type:`external-manifest-preview`,data:{readOnlyManifest:`${s.location}/${Date.now()}`}}}async deletePreview(e){let t=this.cache[e];if(t&&t.deleteLocation)try{await fetch(t.deleteLocation,{method:`DELETE`,headers:{"Content-Type":`application/json`,Origin:`*`}})}catch{}}};function Xi(e,t,n,r,i){let a=Y(),o=Hi(),s=H(),c=I(()=>({setPreview:e=>{e&&i(t=>[...t.filter(t=>t.id!==e.id),e])},removePreview:e=>{i(t=>t.filter(t=>t.id!==e))}}),[i,o]),[l,u]=I(()=>{let e={},t={};for(let r of n){e[r.id]=r;let n=r.getProvides();if(n.length)for(let e of n)t[e]||(t[e]=r.id)}return[e,t]},[n]);async function d(){let n=e.selected,i=r.find(e=>e.id===n);if(r&&r.length&&i){let e=l[i.id].getRequires(),n={};for(let i of r){let r=l[i.id];if(r){let i=r.getProvides();for(let l of i)if(e.indexOf(l)!==-1){let e=await r.updatePreview(o,a,s,n);e&&(c.setPreview(e),t({type:`activatePreview`,payload:e.id}),Object.assign(n,e.data||{}))}}}let u=l[i.id];if(u){let e=await u.updatePreview(o,a,s,n);e?c.setPreview(e):(c.removePreview(i.id),await u.deletePreview(o))}}}async function f(e){l[e]&&o&&(t({type:`selectPreview`,payload:e}),await g(e))}async function p(){let e=u.readOnlyManifest,t=e?l[e]:null;if(t&&o){let e=r.find(e=>e.type===`iiif-preview-service`);if(!e||!await t.isPreviewValid(o,e)){let e=await t.createPreview(o,a,s,{});if(e)return e.data.readOnlyManifest}}return null}function m(e){let n=l[e];n&&o&&(c.removePreview(e),n.deletePreview(o).then(()=>{t({type:`deletePreview`,payload:e})}))}async function h(e){let n=l[e];l[e]&&o&&n&&(await n.focus(o),t({type:`focusPreview`,payload:e}))}async function g(n){let i=l[n];if(i&&o){let d=r.find(e=>e.id===n);if(!d||!i.isPreviewValid(o,d)){let n={},d=i.getRequires();for(let i of d){let d=u[i],f=d?l[d]:null;G(f,`Missing handler for Preview requirement "${i}"`),r.find(e=>e.id===d),e.active.find(e=>e===d);{let e=await f.createPreview(o,a,s,n);Object.assign(n,e?.data||{}),c.setPreview(e),t({type:`activatePreview`,payload:e.id})}}let f=await i.createPreview(o,a,s,n);f&&(c.setPreview(f),t({type:`activatePreview`,payload:f.id}))}}}return I(()=>({selectPreview:f,deletePreview:m,focusPreview:h,activatePreview:g,updatePreviews:d,getPreviewLink:p}),[l,o,s,e.selected,e.active,r])}function Zi(e){return I(()=>{let t=[];for(let n of e)switch(n.type){case`iiif-preview-service`:t.push(new Yi(n));break;case`external-manifest-preview`:t.push(new Ji(n))}return t},[])}const Qi=Xe(function(e,t){switch(t.type){case`focusPreview`:break;case`deletePreview`:e.selected===t.payload&&(e.selected=null),e.active=e.active.filter(e=>e!==t.payload);break;case`activatePreview`:e.active.indexOf(t.payload)===-1&&e.active.push(t.payload);break;case`selectPreview`:e.selected=t.payload,e.active.indexOf(t.payload)===-1&&e.active.push(t.payload)}});function $i(){return{active:[],selected:null}}const ea=j(null),ta=j([]),na=we(function({children:e,configs:t=[]}){let n=Hi(),r=Zi(t),[i,a]=me(`preview-${n}`,[]),[o,s]=Ee(Qi,void 0,$i),c=Xi(o,s,r,i,a),l=I(()=>({configs:t,actions:c,handlers:r,...o}),[c,t,r,o]);return P(()=>{for(let e of i)if(!o.active.includes(e.id)){let t=r.find(t=>t.id===e.id);t&&Promise.resolve(t.isPreviewValid(n,e)).then(t=>{t?s({type:`activatePreview`,payload:e.id}):a(t=>t.filter(t=>t.id!==e.id))})}},[n]),B(ta.Provider,{value:i,children:B(ea.Provider,{value:l,children:e})})});function ra(){return N(ta)}function ia(){let e=N(ea);return G(e,`usePreviewContext() can only be called from inside <PreviewProvider />`),e}const aa=U.button`
63
+ `;const Pi=({height:e=16})=>V(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:e,viewBox:`0 0 24 24`,width:`24px`,fill:`currentColor`,children:[B(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),B(`path`,{d:`M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z`})]}),Fi=({rotate:e=0,...t})=>B(`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:B(`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`})});var Ii=wt(((e,t)=>{t.exports={..._e}})),Li=Et(wt((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Ii();function n(e,n){let[r,i]=(0,t.useState)(!1),a=(0,t.useRef)(null),o=(0,t.useRef)(!0),s=(0,t.useRef)(!1),c=(0,t.useRef)(null),l=(0,t.useMemo)(()=>Array.from({length:e},()=>(0,t.createRef)()),[e]),u=e=>e.key!==void 0,d=e=>{var t;a.current=e,(t=l[e].current)==null||t.focus()};(0,t.useEffect)(()=>{if(o.current){o.current=!1;return}r&&(!s.current||n?.focusFirstItemOnClick)?d(0):r||(s.current=!1)},[r]),(0,t.useEffect)(()=>{if(!r)return;let e={removed:!1},t=e=>{setTimeout(()=>{e.target instanceof Element&&(e.target.closest(`[role="menu"]`)instanceof Element||i(!1))},10)};return setTimeout(()=>{e.removed||document.addEventListener(`click`,t)},1),()=>{e.removed=!0,document.removeEventListener(`click`,t)}},[r]),(0,t.useEffect)(()=>{let e=e=>{r&&(e.key===`ArrowDown`||e.key===`ArrowUp`)&&e.preventDefault()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r]);let f=e=>{if(u(e)){let{key:t}=e;if(![`Enter`,` `,`Tab`,`ArrowDown`,`Escape`].includes(t))return;(t===`Tab`||t===`ArrowDown`)&&s.current&&r&&(e.preventDefault(),d(0)),(t===`Enter`||t===` `)&&(e.preventDefault(),i(!0)),t===`Escape`&&(e.preventDefault(),i(!1))}else n?.focusFirstItemOnClick||(s.current=!r),i(!r)},p=e=>{var t;let{key:n}=e;if([`Tab`,`Shift`,`Enter`,`Escape`,`ArrowUp`,`ArrowDown`,` `].includes(n)){let r=a.current;if(n===`Escape`){i(!1),(t=c.current)==null||t.focus();return}if(n===`Tab`){i(!1);return}if(n===`Enter`||n===` `){e.currentTarget.href||e.currentTarget.click(),i(!1);return}r!==null&&(n===`ArrowUp`?--r:n===`ArrowDown`&&(r+=1),r>l.length-1?r=0:r<0&&(r=l.length-1)),r!==null&&d(r);return}if(/[a-zA-Z0-9./<>?;:"'`!@#$%^&*()\\[\]{}_+=|\\-~,]/.test(n)){let e=l.findIndex(e=>(e.current?.innerText)?.toLowerCase().startsWith(n.toLowerCase())||(e.current?.textContent)?.toLowerCase().startsWith(n.toLowerCase())||(e.current?.getAttribute(`aria-label`))?.toLowerCase().startsWith(n.toLowerCase()));e!==-1&&d(e)}};return{buttonProps:{onKeyDown:f,onClick:f,tabIndex:0,ref:c,role:`button`,"aria-haspopup":!0,"aria-expanded":r},itemProps:Array.from({length:e},(e,t)=>({onKeyDown:p,tabIndex:-1,role:`menuitem`,ref:l[t]})),isOpen:r,setIsOpen:i,moveFocus:d}}e.default=n}))(),1);const Ri=typeof Li.default==`object`&&Li.default!==null&&`default`in Li.default?Li.default.default:Li.default,zi=j(null),Bi=j(null);function Vi(){let e=N(Bi),t=N(zi),n=e||t?.id;return G(n,`useResourceInstance can only be called from inside <ResourceProvider />`),n}function Hi(){let e=N(zi);return G(e,`useResource can only be called from inside <ResourceProvider />`),e}function Ui({id:e,children:t}){return e?B(Bi.Provider,{value:e,children:t}):t}function Wi({resource:e,children:t}){let n=He(),r=t;return e&&e.type===`Manifest`&&(r=B(ze,{vault:n||void 0,children:B(Ie,{manifest:e.id||``,children:t})})),e&&e.type===`Collection`&&(r=B(ze,{vault:n||void 0,children:B(Pe,{collection:e.id||``,children:t})})),B(zi.Provider,{value:e,children:r})}function Gi(e){"@babel/helpers - typeof";return Gi=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Gi(e)}function Ki(e,t){if(Gi(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Gi(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function qi(e){var t=Ki(e,`string`);return Gi(t)==`symbol`?t:t+``}function X(e,t,n){return(t=qi(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ji=class{constructor({id:e,config:t,label:n}){X(this,`id`,void 0),X(this,`label`,void 0),X(this,`type`,`external-manifest-preview`),X(this,`focusable`,!0),X(this,`serviceUrl`,void 0),X(this,`windows`,{}),this.id=e,this.label=n,this.serviceUrl=t.url}isPreviewValid(e){let t=this.windows[e];return!!(t&&t.window&&!t.window.closed)}getRequires(){return[`readOnlyManifest`]}getProvides(){return[]}async createPreview(e,t,n,r){let i=`${this.serviceUrl}`.replace(/\{manifestId}/,r.readOnlyManifest).replace(/\{time}/,`${Date.now()}`),a=window.open(i,this.id);return this.windows[e]={location:i,window:a},{id:this.id,type:`external-manifest-preview`,data:{url:i}}}async focus(e){let t=this.windows[e];t&&t.window&&t.window.focus()}async updatePreview(e,t,n,r){let i=this.windows[e];if(i)try{i.window?.close()}catch{}return this.createPreview(e,t,n,r)}async deletePreview(e){let t=this.windows[e];t&&t.window&&(t.window.close(),delete this.windows[e])}},Yi=class{constructor({id:e,config:t,label:n}){X(this,`id`,void 0),X(this,`label`,void 0),X(this,`type`,`iiif-preview-service`),X(this,`focusable`,!1),X(this,`serviceUrl`,void 0),X(this,`cache`,{}),this.id=e,this.label=n,this.serviceUrl=t.url}getRequires(){return[]}getProvides(){return[`readOnlyManifest`]}async isPreviewValid(e,t){if(this.cache[e])return!0;if(!t||!t.data||!t.data.readOnlyManifest)return!1;let n=t.data.readOnlyManifest;try{return(await fetch(n,{cache:`no-cache`})).ok}catch{return!1}}async createPreview(e,t,n){let r=n.toPresentation3(t),i=await fetch(this.serviceUrl,{method:`POST`,headers:{"Content-Type":`application/json`,Origin:`*`},body:JSON.stringify(r)});G(i.ok,`Unknown error creating preview`);let a=await i.json();return G(a.location,`Missing IIIF location while creating preview`),this.cache[e]={...a,time:Date.now()},{id:this.id,type:`external-manifest-preview`,data:{readOnlyManifest:`${a.location}/${Date.now()}`}}}async focus(){}async updatePreview(e,t,n){let r=this.cache[e];if(!r||Date.now()>r.expirationTtl+r.time||!r.updateLocation)return this.createPreview(e,t,n);let i=r.updateLocation,a=n.toPresentation3(t),o=await fetch(i,{method:`PUT`,headers:{"Content-Type":`application/json`,Origin:`*`},body:JSON.stringify(a)});G(o.ok,`Unknown error updating preview`);let s=await o.json();G(s.location),s.updateLocation&&(r.updateLocation=s.updateLocation);let c=`${s.location}/${Date.now()}`;return await fetch(c,{cache:`no-cache`}),{id:this.id,type:`external-manifest-preview`,data:{readOnlyManifest:`${s.location}/${Date.now()}`}}}async deletePreview(e){let t=this.cache[e];if(t&&t.deleteLocation)try{await fetch(t.deleteLocation,{method:`DELETE`,headers:{"Content-Type":`application/json`,Origin:`*`}})}catch{}}};function Xi(e,t,n,r,i){let a=Hi(),o=Vi(),s=H(),c=I(()=>({setPreview:e=>{e&&i(t=>[...t.filter(t=>t.id!==e.id),e])},removePreview:e=>{i(t=>t.filter(t=>t.id!==e))}}),[i,o]),[l,u]=I(()=>{let e={},t={};for(let r of n){e[r.id]=r;let n=r.getProvides();if(n.length)for(let e of n)t[e]||(t[e]=r.id)}return[e,t]},[n]);async function d(){let n=e.selected,i=r.find(e=>e.id===n);if(r&&r.length&&i){let e=l[i.id].getRequires(),n={};for(let i of r){let r=l[i.id];if(r){let i=r.getProvides();for(let l of i)if(e.indexOf(l)!==-1){let e=await r.updatePreview(o,a,s,n);e&&(c.setPreview(e),t({type:`activatePreview`,payload:e.id}),Object.assign(n,e.data||{}))}}}let u=l[i.id];if(u){let e=await u.updatePreview(o,a,s,n);e?c.setPreview(e):(c.removePreview(i.id),await u.deletePreview(o))}}}async function f(e){l[e]&&o&&(t({type:`selectPreview`,payload:e}),await g(e))}async function p(){let e=u.readOnlyManifest,t=e?l[e]:null;if(t&&o){let e=r.find(e=>e.type===`iiif-preview-service`);if(!e||!await t.isPreviewValid(o,e)){let e=await t.createPreview(o,a,s,{});if(e)return e.data.readOnlyManifest}}return null}function m(e){let n=l[e];n&&o&&(c.removePreview(e),n.deletePreview(o).then(()=>{t({type:`deletePreview`,payload:e})}))}async function h(e){let n=l[e];l[e]&&o&&n&&(await n.focus(o),t({type:`focusPreview`,payload:e}))}async function g(n){let i=l[n];if(i&&o){let d=r.find(e=>e.id===n);if(!d||!i.isPreviewValid(o,d)){let n={},d=i.getRequires();for(let i of d){let d=u[i],f=d?l[d]:null;G(f,`Missing handler for Preview requirement "${i}"`),r.find(e=>e.id===d),e.active.find(e=>e===d);{let e=await f.createPreview(o,a,s,n);Object.assign(n,e?.data||{}),c.setPreview(e),t({type:`activatePreview`,payload:e.id})}}let f=await i.createPreview(o,a,s,n);f&&(c.setPreview(f),t({type:`activatePreview`,payload:f.id}))}}}return I(()=>({selectPreview:f,deletePreview:m,focusPreview:h,activatePreview:g,updatePreviews:d,getPreviewLink:p}),[l,o,s,e.selected,e.active,r])}function Zi(e){return I(()=>{let t=[];for(let n of e)switch(n.type){case`iiif-preview-service`:t.push(new Yi(n));break;case`external-manifest-preview`:t.push(new Ji(n))}return t},[])}const Qi=Xe(function(e,t){switch(t.type){case`focusPreview`:break;case`deletePreview`:e.selected===t.payload&&(e.selected=null),e.active=e.active.filter(e=>e!==t.payload);break;case`activatePreview`:e.active.indexOf(t.payload)===-1&&e.active.push(t.payload);break;case`selectPreview`:e.selected=t.payload,e.active.indexOf(t.payload)===-1&&e.active.push(t.payload)}});function $i(){return{active:[],selected:null}}const ea=j(null),ta=j([]),na=we(function({children:e,configs:t=[]}){let n=Vi(),r=Zi(t),[i,a]=me(`preview-${n}`,[]),[o,s]=Ee(Qi,void 0,$i),c=Xi(o,s,r,i,a),l=I(()=>({configs:t,actions:c,handlers:r,...o}),[c,t,r,o]);return P(()=>{for(let e of i)if(!o.active.includes(e.id)){let t=r.find(t=>t.id===e.id);t&&Promise.resolve(t.isPreviewValid(n,e)).then(t=>{t?s({type:`activatePreview`,payload:e.id}):a(t=>t.filter(t=>t.id!==e.id))})}},[n]),B(ta.Provider,{value:i,children:B(ea.Provider,{value:l,children:e})})});function ra(){return N(ta)}function ia(){let e=N(ea);return G(e,`usePreviewContext() can only be called from inside <PreviewProvider />`),e}const aa=U.button`
64
64
  border: none;
65
65
  outline: none;
66
66
  background-color: transparent;
@@ -239,7 +239,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
239
239
  border-radius: 5px;
240
240
  user-select: none;
241
241
  cursor: not-allowed;
242
- `;function va(e,t){return e>0||!!t?.mainAction||!!t?.actions?.length}function ya({downloadEnabled:e,fileName:t,preview:n}){let{active:r,configs:i,actions:a,selected:o}=ia(),s=H(),c=It(),l=Y(),u=i.filter(e=>e.type===`external-manifest-preview`),d=n?.actions||[],{isOpen:f,buttonProps:p,itemProps:m}=zi(u.length+d.length);return va(u.length,n)?V(z,{children:[e?B(`div`,{className:`mr-4`,children:B(y,{fileName:t||`manifest.json`,label:`Download manifest`,getData:()=>c.export&&c.export.version===2?JSON.stringify(s.toPresentation2(l),null,2):JSON.stringify(s.toPresentation3(l),null,2)})}):null,V(ca,{children:[B(la,{"data-preview-action":n?.mainAction?.id,disabled:n?.mainAction?.disabled||!n?.mainAction&&u.length===0,onClick:()=>{if(n?.mainAction){n.mainAction.onClick();return}if(u.length){if(!o){let e=c.defaultPreview;if(e){let t=i.find(t=>t.id===e);if(t){a.selectPreview(t.id);return}}a.selectPreview(i[0].id)}a.updatePreviews()}},children:n?.mainAction?.label||`Preview`}),u.length+d.length>0?B(ua,{$open:f,...p,"aria-label":`Choose preview`,children:B(Ii,{"aria-hidden":!0})}):null,V(da,{$open:f,role:`menu`,children:[u.map((e,t)=>{let n=r.indexOf(e.id)===-1;return V(fa,{...m[t],children:[B(ma,{$status:n?`available`:e.id===o?`active`:`configured`}),B(ha,{onClick:()=>{a.selectPreview(e.id)},children:e.label}),n?null:B(ga,{onClick:()=>a.deletePreview(e.id),children:B(Fi,{})})]},e.id)}),d.map((e,t)=>V(fa,{...m[u.length+t],"aria-disabled":e.disabled||void 0,onClick:()=>{e.disabled||e.onClick()},children:[B(ma,{$status:e.status||`available`}),B(ha,{children:e.label})]},e.id))]})]})]}):B(_a,{children:`Preview not available`})}const ba=j({resource:null});function xa(){return N(ba)}function Sa(){let e=H(),{resource:t}=xa();G(t,`Nothing selected`);let{id:n,type:r}=t;return Ge(()=>e.get({id:n,type:r}),[n,r])}function Ca(){let{resource:e}=xa();return e}function wa({resource:e,children:t}){let{id:n,type:r}=e||{};return B(ba.Provider,{value:I(()=>({resource:n&&r?{id:n,type:r}:null}),[n,r]),children:t})}function Ta(e,t){switch(t.type){case`setStack`:return{...e,stack:t.payload.resources,current:t.payload.resources[0]||null};case`edit`:{let n=t.payload.reset;return(t.payload.resource?.resource.source?.type===`Manifest`||t.payload.resource?.resource.source?.type===`Canvas`)&&(n=!0),e.current?.resource.source.id===t.payload.resource?.resource.source.id?{...e,current:t.payload.resource}:{...e,current:t.payload.resource,stack:n?[]:e.current?[e.current,...e.stack]:e.stack}}case`syncRemoval`:{let n=qe(t.payload.resource.resource);if(!n||!e.stack.find(e=>qe(e.resource)?.id===n.id))return e;let r=e.current?.resource.id===n.id?null:e.current,i=Ea(e.stack.filter(e=>qe(e.resource)?.id!==n.id),r);return{...e,stack:i,current:r}}case`updateCurrent`:return{...e,current:t.payload.resource};case`back`:{let t=e.stack[0];return{...e,stack:e.stack.slice(1),current:t||null}}case`close`:return{...e,stack:[],current:null};case`create`:return t.payload.resource===null?{...e,create:null}:{...e,create:t.payload}}return e}function Ea(e,t){let n=[],r=null;for(let t of e)r?.resource.id!==t.resource.id&&(n.push(t),r=t);return r&&r.resource.id===t?.resource.id?n.slice(0,n.length-1):n}const Da={stack:[],current:null,create:null},Oa=j(Da),ka=j({edit(){},close(){},back(){},setStack(){},updateCurrent(){},create(){return()=>{}}});function Aa(){return N(ka)}function ja(){return N(Oa).current}function Ma(){return N(Oa).stack}function Na(){return N(Oa).create}function Pa(){let{manifest:e}=We(),t=H(),[n,r]=Ee(e=>e+1,0);G(e,`Manifest not found`);let i=I(()=>new Ze({reference:{id:e,type:`Manifest`},vault:t}),[e,t]);return P(()=>i.observe.start(r),[i]),i.observe.key=`${n}`,i.observe.reset(),i}function Fa(){let{collection:e}=We(),t=H(),[n,r]=Ee(e=>e+1,0);G(e,`Collection not found`);let i=I(()=>new Ze({reference:{id:e,type:`Collection`},vault:t}),[e,t]);return P(()=>i.observe.start(r),[i]),i.observe.key=`${n}`,i.observe.reset(),i}function Ia(e,t={}){let n=H(),[r,i]=Ee(e=>e+1,0);!t.allowNull&&G(e,`Resource not found`);let a=I(()=>t.allowNull&&!e?null:new Ze({reference:qe(e),vault:n,context:{resource:e,parent:t.parent,index:t.index,parentProperty:t.parentProperty}}),[e,n]);return P(()=>a?.observe.start(i),[a]),a&&(a.observe.key=`${r}`,a.observe.reset()),a}function La(){let{annotationPage:e}=We();return G(e,`Annotation page not found`),Ia({id:e,type:`AnnotationPage`})}function Ra(){let e=ja(),{resource:t}=xa(),n=H(),[r,i]=Ee(e=>e+1,0);G(e,`No resource selected`);let a=I(()=>new Ze({reference:t||e.resource.source||e.resource,vault:n}),[t,e,n]);return P(()=>a.observe.start(i),[a]),a.observe.key=`${r}`,a.observe.reset(),a}function za(e){let t=H(),[n,r]=Ee(Ta,e),i=M(e=>{r(e)},[]);P(()=>t.on(`@iiif/REMOVE_REFERENCE`,e=>{let t=e.action,n={id:t.payload.id,type:t.payload.type},i=t.payload.reference;r({type:`syncRemoval`,payload:{resource:{parent:n,resource:i}}})}),[t]);let a=M((e,t=!1)=>i({type:`edit`,payload:{resource:e,reset:t}}),[]),o=M(e=>i({type:`setStack`,payload:{resources:e}}),[]),s=M(e=>i({type:`updateCurrent`,payload:{resource:e}}),[]),c=M(()=>i({type:`close`}),[]),l=M(()=>i({type:`back`}),[]),u=M((e,t)=>(i({type:`create`,payload:{resource:e,options:t}}),()=>{i({type:`create`,payload:{resource:null}})}),[]);return[n,I(()=>({edit:a,updateCurrent:s,close:c,back:l,create:u,setStack:o}),[])]}function Ba(e){let{instanceId:t}=Si(),[n,r]=za(e.initialState||Da);return B(ka.Provider,{value:r,children:B(Oa.Provider,{value:n,children:e.children})},t)}function Va({resource:e,children:t}){let{instanceId:n}=Si(),[r,i]=za(I(()=>({create:null,stack:[],current:{resource:{type:`SpecificResource`,source:{id:e.id,type:e.type}}}}),[]));return B(ka.Provider,{value:i,children:B(Oa.Provider,{value:r,children:t})},n)}const Ha=j(null),Ua=j(null),Wa=j(`default`);function Ga(){return N(Ua)}function Ka(){return N(Ha)}function qa(){return N(Wa)}function Ja(){return J().layout}function Ya(){let e=J(),t=e.layout,n=N(Ha),r=N(Ua);return I(()=>({actions:n,state:r,...t}),[e,r])}const Xa=`@manifest-editor/tags`,Za=`tags`,Qa={type:`flag`,id:`flag`,label:`Flag`,backgroundColor:`#b91c1c`,textColor:`#ffffff`,icon:`flag`},$a=[];function eo(e){return typeof e==`string`?e:e?.id||null}function to(e){return e.type||e.id}function no(e){return`${e.type}:${e.id}`}function ro(e){if(!Array.isArray(e))return $a;let t=new Map;for(let n of e){if(!n?.id)continue;let e=to(n);t.set(e,{...n,type:e})}return Array.from(t.values())}function io(e){return e.label||e.id||e.type}function ao(e,t){return e===Qa.type&&(!t||t===Qa.id)}function oo(e,t){return ao(e.type,e.id)?-1:ao(t.type,t.id)?1:io(e.tag).localeCompare(io(t.tag))||e.type.localeCompare(t.type)||e.id.localeCompare(t.id)}function so(e,t){return ao(e.type)?-1:ao(t.type)?1:e.type.localeCompare(t.type)}function co(e,t){let n=eo(t);return n?ro(e.getResourceMeta(n,Xa)?.[Za]):$a}function lo(e,t){let n=eo(t);return n?ro(e?.iiif?.meta?.[n]?.[Xa]?.[Za]):$a}function uo(e,t,n){let r=eo(t);if(!r)return $a;let i=ro(n);return e.setMetaValue([r,Xa,Za],i),i}function fo(e,t,n){return uo(e,t,[...co(e,t),n])}function po(e,t,n){return co(e,t).find(e=>e.type===n)}function mo(e,t,n,r){return uo(e,t,co(e,t).filter(e=>e.type!==n||(r?e.id!==r:!1)))}function ho(e,t){let n=new Map;for(let r of t){let t=eo(r);if(t)for(let i of co(e,r)){let e=i.type,r=no(i),a=n.get(e);a||(a={key:e,type:i.type,rows:[],canvasIds:[],canvasCount:0,tagCount:0},n.set(e,a));let o=a.rows.find(e=>e.key===r);o||(o={key:r,type:i.type,id:i.id,tag:i,canvasIds:[],canvasCount:0},a.rows.push(o)),o.canvasIds.push(t),o.canvasCount=o.canvasIds.length,a.tagCount+=1}}for(let e of n.values())e.rows.sort(oo),e.canvasIds=Array.from(new Set(e.rows.flatMap(e=>e.canvasIds))),e.canvasCount=e.canvasIds.length;return Array.from(n.values()).sort(so)}function go(e,t,n,r){let i=po(e,t,n);return r?i?.id===r:!!i}function _o(e,t,n){return go(e,t,n.type,n.id)?mo(e,t,n.type):fo(e,t,n)}function vo(e){return{getTags(t){return co(e,t)},setTags(t,n){return uo(e,t,n)},addTag(t,n){return fo(e,t,n)},upsertTag(t,n){return fo(e,t,n)},getTag(t,n){return po(e,t,n)},removeTag(t,n,r){return mo(e,t,n,r)},hasTag(t,n,r){return go(e,t,n,r)},toggleTag(t,n){return _o(e,t,n)}}}function yo(e){let t=eo(e);return Ge(e=>t?lo(e,t):$a,[t])}function bo(e){let t=H(),n=eo(e),r=I(()=>vo(t),[t]);return I(()=>({setTags(e){return r.setTags(n,e)},addTag(e){return r.addTag(n,e)},getTag(e){return r.getTag(n,e)},removeTag(e,t){return r.removeTag(n,e,t)},toggleTag(e){return r.toggleTag(n,e)},hasTag(e,t){return r.hasTag(n,e,t)}}),[r,n])}function xo({icon:e,title:t,...n}){return e===`flag`?V(`svg`,{viewBox:`0 0 24 24`,width:`1em`,height:`1em`,"aria-hidden":!t||void 0,...n,children:[t?B(`title`,{children:t}):null,B(`path`,{fill:`currentColor`,d:`M5 21a1 1 0 0 1-1-1V5.6c0-.42.26-.8.65-.94C6.7 3.9 8.65 4 10.5 4.7c1.55.58 3.05.7 4.5.36l3.75-.88A1 1 0 0 1 20 5.15v9.25c0 .46-.31.86-.75.97l-3.79.9c-1.85.43-3.76.28-5.66-.43-1.28-.48-2.55-.59-3.8-.33V20a1 1 0 0 1-1 1Z`})]}):null}function So({tag:e,showIcon:t=!0,className:n,style:r}){return V(`span`,{className:`inline-flex max-w-full items-center gap-0.5 rounded px-1 py-0.5 font-medium shadow-sm ${n||``}`,style:{backgroundColor:e.backgroundColor||`#e5e7eb`,color:e.textColor||`#111827`,fontSize:9,lineHeight:`11px`,...r},children:[t&&e.icon?B(xo,{icon:e.icon,className:`h-2.5 w-2.5 flex-shrink-0`}):null,B(`span`,{className:`min-w-0 truncate`,children:io(e)})]})}function Co({resource:e,tags:t,className:n}){return t?B(To,{tags:t,className:n}):B(wo,{resource:e,className:n})}function wo({resource:e,className:t}){let n=yo(e);return B(To,{tags:n,className:t})}function To({tags:e,className:t}){let n=e;return n.length?B(`div`,{className:`pointer-events-none absolute bottom-1 right-1 z-10 flex max-w-full flex-wrap justify-end gap-0.5 ${t||``}`,children:n.map(e=>B(So,{tag:e},e.type))}):null}const Eo=j(null);function Do(e){return e===`error`?8e3:5e3}function Oo({children:e,maxVisibleToasts:t=3}){let n=Qe({maxVisibleToasts:t}),r=I(()=>{let e=(e,t)=>n.add(e,{...t,timeout:t?.timeout??Do(e.variant)}),t=(t,n,r)=>e({...n,variant:t},r);return{add:e,info:(e,n)=>t(`info`,e,n),success:(e,n)=>t(`success`,e,n),warning:(e,n)=>t(`warning`,e,n),error:(e,n)=>t(`error`,e,n),close:n.close}},[n]);return V(Eo.Provider,{value:r,children:[e,B(de,{state:n})]})}function ko(){let e=N(Eo);if(!e)throw Error(`useToasts must be used within a ToastProvider`);return e}function Ao(e){return e.status!==`complete`&&e.status!==`error`||!e.completedAt?null:`${e.id}:${e.status}:${e.completedAt}`}function jo(e,t,n){let r=t.label||e.label;return t.status===`complete`?{variant:`success`,title:`${r} complete`,description:t.resultsAvailable?`Results are ready.`:void 0,action:t.resultsAvailable&&n?{label:`Results`,onPress:n}:void 0}:t.status===`error`?{variant:`error`,title:`${r} failed`,description:t.error?.message||t.statusText||`Action failed`}:null}function Mo(e){return{id:e.id,type:e.type,label:e.type,scope:`root`}}function No(e){if(!(!e||!e.id||e.type!==`Canvas`))return{id:e.id,type:`Canvas`,label:`Current canvas`,scope:`canvas`}}function Po(){let e=ja(),t=Ma();return I(()=>No([e,...t].find(e=>e?.resource?.source?.type===`Canvas`)?.resource?.source),[e,t])}function Fo(){let e=Y(),t=Po(),n=H(),r=I(()=>vo(n),[n]),i=I(()=>Zt(n),[n]),a=pi(),o=It(),s=Ga(),c=Ka();return I(()=>({rootResource:e,currentCanvas:t,vault:n,tags:r,canvasProgress:i,plugins:a,config:o,layoutState:s,layoutActions:c}),[e,t,n,r,i,a,o,s,c])}function Io(){let e=q(e=>e.definitions),t=q(e=>e.instances),n=Fo(),r=I(()=>Mo(n.rootResource),[n.rootResource]);return I(()=>{let i=[r,...n.currentCanvas?[n.currentCanvas]:[]];return hn({definitions:e,instances:t,systemContext:n,targets:i,onSupportsError:(e,t)=>{console.error(`Background action "${e.id}" failed support check`,t)}})},[e,t,r,n])}function Lo(){let e=dr(),t=q(e=>e.definitions),n=q(e=>e.instances),r=q(e=>e.plans),i=q(e=>e.controllers),a=q(e=>e.hasHydrated),o=Fo(),s=L(new Set);return P(()=>{if(!a)return;let c=new Map(t.map(e=>[e.id,e]));for(let[t,a]of Object.entries(n)){let n=c.get(a.actionId),l=`${t}:${a.runId}`;!n?.resumable||!zo(a)||!r[t]||i[t]||s.current.has(l)||(s.current.add(l),rr({store:e,resume:!0,context:{...o,definition:n,target:a.target,instanceKey:t,instance:a}}))}},[i,t,a,n,r,e,o]),B(z,{children:t.map(e=>e.render?B(ye,{children:e.render({...o,definition:e})},e.id):null)})}function Ro(){let e=q(e=>e.definitions),t=q(e=>e.instances),n=Fo(),r=ko(),i=L(new Set),a=I(()=>new Map(e.map(e=>[e.id,e])),[e]);return P(()=>{for(let e of Object.values(t)){let t=Ao(e);if(!t||i.current.has(t))continue;let o=a.get(e.actionId);if(!o)continue;let s={...n,definition:o,target:e.target,instanceKey:e.id,instance:e},c=jo(o,e,e.resultsAvailable&&o.onResults?()=>{o.onResults?.(s)}:void 0);c&&(r.add(c),i.current.add(t))}},[a,t,n,r]),null}function zo(e){return e?.status===`preparing`||e?.status===`running`}function Bo(e){return!e||e.status===`idle`?``:e.status===`error`?e.error?.message||e.statusText||`Error`:e.status===`complete`&&e.resultsAvailable?`Results ready`:e.status===`cancelled`?`Cancelled`:e.statusText||e.status}function Vo(e){return e?new Date(e).toLocaleString():`Not recorded`}function Ho(e){return e?new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}):`--:--:--`}function Uo(e){if(!e.startedAt)return`Not recorded`;let t=e.completedAt||Date.now(),n=Math.max(0,Math.round((t-e.startedAt)/1e3)),r=Math.floor(n/60),i=n%60;return r?`${r}m ${i}s`:`${i}s`}function Wo(e){if(e===void 0)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Go({label:e,value:t}){return V(`div`,{className:`min-w-0`,children:[B(`dt`,{className:`text-[10px] font-semibold uppercase tracking-widest text-zinc-400`,children:e}),B(`dd`,{className:`mt-1 break-words text-sm text-zinc-800`,children:t})]})}const Ko={debug:{label:`DBG`,className:`text-zinc-500`},verbose:{label:`VRB`,className:`text-zinc-500`},info:{label:`INF`,className:`text-sky-400`},log:{label:`LOG`,className:`text-zinc-300`},warn:{label:`WRN`,className:`text-amber-400`},warning:{label:`WRN`,className:`text-amber-400`},error:{label:`ERR`,className:`text-red-400`}};function qo(e){return Ko[e?.toLowerCase()]??{label:e?.toUpperCase().slice(0,3)??`LOG`,className:`text-zinc-300`}}const Jo={error:`bg-red-100 text-red-700`,failed:`bg-red-100 text-red-700`,completed:`bg-green-100 text-green-700`,success:`bg-green-100 text-green-700`,started:`bg-sky-100 text-sky-700`,cancelled:`bg-zinc-100 text-zinc-600`,warning:`bg-amber-100 text-amber-700`,warn:`bg-amber-100 text-amber-700`};function Yo(e){return Jo[e?.toLowerCase()]??`bg-zinc-100 text-zinc-600`}function Xo(e){return e?.toLowerCase()in Jo}function Zo({definition:e,instance:t,onClose:n}){let[r,i]=R(`overview`),a=L(null),o=t.logs.length;P(()=>{r===`logs`&&a.current?.scrollIntoView({behavior:`instant`})},[r]);let s={idle:`bg-zinc-100 text-zinc-600`,preparing:`bg-orange-100 text-orange-700`,running:`bg-orange-100 text-orange-700`,complete:`bg-green-100 text-green-700`,error:`bg-red-100 text-red-700`,cancelled:`bg-zinc-100 text-zinc-500`},c=t.events.filter(e=>Xo(e.type)),l=[{id:`overview`,label:`Overview`},{id:`logs`,label:`Logs`,count:o}];return V(ee,{title:t.label||e.label,onClose:n,className:`max-w-3xl`,children:[B(`div`,{className:`sticky top-0 z-10 border-b border-zinc-200 bg-white px-2`,children:B(`div`,{className:`flex gap-0.5`,children:l.map(e=>V(`button`,{type:`button`,onClick:()=>i(e.id),className:[`flex items-center gap-1.5 border-b-2 px-3 py-2.5 text-sm transition-colors -mb-px`,r===e.id?`border-me-primary-500 font-semibold text-me-primary-600`:`border-transparent text-zinc-500 hover:text-zinc-800`].join(` `),children:[e.label,e.count?B(`span`,{className:`rounded-full bg-zinc-100 px-1.5 py-0.5 text-[10px] font-medium text-zinc-500`,children:e.count}):null]},e.id))})}),r===`overview`&&V(`div`,{className:`flex flex-col gap-5 p-5`,children:[V(`div`,{className:`flex flex-wrap items-center gap-2`,children:[B(`span`,{className:[`inline-flex items-center gap-1.5 rounded-full px-3 py-1 text-xs font-semibold uppercase tracking-wide`,s[t.status]??`bg-zinc-100 text-zinc-600`].join(` `),children:t.status}),t.statusText?B(`span`,{className:`text-sm text-zinc-500`,children:t.statusText}):null]}),V(`dl`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[B(Go,{label:`Target`,value:`${t.target.label} (${t.target.type})`}),B(Go,{label:`Run ID`,value:t.runId}),B(Go,{label:`Started`,value:Vo(t.startedAt)}),B(Go,{label:`Finished`,value:Vo(t.completedAt)}),B(Go,{label:`Duration`,value:Uo(t)}),t.progress?B(Go,{label:`Progress`,value:`${Math.round(t.progress.percent)}%${t.progress.label?` — ${t.progress.label}`:``}`}):null]}),t.progress?V(`div`,{children:[B(d,{percent:t.progress.percent,label:t.progress.label||`Background action progress`}),typeof t.progress.current==`number`&&typeof t.progress.total==`number`?V(`div`,{className:`mt-1 text-xs text-zinc-500`,children:[t.progress.current,` of `,t.progress.total,` items`]}):null]}):null,t.error?V(`div`,{className:`rounded-lg border border-red-200 bg-red-50`,children:[B(`div`,{className:`border-b border-red-200 px-4 py-2.5`,children:B(`span`,{className:`text-xs font-semibold uppercase tracking-widest text-red-600`,children:`Error`})}),V(`div`,{className:`p-4`,children:[B(`div`,{className:`text-sm font-medium text-red-800`,children:t.error.message}),t.error.stack?B(`pre`,{className:`mt-3 max-h-40 overflow-auto rounded bg-red-100 p-3 text-xs text-red-700 leading-relaxed whitespace-pre-wrap`,children:t.error.stack}):null]})]}):null,c.length>0?V(`div`,{children:[B(`h3`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-widest text-zinc-400`,children:`Key events`}),B(`div`,{className:`divide-y divide-zinc-100 rounded-lg border border-zinc-200`,children:c.map(e=>V(`div`,{className:`flex items-baseline gap-3 px-3 py-2`,children:[B(`span`,{className:[`shrink-0 rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide`,Yo(e.type)].join(` `),children:e.type}),B(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-700`,children:e.message||e.type}),B(`time`,{className:`shrink-0 text-xs text-zinc-400`,children:Ho(e.createdAt)})]},e.id))})]}):null]}),r===`logs`&&B(`div`,{className:`p-5`,children:o===0?B(`div`,{className:`rounded-lg border border-zinc-200 p-6 text-center text-sm text-zinc-400`,children:`No logs recorded.`}):V(`div`,{className:`overflow-hidden rounded-lg bg-zinc-950 shadow-inner`,children:[V(`div`,{className:`flex items-center gap-1.5 border-b border-white/10 px-3 py-2`,children:[B(`div`,{className:`h-2.5 w-2.5 rounded-full bg-zinc-700`}),B(`div`,{className:`h-2.5 w-2.5 rounded-full bg-zinc-700`}),B(`div`,{className:`h-2.5 w-2.5 rounded-full bg-zinc-700`}),V(`span`,{className:`ml-2 text-[10px] text-zinc-500 font-mono`,children:[o,` `,o===1?`entry`:`entries`]})]}),V(`div`,{className:`max-h-[50vh] overflow-y-auto p-1 font-mono text-xs`,children:[t.logs.map(e=>{let t=qo(e.level);return V(`div`,{className:`group flex gap-0 hover:bg-white/5 rounded px-2 py-1 leading-relaxed`,children:[B(`time`,{className:`w-20 shrink-0 text-zinc-600 select-none pr-2`,children:Ho(e.createdAt)}),B(`span`,{className:[`w-10 shrink-0 select-none font-bold pr-2`,t.className].join(` `),children:t.label}),V(`span`,{className:`min-w-0 flex-1 text-zinc-200 break-words`,children:[e.message,e.data===void 0?null:B(`span`,{className:`block mt-0.5 text-zinc-500 whitespace-pre-wrap`,children:Wo(e.data)})]})]},e.id)}),B(`div`,{ref:a})]})]})})]})}function Qo(){let e=dr(),t=Io(),[n,g]=R(null),_=t.reduce((e,t)=>e+t.actions.length,0),v=t.reduce((e,t)=>e+t.actions.filter(e=>zo(e.instance)).length,0),y=t.reduce((e,t)=>e+t.actions.filter(e=>e.instance?.status===`error`).length,0),{isOpen:b,buttonProps:x,itemProps:S,setIsOpen:C}=zi(_);if(!_)return null;let w=n?t.flatMap(e=>e.actions).find(e=>e.instanceKey===n):void 0,T=0;return V(f,{children:[B(r,{active:b,runningCount:v,errorCount:y,"aria-label":`Actions menu`,...x}),B(u,{open:b,role:`menu`,"aria-hidden":!b,inert:!b,children:B(`div`,{className:`py-1.5`,children:t.map((t,n)=>V(ye,{children:[n?B(i,{}):null,B(p,{children:t.label}),t.actions.map(t=>{let{onKeyDown:n,...r}=S[T++]||{},i=Bo(t.instance),u=zo(t.instance),f=()=>{u||(rr({store:e,context:t.context}),C(!0))},p=()=>{u&&(e.getState().cancelAction(t.instanceKey),C(!0))};return V(s,{status:t.instance?.status||`idle`,children:[B(h,{running:u,...r,"aria-label":u?`Cancel ${t.definition.label}`:`Run ${t.definition.label}`,onMouseDown:e=>{e.preventDefault()},onClick:e=>{e.stopPropagation(),u?p():f()},onKeyDown:e=>{e.key===`Enter`||e.key===` `?(e.preventDefault(),e.stopPropagation(),u?p():f()):n?.(e)},children:V(m,{children:[B(c,{running:u,children:t.instance?.label||t.definition.label}),i?B(l,{variant:t.instance?.status===`error`?`error`:`default`,children:i}):null,t.definition.summary&&!i?B(l,{children:t.definition.summary}):null,u&&t.instance?.progress?B(d,{percent:t.instance.progress.percent,label:t.instance.progress.label||i||t.definition.label}):null]})}),t.instance?.resultsAvailable&&t.definition.onResults?B(o,{onClick:e=>{e.stopPropagation(),t.definition.onResults?.(t.context)},children:`Results`}):null,t.instance?B(a,{"aria-label":`View ${t.definition.label} details`,onClick:e=>{e.preventDefault(),e.stopPropagation(),g(t.instanceKey),C(!0)}}):null]},t.instanceKey)})]},t.id))})}),w?.instance?B(Zo,{definition:w.definition,instance:w.instance,onClose:()=>g(null)}):null]})}const $o=new Set([`fullpage`,`slideshow`,`scroll`]);function es(e,t){return[...e.filter(e=>!e.startsWith(`template-`)&&!$o.has(e)),t.type,`template-${t.id}`]}function ts(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 ns(e,t,n=[]){return ts(e,n)||e.find(e=>e.id===t)||e[0]||null}const rs=`manifest-editor:preset-onboarding:open`;function is(e){return typeof window<`u`&&window.localStorage.getItem(e)===`true`}function as(e){typeof window<`u`&&window.localStorage.setItem(e,`true`)}function os(e,t){return e.mode===`global`||!t?`preset-onboarding/${e.id}`:`preset-onboarding/${e.id}/${t.type}/${t.id}`}function ss(){let e=J(),t=Y(),n=e.preset?.onboarding,r=n?os(n,t):null;return()=>window.dispatchEvent(new CustomEvent(rs,{detail:r}))}function cs({className:t}){let n=J().preset?.onboarding,r=ss();return n?B(e,{className:t,onPress:r,children:n.openLabel||`Open guide`}):null}function ls(e){let t=J(),n=Y(),{state:r,setState:i}=Ci(),a=t.preset?.onboarding,o=t.preset?.onboarding?.renderPreviewButton,s=a?os(a,n):null,c=!!s&&r?.presetOnboardingPreviewHintKey===s;return o?o({...e,preview:t.preset?.preview,showOnboardingPreviewHint:c,onOnboardingPreviewHintClose:()=>{c&&i({presetOnboardingPreviewHintKey:null})}}):B(ya,{...e,preview:t.preset?.preview})}function us(){let t=J(),n=Y(),r=t.preset?.onboarding,{setState:i}=Ci(),a=Ti(),o=Ue(),s=H(),c=o?.behavior||[],l=ts(a.templates,c),u=ns(a.templates,a.selectedTemplateId,c),d=L(u?.id||null);d.current=u?.id||null;let f=I(()=>r?os(r,n):null,[r,n]),[p,m]=R(!1),[h,g]=R(!1);if(P(()=>{if(!f)return;let e=!l&&!is(f);m(e),g(e)},[l,f]),P(()=>{let e=e=>{e.detail===f&&(i({presetOnboardingPreviewHintKey:null}),m(!!r),g(!1))};return window.addEventListener(rs,e),()=>window.removeEventListener(rs,e)},[f,r,i]),!r||!f)return null;let _=()=>{a.setSelectedTemplateId(ns(a.templates,d.current)?.id||null),as(f),h&&i({presetOnboardingPreviewHintKey:f}),m(!1),g(!1)},v=e=>{d.current=e,a.setSelectedTemplateId(e);let t=a.templates.find(t=>t.id===e);if(!o||!t)return;let n=o.behavior||[],r=es(n,t);r.length===n.length&&r.every((e,t)=>e===n[t])||s.modifyEntityField(o,`behavior`,r)};return B(ee,{title:r.title,open:p,onClose:_,actions:V(`div`,{className:`flex gap-2`,children:[B(e,{onPress:_,children:r.dismissLabel||`Dismiss`}),u?B(e,{primary:!0,onPress:()=>{v(d.current),_()},children:r.primaryLabel||`Continue`}):null]}),children:V(`div`,{className:`flex flex-col gap-4 p-6`,children:[r.summary?B(`p`,{className:`text-sm text-gray-600`,children:r.summary}):null,r.renderBody({...a,selectedTemplateId:u?.id||null,selectedTemplate:u,setSelectedTemplateId:v,dismiss:_})]})})}const ds=we(function(e){let[t]=me(`menu-hidden`);return B(Ni,{children:V(Mi,{children:[B(Pi,{onClick:e.onClickLogo,children:B(E,{})}),B(ya,{}),B(cs,{}),B(Qo,{})]})})}),fs=j(null);function ps(){return N(fs)||null}function ms(e,t){let n=ps();return n?n[e][t]:null}function hs({children:e,menu:t}){return B(fs.Provider,{value:t,children:e})}function gs(){return N(Ne)}function _s(e){if(!e)return null;if(e.points.length>2){let t=Math.min(...e.points.map(e=>e[0])),n=Math.min(...e.points.map(e=>e[1])),r=Math.max(0,...e.points.map(e=>e[0])),i=Math.max(0,...e.points.map(e=>e[1]));return{x:t,y:n,width:r-t,height:i-n}}return null}const vs=async e=>new Promise((t,n)=>{let r=document.createElement(`img`);r.onload=()=>t(r),r.onerror=()=>n(),r.src=e,r.complete&&t(r)}),ys=async e=>new Promise((t,n)=>{let r=document.createElement(`video`);r.onloadedmetadata=()=>t(r),r.onerror=()=>n(),r.preload=`metadata`,r.src=e});async function bs(){}async function xs(e,...t){if(!e)return;if(e.endsWith(`.mp3`)||e.endsWith(`.mp4`)||e.endsWith(`.m4a`)||e.endsWith(`.m4v`))try{let t=await ys(e);if(t){let n=t.videoWidth===0;return{id:e,type:t.videoWidth===0?`Sound`:`Video`,width:t.videoWidth||void 0,height:t.videoHeight||void 0,duration:t.duration,format:n?`audio/mp4`:`video/mp4`}}}catch{}let n=null;try{n=await fetch(e)}catch{return ws(e)}if(!n.ok&&(n=await fetch(e+`/info.json`),!n.ok))return ws(e);let r=n.headers.get(`Content-Type`);if(r?.includes(`image/`))return ws(e,r);let i=null;try{i=await n.json()}catch{return null}return await Cs(i,e)}function Ss(e){return e.protocol&&e.protocol===`http://iiif.io/api/image`?(e.type||(e.type=`ImageService`),e):null}async function Cs(e,t){let n=Ss(e);if(n)return n;if(!(e.id||e[`@id`]))return null;let r=await new et.Vault().load(t,e);if(r&&(r&&r?.type===`Manifest`||r?.type===`Collection`))return{id:t,type:r.type,label:$e(r.label)}}async function ws(e,t){let n=e.split(`/`);if(n.length>=8){let e=n.slice(-4);if(e[3].split(`.`).length===2&&(e[2][0]===`!`||e[2]===e[2])){let e=await Ts(n.slice(0,n.length-4).join(`/`)+`/info.json`);if(e&&e?.type&&e?.type?.startsWith(`ImageService`))return e}}try{let n=await vs(e);return{id:e,type:`Image`,width:n.width,height:n.height,format:await Es(e,t)}}catch{}return null}async function Ts(e){try{let t=await fetch(e);return t.ok?await Cs(await t.json(),e):null}catch(e){return console.log(e),null}}async function Es(e,t){if(t)return t;try{let t=(await fetch(e,{method:`HEAD`,mode:`no-cors`})).headers.get(`Content-type`);if(t)return t}catch{}let n=e.toLowerCase();return n.endsWith(`jpg`)||n.endsWith(`jpeg`)?`image/jpeg`:n.endsWith(`png`)?`image/png`:`image/jpeg`}async function Ds(e){try{let t=await vs(e);if(t)return{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}}catch{return null}return null}const Os=De(e=>({regions:{},resources:[],setRegion:(t,n)=>{e(e=>({...e.regions,regions:{[t]:n||null}}))},setHighlight:t=>{e({resources:Array.isArray(t)?t:[t]})},highlight:t=>{e(e=>e.resources.indexOf(t)===-1?{resources:[...e.resources,t]}:e)},clearHighlight:t=>{e(e=>({resources:e.resources.filter(e=>e!==t)}))}}));function ks(e){let t=I(()=>vr(),[]),n=Os(e=>e.regions[t]),r=Os(e=>e.setRegion);P(()=>{n&&e?n!==e&&(n.x!==e.x||n.y!==e.y||n.width!==e.width||n.height!==e.height)&&r(t,e||null):r(t,e||null)},[n]),P(()=>()=>r(t,null),[])}function As(e){let t=Os(e=>e.highlight),n=Os(e=>e.clearHighlight);return P(()=>()=>{e&&n(e)},[n,e]),I(()=>({onMouseEnter(){e&&t(e)},onMouseLeave(){e&&n(e)}}),[e,t,n])}const js=U.div`
242
+ `;function va(e,t){return e>0||!!t?.mainAction||!!t?.actions?.length}function ya({downloadEnabled:e,fileName:t,preview:n}){let{active:r,configs:i,actions:a,selected:o}=ia(),s=H(),c=K(),l=Hi(),u=i.filter(e=>e.type===`external-manifest-preview`),d=n?.actions||[],{isOpen:f,buttonProps:p,itemProps:m}=Ri(u.length+d.length);return va(u.length,n)?V(z,{children:[e?B(`div`,{className:`mr-4`,children:B(y,{fileName:t||`manifest.json`,label:`Download manifest`,getData:()=>c.export&&c.export.version===2?JSON.stringify(s.toPresentation2(l),null,2):JSON.stringify(s.toPresentation3(l),null,2)})}):null,V(ca,{children:[B(la,{"data-preview-action":n?.mainAction?.id,disabled:n?.mainAction?.disabled||!n?.mainAction&&u.length===0,onClick:()=>{if(n?.mainAction){n.mainAction.onClick();return}if(u.length){if(!o){let e=c.defaultPreview;if(e){let t=i.find(t=>t.id===e);if(t){a.selectPreview(t.id);return}}a.selectPreview(i[0].id)}a.updatePreviews()}},children:n?.mainAction?.label||`Preview`}),u.length+d.length>0?B(ua,{$open:f,...p,"aria-label":`Choose preview`,children:B(Fi,{"aria-hidden":!0})}):null,V(da,{$open:f,role:`menu`,children:[u.map((e,t)=>{let n=r.indexOf(e.id)===-1;return V(fa,{...m[t],children:[B(ma,{$status:n?`available`:e.id===o?`active`:`configured`}),B(ha,{onClick:()=>{a.selectPreview(e.id)},children:e.label}),n?null:B(ga,{onClick:()=>a.deletePreview(e.id),children:B(Pi,{})})]},e.id)}),d.map((e,t)=>V(fa,{...m[u.length+t],"aria-disabled":e.disabled||void 0,onClick:()=>{e.disabled||e.onClick()},children:[B(ma,{$status:e.status||`available`}),B(ha,{children:e.label})]},e.id))]})]})]}):B(_a,{children:`Preview not available`})}const ba=j({resource:null});function xa(){return N(ba)}function Sa(){let e=H(),{resource:t}=xa();G(t,`Nothing selected`);let{id:n,type:r}=t;return Ge(()=>e.get({id:n,type:r}),[n,r])}function Ca(){let{resource:e}=xa();return e}function wa({resource:e,children:t}){let{id:n,type:r}=e||{};return B(ba.Provider,{value:I(()=>({resource:n&&r?{id:n,type:r}:null}),[n,r]),children:t})}function Ta(e,t){switch(t.type){case`setStack`:return{...e,stack:t.payload.resources,current:t.payload.resources[0]||null};case`edit`:{let n=t.payload.reset;return(t.payload.resource?.resource.source?.type===`Manifest`||t.payload.resource?.resource.source?.type===`Canvas`)&&(n=!0),e.current?.resource.source.id===t.payload.resource?.resource.source.id?{...e,current:t.payload.resource}:{...e,current:t.payload.resource,stack:n?[]:e.current?[e.current,...e.stack]:e.stack}}case`syncRemoval`:{let n=qe(t.payload.resource.resource);if(!n||!e.stack.find(e=>qe(e.resource)?.id===n.id))return e;let r=e.current?.resource.id===n.id?null:e.current,i=Ea(e.stack.filter(e=>qe(e.resource)?.id!==n.id),r);return{...e,stack:i,current:r}}case`updateCurrent`:return{...e,current:t.payload.resource};case`back`:{let t=e.stack[0];return{...e,stack:e.stack.slice(1),current:t||null}}case`close`:return{...e,stack:[],current:null};case`create`:return t.payload.resource===null?{...e,create:null}:{...e,create:t.payload}}return e}function Ea(e,t){let n=[],r=null;for(let t of e)r?.resource.id!==t.resource.id&&(n.push(t),r=t);return r&&r.resource.id===t?.resource.id?n.slice(0,n.length-1):n}const Da={stack:[],current:null,create:null},Oa=j(Da),ka=j({edit(){},close(){},back(){},setStack(){},updateCurrent(){},create(){return()=>{}}});function Aa(){return N(ka)}function ja(){return N(Oa).current}function Ma(){return N(Oa).stack}function Na(){return N(Oa).create}function Pa(){let{manifest:e}=We(),t=H(),[n,r]=Ee(e=>e+1,0);G(e,`Manifest not found`);let i=I(()=>new Ze({reference:{id:e,type:`Manifest`},vault:t}),[e,t]);return P(()=>i.observe.start(r),[i]),i.observe.key=`${n}`,i.observe.reset(),i}function Fa(){let{collection:e}=We(),t=H(),[n,r]=Ee(e=>e+1,0);G(e,`Collection not found`);let i=I(()=>new Ze({reference:{id:e,type:`Collection`},vault:t}),[e,t]);return P(()=>i.observe.start(r),[i]),i.observe.key=`${n}`,i.observe.reset(),i}function Ia(e,t={}){let n=H(),[r,i]=Ee(e=>e+1,0);!t.allowNull&&G(e,`Resource not found`);let a=I(()=>t.allowNull&&!e?null:new Ze({reference:qe(e),vault:n,context:{resource:e,parent:t.parent,index:t.index,parentProperty:t.parentProperty}}),[e,n]);return P(()=>a?.observe.start(i),[a]),a&&(a.observe.key=`${r}`,a.observe.reset()),a}function La(){let{annotationPage:e}=We();return G(e,`Annotation page not found`),Ia({id:e,type:`AnnotationPage`})}function Ra(){let e=ja(),{resource:t}=xa(),n=H(),[r,i]=Ee(e=>e+1,0);G(e,`No resource selected`);let a=I(()=>new Ze({reference:t||e.resource.source||e.resource,vault:n}),[t,e,n]);return P(()=>a.observe.start(i),[a]),a.observe.key=`${r}`,a.observe.reset(),a}function za(e){let t=H(),[n,r]=Ee(Ta,e),i=M(e=>{r(e)},[]);P(()=>t.on(`@iiif/REMOVE_REFERENCE`,e=>{let t=e.action,n={id:t.payload.id,type:t.payload.type},i=t.payload.reference;r({type:`syncRemoval`,payload:{resource:{parent:n,resource:i}}})}),[t]);let a=M((e,t=!1)=>i({type:`edit`,payload:{resource:e,reset:t}}),[]),o=M(e=>i({type:`setStack`,payload:{resources:e}}),[]),s=M(e=>i({type:`updateCurrent`,payload:{resource:e}}),[]),c=M(()=>i({type:`close`}),[]),l=M(()=>i({type:`back`}),[]),u=M((e,t)=>(i({type:`create`,payload:{resource:e,options:t}}),()=>{i({type:`create`,payload:{resource:null}})}),[]);return[n,I(()=>({edit:a,updateCurrent:s,close:c,back:l,create:u,setStack:o}),[])]}function Ba(e){let{instanceId:t}=xi(),[n,r]=za(e.initialState||Da);return B(ka.Provider,{value:r,children:B(Oa.Provider,{value:n,children:e.children})},t)}function Va({resource:e,children:t}){let{instanceId:n}=xi(),[r,i]=za(I(()=>({create:null,stack:[],current:{resource:{type:`SpecificResource`,source:{id:e.id,type:e.type}}}}),[]));return B(ka.Provider,{value:i,children:B(Oa.Provider,{value:r,children:t})},n)}const Ha=j(null),Ua=j(null),Wa=j(`default`);function Ga(){return N(Ua)}function Ka(){return N(Ha)}function qa(){return N(Wa)}function Ja(){return Y().layout}function Ya(){let e=Y(),t=e.layout,n=N(Ha),r=N(Ua);return I(()=>({actions:n,state:r,...t}),[e,r])}const Xa=`@manifest-editor/tags`,Za=`tags`,Qa={type:`flag`,id:`flag`,label:`Flag`,backgroundColor:`#b91c1c`,textColor:`#ffffff`,icon:`flag`},$a=[];function eo(e){return typeof e==`string`?e:e?.id||null}function to(e){return e.type||e.id}function no(e){return`${e.type}:${e.id}`}function ro(e){if(!Array.isArray(e))return $a;let t=new Map;for(let n of e){if(!n?.id)continue;let e=to(n);t.set(e,{...n,type:e})}return Array.from(t.values())}function io(e){return e.label||e.id||e.type}function ao(e,t){return e===Qa.type&&(!t||t===Qa.id)}function oo(e,t){return ao(e.type,e.id)?-1:ao(t.type,t.id)?1:io(e.tag).localeCompare(io(t.tag))||e.type.localeCompare(t.type)||e.id.localeCompare(t.id)}function so(e,t){return ao(e.type)?-1:ao(t.type)?1:e.type.localeCompare(t.type)}function co(e,t){let n=eo(t);return n?ro(e.getResourceMeta(n,Xa)?.[Za]):$a}function lo(e,t){let n=eo(t);return n?ro(e?.iiif?.meta?.[n]?.[Xa]?.[Za]):$a}function uo(e,t,n){let r=eo(t);if(!r)return $a;let i=ro(n);return e.setMetaValue([r,Xa,Za],i),i}function fo(e,t,n){return uo(e,t,[...co(e,t),n])}function po(e,t,n){return co(e,t).find(e=>e.type===n)}function mo(e,t,n,r){return uo(e,t,co(e,t).filter(e=>e.type!==n||(r?e.id!==r:!1)))}function ho(e,t){let n=new Map;for(let r of t){let t=eo(r);if(t)for(let i of co(e,r)){let e=i.type,r=no(i),a=n.get(e);a||(a={key:e,type:i.type,rows:[],canvasIds:[],canvasCount:0,tagCount:0},n.set(e,a));let o=a.rows.find(e=>e.key===r);o||(o={key:r,type:i.type,id:i.id,tag:i,canvasIds:[],canvasCount:0},a.rows.push(o)),o.canvasIds.push(t),o.canvasCount=o.canvasIds.length,a.tagCount+=1}}for(let e of n.values())e.rows.sort(oo),e.canvasIds=Array.from(new Set(e.rows.flatMap(e=>e.canvasIds))),e.canvasCount=e.canvasIds.length;return Array.from(n.values()).sort(so)}function go(e,t,n,r){let i=po(e,t,n);return r?i?.id===r:!!i}function _o(e,t,n){return go(e,t,n.type,n.id)?mo(e,t,n.type):fo(e,t,n)}function vo(e){return{getTags(t){return co(e,t)},setTags(t,n){return uo(e,t,n)},addTag(t,n){return fo(e,t,n)},upsertTag(t,n){return fo(e,t,n)},getTag(t,n){return po(e,t,n)},removeTag(t,n,r){return mo(e,t,n,r)},hasTag(t,n,r){return go(e,t,n,r)},toggleTag(t,n){return _o(e,t,n)}}}function yo(e){let t=eo(e);return Ge(e=>t?lo(e,t):$a,[t])}function bo(e){let t=H(),n=eo(e),r=I(()=>vo(t),[t]);return I(()=>({setTags(e){return r.setTags(n,e)},addTag(e){return r.addTag(n,e)},getTag(e){return r.getTag(n,e)},removeTag(e,t){return r.removeTag(n,e,t)},toggleTag(e){return r.toggleTag(n,e)},hasTag(e,t){return r.hasTag(n,e,t)}}),[r,n])}function xo({icon:e,title:t,...n}){return e===`flag`?V(`svg`,{viewBox:`0 0 24 24`,width:`1em`,height:`1em`,"aria-hidden":!t||void 0,...n,children:[t?B(`title`,{children:t}):null,B(`path`,{fill:`currentColor`,d:`M5 21a1 1 0 0 1-1-1V5.6c0-.42.26-.8.65-.94C6.7 3.9 8.65 4 10.5 4.7c1.55.58 3.05.7 4.5.36l3.75-.88A1 1 0 0 1 20 5.15v9.25c0 .46-.31.86-.75.97l-3.79.9c-1.85.43-3.76.28-5.66-.43-1.28-.48-2.55-.59-3.8-.33V20a1 1 0 0 1-1 1Z`})]}):null}function So({tag:e,showIcon:t=!0,className:n,style:r}){return V(`span`,{className:`inline-flex max-w-full items-center gap-0.5 rounded px-1 py-0.5 font-medium shadow-sm ${n||``}`,style:{backgroundColor:e.backgroundColor||`#e5e7eb`,color:e.textColor||`#111827`,fontSize:9,lineHeight:`11px`,...r},children:[t&&e.icon?B(xo,{icon:e.icon,className:`h-2.5 w-2.5 flex-shrink-0`}):null,B(`span`,{className:`min-w-0 truncate`,children:io(e)})]})}function Co({resource:e,tags:t,className:n}){return t?B(To,{tags:t,className:n}):B(wo,{resource:e,className:n})}function wo({resource:e,className:t}){let n=yo(e);return B(To,{tags:n,className:t})}function To({tags:e,className:t}){let n=e;return n.length?B(`div`,{className:`pointer-events-none absolute bottom-1 right-1 z-10 flex max-w-full flex-wrap justify-end gap-0.5 ${t||``}`,children:n.map(e=>B(So,{tag:e},e.type))}):null}const Eo=j(null);function Do(e){return e===`error`?8e3:5e3}function Oo({children:e,maxVisibleToasts:t=3}){let n=Qe({maxVisibleToasts:t}),r=I(()=>{let e=(e,t)=>n.add(e,{...t,timeout:t?.timeout??Do(e.variant)}),t=(t,n,r)=>e({...n,variant:t},r);return{add:e,info:(e,n)=>t(`info`,e,n),success:(e,n)=>t(`success`,e,n),warning:(e,n)=>t(`warning`,e,n),error:(e,n)=>t(`error`,e,n),close:n.close}},[n]);return V(Eo.Provider,{value:r,children:[e,B(de,{state:n})]})}function ko(){let e=N(Eo);if(!e)throw Error(`useToasts must be used within a ToastProvider`);return e}function Ao(e){return e.status!==`complete`&&e.status!==`error`||!e.completedAt?null:`${e.id}:${e.status}:${e.completedAt}`}function jo(e,t,n){let r=t.label||e.label;return t.status===`complete`?{variant:`success`,title:`${r} complete`,description:t.resultsAvailable?`Results are ready.`:void 0,action:t.resultsAvailable&&n?{label:`Results`,onPress:n}:void 0}:t.status===`error`?{variant:`error`,title:`${r} failed`,description:t.error?.message||t.statusText||`Action failed`}:null}function Mo(e){return{id:e.id,type:e.type,label:e.type,scope:`root`}}function No(e){if(!(!e||!e.id||e.type!==`Canvas`))return{id:e.id,type:`Canvas`,label:`Current canvas`,scope:`canvas`}}function Po(){let e=ja(),t=Ma();return I(()=>No([e,...t].find(e=>e?.resource?.source?.type===`Canvas`)?.resource?.source),[e,t])}function Fo(){let e=Hi(),t=Po(),n=H(),r=I(()=>vo(n),[n]),i=I(()=>Xt(n),[n]),a=fi(),o=K(),s=Ga(),c=Ka();return I(()=>({rootResource:e,currentCanvas:t,vault:n,tags:r,canvasProgress:i,plugins:a,config:o,layoutState:s,layoutActions:c}),[e,t,n,r,i,a,o,s,c])}function Io(){let e=J(e=>e.definitions),t=J(e=>e.instances),n=Fo(),r=I(()=>Mo(n.rootResource),[n.rootResource]);return I(()=>{let i=[r,...n.currentCanvas?[n.currentCanvas]:[]];return mn({definitions:e,instances:t,systemContext:n,targets:i,onSupportsError:(e,t)=>{console.error(`Background action "${e.id}" failed support check`,t)}})},[e,t,r,n])}function Lo(){let e=ur(),t=J(e=>e.definitions),n=J(e=>e.instances),r=J(e=>e.plans),i=J(e=>e.controllers),a=J(e=>e.hasHydrated),o=Fo(),s=L(new Set);return P(()=>{if(!a)return;let c=new Map(t.map(e=>[e.id,e]));for(let[t,a]of Object.entries(n)){let n=c.get(a.actionId),l=`${t}:${a.runId}`;!n?.resumable||!zo(a)||!r[t]||i[t]||s.current.has(l)||(s.current.add(l),nr({store:e,resume:!0,context:{...o,definition:n,target:a.target,instanceKey:t,instance:a}}))}},[i,t,a,n,r,e,o]),B(z,{children:t.map(e=>e.render?B(ye,{children:e.render({...o,definition:e})},e.id):null)})}function Ro(){let e=J(e=>e.definitions),t=J(e=>e.instances),n=Fo(),r=ko(),i=L(new Set),a=I(()=>new Map(e.map(e=>[e.id,e])),[e]);return P(()=>{for(let e of Object.values(t)){let t=Ao(e);if(!t||i.current.has(t))continue;let o=a.get(e.actionId);if(!o)continue;let s={...n,definition:o,target:e.target,instanceKey:e.id,instance:e},c=jo(o,e,e.resultsAvailable&&o.onResults?()=>{o.onResults?.(s)}:void 0);c&&(r.add(c),i.current.add(t))}},[a,t,n,r]),null}function zo(e){return e?.status===`preparing`||e?.status===`running`}function Bo(e){return!e||e.status===`idle`?``:e.status===`error`?e.error?.message||e.statusText||`Error`:e.status===`complete`&&e.resultsAvailable?`Results ready`:e.status===`cancelled`?`Cancelled`:e.statusText||e.status}function Vo(e){return e?new Date(e).toLocaleString():`Not recorded`}function Ho(e){return e?new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}):`--:--:--`}function Uo(e){if(!e.startedAt)return`Not recorded`;let t=e.completedAt||Date.now(),n=Math.max(0,Math.round((t-e.startedAt)/1e3)),r=Math.floor(n/60),i=n%60;return r?`${r}m ${i}s`:`${i}s`}function Wo(e){if(e===void 0)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Go({label:e,value:t}){return V(`div`,{className:`min-w-0`,children:[B(`dt`,{className:`text-[10px] font-semibold uppercase tracking-widest text-zinc-400`,children:e}),B(`dd`,{className:`mt-1 break-words text-sm text-zinc-800`,children:t})]})}const Ko={debug:{label:`DBG`,className:`text-zinc-500`},verbose:{label:`VRB`,className:`text-zinc-500`},info:{label:`INF`,className:`text-sky-400`},log:{label:`LOG`,className:`text-zinc-300`},warn:{label:`WRN`,className:`text-amber-400`},warning:{label:`WRN`,className:`text-amber-400`},error:{label:`ERR`,className:`text-red-400`}};function qo(e){return Ko[e?.toLowerCase()]??{label:e?.toUpperCase().slice(0,3)??`LOG`,className:`text-zinc-300`}}const Jo={error:`bg-red-100 text-red-700`,failed:`bg-red-100 text-red-700`,completed:`bg-green-100 text-green-700`,success:`bg-green-100 text-green-700`,started:`bg-sky-100 text-sky-700`,cancelled:`bg-zinc-100 text-zinc-600`,warning:`bg-amber-100 text-amber-700`,warn:`bg-amber-100 text-amber-700`};function Yo(e){return Jo[e?.toLowerCase()]??`bg-zinc-100 text-zinc-600`}function Xo(e){return e?.toLowerCase()in Jo}function Zo({definition:e,instance:t,onClose:n}){let[r,i]=R(`overview`),a=L(null),o=t.logs.length;P(()=>{r===`logs`&&a.current?.scrollIntoView({behavior:`instant`})},[r]);let s={idle:`bg-zinc-100 text-zinc-600`,preparing:`bg-orange-100 text-orange-700`,running:`bg-orange-100 text-orange-700`,complete:`bg-green-100 text-green-700`,error:`bg-red-100 text-red-700`,cancelled:`bg-zinc-100 text-zinc-500`},c=t.events.filter(e=>Xo(e.type)),l=[{id:`overview`,label:`Overview`},{id:`logs`,label:`Logs`,count:o}];return V(ee,{title:t.label||e.label,onClose:n,className:`max-w-3xl`,children:[B(`div`,{className:`sticky top-0 z-10 border-b border-zinc-200 bg-white px-2`,children:B(`div`,{className:`flex gap-0.5`,children:l.map(e=>V(`button`,{type:`button`,onClick:()=>i(e.id),className:[`flex items-center gap-1.5 border-b-2 px-3 py-2.5 text-sm transition-colors -mb-px`,r===e.id?`border-me-primary-500 font-semibold text-me-primary-600`:`border-transparent text-zinc-500 hover:text-zinc-800`].join(` `),children:[e.label,e.count?B(`span`,{className:`rounded-full bg-zinc-100 px-1.5 py-0.5 text-[10px] font-medium text-zinc-500`,children:e.count}):null]},e.id))})}),r===`overview`&&V(`div`,{className:`flex flex-col gap-5 p-5`,children:[V(`div`,{className:`flex flex-wrap items-center gap-2`,children:[B(`span`,{className:[`inline-flex items-center gap-1.5 rounded-full px-3 py-1 text-xs font-semibold uppercase tracking-wide`,s[t.status]??`bg-zinc-100 text-zinc-600`].join(` `),children:t.status}),t.statusText?B(`span`,{className:`text-sm text-zinc-500`,children:t.statusText}):null]}),V(`dl`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[B(Go,{label:`Target`,value:`${t.target.label} (${t.target.type})`}),B(Go,{label:`Run ID`,value:t.runId}),B(Go,{label:`Started`,value:Vo(t.startedAt)}),B(Go,{label:`Finished`,value:Vo(t.completedAt)}),B(Go,{label:`Duration`,value:Uo(t)}),t.progress?B(Go,{label:`Progress`,value:`${Math.round(t.progress.percent)}%${t.progress.label?` — ${t.progress.label}`:``}`}):null]}),t.progress?V(`div`,{children:[B(d,{percent:t.progress.percent,label:t.progress.label||`Background action progress`}),typeof t.progress.current==`number`&&typeof t.progress.total==`number`?V(`div`,{className:`mt-1 text-xs text-zinc-500`,children:[t.progress.current,` of `,t.progress.total,` items`]}):null]}):null,t.error?V(`div`,{className:`rounded-lg border border-red-200 bg-red-50`,children:[B(`div`,{className:`border-b border-red-200 px-4 py-2.5`,children:B(`span`,{className:`text-xs font-semibold uppercase tracking-widest text-red-600`,children:`Error`})}),V(`div`,{className:`p-4`,children:[B(`div`,{className:`text-sm font-medium text-red-800`,children:t.error.message}),t.error.stack?B(`pre`,{className:`mt-3 max-h-40 overflow-auto rounded bg-red-100 p-3 text-xs text-red-700 leading-relaxed whitespace-pre-wrap`,children:t.error.stack}):null]})]}):null,c.length>0?V(`div`,{children:[B(`h3`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-widest text-zinc-400`,children:`Key events`}),B(`div`,{className:`divide-y divide-zinc-100 rounded-lg border border-zinc-200`,children:c.map(e=>V(`div`,{className:`flex items-baseline gap-3 px-3 py-2`,children:[B(`span`,{className:[`shrink-0 rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide`,Yo(e.type)].join(` `),children:e.type}),B(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-700`,children:e.message||e.type}),B(`time`,{className:`shrink-0 text-xs text-zinc-400`,children:Ho(e.createdAt)})]},e.id))})]}):null]}),r===`logs`&&B(`div`,{className:`p-5`,children:o===0?B(`div`,{className:`rounded-lg border border-zinc-200 p-6 text-center text-sm text-zinc-400`,children:`No logs recorded.`}):V(`div`,{className:`overflow-hidden rounded-lg bg-zinc-950 shadow-inner`,children:[V(`div`,{className:`flex items-center gap-1.5 border-b border-white/10 px-3 py-2`,children:[B(`div`,{className:`h-2.5 w-2.5 rounded-full bg-zinc-700`}),B(`div`,{className:`h-2.5 w-2.5 rounded-full bg-zinc-700`}),B(`div`,{className:`h-2.5 w-2.5 rounded-full bg-zinc-700`}),V(`span`,{className:`ml-2 text-[10px] text-zinc-500 font-mono`,children:[o,` `,o===1?`entry`:`entries`]})]}),V(`div`,{className:`max-h-[50vh] overflow-y-auto p-1 font-mono text-xs`,children:[t.logs.map(e=>{let t=qo(e.level);return V(`div`,{className:`group flex gap-0 hover:bg-white/5 rounded px-2 py-1 leading-relaxed`,children:[B(`time`,{className:`w-20 shrink-0 text-zinc-600 select-none pr-2`,children:Ho(e.createdAt)}),B(`span`,{className:[`w-10 shrink-0 select-none font-bold pr-2`,t.className].join(` `),children:t.label}),V(`span`,{className:`min-w-0 flex-1 text-zinc-200 break-words`,children:[e.message,e.data===void 0?null:B(`span`,{className:`block mt-0.5 text-zinc-500 whitespace-pre-wrap`,children:Wo(e.data)})]})]},e.id)}),B(`div`,{ref:a})]})]})})]})}function Qo(){let e=ur(),t=Io(),[n,g]=R(null),_=t.reduce((e,t)=>e+t.actions.length,0),v=t.reduce((e,t)=>e+t.actions.filter(e=>zo(e.instance)).length,0),y=t.reduce((e,t)=>e+t.actions.filter(e=>e.instance?.status===`error`).length,0),{isOpen:b,buttonProps:x,itemProps:S,setIsOpen:C}=Ri(_);if(!_)return null;let w=n?t.flatMap(e=>e.actions).find(e=>e.instanceKey===n):void 0,T=0;return V(f,{children:[B(r,{active:b,runningCount:v,errorCount:y,"aria-label":`Actions menu`,...x}),B(u,{open:b,role:`menu`,"aria-hidden":!b,inert:!b,children:B(`div`,{className:`py-1.5`,children:t.map((t,n)=>V(ye,{children:[n?B(i,{}):null,B(p,{children:t.label}),t.actions.map(t=>{let{onKeyDown:n,...r}=S[T++]||{},i=Bo(t.instance),u=zo(t.instance),f=()=>{u||(nr({store:e,context:t.context}),C(!0))},p=()=>{u&&(e.getState().cancelAction(t.instanceKey),C(!0))};return V(s,{status:t.instance?.status||`idle`,children:[B(h,{running:u,...r,"aria-label":u?`Cancel ${t.definition.label}`:`Run ${t.definition.label}`,onMouseDown:e=>{e.preventDefault()},onClick:e=>{e.stopPropagation(),u?p():f()},onKeyDown:e=>{e.key===`Enter`||e.key===` `?(e.preventDefault(),e.stopPropagation(),u?p():f()):n?.(e)},children:V(m,{children:[B(c,{running:u,children:t.instance?.label||t.definition.label}),i?B(l,{variant:t.instance?.status===`error`?`error`:`default`,children:i}):null,t.definition.summary&&!i?B(l,{children:t.definition.summary}):null,u&&t.instance?.progress?B(d,{percent:t.instance.progress.percent,label:t.instance.progress.label||i||t.definition.label}):null]})}),t.instance?.resultsAvailable&&t.definition.onResults?B(o,{onClick:e=>{e.stopPropagation(),t.definition.onResults?.(t.context)},children:`Results`}):null,t.instance?B(a,{"aria-label":`View ${t.definition.label} details`,onClick:e=>{e.preventDefault(),e.stopPropagation(),g(t.instanceKey),C(!0)}}):null]},t.instanceKey)})]},t.id))})}),w?.instance?B(Zo,{definition:w.definition,instance:w.instance,onClose:()=>g(null)}):null]})}const $o=new Set([`fullpage`,`slideshow`,`scroll`]);function es(e,t){return[...e.filter(e=>!e.startsWith(`template-`)&&!$o.has(e)),t.type,`template-${t.id}`]}function ts(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 ns(e,t,n=[]){return ts(e,n)||e.find(e=>e.id===t)||e[0]||null}const rs=`manifest-editor:preset-onboarding:open`;function is(e){return typeof window<`u`&&window.localStorage.getItem(e)===`true`}function as(e){typeof window<`u`&&window.localStorage.setItem(e,`true`)}function os(e,t){return e.mode===`global`||!t?`preset-onboarding/${e.id}`:`preset-onboarding/${e.id}/${t.type}/${t.id}`}function ss(){let e=Y(),t=Hi(),n=e.preset?.onboarding,r=n?os(n,t):null;return()=>window.dispatchEvent(new CustomEvent(rs,{detail:r}))}function cs({className:t}){let n=Y().preset?.onboarding,r=ss();return n?B(e,{className:t,onPress:r,children:n.openLabel||`Open guide`}):null}function ls(e){let t=Y(),n=Hi(),{state:r,setState:i}=Si(),a=t.preset?.onboarding,o=t.preset?.onboarding?.renderPreviewButton,s=a?os(a,n):null,c=!!s&&r?.presetOnboardingPreviewHintKey===s;return o?o({...e,preview:t.preset?.preview,showOnboardingPreviewHint:c,onOnboardingPreviewHintClose:()=>{c&&i({presetOnboardingPreviewHintKey:null})}}):B(ya,{...e,preview:t.preset?.preview})}function us(){let t=Y(),n=Hi(),r=t.preset?.onboarding,{setState:i}=Si(),a=wi(),o=Ue(),s=H(),c=o?.behavior||[],l=ts(a.templates,c),u=ns(a.templates,a.selectedTemplateId,c),d=L(u?.id||null);d.current=u?.id||null;let f=I(()=>r?os(r,n):null,[r,n]),[p,m]=R(!1),[h,g]=R(!1);if(P(()=>{if(!f)return;let e=!l&&!is(f);m(e),g(e)},[l,f]),P(()=>{let e=e=>{e.detail===f&&(i({presetOnboardingPreviewHintKey:null}),m(!!r),g(!1))};return window.addEventListener(rs,e),()=>window.removeEventListener(rs,e)},[f,r,i]),!r||!f)return null;let _=()=>{a.setSelectedTemplateId(ns(a.templates,d.current)?.id||null),as(f),h&&i({presetOnboardingPreviewHintKey:f}),m(!1),g(!1)},v=e=>{d.current=e,a.setSelectedTemplateId(e);let t=a.templates.find(t=>t.id===e);if(!o||!t)return;let n=o.behavior||[],r=es(n,t);r.length===n.length&&r.every((e,t)=>e===n[t])||s.modifyEntityField(o,`behavior`,r)};return B(ee,{title:r.title,open:p,onClose:_,actions:V(`div`,{className:`flex gap-2`,children:[B(e,{onPress:_,children:r.dismissLabel||`Dismiss`}),u?B(e,{primary:!0,onPress:()=>{v(d.current),_()},children:r.primaryLabel||`Continue`}):null]}),children:V(`div`,{className:`flex flex-col gap-4 p-6`,children:[r.summary?B(`p`,{className:`text-sm text-gray-600`,children:r.summary}):null,r.renderBody({...a,selectedTemplateId:u?.id||null,selectedTemplate:u,setSelectedTemplateId:v,dismiss:_})]})})}const ds=we(function(e){let[t]=me(`menu-hidden`);return B(Mi,{children:V(ji,{children:[B(Ni,{onClick:e.onClickLogo,children:B(E,{})}),B(ya,{}),B(cs,{}),B(Qo,{})]})})}),fs=j(null);function ps(){return N(fs)||null}function ms(e,t){let n=ps();return n?n[e][t]:null}function hs({children:e,menu:t}){return B(fs.Provider,{value:t,children:e})}function gs(){return N(Ne)}function _s(e){if(!e)return null;if(e.points.length>2){let t=Math.min(...e.points.map(e=>e[0])),n=Math.min(...e.points.map(e=>e[1])),r=Math.max(0,...e.points.map(e=>e[0])),i=Math.max(0,...e.points.map(e=>e[1]));return{x:t,y:n,width:r-t,height:i-n}}return null}const vs=async e=>new Promise((t,n)=>{let r=document.createElement(`img`);r.onload=()=>t(r),r.onerror=()=>n(),r.src=e,r.complete&&t(r)}),ys=async e=>new Promise((t,n)=>{let r=document.createElement(`video`);r.onloadedmetadata=()=>t(r),r.onerror=()=>n(),r.preload=`metadata`,r.src=e});async function bs(){}async function xs(e,...t){if(!e)return;if(e.endsWith(`.mp3`)||e.endsWith(`.mp4`)||e.endsWith(`.m4a`)||e.endsWith(`.m4v`))try{let t=await ys(e);if(t){let n=t.videoWidth===0;return{id:e,type:t.videoWidth===0?`Sound`:`Video`,width:t.videoWidth||void 0,height:t.videoHeight||void 0,duration:t.duration,format:n?`audio/mp4`:`video/mp4`}}}catch{}let n=null;try{n=await fetch(e)}catch{return ws(e)}if(!n.ok&&(n=await fetch(e+`/info.json`),!n.ok))return ws(e);let r=n.headers.get(`Content-Type`);if(r?.includes(`image/`))return ws(e,r);let i=null;try{i=await n.json()}catch{return null}return await Cs(i,e)}function Ss(e){return e.protocol&&e.protocol===`http://iiif.io/api/image`?(e.type||(e.type=`ImageService`),e):null}async function Cs(e,t){let n=Ss(e);if(n)return n;if(!(e.id||e[`@id`]))return null;let r=await new et.Vault().load(t,e);if(r&&(r&&r?.type===`Manifest`||r?.type===`Collection`))return{id:t,type:r.type,label:$e(r.label)}}async function ws(e,t){let n=e.split(`/`);if(n.length>=8){let e=n.slice(-4);if(e[3].split(`.`).length===2&&(e[2][0]===`!`||e[2]===e[2])){let e=await Ts(n.slice(0,n.length-4).join(`/`)+`/info.json`);if(e&&e?.type&&e?.type?.startsWith(`ImageService`))return e}}try{let n=await vs(e);return{id:e,type:`Image`,width:n.width,height:n.height,format:await Es(e,t)}}catch{}return null}async function Ts(e){try{let t=await fetch(e);return t.ok?await Cs(await t.json(),e):null}catch(e){return console.log(e),null}}async function Es(e,t){if(t)return t;try{let t=(await fetch(e,{method:`HEAD`,mode:`no-cors`})).headers.get(`Content-type`);if(t)return t}catch{}let n=e.toLowerCase();return n.endsWith(`jpg`)||n.endsWith(`jpeg`)?`image/jpeg`:n.endsWith(`png`)?`image/png`:`image/jpeg`}async function Ds(e){try{let t=await vs(e);if(t)return{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}}catch{return null}return null}const Os=De(e=>({regions:{},resources:[],setRegion:(t,n)=>{e(e=>({...e.regions,regions:{[t]:n||null}}))},setHighlight:t=>{e({resources:Array.isArray(t)?t:[t]})},highlight:t=>{e(e=>e.resources.indexOf(t)===-1?{resources:[...e.resources,t]}:e)},clearHighlight:t=>{e(e=>({resources:e.resources.filter(e=>e!==t)}))}}));function ks(e){let t=I(()=>_r(),[]),n=Os(e=>e.regions[t]),r=Os(e=>e.setRegion);P(()=>{n&&e?n!==e&&(n.x!==e.x||n.y!==e.y||n.width!==e.width||n.height!==e.height)&&r(t,e||null):r(t,e||null)},[n]),P(()=>()=>r(t,null),[])}function As(e){let t=Os(e=>e.highlight),n=Os(e=>e.clearHighlight);return P(()=>()=>{e&&n(e)},[n,e]),I(()=>({onMouseEnter(){e&&t(e)},onMouseLeave(){e&&n(e)}}),[e,t,n])}const js=U.div`
243
243
  position: relative;
244
244
  display: inline-block;
245
245
  `;U.div`
@@ -441,13 +441,13 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
441
441
  > * {
442
442
  min-width: 0;
443
443
  }
444
- `;function Xs({panel:e,state:t,actions:n,isLeft:r,pinActions:i=n,transition:a,close:o,available:s=[],style:c,noHeader:l,isModal:u}){let d=N(Le)||null,[f,p]=R(!1),m=Ci(),h=Ya(),{tabs:g,pinnable:_,hideHeader:v}=e?.options||{},y=I(()=>(s||[]).filter(e=>!e.requiresState),[s]),{itemProps:b,isOpen:x,setIsOpen:S}=zi(y.length),[C,w]=R(``),T=L(void 0);P(()=>p(!1),[m.state.canvasId,e?.id]),P(()=>w(``),[e]),P(()=>(T.current=w,()=>{T.current=void 0}),[]);let E=M(e=>{T.current&&T.current(e)},[]),ee=M(r=>{let i=e?t.stack.length?n.popStack:e.backAction?()=>e&&e.backAction&&e.backAction(t,{...h,current:n},m):null:null;r&&(!i||r.metaKey)&&y.length?(r.preventDefault(),S(!0)):i?.()},[n,m,h,e,S,t,y.length]),D=r=>{n.change({id:r.id,state:r.defaultState,stacked:!!(t.stack.length||e?.backAction)})};if(!e||!t.current)return null;let O=e.backAction||t.stack.length?B(Ks,{"aria-label":`Back`,onClick:ee,children:B(Is,{"aria-hidden":`true`})}):null,k=B(Ks,{"aria-label":`Close panel`,onClick:o||n.close,children:B(Fi,{"aria-hidden":`true`})});return B(Hs.Provider,{value:E,children:V(Ws,{"data-modal":u,"data-state":a,"data-flipped":r,style:c,"data-header":!l,children:[l?null:V(Gs,{"data-tabs":!!g,"data-error":f,children:[V(js,{style:{display:`flex`,height:`100%`},children:[e.renderBackAction?e.renderBackAction({backAction:ee,fallback:O}):O,y.length?V(Ns,{$open:x,role:`menu`,style:{left:`0.5em`},children:[B(Ps,{children:`All panels`}),B(Fs,{}),y.map((t,n)=>B(Ms,{...b[n],onClick:()=>D(t),$active:e.id===t.id,children:t.label},n))]}):null]}),C?B(Js,{as:r?`h1`:`h2`,children:C}):v?B(qs,{}):B(Js,{as:r?`h1`:`h2`,children:e.label}),_?t.pinned?B(Ks,{"aria-label":`Unpin panel`,onClick:i.unpin,children:B(Ls,{"aria-hidden":`true`,fill:`orange`})}):B(Ks,{"aria-label":`Pin panel`,onClick:()=>i.pin({id:e.id,state:t.state}),children:B(Ls,{"aria-hidden":`true`,fill:`#ddd`})}):null,e.renderCloseAction?e.renderCloseAction({closeAction:o||n.close,fallback:k}):k]}),B(Ys,{className:`OverrideScrollbar`,children:B(at,{onError:()=>p(!0),FallbackComponent:Vs,resetKeys:[m.state.canvasId,e?.id],onReset:()=>p(!1),children:Bs(e.render(t.state||e.defaultState||{},{...h,current:n,vault:d,transition:a,isModal:u},m))})})]})})}function Zs(e=`vault://homepage-collection.json`){let t=new tt,n=window.localStorage.getItem(`preview-vault-collection`),r=!1;if(n)try{let i=JSON.parse(n);if(i.id&&i.id===e){t.dispatch(ut({id:i.id}));let e=dt(i.id,i);t.dispatch(st({actions:e})),r=!0}}catch{}if(!r){let n=dt(e,{"@context":`http://iiif.io/api/presentation/3/context.json`,id:e,type:`Collection`,label:{en:[`Recent items`]},items:[]});t.dispatch(ut({id:e})),t.dispatch(st({actions:n}))}return t.on(`after:@iiif/REMOVE_REFERENCE`,n=>{n.action.payload.id===e&&window.localStorage.setItem(`preview-vault-collection`,JSON.stringify(t.toPresentation3({id:e,type:`Collection`})))}),{vault:t,unsubscribe:()=>{},addHistory:(n,r)=>{let i=t.getState();if(n&&r&&(r===`Collection`||r===`Manifest`)){let a=i.iiif.entities.Collection[e];if(a){let i=a.items.findIndex(e=>e.id===n);i===-1?t.dispatch(ot({id:e,type:`Collection`,reference:{id:n,type:r},key:`items`,index:0})):t.dispatch(lt({id:e,type:`Collection`,key:`items`,startIndex:i,endIndex:0})),window.localStorage.setItem(`preview-vault-collection`,JSON.stringify(t.toPresentation3({id:e,type:`Collection`})))}}},clearHistory:()=>{t.dispatch(ct({id:e,type:`Collection`,key:`items`,value:[]})),window.localStorage.setItem(`preview-vault-collection`,JSON.stringify(t.toPresentation3({id:e,type:`Collection`})))}}}function Qs(){return N($s)}const $s=j(new tt),ec=j({addHistory:(e,t)=>{},clearHistory:()=>{}}),tc=`manifest-editor://homepage-collection.json`;function nc(){return N(ec)}function rc(e){let{vault:t,unsubscribe:n,addHistory:r,clearHistory:i}=I(()=>Zs(tc),[]);return P(()=>n,[]),B(ec.Provider,{value:{addHistory:r,clearHistory:i},children:B($s.Provider,{value:t,children:e.children})})}function ic({children:e}){let t=Qs();return B(ze,{vault:t,children:e})}function ac(e,t,n,r,i){let a=H(),o=J(),{create:s,edit:c}=Ka(),l=I(()=>it({type:n,parent:e,index:0,property:t},o.layout.creators||[],{vault:a}),[e,t,o.layout.creators,n,a]),u=e&&l.length!==0,d=M((a,o)=>{if(e)return s({type:n,parent:qe(e),property:t,index:a,target:r,initialData:o,...i||{}})},[s,e,t,n,i,r]),f=M((a,o,c)=>{if(e)return s({type:n,filter:a,parent:qe(e),property:t,index:o,target:r,initialData:c,...i||{}})},[s,e,t,n,i,r]);return[u,{create:d,edit:M((n,r)=>{c(n,e?{parent:qe(e),property:t,index:r}:void 0)},[c,e,t]),createFiltered:f,creator:M((a,o)=>{if(e)return s({type:n,initialCreator:a,parent:qe(e),property:t,target:r,initialData:o,...i||{}})},[n,t,e,r,s,i]),buttonProps:I(()=>({"data-action-id":hr(n,t,e)}),[n,t,e])}]}function oc(){let e=H(),t=Qs(),n=J(),r=It();return I(()=>new nt(e,n.layout.creators||[],t,r.creators),[n.layout.creators,r.creators,t,e])}async function sc(e){let t=await e.create(),n=Array.isArray(t)?t[0]:t;return n?(e.onCreate?.(),e.close?.(),e.edit?.(n),!0):!1}const cc=j({});function lc(e){return N(cc)[e]||{}}function uc(e){let t=N(cc),n=I(()=>({...t,[e.id]:e.data}),[t,e.id,e.data]);return B(cc.Provider,{value:n,children:e.children})}const dc=we(function(t){let n=H(),{edit:r,modal:i}=Ka(),[a,o]=R(!1),[s,c]=R(null),l=oc(),u=It(),d=L(!1),f=t.resource.initialData?.selector;ks(f);let p=lc(t.creator.id),m={targetType:t.resource.type,parent:t.resource.parent?{property:t.resource.property,atIndex:t.resource.index,resource:t.resource.parent}:void 0,target:t.resource.target,initialData:{...p,...t.resource.initialData||{},...t.initialData||{}}},h=async e=>{if(!(a||d.current)){o(!0),d.current=!0;try{await sc({create:()=>l.create(t.creator.id,e,m),onCreate:t.onCreate,close:t.skipEditingOnCreate?void 0:()=>{i.popStack(),i.close()},edit:t.skipEditingOnCreate||t.resource.initialData?.skipEditingOnCreate?void 0:e=>r(e,{parent:qe(t.resource.parent),property:t.resource.property,index:t.resource.index})})}catch(e){c(e?.message||`Unknown error`)}finally{o(!1),d.current=!1}}},g=async()=>!0;if(P(()=>{t.resource.initialData?.showEmptyForm||!t.creator.render&&!a&&h({})},[t.creator]),s)return B(`div`,{className:`flex flex-col items-center p-4`,children:B(x,{children:s})});let _=B(`div`,{className:`flex flex-col items-center py-8`,children:V(`div`,{className:`flex gap-2 items-center`,children:[B(A,{}),` `,B(`span`,{children:`Loading`})]})});return a?_:t.creator.render?B(z,{children:B(be,{fallback:_,children:t.creator.render({vault:n,runCreate:h,validate:g,options:m,config:u.creators?.[rt(t.creator)]||{}})})}):V(z,{children:[B(b,{children:`No options available`}),B(e,{primary:!0,onPress:()=>h({}),children:t.creator.actionButton||`Create`})]})});function fc(t){let n=J(),r=H(),[i,a]=R(t.resource.initialCreator||``),[o,s]=R(),[c,l]=R(``),[u,d]=R(!1),[f,p]=R(``),[m,h]=R(null),g=L(null),v=Us(),y=I(()=>it(t.resource,n.layout.creators||[],{vault:r}),[t.resource,n.layout.creators,r]),x=y.some(e=>e.supportsResource);P(()=>{y.length===1&&!i&&!x&&a(y[0].id)},[x,i,y]),P(()=>{x&&!i&&g.current?.focus()},[x,i]);let S=y.find(e=>e.id===i);if(P(()=>{S&&v?.(S.label)}),y.length===0)return B(b,{children:`Not currently supported`});let T=(e,t)=>{s(t||gc(c)),a(e.id)},E=async e=>{e.preventDefault();let n=c.trim();if(!n||u)return;d(!0),p(``),h(null);let i=_c(),a=await Promise.all(y.map(async e=>{if(!e.supportsResource)return null;try{let a=await e.supportsResource(n,i,{vault:r,resource:t.resource});return a?{creator:e,initialData:hc(n,a).initialData}:null}catch(t){return{creator:e,error:t?.message||`Could not check this link`}}})),o=a.filter(pc),s=a.filter(mc);if(d(!1),o.length===1){T(o[0].creator,o[0].initialData);return}if(o.length>1){h(o),p(`Multiple creators can use this link. Choose one below.`);return}p(s[0]?.error||`No creator recognised this link. Choose one below.`)},ee=B(D,{children:B(w,{root:document.getElementById(`headlessui-portal-root`)||void 0,label:`Back to Add content options`,className:`group`,placement:`right`,onPress:()=>{a(``),s(void 0)},children:B(C,{className:`text-2xl opacity-50 group-hover:opacity-70`})})});if(S)return S.hiddenModal?V(z,{children:[ee,B(dc,{creator:S,resource:t.resource,initialData:o})]}):V(`div`,{children:[ee,B(`div`,{className:`p-2 py-6`,children:B(dc,{creator:S,resource:t.resource,initialData:o})})]});let O=m?.length?m.map(e=>e.creator):y,k=new Map(m?.map(e=>[e.creator.id,e.initialData]));return V(z,{children:[x?V(`form`,{className:`p-4 pb-0`,onSubmit:E,children:[B(`label`,{className:`block text-sm font-medium text-gray-700`,htmlFor:`creator-resource-link`,children:`Paste a link`}),V(`div`,{className:`mt-1 flex gap-2`,children:[B(`input`,{ref:g,id:`creator-resource-link`,className:`min-w-0 flex-1 rounded border border-gray-300 px-3 py-2 text-sm`,value:c,onChange:e=>{l(e.currentTarget.value),p(``),h(null)},placeholder:`https://example.org/resource`,type:`url`}),B(e,{primary:!0,type:`submit`,isDisabled:!c.trim()||u,children:u?`Checking`:`Use link`})]}),f?B(`div`,{className:`mt-2 text-sm text-gray-600`,role:`status`,children:f}):null]}):null,B(_,{label:`Select a type`,items:O.map(e=>({id:e.id,title:e.label,description:e.summary||``,icon:e.icon,onClick:()=>T(e,k.get(e.id))}))})]})}function pc(e){return!!e&&!(`error`in e)}function mc(e){return!!e&&`error`in e}function hc(e,t){return typeof t==`object`?t:{initialData:gc(e)}}function gc(e){let t=e.trim();return t?{url:t,youtubeUrl:t}:void 0}function _c(){let e=new Map,t=new Map,n=new Map,r=t=>(e.has(t)||e.set(t,fetch(t).then(e=>{if(!e.ok)throw Error(`Could not load ${t}`);return e.text()})),e.get(t)),i=e=>(n.has(e)||n.set(e,fetch(e,{method:`HEAD`}).then(t=>{if(!t.ok)throw Error(`Could not check ${e}`);return t})),n.get(e));return{text:r,head:i,json(e){return t.has(e)||t.set(e,r(e).then(e=>JSON.parse(e))),t.get(e)},async contentType(e){return(await i(e)).headers.get(`content-type`)||``}}}const vc={id:`@manifest-editor/creator`,label:`Add content`,options:{hideHeader:!0,tabs:!1},render(e){return B(fc,{resource:e})}},yc={color:{main:`#B84C74`,mainHover:`#4a89ff`,logoPink:`#E94581`,white:`white`,grey:`grey`,black:`black`,lightgrey:`#F8F9FA`,mediumgrey:`#dddddd`,danger:`#a90e21`,warning:`#e38627`,lightdanger:`#ffeaea`,lightsuccess:`#c5e8c5`,success:`#6ccd55`,greyOverlay:`rgba(0, 0, 0, 0.2)`,highlight:`#faeed7`},iiifColor:{manifest:`rgba(0, 0, 0, 0.2)`,canvas:`rgba(255, 222, 219, 0.8)`,service:`rgba(13, 110, 253, 0.8)`,annotation:`rgba(247, 226, 173, 0.8)`,contentResource:`rgba(207, 247, 255, 0.8)`,ranges:`rgba(144, 213, 157, 0.8)`},padding:{xs:`0.25rem`,small:`0.5rem`,medium:`1rem`,large:`2rem`},device:{mobile:`375px`,tablet:`768px`,laptop:`992px`,desktop:`1200px`},shadows:{standard:`rgba(0, 0, 0, 0.1) 0px 1px 3px 0px, rgba(0, 0, 0, 0.05) 0px 5px 15px 0px`,bottom:`rgba(0, 0, 0, 0.1) 0px 4px 2px -2px`}};function bc(e){let{}=e,t=H(),n=J(),r=I(()=>it(e.resource,n.layout.creators||[],{vault:t}),[e.resource,n.layout.creators,t]);return r.length===0?B(`div`,{children:`No supported creators found`}):B(`div`,{children:V(ue,{className:`w-full flex-1 overflow-hidden flex flex-col`,children:[B(ce,{className:`flex-1 overflow-hidden w-full flex text-sm whitespace-nowrap`,items:r,children:e=>B(se,{id:e.id,children:e.label})}),r.map(t=>B(le,{id:t.id,className:`p-2`,children:B(Je,{theme:yc,children:B(dc,{creator:t,resource:e.resource,onCreate:e.onCreate,skipEditingOnCreate:!0})})},t.id))]})})}function xc({fallback:e,backAction:t}){let n=Ma(),{back:r}=Aa();return n.length?B(Ks,{"aria-label":`Back`,onClick:r,children:B(Is,{"aria-hidden":`true`})}):e}function Sc({closeAction:e,fallback:t}){let n=Ma();return ja()||n.length?B(Ks,{"aria-label":`Close panel`,onClick:()=>{e()},children:B(Fi,{"aria-hidden":`true`})}):t}function Cc(e,t,n,r){let i=t.filter(t=>t.resourceType===e.resource.source.type);if(i.length===0)return null;for(let t of i){let i=[],a={},o=e.property===`partOf`,s=(t.editors||[]).filter(t=>{if(o&&t.id!==`@manifest-editor/part-of-reference`||r.hideTabs&&r.hideTabs.includes(t.id)||r.onlyTabs&&!r.onlyTabs.includes(t.id))return!1;if(t.supports.sortKey){if(i.includes(t.supports.sortKey))return!1;t.supports.sortFallback&&(a[t.supports.sortKey]=t)}return n.edit&&!t.supports.edit||t.supports.custom&&t.supports.custom(e,n.vault)===!1?!1:(t.supports.sortKey&&i.push(t.supports.sortKey),!0)}),c=Object.keys(a);for(let e of c)!i.includes(e)&&a[e]&&!s.includes(a[e])&&s.push(a[e]);if(s.length)return{...t,editors:s}}return null}function wc({currentTab:e=void 0}){let t=ja(),n=N(Re),r=J(),i=Y(),a=H(),{change:o}=Ka(),s=Us(),{editorConfig:c}=It(),l=t?.resource.source?.id,u=t?.resource.source?.type,d=l!==i.id;l&&d&&i.type===`Collection`&&u===`Collection`&&(u=`EmbeddedCollection`);let f=(u?c[u]:c.All)||{},p=I(()=>{let e={...n},r=t?.resource.source.id,i=t?.resource.source.type,a={Collection:`collection`,Manifest:`manifest`,Range:`range`,Canvas:`canvas`,Annotation:`annotation`,AnnotationPage:`annotationPage`};return i&&a[i]&&(e[a[i]]=r),e},[t,n]);function m(e){return t?B(Re.Provider,{value:p,children:e}):e}let h=I(()=>{if(!t)return null;let e=r.layout.editors||[],n=(r.layout.resources||[]).map(t=>typeof t==`string`?{id:`@default/`+t,label:t,resourceType:t,auto:!0,editors:e.filter(e=>e.supports.resourceTypes.includes(t))}:t);return Cc(t,n,{edit:!0,vault:a},f)},[t,r]);P(()=>{s(h?.label||``)},[h]),P(()=>{let t=h?.editors.map(e=>e.id)||[];t.find(t=>t===e)||o(`@manifest-editor/editor`,{currentTab:t[0]})},[h?.editors,e,o]);let g=I(()=>(h?.editors||[]).map(e=>({id:e.id,label:e.label,renderComponent:()=>e.component(f)})),[h?.editors,f]);if(!t||!h)return null;if(f.singleTab){let e=(h?.editors||[]).find(e=>e.id===f.singleTab);if(e)return m(B(`div`,{className:`w-full`,children:e.component(f)},t.resource.source?.id))}return m(B(oe,{isNested:d,rootResource:i,menuId:t.resource.source.id,menu:g,selectedKey:e,onSelectionChange:e=>{o(`@manifest-editor/editor`,{currentTab:e})}},t.resource.source?.id))}const Tc={id:`@manifest-editor/editor`,label:`Editor`,options:{hideHeader:!0,tabs:!0,minWidth:400},renderBackAction:({backAction:e,fallback:t})=>B(xc,{backAction:e,fallback:t}),renderCloseAction:({closeAction:e,fallback:t})=>B(Sc,{closeAction:e,fallback:t}),render({currentTab:e}){return B(wc,{currentTab:e})}};function Ec(e){let[t,n]=R(!1),r=L(null),i=L(0);function a(t){i.current--,!(t&&i.current!==0)&&(r.current&&(clearTimeout(r.current),r.current=0),r.current=setTimeout(()=>{n(!1)},e))}function o(){i.current++,r.current&&clearTimeout(r.current),n(!0)}return I(()=>[t,{set:o,clear:a}],[t])}function Dc(e){return e?typeof e==`string`?{src:e,alt:``}:e:null}function Oc(e){return e?typeof e==`string`?e:e.name:null}function kc(e){let t=e.extension,n=t.leftPanels?.[0]||t.centerPanels?.[0]||t.rightPanels?.[0]||t.modalPanels?.[0];return n?{id:n.id,label:n.label||`Open plugin`,modal:t.modalPanels?.some(e=>e.id===n.id)||!1}:null}function Ac(e){return e instanceof Error?e.message:`Plugin configuration could not be saved.`}function jc(e){return V(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:[B(`path`,{d:`M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z`}),B(`circle`,{cx:`12`,cy:`12`,r:`3`})]})}function Mc(e){return V(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:[B(`path`,{d:`M7 7h10v10`}),B(`path`,{d:`M7 17 17 7`})]})}function Nc(){let e=J(),{appId:t}=Si(),n=It(),r=Lt(),i=ui(),a=fi(),o=Ka(),{saveGlobalPluginConfig:s}=N(ai),[c,l]=R(!1),[u,d]=R(``),[f,p]=R(null),[m,h]=R(null),[_,v]=R(null),y=I(()=>new Set(Wr(i,e,t).map(e=>e.metadata.id)),[i,e,t]),b=I(()=>{let n=u.trim().toLowerCase();return i.plugins.filter(r=>{let i=Br(r,e,t);return!c&&!i?!1:!n||[r.metadata.label,r.metadata.id,r.metadata.description,Oc(r.metadata.author),...r.metadata.tags||[]].filter(Boolean).join(` `).toLowerCase().includes(n)})},[e,t,i.plugins,u,c]),x=f&&i.plugins.find(e=>e.metadata.id===f)||null;if(!i.plugins.length)return null;function S(e){a.setAppConfig(t,e),r({plugins:{...n.plugins||{},apps:{...n.plugins?.apps||{},[t]:e}}})}async function C(e){if(!s){v(`Global plugin settings are not available in this host.`);return}let n=i.globalApps[t]||{},r={apps:{...i.globalApps,[t]:e}};a.setGlobalAppConfig(t,e);try{await s(r)}catch(e){a.setGlobalAppConfig(t,n),v(Ac(e))}}async function w(n,r,a){v(null),h(`${a}:${n.metadata.id}`);let o=a===`global`?i.globalApps[t]||{}:i.apps[t]||{},s=r?Zr(o,i,n,e,t):{config:Ar(o,n.metadata.id),blocked:[]};if(s.blocked.length){h(null),v(`Cannot enable ${n.metadata.label}: ${s.blocked.join(`, `)}.`);return}a===`global`?await C(s.config):S(s.config),h(null)}function T(e){let t=kc(e);if(t){if(t.modal){o.modal.open({id:t.id});return}o.open(t.id)}}return V(`section`,{className:`flex flex-col gap-3 border-t border-gray-200 pt-4 mt-4`,children:[V(`div`,{className:`flex items-center gap-2`,children:[B(`div`,{className:`min-w-0 flex-1`,children:B(`h3`,{className:`font-semibold text-sm text-gray-900`,children:`Plugins`})}),B(`button`,{type:`button`,className:`rounded border border-gray-200 bg-white px-2 py-1 text-xs text-gray-500 hover:text-gray-700 hover:border-gray-300 transition-colors`,onClick:()=>l(e=>!e),children:c?`Compatible only`:`Show all`})]}),B(`input`,{"aria-label":`Search plugins`,className:`rounded border border-gray-200 px-2.5 py-1.5 text-xs focus:border-me-primary-500 focus:ring-2 focus:ring-me-primary-500/20 focus:outline-none`,type:`search`,placeholder:`Search plugins…`,value:u,onChange:e=>d(e.currentTarget.value)}),_?B(`div`,{className:`rounded border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:_}):null,B(`div`,{className:`flex flex-col gap-2`,children:b.map(n=>{let r=Hr(n,i,t),a=y.has(n.metadata.id),o=r&&n.loadStatus===`loading`,s=r&&n.loadStatus===`error`?n.loadError:null,c=Dc(n.metadata.image),l=r&&!a&&!o&&!s,u=Br(n,e,t),d=Vr(n,e,t),f=kc(n),h=!!n.settings,_=m===`workspace:${n.metadata.id}`;return V(`article`,{className:`flex gap-2.5 rounded-lg border bg-white p-3 text-sm transition-colors ${a?`border-gray-200`:`border-gray-100 bg-gray-50`} ${u?``:`bg-gray-100`}`,children:[c?B(`img`,{className:`h-9 w-9 rounded object-cover flex-none mt-0.5`,src:c.src,alt:c.alt||n.metadata.label}):B(`div`,{className:`h-9 w-9 rounded flex items-center justify-center flex-none mt-0.5 text-lg ${a?`bg-me-primary-50 text-me-primary-500`:`bg-gray-100 text-gray-600`}`,children:B(jc,{className:`w-4 h-4`})}),V(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[V(`div`,{className:`flex items-start justify-between gap-1`,children:[V(`div`,{className:`flex flex-wrap items-center gap-1.5 min-w-0`,children:[B(`span`,{className:`font-medium text-gray-900 text-xs`,children:n.metadata.label}),n.metadata.official?V(`span`,{className:`rounded-full text-me-primary-500 px-1.5 py-0 text-[9px] font-bold inline-flex items-center gap-1`,children:[B(g,{className:`w-3 h-3`}),` Verified`]}):null,n.metadata.version?B(`span`,{className:`text-[10px] text-gray-600`,children:n.metadata.version}):null]}),V(`div`,{className:`flex items-center gap-1 flex-none`,children:[h?B(`button`,{type:`button`,title:`Configure plugin`,"aria-label":`Configure ${n.metadata.label}`,className:`rounded p-1 text-gray-600 hover:text-gray-700 hover:bg-gray-100 transition-colors`,onClick:()=>p(n.metadata.id),children:B(jc,{className:`w-3.5 h-3.5`})}):null,a&&f?B(`button`,{type:`button`,title:`Open ${f.label}`,"aria-label":`Open ${f.label}`,className:`rounded p-1 text-me-primary-500 hover:bg-me-primary-50 transition-colors`,onClick:()=>T(n),children:B(Mc,{className:`w-3.5 h-3.5`})}):null,B(`button`,{type:`button`,disabled:!u||_,onClick:()=>w(n,!r,`workspace`),className:`relative inline-flex h-5 w-9 flex-none items-center rounded-full transition-colors disabled:opacity-40 focus:outline-none focus:ring-2 focus:ring-me-primary-500/30 ${r?`bg-me-primary-500`:`bg-gray-200`}`,title:r?`Disable plugin`:`Enable plugin`,"aria-label":`${r?`Disable`:`Enable`} ${n.metadata.label}`,children:B(`span`,{className:`inline-block h-3.5 w-3.5 transform rounded-full bg-white shadow transition-transform ${r?`translate-x-4`:`translate-x-0.5`}`})})]})]}),n.metadata.description?B(`p`,{className:`text-xs text-gray-500 leading-relaxed`,children:n.metadata.description}):null,o?B(`span`,{className:`text-xs text-gray-500`,children:`Loading plugin…`}):null,s?B(`span`,{className:`text-xs text-red-600`,children:s}):null,l?B(`span`,{className:`text-xs text-amber-600`,children:`Waiting for required dependencies`}):null,!u&&d?B(`span`,{className:`text-xs text-gray-600`,children:d}):null]})]},n.metadata.id)})}),b.length?null:B(`div`,{className:`rounded-lg border border-gray-100 bg-gray-50 p-4 text-center text-xs text-gray-500`,children:`No plugins found.`}),x?B(ee,{title:`Configure ${x.metadata.label}`,onClose:()=>p(null),width:`560px`,children:B(Pc,{plugin:x,onClose:()=>p(null),canSaveGlobal:!!s})}):null]})}function Pc({plugin:e,onClose:t,canSaveGlobal:n}){let r=hi(e.metadata.id),[i,a]=R(`workspace`),[o,s]=R({}),[c,l]=R(!1),[u,d]=R(!1),[f,p]=R(null),m=i===`global`?r.global:r.workspace;P(()=>{s({...m}),p(null),d(!1)},[e.metadata.id,i]);async function h(){let t=e.settings?.validate?.(o);if(t){p(t);return}l(!0),p(null);try{i===`global`?await r.setGlobalSettings(o):r.setWorkspaceSettings(o),d(!0),setTimeout(()=>d(!1),2e3)}catch(e){p(Ac(e))}finally{l(!1)}}async function g(){l(!0),p(null);try{i===`global`?await r.resetGlobalSettings():r.resetWorkspaceSettings(),s({})}catch(e){p(Ac(e))}finally{l(!1)}}let _=n&&r.canSaveGlobal;return V(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[_?V(`div`,{className:`flex items-center gap-1 px-5 pt-4 pb-3 border-b border-gray-100`,children:[B(`span`,{className:`text-xs text-gray-500 mr-2`,children:`Scope:`}),B(`button`,{type:`button`,className:`rounded-full px-3 py-1 text-xs font-medium transition-colors ${i===`workspace`?`bg-me-primary-500 text-white`:`bg-gray-100 text-gray-600 hover:bg-gray-200`}`,onClick:()=>a(`workspace`),children:`This workspace`}),B(`button`,{type:`button`,className:`rounded-full px-3 py-1 text-xs font-medium transition-colors ${i===`global`?`bg-me-primary-500 text-white`:`bg-gray-100 text-gray-600 hover:bg-gray-200`}`,onClick:()=>a(`global`),children:`All workspaces`})]}):null,f?B(`div`,{className:`mx-5 mt-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:f}):null,B(`div`,{className:`flex-1 overflow-y-auto p-5`,children:B(`div`,{className:`flex flex-col gap-3`,children:e.settings?.render?e.settings.render({plugin:e,appId:r.appId,scope:i,value:o,defaults:r.defaults,effective:r.effective,onChange:s}):e.settings?.fields?.length?e.settings.fields.map(e=>B(Fc,{field:e,draft:o,setDraft:s},e.id)):B(`div`,{className:`rounded-lg border border-gray-100 bg-gray-50 p-4 text-center text-sm text-gray-500`,children:`This plugin has no configurable settings.`})})}),V(`div`,{className:`flex items-center justify-between gap-3 border-t border-gray-100 px-5 py-4`,children:[B(`button`,{type:`button`,className:`text-xs text-gray-600 hover:text-gray-700 transition-colors disabled:opacity-40`,disabled:c,onClick:g,children:`Reset to defaults`}),V(`div`,{className:`flex items-center gap-2`,children:[u?B(`span`,{className:`text-xs text-green-600`,children:`✓ Saved`}):null,B(`button`,{type:`button`,className:`rounded-lg bg-me-primary-500 px-4 py-2 text-sm font-medium text-white hover:bg-me-primary-600 disabled:opacity-50 transition-colors`,disabled:c,onClick:h,children:c?`Saving…`:`Save ${i}`})]})]})]})}function Fc({field:e,draft:t,setDraft:n}){let r=t[e.id],i=`plugin-setting-${e.id}`;function a(r){n({...t,[e.id]:r})}let o=B(`label`,{className:`text-sm font-medium text-gray-900`,htmlFor:i,children:e.label}),s=`rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm focus:border-me-primary-500 focus:ring-2 focus:ring-me-primary-500/20 focus:outline-none`;return e.type===`boolean`?V(`div`,{className:`flex items-center justify-between rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[V(`div`,{className:`flex flex-col gap-0.5`,children:[o,e.description?B(`span`,{className:`text-xs text-gray-500`,children:e.description}):null]}),B(`input`,{id:i,type:`checkbox`,checked:r===!0,onChange:e=>a(e.currentTarget.checked),className:`h-4 w-4 rounded border-gray-300 text-me-primary-500 focus:ring-me-primary-500`})]}):e.type===`textarea`?V(`div`,{className:`flex flex-col gap-2 rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[o,e.description?B(`span`,{className:`text-xs text-gray-500`,children:e.description}):null,B(`textarea`,{id:i,className:`${s} min-h-24 resize-y`,value:typeof r==`string`?r:``,placeholder:e.placeholder,onChange:e=>a(e.currentTarget.value)})]}):e.type===`select`?V(`div`,{className:`flex flex-col gap-2 rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[o,e.description?B(`span`,{className:`text-xs text-gray-500`,children:e.description}):null,V(`select`,{id:i,className:s,value:r===void 0?``:String(r),onChange:t=>{let n=e.options?.find(e=>String(e.value)===t.currentTarget.value);a(n?n.value:t.currentTarget.value)},children:[B(`option`,{value:``,children:`Default`}),(e.options||[]).map(e=>B(`option`,{value:String(e.value),children:e.label},String(e.value)))]})]}):V(`div`,{className:`flex flex-col gap-2 rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[o,e.description?B(`span`,{className:`text-xs text-gray-500`,children:e.description}):null,B(`input`,{id:i,className:s,type:e.type===`number`?`number`:`text`,value:typeof r==`string`||typeof r==`number`?r:``,placeholder:e.placeholder,onChange:t=>{a(e.type===`number`?Number(t.currentTarget.value):t.currentTarget.value)}})]})}function Ic(){let t=ia(),n=Y(),r=It(),i=Lt(),[a,o]=Ec(2e3);function s(e){e.preventDefault();let t=new FormData(e.target),n={defaultPreview:t.get(`defaultPreview`),i18n:{...r.i18n||{},advancedLanguageMode:t.get(`advancedLanguageMode`)===`on`,availableLanguages:(t.get(`availableLanguages`)||``).split(`,`).map(e=>e.trim()),defaultLanguage:t.get(`defaultLanguage`)},export:{...r.export||{},version:t.get(`isVersion2`)===`on`?2:3,baseIdentifier:t.get(`base`)||null},plugins:r.plugins,editorFeatureFlags:{...r.editorFeatureFlags||{},rememberCanvasId:t.get(`rememberCanvasId`)===`on`,rememberLeftPanelId:t.get(`rememberLeftPanelId`)===`on`,annotationPopups:t.get(`annotationPopups`)===`on`,manifestGridOptions:t.get(`manifestGridOptions`)===`on`,enableMultiImageCanvases:t.get(`enableMultiImageCanvases`)===`on`,enableMultiMediaCanvases:t.get(`enableMultiMediaCanvases`)===`on`}};i(n),o.set(),o.clear()}return V(re,{children:[B(ae,{title:`Workspace configuration`}),a?B(`div`,{className:`bg-me-primary-500 text-white p-3 text-sm`,children:`Changes saved`}):null,B(ie,{className:`p-4`,children:V(S.Form,{onSubmit:s,className:`flex flex-col gap-3`,children:[V(S.InputContainer,{children:[B(S.Label,{htmlFor:`defaultLanguage`,children:`Default Language`}),B(S.Input,{type:`text`,name:`defaultLanguage`,id:`defaultLanguage`,defaultValue:r.i18n?.defaultLanguage||``})]}),V(S.InputContainer,{children:[B(S.Label,{htmlFor:`availableLanguages`,children:`Available Languages`}),B(S.Input,{type:`text`,name:`availableLanguages`,id:`availableLanguages`,defaultValue:(r.i18n?.availableLanguages||[]).join(`, `)})]}),V(S.InputContainer,{horizontal:!0,className:`my-3`,children:[B(S.Input,{type:`checkbox`,name:`advancedLanguageMode`,id:`advancedLanguageMode`,defaultChecked:r.i18n?.advancedLanguageMode||!1}),B(S.Label,{htmlFor:`advancedLanguageMode`,children:`Advanced Language Mode`})]}),V(S.InputContainer,{horizontal:!0,className:`my-3`,children:[B(S.Input,{type:`checkbox`,name:`textGranularityEnabled`,id:`textGranularityEnabled`,defaultChecked:r.i18n?.textGranularityEnabled||!1}),B(S.Label,{htmlFor:`textGranularityEnabled`,children:`Enable text granularity`})]}),V(S.InputContainer,{horizontal:!0,className:`my-3`,children:[B(S.Input,{type:`checkbox`,name:`rememberCanvasId`,id:`rememberCanvasId`,defaultChecked:r.editorFeatureFlags?.rememberCanvasId||!1}),B(S.Label,{htmlFor:`rememberCanvasId`,children:`Remember Canvas ID`})]}),V(S.InputContainer,{horizontal:!0,className:`my-3`,children:[B(S.Input,{type:`checkbox`,name:`rememberLeftPanelId`,id:`rememberLeftPanelId`,defaultChecked:r.editorFeatureFlags?.rememberLeftPanelId||!1}),B(S.Label,{htmlFor:`rememberLeftPanelId`,children:`Remember Left panel`})]}),V(S.InputContainer,{horizontal:!0,className:`my-3`,children:[B(S.Input,{type:`checkbox`,name:`manifestGridOptions`,id:`manifestGridOptions`,defaultChecked:r.editorFeatureFlags?.manifestGridOptions||!1}),B(S.Label,{htmlFor:`manifestGridOptions`,children:`Manifest Grid Options`})]}),V(S.InputContainer,{horizontal:!0,className:`my-3`,children:[B(S.Input,{type:`checkbox`,name:`isVersion2`,id:`isVersion2`,defaultChecked:r.export?.version===2}),V(S.Label,{htmlFor:`isVersion2`,children:[`Export Presentation 2 `,n.type,`s`]})]}),V(S.InputContainer,{children:[B(S.Label,{htmlFor:`defaultPreview`,children:`Default preview`}),B(`div`,{children:t.configs.map((e,t)=>e.type===`iiif-preview-service`?null:V(S.InputContainer,{horizontal:!0,children:[B(S.Input,{type:`radio`,id:e.id,name:`defaultPreview`,value:e.id,defaultChecked:r.defaultPreview?r.defaultPreview===e.id:t===0}),B(`label`,{htmlFor:e.id,children:e.label})]},e.id))})]}),n.type===`Manifest`?B(`a`,{className:`text-sm text-me-primary-500 hover:underline hover:text-me-primary-600`,href:window.location.pathname.includes(`/exhibition`)?window.location.pathname.replace(`/exhibition`,``)||`/`:`${window.location.pathname}/exhibition`,children:window.location.pathname.includes(`/exhibition`)?`Return to Manifest Editor`:`Go to Exhibition Editor`}):null,B(Nc,{}),B(`div`,{className:`mt-5`,children:B(e,{type:`submit`,children:`Save changes`})})]})})]})}function Lc(e){let t=new Map;for(let n of e){if(!n.configuration?.fields.length)continue;let e=rt(n);(!t.has(e)||n.id===e)&&t.set(e,n)}return Array.from(t.values())}function Rc(){let e=J(),t=It(),n=Lt(),r=I(()=>Lc(e.layout.creators||[]),[e.layout.creators]);function i(e,t){let r=rt(e),i=new FormData(t),a={};for(let t of e.configuration?.fields||[])t.type===`checkbox`&&(a[t.id]=i.get(t.id)===`on`);n({creators:{[r]:a}})}return r.length?B(`div`,{className:`flex max-w-3xl flex-col gap-6`,children:r.map(e=>V(S.Form,{className:`flex flex-col gap-3 border-b border-gray-100 pb-5 last:border-b-0`,onChange:t=>i(e,t.currentTarget),children:[V(`div`,{className:`flex flex-col gap-1`,children:[B(`h3`,{className:`text-base font-semibold text-gray-900`,children:e.label}),e.summary?B(`p`,{className:`text-sm text-gray-500`,children:e.summary}):null]}),e.configuration?.fields.map(n=>{let r=rt(e),i=t.creators?.[r]?.[n.id],a=`${r}-${n.id}`;return n.type===`checkbox`?V(S.InputContainer,{horizontal:!0,className:`my-1 items-start`,children:[B(S.Input,{type:`checkbox`,name:n.id,id:a,defaultChecked:typeof i==`boolean`?i:n.defaultValue||!1}),V(`div`,{className:`flex flex-col gap-1`,children:[B(S.Label,{htmlFor:a,children:n.label}),n.summary?B(`p`,{className:`text-sm text-gray-500`,children:n.summary}):null]})]},n.id):null})]},rt(e)))}):B(b,{children:`No creator settings available`})}function zc(){return Oe((e,t)=>({specificMenus:{},resourceMenus:{},hookMenuItem(t){let n=vr(),r=t.resource?.id||``,i=t.resource?.type;return i?r?(e(e=>({specificMenus:{...e.specificMenus,[r]:{...e.specificMenus[r]||{},menus:{...e.specificMenus[r]?.menus||{},[n]:{sectionTitle:t.sectionTitle,items:t.items}}}}})),()=>{e(e=>({specificMenus:{...e.specificMenus,[r]:{...e.specificMenus[r]||{},menus:{...e.specificMenus[r]?.menus||{},[n]:void 0}}}}))}):(e(e=>({resourceMenus:{...e.resourceMenus,[i]:{...e.resourceMenus[i]||{},menus:{...e.resourceMenus[i]?.menus||{},[n]:{sectionTitle:t.sectionTitle,items:t.items}}}}})),()=>{e(e=>({resourceMenus:{...e.resourceMenus,[i]:{...e.resourceMenus[i]||{},menus:{...e.resourceMenus[i]?.menus||{},[n]:void 0}}}}))}):()=>{}}}))}const Bc=j(null);function Vc({children:e}){let t=I(()=>zc(),[]);return B(Bc.Provider,{value:t,children:e})}function Hc(){let e=N(Bc);if(!e)throw Error(`useContextMenuStore must be used within a ContextMenuProvider`);return e}function Uc(e){let t=Hc(),n=ke(t,e=>e.resourceMenus),r=ke(t,e=>e.specificMenus);return I(()=>{let t=r[e.id||``]?.menus||{},i=n[e.type]?.menus||{},a=Object.values(t).flat(),o=[...Object.values(i).flat(),...a].filter(e=>e!==void 0),s=[],c=[];for(let e of o){let t=[];for(let n of e.items||[])n.id&&s.includes(n.id)||(s.push(n.id),t.push(n));t.length&&c.push({...e,items:t})}return Wc(c)},[r,n,e.id,e.type])}function Wc(e){let t={},n=[];e.forEach(e=>{if(!e)return;let r=e.sectionTitle;if(!r){n.push(...e.items||[]);return}t[r]||(t[r]=[]),t[r].push(...e.items)});let r=Object.entries(t).map(([e,t])=>({sectionTitle:e,items:t}));return n.length&&r.push({items:n}),r}function Gc(e,t=[]){let n=Hc(),r=ke(n,e=>e.hookMenuItem);P(()=>r(e),[r,e.resource?.id,e.resource?.type,...t])}var Kc={CenterPanelContainer:`_CenterPanelContainer_1sbe6_1`,CenterPanelHeader:`_CenterPanelHeader_1sbe6_16`,CenterPanelClose:`_CenterPanelClose_1sbe6_23`,CenterPanelTitle:`_CenterPanelTitle_1sbe6_28`};function qc(e){return V(`div`,{className:Kc.CenterPanelContainer,children:[e.title||e.close?V(`div`,{className:Kc.CenterPanelHeader,children:[e.title?B(`h2`,{className:Kc.CenterPanelTitle,children:e.title}):null,e.close?B(oa,{className:Kc.CenterPanelClose,onClick:e.close,children:B(Fi,{})}):null]}):null,e.children]})}const Jc=U.div`
444
+ `;function Xs({panel:e,state:t,actions:n,isLeft:r,pinActions:i=n,transition:a,close:o,available:s=[],style:c,noHeader:l,isModal:u}){let d=N(Le)||null,[f,p]=R(!1),m=Si(),h=Ya(),{tabs:g,pinnable:_,hideHeader:v}=e?.options||{},y=I(()=>(s||[]).filter(e=>!e.requiresState),[s]),{itemProps:b,isOpen:x,setIsOpen:S}=Ri(y.length),[C,w]=R(``),T=L(void 0);P(()=>p(!1),[m.state.canvasId,e?.id]),P(()=>w(``),[e]),P(()=>(T.current=w,()=>{T.current=void 0}),[]);let E=M(e=>{T.current&&T.current(e)},[]),ee=M(r=>{let i=e?t.stack.length?n.popStack:e.backAction?()=>e&&e.backAction&&e.backAction(t,{...h,current:n},m):null:null;r&&(!i||r.metaKey)&&y.length?(r.preventDefault(),S(!0)):i?.()},[n,m,h,e,S,t,y.length]),D=r=>{n.change({id:r.id,state:r.defaultState,stacked:!!(t.stack.length||e?.backAction)})};if(!e||!t.current)return null;let O=e.backAction||t.stack.length?B(Ks,{"aria-label":`Back`,onClick:ee,children:B(Is,{"aria-hidden":`true`})}):null,k=B(Ks,{"aria-label":`Close panel`,onClick:o||n.close,children:B(Pi,{"aria-hidden":`true`})});return B(Hs.Provider,{value:E,children:V(Ws,{"data-modal":u,"data-state":a,"data-flipped":r,style:c,"data-header":!l,children:[l?null:V(Gs,{"data-tabs":!!g,"data-error":f,children:[V(js,{style:{display:`flex`,height:`100%`},children:[e.renderBackAction?e.renderBackAction({backAction:ee,fallback:O}):O,y.length?V(Ns,{$open:x,role:`menu`,style:{left:`0.5em`},children:[B(Ps,{children:`All panels`}),B(Fs,{}),y.map((t,n)=>B(Ms,{...b[n],onClick:()=>D(t),$active:e.id===t.id,children:t.label},n))]}):null]}),C?B(Js,{as:r?`h1`:`h2`,children:C}):v?B(qs,{}):B(Js,{as:r?`h1`:`h2`,children:e.label}),_?t.pinned?B(Ks,{"aria-label":`Unpin panel`,onClick:i.unpin,children:B(Ls,{"aria-hidden":`true`,fill:`orange`})}):B(Ks,{"aria-label":`Pin panel`,onClick:()=>i.pin({id:e.id,state:t.state}),children:B(Ls,{"aria-hidden":`true`,fill:`#ddd`})}):null,e.renderCloseAction?e.renderCloseAction({closeAction:o||n.close,fallback:k}):k]}),B(Ys,{className:`OverrideScrollbar`,children:B(at,{onError:()=>p(!0),FallbackComponent:Vs,resetKeys:[m.state.canvasId,e?.id],onReset:()=>p(!1),children:Bs(e.render(t.state||e.defaultState||{},{...h,current:n,vault:d,transition:a,isModal:u},m))})})]})})}function Zs(e=`vault://homepage-collection.json`){let t=new tt,n=window.localStorage.getItem(`preview-vault-collection`),r=!1;if(n)try{let i=JSON.parse(n);if(i.id&&i.id===e){t.dispatch(ut({id:i.id}));let e=dt(i.id,i);t.dispatch(st({actions:e})),r=!0}}catch{}if(!r){let n=dt(e,{"@context":`http://iiif.io/api/presentation/3/context.json`,id:e,type:`Collection`,label:{en:[`Recent items`]},items:[]});t.dispatch(ut({id:e})),t.dispatch(st({actions:n}))}return t.on(`after:@iiif/REMOVE_REFERENCE`,n=>{n.action.payload.id===e&&window.localStorage.setItem(`preview-vault-collection`,JSON.stringify(t.toPresentation3({id:e,type:`Collection`})))}),{vault:t,unsubscribe:()=>{},addHistory:(n,r)=>{let i=t.getState();if(n&&r&&(r===`Collection`||r===`Manifest`)){let a=i.iiif.entities.Collection[e];if(a){let i=a.items.findIndex(e=>e.id===n);i===-1?t.dispatch(ot({id:e,type:`Collection`,reference:{id:n,type:r},key:`items`,index:0})):t.dispatch(lt({id:e,type:`Collection`,key:`items`,startIndex:i,endIndex:0})),window.localStorage.setItem(`preview-vault-collection`,JSON.stringify(t.toPresentation3({id:e,type:`Collection`})))}}},clearHistory:()=>{t.dispatch(ct({id:e,type:`Collection`,key:`items`,value:[]})),window.localStorage.setItem(`preview-vault-collection`,JSON.stringify(t.toPresentation3({id:e,type:`Collection`})))}}}function Qs(){return N($s)}const $s=j(new tt),ec=j({addHistory:(e,t)=>{},clearHistory:()=>{}}),tc=`manifest-editor://homepage-collection.json`;function nc(){return N(ec)}function rc(e){let{vault:t,unsubscribe:n,addHistory:r,clearHistory:i}=I(()=>Zs(tc),[]);return P(()=>n,[]),B(ec.Provider,{value:{addHistory:r,clearHistory:i},children:B($s.Provider,{value:t,children:e.children})})}function ic({children:e}){let t=Qs();return B(ze,{vault:t,children:e})}function ac(e,t,n,r,i){let a=H(),o=Y(),{create:s,edit:c}=Ka(),l=I(()=>it({type:n,parent:e,index:0,property:t},o.layout.creators||[],{vault:a}),[e,t,o.layout.creators,n,a]),u=e&&l.length!==0,d=M((a,o)=>{if(e)return s({type:n,parent:qe(e),property:t,index:a,target:r,initialData:o,...i||{}})},[s,e,t,n,i,r]),f=M((a,o,c)=>{if(e)return s({type:n,filter:a,parent:qe(e),property:t,index:o,target:r,initialData:c,...i||{}})},[s,e,t,n,i,r]);return[u,{create:d,edit:M((n,r)=>{c(n,e?{parent:qe(e),property:t,index:r}:void 0)},[c,e,t]),createFiltered:f,creator:M((a,o)=>{if(e)return s({type:n,initialCreator:a,parent:qe(e),property:t,target:r,initialData:o,...i||{}})},[n,t,e,r,s,i]),buttonProps:I(()=>({"data-action-id":mr(n,t,e)}),[n,t,e])}]}function oc(){let e=H(),t=Qs(),n=Y(),r=K();return I(()=>new nt(e,n.layout.creators||[],t,r.creators),[n.layout.creators,r.creators,t,e])}async function sc(e){let t=await e.create(),n=Array.isArray(t)?t[0]:t;return n?(e.onCreate?.(),e.close?.(),e.edit?.(n),!0):!1}const cc=j({});function lc(e){return N(cc)[e]||{}}function uc(e){let t=N(cc),n=I(()=>({...t,[e.id]:e.data}),[t,e.id,e.data]);return B(cc.Provider,{value:n,children:e.children})}const dc=we(function(t){let n=H(),{edit:r,modal:i}=Ka(),[a,o]=R(!1),[s,c]=R(null),l=oc(),u=K(),d=L(!1),f=t.resource.initialData?.selector;ks(f);let p=lc(t.creator.id),m={targetType:t.resource.type,parent:t.resource.parent?{property:t.resource.property,atIndex:t.resource.index,resource:t.resource.parent}:void 0,target:t.resource.target,initialData:{...p,...t.resource.initialData||{},...t.initialData||{}}},h=async e=>{if(!(a||d.current)){o(!0),d.current=!0;try{await sc({create:()=>l.create(t.creator.id,e,m),onCreate:t.onCreate,close:t.skipEditingOnCreate?void 0:()=>{i.popStack(),i.close()},edit:t.skipEditingOnCreate||t.resource.initialData?.skipEditingOnCreate?void 0:e=>r(e,{parent:qe(t.resource.parent),property:t.resource.property,index:t.resource.index})})}catch(e){c(e?.message||`Unknown error`)}finally{o(!1),d.current=!1}}},g=async()=>!0;if(P(()=>{t.resource.initialData?.showEmptyForm||!t.creator.render&&!a&&h({})},[t.creator]),s)return B(`div`,{className:`flex flex-col items-center p-4`,children:B(x,{children:s})});let _=B(`div`,{className:`flex flex-col items-center py-8`,children:V(`div`,{className:`flex gap-2 items-center`,children:[B(A,{}),` `,B(`span`,{children:`Loading`})]})});return a?_:t.creator.render?B(z,{children:B(be,{fallback:_,children:t.creator.render({vault:n,runCreate:h,validate:g,options:m,config:u.creators?.[rt(t.creator)]||{}})})}):V(z,{children:[B(b,{children:`No options available`}),B(e,{primary:!0,onPress:()=>h({}),children:t.creator.actionButton||`Create`})]})});function fc(t){let n=Y(),r=H(),[i,a]=R(t.resource.initialCreator||``),[o,s]=R(),[c,l]=R(``),[u,d]=R(!1),[f,p]=R(``),[m,h]=R(null),g=L(null),v=Us(),y=I(()=>it(t.resource,n.layout.creators||[],{vault:r}),[t.resource,n.layout.creators,r]),x=y.some(e=>e.supportsResource);P(()=>{y.length===1&&!i&&!x&&a(y[0].id)},[x,i,y]),P(()=>{x&&!i&&g.current?.focus()},[x,i]);let S=y.find(e=>e.id===i);if(P(()=>{S&&v?.(S.label)}),y.length===0)return B(b,{children:`Not currently supported`});let T=(e,t)=>{s(t||gc(c)),a(e.id)},E=async e=>{e.preventDefault();let n=c.trim();if(!n||u)return;d(!0),p(``),h(null);let i=_c(),a=await Promise.all(y.map(async e=>{if(!e.supportsResource)return null;try{let a=await e.supportsResource(n,i,{vault:r,resource:t.resource});return a?{creator:e,initialData:hc(n,a).initialData}:null}catch(t){return{creator:e,error:t?.message||`Could not check this link`}}})),o=a.filter(pc),s=a.filter(mc);if(d(!1),o.length===1){T(o[0].creator,o[0].initialData);return}if(o.length>1){h(o),p(`Multiple creators can use this link. Choose one below.`);return}p(s[0]?.error||`No creator recognised this link. Choose one below.`)},ee=B(D,{children:B(w,{root:document.getElementById(`headlessui-portal-root`)||void 0,label:`Back to Add content options`,className:`group`,placement:`right`,onPress:()=>{a(``),s(void 0)},children:B(C,{className:`text-2xl opacity-50 group-hover:opacity-70`})})});if(S)return S.hiddenModal?V(z,{children:[ee,B(dc,{creator:S,resource:t.resource,initialData:o})]}):V(`div`,{children:[ee,B(`div`,{className:`p-2 py-6`,children:B(dc,{creator:S,resource:t.resource,initialData:o})})]});let O=m?.length?m.map(e=>e.creator):y,k=new Map(m?.map(e=>[e.creator.id,e.initialData]));return V(z,{children:[x?V(`form`,{className:`p-4 pb-0`,onSubmit:E,children:[B(`label`,{className:`block text-sm font-medium text-gray-700`,htmlFor:`creator-resource-link`,children:`Paste a link`}),V(`div`,{className:`mt-1 flex gap-2`,children:[B(`input`,{ref:g,id:`creator-resource-link`,className:`min-w-0 flex-1 rounded border border-gray-300 px-3 py-2 text-sm`,value:c,onChange:e=>{l(e.currentTarget.value),p(``),h(null)},placeholder:`https://example.org/resource`,type:`url`}),B(e,{primary:!0,type:`submit`,isDisabled:!c.trim()||u,children:u?`Checking`:`Use link`})]}),f?B(`div`,{className:`mt-2 text-sm text-gray-600`,role:`status`,children:f}):null]}):null,B(_,{label:`Select a type`,items:O.map(e=>({id:e.id,title:e.label,description:e.summary||``,icon:e.icon,onClick:()=>T(e,k.get(e.id))}))})]})}function pc(e){return!!e&&!(`error`in e)}function mc(e){return!!e&&`error`in e}function hc(e,t){return typeof t==`object`?t:{initialData:gc(e)}}function gc(e){let t=e.trim();return t?{url:t,youtubeUrl:t}:void 0}function _c(){let e=new Map,t=new Map,n=new Map,r=t=>(e.has(t)||e.set(t,fetch(t).then(e=>{if(!e.ok)throw Error(`Could not load ${t}`);return e.text()})),e.get(t)),i=e=>(n.has(e)||n.set(e,fetch(e,{method:`HEAD`}).then(t=>{if(!t.ok)throw Error(`Could not check ${e}`);return t})),n.get(e));return{text:r,head:i,json(e){return t.has(e)||t.set(e,r(e).then(e=>JSON.parse(e))),t.get(e)},async contentType(e){return(await i(e)).headers.get(`content-type`)||``}}}const vc={id:`@manifest-editor/creator`,label:`Add content`,options:{hideHeader:!0,tabs:!1},render(e){return B(fc,{resource:e})}},yc={color:{main:`#B84C74`,mainHover:`#4a89ff`,logoPink:`#E94581`,white:`white`,grey:`grey`,black:`black`,lightgrey:`#F8F9FA`,mediumgrey:`#dddddd`,danger:`#a90e21`,warning:`#e38627`,lightdanger:`#ffeaea`,lightsuccess:`#c5e8c5`,success:`#6ccd55`,greyOverlay:`rgba(0, 0, 0, 0.2)`,highlight:`#faeed7`},iiifColor:{manifest:`rgba(0, 0, 0, 0.2)`,canvas:`rgba(255, 222, 219, 0.8)`,service:`rgba(13, 110, 253, 0.8)`,annotation:`rgba(247, 226, 173, 0.8)`,contentResource:`rgba(207, 247, 255, 0.8)`,ranges:`rgba(144, 213, 157, 0.8)`},padding:{xs:`0.25rem`,small:`0.5rem`,medium:`1rem`,large:`2rem`},device:{mobile:`375px`,tablet:`768px`,laptop:`992px`,desktop:`1200px`},shadows:{standard:`rgba(0, 0, 0, 0.1) 0px 1px 3px 0px, rgba(0, 0, 0, 0.05) 0px 5px 15px 0px`,bottom:`rgba(0, 0, 0, 0.1) 0px 4px 2px -2px`}};function bc(e){let{}=e,t=H(),n=Y(),r=I(()=>it(e.resource,n.layout.creators||[],{vault:t}),[e.resource,n.layout.creators,t]);return r.length===0?B(`div`,{children:`No supported creators found`}):B(`div`,{children:V(ue,{className:`w-full flex-1 overflow-hidden flex flex-col`,children:[B(ce,{className:`flex-1 overflow-hidden w-full flex text-sm whitespace-nowrap`,items:r,children:e=>B(se,{id:e.id,children:e.label})}),r.map(t=>B(le,{id:t.id,className:`p-2`,children:B(Je,{theme:yc,children:B(dc,{creator:t,resource:e.resource,onCreate:e.onCreate,skipEditingOnCreate:!0})})},t.id))]})})}function xc({fallback:e,backAction:t}){let n=Ma(),{back:r}=Aa();return n.length?B(Ks,{"aria-label":`Back`,onClick:r,children:B(Is,{"aria-hidden":`true`})}):e}function Sc({closeAction:e,fallback:t}){let n=Ma();return ja()||n.length?B(Ks,{"aria-label":`Close panel`,onClick:()=>{e()},children:B(Pi,{"aria-hidden":`true`})}):t}function Cc(e,t,n,r){let i=t.filter(t=>t.resourceType===e.resource.source.type);if(i.length===0)return null;for(let t of i){let i=[],a={},o=e.property===`partOf`,s=(t.editors||[]).filter(t=>{if(o&&t.id!==`@manifest-editor/part-of-reference`||r.hideTabs&&r.hideTabs.includes(t.id)||r.onlyTabs&&!r.onlyTabs.includes(t.id))return!1;if(t.supports.sortKey){if(i.includes(t.supports.sortKey))return!1;t.supports.sortFallback&&(a[t.supports.sortKey]=t)}return n.edit&&!t.supports.edit||t.supports.custom&&t.supports.custom(e,n.vault)===!1?!1:(t.supports.sortKey&&i.push(t.supports.sortKey),!0)}),c=Object.keys(a);for(let e of c)!i.includes(e)&&a[e]&&!s.includes(a[e])&&s.push(a[e]);if(s.length)return{...t,editors:s}}return null}function wc({currentTab:e=void 0}){let t=ja(),n=N(Re),r=Y(),i=Hi(),a=H(),{change:o}=Ka(),s=Us(),{editorConfig:c}=K(),l=t?.resource.source?.id,u=t?.resource.source?.type,d=l!==i.id;l&&d&&i.type===`Collection`&&u===`Collection`&&(u=`EmbeddedCollection`);let f=(u?c[u]:c.All)||{},p=I(()=>{let e={...n},r=t?.resource.source.id,i=t?.resource.source.type,a={Collection:`collection`,Manifest:`manifest`,Range:`range`,Canvas:`canvas`,Annotation:`annotation`,AnnotationPage:`annotationPage`};return i&&a[i]&&(e[a[i]]=r),e},[t,n]);function m(e){return t?B(Re.Provider,{value:p,children:e}):e}let h=I(()=>{if(!t)return null;let e=r.layout.editors||[],n=(r.layout.resources||[]).map(t=>typeof t==`string`?{id:`@default/`+t,label:t,resourceType:t,auto:!0,editors:e.filter(e=>e.supports.resourceTypes.includes(t))}:t);return Cc(t,n,{edit:!0,vault:a},f)},[t,r]);P(()=>{s(h?.label||``)},[h]),P(()=>{let t=h?.editors.map(e=>e.id)||[];t.find(t=>t===e)||o(`@manifest-editor/editor`,{currentTab:t[0]})},[h?.editors,e,o]);let g=I(()=>(h?.editors||[]).map(e=>({id:e.id,label:e.label,renderComponent:()=>e.component(f)})),[h?.editors,f]);if(!t||!h)return null;if(f.singleTab){let e=(h?.editors||[]).find(e=>e.id===f.singleTab);if(e)return m(B(`div`,{className:`w-full`,children:e.component(f)},t.resource.source?.id))}return m(B(oe,{isNested:d,rootResource:i,menuId:t.resource.source.id,menu:g,selectedKey:e,onSelectionChange:e=>{o(`@manifest-editor/editor`,{currentTab:e})}},t.resource.source?.id))}const Tc={id:`@manifest-editor/editor`,label:`Editor`,options:{hideHeader:!0,tabs:!0,minWidth:400},renderBackAction:({backAction:e,fallback:t})=>B(xc,{backAction:e,fallback:t}),renderCloseAction:({closeAction:e,fallback:t})=>B(Sc,{closeAction:e,fallback:t}),render({currentTab:e}){return B(wc,{currentTab:e})}};function Ec(e){let[t,n]=R(!1),r=L(null),i=L(0);function a(t){i.current--,!(t&&i.current!==0)&&(r.current&&(clearTimeout(r.current),r.current=0),r.current=setTimeout(()=>{n(!1)},e))}function o(){i.current++,r.current&&clearTimeout(r.current),n(!0)}return I(()=>[t,{set:o,clear:a}],[t])}function Dc(e){return e?typeof e==`string`?{src:e,alt:``}:e:null}function Oc(e){return e?typeof e==`string`?e:e.name:null}function kc(e){let t=e.extension,n=t.leftPanels?.[0]||t.centerPanels?.[0]||t.rightPanels?.[0]||t.modalPanels?.[0];return n?{id:n.id,label:n.label||`Open plugin`,modal:t.modalPanels?.some(e=>e.id===n.id)||!1}:null}function Ac(e){return e instanceof Error?e.message:`Plugin configuration could not be saved.`}function jc(e){return V(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:[B(`path`,{d:`M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z`}),B(`circle`,{cx:`12`,cy:`12`,r:`3`})]})}function Mc(e){return V(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:[B(`path`,{d:`M7 7h10v10`}),B(`path`,{d:`M7 17 17 7`})]})}function Nc(){let e=Y(),{appId:t}=xi(),n=K(),r=It(),i=li(),a=di(),o=Ka(),{saveGlobalPluginConfig:s}=N(ii),[c,l]=R(!1),[u,d]=R(``),[f,p]=R(null),[m,h]=R(null),[_,v]=R(null),y=I(()=>new Set(Ur(i,e,t).map(e=>e.metadata.id)),[i,e,t]),b=I(()=>{let n=u.trim().toLowerCase();return i.plugins.filter(r=>{let i=zr(r,e,t);return!c&&!i?!1:!n||[r.metadata.label,r.metadata.id,r.metadata.description,Oc(r.metadata.author),...r.metadata.tags||[]].filter(Boolean).join(` `).toLowerCase().includes(n)})},[e,t,i.plugins,u,c]),x=f&&i.plugins.find(e=>e.metadata.id===f)||null;if(!i.plugins.length)return null;function S(e){a.setAppConfig(t,e),r({plugins:{...n.plugins||{},apps:{...n.plugins?.apps||{},[t]:e}}})}async function C(e){if(!s){v(`Global plugin settings are not available in this host.`);return}let n=i.globalApps[t]||{},r={apps:{...i.globalApps,[t]:e}};a.setGlobalAppConfig(t,e);try{await s(r)}catch(e){a.setGlobalAppConfig(t,n),v(Ac(e))}}async function w(n,r,a){v(null),h(`${a}:${n.metadata.id}`);let o=a===`global`?i.globalApps[t]||{}:i.apps[t]||{},s=r?Xr(o,i,n,e,t):{config:kr(o,n.metadata.id),blocked:[]};if(s.blocked.length){h(null),v(`Cannot enable ${n.metadata.label}: ${s.blocked.join(`, `)}.`);return}a===`global`?await C(s.config):S(s.config),h(null)}function T(e){let t=kc(e);if(t){if(t.modal){o.modal.open({id:t.id});return}o.open(t.id)}}return V(`section`,{className:`flex flex-col gap-3 border-t border-gray-200 pt-4 mt-4`,children:[V(`div`,{className:`flex items-center gap-2`,children:[B(`div`,{className:`min-w-0 flex-1`,children:B(`h3`,{className:`font-semibold text-sm text-gray-900`,children:`Plugins`})}),B(`button`,{type:`button`,className:`rounded border border-gray-200 bg-white px-2 py-1 text-xs text-gray-500 hover:text-gray-700 hover:border-gray-300 transition-colors`,onClick:()=>l(e=>!e),children:c?`Compatible only`:`Show all`})]}),B(`input`,{"aria-label":`Search plugins`,className:`rounded border border-gray-200 px-2.5 py-1.5 text-xs focus:border-me-primary-500 focus:ring-2 focus:ring-me-primary-500/20 focus:outline-none`,type:`search`,placeholder:`Search plugins…`,value:u,onChange:e=>d(e.currentTarget.value)}),_?B(`div`,{className:`rounded border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:_}):null,B(`div`,{className:`flex flex-col gap-2`,children:b.map(n=>{let r=Vr(n,i,t),a=y.has(n.metadata.id),o=r&&n.loadStatus===`loading`,s=r&&n.loadStatus===`error`?n.loadError:null,c=Dc(n.metadata.image),l=r&&!a&&!o&&!s,u=zr(n,e,t),d=Br(n,e,t),f=kc(n),h=!!n.settings,_=m===`workspace:${n.metadata.id}`;return V(`article`,{className:`flex gap-2.5 rounded-lg border bg-white p-3 text-sm transition-colors ${a?`border-gray-200`:`border-gray-100 bg-gray-50`} ${u?``:`bg-gray-100`}`,children:[c?B(`img`,{className:`h-9 w-9 rounded object-cover flex-none mt-0.5`,src:c.src,alt:c.alt||n.metadata.label}):B(`div`,{className:`h-9 w-9 rounded flex items-center justify-center flex-none mt-0.5 text-lg ${a?`bg-me-primary-50 text-me-primary-500`:`bg-gray-100 text-gray-600`}`,children:B(jc,{className:`w-4 h-4`})}),V(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[V(`div`,{className:`flex items-start justify-between gap-1`,children:[V(`div`,{className:`flex flex-wrap items-center gap-1.5 min-w-0`,children:[B(`span`,{className:`font-medium text-gray-900 text-xs`,children:n.metadata.label}),n.metadata.official?V(`span`,{className:`rounded-full text-me-primary-500 px-1.5 py-0 text-[9px] font-bold inline-flex items-center gap-1`,children:[B(g,{className:`w-3 h-3`}),` Verified`]}):null,n.metadata.version?B(`span`,{className:`text-[10px] text-gray-600`,children:n.metadata.version}):null]}),V(`div`,{className:`flex items-center gap-1 flex-none`,children:[h?B(`button`,{type:`button`,title:`Configure plugin`,"aria-label":`Configure ${n.metadata.label}`,className:`rounded p-1 text-gray-600 hover:text-gray-700 hover:bg-gray-100 transition-colors`,onClick:()=>p(n.metadata.id),children:B(jc,{className:`w-3.5 h-3.5`})}):null,a&&f?B(`button`,{type:`button`,title:`Open ${f.label}`,"aria-label":`Open ${f.label}`,className:`rounded p-1 text-me-primary-500 hover:bg-me-primary-50 transition-colors`,onClick:()=>T(n),children:B(Mc,{className:`w-3.5 h-3.5`})}):null,B(`button`,{type:`button`,disabled:!u||_,onClick:()=>w(n,!r,`workspace`),className:`relative inline-flex h-5 w-9 flex-none items-center rounded-full transition-colors disabled:opacity-40 focus:outline-none focus:ring-2 focus:ring-me-primary-500/30 ${r?`bg-me-primary-500`:`bg-gray-200`}`,title:r?`Disable plugin`:`Enable plugin`,"aria-label":`${r?`Disable`:`Enable`} ${n.metadata.label}`,children:B(`span`,{className:`inline-block h-3.5 w-3.5 transform rounded-full bg-white shadow transition-transform ${r?`translate-x-4`:`translate-x-0.5`}`})})]})]}),n.metadata.description?B(`p`,{className:`text-xs text-gray-500 leading-relaxed`,children:n.metadata.description}):null,o?B(`span`,{className:`text-xs text-gray-500`,children:`Loading plugin…`}):null,s?B(`span`,{className:`text-xs text-red-600`,children:s}):null,l?B(`span`,{className:`text-xs text-amber-600`,children:`Waiting for required dependencies`}):null,!u&&d?B(`span`,{className:`text-xs text-gray-600`,children:d}):null]})]},n.metadata.id)})}),b.length?null:B(`div`,{className:`rounded-lg border border-gray-100 bg-gray-50 p-4 text-center text-xs text-gray-500`,children:`No plugins found.`}),x?B(ee,{title:`Configure ${x.metadata.label}`,onClose:()=>p(null),width:`560px`,children:B(Pc,{plugin:x,onClose:()=>p(null),canSaveGlobal:!!s})}):null]})}function Pc({plugin:e,onClose:t,canSaveGlobal:n}){let r=mi(e.metadata.id),[i,a]=R(`workspace`),[o,s]=R({}),[c,l]=R(!1),[u,d]=R(!1),[f,p]=R(null),m=i===`global`?r.global:r.workspace;P(()=>{s({...m}),p(null),d(!1)},[e.metadata.id,i]);async function h(){let t=e.settings?.validate?.(o);if(t){p(t);return}l(!0),p(null);try{i===`global`?await r.setGlobalSettings(o):r.setWorkspaceSettings(o),d(!0),setTimeout(()=>d(!1),2e3)}catch(e){p(Ac(e))}finally{l(!1)}}async function g(){l(!0),p(null);try{i===`global`?await r.resetGlobalSettings():r.resetWorkspaceSettings(),s({})}catch(e){p(Ac(e))}finally{l(!1)}}let _=n&&r.canSaveGlobal;return V(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[_?V(`div`,{className:`flex items-center gap-1 px-5 pt-4 pb-3 border-b border-gray-100`,children:[B(`span`,{className:`text-xs text-gray-500 mr-2`,children:`Scope:`}),B(`button`,{type:`button`,className:`rounded-full px-3 py-1 text-xs font-medium transition-colors ${i===`workspace`?`bg-me-primary-500 text-white`:`bg-gray-100 text-gray-600 hover:bg-gray-200`}`,onClick:()=>a(`workspace`),children:`This workspace`}),B(`button`,{type:`button`,className:`rounded-full px-3 py-1 text-xs font-medium transition-colors ${i===`global`?`bg-me-primary-500 text-white`:`bg-gray-100 text-gray-600 hover:bg-gray-200`}`,onClick:()=>a(`global`),children:`All workspaces`})]}):null,f?B(`div`,{className:`mx-5 mt-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:f}):null,B(`div`,{className:`flex-1 overflow-y-auto p-5`,children:B(`div`,{className:`flex flex-col gap-3`,children:e.settings?.render?e.settings.render({plugin:e,appId:r.appId,scope:i,value:o,defaults:r.defaults,effective:r.effective,onChange:s}):e.settings?.fields?.length?e.settings.fields.map(e=>B(Fc,{field:e,draft:o,setDraft:s},e.id)):B(`div`,{className:`rounded-lg border border-gray-100 bg-gray-50 p-4 text-center text-sm text-gray-500`,children:`This plugin has no configurable settings.`})})}),V(`div`,{className:`flex items-center justify-between gap-3 border-t border-gray-100 px-5 py-4`,children:[B(`button`,{type:`button`,className:`text-xs text-gray-600 hover:text-gray-700 transition-colors disabled:opacity-40`,disabled:c,onClick:g,children:`Reset to defaults`}),V(`div`,{className:`flex items-center gap-2`,children:[u?B(`span`,{className:`text-xs text-green-600`,children:`✓ Saved`}):null,B(`button`,{type:`button`,className:`rounded-lg bg-me-primary-500 px-4 py-2 text-sm font-medium text-white hover:bg-me-primary-600 disabled:opacity-50 transition-colors`,disabled:c,onClick:h,children:c?`Saving…`:`Save ${i}`})]})]})]})}function Fc({field:e,draft:t,setDraft:n}){let r=t[e.id],i=`plugin-setting-${e.id}`;function a(r){n({...t,[e.id]:r})}let o=B(`label`,{className:`text-sm font-medium text-gray-900`,htmlFor:i,children:e.label}),s=`rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm focus:border-me-primary-500 focus:ring-2 focus:ring-me-primary-500/20 focus:outline-none`;return e.type===`boolean`?V(`div`,{className:`flex items-center justify-between rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[V(`div`,{className:`flex flex-col gap-0.5`,children:[o,e.description?B(`span`,{className:`text-xs text-gray-500`,children:e.description}):null]}),B(`input`,{id:i,type:`checkbox`,checked:r===!0,onChange:e=>a(e.currentTarget.checked),className:`h-4 w-4 rounded border-gray-300 text-me-primary-500 focus:ring-me-primary-500`})]}):e.type===`textarea`?V(`div`,{className:`flex flex-col gap-2 rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[o,e.description?B(`span`,{className:`text-xs text-gray-500`,children:e.description}):null,B(`textarea`,{id:i,className:`${s} min-h-24 resize-y`,value:typeof r==`string`?r:``,placeholder:e.placeholder,onChange:e=>a(e.currentTarget.value)})]}):e.type===`select`?V(`div`,{className:`flex flex-col gap-2 rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[o,e.description?B(`span`,{className:`text-xs text-gray-500`,children:e.description}):null,V(`select`,{id:i,className:s,value:r===void 0?``:String(r),onChange:t=>{let n=e.options?.find(e=>String(e.value)===t.currentTarget.value);a(n?n.value:t.currentTarget.value)},children:[B(`option`,{value:``,children:`Default`}),(e.options||[]).map(e=>B(`option`,{value:String(e.value),children:e.label},String(e.value)))]})]}):V(`div`,{className:`flex flex-col gap-2 rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[o,e.description?B(`span`,{className:`text-xs text-gray-500`,children:e.description}):null,B(`input`,{id:i,className:s,type:e.type===`number`?`number`:`text`,value:typeof r==`string`||typeof r==`number`?r:``,placeholder:e.placeholder,onChange:t=>{a(e.type===`number`?Number(t.currentTarget.value):t.currentTarget.value)}})]})}function Ic(){let e=K(),t=It(),n=e.creators[`iiif-image-services`]||{};return V(S.Form,{className:`flex max-w-3xl flex-col gap-4`,onChange:e=>{let n=new FormData(e.currentTarget);t({creators:{"iiif-image-services":{compact:n.get(`compact`)===`compact`?`compact`:`with-dimensions`,includeSizes:n.get(`includeSizes`)===`on`,includeTiles:n.get(`includeTiles`)===`on`}}})},onSubmit:e=>e.preventDefault(),children:[B(`h2`,{className:`text-xl font-semibold text-gray-900`,children:`IIIF Options`}),V(`fieldset`,{className:`flex flex-col gap-4`,children:[B(`legend`,{className:`mb-3 text-base font-semibold`,children:`Image services`}),V(S.InputContainer,{children:[B(S.Label,{htmlFor:`compactImageServices`,children:`Compact services`}),V(`select`,{id:`compactImageServices`,name:`compact`,className:`rounded border border-gray-300 p-2`,defaultValue:n.compact===`compact`?`compact`:`with-dimensions`,children:[B(`option`,{value:`with-dimensions`,children:`id, type, profile, width, height (default)`}),B(`option`,{value:`compact`,children:`id, type, profile (compact)`})]})]}),V(S.InputContainer,{horizontal:!0,children:[B(S.Input,{id:`includeSizes`,name:`includeSizes`,type:`checkbox`,defaultChecked:n.includeSizes===!0}),B(S.Label,{htmlFor:`includeSizes`,children:`Include sizes`})]}),V(S.InputContainer,{horizontal:!0,children:[B(S.Input,{id:`includeTiles`,name:`includeTiles`,type:`checkbox`,defaultChecked:n.includeTiles===!0}),B(S.Label,{htmlFor:`includeTiles`,children:`Include tiles`})]}),B(`p`,{className:`text-sm text-gray-500`,children:`Applies to newly added images. Thumbnails always include available sizes and tiles.`})]})]})}function Lc(){let t=ia(),n=Hi(),r=K(),i=It(),[a,o]=Ec(2e3);function s(e){e.preventDefault();let t=new FormData(e.target),n={defaultPreview:t.get(`defaultPreview`),i18n:{...r.i18n||{},advancedLanguageMode:t.get(`advancedLanguageMode`)===`on`,availableLanguages:(t.get(`availableLanguages`)||``).split(`,`).map(e=>e.trim()),defaultLanguage:t.get(`defaultLanguage`)},export:{...r.export||{},version:t.get(`isVersion2`)===`on`?2:3,baseIdentifier:t.get(`base`)||null},plugins:r.plugins,editorFeatureFlags:{...r.editorFeatureFlags||{},rememberCanvasId:t.get(`rememberCanvasId`)===`on`,rememberLeftPanelId:t.get(`rememberLeftPanelId`)===`on`,annotationPopups:t.get(`annotationPopups`)===`on`,manifestGridOptions:t.get(`manifestGridOptions`)===`on`,enableMultiImageCanvases:t.get(`enableMultiImageCanvases`)===`on`,enableMultiMediaCanvases:t.get(`enableMultiMediaCanvases`)===`on`}};i(n),o.set(),o.clear()}return V(re,{children:[B(ae,{title:`Workspace configuration`}),a?B(`div`,{className:`bg-me-primary-500 text-white p-3 text-sm`,children:`Changes saved`}):null,V(ie,{className:`p-4`,children:[B(Ic,{}),V(S.Form,{onSubmit:s,className:`flex flex-col gap-3`,children:[V(S.InputContainer,{children:[B(S.Label,{htmlFor:`defaultLanguage`,children:`Default Language`}),B(S.Input,{type:`text`,name:`defaultLanguage`,id:`defaultLanguage`,defaultValue:r.i18n?.defaultLanguage||``})]}),V(S.InputContainer,{children:[B(S.Label,{htmlFor:`availableLanguages`,children:`Available Languages`}),B(S.Input,{type:`text`,name:`availableLanguages`,id:`availableLanguages`,defaultValue:(r.i18n?.availableLanguages||[]).join(`, `)})]}),V(S.InputContainer,{horizontal:!0,className:`my-3`,children:[B(S.Input,{type:`checkbox`,name:`advancedLanguageMode`,id:`advancedLanguageMode`,defaultChecked:r.i18n?.advancedLanguageMode||!1}),B(S.Label,{htmlFor:`advancedLanguageMode`,children:`Advanced Language Mode`})]}),V(S.InputContainer,{horizontal:!0,className:`my-3`,children:[B(S.Input,{type:`checkbox`,name:`textGranularityEnabled`,id:`textGranularityEnabled`,defaultChecked:r.i18n?.textGranularityEnabled||!1}),B(S.Label,{htmlFor:`textGranularityEnabled`,children:`Enable text granularity`})]}),V(S.InputContainer,{horizontal:!0,className:`my-3`,children:[B(S.Input,{type:`checkbox`,name:`rememberCanvasId`,id:`rememberCanvasId`,defaultChecked:r.editorFeatureFlags?.rememberCanvasId||!1}),B(S.Label,{htmlFor:`rememberCanvasId`,children:`Remember Canvas ID`})]}),V(S.InputContainer,{horizontal:!0,className:`my-3`,children:[B(S.Input,{type:`checkbox`,name:`rememberLeftPanelId`,id:`rememberLeftPanelId`,defaultChecked:r.editorFeatureFlags?.rememberLeftPanelId||!1}),B(S.Label,{htmlFor:`rememberLeftPanelId`,children:`Remember Left panel`})]}),V(S.InputContainer,{horizontal:!0,className:`my-3`,children:[B(S.Input,{type:`checkbox`,name:`manifestGridOptions`,id:`manifestGridOptions`,defaultChecked:r.editorFeatureFlags?.manifestGridOptions||!1}),B(S.Label,{htmlFor:`manifestGridOptions`,children:`Manifest Grid Options`})]}),V(S.InputContainer,{horizontal:!0,className:`my-3`,children:[B(S.Input,{type:`checkbox`,name:`isVersion2`,id:`isVersion2`,defaultChecked:r.export?.version===2}),V(S.Label,{htmlFor:`isVersion2`,children:[`Export Presentation 2 `,n.type,`s`]})]}),V(S.InputContainer,{children:[B(S.Label,{htmlFor:`defaultPreview`,children:`Default preview`}),B(`div`,{children:t.configs.map((e,t)=>e.type===`iiif-preview-service`?null:V(S.InputContainer,{horizontal:!0,children:[B(S.Input,{type:`radio`,id:e.id,name:`defaultPreview`,value:e.id,defaultChecked:r.defaultPreview?r.defaultPreview===e.id:t===0}),B(`label`,{htmlFor:e.id,children:e.label})]},e.id))})]}),n.type===`Manifest`?B(`a`,{className:`text-sm text-me-primary-500 hover:underline hover:text-me-primary-600`,href:window.location.pathname.includes(`/exhibition`)?window.location.pathname.replace(`/exhibition`,``)||`/`:`${window.location.pathname}/exhibition`,children:window.location.pathname.includes(`/exhibition`)?`Return to Manifest Editor`:`Go to Exhibition Editor`}):null,B(Nc,{}),B(`div`,{className:`mt-5`,children:B(e,{type:`submit`,children:`Save changes`})})]})]})]})}function Rc(e){let t=new Map;for(let n of e){if(!n.configuration?.fields.length)continue;let e=rt(n);(!t.has(e)||n.id===e)&&t.set(e,n)}return Array.from(t.values())}function zc(){let e=Y(),t=K(),n=It(),r=I(()=>Rc(e.layout.creators||[]),[e.layout.creators]);function i(e,t){let r=rt(e),i=new FormData(t),a={};for(let t of e.configuration?.fields||[])t.type===`checkbox`&&(a[t.id]=i.get(t.id)===`on`);n({creators:{[r]:a}})}return r.length?B(`div`,{className:`flex max-w-3xl flex-col gap-6`,children:r.map(e=>V(S.Form,{className:`flex flex-col gap-3 border-b border-gray-100 pb-5 last:border-b-0`,onChange:t=>i(e,t.currentTarget),children:[V(`div`,{className:`flex flex-col gap-1`,children:[B(`h3`,{className:`text-base font-semibold text-gray-900`,children:e.label}),e.summary?B(`p`,{className:`text-sm text-gray-500`,children:e.summary}):null]}),e.configuration?.fields.map(n=>{let r=rt(e),i=t.creators?.[r]?.[n.id],a=`${r}-${n.id}`;return n.type===`checkbox`?V(S.InputContainer,{horizontal:!0,className:`my-1 items-start`,children:[B(S.Input,{type:`checkbox`,name:n.id,id:a,defaultChecked:typeof i==`boolean`?i:n.defaultValue||!1}),V(`div`,{className:`flex flex-col gap-1`,children:[B(S.Label,{htmlFor:a,children:n.label}),n.summary?B(`p`,{className:`text-sm text-gray-500`,children:n.summary}):null]})]},n.id):null})]},rt(e)))}):B(b,{children:`No creator settings available`})}function Bc(){return Oe((e,t)=>({specificMenus:{},resourceMenus:{},hookMenuItem(t){let n=_r(),r=t.resource?.id||``,i=t.resource?.type;return i?r?(e(e=>({specificMenus:{...e.specificMenus,[r]:{...e.specificMenus[r]||{},menus:{...e.specificMenus[r]?.menus||{},[n]:{sectionTitle:t.sectionTitle,items:t.items}}}}})),()=>{e(e=>({specificMenus:{...e.specificMenus,[r]:{...e.specificMenus[r]||{},menus:{...e.specificMenus[r]?.menus||{},[n]:void 0}}}}))}):(e(e=>({resourceMenus:{...e.resourceMenus,[i]:{...e.resourceMenus[i]||{},menus:{...e.resourceMenus[i]?.menus||{},[n]:{sectionTitle:t.sectionTitle,items:t.items}}}}})),()=>{e(e=>({resourceMenus:{...e.resourceMenus,[i]:{...e.resourceMenus[i]||{},menus:{...e.resourceMenus[i]?.menus||{},[n]:void 0}}}}))}):()=>{}}}))}const Vc=j(null);function Hc({children:e}){let t=I(()=>Bc(),[]);return B(Vc.Provider,{value:t,children:e})}function Uc(){let e=N(Vc);if(!e)throw Error(`useContextMenuStore must be used within a ContextMenuProvider`);return e}function Wc(e){let t=Uc(),n=ke(t,e=>e.resourceMenus),r=ke(t,e=>e.specificMenus);return I(()=>{let t=r[e.id||``]?.menus||{},i=n[e.type]?.menus||{},a=Object.values(t).flat(),o=[...Object.values(i).flat(),...a].filter(e=>e!==void 0),s=[],c=[];for(let e of o){let t=[];for(let n of e.items||[])n.id&&s.includes(n.id)||(s.push(n.id),t.push(n));t.length&&c.push({...e,items:t})}return Gc(c)},[r,n,e.id,e.type])}function Gc(e){let t={},n=[];e.forEach(e=>{if(!e)return;let r=e.sectionTitle;if(!r){n.push(...e.items||[]);return}t[r]||(t[r]=[]),t[r].push(...e.items)});let r=Object.entries(t).map(([e,t])=>({sectionTitle:e,items:t}));return n.length&&r.push({items:n}),r}function Kc(e,t=[]){let n=Uc(),r=ke(n,e=>e.hookMenuItem);P(()=>r(e),[r,e.resource?.id,e.resource?.type,...t])}var qc={CenterPanelContainer:`_CenterPanelContainer_1sbe6_1`,CenterPanelHeader:`_CenterPanelHeader_1sbe6_16`,CenterPanelClose:`_CenterPanelClose_1sbe6_23`,CenterPanelTitle:`_CenterPanelTitle_1sbe6_28`};function Jc(e){return V(`div`,{className:qc.CenterPanelContainer,children:[e.title||e.close?V(`div`,{className:qc.CenterPanelHeader,children:[e.title?B(`h2`,{className:qc.CenterPanelTitle,children:e.title}):null,e.close?B(oa,{className:qc.CenterPanelClose,onClick:e.close,children:B(Pi,{})}):null]}):null,e.children]})}const Yc=U.div`
445
445
  flex: 1;
446
446
  display: flex;
447
447
  width: 100%;
448
448
  flex-direction: column;
449
449
  position: relative;
450
- `,Yc=U.div`
450
+ `,Xc=U.div`
451
451
  background: #fff;
452
452
  position: relative;
453
453
  border-bottom: 1px solid #d0d0d0;
@@ -465,11 +465,11 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
465
465
  //flex-direction: column;
466
466
  //justify-content: center;
467
467
  }
468
- `,Xc=U.p`
468
+ `,Zc=U.p`
469
469
  font-size: 0.9em;
470
470
  color: #777;
471
471
  font-weight: 400;
472
- `,Zc=U.button`
472
+ `,Qc=U.button`
473
473
  color: inherit;
474
474
  text-rendering: geometricPrecision;
475
475
  border: none;
@@ -511,7 +511,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
511
511
  margin-top: 0.5em;
512
512
  }
513
513
  }
514
- `,Qc=U.div`
514
+ `,$c=U.div`
515
515
  font-size: 1.4em;
516
516
  padding-right: 0.3em;
517
517
  display: flex;
@@ -520,7 +520,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
520
520
  [data-large="true"] & {
521
521
  font-size: 2em;
522
522
  }
523
- `,$c=U.div`
523
+ `,el=U.div`
524
524
  width: 2em;
525
525
  align-items: center;
526
526
  //padding-top: 0.5em;
@@ -533,11 +533,11 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
533
533
  fill: #999;
534
534
  color: #999;
535
535
  }
536
- `,el=U.div`
536
+ `,tl=U.div`
537
537
  min-height: 0;
538
538
  overflow: visible;
539
539
  display: flex;
540
- `,tl=U.div`
540
+ `,nl=U.div`
541
541
  min-height: 0;
542
542
  overflow: visible;
543
543
  flex: 1;
@@ -550,7 +550,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
550
550
  &[data-max-height="true"] {
551
551
  overflow-y: auto;
552
552
  }
553
- `,nl=U.section`
553
+ `,rl=U.section`
554
554
  display: grid;
555
555
  grid-template-rows: 0fr;
556
556
  overflow: hidden;
@@ -578,7 +578,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
578
578
  &[data-scrolled="true"] {
579
579
  box-shadow: inset 0px 2px 0px 0 rgba(0, 0, 0, 0.1);
580
580
  }
581
- `,rl=U.div`
581
+ `,il=U.div`
582
582
  position: sticky;
583
583
  display: flex;
584
584
  top: 0;
@@ -614,7 +614,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
614
614
  right: 0.5em;
615
615
  }
616
616
  }
617
- `,il=(()=>void 0);let al=0;function ol(){return I(()=>al++,[])}function sl(e,t=!1){let[n,r]=R([]),i=L(-1),a=t=>{let r=document.activeElement,i=n.findIndex(e=>e.current?.button?.current===r);if(i!==-1)switch(t.code){case`Home`:n[0]&&n[0].current?.focus();break;case`End`:{let t=e-1;n[t]&&n[t].current?.focus();break}case`ArrowDown`:if(i!==e-1){let e=i+1;n[e]&&n[e].current?.focus()}break;case`ArrowUp`:if(i!==0){let e=i-1;n[e]&&n[e].current?.focus()}break;case`ArrowLeft`:{let e=n[i];e&&e.current&&e.current.close();break}case`ArrowRight`:{let e=n[i];e&&e.current&&e.current.open();break}}},o=(e,r)=>{if(t&&r&&e!==i.current){i.current=e;for(let t=0;t<n.length;t++){let r=n[t];t!==e&&r.current?.close()}}};return P(()=>{r(t=>Array(e).fill(0).map((e,n)=>t[n]||Se()))},[e]),{open:e=>{let t=n[e];t&&t.current&&t.current.open()},close:e=>{let t=n[e];t&&t.current&&t.current.close()},toggle:e=>{let t=n[e];t&&t.current&&t.current.toggle()},focus:e=>{let t=n[e];t&&t.current&&t.current.focus()},openAll:()=>{for(let e=0;e<n.length;e++)n[e].current?.open()},closeAll:()=>{for(let e=0;e<n.length;e++)n[e].current?.close()},onKeyDown:a,getItemProps:e=>({ref:n[e],onChange:t=>o(e,t)})}}const cl=Ce(function(e,t){let n=L(null),r=L(null),i=ol(),[a,o]=R(e.initialOpen||!1),s=e.onChange||il,c=()=>{s(!a),o(e=>!e)},l=e.maxHeight,[u,d]=R(!1);return Te(t,()=>({open(){s(!0),o(!0)},close(){s(!1),o(!1)},toggle(){c()},focus(){r.current&&r.current.focus()},button:r})),V(Yc,{"data-large":e.large,"data-open":a,children:[V(rl,{"data-open":a,children:[e.icon?B($c,{onClick:c,children:e.icon}):null,V(Zc,{ref:r,onClick:c,"aria-expanded":a,"aria-controls":`accordion-${i}`,children:[e.label,e.description?B(Xc,{children:e.description}):null]}),B(Qc,{onClick:c,children:B(Ii,{width:`1em`,height:`1em`,rotate:a?0:180})})]}),B(nl,{"aria-labelledby":`accordion-${i}`,"aria-hidden":!a,"data-overflow":!!e.overflow,"data-has-icon":!!e.icon,onScroll:e=>{e.target.scrollTop>0?d(!0):d(!1)},ref:n,$initial:!a,"data-scrolled":u,hidden:!a,children:B(el,{children:B(tl,{"data-max-height":!!l,"data-full":e.fullWidth,style:{maxHeight:l||void 0},children:e.children})})})]})});function ll(e){let{getItemProps:t,onKeyDown:n}=sl(e.items.length,e.singleMode);return B(Jc,{onKeyDown:n,children:e.items.map((n,r)=>B(cl,{overflow:e.overflow,maxHeight:e.maxHeight,...n,...t(r),children:n.children},r))})}function ul(){return B(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`48`,viewBox:`0 -960 960 960`,width:`48`,children:B(`path`,{d:`M220-160q-24 0-42-18t-18-42v-143h60v143h520v-143h60v143q0 24-18 42t-42 18H220Zm260-153L287-506l43-43 120 120v-371h60v371l120-120 43 43-193 193Z`})})}const dl=U.div`
617
+ `,al=(()=>void 0);let ol=0;function sl(){return I(()=>ol++,[])}function cl(e,t=!1){let[n,r]=R([]),i=L(-1),a=t=>{let r=document.activeElement,i=n.findIndex(e=>e.current?.button?.current===r);if(i!==-1)switch(t.code){case`Home`:n[0]&&n[0].current?.focus();break;case`End`:{let t=e-1;n[t]&&n[t].current?.focus();break}case`ArrowDown`:if(i!==e-1){let e=i+1;n[e]&&n[e].current?.focus()}break;case`ArrowUp`:if(i!==0){let e=i-1;n[e]&&n[e].current?.focus()}break;case`ArrowLeft`:{let e=n[i];e&&e.current&&e.current.close();break}case`ArrowRight`:{let e=n[i];e&&e.current&&e.current.open();break}}},o=(e,r)=>{if(t&&r&&e!==i.current){i.current=e;for(let t=0;t<n.length;t++){let r=n[t];t!==e&&r.current?.close()}}};return P(()=>{r(t=>Array(e).fill(0).map((e,n)=>t[n]||Se()))},[e]),{open:e=>{let t=n[e];t&&t.current&&t.current.open()},close:e=>{let t=n[e];t&&t.current&&t.current.close()},toggle:e=>{let t=n[e];t&&t.current&&t.current.toggle()},focus:e=>{let t=n[e];t&&t.current&&t.current.focus()},openAll:()=>{for(let e=0;e<n.length;e++)n[e].current?.open()},closeAll:()=>{for(let e=0;e<n.length;e++)n[e].current?.close()},onKeyDown:a,getItemProps:e=>({ref:n[e],onChange:t=>o(e,t)})}}const ll=Ce(function(e,t){let n=L(null),r=L(null),i=sl(),[a,o]=R(e.initialOpen||!1),s=e.onChange||al,c=()=>{s(!a),o(e=>!e)},l=e.maxHeight,[u,d]=R(!1);return Te(t,()=>({open(){s(!0),o(!0)},close(){s(!1),o(!1)},toggle(){c()},focus(){r.current&&r.current.focus()},button:r})),V(Xc,{"data-large":e.large,"data-open":a,children:[V(il,{"data-open":a,children:[e.icon?B(el,{onClick:c,children:e.icon}):null,V(Qc,{ref:r,onClick:c,"aria-expanded":a,"aria-controls":`accordion-${i}`,children:[e.label,e.description?B(Zc,{children:e.description}):null]}),B($c,{onClick:c,children:B(Fi,{width:`1em`,height:`1em`,rotate:a?0:180})})]}),B(rl,{"aria-labelledby":`accordion-${i}`,"aria-hidden":!a,"data-overflow":!!e.overflow,"data-has-icon":!!e.icon,onScroll:e=>{e.target.scrollTop>0?d(!0):d(!1)},ref:n,$initial:!a,"data-scrolled":u,hidden:!a,children:B(tl,{children:B(nl,{"data-max-height":!!l,"data-full":e.fullWidth,style:{maxHeight:l||void 0},children:e.children})})})]})});function ul(e){let{getItemProps:t,onKeyDown:n}=cl(e.items.length,e.singleMode);return B(Yc,{onKeyDown:n,children:e.items.map((n,r)=>B(ll,{overflow:e.overflow,maxHeight:e.maxHeight,...n,...t(r),children:n.children},r))})}function dl(){return B(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`48`,viewBox:`0 -960 960 960`,width:`48`,children:B(`path`,{d:`M220-160q-24 0-42-18t-18-42v-143h60v143h520v-143h60v143q0 24-18 42t-42 18H220Zm260-153L287-506l43-43 120 120v-371h60v371l120-120 43 43-193 193Z`})})}const fl=U.div`
618
618
  padding: 0.3em;
619
619
 
620
620
  display: flex;
@@ -636,12 +636,12 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
636
636
  position: sticky;
637
637
  bottom: 0;
638
638
  }
639
- `;function fl(e){let t=Ue(),n=H(),r=Ka(),i=I(()=>JSON.stringify(n.toPresentation3(t),null,2),[t,n]),a=I(()=>JSON.stringify(n.toPresentation2(t),null,2),[t,n]);return B(qc,{title:`Export manifest`,close:r.centerPanel.popStack,children:B(`div`,{style:{flex:1,overflowY:`auto`},children:B(ll,{items:[{label:`Presentation 3`,description:`Download this version by clicking the "Download" button.`,maxHeight:400,large:!0,initialOpen:!0,overflow:!0,icon:B(oa,{onClick:()=>gr(i,`manifest.json`),children:B(ul,{})}),children:V(`div`,{style:{maxWidth:`100%`},children:[B(`pre`,{style:{whiteSpace:`pre-wrap`},children:JSON.stringify(n.toPresentation3(t),null,2)}),V(dl,{"data-sticky":`true`,children:[B(oa,{onClick:()=>_r(i),children:`Copy to clipboard`}),B(oa,{onClick:()=>gr(i,`manifest.json`),children:`Download`})]})]})},{label:`Presentation 2`,description:`Download this version by clicking the "Download" button.`,maxHeight:400,large:!0,icon:B(oa,{onClick:()=>gr(a,`manifest.json`),children:B(ul,{})}),children:V(`div`,{style:{maxWidth:`100%`},children:[B(`pre`,{style:{whiteSpace:`pre-wrap`},children:JSON.stringify(n.toPresentation2(t),null,2)}),V(dl,{"data-sticky":`true`,children:[B(oa,{onClick:()=>_r(a),children:`Copy to clipboard`}),B(oa,{onClick:()=>gr(a,`manifest.json`),children:`Download`})]})]})}]})})})}function pl({key:e,initialValue:t,requestId:n,getInitialValue:r}){let[i,a]=Ve({requestId:n}),[o,s]=R(r&&r(i)||i[e]||t);return[o,M(t=>{a({[e]:t}),s(t)},[])]}const ml=ft(),hl=j(ml);function gl({children:e,emitter:t}){return B(hl.Provider,{value:t,children:e})}function _l(){return N(hl)}function vl(e,t,n=[]){let r=N(hl);P(()=>{let n=e=>{t(e)};return r.on(e,n),()=>{r.off(e,n)}},[r,e,...n])}function yl(e,t=[]){let n=t.length?t:Array(e.length).fill(!1);if(typeof window>`u`)return n;let r=e.map(e=>window.matchMedia(e)),i=()=>r.map(e=>e.matches),[a,o]=R(i);return F(()=>{let e=()=>o(i);return r.forEach(t=>t.addListener(e)),()=>r.forEach(t=>t.removeListener(e))},[]),a}function bl(e,t,n,r=!0){let i=pt(t,n);P(()=>typeof window>`u`?()=>void 0:(window.addEventListener(`beforeunload`,t,!1),()=>{t(),window.removeEventListener(`beforeunload`,t)}),[t]),P(()=>{if(e&&r)return e.subscribe(i,!0)},[i,e,r])}function xl(){let e=Be(),t=ke(e,e=>e.switchTool),n=ke(e,e=>e.polygonState.currentTool),r=ke(e,e=>e.polygonState.selectedStamp),i=ke(e,e=>e.polygonState.showBoundingBox);return I(()=>({currentTool:n,selectedStamp:r,draw:{active:n===`pencil`,enable:t.draw},polygon:{active:n===`pen`,enable:t.pen},line:{active:n===`line`,enable:t.line},lineBox:{active:n===`lineBox`,enable:t.lineBox},square:{active:n===`box`,enable:t.box},triangle:{active:r?.id===`triangle`,enable:t.triangle},hexagon:{active:r?.id===`hexagon`,enable:t.hexagon},circle:{active:r?.id===`circle`,enable:t.circle},remove:{active:i,enable:t.remove}}),[i,r,n,t])}const Sl=U.div`
639
+ `;function pl(e){let t=Ue(),n=H(),r=Ka(),i=I(()=>JSON.stringify(n.toPresentation3(t),null,2),[t,n]),a=I(()=>JSON.stringify(n.toPresentation2(t),null,2),[t,n]);return B(Jc,{title:`Export manifest`,close:r.centerPanel.popStack,children:B(`div`,{style:{flex:1,overflowY:`auto`},children:B(ul,{items:[{label:`Presentation 3`,description:`Download this version by clicking the "Download" button.`,maxHeight:400,large:!0,initialOpen:!0,overflow:!0,icon:B(oa,{onClick:()=>hr(i,`manifest.json`),children:B(dl,{})}),children:V(`div`,{style:{maxWidth:`100%`},children:[B(`pre`,{style:{whiteSpace:`pre-wrap`},children:JSON.stringify(n.toPresentation3(t),null,2)}),V(fl,{"data-sticky":`true`,children:[B(oa,{onClick:()=>gr(i),children:`Copy to clipboard`}),B(oa,{onClick:()=>hr(i,`manifest.json`),children:`Download`})]})]})},{label:`Presentation 2`,description:`Download this version by clicking the "Download" button.`,maxHeight:400,large:!0,icon:B(oa,{onClick:()=>hr(a,`manifest.json`),children:B(dl,{})}),children:V(`div`,{style:{maxWidth:`100%`},children:[B(`pre`,{style:{whiteSpace:`pre-wrap`},children:JSON.stringify(n.toPresentation2(t),null,2)}),V(fl,{"data-sticky":`true`,children:[B(oa,{onClick:()=>gr(a),children:`Copy to clipboard`}),B(oa,{onClick:()=>hr(a,`manifest.json`),children:`Download`})]})]})}]})})})}function ml({key:e,initialValue:t,requestId:n,getInitialValue:r}){let[i,a]=Ve({requestId:n}),[o,s]=R(r&&r(i)||i[e]||t);return[o,M(t=>{a({[e]:t}),s(t)},[])]}const hl=ft(),gl=j(hl);function _l({children:e,emitter:t}){return B(gl.Provider,{value:t,children:e})}function vl(){return N(gl)}function yl(e,t,n=[]){let r=N(gl);P(()=>{let n=e=>{t(e)};return r.on(e,n),()=>{r.off(e,n)}},[r,e,...n])}function bl(e,t=[]){let n=t.length?t:Array(e.length).fill(!1);if(typeof window>`u`)return n;let r=e.map(e=>window.matchMedia(e)),i=()=>r.map(e=>e.matches),[a,o]=R(i);return F(()=>{let e=()=>o(i);return r.forEach(t=>t.addListener(e)),()=>r.forEach(t=>t.removeListener(e))},[]),a}function xl(e,t,n,r=!0){let i=pt(t,n);P(()=>typeof window>`u`?()=>void 0:(window.addEventListener(`beforeunload`,t,!1),()=>{t(),window.removeEventListener(`beforeunload`,t)}),[t]),P(()=>{if(e&&r)return e.subscribe(i,!0)},[i,e,r])}function Sl(){let e=Be(),t=ke(e,e=>e.switchTool),n=ke(e,e=>e.polygonState.currentTool),r=ke(e,e=>e.polygonState.selectedStamp),i=ke(e,e=>e.polygonState.showBoundingBox);return I(()=>({currentTool:n,selectedStamp:r,draw:{active:n===`pencil`,enable:t.draw},polygon:{active:n===`pen`,enable:t.pen},line:{active:n===`line`,enable:t.line},lineBox:{active:n===`lineBox`,enable:t.lineBox},square:{active:n===`box`,enable:t.box},triangle:{active:r?.id===`triangle`,enable:t.triangle},hexagon:{active:r?.id===`hexagon`,enable:t.hexagon},circle:{active:r?.id===`circle`,enable:t.circle},remove:{active:i,enable:t.remove}}),[i,r,n,t])}const Cl=U.div`
640
640
  position: relative;
641
641
  width: 1px;
642
642
  background: rgba(0, 0, 0, 0.2);
643
643
  z-index: 50;
644
- `,Cl=U(aa)`
644
+ `,wl=U(aa)`
645
645
  transition:
646
646
  opacity 300ms,
647
647
  transform 300ms;
@@ -653,7 +653,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
653
653
  &:focus {
654
654
  outline: 2px solid salmon;
655
655
  }
656
- `;U(Cl)`
656
+ `;U(wl)`
657
657
  background: #fff;
658
658
  width: 30px;
659
659
  height: 30px;
@@ -667,7 +667,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
667
667
  svg {
668
668
  fill: #9999;
669
669
  }
670
- `;const wl=U(Cl)`
670
+ `;const Tl=U(wl)`
671
671
  position: relative;
672
672
  display: flex;
673
673
  opacity: 1;
@@ -694,7 +694,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
694
694
  svg {
695
695
  font-size: 1.5em;
696
696
  }
697
- `,Tl=U.div`
697
+ `,El=U.div`
698
698
  background: rgba(0, 0, 0, 0);
699
699
  position: absolute;
700
700
  width: 16px;
@@ -717,12 +717,12 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
717
717
  &:hover {
718
718
  transform: scaleX(100%);
719
719
  background: rgba(0, 0, 0, 0.1);
720
- ${Cl} {
720
+ ${wl} {
721
721
  transform: scaleX(100%);
722
722
  opacity: 1;
723
723
  }
724
724
  }
725
- `,El=U.div`
725
+ `,Dl=U.div`
726
726
  background: rgba(0, 0, 0, 0);
727
727
  position: absolute;
728
728
  pointer-events: none;
@@ -731,7 +731,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
731
731
  top: 0;
732
732
  bottom: 0;
733
733
  z-index: 51; // This will always be quite high.
734
- `,Dl=Ce(function({dir:e,open:t,actions:n,reset:r},i){let[a,o]=R(!0),s=`mt-[calc(50vh+8px)]`,c=e===`left`?`${s} ml-[13px]`:`${s} ml-[3px]`;return V(Sl,{onClick:()=>n.open(),children:[B(El,{$open:t,$dir:e,className:`group`,children:t?null:V(fe,{placement:e===`left`?`right`:`left`,children:[B(pe,{"aria-label":`Open ${e} panel`,as:wl,$dir:e,onClick:e=>n.open(),children:B(Ii,{"aria-hidden":`true`,className:`text-2xl`,rotate:e===`right`?90:270})}),B(v,{children:`Open`})]})}),V(fe,{placement:e===`left`?`right`:`left`,children:[B(pe,{asChild:!0,children:B(`div`,{children:V(Tl,{ref:i,$open:t,$dir:e,className:`group`,children:[t?V(fe,{placement:e===`left`?`right`:`left`,children:[B(pe,{"aria-label":`Close ${e} panel`,as:T,onPress:()=>n.close(),children:B(`div`,{onMouseOut:()=>{o(!0)},onMouseOver:()=>{o(!1)},children:B(Fi,{"aria-hidden":`true`})})}),B(v,{children:`Close`})]}):null,r&&t?V(fe,{placement:e===`left`?`right`:`left`,children:[B(pe,{"aria-label":`Reset ${e} panel size`,as:T,onPress:()=>r(),children:B(`div`,{onMouseOut:()=>{o(!0)},onMouseOver:()=>{o(!1)},children:B(te,{"aria-hidden":`true`})})}),B(v,{children:`Reset`})]}):null,t?V(fe,{placement:e===`left`?`right`:`left`,children:[B(pe,{asChild:!0,children:B(`div`,{onMouseOut:()=>{o(!0)},onMouseOver:()=>{o(!1)},children:B(ne,{"aria-label":`Resize panel`})})}),B(v,{children:`Resize panel`})]}):null]})})}),a&&B(v,{className:c,children:`Resize panel`})]})]})});function Ol(e){return B(`svg`,{width:`1em`,height:`1em`,viewBox:`0 0 42 42`,xmlns:`http://www.w3.org/2000/svg`,stroke:`currentColor`,...e,children:V(`g`,{transform:`translate(2 2)`,strokeWidth:5,fill:`none`,fillRule:`evenodd`,children:[B(`circle`,{strokeOpacity:.5,cx:18,cy:18,r:18}),B(`path`,{d:`M36 18c0-9.94-8.06-18-18-18`,children:B(`animateTransform`,{attributeName:`transform`,type:`rotate`,from:`0 18 18`,to:`360 18 18`,dur:`1s`,repeatCount:`indefinite`})})]})})}var kl={ghostLoadingBlock:`_ghostLoadingBlock_1i1t4_1`,"ghost-loading":`_ghost-loading_1i1t4_1`,ghostLoading:`_ghost-loading_1i1t4_1`,ghostBlockList:`_ghostBlockList_1i1t4_28`};function Al(){return V(z,{children:[B(`div`,{"data-header":`true`,className:kl.ghostLoadingBlock}),V(`div`,{className:kl.ghostBlockList,children:[B(`div`,{className:kl.ghostLoadingBlock}),B(`div`,{className:kl.ghostLoadingBlock}),B(`div`,{className:kl.ghostLoadingBlock}),B(`div`,{className:kl.ghostLoadingBlock})]})]})}function jl(e,t,n,r=[]){F(()=>{let r=e.current;if(r)return r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}},[t,...r])}function Ml(e,t,n,r){return Math.sqrt(Math.abs(n-e)**2+Math.abs(r-t)**2)}function Nl(e,t,n,r){return n||(r?r/e:t)}function Pl(e,t={}){let n=L(null),r=L(null),i=L(null),a=L(null),o=L(.5),[s,c]=R(!1),l=L(!1),u=L(0),d=L({x:0,y:0}),[{widthA:f,widthB:p},m]=me(`resize-layout/${e}`,{widthA:`auto`,widthB:`${zs({initial:t.widthA,fallback:320,options:{minWidth:t.minWidthPx,maxWidth:t.maxWidthPx}})}px`}),{loading:h=!1}=t;return jl(a,`mousedown`,e=>{d.current.x=e.pageX,d.current.y=e.pageY,u.current&&(clearTimeout(u.current),u.current=0),u.current=setTimeout(()=>{c(!0),l.current=!0},350)},[h]),jl({current:typeof window<`u`?window:void 0},`mouseup`,()=>{let e=n.current;if(e&&l.current){let{x:n,width:r}=e.getBoundingClientRect(),i=t.marginLeft||0,a=Nl(r,.8,t.maxWidthPct,t.maxWidthPx)*r,s=Nl(r,.2,t.minWidthPct,t.minWidthPx)*r;if(t.left){let e=o.current*r-i;m({widthA:`${(1-o.current)*r-i}`,widthB:`${e>a?a:e<s?s:e}px`})}else{let e=1-o.current*r-i;m({widthA:`${e>a?a:e<s?s:e}px`,widthB:`${o.current*r-i}px`})}c(!1),l.current=!1,t.onDragEnd&&t.onDragEnd()}clearTimeout(u.current),u.current=0},[h]),jl(n,`mousemove`,e=>{if(!l.current&&u.current&&Ml(d.current.x,d.current.y,e.pageX,e.pageY)>20&&(c(!0),l.current=!0,clearTimeout(u.current),u.current=0),l.current&&r.current){let i=n.current;if(i){let{x:n,width:a}=i.getBoundingClientRect(),s=t.marginLeft||0,c=t.left||!1,l=Nl(a,.8,t.maxWidthPct,t.maxWidthPx),u=Nl(a,.2,t.minWidthPct,t.minWidthPx);o.current=(a+n-e.pageX-5)/a,c&&(o.current=1-o.current),o.current=o.current<u?u:o.current,o.current=o.current>l?l:o.current,r.current.style.width=`${o.current*a-s}px`}}},[s,h]),{refs:{container:n,resizer:a,resizableDiv:r,otherDiv:i},setWidths:m,isDragging:s,widthA:f,widthB:p}}const Z=`.manifest-editor.exhibition-focused &`,Q=`[data-exhibition-theme="dark"] ${Z}`,$={pink:`#b84c74`,pinkHover:`#9f3f64`,lightApp:`#f4f1ec`,lightStage:`#dfdbd4`,lightPanel:`#fff`,lightPanelSoft:`#f8f6f3`,lightBorder:`#dcd5ce`,lightPanelBorder:`#ddd5ce`,lightText:`#25211f`,lightMuted:`#6a625c`,darkApp:`#18161d`,darkStage:`#0e0d12`,darkPanel:`#28222d`,darkPanelSoft:`#2f2934`,darkPanelHeader:`#25222b`,darkHover:`#312c34`,darkSelected:`#3a3440`,darkText:`#f6f1f4`,darkMuted:`#c8c0c6`,darkSubtle:`#999088`,darkLabel:`#d9d1da`,darkWarning:`#4a2636`,darkWarningBorder:`#7a3f59`,darkBorder:`rgba(246, 241, 244, 0.16)`,darkBorderSoft:`rgba(246, 241, 244, 0.14)`},Fl=U.div`
734
+ `,Ol=Ce(function({dir:e,open:t,actions:n,reset:r},i){let[a,o]=R(!0),s=`mt-[calc(50vh+8px)]`,c=e===`left`?`${s} ml-[13px]`:`${s} ml-[3px]`;return V(Cl,{onClick:()=>n.open(),children:[B(Dl,{$open:t,$dir:e,className:`group`,children:t?null:V(fe,{placement:e===`left`?`right`:`left`,children:[B(pe,{"aria-label":`Open ${e} panel`,as:Tl,$dir:e,onClick:e=>n.open(),children:B(Fi,{"aria-hidden":`true`,className:`text-2xl`,rotate:e===`right`?90:270})}),B(v,{children:`Open`})]})}),V(fe,{placement:e===`left`?`right`:`left`,children:[B(pe,{asChild:!0,children:B(`div`,{children:V(El,{ref:i,$open:t,$dir:e,className:`group`,children:[t?V(fe,{placement:e===`left`?`right`:`left`,children:[B(pe,{"aria-label":`Close ${e} panel`,as:T,onPress:()=>n.close(),children:B(`div`,{onMouseOut:()=>{o(!0)},onMouseOver:()=>{o(!1)},children:B(Pi,{"aria-hidden":`true`})})}),B(v,{children:`Close`})]}):null,r&&t?V(fe,{placement:e===`left`?`right`:`left`,children:[B(pe,{"aria-label":`Reset ${e} panel size`,as:T,onPress:()=>r(),children:B(`div`,{onMouseOut:()=>{o(!0)},onMouseOver:()=>{o(!1)},children:B(te,{"aria-hidden":`true`})})}),B(v,{children:`Reset`})]}):null,t?V(fe,{placement:e===`left`?`right`:`left`,children:[B(pe,{asChild:!0,children:B(`div`,{onMouseOut:()=>{o(!0)},onMouseOver:()=>{o(!1)},children:B(ne,{"aria-label":`Resize panel`})})}),B(v,{children:`Resize panel`})]}):null]})})}),a&&B(v,{className:c,children:`Resize panel`})]})]})});function kl(e){return B(`svg`,{width:`1em`,height:`1em`,viewBox:`0 0 42 42`,xmlns:`http://www.w3.org/2000/svg`,stroke:`currentColor`,...e,children:V(`g`,{transform:`translate(2 2)`,strokeWidth:5,fill:`none`,fillRule:`evenodd`,children:[B(`circle`,{strokeOpacity:.5,cx:18,cy:18,r:18}),B(`path`,{d:`M36 18c0-9.94-8.06-18-18-18`,children:B(`animateTransform`,{attributeName:`transform`,type:`rotate`,from:`0 18 18`,to:`360 18 18`,dur:`1s`,repeatCount:`indefinite`})})]})})}var Al={ghostLoadingBlock:`_ghostLoadingBlock_1i1t4_1`,"ghost-loading":`_ghost-loading_1i1t4_1`,ghostLoading:`_ghost-loading_1i1t4_1`,ghostBlockList:`_ghostBlockList_1i1t4_28`};function jl(){return V(z,{children:[B(`div`,{"data-header":`true`,className:Al.ghostLoadingBlock}),V(`div`,{className:Al.ghostBlockList,children:[B(`div`,{className:Al.ghostLoadingBlock}),B(`div`,{className:Al.ghostLoadingBlock}),B(`div`,{className:Al.ghostLoadingBlock}),B(`div`,{className:Al.ghostLoadingBlock})]})]})}function Ml(e,t,n,r=[]){F(()=>{let r=e.current;if(r)return r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}},[t,...r])}function Nl(e,t,n,r){return Math.sqrt(Math.abs(n-e)**2+Math.abs(r-t)**2)}function Pl(e,t,n,r){return n||(r?r/e:t)}function Fl(e,t={}){let n=L(null),r=L(null),i=L(null),a=L(null),o=L(.5),[s,c]=R(!1),l=L(!1),u=L(0),d=L({x:0,y:0}),[{widthA:f,widthB:p},m]=me(`resize-layout/${e}`,{widthA:`auto`,widthB:`${zs({initial:t.widthA,fallback:320,options:{minWidth:t.minWidthPx,maxWidth:t.maxWidthPx}})}px`}),{loading:h=!1}=t;return Ml(a,`mousedown`,e=>{d.current.x=e.pageX,d.current.y=e.pageY,u.current&&(clearTimeout(u.current),u.current=0),u.current=setTimeout(()=>{c(!0),l.current=!0},350)},[h]),Ml({current:typeof window<`u`?window:void 0},`mouseup`,()=>{let e=n.current;if(e&&l.current){let{x:n,width:r}=e.getBoundingClientRect(),i=t.marginLeft||0,a=Pl(r,.8,t.maxWidthPct,t.maxWidthPx)*r,s=Pl(r,.2,t.minWidthPct,t.minWidthPx)*r;if(t.left){let e=o.current*r-i;m({widthA:`${(1-o.current)*r-i}`,widthB:`${e>a?a:e<s?s:e}px`})}else{let e=1-o.current*r-i;m({widthA:`${e>a?a:e<s?s:e}px`,widthB:`${o.current*r-i}px`})}c(!1),l.current=!1,t.onDragEnd&&t.onDragEnd()}clearTimeout(u.current),u.current=0},[h]),Ml(n,`mousemove`,e=>{if(!l.current&&u.current&&Nl(d.current.x,d.current.y,e.pageX,e.pageY)>20&&(c(!0),l.current=!0,clearTimeout(u.current),u.current=0),l.current&&r.current){let i=n.current;if(i){let{x:n,width:a}=i.getBoundingClientRect(),s=t.marginLeft||0,c=t.left||!1,l=Pl(a,.8,t.maxWidthPct,t.maxWidthPx),u=Pl(a,.2,t.minWidthPct,t.minWidthPx);o.current=(a+n-e.pageX-5)/a,c&&(o.current=1-o.current),o.current=o.current<u?u:o.current,o.current=o.current>l?l:o.current,r.current.style.width=`${o.current*a-s}px`}}},[s,h]),{refs:{container:n,resizer:a,resizableDiv:r,otherDiv:i},setWidths:m,isDragging:s,widthA:f,widthB:p}}const Z=`.manifest-editor.exhibition-focused &`,Q=`[data-exhibition-theme="dark"] ${Z}`,$={pink:`#b84c74`,pinkHover:`#9f3f64`,lightApp:`#f4f1ec`,lightStage:`#dfdbd4`,lightPanel:`#fff`,lightPanelSoft:`#f8f6f3`,lightBorder:`#dcd5ce`,lightPanelBorder:`#ddd5ce`,lightText:`#25211f`,lightMuted:`#6a625c`,darkApp:`#18161d`,darkStage:`#0e0d12`,darkPanel:`#28222d`,darkPanelSoft:`#2f2934`,darkPanelHeader:`#25222b`,darkHover:`#312c34`,darkSelected:`#3a3440`,darkText:`#f6f1f4`,darkMuted:`#c8c0c6`,darkSubtle:`#999088`,darkLabel:`#d9d1da`,darkWarning:`#4a2636`,darkWarningBorder:`#7a3f59`,darkBorder:`rgba(246, 241, 244, 0.16)`,darkBorderSoft:`rgba(246, 241, 244, 0.14)`},Il=U.div`
735
735
  display: flex;
736
736
  flex: 1 1 0;
737
737
  min-height: 0;
@@ -745,7 +745,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
745
745
  ${Q} {
746
746
  background: ${$.darkApp};
747
747
  }
748
- `,Il=U.div`
748
+ `,Ll=U.div`
749
749
  flex: 1 1 0;
750
750
  min-width: 0;
751
751
  min-height: 0;
@@ -861,12 +861,12 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
861
861
  background: ${$.darkHover} !important;
862
862
  color: #fff !important;
863
863
  }
864
- `,Ll=U.div`
864
+ `,Rl=U.div`
865
865
  display: flex;
866
866
  flex: 1;
867
867
  justify-content: center;
868
868
  align-items: center;
869
- `,Rl=U.div`
869
+ `,zl=U.div`
870
870
  position: absolute;
871
871
  top: 3rem;
872
872
  z-index: 40;
@@ -896,7 +896,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
896
896
  `:W`
897
897
  right: 1rem;
898
898
  `}
899
- `,zl=U.button`
899
+ `,Bl=U.button`
900
900
  width: 2.35rem;
901
901
  height: 2.35rem;
902
902
  border: 0;
@@ -956,16 +956,16 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
956
956
  width: 2.75rem;
957
957
  height: 2.75rem;
958
958
  }
959
- `,Bl=U.div`
959
+ `,Vl=U.div`
960
960
  display: flex;
961
961
  flex-direction: column;
962
962
  gap: 0.25rem;
963
- `,Vl=U.div`
963
+ `,Hl=U.div`
964
964
  width: 100%;
965
965
  height: 1px;
966
966
  margin: 0.25rem 0;
967
967
  background: rgba(15, 23, 42, 0.14);
968
- `,Hl=U.aside`
968
+ `,Ul=U.aside`
969
969
  position: absolute;
970
970
  top: 3rem;
971
971
  bottom: 1rem;
@@ -1250,13 +1250,13 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
1250
1250
  min-width: 0;
1251
1251
  transform: translateY(${e=>e.$open?`0`:`0.75rem`});
1252
1252
  }
1253
- `,Ul=U.div`
1253
+ `,Wl=U.div`
1254
1254
  display: flex;
1255
1255
  flex: 1;
1256
1256
  min-width: 0;
1257
1257
  height: 100%;
1258
1258
  overflow: hidden;
1259
- `,Wl=U.div`
1259
+ `,Gl=U.div`
1260
1260
  display: flex;
1261
1261
  flex-direction: column;
1262
1262
  flex: 1;
@@ -1265,16 +1265,16 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
1265
1265
  max-width: 100%;
1266
1266
  min-width: 0;
1267
1267
  overflow: hidden;
1268
- `,Gl=U.header`
1268
+ `,Kl=U.header`
1269
1269
  //box-shadow: 0 3px 2px 0 rgba(0, 0, 0, 0.04), 0 1px 0 0 rgba(0, 0, 0, 0.17);
1270
1270
  z-index: 200;
1271
- `,Kl=U.div`
1272
- background: #fff;
1273
1271
  `,ql=U.div`
1272
+ background: #fff;
1273
+ `,Jl=U.div`
1274
1274
  display: flex;
1275
1275
  flex: 1 1 0;
1276
1276
  min-height: 0;
1277
- `,Jl=U.div`
1277
+ `,Yl=U.div`
1278
1278
  background: #fff;
1279
1279
  display: flex;
1280
1280
  flex-direction: column;
@@ -1293,7 +1293,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
1293
1293
  `;case`unmounted`:case`exited`:return W`
1294
1294
  max-width: 0;
1295
1295
  `}}}
1296
- `,Yl=U.div`
1296
+ `,Xl=U.div`
1297
1297
  flex: 1 1 0;
1298
1298
  background: #e3e7f0;
1299
1299
  // background: #efefef;
@@ -1312,7 +1312,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
1312
1312
  > * {
1313
1313
  min-width: 0;
1314
1314
  }
1315
- `,Xl=U.div`
1315
+ `,Zl=U.div`
1316
1316
  background: #fff;
1317
1317
  display: flex;
1318
1318
  flex-direction: column;
@@ -1328,7 +1328,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
1328
1328
  `;case`unmounted`:case`exited`:return W`
1329
1329
  max-width: 0;
1330
1330
  `}}}
1331
- `,Zl=U.div`
1331
+ `,Ql=U.div`
1332
1332
  display: flex;
1333
1333
  flex: 1;
1334
1334
  height: 100%;
@@ -1338,22 +1338,22 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
1338
1338
 
1339
1339
  ${e=>{switch(e.$menu){case`top`:return W`
1340
1340
  flex-direction: column;
1341
- ${Ql} {
1341
+ ${$l} {
1342
1342
  flex-direction: column;
1343
1343
  }
1344
1344
  `;case`left`:return W`
1345
1345
  flex-direction: row;
1346
- ${Ql} {
1346
+ ${$l} {
1347
1347
  flex-direction: row;
1348
1348
  }
1349
1349
  `;default:case`bottom`:return W`
1350
1350
  flex-direction: column-reverse;
1351
- ${Ql} {
1351
+ ${$l} {
1352
1352
  flex-direction: column;
1353
1353
  }
1354
1354
  `;case`right`:return W`
1355
1355
  flex-direction: row-reverse;
1356
- ${Ql} {
1356
+ ${$l} {
1357
1357
  flex-direction: row;
1358
1358
  }
1359
1359
  `}}}
@@ -1394,7 +1394,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
1394
1394
  font-size: 1.5em;
1395
1395
  color: #999;
1396
1396
  }
1397
- `;const Ql=U.div`
1397
+ `;const $l=U.div`
1398
1398
  display: flex;
1399
1399
  box-shadow:
1400
1400
  0 -3px 2px 0 rgba(0, 0, 0, 0.04),
@@ -1403,23 +1403,23 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
1403
1403
  ${e=>!e.$open&&(e.$position===`top`||e.$position===`bottom`)?W`
1404
1404
  display: none;
1405
1405
  `:``}
1406
- `,$l=U.div`
1406
+ `,eu=U.div`
1407
1407
  display: flex;
1408
1408
  flex-direction: column;
1409
1409
  flex: 1;
1410
1410
  min-width: 0;
1411
1411
  overflow: hidden;
1412
- `;function eu(e,t,n){return e.filter(e=>{if(!e.supports)return!0;try{return e.supports(t)}catch(t){return n?.(e,t),!1}})}function tu(e,t){return t?e.some(e=>e.id===t)?t:e[0]?.id||null:null}function nu(e){return e.map(e=>e.id).join(`,`)}function ru(e){let t=e?.resource;return t?.source?.type||t?.type||null}const iu=we(function(e){let t=J(),n=Ci(),r=Y(),i=Ya(),{vault:a}=N(Le),o=a||void 0,s=Ge(e=>e.iiif),{loading:c,state:l,leftPanels:u,centerPanels:d,rightPanels:f,modals:p=[],actions:m}=i,h=e.isLoading||!1,g=I(()=>({rootResource:r,vault:o,app:t,layoutState:l,appState:n}),[r,o,t,l,n,s]),_=I(()=>eu(u,g,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}).filter(e=>!e.focusedMode?.hide),[u,g]),y=I(()=>eu(d,g,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[d,g]),b=I(()=>eu(f,g,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}).filter(e=>!e.focusedMode?.hide),[f,g]),x=I(()=>eu(p,g,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[p,g]),S=I(()=>_.filter(e=>e.modal),[_]),C=I(()=>_.filter(e=>!e.modal),[_]),w=I(()=>[...x,...S],[x,S]),T=I(()=>({...i,leftPanels:_,centerPanels:y,rightPanels:b,modals:w}),[i,_,y,b,w]),E=C.find(e=>e.id===l.leftPanel.current),D=b.find(e=>e.id===l.rightPanel.current),O=y.find(e=>e.id===l.centerPanel.current),k=w.find(e=>e.id===l.modal.current),te=l.modal.open&&S.some(e=>e.id===l.modal.current)?l.modal.current:l.leftPanel.current,ne=l.pinnedRightPanel.pinned?b.find(e=>e.id===l.pinnedRightPanel.current):void 0,re=D&&(ne?.id!==D.id||!ht(l.pinnedRightPanel.state,l.rightPanel.state)),ie=I(()=>({rootResource:r,vault:o,app:t,layoutState:l,appState:n,actions:m}),[r,o,t,l,n,m]),ae=e=>{e.focusedMode?.onSelect?.(ie)},oe=!E||E.focusedMode?.closeOnMainPanelClick!==!1,[A]=yl([`(max-width: 1020px)`]),se=I(()=>(i.background||[]).map((e,t)=>B(ye,{children:e.render()},t)),[i.background]);F(()=>{b.length&&m.rightPanel.change({id:b[0].id}),C.length&&m.leftPanel.change({id:C[0].id}),y.length&&m.centerPanel.change({id:y[0].id}),m.leftPanel.close(),m.rightPanel.close()},[]),F(()=>{if(O&&O.onMount)return O.onMount(l.centerPanel.state||O.defaultState||{},{...T,current:m.centerPanel,vault:o},n)},[l.centerPanel.current,O?.id]),F(()=>{A&&l.leftPanel.open&&l.rightPanel.open&&m.rightPanel.close()},[A,l.leftPanel.open,l.rightPanel.open]),F(()=>{if(!l.leftPanel.open||!l.leftPanel.current)return;let e=_.find(e=>e.id===l.leftPanel.current);e?.focusedMode?.onSelect&&ae(e)},[l.leftPanel.open,l.leftPanel.current,nu(_)]),F(()=>{if(l.leftPanel.current&&!E){let e=tu(C,l.leftPanel.current);e?m.leftPanel.change({id:e}):m.leftPanel.close()}if(l.centerPanel.current&&!O){let e=tu(y,l.centerPanel.current);e?m.centerPanel.change({id:e}):m.centerPanel.close()}if(l.rightPanel.current&&!D){let e=tu(b,l.rightPanel.current);e?m.rightPanel.change({id:e}):m.rightPanel.close()}if(l.modal.current&&!k){let e=tu(w,l.modal.current);e?m.modal.change({id:e}):m.modal.close()}},[l.leftPanel.current,l.centerPanel.current,l.rightPanel.current,l.modal.current,E?.id,O?.id,D?.id,k?.id,nu(C),nu(y),nu(b),nu(w)]),vl(`layout.edit`,e=>{ru(e)===`Canvas`&&!l.rightPanel.open||(b.find(e=>e.id===`@manifest-editor/editor`)?m.rightPanel.open({id:`@manifest-editor/editor`,stacked:!0}):D&&m.rightPanel.open())},[nu(b),D?.id,l.rightPanel.open]);let ce=`4.5rem`,le=`${zs({options:E?.options,fallback:340})}px`,ue=`${zs({options:D?.options,fallback:420})}px`,de={"--manifest-editor-layout-left-sidebar-small":ce,"--manifest-editor-layout-left-sidebar-large":l.leftPanel.open?`calc(${ce} + ${le})`:ce,"--manifest-editor-layout-right-sidebar-small":ce,"--manifest-editor-layout-right-sidebar-large":l.rightPanel.open?`calc(${ce} + ${ue})`:ce};return F(()=>{if(typeof document>`u`)return;let e=document.documentElement,t=Object.keys(de).map(t=>[t,e.style.getPropertyValue(t)]);for(let[t,n]of Object.entries(de))e.style.setProperty(t,n);return()=>{for(let[n,r]of t)r?e.style.setProperty(n,r):e.style.removeProperty(n)}},[le,ue,l.leftPanel.open,l.rightPanel.open]),c?null:B(Wa.Provider,{value:`focused`,children:V(Wl,{id:e.htmlId||`manifest-editor-container`,className:`manifest-editor ${e.className||``}`,"data-layout-mode":`focused`,style:de,children:[e.hideHeader?null:V(Gl,{children:[e.header||null,e.menu?B(`menu`,{children:e.menu}):null]}),V(Fl,{children:[B(Il,{onClick:()=>{oe&&m.leftPanel.close()},children:V(Zl,{$menu:e.centerPanelMenuPosition||`top`,children:[e.centerPanelMenu?B(Ql,{$open:l.centerPanel.open,$position:e.centerPanelMenuPosition||`top`,children:e.centerPanelMenu}):null,B($l,{children:B(at,{resetKeys:[O?.id],FallbackComponent:Vs,children:h?B(Ll,{children:B(Ol,{stroke:`rgba(0,0,0,.3)`,fontSize:`2em`})}):l.centerPanel.open&&O?Bs(O.render(l.centerPanel.state||O.defaultState||{},{...T,current:m.centerPanel,vault:o},n)):null})})]})}),!y.length&&!_.length?null:V(Rl,{$side:`left`,"aria-label":`Main and left panels`,children:[y.length?B(Bl,{"aria-label":`Main panels`,children:y.filter(e=>!e.focusedMode?.hide).map(e=>V(fe,{placement:`right`,children:[B(pe,{asChild:!0,children:B(zl,{type:`button`,"aria-label":e.label,"data-selected":l.centerPanel.current===e.id,onClick:()=>{m.centerPanel.open({id:e.id}),m.leftPanel.close(),m.rightPanel.close(),ae(e)},children:e.icon||e.label.slice(0,1)})}),B(v,{children:e.label})]},e.id))}):null,y.length&&_.length?B(Vl,{}):null,_.length?B(Bl,{"aria-label":`Left panels`,children:_.map(e=>V(fe,{placement:`right`,children:[B(pe,{asChild:!0,children:B(zl,{type:`button`,"aria-label":e.label,"data-selected":te===e.id,onClick:()=>{if(e.modal){A&&m.rightPanel.close(),l.modal.open&&l.modal.current===e.id?m.modal.close():(m.modal.open({id:e.id,state:e.defaultState}),ae(e));return}A&&m.rightPanel.close(),l.leftPanel.current===e.id?m.leftPanel.toggle():m.leftPanel.open({id:e.id})},children:e.icon||e.label.slice(0,1)})}),B(v,{children:e.label})]},e.id))}):null]}),((e,t,n)=>{if(!t.length)return null;let r=e===`left`?m.leftPanel:m.rightPanel;return B(Rl,{$side:e,"aria-label":`${e} panels`,children:t.map(t=>V(fe,{placement:e===`left`?`right`:`left`,children:[B(pe,{asChild:!0,children:B(zl,{type:`button`,"aria-label":t.label,"data-selected":n===t.id,onClick:()=>{A&&(e===`left`?m.rightPanel.close():m.leftPanel.close()),n===t.id?r.toggle():r.open({id:t.id})},children:t.icon||t.label.slice(0,1)})}),B(v,{children:t.label})]},t.id))})})(`right`,b,l.rightPanel.current),C.length>0?B(Hl,{$side:`left`,$open:l.leftPanel.open,style:{width:le,minWidth:E?.options?.minWidth,maxWidth:E?.options?.maxWidth},children:B(Ul,{children:h?B($l,{children:B(Al,{})}):V(z,{children:[e.leftPanelMenu?B(Ql,{$open:l.leftPanel.open,$position:e.leftPanelMenuPosition||`bottom`,children:e.leftPanelMenu}):null,B($l,{children:E?B(Xs,{isLeft:!0,panel:E,state:l.leftPanel,actions:m.leftPanel}):null})]})})}):null,b.length>0?B(Hl,{$side:`right`,$open:l.rightPanel.open,style:{width:ue,minWidth:D?.options?.minWidth,maxWidth:D?.options?.maxWidth},children:B(Ul,{children:h?B($l,{children:B(Al,{})}):V(z,{children:[e.rightPanelMenu?B(Ql,{$open:l.rightPanel.open,$position:e.rightPanelMenuPosition||`bottom`,children:e.rightPanelMenu}):null,V($l,{children:[re?B(Xs,{panel:D,state:l.rightPanel,actions:m.rightPanel,pinActions:m.pinnedRightPanel,available:b}):null,ne?B(Xs,{panel:ne,state:l.pinnedRightPanel,actions:m.pinnedRightPanel,close:m.rightPanel.close}):null]})]})})}):null]}),B(Kl,{children:e.footer||null}),B(`div`,{className:`hidden`,children:se}),B(Lo,{}),B(Ro,{}),B(z,{children:k?B(ee,{title:k.label,open:l.modal.open,onClose:()=>m.modal.close(),children:k.modal?B(`div`,{className:`h-[70vh] min-h-[60vh] max-h-full flex w-full`,children:B(Xs,{isLeft:!0,isModal:!0,noHeader:!0,panel:k,state:l.modal,actions:m.modal})}):Bs(k.render(l.modal.state||k.defaultState||{},{...T,current:m.modal,vault:o,isModal:!0},n))}):null}),B(us,{})]})})}),au=U.div`
1412
+ `;function tu(e,t,n){return e.filter(e=>{if(!e.supports)return!0;try{return e.supports(t)}catch(t){return n?.(e,t),!1}})}function nu(e,t){return t?e.some(e=>e.id===t)?t:e[0]?.id||null:null}function ru(e){return e.map(e=>e.id).join(`,`)}function iu(e){let t=e?.resource;return t?.source?.type||t?.type||null}const au=we(function(e){let t=Y(),n=Si(),r=Hi(),i=Ya(),{vault:a}=N(Le),o=a||void 0,s=Ge(e=>e.iiif),{loading:c,state:l,leftPanels:u,centerPanels:d,rightPanels:f,modals:p=[],actions:m}=i,h=e.isLoading||!1,g=I(()=>({rootResource:r,vault:o,app:t,layoutState:l,appState:n}),[r,o,t,l,n,s]),_=I(()=>tu(u,g,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}).filter(e=>!e.focusedMode?.hide),[u,g]),y=I(()=>tu(d,g,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[d,g]),b=I(()=>tu(f,g,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}).filter(e=>!e.focusedMode?.hide),[f,g]),x=I(()=>tu(p,g,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[p,g]),S=I(()=>_.filter(e=>e.modal),[_]),C=I(()=>_.filter(e=>!e.modal),[_]),w=I(()=>[...x,...S],[x,S]),T=I(()=>({...i,leftPanels:_,centerPanels:y,rightPanels:b,modals:w}),[i,_,y,b,w]),E=C.find(e=>e.id===l.leftPanel.current),D=b.find(e=>e.id===l.rightPanel.current),O=y.find(e=>e.id===l.centerPanel.current),k=w.find(e=>e.id===l.modal.current),te=l.modal.open&&S.some(e=>e.id===l.modal.current)?l.modal.current:l.leftPanel.current,ne=l.pinnedRightPanel.pinned?b.find(e=>e.id===l.pinnedRightPanel.current):void 0,re=D&&(ne?.id!==D.id||!ht(l.pinnedRightPanel.state,l.rightPanel.state)),ie=I(()=>({rootResource:r,vault:o,app:t,layoutState:l,appState:n,actions:m}),[r,o,t,l,n,m]),ae=e=>{e.focusedMode?.onSelect?.(ie)},oe=!E||E.focusedMode?.closeOnMainPanelClick!==!1,[A]=bl([`(max-width: 1020px)`]),se=I(()=>(i.background||[]).map((e,t)=>B(ye,{children:e.render()},t)),[i.background]);F(()=>{b.length&&m.rightPanel.change({id:b[0].id}),C.length&&m.leftPanel.change({id:C[0].id}),y.length&&m.centerPanel.change({id:y[0].id}),m.leftPanel.close(),m.rightPanel.close()},[]),F(()=>{if(O&&O.onMount)return O.onMount(l.centerPanel.state||O.defaultState||{},{...T,current:m.centerPanel,vault:o},n)},[l.centerPanel.current,O?.id]),F(()=>{A&&l.leftPanel.open&&l.rightPanel.open&&m.rightPanel.close()},[A,l.leftPanel.open,l.rightPanel.open]),F(()=>{if(!l.leftPanel.open||!l.leftPanel.current)return;let e=_.find(e=>e.id===l.leftPanel.current);e?.focusedMode?.onSelect&&ae(e)},[l.leftPanel.open,l.leftPanel.current,ru(_)]),F(()=>{if(l.leftPanel.current&&!E){let e=nu(C,l.leftPanel.current);e?m.leftPanel.change({id:e}):m.leftPanel.close()}if(l.centerPanel.current&&!O){let e=nu(y,l.centerPanel.current);e?m.centerPanel.change({id:e}):m.centerPanel.close()}if(l.rightPanel.current&&!D){let e=nu(b,l.rightPanel.current);e?m.rightPanel.change({id:e}):m.rightPanel.close()}if(l.modal.current&&!k){let e=nu(w,l.modal.current);e?m.modal.change({id:e}):m.modal.close()}},[l.leftPanel.current,l.centerPanel.current,l.rightPanel.current,l.modal.current,E?.id,O?.id,D?.id,k?.id,ru(C),ru(y),ru(b),ru(w)]),yl(`layout.edit`,e=>{iu(e)===`Canvas`&&!l.rightPanel.open||(b.find(e=>e.id===`@manifest-editor/editor`)?m.rightPanel.open({id:`@manifest-editor/editor`,stacked:!0}):D&&m.rightPanel.open())},[ru(b),D?.id,l.rightPanel.open]);let ce=`4.5rem`,le=`${zs({options:E?.options,fallback:340})}px`,ue=`${zs({options:D?.options,fallback:420})}px`,de={"--manifest-editor-layout-left-sidebar-small":ce,"--manifest-editor-layout-left-sidebar-large":l.leftPanel.open?`calc(${ce} + ${le})`:ce,"--manifest-editor-layout-right-sidebar-small":ce,"--manifest-editor-layout-right-sidebar-large":l.rightPanel.open?`calc(${ce} + ${ue})`:ce};return F(()=>{if(typeof document>`u`)return;let e=document.documentElement,t=Object.keys(de).map(t=>[t,e.style.getPropertyValue(t)]);for(let[t,n]of Object.entries(de))e.style.setProperty(t,n);return()=>{for(let[n,r]of t)r?e.style.setProperty(n,r):e.style.removeProperty(n)}},[le,ue,l.leftPanel.open,l.rightPanel.open]),c?null:B(Wa.Provider,{value:`focused`,children:V(Gl,{id:e.htmlId||`manifest-editor-container`,className:`manifest-editor ${e.className||``}`,"data-layout-mode":`focused`,style:de,children:[e.hideHeader?null:V(Kl,{children:[e.header||null,e.menu?B(`menu`,{children:e.menu}):null]}),V(Il,{children:[B(Ll,{onClick:()=>{oe&&m.leftPanel.close()},children:V(Ql,{$menu:e.centerPanelMenuPosition||`top`,children:[e.centerPanelMenu?B($l,{$open:l.centerPanel.open,$position:e.centerPanelMenuPosition||`top`,children:e.centerPanelMenu}):null,B(eu,{children:B(at,{resetKeys:[O?.id],FallbackComponent:Vs,children:h?B(Rl,{children:B(kl,{stroke:`rgba(0,0,0,.3)`,fontSize:`2em`})}):l.centerPanel.open&&O?Bs(O.render(l.centerPanel.state||O.defaultState||{},{...T,current:m.centerPanel,vault:o},n)):null})})]})}),!y.length&&!_.length?null:V(zl,{$side:`left`,"aria-label":`Main and left panels`,children:[y.length?B(Vl,{"aria-label":`Main panels`,children:y.filter(e=>!e.focusedMode?.hide).map(e=>V(fe,{placement:`right`,children:[B(pe,{asChild:!0,children:B(Bl,{type:`button`,"aria-label":e.label,"data-selected":l.centerPanel.current===e.id,onClick:()=>{m.centerPanel.open({id:e.id}),m.leftPanel.close(),m.rightPanel.close(),ae(e)},children:e.icon||e.label.slice(0,1)})}),B(v,{children:e.label})]},e.id))}):null,y.length&&_.length?B(Hl,{}):null,_.length?B(Vl,{"aria-label":`Left panels`,children:_.map(e=>V(fe,{placement:`right`,children:[B(pe,{asChild:!0,children:B(Bl,{type:`button`,"aria-label":e.label,"data-selected":te===e.id,onClick:()=>{if(e.modal){A&&m.rightPanel.close(),l.modal.open&&l.modal.current===e.id?m.modal.close():(m.modal.open({id:e.id,state:e.defaultState}),ae(e));return}A&&m.rightPanel.close(),l.leftPanel.current===e.id?m.leftPanel.toggle():m.leftPanel.open({id:e.id})},children:e.icon||e.label.slice(0,1)})}),B(v,{children:e.label})]},e.id))}):null]}),((e,t,n)=>{if(!t.length)return null;let r=e===`left`?m.leftPanel:m.rightPanel;return B(zl,{$side:e,"aria-label":`${e} panels`,children:t.map(t=>V(fe,{placement:e===`left`?`right`:`left`,children:[B(pe,{asChild:!0,children:B(Bl,{type:`button`,"aria-label":t.label,"data-selected":n===t.id,onClick:()=>{A&&(e===`left`?m.rightPanel.close():m.leftPanel.close()),n===t.id?r.toggle():r.open({id:t.id})},children:t.icon||t.label.slice(0,1)})}),B(v,{children:t.label})]},t.id))})})(`right`,b,l.rightPanel.current),C.length>0?B(Ul,{$side:`left`,$open:l.leftPanel.open,style:{width:le,minWidth:E?.options?.minWidth,maxWidth:E?.options?.maxWidth},children:B(Wl,{children:h?B(eu,{children:B(jl,{})}):V(z,{children:[e.leftPanelMenu?B($l,{$open:l.leftPanel.open,$position:e.leftPanelMenuPosition||`bottom`,children:e.leftPanelMenu}):null,B(eu,{children:E?B(Xs,{isLeft:!0,panel:E,state:l.leftPanel,actions:m.leftPanel}):null})]})})}):null,b.length>0?B(Ul,{$side:`right`,$open:l.rightPanel.open,style:{width:ue,minWidth:D?.options?.minWidth,maxWidth:D?.options?.maxWidth},children:B(Wl,{children:h?B(eu,{children:B(jl,{})}):V(z,{children:[e.rightPanelMenu?B($l,{$open:l.rightPanel.open,$position:e.rightPanelMenuPosition||`bottom`,children:e.rightPanelMenu}):null,V(eu,{children:[re?B(Xs,{panel:D,state:l.rightPanel,actions:m.rightPanel,pinActions:m.pinnedRightPanel,available:b}):null,ne?B(Xs,{panel:ne,state:l.pinnedRightPanel,actions:m.pinnedRightPanel,close:m.rightPanel.close}):null]})]})})}):null]}),B(ql,{children:e.footer||null}),B(`div`,{className:`hidden`,children:se}),B(Lo,{}),B(Ro,{}),B(z,{children:k?B(ee,{title:k.label,open:l.modal.open,onClose:()=>m.modal.close(),children:k.modal?B(`div`,{className:`h-[70vh] min-h-[60vh] max-h-full flex w-full`,children:B(Xs,{isLeft:!0,isModal:!0,noHeader:!0,panel:k,state:l.modal,actions:m.modal})}):Bs(k.render(l.modal.state||k.defaultState||{},{...T,current:m.modal,vault:o,isModal:!0},n))}):null}),B(us,{})]})})}),ou=U.div`
1413
1413
  position: relative;
1414
1414
  display: flex;
1415
1415
  flex: 1;
1416
1416
  overflow: hidden;
1417
1417
  flex-direction: column;
1418
- `,ou=U.div`
1418
+ `,su=U.div`
1419
1419
  flex: 1;
1420
1420
  position: relative;
1421
1421
  z-index: 7;
1422
- `,su=U.div`
1422
+ `,cu=U.div`
1423
1423
  display: flex;
1424
1424
  gap: 0.5rem;
1425
1425
  width: 100%;
@@ -1428,7 +1428,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
1428
1428
  padding: 0.5rem;
1429
1429
  min-height: 4rem;
1430
1430
  z-index: 9;
1431
- `,cu=U.button`
1431
+ `,lu=U.button`
1432
1432
  flex: 1;
1433
1433
  min-width: 0;
1434
1434
  padding: 0.75rem 1rem;
@@ -1439,11 +1439,11 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
1439
1439
  overflow: hidden;
1440
1440
  text-overflow: ellipsis;
1441
1441
  white-space: nowrap;
1442
- `,lu=U.div`
1442
+ `,uu=U.div`
1443
1443
  display: flex;
1444
1444
  flex: 1;
1445
1445
  min-width: 0;
1446
- `,uu=U.button`
1446
+ `,du=U.button`
1447
1447
  display: flex;
1448
1448
  align-items: center;
1449
1449
  justify-content: center;
@@ -1463,7 +1463,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
1463
1463
  flex: 0 0 auto;
1464
1464
  font-size: 1.25em;
1465
1465
  }
1466
- `,du=U.div`
1466
+ `,fu=U.div`
1467
1467
  background: #fff;
1468
1468
  display: flex;
1469
1469
  position: absolute;
@@ -1494,7 +1494,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
1494
1494
  padding-right: 0.5em;
1495
1495
  font-size: 1.1em;
1496
1496
  }
1497
- `,fu=U.div`
1497
+ `,pu=U.div`
1498
1498
  display: flex;
1499
1499
  flex-direction: column;
1500
1500
  position: absolute;
@@ -1510,7 +1510,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
1510
1510
  ${e=>e.$open&&W`
1511
1511
  transform: translateX(0);
1512
1512
  `}
1513
- `,pu=U.button`
1513
+ `,mu=U.button`
1514
1514
  border: 0;
1515
1515
  background: rgba(0, 0, 0, 0.4);
1516
1516
  pointer-events: none;
@@ -1527,6 +1527,6 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
1527
1527
  pointer-events: visible;
1528
1528
  opacity: 1;
1529
1529
  `}
1530
- `,mu=we(function(e){if(e.layoutMode===`focused`)return B(iu,{...e});let t=J(),n=Ci(),r=Y(),i=Ya(),{vault:a}=N(Le),o=a||void 0,s=Ge(e=>e.iiif),c=L(null),l=L(null),{loading:u,state:d,leftPanels:f,centerPanels:p,rightPanels:m,modals:h=[],actions:g}=i,_=I(()=>({rootResource:r,vault:o,app:t,layoutState:d,appState:n}),[r,o,t,d,n,s]),v=I(()=>eu(f,_,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[f,_]),y=I(()=>eu(p,_,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[p,_]),b=I(()=>eu(m,_,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[m,_]),x=I(()=>eu(h,_,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[h,_]),S=I(()=>v.filter(e=>e.modal),[v]),C=I(()=>v.filter(e=>!e.modal),[v]),w=I(()=>[...x,...S],[x,S]),T=I(()=>({...i,leftPanels:v,centerPanels:y,rightPanels:b,modals:w}),[i,v,y,b,w]),E=C.find(e=>e.id===d.leftPanel.current),D=b.find(e=>e.id===d.rightPanel.current),O=y.find(e=>e.id===d.centerPanel.current),te=w.find(e=>e.id===d.modal.current),ne=d.modal.open&&S.some(e=>e.id===d.modal.current)?d.modal.current:d.leftPanel.current,re=d.pinnedRightPanel.pinned?b.find(e=>e.id===d.pinnedRightPanel.current):void 0,[ie]=yl([`(max-width: 1020px)`]),ae=e.isLoading||!1,oe=I(()=>(i.background||[]).map((e,t)=>B(ye,{children:e.render()},t)),[i.background]),A=Pl(`left-panel/${E?.id}`,{left:!0,marginLeft:60,minWidthPx:E?.options?.minWidth||200,maxWidthPx:E?.options?.maxWidth||720,loading:u}),se=Pl(`right-panel/${D?.id}`,{left:!1,minWidthPx:D?.options?.minWidth||320,maxWidthPx:D?.options?.maxWidth||720,loading:u}),ce=D&&(re?.id!==D.id||!ht(d.pinnedRightPanel.state,d.rightPanel.state)),le=A.widthB===`auto`?void 0:()=>A.setWidths({widthA:`auto`,widthB:zs({options:E?.options,fallback:320})}),ue=se.widthB===`auto`?void 0:()=>se.setWidths({widthA:`auto`,widthB:zs({options:D?.options,fallback:320})});if(F(()=>{ie&&d.leftPanel.open&&d.rightPanel.open&&(g.leftPanel.close(),g.rightPanel.close())},[ie]),F(()=>{if(O&&O.onMount)return O.onMount(d.centerPanel.state||O.defaultState||{},{...T,current:g.centerPanel,vault:o},n)},[d.centerPanel.current,O?.id]),F(()=>{if(d.leftPanel.current&&!E){let e=tu(C,d.leftPanel.current);e?g.leftPanel.change({id:e}):g.leftPanel.close()}if(d.centerPanel.current&&!O){let e=tu(y,d.centerPanel.current);e?g.centerPanel.change({id:e}):g.centerPanel.close()}if(d.rightPanel.current&&!D){let e=tu(b,d.rightPanel.current);e?g.rightPanel.change({id:e}):g.rightPanel.close()}if(d.modal.current&&!te){let e=tu(w,d.modal.current);e?g.modal.change({id:e}):g.modal.close()}},[d.leftPanel.current,d.centerPanel.current,d.rightPanel.current,d.modal.current,E?.id,O?.id,D?.id,te?.id,nu(C),nu(y),nu(b),nu(w)]),F(()=>{b.length&&g.rightPanel.change({id:b[0].id}),C.length&&g.leftPanel.change({id:C[0].id}),y.length&&g.centerPanel.change({id:y[0].id})},[]),u)return null;let de=t=>B(Zl,{$menu:e.leftPanelMenuPosition||`bottom`,ref:A.refs.resizableDiv,className:[`manifest-editor`,t?`transition transition-${t}`:``].join(` `),style:{width:d.leftPanel.open||t!==`exited`?A.widthB:void 0,minWidth:E?.options?.minWidth},children:ae?B($l,{children:B(Al,{})}):V(z,{children:[e.leftPanelMenu?B(Ql,{$open:d.leftPanel.open&&t!==`exited`,$position:e.leftPanelMenuPosition||`bottom`,children:e.leftPanelMenu}):null,B($l,{children:d.leftPanel.open||t!==`exited`?B(z,{children:E?B(Xs,{isLeft:!0,noHeader:!0,transition:t,panel:E,state:d.leftPanel,actions:g.leftPanel}):null}):null})]})}),fe=()=>te?B(ee,{title:te.label,open:d.modal.open,onClose:()=>g.modal.close(),children:te.modal?B(`div`,{className:`h-[70vh] min-h-[60vh] max-h-full flex w-full`,children:B(Xs,{isLeft:!0,isModal:!0,noHeader:!0,panel:te,state:d.modal,actions:g.modal})}):Bs(te.render(d.modal.state||te.defaultState||{},{...T,current:g.modal,vault:o,isModal:!0},n))}):null,pe=()=>V(Zl,{$menu:e.centerPanelMenuPosition||`top`,children:[e.centerPanelMenu?B(Ql,{$open:d.centerPanel.open,$position:e.centerPanelMenuPosition||`top`,children:e.centerPanelMenu}):null,B($l,{children:B(at,{resetKeys:[O?.id],FallbackComponent:Vs,children:ae?B(`div`,{style:{display:`flex`,flex:1,justifyContent:`center`,alignItems:`center`},children:B(Ol,{stroke:`rgba(0,0,0,.3)`,fontSize:`2em`})}):d.centerPanel.open&&O?Bs(O.render(d.centerPanel.state||O.defaultState||{},{...T,current:g.centerPanel,vault:o},n)):null})})]}),me=t=>B(Zl,{$menu:e.rightPanelMenuPosition||`bottom`,ref:se.refs.resizableDiv,className:t?`transition transition-${t}`:``,style:{width:d.rightPanel.open||t!==`exited`?se.widthB:void 0,minWidth:D?.options?.minWidth},children:ae?B($l,{children:B(Al,{})}):V(z,{children:[e.rightPanelMenu?B(Ql,{$open:d.rightPanel.open,$position:e.rightPanelMenuPosition||`bottom`,children:e.rightPanelMenu}):null,B($l,{children:d.rightPanel.open||t!==`exited`?V(z,{children:[ce?B(Xs,{panel:D,state:d.rightPanel,actions:g.rightPanel,pinActions:g.pinnedRightPanel,available:b}):null,re?B(Xs,{panel:re,state:d.pinnedRightPanel,actions:g.pinnedRightPanel,close:g.rightPanel.close}):null]}):null})]})});return ie?V(Wl,{children:[e.hideHeader?null:V(Gl,{children:[e.header||null,e.menu?B(`menu`,{children:e.menu}):null]}),B(ql,{children:V(au,{children:[V(su,{children:[C.length>0?B(cu,{type:`button`,"aria-expanded":d.leftPanel.open,onClick:()=>{g.rightPanel.close(),g.leftPanel.toggle()},children:E?.label}):null,b.length>0?B(lu,{children:V(uu,{type:`button`,"aria-expanded":d.rightPanel.open,onClick:()=>{g.leftPanel.close(),g.rightPanel.toggle()},children:[B(Ii,{"aria-hidden":`true`,rotate:90}),D?.label]})}):null]}),B(ou,{children:pe()}),b.length>0?B(du,{$open:d.rightPanel.open,children:me()}):null,C.length>0?V(fu,{$open:d.leftPanel.open,children:[B(`nav`,{"aria-label":`Left panel tabs`,className:`flex flex-none overflow-x-auto border-b border-gray-300`,children:C.map(e=>V(`button`,{type:`button`,"aria-pressed":d.leftPanel.current===e.id,className:`flex flex-1 shrink-0 items-center justify-center gap-1.5 border-0 border-b-[3px] p-3 text-gray-700 [&>svg]:shrink-0 [&>svg]:text-xl ${d.leftPanel.current===e.id?`border-b-[#b83265] bg-[#f9e8ef]`:`border-b-transparent bg-white`}`,onClick:()=>{g.rightPanel.close(),g.leftPanel.open({id:e.id,state:e.defaultState})},children:[e.icon,e.label]},e.id))}),de()]}):null,v.length>0||b.length>0?B(pu,{type:`button`,"aria-label":`Close panels`,$open:d.leftPanel.open||d.rightPanel.open,onClick:()=>{g.leftPanel.close(),g.rightPanel.close()}}):null]})}),B(`div`,{className:`hidden`,children:oe}),B(Lo,{}),B(Ro,{}),B(z,{children:fe()}),B(us,{})]}):V(Wl,{id:e.htmlId||`manifest-editor-container`,className:`manifest-editor ${e.className||``}`,children:[e.hideHeader?null:V(Gl,{children:[e.header||null,e.menu?B(`menu`,{children:e.menu}):null]}),V(ql,{ref:e=>{A.refs.container.current=e,se.refs.container.current=e},children:[v.length>0?B(k,{current:ne,items:v.map(e=>({id:e.id,label:e.label,icon:e.icon,divide:e.divide,separator:e.separator,onClick:()=>{if(e.modal){d.modal.open&&d.modal.current===e.id?g.modal.close():g.modal.open({id:e.id,state:e.defaultState});return}d.leftPanel.current===e.id?g.leftPanel.toggle():g.leftPanel.change({id:e.id})}})),open:d.leftPanel.open}):null,C.length>0?B(mt,{nodeRef:c,in:d.leftPanel.open,timeout:400,unmountOnExit:!1,children:e=>V(z,{children:[B(Jl,{ref:c,$width:A.widthB,$state:e,$motion:!0,children:de(e)}),B(Dl,{ref:A.refs.resizer,reset:le,dir:`left`,transition:e,open:d.leftPanel.open||e!==`exited`,actions:g.leftPanel})]})}):null,B(Yl,{children:pe()}),b.length>0?B(mt,{nodeRef:l,in:d.rightPanel.open,timeout:400,unmountOnExit:!1,children:e=>V(z,{children:[B(Dl,{ref:se.refs.resizer,dir:`right`,reset:ue,open:d.rightPanel.open,actions:g.rightPanel}),B(Xl,{ref:l,$width:se.widthB,$state:e,$motion:!0,children:me(e)})]})}):null]}),B(Kl,{children:e.footer||null}),B(`div`,{className:`hidden`,children:oe}),B(Lo,{}),B(Ro,{}),B(z,{children:fe()}),B(us,{})]})});function hu(e,t){function n(){t({type:`popStack`,panel:e,payload:void 0})}function r(n){t({type:`change`,panel:e,payload:n})}function i(n){t({type:`open`,panel:e,payload:n})}function a(){t({type:`close`,panel:e,payload:void 0})}function o(){t({type:`toggle`,panel:e,payload:void 0})}function s(){t({type:`minimise`,panel:e,payload:void 0})}function c(n){t({type:`maximise`,panel:e,payload:n})}function l(n){t({type:`setCustomWidth`,panel:e,payload:n})}function u(){t({type:`resetSize`,panel:e,payload:void 0})}function d(n){t({type:`pin`,panel:e,payload:n})}function f(){t({type:`unpin`,panel:e,payload:void 0})}return I(()=>({popStack:n,change:r,open:i,close:a,toggle:o,minimise:s,maximise:c,setCustomWidth:l,resetSize:u,pin:d,unpin:f}),[])}function gu(e,t){if(t.payload&&t.payload.stacked){if(e.current){let n=e.stack[e.stack.length-1];if(n&&n.id===e.current)return;t.payload.unique&&(e.stack=e.stack.filter(t=>t.id!==e.current)),e.stack.push({id:e.current,state:e.state?{...Ye(e.state)}:{}})}}else e.stack=[]}function _u(e,t){switch(t.type){case`popStack`:if(e.stack.length){let t=e.stack[e.stack.length-1];t&&(e.current=t.id,e.state=t.state),e.stack=e.stack.slice(0,-1)}break;case`change`:t.payload.id!==e.current&&gu(e,t),e.state=t.payload.state,e.current=t.payload.id;break;case`close`:e.open=!1;break;case`open`:e.open=!0,t.payload&&(t.payload.id!==e.current&&gu(e,t),e.state=t.payload.state,e.current=t.payload.id);break;case`toggle`:e.open=!e.open;break;case`maximise`:e.minimised=!1,t.payload&&(e.state=t.payload.state,e.current=t.payload.id);break;case`minimise`:e.minimised=!0;break;case`setCustomWidth`:e.customWidth=t.payload;break;case`resetSize`:e.customWidth=void 0}if(Rs(e))switch(t.type){case`pin`:e.pinned=!0,e.state=t.payload.state,e.current=t.payload.id;break;case`unpin`:e.pinned=!1,e.state=void 0}}const vu=Xe((e,t)=>{switch(t.panel){case`centerPanel`:_u(e.centerPanel,t);break;case`leftPanel`:_u(e.leftPanel,t);break;case`rightPanel`:_u(e.rightPanel,t);break;case`modal`:_u(e.modal,t);break;case`pinnedRightPanel`:_u(e.pinnedRightPanel,t)}});function yu(){return{customWidth:void 0,minimised:!1,open:!0,current:null,state:null,stack:[]}}function bu(){return{leftPanel:yu(),centerPanel:yu(),rightPanel:yu(),modal:yu(),pinnedRightPanel:{...yu(),pinnable:!0,pinned:!1}}}function xu({className:e,variant:t=`light`}){let n=Ue(),r=H(),{edit:i}=Ka(),a=ja(),o=Ma(),s=n?.items||[],c=n?.viewingDirection===`right-to-left`||n?.viewingDirection===`bottom-to-top`,l=n?.viewingDirection===`top-to-bottom`||n?.viewingDirection===`bottom-to-top`,u=Su(a)||o.map(Su).find(Boolean)||s[0]?.id||``,d=Math.max(0,s.findIndex(e=>e.id===u)),f=s[d]?.id||``,p=d+1,m=I(()=>s.map((e,t)=>{let n=r.get({id:e.id,type:`Canvas`});return{id:e.id,pageNumber:t+1,labelText:$e(n?.label)||`Page ${t+1}`}}),[s,r]),h=e=>{let t=s.findIndex(t=>t.id===e),r=s[t];!r||!n||i({id:r.id,type:`Canvas`},{parent:{id:n.id,type:`Manifest`},property:`items`,index:t},{forceOpen:!1})};if(!n||s.length<2)return B(`div`,{});let g=s[d-1],_=s[d+1],v=t===`dark`;return V(`nav`,{"aria-label":`Manifest pagination`,className:Eu(`inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-1`,`focus-within:ring-2 focus-within:ring-me-primary-500/40`,c&&`flex-row-reverse`,v?`border-white/20 bg-white/10 text-white`:`border-me-gray-300 bg-white text-me-gray-900`,e),children:[B(Cu,{ariaLabel:`Previous canvas`,disabled:!g,onClick:()=>g&&h(g.id),dark:v,children:B(wu,{reverse:c,vertical:l})}),V(`label`,{htmlFor:`manifest-pagination-page-select`,"aria-label":`Page ${p} of ${s.length}`,className:Eu(`relative inline-flex min-h-8 cursor-pointer select-none items-center gap-0.5`,`whitespace-nowrap rounded-full border px-2.5 text-xs font-semibold leading-none`,`focus-within:outline-none focus-within:ring-2 focus-within:ring-me-primary-500/40`,v?`border-white/20 bg-white/10 text-white hover:bg-white/15`:`border-me-gray-300 bg-me-gray-100 text-me-gray-900 hover:bg-me-primary-50`),children:[V(`span`,{children:[p,` / `,s.length]}),B(Tu,{className:Eu(`shrink-0 text-base`,v?`text-white/60`:`text-me-gray-500`)}),B(`select`,{id:`manifest-pagination-page-select`,"aria-label":`Jump to canvas`,value:f,onChange:e=>h(e.target.value),className:`absolute inset-0 cursor-pointer appearance-none border-0 bg-white opacity-0`,children:m.map(e=>V(`option`,{value:e.id,children:[`Page `,e.pageNumber,` - `,e.labelText]},e.id))})]}),B(Cu,{ariaLabel:`Next canvas`,disabled:!_,onClick:()=>_&&h(_.id),dark:v,children:B(wu,{reverse:!c,vertical:l})})]})}function Su(e){let t=e?.resource?.source;return t?.type===`Canvas`?t.id:null}function Cu({ariaLabel:e,children:t,dark:n,disabled:r,onClick:i}){return B(`button`,{type:`button`,"aria-label":e,disabled:r,onClick:i,className:Eu(`inline-flex h-8 w-8 items-center justify-center rounded-full border-0 bg-transparent p-0`,`text-lg transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-me-primary-500/50`,n?`text-white hover:bg-white/15 disabled:text-white/40 disabled:hover:bg-transparent`:`text-me-gray-900 hover:bg-me-primary-50 disabled:text-me-gray-500 disabled:hover:bg-transparent`,`disabled:cursor-not-allowed`),children:t})}function wu({reverse:e,vertical:r}){return B(e?t:n,{"aria-hidden":!0,className:Eu(`block`,r&&`rotate-90`)})}function Tu(e){return B(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,"aria-hidden":!0,...e,children:B(`path`,{fill:`currentColor`,d:`m7 10l5 5l5-5z`})})}function Eu(...e){return e.filter(Boolean).join(` `)}const Du=new WeakMap;function Ou(e,t){let n={port:t,lastActionId:`@genesis`},r=ku(e);function i(e){t.postMessage(typeof e==`string`?e:JSON.stringify(e))}function a(){i({_id:vr(),_type:`init-response`,_lastActionId:n.lastActionId,data:e.getState()})}function o(e){i({_id:e,_type:`vault-action-rejection`,_lastActionId:n.lastActionId,action:e})}function s(e){let t=ju(e.data);if(t){if(t._type===`init-request`){a();return}t._type===`vault-action`&&o(t._id)}}return r.targets.add(n),t.addEventListener(`message`,s),t.start(),()=>{t.removeEventListener(`message`,s),r.targets.delete(n),r.targets.size===0&&e.dispatch===r.patchedDispatch&&(e.dispatch=r.originalDispatch,Du.delete(e)),t.close()}}function ku(e){let t=Du.get(e);if(t)return t;let n=e.dispatch.bind(e),r=new Set,i=(e=>{let t=n(e);for(let t of r)Au(t,e);return t}),a={originalDispatch:n,patchedDispatch:i,targets:r};return e.dispatch=i,Du.set(e,a),a}function Au(e,t){let n={_id:vr(),_type:`vault-action`,_lastActionId:e.lastActionId,action:t};e.lastActionId=n._id,e.port.postMessage(JSON.stringify(n))}function ju(e){try{if(typeof e==`string`)return JSON.parse(e);if(typeof e==`object`&&e)return e}catch{return null}return null}const Mu=j(null);function Nu({children:e}){let t=H(),n=L(null),r=L(null),i=L(null),a=L(!1),[o,s]=R(!0),c=M(()=>{if(!n.current||n.current.closed||!r.current)return;i.current?.();let e=new MessageChannel;i.current=Ou(t,e.port1),n.current.postMessage({_type:`manifest-editor:iframe-preview:connect`,resource:r.current.resource,canvasId:r.current.canvasId||null,annotationId:r.current.annotationId||void 0},new URL(r.current.url).origin,[e.port2]),a.current=!0},[t]);P(()=>{let e=e=>{!r.current||e.source!==n.current||e.origin===new URL(r.current.url).origin&&e.data?._type===`manifest-editor:iframe-preview:ready`&&c()},t=window.setInterval(()=>{n.current?.closed&&(i.current?.(),i.current=null,a.current=!1,n.current=null,s(!0))},1e3);return window.addEventListener(`message`,e),()=>{window.removeEventListener(`message`,e),window.clearInterval(t),i.current?.()}},[c]);let l=M(e=>{r.current=e;let t=n.current;if(t&&!t.closed){t.focus();return}i.current?.(),i.current=null,a.current=!1,n.current=window.open(e.url,e.name||`manifest-editor-preview`,e.features||`popup,width=1200,height=900`),s(!n.current)},[]),u=M(e=>{let t=r.current;r.current=e;let o=n.current;if(!(!o||o.closed)){if(t&&(t.url!==e.url||t.reloadKey!==e.reloadKey)){i.current?.(),i.current=null,a.current=!1,o.location.href=e.url;return}a.current&&o.postMessage({_type:`manifest-editor:iframe-preview:selection`,resource:e.resource,canvasId:e.canvasId||null,annotationId:e.annotationId||void 0},new URL(e.url).origin)}},[]),d=M(()=>{n.current&&!n.current.closed&&n.current.focus()},[]);return B(Mu.Provider,{value:{open:l,update:u,focus:d,isClosed:o},children:e})}function Pu(){let e=N(Mu);return G(e,`usePreviewWindow() can only be called from inside <PreviewWindowProvider />`),e}var Fu=class extends ve{constructor(...e){super(...e),X(this,`state`,{hasError:!1})}static getDerivedStateFromError(e){return console.error(e),{hasError:!0}}componentDidCatch(e,t){console.error(`Uncaught error:`,e,t)}render(){return this.state.hasError?B(`h1`,{children:`Sorry.. there was an error`}):this.props.children}};function Iu(e,t){return typeof e==`string`?{id:e,state:t}:e}const Lu=we(function(e){let t=J(),n=_l(),r=t.layout,[i,a]=Ee(vu,void 0,bu),o={centerPanel:hu(`centerPanel`,a),leftPanel:hu(`leftPanel`,a),rightPanel:hu(`rightPanel`,a),pinnedRightPanel:hu(`pinnedRightPanel`,a),modal:hu(`modal`,a),editingStack:Aa()};function s(e){let t=r.rightPanels.find(t=>t.id===e);if(t)return[t,o.rightPanel,o.pinnedRightPanel];let n=r.centerPanels.find(t=>t.id===e);if(n)return[n,o.centerPanel];let i=r.leftPanels.find(t=>t.id===e);if(i)return i.modal?[i,o.modal]:[i,o.leftPanel];G(!1,`Was not able to find panel with id "${e}"`)}function c(e,t){let{id:r,state:i,stacked:a}=Iu(e,t),[o,c,l]=s(r);if(l&&o.options?.openPinned)l.pin({id:r,state:{...o.defaultState||{},...i||{}}});else{let e={id:r,state:{...o.defaultState||{},...i||{}},stacked:a};n.emit(`layout.open`,e),c.open(e)}}function l(e,t){let{id:r,state:i}=Iu(e,t),[a,o]=s(r),c={id:r,state:{...a.defaultState||{},...i||{}},stacked:!0};n.emit(`layout.open`,c),o.open(c)}function u(e,t){let{id:r,state:i,stacked:a}=Iu(e,t),[o,c]=s(r),l={id:r,state:{...o.defaultState||{},...i||{}},stacked:a};n.emit(`layout.change`,l),c.change(l)}function d(e,t){let{id:r}=Iu(e,t),[,i]=s(r);n.emit(`layout.close`,{id:r}),i.close()}function f(e,t){let{id:r}=Iu(e,t),[,i]=s(r);n.emit(`layout.toggle`,{id:r}),i.toggle()}function p(e,t={},{reset:i,property:a,stacked:s,forceOpen:c,selectedTab:l}={}){let u={resource:Ke(e)?e:{type:`SpecificResource`,source:e},...t};n.emit(`layout.edit`,u),o.editingStack.edit(u,i),r.rightPanels.find(e=>e.id===`@manifest-editor/editor`)&&(c?o.rightPanel.open({id:`@manifest-editor/editor`,stacked:s!==!1,state:{property:a,currentTab:l},unique:!0}):o.rightPanel.change({id:`@manifest-editor/editor`,stacked:s!==!1,state:{property:a,currentTab:l},unique:!0}))}async function m(e){o.editingStack.create(e,{}),n.emit(`layout.create`,e),r.modals?.find(e=>e.id===`@manifest-editor/creator`)?o.modal.open({id:`@manifest-editor/creator`,stacked:!0,unique:!0,state:e}):r.rightPanels.find(e=>e.id===`@manifest-editor/creator`)&&o.rightPanel.open({id:`@manifest-editor/creator`,stacked:!0,unique:!0,state:e})}let h={open:c,change:u,close:d,toggle:f,stack:l,edit:p,create:m};return B(Ha.Provider,{value:I(()=>({...o,...h}),[r]),children:B(Ua.Provider,{value:i,children:e.children})})}),Ru=[{id:`universal-viewer`,config:{url:`https://universalviewer.dev/#?iiifManifestId={manifestId}`},type:`external-manifest-preview`,label:`Universal viewer`},{id:`mirador-3`,type:`external-manifest-preview`,label:`Mirador 3`,config:{url:`https://tomcrane.github.io/scratch/mirador3/?iiif-content={manifestId}`}},{id:`annona`,type:`external-manifest-preview`,label:`Annona`,config:{url:`https://ncsu-libraries.github.io/annona/tools/#/display?url={manifestId}&viewtype=iiif-storyboard&settings=%7B%22fullpage%22%3Atrue%7D`}},{id:`iiif-preview`,config:{url:`https://iiif-preview.digirati.services/store`},type:`iiif-preview-service`,label:`IIIF Preview`}],zu=new gt({approximateServices:!0,verificationsRequired:8,enableFetching:!0});function Bu({config:e,saveConfig:t,children:n,theme:r,previews:i,resource:a,editing:o,backgroundActionPersistence:s}){let c=Si(),l=It(),u=I(()=>{let t=e?.previews||(l.previews?.length?l.previews:Ru);return Nt(l,{previews:t},e)},[l,e]),d=I(()=>({appId:c.appId,instanceId:c.instanceId,rootResource:{id:a.id,type:a.type}}),[c.appId,c.instanceId,a.id,a.type]);return B(Fu,{children:B(Fe.Provider,{value:zu,children:B(Wi,{resource:a,children:B(rc,{children:B(Je,{theme:r||yc,children:V(Rt,{config:u,saveConfig:t,children:[B(vi,{config:u}),B(Ba,{children:B(Lu,{children:B(ur,{persistence:s,persistenceKey:d,children:B(Vc,{children:B(Oo,{children:B(na,{previews:i||[],configs:u.previews,children:B(Nu,{children:B(Me,{children:n})})})})})})})})]})})})})})})}const Vu=new Set([`Collection`,`Manifest`,`Canvas`,`Range`,`AnnotationPage`,`Annotation`,`ContentResource`,`Agent`]),Hu={satisfied:0,missing:0,invalid:0,disallowed:0,"not-applicable":0},Uu=new Set([`label`,`summary`,`language`,`navDate`,`provider`,`requiredStatement`,`rights`,`thumbnail`]);function Wu(e){return e?Array.isArray(e)?e.filter(Boolean):e.split(`.`).filter(Boolean):[]}function Gu(e,t){let n=Wu(e),r=Wu(t);return n.length===r.length&&n.every((e,t)=>e===r[t])}function Ku(e,t){let n=e;for(let e of Wu(t)){if(n==null)return;n=n[e]}return n}function qu(e,t,n){let r=Wu(t);if(!r.length)return n;let i=Array.isArray(e)?[...e]:{...e||{}},a=i;return r.forEach((e,t)=>{if(t===r.length-1){a[e]=n;return}let i=a[e];a[e]=Array.isArray(i)?[...i]:{...i||{}},a=a[e]}),i}function Ju(e){if(e==null)return!1;if(typeof e==`string`)return e.trim().length>0;if(typeof e==`number`||typeof e==`boolean`)return!0;if(Array.isArray(e))return e.some(e=>Ju(e));if(typeof e!=`object`)return!1;let t=Object.entries(e);return t.length?!t.every(([,e])=>typeof e==`string`||Array.isArray(e)&&e.every(e=>typeof e==`string`))||t.some(([,e])=>Ju(e)):!1}function Yu(e){return Array.isArray(e)?e.map(Yu):e&&typeof e==`object`?Object.keys(e).sort().reduce((t,n)=>(t[n]=Yu(e[n]),t),{}):e}function Xu(e,t){return JSON.stringify(Yu(e))===JSON.stringify(Yu(t))}function Zu(e,t,n,r){let i=Wu(n);for(let n of e||[])for(let e of n.terminology?.properties||[])if(!(e.entityType&&e.entityType!==t)&&Gu(e.path,i))return e.label;return r||Td(i)}function Qu(e,t,n){let r=Wu(n),i=[],a,o,s=!1,c=!1;if(!t||!Vu.has(t.type))return{entityType:t?.type,path:r,label:Zu(e,t?.type,r),disallowed:!1,required:!1,rules:i};for(let n of e||[])for(let e of n.rules||[])!(`entityType`in e)||!(`path`in e)||e.entityType===t.type&&Gu(e.path,r)&&(i.push(e),e.type===`disallow-property`&&(s=!0),e.type===`require-non-empty`&&(c=!0),e.type===`fixed-value`&&!o&&(a=e.value,o=e,c=!0));return{entityType:t.type,path:r,label:Zu(e,t.type,r),disallowed:s,required:c,fixedValue:a,fixedValueRule:o,rules:i}}function $u(e,t,n){let r=e||[],i=ed(t,n),a=[];for(let e of r)for(let[n,r]of(e.rules||[]).entries())a.push(...td(e,r,n,i,t));return{specifications:r,results:a,counts:ud(a)}}function ed(e,t){let n=[],r=new Set;function i(t){let a=fd(t);if(!a)return;if(a.type===`SpecificResource`){i(t?.source);return}let o=dd(e,t)||dd(e,a);if(!o||!o.type)return;let s=`${o.type}:${o.id||JSON.stringify(a)}`;if(!r.has(s)){r.add(s),Vu.has(o.type)&&n.push({ref:{id:o.id,type:o.type},resource:o});for(let e of pd(o))i(e)}}return i(t),n}function td(e,t,n,r,i){switch(t.type){case`disallow-property`:case`require-non-empty`:case`fixed-value`:return nd(e,t,n,r);case`iiif:canvas-with-image-service`:return[rd(e,t,n,r,i)];case`iiif:thumbnail-from-body-service`:return id(e,t,n,r,i);case`iiif:valid-rights`:return ad(e,t,n,r);case`iiif:required-statement`:return od(e,t,n,r);case`iiif:metadata-template`:return sd(e,t,n,r);default:return[]}}function nd(e,t,n,r){let i=r.filter(e=>e.ref.type===t.entityType),a=Zu(e?[e]:[],t.entityType,t.path);return i.length?i.map(({ref:r,resource:i})=>{let o=Ku(i,t.path),s=Ju(o);if(t.type===`disallow-property`)return cd(e,t,n,{target:r,path:t.path,status:s?`disallowed`:`satisfied`,displayLabel:a,actual:o,message:s?`${a} is present but is not allowed.`:`${a} is not present.`,editorTarget:ld(r,t.path)});if(t.type===`require-non-empty`)return cd(e,t,n,{target:r,path:t.path,status:s?`satisfied`:`missing`,displayLabel:a,actual:o,message:s?`${a} has a value.`:`${a} must be filled in.`,editorTarget:ld(r,t.path)});let c=Xu(o,t.value);return cd(e,t,n,{target:r,path:t.path,status:c?`satisfied`:s?`invalid`:`missing`,displayLabel:a,expected:t.value,actual:o,message:c?`${a} matches the required value.`:s?`${a} does not match the required value.`:`${a} must use the required value.`,editorTarget:ld(r,t.path)})}):[cd(e,t,n,{status:`not-applicable`,displayLabel:a,message:`No ${t.entityType} resources were found for ${a}.`,path:t.path})]}function rd(e,t,n,r,i){let a=r.filter(e=>e.ref.type===`Canvas`),o=md(t),s=a.find(({resource:e})=>hd(gd(e,i),o));return cd(e,t,n,{target:s?.ref,status:s?`satisfied`:`missing`,displayLabel:t.label||`Canvas image service`,expected:o,message:s?`A canvas contains the required image service.`:o.length?`A canvas must contain one of the required image services: ${o.join(`, `)}.`:`A canvas must contain a painting body with an image service.`,editorTarget:s?ld(s.ref,[`items`]):void 0})}function id(e,t,n,r,i){let a=t.entityType||`Canvas`,o=r.filter(e=>e.ref.type===a);return o.length?o.map(({ref:o,resource:s})=>{let c=a===`Manifest`?r.filter(e=>e.ref.type===`Canvas`).flatMap(e=>gd(e.resource,i)):gd(s,i),l=_d(s,c,i),u=Ju(s.thumbnail);return cd(e,t,n,{target:o,path:[`thumbnail`],status:l?`satisfied`:c.length?u?`invalid`:t.requireThumbnail===!1?`not-applicable`:`missing`:`not-applicable`,displayLabel:Zu([e],o.type,[`thumbnail`],`Thumbnail`),expected:c,actual:s.thumbnail,message:l?`Thumbnail uses the same image service as the painting content.`:c.length?u?`Thumbnail does not use the same image service as the painting content.`:`Thumbnail must be created from the painting image service.`:`No painting image service was found to compare against.`,editorTarget:ld(o,[`thumbnail`])})}):[cd(e,t,n,{status:`not-applicable`,displayLabel:`Thumbnail`,message:`No ${a} resources were found for thumbnail checks.`})]}function ad(e,t,n,r){let i=t.entityType||`Manifest`,a=r.filter(e=>e.ref.type===i),o=t.allowed||[];return a.map(({ref:r,resource:i})=>{let a=i.rights,s=Ju(a),c=typeof a==`string`&&o.map(xd).includes(xd(a));return cd(e,t,n,{target:r,path:[`rights`],status:c?`satisfied`:!s&&t.required!==!1?`missing`:`invalid`,displayLabel:Zu([e],r.type,[`rights`],`Rights`),expected:o,actual:a,message:c?`Rights uses an allowed URI.`:!s&&t.required!==!1?`Rights must use an allowed URI.`:`Rights is not one of the allowed URIs.`,editorTarget:ld(r,[`rights`])})})}function od(e,t,n,r){let i=t.entityType||`Manifest`;return r.filter(e=>e.ref.type===i).map(({ref:r,resource:i})=>{let a=i.requiredStatement,o=t.label?Sd(a?.label,t.label):Ju(a?.label),s=t.value||t.valueRequired!==!1,c=t.value?Sd(a?.value,t.value):!s||Ju(a?.value),l=Ju(a);return cd(e,t,n,{target:r,path:[`requiredStatement`],status:o&&c?`satisfied`:l?`invalid`:`missing`,displayLabel:Zu([e],r.type,[`requiredStatement`],`Required statement`),expected:t.value||t.label,actual:a,message:o&&c?`Required statement is complete.`:l?`Required statement does not match the specification.`:`Required statement must be filled in.`,editorTarget:ld(r,[`requiredStatement`])})})}function sd(e,t,n,r){let i=t.entityType||`Manifest`,a=r.filter(e=>e.ref.type===i),o=[];for(let{ref:r,resource:i}of a){let a=Array.isArray(i.metadata)?i.metadata:[];t.items.forEach((i,s)=>{let c=a.find(e=>Sd(e?.label,i.label)),l=i.value?Sd(c?.value,i.value):!i.valueRequired||Ju(c?.value),u=c&&l?`satisfied`:c&&i.value?`invalid`:`missing`,d=wd(i.label);o.push(cd(e,t,n,{idSuffix:`metadata-${s}`,target:r,path:[`metadata`],status:u,displayLabel:d||`Metadata`,expected:i.value||i.label,actual:c,message:c&&l?`${d||`Metadata`} is present.`:c?`${d||`Metadata`} needs a value.`:`${d||`Metadata`} metadata must be added.`,editorTarget:ld(r,[`metadata`])}))})}return o}function cd(e,t,n,r){let i=t.id||`${t.type}-${n}`,a=r.idSuffix?`-${r.idSuffix}`:``;return{id:`${e.id}-${i}-${r.target?.type||`root`}-${r.target?.id||`none`}${a}`,specificationId:e.id,specificationLabel:e.label,ruleId:i,ruleType:t.type,ruleLabel:t.label||r.displayLabel,ruleIndex:n,target:r.target,path:r.path,status:r.status,displayLabel:r.displayLabel,message:t.message||r.message,expected:r.expected,actual:r.actual,editorTarget:r.editorTarget}}function ld(e,t){let n=t[0];return{resource:e,propertyPath:t,selectedTab:n===`metadata`?`@manifest-editor/metadata`:n&&Uu.has(n)?`@manifest-editor/descriptive-properties`:void 0}}function ud(e){let t={...Hu};for(let n of e)t[n.status]+=1;return t}function dd(e,t){let n=fd(t);if(!n)return t;try{return e.get(n,{skipSelfReturn:!1})||t}catch{try{return e.get(n)||t}catch{return t}}}function fd(e){return!e||typeof e!=`object`?null:e.type===`SpecificResource`?{id:e.id||e.source?.id||``,type:`SpecificResource`}:typeof e.id==`string`&&typeof e.type==`string`?{id:e.id,type:e.type}:null}function pd(e){if(!e||typeof e!=`object`)return[];let t=[];for(let n of[`items`,`structures`,`annotations`,`thumbnail`,`provider`,`homepage`,`rendering`,`seeAlso`,`body`,`target`,`source`]){let r=e[n];Array.isArray(r)?t.push(...r):r&&t.push(r)}return t}function md(e){return[...e.serviceIds||[],...e.serviceId?[e.serviceId]:[]].filter(Boolean)}function hd(e,t){let n=new Set(e.filter(Boolean));return t.length?t.some(e=>n.has(e)):n.size>0}function gd(e,t){let n=bd(t,e?.items),r=[];for(let e of n){let n=bd(t,e?.items);for(let e of n)if((Array.isArray(e?.motivation)?e.motivation:[e?.motivation]).includes(`painting`))for(let n of vd(e?.body,t))r.push(...yd(n))}return Array.from(new Set(r))}function _d(e,t,n){let r=bd(n,e?.thumbnail);if(!r.length||!t.length)return!1;for(let e of r){let n=yd(e),r=typeof e?.id==`string`?e.id:``;if(n.some(e=>t.includes(e))||t.some(e=>r.startsWith(e)))return!0}return!1}function vd(e,t){let n=dd(t,e);return n?Array.isArray(n)?n.flatMap(e=>vd(e,t)):n.type===`SpecificResource`?vd(n.source,t):n.type===`Choice`?n.items?.flatMap(e=>vd(e,t))||[]:[n]:[]}function yd(e){let t=e?.service||e?.services,n=Array.isArray(t)?t:t?[t]:[],r=[];for(let e of n){let t=typeof e==`string`?e:e?.id||e?.[`@id`];typeof t==`string`&&t&&r.push(t)}return Array.from(new Set(r))}function bd(e,t){if(!t)return[];let n=Array.isArray(t)?t:[t];try{let t=e.get(n);if(Array.isArray(t))return t.filter(Boolean)}catch{}return n.map(t=>dd(e,t)).filter(Boolean)}function xd(e){return e.replace(/^https:/,`http:`).replace(/\/?$/,`/`)}function Sd(e,t){return typeof t==`string`?Cd(e).some(e=>e===t):Xu(e,t)}function Cd(e){return e?typeof e==`string`?[e.trim()].filter(Boolean):Array.isArray(e)?e.flatMap(Cd):typeof e==`object`?Object.values(e).flatMap(Cd):[]:[]}function wd(e){return typeof e==`string`?e:Cd(e)[0]||``}function Td(e){return(e[e.length-1]||`Property`).replace(/([A-Z])/g,` $1`).replace(/[-_]/g,` `).replace(/^./,e=>e.toUpperCase())}const Ed=j([]);function Dd({children:e,specifications:t}){let n=I(()=>t||[],[t]);return B(Ed.Provider,{value:n,children:e})}function Od(){return N(Ed)}function kd(e){let t=Y(),n=Od(),r=e||t;return Ge((e,t)=>$u(n,t,r),[n,r.id,r.type])}function Ad(){let e=Od();return I(()=>({getLabel(t,n,r){return Zu(e,t,n,r)}}),[e])}function jd(e,t){let n=Od();return I(()=>Qu(n,e,t),[n,e?.id,e?.type,JSON.stringify(t)])}const Md={},Nd=j(`global`);function Pd(){return N(Nd)}function Fd(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function Id(e){let t=Pd(),[,n]=Ee(e=>e+1,0),r=I(()=>(Md[t]||(Md[t]={}),Md[t][e]||(Md[t][e]={name:e,emitter:ft(),status:`idle`,promise:Promise.resolve(),abort:new AbortController,reject:()=>void 0,resolve:()=>void 0}),Md[t][e]),[t,e]);return Ld(r,`abort`,n),Ld(r,`error`,n),Ld(r,`complete`,n),Ld(r,`running`,n),r}function Ld(e,t,n){let r=M(()=>n(e),[n]);P(()=>{let n=e.emitter;return n.on(t,r),()=>n.off(t,r)},[t,r,e.emitter])}const Rd=()=>void 0;function zd(e,t){let n=Id(e);return Ld(n,`complete`,t||Rd),[e=>{n.status===`running`&&(n.abort.abort(),n.emitter.emit(`abort`)),n.error&&(n.error=``);let t=Fd();t.promise.then(()=>n.emitter.emit(`complete`)).catch(()=>n.emitter.emit(`error`)),n.status=`running`,n.request=e,n.promise=t.promise,n.resolve=t.resolve,n.reject=t.reject,n.emitter.emit(`running`)},n]}function Bd(e,t){let n=Id(e);return Ld(n,`running`,t),[e=>{n.status===`running`&&(n.response=e,n.status=`complete`,n.resolve())},n,(e,t)=>{n.status===`running`&&(n.error=t||e,n.status=`error`,n.reject(e))}]}function Vd({children:e}){return B(Nd.Provider,{value:I(()=>`id-${Date.now()}`,[]),children:e})}function Hd(e){return!1}function Ud({as:e,reference:t,onReference:n,onLink:r,onAnalysis:i,onDropReference:a,onDropLink:o,onDropAnalysis:s,onPasteReference:c,onPasteLink:l,onPasteAnalysis:u,...d}){let f=e||`div`,p=a||n,m=c||n,h=l||r,g=u||i,_=I(()=>t,[t?.id,t?.type]),v=M(function(e){e.defaultPrevented||(e.preventDefault(),e.clipboardData&&_&&_.id&&_.type&&e.clipboardData.setData(`application/json+vault`,JSON.stringify({id:_.id,type:_.type})))},[_]),y=M(async function(e){if(!e.defaultPrevented&&(e.preventDefault(),e.clipboardData)){if(d.onLoading&&d.onLoading(),m){let t=e.clipboardData.getData(`application/json+vault`);if(t)try{let e=JSON.parse(t);e&&e.id&&e.type&&m(e)}catch{}}if(h||g){let t=e.clipboardData.getData(`text`);if(t.startsWith(`http`)){let e=t.split(`
1531
- `);for(let t of e){if(g)try{let e=await Hd(t);if(e){g(e);continue}}catch{}h&&h(t)}}}d.onComplete&&d.onComplete()}},[]),b=M(function(e){e.defaultPrevented||(e.preventDefault(),e.dataTransfer&&d.draggable&&(e.dataTransfer.effectAllowed=`all`,_&&_.id&&_.type&&e.dataTransfer.setData(`application/json+vault`,JSON.stringify({id:_.id,type:_.type}))))},[]),x=M(async function(e){if(e.preventDefault(),e.dataTransfer){if(p){let t=e.dataTransfer.getData(`application/json+vault`);if(t)try{let n=JSON.parse(t);n&&n.id&&n.type&&p(n,e)}catch{return}}let t=e.dataTransfer.getData(`application/json`);if(t){JSON.parse(t);return}if(e.dataTransfer.getData(`text/plain`))return}},[]),S=M(e=>{e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`)},[]);return B(f,{onCopy:v,onPaste:y,onDrop:x,onDragOver:S,onDragStart:b,tabIndex:-1,...d})}export{ds as AppHeader,hs as AppMenuProvider,Di as AppProvider,bi as AppReactContext,Ui as AppResourceInstanceProvider,Wi as AppResourceProvider,xi as AppStateReactContext,je as AtlasStoreProvider,Ne as AtlasStoreReactContext,Ro as BackgroundActionToasts,Qo as BackgroundActionsMenu,Lo as BackgroundActionsMount,ur as BackgroundActionsProvider,lr as BackgroundActionsReactContext,bc as BaseAnnotationCreator,wc as BaseEditor,xc as BaseEditorBackButton,Sc as BaseEditorCloseButton,ua as ButtonChange,ca as ButtonContainer,_a as ButtonEmpty,la as ButtonMain,zt as CANVAS_PROGRESS_META_NAMESPACE,Bt as CANVAS_PROGRESS_STATUS_META_KEY,Ic as ConfigEditor,Rt as ConfigProvider,Pt as ConfigReactContext,Vc as ContextMenuProvider,Bc as ContextMenuReactContext,uc as CreatorInitialData,Rc as CreatorSettings,Ba as EditingStack,Oa as EditingStackContext,gl as EventEmitterProvider,fl as ExportPanel,Qa as FLAG_TAG,tc as HOMEPAGE_COLLECTION,Sl as HandleContainer,Dl as HandleControls,Va as InlineEditingStack,mu as Layout,Ha as LayoutActionsReactContext,Wa as LayoutModeReactContext,Ua as LayoutStateReactContext,on as ManifestEditorCanvasProgressOverlay,So as ManifestEditorTagBadge,xo as ManifestEditorTagIcon,Co as ManifestEditorTagOverlay,xu as ManifestPaginationNavigation,da as MenuContainer,fa as MenuItem,ga as MenuItemClose,ha as MenuItemLabel,ma as MenuItemStatus,_t as MessagePortClientVault,Xs as ModularPanel,Gs as ModularPanelHeader,Ks as ModulePanelButton,ji as MultiAppProvider,Vs as PanelError,vi as PluginConfigBridge,ai as PluginGlobalConfigReactContext,Nc as PluginManager,oi as PluginProvider,ii as PluginReactContext,us as PresetOnboarding,cs as PresetOnboardingButton,ls as PresetPreviewButton,ya as PreviewButton,na as PreviewProvider,ic as PreviewVaultBoundary,rc as PreviewVaultContext,Nu as PreviewWindowProvider,yi as PrimeAppReactContext,hl as ReactEmitterContext,wa as ResourceEditingProvider,ba as ResourceEditingReactContext,Ft as SaveConfigReactContext,Bu as ShellProvider,Dd as SpecificationProvider,Za as TAGS_META_KEY,Xa as TAGS_META_NAMESPACE,Vd as TaskBridge,Oo as ToastProvider,Ud as UniversalCopyTarget,fo as addResourceTag,xs as analyse,Cs as analyseJson,ni as applyPlugins,vc as baseCreator,Tc as baseEditor,Jt as clearCanvasProgressStatus,Xt as clearCanvasProgressStatuses,ed as collectSpecificationResources,_r as copyToClipboard,hr as createActionIdentity,er as createBackgroundActionsStore,gr as createDownload,Ou as createIframeVaultBridge,sr as createLocalForageBackgroundActionPersistence,Zt as createManifestEditorCanvasProgressApi,vo as createManifestEditorTagsApi,Xr as createPluginRuntimeApi,ri as createPluginStore,Zs as createPreviewVault,Qt as createTrackingCanvasProgressApi,bs as detectMedia,Ar as disablePluginInConfig,Cc as editBasedOnResource,Zr as enablePluginAndDependenciesInConfig,kr as enablePluginInConfig,$u as evaluateSpecifications,xr as extendApp,eu as filterSupportedPanels,hn as getAvailableBackgroundActionGroups,ln as getBackgroundActionInstanceKey,Gt as getCanvasProgressStatus,Kt as getCanvasProgressStatusFromState,bu as getDefaultLayoutState,yu as getDefaultPanelState,Yr as getEffectivePluginSettings,wr as getEmptyPluginState,Wr as getEnabledPluginsForApp,Es as getFormat,Ds as getImageDimensions,mr as getManifestNomalized,Vr as getPluginCompatibilityReason,Jr as getPluginDefaultSettings,Ur as getPluginSelectionSource,Gr as getPluginSettingsFromConfig,os as getPresetOnboardingDismissalKey,Qu as getPropertyPolicy,po as getResourceTag,ho as getResourceTagGroups,co as getResourceTags,lo as getResourceTagsFromState,wi as getSelectedPresetTemplate,tu as getSupportedPanelFallback,Zu as getTerminologyLabel,Ku as getValueAtPath,Ju as hasMeaningfulValue,va as hasPreviewOption,go as hasResourceTag,Ir as isLazyPlugin,Fr as isMappedPlugin,Rs as isPinnableState,Br as isPluginCompatible,Hr as isPluginSelected,vu as layoutReducer,yr as mapApp,Pr as mapLazyPlugin,Nr as mapPlugin,un as mergeBackgroundActionDefinitions,Nt as mergeConfig,Mt as mergePartialConfig,br as mergePresetConfig,zr as mergeProviderPlugins,fn as normaliseBackgroundActionError,Yu as normaliseJsonValue,Lr as normalisePlugin,Dr as normalisePluginAppConfig,Or as normalisePluginAppsConfig,Rr as normalisePlugins,Wu as normaliseSpecificationPath,nu as panelIds,zs as panelSizing,Mr as pluginAppConfigEquals,_s as polygonToBoundingBox,vr as randomId,mo as removeResourceTag,Bs as renderHelper,jr as resetPluginInConfig,qr as resetPluginSettingsInConfig,rr as runBackgroundAction,qt as setCanvasProgressStatus,Yt as setCanvasProgressStatuses,Kr as setPluginSettingsInConfig,uo as setResourceTags,qu as setValueAtPath,dn as sortBackgroundActionDefinitions,Xu as specificationJsonEquals,Gu as specificationPathEquals,_o as toggleResourceTag,pl as useAnnotationCreatorState,La as useAnnotationPageEditor,J as useApp,Si as useAppInstance,ps as useAppMenu,ms as useAppMenuItem,Y as useAppResource,Hi as useAppResourceInstance,Ci as useAppState,ki as useApps,gs as useAtlasStore,Io as useAvailableBackgroundActions,Ja as useAvailableLayouts,pr as useBackgroundActionHistory,fr as useBackgroundActionInstance,q as useBackgroundActionsStore,dr as useBackgroundActionsStoreApi,en as useCanvasProgressActions,$t as useCanvasProgressStatus,Fa as useCollectionEditor,It as useConfig,Na as useCreatingResource,ac as useCreator,Gc as useCustomContextMenu,Ec as useDecayState,xa as useEditingContext,ja as useEditingResource,Ma as useEditingResourceStack,Aa as useEditingStack,Ra as useEditor,_l as useEmitter,di as useEnabledPlugins,vl as useEvent,Ia as useGenericEditor,Os as useHighlightedImageResource,As as useHoverHighlightImageResource,lc as useInitialData,oc as useInlineCreator,Ka as useLayoutActions,qa as useLayoutMode,Ya as useLayoutProvider,Ga as useLayoutState,me as useLocalStorage,Pa as useManifestEditor,yl as useMatchMedia,ss as useOpenPresetOnboarding,he as useOptionalLocalStorage,si as useOptionalPluginStoreApi,Ca as useOptionalResource,hu as usePanelActions,fi as usePluginActions,hi as usePluginConfigApi,pi as usePluginRuntimeApi,mi as usePluginSettings,ci as usePluginStoreApi,ui as usePlugins,Ti as usePresetTemplateSelection,ia as usePreviewContext,nc as usePreviewHistory,Qs as usePreviewVault,Pu as usePreviewWindow,ra as usePreviews,gi as useResolvedPluginApp,Sa as useResource,Uc as useResourceContextMenuItems,bo as useResourceTagActions,yo as useResourceTags,Lt as useSaveConfig,bl as useSaveVault,Us as useSetCustomTitle,jd as useSpecificationPropertyPolicy,kd as useSpecificationReport,Ad as useSpecificationTerminology,Od as useSpecifications,xl as useSvgTools,Id as useTask,zd as useTaskDispatch,Ld as useTaskEvent,Bd as useTaskRunner,ks as useTemporaryHighlight,ko as useToasts};
1530
+ `,hu=we(function(e){if(e.layoutMode===`focused`)return B(au,{...e});let t=Y(),n=Si(),r=Hi(),i=Ya(),{vault:a}=N(Le),o=a||void 0,s=Ge(e=>e.iiif),c=L(null),l=L(null),{loading:u,state:d,leftPanels:f,centerPanels:p,rightPanels:m,modals:h=[],actions:g}=i,_=I(()=>({rootResource:r,vault:o,app:t,layoutState:d,appState:n}),[r,o,t,d,n,s]),v=I(()=>tu(f,_,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[f,_]),y=I(()=>tu(p,_,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[p,_]),b=I(()=>tu(m,_,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[m,_]),x=I(()=>tu(h,_,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[h,_]),S=I(()=>v.filter(e=>e.modal),[v]),C=I(()=>v.filter(e=>!e.modal),[v]),w=I(()=>[...x,...S],[x,S]),T=I(()=>({...i,leftPanels:v,centerPanels:y,rightPanels:b,modals:w}),[i,v,y,b,w]),E=C.find(e=>e.id===d.leftPanel.current),D=b.find(e=>e.id===d.rightPanel.current),O=y.find(e=>e.id===d.centerPanel.current),te=w.find(e=>e.id===d.modal.current),ne=d.modal.open&&S.some(e=>e.id===d.modal.current)?d.modal.current:d.leftPanel.current,re=d.pinnedRightPanel.pinned?b.find(e=>e.id===d.pinnedRightPanel.current):void 0,[ie]=bl([`(max-width: 1020px)`]),ae=e.isLoading||!1,oe=I(()=>(i.background||[]).map((e,t)=>B(ye,{children:e.render()},t)),[i.background]),A=Fl(`left-panel/${E?.id}`,{left:!0,marginLeft:60,minWidthPx:E?.options?.minWidth||200,maxWidthPx:E?.options?.maxWidth||720,loading:u}),se=Fl(`right-panel/${D?.id}`,{left:!1,minWidthPx:D?.options?.minWidth||320,maxWidthPx:D?.options?.maxWidth||720,loading:u}),ce=D&&(re?.id!==D.id||!ht(d.pinnedRightPanel.state,d.rightPanel.state)),le=A.widthB===`auto`?void 0:()=>A.setWidths({widthA:`auto`,widthB:zs({options:E?.options,fallback:320})}),ue=se.widthB===`auto`?void 0:()=>se.setWidths({widthA:`auto`,widthB:zs({options:D?.options,fallback:320})});if(F(()=>{ie&&d.leftPanel.open&&d.rightPanel.open&&(g.leftPanel.close(),g.rightPanel.close())},[ie]),F(()=>{if(O&&O.onMount)return O.onMount(d.centerPanel.state||O.defaultState||{},{...T,current:g.centerPanel,vault:o},n)},[d.centerPanel.current,O?.id]),F(()=>{if(d.leftPanel.current&&!E){let e=nu(C,d.leftPanel.current);e?g.leftPanel.change({id:e}):g.leftPanel.close()}if(d.centerPanel.current&&!O){let e=nu(y,d.centerPanel.current);e?g.centerPanel.change({id:e}):g.centerPanel.close()}if(d.rightPanel.current&&!D){let e=nu(b,d.rightPanel.current);e?g.rightPanel.change({id:e}):g.rightPanel.close()}if(d.modal.current&&!te){let e=nu(w,d.modal.current);e?g.modal.change({id:e}):g.modal.close()}},[d.leftPanel.current,d.centerPanel.current,d.rightPanel.current,d.modal.current,E?.id,O?.id,D?.id,te?.id,ru(C),ru(y),ru(b),ru(w)]),F(()=>{b.length&&g.rightPanel.change({id:b[0].id}),C.length&&g.leftPanel.change({id:C[0].id}),y.length&&g.centerPanel.change({id:y[0].id})},[]),u)return null;let de=t=>B(Ql,{$menu:e.leftPanelMenuPosition||`bottom`,ref:A.refs.resizableDiv,className:[`manifest-editor`,t?`transition transition-${t}`:``].join(` `),style:{width:d.leftPanel.open||t!==`exited`?A.widthB:void 0,minWidth:E?.options?.minWidth},children:ae?B(eu,{children:B(jl,{})}):V(z,{children:[e.leftPanelMenu?B($l,{$open:d.leftPanel.open&&t!==`exited`,$position:e.leftPanelMenuPosition||`bottom`,children:e.leftPanelMenu}):null,B(eu,{children:d.leftPanel.open||t!==`exited`?B(z,{children:E?B(Xs,{isLeft:!0,noHeader:!0,transition:t,panel:E,state:d.leftPanel,actions:g.leftPanel}):null}):null})]})}),fe=()=>te?B(ee,{title:te.label,open:d.modal.open,onClose:()=>g.modal.close(),children:te.modal?B(`div`,{className:`h-[70vh] min-h-[60vh] max-h-full flex w-full`,children:B(Xs,{isLeft:!0,isModal:!0,noHeader:!0,panel:te,state:d.modal,actions:g.modal})}):Bs(te.render(d.modal.state||te.defaultState||{},{...T,current:g.modal,vault:o,isModal:!0},n))}):null,pe=()=>V(Ql,{$menu:e.centerPanelMenuPosition||`top`,children:[e.centerPanelMenu?B($l,{$open:d.centerPanel.open,$position:e.centerPanelMenuPosition||`top`,children:e.centerPanelMenu}):null,B(eu,{children:B(at,{resetKeys:[O?.id],FallbackComponent:Vs,children:ae?B(`div`,{style:{display:`flex`,flex:1,justifyContent:`center`,alignItems:`center`},children:B(kl,{stroke:`rgba(0,0,0,.3)`,fontSize:`2em`})}):d.centerPanel.open&&O?Bs(O.render(d.centerPanel.state||O.defaultState||{},{...T,current:g.centerPanel,vault:o},n)):null})})]}),me=t=>B(Ql,{$menu:e.rightPanelMenuPosition||`bottom`,ref:se.refs.resizableDiv,className:t?`transition transition-${t}`:``,style:{width:d.rightPanel.open||t!==`exited`?se.widthB:void 0,minWidth:D?.options?.minWidth},children:ae?B(eu,{children:B(jl,{})}):V(z,{children:[e.rightPanelMenu?B($l,{$open:d.rightPanel.open,$position:e.rightPanelMenuPosition||`bottom`,children:e.rightPanelMenu}):null,B(eu,{children:d.rightPanel.open||t!==`exited`?V(z,{children:[ce?B(Xs,{panel:D,state:d.rightPanel,actions:g.rightPanel,pinActions:g.pinnedRightPanel,available:b}):null,re?B(Xs,{panel:re,state:d.pinnedRightPanel,actions:g.pinnedRightPanel,close:g.rightPanel.close}):null]}):null})]})});return ie?V(Gl,{children:[e.hideHeader?null:V(Kl,{children:[e.header||null,e.menu?B(`menu`,{children:e.menu}):null]}),B(Jl,{children:V(ou,{children:[V(cu,{children:[C.length>0?B(lu,{type:`button`,"aria-expanded":d.leftPanel.open,onClick:()=>{g.rightPanel.close(),g.leftPanel.toggle()},children:E?.label}):null,b.length>0?B(uu,{children:V(du,{type:`button`,"aria-expanded":d.rightPanel.open,onClick:()=>{g.leftPanel.close(),g.rightPanel.toggle()},children:[B(Fi,{"aria-hidden":`true`,rotate:90}),D?.label]})}):null]}),B(su,{children:pe()}),b.length>0?B(fu,{$open:d.rightPanel.open,children:me()}):null,C.length>0?V(pu,{$open:d.leftPanel.open,children:[B(`nav`,{"aria-label":`Left panel tabs`,className:`flex flex-none overflow-x-auto border-b border-gray-300`,children:C.map(e=>V(`button`,{type:`button`,"aria-pressed":d.leftPanel.current===e.id,className:`flex flex-1 shrink-0 items-center justify-center gap-1.5 border-0 border-b-[3px] p-3 text-gray-700 [&>svg]:shrink-0 [&>svg]:text-xl ${d.leftPanel.current===e.id?`border-b-[#b83265] bg-[#f9e8ef]`:`border-b-transparent bg-white`}`,onClick:()=>{g.rightPanel.close(),g.leftPanel.open({id:e.id,state:e.defaultState})},children:[e.icon,e.label]},e.id))}),de()]}):null,v.length>0||b.length>0?B(mu,{type:`button`,"aria-label":`Close panels`,$open:d.leftPanel.open||d.rightPanel.open,onClick:()=>{g.leftPanel.close(),g.rightPanel.close()}}):null]})}),B(`div`,{className:`hidden`,children:oe}),B(Lo,{}),B(Ro,{}),B(z,{children:fe()}),B(us,{})]}):V(Gl,{id:e.htmlId||`manifest-editor-container`,className:`manifest-editor ${e.className||``}`,children:[e.hideHeader?null:V(Kl,{children:[e.header||null,e.menu?B(`menu`,{children:e.menu}):null]}),V(Jl,{ref:e=>{A.refs.container.current=e,se.refs.container.current=e},children:[v.length>0?B(k,{current:ne,items:v.map(e=>({id:e.id,label:e.label,icon:e.icon,divide:e.divide,separator:e.separator,onClick:()=>{if(e.modal){d.modal.open&&d.modal.current===e.id?g.modal.close():g.modal.open({id:e.id,state:e.defaultState});return}d.leftPanel.current===e.id?g.leftPanel.toggle():g.leftPanel.change({id:e.id})}})),open:d.leftPanel.open}):null,C.length>0?B(mt,{nodeRef:c,in:d.leftPanel.open,timeout:400,unmountOnExit:!1,children:e=>V(z,{children:[B(Yl,{ref:c,$width:A.widthB,$state:e,$motion:!0,children:de(e)}),B(Ol,{ref:A.refs.resizer,reset:le,dir:`left`,transition:e,open:d.leftPanel.open||e!==`exited`,actions:g.leftPanel})]})}):null,B(Xl,{children:pe()}),b.length>0?B(mt,{nodeRef:l,in:d.rightPanel.open,timeout:400,unmountOnExit:!1,children:e=>V(z,{children:[B(Ol,{ref:se.refs.resizer,dir:`right`,reset:ue,open:d.rightPanel.open,actions:g.rightPanel}),B(Zl,{ref:l,$width:se.widthB,$state:e,$motion:!0,children:me(e)})]})}):null]}),B(ql,{children:e.footer||null}),B(`div`,{className:`hidden`,children:oe}),B(Lo,{}),B(Ro,{}),B(z,{children:fe()}),B(us,{})]})});function gu(e,t){function n(){t({type:`popStack`,panel:e,payload:void 0})}function r(n){t({type:`change`,panel:e,payload:n})}function i(n){t({type:`open`,panel:e,payload:n})}function a(){t({type:`close`,panel:e,payload:void 0})}function o(){t({type:`toggle`,panel:e,payload:void 0})}function s(){t({type:`minimise`,panel:e,payload:void 0})}function c(n){t({type:`maximise`,panel:e,payload:n})}function l(n){t({type:`setCustomWidth`,panel:e,payload:n})}function u(){t({type:`resetSize`,panel:e,payload:void 0})}function d(n){t({type:`pin`,panel:e,payload:n})}function f(){t({type:`unpin`,panel:e,payload:void 0})}return I(()=>({popStack:n,change:r,open:i,close:a,toggle:o,minimise:s,maximise:c,setCustomWidth:l,resetSize:u,pin:d,unpin:f}),[])}function _u(e,t){if(t.payload&&t.payload.stacked){if(e.current){let n=e.stack[e.stack.length-1];if(n&&n.id===e.current)return;t.payload.unique&&(e.stack=e.stack.filter(t=>t.id!==e.current)),e.stack.push({id:e.current,state:e.state?{...Ye(e.state)}:{}})}}else e.stack=[]}function vu(e,t){switch(t.type){case`popStack`:if(e.stack.length){let t=e.stack[e.stack.length-1];t&&(e.current=t.id,e.state=t.state),e.stack=e.stack.slice(0,-1)}break;case`change`:t.payload.id!==e.current&&_u(e,t),e.state=t.payload.state,e.current=t.payload.id;break;case`close`:e.open=!1;break;case`open`:e.open=!0,t.payload&&(t.payload.id!==e.current&&_u(e,t),e.state=t.payload.state,e.current=t.payload.id);break;case`toggle`:e.open=!e.open;break;case`maximise`:e.minimised=!1,t.payload&&(e.state=t.payload.state,e.current=t.payload.id);break;case`minimise`:e.minimised=!0;break;case`setCustomWidth`:e.customWidth=t.payload;break;case`resetSize`:e.customWidth=void 0}if(Rs(e))switch(t.type){case`pin`:e.pinned=!0,e.state=t.payload.state,e.current=t.payload.id;break;case`unpin`:e.pinned=!1,e.state=void 0}}const yu=Xe((e,t)=>{switch(t.panel){case`centerPanel`:vu(e.centerPanel,t);break;case`leftPanel`:vu(e.leftPanel,t);break;case`rightPanel`:vu(e.rightPanel,t);break;case`modal`:vu(e.modal,t);break;case`pinnedRightPanel`:vu(e.pinnedRightPanel,t)}});function bu(){return{customWidth:void 0,minimised:!1,open:!0,current:null,state:null,stack:[]}}function xu(){return{leftPanel:bu(),centerPanel:bu(),rightPanel:bu(),modal:bu(),pinnedRightPanel:{...bu(),pinnable:!0,pinned:!1}}}function Su({className:e,variant:t=`light`}){let n=Ue(),r=H(),{edit:i}=Ka(),a=ja(),o=Ma(),s=n?.items||[],c=n?.viewingDirection===`right-to-left`||n?.viewingDirection===`bottom-to-top`,l=n?.viewingDirection===`top-to-bottom`||n?.viewingDirection===`bottom-to-top`,u=Cu(a)||o.map(Cu).find(Boolean)||s[0]?.id||``,d=Math.max(0,s.findIndex(e=>e.id===u)),f=s[d]?.id||``,p=d+1,m=I(()=>s.map((e,t)=>{let n=r.get({id:e.id,type:`Canvas`});return{id:e.id,pageNumber:t+1,labelText:$e(n?.label)||`Page ${t+1}`}}),[s,r]),h=e=>{let t=s.findIndex(t=>t.id===e),r=s[t];!r||!n||i({id:r.id,type:`Canvas`},{parent:{id:n.id,type:`Manifest`},property:`items`,index:t},{forceOpen:!1})};if(!n||s.length<2)return B(`div`,{});let g=s[d-1],_=s[d+1],v=t===`dark`;return V(`nav`,{"aria-label":`Manifest pagination`,className:Du(`inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-1`,`focus-within:ring-2 focus-within:ring-me-primary-500/40`,c&&`flex-row-reverse`,v?`border-white/20 bg-white/10 text-white`:`border-me-gray-300 bg-white text-me-gray-900`,e),children:[B(wu,{ariaLabel:`Previous canvas`,disabled:!g,onClick:()=>g&&h(g.id),dark:v,children:B(Tu,{reverse:c,vertical:l})}),V(`label`,{htmlFor:`manifest-pagination-page-select`,"aria-label":`Page ${p} of ${s.length}`,className:Du(`relative inline-flex min-h-8 cursor-pointer select-none items-center gap-0.5`,`whitespace-nowrap rounded-full border px-2.5 text-xs font-semibold leading-none`,`focus-within:outline-none focus-within:ring-2 focus-within:ring-me-primary-500/40`,v?`border-white/20 bg-white/10 text-white hover:bg-white/15`:`border-me-gray-300 bg-me-gray-100 text-me-gray-900 hover:bg-me-primary-50`),children:[V(`span`,{children:[p,` / `,s.length]}),B(Eu,{className:Du(`shrink-0 text-base`,v?`text-white/60`:`text-me-gray-500`)}),B(`select`,{id:`manifest-pagination-page-select`,"aria-label":`Jump to canvas`,value:f,onChange:e=>h(e.target.value),className:`absolute inset-0 cursor-pointer appearance-none border-0 bg-white opacity-0`,children:m.map(e=>V(`option`,{value:e.id,children:[`Page `,e.pageNumber,` - `,e.labelText]},e.id))})]}),B(wu,{ariaLabel:`Next canvas`,disabled:!_,onClick:()=>_&&h(_.id),dark:v,children:B(Tu,{reverse:!c,vertical:l})})]})}function Cu(e){let t=e?.resource?.source;return t?.type===`Canvas`?t.id:null}function wu({ariaLabel:e,children:t,dark:n,disabled:r,onClick:i}){return B(`button`,{type:`button`,"aria-label":e,disabled:r,onClick:i,className:Du(`inline-flex h-8 w-8 items-center justify-center rounded-full border-0 bg-transparent p-0`,`text-lg transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-me-primary-500/50`,n?`text-white hover:bg-white/15 disabled:text-white/40 disabled:hover:bg-transparent`:`text-me-gray-900 hover:bg-me-primary-50 disabled:text-me-gray-500 disabled:hover:bg-transparent`,`disabled:cursor-not-allowed`),children:t})}function Tu({reverse:e,vertical:r}){return B(e?t:n,{"aria-hidden":!0,className:Du(`block`,r&&`rotate-90`)})}function Eu(e){return B(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,"aria-hidden":!0,...e,children:B(`path`,{fill:`currentColor`,d:`m7 10l5 5l5-5z`})})}function Du(...e){return e.filter(Boolean).join(` `)}const Ou=new WeakMap;function ku(e,t){let n={port:t,lastActionId:`@genesis`},r=Au(e);function i(e){t.postMessage(typeof e==`string`?e:JSON.stringify(e))}function a(){i({_id:_r(),_type:`init-response`,_lastActionId:n.lastActionId,data:e.getState()})}function o(e){i({_id:e,_type:`vault-action-rejection`,_lastActionId:n.lastActionId,action:e})}function s(e){let t=Mu(e.data);if(t){if(t._type===`init-request`){a();return}t._type===`vault-action`&&o(t._id)}}return r.targets.add(n),t.addEventListener(`message`,s),t.start(),()=>{t.removeEventListener(`message`,s),r.targets.delete(n),r.targets.size===0&&e.dispatch===r.patchedDispatch&&(e.dispatch=r.originalDispatch,Ou.delete(e)),t.close()}}function Au(e){let t=Ou.get(e);if(t)return t;let n=e.dispatch.bind(e),r=new Set,i=(e=>{let t=n(e);for(let t of r)ju(t,e);return t}),a={originalDispatch:n,patchedDispatch:i,targets:r};return e.dispatch=i,Ou.set(e,a),a}function ju(e,t){let n={_id:_r(),_type:`vault-action`,_lastActionId:e.lastActionId,action:t};e.lastActionId=n._id,e.port.postMessage(JSON.stringify(n))}function Mu(e){try{if(typeof e==`string`)return JSON.parse(e);if(typeof e==`object`&&e)return e}catch{return null}return null}const Nu=j(null);function Pu({children:e}){let t=H(),n=L(null),r=L(null),i=L(null),a=L(!1),[o,s]=R(!0),c=M(()=>{if(!n.current||n.current.closed||!r.current)return;i.current?.();let e=new MessageChannel;i.current=ku(t,e.port1),n.current.postMessage({_type:`manifest-editor:iframe-preview:connect`,resource:r.current.resource,canvasId:r.current.canvasId||null,annotationId:r.current.annotationId||void 0},new URL(r.current.url).origin,[e.port2]),a.current=!0},[t]);P(()=>{let e=e=>{!r.current||e.source!==n.current||e.origin===new URL(r.current.url).origin&&e.data?._type===`manifest-editor:iframe-preview:ready`&&c()},t=window.setInterval(()=>{n.current?.closed&&(i.current?.(),i.current=null,a.current=!1,n.current=null,s(!0))},1e3);return window.addEventListener(`message`,e),()=>{window.removeEventListener(`message`,e),window.clearInterval(t),i.current?.()}},[c]);let l=M(e=>{r.current=e;let t=n.current;if(t&&!t.closed){t.focus();return}i.current?.(),i.current=null,a.current=!1,n.current=window.open(e.url,e.name||`manifest-editor-preview`,e.features||`popup,width=1200,height=900`),s(!n.current)},[]),u=M(e=>{let t=r.current;r.current=e;let o=n.current;if(!(!o||o.closed)){if(t&&(t.url!==e.url||t.reloadKey!==e.reloadKey)){i.current?.(),i.current=null,a.current=!1,o.location.href=e.url;return}a.current&&o.postMessage({_type:`manifest-editor:iframe-preview:selection`,resource:e.resource,canvasId:e.canvasId||null,annotationId:e.annotationId||void 0},new URL(e.url).origin)}},[]),d=M(()=>{n.current&&!n.current.closed&&n.current.focus()},[]);return B(Nu.Provider,{value:{open:l,update:u,focus:d,isClosed:o},children:e})}function Fu(){let e=N(Nu);return G(e,`usePreviewWindow() can only be called from inside <PreviewWindowProvider />`),e}var Iu=class extends ve{constructor(...e){super(...e),X(this,`state`,{hasError:!1})}static getDerivedStateFromError(e){return console.error(e),{hasError:!0}}componentDidCatch(e,t){console.error(`Uncaught error:`,e,t)}render(){return this.state.hasError?B(`h1`,{children:`Sorry.. there was an error`}):this.props.children}};function Lu(e,t){return typeof e==`string`?{id:e,state:t}:e}const Ru=we(function(e){let t=Y(),n=vl(),r=t.layout,[i,a]=Ee(yu,void 0,xu),o={centerPanel:gu(`centerPanel`,a),leftPanel:gu(`leftPanel`,a),rightPanel:gu(`rightPanel`,a),pinnedRightPanel:gu(`pinnedRightPanel`,a),modal:gu(`modal`,a),editingStack:Aa()};function s(e){let t=r.rightPanels.find(t=>t.id===e);if(t)return[t,o.rightPanel,o.pinnedRightPanel];let n=r.centerPanels.find(t=>t.id===e);if(n)return[n,o.centerPanel];let i=r.leftPanels.find(t=>t.id===e);if(i)return i.modal?[i,o.modal]:[i,o.leftPanel];G(!1,`Was not able to find panel with id "${e}"`)}function c(e,t){let{id:r,state:i,stacked:a}=Lu(e,t),[o,c,l]=s(r);if(l&&o.options?.openPinned)l.pin({id:r,state:{...o.defaultState||{},...i||{}}});else{let e={id:r,state:{...o.defaultState||{},...i||{}},stacked:a};n.emit(`layout.open`,e),c.open(e)}}function l(e,t){let{id:r,state:i}=Lu(e,t),[a,o]=s(r),c={id:r,state:{...a.defaultState||{},...i||{}},stacked:!0};n.emit(`layout.open`,c),o.open(c)}function u(e,t){let{id:r,state:i,stacked:a}=Lu(e,t),[o,c]=s(r),l={id:r,state:{...o.defaultState||{},...i||{}},stacked:a};n.emit(`layout.change`,l),c.change(l)}function d(e,t){let{id:r}=Lu(e,t),[,i]=s(r);n.emit(`layout.close`,{id:r}),i.close()}function f(e,t){let{id:r}=Lu(e,t),[,i]=s(r);n.emit(`layout.toggle`,{id:r}),i.toggle()}function p(e,t={},{reset:i,property:a,stacked:s,forceOpen:c,selectedTab:l}={}){let u={resource:Ke(e)?e:{type:`SpecificResource`,source:e},...t};n.emit(`layout.edit`,u),o.editingStack.edit(u,i),r.rightPanels.find(e=>e.id===`@manifest-editor/editor`)&&(c?o.rightPanel.open({id:`@manifest-editor/editor`,stacked:s!==!1,state:{property:a,currentTab:l},unique:!0}):o.rightPanel.change({id:`@manifest-editor/editor`,stacked:s!==!1,state:{property:a,currentTab:l},unique:!0}))}async function m(e){o.editingStack.create(e,{}),n.emit(`layout.create`,e),r.modals?.find(e=>e.id===`@manifest-editor/creator`)?o.modal.open({id:`@manifest-editor/creator`,stacked:!0,unique:!0,state:e}):r.rightPanels.find(e=>e.id===`@manifest-editor/creator`)&&o.rightPanel.open({id:`@manifest-editor/creator`,stacked:!0,unique:!0,state:e})}let h={open:c,change:u,close:d,toggle:f,stack:l,edit:p,create:m};return B(Ha.Provider,{value:I(()=>({...o,...h}),[r]),children:B(Ua.Provider,{value:i,children:e.children})})}),zu=[{id:`universal-viewer`,config:{url:`https://universalviewer.dev/#?iiifManifestId={manifestId}`},type:`external-manifest-preview`,label:`Universal viewer`},{id:`mirador-3`,type:`external-manifest-preview`,label:`Mirador 3`,config:{url:`https://tomcrane.github.io/scratch/mirador3/?iiif-content={manifestId}`}},{id:`annona`,type:`external-manifest-preview`,label:`Annona`,config:{url:`https://ncsu-libraries.github.io/annona/tools/#/display?url={manifestId}&viewtype=iiif-storyboard&settings=%7B%22fullpage%22%3Atrue%7D`}},{id:`iiif-preview`,config:{url:`https://iiif-preview.digirati.services/store`},type:`iiif-preview-service`,label:`IIIF Preview`}],Bu=new gt({approximateServices:!0,verificationsRequired:8,enableFetching:!0});function Vu({config:e,saveConfig:t,children:n,theme:r,previews:i,resource:a,editing:o,backgroundActionPersistence:s}){let c=xi(),l=K(),u=I(()=>{let t=e?.previews||(l.previews?.length?l.previews:zu);return Nt(l,{previews:t},e)},[l,e]),d=I(()=>({appId:c.appId,instanceId:c.instanceId,rootResource:{id:a.id,type:a.type}}),[c.appId,c.instanceId,a.id,a.type]);return B(Iu,{children:B(Fe.Provider,{value:Bu,children:B(Wi,{resource:a,children:B(rc,{children:B(Je,{theme:r||yc,children:V(Lt,{config:u,saveConfig:t,children:[B(_i,{config:u}),B(Ba,{children:B(Ru,{children:B(lr,{persistence:s,persistenceKey:d,children:B(Hc,{children:B(Oo,{children:B(na,{previews:i||[],configs:u.previews,children:B(Pu,{children:B(Me,{children:n})})})})})})})})]})})})})})})}const Hu=new Set([`Collection`,`Manifest`,`Canvas`,`Range`,`AnnotationPage`,`Annotation`,`ContentResource`,`Agent`]),Uu={satisfied:0,missing:0,invalid:0,disallowed:0,"not-applicable":0},Wu=new Set([`label`,`summary`,`language`,`navDate`,`provider`,`requiredStatement`,`rights`,`thumbnail`]);function Gu(e){return e?Array.isArray(e)?e.filter(Boolean):e.split(`.`).filter(Boolean):[]}function Ku(e,t){let n=Gu(e),r=Gu(t);return n.length===r.length&&n.every((e,t)=>e===r[t])}function qu(e,t){let n=e;for(let e of Gu(t)){if(n==null)return;n=n[e]}return n}function Ju(e,t,n){let r=Gu(t);if(!r.length)return n;let i=Array.isArray(e)?[...e]:{...e||{}},a=i;return r.forEach((e,t)=>{if(t===r.length-1){a[e]=n;return}let i=a[e];a[e]=Array.isArray(i)?[...i]:{...i||{}},a=a[e]}),i}function Yu(e){if(e==null)return!1;if(typeof e==`string`)return e.trim().length>0;if(typeof e==`number`||typeof e==`boolean`)return!0;if(Array.isArray(e))return e.some(e=>Yu(e));if(typeof e!=`object`)return!1;let t=Object.entries(e);return t.length?!t.every(([,e])=>typeof e==`string`||Array.isArray(e)&&e.every(e=>typeof e==`string`))||t.some(([,e])=>Yu(e)):!1}function Xu(e){return Array.isArray(e)?e.map(Xu):e&&typeof e==`object`?Object.keys(e).sort().reduce((t,n)=>(t[n]=Xu(e[n]),t),{}):e}function Zu(e,t){return JSON.stringify(Xu(e))===JSON.stringify(Xu(t))}function Qu(e,t,n,r){let i=Gu(n);for(let n of e||[])for(let e of n.terminology?.properties||[])if(!(e.entityType&&e.entityType!==t)&&Ku(e.path,i))return e.label;return r||Ed(i)}function $u(e,t,n){let r=Gu(n),i=[],a,o,s=!1,c=!1;if(!t||!Hu.has(t.type))return{entityType:t?.type,path:r,label:Qu(e,t?.type,r),disallowed:!1,required:!1,rules:i};for(let n of e||[])for(let e of n.rules||[])!(`entityType`in e)||!(`path`in e)||e.entityType===t.type&&Ku(e.path,r)&&(i.push(e),e.type===`disallow-property`&&(s=!0),e.type===`require-non-empty`&&(c=!0),e.type===`fixed-value`&&!o&&(a=e.value,o=e,c=!0));return{entityType:t.type,path:r,label:Qu(e,t.type,r),disallowed:s,required:c,fixedValue:a,fixedValueRule:o,rules:i}}function ed(e,t,n){let r=e||[],i=td(t,n),a=[];for(let e of r)for(let[n,r]of(e.rules||[]).entries())a.push(...nd(e,r,n,i,t));return{specifications:r,results:a,counts:dd(a)}}function td(e,t){let n=[],r=new Set;function i(t){let a=pd(t);if(!a)return;if(a.type===`SpecificResource`){i(t?.source);return}let o=fd(e,t)||fd(e,a);if(!o||!o.type)return;let s=`${o.type}:${o.id||JSON.stringify(a)}`;if(!r.has(s)){r.add(s),Hu.has(o.type)&&n.push({ref:{id:o.id,type:o.type},resource:o});for(let e of md(o))i(e)}}return i(t),n}function nd(e,t,n,r,i){switch(t.type){case`disallow-property`:case`require-non-empty`:case`fixed-value`:return rd(e,t,n,r);case`iiif:canvas-with-image-service`:return[id(e,t,n,r,i)];case`iiif:thumbnail-from-body-service`:return ad(e,t,n,r,i);case`iiif:valid-rights`:return od(e,t,n,r);case`iiif:required-statement`:return sd(e,t,n,r);case`iiif:metadata-template`:return cd(e,t,n,r);default:return[]}}function rd(e,t,n,r){let i=r.filter(e=>e.ref.type===t.entityType),a=Qu(e?[e]:[],t.entityType,t.path);return i.length?i.map(({ref:r,resource:i})=>{let o=qu(i,t.path),s=Yu(o);if(t.type===`disallow-property`)return ld(e,t,n,{target:r,path:t.path,status:s?`disallowed`:`satisfied`,displayLabel:a,actual:o,message:s?`${a} is present but is not allowed.`:`${a} is not present.`,editorTarget:ud(r,t.path)});if(t.type===`require-non-empty`)return ld(e,t,n,{target:r,path:t.path,status:s?`satisfied`:`missing`,displayLabel:a,actual:o,message:s?`${a} has a value.`:`${a} must be filled in.`,editorTarget:ud(r,t.path)});let c=Zu(o,t.value);return ld(e,t,n,{target:r,path:t.path,status:c?`satisfied`:s?`invalid`:`missing`,displayLabel:a,expected:t.value,actual:o,message:c?`${a} matches the required value.`:s?`${a} does not match the required value.`:`${a} must use the required value.`,editorTarget:ud(r,t.path)})}):[ld(e,t,n,{status:`not-applicable`,displayLabel:a,message:`No ${t.entityType} resources were found for ${a}.`,path:t.path})]}function id(e,t,n,r,i){let a=r.filter(e=>e.ref.type===`Canvas`),o=hd(t),s=a.find(({resource:e})=>gd(_d(e,i),o));return ld(e,t,n,{target:s?.ref,status:s?`satisfied`:`missing`,displayLabel:t.label||`Canvas image service`,expected:o,message:s?`A canvas contains the required image service.`:o.length?`A canvas must contain one of the required image services: ${o.join(`, `)}.`:`A canvas must contain a painting body with an image service.`,editorTarget:s?ud(s.ref,[`items`]):void 0})}function ad(e,t,n,r,i){let a=t.entityType||`Canvas`,o=r.filter(e=>e.ref.type===a);return o.length?o.map(({ref:o,resource:s})=>{let c=a===`Manifest`?r.filter(e=>e.ref.type===`Canvas`).flatMap(e=>_d(e.resource,i)):_d(s,i),l=vd(s,c,i),u=Yu(s.thumbnail);return ld(e,t,n,{target:o,path:[`thumbnail`],status:l?`satisfied`:c.length?u?`invalid`:t.requireThumbnail===!1?`not-applicable`:`missing`:`not-applicable`,displayLabel:Qu([e],o.type,[`thumbnail`],`Thumbnail`),expected:c,actual:s.thumbnail,message:l?`Thumbnail uses the same image service as the painting content.`:c.length?u?`Thumbnail does not use the same image service as the painting content.`:`Thumbnail must be created from the painting image service.`:`No painting image service was found to compare against.`,editorTarget:ud(o,[`thumbnail`])})}):[ld(e,t,n,{status:`not-applicable`,displayLabel:`Thumbnail`,message:`No ${a} resources were found for thumbnail checks.`})]}function od(e,t,n,r){let i=t.entityType||`Manifest`,a=r.filter(e=>e.ref.type===i),o=t.allowed||[];return a.map(({ref:r,resource:i})=>{let a=i.rights,s=Yu(a),c=typeof a==`string`&&o.map(Sd).includes(Sd(a));return ld(e,t,n,{target:r,path:[`rights`],status:c?`satisfied`:!s&&t.required!==!1?`missing`:`invalid`,displayLabel:Qu([e],r.type,[`rights`],`Rights`),expected:o,actual:a,message:c?`Rights uses an allowed URI.`:!s&&t.required!==!1?`Rights must use an allowed URI.`:`Rights is not one of the allowed URIs.`,editorTarget:ud(r,[`rights`])})})}function sd(e,t,n,r){let i=t.entityType||`Manifest`;return r.filter(e=>e.ref.type===i).map(({ref:r,resource:i})=>{let a=i.requiredStatement,o=t.label?Cd(a?.label,t.label):Yu(a?.label),s=t.value||t.valueRequired!==!1,c=t.value?Cd(a?.value,t.value):!s||Yu(a?.value),l=Yu(a);return ld(e,t,n,{target:r,path:[`requiredStatement`],status:o&&c?`satisfied`:l?`invalid`:`missing`,displayLabel:Qu([e],r.type,[`requiredStatement`],`Required statement`),expected:t.value||t.label,actual:a,message:o&&c?`Required statement is complete.`:l?`Required statement does not match the specification.`:`Required statement must be filled in.`,editorTarget:ud(r,[`requiredStatement`])})})}function cd(e,t,n,r){let i=t.entityType||`Manifest`,a=r.filter(e=>e.ref.type===i),o=[];for(let{ref:r,resource:i}of a){let a=Array.isArray(i.metadata)?i.metadata:[];t.items.forEach((i,s)=>{let c=a.find(e=>Cd(e?.label,i.label)),l=i.value?Cd(c?.value,i.value):!i.valueRequired||Yu(c?.value),u=c&&l?`satisfied`:c&&i.value?`invalid`:`missing`,d=Td(i.label);o.push(ld(e,t,n,{idSuffix:`metadata-${s}`,target:r,path:[`metadata`],status:u,displayLabel:d||`Metadata`,expected:i.value||i.label,actual:c,message:c&&l?`${d||`Metadata`} is present.`:c?`${d||`Metadata`} needs a value.`:`${d||`Metadata`} metadata must be added.`,editorTarget:ud(r,[`metadata`])}))})}return o}function ld(e,t,n,r){let i=t.id||`${t.type}-${n}`,a=r.idSuffix?`-${r.idSuffix}`:``;return{id:`${e.id}-${i}-${r.target?.type||`root`}-${r.target?.id||`none`}${a}`,specificationId:e.id,specificationLabel:e.label,ruleId:i,ruleType:t.type,ruleLabel:t.label||r.displayLabel,ruleIndex:n,target:r.target,path:r.path,status:r.status,displayLabel:r.displayLabel,message:t.message||r.message,expected:r.expected,actual:r.actual,editorTarget:r.editorTarget}}function ud(e,t){let n=t[0];return{resource:e,propertyPath:t,selectedTab:n===`metadata`?`@manifest-editor/metadata`:n&&Wu.has(n)?`@manifest-editor/descriptive-properties`:void 0}}function dd(e){let t={...Uu};for(let n of e)t[n.status]+=1;return t}function fd(e,t){let n=pd(t);if(!n)return t;try{return e.get(n,{skipSelfReturn:!1})||t}catch{try{return e.get(n)||t}catch{return t}}}function pd(e){return!e||typeof e!=`object`?null:e.type===`SpecificResource`?{id:e.id||e.source?.id||``,type:`SpecificResource`}:typeof e.id==`string`&&typeof e.type==`string`?{id:e.id,type:e.type}:null}function md(e){if(!e||typeof e!=`object`)return[];let t=[];for(let n of[`items`,`structures`,`annotations`,`thumbnail`,`provider`,`homepage`,`rendering`,`seeAlso`,`body`,`target`,`source`]){let r=e[n];Array.isArray(r)?t.push(...r):r&&t.push(r)}return t}function hd(e){return[...e.serviceIds||[],...e.serviceId?[e.serviceId]:[]].filter(Boolean)}function gd(e,t){let n=new Set(e.filter(Boolean));return t.length?t.some(e=>n.has(e)):n.size>0}function _d(e,t){let n=xd(t,e?.items),r=[];for(let e of n){let n=xd(t,e?.items);for(let e of n)if((Array.isArray(e?.motivation)?e.motivation:[e?.motivation]).includes(`painting`))for(let n of yd(e?.body,t))r.push(...bd(n))}return Array.from(new Set(r))}function vd(e,t,n){let r=xd(n,e?.thumbnail);if(!r.length||!t.length)return!1;for(let e of r){let n=bd(e),r=typeof e?.id==`string`?e.id:``;if(n.some(e=>t.includes(e))||t.some(e=>r.startsWith(e)))return!0}return!1}function yd(e,t){let n=fd(t,e);return n?Array.isArray(n)?n.flatMap(e=>yd(e,t)):n.type===`SpecificResource`?yd(n.source,t):n.type===`Choice`?n.items?.flatMap(e=>yd(e,t))||[]:[n]:[]}function bd(e){let t=e?.service||e?.services,n=Array.isArray(t)?t:t?[t]:[],r=[];for(let e of n){let t=typeof e==`string`?e:e?.id||e?.[`@id`];typeof t==`string`&&t&&r.push(t)}return Array.from(new Set(r))}function xd(e,t){if(!t)return[];let n=Array.isArray(t)?t:[t];try{let t=e.get(n);if(Array.isArray(t))return t.filter(Boolean)}catch{}return n.map(t=>fd(e,t)).filter(Boolean)}function Sd(e){return e.replace(/^https:/,`http:`).replace(/\/?$/,`/`)}function Cd(e,t){return typeof t==`string`?wd(e).some(e=>e===t):Zu(e,t)}function wd(e){return e?typeof e==`string`?[e.trim()].filter(Boolean):Array.isArray(e)?e.flatMap(wd):typeof e==`object`?Object.values(e).flatMap(wd):[]:[]}function Td(e){return typeof e==`string`?e:wd(e)[0]||``}function Ed(e){return(e[e.length-1]||`Property`).replace(/([A-Z])/g,` $1`).replace(/[-_]/g,` `).replace(/^./,e=>e.toUpperCase())}const Dd=j([]);function Od({children:e,specifications:t}){let n=I(()=>t||[],[t]);return B(Dd.Provider,{value:n,children:e})}function kd(){return N(Dd)}function Ad(e){let t=Hi(),n=kd(),r=e||t;return Ge((e,t)=>ed(n,t,r),[n,r.id,r.type])}function jd(){let e=kd();return I(()=>({getLabel(t,n,r){return Qu(e,t,n,r)}}),[e])}function Md(e,t){let n=kd();return I(()=>$u(n,e,t),[n,e?.id,e?.type,JSON.stringify(t)])}const Nd={},Pd=j(`global`);function Fd(){return N(Pd)}function Id(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function Ld(e){let t=Fd(),[,n]=Ee(e=>e+1,0),r=I(()=>(Nd[t]||(Nd[t]={}),Nd[t][e]||(Nd[t][e]={name:e,emitter:ft(),status:`idle`,promise:Promise.resolve(),abort:new AbortController,reject:()=>void 0,resolve:()=>void 0}),Nd[t][e]),[t,e]);return Rd(r,`abort`,n),Rd(r,`error`,n),Rd(r,`complete`,n),Rd(r,`running`,n),r}function Rd(e,t,n){let r=M(()=>n(e),[n]);P(()=>{let n=e.emitter;return n.on(t,r),()=>n.off(t,r)},[t,r,e.emitter])}const zd=()=>void 0;function Bd(e,t){let n=Ld(e);return Rd(n,`complete`,t||zd),[e=>{n.status===`running`&&(n.abort.abort(),n.emitter.emit(`abort`)),n.error&&(n.error=``);let t=Id();t.promise.then(()=>n.emitter.emit(`complete`)).catch(()=>n.emitter.emit(`error`)),n.status=`running`,n.request=e,n.promise=t.promise,n.resolve=t.resolve,n.reject=t.reject,n.emitter.emit(`running`)},n]}function Vd(e,t){let n=Ld(e);return Rd(n,`running`,t),[e=>{n.status===`running`&&(n.response=e,n.status=`complete`,n.resolve())},n,(e,t)=>{n.status===`running`&&(n.error=t||e,n.status=`error`,n.reject(e))}]}function Hd({children:e}){return B(Pd.Provider,{value:I(()=>`id-${Date.now()}`,[]),children:e})}function Ud(e){return!1}function Wd({as:e,reference:t,onReference:n,onLink:r,onAnalysis:i,onDropReference:a,onDropLink:o,onDropAnalysis:s,onPasteReference:c,onPasteLink:l,onPasteAnalysis:u,...d}){let f=e||`div`,p=a||n,m=c||n,h=l||r,g=u||i,_=I(()=>t,[t?.id,t?.type]),v=M(function(e){e.defaultPrevented||(e.preventDefault(),e.clipboardData&&_&&_.id&&_.type&&e.clipboardData.setData(`application/json+vault`,JSON.stringify({id:_.id,type:_.type})))},[_]),y=M(async function(e){if(!e.defaultPrevented&&(e.preventDefault(),e.clipboardData)){if(d.onLoading&&d.onLoading(),m){let t=e.clipboardData.getData(`application/json+vault`);if(t)try{let e=JSON.parse(t);e&&e.id&&e.type&&m(e)}catch{}}if(h||g){let t=e.clipboardData.getData(`text`);if(t.startsWith(`http`)){let e=t.split(`
1531
+ `);for(let t of e){if(g)try{let e=await Ud(t);if(e){g(e);continue}}catch{}h&&h(t)}}}d.onComplete&&d.onComplete()}},[]),b=M(function(e){e.defaultPrevented||(e.preventDefault(),e.dataTransfer&&d.draggable&&(e.dataTransfer.effectAllowed=`all`,_&&_.id&&_.type&&e.dataTransfer.setData(`application/json+vault`,JSON.stringify({id:_.id,type:_.type}))))},[]),x=M(async function(e){if(e.preventDefault(),e.dataTransfer){if(p){let t=e.dataTransfer.getData(`application/json+vault`);if(t)try{let n=JSON.parse(t);n&&n.id&&n.type&&p(n,e)}catch{return}}let t=e.dataTransfer.getData(`application/json`);if(t){JSON.parse(t);return}if(e.dataTransfer.getData(`text/plain`))return}},[]),S=M(e=>{e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`)},[]);return B(f,{onCopy:v,onPaste:y,onDrop:x,onDragOver:S,onDragStart:b,tabIndex:-1,...d})}export{ds as AppHeader,hs as AppMenuProvider,Ei as AppProvider,yi as AppReactContext,Ui as AppResourceInstanceProvider,Wi as AppResourceProvider,bi as AppStateReactContext,je as AtlasStoreProvider,Ne as AtlasStoreReactContext,Ro as BackgroundActionToasts,Qo as BackgroundActionsMenu,Lo as BackgroundActionsMount,lr as BackgroundActionsProvider,cr as BackgroundActionsReactContext,bc as BaseAnnotationCreator,wc as BaseEditor,xc as BaseEditorBackButton,Sc as BaseEditorCloseButton,ua as ButtonChange,ca as ButtonContainer,_a as ButtonEmpty,la as ButtonMain,Rt as CANVAS_PROGRESS_META_NAMESPACE,zt as CANVAS_PROGRESS_STATUS_META_KEY,Lc as ConfigEditor,Lt as ConfigProvider,Pt as ConfigReactContext,Hc as ContextMenuProvider,Vc as ContextMenuReactContext,uc as CreatorInitialData,zc as CreatorSettings,Ba as EditingStack,Oa as EditingStackContext,_l as EventEmitterProvider,pl as ExportPanel,Qa as FLAG_TAG,tc as HOMEPAGE_COLLECTION,Cl as HandleContainer,Ol as HandleControls,Ic as IIIFOptions,Va as InlineEditingStack,hu as Layout,Ha as LayoutActionsReactContext,Wa as LayoutModeReactContext,Ua as LayoutStateReactContext,an as ManifestEditorCanvasProgressOverlay,So as ManifestEditorTagBadge,xo as ManifestEditorTagIcon,Co as ManifestEditorTagOverlay,Su as ManifestPaginationNavigation,da as MenuContainer,fa as MenuItem,ga as MenuItemClose,ha as MenuItemLabel,ma as MenuItemStatus,_t as MessagePortClientVault,Xs as ModularPanel,Gs as ModularPanelHeader,Ks as ModulePanelButton,Ai as MultiAppProvider,Vs as PanelError,_i as PluginConfigBridge,ii as PluginGlobalConfigReactContext,Nc as PluginManager,ai as PluginProvider,ri as PluginReactContext,us as PresetOnboarding,cs as PresetOnboardingButton,ls as PresetPreviewButton,ya as PreviewButton,na as PreviewProvider,ic as PreviewVaultBoundary,rc as PreviewVaultContext,Pu as PreviewWindowProvider,vi as PrimeAppReactContext,gl as ReactEmitterContext,wa as ResourceEditingProvider,ba as ResourceEditingReactContext,Ft as SaveConfigReactContext,Vu as ShellProvider,Od as SpecificationProvider,Za as TAGS_META_KEY,Xa as TAGS_META_NAMESPACE,Hd as TaskBridge,Oo as ToastProvider,Wd as UniversalCopyTarget,fo as addResourceTag,xs as analyse,Cs as analyseJson,ti as applyPlugins,vc as baseCreator,Tc as baseEditor,qt as clearCanvasProgressStatus,Yt as clearCanvasProgressStatuses,td as collectSpecificationResources,gr as copyToClipboard,mr as createActionIdentity,$n as createBackgroundActionsStore,hr as createDownload,ku as createIframeVaultBridge,or as createLocalForageBackgroundActionPersistence,Xt as createManifestEditorCanvasProgressApi,vo as createManifestEditorTagsApi,Yr as createPluginRuntimeApi,ni as createPluginStore,Zs as createPreviewVault,Zt as createTrackingCanvasProgressApi,bs as detectMedia,kr as disablePluginInConfig,Cc as editBasedOnResource,Xr as enablePluginAndDependenciesInConfig,Or as enablePluginInConfig,ed as evaluateSpecifications,br as extendApp,tu as filterSupportedPanels,mn as getAvailableBackgroundActionGroups,cn as getBackgroundActionInstanceKey,Wt as getCanvasProgressStatus,Gt as getCanvasProgressStatusFromState,xu as getDefaultLayoutState,bu as getDefaultPanelState,Jr as getEffectivePluginSettings,Cr as getEmptyPluginState,Ur as getEnabledPluginsForApp,Es as getFormat,Ds as getImageDimensions,pr as getManifestNomalized,Br as getPluginCompatibilityReason,qr as getPluginDefaultSettings,Hr as getPluginSelectionSource,Wr as getPluginSettingsFromConfig,os as getPresetOnboardingDismissalKey,$u as getPropertyPolicy,po as getResourceTag,ho as getResourceTagGroups,co as getResourceTags,lo as getResourceTagsFromState,Ci as getSelectedPresetTemplate,nu as getSupportedPanelFallback,Qu as getTerminologyLabel,qu as getValueAtPath,Yu as hasMeaningfulValue,va as hasPreviewOption,go as hasResourceTag,Fr as isLazyPlugin,Pr as isMappedPlugin,Rs as isPinnableState,zr as isPluginCompatible,Vr as isPluginSelected,yu as layoutReducer,vr as mapApp,Nr as mapLazyPlugin,Mr as mapPlugin,ln as mergeBackgroundActionDefinitions,Nt as mergeConfig,Mt as mergePartialConfig,yr as mergePresetConfig,Rr as mergeProviderPlugins,dn as normaliseBackgroundActionError,Xu as normaliseJsonValue,Ir as normalisePlugin,Er as normalisePluginAppConfig,Dr as normalisePluginAppsConfig,Lr as normalisePlugins,Gu as normaliseSpecificationPath,ru as panelIds,zs as panelSizing,jr as pluginAppConfigEquals,_s as polygonToBoundingBox,_r as randomId,mo as removeResourceTag,Bs as renderHelper,Ar as resetPluginInConfig,Kr as resetPluginSettingsInConfig,nr as runBackgroundAction,Kt as setCanvasProgressStatus,Jt as setCanvasProgressStatuses,Gr as setPluginSettingsInConfig,uo as setResourceTags,Ju as setValueAtPath,un as sortBackgroundActionDefinitions,Zu as specificationJsonEquals,Ku as specificationPathEquals,_o as toggleResourceTag,ml as useAnnotationCreatorState,La as useAnnotationPageEditor,Y as useApp,xi as useAppInstance,ps as useAppMenu,ms as useAppMenuItem,Hi as useAppResource,Vi as useAppResourceInstance,Si as useAppState,Oi as useApps,gs as useAtlasStore,Io as useAvailableBackgroundActions,Ja as useAvailableLayouts,fr as useBackgroundActionHistory,dr as useBackgroundActionInstance,J as useBackgroundActionsStore,ur as useBackgroundActionsStoreApi,$t as useCanvasProgressActions,Qt as useCanvasProgressStatus,Fa as useCollectionEditor,K as useConfig,Na as useCreatingResource,ac as useCreator,Kc as useCustomContextMenu,Ec as useDecayState,xa as useEditingContext,ja as useEditingResource,Ma as useEditingResourceStack,Aa as useEditingStack,Ra as useEditor,vl as useEmitter,ui as useEnabledPlugins,yl as useEvent,Ia as useGenericEditor,Os as useHighlightedImageResource,As as useHoverHighlightImageResource,lc as useInitialData,oc as useInlineCreator,Ka as useLayoutActions,qa as useLayoutMode,Ya as useLayoutProvider,Ga as useLayoutState,me as useLocalStorage,Pa as useManifestEditor,bl as useMatchMedia,ss as useOpenPresetOnboarding,he as useOptionalLocalStorage,oi as useOptionalPluginStoreApi,Ca as useOptionalResource,gu as usePanelActions,di as usePluginActions,mi as usePluginConfigApi,fi as usePluginRuntimeApi,pi as usePluginSettings,si as usePluginStoreApi,li as usePlugins,wi as usePresetTemplateSelection,ia as usePreviewContext,nc as usePreviewHistory,Qs as usePreviewVault,Fu as usePreviewWindow,ra as usePreviews,hi as useResolvedPluginApp,Sa as useResource,Wc as useResourceContextMenuItems,bo as useResourceTagActions,yo as useResourceTags,It as useSaveConfig,xl as useSaveVault,Us as useSetCustomTitle,Md as useSpecificationPropertyPolicy,Ad as useSpecificationReport,jd as useSpecificationTerminology,kd as useSpecifications,Sl as useSvgTools,Ld as useTask,Bd as useTaskDispatch,Rd as useTaskEvent,Vd as useTaskRunner,ks as useTemporaryHighlight,ko as useToasts};
1532
1532
  //# sourceMappingURL=index.js.map