@manifest-editor/shell 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
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 te,PaddedSidebarContainer as ne,PanelSideMenu as re,ResetIcon as ie,ResizeHandle as ae,Sidebar as oe,SidebarContent as D,SidebarHeader as se,SidebarTabs as ce,Spinner as le,Tab as ue,TabList as de,TabPanel as fe,Tabs as pe,ToastRegion as me,Tooltip as he,TooltipTrigger as ge,useLocalStorage as _e,useOptionalLocalStorage as ve,useOptionalLocalStorage as ye}from"@manifest-editor/components";import{Component as be,Fragment as xe,Suspense as Se,createContext as O,createElement as Ce,createRef as we,forwardRef as Te,memo as Ee,useCallback as k,useContext as A,useEffect as j,useImperativeHandle as De,useLayoutEffect as M,useMemo as N,useReducer as Oe,useRef as P,useState as F}from"react";import{Fragment as I,jsx as L,jsxs as R}from"react/jsx-runtime";import{create as ke,createStore as Ae,useStore as je}from"zustand";import Me from"localforage";import{AtlasStoreProvider as Ne,AtlasStoreProvider as Pe,AtlasStoreReactContext as Fe,CollectionContext as Ie,ImageServiceLoaderContext as Le,ManifestContext as Re,ReactVaultContext as ze,ResourceReactContext as Be,VaultProvider as Ve,useAtlasStore as He,useCurrentAnnotationMetadata as Ue,useExistingVault as We,useManifest as Ge,useResourceContext as Ke,useVault as z,useVaultSelector as qe}from"react-iiif-vault";import{isSpecificResource as Je,toRef as B}from"@iiif/parser";import V,{ThemeProvider as Ye,css as H}from"styled-components";import Xe from"react-accessible-dropdown-menu-hook";import{original as Ze,produce as Qe}from"immer";import{EditorInstance as $e}from"@manifest-editor/editor-api";import{useToastState as et}from"@react-stately/toast";import{getValue as tt}from"@iiif/helpers";import*as nt from"@iiif/helpers/vault";import{Vault as rt}from"@iiif/helpers/vault";import{Creator as it,matchBasedOnResource as at}from"@manifest-editor/creator-api";import{ErrorBoundary as ot}from"react-error-boundary";import{addReference as st,batchActions as ct,modifyEntityField as lt,reorderEntityField as ut,requestResource as dt}from"@iiif/helpers/vault/actions";import{actionListFromResource as ft}from"@iiif/helpers/vault/utility";import pt from"mitt";import{useDebounce as mt}from"tiny-use-debounce";import{Transition as ht}from"react-transition-group";import gt from"shallowequal";import{ImageServiceLoader as _t}from"@atlas-viewer/iiif-image-api";import{MessagePortClientVault as vt}from"@manifest-editor/client-vault";var yt=!0,bt=`Invariant failed`;function U(e,t){if(!e){if(yt)throw Error(bt);var n=typeof t==`function`?t():t,r=n?`${bt}: ${n}`:bt;throw Error(r)}}const xt={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}};function St(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 Ct(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 wt(...e){let t={};for(let n of e)n&&(t={...t,...n,editorConfig:St(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,plugins:Ct(t.plugins,n.plugins)});return t}function Tt(...e){return wt(xt,...e)}const Et=O(xt),Dt=O(()=>{});function Ot(){return A(Et)}function kt(){return A(Dt)}function At({children:e,config:t,saveConfig:n}){let[r,i]=F(null),a=N(()=>Tt(t,r),[t,r]),o=k(e=>{i(t=>wt(t,e)),n&&n(e)},[n]);return L(Dt.Provider,{value:o,children:L(Et.Provider,{value:a,children:e})})}const jt=`@manifest-editor/canvas-progress`,Mt=`status`,Nt=new Set([`queued`,`pending`,`done`]);function Pt(e){return typeof e==`string`?e:e?.id||null}function Ft(e){return typeof e==`string`&&Nt.has(e)?e:`none`}function It(e){return typeof e==`string`&&Nt.has(e)}function Lt(e,t){let n=Pt(t);return n?Ft(e.getResourceMeta(n,jt)?.[Mt]):`none`}function Rt(e,t){let n=Pt(t);return n?Ft(e?.iiif?.meta?.[n]?.[jt]?.[Mt]):`none`}function zt(e,t,n){let r=Pt(t);if(!r)return`none`;let i=It(n)?n:void 0;return e.setMetaValue([r,jt,Mt],i),i||`none`}function Bt(e,t){return zt(e,t,`none`)}function Vt(e,t,n){let r={};for(let i of t){let t=Pt(i);t&&(r[t]=zt(e,i,n))}return r}function Ht(e,t){return Vt(e,t,`none`)}function Ut(e){return{getStatus(t){return Lt(e,t)},setStatus(t,n){return zt(e,t,n)},clearStatus(t){return Bt(e,t)},setStatuses(t,n){return Vt(e,t,n)},clearStatuses(t){return Ht(e,t)}}}function Wt(e,t=new Set){function n(e){let n=Pt(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 Gt(e){let t=Pt(e);return qe(e=>t?Rt(e,t):`none`,[t])}function Kt(e){let t=z(),n=Pt(e),r=N(()=>Ut(t),[t]);return N(()=>({setStatus(e){return r.setStatus(n,e)},clearStatus(){return r.clearStatus(n)},getStatus(){return r.getStatus(n)}}),[r,n])}const qt={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 Jt({className:e}){return R(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[L(`circle`,{cx:`12`,cy:`12`,r:`9`}),L(`path`,{d:`M12 7v5l2.5 2.5`})]})}function Yt({className:e}){return R(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,children:[L(`circle`,{cx:`12`,cy:`12`,r:`9`,stroke:`currentColor`,strokeWidth:`2.5`,strokeOpacity:`0.3`}),L(`path`,{d:`M12 3a9 9 0 0 1 9 9`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`})]})}function Xt({className:e}){return L(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:L(`path`,{d:`M5 12l4 4 8-8`})})}function Zt({resource:e,status:t,className:n}){return t?L($t,{status:t,className:n}):L(Qt,{resource:e,className:n})}function Qt({resource:e,className:t}){return L($t,{status:Gt(e),className:t})}function $t({status:e,className:t}){if(e===`none`)return null;let n=qt[e];return R(I,{children:[n.dimOverlay&&L(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 z-10 bg-white/40`}),L(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-x-0 top-0 z-10 h-[3px] rounded-t-sm ${n.stripClass} ${t||``}`}),R(`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:[L(`span`,{className:`sr-only`,children:n.label}),e===`queued`&&L(Jt,{className:`h-2.5 w-2.5 text-white`}),e===`pending`&&L(Yt,{className:`h-2.5 w-2.5 animate-spin text-white`}),e===`done`&&L(Xt,{className:`h-2.5 w-2.5 text-white`})]})]})}function en(e,t){return`${e}::${t.type}::${t.id}`}function tn(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 nn(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 rn(e){return e instanceof Error?{message:e.message,stack:e.stack,detail:e}:{message:typeof e==`string`?e:`Background action failed`,detail:e}}function an(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}:rn(e)}function on(e,t){return e.resourceTypes?.length?e.resourceTypes.includes(t.type):!0}function sn({definitions:e,instances:t,systemContext:n,targets:r,onSupportsError:i}){let a=nn(e),o=[];for(let e of r){let r=[];for(let o of a){if(!on(o,e))continue;let a=en(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 cn=0;function ln(e){return cn+=1,`${e}-${Date.now()}-${cn}`}function un(e,t,n,r=Date.now()){return{id:ln(`event`),createdAt:r,type:e,message:t,data:n}}function W(e,t,n,r,i=Date.now()){return{...e,events:[...e.events,un(t,n,r,i)]}}function dn(e){return e.filter(e=>String(e.type)!==`progress`)}function fn(e){return{...e,logs:[...e.logs],events:dn(e.events),progress:e.progress?{...e.progress}:void 0}}function pn(e,t,n){if(!_n(n.status))return e;let r=e[t]||[],i=fn(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 G(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:pn(e.histories,t,i)}}function mn(e){return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}function hn(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:mn(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 gn(e){return e===`preparing`||e===`running`}function _n(e){return e===`complete`||e===`error`||e===`cancelled`}function vn(e){return e===`queued`||e===`running`||e===`complete`||e===`skipped`||e===`error`||e===`cancelled`}function yn(e){return!e||e===`queued`||e===`running`}function bn(e){return e===`complete`||e===`skipped`||e===`error`||e===`cancelled`}function xn(e){if(e!==void 0)try{return JSON.parse(JSON.stringify(e))}catch{return}}function Sn(e){return e&&{message:e.message,stack:e.stack,detail:xn(e.detail)}}function Cn(e){return{...e,error:Sn(e.error)||null,result:xn(e.result),logs:e.logs.map(e=>({...e,data:xn(e.data)})),events:dn(e.events).map(e=>({...e,data:xn(e.data)})),progress:e.progress?{...e.progress}:void 0}}function wn(e){return{...e,status:An(e.status),input:xn(e.input),result:xn(e.result),error:Sn(e.error)||null}}function Tn(e){return{version:1,data:xn(e.data),tasks:e.tasks.map(wn)}}function En(e){return{version:1,savedAt:Date.now(),instances:Object.fromEntries(Object.entries(e.instances).map(([e,t])=>[e,Cn(t)])),histories:Object.fromEntries(Object.entries(e.histories).map(([e,t])=>[e,t.map(Cn)])),plans:Object.fromEntries(Object.entries(e.plans).map(([e,t])=>[e,Tn(t)]))}}function Dn(){return{version:1,savedAt:Date.now(),instances:{},histories:{},plans:{}}}function On(e,t){return{version:1,savedAt:t.savedAt,instances:{...e.instances,...t.instances},histories:{...e.histories,...t.histories},plans:{...e.plans,...t.plans}}}function kn(e){return!Object.keys(e.instances).length&&!Object.keys(e.histories).length&&!Object.keys(e.plans).length}function An(e){return vn(e)?e:`queued`}function jn(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:An(e.status),error:e.error?an(e.error):null,createdAt:typeof e.createdAt==`number`?e.createdAt:n}}function Mn(e){return!e||e.version!==1||!Array.isArray(e.tasks)?null:{version:1,data:e.data,tasks:e.tasks.map(jn)}}function Nn(e){return{...e,tasks:e.tasks.map(e=>e.status===`running`?{...e,status:`queued`,statusText:`Queued after reload`,startedAt:void 0}:e)}}function Pn(e,t=Date.now()){return{...e,tasks:e.tasks.map(e=>yn(e.status)?{...e,status:`cancelled`,statusText:`Cancelled`,error:null,completedAt:t}:e)}}function Fn(e){return{...e,error:e.error?an(e.error):null,logs:Array.isArray(e.logs)?e.logs:[],events:dn(Array.isArray(e.events)?e.events:[]),resultsAvailable:e.resultsAvailable===!0}}function In(e){return!e||e.version!==1?Dn():{version:1,savedAt:typeof e.savedAt==`number`?e.savedAt:Date.now(),instances:e.instances||{},histories:e.histories||{},plans:e.plans||{}}}function Ln(e,t,n){let r=e,i=t;if(gn(e.status))if(e.cancelRequestedAt){let t=Date.now();i=i&&Pn(i,t),r=W({...e,status:`cancelled`,statusText:`Cancelled`,completedAt:t,cancelledAt:t},`status`,`Cancelled`,{status:`cancelled`},t)}else if(n.resumable&&i)i=Nn(i),r=W({...e,status:`running`,statusText:`Resuming`,completedAt:void 0,cancelledAt:void 0},`status`,`Resuming`,{status:`running`});else{let t=Date.now();r=W({...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 Rn(e,t){let n=In(e),r=new Map(t.map(e=>[e.id,e])),i={},a={},o={},s=Dn();for(let[e,t]of Object.entries(n.histories)){let n=(Array.isArray(t)?t:[]).map(Fn),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=Fn(t),l=Mn(n.plans[e]),u=r.get(c.actionId);if(!u){s.instances[e]=Cn(c),l&&(s.plans[e]=Tn(l));continue}let d=Ln(c,l,u);i[e]=d.instance,a=pn(a,e,d.instance),d.plan&&(o[e]=d.plan)}return{instances:i,histories:a,plans:o,deferred:s}}function zn(e,t){let n=e.tasks.length;if(!n)return;let r=e.tasks.filter(e=>bn(e.status)).length;return hn({current:r,total:n,label:t})}function Bn(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 Vn(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 Hn(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(An(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||Un(m,p)&&(await Wn(),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=>bn(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=Bn(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||Yn(e))throw l(u.id,{status:`cancelled`,statusText:`Cancelled`,error:null,completedAt:Date.now()},!0),e;let n=rn(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=>bn(e.status)).length,total:d,label:_})}}return s()}return{getAll:s,getPending:()=>c(),update:l,runEach:u}}function Un(e,t){return t!==!1&&(!e||Date.now()-e>=t)}function Wn(){return new Promise(e=>{setTimeout(e,0)})}function Gn(e=[]){let t=null,n=null,r=null,i=Dn();return Ae((a,o)=>{function s(e,t){let n=tn([],t),r=Rn(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&&gn(e.instances[t].status)))}}async function c(){if(r&&(clearTimeout(r),r=null),!t||!n||!o().hasHydrated)return;let e=On(i,En(o()));if(kn(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:tn([],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=Rn(In(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,tn(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:ln(`run`),actionId:t.id,target:n,label:t.label,status:`preparing`,statusText:`Preparing`,error:null,result:void 0,resultsAvailable:!1,logs:[],events:[un(`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=>({...G(r,e,e=>W({...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||!gn(n.status))return;let r=Date.now();a(t=>{let n=G(t,e,e=>W(W({...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]:Pn(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=>({...G(r,e,e=>W({...e,label:t},`label`,t,{label:t},n))})),l()},setActionStatus(e,t,n){let r=Date.now(),i=_n(t)?r:void 0;a(a=>({...G(a,e,e=>W({...e,status:t,statusText:n,completedAt:i,cancelledAt:t===`cancelled`?r:void 0},`status`,n||t,{status:t},r)),controllers:gn(t)?a.controllers:Object.fromEntries(Object.entries(a.controllers).filter(([t])=>t!==e))})),l(_n(t))},setActionError(e,t,n){let r=Date.now(),i=rn(t);a(t=>({...G(t,e,e=>W({...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:ln(`log`),createdAt:i,level:n,message:t,data:r};a(a=>({...G(a,e,e=>W({...e,logs:[...e.logs,o]},`log`,t,{level:n,data:r},i))})),l()},setActionProgress(e,t){let n=t?hn(t):void 0;a(t=>({...G(t,e,e=>({...e,progress:n}))}))},setResult(e,t){let n=Date.now();a(r=>({...G(r,e,e=>W({...e,result:t},`result`,`Result recorded`,void 0,n))})),l(!0)},setResultsAvailable(e,t){let n=Date.now();a(r=>({...G(r,e,e=>W({...e,resultsAvailable:t},`results-available`,t?`Results available`:`Results hidden`,{available:t},n))})),l(!0)},setActionPlan(e,t){let n=Mn(t);n&&(a(t=>({...G(t,e,e=>({...e,progress:zn(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?jn({...e,...n,status:n.status?An(n.status):e.status,error:n.error?an(n.error):n.error===null?null:e.error},0):e),o={...i,tasks:a};return{...G(r,e,e=>({...e,progress:zn(o,n.statusText||n.label)})),plans:{...r.plans,[e]:o}}}),l(r)}}})}function Kn(e,t,n){let{store:r,context:i}=e,{instanceKey:a}=i,o=Hn(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 qn(e){return!!e&&typeof e==`object`&&e.version===1&&Array.isArray(e.tasks)}async function Jn(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=Wt(n.canvasProgress),d=()=>c.abort();e.signal&&(e.signal.aborted?c.abort():e.signal.addEventListener(`abort`,d,{once:!0})),e.resume&&o&&gn(o.status)?t.getState().resumeAction(i,c):t.getState().startAction(i,r,a,c);let f=()=>{let e=t.getState().instances[i];e&&!_n(e.status)&&t.getState().setActionStatus(i,`cancelled`,`Cancelled`)};try{if(!e.resume&&r.prepare){let n=await r.prepare(Kn(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];qn(n)&&t.getState().setActionPlan(i,n)}if(l.aborted)return f(),t.getState().instances[i];let n=t.getState().plans[i];n&&Vn(u,n),t.getState().setActionStatus(i,`running`,e.resume?`Resuming`:`Running`);let a=await r.run(Kn(e,l,u));if(l.aborted)return f(),t.getState().instances[i];let o=t.getState().instances[i];a!==void 0&&o&&!_n(o.status)&&t.getState().setResult(i,a),o=t.getState().instances[i],o&&gn(o.status)&&((a!==void 0||o?.resultsAvailable)&&t.getState().setResultsAvailable(i,!0),t.getState().setActionStatus(i,`complete`,`Complete`))}catch(e){l.aborted||Yn(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 Yn(e){return e instanceof Error&&(e.name===`AbortError`||e.message.toLowerCase().includes(`aborted`))}function Xn(e){return JSON.stringify([e.appId,e.instanceId,e.rootResource.type,e.rootResource.id])}let Zn;function Qn(){if(typeof window>`u`)return null;let e=Me.createInstance({name:`manifest-editor-background-actions-v1`,storeName:`background-actions`});return{async load(t){return e.getItem(Xn(t))},async save(t,n){await e.setItem(Xn(t),n)},async clear(t){await e.removeItem(Xn(t))}}}function $n(){return Zn===void 0&&(Zn=Qn()),Zn}const er=O(null);function tr({children:e,persistence:t,persistenceKey:n}){let r=q(),i=fi(),a=N(()=>Gn(),[]),o=r.layout.backgroundActions||[],s=N(()=>t===!1?null:t||$n(),[t]),c=N(()=>n||null,[n]);return j(()=>{a.getState().setDefinitions(o)},[a,o]),j(()=>{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]),j(()=>{let e=()=>{a.getState().flushPersistence()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[a]),Ce(er.Provider,{value:a},e)}function nr(){let e=A(er);if(!e)throw Error(`useBackgroundActionsStore must be used within a BackgroundActionsProvider`);return e}function K(e=e=>e){return je(nr(),e)}function rr(e){return K(t=>t.instances[e])}function ir(e){return K(t=>t.histories[e]||[])}async function ar(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 or(e,t,n){return`create_${e}_${t}_${B(n)?.type||`unknown`}`}function sr(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 cr(e){return navigator.clipboard.writeText(typeof e==`string`?e:JSON.stringify(e,null,2))}function lr(){return`${Math.random().toString(36).substr(2)}-${Date.now().toString(36)}`}function ur(e,t){let{default:n,config:r,...i}=e,a={metadata:n,layout:{leftPanels:[],rightPanels:[],centerPanels:[],...i},config:r};return t?t(a):a}function dr(e,t,n){return{...e,metadata:t,config:wt(e.config||{},n.config||{}),layout:{...e.layout,leftPanels:[...(e.layout.leftPanels||[]).filter(e=>n?.leftPanelIds?n.leftPanelIds.includes(e.id):!0),...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:tn(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 fr=[`leftPanels`,`centerPanels`,`rightPanels`,`modalPanels`,`annotations`,`canvasEditors`,`editors`,`creators`,`background`,`backgroundActions`],pr={plugins:[],enabled:[],disabled:[],globalApps:{},apps:{}};function mr(){return pr}function hr(e=[]){return Array.from(new Set(e.filter(Boolean)))}function gr(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function _r(e={}){return{...e,enabled:hr(e.enabled||[]),disabled:hr(e.disabled||[]),settings:e.settings?{...e.settings}:void 0}}function vr(e){let t={};for(let[n,r]of Object.entries(e?.apps||{}))t[n]=_r(r);return t}function yr(e={},t){return{...e,enabled:hr([...(e.enabled||[]).filter(e=>e!==t),t]),disabled:(e.disabled||[]).filter(e=>e!==t)}}function br(e={},t){return{...e,enabled:(e.enabled||[]).filter(e=>e!==t),disabled:hr([...(e.disabled||[]).filter(e=>e!==t),t])}}function xr(e={},t){return{...e,enabled:(e.enabled||[]).filter(e=>e!==t),disabled:(e.disabled||[]).filter(e=>e!==t)}}function Sr(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 Cr(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 wr(e){return{metadata:e.default,extension:{},settings:e.settings,load:e.load,loadStatus:`idle`}}function Tr(e){return!!e&&`metadata`in e&&`extension`in e}function Er(e){return!!e&&`load`in e&&`default`in e}function Dr(e){return Tr(e)?e:Er(e)?wr(e):Cr(e)}function Or(e=[]){return e.map(Dr)}function kr(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 Ar(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 jr(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 Mr(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 Nr(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 Pr(e,t,n){let r=[],i=new Set,a=new Set,o=new Set(e.plugins.filter(r=>Ar(r,t,n)&&Mr(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 Ur(`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 Ur(`Plugin "${u}" was not enabled because dependency "${r}" is not enabled.`),c.delete(u),a.add(u),!1;if(!Ar(e,t,n))return Ur(`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)Ar(r,t,n)&&Mr(r,e,n)&&l(r);return r}function Fr(e,t){let n=e?.settings?.[t];return gr(n)?n:{}}function Ir(e={},t,n){return{...e,settings:{...e.settings||{},[t]:n}}}function Lr(e={},t){let n={...e.settings||{}};return delete n[t],{...e,settings:n}}function Rr(e){return{...e?.settings?.defaults||{}}}function zr(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{...Rr(r),...Fr(i,t),...Fr(a,t)}}function Br(e,t){return{getSettings(n){return zr(e,n,t)}}}function Vr(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(!Ar(e,r,i)){s.push(`${e.metadata.label} is not compatible`);continue}u(e)}c.delete(t),l=yr(l,t),o.push(t)}}return u(n),s.length?{config:e,enabledIds:[],blocked:s}:{config:l,enabledIds:o,blocked:s}}function Hr(e,t){return t===`modalPanels`?e.layout.modals||[]:e.layout[t]||[]}function Ur(e){globalThis.process?.env?.NODE_ENV!==`production`&&console.warn(`[manifest-editor/plugin] ${e}`)}function Wr(e,t,n,r){if(!r?.length)return;let i=[];for(let a of r){if(n.has(a.id)){Ur(`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 Gr(e,t){let n=t.extension,r={config:n.config,disableSideEffects:n.disableSideEffects};for(let i of fr){let a=Wr(t,i,new Set(Hr(e,i).map(e=>e.id)),n[i]);a&&(r[i]=a)}return r}function Kr(e,t,n){if(!t.length)return e;let r=e,i=new Set;for(let a of t){if(!Ar(a,e,n))continue;let t=(a.metadata.dependencies||[]).filter(e=>!i.has(e));if(t.length){Ur(`Plugin "${a.metadata.id}" was not applied because dependencies are missing or later in the plugin order: ${t.join(`, `)}`);continue}let o=Gr(r,a);r=dr(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:wt(e.config||{},...t.filter(e=>i.has(e.metadata.id)).map(e=>e.extension.config||{}),r.config||{}),layout:{...r.layout,leftPanels:[...l,...o],backgroundActions:tn([],r.layout.backgroundActions||[])}}}function qr({plugins:e=[],enabled:t=[],disabled:n=[],globalPluginConfig:r}={}){let i=(e=[])=>Array.from(new Set(e.filter(Boolean)));return Ae(a=>({plugins:e,enabled:i(t),disabled:i(n),globalApps:vr(r),apps:{},setProviderState(e){a(t=>({...t,plugins:kr(t.plugins,e.plugins||[]),enabled:i(e.enabled||[]),disabled:i(e.disabled||[]),globalApps:vr(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=_r(t);a(t=>Sr(t.apps[e],n)?t:{...t,apps:{...t.apps,[e]:n}})},setGlobalConfig(e){a(t=>({...t,globalApps:vr(e)}))},setGlobalAppConfig(e,t){let n=_r(t);a(t=>Sr(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]:yr(r.globalApps[e],t)}}:{apps:{...r.apps,[e]:yr(r.apps[e],t)}}}))},disable(e,t,n=`workspace`){a(r=>({...r,...n===`global`?{globalApps:{...r.globalApps,[e]:br(r.globalApps[e],t)}}:{apps:{...r.apps,[e]:br(r.apps[e],t)}}}))}}))}const Jr=O(null),Yr=O({});function Xr({plugins:e,enabled:t,disabled:n,globalPluginConfig:r,saveGlobalPluginConfig:i,children:a}){let o=N(()=>Or(e),[e]),s=N(()=>qr({plugins:o,enabled:t,disabled:n,globalPluginConfig:r}),[]);j(()=>{s.getState().setProviderState({plugins:o,enabled:t,disabled:n,globalPluginConfig:r})},[s,o,t,n,r]);let c=N(()=>({globalPluginConfig:r,saveGlobalPluginConfig:i}),[r,i]);return Ce(Yr.Provider,{value:c},Ce(Jr.Provider,{value:s},a))}function Zr(){return A(Jr)}function Qr(){let e=Zr();if(!e)throw Error(`usePluginStoreApi must be used within <PluginProvider />`);return e}function $r(e){let t=Zr();return t?je(t,e):e(mr())}function ei(){return $r(e=>({plugins:e.plugins,enabled:e.enabled,disabled:e.disabled,globalApps:e.globalApps,apps:e.apps}))}function ti(e){let t=A(ui),n=A(li),r=ei(),i=e||t?.appId;return N(()=>Pr(r,n,i),[r,n,i])}function ni(){let e=Zr();return N(()=>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 ri(e){let t=A(ui),n=ei(),r=e||t?.appId;return N(()=>Br(n,r),[n,r])}function ii(e,t){let n=A(ui),r=ei(),i=t||n?.appId;return N(()=>zr(r,e,i),[r,e,i])}function ai(e,t){let n=A(ui),r=Zr(),i=ei(),a=Ot(),o=kt(),{saveGlobalPluginConfig:s}=A(Yr),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=N(()=>Rr(l||void 0),[l]),p=N(()=>Fr(u,e),[u,e]),m=N(()=>Fr(d,e),[d,e]),h=N(()=>zr(i,e,c),[i,e,c]),g=k(e=>{c&&(r?.getState().setAppConfig(c,e),o({plugins:{...a.plugins||{},apps:{...a.plugins?.apps||{},[c]:e}}}))},[a.plugins,c,o,r]),_=k(t=>{g(Ir(d||{},e,t))},[g,e,d]),v=k(()=>{g(Lr(d||{},e))},[g,e,d]),y=k(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=k(async t=>{await y(Ir(u||{},e,t))},[u,y,e]),x=k(async()=>{await y(Lr(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 oi(e,t){let n=ei(),r=Zr(),i=N(()=>Pr(n,e,t),[n,e,t]);return j(()=>{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,Dr(t))}).catch(t=>{r.getState().setPluginLoadError(e.metadata.id,si(t))}))},[r,i]),N(()=>Kr(e,i.filter(e=>!e.load||e.loadStatus===`loaded`),t),[e,i,t])}function si(e){return e instanceof Error?e.message:typeof e==`string`?e:`Plugin failed to load.`}function ci({config:e}){let t=A(ui),n=Zr(),r=t?.appId,i=r?e?.plugins?.apps?.[r]:void 0;return j(()=>{!n||!r||n.getState().setAppConfig(r,i||{})},[n,r,i]),null}const li=O(null),ui=O(null),di=O({state:null,setState:()=>{}});function fi(){let e=A(ui);return U(e,`Hook useAppInstance must be used inside <AppProvider />`),e}function q(){let e=A(li);return U(e,`Hook useApp must be used inside <AppProvider />`),e}function pi(){return A(di)}function mi(e){let[t,n,r]=_e(`app-state/${e.appId}/${e.instanceId}`,e.initialState||{}),i=k(e=>{let t=r.current?JSON.parse(r.current||`{}`):{},i=(typeof e==`function`?e(t):e)||{};n({...t,...i})},[]);j(()=>{e.args&&i(e.args)},[e.appId]);let a=N(()=>({state:t||{},setState:i}),[i,t]);return L(di.Provider,{value:a,children:e.children})}function hi({instanceId:e,appId:t,args:n,definition:r,children:i,initialState:a}){let o=N(()=>({instanceId:e,appId:t,args:n}),[e,t,n]),s=N(()=>a||{},[e]),c=oi(r,t);return L(At,{config:c.config||{},children:L(li.Provider,{value:c,children:L(ui.Provider,{value:o,children:L(mi,{instanceId:o.instanceId,appId:o.appId,args:o.args,initialState:s,children:i})})})})}const gi=O(null);function _i(){let e=A(gi);return U(e,`Hook useApps must be used inside <MultiAppProvider />`),e}function vi(e,t=!1){let[n,r]=ye(`SelectedApplication`,e||{id:`splash`},!t);return[n,r]}function yi({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]=vi(t,n),d=e=>{e===`Manifest`&&u({id:c}),e===`Collection`&&u({id:s})},f=N(()=>({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:L(hi,{appId:l.id,definition:p,instanceId:l.id+r,args:l.args,children:L(gi.Provider,{value:f,children:i})})}const bi=V.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:{}};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`
2
2
  display: flex;
3
3
  align-items: center;
4
4
  height: 3em;
5
5
  padding: 0.5em;
6
- `,xi=V.div`
6
+ `,Ni=U.div`
7
7
  display: flex;
8
8
  padding: 0.25em;
9
9
  flex-direction: column;
10
- `;V.button`
10
+ `;U.button`
11
11
  height: 1.75em;
12
12
  width: 1.75em;
13
13
  background: #e9e9e9;
@@ -26,9 +26,9 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
26
26
  fill: #fff;
27
27
  }
28
28
  }
29
- `,V.div`
29
+ `,U.div`
30
30
  flex: 1;
31
- `;const Si=V.div`
31
+ `;const Pi=U.div`
32
32
  color: #6e6e6e;
33
33
  display: flex;
34
34
  align-items: center;
@@ -39,7 +39,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
39
39
  user-select: none;
40
40
  cursor: pointer;
41
41
  margin-right: 0.5em;
42
- `;V.div`
42
+ `;U.div`
43
43
  margin: 0 auto;
44
44
  padding: 3px;
45
45
  background: #f4f4f4;
@@ -52,7 +52,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
52
52
  @media (max-width: 450px) {
53
53
  display: none;
54
54
  }
55
- `,V.button`
55
+ `,U.button`
56
56
  background: #e7fff4;
57
57
  border: 1px solid #c5e3cd;
58
58
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.06);
@@ -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 Ci=({height:e=16})=>R(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:e,viewBox:`0 0 24 24`,width:`24px`,fill:`currentColor`,children:[L(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),L(`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`})]}),wi=({rotate:e=0,...t})=>L(`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:L(`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`})}),Ti=O(null),Ei=O(null);function Di(){let e=A(Ei),t=A(Ti),n=e||t?.id;return U(n,`useResourceInstance can only be called from inside <ResourceProvider />`),n}function Oi(){let e=A(Ti);return U(e,`useResource can only be called from inside <ResourceProvider />`),e}function ki({id:e,children:t}){return e?L(Ei.Provider,{value:e,children:t}):t}function Ai({resource:e,children:t}){let n=We(),r=t;return e&&e.type===`Manifest`&&(r=L(Ve,{vault:n||void 0,children:L(Re,{manifest:e.id||``,children:t})})),e&&e.type===`Collection`&&(r=L(Ve,{vault:n||void 0,children:L(Ie,{collection:e.id||``,children:t})})),L(Ti.Provider,{value:e,children:r})}function ji(e){"@babel/helpers - typeof";return ji=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},ji(e)}function Mi(e,t){if(ji(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(ji(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Ni(e){var t=Mi(e,`string`);return ji(t)==`symbol`?t:t+``}function J(e,t,n){return(t=Ni(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Pi=class{constructor({id:e,config:t,label:n}){J(this,`id`,void 0),J(this,`label`,void 0),J(this,`type`,`external-manifest-preview`),J(this,`focusable`,!0),J(this,`serviceUrl`,void 0),J(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])}},Fi=class{constructor({id:e,config:t,label:n}){J(this,`id`,void 0),J(this,`label`,void 0),J(this,`type`,`iiif-preview-service`),J(this,`focusable`,!1),J(this,`serviceUrl`,void 0),J(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)});U(i.ok,`Unknown error creating preview`);let a=await i.json();return U(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)});U(o.ok,`Unknown error updating preview`);let s=await o.json();U(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 Ii(e,t,n,r,i){let a=Oi(),o=Di(),s=z(),c=N(()=>({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]=N(()=>{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;U(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 N(()=>({selectPreview:f,deletePreview:m,focusPreview:h,activatePreview:g,updatePreviews:d,getPreviewLink:p}),[l,o,s,e.selected,e.active,r])}function Li(e){return N(()=>{let t=[];for(let n of e)switch(n.type){case`iiif-preview-service`:t.push(new Fi(n));break;case`external-manifest-preview`:t.push(new Pi(n));break}return t},[])}const Ri=Qe(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);break}});function zi(){return{active:[],selected:null}}const Bi=O(null),Vi=O([]),Hi=Ee(function({children:e,configs:t=[]}){let n=Di(),r=Li(t),[i,a]=_e(`preview-${n}`,[]),[o,s]=Oe(Ri,void 0,zi),c=Ii(o,s,r,i,a),l=N(()=>({configs:t,actions:c,handlers:r,...o}),[c,t,r,o]);return j(()=>{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]),L(Vi.Provider,{value:i,children:L(Bi.Provider,{value:l,children:e})})});function Ui(){return A(Vi)}function Wi(){let e=A(Bi);return U(e,`usePreviewContext() can only be called from inside <PreviewProvider />`),e}const Gi=V.button`
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`
64
64
  border: none;
65
65
  outline: none;
66
66
  background-color: transparent;
@@ -72,7 +72,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
72
72
  &:hover {
73
73
  color: inherit;
74
74
  }
75
- `,Y=V.button`
75
+ `,oa=U.button`
76
76
  padding: 0.5rem 1rem;
77
77
  color: ${e=>e.theme.color.main||`none`};
78
78
  background-color: ${e=>e.theme.color.white||`white`};
@@ -90,11 +90,11 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
90
90
  &:hover {
91
91
  background: #eee;
92
92
  }
93
- `;V(Y)`
93
+ `;U(oa)`
94
94
  padding: 0.25em ${e=>e.theme.padding.xs||`0.4em`};
95
95
  height: unset;
96
96
  background: none;
97
- `,V(Y)`
97
+ `,U(oa)`
98
98
  {
99
99
  padding: 0 ${e=>e.theme.padding.medium||`1rem`};
100
100
  color: ${e=>e.theme.color.main||`#B84C74;`};
@@ -113,7 +113,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
113
113
  cursor: not-allowed;
114
114
  }
115
115
  }
116
- `;const Ki=V(Y)`
116
+ `;const sa=U(oa)`
117
117
  padding: 0 ${e=>e.theme.padding.medium||`1rem`};
118
118
  color: ${e=>e.theme.color.white||`white`};
119
119
  background-color: ${e=>e.theme.color.main||`#B84C74;`};
@@ -126,17 +126,17 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
126
126
  &:hover {
127
127
  background-color: ${e=>e.theme.color.mainHover||`#B84C74;`};
128
128
  }
129
- `;V.div`
129
+ `;U.div`
130
130
  display: flex;
131
131
  flex-direction: row;
132
132
  flex-wrap: wrap;
133
133
  align-items: flex-start;
134
134
  justify-content: ${e=>e.$right?`flex-end`:`flex-start`};
135
- `;const qi=V.div`
135
+ `;const ca=U.div`
136
136
  display: flex;
137
137
  position: relative;
138
138
  width: 10em;
139
- `,Ji=V(Gi)`
139
+ `,la=U(aa)`
140
140
  flex: 1;
141
141
  padding: 0.5em 0.8em;
142
142
  background: #b84c74;
@@ -157,7 +157,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
157
157
  background: #892c4e;
158
158
  box-shadow: inset 0 2px 8px 0 rgba(0, 0, 0, 0.15);
159
159
  }
160
- `,Yi=V(Gi)`
160
+ `,ua=U(aa)`
161
161
  background: #b84c74;
162
162
  border-top-right-radius: 5px;
163
163
  border-bottom-right-radius: 5px;
@@ -178,11 +178,11 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
178
178
  box-shadow: inset 0 2px 8px 0 rgba(0, 0, 0, 0.15);
179
179
  }
180
180
 
181
- ${e=>e.$open&&H`
181
+ ${e=>e.$open&&W`
182
182
  background: #892c4e;
183
183
  box-shadow: inset 0 2px 8px 0 rgba(0, 0, 0, 0.15);
184
184
  `}
185
- `,Xi=V.div`
185
+ `,da=U.div`
186
186
  position: absolute;
187
187
  opacity: 0;
188
188
  top: 100%;
@@ -199,11 +199,11 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
199
199
  color: #25211f;
200
200
  overflow: hidden;
201
201
 
202
- ${e=>e.$open&&H`
202
+ ${e=>e.$open&&W`
203
203
  opacity: 1;
204
204
  pointer-events: visible;
205
205
  `}
206
- `,Zi=V.div`
206
+ `,fa=U.div`
207
207
  display: flex;
208
208
  background: #fff;
209
209
  color: #25211f;
@@ -213,13 +213,13 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
213
213
  &:hover {
214
214
  background: #f9f9f9;
215
215
  }
216
- `,Qi={available:`#ddd`,configured:`#e37266`,active:`#4cb235`},$i=V.div`
216
+ `,pa={available:`#ddd`,configured:`#e37266`,active:`#4cb235`},ma=U.div`
217
217
  margin: 0.2em 0.5em;
218
218
  width: 8px;
219
219
  height: 8px;
220
220
  border-radius: 50%;
221
- background-color: ${e=>Qi[e.$status]};
222
- `,ea=V.div`
221
+ background-color: ${e=>pa[e.$status]};
222
+ `,ha=U.div`
223
223
  flex: 1;
224
224
  font-size: 0.925em;
225
225
  color: #25211f;
@@ -228,10 +228,10 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
228
228
  cursor: pointer;
229
229
  white-space: nowrap;
230
230
  overflow: hidden;
231
- `,ta=V.div`
231
+ `,ga=U.div`
232
232
  background: #f9f9f9;
233
233
  font-size: 0.8em;
234
- `,na=V.div`
234
+ `,_a=U.div`
235
235
  color: #999;
236
236
  font-size: 0.8em;
237
237
  padding: 0.6em 0.8em;
@@ -239,10 +239,10 @@ 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 ra({downloadEnabled:e,fileName:t}){let{active:n,configs:r,actions:i,selected:a}=Wi(),o=z(),s=Ot(),c=Oi(),l=r.filter(e=>e.type===`external-manifest-preview`),{isOpen:u,buttonProps:d,itemProps:f}=Xe(l.length);return l.length===0?L(na,{children:`Preview not available`}):R(I,{children:[e?L(`div`,{className:`mr-4`,children:L(y,{fileName:t||`manifest.json`,label:`Download manifest`,getData:()=>s.export&&s.export.version===2?JSON.stringify(o.toPresentation2(c),null,2):JSON.stringify(o.toPresentation3(c),null,2)})}):null,R(qi,{children:[L(Ji,{onClick:()=>{if(!a){let e=s.defaultPreview;if(e){let t=r.find(t=>t.id===e);if(t){i.selectPreview(t.id);return}}i.selectPreview(r[0].id)}i.updatePreviews()},children:`Preview`}),L(Yi,{$open:u,...d,children:L(wi,{})}),L(Xi,{$open:u,children:l.map((e,t)=>{let r=n.indexOf(e.id)===-1;return R(Zi,{...f[t],children:[L($i,{$status:r?`available`:e.id===a?`active`:`configured`}),L(ea,{onClick:()=>{i.selectPreview(e.id)},children:e.label}),r?null:L(ta,{onClick:()=>i.deletePreview(e.id),children:L(Ci,{})})]},e.id)})})]})]})}function ia(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=B(t.payload.resource.resource);if(!n||!e.stack.find(e=>B(e.resource)?.id===n.id))return e;let r=e.current?.resource.id===n.id?null:e.current,i=aa(e.stack.filter(e=>B(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 aa(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 oa={stack:[],current:null,create:null},sa=O(oa),ca=O({edit(){},close(){},back(){},setStack(){},updateCurrent(){},create(){return()=>{}}});function la(){return A(ca)}function ua(){return A(sa).current}function da(){return A(sa).stack}function fa(){return A(sa).create}function pa(){let{manifest:e}=Ke(),t=z(),[n,r]=Oe(e=>e+1,0);U(e,`Manifest not found`);let i=N(()=>new $e({reference:{id:e,type:`Manifest`},vault:t}),[e,t]);return j(()=>i.observe.start(r),[i]),i.observe.key=`${n}`,i.observe.reset(),i}function ma(){let{collection:e}=Ke(),t=z(),[n,r]=Oe(e=>e+1,0);U(e,`Collection not found`);let i=N(()=>new $e({reference:{id:e,type:`Collection`},vault:t}),[e,t]);return j(()=>i.observe.start(r),[i]),i.observe.key=`${n}`,i.observe.reset(),i}function ha(e,t={}){let n=z(),[r,i]=Oe(e=>e+1,0);!t.allowNull&&U(e,`Resource not found`);let a=N(()=>t.allowNull&&!e?null:new $e({reference:B(e),vault:n,context:{resource:e,parent:t.parent,index:t.index,parentProperty:t.parentProperty}}),[e,n]);return j(()=>a?.observe.start(i),[a]),a&&(a.observe.key=`${r}`,a.observe.reset()),a}function ga(){let{annotationPage:e}=Ke();return U(e,`Annotation page not found`),ha({id:e,type:`AnnotationPage`})}function _a(){let e=ua(),t=z(),[n,r]=Oe(e=>e+1,0);U(e,`No resource selected`);let i=N(()=>new $e({reference:e.resource.source||e.resource,vault:t}),[e,t]);return j(()=>i.observe.start(r),[i]),i.observe.key=`${n}`,i.observe.reset(),i}function va(e){let t=z(),[n,r]=Oe(ia,e),i=k(e=>{r(e)},[]);j(()=>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=k((e,t=!1)=>i({type:`edit`,payload:{resource:e,reset:t}}),[]),o=k(e=>i({type:`setStack`,payload:{resources:e}}),[]),s=k(e=>i({type:`updateCurrent`,payload:{resource:e}}),[]),c=k(()=>i({type:`close`}),[]),l=k(()=>i({type:`back`}),[]),u=k((e,t)=>(i({type:`create`,payload:{resource:e,options:t}}),()=>{i({type:`create`,payload:{resource:null}})}),[]);return[n,N(()=>({edit:a,updateCurrent:s,close:c,back:l,create:u,setStack:o}),[])]}function ya(e){let{instanceId:t}=fi(),[n,r]=va(e.initialState||oa);return L(ca.Provider,{value:r,children:L(sa.Provider,{value:n,children:e.children})},t)}function ba({resource:e,children:t}){let{instanceId:n}=fi(),[r,i]=va(N(()=>({create:null,stack:[],current:{resource:{type:`SpecificResource`,source:{id:e.id,type:e.type}}}}),[]));return L(ca.Provider,{value:i,children:L(sa.Provider,{value:r,children:t})},n)}const xa=O(null),Sa=O(null),Ca=O(`default`);function wa(){return A(Sa)}function Ta(){return A(xa)}function Ea(){return A(Ca)}function Da(){return q().layout}function Oa(){let e=q(),t=e.layout,n=A(xa),r=A(Sa);return N(()=>({actions:n,state:r,...t}),[e,r])}const ka=`@manifest-editor/tags`,Aa=`tags`,ja={type:`flag`,id:`flag`,label:`Flag`,backgroundColor:`#b91c1c`,textColor:`#ffffff`,icon:`flag`},Ma=[];function Na(e){return typeof e==`string`?e:e?.id||null}function Pa(e){return e.type||e.id}function Fa(e){return`${e.type}:${e.id}`}function Ia(e){if(!Array.isArray(e))return Ma;let t=new Map;for(let n of e){if(!n?.id)continue;let e=Pa(n);t.set(e,{...n,type:e})}return Array.from(t.values())}function La(e){return e.label||e.id||e.type}function Ra(e,t){return e===ja.type&&(!t||t===ja.id)}function za(e,t){return Ra(e.type,e.id)?-1:Ra(t.type,t.id)?1:La(e.tag).localeCompare(La(t.tag))||e.type.localeCompare(t.type)||e.id.localeCompare(t.id)}function Ba(e,t){return Ra(e.type)?-1:Ra(t.type)?1:e.type.localeCompare(t.type)}function Va(e,t){let n=Na(t);return n?Ia(e.getResourceMeta(n,ka)?.[Aa]):Ma}function Ha(e,t){let n=Na(t);return n?Ia(e?.iiif?.meta?.[n]?.[ka]?.[Aa]):Ma}function Ua(e,t,n){let r=Na(t);if(!r)return Ma;let i=Ia(n);return e.setMetaValue([r,ka,Aa],i),i}function Wa(e,t,n){return Ua(e,t,[...Va(e,t),n])}function Ga(e,t,n){return Va(e,t).find(e=>e.type===n)}function Ka(e,t,n,r){return Ua(e,t,Va(e,t).filter(e=>e.type!==n||(r?e.id!==r:!1)))}function qa(e,t){let n=new Map;for(let r of t){let t=Na(r);if(t)for(let i of Va(e,r)){let e=i.type,r=Fa(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(za),e.canvasIds=Array.from(new Set(e.rows.flatMap(e=>e.canvasIds))),e.canvasCount=e.canvasIds.length;return Array.from(n.values()).sort(Ba)}function Ja(e,t,n,r){let i=Ga(e,t,n);return r?i?.id===r:!!i}function Ya(e,t,n){return Ja(e,t,n.type,n.id)?Ka(e,t,n.type):Wa(e,t,n)}function Xa(e){return{getTags(t){return Va(e,t)},setTags(t,n){return Ua(e,t,n)},addTag(t,n){return Wa(e,t,n)},upsertTag(t,n){return Wa(e,t,n)},getTag(t,n){return Ga(e,t,n)},removeTag(t,n,r){return Ka(e,t,n,r)},hasTag(t,n,r){return Ja(e,t,n,r)},toggleTag(t,n){return Ya(e,t,n)}}}function Za(e){let t=Na(e);return qe(e=>t?Ha(e,t):Ma,[t])}function Qa(e){let t=z(),n=Na(e),r=N(()=>Xa(t),[t]);return N(()=>({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 $a({icon:e,title:t,...n}){return e===`flag`?R(`svg`,{viewBox:`0 0 24 24`,width:`1em`,height:`1em`,"aria-hidden":t?void 0:!0,...n,children:[t?L(`title`,{children:t}):null,L(`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 eo({tag:e,showIcon:t=!0,className:n,style:r}){return R(`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?L($a,{icon:e.icon,className:`h-2.5 w-2.5 flex-shrink-0`}):null,L(`span`,{className:`min-w-0 truncate`,children:La(e)})]})}function to({resource:e,tags:t,className:n}){return t?L(ro,{tags:t,className:n}):L(no,{resource:e,className:n})}function no({resource:e,className:t}){return L(ro,{tags:Za(e),className:t})}function ro({tags:e,className:t}){let n=e;return n.length?L(`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=>L(eo,{tag:e},e.type))}):null}const io=O(null);function ao(e){return e===`error`?8e3:5e3}function oo({children:e,maxVisibleToasts:t=3}){let n=et({maxVisibleToasts:t}),r=N(()=>{let e=(e,t)=>n.add(e,{...t,timeout:t?.timeout??ao(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 R(io.Provider,{value:r,children:[e,L(me,{state:n})]})}function so(){let e=A(io);if(!e)throw Error(`useToasts must be used within a ToastProvider`);return e}function co(e){return e.status!==`complete`&&e.status!==`error`||!e.completedAt?null:`${e.id}:${e.status}:${e.completedAt}`}function lo(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 uo(e){return{id:e.id,type:e.type,label:e.type,scope:`root`}}function fo(e){if(!(!e||!e.id||e.type!==`Canvas`))return{id:e.id,type:`Canvas`,label:`Current canvas`,scope:`canvas`}}function po(){let e=ua(),t=da();return N(()=>fo([e,...t].find(e=>e?.resource?.source?.type===`Canvas`)?.resource?.source),[e,t])}function mo(){let e=Oi(),t=po(),n=z(),r=N(()=>Xa(n),[n]),i=N(()=>Ut(n),[n]),a=ri(),o=Ot(),s=wa(),c=Ta();return N(()=>({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 ho(){let e=K(e=>e.definitions),t=K(e=>e.instances),n=mo(),r=N(()=>uo(n.rootResource),[n.rootResource]);return N(()=>sn({definitions:e,instances:t,systemContext:n,targets:[r,...n.currentCanvas?[n.currentCanvas]:[]],onSupportsError:(e,t)=>{console.error(`Background action "${e.id}" failed support check`,t)}}),[e,t,r,n])}function go(){let e=nr(),t=K(e=>e.definitions),n=K(e=>e.instances),r=K(e=>e.plans),i=K(e=>e.controllers),a=K(e=>e.hasHydrated),o=mo(),s=P(new Set);return j(()=>{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||!vo(a)||!r[t]||i[t]||s.current.has(l)||(s.current.add(l),Jn({store:e,resume:!0,context:{...o,definition:n,target:a.target,instanceKey:t,instance:a}}))}},[i,t,a,n,r,e,o]),L(I,{children:t.map(e=>e.render?L(xe,{children:e.render({...o,definition:e})},e.id):null)})}function _o(){let e=K(e=>e.definitions),t=K(e=>e.instances),n=mo(),r=so(),i=P(new Set),a=N(()=>new Map(e.map(e=>[e.id,e])),[e]);return j(()=>{for(let e of Object.values(t)){let t=co(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=lo(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 vo(e){return e?.status===`preparing`||e?.status===`running`}function yo(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 bo(e){return e?new Date(e).toLocaleString():`Not recorded`}function xo(e){return e?new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}):`--:--:--`}function So(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 Co(e){if(e===void 0)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function wo({label:e,value:t}){return R(`div`,{className:`min-w-0`,children:[L(`dt`,{className:`text-[10px] font-semibold uppercase tracking-widest text-zinc-400`,children:e}),L(`dd`,{className:`mt-1 break-words text-sm text-zinc-800`,children:t})]})}const To={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 Eo(e){return To[e?.toLowerCase()]??{label:e?.toUpperCase().slice(0,3)??`LOG`,className:`text-zinc-300`}}const Do={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 Oo(e){return Do[e?.toLowerCase()]??`bg-zinc-100 text-zinc-600`}function ko(e){return e?.toLowerCase()in Do}function Ao({definition:e,instance:t,onClose:n}){let[r,i]=F(`overview`),a=P(null),o=t.logs.length;j(()=>{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=>ko(e.type)),l=[{id:`overview`,label:`Overview`},{id:`logs`,label:`Logs`,count:o}];return R(ee,{title:t.label||e.label,onClose:n,className:`max-w-3xl`,children:[L(`div`,{className:`sticky top-0 z-10 border-b border-zinc-200 bg-white px-2`,children:L(`div`,{className:`flex gap-0.5`,children:l.map(e=>R(`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?L(`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`&&R(`div`,{className:`flex flex-col gap-5 p-5`,children:[R(`div`,{className:`flex flex-wrap items-center gap-2`,children:[L(`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?L(`span`,{className:`text-sm text-zinc-500`,children:t.statusText}):null]}),R(`dl`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[L(wo,{label:`Target`,value:`${t.target.label} (${t.target.type})`}),L(wo,{label:`Run ID`,value:t.runId}),L(wo,{label:`Started`,value:bo(t.startedAt)}),L(wo,{label:`Finished`,value:bo(t.completedAt)}),L(wo,{label:`Duration`,value:So(t)}),t.progress?L(wo,{label:`Progress`,value:`${Math.round(t.progress.percent)}%${t.progress.label?` — ${t.progress.label}`:``}`}):null]}),t.progress?R(`div`,{children:[L(d,{percent:t.progress.percent,label:t.progress.label||`Background action progress`}),typeof t.progress.current==`number`&&typeof t.progress.total==`number`?R(`div`,{className:`mt-1 text-xs text-zinc-500`,children:[t.progress.current,` of `,t.progress.total,` items`]}):null]}):null,t.error?R(`div`,{className:`rounded-lg border border-red-200 bg-red-50`,children:[L(`div`,{className:`border-b border-red-200 px-4 py-2.5`,children:L(`span`,{className:`text-xs font-semibold uppercase tracking-widest text-red-600`,children:`Error`})}),R(`div`,{className:`p-4`,children:[L(`div`,{className:`text-sm font-medium text-red-800`,children:t.error.message}),t.error.stack?L(`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?R(`div`,{children:[L(`h3`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-widest text-zinc-400`,children:`Key events`}),L(`div`,{className:`divide-y divide-zinc-100 rounded-lg border border-zinc-200`,children:c.map(e=>R(`div`,{className:`flex items-baseline gap-3 px-3 py-2`,children:[L(`span`,{className:[`shrink-0 rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide`,Oo(e.type)].join(` `),children:e.type}),L(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-700`,children:e.message||e.type}),L(`time`,{className:`shrink-0 text-xs text-zinc-400`,children:xo(e.createdAt)})]},e.id))})]}):null]}),r===`logs`&&L(`div`,{className:`p-5`,children:o===0?L(`div`,{className:`rounded-lg border border-zinc-200 p-6 text-center text-sm text-zinc-400`,children:`No logs recorded.`}):R(`div`,{className:`overflow-hidden rounded-lg bg-zinc-950 shadow-inner`,children:[R(`div`,{className:`flex items-center gap-1.5 border-b border-white/10 px-3 py-2`,children:[L(`div`,{className:`h-2.5 w-2.5 rounded-full bg-zinc-700`}),L(`div`,{className:`h-2.5 w-2.5 rounded-full bg-zinc-700`}),L(`div`,{className:`h-2.5 w-2.5 rounded-full bg-zinc-700`}),R(`span`,{className:`ml-2 text-[10px] text-zinc-500 font-mono`,children:[o,` `,o===1?`entry`:`entries`]})]}),R(`div`,{className:`max-h-[50vh] overflow-y-auto p-1 font-mono text-xs`,children:[t.logs.map(e=>{let t=Eo(e.level);return R(`div`,{className:`group flex gap-0 hover:bg-white/5 rounded px-2 py-1 leading-relaxed`,children:[L(`time`,{className:`w-20 shrink-0 text-zinc-600 select-none pr-2`,children:xo(e.createdAt)}),L(`span`,{className:[`w-10 shrink-0 select-none font-bold pr-2`,t.className].join(` `),children:t.label}),R(`span`,{className:`min-w-0 flex-1 text-zinc-200 break-words`,children:[e.message,e.data===void 0?null:L(`span`,{className:`block mt-0.5 text-zinc-500 whitespace-pre-wrap`,children:Co(e.data)})]})]},e.id)}),L(`div`,{ref:a})]})]})})]})}function jo(){let e=nr(),t=ho(),[n,g]=F(null),_=t.reduce((e,t)=>e+t.actions.length,0),v=t.reduce((e,t)=>e+t.actions.filter(e=>vo(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}=Xe(_);if(!_)return null;let w=n?t.flatMap(e=>e.actions).find(e=>e.instanceKey===n):void 0,T=0;return R(f,{children:[L(r,{active:b,runningCount:v,errorCount:y,"aria-label":`Actions menu`,...x}),L(u,{open:b,role:`menu`,children:L(`div`,{className:`py-1.5`,children:t.map((t,n)=>R(xe,{children:[n?L(i,{}):null,L(p,{children:t.label}),t.actions.map(t=>{let{onKeyDown:n,...r}=S[T++]||{},i=yo(t.instance),u=vo(t.instance),f=()=>{u||(Jn({store:e,context:t.context}),C(!0))},p=()=>{u&&(e.getState().cancelAction(t.instanceKey),C(!0))};return R(s,{status:t.instance?.status||`idle`,children:[L(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:R(m,{children:[L(c,{running:u,children:t.instance?.label||t.definition.label}),i?L(l,{variant:t.instance?.status===`error`?`error`:`default`,children:i}):null,t.definition.summary&&!i?L(l,{children:t.definition.summary}):null,u&&t.instance?.progress?L(d,{percent:t.instance.progress.percent,label:t.instance.progress.label||i||t.definition.label}):null]})}),t.instance?.resultsAvailable&&t.definition.onResults?L(o,{onClick:e=>{e.stopPropagation(),t.definition.onResults?.(t.context)},children:`Results`}):null,t.instance?L(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?L(Ao,{definition:w.definition,instance:w.instance,onClose:()=>g(null)}):null]})}const Mo=Ee(function(e){let[t]=_e(`menu-hidden`);return L(xi,{children:R(bi,{children:[L(Si,{onClick:e.onClickLogo,children:L(E,{})}),L(ra,{}),L(jo,{})]})})}),No=O(null);function Po(){return A(No)||null}function Fo(e,t){let n=Po();return n?n[e][t]:null}function Io({children:e,menu:t}){return L(No.Provider,{value:t,children:e})}function Lo(){return A(Fe)}function Ro(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 zo=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)}),Bo=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 Vo(){}async function Ho(e,...t){if(!e)return;if(e.endsWith(`.mp3`)||e.endsWith(`.mp4`)||e.endsWith(`.m4a`)||e.endsWith(`.m4v`))try{let t=await Bo(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 Go(e)}if(!n.ok&&(n=await fetch(e+`/info.json`),!n.ok))return Go(e);let r=n.headers.get(`Content-Type`);if(r?.includes(`image/`))return Go(e,r);let i=null;try{i=await n.json()}catch{return null}return await Wo(i,e)}function Uo(e){return e.protocol&&e.protocol===`http://iiif.io/api/image`?(e.type||(e.type=`ImageService`),e):null}async function Wo(e,t){let n=Uo(e);if(n)return n;if(!(e.id||e[`@id`]))return null;let r=await new nt.Vault().load(t,e);if(r&&(r&&r?.type===`Manifest`||r?.type===`Collection`))return{id:t,type:r.type,label:tt(r.label)}}async function Go(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 Ko(n.slice(0,n.length-4).join(`/`)+`/info.json`);if(e&&e?.type&&e?.type?.startsWith(`ImageService`))return e}}try{let n=await zo(e);return{id:e,type:`Image`,width:n.width,height:n.height,format:await qo(e,t)}}catch{}return null}async function Ko(e){try{let t=await fetch(e);return t.ok?await Wo(await t.json(),e):null}catch(e){return console.log(e),null}}async function qo(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 Jo(e){try{let t=await zo(e);if(t)return{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}}catch{return null}return null}const Yo=ke(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 Xo(e){let t=N(()=>lr(),[]),n=Yo(e=>e.regions[t]),r=Yo(e=>e.setRegion);j(()=>{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]),j(()=>()=>r(t,null),[])}function Zo(e){let t=Yo(e=>e.highlight),n=Yo(e=>e.clearHighlight);return j(()=>()=>{e&&n(e)},[n,e]),N(()=>({onMouseEnter(){e&&t(e)},onMouseLeave(){e&&n(e)}}),[e,t,n])}const Qo=e=>R(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`1em`,width:`1em`,viewBox:`0 0 24 24`,...e,children:[L(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),L(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),L(`path`,{d:`M12 17.27 18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z`,fill:`currentColor`})]}),$o=({style:e})=>R(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`1rem`,viewBox:`0 0 24 24`,width:`1rem`,fill:`#000000`,style:e,children:[L(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),L(`path`,{d:`M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z`})]});function es(e){let t=e.error.toString(),[n,r]=F(!1);return R(ne,{children:[L(x,{className:`mb-2`,children:t}),L(Ki,{onClick:e.resetErrorBoundary,children:`Try again`})]})}function ts(e){return e&&e.pinnable}function ns({initial:e,fallback:t,options:n={}}){return Math.max(n.minWidth||0,Math.min(n.maxWidth||1/0,e||t))}function rs(e){return typeof e==`string`?Ce(`div`,{dangerouslySetInnerHTML:{__html:e}}):e}const is=V.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=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`
243
243
  position: relative;
244
244
  display: inline-block;
245
- `;V.div`
245
+ `;U.div`
246
246
  display: flex;
247
247
  flex-direction: column;
248
248
  position: absolute;
@@ -257,7 +257,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
257
257
  background-color: ${e=>e.theme.color.lightgrey||`lightgrey`};
258
258
  }
259
259
  }
260
- `;const as=V.button`
260
+ `;const Ms=U.button`
261
261
  padding: 0 ${e=>e.theme.padding.small||`0.5rem`};
262
262
  color: ${e=>e.theme.color.main||`none`};
263
263
  background-color: ${e=>e.theme.color.white||`white`};
@@ -276,7 +276,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
276
276
  background-color: ${e=>e.theme.color.lightgrey||`lightgrey`};
277
277
  }
278
278
 
279
- ${e=>e.$active&&H`
279
+ ${e=>e.$active&&W`
280
280
  background: #b84c74;
281
281
  color: #fff;
282
282
  &:hover {
@@ -284,7 +284,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
284
284
  color: #fff;
285
285
  }
286
286
  `}
287
- `,os=V.div`
287
+ `,Ns=U.div`
288
288
  display: none;
289
289
  flex-direction: column;
290
290
  position: absolute;
@@ -302,26 +302,26 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
302
302
  overflow: hidden;
303
303
  padding-bottom: 3px;
304
304
 
305
- ${Y} {
305
+ ${oa} {
306
306
  &:hover {
307
307
  background-color: ${e=>e.theme.color.lightgrey||`lightgrey`};
308
308
  }
309
309
  }
310
310
 
311
- ${e=>e.$open&&H`
311
+ ${e=>e.$open&&W`
312
312
  display: flex;
313
313
  `}
314
- `,ss=V.div`
314
+ `,Ps=U.div`
315
315
  color: #999;
316
316
  text-transform: uppercase;
317
317
  font-weight: 600;
318
318
  padding: 0.7em;
319
319
  font-size: 0.875em;
320
- `,cs=V.div`
320
+ `,Fs=U.div`
321
321
  height: 1px;
322
322
  margin: 0 0.5em;
323
323
  background: #eee;
324
- `,ls=O(null);function us(){return A(ls)}const ds=V.div`
324
+ `,Is=({style:e})=>V(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`1rem`,viewBox:`0 0 24 24`,width:`1rem`,fill:`#000000`,style:e,children:[B(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),B(`path`,{d:`M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z`})]}),Ls=e=>V(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`1em`,width:`1em`,viewBox:`0 0 24 24`,...e,children:[B(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),B(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),B(`path`,{d:`M12 17.27 18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z`,fill:`currentColor`})]});function Rs(e){return e&&e.pinnable}function zs({initial:e,fallback:t,options:n={}}){return Math.max(n.minWidth||0,Math.min(n.maxWidth||1/0,e||t))}function Bs(e){return typeof e==`string`?xe(`div`,{dangerouslySetInnerHTML:{__html:e}}):e}function Vs(e){let t=e.error.toString(),[n,r]=R(!1);return V(O,{children:[B(x,{className:`mb-2`,children:t}),B(sa,{onClick:e.resetErrorBoundary,children:`Try again`})]})}const Hs=j(null);function Us(){return N(Hs)}const Ws=U.div`
325
325
  display: flex;
326
326
  flex-direction: column;
327
327
  position: relative;
@@ -333,6 +333,10 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
333
333
  border-top: 1px solid #e4e7f0;
334
334
  }
335
335
 
336
+ &[data-modal="true"] {
337
+ width: 100%;
338
+ }
339
+
336
340
  &[data-floating="true"] {
337
341
  margin: 10px;
338
342
  border-radius: 5px;
@@ -373,7 +377,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
373
377
  &[data-state="unmounted"] {
374
378
  transform: translateX(100%);
375
379
  }
376
- `,fs=V.div`
380
+ `,Gs=U.div`
377
381
  background: #fff;
378
382
  display: flex;
379
383
  height: 2.8em;
@@ -395,27 +399,38 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
395
399
  background: #ffc2d2;
396
400
  box-shadow: inset 0 -5px 10px 0 rgba(255, 255, 255, 0.5);
397
401
  }
398
- `,ps=V.button`
402
+ `,Ks=U.button`
399
403
  border: none;
400
404
  background: transparent;
401
405
  padding: 0 0.4em;
402
406
  margin: 0.3em;
407
+ min-width: 24px;
408
+ height: 24px;
409
+ display: inline-flex;
410
+ align-items: center;
411
+ justify-content: center;
403
412
  border-radius: 3px;
413
+ &:focus-visible {
414
+ outline: 2px solid #b84c74;
415
+ outline-offset: 2px;
416
+ }
404
417
  &:hover {
405
418
  background: #eee;
406
419
  }
407
420
  svg {
408
421
  font-size: 1.2em;
409
422
  }
410
- `,ms=V.div`
423
+ `,qs=U.div`
411
424
  flex: 1 1 0px;
412
- `,hs=V.div`
425
+ `,Js=U.h2`
413
426
  font-size: 0.875em;
427
+ font-weight: 400;
428
+ margin: 0;
414
429
  flex: 1 1 0px;
415
430
  padding-left: 1em;
416
431
  text-align: center;
417
432
  align-self: center;
418
- `,gs=V.div`
433
+ `,Ys=U.div`
419
434
  flex: 1 1 0px;
420
435
  display: flex;
421
436
 
@@ -426,13 +441,13 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
426
441
  > * {
427
442
  min-width: 0;
428
443
  }
429
- `;function _s({panel:e,state:t,actions:n,isLeft:r,pinActions:i=n,transition:a,close:o,available:s=[],style:c,noHeader:l}){let u=A(ze)||null,[d,f]=F(!1),p=pi(),m=Oa(),{tabs:h,pinnable:g,hideHeader:_}=e?.options||{},v=[p.state.canvasId,e?.id],y=N(()=>(s||[]).filter(e=>!e.requiresState),[s]),{itemProps:b,isOpen:x,setIsOpen:S}=Xe(y.length),[C,w]=F(``),T=P(void 0);j(()=>f(!1),v),j(()=>w(``),[e]),j(()=>(T.current=w,()=>{T.current=void 0}),[]);let E=k(e=>{T.current&&T.current(e)},[]),ee=k(r=>{let i=e?t.stack.length?n.popStack:e.backAction?()=>e&&e.backAction&&e.backAction(t,{...m,current:n},p):null:null;r&&(!i||r.metaKey)&&y.length?(r.preventDefault(),S(!0)):i&&i()},[n,p,m,e,S,t,y.length]),te=r=>{n.change({id:r.id,state:r.defaultState,stacked:!!(t.stack.length||e?.backAction)})};if(!e||!t.current)return null;let ne=e.backAction||t.stack.length?L(ps,{onClick:ee,children:L($o,{})}):null,re=L(ps,{onClick:o||n.close,children:L(Ci,{})});return L(ls.Provider,{value:E,children:R(ds,{"data-state":a,"data-flipped":r,style:c,"data-header":!l,children:[l?null:R(fs,{"data-tabs":!!h,"data-error":d,children:[R(is,{style:{display:`flex`,height:`100%`},children:[e.renderBackAction?e.renderBackAction({backAction:ee,fallback:ne}):ne,y.length?R(os,{$open:x,style:{left:`0.5em`},children:[L(ss,{children:`All panels`}),L(cs,{}),y.map((t,n)=>L(as,{...b[n],onClick:()=>te(t),$active:e.id===t.id,children:t.label},n))]}):null]}),C?L(hs,{children:C}):_?L(ms,{}):L(hs,{children:e.label}),g?t.pinned?L(ps,{onClick:i.unpin,children:L(Qo,{fill:`orange`})}):L(ps,{onClick:()=>i.pin({id:e.id,state:t.state}),children:L(Qo,{fill:`#ddd`})}):null,e.renderCloseAction?e.renderCloseAction({closeAction:o||n.close,fallback:re}):re]}),L(gs,{className:`OverrideScrollbar`,children:L(ot,{onError:()=>f(!0),FallbackComponent:es,resetKeys:v,onReset:()=>f(!1),children:rs(e.render(t.state||e.defaultState||{},{...m,current:n,vault:u,transition:a},p))})})]})})}function vs(e=`vault://homepage-collection.json`){let t=new rt,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(dt({id:i.id}));let e=ft(i.id,i);t.dispatch(ct({actions:e})),r=!0}}catch{}if(!r){let n=ft(e,{"@context":`http://iiif.io/api/presentation/3/context.json`,id:e,type:`Collection`,label:{en:[`Recent items`]},items:[]});t.dispatch(dt({id:e})),t.dispatch(ct({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(st({id:e,type:`Collection`,reference:{id:n,type:r},key:`items`,index:0})):t.dispatch(ut({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(lt({id:e,type:`Collection`,key:`items`,value:[]})),window.localStorage.setItem(`preview-vault-collection`,JSON.stringify(t.toPresentation3({id:e,type:`Collection`})))}}}function ys(){return A(bs)}const bs=O(new rt),xs=O({addHistory:(e,t)=>{},clearHistory:()=>{}}),Ss=`manifest-editor://homepage-collection.json`;function Cs(){return A(xs)}function ws(e){let{vault:t,unsubscribe:n,addHistory:r,clearHistory:i}=N(()=>vs(Ss),[]);return j(()=>n,[]),L(xs.Provider,{value:{addHistory:r,clearHistory:i},children:L(bs.Provider,{value:t,children:e.children})})}function Ts({children:e}){return L(Ve,{vault:ys(),children:e})}function Es(e,t,n,r,i){let a=z(),o=q(),{create:s,edit:c}=Ta(),l=N(()=>at({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=k((a,o)=>{if(e)return s({type:n,parent:B(e),property:t,index:a,target:r,initialData:o,...i||{}})},[s,e,t,n,i,r]),f=k((a,o,c)=>{if(e)return s({type:n,filter:a,parent:B(e),property:t,index:o,target:r,initialData:c,...i||{}})},[s,e,t,n,i,r]);return[u,{create:d,edit:k((n,r)=>{c(n,e?{parent:B(e),property:t,index:r}:void 0)},[c,e,t]),createFiltered:f,creator:k((a,o)=>{if(e)return s({type:n,initialCreator:a,parent:B(e),property:t,target:r,initialData:o,...i||{}})},[n,t,e,r,s,i]),buttonProps:N(()=>({"data-action-id":or(n,t,e)}),[n,t,e])}]}function Ds(){let e=z(),t=ys(),n=q();return N(()=>new it(e,n.layout.creators||[],t),[n.layout.creators,e])}const Os=O({});function ks(e){return A(Os)[e]||{}}function As(e){let t=A(Os),n=N(()=>({...t,[e.id]:e.data}),[t,e.id,e.data]);return L(Os.Provider,{value:n,children:e.children})}const js=Ee(function(t){let n=z(),{edit:r,modal:i}=Ta(),[a,o]=F(!1),[s,c]=F(null),l=Ds(),u=P(!1),d=t.resource.initialData?.selector;Xo(d);let f=ks(t.creator.id),p={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:{...f,...t.resource.initialData||{}}},m=e=>{try{if(a||u.current)return;o(!0),u.current=!0,l.create(t.creator.id,e,p).catch(e=>(c(e?.message||`Unknown error`),null)).then(async e=>{if(t.onCreate?.(),t.resource.initialData?.skipEditingOnCreate){o(!1),i.popStack(),i.close();return}if(t.skipEditingOnCreate||!e)return;let n=Array.isArray(e)?e[0]:e;o(!1),i.popStack(),i.close(),n&&r(n,{parent:B(t.resource.parent),property:t.resource.property,index:t.resource.index})})}catch(e){c(e?.message||`Unknown error`)}},h=async()=>!0;if(j(()=>{t.resource.initialData?.showEmptyForm||!t.creator.render&&!a&&m({})},[t.creator]),s)return L(`div`,{className:`flex flex-col items-center p-4`,children:L(x,{children:s})});let g=L(`div`,{className:`flex flex-col items-center py-8`,children:R(`div`,{className:`flex gap-2 items-center`,children:[L(le,{}),` `,L(`span`,{children:`Loading`})]})});return a?g:t.creator.render?L(I,{children:L(Se,{fallback:g,children:t.creator.render({vault:n,runCreate:m,validate:h,options:p})})}):R(I,{children:[L(b,{children:`No options available`}),L(e,{primary:!0,onPress:()=>m({}),children:t.creator.actionButton||`Create`})]})});function Ms(e){let t=q(),n=z(),[r,i]=F(e.resource.initialCreator||``),a=us(),o=N(()=>at(e.resource,t.layout.creators||[],{vault:n}),[e.resource,t.layout.creators,n]);o.length===1&&!r&&i(o[0].id);let s=o.find(e=>e.id===r);if(j(()=>{s&&a?.(s.label)}),o.length===0)return L(b,{children:`Not currently supported`});let c=L(te,{children:L(w,{root:document.getElementById(`headlessui-portal-root`)||void 0,label:`Back to Add content options`,className:`group`,placement:`right`,onPress:()=>i(``),children:L(C,{className:`text-2xl opacity-50 group-hover:opacity-70`})})});return s?s.hiddenModal?R(I,{children:[c,L(js,{creator:s,resource:e.resource})]}):R(`div`,{children:[c,L(`div`,{className:`p-2 py-6`,children:L(js,{creator:s,resource:e.resource})})]}):L(_,{label:`Select a type`,items:o.map(e=>({id:e.id,title:e.label,description:e.summary||``,icon:e.icon,onClick:()=>i(e.id)}))})}const Ns={id:`@manifest-editor/creator`,label:`Add content`,options:{hideHeader:!0,tabs:!1},render(e){return L(Ms,{resource:e})}},Ps={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 Fs(e){let{}=e,t=z(),n=q(),r=N(()=>at(e.resource,n.layout.creators||[],{vault:t}),[e.resource,n.layout.creators,t]);return r.length===0?L(`div`,{children:`No supported creators found`}):L(`div`,{children:R(pe,{className:`w-full flex-1 overflow-hidden flex flex-col`,children:[L(de,{className:`flex-1 overflow-hidden w-full flex text-sm whitespace-nowrap`,items:r,children:e=>L(ue,{id:e.id,children:e.label})}),r.map(t=>L(fe,{id:t.id,className:`p-2`,children:L(Ye,{theme:Ps,children:L(js,{creator:t,resource:e.resource,onCreate:e.onCreate,skipEditingOnCreate:!0})})},t.id))]})})}function Is({fallback:e,backAction:t}){let n=da(),{back:r}=la();return n.length?L(ps,{onClick:r,children:L($o,{})}):e}function Ls({closeAction:e,fallback:t}){let n=da();return ua()||n.length?L(ps,{onClick:()=>{e()},children:L(Ci,{})}):t}function Rs(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=(t.editors||[]).filter(t=>{if(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)}),s=Object.keys(a);for(let e of s)!i.includes(e)&&a[e]&&!o.includes(a[e])&&o.push(a[e]);if(o.length)return{...t,editors:o}}return null}function zs({currentTab:e=void 0}){let t=ua(),n=A(Be),r=q(),i=Oi(),a=z(),{change:o}=Ta(),s=us(),{editorConfig:c}=Ot(),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=N(()=>{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?L(Be.Provider,{value:p,children:e}):e}let h=N(()=>{if(!t)return null;let e=r.layout.editors||[];return Rs(t,(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),{edit:!0,vault:a},f)},[t,r]);j(()=>{s(h?.label||``)},[h]),j(()=>{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=N(()=>(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(L(`div`,{className:`w-full`,children:e.component(f)},t.resource.source?.id))}return m(L(ce,{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 Bs={id:`@manifest-editor/editor`,label:`Editor`,options:{hideHeader:!0,tabs:!0,minWidth:400},renderBackAction:({backAction:e,fallback:t})=>L(Is,{backAction:e,fallback:t}),renderCloseAction:({closeAction:e,fallback:t})=>L(Ls,{closeAction:e,fallback:t}),render({currentTab:e}){return L(zs,{currentTab:e})}};function Vs(e){let[t,n]=F(!1),r=P(null),i=P(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 N(()=>[t,{set:o,clear:a}],[t])}function Hs(e){return e?typeof e==`string`?{src:e,alt:``}:e:null}function Us(e){return e?typeof e==`string`?e:e.name:null}function Ws(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 Gs(e){return e instanceof Error?e.message:`Plugin configuration could not be saved.`}function Ks(e){return R(`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:[L(`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`}),L(`circle`,{cx:`12`,cy:`12`,r:`3`})]})}function qs(e){return R(`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:[L(`path`,{d:`M7 7h10v10`}),L(`path`,{d:`M7 17 17 7`})]})}function Js(){let e=q(),{appId:t}=fi(),n=Ot(),r=kt(),i=ei(),a=ni(),o=Ta(),{saveGlobalPluginConfig:s}=A(Yr),[c,l]=F(!1),[u,d]=F(``),[f,p]=F(null),[m,h]=F(null),[_,v]=F(null),y=N(()=>new Set(Pr(i,e,t).map(e=>e.metadata.id)),[i,e,t]),b=N(()=>{let n=u.trim().toLowerCase();return i.plugins.filter(r=>{let i=Ar(r,e,t);return!c&&!i?!1:n?[r.metadata.label,r.metadata.id,r.metadata.description,Us(r.metadata.author),...r.metadata.tags||[]].filter(Boolean).join(` `).toLowerCase().includes(n):!0})},[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(Gs(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?Vr(o,i,n,e,t):{config:br(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=Ws(e);if(t){if(t.modal){o.modal.open({id:t.id});return}o.open(t.id)}}return R(`section`,{className:`flex flex-col gap-3 border-t border-gray-200 pt-4 mt-4`,children:[R(`div`,{className:`flex items-center gap-2`,children:[L(`div`,{className:`min-w-0 flex-1`,children:L(`h3`,{className:`font-semibold text-sm text-gray-900`,children:`Plugins`})}),L(`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`})]}),L(`input`,{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)}),_?L(`div`,{className:`rounded border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:_}):null,L(`div`,{className:`flex flex-col gap-2`,children:b.map(n=>{let r=Mr(n,i,t),a=y.has(n.metadata.id),o=r&&n.loadStatus===`loading`,s=r&&n.loadStatus===`error`?n.loadError:null,c=Hs(n.metadata.image),l=r&&!a&&!o&&!s,u=Ar(n,e,t),d=jr(n,e,t),f=Ws(n),h=!!n.settings,_=m===`workspace:${n.metadata.id}`;return R(`article`,{className:`flex gap-2.5 rounded-lg border bg-white p-3 text-sm transition-colors ${a?`border-gray-200`:`border-gray-100 opacity-60`} ${u?``:`opacity-40`}`,children:[c?L(`img`,{className:`h-9 w-9 rounded object-cover flex-none mt-0.5`,src:c.src,alt:c.alt||n.metadata.label}):L(`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-400`}`,children:L(Ks,{className:`w-4 h-4`})}),R(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[R(`div`,{className:`flex items-start justify-between gap-1`,children:[R(`div`,{className:`flex flex-wrap items-center gap-1.5 min-w-0`,children:[L(`span`,{className:`font-medium text-gray-900 text-xs`,children:n.metadata.label}),n.metadata.official?R(`span`,{className:`rounded-full text-me-primary-500 px-1.5 py-0 text-[9px] font-bold inline-flex items-center gap-1`,children:[L(g,{className:`w-3 h-3`}),` Verified`]}):null,n.metadata.version?L(`span`,{className:`text-[10px] text-gray-400`,children:n.metadata.version}):null]}),R(`div`,{className:`flex items-center gap-1 flex-none`,children:[h?L(`button`,{type:`button`,title:`Configure plugin`,className:`rounded p-1 text-gray-400 hover:text-gray-700 hover:bg-gray-100 transition-colors`,onClick:()=>p(n.metadata.id),children:L(Ks,{className:`w-3.5 h-3.5`})}):null,a&&f?L(`button`,{type:`button`,title:`Open ${f.label}`,className:`rounded p-1 text-me-primary-500 hover:bg-me-primary-50 transition-colors`,onClick:()=>T(n),children:L(qs,{className:`w-3.5 h-3.5`})}):null,L(`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 plugin`:`Enable plugin`,children:L(`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?L(`p`,{className:`text-xs text-gray-500 leading-relaxed`,children:n.metadata.description}):null,o?L(`span`,{className:`text-xs text-gray-500`,children:`Loading plugin…`}):null,s?L(`span`,{className:`text-xs text-red-600`,children:s}):null,l?L(`span`,{className:`text-xs text-amber-600`,children:`Waiting for required dependencies`}):null,!u&&d?L(`span`,{className:`text-xs text-gray-400`,children:d}):null]})]},n.metadata.id)})}),b.length?null:L(`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?L(ee,{title:`Configure ${x.metadata.label}`,onClose:()=>p(null),width:`560px`,children:L(Ys,{plugin:x,onClose:()=>p(null),canSaveGlobal:!!s})}):null]})}function Ys({plugin:e,onClose:t,canSaveGlobal:n}){let r=ai(e.metadata.id),[i,a]=F(`workspace`),[o,s]=F({}),[c,l]=F(!1),[u,d]=F(!1),[f,p]=F(null),m=i===`global`?r.global:r.workspace;j(()=>{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(Gs(e))}finally{l(!1)}}async function g(){l(!0),p(null);try{i===`global`?await r.resetGlobalSettings():r.resetWorkspaceSettings(),s({})}catch(e){p(Gs(e))}finally{l(!1)}}return R(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[n&&r.canSaveGlobal?R(`div`,{className:`flex items-center gap-1 px-5 pt-4 pb-3 border-b border-gray-100`,children:[L(`span`,{className:`text-xs text-gray-500 mr-2`,children:`Scope:`}),L(`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`}),L(`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?L(`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,L(`div`,{className:`flex-1 overflow-y-auto p-5`,children:L(`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=>L(Xs,{field:e,draft:o,setDraft:s},e.id)):L(`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.`})})}),R(`div`,{className:`flex items-center justify-between gap-3 border-t border-gray-100 px-5 py-4`,children:[L(`button`,{type:`button`,className:`text-xs text-gray-400 hover:text-gray-600 transition-colors disabled:opacity-40`,disabled:c,onClick:g,children:`Reset to defaults`}),R(`div`,{className:`flex items-center gap-2`,children:[u?L(`span`,{className:`text-xs text-green-600`,children:`✓ Saved`}):null,L(`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 Xs({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=L(`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`?R(`div`,{className:`flex items-center justify-between rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[R(`div`,{className:`flex flex-col gap-0.5`,children:[o,e.description?L(`span`,{className:`text-xs text-gray-500`,children:e.description}):null]}),L(`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`?R(`div`,{className:`flex flex-col gap-2 rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[o,e.description?L(`span`,{className:`text-xs text-gray-500`,children:e.description}):null,L(`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`?R(`div`,{className:`flex flex-col gap-2 rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[o,e.description?L(`span`,{className:`text-xs text-gray-500`,children:e.description}):null,R(`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:[L(`option`,{value:``,children:`Default`}),(e.options||[]).map(e=>L(`option`,{value:String(e.value),children:e.label},String(e.value)))]})]}):R(`div`,{className:`flex flex-col gap-2 rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[o,e.description?L(`span`,{className:`text-xs text-gray-500`,children:e.description}):null,L(`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 Zs(){let t=Wi(),n=Oi(),r=Ot(),i=kt(),[a,o]=Vs(2e3);function s(e){e.preventDefault();let t=new FormData(e.target);i({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`}}),o.set(),o.clear()}return R(oe,{children:[L(se,{title:`Workspace configuration`}),a?L(`div`,{className:`bg-me-primary-500 text-white p-3 text-sm`,children:`Changes saved`}):null,L(D,{className:`p-4`,children:R(S.Form,{onSubmit:s,className:`flex flex-col gap-3`,children:[R(S.InputContainer,{children:[L(S.Label,{htmlFor:`defaultLanguage`,children:`Default Language`}),L(S.Input,{type:`text`,name:`defaultLanguage`,id:`defaultLanguage`,defaultValue:r.i18n?.defaultLanguage||``})]}),R(S.InputContainer,{children:[L(S.Label,{htmlFor:`availableLanguages`,children:`Available Languages`}),L(S.Input,{type:`text`,name:`availableLanguages`,id:`availableLanguages`,defaultValue:(r.i18n?.availableLanguages||[]).join(`, `)})]}),R(S.InputContainer,{horizontal:!0,className:`my-3`,children:[L(S.Input,{type:`checkbox`,name:`advancedLanguageMode`,id:`advancedLanguageMode`,defaultChecked:r.i18n?.advancedLanguageMode||!1}),L(S.Label,{htmlFor:`advancedLanguageMode`,children:`Advanced Language Mode`})]}),R(S.InputContainer,{horizontal:!0,className:`my-3`,children:[L(S.Input,{type:`checkbox`,name:`textGranularityEnabled`,id:`textGranularityEnabled`,defaultChecked:r.i18n?.textGranularityEnabled||!1}),L(S.Label,{htmlFor:`textGranularityEnabled`,children:`Enable text granularity`})]}),R(S.InputContainer,{horizontal:!0,className:`my-3`,children:[L(S.Input,{type:`checkbox`,name:`rememberCanvasId`,id:`rememberCanvasId`,defaultChecked:r.editorFeatureFlags?.rememberCanvasId||!1}),L(S.Label,{htmlFor:`rememberCanvasId`,children:`Remember Canvas ID`})]}),R(S.InputContainer,{horizontal:!0,className:`my-3`,children:[L(S.Input,{type:`checkbox`,name:`rememberLeftPanelId`,id:`rememberLeftPanelId`,defaultChecked:r.editorFeatureFlags?.rememberLeftPanelId||!1}),L(S.Label,{htmlFor:`rememberLeftPanelId`,children:`Remember Left panel`})]}),R(S.InputContainer,{horizontal:!0,className:`my-3`,children:[L(S.Input,{type:`checkbox`,name:`manifestGridOptions`,id:`manifestGridOptions`,defaultChecked:r.editorFeatureFlags?.manifestGridOptions||!1}),L(S.Label,{htmlFor:`manifestGridOptions`,children:`Manifest Grid Options`})]}),R(S.InputContainer,{horizontal:!0,className:`my-3`,children:[L(S.Input,{type:`checkbox`,name:`isVersion2`,id:`isVersion2`,defaultChecked:r.export?.version===2}),R(S.Label,{htmlFor:`isVersion2`,children:[`Export Presentation 2 `,n.type,`s`]})]}),R(S.InputContainer,{children:[L(S.Label,{htmlFor:`defaultPreview`,children:`Default preview`}),L(`div`,{children:t.configs.map((e,t)=>e.type===`iiif-preview-service`?null:R(S.InputContainer,{horizontal:!0,children:[L(S.Input,{type:`radio`,id:e.id,name:`defaultPreview`,value:e.id,defaultChecked:r.defaultPreview?r.defaultPreview===e.id:t===0}),L(`label`,{htmlFor:e.id,children:e.label})]},e.id))})]}),n.type===`Manifest`?L(`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,L(Js,{}),L(`div`,{className:`mt-5`,children:L(e,{type:`submit`,children:`Save changes`})})]})})]})}function Qs(){return Ae((e,t)=>({specificMenus:{},resourceMenus:{},hookMenuItem(t){let n=lr(),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 $s=O(null);function ec({children:e}){let t=N(()=>Qs(),[]);return L($s.Provider,{value:t,children:e})}function tc(){let e=A($s);if(!e)throw Error(`useContextMenuStore must be used within a ContextMenuProvider`);return e}function nc(e){let t=tc(),n=je(t,e=>e.resourceMenus),r=je(t,e=>e.specificMenus);return N(()=>{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 rc(c)},[r,n,e.id,e.type])}function rc(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 ic(e,t=[]){let n=je(tc(),e=>e.hookMenuItem);j(()=>n(e),[n,e.resource?.id,e.resource?.type,...t])}var ac={};function oc(e){return R(`div`,{className:ac.CenterPanelContainer,children:[e.title||e.close?R(`div`,{className:ac.CenterPanelHeader,children:[e.title?L(`h2`,{className:ac.CenterPanelTitle,children:e.title}):null,e.close?L(Y,{className:ac.CenterPanelClose,onClick:e.close,children:L(Ci,{})}):null]}):null,e.children]})}const sc=V.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=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`
430
445
  flex: 1;
431
446
  display: flex;
432
447
  width: 100%;
433
448
  flex-direction: column;
434
449
  position: relative;
435
- `,cc=V.div`
450
+ `,Yc=U.div`
436
451
  background: #fff;
437
452
  position: relative;
438
453
  border-bottom: 1px solid #d0d0d0;
@@ -450,11 +465,11 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
450
465
  //flex-direction: column;
451
466
  //justify-content: center;
452
467
  }
453
- `,lc=V.p`
468
+ `,Xc=U.p`
454
469
  font-size: 0.9em;
455
470
  color: #777;
456
471
  font-weight: 400;
457
- `,uc=V.button`
472
+ `,Zc=U.button`
458
473
  color: inherit;
459
474
  text-rendering: geometricPrecision;
460
475
  border: none;
@@ -496,7 +511,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
496
511
  margin-top: 0.5em;
497
512
  }
498
513
  }
499
- `,dc=V.div`
514
+ `,Qc=U.div`
500
515
  font-size: 1.4em;
501
516
  padding-right: 0.3em;
502
517
  display: flex;
@@ -505,7 +520,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
505
520
  [data-large="true"] & {
506
521
  font-size: 2em;
507
522
  }
508
- `,fc=V.div`
523
+ `,$c=U.div`
509
524
  width: 2em;
510
525
  align-items: center;
511
526
  //padding-top: 0.5em;
@@ -518,11 +533,11 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
518
533
  fill: #999;
519
534
  color: #999;
520
535
  }
521
- `,pc=V.div`
536
+ `,el=U.div`
522
537
  min-height: 0;
523
538
  overflow: visible;
524
539
  display: flex;
525
- `,mc=V.div`
540
+ `,tl=U.div`
526
541
  min-height: 0;
527
542
  overflow: visible;
528
543
  flex: 1;
@@ -535,7 +550,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
535
550
  &[data-max-height="true"] {
536
551
  overflow-y: auto;
537
552
  }
538
- `,hc=V.section`
553
+ `,nl=U.section`
539
554
  display: grid;
540
555
  grid-template-rows: 0fr;
541
556
  overflow: hidden;
@@ -563,7 +578,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
563
578
  &[data-scrolled="true"] {
564
579
  box-shadow: inset 0px 2px 0px 0 rgba(0, 0, 0, 0.1);
565
580
  }
566
- `,gc=V.div`
581
+ `,rl=U.div`
567
582
  position: sticky;
568
583
  display: flex;
569
584
  top: 0;
@@ -599,7 +614,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
599
614
  right: 0.5em;
600
615
  }
601
616
  }
602
- `,_c=(()=>void 0);let vc=0;function yc(){return N(()=>vc++,[])}function bc(e,t=!1){let[n,r]=F([]),i=P(-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 j(()=>{r(t=>Array(e).fill(0).map((e,n)=>t[n]||we()))},[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 xc=Te(function(e,t){let n=P(null),r=P(null),i=yc(),[a,o]=F(e.initialOpen||!1),s=e.onChange||_c,c=()=>{s(!a),o(e=>!e)},l=e.maxHeight,[u,d]=F(!1);De(t,()=>({open(){s(!0),o(!0)},close(){s(!1),o(!1)},toggle(){c()},focus(){r.current&&r.current.focus()},button:r}));let f=e=>{e.target.scrollTop>0?d(!0):d(!1)};return R(cc,{"data-large":e.large,"data-open":a,children:[R(gc,{"data-open":a,children:[e.icon?L(fc,{onClick:c,children:e.icon}):null,R(uc,{ref:r,onClick:c,"aria-expanded":a,"aria-controls":`accordion-${i}`,children:[e.label,e.description?L(lc,{children:e.description}):null]}),L(dc,{onClick:c,children:L(wi,{width:`1em`,height:`1em`,rotate:a?0:180})})]}),L(hc,{"aria-labelledby":`accordion-${i}`,"aria-hidden":!a,"data-overflow":!!e.overflow,"data-has-icon":!!e.icon,onScroll:f,ref:n,$initial:!a,"data-scrolled":u,hidden:!a,children:L(pc,{children:L(mc,{"data-max-height":!!l,"data-full":e.fullWidth,style:{maxHeight:l||void 0},children:e.children})})})]})});function Sc(e){let{getItemProps:t,onKeyDown:n}=bc(e.items.length,e.singleMode);return L(sc,{onKeyDown:n,children:e.items.map((n,r)=>L(xc,{overflow:e.overflow,maxHeight:e.maxHeight,...n,...t(r),children:n.children},r))})}function Cc(){return L(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`48`,viewBox:`0 -960 960 960`,width:`48`,children:L(`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 wc=V.div`
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`
603
618
  padding: 0.3em;
604
619
 
605
620
  display: flex;
@@ -621,12 +636,12 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
621
636
  position: sticky;
622
637
  bottom: 0;
623
638
  }
624
- `;function Tc(e){let t=Ge(),n=z(),r=Ta(),i=N(()=>JSON.stringify(n.toPresentation3(t),null,2),[t,n]),a=N(()=>JSON.stringify(n.toPresentation2(t),null,2),[t,n]);return L(oc,{title:`Export manifest`,close:r.centerPanel.popStack,children:L(`div`,{style:{flex:1,overflowY:`auto`},children:L(Sc,{items:[{label:`Presentation 3`,description:`Download this version by clicking the "Download" button.`,maxHeight:400,large:!0,initialOpen:!0,overflow:!0,icon:L(Y,{onClick:()=>sr(i,`manifest.json`),children:L(Cc,{})}),children:R(`div`,{style:{maxWidth:`100%`},children:[L(`pre`,{style:{whiteSpace:`pre-wrap`},children:JSON.stringify(n.toPresentation3(t),null,2)}),R(wc,{"data-sticky":`true`,children:[L(Y,{onClick:()=>cr(i),children:`Copy to clipboard`}),L(Y,{onClick:()=>sr(i,`manifest.json`),children:`Download`})]})]})},{label:`Presentation 2`,description:`Download this version by clicking the "Download" button.`,maxHeight:400,large:!0,icon:L(Y,{onClick:()=>sr(a,`manifest.json`),children:L(Cc,{})}),children:R(`div`,{style:{maxWidth:`100%`},children:[L(`pre`,{style:{whiteSpace:`pre-wrap`},children:JSON.stringify(n.toPresentation2(t),null,2)}),R(wc,{"data-sticky":`true`,children:[L(Y,{onClick:()=>cr(a),children:`Copy to clipboard`}),L(Y,{onClick:()=>sr(a,`manifest.json`),children:`Download`})]})]})}]})})})}function Ec({key:e,initialValue:t,requestId:n,getInitialValue:r}){let[i,a]=Ue({requestId:n}),[o,s]=F(r&&r(i)||i[e]||t);return[o,k(t=>{a({[e]:t}),s(t)},[])]}const Dc=O(pt());function Oc({children:e,emitter:t}){return L(Dc.Provider,{value:t,children:e})}function kc(){return A(Dc)}function Ac(e,t,n=[]){let r=A(Dc);j(()=>{let n=e=>{t(e)};return r.on(e,n),()=>{r.off(e,n)}},[r,e,...n])}function jc(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]=F(i);return M(()=>{let e=()=>o(i);return r.forEach(t=>t.addListener(e)),()=>r.forEach(t=>t.removeListener(e))},[]),a}function Mc(e,t,n,r=!0){let i=mt(t,n);j(()=>typeof window>`u`?()=>void 0:(window.addEventListener(`beforeunload`,t,!1),()=>{t(),window.removeEventListener(`beforeunload`,t)}),[t]),j(()=>{if(e&&r)return e.subscribe(i,!0)},[i,e,r])}function Nc(){let e=He(),t=je(e,e=>e.switchTool),n=je(e,e=>e.polygonState.currentTool),r=je(e,e=>e.polygonState.selectedStamp),i=je(e,e=>e.polygonState.showBoundingBox);return N(()=>({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 Pc=V.div`
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`
625
640
  position: relative;
626
641
  width: 1px;
627
642
  background: rgba(0, 0, 0, 0.2);
628
643
  z-index: 50;
629
- `,Fc=V(Gi)`
644
+ `,Cl=U(aa)`
630
645
  transition:
631
646
  opacity 300ms,
632
647
  transform 300ms;
@@ -638,7 +653,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
638
653
  &:focus {
639
654
  outline: 2px solid salmon;
640
655
  }
641
- `;V(Fc)`
656
+ `;U(Cl)`
642
657
  background: #fff;
643
658
  width: 30px;
644
659
  height: 30px;
@@ -652,7 +667,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
652
667
  svg {
653
668
  fill: #9999;
654
669
  }
655
- `;const Ic=V(Fc)`
670
+ `;const wl=U(Cl)`
656
671
  position: relative;
657
672
  display: flex;
658
673
  opacity: 1;
@@ -679,7 +694,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
679
694
  svg {
680
695
  font-size: 1.5em;
681
696
  }
682
- `,Lc=V.div`
697
+ `,Tl=U.div`
683
698
  background: rgba(0, 0, 0, 0);
684
699
  position: absolute;
685
700
  width: 16px;
@@ -702,12 +717,12 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
702
717
  &:hover {
703
718
  transform: scaleX(100%);
704
719
  background: rgba(0, 0, 0, 0.1);
705
- ${Fc} {
720
+ ${Cl} {
706
721
  transform: scaleX(100%);
707
722
  opacity: 1;
708
723
  }
709
724
  }
710
- `,Rc=V.div`
725
+ `,El=U.div`
711
726
  background: rgba(0, 0, 0, 0);
712
727
  position: absolute;
713
728
  pointer-events: none;
@@ -716,7 +731,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
716
731
  top: 0;
717
732
  bottom: 0;
718
733
  z-index: 51; // This will always be quite high.
719
- `,zc=Te(function({dir:e,open:t,actions:n,reset:r},i){let[a,o]=F(!0),s=`mt-[calc(50vh+8px)]`,c=e===`left`?`${s} ml-[13px]`:`${s} ml-[3px]`;return R(Pc,{onClick:()=>n.open(),children:[L(Rc,{$open:t,$dir:e,className:`group`,children:t?null:R(he,{placement:e===`left`?`right`:`left`,children:[L(ge,{as:Ic,$dir:e,onClick:e=>n.open(),children:L(wi,{className:`text-2xl`,rotate:e===`right`?90:270})}),L(v,{children:`Open`})]})}),R(he,{placement:e===`left`?`right`:`left`,children:[L(ge,{"aria-label":`Resize panel`,asChild:!0,children:L(`div`,{children:R(Lc,{ref:i,$open:t,$dir:e,className:`group`,children:[t?R(he,{placement:e===`left`?`right`:`left`,children:[L(ge,{as:T,onPress:()=>n.close(),children:L(`div`,{onMouseOut:()=>{o(!0)},onMouseOver:()=>{o(!1)},children:L(Ci,{})})}),L(v,{children:`Close`})]}):null,r&&t?R(he,{placement:e===`left`?`right`:`left`,children:[L(ge,{as:T,onPress:()=>r(),children:L(`div`,{onMouseOut:()=>{o(!0)},onMouseOver:()=>{o(!1)},children:L(ie,{})})}),L(v,{children:`Reset`})]}):null,t?R(he,{placement:e===`left`?`right`:`left`,children:[L(ge,{asChild:!0,"aria-label":`Resize panel`,children:L(`div`,{onMouseOut:()=>{o(!0)},onMouseOver:()=>{o(!1)},children:L(ae,{"aria-label":`Resize panel`})})}),L(v,{children:`Resize panel`})]}):null]})})}),a&&L(v,{className:c,children:`Resize panel`})]})]})});function Bc(e){return L(`svg`,{width:`1em`,height:`1em`,viewBox:`0 0 42 42`,xmlns:`http://www.w3.org/2000/svg`,stroke:`currentColor`,...e,children:R(`g`,{transform:`translate(2 2)`,strokeWidth:5,fill:`none`,fillRule:`evenodd`,children:[L(`circle`,{strokeOpacity:.5,cx:18,cy:18,r:18}),L(`path`,{d:`M36 18c0-9.94-8.06-18-18-18`,children:L(`animateTransform`,{attributeName:`transform`,type:`rotate`,from:`0 18 18`,to:`360 18 18`,dur:`1s`,repeatCount:`indefinite`})})]})})}var Vc={};function Hc(){return R(I,{children:[L(`div`,{"data-header":`true`,className:Vc.ghostLoadingBlock}),R(`div`,{className:Vc.ghostBlockList,children:[L(`div`,{className:Vc.ghostLoadingBlock}),L(`div`,{className:Vc.ghostLoadingBlock}),L(`div`,{className:Vc.ghostLoadingBlock}),L(`div`,{className:Vc.ghostLoadingBlock})]})]})}function Uc(e,t,n,r=[]){M(()=>{let r=e.current;if(r)return r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}},[t,...r])}function Wc(e,t,n,r){return Math.sqrt(Math.abs(n-e)**2+Math.abs(r-t)**2)}function Gc(e,t,n,r){return n||(r?r/e:t)}function Kc(e,t={}){let n=P(null),r=P(null),i=P(null),a=P(null),o=P(.5),[s,c]=F(!1),l=P(!1),u=P(0),d=P({x:0,y:0}),[{widthA:f,widthB:p},m]=_e(`resize-layout/${e}`,{widthA:`auto`,widthB:`${ns({initial:t.widthA,fallback:320,options:{minWidth:t.minWidthPx,maxWidth:t.maxWidthPx}})}px`}),{loading:h=!1}=t;return Uc(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]),Uc({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=Gc(r,.8,t.maxWidthPct,t.maxWidthPx)*r,s=Gc(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]),Uc(n,`mousemove`,e=>{if(!l.current&&u.current&&Wc(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=Gc(a,.8,t.maxWidthPct,t.maxWidthPx),u=Gc(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}}function qc(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 Jc(e,t){return t?e.some(e=>e.id===t)?t:e[0]?.id||null:null}function X(e){return e.map(e=>e.id).join(`,`)}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)`},Yc=V.div`
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`
720
735
  display: flex;
721
736
  flex: 1 1 0;
722
737
  min-height: 0;
@@ -730,7 +745,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
730
745
  ${Q} {
731
746
  background: ${$.darkApp};
732
747
  }
733
- `,Xc=V.div`
748
+ `,Il=U.div`
734
749
  flex: 1 1 0;
735
750
  min-width: 0;
736
751
  min-height: 0;
@@ -846,12 +861,12 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
846
861
  background: ${$.darkHover} !important;
847
862
  color: #fff !important;
848
863
  }
849
- `,Zc=V.div`
864
+ `,Ll=U.div`
850
865
  display: flex;
851
866
  flex: 1;
852
867
  justify-content: center;
853
868
  align-items: center;
854
- `,Qc=V.div`
869
+ `,Rl=U.div`
855
870
  position: absolute;
856
871
  top: 3rem;
857
872
  z-index: 40;
@@ -876,12 +891,12 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
876
891
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.36);
877
892
  }
878
893
 
879
- ${e=>e.$side===`left`?H`
894
+ ${e=>e.$side===`left`?W`
880
895
  left: 1rem;
881
- `:H`
896
+ `:W`
882
897
  right: 1rem;
883
898
  `}
884
- `,$c=V.button`
899
+ `,zl=U.button`
885
900
  width: 2.35rem;
886
901
  height: 2.35rem;
887
902
  border: 0;
@@ -936,16 +951,21 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
936
951
  width: 1.25em;
937
952
  height: 1.25em;
938
953
  }
939
- `,el=V.div`
954
+
955
+ @media (max-width: 1020px) {
956
+ width: 2.75rem;
957
+ height: 2.75rem;
958
+ }
959
+ `,Bl=U.div`
940
960
  display: flex;
941
961
  flex-direction: column;
942
962
  gap: 0.25rem;
943
- `,tl=V.div`
963
+ `,Vl=U.div`
944
964
  width: 100%;
945
965
  height: 1px;
946
966
  margin: 0.25rem 0;
947
967
  background: rgba(15, 23, 42, 0.14);
948
- `,nl=V.aside`
968
+ `,Hl=U.aside`
949
969
  position: absolute;
950
970
  top: 3rem;
951
971
  bottom: 1rem;
@@ -958,7 +978,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
958
978
  border-radius: 6px;
959
979
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
960
980
  overflow: hidden;
961
- opacity: ${e=>e.$open?1:0};
981
+ opacity: ${e=>+!!e.$open};
962
982
  pointer-events: ${e=>e.$open?`auto`:`none`};
963
983
  transition:
964
984
  opacity 180ms ease,
@@ -1000,7 +1020,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
1000
1020
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.42);
1001
1021
  }
1002
1022
 
1003
- ${Q} ${fs} {
1023
+ ${Q} ${Gs} {
1004
1024
  background: ${$.darkPanelHeader} !important;
1005
1025
  border-color: ${$.darkBorder} !important;
1006
1026
  color: ${$.darkText} !important;
@@ -1009,11 +1029,11 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
1009
1029
  inset 0 1px 0 0 ${$.darkBorder} !important;
1010
1030
  }
1011
1031
 
1012
- ${Q} ${ps} {
1032
+ ${Q} ${Ks} {
1013
1033
  color: ${$.darkText} !important;
1014
1034
  }
1015
1035
 
1016
- ${Q} ${ps}:hover {
1036
+ ${Q} ${Ks}:hover {
1017
1037
  background: ${$.darkHover} !important;
1018
1038
  color: #fff !important;
1019
1039
  }
@@ -1212,10 +1232,10 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
1212
1232
  border-color: ${$.darkBorder} !important;
1213
1233
  }
1214
1234
 
1215
- ${e=>e.$side===`left`?H`
1235
+ ${e=>e.$side===`left`?W`
1216
1236
  left: 4.5rem;
1217
1237
  transform: translateX(${e.$open?`0`:`-0.75rem`});
1218
- `:H`
1238
+ `:W`
1219
1239
  right: 4.5rem;
1220
1240
  transform: translateX(${e.$open?`0`:`0.75rem`});
1221
1241
  `}
@@ -1230,13 +1250,13 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
1230
1250
  min-width: 0;
1231
1251
  transform: translateY(${e=>e.$open?`0`:`0.75rem`});
1232
1252
  }
1233
- `,rl=V.div`
1253
+ `,Ul=U.div`
1234
1254
  display: flex;
1235
1255
  flex: 1;
1236
1256
  min-width: 0;
1237
1257
  height: 100%;
1238
1258
  overflow: hidden;
1239
- `,il=V.div`
1259
+ `,Wl=U.div`
1240
1260
  display: flex;
1241
1261
  flex-direction: column;
1242
1262
  flex: 1;
@@ -1245,16 +1265,16 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
1245
1265
  max-width: 100%;
1246
1266
  min-width: 0;
1247
1267
  overflow: hidden;
1248
- `,al=V.header`
1268
+ `,Gl=U.header`
1249
1269
  //box-shadow: 0 3px 2px 0 rgba(0, 0, 0, 0.04), 0 1px 0 0 rgba(0, 0, 0, 0.17);
1250
1270
  z-index: 200;
1251
- `,ol=V.div`
1271
+ `,Kl=U.div`
1252
1272
  background: #fff;
1253
- `,sl=V.div`
1273
+ `,ql=U.div`
1254
1274
  display: flex;
1255
1275
  flex: 1 1 0;
1256
1276
  min-height: 0;
1257
- `,cl=V.div`
1277
+ `,Jl=U.div`
1258
1278
  background: #fff;
1259
1279
  display: flex;
1260
1280
  flex-direction: column;
@@ -1262,18 +1282,18 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
1262
1282
  max-width: 720px;
1263
1283
  align-items: flex-end;
1264
1284
 
1265
- ${e=>e.$motion?H`
1285
+ ${e=>e.$motion?W`
1266
1286
  transition: max-width 400ms;
1267
1287
  `:``}
1268
1288
 
1269
- ${e=>{switch(e.$state){case`entering`:return H`
1289
+ ${e=>{switch(e.$state){case`entering`:return W`
1270
1290
  max-width: ${e.$width};
1271
- `;case`exiting`:return H`
1291
+ `;case`exiting`:return W`
1272
1292
  max-width: 0;
1273
- `;case`unmounted`:case`exited`:return H`
1293
+ `;case`unmounted`:case`exited`:return W`
1274
1294
  max-width: 0;
1275
1295
  `}}}
1276
- `,ll=V.div`
1296
+ `,Yl=U.div`
1277
1297
  flex: 1 1 0;
1278
1298
  background: #e3e7f0;
1279
1299
  // background: #efefef;
@@ -1292,7 +1312,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
1292
1312
  > * {
1293
1313
  min-width: 0;
1294
1314
  }
1295
- `,ul=V.div`
1315
+ `,Xl=U.div`
1296
1316
  background: #fff;
1297
1317
  display: flex;
1298
1318
  flex-direction: column;
@@ -1301,14 +1321,14 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
1301
1321
 
1302
1322
  ${e=>e.$motion?`transition: max-width 400ms;`:``}
1303
1323
 
1304
- ${e=>{switch(e.$state){case`entering`:return H`
1324
+ ${e=>{switch(e.$state){case`entering`:return W`
1305
1325
  max-width: ${e.$width};
1306
- `;case`exiting`:return H`
1326
+ `;case`exiting`:return W`
1307
1327
  max-width: 0;
1308
- `;case`unmounted`:case`exited`:return H`
1328
+ `;case`unmounted`:case`exited`:return W`
1309
1329
  max-width: 0;
1310
1330
  `}}}
1311
- `,dl=V.div`
1331
+ `,Zl=U.div`
1312
1332
  display: flex;
1313
1333
  flex: 1;
1314
1334
  height: 100%;
@@ -1316,28 +1336,28 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
1316
1336
  transition: min-width 400ms;
1317
1337
  overflow: hidden;
1318
1338
 
1319
- ${e=>{switch(e.$menu){case`top`:return H`
1339
+ ${e=>{switch(e.$menu){case`top`:return W`
1320
1340
  flex-direction: column;
1321
- ${fl} {
1341
+ ${Ql} {
1322
1342
  flex-direction: column;
1323
1343
  }
1324
- `;case`left`:return H`
1344
+ `;case`left`:return W`
1325
1345
  flex-direction: row;
1326
- ${fl} {
1346
+ ${Ql} {
1327
1347
  flex-direction: row;
1328
1348
  }
1329
- `;default:case`bottom`:return H`
1349
+ `;default:case`bottom`:return W`
1330
1350
  flex-direction: column-reverse;
1331
- ${fl} {
1351
+ ${Ql} {
1332
1352
  flex-direction: column;
1333
1353
  }
1334
- `;case`right`:return H`
1354
+ `;case`right`:return W`
1335
1355
  flex-direction: row-reverse;
1336
- ${fl} {
1356
+ ${Ql} {
1337
1357
  flex-direction: row;
1338
1358
  }
1339
1359
  `}}}
1340
- `;V.div`
1360
+ `;U.div`
1341
1361
  background: #fff;
1342
1362
  border-top: 1px solid #e3e7f0;
1343
1363
  border-right: 1px solid #e3e7f0;
@@ -1347,7 +1367,7 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
1347
1367
  /* width: 3.35em;
1348
1368
  padding: 0.3em;
1349
1369
  gap: 0.3em; */
1350
- `,V.button`
1370
+ `,U.button`
1351
1371
  cursor: pointer;
1352
1372
  aspect-ratio: 1;
1353
1373
  width: 3em;
@@ -1374,124 +1394,124 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
1374
1394
  font-size: 1.5em;
1375
1395
  color: #999;
1376
1396
  }
1377
- `;const fl=V.div`
1397
+ `;const Ql=U.div`
1378
1398
  display: flex;
1379
1399
  box-shadow:
1380
1400
  0 -3px 2px 0 rgba(0, 0, 0, 0.04),
1381
1401
  0 -1px 0 0 rgba(0, 0, 0, 0.17);
1382
1402
 
1383
- ${e=>!e.$open&&(e.$position===`top`||e.$position===`bottom`)?H`
1403
+ ${e=>!e.$open&&(e.$position===`top`||e.$position===`bottom`)?W`
1384
1404
  display: none;
1385
1405
  `:``}
1386
- `,pl=V.div`
1406
+ `,$l=U.div`
1387
1407
  display: flex;
1388
1408
  flex-direction: column;
1389
1409
  flex: 1;
1390
1410
  min-width: 0;
1391
1411
  overflow: hidden;
1392
- `;function ml(e){let t=e?.resource;return t?.source?.type||t?.type||null}const hl=Ee(function(e){let t=q(),n=pi(),r=Oi(),i=Oa(),{vault:a}=A(ze),o=a||void 0,s=qe(e=>e.iiif),{loading:c,state:l,leftPanels:u,centerPanels:d,rightPanels:f,modals:p=[],actions:m}=i,h=e.isLoading||!1,g=N(()=>({rootResource:r,vault:o,app:t,layoutState:l,appState:n}),[r,o,t,l,n,s]),_=N(()=>qc(u,g,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}).filter(e=>!e.focusedMode?.hide),[u,g]),y=N(()=>qc(d,g,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[d,g]),b=N(()=>qc(f,g,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}).filter(e=>!e.focusedMode?.hide),[f,g]),x=N(()=>qc(p,g,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[p,g]),S=N(()=>({...i,leftPanels:_,centerPanels:y,rightPanels:b,modals:x}),[i,_,y,b,x]),C=_.find(e=>e.id===l.leftPanel.current),w=b.find(e=>e.id===l.rightPanel.current),T=y.find(e=>e.id===l.centerPanel.current),E=x.find(e=>e.id===l.modal.current),te=l.pinnedRightPanel.pinned?b.find(e=>e.id===l.pinnedRightPanel.current):void 0,ne=w&&(te?.id!==w.id||!gt(l.pinnedRightPanel.state,l.rightPanel.state)),re=N(()=>({rootResource:r,vault:o,app:t,layoutState:l,appState:n,actions:m}),[r,o,t,l,n,m]),ie=e=>{e.focusedMode?.onSelect?.(re)},ae=!C||C.focusedMode?.closeOnMainPanelClick!==!1,oe=N(()=>(i.background||[]).map((e,t)=>L(xe,{children:e.render()},t)),[i.background]);M(()=>{b.length&&m.rightPanel.change({id:b[0].id}),_.length&&m.leftPanel.change({id:_[0].id}),y.length&&m.centerPanel.change({id:y[0].id}),m.leftPanel.close(),m.rightPanel.close()},[]),M(()=>{if(T&&T.onMount)return T.onMount(l.centerPanel.state||T.defaultState||{},{...S,current:m.centerPanel,vault:o},n)},[l.centerPanel.current,T?.id]),M(()=>{if(!l.leftPanel.open||!l.leftPanel.current)return;let e=_.find(e=>e.id===l.leftPanel.current);e?.focusedMode?.onSelect&&ie(e)},[l.leftPanel.open,l.leftPanel.current,X(_)]),M(()=>{if(l.leftPanel.current&&!C){let e=Jc(_,l.leftPanel.current);e?m.leftPanel.change({id:e}):m.leftPanel.close()}if(l.centerPanel.current&&!T){let e=Jc(y,l.centerPanel.current);e?m.centerPanel.change({id:e}):m.centerPanel.close()}if(l.rightPanel.current&&!w){let e=Jc(b,l.rightPanel.current);e?m.rightPanel.change({id:e}):m.rightPanel.close()}if(l.modal.current&&!E){let e=Jc(x,l.modal.current);e?m.modal.change({id:e}):m.modal.close()}},[l.leftPanel.current,l.centerPanel.current,l.rightPanel.current,l.modal.current,C?.id,T?.id,w?.id,E?.id,X(_),X(y),X(b),X(x)]),Ac(`layout.edit`,e=>{ml(e)===`Canvas`&&!l.rightPanel.open||(b.find(e=>e.id===`@manifest-editor/editor`)?m.rightPanel.open({id:`@manifest-editor/editor`,stacked:!0}):w&&m.rightPanel.open())},[X(b),w?.id,l.rightPanel.open]);let D=`4.5rem`,se=`${ns({options:C?.options,fallback:340})}px`,ce=`${ns({options:w?.options,fallback:420})}px`,le={"--manifest-editor-layout-left-sidebar-small":D,"--manifest-editor-layout-left-sidebar-large":l.leftPanel.open?`calc(${D} + ${se})`:D,"--manifest-editor-layout-right-sidebar-small":D,"--manifest-editor-layout-right-sidebar-large":l.rightPanel.open?`calc(${D} + ${ce})`:D};if(M(()=>{if(typeof document>`u`)return;let e=document.documentElement,t=Object.keys(le).map(t=>[t,e.style.getPropertyValue(t)]);for(let[t,n]of Object.entries(le))e.style.setProperty(t,n);return()=>{for(let[n,r]of t)r?e.style.setProperty(n,r):e.style.removeProperty(n)}},[se,ce,l.leftPanel.open,l.rightPanel.open]),c)return null;let ue=(e,t,n)=>{if(!t.length)return null;let r=e===`left`?m.leftPanel:m.rightPanel;return L(Qc,{$side:e,"aria-label":`${e} panels`,children:t.map(t=>R(he,{placement:e===`left`?`right`:`left`,children:[L(ge,{asChild:!0,children:L($c,{type:`button`,"aria-label":t.label,"data-selected":n===t.id,onClick:()=>{n===t.id?r.toggle():r.open({id:t.id})},children:t.icon||t.label.slice(0,1)})}),L(v,{children:t.label})]},t.id))})},de=()=>!y.length&&!_.length?null:R(Qc,{$side:`left`,"aria-label":`Main and left panels`,children:[y.length?L(el,{"aria-label":`Main panels`,children:y.filter(e=>!e.focusedMode?.hide).map(e=>R(he,{placement:`right`,children:[L(ge,{asChild:!0,children:L($c,{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(),ie(e)},children:e.icon||e.label.slice(0,1)})}),L(v,{children:e.label})]},e.id))}):null,y.length&&_.length?L(tl,{}):null,_.length?L(el,{"aria-label":`Left panels`,children:_.map(e=>R(he,{placement:`right`,children:[L(ge,{asChild:!0,children:L($c,{type:`button`,"aria-label":e.label,"data-selected":l.leftPanel.current===e.id,onClick:()=>{l.leftPanel.current===e.id?m.leftPanel.toggle():m.leftPanel.open({id:e.id})},children:e.icon||e.label.slice(0,1)})}),L(v,{children:e.label})]},e.id))}):null]}),fe=()=>!E||l.modal.open===!1?null:L(ee,{title:E.label,onClose:()=>m.modal.close(),children:rs(E.render(l.modal.state||E.defaultState||{},{...S,current:m.modal,vault:o},n))}),pe=()=>R(dl,{$menu:e.centerPanelMenuPosition||`top`,children:[e.centerPanelMenu?L(fl,{$open:l.centerPanel.open,$position:e.centerPanelMenuPosition||`top`,children:e.centerPanelMenu}):null,L(pl,{children:L(ot,{resetKeys:[T?.id],FallbackComponent:es,children:h?L(Zc,{children:L(Bc,{stroke:`rgba(0,0,0,.3)`,fontSize:`2em`})}):l.centerPanel.open&&T?rs(T.render(l.centerPanel.state||T.defaultState||{},{...S,current:m.centerPanel,vault:o},n)):null})})]}),me=()=>L(rl,{children:h?L(pl,{children:L(Hc,{})}):R(I,{children:[e.leftPanelMenu?L(fl,{$open:l.leftPanel.open,$position:e.leftPanelMenuPosition||`bottom`,children:e.leftPanelMenu}):null,L(pl,{children:C?L(_s,{isLeft:!0,panel:C,state:l.leftPanel,actions:m.leftPanel}):null})]})}),_e=()=>L(rl,{children:h?L(pl,{children:L(Hc,{})}):R(I,{children:[e.rightPanelMenu?L(fl,{$open:l.rightPanel.open,$position:e.rightPanelMenuPosition||`bottom`,children:e.rightPanelMenu}):null,R(pl,{children:[ne?L(_s,{panel:w,state:l.rightPanel,actions:m.rightPanel,pinActions:m.pinnedRightPanel,available:b}):null,te?L(_s,{panel:te,state:l.pinnedRightPanel,actions:m.pinnedRightPanel,close:m.rightPanel.close}):null]})]})});return L(Ca.Provider,{value:`focused`,children:R(il,{id:e.htmlId||`manifest-editor-container`,className:`manifest-editor ${e.className||``}`,"data-layout-mode":`focused`,style:le,children:[e.hideHeader?null:R(al,{children:[e.header||null,e.menu?L(`menu`,{children:e.menu}):null]}),R(Yc,{children:[L(Xc,{onClick:()=>{ae&&m.leftPanel.close()},children:pe()}),de(),ue(`right`,b,l.rightPanel.current),_.length>0?L(nl,{$side:`left`,$open:l.leftPanel.open,style:{width:se,minWidth:C?.options?.minWidth,maxWidth:C?.options?.maxWidth},children:me()}):null,b.length>0?L(nl,{$side:`right`,$open:l.rightPanel.open,style:{width:ce,minWidth:w?.options?.minWidth,maxWidth:w?.options?.maxWidth},children:_e()}):null]}),L(ol,{children:e.footer||null}),L(`div`,{className:`hidden`,children:oe}),L(go,{}),L(_o,{}),L(I,{children:fe()})]})})}),gl=V.div`
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`
1393
1413
  position: relative;
1394
1414
  display: flex;
1395
1415
  flex: 1;
1396
1416
  overflow: hidden;
1397
1417
  flex-direction: column;
1398
- `,_l=V.div`
1418
+ `,ou=U.div`
1399
1419
  flex: 1;
1400
1420
  position: relative;
1401
1421
  z-index: 7;
1402
- `,vl=V.div`
1422
+ `,su=U.div`
1403
1423
  display: flex;
1404
- justify-content: space-around;
1424
+ gap: 0.5rem;
1405
1425
  width: 100%;
1406
1426
  background: #fff;
1407
- border-top: 1px solid #cbcbcb;
1408
- padding: 0.5em;
1409
- height: 3.4rem;
1410
- `,yl=V.button`
1411
- //background: red;
1412
- padding: 0.5em 1em;
1413
- width: 32%;
1414
-
1427
+ border-bottom: 1px solid #cbcbcb;
1428
+ padding: 0.5rem;
1429
+ min-height: 4rem;
1430
+ z-index: 9;
1431
+ `,cu=U.button`
1432
+ flex: 1;
1433
+ min-width: 0;
1434
+ padding: 0.75rem 1rem;
1415
1435
  border-radius: 5px;
1416
- border: none;
1436
+ border: 1px solid #979797;
1417
1437
  background: #ffffff;
1418
- `,bl=V.button`
1419
- padding: 0.5em 1em;
1420
- width: 32%;
1421
-
1422
- border-radius: 5px;
1423
-
1424
- background: #5e59c2;
1425
- border: 1px solid rgba(0, 0, 0, 0.21);
1426
- color: #ffffff;
1427
- `,xl=V.div`
1428
- position: relative;
1429
- width: 32%;
1430
- margin: 0 0.75em;
1431
- z-index: 9;
1432
- `,Sl=V.button`
1433
- padding: 0.4em 1em 0.65em;
1434
- position: absolute;
1438
+ font-size: 1rem;
1439
+ overflow: hidden;
1440
+ text-overflow: ellipsis;
1441
+ white-space: nowrap;
1442
+ `,lu=U.div`
1443
+ display: flex;
1444
+ flex: 1;
1445
+ min-width: 0;
1446
+ `,uu=U.button`
1447
+ display: flex;
1448
+ align-items: center;
1449
+ justify-content: center;
1450
+ gap: 0.5rem;
1435
1451
  width: 100%;
1436
- bottom: 1em;
1452
+ min-width: 0;
1453
+ padding: 0.75rem 1rem;
1437
1454
  background: #ffffff;
1438
- box-shadow: 0 3px 18px 0 rgba(0, 0, 0, 0.04);
1439
1455
  border-radius: 5px;
1440
1456
  border: 1px solid #979797;
1441
- letter-spacing: -0.46px;
1457
+ font-size: 1rem;
1442
1458
  white-space: nowrap;
1443
1459
  overflow: hidden;
1444
1460
  text-overflow: ellipsis;
1445
1461
 
1446
1462
  svg {
1447
- display: block;
1448
- margin: auto;
1449
- font-size: 1.8em;
1463
+ flex: 0 0 auto;
1464
+ font-size: 1.25em;
1450
1465
  }
1451
- `,Cl=V.div`
1466
+ `,du=U.div`
1452
1467
  background: #fff;
1453
1468
  display: flex;
1454
1469
  position: absolute;
1455
- transform: translateY(100%);
1470
+ transform: translateX(100%);
1456
1471
  overflow-y: auto;
1457
- left: 0;
1472
+ left: auto;
1458
1473
  right: 0;
1459
- top: 7em;
1474
+ top: 4rem;
1475
+ width: min(100%, 480px);
1460
1476
  z-index: 10;
1461
1477
  box-shadow:
1462
- 0 -5px 15px 0 rgba(0, 0, 0, 0),
1463
- 0 -3px 5px 0 rgba(0, 0, 0, 0);
1478
+ -5px 0 15px 0 rgba(0, 0, 0, 0),
1479
+ -3px 0 5px 0 rgba(0, 0, 0, 0);
1464
1480
  bottom: 0;
1465
1481
  transition:
1466
1482
  0.3s transform ease-in-out,
1467
1483
  0.3s box-shadow;
1468
- ${e=>e.$open&&H`
1484
+ ${e=>e.$open&&W`
1469
1485
  box-shadow:
1470
- 0 -5px 15px 0 rgba(0, 0, 0, 0.1),
1471
- 0 -3px 5px 0 rgba(0, 0, 0, 0.1);
1472
- transform: translateY(0);
1486
+ -5px 0 15px 0 rgba(0, 0, 0, 0.1),
1487
+ -3px 0 5px 0 rgba(0, 0, 0, 0.1);
1488
+ transform: translateX(0);
1473
1489
  `}
1474
1490
 
1475
- ${fs} {
1491
+ ${Gs} {
1476
1492
  box-shadow: none;
1477
1493
  padding-left: 0.5em;
1478
1494
  padding-right: 0.5em;
1479
1495
  font-size: 1.1em;
1480
1496
  }
1481
- `,wl=V.div`
1497
+ `,fu=U.div`
1498
+ display: flex;
1499
+ flex-direction: column;
1482
1500
  position: absolute;
1483
1501
  transform: translateX(-100%);
1484
1502
  background: #fff;
1485
1503
  left: 0;
1486
- top: 0;
1504
+ top: 4rem;
1487
1505
  bottom: 0;
1506
+ width: min(90%, 420px);
1488
1507
  z-index: 10;
1489
- overflow-y: auto;
1508
+ overflow: hidden;
1490
1509
  transition: 0.5s transform;
1491
- ${e=>e.$open&&H`
1510
+ ${e=>e.$open&&W`
1492
1511
  transform: translateX(0);
1493
1512
  `}
1494
- `,Tl=V.div`
1513
+ `,pu=U.button`
1514
+ border: 0;
1495
1515
  background: rgba(0, 0, 0, 0.4);
1496
1516
  pointer-events: none;
1497
1517
  position: absolute;
@@ -1503,10 +1523,10 @@ import{ActionButton as e,ArrowRightIcon as t,BackIcon as n,BackgroundActionMenuB
1503
1523
  opacity: 0;
1504
1524
  transition: opacity 0.5s;
1505
1525
 
1506
- ${e=>e.$open&&H`
1526
+ ${e=>e.$open&&W`
1507
1527
  pointer-events: visible;
1508
1528
  opacity: 1;
1509
1529
  `}
1510
- `,El=Ee(function(e){if(e.layoutMode===`focused`)return L(hl,{...e});let t=q(),n=pi(),r=Oi(),i=Oa(),{vault:a}=A(ze),o=a||void 0,s=qe(e=>e.iiif),c=P(null),l=P(null),{loading:u,state:d,leftPanels:f,centerPanels:p,rightPanels:m,modals:h=[],actions:g}=i,_=N(()=>({rootResource:r,vault:o,app:t,layoutState:d,appState:n}),[r,o,t,d,n,s]),v=N(()=>qc(f,_,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[f,_]),y=N(()=>qc(p,_,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[p,_]),b=N(()=>qc(m,_,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[m,_]),x=N(()=>qc(h,_,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[h,_]),S=N(()=>({...i,leftPanels:v,centerPanels:y,rightPanels:b,modals:x}),[i,v,y,b,x]),C=v.find(e=>e.id===d.leftPanel.current),w=b.find(e=>e.id===d.rightPanel.current),T=y.find(e=>e.id===d.centerPanel.current),E=x.find(e=>e.id===d.modal.current),te=d.pinnedRightPanel.pinned?b.find(e=>e.id===d.pinnedRightPanel.current):void 0,[ne]=jc([`(max-width: 1020px)`]),ie=e.isLoading||!1,ae=N(()=>(i.background||[]).map((e,t)=>L(xe,{children:e.render()},t)),[i.background]),oe=Kc(`left-panel/${C?.id}`,{left:!0,marginLeft:60,minWidthPx:C?.options?.minWidth||200,maxWidthPx:C?.options?.maxWidth||720,loading:u}),D=Kc(`right-panel/${w?.id}`,{left:!1,minWidthPx:w?.options?.minWidth||320,maxWidthPx:w?.options?.maxWidth||720,loading:u}),se=w&&(te?.id!==w.id||!gt(d.pinnedRightPanel.state,d.rightPanel.state)),ce=oe.widthB===`auto`?void 0:()=>oe.setWidths({widthA:`auto`,widthB:ns({options:C?.options,fallback:320})}),le=D.widthB===`auto`?void 0:()=>D.setWidths({widthA:`auto`,widthB:ns({options:w?.options,fallback:320})});if(M(()=>{ne&&d.leftPanel.open&&d.rightPanel.open&&(g.leftPanel.close(),g.rightPanel.close())},[ne]),M(()=>{if(T&&T.onMount)return T.onMount(d.centerPanel.state||T.defaultState||{},{...S,current:g.centerPanel,vault:o},n)},[d.centerPanel.current,T?.id]),M(()=>{if(d.leftPanel.current&&!C){let e=Jc(v,d.leftPanel.current);e?g.leftPanel.change({id:e}):g.leftPanel.close()}if(d.centerPanel.current&&!T){let e=Jc(y,d.centerPanel.current);e?g.centerPanel.change({id:e}):g.centerPanel.close()}if(d.rightPanel.current&&!w){let e=Jc(b,d.rightPanel.current);e?g.rightPanel.change({id:e}):g.rightPanel.close()}if(d.modal.current&&!E){let e=Jc(x,d.modal.current);e?g.modal.change({id:e}):g.modal.close()}},[d.leftPanel.current,d.centerPanel.current,d.rightPanel.current,d.modal.current,C?.id,T?.id,w?.id,E?.id,X(v),X(y),X(b),X(x)]),M(()=>{b.length&&g.rightPanel.change({id:b[0].id}),v.length&&g.leftPanel.change({id:v[0].id}),y.length&&g.centerPanel.change({id:y[0].id})},[]),u)return null;let ue=t=>L(dl,{$menu:e.leftPanelMenuPosition||`bottom`,ref:oe.refs.resizableDiv,className:[`manifest-editor`,t?`transition transition-${t}`:``].join(` `),style:{width:d.leftPanel.open||t!==`exited`?oe.widthB:void 0,minWidth:C?.options?.minWidth},children:ie?L(pl,{children:L(Hc,{})}):R(I,{children:[e.leftPanelMenu?L(fl,{$open:d.leftPanel.open&&t!==`exited`,$position:e.leftPanelMenuPosition||`bottom`,children:e.leftPanelMenu}):null,L(pl,{children:d.leftPanel.open||t!==`exited`?L(I,{children:C?L(_s,{isLeft:!0,noHeader:!0,transition:t,panel:C,state:d.leftPanel,actions:g.leftPanel}):null}):null})]})}),de=()=>!E||d.modal.open===!1?null:L(ee,{title:E.label,onClose:()=>g.modal.close(),children:rs(E.render(d.modal.state||E.defaultState||{},{...S,current:g.modal,vault:o},n))}),fe=()=>R(dl,{$menu:e.centerPanelMenuPosition||`top`,children:[e.centerPanelMenu?L(fl,{$open:d.centerPanel.open,$position:e.centerPanelMenuPosition||`top`,children:e.centerPanelMenu}):null,L(pl,{children:L(ot,{resetKeys:[T?.id],FallbackComponent:es,children:ie?L(`div`,{style:{display:`flex`,flex:1,justifyContent:`center`,alignItems:`center`},children:L(Bc,{stroke:`rgba(0,0,0,.3)`,fontSize:`2em`})}):d.centerPanel.open&&T?rs(T.render(d.centerPanel.state||T.defaultState||{},{...S,current:g.centerPanel,vault:o},n)):null})})]}),pe=t=>L(dl,{$menu:e.rightPanelMenuPosition||`bottom`,ref:D.refs.resizableDiv,className:t?`transition transition-${t}`:``,style:{width:d.rightPanel.open||t!==`exited`?D.widthB:void 0,minWidth:w?.options?.minWidth},children:ie?L(pl,{children:L(Hc,{})}):R(I,{children:[e.rightPanelMenu?L(fl,{$open:d.rightPanel.open,$position:e.rightPanelMenuPosition||`bottom`,children:e.rightPanelMenu}):null,L(pl,{children:d.rightPanel.open||t!==`exited`?R(I,{children:[se?L(_s,{panel:w,state:d.rightPanel,actions:g.rightPanel,pinActions:g.pinnedRightPanel,available:b}):null,te?L(_s,{panel:te,state:d.pinnedRightPanel,actions:g.pinnedRightPanel,close:g.rightPanel.close}):null]}):null})]})});return ne?R(il,{children:[e.hideHeader?null:R(al,{children:[e.header||null,e.menu?L(`menu`,{children:e.menu}):null]}),L(sl,{children:R(gl,{children:[L(_l,{children:fe()}),R(vl,{children:[v.length>0?L(yl,{onClick:g.leftPanel.toggle,children:C?.label}):null,b.length>0?L(xl,{children:R(Sl,{onClick:g.rightPanel.toggle,children:[L(wi,{rotate:180}),w?.label]})}):null,L(bl,{children:`Preview`})]}),b.length>0?L(Cl,{$open:d.rightPanel.open,children:pe()}):null,v.length>0?L(wl,{$open:d.leftPanel.open,children:ue()}):null,v.length>0||b.length>0?L(Tl,{$open:d.leftPanel.open||d.rightPanel.open,onClick:()=>{g.leftPanel.close(),g.rightPanel.close()}}):null]})})]}):R(il,{id:e.htmlId||`manifest-editor-container`,className:`manifest-editor ${e.className||``}`,children:[e.hideHeader?null:R(al,{children:[e.header||null,e.menu?L(`menu`,{children:e.menu}):null]}),R(sl,{ref:e=>{oe.refs.container.current=e,D.refs.container.current=e},children:[v.length>0?L(re,{current:d.leftPanel.current,items:v.map(e=>({id:e.id,label:e.label,icon:e.icon,divide:e.divide,separator:e.separator,onClick:()=>{d.leftPanel.current===e.id?g.leftPanel.toggle():g.leftPanel.change({id:e.id})}})),open:d.leftPanel.open}):null,v.length>0?L(ht,{nodeRef:c,in:d.leftPanel.open,timeout:400,unmountOnExit:!1,children:e=>R(I,{children:[L(cl,{ref:c,$width:oe.widthB,$state:e,$motion:!0,children:ue(e)}),L(zc,{ref:oe.refs.resizer,reset:ce,dir:`left`,transition:e,open:d.leftPanel.open||e!==`exited`,actions:g.leftPanel})]})}):null,L(ll,{children:fe()}),b.length>0?L(ht,{nodeRef:l,in:d.rightPanel.open,timeout:400,unmountOnExit:!1,children:e=>R(I,{children:[L(zc,{ref:D.refs.resizer,dir:`right`,reset:le,open:d.rightPanel.open,actions:g.rightPanel}),L(ul,{ref:l,$width:D.widthB,$state:e,$motion:!0,children:pe(e)})]})}):null]}),L(ol,{children:e.footer||null}),L(`div`,{className:`hidden`,children:ae}),L(go,{}),L(_o,{}),L(I,{children:de()})]})});function Dl(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 N(()=>({popStack:n,change:r,open:i,close:a,toggle:o,minimise:s,maximise:c,setCustomWidth:l,resetSize:u,pin:d,unpin:f}),[])}function Ol(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?{...Ze(e.state)}:{}})}}else e.stack=[]}function kl(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&&Ol(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&&Ol(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(ts(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;break}}const Al=Qe((e,t)=>{switch(t.panel){case`centerPanel`:kl(e.centerPanel,t);break;case`leftPanel`:kl(e.leftPanel,t);break;case`rightPanel`:kl(e.rightPanel,t);break;case`modal`:kl(e.modal,t);break;case`pinnedRightPanel`:kl(e.pinnedRightPanel,t);break}});function jl(){return{customWidth:void 0,minimised:!1,open:!0,current:null,state:null,stack:[]}}function Ml(){return{leftPanel:jl(),centerPanel:jl(),rightPanel:jl(),modal:jl(),pinnedRightPanel:{...jl(),pinnable:!0,pinned:!1}}}function Nl({className:e,variant:t=`light`}){let n=Ge(),r=z(),{edit:i}=Ta(),a=ua(),o=da(),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=Pl(a)||o.map(Pl).find(Boolean)||s[0]?.id||``,d=Math.max(0,s.findIndex(e=>e.id===u)),f=s[d]?.id||``,p=d+1,m=N(()=>s.map((e,t)=>{let n=r.get({id:e.id,type:`Canvas`});return{id:e.id,pageNumber:t+1,labelText:tt(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 L(`div`,{});let g=s[d-1],_=s[d+1],v=t===`dark`;return R(`nav`,{"aria-label":`Manifest pagination`,className:Rl(`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:[L(Fl,{ariaLabel:`Previous canvas`,disabled:!g,onClick:()=>g&&h(g.id),dark:v,children:L(Il,{reverse:c,vertical:l})}),R(`label`,{htmlFor:`manifest-pagination-page-select`,"aria-label":`Page ${p} of ${s.length}`,className:Rl(`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:[R(`span`,{children:[p,` / `,s.length]}),L(Ll,{className:Rl(`shrink-0 text-base`,v?`text-white/60`:`text-me-gray-500`)}),L(`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=>R(`option`,{value:e.id,children:[`Page `,e.pageNumber,` - `,e.labelText]},e.id))})]}),L(Fl,{ariaLabel:`Next canvas`,disabled:!_,onClick:()=>_&&h(_.id),dark:v,children:L(Il,{reverse:!c,vertical:l})})]})}function Pl(e){let t=e?.resource?.source;return t?.type===`Canvas`?t.id:null}function Fl({ariaLabel:e,children:t,dark:n,disabled:r,onClick:i}){return L(`button`,{type:`button`,"aria-label":e,disabled:r,onClick:i,className:Rl(`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 Il({reverse:e,vertical:r}){return L(e?t:n,{"aria-hidden":!0,className:Rl(`block`,r&&`rotate-90`)})}function Ll(e){return L(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,"aria-hidden":!0,...e,children:L(`path`,{fill:`currentColor`,d:`m7 10l5 5l5-5z`})})}function Rl(...e){return e.filter(Boolean).join(` `)}const zl=new WeakMap;function Bl(e,t){let n={port:t,lastActionId:`@genesis`},r=Vl(e);function i(e){t.postMessage(typeof e==`string`?e:JSON.stringify(e))}function a(){i({_id:lr(),_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=Ul(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,zl.delete(e)),t.close()}}function Vl(e){let t=zl.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)Hl(t,e);return t}),a={originalDispatch:n,patchedDispatch:i,targets:r};return e.dispatch=i,zl.set(e,a),a}function Hl(e,t){let n={_id:lr(),_type:`vault-action`,_lastActionId:e.lastActionId,action:t};e.lastActionId=n._id,e.port.postMessage(JSON.stringify(n))}function Ul(e){try{if(typeof e==`string`)return JSON.parse(e);if(typeof e==`object`&&e)return e}catch{return null}return null}const Wl=O({resource:null});function Gl(){return A(Wl)}function Kl(){let e=z(),{resource:t}=Gl();U(t,`Nothing selected`);let{id:n,type:r}=t;return qe(()=>e.get({id:n,type:r}),[n,r])}function ql(){let{resource:e}=Gl();return e}function Jl({resource:e,children:t}){let{id:n,type:r}=e||{};return L(Wl.Provider,{value:N(()=>({resource:n&&r?{id:n,type:r}:null}),[n,r]),children:t})}var Yl=class extends be{constructor(...e){super(...e),J(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?L(`h1`,{children:`Sorry.. there was an error`}):this.props.children}};function Xl(e,t){return typeof e==`string`?{id:e,state:t}:e}const Zl=Ee(function(e){let t=q(),n=kc(),r=t.layout,[i,a]=Oe(Al,void 0,Ml),o={centerPanel:Dl(`centerPanel`,a),leftPanel:Dl(`leftPanel`,a),rightPanel:Dl(`rightPanel`,a),pinnedRightPanel:Dl(`pinnedRightPanel`,a),modal:Dl(`modal`,a),editingStack:la()};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,o.leftPanel];U(!1,`Was not able to find panel with id "${e}"`)}function c(e,t){let{id:r,state:i,stacked:a}=Xl(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}=Xl(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}=Xl(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}=Xl(e,t),[,i]=s(r);n.emit(`layout.close`,{id:r}),i.close()}function f(e,t){let{id:r}=Xl(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:Je(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 L(xa.Provider,{value:N(()=>({...o,...h}),[r]),children:L(Sa.Provider,{value:i,children:e.children})})}),Ql=[{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`}],$l=new _t({approximateServices:!0,verificationsRequired:8,enableFetching:!0});function eu({config:e,saveConfig:t,children:n,theme:r,previews:i,resource:a,editing:o,backgroundActionPersistence:s}){let c=fi(),l=Ot(),u=N(()=>Tt(l,{previews:e?.previews||(l.previews?.length?l.previews:Ql)},e),[l,e]),d=N(()=>({appId:c.appId,instanceId:c.instanceId,rootResource:{id:a.id,type:a.type}}),[c.appId,c.instanceId,a.id,a.type]);return L(Yl,{children:L(Le.Provider,{value:$l,children:L(Ai,{resource:a,children:L(ws,{children:L(Ye,{theme:r||Ps,children:R(At,{config:u,saveConfig:t,children:[L(ci,{config:u}),L(ya,{children:L(Zl,{children:L(tr,{persistence:s,persistenceKey:d,children:L(ec,{children:L(oo,{children:L(Hi,{previews:i||[],configs:u.previews,children:L(Pe,{children:n})})})})})})})]})})})})})})}const tu=new Set([`Collection`,`Manifest`,`Canvas`,`Range`,`AnnotationPage`,`Annotation`,`ContentResource`,`Agent`]),nu={satisfied:0,missing:0,invalid:0,disallowed:0,"not-applicable":0},ru=new Set([`label`,`summary`,`language`,`navDate`,`provider`,`requiredStatement`,`rights`,`thumbnail`]);function iu(e){return e?Array.isArray(e)?e.filter(Boolean):e.split(`.`).filter(Boolean):[]}function au(e,t){let n=iu(e),r=iu(t);return n.length===r.length&&n.every((e,t)=>e===r[t])}function ou(e,t){let n=e;for(let e of iu(t)){if(n==null)return;n=n[e]}return n}function su(e,t,n){let r=iu(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 cu(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=>cu(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])=>cu(e)):!0:!1}function lu(e){return Array.isArray(e)?e.map(lu):e&&typeof e==`object`?Object.keys(e).sort().reduce((t,n)=>(t[n]=lu(e[n]),t),{}):e}function uu(e,t){return JSON.stringify(lu(e))===JSON.stringify(lu(t))}function du(e,t,n,r){let i=iu(n);for(let n of e||[])for(let e of n.terminology?.properties||[])if(!(e.entityType&&e.entityType!==t)&&au(e.path,i))return e.label;return r||zu(i)}function fu(e,t,n){let r=iu(n),i=[],a,o,s=!1,c=!1;if(!t||!tu.has(t.type))return{entityType:t?.type,path:r,label:du(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&&au(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:du(e,t.type,r),disallowed:s,required:c,fixedValue:a,fixedValueRule:o,rules:i}}function pu(e,t,n){let r=e||[],i=mu(t,n),a=[];for(let e of r)for(let[n,r]of(e.rules||[]).entries())a.push(...hu(e,r,n,i,t));return{specifications:r,results:a,counts:wu(a)}}function mu(e,t){let n=[],r=new Set;function i(t){let a=Eu(t);if(!a)return;if(a.type===`SpecificResource`){i(t?.source);return}let o=Tu(e,t)||Tu(e,a);if(!o||!o.type)return;let s=`${o.type}:${o.id||JSON.stringify(a)}`;if(!r.has(s)){r.add(s),tu.has(o.type)&&n.push({ref:{id:o.id,type:o.type},resource:o});for(let e of Du(o))i(e)}}return i(t),n}function hu(e,t,n,r,i){switch(t.type){case`disallow-property`:case`require-non-empty`:case`fixed-value`:return gu(e,t,n,r);case`iiif:canvas-with-image-service`:return[_u(e,t,n,r,i)];case`iiif:thumbnail-from-body-service`:return vu(e,t,n,r,i);case`iiif:valid-rights`:return yu(e,t,n,r);case`iiif:required-statement`:return bu(e,t,n,r);case`iiif:metadata-template`:return xu(e,t,n,r);default:return[]}}function gu(e,t,n,r){let i=r.filter(e=>e.ref.type===t.entityType),a=du(e?[e]:[],t.entityType,t.path);return i.length?i.map(({ref:r,resource:i})=>{let o=ou(i,t.path),s=cu(o);if(t.type===`disallow-property`)return Su(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:Cu(r,t.path)});if(t.type===`require-non-empty`)return Su(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:Cu(r,t.path)});let c=uu(o,t.value);return Su(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:Cu(r,t.path)})}):[Su(e,t,n,{status:`not-applicable`,displayLabel:a,message:`No ${t.entityType} resources were found for ${a}.`,path:t.path})]}function _u(e,t,n,r,i){let a=r.filter(e=>e.ref.type===`Canvas`),o=Ou(t),s=a.find(({resource:e})=>ku(Au(e,i),o));return Su(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?Cu(s.ref,[`items`]):void 0})}function vu(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=>Au(e.resource,i)):Au(s,i),l=ju(s,c,i),u=cu(s.thumbnail);return Su(e,t,n,{target:o,path:[`thumbnail`],status:l?`satisfied`:c.length?u?`invalid`:t.requireThumbnail===!1?`not-applicable`:`missing`:`not-applicable`,displayLabel:du([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:Cu(o,[`thumbnail`])})}):[Su(e,t,n,{status:`not-applicable`,displayLabel:`Thumbnail`,message:`No ${a} resources were found for thumbnail checks.`})]}function yu(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=cu(a),c=typeof a==`string`&&o.map(Fu).includes(Fu(a));return Su(e,t,n,{target:r,path:[`rights`],status:c?`satisfied`:!s&&t.required!==!1?`missing`:`invalid`,displayLabel:du([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:Cu(r,[`rights`])})})}function bu(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?Iu(a?.label,t.label):cu(a?.label),s=t.value||t.valueRequired!==!1,c=t.value?Iu(a?.value,t.value):!s||cu(a?.value),l=cu(a);return Su(e,t,n,{target:r,path:[`requiredStatement`],status:o&&c?`satisfied`:l?`invalid`:`missing`,displayLabel:du([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:Cu(r,[`requiredStatement`])})})}function xu(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=>Iu(e?.label,i.label)),l=i.value?Iu(c?.value,i.value):i.valueRequired?cu(c?.value):!0,u=c&&l?`satisfied`:c&&i.value?`invalid`:`missing`,d=Ru(i.label);o.push(Su(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:Cu(r,[`metadata`])}))})}return o}function Su(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 Cu(e,t){let n=t[0];return{resource:e,propertyPath:t,selectedTab:n===`metadata`?`@manifest-editor/metadata`:n&&ru.has(n)?`@manifest-editor/descriptive-properties`:void 0}}function wu(e){let t={...nu};for(let n of e)t[n.status]+=1;return t}function Tu(e,t){let n=Eu(t);if(!n)return t;try{return e.get(n,{skipSelfReturn:!1})||t}catch{try{return e.get(n)||t}catch{return t}}}function Eu(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 Du(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 Ou(e){return[...e.serviceIds||[],...e.serviceId?[e.serviceId]:[]].filter(Boolean)}function ku(e,t){let n=new Set(e.filter(Boolean));return t.length?t.some(e=>n.has(e)):n.size>0}function Au(e,t){let n=Pu(t,e?.items),r=[];for(let e of n){let n=Pu(t,e?.items);for(let e of n)if((Array.isArray(e?.motivation)?e.motivation:[e?.motivation]).includes(`painting`))for(let n of Mu(e?.body,t))r.push(...Nu(n))}return Array.from(new Set(r))}function ju(e,t,n){let r=Pu(n,e?.thumbnail);if(!r.length||!t.length)return!1;for(let e of r){let n=Nu(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 Mu(e,t){let n=Tu(t,e);return n?Array.isArray(n)?n.flatMap(e=>Mu(e,t)):n.type===`SpecificResource`?Mu(n.source,t):n.type===`Choice`?n.items?.flatMap(e=>Mu(e,t))||[]:[n]:[]}function Nu(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 Pu(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=>Tu(e,t)).filter(Boolean)}function Fu(e){return e.replace(/^https:/,`http:`).replace(/\/?$/,`/`)}function Iu(e,t){return typeof t==`string`?Lu(e).some(e=>e===t):uu(e,t)}function Lu(e){return e?typeof e==`string`?[e.trim()].filter(Boolean):Array.isArray(e)?e.flatMap(Lu):typeof e==`object`?Object.values(e).flatMap(Lu):[]:[]}function Ru(e){return typeof e==`string`?e:Lu(e)[0]||``}function zu(e){return(e[e.length-1]||`Property`).replace(/([A-Z])/g,` $1`).replace(/[-_]/g,` `).replace(/^./,e=>e.toUpperCase())}const Bu=O([]);function Vu({children:e,specifications:t}){let n=N(()=>t||[],[t]);return L(Bu.Provider,{value:n,children:e})}function Hu(){return A(Bu)}function Uu(e){let t=Oi(),n=Hu(),r=e||t;return qe((e,t)=>pu(n,t,r),[n,r.id,r.type])}function Wu(){let e=Hu();return N(()=>({getLabel(t,n,r){return du(e,t,n,r)}}),[e])}function Gu(e,t){let n=Hu();return N(()=>fu(n,e,t),[n,e?.id,e?.type,JSON.stringify(t)])}const Ku={},qu=O(`global`);function Ju(){return A(qu)}function Yu(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function Xu(e){let t=Ju(),[,n]=Oe(e=>e+1,0),r=N(()=>(Ku[t]||(Ku[t]={}),Ku[t][e]||(Ku[t][e]={name:e,emitter:pt(),status:`idle`,promise:Promise.resolve(),abort:new AbortController,reject:()=>void 0,resolve:()=>void 0}),Ku[t][e]),[t,e]);return Zu(r,`abort`,n),Zu(r,`error`,n),Zu(r,`complete`,n),Zu(r,`running`,n),r}function Zu(e,t,n){let r=k(()=>n(e),[n]);j(()=>{let n=e.emitter;return n.on(t,r),()=>n.off(t,r)},[t,r,e.emitter])}const Qu=()=>void 0;function $u(e,t){let n=Xu(e);return Zu(n,`complete`,t||Qu),[e=>{n.status===`running`&&(n.abort.abort(),n.emitter.emit(`abort`)),n.error&&(n.error=``);let t=Yu();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 ed(e,t){let n=Xu(e);return Zu(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 td({children:e}){return L(qu.Provider,{value:N(()=>`id-${Date.now()}`,[]),children:e})}function nd(e){return!1}function rd({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,_=N(()=>t,[t?.id,t?.type]),v=k(function(e){e.defaultPrevented||(e.preventDefault(),e.clipboardData&&_&&_.id&&_.type&&e.clipboardData.setData(`application/json+vault`,JSON.stringify({id:_.id,type:_.type})))},[_]),y=k(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(`
1511
- `);for(let t of e){if(g)try{let e=await nd(t);if(e){g(e);continue}}catch{}h&&h(t)}}}d.onComplete&&d.onComplete()}},[]),b=k(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}))))},[]);return L(f,{onCopy:v,onPaste:y,onDrop:k(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}},[]),onDragOver:k(e=>{e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`)},[]),onDragStart:b,tabIndex:-1,...d})}export{Mo as AppHeader,Io as AppMenuProvider,hi as AppProvider,ui as AppReactContext,ki as AppResourceInstanceProvider,Ai as AppResourceProvider,di as AppStateReactContext,Ne as AtlasStoreProvider,Fe as AtlasStoreReactContext,_o as BackgroundActionToasts,jo as BackgroundActionsMenu,go as BackgroundActionsMount,tr as BackgroundActionsProvider,er as BackgroundActionsReactContext,Fs as BaseAnnotationCreator,zs as BaseEditor,Is as BaseEditorBackButton,Ls as BaseEditorCloseButton,jt as CANVAS_PROGRESS_META_NAMESPACE,Mt as CANVAS_PROGRESS_STATUS_META_KEY,Zs as ConfigEditor,At as ConfigProvider,Et as ConfigReactContext,ec as ContextMenuProvider,$s as ContextMenuReactContext,As as CreatorInitialData,ya as EditingStack,sa as EditingStackContext,Oc as EventEmitterProvider,Tc as ExportPanel,ja as FLAG_TAG,Ss as HOMEPAGE_COLLECTION,Pc as HandleContainer,zc as HandleControls,ba as InlineEditingStack,El as Layout,xa as LayoutActionsReactContext,Ca as LayoutModeReactContext,Sa as LayoutStateReactContext,Zt as ManifestEditorCanvasProgressOverlay,eo as ManifestEditorTagBadge,$a as ManifestEditorTagIcon,to as ManifestEditorTagOverlay,Nl as ManifestPaginationNavigation,vt as MessagePortClientVault,_s as ModularPanel,fs as ModularPanelHeader,ps as ModulePanelButton,yi as MultiAppProvider,es as PanelError,ci as PluginConfigBridge,Yr as PluginGlobalConfigReactContext,Js as PluginManager,Xr as PluginProvider,Jr as PluginReactContext,ra as PreviewButton,Hi as PreviewProvider,Ts as PreviewVaultBoundary,ws as PreviewVaultContext,li as PrimeAppReactContext,Dc as ReactEmitterContext,Jl as ResourceEditingProvider,Wl as ResourceEditingReactContext,Dt as SaveConfigReactContext,eu as ShellProvider,Vu as SpecificationProvider,Aa as TAGS_META_KEY,ka as TAGS_META_NAMESPACE,td as TaskBridge,oo as ToastProvider,rd as UniversalCopyTarget,Wa as addResourceTag,Ho as analyse,Wo as analyseJson,Kr as applyPlugins,Ns as baseCreator,Bs as baseEditor,Bt as clearCanvasProgressStatus,Ht as clearCanvasProgressStatuses,mu as collectSpecificationResources,cr as copyToClipboard,or as createActionIdentity,Gn as createBackgroundActionsStore,sr as createDownload,Bl as createIframeVaultBridge,Qn as createLocalForageBackgroundActionPersistence,Ut as createManifestEditorCanvasProgressApi,Xa as createManifestEditorTagsApi,Br as createPluginRuntimeApi,qr as createPluginStore,vs as createPreviewVault,Wt as createTrackingCanvasProgressApi,Vo as detectMedia,br as disablePluginInConfig,Rs as editBasedOnResource,Vr as enablePluginAndDependenciesInConfig,yr as enablePluginInConfig,pu as evaluateSpecifications,dr as extendApp,qc as filterSupportedPanels,sn as getAvailableBackgroundActionGroups,en as getBackgroundActionInstanceKey,Lt as getCanvasProgressStatus,Rt as getCanvasProgressStatusFromState,Ml as getDefaultLayoutState,jl as getDefaultPanelState,zr as getEffectivePluginSettings,mr as getEmptyPluginState,Pr as getEnabledPluginsForApp,qo as getFormat,Jo as getImageDimensions,ar as getManifestNomalized,jr as getPluginCompatibilityReason,Rr as getPluginDefaultSettings,Nr as getPluginSelectionSource,Fr as getPluginSettingsFromConfig,fu as getPropertyPolicy,Ga as getResourceTag,qa as getResourceTagGroups,Va as getResourceTags,Ha as getResourceTagsFromState,Jc as getSupportedPanelFallback,du as getTerminologyLabel,ou as getValueAtPath,cu as hasMeaningfulValue,Ja as hasResourceTag,Er as isLazyPlugin,Tr as isMappedPlugin,ts as isPinnableState,Ar as isPluginCompatible,Mr as isPluginSelected,Al as layoutReducer,ur as mapApp,wr as mapLazyPlugin,Cr as mapPlugin,tn as mergeBackgroundActionDefinitions,Tt as mergeConfig,wt as mergePartialConfig,kr as mergeProviderPlugins,rn as normaliseBackgroundActionError,lu as normaliseJsonValue,Dr as normalisePlugin,_r as normalisePluginAppConfig,vr as normalisePluginAppsConfig,Or as normalisePlugins,iu as normaliseSpecificationPath,X as panelIds,ns as panelSizing,Sr as pluginAppConfigEquals,Ro as polygonToBoundingBox,lr as randomId,Ka as removeResourceTag,rs as renderHelper,xr as resetPluginInConfig,Lr as resetPluginSettingsInConfig,Jn as runBackgroundAction,zt as setCanvasProgressStatus,Vt as setCanvasProgressStatuses,Ir as setPluginSettingsInConfig,Ua as setResourceTags,su as setValueAtPath,nn as sortBackgroundActionDefinitions,uu as specificationJsonEquals,au as specificationPathEquals,Ya as toggleResourceTag,Ec as useAnnotationCreatorState,ga as useAnnotationPageEditor,q as useApp,fi as useAppInstance,Po as useAppMenu,Fo as useAppMenuItem,Oi as useAppResource,Di as useAppResourceInstance,pi as useAppState,_i as useApps,Lo as useAtlasStore,ho as useAvailableBackgroundActions,Da as useAvailableLayouts,ir as useBackgroundActionHistory,rr as useBackgroundActionInstance,K as useBackgroundActionsStore,nr as useBackgroundActionsStoreApi,Kt as useCanvasProgressActions,Gt as useCanvasProgressStatus,ma as useCollectionEditor,Ot as useConfig,fa as useCreatingResource,Es as useCreator,ic as useCustomContextMenu,Vs as useDecayState,Gl as useEditingContext,ua as useEditingResource,da as useEditingResourceStack,la as useEditingStack,_a as useEditor,kc as useEmitter,ti as useEnabledPlugins,Ac as useEvent,ha as useGenericEditor,Yo as useHighlightedImageResource,Zo as useHoverHighlightImageResource,ks as useInitialData,Ds as useInlineCreator,Ta as useLayoutActions,Ea as useLayoutMode,Oa as useLayoutProvider,wa as useLayoutState,_e as useLocalStorage,pa as useManifestEditor,jc as useMatchMedia,ve as useOptionalLocalStorage,Zr as useOptionalPluginStoreApi,ql as useOptionalResource,Dl as usePanelActions,ni as usePluginActions,ai as usePluginConfigApi,ri as usePluginRuntimeApi,ii as usePluginSettings,Qr as usePluginStoreApi,ei as usePlugins,Wi as usePreviewContext,Cs as usePreviewHistory,ys as usePreviewVault,Ui as usePreviews,oi as useResolvedPluginApp,Kl as useResource,nc as useResourceContextMenuItems,Qa as useResourceTagActions,Za as useResourceTags,kt as useSaveConfig,Mc as useSaveVault,us as useSetCustomTitle,Gu as useSpecificationPropertyPolicy,Uu as useSpecificationReport,Wu as useSpecificationTerminology,Hu as useSpecifications,Nc as useSvgTools,Xu as useTask,$u as useTaskDispatch,Zu as useTaskEvent,ed as useTaskRunner,Xo as useTemporaryHighlight,so as useToasts};
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};
1512
1532
  //# sourceMappingURL=index.js.map