@manifest-editor/shell 2.2.2-next.0.4041094 → 2.2.2-next.0.92cba17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +374 -349
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +253 -56
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +254 -57
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +148 -123
- package/dist/index.js.map +1 -1
- package/package.json +22 -12
package/dist/index.cjs
CHANGED
|
@@ -1,13 +1,31 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));let l=require("@manifest-editor/components"),u=require("react");u=c(u,1);let d=require("react/jsx-runtime"),f=require("zustand"),p=require("localforage");p=c(p,1);let m=require("react-iiif-vault"),h=require("@iiif/parser"),g=require("styled-components");g=c(g,1);let _=require("immer"),v=require("@manifest-editor/editor-api"),y=require("@react-stately/toast"),b=require("@iiif/helpers"),x=require("@iiif/helpers/vault");x=c(x,1);let S=require("@manifest-editor/creator-api"),C=require("react-error-boundary"),w=require("@iiif/helpers/vault/actions"),T=require("@iiif/helpers/vault/utility"),E=require("mitt");E=c(E,1);let D=require("tiny-use-debounce"),O=require("react-transition-group"),ee=require("shallowequal");ee=c(ee,1);let k=require("@atlas-viewer/iiif-image-api"),A=require("@manifest-editor/client-vault");var j=process.env.NODE_ENV===`production`,M=`Invariant failed`;function N(e,t){if(!e){if(j)throw Error(M);var n=typeof t==`function`?t():t,r=n?`${M}: ${n}`:M;throw Error(r)}}const P={previews:[],behaviorPresets:[`auto-advance`,`no-auto-advance`,`repeat`,`no-repeat`,`unordered`,`individuals`,`continuous`,`paged`,`non-paged`,`facing-pages`,`multi-part`,`together`,`sequence`,`thumbnail-nav`,`no-nav`,`hidden`],defaultPreview:null,editorConfig:{},newTemplates:null,i18n:{advancedLanguageMode:!1,availableLanguages:[`en`,`cy`,`nl`,`fr`],defaultLanguage:`en`},editorFeatureFlags:{enableMultiImageCanvases:!0,enableMultiMediaCanvases:!0,annotationPopups:!1,rememberCanvasId:!0,manifestGridOptions:!1,rememberLeftPanelId:!1},uploadBackends:[],plugins:{apps:{}},export:{baseIdentifier:null,version:3},creators:{"iiif-image-services":{compact:`with-dimensions`,includeSizes:!1,includeTiles:!1}}};function F(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 te(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 ne(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 I(...e){let t={};for(let n of e)n&&(t={...t,...n,editorConfig:F(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:ne(t.creators,n.creators),plugins:te(t.plugins,n.plugins)});return t}function re(...e){return I(P,...e)}const L=(0,u.createContext)(P),R=(0,u.createContext)(()=>{});function z(){return(0,u.useContext)(L)}function ie(){return(0,u.useContext)(R)}function ae({children:e,config:t,saveConfig:n}){let[r,i]=(0,u.useState)(null),a=(0,u.useMemo)(()=>re(t,r),[t,r]),o=(0,u.useCallback)(e=>{i(t=>I(t,e)),n&&n(e)},[n]);return(0,d.jsx)(R.Provider,{value:o,children:(0,d.jsx)(L.Provider,{value:a,children:e})})}const oe=`@manifest-editor/canvas-progress`,se=`status`,ce=new Set([`queued`,`pending`,`done`]);function le(e){return typeof e==`string`?e:e?.id||null}function ue(e){return typeof e==`string`&&ce.has(e)?e:`none`}function de(e){return typeof e==`string`&&ce.has(e)}function fe(e,t){let n=le(t);return n?ue(e.getResourceMeta(n,oe)?.[se]):`none`}function pe(e,t){let n=le(t);return n?ue(e?.iiif?.meta?.[n]?.[oe]?.[se]):`none`}function me(e,t,n){let r=le(t);if(!r)return`none`;let i=de(n)?n:void 0;return e.setMetaValue([r,oe,se],i),i||`none`}function he(e,t){return me(e,t,`none`)}function ge(e,t,n){let r={};for(let i of t){let t=le(i);t&&(r[t]=me(e,i,n))}return r}function _e(e,t){return ge(e,t,`none`)}function ve(e){return{getStatus(t){return fe(e,t)},setStatus(t,n){return me(e,t,n)},clearStatus(t){return he(e,t)},setStatuses(t,n){return ge(e,t,n)},clearStatuses(t){return _e(e,t)}}}function ye(e,t=new Set){function n(e){let n=le(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 be(e){let t=le(e);return(0,m.useVaultSelector)(e=>t?pe(e,t):`none`,[t])}function xe(e){let t=(0,m.useVault)(),n=le(e),r=(0,u.useMemo)(()=>ve(t),[t]);return(0,u.useMemo)(()=>({setStatus(e){return r.setStatus(n,e)},clearStatus(){return r.clearStatus(n)},getStatus(){return r.getStatus(n)}}),[r,n])}const Se={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 Ce({className:e}){return(0,d.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,d.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,d.jsx)(`path`,{d:`M12 7v5l2.5 2.5`})]})}function we({className:e}){return(0,d.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,children:[(0,d.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,stroke:`currentColor`,strokeWidth:`2.5`,strokeOpacity:`0.3`}),(0,d.jsx)(`path`,{d:`M12 3a9 9 0 0 1 9 9`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`})]})}function Te({className:e}){return(0,d.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,d.jsx)(`path`,{d:`M5 12l4 4 8-8`})})}function Ee({resource:e,status:t,className:n}){return t?(0,d.jsx)(Oe,{status:t,className:n}):(0,d.jsx)(De,{resource:e,className:n})}function De({resource:e,className:t}){let n=be(e);return(0,d.jsx)(Oe,{status:n,className:t})}function Oe({status:e,className:t}){if(e===`none`)return null;let n=Se[e];return(0,d.jsxs)(d.Fragment,{children:[n.dimOverlay&&(0,d.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 z-10 bg-white/40`}),(0,d.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-x-0 top-0 z-10 h-[3px] rounded-t-sm ${n.stripClass} ${t||``}`}),(0,d.jsxs)(`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:[(0,d.jsx)(`span`,{className:`sr-only`,children:n.label}),e===`queued`&&(0,d.jsx)(Ce,{className:`h-2.5 w-2.5 text-white`}),e===`pending`&&(0,d.jsx)(we,{className:`h-2.5 w-2.5 animate-spin text-white`}),e===`done`&&(0,d.jsx)(Te,{className:`h-2.5 w-2.5 text-white`})]})]})}function ke(e,t){return`${e}::${t.type}::${t.id}`}function Ae(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 je(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 Me(e){return e instanceof Error?{message:e.message,stack:e.stack,detail:e}:{message:typeof e==`string`?e:`Background action failed`,detail:e}}function Ne(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}:Me(e)}function Pe(e,t){return!e.resourceTypes?.length||e.resourceTypes.includes(t.type)}function Fe({definitions:e,instances:t,systemContext:n,targets:r,onSupportsError:i}){let a=je(e),o=[];for(let e of r){let r=[];for(let o of a){if(!Pe(o,e))continue;let a=ke(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 Ie=0;function Le(e){return Ie+=1,`${e}-${Date.now()}-${Ie}`}function Re(e,t,n,r=Date.now()){return{id:Le(`event`),createdAt:r,type:e,message:t,data:n}}function B(e,t,n,r,i=Date.now()){return{...e,events:[...e.events,Re(t,n,r,i)]}}function ze(e){return e.filter(e=>String(e.type)!==`progress`)}function Be(e){return{...e,logs:[...e.logs],events:ze(e.events),progress:e.progress?{...e.progress}:void 0}}function Ve(e,t,n){if(!Ge(n.status))return e;let r=e[t]||[],i=Be(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 V(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:Ve(e.histories,t,i)}}function He(e){return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}function Ue(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:He(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 We(e){return e===`preparing`||e===`running`}function Ge(e){return e===`complete`||e===`error`||e===`cancelled`}function Ke(e){return e===`queued`||e===`running`||e===`complete`||e===`skipped`||e===`error`||e===`cancelled`}function qe(e){return!e||e===`queued`||e===`running`}function Je(e){return e===`complete`||e===`skipped`||e===`error`||e===`cancelled`}function Ye(e){if(e!==void 0)try{return JSON.parse(JSON.stringify(e))}catch{return}}function Xe(e){return e&&{message:e.message,stack:e.stack,detail:Ye(e.detail)}}function Ze(e){return{...e,error:Xe(e.error)||null,result:Ye(e.result),logs:e.logs.map(e=>({...e,data:Ye(e.data)})),events:ze(e.events).map(e=>({...e,data:Ye(e.data)})),progress:e.progress?{...e.progress}:void 0}}function Qe(e){return{...e,status:it(e.status),input:Ye(e.input),result:Ye(e.result),error:Xe(e.error)||null}}function $e(e){return{version:1,data:Ye(e.data),tasks:e.tasks.map(Qe)}}function et(e){return{version:1,savedAt:Date.now(),instances:Object.fromEntries(Object.entries(e.instances).map(([e,t])=>[e,Ze(t)])),histories:Object.fromEntries(Object.entries(e.histories).map(([e,t])=>[e,t.map(Ze)])),plans:Object.fromEntries(Object.entries(e.plans).map(([e,t])=>[e,$e(t)]))}}function tt(){return{version:1,savedAt:Date.now(),instances:{},histories:{},plans:{}}}function nt(e,t){return{version:1,savedAt:t.savedAt,instances:{...e.instances,...t.instances},histories:{...e.histories,...t.histories},plans:{...e.plans,...t.plans}}}function rt(e){return!Object.keys(e.instances).length&&!Object.keys(e.histories).length&&!Object.keys(e.plans).length}function it(e){return Ke(e)?e:`queued`}function at(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:it(e.status),error:e.error?Ne(e.error):null,createdAt:typeof e.createdAt==`number`?e.createdAt:n}}function ot(e){return!e||e.version!==1||!Array.isArray(e.tasks)?null:{version:1,data:e.data,tasks:e.tasks.map(at)}}function st(e){return{...e,tasks:e.tasks.map(e=>e.status===`running`?{...e,status:`queued`,statusText:`Queued after reload`,startedAt:void 0}:e)}}function ct(e,t=Date.now()){return{...e,tasks:e.tasks.map(e=>qe(e.status)?{...e,status:`cancelled`,statusText:`Cancelled`,error:null,completedAt:t}:e)}}function lt(e){return{...e,error:e.error?Ne(e.error):null,logs:Array.isArray(e.logs)?e.logs:[],events:ze(Array.isArray(e.events)?e.events:[]),resultsAvailable:e.resultsAvailable===!0}}function ut(e){return!e||e.version!==1?tt():{version:1,savedAt:typeof e.savedAt==`number`?e.savedAt:Date.now(),instances:e.instances||{},histories:e.histories||{},plans:e.plans||{}}}function dt(e,t,n){let r=e,i=t;if(We(e.status)){if(e.cancelRequestedAt){let t=Date.now();i=i&&ct(i,t),r=B({...e,status:`cancelled`,statusText:`Cancelled`,completedAt:t,cancelledAt:t},`status`,`Cancelled`,{status:`cancelled`},t)}else if(n.resumable&&i)i=st(i),r=B({...e,status:`running`,statusText:`Resuming`,completedAt:void 0,cancelledAt:void 0},`status`,`Resuming`,{status:`running`});else{let t=Date.now();r=B({...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 ft(e,t){let n=ut(e),r=new Map(t.map(e=>[e.id,e])),i={},a={},o={},s=tt();for(let[e,t]of Object.entries(n.histories)){let n=(Array.isArray(t)?t:[]).map(lt),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=lt(t),l=ot(n.plans[e]),u=r.get(c.actionId);if(!u){s.instances[e]=Ze(c),l&&(s.plans[e]=$e(l));continue}let d=dt(c,l,u);i[e]=d.instance,a=Ve(a,e,d.instance),d.plan&&(o[e]=d.plan)}return{instances:i,histories:a,plans:o,deferred:s}}function pt(e,t){let n=e.tasks.length;if(!n)return;let r=e.tasks.filter(e=>Je(e.status)).length;return Ue({current:r,total:n,label:t})}function mt(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 ht(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 gt(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(it(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||_t(m,p)&&(await vt(),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=>Je(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=mt(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||Ct(e))throw l(u.id,{status:`cancelled`,statusText:`Cancelled`,error:null,completedAt:Date.now()},!0),e;let n=Me(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=>Je(e.status)).length,total:d,label:_})}}return s()}return{getAll:s,getPending:()=>c(),update:l,runEach:u}}function _t(e,t){return t!==!1&&(!e||Date.now()-e>=t)}function vt(){return new Promise(e=>{setTimeout(e,0)})}function yt(e=[]){let t=null,n=null,r=null,i=tt();return(0,f.createStore)((a,o)=>{function s(e,t){let n=Ae([],t),r=ft(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&&We(e.instances[t].status)))}}async function c(){if(r&&(clearTimeout(r),r=null),!t||!n||!o().hasHydrated)return;let e=nt(i,et(o()));if(rt(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:Ae([],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=ft(ut(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,Ae(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:Le(`run`),actionId:t.id,target:n,label:t.label,status:`preparing`,statusText:`Preparing`,error:null,result:void 0,resultsAvailable:!1,logs:[],events:[Re(`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=>({...V(r,e,e=>B({...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||!We(n.status))return;let r=Date.now();a(t=>{let n=V(t,e,e=>B(B({...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]:ct(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=>({...V(r,e,e=>B({...e,label:t},`label`,t,{label:t},n))})),l()},setActionStatus(e,t,n){let r=Date.now(),i=Ge(t)?r:void 0;a(a=>({...V(a,e,e=>B({...e,status:t,statusText:n,completedAt:i,cancelledAt:t===`cancelled`?r:void 0},`status`,n||t,{status:t},r)),controllers:We(t)?a.controllers:Object.fromEntries(Object.entries(a.controllers).filter(([t])=>t!==e))})),l(Ge(t))},setActionError(e,t,n){let r=Date.now(),i=Me(t);a(t=>({...V(t,e,e=>B({...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:Le(`log`),createdAt:i,level:n,message:t,data:r};a(a=>({...V(a,e,e=>B({...e,logs:[...e.logs,o]},`log`,t,{level:n,data:r},i))})),l()},setActionProgress(e,t){let n=t?Ue(t):void 0;a(t=>({...V(t,e,e=>({...e,progress:n}))}))},setResult(e,t){let n=Date.now();a(r=>({...V(r,e,e=>B({...e,result:t},`result`,`Result recorded`,void 0,n))})),l(!0)},setResultsAvailable(e,t){let n=Date.now();a(r=>({...V(r,e,e=>B({...e,resultsAvailable:t},`results-available`,t?`Results available`:`Results hidden`,{available:t},n))})),l(!0)},setActionPlan(e,t){let n=ot(t);n&&(a(t=>({...V(t,e,e=>({...e,progress:pt(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?at({...e,...n,status:n.status?it(n.status):e.status,error:n.error?Ne(n.error):n.error===null?null:e.error},0):e),o={...i,tasks:a};return{...V(r,e,e=>({...e,progress:pt(o,n.statusText||n.label)})),plans:{...r.plans,[e]:o}}}),l(r)}}})}function bt(e,t,n){let{store:r,context:i}=e,{instanceKey:a}=i,o=gt(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 xt(e){return!!e&&typeof e==`object`&&e.version===1&&Array.isArray(e.tasks)}async function St(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=ye(n.canvasProgress),d=()=>c.abort();e.signal&&(e.signal.aborted?c.abort():e.signal.addEventListener(`abort`,d,{once:!0})),e.resume&&o&&We(o.status)?t.getState().resumeAction(i,c):t.getState().startAction(i,r,a,c);let f=()=>{let e=t.getState().instances[i];e&&!Ge(e.status)&&t.getState().setActionStatus(i,`cancelled`,`Cancelled`)};try{if(!e.resume&&r.prepare){let n=await r.prepare(bt(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];xt(n)&&t.getState().setActionPlan(i,n)}if(l.aborted)return f(),t.getState().instances[i];let n=t.getState().plans[i];n&&ht(u,n),t.getState().setActionStatus(i,`running`,e.resume?`Resuming`:`Running`);let a=await r.run(bt(e,l,u));if(l.aborted)return f(),t.getState().instances[i];let o=t.getState().instances[i];a!==void 0&&o&&!Ge(o.status)&&t.getState().setResult(i,a),o=t.getState().instances[i],o&&We(o.status)&&((a!==void 0||o?.resultsAvailable)&&t.getState().setResultsAvailable(i,!0),t.getState().setActionStatus(i,`complete`,`Complete`))}catch(e){l.aborted||Ct(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 Ct(e){return e instanceof Error&&(e.name===`AbortError`||e.message.toLowerCase().includes(`aborted`))}function wt(e){return JSON.stringify([e.appId,e.instanceId,e.rootResource.type,e.rootResource.id])}let Tt;function Et(){if(typeof window>`u`)return null;let e=p.default.createInstance({name:`manifest-editor-background-actions-v1`,storeName:`background-actions`});return{async load(t){return e.getItem(wt(t))},async save(t,n){await e.setItem(wt(t),n)},async clear(t){await e.removeItem(wt(t))}}}function Dt(){return Tt===void 0&&(Tt=Et()),Tt}const Ot=(0,u.createContext)(null);function kt({children:e,persistence:t,persistenceKey:n}){let r=U(),i=Hn(),a=(0,u.useMemo)(()=>yt(),[]),o=r.layout.backgroundActions||[],s=(0,u.useMemo)(()=>t===!1?null:t||Dt(),[t]),c=(0,u.useMemo)(()=>n||null,[n]);return(0,u.useEffect)(()=>{a.getState().setDefinitions(o)},[a,o]),(0,u.useEffect)(()=>{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]),(0,u.useEffect)(()=>{let e=()=>{a.getState().flushPersistence()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[a]),(0,u.createElement)(Ot.Provider,{value:a},e)}function At(){let e=(0,u.useContext)(Ot);if(!e)throw Error(`useBackgroundActionsStore must be used within a BackgroundActionsProvider`);return e}function H(e=e=>e){return(0,f.useStore)(At(),e)}function jt(e){return H(t=>t.instances[e])}function Mt(e){return H(t=>t.histories[e]||[])}async function Nt(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 Pt(e,t,n){return`create_${e}_${t}_${(0,h.toRef)(n)?.type||`unknown`}`}function Ft(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 It(e){return navigator.clipboard.writeText(typeof e==`string`?e:JSON.stringify(e,null,2))}function Lt(){return`${Math.random().toString(36).substr(2)}-${Date.now().toString(36)}`}function Rt(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:zt(void 0,s.preset)}}function zt(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 Bt(e,t,n){return{...e,metadata:t,config:I(e.config||{},n.config||{}),preset:zt(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:Ae(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 Vt=[`leftPanels`,`centerPanels`,`rightPanels`,`modalPanels`,`annotations`,`canvasEditors`,`editors`,`creators`,`background`,`backgroundActions`],Ht={plugins:[],enabled:[],disabled:[],globalApps:{},apps:{}};function Ut(){return Ht}function Wt(e=[]){return Array.from(new Set(e.filter(Boolean)))}function Gt(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Kt(e={}){return{...e,enabled:Wt(e.enabled||[]),disabled:Wt(e.disabled||[]),settings:e.settings?{...e.settings}:void 0}}function qt(e){let t={};for(let[n,r]of Object.entries(e?.apps||{}))t[n]=Kt(r);return t}function Jt(e={},t){return{...e,enabled:Wt([...(e.enabled||[]).filter(e=>e!==t),t]),disabled:(e.disabled||[]).filter(e=>e!==t)}}function Yt(e={},t){return{...e,enabled:(e.enabled||[]).filter(e=>e!==t),disabled:Wt([...(e.disabled||[]).filter(e=>e!==t),t])}}function Xt(e={},t){return{...e,enabled:(e.enabled||[]).filter(e=>e!==t),disabled:(e.disabled||[]).filter(e=>e!==t)}}function Zt(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 Qt(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 $t(e){return{metadata:e.default,extension:{},settings:e.settings,load:e.load,loadStatus:`idle`}}function en(e){return!!e&&`metadata`in e&&`extension`in e}function tn(e){return!!e&&`load`in e&&`default`in e}function nn(e){return en(e)?e:tn(e)?$t(e):Qt(e)}function rn(e=[]){return e.map(nn)}function an(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 on(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 sn(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 cn(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 ln(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 un(e,t,n){let r=[],i=new Set,a=new Set,o=new Set(e.plugins.filter(r=>on(r,t,n)&&cn(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 yn(`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 yn(`Plugin "${u}" was not enabled because dependency "${r}" is not enabled.`),c.delete(u),a.add(u),!1;if(!on(e,t,n))return yn(`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)on(r,t,n)&&cn(r,e,n)&&l(r);return r}function dn(e,t){let n=e?.settings?.[t];return Gt(n)?n:{}}function fn(e={},t,n){return{...e,settings:{...e.settings||{},[t]:n}}}function pn(e={},t){let n={...e.settings||{}};return delete n[t],{...e,settings:n}}function mn(e){return{...e?.settings?.defaults||{}}}function hn(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{...mn(r),...dn(i,t),...dn(a,t)}}function gn(e,t){return{getSettings(n){return hn(e,n,t)}}}function _n(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(!on(e,r,i)){s.push(`${e.metadata.label} is not compatible`);continue}u(e)}c.delete(t),l=Jt(l,t),o.push(t)}}return u(n),s.length?{config:e,enabledIds:[],blocked:s}:{config:l,enabledIds:o,blocked:s}}function vn(e,t){return t===`modalPanels`?e.layout.modals||[]:e.layout[t]||[]}function yn(e){globalThis.process?.env?.NODE_ENV!==`production`&&console.warn(`[manifest-editor/plugin] ${e}`)}function bn(e,t,n,r){if(!r?.length)return;let i=[];for(let a of r){if(n.has(a.id)){yn(`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 xn(e,t){let n=t.extension,r={config:n.config,preset:n.preset,disableSideEffects:n.disableSideEffects};for(let i of Vt){let a=bn(t,i,new Set(vn(e,i).map(e=>e.id)),n[i]);a&&(r[i]=a)}return r}function Sn(e,t,n){if(!t.length)return e;let r=e,i=new Set;for(let a of t){if(!on(a,e,n))continue;let t=(a.metadata.dependencies||[]).filter(e=>!i.has(e));if(t.length){yn(`Plugin "${a.metadata.id}" was not applied because dependencies are missing or later in the plugin order: ${t.join(`, `)}`);continue}let o=xn(r,a);r=Bt(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:I(e.config||{},...t.filter(e=>i.has(e.metadata.id)).map(e=>e.extension.config||{}),r.config||{}),layout:{...r.layout,leftPanels:[...l,...o],backgroundActions:Ae([],r.layout.backgroundActions||[])}}}function Cn({plugins:e=[],enabled:t=[],disabled:n=[],globalPluginConfig:r}={}){let i=(e=[])=>Array.from(new Set(e.filter(Boolean)));return(0,f.createStore)(a=>({plugins:e,enabled:i(t),disabled:i(n),globalApps:qt(r),apps:{},setProviderState(e){a(t=>({...t,plugins:an(t.plugins,e.plugins||[]),enabled:i(e.enabled||[]),disabled:i(e.disabled||[]),globalApps:qt(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=Kt(t);a(t=>Zt(t.apps[e],n)?t:{...t,apps:{...t.apps,[e]:n}})},setGlobalConfig(e){a(t=>({...t,globalApps:qt(e)}))},setGlobalAppConfig(e,t){let n=Kt(t);a(t=>Zt(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]:Jt(r.globalApps[e],t)}}:{apps:{...r.apps,[e]:Jt(r.apps[e],t)}}}))},disable(e,t,n=`workspace`){a(r=>({...r,...n===`global`?{globalApps:{...r.globalApps,[e]:Yt(r.globalApps[e],t)}}:{apps:{...r.apps,[e]:Yt(r.apps[e],t)}}}))}}))}const wn=(0,u.createContext)(null),Tn=(0,u.createContext)({});function En({plugins:e,enabled:t,disabled:n,globalPluginConfig:r,saveGlobalPluginConfig:i,children:a}){let o=(0,u.useMemo)(()=>rn(e),[e]),s=(0,u.useMemo)(()=>Cn({plugins:o,enabled:t,disabled:n,globalPluginConfig:r}),[]);(0,u.useEffect)(()=>{s.getState().setProviderState({plugins:o,enabled:t,disabled:n,globalPluginConfig:r})},[s,o,t,n,r]);let c=(0,u.useMemo)(()=>({globalPluginConfig:r,saveGlobalPluginConfig:i}),[r,i]);return(0,u.createElement)(Tn.Provider,{value:c},(0,u.createElement)(wn.Provider,{value:s},a))}function Dn(){return(0,u.useContext)(wn)}function On(){let e=Dn();if(!e)throw Error(`usePluginStoreApi must be used within <PluginProvider />`);return e}function kn(e){let t=Dn();return t?(0,f.useStore)(t,e):e(Ut())}function An(){return kn(e=>({plugins:e.plugins,enabled:e.enabled,disabled:e.disabled,globalApps:e.globalApps,apps:e.apps}))}function jn(e){let t=(0,u.useContext)(Bn),n=(0,u.useContext)(zn),r=An(),i=e||t?.appId;return(0,u.useMemo)(()=>un(r,n,i),[r,n,i])}function Mn(){let e=Dn();return(0,u.useMemo)(()=>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 Nn(e){let t=(0,u.useContext)(Bn),n=An(),r=e||t?.appId;return(0,u.useMemo)(()=>gn(n,r),[n,r])}function Pn(e,t){let n=(0,u.useContext)(Bn),r=An(),i=t||n?.appId;return(0,u.useMemo)(()=>hn(r,e,i),[r,e,i])}function Fn(e,t){let n=(0,u.useContext)(Bn),r=Dn(),i=An(),a=z(),o=ie(),{saveGlobalPluginConfig:s}=(0,u.useContext)(Tn),c=t||n?.appId||``,l=i.plugins.find(t=>t.metadata.id===e)||null,d=c?i.globalApps[c]:void 0,f=c?i.apps[c]:void 0,p=(0,u.useMemo)(()=>mn(l||void 0),[l]),m=(0,u.useMemo)(()=>dn(d,e),[d,e]),h=(0,u.useMemo)(()=>dn(f,e),[f,e]),g=(0,u.useMemo)(()=>hn(i,e,c),[i,e,c]),_=(0,u.useCallback)(e=>{c&&(r?.getState().setAppConfig(c,e),o({plugins:{...a.plugins||{},apps:{...a.plugins?.apps||{},[c]:e}}}))},[a.plugins,c,o,r]),v=(0,u.useCallback)(t=>{_(fn(f||{},e,t))},[_,e,f]),y=(0,u.useCallback)(()=>{_(pn(f||{},e))},[_,e,f]),b=(0,u.useCallback)(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]),x=(0,u.useCallback)(async t=>{await b(fn(d||{},e,t))},[d,b,e]),S=(0,u.useCallback)(async()=>{await b(pn(d||{},e))},[d,b,e]);return{plugin:l,appId:c,defaults:p,global:m,workspace:h,effective:g,canSaveGlobal:!!s,setWorkspaceSettings:v,resetWorkspaceSettings:y,setGlobalSettings:x,resetGlobalSettings:S}}function In(e,t){let n=An(),r=Dn(),i=(0,u.useMemo)(()=>un(n,e,t),[n,e,t]);return(0,u.useEffect)(()=>{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,nn(t))}).catch(t=>{r.getState().setPluginLoadError(e.metadata.id,Ln(t))}))},[r,i]),(0,u.useMemo)(()=>Sn(e,i.filter(e=>!e.load||e.loadStatus===`loaded`),t),[e,i,t])}function Ln(e){return e instanceof Error?e.message:typeof e==`string`?e:`Plugin failed to load.`}function Rn({config:e}){let t=(0,u.useContext)(Bn),n=Dn(),r=t?.appId,i=r?e?.plugins?.apps?.[r]:void 0;return(0,u.useEffect)(()=>{!n||!r||n.getState().setAppConfig(r,i||{})},[n,r,i]),null}const zn=(0,u.createContext)(null),Bn=(0,u.createContext)(null),Vn=(0,u.createContext)({state:null,setState:()=>{}});function Hn(){let e=(0,u.useContext)(Bn);return N(e,`Hook useAppInstance must be used inside <AppProvider />`),e}function U(){let e=(0,u.useContext)(zn);return N(e,`Hook useApp must be used inside <AppProvider />`),e}function Un(){return(0,u.useContext)(Vn)}function Wn(e,t){return e.find(e=>e.id===t)||null}function Gn(){let e=U(),{state:t,setState:n}=Un(),r=e.preset?.templates||[],i=typeof t?.presetTemplateId==`string`?t.presetTemplateId:null;return{templates:r,selectedTemplateId:i,selectedTemplate:(0,u.useMemo)(()=>Wn(r,i),[i,r]),setSelectedTemplateId:(0,u.useCallback)(e=>n({presetTemplateId:e}),[n])}}function Kn(e){let[t,n,r]=(0,l.useLocalStorage)(`app-state/${e.appId}/${e.instanceId}`,e.initialState||{}),i=(0,u.useCallback)(e=>{let t=r.current?JSON.parse(r.current||`{}`):{},i=(typeof e==`function`?e(t):e)||{};n({...t,...i})},[]);(0,u.useEffect)(()=>{e.args&&i(e.args)},[e.appId]);let a=(0,u.useMemo)(()=>({state:t||{},setState:i}),[i,t]);return(0,d.jsx)(Vn.Provider,{value:a,children:e.children})}function qn({instanceId:e,appId:t,args:n,definition:r,children:i,initialState:a}){let o=(0,u.useMemo)(()=>({instanceId:e,appId:t,args:n}),[e,t,n]),s=(0,u.useMemo)(()=>a||{},[e]),c=In(r,t);return(0,d.jsx)(ae,{config:c.config||{},children:(0,d.jsx)(zn.Provider,{value:c,children:(0,d.jsx)(Bn.Provider,{value:o,children:(0,d.jsx)(Kn,{instanceId:o.instanceId,appId:o.appId,args:o.args,initialState:s,children:i})})})})}const Jn=(0,u.createContext)(null);function Yn(){let e=(0,u.useContext)(Jn);return N(e,`Hook useApps must be used inside <MultiAppProvider />`),e}function Xn(e,t=!1){let[n,r]=(0,l.useOptionalLocalStorage)(`SelectedApplication`,e||{id:`splash`},!t);return[n,r]}function Zn({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,f]=Xn(t,n),p=e=>{e===`Manifest`&&f({id:c}),e===`Collection`&&f({id:s})},m=(0,u.useMemo)(()=>({currentApp:l||{id:o},initialApp:t||{id:o},apps:e,changeApp:f,changeProjectType:p}),[t,e,l]),h=e[m.currentApp.id];return!l||!h?null:(0,d.jsx)(qn,{appId:l.id,definition:h,instanceId:l.id+r,args:l.args,children:(0,d.jsx)(Jn.Provider,{value:m,children:i})})}const Qn=g.default.div`
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));let l=require("@manifest-editor/components"),u=require("react");u=c(u,1);let d=require("react/jsx-runtime"),f=require("@manifest-editor/i18n"),p=require("zustand"),m=require("@manifest-editor/i18n/core"),h=require("localforage");h=c(h,1);let g=require("react-iiif-vault"),_=require("@iiif/parser"),v=require("@iiif/helpers"),y=require("styled-components");y=c(y,1);let b=require("iiif-browser/notebook"),x=require("@iiif/helpers/vault");x=c(x,1);let S=require("@iiif/helpers/vault/actions"),C=require("@iiif/helpers/vault/utility"),w=require("@tiptap/extension-list"),T=require("iiif-browser/tiptap"),E=require("@tiptap/markdown"),D=require("@tiptap/starter-kit");D=c(D,1);let O=require("immer"),k=require("@manifest-editor/editor-api"),A=require("@react-stately/toast"),j=require("@manifest-editor/creator-api"),M=require("react-error-boundary"),N=require("mitt");N=c(N,1);let P=require("tiny-use-debounce"),F=require("react-transition-group"),ee=require("shallowequal");ee=c(ee,1);let I=require("@atlas-viewer/iiif-image-api"),L=require("@manifest-editor/client-vault");var R=process.env.NODE_ENV===`production`,te=`Invariant failed`;function z(e,t){if(!e){if(R)throw Error(te);var n=typeof t==`function`?t():t,r=n?`${te}: ${n}`:te;throw Error(r)}}function B(e,t){if(!(!e&&!t))return e&&V(e),t&&V(t),{...e,...t,requiredNamespaces:[...new Set([...e?.requiredNamespaces||[],...t?.requiredNamespaces||[]])]}}function ne(e,t){if(!e&&!t)return;let n=(e,t)=>{let r={...e};for(let[e,i]of Object.entries(t||{}))r[e]=i&&typeof i==`object`&&!Array.isArray(i)?n(r[e],i):i;return r};return{...e,...t,config:{...e?.config,...t?.config},catalogs:n(e?.catalogs,t?.catalogs),profiles:n(e?.profiles,t?.profiles),presetProfiles:n(e?.presetProfiles,t?.presetProfiles),host:n(e?.host,t?.host),policies:[...e?.policies||[],...t?.policies||[]],presets:[...e?.presets||[],...t?.presets||[]],registrations:[...e?.registrations||[],...t?.registrations||[]],resourceLoaders:[...new Set([...e?.resourceLoaders||[],...t?.resourceLoaders||[]])],requiredNamespaces:[...new Set([...e?.requiredNamespaces||[],...t?.requiredNamespaces||[]])]}}const re={type:`object`,additionalProperties:!1,properties:{timeZone:{type:`string`,minLength:1},defaultLocale:{type:`string`,minLength:1},fallbackLocale:{type:`string`,minLength:1},defaultProfile:{type:`string`,minLength:1},availableLocales:{type:`array`,minItems:1,items:{type:`string`,minLength:1}},availableProfiles:{type:`array`,minItems:1,items:{type:`string`,minLength:1}},requiredNamespaces:{type:`array`,items:{type:`string`,minLength:1}}}};function V(e){if(!e||typeof e!=`object`||Array.isArray(e))throw TypeError(`uiI18n must be an object`);for(let[t,n]of Object.entries(e)){if(!Object.hasOwn(re.properties,t))throw TypeError(`Unknown uiI18n field: ${t}`);let e=re.properties[t];if(!e)throw TypeError(`Unknown uiI18n field: ${t}`);if(n!==void 0&&(t===`timeZone`&&new Intl.DateTimeFormat(`en-GB`,{timeZone:n}),e.type===`string`?typeof n!=`string`||!n.trim():!Array.isArray(n)||t!==`requiredNamespaces`&&!n.length||n.some(e=>typeof e!=`string`||!e.trim())))throw TypeError(`Invalid uiI18n field: ${t}`)}}const H={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:!0,rememberLeftPanelId:!0},uploadBackends:[],plugins:{apps:{}},export:{baseIdentifier:null,version:3},creators:{"iiif-image-services":{compact:`with-dimensions`,includeSizes:!1,includeTiles:!1}}};function ie(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 ae(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 oe(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 se(...e){let t={};for(let n of e)n&&(t={...t,...n,uiI18n:B(t.uiI18n,n.uiI18n),notebook:t.notebook||n.notebook?{...t.notebook,...n.notebook}:void 0,editorConfig:ie(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:oe(t.creators,n.creators),plugins:ae(t.plugins,n.plugins)});return t}function ce(...e){return se(H,...e)}const le=(0,u.createContext)(H),ue=(0,u.createContext)(()=>{});function U(){return(0,u.useContext)(le)}function de(){return(0,u.useContext)(ue)}function fe({children:e,config:t,saveConfig:n}){let[r,i]=(0,u.useState)(null),a=(0,u.useMemo)(()=>ce(t,r),[t,r]),o=(0,u.useCallback)(e=>{i(t=>se(t,e)),n&&n(e)},[n]);return(0,d.jsx)(ue.Provider,{value:o,children:(0,d.jsx)(le.Provider,{value:a,children:e})})}function pe(e){let t=e=>Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,t.allowEmpty,[...t.placeholders].sort(),[...t.tags].sort()]);return JSON.stringify([t(e.messages),t(e.plurals)])}function me(e,t){if(e===t)return!0;if(e.owner!==t.owner||e.namespace!==t.namespace||e.sourceLocale!==t.sourceLocale)return!1;let n=Object.keys(e.loaders);return n.length===Object.keys(t.loaders).length&&n.every(n=>e.loaders[n]===t.loaders[n])&&pe(e.contract)===pe(t.contract)}function he(...e){let t=[];for(let n of e.flat())t.some(e=>me(e,n))||t.push(n);return t}function ge(e){return e||(0,m.createEditorI18n)()}function _e(e,t,n){return t?n.resolveMessage(t.labelMessage,t.label):n.resolveMessage(e.labelMessage,e.label)}function ve(e,t){return!e||e.status===`idle`?``:e.status===`error`?t.resolveMessage(e.error?.messageReference,e.error?.message)||t.resolveMessage(e.statusTextMessage,e.statusText)||t.translate(`shell`)(`background.error`):e.status===`complete`&&e.resultsAvailable?t.translate(`shell`)(`background.ready`):t.resolveMessage(e.statusTextMessage,e.statusText)||t.translate(`shell`)(`background.${e.status}`)}function W(e,t){return{namespace:`shell`,key:`background.${e}`,defaultValue:t}}const ye=`@manifest-editor/canvas-progress`,be=`status`,xe=new Set([`queued`,`pending`,`done`]);function Se(e){return typeof e==`string`?e:e?.id||null}function Ce(e){return typeof e==`string`&&xe.has(e)?e:`none`}function we(e){return typeof e==`string`&&xe.has(e)}function Te(e,t){let n=Se(t);return n?Ce(e.getResourceMeta(n,ye)?.[be]):`none`}function Ee(e,t){let n=Se(t);return n?Ce(e?.iiif?.meta?.[n]?.[ye]?.[be]):`none`}function De(e,t,n){let r=Se(t);if(!r)return`none`;let i=we(n)?n:void 0;return e.setMetaValue([r,ye,be],i),i||`none`}function Oe(e,t){return De(e,t,`none`)}function ke(e,t,n){let r={};for(let i of t){let t=Se(i);t&&(r[t]=De(e,i,n))}return r}function Ae(e,t){return ke(e,t,`none`)}function je(e){return{getStatus(t){return Te(e,t)},setStatus(t,n){return De(e,t,n)},clearStatus(t){return Oe(e,t)},setStatuses(t,n){return ke(e,t,n)},clearStatuses(t){return Ae(e,t)}}}function Me(e,t=new Set){function n(e){let n=Se(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 Ne(e){let t=Se(e);return(0,g.useVaultSelector)(e=>t?Ee(e,t):`none`,[t])}function Pe(e){let t=(0,g.useVault)(),n=Se(e),r=(0,u.useMemo)(()=>je(t),[t]);return(0,u.useMemo)(()=>({setStatus(e){return r.setStatus(n,e)},clearStatus(){return r.clearStatus(n)},getStatus(){return r.getStatus(n)}}),[r,n])}const Fe={queued:{stripClass:`bg-zinc-400/80`,badgeClass:`bg-zinc-500`,dimOverlay:!0},pending:{stripClass:`bg-amber-400/90 animate-pulse`,badgeClass:`bg-amber-500`},done:{stripClass:`bg-me-primary-500`,badgeClass:`bg-me-primary-500`}};function Ie({className:e}){return(0,d.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,d.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,d.jsx)(`path`,{d:`M12 7v5l2.5 2.5`})]})}function Le({className:e}){return(0,d.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,children:[(0,d.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,stroke:`currentColor`,strokeWidth:`2.5`,strokeOpacity:`0.3`}),(0,d.jsx)(`path`,{d:`M12 3a9 9 0 0 1 9 9`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`})]})}function Re({className:e}){return(0,d.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,d.jsx)(`path`,{d:`M5 12l4 4 8-8`})})}function ze({resource:e,status:t,className:n}){return t?(0,d.jsx)(Ve,{status:t,className:n}):(0,d.jsx)(Be,{resource:e,className:n})}function Be({resource:e,className:t}){let n=Ne(e);return(0,d.jsx)(Ve,{status:n,className:t})}function Ve({status:e,className:t}){let n=(0,f.useTranslations)(`shell`);if(e===`none`)return null;let r=Fe[e];return(0,d.jsxs)(d.Fragment,{children:[r.dimOverlay&&(0,d.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 z-10 bg-white/40`}),(0,d.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-x-0 top-0 z-10 h-[3px] rounded-t-sm ${r.stripClass} ${t||``}`}),(0,d.jsxs)(`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 ${r.badgeClass} shadow-md ring-2 ring-white/70`,title:n(`progress.${e}`),children:[(0,d.jsx)(`span`,{className:`sr-only`,children:n(`progress.${e}`)}),e===`queued`&&(0,d.jsx)(Ie,{className:`h-2.5 w-2.5 text-white`}),e===`pending`&&(0,d.jsx)(Le,{className:`h-2.5 w-2.5 animate-spin text-white`}),e===`done`&&(0,d.jsx)(Re,{className:`h-2.5 w-2.5 text-white`})]})]})}function He(e,t){return`${e}::${t.type}::${t.id}`}function Ue(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 We(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 Ge(e){return e instanceof Error?{message:e.message,stack:e.stack,detail:e}:{message:typeof e==`string`?e:`Background action failed`,messageReference:typeof e==`string`?void 0:W(`failedGeneric`,`Background action failed`),detail:e}}function Ke(e){return e&&typeof e==`object`&&typeof e.message==`string`?{message:e.message,messageReference:e.messageReference,stack:typeof e.stack==`string`?e.stack:void 0,detail:e.detail}:Ge(e)}function qe(e,t){return!e.resourceTypes?.length||e.resourceTypes.includes(t.type)}function Je({definitions:e,instances:t,systemContext:n,targets:r,onSupportsError:i}){let a=We(e),o=[];for(let e of r){let r=[];for(let o of a){if(!qe(o,e))continue;let a=He(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 Ye=0;function Xe(e){return Ye+=1,`${e}-${Date.now()}-${Ye}`}function Ze(e,t,n,r=Date.now(),i){return{id:Xe(`event`),createdAt:r,type:e,message:t,messageReference:i,data:n}}function G(e,t,n,r,i=Date.now(),a=t===`label`?e.labelMessage:t===`status`?e.statusTextMessage:void 0){return{...e,events:[...e.events,Ze(t,n,r,i,a)]}}function Qe(e){return e.filter(e=>String(e.type)!==`progress`)}function $e(e){return{...e,logs:[...e.logs],events:Qe(e.events),progress:e.progress?{...e.progress}:void 0}}function et(e,t,n){if(!at(n.status))return e;let r=e[t]||[],i=$e(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 tt(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:et(e.histories,t,i)}}function nt(e){return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}function rt(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:nt(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,labelMessage:t.labelMessage}}function it(e){return e===`preparing`||e===`running`}function at(e){return e===`complete`||e===`error`||e===`cancelled`}function ot(e){return e===`queued`||e===`running`||e===`complete`||e===`skipped`||e===`error`||e===`cancelled`}function st(e){return!e||e===`queued`||e===`running`}function ct(e){return e===`complete`||e===`skipped`||e===`error`||e===`cancelled`}function lt(e){if(e!==void 0)try{return JSON.parse(JSON.stringify(e))}catch{return}}function ut(e){return e&&{message:e.message,messageReference:e.messageReference,stack:e.stack,detail:lt(e.detail)}}function dt(e){return{...e,error:ut(e.error)||null,result:lt(e.result),logs:e.logs.map(e=>({...e,data:lt(e.data)})),events:Qe(e.events).map(e=>({...e,data:lt(e.data)})),progress:e.progress?{...e.progress}:void 0}}function ft(e){return{...e,status:vt(e.status),input:lt(e.input),result:lt(e.result),error:ut(e.error)||null}}function pt(e){return{version:1,data:lt(e.data),tasks:e.tasks.map(ft)}}function mt(e){return{version:1,savedAt:Date.now(),instances:Object.fromEntries(Object.entries(e.instances).map(([e,t])=>[e,dt(t)])),histories:Object.fromEntries(Object.entries(e.histories).map(([e,t])=>[e,t.map(dt)])),plans:Object.fromEntries(Object.entries(e.plans).map(([e,t])=>[e,pt(t)]))}}function ht(){return{version:1,savedAt:Date.now(),instances:{},histories:{},plans:{}}}function gt(e,t){return{version:1,savedAt:t.savedAt,instances:{...e.instances,...t.instances},histories:{...e.histories,...t.histories},plans:{...e.plans,...t.plans}}}function _t(e){return!Object.keys(e.instances).length&&!Object.keys(e.histories).length&&!Object.keys(e.plans).length}function vt(e){return ot(e)?e:`queued`}function yt(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:vt(e.status),error:e.error?Ke(e.error):null,createdAt:typeof e.createdAt==`number`?e.createdAt:n}}function bt(e){return!e||e.version!==1||!Array.isArray(e.tasks)?null:{version:1,data:e.data,tasks:e.tasks.map(yt)}}function xt(e){return{...e,tasks:e.tasks.map(e=>e.status===`running`?{...e,status:`queued`,statusText:`Queued after reload`,statusTextMessage:{namespace:`shell`,key:`background.requeued`},startedAt:void 0}:e)}}function St(e,t=Date.now()){return{...e,tasks:e.tasks.map(e=>st(e.status)?{...e,status:`cancelled`,statusText:`Cancelled`,statusTextMessage:{namespace:`shell`,key:`background.cancelled`},error:null,completedAt:t}:e)}}function Ct(e){return{...e,error:e.error?Ke(e.error):null,logs:Array.isArray(e.logs)?e.logs:[],events:Qe(Array.isArray(e.events)?e.events:[]),resultsAvailable:e.resultsAvailable===!0}}function wt(e){return!e||e.version!==1?ht():{version:1,savedAt:typeof e.savedAt==`number`?e.savedAt:Date.now(),instances:e.instances||{},histories:e.histories||{},plans:e.plans||{}}}function Tt(e,t,n){let r=e,i=t;if(it(e.status)){if(e.cancelRequestedAt){let t=Date.now();i=i&&St(i,t),r=G({...e,status:`cancelled`,statusText:`Cancelled`,statusTextMessage:{namespace:`shell`,key:`background.cancelled`},completedAt:t,cancelledAt:t},`status`,`Cancelled`,{status:`cancelled`},t,W(`cancelled`,`Cancelled`))}else if(n.resumable&&i)i=xt(i),r=G({...e,status:`running`,statusText:`Resuming`,statusTextMessage:{namespace:`shell`,key:`background.resuming`},completedAt:void 0,cancelledAt:void 0},`status`,`Resuming`,{status:`running`},void 0,W(`resuming`,`Resuming`));else{let t=Date.now();r=G({...e,status:`cancelled`,statusText:`Interrupted by page reload`,statusTextMessage:{namespace:`shell`,key:`background.interrupted`},completedAt:t,cancelledAt:t},`status`,`Interrupted by page reload`,{status:`cancelled`},t,W(`interrupted`,`Interrupted by page reload`))}}return{instance:r,plan:i}}function Et(e,t){let n=wt(e),r=new Map(t.map(e=>[e.id,e])),i={},a={},o={},s=ht();for(let[e,t]of Object.entries(n.histories)){let n=(Array.isArray(t)?t:[]).map(Ct),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=Ct(t),l=bt(n.plans[e]),u=r.get(c.actionId);if(!u){s.instances[e]=dt(c),l&&(s.plans[e]=pt(l));continue}let d=Tt(c,l,u);i[e]=d.instance,a=et(a,e,d.instance),d.plan&&(o[e]=d.plan)}return{instances:i,histories:a,plans:o,deferred:s}}function Dt(e,t,n){let r=e.tasks.length;if(!r)return;let i=e.tasks.filter(e=>ct(e.status)).length;return rt({current:i,total:r,label:t,labelMessage:n})}function Ot(e){return e&&typeof e==`object`&&`taskStatus`in e&&(e.taskStatus===`complete`||e.taskStatus===`skipped`)?{taskStatus:e.taskStatus,result:e.result,statusText:e.statusText,statusTextMessage:e.statusTextMessage}:{taskStatus:`complete`,result:e}}function kt(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 At(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(vt(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||jt(m,p)&&(await Mt(),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}`,v=i.progressLabel?void 0:u.labelMessage||(u.label?void 0:{namespace:`shell`,key:`background.task`,values:{current:g+1,total:d},defaultValue:`Task {{current}}/{{total}}`});u.target?.type===`Canvas`&&n.setStatus(u.target,`pending`),l(u.id,{status:`running`,statusText:_,statusTextMessage:v,error:null,startedAt:Date.now(),completedAt:void 0},!0),r.getState().setActionStatus(a,`running`,_,v),r.getState().setActionProgress(a,{current:s().filter(e=>ct(e.status)).length,total:d,label:_,labelMessage:v});try{let r=await e(u,{index:g,total:d,pendingIndex:c,pendingTotal:f});if(t.aborted)throw Error(`Background action cancelled.`);let i=Ot(r);l(u.id,{status:i.taskStatus,statusText:i.statusText||(i.taskStatus===`skipped`?`Skipped`:`Complete`),statusTextMessage:i.statusTextMessage||(i.statusText?void 0:W(i.taskStatus===`skipped`?`skipped`:`complete`,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||Lt(e))throw l(u.id,{status:`cancelled`,statusText:`Cancelled`,statusTextMessage:{namespace:`shell`,key:`background.cancelled`},error:null,completedAt:Date.now()},!0),e;let n=Ge(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=>ct(e.status)).length,total:d,label:_})}}return s()}return{getAll:s,getPending:()=>c(),update:l,runEach:u}}function jt(e,t){return t!==!1&&(!e||Date.now()-e>=t)}function Mt(){return new Promise(e=>{setTimeout(e,0)})}function Nt(e=[]){let t=null,n=null,r=null,i=ht();return(0,p.createStore)((a,o)=>{function s(e,t){let n=Ue([],t),r=Et(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&&it(e.instances[t].status)))}}async function c(){if(r&&(clearTimeout(r),r=null),!t||!n||!o().hasHydrated)return;let e=gt(i,mt(o()));if(_t(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:Ue([],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=Et(wt(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,Ue(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:Xe(`run`),actionId:t.id,target:n,label:t.label,labelMessage:t.labelMessage,status:`preparing`,statusText:`Preparing`,statusTextMessage:{namespace:`shell`,key:`background.preparing`},error:null,result:void 0,resultsAvailable:!1,logs:[],events:[Ze(`started`,`Preparing`,{status:`preparing`},i,W(`preparing`,`Preparing`))],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=>({...tt(r,e,e=>G({...e,status:`running`,statusText:`Resuming`,statusTextMessage:{namespace:`shell`,key:`background.resuming`},completedAt:void 0,cancelledAt:void 0},`status`,`Resuming`,{status:`running`},n,W(`resuming`,`Resuming`))),controllers:{...r.controllers,[e]:t}})),l(!0)},cancelAction(e){let t=o().controllers[e],n=o().instances[e];if(!n||!it(n.status))return;let r=Date.now();a(t=>{let n=tt(t,e,e=>G(G({...e,status:`cancelled`,statusText:`Cancelled`,statusTextMessage:{namespace:`shell`,key:`background.cancelled`},completedAt:r,cancelledAt:r,cancelRequestedAt:e.cancelRequestedAt||r},`cancel-requested`,`Cancelling`,void 0,r,W(`cancelling`,`Cancelling`)),`status`,`Cancelled`,{status:`cancelled`},r,W(`cancelled`,`Cancelled`))),i=t.plans[e];return{...n,plans:i?{...t.plans,[e]:St(i,r)}:t.plans,controllers:Object.fromEntries(Object.entries(t.controllers).filter(([t])=>t!==e))}}),l(!0),t?.abort()},setActionLabel(e,t,n){let r=Date.now();a(i=>({...tt(i,e,e=>G({...e,label:t,labelMessage:n},`label`,t,{label:t},r))})),l()},setActionStatus(e,t,n,r){let i=Date.now(),o=at(t)?i:void 0;a(a=>({...tt(a,e,e=>G({...e,status:t,statusText:n,statusTextMessage:r,completedAt:o,cancelledAt:t===`cancelled`?i:void 0},`status`,n||t,{status:t},i)),controllers:it(t)?a.controllers:Object.fromEntries(Object.entries(a.controllers).filter(([t])=>t!==e))})),l(at(t))},setActionError(e,t,n,r){let i=Date.now(),o=Ge(t);a(t=>({...tt(t,e,e=>G({...e,status:`error`,statusText:n,statusTextMessage:r,error:o,completedAt:i,cancelledAt:void 0},`error`,n||o.message,o,i)),controllers:Object.fromEntries(Object.entries(t.controllers).filter(([t])=>t!==e))})),l(!0)},appendActionLog(e,t,n=`info`,r,i){let o=Date.now(),s={id:Xe(`log`),createdAt:o,level:n,message:t,messageReference:i,data:r};a(i=>({...tt(i,e,e=>G({...e,logs:[...e.logs,s]},`log`,t,{level:n,data:r},o))})),l()},setActionProgress(e,t){let n=t?rt(t):void 0;a(t=>({...tt(t,e,e=>({...e,progress:n}))}))},setResult(e,t){let n=Date.now();a(r=>({...tt(r,e,e=>G({...e,result:t},`result`,`Result recorded`,void 0,n,W(`resultRecorded`,`Result recorded`)))})),l(!0)},setResultsAvailable(e,t){let n=Date.now();a(r=>({...tt(r,e,e=>G({...e,resultsAvailable:t},`results-available`,t?`Results available`:`Results hidden`,{available:t},n,t?W(`resultsAvailable`,`Results available`):W(`resultsHidden`,`Results hidden`)))})),l(!0)},setActionPlan(e,t){let n=bt(t);n&&(a(t=>({...tt(t,e,e=>({...e,progress:Dt(n,`Queued`,W(`queued`,`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?yt({...e,...n,status:n.status?vt(n.status):e.status,error:n.error?Ke(n.error):n.error===null?null:e.error},0):e),o={...i,tasks:a};return{...tt(r,e,e=>({...e,progress:Dt(o,n.statusText||n.label)})),plans:{...r.plans,[e]:o}}}),l(r)}}})}function Pt(e,t,n){let{store:r,context:i}=e,{instanceKey:a}=i,o=At(e,t,n);return{...i,i18n:ge(i.i18n),canvasProgress:n,instance:r.getState().instances[a],plan:r.getState().plans[a],tasks:o,signal:t,prepareData:e.prepareData,setActionLabel(e,t){r.getState().setActionLabel(a,e,t)},setActionStatus(e,t,n){r.getState().setActionStatus(a,e,t,n)},setActionError(e,t,n){r.getState().setActionError(a,e,t,n)},appendActionLog(e,t,n,i){r.getState().appendActionLog(a,e,t,n,i)},setActionProgress(e){r.getState().setActionProgress(a,e)},setResult(e){r.getState().setResult(a,e)},setResultsAvailable(e){r.getState().setResultsAvailable(a,e)}}}function Ft(e){return!!e&&typeof e==`object`&&e.version===1&&Array.isArray(e.tasks)}async function It(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=Me(n.canvasProgress),d=()=>c.abort();e.signal&&(e.signal.aborted?c.abort():e.signal.addEventListener(`abort`,d,{once:!0})),e.resume&&o&&it(o.status)?t.getState().resumeAction(i,c):t.getState().startAction(i,r,a,c);let f=()=>{let e=t.getState().instances[i];e&&!at(e.status)&&t.getState().setActionStatus(i,`cancelled`,`Cancelled`,W(`cancelled`,`Cancelled`))};try{if(!e.resume&&r.prepare){let n=await r.prepare(Pt(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];Ft(n)&&t.getState().setActionPlan(i,n)}if(l.aborted)return f(),t.getState().instances[i];let n=t.getState().plans[i];n&&kt(u,n),t.getState().setActionStatus(i,`running`,e.resume?`Resuming`:`Running`,W(e.resume?`resuming`:`running`,e.resume?`Resuming`:`Running`));let a=await r.run(Pt(e,l,u));if(l.aborted)return f(),t.getState().instances[i];let o=t.getState().instances[i];a!==void 0&&o&&!at(o.status)&&t.getState().setResult(i,a),o=t.getState().instances[i],o&&it(o.status)&&((a!==void 0||o?.resultsAvailable)&&t.getState().setResultsAvailable(i,!0),t.getState().setActionStatus(i,`complete`,`Complete`,W(`complete`,`Complete`)))}catch(e){l.aborted||Lt(e)?f():t.getState().setActionError(i,e,`Error`,W(`error`,`Error`))}finally{u.clearTrackedStatuses(),e.signal?.removeEventListener(`abort`,d),await t.getState().flushPersistence()}return t.getState().instances[i]}function Lt(e){return e instanceof Error&&(e.name===`AbortError`||e.message.toLowerCase().includes(`aborted`))}function Rt(e){return JSON.stringify([e.appId,e.instanceId,e.rootResource.type,e.rootResource.id])}let zt;function Bt(){if(typeof window>`u`)return null;let e=h.default.createInstance({name:`manifest-editor-background-actions-v1`,storeName:`background-actions`});return{async load(t){return e.getItem(Rt(t))},async save(t,n){await e.setItem(Rt(t),n)},async clear(t){await e.removeItem(Rt(t))}}}function Vt(){return zt===void 0&&(zt=Bt()),zt}const Ht=(0,u.createContext)(null);function Ut({children:e,persistence:t,persistenceKey:n}){let r=q(),i=or(),a=(0,u.useMemo)(()=>Nt(),[]),o=r.layout.backgroundActions||[],s=(0,u.useMemo)(()=>t===!1?null:t||Vt(),[t]),c=(0,u.useMemo)(()=>n||null,[n]);return(0,u.useEffect)(()=>{a.getState().setDefinitions(o)},[a,o]),(0,u.useEffect)(()=>{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]),(0,u.useEffect)(()=>{let e=()=>{a.getState().flushPersistence()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[a]),(0,u.createElement)(Ht.Provider,{value:a},e)}function Wt(){let e=(0,u.useContext)(Ht);if(!e)throw Error(`useBackgroundActionsStore must be used within a BackgroundActionsProvider`);return e}function K(e=e=>e){return(0,p.useStore)(Wt(),e)}function Gt(e){return K(t=>t.instances[e])}function Kt(e){return K(t=>t.histories[e]||[])}async function qt(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 Jt(e,t,n){return`create_${e}_${t}_${(0,_.toRef)(n)?.type||`unknown`}`}function Yt(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 Xt(e){return navigator.clipboard.writeText(typeof e==`string`?e:JSON.stringify(e,null,2))}function Zt(){return`${Math.random().toString(36).substr(2)}-${Date.now().toString(36)}`}function Qt(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:$t(void 0,s.preset)}}function $t(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||{},localisation:ne(e?.localisation,t?.localisation),templateFilter:n,templates:n?r.filter(n):r,preview:i}}function en(e,t,n){return{...e,metadata:t,config:se(e.config||{},n.config||{}),preset:$t(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:Ue(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 tn=[`leftPanels`,`centerPanels`,`rightPanels`,`modalPanels`,`annotations`,`canvasEditors`,`editors`,`creators`,`background`,`backgroundActions`],nn={plugins:[],enabled:[],disabled:[],globalApps:{},apps:{}};function rn(){return nn}function an(e=[]){return Array.from(new Set(e.filter(Boolean)))}function on(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function sn(e={}){return{...e,enabled:an(e.enabled||[]),disabled:an(e.disabled||[]),settings:e.settings?{...e.settings}:void 0}}function cn(e){let t={};for(let[n,r]of Object.entries(e?.apps||{}))t[n]=sn(r);return t}function ln(e={},t){return{...e,enabled:an([...(e.enabled||[]).filter(e=>e!==t),t]),disabled:(e.disabled||[]).filter(e=>e!==t)}}function un(e={},t){return{...e,enabled:(e.enabled||[]).filter(e=>e!==t),disabled:an([...(e.disabled||[]).filter(e=>e!==t),t])}}function dn(e={},t){return{...e,enabled:(e.enabled||[]).filter(e=>e!==t),disabled:(e.disabled||[]).filter(e=>e!==t)}}function fn(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 pn(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 mn(e){return{metadata:e.default,extension:{},settings:e.settings,load:e.load,loadStatus:`idle`}}function hn(e){return!!e&&`metadata`in e&&`extension`in e}function gn(e){return!!e&&`load`in e&&`default`in e}function _n(e){return hn(e)?e:gn(e)?mn(e):pn(e)}function vn(e=[]){return e.map(_n)}function yn(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 bn(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 xn(e,t,n,r){let i=e.metadata.supports;if(!i)return null;if(i.apps?.length){let e=new Set([n,t?.metadata.id].filter(Boolean));if(!i.apps.some(t=>e.has(t)))return r?.app||`This plugin does not support the current app.`}if(i.projectTypes?.length){let e=t?.metadata.projectType;if(!e||!i.projectTypes.includes(e))return r?.project||`This plugin does not support the current project type.`}return null}function Sn(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 Cn(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 wn(e,t,n){let r=[],i=new Set,a=new Set,o=new Set(e.plugins.filter(r=>bn(r,t,n)&&Sn(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 Nn(`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 Nn(`Plugin "${u}" was not enabled because dependency "${r}" is not enabled.`),c.delete(u),a.add(u),!1;if(!bn(e,t,n))return Nn(`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)bn(r,t,n)&&Sn(r,e,n)&&l(r);return r}function Tn(e,t){let n=e?.settings?.[t];return on(n)?n:{}}function En(e={},t,n){return{...e,settings:{...e.settings||{},[t]:n}}}function Dn(e={},t){let n={...e.settings||{}};return delete n[t],{...e,settings:n}}function On(e){return{...e?.settings?.defaults||{}}}function kn(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{...On(r),...Tn(i,t),...Tn(a,t)}}function An(e,t){return{getSettings(n){return kn(e,n,t)}}}function jn(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(!bn(e,r,i)){s.push(`${e.metadata.label} is not compatible`);continue}u(e)}c.delete(t),l=ln(l,t),o.push(t)}}return u(n),s.length?{config:e,enabledIds:[],blocked:s}:{config:l,enabledIds:o,blocked:s}}function Mn(e,t){return t===`modalPanels`?e.layout.modals||[]:e.layout[t]||[]}function Nn(e){globalThis.process?.env?.NODE_ENV!==`production`&&console.warn(`[manifest-editor/plugin] ${e}`)}function Pn(e,t,n,r){if(!r?.length)return;let i=[];for(let a of r){if(n.has(a.id)){Nn(`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 Fn(e,t){let n=t.extension,r={config:n.config,preset:n.preset,disableSideEffects:n.disableSideEffects};for(let i of tn){let a=Pn(t,i,new Set(Mn(e,i).map(e=>e.id)),n[i]);a&&(r[i]=a)}return r}function In(e,t,n){if(!t.length)return e;let r=e,i=new Set;for(let a of t){if(!bn(a,e,n))continue;let t=(a.metadata.dependencies||[]).filter(e=>!i.has(e));if(t.length){Nn(`Plugin "${a.metadata.id}" was not applied because dependencies are missing or later in the plugin order: ${t.join(`, `)}`);continue}let o=Fn(r,a);r=en(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:se(e.config||{},...t.filter(e=>i.has(e.metadata.id)).map(e=>e.extension.config||{}),r.config||{}),layout:{...r.layout,leftPanels:[...l,...o],backgroundActions:Ue([],r.layout.backgroundActions||[])}}}function Ln({plugins:e=[],enabled:t=[],disabled:n=[],globalPluginConfig:r}={}){let i=(e=[])=>Array.from(new Set(e.filter(Boolean)));return(0,p.createStore)(a=>({plugins:e,enabled:i(t),disabled:i(n),globalApps:cn(r),apps:{},setProviderState(e){a(t=>({...t,plugins:yn(t.plugins,e.plugins||[]),enabled:i(e.enabled||[]),disabled:i(e.disabled||[]),globalApps:cn(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,localisation:n.metadata.localisation||t.metadata.localisation?{registrations:he(n.metadata.localisation?.registrations||[],t.metadata.localisation?.registrations||[]),requiredNamespaces:[...new Set([...n.metadata.localisation?.requiredNamespaces||[],...t.metadata.localisation?.requiredNamespaces||[]])]}:void 0},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=sn(t);a(t=>fn(t.apps[e],n)?t:{...t,apps:{...t.apps,[e]:n}})},setGlobalConfig(e){a(t=>({...t,globalApps:cn(e)}))},setGlobalAppConfig(e,t){let n=sn(t);a(t=>fn(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]:ln(r.globalApps[e],t)}}:{apps:{...r.apps,[e]:ln(r.apps[e],t)}}}))},disable(e,t,n=`workspace`){a(r=>({...r,...n===`global`?{globalApps:{...r.globalApps,[e]:un(r.globalApps[e],t)}}:{apps:{...r.apps,[e]:un(r.apps[e],t)}}}))}}))}const Rn=(0,u.createContext)(null),zn=(0,u.createContext)({});function Bn({plugins:e,enabled:t,disabled:n,globalPluginConfig:r,saveGlobalPluginConfig:i,children:a}){let o=(0,u.useMemo)(()=>vn(e),[e]),s=(0,u.useMemo)(()=>Ln({plugins:o,enabled:t,disabled:n,globalPluginConfig:r}),[]);(0,u.useEffect)(()=>{s.getState().setProviderState({plugins:o,enabled:t,disabled:n,globalPluginConfig:r})},[s,o,t,n,r]);let c=(0,u.useMemo)(()=>({globalPluginConfig:r,saveGlobalPluginConfig:i}),[r,i]);return(0,u.createElement)(zn.Provider,{value:c},(0,u.createElement)(Rn.Provider,{value:s},a))}function Vn(){return(0,u.useContext)(Rn)}function Hn(){let e=Vn();if(!e)throw Error(`usePluginStoreApi must be used within <PluginProvider />`);return e}function Un(e){let t=Vn();return t?(0,p.useStore)(t,e):e(rn())}function Wn(){return Un(e=>({plugins:e.plugins,enabled:e.enabled,disabled:e.disabled,globalApps:e.globalApps,apps:e.apps}))}function Gn(e){let t=(0,u.useContext)(ir),n=(0,u.useContext)(rr),r=Wn(),i=e||t?.appId;return(0,u.useMemo)(()=>wn(r,n,i),[r,n,i])}function Kn(){let e=Vn();return(0,u.useMemo)(()=>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 qn(e){let t=(0,u.useContext)(ir),n=Wn(),r=e||t?.appId;return(0,u.useMemo)(()=>An(n,r),[n,r])}function Jn(e,t){let n=(0,u.useContext)(ir),r=Wn(),i=t||n?.appId;return(0,u.useMemo)(()=>kn(r,e,i),[r,e,i])}function Yn(e,t){let n=(0,u.useContext)(ir),r=Vn(),i=Wn(),a=U(),o=de(),{saveGlobalPluginConfig:s}=(0,u.useContext)(zn),c=t||n?.appId||``,l=i.plugins.find(t=>t.metadata.id===e)||null,d=c?i.globalApps[c]:void 0,f=c?i.apps[c]:void 0,p=(0,u.useMemo)(()=>On(l||void 0),[l]),m=(0,u.useMemo)(()=>Tn(d,e),[d,e]),h=(0,u.useMemo)(()=>Tn(f,e),[f,e]),g=(0,u.useMemo)(()=>kn(i,e,c),[i,e,c]),_=(0,u.useCallback)(e=>{c&&(r?.getState().setAppConfig(c,e),o({plugins:{...a.plugins||{},apps:{...a.plugins?.apps||{},[c]:e}}}))},[a.plugins,c,o,r]),v=(0,u.useCallback)(t=>{_(En(f||{},e,t))},[_,e,f]),y=(0,u.useCallback)(()=>{_(Dn(f||{},e))},[_,e,f]),b=(0,u.useCallback)(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]),x=(0,u.useCallback)(async t=>{await b(En(d||{},e,t))},[d,b,e]),S=(0,u.useCallback)(async()=>{await b(Dn(d||{},e))},[d,b,e]);return{plugin:l,appId:c,defaults:p,global:m,workspace:h,effective:g,canSaveGlobal:!!s,setWorkspaceSettings:v,resetWorkspaceSettings:y,setGlobalSettings:x,resetGlobalSettings:S}}function Xn(e,t){let n=Wn(),r=Vn(),i=(0,u.useMemo)(()=>wn(n,e,t),[n,e,t]);return(0,u.useEffect)(()=>{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,_n(t))}).catch(t=>{r.getState().setPluginLoadError(e.metadata.id,Zn(t))}))},[r,i]),(0,u.useMemo)(()=>In(e,i.filter(e=>!e.load||e.loadStatus===`loaded`),t),[e,i,t])}function Zn(e){return e instanceof Error?e.message:typeof e==`string`?e:`Plugin failed to load.`}function Qn({config:e}){let t=(0,u.useContext)(ir),n=Vn(),r=t?.appId,i=r?e?.plugins?.apps?.[r]:void 0;return(0,u.useEffect)(()=>{!n||!r||n.getState().setAppConfig(r,i||{})},[n,r,i]),null}const $n=new WeakMap,er=new WeakMap;function tr(e,t,n,r){let i=e.get(t);i||(i=new Map,e.set(t,i));let a=i.get(n);if(a)return a;let o=Promise.resolve().then(r);return i.set(n,o),o.catch(()=>{i.get(n)===o&&i.delete(n)}),o}function nr(){let e=(0,f.useOptionalEditorI18nInstance)(),{plugins:t}=Wn();return(0,u.useEffect)(()=>{if(!e)return;let n=!0;return(async()=>{for(let r of t){if(!n)return;for(let t of r.metadata.localisation?.registrations||[]){if(!n)return;try{let n=[...$n.get(e)?.keys()||[]].find(e=>me(e,t))||t;await tr($n,e,n,()=>e.register(n))}catch(e){n&&console.error(`Plugin translation registration failed`,r.metadata.id,e)}}if(!n)return;let t=[...new Set(r.metadata.localisation?.requiredNamespaces||[])].sort();for(let i of t){if(!n)return;try{await tr(er,e,i,()=>e.loadNamespaces([i]))}catch(e){n&&console.error(`Plugin translation namespace failed`,r.metadata.id,i,e)}}}})().catch(e=>{n&&console.error(`Plugin translation registration failed`,e)}),()=>{n=!1}},[e,t]),null}const rr=(0,u.createContext)(null),ir=(0,u.createContext)(null),ar=(0,u.createContext)({state:null,setState:()=>{}});function or(){let e=(0,u.useContext)(ir);return z(e,`Hook useAppInstance must be used inside <AppProvider />`),e}function q(){let e=(0,u.useContext)(rr);return z(e,`Hook useApp must be used inside <AppProvider />`),e}function sr(){return(0,u.useContext)(ar)}function cr(e,t){return e.find(e=>e.id===t)||null}function lr(){let e=q(),{state:t,setState:n}=sr(),r=e.preset?.templates||[],i=typeof t?.presetTemplateId==`string`?t.presetTemplateId:null;return{templates:r,selectedTemplateId:i,selectedTemplate:(0,u.useMemo)(()=>cr(r,i),[i,r]),setSelectedTemplateId:(0,u.useCallback)(e=>n({presetTemplateId:e}),[n])}}function ur(e){let[t,n,r]=(0,l.useLocalStorage)(`app-state/${e.appId}/${e.instanceId}`,e.initialState||{}),i=(0,u.useCallback)(e=>{let t=r.current?JSON.parse(r.current||`{}`):{},i=(typeof e==`function`?e(t):e)||{};n({...t,...i})},[]);(0,u.useEffect)(()=>{e.args&&i(e.args)},[e.appId]);let a=(0,u.useMemo)(()=>({state:t||{},setState:i}),[i,t]);return(0,d.jsx)(ar.Provider,{value:a,children:e.children})}function dr({instanceId:e,appId:t,args:n,definition:r,children:i,initialState:a}){let o=(0,u.useMemo)(()=>({instanceId:e,appId:t,args:n}),[e,t,n]),s=(0,u.useMemo)(()=>a||{},[e]),c=Xn(r,t);return(0,d.jsx)(fe,{config:c.config||{},children:(0,d.jsx)(rr.Provider,{value:c,children:(0,d.jsx)(ir.Provider,{value:o,children:(0,d.jsx)(ur,{instanceId:o.instanceId,appId:o.appId,args:o.args,initialState:s,children:i})})})})}const fr=(0,u.createContext)(null);function pr(){let e=(0,u.useContext)(fr);return z(e,`Hook useApps must be used inside <MultiAppProvider />`),e}function mr(e,t=!1){let[n,r]=(0,l.useOptionalLocalStorage)(`SelectedApplication`,e||{id:`splash`},!t);return[n,r]}function hr({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,f]=mr(t,n),p=e=>{e===`Manifest`&&f({id:c}),e===`Collection`&&f({id:s})},m=(0,u.useMemo)(()=>({currentApp:l||{id:o},initialApp:t||{id:o},apps:e,changeApp:f,changeProjectType:p}),[t,e,l]),h=e[m.currentApp.id];return!l||!h?null:(0,d.jsx)(dr,{appId:l.id,definition:h,instanceId:l.id+r,args:l.args,children:(0,d.jsx)(fr.Provider,{value:m,children:i})})}const gr=(0,u.createContext)(null),_r=(0,u.createContext)(null);function vr(){let e=(0,u.useContext)(_r),t=(0,u.useContext)(gr),n=e||t?.id;return z(n,`useResourceInstance can only be called from inside <ResourceProvider />`),n}function J(){let e=(0,u.useContext)(gr);return z(e,`useResource can only be called from inside <ResourceProvider />`),e}function yr({id:e,children:t}){return e?(0,d.jsx)(_r.Provider,{value:e,children:t}):t}function br({resource:e,children:t}){let n=(0,g.useExistingVault)(),r=t;return e&&e.type===`Manifest`&&(r=(0,d.jsx)(g.VaultProvider,{vault:n||void 0,children:(0,d.jsx)(g.ManifestContext,{manifest:e.id||``,children:t})})),e&&e.type===`Collection`&&(r=(0,d.jsx)(g.VaultProvider,{vault:n||void 0,children:(0,d.jsx)(g.CollectionContext,{collection:e.id||``,children:t})})),(0,d.jsx)(gr.Provider,{value:e,children:r})}const xr=(0,u.createContext)(null),Sr=(0,u.createContext)(null),Cr=(0,u.createContext)(`default`);function wr(){return(0,u.useContext)(Sr)}function Tr(){return(0,u.useContext)(xr)}function Er(){return(0,u.useContext)(Cr)}function Dr(){return q().layout}function Or(){let e=q(),t=e.layout,n=(0,u.useContext)(xr),r=(0,u.useContext)(Sr);return(0,u.useMemo)(()=>({actions:n,state:r,...t}),[e,r])}function kr(e=`vault://homepage-collection.json`){let t=new x.Vault,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((0,S.requestResource)({id:i.id}));let e=(0,C.actionListFromResource)(i.id,i);t.dispatch((0,S.batchActions)({actions:e})),r=!0}}catch{}if(!r){let n=(0,C.actionListFromResource)(e,{"@context":`http://iiif.io/api/presentation/3/context.json`,id:e,type:`Collection`,label:{en:[`Recent items`]},items:[]});t.dispatch((0,S.requestResource)({id:e})),t.dispatch((0,S.batchActions)({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((0,S.addReference)({id:e,type:`Collection`,reference:{id:n,type:r},key:`items`,index:0})):t.dispatch((0,S.reorderEntityField)({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((0,S.modifyEntityField)({id:e,type:`Collection`,key:`items`,value:[]})),window.localStorage.setItem(`preview-vault-collection`,JSON.stringify(t.toPresentation3({id:e,type:`Collection`})))}}}function Ar(){return(0,u.useContext)(jr)}const jr=(0,u.createContext)(new x.Vault),Mr=(0,u.createContext)({addHistory:(e,t)=>{},clearHistory:()=>{}}),Nr=`manifest-editor://homepage-collection.json`;function Pr(){return(0,u.useContext)(Mr)}function Fr(e){let{vault:t,unsubscribe:n,addHistory:r,clearHistory:i}=(0,u.useMemo)(()=>kr(Nr),[]);return(0,u.useEffect)(()=>n,[]),(0,d.jsx)(Mr.Provider,{value:{addHistory:r,clearHistory:i},children:(0,d.jsx)(jr.Provider,{value:t,children:e.children})})}function Ir({children:e}){let t=Ar();return(0,d.jsx)(g.VaultProvider,{vault:t,children:e})}const Lr=new Map;function Rr(e){if(typeof window>`u`)return(0,b.createNotebook)({storageKey:!1});let t=Lr.get(e);return t||(t=(0,b.createNotebook)({storageKey:`manifest-editor:notebook:${e}`}),Lr.set(e,t)),t}function zr(e){return new E.MarkdownManager({extensions:[D.default,w.TaskList,w.TaskItem.configure({nested:!0}),T.IIIFImage.extend({markdownTokenName:`image`,parseMarkdown:(e,t)=>t.createNode(`iiifImage`,{src:e.href,alt:e.text||``})})]}).parse(e)}function Br(e,t,n){let r=e.getState().notes,i=new Date().toISOString(),a=(n.initialNotes||[]).filter(e=>!r.some(n=>n.id===e.id&&n.projectId===t)).map(e=>({id:e.id,title:e.title,projectId:t,content:e.content??(n.parseMarkdown??zr)(e.markdown??``),createdAt:i,updatedAt:i}));a.length&&e.setState({notes:[...r,...a]})}function Vr(e){if(e.type!==`ImageService`)return e.source||e.id;if(e.infoUrl)return e.infoUrl;let t=new URL(e.id);return t.pathname=`${t.pathname.replace(/\/info\.json$|\/$/g,``)}/info.json`,t.toString()}function Hr(e,t){let n=new Map;for(let r of e.filter(e=>e.projectId===t)){for(let e of(0,b.noteResources)(r.content)){let t=Vr(e);n.has(t)||n.set(t,{url:t,label:e.label,thumbnail:e.thumbnail,noteTitle:r.title})}let e=t=>{for(let e of t.marks??[]){let i=e.type===`link`?e.attrs?.href:void 0;typeof i==`string`&&/^https?:\/\//.test(i)&&!n.has(i)&&n.set(i,{url:i,label:t.text||i,noteTitle:r.title})}t.content?.forEach(e)};e(r.content)}return[...n.values()]}function Ur(e,t,n,r){let i=e.getState(),a=i.notes.filter(e=>e.projectId===t).sort((e,t)=>e.createdAt.localeCompare(t.createdAt)||e.id.localeCompare(t.id)),o=a.find(e=>e.id===r)??a[0]??i.createNote(t,n);return o.title!==n&&i.updateNote(o.id,{title:n}),o.id}const Wr=`@manifest-editor/notebook`;function Gr({className:e=``}){return(0,d.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:e,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,d.jsx)(`path`,{fill:`currentColor`,d:`M6 15.325q.35-.175.725-.25T7.5 15H8V4h-.5q-.625 0-1.062.438T6 5.5zM10 15h8V4h-8zm-4 .325V4zM7.5 22q-1.45 0-2.475-1.025T4 18.5v-13q0-1.45 1.025-2.475T7.5 2H18q.825 0 1.413.587T20 4v12.525q0 .2-.162.363t-.588.362q-.35.175-.55.5t-.2.75t.2.763t.55.487t.55.413t.2.562v.25q0 .425-.288.725T19 22zm0-2h9.325q-.15-.35-.237-.712T16.5 18.5q0-.4.075-.775t.25-.725H7.5q-.65 0-1.075.438T6 18.5q0 .65.425 1.075T7.5 20`})})}function Kr(){let e=vr(),t=U().notebook,n=t?.projectId??e;return{notebook:(0,u.useMemo)(()=>Rr(n),[n]),projectId:n,enabled:!!t?.enabled}}function qr(){let{notebook:e,projectId:t,enabled:n}=Kr(),r=U().notebook;return(0,u.useEffect)(()=>{if(!n||!r)return;let i=e.subscribe((e,n)=>{e.notes!==n.notes&&r.onChange?.(e.notes,t)});return Br(e,t,r),i},[e,t,r,n]),null}function Jr(){let{notebook:e,projectId:t,enabled:n}=Kr();return(0,u.useMemo)(()=>n?[(0,b.notebookPlugin)({notebook:e,projectId:t})]:[],[e,t,n])}function Yr(){return U().notebook?.enabled?(0,d.jsx)(`div`,{className:`flex justify-end p-2`,children:(0,d.jsx)(Xr,{})}):null}function Xr(){let e=(0,f.useTranslations)(`shell`),t=U(),n=Tr(),r=wr();if(!t.notebook?.enabled)return null;let i=r.leftPanel.current===`@manifest-editor/notebook`&&r.leftPanel.open;return(0,d.jsx)(l.BackgroundActionMenuButton,{title:e(`notebook.hint`),"aria-label":e(`notebook.title`),"aria-expanded":i,active:i,onClick:()=>i?n.leftPanel.close():n.leftPanel.open({id:Wr}),children:(0,d.jsx)(Gr,{})})}const Zr=(0,y.default)(b.IIIFNotebook)`
|
|
2
|
+
font-family: inherit;
|
|
3
|
+
.iiif-notebook__sidebar,
|
|
4
|
+
.iiif-notebook__resize,
|
|
5
|
+
.iiif-notebook__title-row {
|
|
6
|
+
display: none;
|
|
7
|
+
}
|
|
8
|
+
.iiif-notebook__main {
|
|
9
|
+
padding: 0 16px;
|
|
10
|
+
}
|
|
11
|
+
.iiif-notebook__toolbar {
|
|
12
|
+
padding: 6px 0;
|
|
13
|
+
}
|
|
14
|
+
.iiif-notebook__prose {
|
|
15
|
+
font-size: 14px;
|
|
16
|
+
line-height: 1.65;
|
|
17
|
+
padding-bottom: 40px;
|
|
18
|
+
}
|
|
19
|
+
`;function Qr(){let e=(0,f.useTranslations)(`shell`),{notebook:t,projectId:n}=Kr(),r=U().notebook,i=(0,g.useManifest)(),a=(0,v.getValue)(i?.label),o=a||e(`notebook.untitled`),s=Ar(),[c,p]=(0,u.useState)(),{create:m}=Tr(),h=(0,u.useCallback)(e=>{if(!i)return;let t=Vr(e),n=e.type===`ImageService`?{...e,id:t}:e;m({type:`Canvas`,isPainting:!0,parent:{id:i.id,type:`Manifest`},property:`items`,initialCreator:r?.browserCreatorId??`@manifest-editor/iiif-browser-creator`,initialData:{url:t,iiifBrowserOptions:{history:(0,b.notebookResourceHistory)(n)}}})},[m,i,r?.browserCreatorId]);return(0,u.useEffect)(()=>{p(Ur(t,n,a||`Untitled manifest`,r?.initialNotes?.[0]?.id)),t.getState().setWorkspaceView(n,{sidebarCollapsed:!0})},[t,n,a,r?.initialNotes]),(0,d.jsx)(Ir,{children:(0,d.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[(0,d.jsxs)(`div`,{className:`border-b border-gray-100 px-4 py-4`,children:[(0,d.jsx)(`h2`,{className:`m-0 text-base font-medium leading-snug text-gray-800`,children:o}),(0,d.jsx)(`p`,{className:`mb-0 mt-1 text-xs leading-relaxed text-gray-500`,children:e(`notebook.description`)})]}),(0,d.jsx)(`div`,{className:`min-h-0 flex-1`,children:c?(0,d.jsx)(l.IIIFBrowserI18nProvider,{children:(0,d.jsx)(Zr,{notebook:t,projectId:n,noteId:c,height:`100%`,defaultSidebarCollapsed:!0,className:`manifest-project-notebook`,browserProps:{vault:s},onOpenResource:h})}):null})]})})}function $r(e){try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}}function ei({onSelect:e,isDisabled:t,onOpenNotebook:n}){let r=(0,f.useTranslations)(`shell`),{notebook:i,projectId:a,enabled:o}=Kr(),s=(0,p.useStore)(i,e=>e.notes),c=(0,u.useMemo)(()=>Hr(s,a),[s,a]);return!o||!c.length?null:(0,d.jsxs)(`section`,{"aria-label":r(`notebook.saved`),className:`mt-4`,children:[(0,d.jsx)(`h3`,{className:`mb-1 text-xs font-medium text-gray-500`,children:r(`notebook.saved`)}),(0,d.jsxs)(`div`,{className:`flex flex-col`,children:[c.length>4&&n?(0,d.jsxs)(`button`,{type:`button`,disabled:t,onClick:n,className:`flex w-full items-center gap-3 rounded-md px-2 py-1.5 text-left text-sm text-me-primary-500 hover:bg-gray-50 focus-visible:outline focus-visible:outline-2 focus-visible:outline-me-primary-500 disabled:opacity-50`,children:[(0,d.jsx)(`span`,{className:`flex h-8 w-8 shrink-0 items-center justify-center`,children:(0,d.jsx)(l.IIIFBrowserIcon,{className:`h-5 w-5`})}),r(`notebook.viewAll`,{count:c.length})]}):null,c.slice(0,4).map(n=>(0,d.jsxs)(`button`,{type:`button`,disabled:t,title:n.url,className:`flex w-full items-center gap-3 rounded-md px-2 py-1.5 text-left hover:bg-gray-50 focus-visible:outline focus-visible:outline-2 focus-visible:outline-me-primary-500 disabled:opacity-50`,onClick:()=>e(n.url),children:[n.thumbnail?(0,d.jsx)(`img`,{src:n.thumbnail,alt:``,loading:`lazy`,className:`h-8 w-8 shrink-0 rounded object-cover`}):(0,d.jsx)(`span`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded bg-gray-50 text-gray-400`,children:(0,d.jsx)(Gr,{className:`h-4 w-4`})}),(0,d.jsxs)(`span`,{className:`min-w-0`,children:[(0,d.jsx)(`span`,{className:`block truncate text-sm text-gray-700`,children:n.label}),(0,d.jsxs)(`span`,{className:`block truncate text-xs text-gray-400`,children:[$r(n.url),n.noteTitle?` · ${n.noteTitle}`:``]})]})]},n.url))]})]})}const ti=y.default.div`
|
|
2
20
|
display: flex;
|
|
3
21
|
align-items: center;
|
|
4
22
|
height: 3em;
|
|
5
23
|
padding: 0.5em;
|
|
6
|
-
|
|
24
|
+
`,ni=y.default.div`
|
|
7
25
|
display: flex;
|
|
8
26
|
padding: 0.25em;
|
|
9
27
|
flex-direction: column;
|
|
10
|
-
`;
|
|
28
|
+
`;y.default.button`
|
|
11
29
|
height: 1.75em;
|
|
12
30
|
width: 1.75em;
|
|
13
31
|
background: #e9e9e9;
|
|
@@ -26,9 +44,9 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
26
44
|
fill: #fff;
|
|
27
45
|
}
|
|
28
46
|
}
|
|
29
|
-
`,
|
|
47
|
+
`,y.default.div`
|
|
30
48
|
flex: 1;
|
|
31
|
-
`;const
|
|
49
|
+
`;const ri=y.default.div`
|
|
32
50
|
color: #6e6e6e;
|
|
33
51
|
display: flex;
|
|
34
52
|
align-items: center;
|
|
@@ -39,7 +57,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
39
57
|
user-select: none;
|
|
40
58
|
cursor: pointer;
|
|
41
59
|
margin-right: 0.5em;
|
|
42
|
-
`;
|
|
60
|
+
`;y.default.div`
|
|
43
61
|
margin: 0 auto;
|
|
44
62
|
padding: 3px;
|
|
45
63
|
background: #f4f4f4;
|
|
@@ -52,7 +70,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
52
70
|
@media (max-width: 450px) {
|
|
53
71
|
display: none;
|
|
54
72
|
}
|
|
55
|
-
`,
|
|
73
|
+
`,y.default.button`
|
|
56
74
|
background: #e7fff4;
|
|
57
75
|
border: 1px solid #c5e3cd;
|
|
58
76
|
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.06);
|
|
@@ -60,7 +78,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
60
78
|
color: #666666;
|
|
61
79
|
padding: 0.35em 0.7em;
|
|
62
80
|
letter-spacing: -0.42px;
|
|
63
|
-
`;const tr=({height:e=16})=>(0,d.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:e,viewBox:`0 0 24 24`,width:`24px`,fill:`currentColor`,children:[(0,d.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,d.jsx)(`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`})]}),nr=({rotate:e=0,...t})=>(0,d.jsx)(`svg`,{version:`1.2`,xmlns:`http://www.w3.org/2000/svg`,overflow:`visible`,preserveAspectRatio:`none`,viewBox:`0 0 24 24`,width:`1em`,height:`1em`,style:{fill:`rgba(0, 0, 0, 0.6)`,transform:`rotate(${e}deg)`,transition:`transform 0.2s`},...t,children:(0,d.jsx)(`path`,{d:`M8.12 9.29 12 13.17l3.88-3.88a.996.996 0 1 1 1.41 1.41l-4.59 4.59a.996.996 0 0 1-1.41 0L6.7 10.7a.996.996 0 0 1 0-1.41c.39-.38 1.03-.39 1.42 0z`,fill:`currentColor`})});var rr=c(o((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=require("react");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 ir=typeof rr.default==`object`&&rr.default!==null&&`default`in rr.default?rr.default.default:rr.default,ar=(0,u.createContext)(null),or=(0,u.createContext)(null);function sr(){let e=(0,u.useContext)(or),t=(0,u.useContext)(ar),n=e||t?.id;return N(n,`useResourceInstance can only be called from inside <ResourceProvider />`),n}function W(){let e=(0,u.useContext)(ar);return N(e,`useResource can only be called from inside <ResourceProvider />`),e}function cr({id:e,children:t}){return e?(0,d.jsx)(or.Provider,{value:e,children:t}):t}function lr({resource:e,children:t}){let n=(0,m.useExistingVault)(),r=t;return e&&e.type===`Manifest`&&(r=(0,d.jsx)(m.VaultProvider,{vault:n||void 0,children:(0,d.jsx)(m.ManifestContext,{manifest:e.id||``,children:t})})),e&&e.type===`Collection`&&(r=(0,d.jsx)(m.VaultProvider,{vault:n||void 0,children:(0,d.jsx)(m.CollectionContext,{collection:e.id||``,children:t})})),(0,d.jsx)(ar.Provider,{value:e,children:r})}function ur(e){"@babel/helpers - typeof";return ur=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},ur(e)}function dr(e,t){if(ur(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(ur(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function fr(e){var t=dr(e,`string`);return ur(t)==`symbol`?t:t+``}function G(e,t,n){return(t=fr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var pr=class{constructor({id:e,config:t,label:n}){G(this,`id`,void 0),G(this,`label`,void 0),G(this,`type`,`external-manifest-preview`),G(this,`focusable`,!0),G(this,`serviceUrl`,void 0),G(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])}},mr=class{constructor({id:e,config:t,label:n}){G(this,`id`,void 0),G(this,`label`,void 0),G(this,`type`,`iiif-preview-service`),G(this,`focusable`,!1),G(this,`serviceUrl`,void 0),G(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)});N(i.ok,`Unknown error creating preview`);let a=await i.json();return N(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)});N(o.ok,`Unknown error updating preview`);let s=await o.json();N(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 hr(e,t,n,r,i){let a=W(),o=sr(),s=(0,m.useVault)(),c=(0,u.useMemo)(()=>({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,d]=(0,u.useMemo)(()=>{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 f(){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 p(e){l[e]&&o&&(t({type:`selectPreview`,payload:e}),await v(e))}async function h(){let e=d.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 g(e){let n=l[e];n&&o&&(c.removePreview(e),n.deletePreview(o).then(()=>{t({type:`deletePreview`,payload:e})}))}async function _(e){let n=l[e];l[e]&&o&&n&&(await n.focus(o),t({type:`focusPreview`,payload:e}))}async function v(n){let i=l[n];if(i&&o){let u=r.find(e=>e.id===n);if(!u||!i.isPreviewValid(o,u)){let n={},u=i.getRequires();for(let i of u){let u=d[i],f=u?l[u]:null;N(f,`Missing handler for Preview requirement "${i}"`),r.find(e=>e.id===u),e.active.find(e=>e===u);{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(0,u.useMemo)(()=>({selectPreview:p,deletePreview:g,focusPreview:_,activatePreview:v,updatePreviews:f,getPreviewLink:h}),[l,o,s,e.selected,e.active,r])}function gr(e){return(0,u.useMemo)(()=>{let t=[];for(let n of e)switch(n.type){case`iiif-preview-service`:t.push(new mr(n));break;case`external-manifest-preview`:t.push(new pr(n))}return t},[])}const _r=(0,_.produce)(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 vr(){return{active:[],selected:null}}const yr=(0,u.createContext)(null),br=(0,u.createContext)([]),xr=(0,u.memo)(function({children:e,configs:t=[]}){let n=sr(),r=gr(t),[i,a]=(0,l.useLocalStorage)(`preview-${n}`,[]),[o,s]=(0,u.useReducer)(_r,void 0,vr),c=hr(o,s,r,i,a),f=(0,u.useMemo)(()=>({configs:t,actions:c,handlers:r,...o}),[c,t,r,o]);return(0,u.useEffect)(()=>{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]),(0,d.jsx)(br.Provider,{value:i,children:(0,d.jsx)(yr.Provider,{value:f,children:e})})});function Sr(){return(0,u.useContext)(br)}function Cr(){let e=(0,u.useContext)(yr);return N(e,`usePreviewContext() can only be called from inside <PreviewProvider />`),e}const wr=g.default.button`
|
|
81
|
+
`;const ii=({height:e=16})=>(0,d.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:e,viewBox:`0 0 24 24`,width:`24px`,fill:`currentColor`,children:[(0,d.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,d.jsx)(`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`})]}),ai=({rotate:e=0,...t})=>(0,d.jsx)(`svg`,{version:`1.2`,xmlns:`http://www.w3.org/2000/svg`,overflow:`visible`,preserveAspectRatio:`none`,viewBox:`0 0 24 24`,width:`1em`,height:`1em`,style:{fill:`rgba(0, 0, 0, 0.6)`,transform:`rotate(${e}deg)`,transition:`transform 0.2s`},...t,children:(0,d.jsx)(`path`,{d:`M8.12 9.29 12 13.17l3.88-3.88a.996.996 0 1 1 1.41 1.41l-4.59 4.59a.996.996 0 0 1-1.41 0L6.7 10.7a.996.996 0 0 1 0-1.41c.39-.38 1.03-.39 1.42 0z`,fill:`currentColor`})}),oi=c(o((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=require("react");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).default,si=typeof oi==`object`&&oi&&`default`in oi?oi.default:oi;function ci(e){"@babel/helpers - typeof";return ci=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},ci(e)}function li(e,t){if(ci(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(ci(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ui(e){var t=li(e,`string`);return ci(t)==`symbol`?t:t+``}function Y(e,t,n){return(t=ui(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var di=class{constructor({id:e,config:t,label:n,labelMessage:r}){Y(this,`id`,void 0),Y(this,`label`,void 0),Y(this,`labelMessage`,void 0),Y(this,`type`,`external-manifest-preview`),Y(this,`focusable`,!0),Y(this,`serviceUrl`,void 0),Y(this,`windows`,{}),this.id=e,this.label=n,this.labelMessage=r,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,labelMessage:r}){Y(this,`id`,void 0),Y(this,`label`,void 0),Y(this,`labelMessage`,void 0),Y(this,`type`,`iiif-preview-service`),Y(this,`focusable`,!1),Y(this,`serviceUrl`,void 0),Y(this,`cache`,{}),this.id=e,this.label=n,this.labelMessage=r,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)});z(i.ok,`Unknown error creating preview`);let a=await i.json();return z(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)});z(o.ok,`Unknown error updating preview`);let s=await o.json();z(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 pi(e,t,n,r,i){let a=J(),o=vr(),s=(0,g.useVault)(),c=(0,u.useMemo)(()=>({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,d]=(0,u.useMemo)(()=>{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 f(){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 p(e){l[e]&&o&&(t({type:`selectPreview`,payload:e}),await v(e))}async function m(){let e=d.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 h(e){let n=l[e];n&&o&&(c.removePreview(e),n.deletePreview(o).then(()=>{t({type:`deletePreview`,payload:e})}))}async function _(e){let n=l[e];l[e]&&o&&n&&(await n.focus(o),t({type:`focusPreview`,payload:e}))}async function v(n){let i=l[n];if(i&&o){let u=r.find(e=>e.id===n);if(!u||!i.isPreviewValid(o,u)){let n={},u=i.getRequires();for(let i of u){let u=d[i],f=u?l[u]:null;z(f,`Missing handler for Preview requirement "${i}"`),r.find(e=>e.id===u),e.active.find(e=>e===u);{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(0,u.useMemo)(()=>({selectPreview:p,deletePreview:h,focusPreview:_,activatePreview:v,updatePreviews:f,getPreviewLink:m}),[l,o,s,e.selected,e.active,r])}function mi(e){return(0,u.useMemo)(()=>{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 di(n))}return t},[])}const hi=(0,O.produce)(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 gi(){return{active:[],selected:null}}const _i=(0,u.createContext)(null),vi=(0,u.createContext)([]),yi=(0,u.memo)(function({children:e,configs:t=[]}){let n=vr(),r=mi(t),[i,a]=(0,l.useLocalStorage)(`preview-${n}`,[]),[o,s]=(0,u.useReducer)(hi,void 0,gi),c=pi(o,s,r,i,a),f=(0,u.useMemo)(()=>({configs:t,actions:c,handlers:r,...o}),[c,t,r,o]);return(0,u.useEffect)(()=>{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]),(0,d.jsx)(vi.Provider,{value:i,children:(0,d.jsx)(_i.Provider,{value:f,children:e})})});function bi(){return(0,u.useContext)(vi)}function xi(){let e=(0,u.useContext)(_i);return z(e,`usePreviewContext() can only be called from inside <PreviewProvider />`),e}const Si=y.default.button`
|
|
64
82
|
border: none;
|
|
65
83
|
outline: none;
|
|
66
84
|
background-color: transparent;
|
|
@@ -72,7 +90,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
72
90
|
&:hover {
|
|
73
91
|
color: inherit;
|
|
74
92
|
}
|
|
75
|
-
`,
|
|
93
|
+
`,X=y.default.button`
|
|
76
94
|
padding: 0.5rem 1rem;
|
|
77
95
|
color: ${e=>e.theme.color.main||`none`};
|
|
78
96
|
background-color: ${e=>e.theme.color.white||`white`};
|
|
@@ -90,11 +108,11 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
90
108
|
&:hover {
|
|
91
109
|
background: #eee;
|
|
92
110
|
}
|
|
93
|
-
`;(0,
|
|
111
|
+
`;(0,y.default)(X)`
|
|
94
112
|
padding: 0.25em ${e=>e.theme.padding.xs||`0.4em`};
|
|
95
113
|
height: unset;
|
|
96
114
|
background: none;
|
|
97
|
-
`,(0,
|
|
115
|
+
`,(0,y.default)(X)`
|
|
98
116
|
{
|
|
99
117
|
padding: 0 ${e=>e.theme.padding.medium||`1rem`};
|
|
100
118
|
color: ${e=>e.theme.color.main||`#B84C74;`};
|
|
@@ -113,7 +131,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
113
131
|
cursor: not-allowed;
|
|
114
132
|
}
|
|
115
133
|
}
|
|
116
|
-
`;const
|
|
134
|
+
`;const Ci=(0,y.default)(X)`
|
|
117
135
|
padding: 0 ${e=>e.theme.padding.medium||`1rem`};
|
|
118
136
|
color: ${e=>e.theme.color.white||`white`};
|
|
119
137
|
background-color: ${e=>e.theme.color.main||`#B84C74;`};
|
|
@@ -126,17 +144,17 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
126
144
|
&:hover {
|
|
127
145
|
background-color: ${e=>e.theme.color.mainHover||`#B84C74;`};
|
|
128
146
|
}
|
|
129
|
-
`;
|
|
147
|
+
`;y.default.div`
|
|
130
148
|
display: flex;
|
|
131
149
|
flex-direction: row;
|
|
132
150
|
flex-wrap: wrap;
|
|
133
151
|
align-items: flex-start;
|
|
134
152
|
justify-content: ${e=>e.$right?`flex-end`:`flex-start`};
|
|
135
|
-
`;const
|
|
153
|
+
`;const wi=y.default.div.attrs({"data-preview-button":!0})`
|
|
136
154
|
display: flex;
|
|
137
155
|
position: relative;
|
|
138
156
|
width: 10em;
|
|
139
|
-
`,
|
|
157
|
+
`,Ti=(0,y.default)(Si)`
|
|
140
158
|
flex: 1;
|
|
141
159
|
padding: 0.5em 0.8em;
|
|
142
160
|
background: #b84c74;
|
|
@@ -157,7 +175,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
157
175
|
background: #892c4e;
|
|
158
176
|
box-shadow: inset 0 2px 8px 0 rgba(0, 0, 0, 0.15);
|
|
159
177
|
}
|
|
160
|
-
`,
|
|
178
|
+
`,Ei=(0,y.default)(Si)`
|
|
161
179
|
background: #b84c74;
|
|
162
180
|
border-top-right-radius: 5px;
|
|
163
181
|
border-bottom-right-radius: 5px;
|
|
@@ -178,11 +196,11 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
178
196
|
box-shadow: inset 0 2px 8px 0 rgba(0, 0, 0, 0.15);
|
|
179
197
|
}
|
|
180
198
|
|
|
181
|
-
${e=>e.$open&&
|
|
199
|
+
${e=>e.$open&&y.css`
|
|
182
200
|
background: #892c4e;
|
|
183
201
|
box-shadow: inset 0 2px 8px 0 rgba(0, 0, 0, 0.15);
|
|
184
202
|
`}
|
|
185
|
-
`,
|
|
203
|
+
`,Di=y.default.div`
|
|
186
204
|
position: absolute;
|
|
187
205
|
opacity: 0;
|
|
188
206
|
top: 100%;
|
|
@@ -199,11 +217,11 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
199
217
|
color: #25211f;
|
|
200
218
|
overflow: hidden;
|
|
201
219
|
|
|
202
|
-
${e=>e.$open&&
|
|
220
|
+
${e=>e.$open&&y.css`
|
|
203
221
|
opacity: 1;
|
|
204
222
|
pointer-events: visible;
|
|
205
223
|
`}
|
|
206
|
-
`,
|
|
224
|
+
`,Oi=y.default.div`
|
|
207
225
|
display: flex;
|
|
208
226
|
background: #fff;
|
|
209
227
|
color: #25211f;
|
|
@@ -213,13 +231,13 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
213
231
|
&:hover {
|
|
214
232
|
background: #f9f9f9;
|
|
215
233
|
}
|
|
216
|
-
`,
|
|
234
|
+
`,ki={available:`#ddd`,configured:`#e37266`,active:`#4cb235`},Ai=y.default.div`
|
|
217
235
|
margin: 0.2em 0.5em;
|
|
218
236
|
width: 8px;
|
|
219
237
|
height: 8px;
|
|
220
238
|
border-radius: 50%;
|
|
221
|
-
background-color: ${e=>
|
|
222
|
-
`,
|
|
239
|
+
background-color: ${e=>ki[e.$status]};
|
|
240
|
+
`,ji=y.default.div`
|
|
223
241
|
flex: 1;
|
|
224
242
|
font-size: 0.925em;
|
|
225
243
|
color: #25211f;
|
|
@@ -228,10 +246,10 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
228
246
|
cursor: pointer;
|
|
229
247
|
white-space: nowrap;
|
|
230
248
|
overflow: hidden;
|
|
231
|
-
`,
|
|
249
|
+
`,Mi=y.default.div`
|
|
232
250
|
background: #f9f9f9;
|
|
233
251
|
font-size: 0.8em;
|
|
234
|
-
`,
|
|
252
|
+
`,Ni=y.default.div`
|
|
235
253
|
color: #999;
|
|
236
254
|
font-size: 0.8em;
|
|
237
255
|
padding: 0.6em 0.8em;
|
|
@@ -239,10 +257,10 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
239
257
|
border-radius: 5px;
|
|
240
258
|
user-select: none;
|
|
241
259
|
cursor: not-allowed;
|
|
242
|
-
`;function Ir(e,t){return e>0||!!t?.mainAction||!!t?.actions?.length}function Lr({downloadEnabled:e,fileName:t,preview:n}){let{active:r,configs:i,actions:a,selected:o}=Cr(),s=(0,m.useVault)(),c=z(),u=W(),f=i.filter(e=>e.type===`external-manifest-preview`),p=n?.actions||[],{isOpen:h,buttonProps:g,itemProps:_}=ir(f.length+p.length);return Ir(f.length,n)?(0,d.jsxs)(d.Fragment,{children:[e?(0,d.jsx)(`div`,{className:`mr-4`,children:(0,d.jsx)(l.DownloadButton,{fileName:t||`manifest.json`,label:`Download manifest`,getData:()=>c.export&&c.export.version===2?JSON.stringify(s.toPresentation2(u),null,2):JSON.stringify(s.toPresentation3(u),null,2)})}):null,(0,d.jsxs)(Er,{children:[(0,d.jsx)(Dr,{"data-preview-action":n?.mainAction?.id,disabled:n?.mainAction?.disabled||!n?.mainAction&&f.length===0,onClick:()=>{if(n?.mainAction){n.mainAction.onClick();return}if(f.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`}),f.length+p.length>0?(0,d.jsx)(Or,{$open:h,...g,"aria-label":`Choose preview`,children:(0,d.jsx)(nr,{"aria-hidden":!0})}):null,(0,d.jsxs)(kr,{$open:h,role:`menu`,children:[f.map((e,t)=>{let n=r.indexOf(e.id)===-1;return(0,d.jsxs)(Ar,{..._[t],children:[(0,d.jsx)(Mr,{$status:n?`available`:e.id===o?`active`:`configured`}),(0,d.jsx)(Nr,{onClick:()=>{a.selectPreview(e.id)},children:e.label}),n?null:(0,d.jsx)(Pr,{onClick:()=>a.deletePreview(e.id),children:(0,d.jsx)(tr,{})})]},e.id)}),p.map((e,t)=>(0,d.jsxs)(Ar,{..._[f.length+t],"aria-disabled":e.disabled||void 0,onClick:()=>{e.disabled||e.onClick()},children:[(0,d.jsx)(Mr,{$status:e.status||`available`}),(0,d.jsx)(Nr,{children:e.label})]},e.id))]})]})]}):(0,d.jsx)(Fr,{children:`Preview not available`})}const Rr=(0,u.createContext)({resource:null});function zr(){return(0,u.useContext)(Rr)}function Br(){let e=(0,m.useVault)(),{resource:t}=zr();N(t,`Nothing selected`);let{id:n,type:r}=t;return(0,m.useVaultSelector)(()=>e.get({id:n,type:r}),[n,r])}function Vr(){let{resource:e}=zr();return e}function Hr({resource:e,children:t}){let{id:n,type:r}=e||{};return(0,d.jsx)(Rr.Provider,{value:(0,u.useMemo)(()=>({resource:n&&r?{id:n,type:r}:null}),[n,r]),children:t})}function Ur(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=(0,h.toRef)(t.payload.resource.resource);if(!n||!e.stack.find(e=>(0,h.toRef)(e.resource)?.id===n.id))return e;let r=e.current?.resource.id===n.id?null:e.current,i=Wr(e.stack.filter(e=>(0,h.toRef)(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 Wr(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 Gr={stack:[],current:null,create:null},Kr=(0,u.createContext)(Gr),qr=(0,u.createContext)({edit(){},close(){},back(){},setStack(){},updateCurrent(){},create(){return()=>{}}});function Jr(){return(0,u.useContext)(qr)}function Yr(){return(0,u.useContext)(Kr).current}function Xr(){return(0,u.useContext)(Kr).stack}function Zr(){return(0,u.useContext)(Kr).create}function Qr(){let{manifest:e}=(0,m.useResourceContext)(),t=(0,m.useVault)(),[n,r]=(0,u.useReducer)(e=>e+1,0);N(e,`Manifest not found`);let i=(0,u.useMemo)(()=>new v.EditorInstance({reference:{id:e,type:`Manifest`},vault:t}),[e,t]);return(0,u.useEffect)(()=>i.observe.start(r),[i]),i.observe.key=`${n}`,i.observe.reset(),i}function $r(){let{collection:e}=(0,m.useResourceContext)(),t=(0,m.useVault)(),[n,r]=(0,u.useReducer)(e=>e+1,0);N(e,`Collection not found`);let i=(0,u.useMemo)(()=>new v.EditorInstance({reference:{id:e,type:`Collection`},vault:t}),[e,t]);return(0,u.useEffect)(()=>i.observe.start(r),[i]),i.observe.key=`${n}`,i.observe.reset(),i}function ei(e,t={}){let n=(0,m.useVault)(),[r,i]=(0,u.useReducer)(e=>e+1,0);!t.allowNull&&N(e,`Resource not found`);let a=(0,u.useMemo)(()=>t.allowNull&&!e?null:new v.EditorInstance({reference:(0,h.toRef)(e),vault:n,context:{resource:e,parent:t.parent,index:t.index,parentProperty:t.parentProperty}}),[e,n]);return(0,u.useEffect)(()=>a?.observe.start(i),[a]),a&&(a.observe.key=`${r}`,a.observe.reset()),a}function ti(){let{annotationPage:e}=(0,m.useResourceContext)();return N(e,`Annotation page not found`),ei({id:e,type:`AnnotationPage`})}function ni(){let e=Yr(),{resource:t}=zr(),n=(0,m.useVault)(),[r,i]=(0,u.useReducer)(e=>e+1,0);N(e,`No resource selected`);let a=(0,u.useMemo)(()=>new v.EditorInstance({reference:t||e.resource.source||e.resource,vault:n}),[t,e,n]);return(0,u.useEffect)(()=>a.observe.start(i),[a]),a.observe.key=`${r}`,a.observe.reset(),a}function ri(e){let t=(0,m.useVault)(),[n,r]=(0,u.useReducer)(Ur,e),i=(0,u.useCallback)(e=>{r(e)},[]);(0,u.useEffect)(()=>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=(0,u.useCallback)((e,t=!1)=>i({type:`edit`,payload:{resource:e,reset:t}}),[]),o=(0,u.useCallback)(e=>i({type:`setStack`,payload:{resources:e}}),[]),s=(0,u.useCallback)(e=>i({type:`updateCurrent`,payload:{resource:e}}),[]),c=(0,u.useCallback)(()=>i({type:`close`}),[]),l=(0,u.useCallback)(()=>i({type:`back`}),[]),d=(0,u.useCallback)((e,t)=>(i({type:`create`,payload:{resource:e,options:t}}),()=>{i({type:`create`,payload:{resource:null}})}),[]);return[n,(0,u.useMemo)(()=>({edit:a,updateCurrent:s,close:c,back:l,create:d,setStack:o}),[])]}function ii(e){let{instanceId:t}=Hn(),[n,r]=ri(e.initialState||Gr);return(0,d.jsx)(qr.Provider,{value:r,children:(0,d.jsx)(Kr.Provider,{value:n,children:e.children})},t)}function ai({resource:e,children:t}){let{instanceId:n}=Hn(),[r,i]=ri((0,u.useMemo)(()=>({create:null,stack:[],current:{resource:{type:`SpecificResource`,source:{id:e.id,type:e.type}}}}),[]));return(0,d.jsx)(qr.Provider,{value:i,children:(0,d.jsx)(Kr.Provider,{value:r,children:t})},n)}const oi=(0,u.createContext)(null),si=(0,u.createContext)(null),ci=(0,u.createContext)(`default`);function li(){return(0,u.useContext)(si)}function ui(){return(0,u.useContext)(oi)}function di(){return(0,u.useContext)(ci)}function fi(){return U().layout}function pi(){let e=U(),t=e.layout,n=(0,u.useContext)(oi),r=(0,u.useContext)(si);return(0,u.useMemo)(()=>({actions:n,state:r,...t}),[e,r])}const mi=`@manifest-editor/tags`,hi=`tags`,gi={type:`flag`,id:`flag`,label:`Flag`,backgroundColor:`#b91c1c`,textColor:`#ffffff`,icon:`flag`},_i=[];function vi(e){return typeof e==`string`?e:e?.id||null}function yi(e){return e.type||e.id}function bi(e){return`${e.type}:${e.id}`}function xi(e){if(!Array.isArray(e))return _i;let t=new Map;for(let n of e){if(!n?.id)continue;let e=yi(n);t.set(e,{...n,type:e})}return Array.from(t.values())}function Si(e){return e.label||e.id||e.type}function Ci(e,t){return e===gi.type&&(!t||t===gi.id)}function wi(e,t){return Ci(e.type,e.id)?-1:Ci(t.type,t.id)?1:Si(e.tag).localeCompare(Si(t.tag))||e.type.localeCompare(t.type)||e.id.localeCompare(t.id)}function Ti(e,t){return Ci(e.type)?-1:Ci(t.type)?1:e.type.localeCompare(t.type)}function Ei(e,t){let n=vi(t);return n?xi(e.getResourceMeta(n,mi)?.[hi]):_i}function Di(e,t){let n=vi(t);return n?xi(e?.iiif?.meta?.[n]?.[mi]?.[hi]):_i}function Oi(e,t,n){let r=vi(t);if(!r)return _i;let i=xi(n);return e.setMetaValue([r,mi,hi],i),i}function ki(e,t,n){return Oi(e,t,[...Ei(e,t),n])}function Ai(e,t,n){return Ei(e,t).find(e=>e.type===n)}function ji(e,t,n,r){return Oi(e,t,Ei(e,t).filter(e=>e.type!==n||(r?e.id!==r:!1)))}function Mi(e,t){let n=new Map;for(let r of t){let t=vi(r);if(t)for(let i of Ei(e,r)){let e=i.type,r=bi(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(wi),e.canvasIds=Array.from(new Set(e.rows.flatMap(e=>e.canvasIds))),e.canvasCount=e.canvasIds.length;return Array.from(n.values()).sort(Ti)}function Ni(e,t,n,r){let i=Ai(e,t,n);return r?i?.id===r:!!i}function Pi(e,t,n){return Ni(e,t,n.type,n.id)?ji(e,t,n.type):ki(e,t,n)}function Fi(e){return{getTags(t){return Ei(e,t)},setTags(t,n){return Oi(e,t,n)},addTag(t,n){return ki(e,t,n)},upsertTag(t,n){return ki(e,t,n)},getTag(t,n){return Ai(e,t,n)},removeTag(t,n,r){return ji(e,t,n,r)},hasTag(t,n,r){return Ni(e,t,n,r)},toggleTag(t,n){return Pi(e,t,n)}}}function Ii(e){let t=vi(e);return(0,m.useVaultSelector)(e=>t?Di(e,t):_i,[t])}function Li(e){let t=(0,m.useVault)(),n=vi(e),r=(0,u.useMemo)(()=>Fi(t),[t]);return(0,u.useMemo)(()=>({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 Ri({icon:e,title:t,...n}){return e===`flag`?(0,d.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`1em`,height:`1em`,"aria-hidden":!t||void 0,...n,children:[t?(0,d.jsx)(`title`,{children:t}):null,(0,d.jsx)(`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 zi({tag:e,showIcon:t=!0,className:n,style:r}){return(0,d.jsxs)(`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?(0,d.jsx)(Ri,{icon:e.icon,className:`h-2.5 w-2.5 flex-shrink-0`}):null,(0,d.jsx)(`span`,{className:`min-w-0 truncate`,children:Si(e)})]})}function Bi({resource:e,tags:t,className:n}){return t?(0,d.jsx)(Hi,{tags:t,className:n}):(0,d.jsx)(Vi,{resource:e,className:n})}function Vi({resource:e,className:t}){let n=Ii(e);return(0,d.jsx)(Hi,{tags:n,className:t})}function Hi({tags:e,className:t}){let n=e;return n.length?(0,d.jsx)(`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=>(0,d.jsx)(zi,{tag:e},e.type))}):null}const Ui=(0,u.createContext)(null);function Wi(e){return e===`error`?8e3:5e3}function Gi({children:e,maxVisibleToasts:t=3}){let n=(0,y.useToastState)({maxVisibleToasts:t}),r=(0,u.useMemo)(()=>{let e=(e,t)=>n.add(e,{...t,timeout:t?.timeout??Wi(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(0,d.jsxs)(Ui.Provider,{value:r,children:[e,(0,d.jsx)(l.ToastRegion,{state:n})]})}function Ki(){let e=(0,u.useContext)(Ui);if(!e)throw Error(`useToasts must be used within a ToastProvider`);return e}function qi(e){return e.status!==`complete`&&e.status!==`error`||!e.completedAt?null:`${e.id}:${e.status}:${e.completedAt}`}function Ji(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 Yi(e){return{id:e.id,type:e.type,label:e.type,scope:`root`}}function Xi(e){if(!(!e||!e.id||e.type!==`Canvas`))return{id:e.id,type:`Canvas`,label:`Current canvas`,scope:`canvas`}}function Zi(){let e=Yr(),t=Xr();return(0,u.useMemo)(()=>Xi([e,...t].find(e=>e?.resource?.source?.type===`Canvas`)?.resource?.source),[e,t])}function Qi(){let e=W(),t=Zi(),n=(0,m.useVault)(),r=(0,u.useMemo)(()=>Fi(n),[n]),i=(0,u.useMemo)(()=>ve(n),[n]),a=Nn(),o=z(),s=li(),c=ui();return(0,u.useMemo)(()=>({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 $i(){let e=H(e=>e.definitions),t=H(e=>e.instances),n=Qi(),r=(0,u.useMemo)(()=>Yi(n.rootResource),[n.rootResource]);return(0,u.useMemo)(()=>{let i=[r,...n.currentCanvas?[n.currentCanvas]:[]];return Fe({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 ea(){let e=At(),t=H(e=>e.definitions),n=H(e=>e.instances),r=H(e=>e.plans),i=H(e=>e.controllers),a=H(e=>e.hasHydrated),o=Qi(),s=(0,u.useRef)(new Set);return(0,u.useEffect)(()=>{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||!na(a)||!r[t]||i[t]||s.current.has(l)||(s.current.add(l),St({store:e,resume:!0,context:{...o,definition:n,target:a.target,instanceKey:t,instance:a}}))}},[i,t,a,n,r,e,o]),(0,d.jsx)(d.Fragment,{children:t.map(e=>e.render?(0,d.jsx)(u.Fragment,{children:e.render({...o,definition:e})},e.id):null)})}function ta(){let e=H(e=>e.definitions),t=H(e=>e.instances),n=Qi(),r=Ki(),i=(0,u.useRef)(new Set),a=(0,u.useMemo)(()=>new Map(e.map(e=>[e.id,e])),[e]);return(0,u.useEffect)(()=>{for(let e of Object.values(t)){let t=qi(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=Ji(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 na(e){return e?.status===`preparing`||e?.status===`running`}function ra(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 ia(e){return e?new Date(e).toLocaleString():`Not recorded`}function aa(e){return e?new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}):`--:--:--`}function oa(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 sa(e){if(e===void 0)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function ca({label:e,value:t}){return(0,d.jsxs)(`div`,{className:`min-w-0`,children:[(0,d.jsx)(`dt`,{className:`text-[10px] font-semibold uppercase tracking-widest text-zinc-400`,children:e}),(0,d.jsx)(`dd`,{className:`mt-1 break-words text-sm text-zinc-800`,children:t})]})}const la={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 ua(e){return la[e?.toLowerCase()]??{label:e?.toUpperCase().slice(0,3)??`LOG`,className:`text-zinc-300`}}const da={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 fa(e){return da[e?.toLowerCase()]??`bg-zinc-100 text-zinc-600`}function pa(e){return e?.toLowerCase()in da}function ma({definition:e,instance:t,onClose:n}){let[r,i]=(0,u.useState)(`overview`),a=(0,u.useRef)(null),o=t.logs.length;(0,u.useEffect)(()=>{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=>pa(e.type)),f=[{id:`overview`,label:`Overview`},{id:`logs`,label:`Logs`,count:o}];return(0,d.jsxs)(l.Modal,{title:t.label||e.label,onClose:n,className:`max-w-3xl`,children:[(0,d.jsx)(`div`,{className:`sticky top-0 z-10 border-b border-zinc-200 bg-white px-2`,children:(0,d.jsx)(`div`,{className:`flex gap-0.5`,children:f.map(e=>(0,d.jsxs)(`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?(0,d.jsx)(`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`&&(0,d.jsxs)(`div`,{className:`flex flex-col gap-5 p-5`,children:[(0,d.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,d.jsx)(`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?(0,d.jsx)(`span`,{className:`text-sm text-zinc-500`,children:t.statusText}):null]}),(0,d.jsxs)(`dl`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,d.jsx)(ca,{label:`Target`,value:`${t.target.label} (${t.target.type})`}),(0,d.jsx)(ca,{label:`Run ID`,value:t.runId}),(0,d.jsx)(ca,{label:`Started`,value:ia(t.startedAt)}),(0,d.jsx)(ca,{label:`Finished`,value:ia(t.completedAt)}),(0,d.jsx)(ca,{label:`Duration`,value:oa(t)}),t.progress?(0,d.jsx)(ca,{label:`Progress`,value:`${Math.round(t.progress.percent)}%${t.progress.label?` — ${t.progress.label}`:``}`}):null]}),t.progress?(0,d.jsxs)(`div`,{children:[(0,d.jsx)(l.BackgroundActionMenuProgressBar,{percent:t.progress.percent,label:t.progress.label||`Background action progress`}),typeof t.progress.current==`number`&&typeof t.progress.total==`number`?(0,d.jsxs)(`div`,{className:`mt-1 text-xs text-zinc-500`,children:[t.progress.current,` of `,t.progress.total,` items`]}):null]}):null,t.error?(0,d.jsxs)(`div`,{className:`rounded-lg border border-red-200 bg-red-50`,children:[(0,d.jsx)(`div`,{className:`border-b border-red-200 px-4 py-2.5`,children:(0,d.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-widest text-red-600`,children:`Error`})}),(0,d.jsxs)(`div`,{className:`p-4`,children:[(0,d.jsx)(`div`,{className:`text-sm font-medium text-red-800`,children:t.error.message}),t.error.stack?(0,d.jsx)(`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?(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h3`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-widest text-zinc-400`,children:`Key events`}),(0,d.jsx)(`div`,{className:`divide-y divide-zinc-100 rounded-lg border border-zinc-200`,children:c.map(e=>(0,d.jsxs)(`div`,{className:`flex items-baseline gap-3 px-3 py-2`,children:[(0,d.jsx)(`span`,{className:[`shrink-0 rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide`,fa(e.type)].join(` `),children:e.type}),(0,d.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-700`,children:e.message||e.type}),(0,d.jsx)(`time`,{className:`shrink-0 text-xs text-zinc-400`,children:aa(e.createdAt)})]},e.id))})]}):null]}),r===`logs`&&(0,d.jsx)(`div`,{className:`p-5`,children:o===0?(0,d.jsx)(`div`,{className:`rounded-lg border border-zinc-200 p-6 text-center text-sm text-zinc-400`,children:`No logs recorded.`}):(0,d.jsxs)(`div`,{className:`overflow-hidden rounded-lg bg-zinc-950 shadow-inner`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-white/10 px-3 py-2`,children:[(0,d.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full bg-zinc-700`}),(0,d.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full bg-zinc-700`}),(0,d.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full bg-zinc-700`}),(0,d.jsxs)(`span`,{className:`ml-2 text-[10px] text-zinc-500 font-mono`,children:[o,` `,o===1?`entry`:`entries`]})]}),(0,d.jsxs)(`div`,{className:`max-h-[50vh] overflow-y-auto p-1 font-mono text-xs`,children:[t.logs.map(e=>{let t=ua(e.level);return(0,d.jsxs)(`div`,{className:`group flex gap-0 hover:bg-white/5 rounded px-2 py-1 leading-relaxed`,children:[(0,d.jsx)(`time`,{className:`w-20 shrink-0 text-zinc-600 select-none pr-2`,children:aa(e.createdAt)}),(0,d.jsx)(`span`,{className:[`w-10 shrink-0 select-none font-bold pr-2`,t.className].join(` `),children:t.label}),(0,d.jsxs)(`span`,{className:`min-w-0 flex-1 text-zinc-200 break-words`,children:[e.message,e.data===void 0?null:(0,d.jsx)(`span`,{className:`block mt-0.5 text-zinc-500 whitespace-pre-wrap`,children:sa(e.data)})]})]},e.id)}),(0,d.jsx)(`div`,{ref:a})]})]})})]})}function ha(){let e=At(),t=$i(),[n,r]=(0,u.useState)(null),i=t.reduce((e,t)=>e+t.actions.length,0),a=t.reduce((e,t)=>e+t.actions.filter(e=>na(e.instance)).length,0),o=t.reduce((e,t)=>e+t.actions.filter(e=>e.instance?.status===`error`).length,0),{isOpen:s,buttonProps:c,itemProps:f,setIsOpen:p}=ir(i);if(!i)return null;let m=n?t.flatMap(e=>e.actions).find(e=>e.instanceKey===n):void 0,h=0;return(0,d.jsxs)(l.BackgroundActionMenuRoot,{children:[(0,d.jsx)(l.BackgroundActionMenuButton,{active:s,runningCount:a,errorCount:o,"aria-label":`Actions menu`,...c}),(0,d.jsx)(l.BackgroundActionMenuPanel,{open:s,role:`menu`,"aria-hidden":!s,inert:!s,children:(0,d.jsx)(`div`,{className:`py-1.5`,children:t.map((t,n)=>(0,d.jsxs)(u.Fragment,{children:[n?(0,d.jsx)(l.BackgroundActionMenuDivider,{}):null,(0,d.jsx)(l.BackgroundActionMenuSection,{children:t.label}),t.actions.map(t=>{let{onKeyDown:n,...i}=f[h++]||{},a=ra(t.instance),o=na(t.instance),s=()=>{o||(St({store:e,context:t.context}),p(!0))},c=()=>{o&&(e.getState().cancelAction(t.instanceKey),p(!0))};return(0,d.jsxs)(l.BackgroundActionMenuItem,{status:t.instance?.status||`idle`,children:[(0,d.jsx)(l.BackgroundActionMenuTrigger,{running:o,...i,"aria-label":o?`Cancel ${t.definition.label}`:`Run ${t.definition.label}`,onMouseDown:e=>{e.preventDefault()},onClick:e=>{e.stopPropagation(),o?c():s()},onKeyDown:e=>{e.key===`Enter`||e.key===` `?(e.preventDefault(),e.stopPropagation(),o?c():s()):n?.(e)},children:(0,d.jsxs)(l.BackgroundActionMenuText,{children:[(0,d.jsx)(l.BackgroundActionMenuLabel,{running:o,children:t.instance?.label||t.definition.label}),a?(0,d.jsx)(l.BackgroundActionMenuMeta,{variant:t.instance?.status===`error`?`error`:`default`,children:a}):null,t.definition.summary&&!a?(0,d.jsx)(l.BackgroundActionMenuMeta,{children:t.definition.summary}):null,o&&t.instance?.progress?(0,d.jsx)(l.BackgroundActionMenuProgressBar,{percent:t.instance.progress.percent,label:t.instance.progress.label||a||t.definition.label}):null]})}),t.instance?.resultsAvailable&&t.definition.onResults?(0,d.jsx)(l.BackgroundActionMenuInlineAction,{onClick:e=>{e.stopPropagation(),t.definition.onResults?.(t.context)},children:`Results`}):null,t.instance?(0,d.jsx)(l.BackgroundActionMenuInfoButton,{"aria-label":`View ${t.definition.label} details`,onClick:e=>{e.preventDefault(),e.stopPropagation(),r(t.instanceKey),p(!0)}}):null]},t.instanceKey)})]},t.id))})}),m?.instance?(0,d.jsx)(ma,{definition:m.definition,instance:m.instance,onClose:()=>r(null)}):null]})}const ga=new Set([`fullpage`,`slideshow`,`scroll`]);function _a(e,t){return[...e.filter(e=>!e.startsWith(`template-`)&&!ga.has(e)),t.type,`template-${t.id}`]}function va(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 ya(e,t,n=[]){return va(e,n)||e.find(e=>e.id===t)||e[0]||null}const ba=`manifest-editor:preset-onboarding:open`;function xa(e){return typeof window<`u`&&window.localStorage.getItem(e)===`true`}function Sa(e){typeof window<`u`&&window.localStorage.setItem(e,`true`)}function Ca(e,t){return e.mode===`global`||!t?`preset-onboarding/${e.id}`:`preset-onboarding/${e.id}/${t.type}/${t.id}`}function wa(){let e=U(),t=W(),n=e.preset?.onboarding,r=n?Ca(n,t):null;return()=>window.dispatchEvent(new CustomEvent(ba,{detail:r}))}function Ta({className:e}){let t=U().preset?.onboarding,n=wa();return t?(0,d.jsx)(l.ActionButton,{className:e,onPress:n,children:t.openLabel||`Open guide`}):null}function Ea(e){let t=U(),n=W(),{state:r,setState:i}=Un(),a=t.preset?.onboarding,o=t.preset?.onboarding?.renderPreviewButton,s=a?Ca(a,n):null,c=!!s&&r?.presetOnboardingPreviewHintKey===s;return o?o({...e,preview:t.preset?.preview,showOnboardingPreviewHint:c,onOnboardingPreviewHintClose:()=>{c&&i({presetOnboardingPreviewHintKey:null})}}):(0,d.jsx)(Lr,{...e,preview:t.preset?.preview})}function Da(){let e=U(),t=W(),n=e.preset?.onboarding,{setState:r}=Un(),i=Gn(),a=(0,m.useManifest)(),o=(0,m.useVault)(),s=a?.behavior||[],c=va(i.templates,s),f=ya(i.templates,i.selectedTemplateId,s),p=(0,u.useRef)(f?.id||null);p.current=f?.id||null;let h=(0,u.useMemo)(()=>n?Ca(n,t):null,[n,t]),[g,_]=(0,u.useState)(!1),[v,y]=(0,u.useState)(!1);if((0,u.useEffect)(()=>{if(!h)return;let e=!c&&!xa(h);_(e),y(e)},[c,h]),(0,u.useEffect)(()=>{let e=e=>{e.detail===h&&(r({presetOnboardingPreviewHintKey:null}),_(!!n),y(!1))};return window.addEventListener(ba,e),()=>window.removeEventListener(ba,e)},[h,n,r]),!n||!h)return null;let b=()=>{i.setSelectedTemplateId(ya(i.templates,p.current)?.id||null),Sa(h),v&&r({presetOnboardingPreviewHintKey:h}),_(!1),y(!1)},x=e=>{p.current=e,i.setSelectedTemplateId(e);let t=i.templates.find(t=>t.id===e);if(!a||!t)return;let n=a.behavior||[],r=_a(n,t);r.length===n.length&&r.every((e,t)=>e===n[t])||o.modifyEntityField(a,`behavior`,r)};return(0,d.jsx)(l.Modal,{title:n.title,open:g,onClose:b,actions:(0,d.jsxs)(`div`,{className:`flex gap-2`,children:[(0,d.jsx)(l.ActionButton,{onPress:b,children:n.dismissLabel||`Dismiss`}),f?(0,d.jsx)(l.ActionButton,{primary:!0,onPress:()=>{x(p.current),b()},children:n.primaryLabel||`Continue`}):null]}),children:(0,d.jsxs)(`div`,{className:`flex flex-col gap-4 p-6`,children:[n.summary?(0,d.jsx)(`p`,{className:`text-sm text-gray-600`,children:n.summary}):null,n.renderBody({...i,selectedTemplateId:f?.id||null,selectedTemplate:f,setSelectedTemplateId:x,dismiss:b})]})})}const Oa=(0,u.memo)(function(e){let[t]=(0,l.useLocalStorage)(`menu-hidden`);return(0,d.jsx)($n,{children:(0,d.jsxs)(Qn,{children:[(0,d.jsx)(er,{onClick:e.onClickLogo,children:(0,d.jsx)(l.ManifestEditorLogo,{})}),(0,d.jsx)(Lr,{}),(0,d.jsx)(Ta,{}),(0,d.jsx)(ha,{})]})})}),ka=(0,u.createContext)(null);function Aa(){return(0,u.useContext)(ka)||null}function ja(e,t){let n=Aa();return n?n[e][t]:null}function Ma({children:e,menu:t}){return(0,d.jsx)(ka.Provider,{value:t,children:e})}function Na(){return(0,u.useContext)(m.AtlasStoreReactContext)}function Pa(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 Fa=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)}),Ia=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 La(){}async function Ra(e,...t){if(!e)return;if(e.endsWith(`.mp3`)||e.endsWith(`.mp4`)||e.endsWith(`.m4a`)||e.endsWith(`.m4v`))try{let t=await Ia(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 Va(e)}if(!n.ok&&(n=await fetch(e+`/info.json`),!n.ok))return Va(e);let r=n.headers.get(`Content-Type`);if(r?.includes(`image/`))return Va(e,r);let i=null;try{i=await n.json()}catch{return null}return await Ba(i,e)}function za(e){return e.protocol&&e.protocol===`http://iiif.io/api/image`?(e.type||(e.type=`ImageService`),e):null}async function Ba(e,t){let n=za(e);if(n)return n;if(!(e.id||e[`@id`]))return null;let r=await new x.Vault().load(t,e);if(r&&(r&&r?.type===`Manifest`||r?.type===`Collection`))return{id:t,type:r.type,label:(0,b.getValue)(r.label)}}async function Va(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 Ha(n.slice(0,n.length-4).join(`/`)+`/info.json`);if(e&&e?.type&&e?.type?.startsWith(`ImageService`))return e}}try{let n=await Fa(e);return{id:e,type:`Image`,width:n.width,height:n.height,format:await Ua(e,t)}}catch{}return null}async function Ha(e){try{let t=await fetch(e);return t.ok?await Ba(await t.json(),e):null}catch(e){return console.log(e),null}}async function Ua(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 Wa(e){try{let t=await Fa(e);if(t)return{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}}catch{return null}return null}const Ga=(0,f.create)(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 Ka(e){let t=(0,u.useMemo)(()=>Lt(),[]),n=Ga(e=>e.regions[t]),r=Ga(e=>e.setRegion);(0,u.useEffect)(()=>{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]),(0,u.useEffect)(()=>()=>r(t,null),[])}function qa(e){let t=Ga(e=>e.highlight),n=Ga(e=>e.clearHighlight);return(0,u.useEffect)(()=>()=>{e&&n(e)},[n,e]),(0,u.useMemo)(()=>({onMouseEnter(){e&&t(e)},onMouseLeave(){e&&n(e)}}),[e,t,n])}const Ja=g.default.div`
|
|
260
|
+
`;function Pi(e,t){return e>0||!!t?.mainAction||!!t?.actions?.length}function Fi({downloadEnabled:e,fileName:t,preview:n}){let{resolveMessage:r}=(0,f.useEditorI18n)(),i=(0,f.useTranslations)(`shell`),{active:a,configs:o,actions:s,selected:c}=xi(),u=(0,g.useVault)(),p=U(),m=J(),h=o.filter(e=>e.type===`external-manifest-preview`),_=n?.actions||[],{isOpen:v,buttonProps:y,itemProps:b}=si(h.length+_.length);return Pi(h.length,n)?(0,d.jsxs)(d.Fragment,{children:[e?(0,d.jsx)(`div`,{className:`mr-4`,children:(0,d.jsx)(l.DownloadButton,{fileName:t||`manifest.json`,label:i(`preview.download`),getData:()=>p.export&&p.export.version===2?JSON.stringify(u.toPresentation2(m),null,2):JSON.stringify(u.toPresentation3(m),null,2)})}):null,(0,d.jsxs)(wi,{children:[(0,d.jsx)(Ti,{"data-preview-action":n?.mainAction?.id,disabled:n?.mainAction?.disabled||!n?.mainAction&&h.length===0,onClick:()=>{if(n?.mainAction){n.mainAction.onClick();return}if(h.length){if(!c){let e=p.defaultPreview;if(e){let t=o.find(t=>t.id===e);if(t){s.selectPreview(t.id);return}}s.selectPreview(o[0].id)}s.updatePreviews()}},children:r(n?.mainAction?.labelMessage,n?.mainAction?.label)||i(`preview.open`)}),h.length+_.length>0?(0,d.jsx)(Ei,{$open:v,...y,"aria-label":i(`preview.choose`),children:(0,d.jsx)(ai,{"aria-hidden":!0})}):null,(0,d.jsxs)(Di,{$open:v,role:`menu`,children:[h.map((e,t)=>{let n=a.indexOf(e.id)===-1;return(0,d.jsxs)(Oi,{...b[t],children:[(0,d.jsx)(Ai,{$status:n?`available`:e.id===c?`active`:`configured`}),(0,d.jsx)(ji,{onClick:()=>{s.selectPreview(e.id)},children:r(e?.labelMessage,e.label)}),n?null:(0,d.jsx)(Mi,{onClick:()=>s.deletePreview(e.id),children:(0,d.jsx)(ii,{})})]},e.id)}),_.map((e,t)=>(0,d.jsxs)(Oi,{...b[h.length+t],"aria-disabled":e.disabled||void 0,onClick:()=>{e.disabled||e.onClick()},children:[(0,d.jsx)(Ai,{$status:e.status||`available`}),(0,d.jsx)(ji,{children:r(e?.labelMessage,e.label)})]},e.id))]})]})]}):(0,d.jsx)(Ni,{children:i(`preview.unavailable`)})}const Ii=(0,u.createContext)({resource:null});function Li(){return(0,u.useContext)(Ii)}function Ri(){let e=(0,g.useVault)(),{resource:t}=Li();z(t,`Nothing selected`);let{id:n,type:r}=t;return(0,g.useVaultSelector)(()=>e.get({id:n,type:r}),[n,r])}function zi(){let{resource:e}=Li();return e}function Bi({resource:e,children:t}){let{id:n,type:r}=e||{};return(0,d.jsx)(Ii.Provider,{value:(0,u.useMemo)(()=>({resource:n&&r?{id:n,type:r}:null}),[n,r]),children:t})}function Vi(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=(0,_.toRef)(t.payload.resource.resource);if(!n||!e.stack.find(e=>(0,_.toRef)(e.resource)?.id===n.id))return e;let r=e.current?.resource.id===n.id?null:e.current,i=Hi(e.stack.filter(e=>(0,_.toRef)(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 Hi(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 Ui={stack:[],current:null,create:null},Wi=(0,u.createContext)(Ui),Gi=(0,u.createContext)({edit(){},close(){},back(){},setStack(){},updateCurrent(){},create(){return()=>{}}});function Ki(){return(0,u.useContext)(Gi)}function qi(){return(0,u.useContext)(Wi).current}function Ji(){return(0,u.useContext)(Wi).stack}function Yi(){return(0,u.useContext)(Wi).create}function Xi(){let{manifest:e}=(0,g.useResourceContext)(),t=(0,g.useVault)(),[n,r]=(0,u.useReducer)(e=>e+1,0);z(e,`Manifest not found`);let i=(0,u.useMemo)(()=>new k.EditorInstance({reference:{id:e,type:`Manifest`},vault:t}),[e,t]);return(0,u.useEffect)(()=>i.observe.start(r),[i]),i.observe.key=`${n}`,i.observe.reset(),i}function Zi(){let{collection:e}=(0,g.useResourceContext)(),t=(0,g.useVault)(),[n,r]=(0,u.useReducer)(e=>e+1,0);z(e,`Collection not found`);let i=(0,u.useMemo)(()=>new k.EditorInstance({reference:{id:e,type:`Collection`},vault:t}),[e,t]);return(0,u.useEffect)(()=>i.observe.start(r),[i]),i.observe.key=`${n}`,i.observe.reset(),i}function Qi(e,t={}){let n=(0,g.useVault)(),[r,i]=(0,u.useReducer)(e=>e+1,0);!t.allowNull&&z(e,`Resource not found`);let a=(0,u.useMemo)(()=>t.allowNull&&!e?null:new k.EditorInstance({reference:(0,_.toRef)(e),vault:n,context:{resource:e,parent:t.parent,index:t.index,parentProperty:t.parentProperty}}),[e,n]);return(0,u.useEffect)(()=>a?.observe.start(i),[a]),a&&(a.observe.key=`${r}`,a.observe.reset()),a}function $i(){let{annotationPage:e}=(0,g.useResourceContext)();return z(e,`Annotation page not found`),Qi({id:e,type:`AnnotationPage`})}function ea(){let e=qi(),{resource:t}=Li(),n=(0,g.useVault)(),[r,i]=(0,u.useReducer)(e=>e+1,0);z(e,`No resource selected`);let a=(0,u.useMemo)(()=>new k.EditorInstance({reference:t||e.resource.source||e.resource,vault:n}),[t,e,n]);return(0,u.useEffect)(()=>a.observe.start(i),[a]),a.observe.key=`${r}`,a.observe.reset(),a}function ta(e){let t=(0,g.useVault)(),[n,r]=(0,u.useReducer)(Vi,e),i=(0,u.useCallback)(e=>{r(e)},[]);(0,u.useEffect)(()=>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=(0,u.useCallback)((e,t=!1)=>i({type:`edit`,payload:{resource:e,reset:t}}),[]),o=(0,u.useCallback)(e=>i({type:`setStack`,payload:{resources:e}}),[]),s=(0,u.useCallback)(e=>i({type:`updateCurrent`,payload:{resource:e}}),[]),c=(0,u.useCallback)(()=>i({type:`close`}),[]),l=(0,u.useCallback)(()=>i({type:`back`}),[]),d=(0,u.useCallback)((e,t)=>(i({type:`create`,payload:{resource:e,options:t}}),()=>{i({type:`create`,payload:{resource:null}})}),[]);return[n,(0,u.useMemo)(()=>({edit:a,updateCurrent:s,close:c,back:l,create:d,setStack:o}),[])]}function na(e){let{instanceId:t}=or(),[n,r]=ta(e.initialState||Ui);return(0,d.jsx)(Gi.Provider,{value:r,children:(0,d.jsx)(Wi.Provider,{value:n,children:e.children})},t)}function ra({resource:e,children:t}){let{instanceId:n}=or(),[r,i]=ta((0,u.useMemo)(()=>({create:null,stack:[],current:{resource:{type:`SpecificResource`,source:{id:e.id,type:e.type}}}}),[]));return(0,d.jsx)(Gi.Provider,{value:i,children:(0,d.jsx)(Wi.Provider,{value:r,children:t})},n)}const ia=`@manifest-editor/tags`,aa=`tags`,oa={type:`flag`,id:`flag`,label:`Flag`,backgroundColor:`#b91c1c`,textColor:`#ffffff`,icon:`flag`},sa=[];function ca(e){return typeof e==`string`?e:e?.id||null}function la(e){return e.type||e.id}function ua(e){return`${e.type}:${e.id}`}function da(e){if(!Array.isArray(e))return sa;let t=new Map;for(let n of e){if(!n?.id)continue;let e=la(n);t.set(e,{...n,type:e})}return Array.from(t.values())}function fa(e){return e.label||e.id||e.type}function pa(e,t){return e===oa.type&&(!t||t===oa.id)}function ma(e,t){return pa(e.type,e.id)?-1:pa(t.type,t.id)?1:fa(e.tag).localeCompare(fa(t.tag))||e.type.localeCompare(t.type)||e.id.localeCompare(t.id)}function ha(e,t){return pa(e.type)?-1:pa(t.type)?1:e.type.localeCompare(t.type)}function ga(e,t){let n=ca(t);return n?da(e.getResourceMeta(n,ia)?.[aa]):sa}function _a(e,t){let n=ca(t);return n?da(e?.iiif?.meta?.[n]?.[ia]?.[aa]):sa}function va(e,t,n){let r=ca(t);if(!r)return sa;let i=da(n);return e.setMetaValue([r,ia,aa],i),i}function ya(e,t,n){return va(e,t,[...ga(e,t),n])}function ba(e,t,n){return ga(e,t).find(e=>e.type===n)}function xa(e,t,n,r){return va(e,t,ga(e,t).filter(e=>e.type!==n||(r?e.id!==r:!1)))}function Sa(e,t){let n=new Map;for(let r of t){let t=ca(r);if(t)for(let i of ga(e,r)){let e=i.type,r=ua(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(ma),e.canvasIds=Array.from(new Set(e.rows.flatMap(e=>e.canvasIds))),e.canvasCount=e.canvasIds.length;return Array.from(n.values()).sort(ha)}function Ca(e,t,n,r){let i=ba(e,t,n);return r?i?.id===r:!!i}function wa(e,t,n){return Ca(e,t,n.type,n.id)?xa(e,t,n.type):ya(e,t,n)}function Ta(e){return{getTags(t){return ga(e,t)},setTags(t,n){return va(e,t,n)},addTag(t,n){return ya(e,t,n)},upsertTag(t,n){return ya(e,t,n)},getTag(t,n){return ba(e,t,n)},removeTag(t,n,r){return xa(e,t,n,r)},hasTag(t,n,r){return Ca(e,t,n,r)},toggleTag(t,n){return wa(e,t,n)}}}function Ea(e){let t=ca(e);return(0,g.useVaultSelector)(e=>t?_a(e,t):sa,[t])}function Da(e){let t=(0,g.useVault)(),n=ca(e),r=(0,u.useMemo)(()=>Ta(t),[t]);return(0,u.useMemo)(()=>({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 Oa({icon:e,title:t,...n}){return e===`flag`?(0,d.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`1em`,height:`1em`,"aria-hidden":!t||void 0,...n,children:[t?(0,d.jsx)(`title`,{children:t}):null,(0,d.jsx)(`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 ka({tag:e,showIcon:t=!0,className:n,style:r}){return(0,d.jsxs)(`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?(0,d.jsx)(Oa,{icon:e.icon,className:`h-2.5 w-2.5 flex-shrink-0`}):null,(0,d.jsx)(`span`,{className:`min-w-0 truncate`,children:fa(e)})]})}function Aa({resource:e,tags:t,className:n}){return t?(0,d.jsx)(Ma,{tags:t,className:n}):(0,d.jsx)(ja,{resource:e,className:n})}function ja({resource:e,className:t}){let n=Ea(e);return(0,d.jsx)(Ma,{tags:n,className:t})}function Ma({tags:e,className:t}){let n=e;return n.length?(0,d.jsx)(`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=>(0,d.jsx)(ka,{tag:e},e.type))}):null}const Na=(0,u.createContext)(null);function Pa(e){return e===`error`?8e3:5e3}function Fa({children:e,maxVisibleToasts:t=3}){let n=(0,A.useToastState)({maxVisibleToasts:t}),r=(0,u.useMemo)(()=>{let e=(e,t)=>n.add(e,{...t,timeout:t?.timeout??Pa(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(0,d.jsxs)(Na.Provider,{value:r,children:[e,(0,d.jsx)(l.ToastRegion,{state:n})]})}function Ia(){let e=(0,u.useContext)(Na);if(!e)throw Error(`useToasts must be used within a ToastProvider`);return e}function La(e){return e.status!==`complete`&&e.status!==`error`||!e.completedAt?null:`${e.id}:${e.status}:${e.completedAt}`}function Ra(e,t,n,r){let i=ge(r),a=i.translate(`shell`),o=_e(e,t,i);return t.status===`complete`?{variant:`success`,title:a(`background.toastComplete`,{name:o}),description:t.resultsAvailable?a(`background.resultsReady`):void 0,action:t.resultsAvailable&&n?{label:a(`background.results`),onPress:n}:void 0}:t.status===`error`?{variant:`error`,title:a(`background.toastFailed`,{name:o}),description:ve(t,i)||a(`background.failed`)}:null}function za(e){return{id:e.id,type:e.type,label:e.type,labelMessage:{namespace:`editor-api`,key:`resources.${e.type.charAt(0).toLowerCase()}${e.type.slice(1)}`,defaultValue:e.type},scope:`root`}}function Ba(e){if(!(!e||!e.id||e.type!==`Canvas`))return{id:e.id,type:`Canvas`,label:`Current canvas`,labelMessage:{namespace:`shell`,key:`background.currentCanvas`},scope:`canvas`}}function Va(){let e=qi(),t=Ji();return(0,u.useMemo)(()=>Ba([e,...t].find(e=>e?.resource?.source?.type===`Canvas`)?.resource?.source),[e,t])}function Ha(){let{resolveMessage:e,translate:t}=(0,f.useEditorI18n)(),n=(0,u.useRef)({resolveMessage:e,translate:t});return n.current={resolveMessage:e,translate:t},(0,u.useMemo)(()=>({resolveMessage:(e,t)=>n.current.resolveMessage(e,t),translate:e=>(...t)=>n.current.translate(e)(...t)}),[])}function Ua(){let e=Ha(),t=J(),n=Va(),r=(0,g.useVault)(),i=(0,u.useMemo)(()=>Ta(r),[r]),a=(0,u.useMemo)(()=>je(r),[r]),o=qn(),s=U(),c=wr(),l=Tr();return(0,u.useMemo)(()=>({i18n:e,rootResource:t,currentCanvas:n,vault:r,tags:i,canvasProgress:a,plugins:o,config:s,layoutState:c,layoutActions:l}),[e,t,n,r,i,a,o,s,c,l])}function Wa(){let e=K(e=>e.definitions),t=K(e=>e.instances),n=Ua(),r=(0,u.useMemo)(()=>za(n.rootResource),[n.rootResource]);return(0,u.useMemo)(()=>{let i=[r,...n.currentCanvas?[n.currentCanvas]:[]];return Je({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 Ga(){let e=Wt(),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=Ua(),s=(0,u.useRef)(new Set);return(0,u.useEffect)(()=>{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||!Ja(a)||!r[t]||i[t]||s.current.has(l)||(s.current.add(l),It({store:e,resume:!0,context:{...o,definition:n,target:a.target,instanceKey:t,instance:a}}))}},[i,t,a,n,r,e,o]),(0,d.jsx)(d.Fragment,{children:t.map(e=>e.render?(0,d.jsx)(u.Fragment,{children:e.render({...o,definition:e})},e.id):null)})}function Ka({definition:e,instance:t,part:n}){let r=Ra(e,t,()=>{},(0,f.useEditorI18n)());return(0,d.jsx)(d.Fragment,{children:n===`action`?r?.action?.label:r?.[n]})}function qa(){let e=K(e=>e.definitions),t=K(e=>e.instances),n=Ua(),r=Ia(),i=(0,u.useRef)(new Set),a=(0,u.useMemo)(()=>new Map(e.map(e=>[e.id,e])),[e]);return(0,u.useEffect)(()=>{for(let e of Object.values(t)){let t=La(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=Ra(o,e,e.resultsAvailable&&o.onResults?()=>{o.onResults?.(s)}:void 0,n.i18n);c&&(r.add({...c,title:(0,d.jsx)(Ka,{definition:o,instance:e,part:`title`}),description:c.description?(0,d.jsx)(Ka,{definition:o,instance:e,part:`description`}):void 0,action:c.action?{...c.action,label:(0,d.jsx)(Ka,{definition:o,instance:e,part:`action`})}:void 0}),i.current.add(t))}},[a,t,n,r]),null}function Ja(e){return e?.status===`preparing`||e?.status===`running`}function Ya(e,t,n,r){return e&&Number.isFinite(e)?new Intl.DateTimeFormat(t,{dateStyle:`medium`,timeStyle:`medium`,timeZone:n}).format(e):r}function Xa(e,t,n){return e&&Number.isFinite(e)?new Intl.DateTimeFormat(t,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,timeZone:n}).format(e):`--:--:--`}function Za(e){if(e===void 0)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Qa({label:e,value:t}){return(0,d.jsxs)(`div`,{className:`min-w-0`,children:[(0,d.jsx)(`dt`,{className:`text-[10px] font-semibold uppercase tracking-widest text-zinc-400`,children:e}),(0,d.jsx)(`dd`,{className:`mt-1 break-words text-sm text-zinc-800`,children:t})]})}const $a={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 $a[e?.toLowerCase()]??{label:e?.toUpperCase().slice(0,3)??`LOG`,className:`text-zinc-300`}}const to={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 no(e){return to[e?.toLowerCase()]??`bg-zinc-100 text-zinc-600`}function ro(e){return e?.toLowerCase()in to}function io({definition:e,instance:t,onClose:n}){let r=(0,f.useEditorI18n)(),{resolveMessage:i,locale:a}=r,o=U().uiI18n?.timeZone||`UTC`,s=(0,f.useTranslations)(`shell`),[c,p]=(0,u.useState)(`overview`),m=(0,u.useRef)(null),h=t.logs.length,g=i(t.progress?.labelMessage,t.progress?.label),_=new Intl.NumberFormat(a,{style:`percent`,maximumFractionDigits:0}).format((t.progress?.percent||0)/100);(0,u.useEffect)(()=>{c===`logs`&&m.current?.scrollIntoView({behavior:`instant`})},[c]);let v={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`},y=t.events.filter(e=>ro(e.type)),b=[{id:`overview`,label:s(`background.overview`)},{id:`logs`,label:s(`background.logs`),count:h}];return(0,d.jsxs)(l.Modal,{title:_e(e,t,r),onClose:n,className:`max-w-3xl`,children:[(0,d.jsx)(`div`,{className:`sticky top-0 z-10 border-b border-zinc-200 bg-white px-2`,children:(0,d.jsx)(`div`,{className:`flex gap-0.5`,children:b.map(e=>(0,d.jsxs)(`button`,{type:`button`,onClick:()=>p(e.id),className:[`flex items-center gap-1.5 border-b-2 px-3 py-2.5 text-sm transition-colors -mb-px`,c===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?(0,d.jsx)(`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))})}),c===`overview`&&(0,d.jsxs)(`div`,{className:`flex flex-col gap-5 p-5`,children:[(0,d.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,d.jsx)(`span`,{className:[`inline-flex items-center gap-1.5 rounded-full px-3 py-1 text-xs font-semibold uppercase tracking-wide`,v[t.status]??`bg-zinc-100 text-zinc-600`].join(` `),children:s(`background.${t.status}`)}),t.statusText?(0,d.jsx)(`span`,{className:`text-sm text-zinc-500`,children:i(t.statusTextMessage,t.statusText)}):null]}),(0,d.jsx)(`p`,{className:`text-xs text-zinc-500`,children:s(`background.timeZone`,{timeZone:o})}),(0,d.jsxs)(`dl`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,d.jsx)(Qa,{label:s(`background.target`),value:i(t.target.labelMessage,t.target.label)}),(0,d.jsx)(Qa,{label:s(`background.runId`),value:t.runId}),(0,d.jsx)(Qa,{label:s(`background.started`),value:Ya(t.startedAt,a,o,s(`background.notRecorded`))}),(0,d.jsx)(Qa,{label:s(`background.finished`),value:Ya(t.completedAt,a,o,s(`background.notRecorded`))}),(0,d.jsx)(Qa,{label:s(`background.duration`),value:t.startedAt?s(`background.seconds`,{count:Math.max(0,Math.round(((t.completedAt||Date.now())-t.startedAt)/1e3))}):s(`background.notRecorded`)}),t.progress?(0,d.jsx)(Qa,{label:s(`background.progressLabel`),value:g?s(`background.progressValue`,{percent:_,label:g}):_}):null]}),t.progress?(0,d.jsxs)(`div`,{children:[(0,d.jsx)(l.BackgroundActionMenuProgressBar,{percent:t.progress.percent,label:i(t.progress.labelMessage,t.progress.label)||s(`background.progressAccessible`)}),typeof t.progress.current==`number`&&typeof t.progress.total==`number`?(0,d.jsx)(`div`,{className:`mt-1 text-xs text-zinc-500`,children:s(`background.items`,{current:t.progress.current,count:t.progress.total})}):null]}):null,t.error?(0,d.jsxs)(`div`,{className:`rounded-lg border border-red-200 bg-red-50`,children:[(0,d.jsx)(`div`,{className:`border-b border-red-200 px-4 py-2.5`,children:(0,d.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-widest text-red-600`,children:s(`background.error`)})}),(0,d.jsxs)(`div`,{className:`p-4`,children:[(0,d.jsx)(`div`,{className:`text-sm font-medium text-red-800`,children:i(t.error.messageReference,t.error.message)}),t.error.stack?(0,d.jsx)(`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,y.length>0?(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h3`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-widest text-zinc-400`,children:s(`background.events`)}),(0,d.jsx)(`div`,{className:`divide-y divide-zinc-100 rounded-lg border border-zinc-200`,children:y.map(e=>(0,d.jsxs)(`div`,{className:`flex items-baseline gap-3 px-3 py-2`,children:[(0,d.jsx)(`span`,{className:[`shrink-0 rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide`,no(e.type)].join(` `),children:s(`events.${e.type}`,void 0,{defaultValue:e.type})}),(0,d.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-700`,children:i(e.messageReference,e.message)||s(`events.${s(`events.${e.type}`,void 0,{defaultValue:e.type})}`,void 0,{defaultValue:e.type})}),(0,d.jsx)(`time`,{className:`shrink-0 text-xs text-zinc-400`,children:Xa(e.createdAt,a,o)})]},e.id))})]}):null]}),c===`logs`&&(0,d.jsx)(`div`,{className:`p-5`,children:h===0?(0,d.jsx)(`div`,{className:`rounded-lg border border-zinc-200 p-6 text-center text-sm text-zinc-400`,children:s(`background.noLogs`)}):(0,d.jsxs)(`div`,{className:`overflow-hidden rounded-lg bg-zinc-950 shadow-inner`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-white/10 px-3 py-2`,children:[(0,d.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full bg-zinc-700`}),(0,d.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full bg-zinc-700`}),(0,d.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full bg-zinc-700`}),(0,d.jsx)(`span`,{className:`ml-2 text-[10px] text-zinc-500 font-mono`,children:s(`background.entries`,{count:h})})]}),(0,d.jsxs)(`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(0,d.jsxs)(`div`,{className:`group flex gap-0 hover:bg-white/5 rounded px-2 py-1 leading-relaxed`,children:[(0,d.jsx)(`time`,{className:`w-20 shrink-0 text-zinc-600 select-none pr-2`,children:Xa(e.createdAt,a,o)}),(0,d.jsx)(`span`,{className:[`w-10 shrink-0 select-none font-bold pr-2`,t.className].join(` `),children:s(`logLevels.${e.level}`,void 0,{defaultValue:t.label})}),(0,d.jsxs)(`span`,{className:`min-w-0 flex-1 text-zinc-200 break-words`,children:[i(e.messageReference,e.message),e.data===void 0?null:(0,d.jsx)(`span`,{className:`block mt-0.5 text-zinc-500 whitespace-pre-wrap`,children:Za(e.data)})]})]},e.id)}),(0,d.jsx)(`div`,{ref:m})]})]})})]})}function ao(){let e=(0,f.useEditorI18n)(),{resolveMessage:t}=e,n=(0,f.useTranslations)(`shell`),r=Wt(),i=Wa(),[a,o]=(0,u.useState)(null),s=i.reduce((e,t)=>e+t.actions.length,0),c=i.reduce((e,t)=>e+t.actions.filter(e=>Ja(e.instance)).length,0),p=i.reduce((e,t)=>e+t.actions.filter(e=>e.instance?.status===`error`).length,0),{isOpen:m,buttonProps:h,itemProps:g,setIsOpen:_}=si(s);if(!s)return null;let v=a?i.flatMap(e=>e.actions).find(e=>e.instanceKey===a):void 0,y=0;return(0,d.jsxs)(l.BackgroundActionMenuRoot,{children:[(0,d.jsx)(l.BackgroundActionMenuButton,{active:m,runningCount:c,errorCount:p,"aria-label":n(`background.menu`),...h}),(0,d.jsx)(l.BackgroundActionMenuPanel,{open:m,role:`menu`,"aria-hidden":!m,inert:!m,children:(0,d.jsx)(`div`,{className:`py-1.5`,children:i.map((i,a)=>(0,d.jsxs)(u.Fragment,{children:[a?(0,d.jsx)(l.BackgroundActionMenuDivider,{}):null,(0,d.jsx)(l.BackgroundActionMenuSection,{children:t(i.target.labelMessage,i.label)}),i.actions.map(i=>{let{onKeyDown:a,...s}=g[y++]||{},c=ve(i.instance,e),u=Ja(i.instance),f=()=>{u||(It({store:r,context:i.context}),_(!0))},p=()=>{u&&(r.getState().cancelAction(i.instanceKey),_(!0))};return(0,d.jsxs)(l.BackgroundActionMenuItem,{status:i.instance?.status||`idle`,children:[(0,d.jsx)(l.BackgroundActionMenuTrigger,{running:u,...s,"aria-label":n(u?`background.cancelAction`:`background.runAction`,{name:t(i.definition.labelMessage,i.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()):a?.(e)},children:(0,d.jsxs)(l.BackgroundActionMenuText,{children:[(0,d.jsx)(l.BackgroundActionMenuLabel,{running:u,children:_e(i.definition,i.instance,e)}),c?(0,d.jsx)(l.BackgroundActionMenuMeta,{variant:i.instance?.status===`error`?`error`:`default`,children:c}):null,t(i.definition.summaryMessage,i.definition.summary)&&!c?(0,d.jsx)(l.BackgroundActionMenuMeta,{children:t(i.definition.summaryMessage,i.definition.summary)}):null,u&&i.instance?.progress?(0,d.jsx)(l.BackgroundActionMenuProgressBar,{percent:i.instance.progress.percent,label:t(i.instance.progress.labelMessage,i.instance.progress.label)||c||t(i.definition.labelMessage,i.definition.label)}):null]})}),i.instance?.resultsAvailable&&i.definition.onResults?(0,d.jsx)(l.BackgroundActionMenuInlineAction,{onClick:e=>{e.stopPropagation(),i.definition.onResults?.(i.context)},children:n(`background.results`)}):null,i.instance?(0,d.jsx)(l.BackgroundActionMenuInfoButton,{"aria-label":n(`background.viewDetails`,{name:t(i.definition.labelMessage,i.definition.label)}),onClick:e=>{e.preventDefault(),e.stopPropagation(),o(i.instanceKey),_(!0)}}):null]},i.instanceKey)})]},i.id))})}),v?.instance?(0,d.jsx)(io,{definition:v.definition,instance:v.instance,onClose:()=>o(null)}):null]})}const oo=new Set([`fullpage`,`slideshow`,`scroll`]);function so(e,t){return[...e.filter(e=>!e.startsWith(`template-`)&&!oo.has(e)),t.type,`template-${t.id}`]}function co(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 lo(e,t,n=[]){return co(e,n)||e.find(e=>e.id===t)||e[0]||null}const uo=`manifest-editor:preset-onboarding:open`;function fo(e){return typeof window<`u`&&window.localStorage.getItem(e)===`true`}function po(e){typeof window<`u`&&window.localStorage.setItem(e,`true`)}function mo(e,t){return e.mode===`global`||!t?`preset-onboarding/${e.id}`:`preset-onboarding/${e.id}/${t.type}/${t.id}`}function ho(){let e=q(),t=J(),n=e.preset?.onboarding,r=n?mo(n,t):null;return()=>window.dispatchEvent(new CustomEvent(uo,{detail:r}))}function go({className:e}){let{resolveMessage:t}=(0,f.useEditorI18n)(),n=(0,f.useTranslations)(`shell`),r=q().preset?.onboarding,i=ho();return r?(0,d.jsx)(l.ActionButton,{className:e,onPress:i,children:t(r?.openLabelMessage,r.openLabel)||n(`onboarding.openGuide`)}):null}function _o(e){let{resolveMessage:t}=(0,f.useEditorI18n)(),n=q(),r=J(),{state:i,setState:a}=sr(),o=n.preset?.onboarding,s=n.preset?.onboarding?.renderPreviewButton,c=o?mo(o,r):null,l=!!c&&i?.presetOnboardingPreviewHintKey===c;return s?s({i18n:{resolveMessage:t},...e,preview:n.preset?.preview,showOnboardingPreviewHint:l,onOnboardingPreviewHintClose:()=>{l&&a({presetOnboardingPreviewHintKey:null})}}):(0,d.jsx)(Fi,{...e,preview:n.preset?.preview})}function vo(){let{resolveMessage:e}=(0,f.useEditorI18n)(),t=(0,f.useTranslations)(`shell`),n=q(),r=J(),i=n.preset?.onboarding,{setState:a}=sr(),o=lr(),s=(0,g.useManifest)(),c=(0,g.useVault)(),p=s?.behavior||[],m=co(o.templates,p),h=lo(o.templates,o.selectedTemplateId,p),_=(0,u.useRef)(h?.id||null);_.current=h?.id||null;let v=(0,u.useMemo)(()=>i?mo(i,r):null,[i,r]),[y,b]=(0,u.useState)(!1),[x,S]=(0,u.useState)(!1);if((0,u.useEffect)(()=>{if(!v)return;let e=!m&&!fo(v);b(e),S(e)},[m,v]),(0,u.useEffect)(()=>{let e=e=>{e.detail===v&&(a({presetOnboardingPreviewHintKey:null}),b(!!i),S(!1))};return window.addEventListener(uo,e),()=>window.removeEventListener(uo,e)},[v,i,a]),!i||!v)return null;let C=()=>{o.setSelectedTemplateId(lo(o.templates,_.current)?.id||null),po(v),x&&a({presetOnboardingPreviewHintKey:v}),b(!1),S(!1)},w=e=>{_.current=e,o.setSelectedTemplateId(e);let t=o.templates.find(t=>t.id===e);if(!s||!t)return;let n=s.behavior||[],r=so(n,t);r.length===n.length&&r.every((e,t)=>e===n[t])||c.modifyEntityField(s,`behavior`,r)};return(0,d.jsx)(l.Modal,{title:e(i?.titleMessage,i.title),open:y,onClose:C,actions:(0,d.jsxs)(`div`,{className:`flex gap-2`,children:[(0,d.jsx)(l.ActionButton,{onPress:C,children:e(i?.dismissLabelMessage,i.dismissLabel)||t(`onboarding.close`)}),h?(0,d.jsx)(l.ActionButton,{primary:!0,onPress:()=>{w(_.current),C()},children:e(i?.primaryLabelMessage,i.primaryLabel)||t(`onboarding.continue`)}):null]}),children:(0,d.jsxs)(`div`,{className:`flex flex-col gap-4 p-6`,children:[e(i?.summaryMessage,i.summary)?(0,d.jsx)(`p`,{className:`text-sm text-gray-600`,children:e(i?.summaryMessage,i.summary)}):null,i.renderBody({i18n:{resolveMessage:e},...o,selectedTemplateId:h?.id||null,selectedTemplate:h,setSelectedTemplateId:w,dismiss:C})]})})}const yo=(0,u.memo)(function(e){let[t]=(0,l.useLocalStorage)(`menu-hidden`);return(0,d.jsx)(ni,{children:(0,d.jsxs)(ti,{children:[(0,d.jsx)(ri,{onClick:e.onClickLogo,children:(0,d.jsx)(l.ManifestEditorLogo,{})}),(0,d.jsx)(Xr,{}),(0,d.jsx)(Fi,{}),(0,d.jsx)(go,{}),(0,d.jsx)(ao,{})]})})}),bo=(0,u.createContext)(null);function xo(){return(0,u.useContext)(bo)||null}function So(e,t){let n=xo();return n?n[e][t]:null}function Co({children:e,menu:t}){return(0,d.jsx)(bo.Provider,{value:t,children:e})}function wo(){return(0,u.useContext)(g.AtlasStoreReactContext)}function To(){let e=wo();return(0,u.useLayoutEffect)(()=>e.subscribe((e,t)=>{if(e.tool.requestId===t.tool.requestId)return;let n=e.polygons;Object.assign(n.state,{transitionPoints:null,transitionBoundingBox:null,transitionOrigin:null,transitionDirection:null,transitionBezierLine:null,transitionDraw:[],transitionRotate:!1,selectionBox:null,line:null,lineBox:null}),n.setState({transitioning:!1,transitionIntentType:null,actionIntentType:null}),n.blur(),e.tool.requestId||n.setShape(null),e.requests[e.tool.requestId||``]?.type!==`target`&&n.unlockAspectRatio()}),[e]),null}function Eo(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 Do=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)}),Oo=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 ko(){}async function Ao(e,...t){if(!e)return;if(e.endsWith(`.mp3`)||e.endsWith(`.mp4`)||e.endsWith(`.m4a`)||e.endsWith(`.m4v`))try{let t=await Oo(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 No(e)}if(!n.ok&&(n=await fetch(e+`/info.json`),!n.ok))return No(e);let r=n.headers.get(`Content-Type`);if(r?.includes(`image/`))return No(e,r);let i=null;try{i=await n.json()}catch{return null}return await Mo(i,e)}function jo(e){return e.protocol&&e.protocol===`http://iiif.io/api/image`?(e.type||(e.type=`ImageService`),e):null}async function Mo(e,t){let n=jo(e);if(n)return n;if(!(e.id||e[`@id`]))return null;let r=await new x.Vault().load(t,e);if(r&&(r&&r?.type===`Manifest`||r?.type===`Collection`))return{id:t,type:r.type,label:(0,v.getValue)(r.label)}}async function No(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 Po(n.slice(0,n.length-4).join(`/`)+`/info.json`);if(e&&e?.type&&e?.type?.startsWith(`ImageService`))return e}}try{let n=await Do(e);return{id:e,type:`Image`,width:n.width,height:n.height,format:await Fo(e,t)}}catch{}return null}async function Po(e){try{let t=await fetch(e);return t.ok?await Mo(await t.json(),e):null}catch(e){return console.log(e),null}}async function Fo(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 Io(e){try{let t=await Do(e);if(t)return{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}}catch{return null}return null}const Lo=(0,p.create)(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 Ro(e){let t=(0,u.useMemo)(()=>Zt(),[]),n=Lo(e=>e.regions[t]),r=Lo(e=>e.setRegion);(0,u.useEffect)(()=>{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]),(0,u.useEffect)(()=>()=>r(t,null),[])}function zo(e){let t=Lo(e=>e.highlight),n=Lo(e=>e.clearHighlight);return(0,u.useEffect)(()=>()=>{e&&n(e)},[n,e]),(0,u.useMemo)(()=>({onMouseEnter(){e&&t(e)},onMouseLeave(){e&&n(e)}}),[e,t,n])}const Bo=y.default.div`
|
|
243
261
|
position: relative;
|
|
244
262
|
display: inline-block;
|
|
245
|
-
`;
|
|
263
|
+
`;y.default.div`
|
|
246
264
|
display: flex;
|
|
247
265
|
flex-direction: column;
|
|
248
266
|
position: absolute;
|
|
@@ -257,7 +275,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
257
275
|
background-color: ${e=>e.theme.color.lightgrey||`lightgrey`};
|
|
258
276
|
}
|
|
259
277
|
}
|
|
260
|
-
`;const
|
|
278
|
+
`;const Vo=y.default.button`
|
|
261
279
|
padding: 0 ${e=>e.theme.padding.small||`0.5rem`};
|
|
262
280
|
color: ${e=>e.theme.color.main||`none`};
|
|
263
281
|
background-color: ${e=>e.theme.color.white||`white`};
|
|
@@ -276,7 +294,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
276
294
|
background-color: ${e=>e.theme.color.lightgrey||`lightgrey`};
|
|
277
295
|
}
|
|
278
296
|
|
|
279
|
-
${e=>e.$active&&
|
|
297
|
+
${e=>e.$active&&y.css`
|
|
280
298
|
background: #b84c74;
|
|
281
299
|
color: #fff;
|
|
282
300
|
&:hover {
|
|
@@ -284,7 +302,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
284
302
|
color: #fff;
|
|
285
303
|
}
|
|
286
304
|
`}
|
|
287
|
-
`,
|
|
305
|
+
`,Ho=y.default.div`
|
|
288
306
|
display: none;
|
|
289
307
|
flex-direction: column;
|
|
290
308
|
position: absolute;
|
|
@@ -302,26 +320,26 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
302
320
|
overflow: hidden;
|
|
303
321
|
padding-bottom: 3px;
|
|
304
322
|
|
|
305
|
-
${
|
|
323
|
+
${X} {
|
|
306
324
|
&:hover {
|
|
307
325
|
background-color: ${e=>e.theme.color.lightgrey||`lightgrey`};
|
|
308
326
|
}
|
|
309
327
|
}
|
|
310
328
|
|
|
311
|
-
${e=>e.$open&&
|
|
329
|
+
${e=>e.$open&&y.css`
|
|
312
330
|
display: flex;
|
|
313
331
|
`}
|
|
314
|
-
`,
|
|
332
|
+
`,Uo=y.default.div`
|
|
315
333
|
color: #999;
|
|
316
334
|
text-transform: uppercase;
|
|
317
335
|
font-weight: 600;
|
|
318
336
|
padding: 0.7em;
|
|
319
337
|
font-size: 0.875em;
|
|
320
|
-
`,
|
|
338
|
+
`,Wo=y.default.div`
|
|
321
339
|
height: 1px;
|
|
322
340
|
margin: 0 0.5em;
|
|
323
341
|
background: #eee;
|
|
324
|
-
|
|
342
|
+
`,Go=({style:e})=>(0,d.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`1rem`,viewBox:`0 0 24 24`,width:`1rem`,fill:`#000000`,style:e,children:[(0,d.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,d.jsx)(`path`,{d:`M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z`})]}),Ko=e=>(0,d.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`1em`,width:`1em`,viewBox:`0 0 24 24`,...e,children:[(0,d.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,d.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,d.jsx)(`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 qo(e){return e&&e.pinnable}function Jo({initial:e,fallback:t,options:n={}}){return Math.max(n.minWidth||0,Math.min(n.maxWidth||1/0,e||t))}function Yo(e){return typeof e==`string`?(0,u.createElement)(`div`,{dangerouslySetInnerHTML:{__html:e}}):e}function Xo(e){let t=(0,f.useTranslations)(`shell`),n=e.error.toString(),[r,i]=(0,u.useState)(!1);return(0,d.jsxs)(l.PaddedSidebarContainer,{children:[(0,d.jsx)(l.ErrorMessage,{className:`mb-2`,children:t(`panels.error`)}),(0,d.jsxs)(`details`,{className:`mb-2 text-sm`,children:[(0,d.jsx)(`summary`,{children:t(`panels.technicalDetails`)}),(0,d.jsx)(`pre`,{className:`whitespace-pre-wrap`,children:n})]}),(0,d.jsx)(Ci,{onClick:e.resetErrorBoundary,children:t(`actions.retry`)})]})}const Zo=(0,u.createContext)(null);function Qo(){return(0,u.useContext)(Zo)}const $o=y.default.div`
|
|
325
343
|
display: flex;
|
|
326
344
|
flex-direction: column;
|
|
327
345
|
position: relative;
|
|
@@ -377,7 +395,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
377
395
|
&[data-state="unmounted"] {
|
|
378
396
|
transform: translateX(100%);
|
|
379
397
|
}
|
|
380
|
-
`,
|
|
398
|
+
`,es=y.default.div`
|
|
381
399
|
background: #fff;
|
|
382
400
|
display: flex;
|
|
383
401
|
height: 2.8em;
|
|
@@ -399,7 +417,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
399
417
|
background: #ffc2d2;
|
|
400
418
|
box-shadow: inset 0 -5px 10px 0 rgba(255, 255, 255, 0.5);
|
|
401
419
|
}
|
|
402
|
-
`,
|
|
420
|
+
`,ts=y.default.button`
|
|
403
421
|
border: none;
|
|
404
422
|
background: transparent;
|
|
405
423
|
padding: 0 0.4em;
|
|
@@ -420,9 +438,9 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
420
438
|
svg {
|
|
421
439
|
font-size: 1.2em;
|
|
422
440
|
}
|
|
423
|
-
`,
|
|
441
|
+
`,ns=y.default.div`
|
|
424
442
|
flex: 1 1 0px;
|
|
425
|
-
`,
|
|
443
|
+
`,rs=y.default.h2`
|
|
426
444
|
font-size: 0.875em;
|
|
427
445
|
font-weight: 400;
|
|
428
446
|
margin: 0;
|
|
@@ -430,7 +448,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
430
448
|
padding-left: 1em;
|
|
431
449
|
text-align: center;
|
|
432
450
|
align-self: center;
|
|
433
|
-
`,
|
|
451
|
+
`,is=y.default.div`
|
|
434
452
|
flex: 1 1 0px;
|
|
435
453
|
display: flex;
|
|
436
454
|
|
|
@@ -441,13 +459,20 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
441
459
|
> * {
|
|
442
460
|
min-width: 0;
|
|
443
461
|
}
|
|
444
|
-
`;function mo({panel:e,state:t,actions:n,isLeft:r,pinActions:i=n,transition:a,close:o,available:s=[],style:c,noHeader:l,isModal:f}){let p=(0,u.useContext)(m.ReactVaultContext)||null,[h,g]=(0,u.useState)(!1),_=Un(),v=pi(),{tabs:y,pinnable:b,hideHeader:x}=e?.options||{},S=(0,u.useMemo)(()=>(s||[]).filter(e=>!e.requiresState),[s]),{itemProps:w,isOpen:T,setIsOpen:E}=ir(S.length),[D,O]=(0,u.useState)(``),ee=(0,u.useRef)(void 0);(0,u.useEffect)(()=>g(!1),[_.state.canvasId,e?.id]),(0,u.useEffect)(()=>O(``),[e]),(0,u.useEffect)(()=>(ee.current=O,()=>{ee.current=void 0}),[]);let k=(0,u.useCallback)(e=>{ee.current&&ee.current(e)},[]),A=(0,u.useCallback)(r=>{let i=e?t.stack.length?n.popStack:e.backAction?()=>e&&e.backAction&&e.backAction(t,{...v,current:n},_):null:null;r&&(!i||r.metaKey)&&S.length?(r.preventDefault(),E(!0)):i?.()},[n,_,v,e,E,t,S.length]),j=r=>{n.change({id:r.id,state:r.defaultState,stacked:!!(t.stack.length||e?.backAction)})};if(!e||!t.current)return null;let M=e.backAction||t.stack.length?(0,d.jsx)(lo,{"aria-label":`Back`,onClick:A,children:(0,d.jsx)($a,{"aria-hidden":`true`})}):null,N=(0,d.jsx)(lo,{"aria-label":`Close panel`,onClick:o||n.close,children:(0,d.jsx)(tr,{"aria-hidden":`true`})});return(0,d.jsx)(ao.Provider,{value:k,children:(0,d.jsxs)(so,{"data-modal":f,"data-state":a,"data-flipped":r,style:c,"data-header":!l,children:[l?null:(0,d.jsxs)(co,{"data-tabs":!!y,"data-error":h,children:[(0,d.jsxs)(Ja,{style:{display:`flex`,height:`100%`},children:[e.renderBackAction?e.renderBackAction({backAction:A,fallback:M}):M,S.length?(0,d.jsxs)(Xa,{$open:T,role:`menu`,style:{left:`0.5em`},children:[(0,d.jsx)(Za,{children:`All panels`}),(0,d.jsx)(Qa,{}),S.map((t,n)=>(0,d.jsx)(Ya,{...w[n],onClick:()=>j(t),$active:e.id===t.id,children:t.label},n))]}):null]}),D?(0,d.jsx)(fo,{as:r?`h1`:`h2`,children:D}):x?(0,d.jsx)(uo,{}):(0,d.jsx)(fo,{as:r?`h1`:`h2`,children:e.label}),b?t.pinned?(0,d.jsx)(lo,{"aria-label":`Unpin panel`,onClick:i.unpin,children:(0,d.jsx)(eo,{"aria-hidden":`true`,fill:`orange`})}):(0,d.jsx)(lo,{"aria-label":`Pin panel`,onClick:()=>i.pin({id:e.id,state:t.state}),children:(0,d.jsx)(eo,{"aria-hidden":`true`,fill:`#ddd`})}):null,e.renderCloseAction?e.renderCloseAction({closeAction:o||n.close,fallback:N}):N]}),(0,d.jsx)(po,{className:`OverrideScrollbar`,children:(0,d.jsx)(C.ErrorBoundary,{onError:()=>g(!0),FallbackComponent:io,resetKeys:[_.state.canvasId,e?.id],onReset:()=>g(!1),children:ro(e.render(t.state||e.defaultState||{},{...v,current:n,vault:p,transition:a,isModal:f},_))})})]})})}function ho(e=`vault://homepage-collection.json`){let t=new x.Vault,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((0,w.requestResource)({id:i.id}));let e=(0,T.actionListFromResource)(i.id,i);t.dispatch((0,w.batchActions)({actions:e})),r=!0}}catch{}if(!r){let n=(0,T.actionListFromResource)(e,{"@context":`http://iiif.io/api/presentation/3/context.json`,id:e,type:`Collection`,label:{en:[`Recent items`]},items:[]});t.dispatch((0,w.requestResource)({id:e})),t.dispatch((0,w.batchActions)({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((0,w.addReference)({id:e,type:`Collection`,reference:{id:n,type:r},key:`items`,index:0})):t.dispatch((0,w.reorderEntityField)({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((0,w.modifyEntityField)({id:e,type:`Collection`,key:`items`,value:[]})),window.localStorage.setItem(`preview-vault-collection`,JSON.stringify(t.toPresentation3({id:e,type:`Collection`})))}}}function go(){return(0,u.useContext)(_o)}const _o=(0,u.createContext)(new x.Vault),vo=(0,u.createContext)({addHistory:(e,t)=>{},clearHistory:()=>{}}),yo=`manifest-editor://homepage-collection.json`;function bo(){return(0,u.useContext)(vo)}function xo(e){let{vault:t,unsubscribe:n,addHistory:r,clearHistory:i}=(0,u.useMemo)(()=>ho(yo),[]);return(0,u.useEffect)(()=>n,[]),(0,d.jsx)(vo.Provider,{value:{addHistory:r,clearHistory:i},children:(0,d.jsx)(_o.Provider,{value:t,children:e.children})})}function So({children:e}){let t=go();return(0,d.jsx)(m.VaultProvider,{vault:t,children:e})}function Co(e,t,n,r,i){let a=(0,m.useVault)(),o=U(),{create:s,edit:c}=ui(),l=(0,u.useMemo)(()=>(0,S.matchBasedOnResource)({type:n,parent:e,index:0,property:t},o.layout.creators||[],{vault:a}),[e,t,o.layout.creators,n,a]),d=e&&l.length!==0,f=(0,u.useCallback)((a,o)=>{if(e)return s({type:n,parent:(0,h.toRef)(e),property:t,index:a,target:r,initialData:o,...i||{}})},[s,e,t,n,i,r]),p=(0,u.useCallback)((a,o,c)=>{if(e)return s({type:n,filter:a,parent:(0,h.toRef)(e),property:t,index:o,target:r,initialData:c,...i||{}})},[s,e,t,n,i,r]);return[d,{create:f,edit:(0,u.useCallback)((n,r)=>{c(n,e?{parent:(0,h.toRef)(e),property:t,index:r}:void 0)},[c,e,t]),createFiltered:p,creator:(0,u.useCallback)((a,o)=>{if(e)return s({type:n,initialCreator:a,parent:(0,h.toRef)(e),property:t,target:r,initialData:o,...i||{}})},[n,t,e,r,s,i]),buttonProps:(0,u.useMemo)(()=>({"data-action-id":Pt(n,t,e)}),[n,t,e])}]}function wo(){let e=(0,m.useVault)(),t=go(),n=U(),r=z();return(0,u.useMemo)(()=>new S.Creator(e,n.layout.creators||[],t,r.creators),[n.layout.creators,r.creators,t,e])}async function To(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 Eo=(0,u.createContext)({});function Do(e){return(0,u.useContext)(Eo)[e]||{}}function Oo(e){let t=(0,u.useContext)(Eo),n=(0,u.useMemo)(()=>({...t,[e.id]:e.data}),[t,e.id,e.data]);return(0,d.jsx)(Eo.Provider,{value:n,children:e.children})}const ko=(0,u.memo)(function(e){let t=(0,m.useVault)(),{edit:n,modal:r}=ui(),[i,a]=(0,u.useState)(!1),[o,s]=(0,u.useState)(null),c=wo(),f=z(),p=(0,u.useRef)(!1),g=e.resource.initialData?.selector;Ka(g);let _=Do(e.creator.id),v={targetType:e.resource.type,parent:e.resource.parent?{property:e.resource.property,atIndex:e.resource.index,resource:e.resource.parent}:void 0,target:e.resource.target,initialData:{..._,...e.resource.initialData||{},...e.initialData||{}}},y=async t=>{if(!(i||p.current)){a(!0),p.current=!0;try{await To({create:()=>c.create(e.creator.id,t,v),onCreate:e.onCreate,close:e.skipEditingOnCreate?void 0:()=>{r.popStack(),r.close()},edit:e.skipEditingOnCreate||e.resource.initialData?.skipEditingOnCreate?void 0:t=>n(t,{parent:(0,h.toRef)(e.resource.parent),property:e.resource.property,index:e.resource.index})})}catch(e){s(e?.message||`Unknown error`)}finally{a(!1),p.current=!1}}},b=async()=>!0;if((0,u.useEffect)(()=>{e.resource.initialData?.showEmptyForm||!e.creator.render&&!i&&y({})},[e.creator]),o)return(0,d.jsx)(`div`,{className:`flex flex-col items-center p-4`,children:(0,d.jsx)(l.ErrorMessage,{children:o})});let x=(0,d.jsx)(`div`,{className:`flex flex-col items-center py-8`,children:(0,d.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,d.jsx)(l.Spinner,{}),` `,(0,d.jsx)(`span`,{children:`Loading`})]})});return i?x:e.creator.render?(0,d.jsx)(d.Fragment,{children:(0,d.jsx)(u.Suspense,{fallback:x,children:e.creator.render({vault:t,runCreate:y,validate:b,options:v,config:f.creators?.[(0,S.getCreatorConfigKey)(e.creator)]||{}})})}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(l.EmptyState,{children:`No options available`}),(0,d.jsx)(l.ActionButton,{primary:!0,onPress:()=>y({}),children:e.creator.actionButton||`Create`})]})});function Ao(e){let t=U(),n=(0,m.useVault)(),[r,i]=(0,u.useState)(e.resource.initialCreator||``),[a,o]=(0,u.useState)(),[s,c]=(0,u.useState)(``),[f,p]=(0,u.useState)(!1),[h,g]=(0,u.useState)(``),[_,v]=(0,u.useState)(null),y=(0,u.useRef)(null),b=oo(),x=(0,u.useMemo)(()=>(0,S.matchBasedOnResource)(e.resource,t.layout.creators||[],{vault:n}),[e.resource,t.layout.creators,n]),C=x.some(e=>e.supportsResource);(0,u.useEffect)(()=>{x.length===1&&!r&&!C&&i(x[0].id)},[C,r,x]),(0,u.useEffect)(()=>{C&&!r&&y.current?.focus()},[C,r]);let w=x.find(e=>e.id===r);if((0,u.useEffect)(()=>{w&&b?.(w.label)}),x.length===0)return(0,d.jsx)(l.EmptyState,{children:`Not currently supported`});let T=(e,t)=>{o(t||Po(s)),i(e.id)},E=async t=>{t.preventDefault();let r=s.trim();if(!r||f)return;p(!0),g(``),v(null);let i=Fo(),a=await Promise.all(x.map(async t=>{if(!t.supportsResource)return null;try{let a=await t.supportsResource(r,i,{vault:n,resource:e.resource});return a?{creator:t,initialData:No(r,a).initialData}:null}catch(e){return{creator:t,error:e?.message||`Could not check this link`}}})),o=a.filter(jo),c=a.filter(Mo);if(p(!1),o.length===1){T(o[0].creator,o[0].initialData);return}if(o.length>1){v(o),g(`Multiple creators can use this link. Choose one below.`);return}g(c[0]?.error||`No creator recognised this link. Choose one below.`)},D=(0,d.jsx)(l.ModalBackSlot,{children:(0,d.jsx)(l.IconButton,{root:document.getElementById(`headlessui-portal-root`)||void 0,label:`Back to Add content options`,className:`group`,placement:`right`,onPress:()=>{i(``),o(void 0)},children:(0,d.jsx)(l.GridIcon,{className:`text-2xl opacity-50 group-hover:opacity-70`})})});if(w)return w.hiddenModal?(0,d.jsxs)(d.Fragment,{children:[D,(0,d.jsx)(ko,{creator:w,resource:e.resource,initialData:a})]}):(0,d.jsxs)(`div`,{children:[D,(0,d.jsx)(`div`,{className:`p-2 py-6`,children:(0,d.jsx)(ko,{creator:w,resource:e.resource,initialData:a})})]});let O=_?.length?_.map(e=>e.creator):x,ee=new Map(_?.map(e=>[e.creator.id,e.initialData]));return(0,d.jsxs)(d.Fragment,{children:[C?(0,d.jsxs)(`form`,{className:`p-4 pb-0`,onSubmit:E,children:[(0,d.jsx)(`label`,{className:`block text-sm font-medium text-gray-700`,htmlFor:`creator-resource-link`,children:`Paste a link`}),(0,d.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,d.jsx)(`input`,{ref:y,id:`creator-resource-link`,className:`min-w-0 flex-1 rounded border border-gray-300 px-3 py-2 text-sm`,value:s,onChange:e=>{c(e.currentTarget.value),g(``),v(null)},placeholder:`https://example.org/resource`,type:`url`}),(0,d.jsx)(l.ActionButton,{primary:!0,type:`submit`,isDisabled:!s.trim()||f,children:f?`Checking`:`Use link`})]}),h?(0,d.jsx)(`div`,{className:`mt-2 text-sm text-gray-600`,role:`status`,children:h}):null]}):null,(0,d.jsx)(l.CreatorGrid,{label:`Select a type`,items:O.map(e=>({id:e.id,title:e.label,description:e.summary||``,icon:e.icon,onClick:()=>T(e,ee.get(e.id))}))})]})}function jo(e){return!!e&&!(`error`in e)}function Mo(e){return!!e&&`error`in e}function No(e,t){return typeof t==`object`?t:{initialData:Po(e)}}function Po(e){let t=e.trim();return t?{url:t,youtubeUrl:t}:void 0}function Fo(){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 Io={id:`@manifest-editor/creator`,label:`Add content`,options:{hideHeader:!0,tabs:!1},render(e){return(0,d.jsx)(Ao,{resource:e})}},Lo={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 Ro(e){let{}=e,t=(0,m.useVault)(),n=U(),r=(0,u.useMemo)(()=>(0,S.matchBasedOnResource)(e.resource,n.layout.creators||[],{vault:t}),[e.resource,n.layout.creators,t]);return r.length===0?(0,d.jsx)(`div`,{children:`No supported creators found`}):(0,d.jsx)(`div`,{children:(0,d.jsxs)(l.Tabs,{className:`w-full flex-1 overflow-hidden flex flex-col`,children:[(0,d.jsx)(l.TabList,{className:`flex-1 overflow-hidden w-full flex text-sm whitespace-nowrap`,items:r,children:e=>(0,d.jsx)(l.Tab,{id:e.id,children:e.label})}),r.map(t=>(0,d.jsx)(l.TabPanel,{id:t.id,className:`p-2`,children:(0,d.jsx)(g.ThemeProvider,{theme:Lo,children:(0,d.jsx)(ko,{creator:t,resource:e.resource,onCreate:e.onCreate,skipEditingOnCreate:!0})})},t.id))]})})}function zo({fallback:e,backAction:t}){let n=Xr(),{back:r}=Jr();return n.length?(0,d.jsx)(lo,{"aria-label":`Back`,onClick:r,children:(0,d.jsx)($a,{"aria-hidden":`true`})}):e}function Bo({closeAction:e,fallback:t}){let n=Xr();return Yr()||n.length?(0,d.jsx)(lo,{"aria-label":`Close panel`,onClick:()=>{e()},children:(0,d.jsx)(tr,{"aria-hidden":`true`})}):t}function Vo(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 Ho({currentTab:e=void 0}){let t=Yr(),n=(0,u.useContext)(m.ResourceReactContext),r=U(),i=W(),a=(0,m.useVault)(),{change:o}=ui(),s=oo(),{editorConfig:c}=z(),f=t?.resource.source?.id,p=t?.resource.source?.type,h=f!==i.id;f&&h&&i.type===`Collection`&&p===`Collection`&&(p=`EmbeddedCollection`);let g=(p?c[p]:c.All)||{},_=(0,u.useMemo)(()=>{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 v(e){return t?(0,d.jsx)(m.ResourceReactContext.Provider,{value:_,children:e}):e}let y=(0,u.useMemo)(()=>{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 Vo(t,n,{edit:!0,vault:a},g)},[t,r]);(0,u.useEffect)(()=>{s(y?.label||``)},[y]),(0,u.useEffect)(()=>{let t=y?.editors.map(e=>e.id)||[];t.find(t=>t===e)||o(`@manifest-editor/editor`,{currentTab:t[0]})},[y?.editors,e,o]);let b=(0,u.useMemo)(()=>(y?.editors||[]).map(e=>({id:e.id,label:e.label,renderComponent:()=>e.component(g)})),[y?.editors,g]);if(!t||!y)return null;if(g.singleTab){let e=(y?.editors||[]).find(e=>e.id===g.singleTab);if(e)return v((0,d.jsx)(`div`,{className:`w-full`,children:e.component(g)},t.resource.source?.id))}return v((0,d.jsx)(l.SidebarTabs,{isNested:h,rootResource:i,menuId:t.resource.source.id,menu:b,selectedKey:e,onSelectionChange:e=>{o(`@manifest-editor/editor`,{currentTab:e})}},t.resource.source?.id))}const Uo={id:`@manifest-editor/editor`,label:`Editor`,options:{hideHeader:!0,tabs:!0,minWidth:400},renderBackAction:({backAction:e,fallback:t})=>(0,d.jsx)(zo,{backAction:e,fallback:t}),renderCloseAction:({closeAction:e,fallback:t})=>(0,d.jsx)(Bo,{closeAction:e,fallback:t}),render({currentTab:e}){return(0,d.jsx)(Ho,{currentTab:e})}};function Wo(e){let[t,n]=(0,u.useState)(!1),r=(0,u.useRef)(null),i=(0,u.useRef)(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(0,u.useMemo)(()=>[t,{set:o,clear:a}],[t])}function Go(e){return e?typeof e==`string`?{src:e,alt:``}:e:null}function Ko(e){return e?typeof e==`string`?e:e.name:null}function qo(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 Jo(e){return e instanceof Error?e.message:`Plugin configuration could not be saved.`}function Yo(e){return(0,d.jsxs)(`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:[(0,d.jsx)(`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`}),(0,d.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]})}function Xo(e){return(0,d.jsxs)(`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:[(0,d.jsx)(`path`,{d:`M7 7h10v10`}),(0,d.jsx)(`path`,{d:`M7 17 17 7`})]})}function Zo(){let e=U(),{appId:t}=Hn(),n=z(),r=ie(),i=An(),a=Mn(),o=ui(),{saveGlobalPluginConfig:s}=(0,u.useContext)(Tn),[c,f]=(0,u.useState)(!1),[p,m]=(0,u.useState)(``),[h,g]=(0,u.useState)(null),[_,v]=(0,u.useState)(null),[y,b]=(0,u.useState)(null),x=(0,u.useMemo)(()=>new Set(un(i,e,t).map(e=>e.metadata.id)),[i,e,t]),S=(0,u.useMemo)(()=>{let n=p.trim().toLowerCase();return i.plugins.filter(r=>{let i=on(r,e,t);return!c&&!i?!1:!n||[r.metadata.label,r.metadata.id,r.metadata.description,Ko(r.metadata.author),...r.metadata.tags||[]].filter(Boolean).join(` `).toLowerCase().includes(n)})},[e,t,i.plugins,p,c]),C=h&&i.plugins.find(e=>e.metadata.id===h)||null;if(!i.plugins.length)return null;function w(e){a.setAppConfig(t,e),r({plugins:{...n.plugins||{},apps:{...n.plugins?.apps||{},[t]:e}}})}async function T(e){if(!s){b(`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),b(Jo(e))}}async function E(n,r,a){b(null),v(`${a}:${n.metadata.id}`);let o=a===`global`?i.globalApps[t]||{}:i.apps[t]||{},s=r?_n(o,i,n,e,t):{config:Yt(o,n.metadata.id),blocked:[]};if(s.blocked.length){v(null),b(`Cannot enable ${n.metadata.label}: ${s.blocked.join(`, `)}.`);return}a===`global`?await T(s.config):w(s.config),v(null)}function D(e){let t=qo(e);if(t){if(t.modal){o.modal.open({id:t.id});return}o.open(t.id)}}return(0,d.jsxs)(`section`,{className:`flex flex-col gap-3 border-t border-gray-200 pt-4 mt-4`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,d.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,d.jsx)(`h3`,{className:`font-semibold text-sm text-gray-900`,children:`Plugins`})}),(0,d.jsx)(`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:()=>f(e=>!e),children:c?`Compatible only`:`Show all`})]}),(0,d.jsx)(`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:p,onChange:e=>m(e.currentTarget.value)}),y?(0,d.jsx)(`div`,{className:`rounded border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:y}):null,(0,d.jsx)(`div`,{className:`flex flex-col gap-2`,children:S.map(n=>{let r=cn(n,i,t),a=x.has(n.metadata.id),o=r&&n.loadStatus===`loading`,s=r&&n.loadStatus===`error`?n.loadError:null,c=Go(n.metadata.image),u=r&&!a&&!o&&!s,f=on(n,e,t),p=sn(n,e,t),m=qo(n),h=!!n.settings,v=_===`workspace:${n.metadata.id}`;return(0,d.jsxs)(`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`} ${f?``:`bg-gray-100`}`,children:[c?(0,d.jsx)(`img`,{className:`h-9 w-9 rounded object-cover flex-none mt-0.5`,src:c.src,alt:c.alt||n.metadata.label}):(0,d.jsx)(`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:(0,d.jsx)(Yo,{className:`w-4 h-4`})}),(0,d.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,d.jsxs)(`div`,{className:`flex items-start justify-between gap-1`,children:[(0,d.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 min-w-0`,children:[(0,d.jsx)(`span`,{className:`font-medium text-gray-900 text-xs`,children:n.metadata.label}),n.metadata.official?(0,d.jsxs)(`span`,{className:`rounded-full text-me-primary-500 px-1.5 py-0 text-[9px] font-bold inline-flex items-center gap-1`,children:[(0,d.jsx)(l.CheckIcon,{className:`w-3 h-3`}),` Verified`]}):null,n.metadata.version?(0,d.jsx)(`span`,{className:`text-[10px] text-gray-600`,children:n.metadata.version}):null]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-1 flex-none`,children:[h?(0,d.jsx)(`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:()=>g(n.metadata.id),children:(0,d.jsx)(Yo,{className:`w-3.5 h-3.5`})}):null,a&&m?(0,d.jsx)(`button`,{type:`button`,title:`Open ${m.label}`,"aria-label":`Open ${m.label}`,className:`rounded p-1 text-me-primary-500 hover:bg-me-primary-50 transition-colors`,onClick:()=>D(n),children:(0,d.jsx)(Xo,{className:`w-3.5 h-3.5`})}):null,(0,d.jsx)(`button`,{type:`button`,disabled:!f||v,onClick:()=>E(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:(0,d.jsx)(`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?(0,d.jsx)(`p`,{className:`text-xs text-gray-500 leading-relaxed`,children:n.metadata.description}):null,o?(0,d.jsx)(`span`,{className:`text-xs text-gray-500`,children:`Loading plugin…`}):null,s?(0,d.jsx)(`span`,{className:`text-xs text-red-600`,children:s}):null,u?(0,d.jsx)(`span`,{className:`text-xs text-amber-600`,children:`Waiting for required dependencies`}):null,!f&&p?(0,d.jsx)(`span`,{className:`text-xs text-gray-600`,children:p}):null]})]},n.metadata.id)})}),S.length?null:(0,d.jsx)(`div`,{className:`rounded-lg border border-gray-100 bg-gray-50 p-4 text-center text-xs text-gray-500`,children:`No plugins found.`}),C?(0,d.jsx)(l.Modal,{title:`Configure ${C.metadata.label}`,onClose:()=>g(null),width:`560px`,children:(0,d.jsx)(Qo,{plugin:C,onClose:()=>g(null),canSaveGlobal:!!s})}):null]})}function Qo({plugin:e,onClose:t,canSaveGlobal:n}){let r=Fn(e.metadata.id),[i,a]=(0,u.useState)(`workspace`),[o,s]=(0,u.useState)({}),[c,l]=(0,u.useState)(!1),[f,p]=(0,u.useState)(!1),[m,h]=(0,u.useState)(null),g=i===`global`?r.global:r.workspace;(0,u.useEffect)(()=>{s({...g}),h(null),p(!1)},[e.metadata.id,i]);async function _(){let t=e.settings?.validate?.(o);if(t){h(t);return}l(!0),h(null);try{i===`global`?await r.setGlobalSettings(o):r.setWorkspaceSettings(o),p(!0),setTimeout(()=>p(!1),2e3)}catch(e){h(Jo(e))}finally{l(!1)}}async function v(){l(!0),h(null);try{i===`global`?await r.resetGlobalSettings():r.resetWorkspaceSettings(),s({})}catch(e){h(Jo(e))}finally{l(!1)}}let y=n&&r.canSaveGlobal;return(0,d.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[y?(0,d.jsxs)(`div`,{className:`flex items-center gap-1 px-5 pt-4 pb-3 border-b border-gray-100`,children:[(0,d.jsx)(`span`,{className:`text-xs text-gray-500 mr-2`,children:`Scope:`}),(0,d.jsx)(`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`}),(0,d.jsx)(`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,m?(0,d.jsx)(`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:m}):null,(0,d.jsx)(`div`,{className:`flex-1 overflow-y-auto p-5`,children:(0,d.jsx)(`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=>(0,d.jsx)($o,{field:e,draft:o,setDraft:s},e.id)):(0,d.jsx)(`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.`})})}),(0,d.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-gray-100 px-5 py-4`,children:[(0,d.jsx)(`button`,{type:`button`,className:`text-xs text-gray-600 hover:text-gray-700 transition-colors disabled:opacity-40`,disabled:c,onClick:v,children:`Reset to defaults`}),(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[f?(0,d.jsx)(`span`,{className:`text-xs text-green-600`,children:`✓ Saved`}):null,(0,d.jsx)(`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:_,children:c?`Saving…`:`Save ${i}`})]})]})]})}function $o({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=(0,d.jsx)(`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`?(0,d.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[(0,d.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[o,e.description?(0,d.jsx)(`span`,{className:`text-xs text-gray-500`,children:e.description}):null]}),(0,d.jsx)(`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`?(0,d.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[o,e.description?(0,d.jsx)(`span`,{className:`text-xs text-gray-500`,children:e.description}):null,(0,d.jsx)(`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`?(0,d.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[o,e.description?(0,d.jsx)(`span`,{className:`text-xs text-gray-500`,children:e.description}):null,(0,d.jsxs)(`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:[(0,d.jsx)(`option`,{value:``,children:`Default`}),(e.options||[]).map(e=>(0,d.jsx)(`option`,{value:String(e.value),children:e.label},String(e.value)))]})]}):(0,d.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[o,e.description?(0,d.jsx)(`span`,{className:`text-xs text-gray-500`,children:e.description}):null,(0,d.jsx)(`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 es(){let e=z(),t=ie(),n=e.creators[`iiif-image-services`]||{};return(0,d.jsxs)(l.Form.Form,{className:`flex max-w-3xl flex-col gap-4`,onChange:e=>{let n=new FormData(e.currentTarget);t({creators:{"iiif-image-services":{compact:n.get(`compact`)===`compact`?`compact`:`with-dimensions`,includeSizes:n.get(`includeSizes`)===`on`,includeTiles:n.get(`includeTiles`)===`on`}}})},onSubmit:e=>e.preventDefault(),children:[(0,d.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900`,children:`IIIF Options`}),(0,d.jsxs)(`fieldset`,{className:`flex flex-col gap-4`,children:[(0,d.jsx)(`legend`,{className:`mb-3 text-base font-semibold`,children:`Image services`}),(0,d.jsxs)(l.Form.InputContainer,{children:[(0,d.jsx)(l.Form.Label,{htmlFor:`compactImageServices`,children:`Compact services`}),(0,d.jsxs)(`select`,{id:`compactImageServices`,name:`compact`,className:`rounded border border-gray-300 p-2`,defaultValue:n.compact===`compact`?`compact`:`with-dimensions`,children:[(0,d.jsx)(`option`,{value:`with-dimensions`,children:`id, type, profile, width, height (default)`}),(0,d.jsx)(`option`,{value:`compact`,children:`id, type, profile (compact)`})]})]}),(0,d.jsxs)(l.Form.InputContainer,{horizontal:!0,children:[(0,d.jsx)(l.Form.Input,{id:`includeSizes`,name:`includeSizes`,type:`checkbox`,defaultChecked:n.includeSizes===!0}),(0,d.jsx)(l.Form.Label,{htmlFor:`includeSizes`,children:`Include sizes`})]}),(0,d.jsxs)(l.Form.InputContainer,{horizontal:!0,children:[(0,d.jsx)(l.Form.Input,{id:`includeTiles`,name:`includeTiles`,type:`checkbox`,defaultChecked:n.includeTiles===!0}),(0,d.jsx)(l.Form.Label,{htmlFor:`includeTiles`,children:`Include tiles`})]}),(0,d.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Applies to newly added images. Thumbnails always include available sizes and tiles.`})]})]})}function ts(){let e=Cr(),t=W(),n=z(),r=ie(),[i,a]=Wo(2e3);function o(e){e.preventDefault();let t=new FormData(e.target),i={defaultPreview:t.get(`defaultPreview`),i18n:{...n.i18n||{},advancedLanguageMode:t.get(`advancedLanguageMode`)===`on`,availableLanguages:(t.get(`availableLanguages`)||``).split(`,`).map(e=>e.trim()),defaultLanguage:t.get(`defaultLanguage`)},export:{...n.export||{},version:t.get(`isVersion2`)===`on`?2:3,baseIdentifier:t.get(`base`)||null},plugins:n.plugins,editorFeatureFlags:{...n.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`}};r(i),a.set(),a.clear()}return(0,d.jsxs)(l.Sidebar,{children:[(0,d.jsx)(l.SidebarHeader,{title:`Workspace configuration`}),i?(0,d.jsx)(`div`,{className:`bg-me-primary-500 text-white p-3 text-sm`,children:`Changes saved`}):null,(0,d.jsxs)(l.SidebarContent,{className:`p-4`,children:[(0,d.jsx)(es,{}),(0,d.jsxs)(l.Form.Form,{onSubmit:o,className:`flex flex-col gap-3`,children:[(0,d.jsxs)(l.Form.InputContainer,{children:[(0,d.jsx)(l.Form.Label,{htmlFor:`defaultLanguage`,children:`Default Language`}),(0,d.jsx)(l.Form.Input,{type:`text`,name:`defaultLanguage`,id:`defaultLanguage`,defaultValue:n.i18n?.defaultLanguage||``})]}),(0,d.jsxs)(l.Form.InputContainer,{children:[(0,d.jsx)(l.Form.Label,{htmlFor:`availableLanguages`,children:`Available Languages`}),(0,d.jsx)(l.Form.Input,{type:`text`,name:`availableLanguages`,id:`availableLanguages`,defaultValue:(n.i18n?.availableLanguages||[]).join(`, `)})]}),(0,d.jsxs)(l.Form.InputContainer,{horizontal:!0,className:`my-3`,children:[(0,d.jsx)(l.Form.Input,{type:`checkbox`,name:`advancedLanguageMode`,id:`advancedLanguageMode`,defaultChecked:n.i18n?.advancedLanguageMode||!1}),(0,d.jsx)(l.Form.Label,{htmlFor:`advancedLanguageMode`,children:`Advanced Language Mode`})]}),(0,d.jsxs)(l.Form.InputContainer,{horizontal:!0,className:`my-3`,children:[(0,d.jsx)(l.Form.Input,{type:`checkbox`,name:`textGranularityEnabled`,id:`textGranularityEnabled`,defaultChecked:n.i18n?.textGranularityEnabled||!1}),(0,d.jsx)(l.Form.Label,{htmlFor:`textGranularityEnabled`,children:`Enable text granularity`})]}),(0,d.jsxs)(l.Form.InputContainer,{horizontal:!0,className:`my-3`,children:[(0,d.jsx)(l.Form.Input,{type:`checkbox`,name:`rememberCanvasId`,id:`rememberCanvasId`,defaultChecked:n.editorFeatureFlags?.rememberCanvasId||!1}),(0,d.jsx)(l.Form.Label,{htmlFor:`rememberCanvasId`,children:`Remember Canvas ID`})]}),(0,d.jsxs)(l.Form.InputContainer,{horizontal:!0,className:`my-3`,children:[(0,d.jsx)(l.Form.Input,{type:`checkbox`,name:`rememberLeftPanelId`,id:`rememberLeftPanelId`,defaultChecked:n.editorFeatureFlags?.rememberLeftPanelId||!1}),(0,d.jsx)(l.Form.Label,{htmlFor:`rememberLeftPanelId`,children:`Remember Left panel`})]}),(0,d.jsxs)(l.Form.InputContainer,{horizontal:!0,className:`my-3`,children:[(0,d.jsx)(l.Form.Input,{type:`checkbox`,name:`manifestGridOptions`,id:`manifestGridOptions`,defaultChecked:n.editorFeatureFlags?.manifestGridOptions||!1}),(0,d.jsx)(l.Form.Label,{htmlFor:`manifestGridOptions`,children:`Manifest Grid Options`})]}),(0,d.jsxs)(l.Form.InputContainer,{horizontal:!0,className:`my-3`,children:[(0,d.jsx)(l.Form.Input,{type:`checkbox`,name:`isVersion2`,id:`isVersion2`,defaultChecked:n.export?.version===2}),(0,d.jsxs)(l.Form.Label,{htmlFor:`isVersion2`,children:[`Export Presentation 2 `,t.type,`s`]})]}),(0,d.jsxs)(l.Form.InputContainer,{children:[(0,d.jsx)(l.Form.Label,{htmlFor:`defaultPreview`,children:`Default preview`}),(0,d.jsx)(`div`,{children:e.configs.map((e,t)=>e.type===`iiif-preview-service`?null:(0,d.jsxs)(l.Form.InputContainer,{horizontal:!0,children:[(0,d.jsx)(l.Form.Input,{type:`radio`,id:e.id,name:`defaultPreview`,value:e.id,defaultChecked:n.defaultPreview?n.defaultPreview===e.id:t===0}),(0,d.jsx)(`label`,{htmlFor:e.id,children:e.label})]},e.id))})]}),t.type===`Manifest`?(0,d.jsx)(`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,(0,d.jsx)(Zo,{}),(0,d.jsx)(`div`,{className:`mt-5`,children:(0,d.jsx)(l.ActionButton,{type:`submit`,children:`Save changes`})})]})]})]})}function ns(e){let t=new Map;for(let n of e){if(!n.configuration?.fields.length)continue;let e=(0,S.getCreatorConfigKey)(n);(!t.has(e)||n.id===e)&&t.set(e,n)}return Array.from(t.values())}function rs(){let e=U(),t=z(),n=ie(),r=(0,u.useMemo)(()=>ns(e.layout.creators||[]),[e.layout.creators]);function i(e,t){let r=(0,S.getCreatorConfigKey)(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?(0,d.jsx)(`div`,{className:`flex max-w-3xl flex-col gap-6`,children:r.map(e=>(0,d.jsxs)(l.Form.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:[(0,d.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,d.jsx)(`h3`,{className:`text-base font-semibold text-gray-900`,children:e.label}),e.summary?(0,d.jsx)(`p`,{className:`text-sm text-gray-500`,children:e.summary}):null]}),e.configuration?.fields.map(n=>{let r=(0,S.getCreatorConfigKey)(e),i=t.creators?.[r]?.[n.id],a=`${r}-${n.id}`;return n.type===`checkbox`?(0,d.jsxs)(l.Form.InputContainer,{horizontal:!0,className:`my-1 items-start`,children:[(0,d.jsx)(l.Form.Input,{type:`checkbox`,name:n.id,id:a,defaultChecked:typeof i==`boolean`?i:n.defaultValue||!1}),(0,d.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,d.jsx)(l.Form.Label,{htmlFor:a,children:n.label}),n.summary?(0,d.jsx)(`p`,{className:`text-sm text-gray-500`,children:n.summary}):null]})]},n.id):null})]},(0,S.getCreatorConfigKey)(e)))}):(0,d.jsx)(l.EmptyState,{children:`No creator settings available`})}function is(){return(0,f.createStore)((e,t)=>({specificMenus:{},resourceMenus:{},hookMenuItem(t){let n=Lt(),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 as=(0,u.createContext)(null);function os({children:e}){let t=(0,u.useMemo)(()=>is(),[]);return(0,d.jsx)(as.Provider,{value:t,children:e})}function ss(){let e=(0,u.useContext)(as);if(!e)throw Error(`useContextMenuStore must be used within a ContextMenuProvider`);return e}function cs(e){let t=ss(),n=(0,f.useStore)(t,e=>e.resourceMenus),r=(0,f.useStore)(t,e=>e.specificMenus);return(0,u.useMemo)(()=>{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 ls(c)},[r,n,e.id,e.type])}function ls(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 us(e,t=[]){let n=ss(),r=(0,f.useStore)(n,e=>e.hookMenuItem);(0,u.useEffect)(()=>r(e),[r,e.resource?.id,e.resource?.type,...t])}var ds={CenterPanelContainer:`_CenterPanelContainer_1sbe6_1`,CenterPanelHeader:`_CenterPanelHeader_1sbe6_16`,CenterPanelClose:`_CenterPanelClose_1sbe6_23`,CenterPanelTitle:`_CenterPanelTitle_1sbe6_28`};function fs(e){return(0,d.jsxs)(`div`,{className:ds.CenterPanelContainer,children:[e.title||e.close?(0,d.jsxs)(`div`,{className:ds.CenterPanelHeader,children:[e.title?(0,d.jsx)(`h2`,{className:ds.CenterPanelTitle,children:e.title}):null,e.close?(0,d.jsx)(K,{className:ds.CenterPanelClose,onClick:e.close,children:(0,d.jsx)(tr,{})}):null]}):null,e.children]})}const ps=g.default.div`
|
|
462
|
+
`;function as({panel:e,state:t,actions:n,isLeft:r,pinActions:i=n,transition:a,close:o,available:s=[],style:c,noHeader:l,isModal:p}){let{resolveMessage:m}=(0,f.useEditorI18n)(),h=(0,f.useTranslations)(`shell`),_=(0,u.useContext)(g.ReactVaultContext)||null,[v,y]=(0,u.useState)(!1),b=sr(),x=Or(),{tabs:S,pinnable:C,hideHeader:w}=e?.options||{},T=(0,u.useMemo)(()=>(s||[]).filter(e=>!e.requiresState),[s]),{itemProps:E,isOpen:D,setIsOpen:O}=si(T.length),[k,A]=(0,u.useState)(``),j=(0,u.useRef)(void 0);(0,u.useEffect)(()=>y(!1),[b.state.canvasId,e?.id]),(0,u.useEffect)(()=>A(``),[e]),(0,u.useEffect)(()=>(j.current=A,()=>{j.current=void 0}),[]);let N=(0,u.useCallback)(e=>{j.current&&j.current(e)},[]),P=(0,u.useCallback)(r=>{let i=e?t.stack.length?n.popStack:e.backAction?()=>e&&e.backAction&&e.backAction(t,{...x,current:n},b):null:null;r&&(!i||r.metaKey)&&T.length?(r.preventDefault(),O(!0)):i?.()},[n,b,x,e,O,t,T.length]),F=r=>{n.change({id:r.id,state:r.defaultState,stacked:!!(t.stack.length||e?.backAction)})};if(!e||!t.current)return null;let ee=e.backAction||t.stack.length?(0,d.jsx)(ts,{"aria-label":h(`actions.back`),onClick:P,children:(0,d.jsx)(Go,{"aria-hidden":`true`})}):null,I=(0,d.jsx)(ts,{"aria-label":h(`actions.closePanel`),onClick:o||n.close,children:(0,d.jsx)(ii,{"aria-hidden":`true`})});return(0,d.jsx)(Zo.Provider,{value:N,children:(0,d.jsxs)($o,{"data-modal":p,"data-state":a,"data-flipped":r,style:c,"data-header":!l,children:[l?null:(0,d.jsxs)(es,{"data-tabs":!!S,"data-error":v,children:[(0,d.jsxs)(Bo,{style:{display:`flex`,height:`100%`},children:[e.renderBackAction?e.renderBackAction({backAction:P,fallback:ee}):ee,T.length?(0,d.jsxs)(Ho,{$open:D,role:`menu`,style:{left:`0.5em`},children:[(0,d.jsx)(Uo,{children:h(`panels.all`)}),(0,d.jsx)(Wo,{}),T.map((t,n)=>(0,d.jsx)(Vo,{...E[n],onClick:()=>F(t),$active:e.id===t.id,children:m(t?.labelMessage,t.label)},n))]}):null]}),k?(0,d.jsx)(rs,{as:r?`h1`:`h2`,children:k}):w?(0,d.jsx)(ns,{}):(0,d.jsx)(rs,{as:r?`h1`:`h2`,children:m(e?.labelMessage,e.label)}),C?t.pinned?(0,d.jsx)(ts,{"aria-label":h(`panels.unpin`),onClick:i.unpin,children:(0,d.jsx)(Ko,{"aria-hidden":`true`,fill:`orange`})}):(0,d.jsx)(ts,{"aria-label":h(`panels.pin`),onClick:()=>i.pin({id:e.id,state:t.state}),children:(0,d.jsx)(Ko,{"aria-hidden":`true`,fill:`#ddd`})}):null,e.renderCloseAction?e.renderCloseAction({closeAction:o||n.close,fallback:I}):I]}),(0,d.jsx)(is,{className:`OverrideScrollbar`,children:(0,d.jsx)(M.ErrorBoundary,{onError:()=>y(!0),FallbackComponent:Xo,resetKeys:[b.state.canvasId,e?.id],onReset:()=>y(!1),children:Yo(e.render(t.state||e.defaultState||{},{...x,current:n,vault:_,transition:a,isModal:p},b))})})]})})}function os(e,t,n,r,i){let a=(0,g.useVault)(),o=q(),{create:s,edit:c}=Tr(),l=(0,u.useMemo)(()=>(0,j.matchBasedOnResource)({type:n,parent:e,index:0,property:t,filter:i?.filter},o.layout.creators||[],{vault:a}),[e,t,o.layout.creators,n,a,i?.filter]),d=e&&l.length!==0,f=(0,u.useCallback)((a,o)=>{if(e)return s({type:n,parent:(0,_.toRef)(e),property:t,index:a,target:r,initialData:o,...i||{}})},[s,e,t,n,i,r]),p=(0,u.useCallback)((a,o,c)=>{if(e)return s({type:n,filter:a,parent:(0,_.toRef)(e),property:t,index:o,target:r,initialData:c,...i||{}})},[s,e,t,n,i,r]);return[d,{create:f,edit:(0,u.useCallback)((n,r)=>{c(n,e?{parent:(0,_.toRef)(e),property:t,index:r}:void 0)},[c,e,t]),createFiltered:p,creator:(0,u.useCallback)((a,o)=>{if(e)return s({type:n,initialCreator:a,parent:(0,_.toRef)(e),property:t,target:r,initialData:o,...i||{}})},[n,t,e,r,s,i]),buttonProps:(0,u.useMemo)(()=>({"data-action-id":Jt(n,t,e)}),[n,t,e])}]}function ss(){let e=(0,g.useVault)(),t=Ar(),n=q(),r=U();return(0,u.useMemo)(()=>new j.Creator(e,n.layout.creators||[],t,r.creators),[n.layout.creators,r.creators,t,e])}async function cs(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 ls=(0,u.createContext)({});function us(e){return(0,u.useContext)(ls)[e]||{}}function ds(e){let t=(0,u.useContext)(ls),n=(0,u.useMemo)(()=>({...t,[e.id]:e.data}),[t,e.id,e.data]);return(0,d.jsx)(ls.Provider,{value:n,children:e.children})}function fs(){return(0,d.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`24px`,viewBox:`0 0 24 24`,width:`24px`,fill:`#000000`,children:[(0,d.jsx)(`path`,{d:`M0 0h24v24H0z`,fill:`none`}),(0,d.jsx)(`path`,{d:`M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z`})]})}const ps=[{icon:(0,d.jsx)(l.IIIFLogo,{}),text:`https://example.org/iiif/manifest.json`},{icon:(0,d.jsx)(l.AddImageIcon,{}),text:`https://example.org/photo.jpg`},{icon:(0,d.jsx)(l.VideoIcon,{}),text:`https://example.org/video.mp4`},{icon:(0,d.jsx)(l.YouTubeIcon,{}),text:`https://www.youtube.com/watch?v=…`}];function ms(){let[e,t]=(0,u.useState)(!0);return(0,u.useEffect)(()=>{let e=window.matchMedia(`(prefers-reduced-motion: reduce)`);t(e.matches);let n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function hs({value:e,onChange:t,inputRef:n,isChecking:r,rotateExamples:i=!0,onBrowse:a}){let o=(0,f.useTranslations)(`shell`),s=ms(),[c,p]=(0,u.useState)(0),m=i&&!s&&!e&&!r;(0,u.useEffect)(()=>{if(!m)return;let e=setInterval(()=>p(e=>(e+1)%ps.length),2e3);return()=>clearInterval(e)},[m]);let h=ps[c];return(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`style`,{children:`
|
|
463
|
+
@keyframes creator-resource-hint-in {
|
|
464
|
+
from { opacity: 0; transform: translateY(6px); }
|
|
465
|
+
to { opacity: 1; transform: translateY(0); }
|
|
466
|
+
}
|
|
467
|
+
.creator-resource-hint { animation: creator-resource-hint-in 180ms ease-out; }
|
|
468
|
+
@media (prefers-reduced-motion: reduce) { .creator-resource-hint { animation: none; } }
|
|
469
|
+
`}),(0,d.jsx)(`label`,{className:`block text-sm font-medium text-gray-700`,htmlFor:`creator-resource-link`,children:o(`creator.paste`)}),(0,d.jsxs)(`div`,{className:`mt-1 flex min-h-12 w-full items-center rounded-md border border-gray-300 bg-white p-1 focus-within:border-me-primary-500 focus-within:ring-2 focus-within:ring-me-primary-500`,children:[(0,d.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,d.jsx)(`input`,{ref:n,id:`creator-resource-link`,type:`url`,autoComplete:`off`,spellCheck:!1,value:e,onChange:e=>t(e.currentTarget.value),placeholder:m?``:i?`https://example.org/manifest.json`:`https://example.org/resource`,className:`block h-10 w-full min-w-0 border-none bg-transparent pl-9 pr-2 text-sm outline-none focus:outline-none`}),(0,d.jsx)(`span`,{className:`pointer-events-none absolute inset-y-0 left-3 flex items-center text-gray-400 [&>svg]:h-4 [&>svg]:w-4`,"aria-hidden":`true`,children:m?h.icon:(0,d.jsx)(fs,{})}),m?(0,d.jsx)(`span`,{"aria-hidden":`true`,className:`creator-resource-hint pointer-events-none absolute inset-y-0 left-9 right-3 flex items-center overflow-hidden`,children:(0,d.jsx)(`span`,{className:`truncate text-sm text-gray-400`,children:h.text})},c):null]}),a?(0,d.jsx)(`button`,{type:`button`,"aria-label":o(`creator.browse`),title:o(`creator.browse`),disabled:r,onClick:a,className:`mr-1 flex h-9 w-9 shrink-0 items-center justify-center rounded bg-transparent text-gray-500 hover:bg-gray-100 hover:text-me-primary-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-me-primary-500 disabled:opacity-50`,children:(0,d.jsx)(l.IIIFBrowserIcon,{className:`h-5 w-5`})}):null,(0,d.jsx)(l.ActionButton,{primary:!0,type:`submit`,isDisabled:!e.trim()||r,className:`h-9 shrink-0 justify-center px-3`,children:o(r?`creator.checkingShort`:`creator.useLink`)})]})]})}const gs=(0,u.memo)(function(e){let{resolveMessage:t}=(0,f.useEditorI18n)(),n=(0,f.useTranslations)(`shell`),r=(0,g.useVault)(),{edit:i,modal:a,open:o}=Tr(),[s,c]=(0,u.useState)(!1),[p,m]=(0,u.useState)(null),h=ss(),v=U(),y=(0,u.useRef)(!1),b=e.resource.initialData?.selector;Ro(b);let x=us(e.creator.id),S={targetType:e.resource.type,parent:e.resource.parent?{property:e.resource.property,atIndex:e.resource.index,resource:e.resource.parent}:void 0,target:e.resource.target,placeholderPosition:e.resource.placeholderPosition,initialData:{...x,...e.resource.initialData||{},...e.initialData||{}}},C=async t=>{if(!(s||y.current)){m(null),c(!0),y.current=!0;try{await cs({create:()=>h.create(e.creator.id,t,S),onCreate:e.onCreate,close:e.skipEditingOnCreate?void 0:()=>{a.popStack(),a.close()},edit:e.skipEditingOnCreate||e.resource.initialData?.skipEditingOnCreate?void 0:t=>{t.type===`Canvas`&&o({id:`current-canvas`}),i(t,{parent:(0,_.toRef)(e.resource.parent),property:e.resource.property,index:e.resource.index},{selectedTab:e.creator.initialEditor})}})}catch(n){m(e.creator.validationErrorMessage?.(n,{payload:t,vault:r})||n?.message||{message:{namespace:`shell`,key:`creator.unknownError`}})}finally{c(!1),y.current=!1}}},w=async()=>!0;(0,u.useEffect)(()=>{e.resource.initialData?.showEmptyForm||!e.creator.render&&!s&&C({})},[e.creator]);let T=(0,d.jsx)(`div`,{className:`flex flex-col items-center py-8`,children:(0,d.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,d.jsx)(l.Spinner,{}),` `,(0,d.jsx)(`span`,{children:n(`creator.loading`)})]})});return e.creator.render?(0,d.jsxs)(d.Fragment,{children:[s?T:null,(0,d.jsxs)(`div`,{hidden:s,children:[t(e.creator.helpMessage||e.creator.summaryMessage,e.creator.summary)&&!e.compact&&!e.creator.hideSummary?(0,d.jsx)(`div`,{className:`flex justify-end px-4`,children:(0,d.jsxs)(l.Tooltip,{children:[(0,d.jsx)(l.TooltipTrigger,{"aria-label":n(`creator.help`,{name:t(e.creator.labelMessage,e.creator.label)}),className:`rounded p-1 text-gray-500 focus-visible:outline focus-visible:outline-2`,children:(0,d.jsx)(l.InfoIcon,{className:`h-5 w-5`})}),(0,d.jsx)(l.DefaultTooltipContent,{className:`max-w-xs`,root:document.getElementById(`headlessui-portal-root`)||void 0,children:t(e.creator.helpMessage||e.creator.summaryMessage,e.creator.summary)})]})}):null,p?(0,d.jsx)(l.ErrorMessage,{children:typeof p==`string`?p:t(p.message)}):null,(0,d.jsx)(u.Suspense,{fallback:T,children:e.creator.render({vault:r,i18n:{resolveMessage:t},runCreate:C,validate:w,options:S,config:v.creators?.[(0,j.getCreatorConfigKey)(e.creator)]||{}})})]})]}):s?T:e.compact?(0,d.jsxs)(d.Fragment,{children:[p?(0,d.jsx)(l.ErrorMessage,{children:typeof p==`string`?p:t(p.message)}):null,(0,d.jsx)(`div`,{className:`flex justify-end`,children:(0,d.jsx)(l.ActionButton,{primary:!0,onPress:()=>C({}),children:t(e.creator?.actionButtonMessage,e.creator.actionButton)||n(`creator.create`)})})]}):(0,d.jsxs)(d.Fragment,{children:[p?(0,d.jsx)(l.ErrorMessage,{children:typeof p==`string`?p:t(p.message)}):(0,d.jsx)(l.EmptyState,{children:n(`creator.noOptions`)}),(0,d.jsx)(l.ActionButton,{primary:!0,onPress:()=>C({}),children:t(e.creator?.actionButtonMessage,e.creator.actionButton)||n(`creator.create`)})]})});function _s(e){let{resolveMessage:t}=(0,f.useEditorI18n)(),n=(0,f.useTranslations)(`shell`),r=q(),i=U(),a=(0,g.useVault)(),[o,s]=(0,u.useState)(e.resource.initialCreator||``),[c,p]=(0,u.useState)(),[m,h]=(0,u.useState)(``),[_,v]=(0,u.useState)(!1),[y,b]=(0,u.useState)(``),[x,S]=(0,u.useState)(null),C=(0,u.useRef)(null),w=(0,u.useRef)(0),T=(0,u.useRef)(null),E=(0,u.useId)(),D=e.resource.type===`Canvas`&&e.resource.parent?.type===`Manifest`&&e.resource.property===`items`,[O,k]=(0,u.useState)(!1),A=Qo(),M=(0,u.useMemo)(()=>(0,j.matchBasedOnResource)(e.resource,r.layout.creators||[],{vault:a}),[e.resource,r.layout.creators,a]),N=M.some(e=>e.supportsResource),P=M.find(e=>e.id===i.notebook?.browserCreatorId)??M.find(e=>(0,j.getCreatorConfigKey)(e)===`@manifest-editor/iiif-browser-creator`),F=M.filter(e=>!e.supportsResource);(0,u.useEffect)(()=>()=>{w.current++,T.current?.abort()},[]);let ee=()=>{w.current++,T.current?.abort(),T.current=null,v(!1)};(0,u.useEffect)(()=>{M.length===1&&!o&&!N&&s(M[0].id)},[N,o,M]),(0,u.useEffect)(()=>{N&&!o&&C.current?.focus()},[N,o]);let I=M.find(e=>e.id===o);if((0,u.useEffect)(()=>{A?.(t(I?.labelMessage,I?.label)||n(`creator.add`))}),M.length===0)return(0,d.jsx)(l.EmptyState,{children:n(`creator.unsupported`)});let L=(e,t)=>{ee(),p(t||xs(m)),s(e.id)},R=P?e=>L(P,{url:e??(m.trim()||void 0)}):void 0,te=async(t,r)=>{t?.preventDefault();let i=(r??m).trim();if(r&&h(r),!i||_)return;let o=++w.current,s=new AbortController;T.current=s,v(!0),b(``),S(null);let c=!1,l=!1,u=Ss(s.signal,()=>{c=!0}),d,f=new Promise(e=>{d=setTimeout(()=>{l=!0,s.abort(),e(null)},1e4)}),p=await Promise.all(M.map(async t=>t.supportsResource?Promise.race([(async()=>{try{let n=await t.supportsResource(i,u,{vault:a,resource:e.resource});return n?{creator:t,initialData:bs(i,n).initialData}:null}catch{return{creator:t,error:n(`creator.probeFailed`)}}})(),f]):null));if(clearTimeout(d),o!==w.current)return;T.current=null,v(!1);let g=p.filter(vs);if(g.length===1){L(g[0].creator,g[0].initialData);return}if(g.length>1){k(!1),S(g);return}k(!0),b(l?`creator.timeout`:c||p.some(ys)?`creator.requestFailed`:`creator.unrecognised`)},z=(0,d.jsx)(l.ModalBackSlot,{children:(0,d.jsx)(l.IconButton,{root:document.getElementById(`headlessui-portal-root`)||void 0,label:n(`creator.back`),className:`group`,placement:`right`,onPress:()=>{ee(),s(``),p(void 0)},children:(0,d.jsx)(l.GridIcon,{className:`text-2xl opacity-50 group-hover:opacity-70`})})});if(I)return I.hiddenModal?(0,d.jsxs)(d.Fragment,{children:[z,(0,d.jsx)(gs,{creator:I,resource:e.resource,initialData:c})]}):(0,d.jsxs)(`div`,{children:[z,(0,d.jsx)(`div`,{className:`p-2 py-6`,children:(0,d.jsx)(gs,{creator:I,resource:e.resource,initialData:c})})]});let B=!N||O||!D&&!x,ne=B?M:x?.map(e=>e.creator)||[],re=new Map(x?.map(e=>[e.creator.id,e.initialData])),V=(e,n,r=!1)=>(0,d.jsx)(l.CreatorGrid,{label:n,compact:r,items:e.map(e=>({id:e.id,title:t(e?.labelMessage,e.label),description:t(e?.summaryMessage,e.summary)||``,icon:e.icon,onClick:()=>L(e,re.get(e.id))}))});return(0,d.jsxs)(d.Fragment,{children:[N?(0,d.jsxs)(`form`,{className:`p-4`,onSubmit:e=>void te(e),"aria-busy":_,children:[(0,d.jsx)(hs,{inputRef:C,rotateExamples:D,onBrowse:R?()=>R():void 0,value:m,isChecking:_,onChange:e=>{ee(),h(e),b(``),S(null)}}),(0,d.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`text-sm text-gray-600`,children:[_?(0,d.jsx)(`span`,{className:`sr-only`,children:n(`creator.checking`)}):null,y?(0,d.jsx)(`p`,{className:`mt-3`,children:n(y)}):null,x&&!B?(0,d.jsx)(`p`,{className:`mt-3`,children:n(`creator.chooseLink`)}):null]}),m?null:(0,d.jsx)(ei,{isDisabled:_,onSelect:e=>void te(void 0,e),onOpenNotebook:R?()=>R(`iiif://notes`):void 0})]}):null,(0,d.jsx)(`div`,{id:E,children:ne.length?V(ne,n(x&&!B?`creator.matches`:`creator.selectType`)):null}),D&&!B&&F.length?V(F,n(`creator.noLink`),!0):null,N&&(D||x)?(0,d.jsx)(`div`,{className:`px-4 pb-4`,children:(0,d.jsx)(X,{className:`rounded px-2 py-1 text-sm text-me-gray-700 hover:bg-gray-100 focus-visible:outline focus-visible:outline-2`,"aria-expanded":O,"aria-controls":E,onClick:()=>{ee(),k(!O)},children:n(O?`creator.fewer`:`creator.chooseType`)})}):null]})}function vs(e){return!!e&&!(`error`in e)}function ys(e){return!!e&&`error`in e}function bs(e,t){return typeof t==`object`?t:{initialData:xs(e)}}function xs(e){let t=e.trim();return t?{url:t,youtubeUrl:t}:void 0}function Ss(e,t){let n=async(n,r=`GET`)=>{try{let t=await fetch(n,{method:r,signal:e});if(!t.ok)throw Error(`Could not load link`);return t}catch(e){throw t(),e}},r=new Map,i=new Map,a=new Map,o=e=>(r.has(e)||r.set(e,n(e).then(e=>e.text())),r.get(e)),s=e=>(a.has(e)||a.set(e,n(e,`HEAD`)),a.get(e));return{text:o,head:s,json(e){return i.has(e)||i.set(e,o(e).then(e=>JSON.parse(e))),i.get(e)},async contentType(e){return(await s(e)).headers.get(`content-type`)||``}}}const Cs={id:`@manifest-editor/creator`,label:`Add content`,labelMessage:{namespace:`shell`,key:`creator.add`},options:{hideHeader:!0,tabs:!1},render(e){return(0,d.jsx)(_s,{resource:e})}},ws={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 Ts(e){let{resolveMessage:t}=(0,f.useEditorI18n)(),n=(0,f.useTranslations)(`shell`),r=(0,g.useVault)(),i=q(),a=(0,u.useMemo)(()=>(0,j.matchBasedOnResource)(e.resource,i.layout.creators||[],{vault:r}),[e.resource,i.layout.creators,r]),[o,s]=(0,u.useState)(null),c=a.find(e=>e.id===o)||a[0];return a.length===0?(0,d.jsx)(`div`,{className:`p-4 text-sm text-gray-500`,children:n(`creator.noCreators`)}):(0,d.jsxs)(l.Tabs,{className:`flex w-full flex-col`,selectedKey:c?.id,onSelectionChange:s,children:[a.length>1?(0,d.jsx)(l.TabList,{"aria-label":n(`creator.annotationType`),className:`mx-3 mt-3 flex gap-0.5 rounded-md bg-gray-100 p-0.5 text-sm`,items:a,children:e=>(0,d.jsxs)(l.Tab,{id:e.id,className:({isSelected:e,isFocusVisible:t})=>[`flex min-w-0 flex-auto items-center justify-center gap-1.5 rounded border-b-0 px-2 py-1 font-medium`,e?`bg-white text-gray-900 shadow-sm`:`text-gray-600 hover:text-gray-900`,t?`bg-white ring-2 ring-me-primary-500`:``].join(` `),children:[(0,d.jsx)(`span`,{"aria-hidden":!0,className:`flex flex-none text-base [&>svg]:h-4 [&>svg]:w-4`,children:e.icon}),(0,d.jsx)(`span`,{className:`truncate`,children:t(e?.labelMessage,e.label)})]})}):null,t(c?.summaryMessage,c?.summary)?(0,d.jsx)(`p`,{className:`mx-4 mt-2 text-xs text-gray-500`,children:t(c?.summaryMessage,c?.summary)}):null,a.map(t=>(0,d.jsx)(l.TabPanel,{id:t.id,className:`p-3 pt-2 outline-none`,children:(0,d.jsx)(y.ThemeProvider,{theme:ws,children:(0,d.jsx)(gs,{creator:t,resource:e.resource,onCreate:e.onCreate,skipEditingOnCreate:!0,compact:!0})})},t.id))]})}function Es({fallback:e,backAction:t}){let n=(0,f.useTranslations)(`shell`),r=Ji(),{back:i}=Ki();return r.length?(0,d.jsx)(ts,{"aria-label":n(`actions.back`),onClick:i,children:(0,d.jsx)(Go,{"aria-hidden":`true`})}):e}function Ds({closeAction:e,fallback:t}){let n=(0,f.useTranslations)(`shell`),r=Ji();return qi()||r.length?(0,d.jsx)(ts,{"aria-label":n(`actions.closePanel`),onClick:()=>{e()},children:(0,d.jsx)(ii,{"aria-hidden":`true`})}):t}function Os(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 ks({currentTab:e=void 0}){let{resolveMessage:t,locale:n,profile:r}=(0,f.useEditorI18n)(),i=qi(),a=(0,u.useContext)(g.ResourceReactContext),o=q(),s=J(),c=(0,g.useVault)(),{change:p}=Tr(),m=Qo(),{editorConfig:h}=U(),_=i?.resource.source?.id,v=i?.resource.source?.type,y=_!==s.id;_&&y&&s.type===`Collection`&&v===`Collection`&&(v=`EmbeddedCollection`);let b=(v?h[v]:h.All)||{},x=(0,u.useMemo)(()=>{let e={...a},t=i?.resource.source.id,n=i?.resource.source.type,r={Collection:`collection`,Manifest:`manifest`,Range:`range`,Canvas:`canvas`,Annotation:`annotation`,AnnotationPage:`annotationPage`};return n&&r[n]&&(e[r[n]]=t),e},[i,a]);function S(e){return i?(0,d.jsx)(g.ResourceReactContext.Provider,{value:x,children:e}):e}let C=(0,u.useMemo)(()=>{if(!i)return null;let e=o.layout.editors||[],t=(o.layout.resources||[]).map(t=>typeof t==`string`?{id:`@default/`+t,label:t,labelMessage:{namespace:`editor-api`,key:`resources.${t.charAt(0).toLowerCase()}${t.slice(1)}`,defaultValue:t},resourceType:t,auto:!0,editors:e.filter(e=>e.supports.resourceTypes.includes(t))}:t);return Os(i,t,{edit:!0,vault:c},b)},[i,o]);(0,u.useEffect)(()=>{m(t(C?.labelMessage,C?.label)||``)},[C,t,n,r,m]),(0,u.useEffect)(()=>{let t=C?.editors.map(e=>e.id)||[];t.find(t=>t===e)||p(`@manifest-editor/editor`,{currentTab:t[0]})},[C?.editors,e,p]);let w=(0,u.useMemo)(()=>(C?.editors||[]).map(e=>({id:e.id,label:t(e?.labelMessage,e.label),renderComponent:()=>e.component(b)})),[C?.editors,b,t,n,r]);if(!i||!C)return null;if(b.singleTab){let e=(C?.editors||[]).find(e=>e.id===b.singleTab);if(e)return S((0,d.jsx)(`div`,{className:`w-full`,children:e.component(b)},i.resource.source?.id))}return S((0,d.jsx)(l.SidebarTabs,{isNested:y,rootResource:s,menuId:i.resource.source.id,menu:w,selectedKey:e,onSelectionChange:e=>{p(`@manifest-editor/editor`,{currentTab:e})}},i.resource.source?.id))}const As={id:`@manifest-editor/editor`,label:`Editor`,labelMessage:{namespace:`shell`,key:`panels.editor`},options:{hideHeader:!0,tabs:!0,minWidth:400},renderBackAction:({backAction:e,fallback:t})=>(0,d.jsx)(Es,{backAction:e,fallback:t}),renderCloseAction:({closeAction:e,fallback:t})=>(0,d.jsx)(Ds,{closeAction:e,fallback:t}),render({currentTab:e}){return(0,d.jsx)(ks,{currentTab:e})}};function js(e){let[t,n]=(0,u.useState)(!1),r=(0,u.useRef)(null),i=(0,u.useRef)(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(0,u.useMemo)(()=>[t,{set:o,clear:a}],[t])}function Ms(e){return e?typeof e==`string`?{src:e,alt:``,altMessage:void 0}:e:null}function Ns(e){return e?typeof e==`string`?e:e.name:null}function Ps(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`,labelMessage:n.labelMessage,modal:t.modalPanels?.some(e=>e.id===n.id)||!1}:null}function Fs(e,t){return e instanceof Error?e.message:t}function Is(e){return(0,d.jsxs)(`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:[(0,d.jsx)(`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`}),(0,d.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]})}function Ls(e){return(0,d.jsxs)(`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:[(0,d.jsx)(`path`,{d:`M7 7h10v10`}),(0,d.jsx)(`path`,{d:`M7 17 17 7`})]})}function Rs(){let{resolveMessage:e,locale:t,profile:n}=(0,f.useEditorI18n)(),r=(0,f.useTranslations)(`shell`),i=q(),{appId:a}=or(),o=U(),s=de(),c=Wn(),p=Kn(),m=Tr(),{saveGlobalPluginConfig:h}=(0,u.useContext)(zn),[g,_]=(0,u.useState)(!1),[v,y]=(0,u.useState)(``),[b,x]=(0,u.useState)(null),[S,C]=(0,u.useState)(null),[w,T]=(0,u.useState)(null),E=(0,u.useMemo)(()=>new Set(wn(c,i,a).map(e=>e.metadata.id)),[c,i,a]),D=(0,u.useMemo)(()=>{let t=v.trim().toLowerCase();return c.plugins.filter(n=>{let r=bn(n,i,a);return!g&&!r?!1:!t||[e(n.metadata?.labelMessage,n.metadata.label),n.metadata.id,e(n.metadata?.descriptionMessage,n.metadata.description),Ns(n.metadata.author),...n.metadata.tags||[]].filter(Boolean).join(` `).toLowerCase().includes(t)})},[i,a,c.plugins,v,g,t,n,e]),O=b&&c.plugins.find(e=>e.metadata.id===b)||null;if(!c.plugins.length)return null;function k(e){p.setAppConfig(a,e),s({plugins:{...o.plugins||{},apps:{...o.plugins?.apps||{},[a]:e}}})}async function A(e){if(!h){T(r(`plugins.globalUnavailable`));return}let t=c.globalApps[a]||{},n={apps:{...c.globalApps,[a]:e}};p.setGlobalAppConfig(a,e);try{await h(n)}catch(e){p.setGlobalAppConfig(a,t),T(Fs(e,r(`plugins.saveFailed`)))}}async function j(t,n,o){T(null),C(`${o}:${t.metadata.id}`);let s=o===`global`?c.globalApps[a]||{}:c.apps[a]||{},l=n?jn(s,c,t,i,a):{config:un(s,t.metadata.id),blocked:[]};if(l.blocked.length){C(null),T(r(`plugins.cannotEnable`,{name:e(t.metadata.labelMessage,t.metadata.label),dependencies:l.blocked.join(`, `)}));return}o===`global`?await A(l.config):k(l.config),C(null)}function M(e){let t=Ps(e);if(t){if(t.modal){m.modal.open({id:t.id});return}m.open(t.id)}}return(0,d.jsxs)(`section`,{className:`flex flex-col gap-3 border-t border-gray-200 pt-4 mt-4`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,d.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,d.jsx)(`h3`,{className:`font-semibold text-sm text-gray-900`,children:r(`plugins.title`)})}),(0,d.jsx)(`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:()=>_(e=>!e),children:r(g?`plugins.compatible`:`plugins.showAll`)})]}),(0,d.jsx)(`input`,{"aria-label":r(`plugins.search`),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:r(`plugins.searchPlaceholder`),value:v,onChange:e=>y(e.currentTarget.value)}),w?(0,d.jsx)(`div`,{className:`rounded border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:w}):null,(0,d.jsx)(`div`,{className:`flex flex-col gap-2`,children:D.map(t=>{let n=Sn(t,c,a),o=E.has(t.metadata.id),s=n&&t.loadStatus===`loading`,u=n&&t.loadStatus===`error`?t.loadError:null,f=Ms(t.metadata.image),p=n&&!o&&!s&&!u,m=bn(t,i,a),h=xn(t,i,a,{app:r(`plugins.incompatibleApp`),project:r(`plugins.incompatibleProject`)}),g=Ps(t),_=!!t.settings,v=S===`workspace:${t.metadata.id}`;return(0,d.jsxs)(`article`,{className:`flex gap-2.5 rounded-lg border bg-white p-3 text-sm transition-colors ${o?`border-gray-200`:`border-gray-100 bg-gray-50`} ${m?``:`bg-gray-100`}`,children:[f?(0,d.jsx)(`img`,{className:`h-9 w-9 rounded object-cover flex-none mt-0.5`,src:f.src,alt:e(f.altMessage,f.alt)||e(t.metadata?.labelMessage,t.metadata.label)}):(0,d.jsx)(`div`,{className:`h-9 w-9 rounded flex items-center justify-center flex-none mt-0.5 text-lg ${o?`bg-me-primary-50 text-me-primary-500`:`bg-gray-100 text-gray-600`}`,children:(0,d.jsx)(Is,{className:`w-4 h-4`})}),(0,d.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,d.jsxs)(`div`,{className:`flex items-start justify-between gap-1`,children:[(0,d.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 min-w-0`,children:[(0,d.jsx)(`span`,{className:`font-medium text-gray-900 text-xs`,children:e(t.metadata?.labelMessage,t.metadata.label)}),t.metadata.official?(0,d.jsxs)(`span`,{className:`rounded-full text-me-primary-500 px-1.5 py-0 text-[9px] font-bold inline-flex items-center gap-1`,children:[(0,d.jsx)(l.CheckIcon,{className:`w-3 h-3`}),r(`plugins.verified`)]}):null,t.metadata.version?(0,d.jsx)(`span`,{className:`text-[10px] text-gray-600`,children:t.metadata.version}):null]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-1 flex-none`,children:[_?(0,d.jsx)(`button`,{type:`button`,title:r(`plugins.configure`),"aria-label":r(`plugins.configureNamed`,{name:e(t.metadata.labelMessage,t.metadata.label)}),className:`rounded p-1 text-gray-600 hover:text-gray-700 hover:bg-gray-100 transition-colors`,onClick:()=>x(t.metadata.id),children:(0,d.jsx)(Is,{className:`w-3.5 h-3.5`})}):null,o&&g?(0,d.jsx)(`button`,{type:`button`,title:r(`plugins.openNamed`,{name:e(g.labelMessage,g.label)}),"aria-label":r(`plugins.openNamed`,{name:e(g.labelMessage,g.label)}),className:`rounded p-1 text-me-primary-500 hover:bg-me-primary-50 transition-colors`,onClick:()=>M(t),children:(0,d.jsx)(Ls,{className:`w-3.5 h-3.5`})}):null,(0,d.jsx)(`button`,{type:`button`,disabled:!m||v,onClick:()=>j(t,!n,`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 ${n?`bg-me-primary-500`:`bg-gray-200`}`,title:r(n?`plugins.disablePlugin`:`plugins.enablePlugin`),"aria-label":r(n?`plugins.disableNamed`:`plugins.enableNamed`,{name:e(t.metadata.labelMessage,t.metadata.label)}),children:(0,d.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 transform rounded-full bg-white shadow transition-transform ${n?`translate-x-4`:`translate-x-0.5`}`})})]})]}),e(t.metadata?.descriptionMessage,t.metadata.description)?(0,d.jsx)(`p`,{className:`text-xs text-gray-500 leading-relaxed`,children:e(t.metadata?.descriptionMessage,t.metadata.description)}):null,s?(0,d.jsx)(`span`,{className:`text-xs text-gray-500`,children:r(`plugins.loading`)}):null,u?(0,d.jsx)(`span`,{className:`text-xs text-red-600`,children:r(`plugins.loadFailed`,{pluginName:e(t.metadata.labelMessage,t.metadata.label)})}):null,p?(0,d.jsx)(`span`,{className:`text-xs text-amber-600`,children:r(`plugins.waiting`)}):null,!m&&h?(0,d.jsx)(`span`,{className:`text-xs text-gray-600`,children:h}):null]})]},t.metadata.id)})}),D.length?null:(0,d.jsx)(`div`,{className:`rounded-lg border border-gray-100 bg-gray-50 p-4 text-center text-xs text-gray-500`,children:r(`plugins.empty`)}),O?(0,d.jsx)(l.Modal,{title:r(`plugins.configureNamed`,{name:e(O.metadata.labelMessage,O.metadata.label)}),onClose:()=>x(null),width:`560px`,children:(0,d.jsx)(zs,{plugin:O,onClose:()=>x(null),canSaveGlobal:!!h})}):null]})}function zs({plugin:e,onClose:t,canSaveGlobal:n}){let r=(0,f.useTranslations)(`shell`),{resolveMessage:i}=(0,f.useEditorI18n)(),a=Yn(e.metadata.id),[o,s]=(0,u.useState)(`workspace`),[c,l]=(0,u.useState)({}),[p,m]=(0,u.useState)(!1),[h,g]=(0,u.useState)(!1),[_,v]=(0,u.useState)(null),y=o===`global`?a.global:a.workspace;(0,u.useEffect)(()=>{l({...y}),v(null),g(!1)},[e.metadata.id,o]);async function b(){let t=e.settings?.validate?.(c);if(t){v(t);return}m(!0),v(null);try{o===`global`?await a.setGlobalSettings(c):a.setWorkspaceSettings(c),g(!0),setTimeout(()=>g(!1),2e3)}catch(e){v(Fs(e,r(`plugins.saveFailed`)))}finally{m(!1)}}async function x(){m(!0),v(null);try{o===`global`?await a.resetGlobalSettings():a.resetWorkspaceSettings(),l({})}catch(e){v(Fs(e,r(`plugins.saveFailed`)))}finally{m(!1)}}let S=n&&a.canSaveGlobal;return(0,d.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[S?(0,d.jsxs)(`div`,{className:`flex items-center gap-1 px-5 pt-4 pb-3 border-b border-gray-100`,children:[(0,d.jsx)(`span`,{className:`text-xs text-gray-500 mr-2`,children:r(`plugins.scope`)}),(0,d.jsx)(`button`,{type:`button`,className:`rounded-full px-3 py-1 text-xs font-medium transition-colors ${o===`workspace`?`bg-me-primary-500 text-white`:`bg-gray-100 text-gray-600 hover:bg-gray-200`}`,onClick:()=>s(`workspace`),children:r(`plugins.workspace`)}),(0,d.jsx)(`button`,{type:`button`,className:`rounded-full px-3 py-1 text-xs font-medium transition-colors ${o===`global`?`bg-me-primary-500 text-white`:`bg-gray-100 text-gray-600 hover:bg-gray-200`}`,onClick:()=>s(`global`),children:r(`plugins.global`)})]}):null,_?(0,d.jsx)(`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:_}):null,(0,d.jsx)(`div`,{className:`flex-1 overflow-y-auto p-5`,children:(0,d.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.settings?.render?e.settings.render({i18n:{resolveMessage:i},plugin:e,appId:a.appId,scope:o,value:c,defaults:a.defaults,effective:a.effective,onChange:l}):e.settings?.fields?.length?e.settings.fields.map(e=>(0,d.jsx)(Bs,{field:e,draft:c,setDraft:l},e.id)):(0,d.jsx)(`div`,{className:`rounded-lg border border-gray-100 bg-gray-50 p-4 text-center text-sm text-gray-500`,children:r(`plugins.noSettings`)})})}),(0,d.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-gray-100 px-5 py-4`,children:[(0,d.jsx)(`button`,{type:`button`,className:`text-xs text-gray-600 hover:text-gray-700 transition-colors disabled:opacity-40`,disabled:p,onClick:x,children:r(`plugins.reset`)}),(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[h?(0,d.jsx)(`span`,{className:`text-xs text-green-600`,children:r(`plugins.saved`)}):null,(0,d.jsx)(`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:p,onClick:b,children:r(p?`plugins.saving`:o===`workspace`?`plugins.saveWorkspace`:`plugins.saveGlobal`)})]})]})]})}function Bs({field:e,draft:t,setDraft:n}){let{resolveMessage:r}=(0,f.useEditorI18n)(),i=(0,f.useTranslations)(`shell`),a=t[e.id],o=`plugin-setting-${e.id}`;function s(r){n({...t,[e.id]:r})}let c=(0,d.jsx)(`label`,{className:`text-sm font-medium text-gray-900`,htmlFor:o,children:r(e?.labelMessage,e.label)}),l=`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`?(0,d.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[(0,d.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[c,r(e?.descriptionMessage,e.description)?(0,d.jsx)(`span`,{className:`text-xs text-gray-500`,children:r(e?.descriptionMessage,e.description)}):null]}),(0,d.jsx)(`input`,{id:o,type:`checkbox`,checked:a===!0,onChange:e=>s(e.currentTarget.checked),className:`h-4 w-4 rounded border-gray-300 text-me-primary-500 focus:ring-me-primary-500`})]}):e.type===`textarea`?(0,d.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[c,r(e?.descriptionMessage,e.description)?(0,d.jsx)(`span`,{className:`text-xs text-gray-500`,children:r(e?.descriptionMessage,e.description)}):null,(0,d.jsx)(`textarea`,{id:o,className:`${l} min-h-24 resize-y`,value:typeof a==`string`?a:``,placeholder:r(e?.placeholderMessage,e.placeholder),onChange:e=>s(e.currentTarget.value)})]}):e.type===`select`?(0,d.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[c,r(e?.descriptionMessage,e.description)?(0,d.jsx)(`span`,{className:`text-xs text-gray-500`,children:r(e?.descriptionMessage,e.description)}):null,(0,d.jsxs)(`select`,{id:o,className:l,value:a===void 0?``:String(a),onChange:t=>{let n=e.options?.find(e=>String(e.value)===t.currentTarget.value);s(n?n.value:t.currentTarget.value)},children:[(0,d.jsx)(`option`,{value:``,children:i(`plugins.default`)}),(e.options||[]).map(e=>(0,d.jsx)(`option`,{value:String(e.value),children:r(e?.labelMessage,e.label)},String(e.value)))]})]}):(0,d.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-gray-100 bg-white px-4 py-3`,children:[c,r(e?.descriptionMessage,e.description)?(0,d.jsx)(`span`,{className:`text-xs text-gray-500`,children:r(e?.descriptionMessage,e.description)}):null,(0,d.jsx)(`input`,{id:o,className:l,type:e.type===`number`?`number`:`text`,value:typeof a==`string`||typeof a==`number`?a:``,placeholder:r(e?.placeholderMessage,e.placeholder),onChange:t=>{s(e.type===`number`?Number(t.currentTarget.value):t.currentTarget.value)}})]})}function Vs(){let e=(0,f.useTranslations)(`shell`),t=U(),n=de(),r=t.creators[`iiif-image-services`]||{};return(0,d.jsxs)(l.Form.Form,{className:`flex max-w-3xl flex-col gap-4`,onChange:e=>{let t=new FormData(e.currentTarget);n({creators:{"iiif-image-services":{compact:t.get(`compact`)===`compact`?`compact`:`with-dimensions`,includeSizes:t.get(`includeSizes`)===`on`,includeTiles:t.get(`includeTiles`)===`on`}}})},onSubmit:e=>e.preventDefault(),children:[(0,d.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900`,children:e(`settings.iiif`)}),(0,d.jsxs)(`fieldset`,{className:`flex flex-col gap-4`,children:[(0,d.jsx)(`legend`,{className:`mb-3 text-base font-semibold`,children:e(`settings.imageServices`)}),(0,d.jsxs)(l.Form.InputContainer,{children:[(0,d.jsx)(l.Form.Label,{htmlFor:`compactImageServices`,children:e(`settings.compact`)}),(0,d.jsxs)(`select`,{id:`compactImageServices`,name:`compact`,className:`rounded border border-gray-300 p-2`,defaultValue:r.compact===`compact`?`compact`:`with-dimensions`,children:[(0,d.jsx)(`option`,{value:`with-dimensions`,children:e(`settings.dimensions`)}),(0,d.jsx)(`option`,{value:`compact`,children:e(`settings.minimal`)})]})]}),(0,d.jsxs)(l.Form.InputContainer,{horizontal:!0,children:[(0,d.jsx)(l.Form.Input,{id:`includeSizes`,name:`includeSizes`,type:`checkbox`,defaultChecked:r.includeSizes===!0}),(0,d.jsx)(l.Form.Label,{htmlFor:`includeSizes`,children:e(`settings.sizes`)})]}),(0,d.jsxs)(l.Form.InputContainer,{horizontal:!0,children:[(0,d.jsx)(l.Form.Input,{id:`includeTiles`,name:`includeTiles`,type:`checkbox`,defaultChecked:r.includeTiles===!0}),(0,d.jsx)(l.Form.Label,{htmlFor:`includeTiles`,children:e(`settings.tiles`)})]}),(0,d.jsx)(`p`,{className:`text-sm text-gray-500`,children:e(`settings.imageHelp`)})]})]})}function Hs(){let{resolveMessage:e}=(0,f.useEditorI18n)(),t=(0,f.useTranslations)(`shell`),n=xi(),r=J(),i=U(),a=de(),[o,s]=js(2e3);function c(e){e.preventDefault();let t=new FormData(e.target),n={defaultPreview:t.get(`defaultPreview`),i18n:{...i.i18n||{},advancedLanguageMode:t.get(`advancedLanguageMode`)===`on`,availableLanguages:(t.get(`availableLanguages`)||``).split(`,`).map(e=>e.trim()),defaultLanguage:t.get(`defaultLanguage`)},export:{...i.export||{},version:t.get(`isVersion2`)===`on`?2:3,baseIdentifier:t.get(`base`)||null},plugins:i.plugins,editorFeatureFlags:{...i.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`}};a(n),s.set(),s.clear()}return(0,d.jsxs)(l.Sidebar,{children:[(0,d.jsx)(l.SidebarHeader,{title:t(`settings.title`)}),o?(0,d.jsx)(`div`,{className:`bg-me-primary-500 text-white p-3 text-sm`,children:t(`settings.saved`)}):null,(0,d.jsxs)(l.SidebarContent,{className:`p-4`,children:[(0,d.jsx)(Vs,{}),(0,d.jsxs)(l.Form.Form,{onSubmit:c,className:`flex flex-col gap-3`,children:[(0,d.jsxs)(l.Form.InputContainer,{children:[(0,d.jsx)(l.Form.Label,{htmlFor:`defaultLanguage`,children:t(`settings.contentDefault`)}),(0,d.jsx)(l.Form.Input,{type:`text`,name:`defaultLanguage`,id:`defaultLanguage`,defaultValue:i.i18n?.defaultLanguage||``})]}),(0,d.jsxs)(l.Form.InputContainer,{children:[(0,d.jsx)(l.Form.Label,{htmlFor:`availableLanguages`,children:t(`settings.contentAvailable`)}),(0,d.jsx)(l.Form.Input,{type:`text`,name:`availableLanguages`,id:`availableLanguages`,defaultValue:(i.i18n?.availableLanguages||[]).join(`, `)})]}),(0,d.jsxs)(l.Form.InputContainer,{horizontal:!0,className:`my-3`,children:[(0,d.jsx)(l.Form.Input,{type:`checkbox`,name:`advancedLanguageMode`,id:`advancedLanguageMode`,defaultChecked:i.i18n?.advancedLanguageMode||!1}),(0,d.jsx)(l.Form.Label,{htmlFor:`advancedLanguageMode`,children:t(`settings.contentAdvanced`)})]}),(0,d.jsxs)(l.Form.InputContainer,{horizontal:!0,className:`my-3`,children:[(0,d.jsx)(l.Form.Input,{type:`checkbox`,name:`textGranularityEnabled`,id:`textGranularityEnabled`,defaultChecked:i.i18n?.textGranularityEnabled||!1}),(0,d.jsx)(l.Form.Label,{htmlFor:`textGranularityEnabled`,children:t(`settings.textGranularity`)})]}),(0,d.jsxs)(l.Form.InputContainer,{horizontal:!0,className:`my-3`,children:[(0,d.jsx)(l.Form.Input,{type:`checkbox`,name:`rememberCanvasId`,id:`rememberCanvasId`,defaultChecked:i.editorFeatureFlags?.rememberCanvasId||!1}),(0,d.jsx)(l.Form.Label,{htmlFor:`rememberCanvasId`,children:t(`settings.rememberCanvas`)})]}),(0,d.jsxs)(l.Form.InputContainer,{horizontal:!0,className:`my-3`,children:[(0,d.jsx)(l.Form.Input,{type:`checkbox`,name:`rememberLeftPanelId`,id:`rememberLeftPanelId`,defaultChecked:i.editorFeatureFlags?.rememberLeftPanelId||!1}),(0,d.jsx)(l.Form.Label,{htmlFor:`rememberLeftPanelId`,children:t(`settings.rememberPanel`)})]}),(0,d.jsxs)(l.Form.InputContainer,{horizontal:!0,className:`my-3`,children:[(0,d.jsx)(l.Form.Input,{type:`checkbox`,name:`manifestGridOptions`,id:`manifestGridOptions`,defaultChecked:i.editorFeatureFlags?.manifestGridOptions||!1}),(0,d.jsx)(l.Form.Label,{htmlFor:`manifestGridOptions`,children:t(`settings.grid`)})]}),(0,d.jsxs)(l.Form.InputContainer,{horizontal:!0,className:`my-3`,children:[(0,d.jsx)(l.Form.Input,{type:`checkbox`,name:`isVersion2`,id:`isVersion2`,defaultChecked:i.export?.version===2}),(0,d.jsx)(l.Form.Label,{htmlFor:`isVersion2`,children:t(r.type===`Collection`?`settings.exportCollections`:`settings.exportManifests`)})]}),(0,d.jsxs)(l.Form.InputContainer,{children:[(0,d.jsx)(l.Form.Label,{htmlFor:`defaultPreview`,children:t(`settings.defaultPreview`)}),(0,d.jsx)(`div`,{children:n.configs.map((t,n)=>t.type===`iiif-preview-service`?null:(0,d.jsxs)(l.Form.InputContainer,{horizontal:!0,children:[(0,d.jsx)(l.Form.Input,{type:`radio`,id:t.id,name:`defaultPreview`,value:t.id,defaultChecked:i.defaultPreview?i.defaultPreview===t.id:n===0}),(0,d.jsx)(`label`,{htmlFor:t.id,children:e(t?.labelMessage,t.label)})]},t.id))})]}),r.type===`Manifest`?(0,d.jsx)(`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`)?t(`settings.return`):t(`settings.exhibition`)}):null,(0,d.jsx)(Rs,{}),(0,d.jsx)(`div`,{className:`mt-5`,children:(0,d.jsx)(l.ActionButton,{type:`submit`,children:t(`actions.save`)})})]})]})]})}function Us(e){let t=new Map;for(let n of e){if(!n.configuration?.fields.length)continue;let e=(0,j.getCreatorConfigKey)(n);(!t.has(e)||n.id===e)&&t.set(e,n)}return Array.from(t.values())}function Ws(){let{resolveMessage:e}=(0,f.useEditorI18n)(),t=(0,f.useTranslations)(`shell`),n=q(),r=U(),i=de(),a=(0,u.useMemo)(()=>Us(n.layout.creators||[]),[n.layout.creators]);function o(e,t){let n=(0,j.getCreatorConfigKey)(e),r=new FormData(t),a={};for(let t of e.configuration?.fields||[])t.type===`checkbox`&&(a[t.id]=r.get(t.id)===`on`);i({creators:{[n]:a}})}return a.length?(0,d.jsx)(`div`,{className:`flex max-w-3xl flex-col gap-6`,children:a.map(t=>(0,d.jsxs)(l.Form.Form,{className:`flex flex-col gap-3 border-b border-gray-100 pb-5 last:border-b-0`,onChange:e=>o(t,e.currentTarget),children:[(0,d.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,d.jsx)(`h3`,{className:`text-base font-semibold text-gray-900`,children:e(t?.labelMessage,t.label)}),e(t?.summaryMessage,t.summary)?(0,d.jsx)(`p`,{className:`text-sm text-gray-500`,children:e(t?.summaryMessage,t.summary)}):null]}),t.configuration?.fields.map(n=>{let i=(0,j.getCreatorConfigKey)(t),a=r.creators?.[i]?.[n.id],o=`${i}-${n.id}`;return n.type===`checkbox`?(0,d.jsxs)(l.Form.InputContainer,{horizontal:!0,className:`my-1 items-start`,children:[(0,d.jsx)(l.Form.Input,{type:`checkbox`,name:n.id,id:o,defaultChecked:typeof a==`boolean`?a:n.defaultValue||!1}),(0,d.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,d.jsx)(l.Form.Label,{htmlFor:o,children:e(n?.labelMessage,n.label)}),e(n?.summaryMessage,n.summary)?(0,d.jsx)(`p`,{className:`text-sm text-gray-500`,children:e(n?.summaryMessage,n.summary)}):null]})]},n.id):null})]},(0,j.getCreatorConfigKey)(t)))}):(0,d.jsx)(l.EmptyState,{children:t(`settings.noCreators`)})}function Gs(){return(0,p.createStore)((e,t)=>({specificMenus:{},resourceMenus:{},hookMenuItem(t){let n=Zt(),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 Ks=(0,u.createContext)(null);function qs({children:e}){let t=(0,u.useMemo)(()=>Gs(),[]);return(0,d.jsx)(Ks.Provider,{value:t,children:e})}function Js(){let e=(0,u.useContext)(Ks);if(!e)throw Error(`useContextMenuStore must be used within a ContextMenuProvider`);return e}function Ys(e){let t=Js(),n=(0,p.useStore)(t,e=>e.resourceMenus),r=(0,p.useStore)(t,e=>e.specificMenus);return(0,u.useMemo)(()=>{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 Xs(c)},[r,n,e.id,e.type])}function Xs(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 Zs(e,t=[]){let n=Js(),r=(0,p.useStore)(n,e=>e.hookMenuItem);(0,u.useEffect)(()=>r(e),[r,e.resource?.id,e.resource?.type,...t])}var Qs={CenterPanelContainer:`_CenterPanelContainer_1sbe6_1`,CenterPanelHeader:`_CenterPanelHeader_1sbe6_16`,CenterPanelClose:`_CenterPanelClose_1sbe6_23`,CenterPanelTitle:`_CenterPanelTitle_1sbe6_28`};function $s(e){let t=(0,f.useTranslations)(`ui`);return(0,d.jsxs)(`div`,{className:Qs.CenterPanelContainer,children:[e.title||e.close?(0,d.jsxs)(`div`,{className:Qs.CenterPanelHeader,children:[e.title?(0,d.jsx)(`h2`,{className:Qs.CenterPanelTitle,children:e.title}):null,e.close?(0,d.jsx)(X,{"aria-label":t(`actions.close`),className:Qs.CenterPanelClose,onClick:e.close,children:(0,d.jsx)(ii,{})}):null]}):null,e.children]})}const ec=y.default.div`
|
|
445
470
|
flex: 1;
|
|
446
471
|
display: flex;
|
|
447
472
|
width: 100%;
|
|
448
473
|
flex-direction: column;
|
|
449
474
|
position: relative;
|
|
450
|
-
`,
|
|
475
|
+
`,tc=y.default.div`
|
|
451
476
|
background: #fff;
|
|
452
477
|
position: relative;
|
|
453
478
|
border-bottom: 1px solid #d0d0d0;
|
|
@@ -465,11 +490,11 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
465
490
|
//flex-direction: column;
|
|
466
491
|
//justify-content: center;
|
|
467
492
|
}
|
|
468
|
-
`,
|
|
493
|
+
`,nc=y.default.p`
|
|
469
494
|
font-size: 0.9em;
|
|
470
495
|
color: #777;
|
|
471
496
|
font-weight: 400;
|
|
472
|
-
`,
|
|
497
|
+
`,rc=y.default.button`
|
|
473
498
|
color: inherit;
|
|
474
499
|
text-rendering: geometricPrecision;
|
|
475
500
|
border: none;
|
|
@@ -511,7 +536,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
511
536
|
margin-top: 0.5em;
|
|
512
537
|
}
|
|
513
538
|
}
|
|
514
|
-
`,
|
|
539
|
+
`,ic=y.default.div`
|
|
515
540
|
font-size: 1.4em;
|
|
516
541
|
padding-right: 0.3em;
|
|
517
542
|
display: flex;
|
|
@@ -520,7 +545,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
520
545
|
[data-large="true"] & {
|
|
521
546
|
font-size: 2em;
|
|
522
547
|
}
|
|
523
|
-
`,
|
|
548
|
+
`,ac=y.default.div`
|
|
524
549
|
width: 2em;
|
|
525
550
|
align-items: center;
|
|
526
551
|
//padding-top: 0.5em;
|
|
@@ -533,11 +558,11 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
533
558
|
fill: #999;
|
|
534
559
|
color: #999;
|
|
535
560
|
}
|
|
536
|
-
`,
|
|
561
|
+
`,oc=y.default.div`
|
|
537
562
|
min-height: 0;
|
|
538
563
|
overflow: visible;
|
|
539
564
|
display: flex;
|
|
540
|
-
`,
|
|
565
|
+
`,sc=y.default.div`
|
|
541
566
|
min-height: 0;
|
|
542
567
|
overflow: visible;
|
|
543
568
|
flex: 1;
|
|
@@ -550,7 +575,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
550
575
|
&[data-max-height="true"] {
|
|
551
576
|
overflow-y: auto;
|
|
552
577
|
}
|
|
553
|
-
`,
|
|
578
|
+
`,cc=y.default.section`
|
|
554
579
|
display: grid;
|
|
555
580
|
grid-template-rows: 0fr;
|
|
556
581
|
overflow: hidden;
|
|
@@ -578,7 +603,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
578
603
|
&[data-scrolled="true"] {
|
|
579
604
|
box-shadow: inset 0px 2px 0px 0 rgba(0, 0, 0, 0.1);
|
|
580
605
|
}
|
|
581
|
-
`,
|
|
606
|
+
`,lc=y.default.div`
|
|
582
607
|
position: sticky;
|
|
583
608
|
display: flex;
|
|
584
609
|
top: 0;
|
|
@@ -614,7 +639,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
614
639
|
right: 0.5em;
|
|
615
640
|
}
|
|
616
641
|
}
|
|
617
|
-
`,
|
|
642
|
+
`,uc=(()=>void 0);let dc=0;function fc(){return(0,u.useMemo)(()=>dc++,[])}function pc(e,t=!1){let[n,r]=(0,u.useState)([]),i=(0,u.useRef)(-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(0,u.useEffect)(()=>{r(t=>Array(e).fill(0).map((e,n)=>t[n]||(0,u.createRef)()))},[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 mc=(0,u.forwardRef)(function(e,t){let n=(0,u.useRef)(null),r=(0,u.useRef)(null),i=fc(),[a,o]=(0,u.useState)(e.initialOpen||!1),s=e.onChange||uc,c=()=>{s(!a),o(e=>!e)},l=e.maxHeight,[f,p]=(0,u.useState)(!1);return(0,u.useImperativeHandle)(t,()=>({open(){s(!0),o(!0)},close(){s(!1),o(!1)},toggle(){c()},focus(){r.current&&r.current.focus()},button:r})),(0,d.jsxs)(tc,{"data-large":e.large,"data-open":a,children:[(0,d.jsxs)(lc,{"data-open":a,children:[e.icon?(0,d.jsx)(ac,{onClick:c,children:e.icon}):null,(0,d.jsxs)(rc,{ref:r,onClick:c,"aria-expanded":a,"aria-controls":`accordion-${i}`,children:[e.label,e.description?(0,d.jsx)(nc,{children:e.description}):null]}),(0,d.jsx)(ic,{onClick:c,children:(0,d.jsx)(ai,{width:`1em`,height:`1em`,rotate:a?0:180})})]}),(0,d.jsx)(cc,{"aria-labelledby":`accordion-${i}`,"aria-hidden":!a,"data-overflow":!!e.overflow,"data-has-icon":!!e.icon,onScroll:e=>{e.target.scrollTop>0?p(!0):p(!1)},ref:n,$initial:!a,"data-scrolled":f,hidden:!a,children:(0,d.jsx)(oc,{children:(0,d.jsx)(sc,{"data-max-height":!!l,"data-full":e.fullWidth,style:{maxHeight:l||void 0},children:e.children})})})]})});function hc(e){let{getItemProps:t,onKeyDown:n}=pc(e.items.length,e.singleMode);return(0,d.jsx)(ec,{onKeyDown:n,children:e.items.map((n,r)=>(0,d.jsx)(mc,{overflow:e.overflow,maxHeight:e.maxHeight,...n,...t(r),children:n.children},r))})}function gc(){return(0,d.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`48`,viewBox:`0 -960 960 960`,width:`48`,children:(0,d.jsx)(`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 _c=y.default.div`
|
|
618
643
|
padding: 0.3em;
|
|
619
644
|
|
|
620
645
|
display: flex;
|
|
@@ -636,12 +661,12 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
636
661
|
position: sticky;
|
|
637
662
|
bottom: 0;
|
|
638
663
|
}
|
|
639
|
-
`;function
|
|
664
|
+
`;function vc(e){let t=(0,f.useTranslations)(`shell`),n=(0,g.useManifest)(),r=(0,g.useVault)(),i=Tr(),a=(0,u.useMemo)(()=>JSON.stringify(r.toPresentation3(n),null,2),[n,r]),o=(0,u.useMemo)(()=>JSON.stringify(r.toPresentation2(n),null,2),[n,r]);return(0,d.jsx)($s,{title:t(`export.title`),close:i.centerPanel.popStack,children:(0,d.jsx)(`div`,{style:{flex:1,overflowY:`auto`},children:(0,d.jsx)(hc,{items:[{label:t(`export.presentation3`),description:t(`export.instructions`),maxHeight:400,large:!0,initialOpen:!0,overflow:!0,icon:(0,d.jsx)(X,{onClick:()=>Yt(a,`manifest.json`),children:(0,d.jsx)(gc,{})}),children:(0,d.jsxs)(`div`,{style:{maxWidth:`100%`},children:[(0,d.jsx)(`pre`,{style:{whiteSpace:`pre-wrap`},children:JSON.stringify(r.toPresentation3(n),null,2)}),(0,d.jsxs)(_c,{"data-sticky":`true`,children:[(0,d.jsx)(X,{onClick:()=>Xt(a),children:t(`export.copy`)}),(0,d.jsx)(X,{onClick:()=>Yt(a,`manifest.json`),children:t(`export.download`)})]})]})},{label:t(`export.presentation2`),description:t(`export.instructions`),maxHeight:400,large:!0,icon:(0,d.jsx)(X,{onClick:()=>Yt(o,`manifest.json`),children:(0,d.jsx)(gc,{})}),children:(0,d.jsxs)(`div`,{style:{maxWidth:`100%`},children:[(0,d.jsx)(`pre`,{style:{whiteSpace:`pre-wrap`},children:JSON.stringify(r.toPresentation2(n),null,2)}),(0,d.jsxs)(_c,{"data-sticky":`true`,children:[(0,d.jsx)(X,{onClick:()=>Xt(o),children:t(`export.copy`)}),(0,d.jsx)(X,{onClick:()=>Yt(o,`manifest.json`),children:t(`export.download`)})]})]})}]})})})}function yc({key:e,initialValue:t,requestId:n,getInitialValue:r}){let[i,a]=(0,g.useCurrentAnnotationMetadata)({requestId:n}),[o,s]=(0,u.useState)(r&&r(i)||i[e]||t);return[o,(0,u.useCallback)(t=>{a({[e]:t}),s(t)},[])]}const bc=(0,N.default)(),xc=(0,u.createContext)(bc);function Sc({children:e,emitter:t}){return(0,d.jsx)(xc.Provider,{value:t,children:e})}function Cc(){return(0,u.useContext)(xc)}function wc(e,t,n=[]){let r=(0,u.useContext)(xc);(0,u.useEffect)(()=>{let n=e=>{t(e)};return r.on(e,n),()=>{r.off(e,n)}},[r,e,...n])}function Tc(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]=(0,u.useState)(i);return(0,u.useLayoutEffect)(()=>{let e=()=>o(i);return r.forEach(t=>t.addListener(e)),()=>r.forEach(t=>t.removeListener(e))},[]),a}function Ec(e,t,n,r=!0){let i=(0,P.useDebounce)(t,n);(0,u.useEffect)(()=>typeof window>`u`?()=>void 0:(window.addEventListener(`beforeunload`,t,!1),()=>{t(),window.removeEventListener(`beforeunload`,t)}),[t]),(0,u.useEffect)(()=>{if(e&&r)return e.subscribe(i,!0)},[i,e,r])}function Dc(){let e=(0,g.useAtlasStore)(),t=(0,p.useStore)(e,e=>e.switchTool),n=(0,p.useStore)(e,e=>e.polygonState.currentTool),r=(0,p.useStore)(e,e=>e.polygonState.selectedStamp),i=(0,p.useStore)(e,e=>e.polygonState.showBoundingBox);return(0,u.useMemo)(()=>({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 Oc=y.default.div`
|
|
640
665
|
position: relative;
|
|
641
666
|
width: 1px;
|
|
642
667
|
background: rgba(0, 0, 0, 0.2);
|
|
643
668
|
z-index: 50;
|
|
644
|
-
`,
|
|
669
|
+
`,kc=(0,y.default)(Si)`
|
|
645
670
|
transition:
|
|
646
671
|
opacity 300ms,
|
|
647
672
|
transform 300ms;
|
|
@@ -653,7 +678,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
653
678
|
&:focus {
|
|
654
679
|
outline: 2px solid salmon;
|
|
655
680
|
}
|
|
656
|
-
`;(0,
|
|
681
|
+
`;(0,y.default)(kc)`
|
|
657
682
|
background: #fff;
|
|
658
683
|
width: 30px;
|
|
659
684
|
height: 30px;
|
|
@@ -667,7 +692,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
667
692
|
svg {
|
|
668
693
|
fill: #9999;
|
|
669
694
|
}
|
|
670
|
-
`;const
|
|
695
|
+
`;const Ac=(0,y.default)(kc)`
|
|
671
696
|
position: relative;
|
|
672
697
|
display: flex;
|
|
673
698
|
opacity: 1;
|
|
@@ -694,7 +719,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
694
719
|
svg {
|
|
695
720
|
font-size: 1.5em;
|
|
696
721
|
}
|
|
697
|
-
`,
|
|
722
|
+
`,jc=y.default.div`
|
|
698
723
|
background: rgba(0, 0, 0, 0);
|
|
699
724
|
position: absolute;
|
|
700
725
|
width: 16px;
|
|
@@ -717,12 +742,12 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
717
742
|
&:hover {
|
|
718
743
|
transform: scaleX(100%);
|
|
719
744
|
background: rgba(0, 0, 0, 0.1);
|
|
720
|
-
${
|
|
745
|
+
${kc} {
|
|
721
746
|
transform: scaleX(100%);
|
|
722
747
|
opacity: 1;
|
|
723
748
|
}
|
|
724
749
|
}
|
|
725
|
-
`,
|
|
750
|
+
`,Mc=y.default.div`
|
|
726
751
|
background: rgba(0, 0, 0, 0);
|
|
727
752
|
position: absolute;
|
|
728
753
|
pointer-events: none;
|
|
@@ -731,21 +756,21 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
731
756
|
top: 0;
|
|
732
757
|
bottom: 0;
|
|
733
758
|
z-index: 51; // This will always be quite high.
|
|
734
|
-
`,
|
|
759
|
+
`,Nc=(0,u.forwardRef)(function({dir:e,open:t,actions:n,reset:r},i){let a=(0,f.useTranslations)(`shell`),[o,s]=(0,u.useState)(!0),c=`mt-[calc(50vh+8px)]`,p=e===`left`?`${c} ml-[13px]`:`${c} ml-[3px]`;return(0,d.jsxs)(Oc,{onClick:()=>n.open(),children:[(0,d.jsx)(Mc,{$open:t,$dir:e,className:`group`,children:t?null:(0,d.jsxs)(l.Tooltip,{placement:e===`left`?`right`:`left`,children:[(0,d.jsx)(l.TooltipTrigger,{"aria-label":a(e===`left`?`panels.openLeft`:`panels.openRight`),as:Ac,$dir:e,onClick:e=>n.open(),children:(0,d.jsx)(ai,{"aria-hidden":`true`,className:`text-2xl`,rotate:e===`right`?90:270})}),(0,d.jsx)(l.DefaultTooltipContent,{children:a(`actions.open`)})]})}),(0,d.jsxs)(l.Tooltip,{placement:e===`left`?`right`:`left`,children:[(0,d.jsx)(l.TooltipTrigger,{asChild:!0,children:(0,d.jsx)(`div`,{children:(0,d.jsxs)(jc,{ref:i,$open:t,$dir:e,className:`group`,children:[t?(0,d.jsxs)(l.Tooltip,{placement:e===`left`?`right`:`left`,children:[(0,d.jsx)(l.TooltipTrigger,{"aria-label":a(e===`left`?`panels.closeLeft`:`panels.closeRight`),as:l.IconHandle,onPress:()=>n.close(),children:(0,d.jsx)(`div`,{onMouseOut:()=>{s(!0)},onMouseOver:()=>{s(!1)},children:(0,d.jsx)(ii,{"aria-hidden":`true`})})}),(0,d.jsx)(l.DefaultTooltipContent,{children:a(`actions.close`)})]}):null,r&&t?(0,d.jsxs)(l.Tooltip,{placement:e===`left`?`right`:`left`,children:[(0,d.jsx)(l.TooltipTrigger,{"aria-label":a(e===`left`?`panels.resetLeft`:`panels.resetRight`),as:l.IconHandle,onPress:()=>r(),children:(0,d.jsx)(`div`,{onMouseOut:()=>{s(!0)},onMouseOver:()=>{s(!1)},children:(0,d.jsx)(l.ResetIcon,{"aria-hidden":`true`})})}),(0,d.jsx)(l.DefaultTooltipContent,{children:a(`actions.reset`)})]}):null,t?(0,d.jsxs)(l.Tooltip,{placement:e===`left`?`right`:`left`,children:[(0,d.jsx)(l.TooltipTrigger,{asChild:!0,children:(0,d.jsx)(`div`,{onMouseOut:()=>{s(!0)},onMouseOver:()=>{s(!1)},children:(0,d.jsx)(l.ResizeHandle,{"aria-label":a(`panels.resize`)})})}),(0,d.jsx)(l.DefaultTooltipContent,{children:a(`panels.resize`)})]}):null]})})}),o&&(0,d.jsx)(l.DefaultTooltipContent,{className:p,children:a(`panels.resize`)})]})]})});function Pc(e){return(0,d.jsx)(`svg`,{width:`1em`,height:`1em`,viewBox:`0 0 42 42`,xmlns:`http://www.w3.org/2000/svg`,stroke:`currentColor`,...e,children:(0,d.jsxs)(`g`,{transform:`translate(2 2)`,strokeWidth:5,fill:`none`,fillRule:`evenodd`,children:[(0,d.jsx)(`circle`,{strokeOpacity:.5,cx:18,cy:18,r:18}),(0,d.jsx)(`path`,{d:`M36 18c0-9.94-8.06-18-18-18`,children:(0,d.jsx)(`animateTransform`,{attributeName:`transform`,type:`rotate`,from:`0 18 18`,to:`360 18 18`,dur:`1s`,repeatCount:`indefinite`})})]})})}var Fc={ghostLoadingBlock:`_ghostLoadingBlock_1i1t4_1`,"ghost-loading":`_ghost-loading_1i1t4_1`,ghostLoading:`_ghost-loading_1i1t4_1`,ghostBlockList:`_ghostBlockList_1i1t4_28`};function Ic(){return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{"data-header":`true`,className:Fc.ghostLoadingBlock}),(0,d.jsxs)(`div`,{className:Fc.ghostBlockList,children:[(0,d.jsx)(`div`,{className:Fc.ghostLoadingBlock}),(0,d.jsx)(`div`,{className:Fc.ghostLoadingBlock}),(0,d.jsx)(`div`,{className:Fc.ghostLoadingBlock}),(0,d.jsx)(`div`,{className:Fc.ghostLoadingBlock})]})]})}function Lc(e,t,n,r=[]){(0,u.useLayoutEffect)(()=>{let r=e.current;if(r)return r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}},[t,...r])}function Rc(e,t,n,r){return Math.sqrt(Math.abs(n-e)**2+Math.abs(r-t)**2)}function zc(e,t,n,r){return n||(r?r/e:t)}function Bc(e,t={}){let n=(0,u.useRef)(null),r=(0,u.useRef)(null),i=(0,u.useRef)(null),a=(0,u.useRef)(null),o=(0,u.useRef)(.5),[s,c]=(0,u.useState)(!1),d=(0,u.useRef)(!1),f=(0,u.useRef)(0),p=(0,u.useRef)({x:0,y:0}),[{widthA:m,widthB:h},g]=(0,l.useLocalStorage)(`resize-layout/${e}`,{widthA:`auto`,widthB:`${Jo({initial:t.widthA,fallback:320,options:{minWidth:t.minWidthPx,maxWidth:t.maxWidthPx}})}px`}),{loading:_=!1}=t;return Lc(a,`mousedown`,e=>{p.current.x=e.pageX,p.current.y=e.pageY,f.current&&(clearTimeout(f.current),f.current=0),f.current=setTimeout(()=>{c(!0),d.current=!0},350)},[_]),Lc({current:typeof window<`u`?window:void 0},`mouseup`,()=>{let e=n.current;if(e&&d.current){let{x:n,width:r}=e.getBoundingClientRect(),i=t.marginLeft||0,a=zc(r,.8,t.maxWidthPct,t.maxWidthPx)*r,s=zc(r,.2,t.minWidthPct,t.minWidthPx)*r;if(t.left){let e=o.current*r-i;g({widthA:`${(1-o.current)*r-i}`,widthB:`${e>a?a:e<s?s:e}px`})}else{let e=1-o.current*r-i;g({widthA:`${e>a?a:e<s?s:e}px`,widthB:`${o.current*r-i}px`})}c(!1),d.current=!1,t.onDragEnd&&t.onDragEnd()}clearTimeout(f.current),f.current=0},[_]),Lc(n,`mousemove`,e=>{if(!d.current&&f.current&&Rc(p.current.x,p.current.y,e.pageX,e.pageY)>20&&(c(!0),d.current=!0,clearTimeout(f.current),f.current=0),d.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=zc(a,.8,t.maxWidthPct,t.maxWidthPx),u=zc(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,_]),{refs:{container:n,resizer:a,resizableDiv:r,otherDiv:i},setWidths:g,isDragging:s,widthA:m,widthB:h}}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)`},Vc=y.default.div`
|
|
735
760
|
display: flex;
|
|
736
761
|
flex: 1 1 0;
|
|
737
762
|
min-height: 0;
|
|
738
763
|
position: relative;
|
|
739
764
|
overflow: hidden;
|
|
740
765
|
|
|
741
|
-
${
|
|
742
|
-
background: ${
|
|
766
|
+
${Z} {
|
|
767
|
+
background: ${$.lightApp};
|
|
743
768
|
}
|
|
744
769
|
|
|
745
|
-
${
|
|
746
|
-
background: ${
|
|
770
|
+
${Q} {
|
|
771
|
+
background: ${$.darkApp};
|
|
747
772
|
}
|
|
748
|
-
`,
|
|
773
|
+
`,Hc=y.default.div`
|
|
749
774
|
flex: 1 1 0;
|
|
750
775
|
min-width: 0;
|
|
751
776
|
min-height: 0;
|
|
@@ -754,119 +779,119 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
754
779
|
padding-top: 1px;
|
|
755
780
|
overflow: hidden;
|
|
756
781
|
|
|
757
|
-
${
|
|
758
|
-
background: ${
|
|
782
|
+
${Z} {
|
|
783
|
+
background: ${$.lightApp};
|
|
759
784
|
}
|
|
760
785
|
|
|
761
|
-
${
|
|
762
|
-
background: ${
|
|
786
|
+
${Q} {
|
|
787
|
+
background: ${$.darkApp};
|
|
763
788
|
}
|
|
764
789
|
|
|
765
790
|
> * {
|
|
766
791
|
min-width: 0;
|
|
767
792
|
}
|
|
768
793
|
|
|
769
|
-
${
|
|
770
|
-
background: ${
|
|
771
|
-
color: ${
|
|
794
|
+
${Z} > .delft-exhibition {
|
|
795
|
+
background: ${$.lightStage};
|
|
796
|
+
color: ${$.lightText};
|
|
772
797
|
}
|
|
773
798
|
|
|
774
|
-
${
|
|
775
|
-
--atlas-background: ${
|
|
776
|
-
background: ${
|
|
799
|
+
${Z} .atlas-container {
|
|
800
|
+
--atlas-background: var(--canvas-workspace-background, ${$.lightStage}) !important;
|
|
801
|
+
background: var(--canvas-workspace-background, ${$.lightStage}) !important;
|
|
777
802
|
}
|
|
778
803
|
|
|
779
|
-
${
|
|
780
|
-
background: ${
|
|
804
|
+
${Z} .atlas-canvas {
|
|
805
|
+
background: var(--canvas-workspace-background, ${$.lightStage}) !important;
|
|
781
806
|
}
|
|
782
807
|
|
|
783
|
-
${
|
|
784
|
-
background: ${
|
|
785
|
-
color: ${
|
|
808
|
+
${Q} > .delft-exhibition {
|
|
809
|
+
background: ${$.darkStage};
|
|
810
|
+
color: ${$.darkText};
|
|
786
811
|
}
|
|
787
812
|
|
|
788
|
-
${
|
|
789
|
-
--atlas-background: ${
|
|
790
|
-
background: ${
|
|
813
|
+
${Q} .atlas-container {
|
|
814
|
+
--atlas-background: var(--canvas-workspace-background, ${$.darkStage}) !important;
|
|
815
|
+
background: var(--canvas-workspace-background, ${$.darkStage}) !important;
|
|
791
816
|
}
|
|
792
817
|
|
|
793
|
-
${
|
|
794
|
-
background: ${
|
|
818
|
+
${Q} .atlas-canvas {
|
|
819
|
+
background: var(--canvas-workspace-background, ${$.darkStage}) !important;
|
|
795
820
|
}
|
|
796
821
|
|
|
797
|
-
${
|
|
798
|
-
${
|
|
799
|
-
background: ${
|
|
822
|
+
${Q} [class*="CanvasContainer"],
|
|
823
|
+
${Q} [class*="ViewerContainer"] {
|
|
824
|
+
background: ${$.darkStage} !important;
|
|
800
825
|
}
|
|
801
826
|
|
|
802
|
-
${
|
|
803
|
-
${
|
|
804
|
-
background: ${
|
|
805
|
-
color: ${
|
|
827
|
+
${Q} .exhibition-slideshow-workbench,
|
|
828
|
+
${Q} .exhibition-slideshow-current-canvas {
|
|
829
|
+
background: ${$.darkApp} !important;
|
|
830
|
+
color: ${$.darkText} !important;
|
|
806
831
|
}
|
|
807
832
|
|
|
808
|
-
${
|
|
809
|
-
${
|
|
810
|
-
background: ${
|
|
833
|
+
${Q} .exhibition-slideshow-current-viewport,
|
|
834
|
+
${Q} .exhibition-slideshow-preview-frame {
|
|
835
|
+
background: ${$.darkStage} !important;
|
|
811
836
|
}
|
|
812
837
|
|
|
813
|
-
${
|
|
814
|
-
color: ${
|
|
838
|
+
${Q} .exhibition-slideshow-heading {
|
|
839
|
+
color: ${$.darkText} !important;
|
|
815
840
|
}
|
|
816
841
|
|
|
817
|
-
${
|
|
818
|
-
color: ${
|
|
842
|
+
${Q} .exhibition-slideshow-muted {
|
|
843
|
+
color: ${$.darkMuted} !important;
|
|
819
844
|
}
|
|
820
845
|
|
|
821
|
-
${
|
|
822
|
-
${
|
|
823
|
-
${
|
|
824
|
-
${
|
|
825
|
-
${
|
|
826
|
-
${
|
|
827
|
-
${
|
|
828
|
-
background: ${
|
|
829
|
-
border-color: ${
|
|
830
|
-
color: ${
|
|
846
|
+
${Q} .exhibition-slideshow-preview-card,
|
|
847
|
+
${Q} .exhibition-slideshow-slide-strip,
|
|
848
|
+
${Q} .exhibition-slideshow-slide-card,
|
|
849
|
+
${Q} .exhibition-slideshow-content-item,
|
|
850
|
+
${Q} .exhibition-slideshow-content-empty,
|
|
851
|
+
${Q} .exhibition-slideshow-navigation,
|
|
852
|
+
${Q} .exhibition-slideshow-current-preview {
|
|
853
|
+
background: ${$.darkPanel} !important;
|
|
854
|
+
border-color: ${$.darkBorder} !important;
|
|
855
|
+
color: ${$.darkText} !important;
|
|
831
856
|
}
|
|
832
857
|
|
|
833
|
-
${
|
|
834
|
-
background: ${
|
|
835
|
-
border-color: ${
|
|
858
|
+
${Q} .exhibition-slideshow-content-item-selected {
|
|
859
|
+
background: ${$.darkSelected} !important;
|
|
860
|
+
border-color: ${$.pink} !important;
|
|
836
861
|
}
|
|
837
862
|
|
|
838
|
-
${
|
|
839
|
-
${
|
|
840
|
-
background: ${
|
|
841
|
-
border-color: ${
|
|
842
|
-
color: ${
|
|
863
|
+
${Q} .exhibition-slideshow-toolbar,
|
|
864
|
+
${Q} .exhibition-slideshow-current-toolbar {
|
|
865
|
+
background: ${$.darkPanelHeader} !important;
|
|
866
|
+
border-color: ${$.darkBorder} !important;
|
|
867
|
+
color: ${$.darkText} !important;
|
|
843
868
|
}
|
|
844
869
|
|
|
845
|
-
${
|
|
846
|
-
${
|
|
847
|
-
${
|
|
848
|
-
${
|
|
849
|
-
${
|
|
850
|
-
${
|
|
851
|
-
background: ${
|
|
852
|
-
border-color: ${
|
|
853
|
-
color: ${
|
|
870
|
+
${Q} .exhibition-slideshow-navigation button,
|
|
871
|
+
${Q} .exhibition-slideshow-navigation-current,
|
|
872
|
+
${Q} .exhibition-slideshow-toolbar button,
|
|
873
|
+
${Q} .exhibition-slideshow-slide-card button,
|
|
874
|
+
${Q} .exhibition-slideshow-content-item button,
|
|
875
|
+
${Q} .exhibition-slideshow-current-control {
|
|
876
|
+
background: ${$.darkPanelSoft} !important;
|
|
877
|
+
border-color: ${$.darkBorder} !important;
|
|
878
|
+
color: ${$.darkText} !important;
|
|
854
879
|
}
|
|
855
880
|
|
|
856
|
-
${
|
|
857
|
-
${
|
|
858
|
-
${
|
|
859
|
-
${
|
|
860
|
-
${
|
|
861
|
-
background: ${
|
|
881
|
+
${Q} .exhibition-slideshow-navigation button:not(:disabled):hover,
|
|
882
|
+
${Q} .exhibition-slideshow-toolbar button:not(:disabled):hover,
|
|
883
|
+
${Q} .exhibition-slideshow-slide-card button:not(:disabled):hover,
|
|
884
|
+
${Q} .exhibition-slideshow-content-item button:not(:disabled):hover,
|
|
885
|
+
${Q} .exhibition-slideshow-current-control:not(:disabled):hover {
|
|
886
|
+
background: ${$.darkHover} !important;
|
|
862
887
|
color: #fff !important;
|
|
863
888
|
}
|
|
864
|
-
`,
|
|
889
|
+
`,Uc=y.default.div`
|
|
865
890
|
display: flex;
|
|
866
891
|
flex: 1;
|
|
867
892
|
justify-content: center;
|
|
868
893
|
align-items: center;
|
|
869
|
-
`,
|
|
894
|
+
`,Wc=y.default.div`
|
|
870
895
|
position: absolute;
|
|
871
896
|
top: 3rem;
|
|
872
897
|
z-index: 40;
|
|
@@ -879,24 +904,24 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
879
904
|
background: rgba(255, 255, 255, 0.94);
|
|
880
905
|
box-shadow: 0 8px 22px rgba(15, 23, 42, 0.12);
|
|
881
906
|
|
|
882
|
-
${
|
|
883
|
-
border-color: ${
|
|
907
|
+
${Z} {
|
|
908
|
+
border-color: ${$.lightBorder};
|
|
884
909
|
background: rgba(255, 255, 255, 0.96);
|
|
885
910
|
box-shadow: 0 8px 22px rgba(38, 33, 42, 0.12);
|
|
886
911
|
}
|
|
887
912
|
|
|
888
|
-
${
|
|
889
|
-
border-color: ${
|
|
913
|
+
${Q} {
|
|
914
|
+
border-color: ${$.darkBorder};
|
|
890
915
|
background: rgba(38, 33, 42, 0.94);
|
|
891
916
|
box-shadow: 0 12px 28px rgba(0, 0, 0, 0.36);
|
|
892
917
|
}
|
|
893
918
|
|
|
894
|
-
${e=>e.$side===`left`?
|
|
919
|
+
${e=>e.$side===`left`?y.css`
|
|
895
920
|
left: 1rem;
|
|
896
|
-
`:
|
|
921
|
+
`:y.css`
|
|
897
922
|
right: 1rem;
|
|
898
923
|
`}
|
|
899
|
-
`,
|
|
924
|
+
`,Gc=y.default.button`
|
|
900
925
|
width: 2.35rem;
|
|
901
926
|
height: 2.35rem;
|
|
902
927
|
border: 0;
|
|
@@ -915,35 +940,35 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
915
940
|
}
|
|
916
941
|
|
|
917
942
|
&[data-selected="true"] {
|
|
918
|
-
background: ${
|
|
943
|
+
background: ${$.pink};
|
|
919
944
|
color: #fff;
|
|
920
945
|
}
|
|
921
946
|
|
|
922
|
-
${
|
|
923
|
-
color: ${
|
|
947
|
+
${Z} {
|
|
948
|
+
color: ${$.lightMuted};
|
|
924
949
|
}
|
|
925
950
|
|
|
926
|
-
${
|
|
951
|
+
${Z}:hover {
|
|
927
952
|
background: #f5eaf0;
|
|
928
|
-
color: ${
|
|
953
|
+
color: ${$.lightText};
|
|
929
954
|
}
|
|
930
955
|
|
|
931
|
-
${
|
|
932
|
-
background: ${
|
|
956
|
+
${Z}[data-selected="true"] {
|
|
957
|
+
background: ${$.pink};
|
|
933
958
|
color: #fff;
|
|
934
959
|
}
|
|
935
960
|
|
|
936
|
-
${
|
|
961
|
+
${Q} {
|
|
937
962
|
color: #efe8ed;
|
|
938
963
|
}
|
|
939
964
|
|
|
940
|
-
${
|
|
965
|
+
${Q}:hover {
|
|
941
966
|
background: rgba(255, 255, 255, 0.1);
|
|
942
967
|
color: #fff;
|
|
943
968
|
}
|
|
944
969
|
|
|
945
|
-
${
|
|
946
|
-
background: ${
|
|
970
|
+
${Q}[data-selected="true"] {
|
|
971
|
+
background: ${$.pink};
|
|
947
972
|
color: #fff;
|
|
948
973
|
}
|
|
949
974
|
|
|
@@ -956,16 +981,16 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
956
981
|
width: 2.75rem;
|
|
957
982
|
height: 2.75rem;
|
|
958
983
|
}
|
|
959
|
-
`,
|
|
984
|
+
`,Kc=y.default.div`
|
|
960
985
|
display: flex;
|
|
961
986
|
flex-direction: column;
|
|
962
987
|
gap: 0.25rem;
|
|
963
|
-
`,
|
|
988
|
+
`,qc=y.default.div`
|
|
964
989
|
width: 100%;
|
|
965
990
|
height: 1px;
|
|
966
991
|
margin: 0.25rem 0;
|
|
967
992
|
background: rgba(15, 23, 42, 0.14);
|
|
968
|
-
`,
|
|
993
|
+
`,Jc=y.default.aside`
|
|
969
994
|
position: absolute;
|
|
970
995
|
top: 3rem;
|
|
971
996
|
bottom: 1rem;
|
|
@@ -984,258 +1009,258 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
984
1009
|
opacity 180ms ease,
|
|
985
1010
|
transform 180ms ease;
|
|
986
1011
|
|
|
987
|
-
${
|
|
988
|
-
background: ${
|
|
989
|
-
border-color: ${
|
|
1012
|
+
${Z} {
|
|
1013
|
+
background: ${$.lightPanel};
|
|
1014
|
+
border-color: ${$.lightPanelBorder};
|
|
990
1015
|
border-radius: 10px;
|
|
991
|
-
color: ${
|
|
1016
|
+
color: ${$.lightText};
|
|
992
1017
|
box-shadow: 0 18px 42px rgba(38, 33, 42, 0.14);
|
|
993
1018
|
}
|
|
994
1019
|
|
|
995
|
-
${
|
|
996
|
-
background-color: ${
|
|
1020
|
+
${Z} [class~="bg-white"] {
|
|
1021
|
+
background-color: ${$.lightPanel} !important;
|
|
997
1022
|
}
|
|
998
1023
|
|
|
999
|
-
${
|
|
1000
|
-
background-color: ${
|
|
1024
|
+
${Z} [class*="bg-[#f8f6f3]"] {
|
|
1025
|
+
background-color: ${$.lightPanelSoft} !important;
|
|
1001
1026
|
}
|
|
1002
1027
|
|
|
1003
|
-
${
|
|
1004
|
-
border-color: ${
|
|
1028
|
+
${Z} [class*="border-[#dcd5ce]"] {
|
|
1029
|
+
border-color: ${$.lightBorder} !important;
|
|
1005
1030
|
}
|
|
1006
1031
|
|
|
1007
|
-
${
|
|
1008
|
-
--exhibition-primary: ${
|
|
1009
|
-
--exhibition-field-bg: ${
|
|
1010
|
-
--exhibition-field-border: ${
|
|
1011
|
-
--exhibition-text: ${
|
|
1012
|
-
--exhibition-muted: ${
|
|
1013
|
-
--exhibition-button-bg: ${
|
|
1032
|
+
${Q} {
|
|
1033
|
+
--exhibition-primary: ${$.pink};
|
|
1034
|
+
--exhibition-field-bg: ${$.darkPanelSoft};
|
|
1035
|
+
--exhibition-field-border: ${$.darkBorder};
|
|
1036
|
+
--exhibition-text: ${$.darkText};
|
|
1037
|
+
--exhibition-muted: ${$.darkMuted};
|
|
1038
|
+
--exhibition-button-bg: ${$.darkPanelSoft};
|
|
1014
1039
|
--exhibition-button-text: #fff;
|
|
1015
|
-
--exhibition-inactive-button-text: ${
|
|
1040
|
+
--exhibition-inactive-button-text: ${$.darkText};
|
|
1016
1041
|
|
|
1017
|
-
background: ${
|
|
1018
|
-
border-color: ${
|
|
1019
|
-
color: ${
|
|
1042
|
+
background: ${$.darkPanel};
|
|
1043
|
+
border-color: ${$.darkBorderSoft};
|
|
1044
|
+
color: ${$.darkText};
|
|
1020
1045
|
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.42);
|
|
1021
1046
|
}
|
|
1022
1047
|
|
|
1023
|
-
${
|
|
1024
|
-
background: ${
|
|
1025
|
-
border-color: ${
|
|
1026
|
-
color: ${
|
|
1048
|
+
${Q} ${es} {
|
|
1049
|
+
background: ${$.darkPanelHeader} !important;
|
|
1050
|
+
border-color: ${$.darkBorder} !important;
|
|
1051
|
+
color: ${$.darkText} !important;
|
|
1027
1052
|
box-shadow:
|
|
1028
|
-
inset 0 -1px 0 0 ${
|
|
1029
|
-
inset 0 1px 0 0 ${
|
|
1053
|
+
inset 0 -1px 0 0 ${$.darkBorder},
|
|
1054
|
+
inset 0 1px 0 0 ${$.darkBorder} !important;
|
|
1030
1055
|
}
|
|
1031
1056
|
|
|
1032
|
-
${
|
|
1033
|
-
color: ${
|
|
1057
|
+
${Q} ${ts} {
|
|
1058
|
+
color: ${$.darkText} !important;
|
|
1034
1059
|
}
|
|
1035
1060
|
|
|
1036
|
-
${
|
|
1037
|
-
background: ${
|
|
1061
|
+
${Q} ${ts}:hover {
|
|
1062
|
+
background: ${$.darkHover} !important;
|
|
1038
1063
|
color: #fff !important;
|
|
1039
1064
|
}
|
|
1040
1065
|
|
|
1041
|
-
${
|
|
1042
|
-
${
|
|
1043
|
-
background-color: ${
|
|
1066
|
+
${Q} [class~="bg-white"],
|
|
1067
|
+
${Q} [class*="bg-[#f8f6f3]"] {
|
|
1068
|
+
background-color: ${$.darkPanelSoft} !important;
|
|
1044
1069
|
}
|
|
1045
1070
|
|
|
1046
|
-
${
|
|
1047
|
-
${
|
|
1048
|
-
${
|
|
1049
|
-
background-color: ${
|
|
1050
|
-
color: ${
|
|
1071
|
+
${Q} [class*="bg-gray-200"],
|
|
1072
|
+
${Q} [class*="bg-gray-100"],
|
|
1073
|
+
${Q} [class*="bg-me-gray-100"] {
|
|
1074
|
+
background-color: ${$.darkPanelHeader} !important;
|
|
1075
|
+
color: ${$.darkText} !important;
|
|
1051
1076
|
}
|
|
1052
1077
|
|
|
1053
|
-
${
|
|
1054
|
-
${
|
|
1055
|
-
${
|
|
1056
|
-
${
|
|
1057
|
-
${
|
|
1058
|
-
${
|
|
1059
|
-
${
|
|
1060
|
-
${
|
|
1061
|
-
${
|
|
1062
|
-
background-color: ${
|
|
1078
|
+
${Q} [class*="hover:bg-gray-100"]:hover,
|
|
1079
|
+
${Q} [class*="hover:bg-gray-200"]:hover,
|
|
1080
|
+
${Q} [class*="hover:bg-gray-300"]:hover,
|
|
1081
|
+
${Q} [class*="hover:bg-me-gray-100"]:hover,
|
|
1082
|
+
${Q} [class*="hover:bg-me-gray-300"]:hover,
|
|
1083
|
+
${Q} [class*="hover:bg-me-50"]:hover,
|
|
1084
|
+
${Q} [class*="hover:bg-me-100"]:hover,
|
|
1085
|
+
${Q} [class*="hover:bg-me-primary-50"]:hover,
|
|
1086
|
+
${Q} [class*="hover:bg-me-primary-100"]:hover {
|
|
1087
|
+
background-color: ${$.darkHover} !important;
|
|
1063
1088
|
color: #fff !important;
|
|
1064
1089
|
}
|
|
1065
1090
|
|
|
1066
|
-
${
|
|
1067
|
-
${
|
|
1068
|
-
${
|
|
1091
|
+
${Q} [class*="hover:text-black"]:hover,
|
|
1092
|
+
${Q} [class*="hover:text-gray-"]:hover,
|
|
1093
|
+
${Q} [class*="hover:text-me-"]:hover {
|
|
1069
1094
|
color: #fff !important;
|
|
1070
1095
|
}
|
|
1071
1096
|
|
|
1072
|
-
${
|
|
1097
|
+
${Q} label {
|
|
1073
1098
|
background-color: transparent !important;
|
|
1074
|
-
color: ${
|
|
1099
|
+
color: ${$.darkLabel} !important;
|
|
1075
1100
|
}
|
|
1076
1101
|
|
|
1077
|
-
${
|
|
1078
|
-
color: ${
|
|
1102
|
+
${Z} .exhibition-workbench-muted {
|
|
1103
|
+
color: ${$.lightMuted} !important;
|
|
1079
1104
|
}
|
|
1080
1105
|
|
|
1081
|
-
${
|
|
1082
|
-
color: ${
|
|
1106
|
+
${Q} .exhibition-workbench-muted {
|
|
1107
|
+
color: ${$.darkMuted} !important;
|
|
1083
1108
|
}
|
|
1084
1109
|
|
|
1085
|
-
${
|
|
1086
|
-
color: ${
|
|
1110
|
+
${Q} .exhibition-workbench-tab[class*="text-me-primary"] {
|
|
1111
|
+
color: ${$.darkText} !important;
|
|
1087
1112
|
}
|
|
1088
1113
|
|
|
1089
|
-
${
|
|
1090
|
-
background-color: ${
|
|
1091
|
-
border-color: ${
|
|
1092
|
-
color: ${
|
|
1114
|
+
${Q} fieldset {
|
|
1115
|
+
background-color: ${$.darkPanelSoft} !important;
|
|
1116
|
+
border-color: ${$.darkBorder} !important;
|
|
1117
|
+
color: ${$.darkText} !important;
|
|
1093
1118
|
}
|
|
1094
1119
|
|
|
1095
|
-
${
|
|
1096
|
-
${
|
|
1097
|
-
${
|
|
1098
|
-
${
|
|
1099
|
-
background-color: ${
|
|
1100
|
-
color: ${
|
|
1120
|
+
${Q} [class*="bg-me-50"],
|
|
1121
|
+
${Q} [class*="bg-me-100"],
|
|
1122
|
+
${Q} [class*="bg-me-primary-50"],
|
|
1123
|
+
${Q} [class*="bg-me-primary-100"] {
|
|
1124
|
+
background-color: ${$.darkSelected} !important;
|
|
1125
|
+
color: ${$.darkText} !important;
|
|
1101
1126
|
}
|
|
1102
1127
|
|
|
1103
|
-
${
|
|
1104
|
-
${
|
|
1105
|
-
${
|
|
1106
|
-
${
|
|
1107
|
-
${
|
|
1108
|
-
color: ${
|
|
1128
|
+
${Q} [class*="text-me-700"],
|
|
1129
|
+
${Q} [class*="text-me-500"],
|
|
1130
|
+
${Q} [class*="text-me-primary-500"],
|
|
1131
|
+
${Q} [class*="text-me-primary-600"],
|
|
1132
|
+
${Q} [class*="text-me-primary-700"] {
|
|
1133
|
+
color: ${$.darkText} !important;
|
|
1109
1134
|
}
|
|
1110
1135
|
|
|
1111
|
-
${
|
|
1112
|
-
background-color: ${
|
|
1113
|
-
color: ${
|
|
1136
|
+
${Q} [class*="bg-me-gray-100"] {
|
|
1137
|
+
background-color: ${$.darkPanelHeader} !important;
|
|
1138
|
+
color: ${$.darkText} !important;
|
|
1114
1139
|
}
|
|
1115
1140
|
|
|
1116
|
-
${
|
|
1117
|
-
border-bottom-color: ${
|
|
1141
|
+
${Q} [class*="border-b-me-gray-300"] {
|
|
1142
|
+
border-bottom-color: ${$.darkSelected} !important;
|
|
1118
1143
|
}
|
|
1119
1144
|
|
|
1120
|
-
${
|
|
1121
|
-
${
|
|
1122
|
-
background-color: ${
|
|
1145
|
+
${Q} [class*="hover:bg-me-gray-300"]:hover,
|
|
1146
|
+
${Q} [class*="bg-me-gray-300"] {
|
|
1147
|
+
background-color: ${$.darkHover} !important;
|
|
1123
1148
|
color: #fff !important;
|
|
1124
1149
|
}
|
|
1125
1150
|
|
|
1126
|
-
${
|
|
1127
|
-
${
|
|
1128
|
-
${
|
|
1129
|
-
${
|
|
1151
|
+
${Q} [data-active],
|
|
1152
|
+
${Q} [data-selected],
|
|
1153
|
+
${Q} [aria-selected="true"],
|
|
1154
|
+
${Q} [data-canvas-selected="true"] {
|
|
1130
1155
|
color: #fff !important;
|
|
1131
1156
|
}
|
|
1132
1157
|
|
|
1133
|
-
${
|
|
1134
|
-
${
|
|
1135
|
-
${
|
|
1136
|
-
background-color: ${
|
|
1158
|
+
${Q} [data-active="true"],
|
|
1159
|
+
${Q} [data-selected="true"],
|
|
1160
|
+
${Q} [aria-selected="true"] {
|
|
1161
|
+
background-color: ${$.pink} !important;
|
|
1137
1162
|
}
|
|
1138
1163
|
|
|
1139
|
-
${
|
|
1140
|
-
${
|
|
1141
|
-
${
|
|
1142
|
-
background-color: ${
|
|
1164
|
+
${Q} [class*="bg-me-primary-500"],
|
|
1165
|
+
${Q} [class*="bg-me-500"],
|
|
1166
|
+
${Q} [class*="bg-me-700"] {
|
|
1167
|
+
background-color: ${$.pink} !important;
|
|
1143
1168
|
color: #fff !important;
|
|
1144
1169
|
}
|
|
1145
1170
|
|
|
1146
|
-
${
|
|
1147
|
-
${
|
|
1148
|
-
${
|
|
1149
|
-
${
|
|
1150
|
-
background-color: ${
|
|
1171
|
+
${Q} [class*="hover:bg-me-primary-500"]:hover,
|
|
1172
|
+
${Q} [class*="hover:bg-me-primary-600"]:hover,
|
|
1173
|
+
${Q} [class*="hover:bg-me-600"]:hover,
|
|
1174
|
+
${Q} [class*="hover:bg-me-800"]:hover {
|
|
1175
|
+
background-color: ${$.pinkHover} !important;
|
|
1151
1176
|
color: #fff !important;
|
|
1152
1177
|
}
|
|
1153
1178
|
|
|
1154
|
-
${
|
|
1155
|
-
${
|
|
1156
|
-
color: ${
|
|
1179
|
+
${Q} [class*="text-[#25211f]"],
|
|
1180
|
+
${Q} [class*="text-black"] {
|
|
1181
|
+
color: ${$.darkText} !important;
|
|
1157
1182
|
}
|
|
1158
1183
|
|
|
1159
|
-
${
|
|
1160
|
-
${
|
|
1161
|
-
${
|
|
1162
|
-
color: ${
|
|
1184
|
+
${Q} [class*="text-black/40"],
|
|
1185
|
+
${Q} [class*="text-black/50"],
|
|
1186
|
+
${Q} [class*="text-black/60"] {
|
|
1187
|
+
color: ${$.darkMuted} !important;
|
|
1163
1188
|
}
|
|
1164
1189
|
|
|
1165
|
-
${
|
|
1166
|
-
${
|
|
1167
|
-
${
|
|
1168
|
-
${
|
|
1169
|
-
border-color: ${
|
|
1190
|
+
${Q} [class*="border-[#dcd5ce]"],
|
|
1191
|
+
${Q} [class*="border-[#e4ddd6]"],
|
|
1192
|
+
${Q} .border,
|
|
1193
|
+
${Q} .border-b {
|
|
1194
|
+
border-color: ${$.darkBorder} !important;
|
|
1170
1195
|
}
|
|
1171
1196
|
|
|
1172
|
-
${
|
|
1173
|
-
${
|
|
1174
|
-
${
|
|
1175
|
-
background-color: ${
|
|
1197
|
+
${Q} select,
|
|
1198
|
+
${Q} input,
|
|
1199
|
+
${Q} textarea {
|
|
1200
|
+
background-color: ${$.darkPanelSoft} !important;
|
|
1176
1201
|
border-color: rgba(246, 241, 244, 0.18) !important;
|
|
1177
|
-
color: ${
|
|
1202
|
+
color: ${$.darkText} !important;
|
|
1178
1203
|
}
|
|
1179
1204
|
|
|
1180
|
-
${
|
|
1181
|
-
${
|
|
1182
|
-
color: ${
|
|
1205
|
+
${Q} input::placeholder,
|
|
1206
|
+
${Q} textarea::placeholder {
|
|
1207
|
+
color: ${$.darkSubtle} !important;
|
|
1183
1208
|
}
|
|
1184
1209
|
|
|
1185
|
-
${
|
|
1186
|
-
background-color: ${
|
|
1187
|
-
border-color: ${
|
|
1188
|
-
color: ${
|
|
1210
|
+
${Q} .exhibition-tour-step-card {
|
|
1211
|
+
background-color: ${$.darkPanelSoft} !important;
|
|
1212
|
+
border-color: ${$.darkBorder} !important;
|
|
1213
|
+
color: ${$.darkText} !important;
|
|
1189
1214
|
}
|
|
1190
1215
|
|
|
1191
|
-
${
|
|
1192
|
-
${
|
|
1216
|
+
${Q} .exhibition-tour-step-body,
|
|
1217
|
+
${Q} .exhibition-tour-step-body * {
|
|
1193
1218
|
background-color: transparent !important;
|
|
1194
|
-
color: ${
|
|
1219
|
+
color: ${$.darkText} !important;
|
|
1195
1220
|
}
|
|
1196
1221
|
|
|
1197
|
-
${
|
|
1198
|
-
${
|
|
1222
|
+
${Q} a,
|
|
1223
|
+
${Q} button {
|
|
1199
1224
|
color: inherit;
|
|
1200
1225
|
}
|
|
1201
1226
|
|
|
1202
|
-
${
|
|
1203
|
-
background-color: ${
|
|
1204
|
-
border-color: ${
|
|
1205
|
-
color: ${
|
|
1227
|
+
${Q} .exhibition-aspect-warning {
|
|
1228
|
+
background-color: ${$.darkWarning} !important;
|
|
1229
|
+
border-color: ${$.darkWarningBorder} !important;
|
|
1230
|
+
color: ${$.darkText} !important;
|
|
1206
1231
|
}
|
|
1207
1232
|
|
|
1208
|
-
${
|
|
1209
|
-
${
|
|
1210
|
-
color: ${
|
|
1233
|
+
${Q} .exhibition-aspect-warning [class*="text-me-"],
|
|
1234
|
+
${Q} .exhibition-aspect-warning [class*="text-black"] {
|
|
1235
|
+
color: ${$.darkText} !important;
|
|
1211
1236
|
}
|
|
1212
1237
|
|
|
1213
|
-
${
|
|
1214
|
-
color: ${
|
|
1238
|
+
${Q} fieldset button {
|
|
1239
|
+
color: ${$.darkText} !important;
|
|
1215
1240
|
}
|
|
1216
1241
|
|
|
1217
|
-
${
|
|
1218
|
-
background-color: ${
|
|
1242
|
+
${Q} fieldset button:hover {
|
|
1243
|
+
background-color: ${$.darkHover} !important;
|
|
1219
1244
|
color: #fff !important;
|
|
1220
1245
|
}
|
|
1221
1246
|
|
|
1222
|
-
${
|
|
1223
|
-
background-color: ${
|
|
1247
|
+
${Q} fieldset button[data-active="true"] {
|
|
1248
|
+
background-color: ${$.pink} !important;
|
|
1224
1249
|
color: #fff !important;
|
|
1225
1250
|
}
|
|
1226
1251
|
|
|
1227
|
-
${
|
|
1228
|
-
${
|
|
1229
|
-
${
|
|
1230
|
-
background-color: ${
|
|
1231
|
-
color: ${
|
|
1232
|
-
border-color: ${
|
|
1252
|
+
${Q} [role="menu"],
|
|
1253
|
+
${Q} [class*="DropdownMenu"],
|
|
1254
|
+
${Q} [class*="DropdownContent"] {
|
|
1255
|
+
background-color: ${$.darkPanelHeader} !important;
|
|
1256
|
+
color: ${$.darkText} !important;
|
|
1257
|
+
border-color: ${$.darkBorder} !important;
|
|
1233
1258
|
}
|
|
1234
1259
|
|
|
1235
|
-
${e=>e.$side===`left`?
|
|
1260
|
+
${e=>e.$side===`left`?y.css`
|
|
1236
1261
|
left: 4.5rem;
|
|
1237
1262
|
transform: translateX(${e.$open?`0`:`-0.75rem`});
|
|
1238
|
-
`:
|
|
1263
|
+
`:y.css`
|
|
1239
1264
|
right: 4.5rem;
|
|
1240
1265
|
transform: translateX(${e.$open?`0`:`0.75rem`});
|
|
1241
1266
|
`}
|
|
@@ -1250,13 +1275,13 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
1250
1275
|
min-width: 0;
|
|
1251
1276
|
transform: translateY(${e=>e.$open?`0`:`0.75rem`});
|
|
1252
1277
|
}
|
|
1253
|
-
`,
|
|
1278
|
+
`,Yc=y.default.div`
|
|
1254
1279
|
display: flex;
|
|
1255
1280
|
flex: 1;
|
|
1256
1281
|
min-width: 0;
|
|
1257
1282
|
height: 100%;
|
|
1258
1283
|
overflow: hidden;
|
|
1259
|
-
`,
|
|
1284
|
+
`,Xc=y.default.div`
|
|
1260
1285
|
display: flex;
|
|
1261
1286
|
flex-direction: column;
|
|
1262
1287
|
flex: 1;
|
|
@@ -1265,16 +1290,16 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
1265
1290
|
max-width: 100%;
|
|
1266
1291
|
min-width: 0;
|
|
1267
1292
|
overflow: hidden;
|
|
1268
|
-
`,
|
|
1293
|
+
`,Zc=y.default.header`
|
|
1269
1294
|
//box-shadow: 0 3px 2px 0 rgba(0, 0, 0, 0.04), 0 1px 0 0 rgba(0, 0, 0, 0.17);
|
|
1270
1295
|
z-index: 200;
|
|
1271
|
-
`,
|
|
1296
|
+
`,Qc=y.default.div`
|
|
1272
1297
|
background: #fff;
|
|
1273
|
-
|
|
1298
|
+
`,$c=y.default.div`
|
|
1274
1299
|
display: flex;
|
|
1275
1300
|
flex: 1 1 0;
|
|
1276
1301
|
min-height: 0;
|
|
1277
|
-
`,
|
|
1302
|
+
`,el=y.default.div`
|
|
1278
1303
|
background: #fff;
|
|
1279
1304
|
display: flex;
|
|
1280
1305
|
flex-direction: column;
|
|
@@ -1282,18 +1307,18 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
1282
1307
|
max-width: 720px;
|
|
1283
1308
|
align-items: flex-end;
|
|
1284
1309
|
|
|
1285
|
-
${e=>e.$motion?
|
|
1310
|
+
${e=>e.$motion?y.css`
|
|
1286
1311
|
transition: max-width 400ms;
|
|
1287
1312
|
`:``}
|
|
1288
1313
|
|
|
1289
|
-
${e=>{switch(e.$state){case`entering`:return
|
|
1314
|
+
${e=>{switch(e.$state){case`entering`:return y.css`
|
|
1290
1315
|
max-width: ${e.$width};
|
|
1291
|
-
`;case`exiting`:return
|
|
1316
|
+
`;case`exiting`:return y.css`
|
|
1292
1317
|
max-width: 0;
|
|
1293
|
-
`;case`unmounted`:case`exited`:return
|
|
1318
|
+
`;case`unmounted`:case`exited`:return y.css`
|
|
1294
1319
|
max-width: 0;
|
|
1295
1320
|
`}}}
|
|
1296
|
-
`,
|
|
1321
|
+
`,tl=y.default.div`
|
|
1297
1322
|
flex: 1 1 0;
|
|
1298
1323
|
background: #e3e7f0;
|
|
1299
1324
|
// background: #efefef;
|
|
@@ -1312,7 +1337,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
1312
1337
|
> * {
|
|
1313
1338
|
min-width: 0;
|
|
1314
1339
|
}
|
|
1315
|
-
`,
|
|
1340
|
+
`,nl=y.default.div`
|
|
1316
1341
|
background: #fff;
|
|
1317
1342
|
display: flex;
|
|
1318
1343
|
flex-direction: column;
|
|
@@ -1321,14 +1346,14 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
1321
1346
|
|
|
1322
1347
|
${e=>e.$motion?`transition: max-width 400ms;`:``}
|
|
1323
1348
|
|
|
1324
|
-
${e=>{switch(e.$state){case`entering`:return
|
|
1349
|
+
${e=>{switch(e.$state){case`entering`:return y.css`
|
|
1325
1350
|
max-width: ${e.$width};
|
|
1326
|
-
`;case`exiting`:return
|
|
1351
|
+
`;case`exiting`:return y.css`
|
|
1327
1352
|
max-width: 0;
|
|
1328
|
-
`;case`unmounted`:case`exited`:return
|
|
1353
|
+
`;case`unmounted`:case`exited`:return y.css`
|
|
1329
1354
|
max-width: 0;
|
|
1330
1355
|
`}}}
|
|
1331
|
-
`,
|
|
1356
|
+
`,rl=y.default.div`
|
|
1332
1357
|
display: flex;
|
|
1333
1358
|
flex: 1;
|
|
1334
1359
|
height: 100%;
|
|
@@ -1336,28 +1361,28 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
1336
1361
|
transition: min-width 400ms;
|
|
1337
1362
|
overflow: hidden;
|
|
1338
1363
|
|
|
1339
|
-
${e=>{switch(e.$menu){case`top`:return
|
|
1364
|
+
${e=>{switch(e.$menu){case`top`:return y.css`
|
|
1340
1365
|
flex-direction: column;
|
|
1341
|
-
${
|
|
1366
|
+
${il} {
|
|
1342
1367
|
flex-direction: column;
|
|
1343
1368
|
}
|
|
1344
|
-
`;case`left`:return
|
|
1369
|
+
`;case`left`:return y.css`
|
|
1345
1370
|
flex-direction: row;
|
|
1346
|
-
${
|
|
1371
|
+
${il} {
|
|
1347
1372
|
flex-direction: row;
|
|
1348
1373
|
}
|
|
1349
|
-
`;default:case`bottom`:return
|
|
1374
|
+
`;default:case`bottom`:return y.css`
|
|
1350
1375
|
flex-direction: column-reverse;
|
|
1351
|
-
${
|
|
1376
|
+
${il} {
|
|
1352
1377
|
flex-direction: column;
|
|
1353
1378
|
}
|
|
1354
|
-
`;case`right`:return
|
|
1379
|
+
`;case`right`:return y.css`
|
|
1355
1380
|
flex-direction: row-reverse;
|
|
1356
|
-
${
|
|
1381
|
+
${il} {
|
|
1357
1382
|
flex-direction: row;
|
|
1358
1383
|
}
|
|
1359
1384
|
`}}}
|
|
1360
|
-
`;
|
|
1385
|
+
`;y.default.div`
|
|
1361
1386
|
background: #fff;
|
|
1362
1387
|
border-top: 1px solid #e3e7f0;
|
|
1363
1388
|
border-right: 1px solid #e3e7f0;
|
|
@@ -1367,7 +1392,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
1367
1392
|
/* width: 3.35em;
|
|
1368
1393
|
padding: 0.3em;
|
|
1369
1394
|
gap: 0.3em; */
|
|
1370
|
-
`,
|
|
1395
|
+
`,y.default.button`
|
|
1371
1396
|
cursor: pointer;
|
|
1372
1397
|
aspect-ratio: 1;
|
|
1373
1398
|
width: 3em;
|
|
@@ -1394,32 +1419,32 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
1394
1419
|
font-size: 1.5em;
|
|
1395
1420
|
color: #999;
|
|
1396
1421
|
}
|
|
1397
|
-
`;const
|
|
1422
|
+
`;const il=y.default.div`
|
|
1398
1423
|
display: flex;
|
|
1399
1424
|
box-shadow:
|
|
1400
1425
|
0 -3px 2px 0 rgba(0, 0, 0, 0.04),
|
|
1401
1426
|
0 -1px 0 0 rgba(0, 0, 0, 0.17);
|
|
1402
1427
|
|
|
1403
|
-
${e=>!e.$open&&(e.$position===`top`||e.$position===`bottom`)?
|
|
1428
|
+
${e=>!e.$open&&(e.$position===`top`||e.$position===`bottom`)?y.css`
|
|
1404
1429
|
display: none;
|
|
1405
1430
|
`:``}
|
|
1406
|
-
`,
|
|
1431
|
+
`,al=y.default.div`
|
|
1407
1432
|
display: flex;
|
|
1408
1433
|
flex-direction: column;
|
|
1409
1434
|
flex: 1;
|
|
1410
1435
|
min-width: 0;
|
|
1411
1436
|
overflow: hidden;
|
|
1412
|
-
`;function
|
|
1437
|
+
`;function ol(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 sl(e,t){return t?e.some(e=>e.id===t)?t:e[0]?.id||null:null}function cl(e){return e.map(e=>e.id).join(`,`)}function ll(e){let t=e?.resource;return t?.source?.type||t?.type||null}const ul=(0,u.memo)(function(e){let{resolveMessage:t}=(0,f.useEditorI18n)(),n=(0,f.useTranslations)(`shell`),r=q(),i=sr(),a=J(),o=Or(),{vault:s}=(0,u.useContext)(g.ReactVaultContext),c=s||void 0,p=(0,g.useVaultSelector)(e=>e.iiif),{loading:m,state:h,leftPanels:_,centerPanels:v,rightPanels:y,modals:b=[],actions:x}=o,S=e.isLoading||!1,C=(0,u.useMemo)(()=>({rootResource:a,vault:c,app:r,layoutState:h,appState:i}),[a,c,r,h,i,p]),w=(0,u.useMemo)(()=>ol(_,C,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}).filter(e=>!e.focusedMode?.hide),[_,C]),T=(0,u.useMemo)(()=>ol(v,C,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[v,C]),E=(0,u.useMemo)(()=>ol(y,C,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}).filter(e=>!e.focusedMode?.hide),[y,C]),D=(0,u.useMemo)(()=>ol(b,C,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[b,C]),O=(0,u.useMemo)(()=>w.filter(e=>e.modal),[w]),k=(0,u.useMemo)(()=>w.filter(e=>!e.modal),[w]),A=(0,u.useMemo)(()=>[...D,...O],[D,O]),j=(0,u.useMemo)(()=>({...o,leftPanels:w,centerPanels:T,rightPanels:E,modals:A}),[o,w,T,E,A]),N=k.find(e=>e.id===h.leftPanel.current),P=E.find(e=>e.id===h.rightPanel.current),F=T.find(e=>e.id===h.centerPanel.current),I=A.find(e=>e.id===h.modal.current),L=h.modal.open&&O.some(e=>e.id===h.modal.current)?h.modal.current:h.leftPanel.current,R=h.pinnedRightPanel.pinned?E.find(e=>e.id===h.pinnedRightPanel.current):void 0,te=P&&(R?.id!==P.id||!(0,ee.default)(h.pinnedRightPanel.state,h.rightPanel.state)),z=(0,u.useMemo)(()=>({rootResource:a,vault:c,app:r,layoutState:h,appState:i,actions:x}),[a,c,r,h,i,x]),B=e=>{e.focusedMode?.onSelect?.(z)},ne=!N||N.focusedMode?.closeOnMainPanelClick!==!1,[re]=Tc([`(max-width: 1020px)`]),V=(0,u.useMemo)(()=>(o.background||[]).map((e,t)=>(0,d.jsx)(u.Fragment,{children:e.render()},t)),[o.background]);(0,u.useLayoutEffect)(()=>{E.length&&x.rightPanel.change({id:E[0].id}),k.length&&x.leftPanel.change({id:k[0].id}),T.length&&x.centerPanel.change({id:T[0].id}),x.leftPanel.close(),x.rightPanel.close()},[]),(0,u.useLayoutEffect)(()=>{if(F&&F.onMount)return F.onMount(h.centerPanel.state||F.defaultState||{},{...j,current:x.centerPanel,vault:c},i)},[h.centerPanel.current,F?.id]),(0,u.useLayoutEffect)(()=>{re&&h.leftPanel.open&&h.rightPanel.open&&x.rightPanel.close()},[re,h.leftPanel.open,h.rightPanel.open]),(0,u.useLayoutEffect)(()=>{if(!h.leftPanel.open||!h.leftPanel.current)return;let e=w.find(e=>e.id===h.leftPanel.current);e?.focusedMode?.onSelect&&B(e)},[h.leftPanel.open,h.leftPanel.current,cl(w)]),(0,u.useLayoutEffect)(()=>{if(h.leftPanel.current&&!N){let e=sl(k,h.leftPanel.current);e?x.leftPanel.change({id:e}):x.leftPanel.close()}if(h.centerPanel.current&&!F){let e=sl(T,h.centerPanel.current);e?x.centerPanel.change({id:e}):x.centerPanel.close()}if(h.rightPanel.current&&!P){let e=sl(E,h.rightPanel.current);e?x.rightPanel.change({id:e}):x.rightPanel.close()}if(h.modal.current&&!I){let e=sl(A,h.modal.current);e?x.modal.change({id:e}):x.modal.close()}},[h.leftPanel.current,h.centerPanel.current,h.rightPanel.current,h.modal.current,N?.id,F?.id,P?.id,I?.id,cl(k),cl(T),cl(E),cl(A)]),wc(`layout.edit`,e=>{ll(e)===`Canvas`&&!h.rightPanel.open||(E.find(e=>e.id===`@manifest-editor/editor`)?x.rightPanel.open({id:`@manifest-editor/editor`,stacked:!0}):P&&x.rightPanel.open())},[cl(E),P?.id,h.rightPanel.open]);let H=`4.5rem`,ie=`${Jo({options:N?.options,fallback:340})}px`,ae=`${Jo({options:P?.options,fallback:420})}px`,oe={"--manifest-editor-layout-left-sidebar-small":H,"--manifest-editor-layout-left-sidebar-large":h.leftPanel.open?`calc(${H} + ${ie})`:H,"--manifest-editor-layout-right-sidebar-small":H,"--manifest-editor-layout-right-sidebar-large":h.rightPanel.open?`calc(${H} + ${ae})`:H};return(0,u.useLayoutEffect)(()=>{if(typeof document>`u`)return;let e=document.documentElement,t=Object.keys(oe).map(t=>[t,e.style.getPropertyValue(t)]);for(let[t,n]of Object.entries(oe))e.style.setProperty(t,n);return()=>{for(let[n,r]of t)r?e.style.setProperty(n,r):e.style.removeProperty(n)}},[ie,ae,h.leftPanel.open,h.rightPanel.open]),m?null:(0,d.jsx)(Cr.Provider,{value:`focused`,children:(0,d.jsxs)(Xc,{id:e.htmlId||`manifest-editor-container`,className:`manifest-editor ${e.className||``}`,"data-layout-mode":`focused`,style:oe,children:[e.hideHeader?null:(0,d.jsxs)(Zc,{children:[e.header||null,e.menu?(0,d.jsx)(`menu`,{children:e.menu}):null]}),(0,d.jsxs)(Vc,{children:[(0,d.jsx)(Hc,{onClick:()=>{ne&&x.leftPanel.close()},children:(0,d.jsxs)(rl,{$menu:e.centerPanelMenuPosition||`top`,children:[e.centerPanelMenu?(0,d.jsx)(il,{$open:h.centerPanel.open,$position:e.centerPanelMenuPosition||`top`,children:e.centerPanelMenu}):null,(0,d.jsx)(al,{children:(0,d.jsx)(M.ErrorBoundary,{resetKeys:[F?.id],FallbackComponent:Xo,children:S?(0,d.jsx)(Uc,{children:(0,d.jsx)(Pc,{stroke:`rgba(0,0,0,.3)`,fontSize:`2em`})}):h.centerPanel.open&&F?Yo(F.render(h.centerPanel.state||F.defaultState||{},{...j,current:x.centerPanel,vault:c},i)):null})})]})}),!T.length&&!w.length?null:(0,d.jsxs)(Wc,{$side:`left`,"aria-label":n(`panels.mainAndLeft`),children:[T.length?(0,d.jsx)(Kc,{"aria-label":n(`panels.main`),children:T.filter(e=>!e.focusedMode?.hide).map(e=>(0,d.jsxs)(l.Tooltip,{placement:`right`,children:[(0,d.jsx)(l.TooltipTrigger,{asChild:!0,children:(0,d.jsx)(Gc,{type:`button`,"aria-label":t(e?.labelMessage,e.label),"data-selected":h.centerPanel.current===e.id,onClick:()=>{x.centerPanel.open({id:e.id}),x.leftPanel.close(),x.rightPanel.close(),B(e)},children:e.icon||t(e?.labelMessage,e.label).slice(0,1)})}),(0,d.jsx)(l.DefaultTooltipContent,{children:t(e?.labelMessage,e.label)})]},e.id))}):null,T.length&&w.length?(0,d.jsx)(qc,{}):null,w.length?(0,d.jsx)(Kc,{"aria-label":n(`panels.left`),children:w.map(e=>(0,d.jsxs)(l.Tooltip,{placement:`right`,children:[(0,d.jsx)(l.TooltipTrigger,{asChild:!0,children:(0,d.jsx)(Gc,{type:`button`,"aria-label":t(e?.labelMessage,e.label),"data-selected":L===e.id,onClick:()=>{if(e.modal){re&&x.rightPanel.close(),h.modal.open&&h.modal.current===e.id?x.modal.close():(x.modal.open({id:e.id,state:e.defaultState}),B(e));return}re&&x.rightPanel.close(),h.leftPanel.current===e.id?x.leftPanel.toggle():x.leftPanel.open({id:e.id})},children:e.icon||t(e?.labelMessage,e.label).slice(0,1)})}),(0,d.jsx)(l.DefaultTooltipContent,{children:t(e?.labelMessage,e.label)})]},e.id))}):null]}),((e,n,r)=>{if(!n.length)return null;let i=e===`left`?x.leftPanel:x.rightPanel;return(0,d.jsx)(Wc,{$side:e,"aria-label":`${e} panels`,children:n.map(n=>(0,d.jsxs)(l.Tooltip,{placement:e===`left`?`right`:`left`,children:[(0,d.jsx)(l.TooltipTrigger,{asChild:!0,children:(0,d.jsx)(Gc,{type:`button`,"aria-label":t(n?.labelMessage,n.label),"data-selected":r===n.id,onClick:()=>{re&&(e===`left`?x.rightPanel.close():x.leftPanel.close()),r===n.id?i.toggle():i.open({id:n.id})},children:n.icon||t(n?.labelMessage,n.label).slice(0,1)})}),(0,d.jsx)(l.DefaultTooltipContent,{children:t(n?.labelMessage,n.label)})]},n.id))})})(`right`,E,h.rightPanel.current),k.length>0?(0,d.jsx)(Jc,{$side:`left`,$open:h.leftPanel.open,style:{width:ie,minWidth:N?.options?.minWidth,maxWidth:N?.options?.maxWidth},children:(0,d.jsx)(Yc,{children:S?(0,d.jsx)(al,{children:(0,d.jsx)(Ic,{})}):(0,d.jsxs)(d.Fragment,{children:[e.leftPanelMenu?(0,d.jsx)(il,{$open:h.leftPanel.open,$position:e.leftPanelMenuPosition||`bottom`,children:e.leftPanelMenu}):null,(0,d.jsx)(al,{children:N?(0,d.jsx)(as,{isLeft:!0,panel:N,state:h.leftPanel,actions:x.leftPanel}):null})]})})}):null,E.length>0?(0,d.jsx)(Jc,{$side:`right`,$open:h.rightPanel.open,style:{width:ae,minWidth:P?.options?.minWidth,maxWidth:P?.options?.maxWidth},children:(0,d.jsx)(Yc,{children:S?(0,d.jsx)(al,{children:(0,d.jsx)(Ic,{})}):(0,d.jsxs)(d.Fragment,{children:[e.rightPanelMenu?(0,d.jsx)(il,{$open:h.rightPanel.open,$position:e.rightPanelMenuPosition||`bottom`,children:e.rightPanelMenu}):null,(0,d.jsxs)(al,{children:[te?(0,d.jsx)(as,{panel:P,state:h.rightPanel,actions:x.rightPanel,pinActions:x.pinnedRightPanel,available:E}):null,R?(0,d.jsx)(as,{panel:R,state:h.pinnedRightPanel,actions:x.pinnedRightPanel,close:x.rightPanel.close}):null]})]})})}):null]}),(0,d.jsx)(Qc,{children:e.footer||null}),(0,d.jsx)(`div`,{className:`hidden`,children:V}),(0,d.jsx)(Ga,{}),(0,d.jsx)(qa,{}),(0,d.jsx)(d.Fragment,{children:I?(0,d.jsx)(l.Modal,{title:t(I?.labelMessage,I.label),open:h.modal.open,onClose:()=>x.modal.close(),children:I.modal?(0,d.jsx)(`div`,{className:`h-[70vh] min-h-[60vh] max-h-full flex w-full`,children:(0,d.jsx)(as,{isLeft:!0,isModal:!0,noHeader:!0,panel:I,state:h.modal,actions:x.modal})}):Yo(I.render(h.modal.state||I.defaultState||{},{...j,current:x.modal,vault:c,isModal:!0},i))}):null}),(0,d.jsx)(vo,{})]})})}),dl=y.default.div`
|
|
1413
1438
|
position: relative;
|
|
1414
1439
|
display: flex;
|
|
1415
1440
|
flex: 1;
|
|
1416
1441
|
overflow: hidden;
|
|
1417
1442
|
flex-direction: column;
|
|
1418
|
-
`,
|
|
1443
|
+
`,fl=y.default.div`
|
|
1419
1444
|
flex: 1;
|
|
1420
1445
|
position: relative;
|
|
1421
1446
|
z-index: 7;
|
|
1422
|
-
`,
|
|
1447
|
+
`,pl=y.default.div`
|
|
1423
1448
|
display: flex;
|
|
1424
1449
|
gap: 0.5rem;
|
|
1425
1450
|
width: 100%;
|
|
@@ -1428,7 +1453,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
1428
1453
|
padding: 0.5rem;
|
|
1429
1454
|
min-height: 4rem;
|
|
1430
1455
|
z-index: 9;
|
|
1431
|
-
`,
|
|
1456
|
+
`,ml=y.default.button`
|
|
1432
1457
|
flex: 1;
|
|
1433
1458
|
min-width: 0;
|
|
1434
1459
|
padding: 0.75rem 1rem;
|
|
@@ -1439,11 +1464,11 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
1439
1464
|
overflow: hidden;
|
|
1440
1465
|
text-overflow: ellipsis;
|
|
1441
1466
|
white-space: nowrap;
|
|
1442
|
-
`,
|
|
1467
|
+
`,hl=y.default.div`
|
|
1443
1468
|
display: flex;
|
|
1444
1469
|
flex: 1;
|
|
1445
1470
|
min-width: 0;
|
|
1446
|
-
`,
|
|
1471
|
+
`,gl=y.default.button`
|
|
1447
1472
|
display: flex;
|
|
1448
1473
|
align-items: center;
|
|
1449
1474
|
justify-content: center;
|
|
@@ -1463,7 +1488,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
1463
1488
|
flex: 0 0 auto;
|
|
1464
1489
|
font-size: 1.25em;
|
|
1465
1490
|
}
|
|
1466
|
-
`,
|
|
1491
|
+
`,_l=y.default.div`
|
|
1467
1492
|
background: #fff;
|
|
1468
1493
|
display: flex;
|
|
1469
1494
|
position: absolute;
|
|
@@ -1481,20 +1506,20 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
1481
1506
|
transition:
|
|
1482
1507
|
0.3s transform ease-in-out,
|
|
1483
1508
|
0.3s box-shadow;
|
|
1484
|
-
${e=>e.$open&&
|
|
1509
|
+
${e=>e.$open&&y.css`
|
|
1485
1510
|
box-shadow:
|
|
1486
1511
|
-5px 0 15px 0 rgba(0, 0, 0, 0.1),
|
|
1487
1512
|
-3px 0 5px 0 rgba(0, 0, 0, 0.1);
|
|
1488
1513
|
transform: translateX(0);
|
|
1489
1514
|
`}
|
|
1490
1515
|
|
|
1491
|
-
${
|
|
1516
|
+
${es} {
|
|
1492
1517
|
box-shadow: none;
|
|
1493
1518
|
padding-left: 0.5em;
|
|
1494
1519
|
padding-right: 0.5em;
|
|
1495
1520
|
font-size: 1.1em;
|
|
1496
1521
|
}
|
|
1497
|
-
`,
|
|
1522
|
+
`,vl=y.default.div`
|
|
1498
1523
|
display: flex;
|
|
1499
1524
|
flex-direction: column;
|
|
1500
1525
|
position: absolute;
|
|
@@ -1507,10 +1532,10 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
1507
1532
|
z-index: 10;
|
|
1508
1533
|
overflow: hidden;
|
|
1509
1534
|
transition: 0.5s transform;
|
|
1510
|
-
${e=>e.$open&&
|
|
1535
|
+
${e=>e.$open&&y.css`
|
|
1511
1536
|
transform: translateX(0);
|
|
1512
1537
|
`}
|
|
1513
|
-
`,
|
|
1538
|
+
`,yl=y.default.button`
|
|
1514
1539
|
border: 0;
|
|
1515
1540
|
background: rgba(0, 0, 0, 0.4);
|
|
1516
1541
|
pointer-events: none;
|
|
@@ -1523,10 +1548,10 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
1523
1548
|
opacity: 0;
|
|
1524
1549
|
transition: opacity 0.5s;
|
|
1525
1550
|
|
|
1526
|
-
${e=>e.$open&&
|
|
1551
|
+
${e=>e.$open&&y.css`
|
|
1527
1552
|
pointer-events: visible;
|
|
1528
1553
|
opacity: 1;
|
|
1529
1554
|
`}
|
|
1530
|
-
`,Ac=(0,u.memo)(function(e){if(e.layoutMode===`focused`)return(0,d.jsx)(bc,{...e});let t=U(),n=Un(),r=W(),i=pi(),{vault:a}=(0,u.useContext)(m.ReactVaultContext),o=a||void 0,s=(0,m.useVaultSelector)(e=>e.iiif),c=(0,u.useRef)(null),f=(0,u.useRef)(null),{loading:p,state:h,leftPanels:g,centerPanels:_,rightPanels:v,modals:y=[],actions:b}=i,x=(0,u.useMemo)(()=>({rootResource:r,vault:o,app:t,layoutState:h,appState:n}),[r,o,t,h,n,s]),S=(0,u.useMemo)(()=>_c(g,x,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[g,x]),w=(0,u.useMemo)(()=>_c(_,x,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[_,x]),T=(0,u.useMemo)(()=>_c(v,x,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[v,x]),E=(0,u.useMemo)(()=>_c(y,x,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[y,x]),D=(0,u.useMemo)(()=>S.filter(e=>e.modal),[S]),k=(0,u.useMemo)(()=>S.filter(e=>!e.modal),[S]),A=(0,u.useMemo)(()=>[...E,...D],[E,D]),j=(0,u.useMemo)(()=>({...i,leftPanels:S,centerPanels:w,rightPanels:T,modals:A}),[i,S,w,T,A]),M=k.find(e=>e.id===h.leftPanel.current),N=T.find(e=>e.id===h.rightPanel.current),P=w.find(e=>e.id===h.centerPanel.current),F=A.find(e=>e.id===h.modal.current),te=h.modal.open&&D.some(e=>e.id===h.modal.current)?h.modal.current:h.leftPanel.current,ne=h.pinnedRightPanel.pinned?T.find(e=>e.id===h.pinnedRightPanel.current):void 0,[I]=Rs([`(max-width: 1020px)`]),re=e.isLoading||!1,L=(0,u.useMemo)(()=>(i.background||[]).map((e,t)=>(0,d.jsx)(u.Fragment,{children:e.render()},t)),[i.background]),R=$s(`left-panel/${M?.id}`,{left:!0,marginLeft:60,minWidthPx:M?.options?.minWidth||200,maxWidthPx:M?.options?.maxWidth||720,loading:p}),z=$s(`right-panel/${N?.id}`,{left:!1,minWidthPx:N?.options?.minWidth||320,maxWidthPx:N?.options?.maxWidth||720,loading:p}),ie=N&&(ne?.id!==N.id||!(0,ee.default)(h.pinnedRightPanel.state,h.rightPanel.state)),ae=R.widthB===`auto`?void 0:()=>R.setWidths({widthA:`auto`,widthB:no({options:M?.options,fallback:320})}),oe=z.widthB===`auto`?void 0:()=>z.setWidths({widthA:`auto`,widthB:no({options:N?.options,fallback:320})});if((0,u.useLayoutEffect)(()=>{I&&h.leftPanel.open&&h.rightPanel.open&&(b.leftPanel.close(),b.rightPanel.close())},[I]),(0,u.useLayoutEffect)(()=>{if(P&&P.onMount)return P.onMount(h.centerPanel.state||P.defaultState||{},{...j,current:b.centerPanel,vault:o},n)},[h.centerPanel.current,P?.id]),(0,u.useLayoutEffect)(()=>{if(h.leftPanel.current&&!M){let e=vc(k,h.leftPanel.current);e?b.leftPanel.change({id:e}):b.leftPanel.close()}if(h.centerPanel.current&&!P){let e=vc(w,h.centerPanel.current);e?b.centerPanel.change({id:e}):b.centerPanel.close()}if(h.rightPanel.current&&!N){let e=vc(T,h.rightPanel.current);e?b.rightPanel.change({id:e}):b.rightPanel.close()}if(h.modal.current&&!F){let e=vc(A,h.modal.current);e?b.modal.change({id:e}):b.modal.close()}},[h.leftPanel.current,h.centerPanel.current,h.rightPanel.current,h.modal.current,M?.id,P?.id,N?.id,F?.id,Q(k),Q(w),Q(T),Q(A)]),(0,u.useLayoutEffect)(()=>{T.length&&b.rightPanel.change({id:T[0].id}),k.length&&b.leftPanel.change({id:k[0].id}),w.length&&b.centerPanel.change({id:w[0].id})},[]),p)return null;let se=t=>(0,d.jsx)(gc,{$menu:e.leftPanelMenuPosition||`bottom`,ref:R.refs.resizableDiv,className:[`manifest-editor`,t?`transition transition-${t}`:``].join(` `),style:{width:h.leftPanel.open||t!==`exited`?R.widthB:void 0,minWidth:M?.options?.minWidth},children:re?(0,d.jsx)(Z,{children:(0,d.jsx)(Ys,{})}):(0,d.jsxs)(d.Fragment,{children:[e.leftPanelMenu?(0,d.jsx)(X,{$open:h.leftPanel.open&&t!==`exited`,$position:e.leftPanelMenuPosition||`bottom`,children:e.leftPanelMenu}):null,(0,d.jsx)(Z,{children:h.leftPanel.open||t!==`exited`?(0,d.jsx)(d.Fragment,{children:M?(0,d.jsx)(mo,{isLeft:!0,noHeader:!0,transition:t,panel:M,state:h.leftPanel,actions:b.leftPanel}):null}):null})]})}),ce=()=>F?(0,d.jsx)(l.Modal,{title:F.label,open:h.modal.open,onClose:()=>b.modal.close(),children:F.modal?(0,d.jsx)(`div`,{className:`h-[70vh] min-h-[60vh] max-h-full flex w-full`,children:(0,d.jsx)(mo,{isLeft:!0,isModal:!0,noHeader:!0,panel:F,state:h.modal,actions:b.modal})}):ro(F.render(h.modal.state||F.defaultState||{},{...j,current:b.modal,vault:o,isModal:!0},n))}):null,le=()=>(0,d.jsxs)(gc,{$menu:e.centerPanelMenuPosition||`top`,children:[e.centerPanelMenu?(0,d.jsx)(X,{$open:h.centerPanel.open,$position:e.centerPanelMenuPosition||`top`,children:e.centerPanelMenu}):null,(0,d.jsx)(Z,{children:(0,d.jsx)(C.ErrorBoundary,{resetKeys:[P?.id],FallbackComponent:io,children:re?(0,d.jsx)(`div`,{style:{display:`flex`,flex:1,justifyContent:`center`,alignItems:`center`},children:(0,d.jsx)(qs,{stroke:`rgba(0,0,0,.3)`,fontSize:`2em`})}):h.centerPanel.open&&P?ro(P.render(h.centerPanel.state||P.defaultState||{},{...j,current:b.centerPanel,vault:o},n)):null})})]}),ue=t=>(0,d.jsx)(gc,{$menu:e.rightPanelMenuPosition||`bottom`,ref:z.refs.resizableDiv,className:t?`transition transition-${t}`:``,style:{width:h.rightPanel.open||t!==`exited`?z.widthB:void 0,minWidth:N?.options?.minWidth},children:re?(0,d.jsx)(Z,{children:(0,d.jsx)(Ys,{})}):(0,d.jsxs)(d.Fragment,{children:[e.rightPanelMenu?(0,d.jsx)(X,{$open:h.rightPanel.open,$position:e.rightPanelMenuPosition||`bottom`,children:e.rightPanelMenu}):null,(0,d.jsx)(Z,{children:h.rightPanel.open||t!==`exited`?(0,d.jsxs)(d.Fragment,{children:[ie?(0,d.jsx)(mo,{panel:N,state:h.rightPanel,actions:b.rightPanel,pinActions:b.pinnedRightPanel,available:T}):null,ne?(0,d.jsx)(mo,{panel:ne,state:h.pinnedRightPanel,actions:b.pinnedRightPanel,close:b.rightPanel.close}):null]}):null})]})});return I?(0,d.jsxs)(lc,{children:[e.hideHeader?null:(0,d.jsxs)(uc,{children:[e.header||null,e.menu?(0,d.jsx)(`menu`,{children:e.menu}):null]}),(0,d.jsx)(fc,{children:(0,d.jsxs)(xc,{children:[(0,d.jsxs)(Cc,{children:[k.length>0?(0,d.jsx)(wc,{type:`button`,"aria-expanded":h.leftPanel.open,onClick:()=>{b.rightPanel.close(),b.leftPanel.toggle()},children:M?.label}):null,T.length>0?(0,d.jsx)(Tc,{children:(0,d.jsxs)(Ec,{type:`button`,"aria-expanded":h.rightPanel.open,onClick:()=>{b.leftPanel.close(),b.rightPanel.toggle()},children:[(0,d.jsx)(nr,{"aria-hidden":`true`,rotate:90}),N?.label]})}):null]}),(0,d.jsx)(Sc,{children:le()}),T.length>0?(0,d.jsx)(Dc,{$open:h.rightPanel.open,children:ue()}):null,k.length>0?(0,d.jsxs)(Oc,{$open:h.leftPanel.open,children:[(0,d.jsx)(`nav`,{"aria-label":`Left panel tabs`,className:`flex flex-none overflow-x-auto border-b border-gray-300`,children:k.map(e=>(0,d.jsxs)(`button`,{type:`button`,"aria-pressed":h.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 ${h.leftPanel.current===e.id?`border-b-[#b83265] bg-[#f9e8ef]`:`border-b-transparent bg-white`}`,onClick:()=>{b.rightPanel.close(),b.leftPanel.open({id:e.id,state:e.defaultState})},children:[e.icon,e.label]},e.id))}),se()]}):null,S.length>0||T.length>0?(0,d.jsx)(kc,{type:`button`,"aria-label":`Close panels`,$open:h.leftPanel.open||h.rightPanel.open,onClick:()=>{b.leftPanel.close(),b.rightPanel.close()}}):null]})}),(0,d.jsx)(`div`,{className:`hidden`,children:L}),(0,d.jsx)(ea,{}),(0,d.jsx)(ta,{}),(0,d.jsx)(d.Fragment,{children:ce()}),(0,d.jsx)(Da,{})]}):(0,d.jsxs)(lc,{id:e.htmlId||`manifest-editor-container`,className:`manifest-editor ${e.className||``}`,children:[e.hideHeader?null:(0,d.jsxs)(uc,{children:[e.header||null,e.menu?(0,d.jsx)(`menu`,{children:e.menu}):null]}),(0,d.jsxs)(fc,{ref:e=>{R.refs.container.current=e,z.refs.container.current=e},children:[S.length>0?(0,d.jsx)(l.PanelSideMenu,{current:te,items:S.map(e=>({id:e.id,label:e.label,icon:e.icon,divide:e.divide,separator:e.separator,onClick:()=>{if(e.modal){h.modal.open&&h.modal.current===e.id?b.modal.close():b.modal.open({id:e.id,state:e.defaultState});return}h.leftPanel.current===e.id?b.leftPanel.toggle():b.leftPanel.change({id:e.id})}})),open:h.leftPanel.open}):null,k.length>0?(0,d.jsx)(O.Transition,{nodeRef:c,in:h.leftPanel.open,timeout:400,unmountOnExit:!1,children:e=>(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(pc,{ref:c,$width:R.widthB,$state:e,$motion:!0,children:se(e)}),(0,d.jsx)(Ks,{ref:R.refs.resizer,reset:ae,dir:`left`,transition:e,open:h.leftPanel.open||e!==`exited`,actions:b.leftPanel})]})}):null,(0,d.jsx)(mc,{children:le()}),T.length>0?(0,d.jsx)(O.Transition,{nodeRef:f,in:h.rightPanel.open,timeout:400,unmountOnExit:!1,children:e=>(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(Ks,{ref:z.refs.resizer,dir:`right`,reset:oe,open:h.rightPanel.open,actions:b.rightPanel}),(0,d.jsx)(hc,{ref:f,$width:z.widthB,$state:e,$motion:!0,children:ue(e)})]})}):null]}),(0,d.jsx)(dc,{children:e.footer||null}),(0,d.jsx)(`div`,{className:`hidden`,children:L}),(0,d.jsx)(ea,{}),(0,d.jsx)(ta,{}),(0,d.jsx)(d.Fragment,{children:ce()}),(0,d.jsx)(Da,{})]})});function jc(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 d(){t({type:`resetSize`,panel:e,payload:void 0})}function f(n){t({type:`pin`,panel:e,payload:n})}function p(){t({type:`unpin`,panel:e,payload:void 0})}return(0,u.useMemo)(()=>({popStack:n,change:r,open:i,close:a,toggle:o,minimise:s,maximise:c,setCustomWidth:l,resetSize:d,pin:f,unpin:p}),[])}function Mc(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?{...(0,_.original)(e.state)}:{}})}}else e.stack=[]}function Nc(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&&Mc(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&&Mc(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(to(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 Pc=(0,_.produce)((e,t)=>{switch(t.panel){case`centerPanel`:Nc(e.centerPanel,t);break;case`leftPanel`:Nc(e.leftPanel,t);break;case`rightPanel`:Nc(e.rightPanel,t);break;case`modal`:Nc(e.modal,t);break;case`pinnedRightPanel`:Nc(e.pinnedRightPanel,t)}});function Fc(){return{customWidth:void 0,minimised:!1,open:!0,current:null,state:null,stack:[]}}function Ic(){return{leftPanel:Fc(),centerPanel:Fc(),rightPanel:Fc(),modal:Fc(),pinnedRightPanel:{...Fc(),pinnable:!0,pinned:!1}}}function Lc({className:e,variant:t=`light`}){let n=(0,m.useManifest)(),r=(0,m.useVault)(),{edit:i}=ui(),a=Yr(),o=Xr(),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`,f=Rc(a)||o.map(Rc).find(Boolean)||s[0]?.id||``,p=Math.max(0,s.findIndex(e=>e.id===f)),h=s[p]?.id||``,g=p+1,_=(0,u.useMemo)(()=>s.map((e,t)=>{let n=r.get({id:e.id,type:`Canvas`});return{id:e.id,pageNumber:t+1,labelText:(0,b.getValue)(n?.label)||`Page ${t+1}`}}),[s,r]),v=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(0,d.jsx)(`div`,{});let y=s[p-1],x=s[p+1],S=t===`dark`;return(0,d.jsxs)(`nav`,{"aria-label":`Manifest pagination`,className:Hc(`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`,S?`border-white/20 bg-white/10 text-white`:`border-me-gray-300 bg-white text-me-gray-900`,e),children:[(0,d.jsx)(zc,{ariaLabel:`Previous canvas`,disabled:!y,onClick:()=>y&&v(y.id),dark:S,children:(0,d.jsx)(Bc,{reverse:c,vertical:l})}),(0,d.jsxs)(`label`,{htmlFor:`manifest-pagination-page-select`,"aria-label":`Page ${g} of ${s.length}`,className:Hc(`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`,S?`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:[(0,d.jsxs)(`span`,{children:[g,` / `,s.length]}),(0,d.jsx)(Vc,{className:Hc(`shrink-0 text-base`,S?`text-white/60`:`text-me-gray-500`)}),(0,d.jsx)(`select`,{id:`manifest-pagination-page-select`,"aria-label":`Jump to canvas`,value:h,onChange:e=>v(e.target.value),className:`absolute inset-0 cursor-pointer appearance-none border-0 bg-white opacity-0`,children:_.map(e=>(0,d.jsxs)(`option`,{value:e.id,children:[`Page `,e.pageNumber,` - `,e.labelText]},e.id))})]}),(0,d.jsx)(zc,{ariaLabel:`Next canvas`,disabled:!x,onClick:()=>x&&v(x.id),dark:S,children:(0,d.jsx)(Bc,{reverse:!c,vertical:l})})]})}function Rc(e){let t=e?.resource?.source;return t?.type===`Canvas`?t.id:null}function zc({ariaLabel:e,children:t,dark:n,disabled:r,onClick:i}){return(0,d.jsx)(`button`,{type:`button`,"aria-label":e,disabled:r,onClick:i,className:Hc(`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 Bc({reverse:e,vertical:t}){return(0,d.jsx)(e?l.ArrowRightIcon:l.BackIcon,{"aria-hidden":!0,className:Hc(`block`,t&&`rotate-90`)})}function Vc(e){return(0,d.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,"aria-hidden":!0,...e,children:(0,d.jsx)(`path`,{fill:`currentColor`,d:`m7 10l5 5l5-5z`})})}function Hc(...e){return e.filter(Boolean).join(` `)}const Uc=new WeakMap;function Wc(e,t){let n={port:t,lastActionId:`@genesis`},r=Gc(e);function i(e){t.postMessage(typeof e==`string`?e:JSON.stringify(e))}function a(){i({_id:Lt(),_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=qc(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,Uc.delete(e)),t.close()}}function Gc(e){let t=Uc.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)Kc(t,e);return t}),a={originalDispatch:n,patchedDispatch:i,targets:r};return e.dispatch=i,Uc.set(e,a),a}function Kc(e,t){let n={_id:Lt(),_type:`vault-action`,_lastActionId:e.lastActionId,action:t};e.lastActionId=n._id,e.port.postMessage(JSON.stringify(n))}function qc(e){try{if(typeof e==`string`)return JSON.parse(e);if(typeof e==`object`&&e)return e}catch{return null}return null}const Jc=(0,u.createContext)(null);function Yc({children:e}){let t=(0,m.useVault)(),n=(0,u.useRef)(null),r=(0,u.useRef)(null),i=(0,u.useRef)(null),a=(0,u.useRef)(!1),[o,s]=(0,u.useState)(!0),c=(0,u.useCallback)(()=>{if(!n.current||n.current.closed||!r.current)return;i.current?.();let e=new MessageChannel;i.current=Wc(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]);(0,u.useEffect)(()=>{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=(0,u.useCallback)(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)},[]),f=(0,u.useCallback)(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)}},[]),p=(0,u.useCallback)(()=>{n.current&&!n.current.closed&&n.current.focus()},[]);return(0,d.jsx)(Jc.Provider,{value:{open:l,update:f,focus:p,isClosed:o},children:e})}function Xc(){let e=(0,u.useContext)(Jc);return N(e,`usePreviewWindow() can only be called from inside <PreviewWindowProvider />`),e}var Zc=class extends u.Component{constructor(...e){super(...e),G(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?(0,d.jsx)(`h1`,{children:`Sorry.. there was an error`}):this.props.children}};function Qc(e,t){return typeof e==`string`?{id:e,state:t}:e}const $c=(0,u.memo)(function(e){let t=U(),n=Is(),r=t.layout,[i,a]=(0,u.useReducer)(Pc,void 0,Ic),o={centerPanel:jc(`centerPanel`,a),leftPanel:jc(`leftPanel`,a),rightPanel:jc(`rightPanel`,a),pinnedRightPanel:jc(`pinnedRightPanel`,a),modal:jc(`modal`,a),editingStack:Jr()};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];N(!1,`Was not able to find panel with id "${e}"`)}function c(e,t){let{id:r,state:i,stacked:a}=Qc(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}=Qc(e,t),[a,o]=s(r),c={id:r,state:{...a.defaultState||{},...i||{}},stacked:!0};n.emit(`layout.open`,c),o.open(c)}function f(e,t){let{id:r,state:i,stacked:a}=Qc(e,t),[o,c]=s(r),l={id:r,state:{...o.defaultState||{},...i||{}},stacked:a};n.emit(`layout.change`,l),c.change(l)}function p(e,t){let{id:r}=Qc(e,t),[,i]=s(r);n.emit(`layout.close`,{id:r}),i.close()}function m(e,t){let{id:r}=Qc(e,t),[,i]=s(r);n.emit(`layout.toggle`,{id:r}),i.toggle()}function g(e,t={},{reset:i,property:a,stacked:s,forceOpen:c,selectedTab:l}={}){let u={resource:(0,h.isSpecificResource)(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 _(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 v={open:c,change:f,close:p,toggle:m,stack:l,edit:g,create:_};return(0,d.jsx)(oi.Provider,{value:(0,u.useMemo)(()=>({...o,...v}),[r]),children:(0,d.jsx)(si.Provider,{value:i,children:e.children})})}),el=[{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`}],tl=new k.ImageServiceLoader({approximateServices:!0,verificationsRequired:8,enableFetching:!0});function nl({config:e,saveConfig:t,children:n,theme:r,previews:i,resource:a,editing:o,backgroundActionPersistence:s}){let c=Hn(),l=z(),f=(0,u.useMemo)(()=>{let t=e?.previews||(l.previews?.length?l.previews:el);return re(l,{previews:t},e)},[l,e]),p=(0,u.useMemo)(()=>({appId:c.appId,instanceId:c.instanceId,rootResource:{id:a.id,type:a.type}}),[c.appId,c.instanceId,a.id,a.type]);return(0,d.jsx)(Zc,{children:(0,d.jsx)(m.ImageServiceLoaderContext.Provider,{value:tl,children:(0,d.jsx)(lr,{resource:a,children:(0,d.jsx)(xo,{children:(0,d.jsx)(g.ThemeProvider,{theme:r||Lo,children:(0,d.jsxs)(ae,{config:f,saveConfig:t,children:[(0,d.jsx)(Rn,{config:f}),(0,d.jsx)(ii,{children:(0,d.jsx)($c,{children:(0,d.jsx)(kt,{persistence:s,persistenceKey:p,children:(0,d.jsx)(os,{children:(0,d.jsx)(Gi,{children:(0,d.jsx)(xr,{previews:i||[],configs:f.previews,children:(0,d.jsx)(Yc,{children:(0,d.jsx)(m.AtlasStoreProvider,{children:n})})})})})})})})]})})})})})})}const rl=new Set([`Collection`,`Manifest`,`Canvas`,`Range`,`AnnotationPage`,`Annotation`,`ContentResource`,`Agent`]),il={satisfied:0,missing:0,invalid:0,disallowed:0,"not-applicable":0},al=new Set([`label`,`summary`,`language`,`navDate`,`provider`,`requiredStatement`,`rights`,`thumbnail`]);function ol(e){return e?Array.isArray(e)?e.filter(Boolean):e.split(`.`).filter(Boolean):[]}function sl(e,t){let n=ol(e),r=ol(t);return n.length===r.length&&n.every((e,t)=>e===r[t])}function cl(e,t){let n=e;for(let e of ol(t)){if(n==null)return;n=n[e]}return n}function ll(e,t,n){let r=ol(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 $(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=>$(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])=>$(e)):!1}function ul(e){return Array.isArray(e)?e.map(ul):e&&typeof e==`object`?Object.keys(e).sort().reduce((t,n)=>(t[n]=ul(e[n]),t),{}):e}function dl(e,t){return JSON.stringify(ul(e))===JSON.stringify(ul(t))}function fl(e,t,n,r){let i=ol(n);for(let n of e||[])for(let e of n.terminology?.properties||[])if(!(e.entityType&&e.entityType!==t)&&sl(e.path,i))return e.label;return r||Bl(i)}function pl(e,t,n){let r=ol(n),i=[],a,o,s=!1,c=!1;if(!t||!rl.has(t.type))return{entityType:t?.type,path:r,label:fl(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&&sl(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:fl(e,t.type,r),disallowed:s,required:c,fixedValue:a,fixedValueRule:o,rules:i}}function ml(e,t,n){let r=e||[],i=hl(t,n),a=[];for(let e of r)for(let[n,r]of(e.rules||[]).entries())a.push(...gl(e,r,n,i,t));return{specifications:r,results:a,counts:Tl(a)}}function hl(e,t){let n=[],r=new Set;function i(t){let a=Dl(t);if(!a)return;if(a.type===`SpecificResource`){i(t?.source);return}let o=El(e,t)||El(e,a);if(!o||!o.type)return;let s=`${o.type}:${o.id||JSON.stringify(a)}`;if(!r.has(s)){r.add(s),rl.has(o.type)&&n.push({ref:{id:o.id,type:o.type},resource:o});for(let e of Ol(o))i(e)}}return i(t),n}function gl(e,t,n,r,i){switch(t.type){case`disallow-property`:case`require-non-empty`:case`fixed-value`:return _l(e,t,n,r);case`iiif:canvas-with-image-service`:return[vl(e,t,n,r,i)];case`iiif:thumbnail-from-body-service`:return yl(e,t,n,r,i);case`iiif:valid-rights`:return bl(e,t,n,r);case`iiif:required-statement`:return xl(e,t,n,r);case`iiif:metadata-template`:return Sl(e,t,n,r);default:return[]}}function _l(e,t,n,r){let i=r.filter(e=>e.ref.type===t.entityType),a=fl(e?[e]:[],t.entityType,t.path);return i.length?i.map(({ref:r,resource:i})=>{let o=cl(i,t.path),s=$(o);if(t.type===`disallow-property`)return Cl(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:wl(r,t.path)});if(t.type===`require-non-empty`)return Cl(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:wl(r,t.path)});let c=dl(o,t.value);return Cl(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:wl(r,t.path)})}):[Cl(e,t,n,{status:`not-applicable`,displayLabel:a,message:`No ${t.entityType} resources were found for ${a}.`,path:t.path})]}function vl(e,t,n,r,i){let a=r.filter(e=>e.ref.type===`Canvas`),o=kl(t),s=a.find(({resource:e})=>Al(jl(e,i),o));return Cl(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?wl(s.ref,[`items`]):void 0})}function yl(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=>jl(e.resource,i)):jl(s,i),l=Ml(s,c,i),u=$(s.thumbnail);return Cl(e,t,n,{target:o,path:[`thumbnail`],status:l?`satisfied`:c.length?u?`invalid`:t.requireThumbnail===!1?`not-applicable`:`missing`:`not-applicable`,displayLabel:fl([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:wl(o,[`thumbnail`])})}):[Cl(e,t,n,{status:`not-applicable`,displayLabel:`Thumbnail`,message:`No ${a} resources were found for thumbnail checks.`})]}function bl(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=$(a),c=typeof a==`string`&&o.map(Il).includes(Il(a));return Cl(e,t,n,{target:r,path:[`rights`],status:c?`satisfied`:!s&&t.required!==!1?`missing`:`invalid`,displayLabel:fl([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:wl(r,[`rights`])})})}function xl(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?Ll(a?.label,t.label):$(a?.label),s=t.value||t.valueRequired!==!1,c=t.value?Ll(a?.value,t.value):!s||$(a?.value),l=$(a);return Cl(e,t,n,{target:r,path:[`requiredStatement`],status:o&&c?`satisfied`:l?`invalid`:`missing`,displayLabel:fl([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:wl(r,[`requiredStatement`])})})}function Sl(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=>Ll(e?.label,i.label)),l=i.value?Ll(c?.value,i.value):!i.valueRequired||$(c?.value),u=c&&l?`satisfied`:c&&i.value?`invalid`:`missing`,d=zl(i.label);o.push(Cl(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:wl(r,[`metadata`])}))})}return o}function Cl(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 wl(e,t){let n=t[0];return{resource:e,propertyPath:t,selectedTab:n===`metadata`?`@manifest-editor/metadata`:n&&al.has(n)?`@manifest-editor/descriptive-properties`:void 0}}function Tl(e){let t={...il};for(let n of e)t[n.status]+=1;return t}function El(e,t){let n=Dl(t);if(!n)return t;try{return e.get(n,{skipSelfReturn:!1})||t}catch{try{return e.get(n)||t}catch{return t}}}function Dl(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 Ol(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 kl(e){return[...e.serviceIds||[],...e.serviceId?[e.serviceId]:[]].filter(Boolean)}function Al(e,t){let n=new Set(e.filter(Boolean));return t.length?t.some(e=>n.has(e)):n.size>0}function jl(e,t){let n=Fl(t,e?.items),r=[];for(let e of n){let n=Fl(t,e?.items);for(let e of n)if((Array.isArray(e?.motivation)?e.motivation:[e?.motivation]).includes(`painting`))for(let n of Nl(e?.body,t))r.push(...Pl(n))}return Array.from(new Set(r))}function Ml(e,t,n){let r=Fl(n,e?.thumbnail);if(!r.length||!t.length)return!1;for(let e of r){let n=Pl(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 Nl(e,t){let n=El(t,e);return n?Array.isArray(n)?n.flatMap(e=>Nl(e,t)):n.type===`SpecificResource`?Nl(n.source,t):n.type===`Choice`?n.items?.flatMap(e=>Nl(e,t))||[]:[n]:[]}function Pl(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 Fl(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=>El(e,t)).filter(Boolean)}function Il(e){return e.replace(/^https:/,`http:`).replace(/\/?$/,`/`)}function Ll(e,t){return typeof t==`string`?Rl(e).some(e=>e===t):dl(e,t)}function Rl(e){return e?typeof e==`string`?[e.trim()].filter(Boolean):Array.isArray(e)?e.flatMap(Rl):typeof e==`object`?Object.values(e).flatMap(Rl):[]:[]}function zl(e){return typeof e==`string`?e:Rl(e)[0]||``}function Bl(e){return(e[e.length-1]||`Property`).replace(/([A-Z])/g,` $1`).replace(/[-_]/g,` `).replace(/^./,e=>e.toUpperCase())}const Vl=(0,u.createContext)([]);function Hl({children:e,specifications:t}){let n=(0,u.useMemo)(()=>t||[],[t]);return(0,d.jsx)(Vl.Provider,{value:n,children:e})}function Ul(){return(0,u.useContext)(Vl)}function Wl(e){let t=W(),n=Ul(),r=e||t;return(0,m.useVaultSelector)((e,t)=>ml(n,t,r),[n,r.id,r.type])}function Gl(){let e=Ul();return(0,u.useMemo)(()=>({getLabel(t,n,r){return fl(e,t,n,r)}}),[e])}function Kl(e,t){let n=Ul();return(0,u.useMemo)(()=>pl(n,e,t),[n,e?.id,e?.type,JSON.stringify(t)])}const ql={},Jl=(0,u.createContext)(`global`);function Yl(){return(0,u.useContext)(Jl)}function Xl(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function Zl(e){let t=Yl(),[,n]=(0,u.useReducer)(e=>e+1,0),r=(0,u.useMemo)(()=>(ql[t]||(ql[t]={}),ql[t][e]||(ql[t][e]={name:e,emitter:(0,E.default)(),status:`idle`,promise:Promise.resolve(),abort:new AbortController,reject:()=>void 0,resolve:()=>void 0}),ql[t][e]),[t,e]);return Ql(r,`abort`,n),Ql(r,`error`,n),Ql(r,`complete`,n),Ql(r,`running`,n),r}function Ql(e,t,n){let r=(0,u.useCallback)(()=>n(e),[n]);(0,u.useEffect)(()=>{let n=e.emitter;return n.on(t,r),()=>n.off(t,r)},[t,r,e.emitter])}const $l=()=>void 0;function eu(e,t){let n=Zl(e);return Ql(n,`complete`,t||$l),[e=>{n.status===`running`&&(n.abort.abort(),n.emitter.emit(`abort`)),n.error&&(n.error=``);let t=Xl();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 tu(e,t){let n=Zl(e);return Ql(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 nu({children:e}){return(0,d.jsx)(Jl.Provider,{value:(0,u.useMemo)(()=>`id-${Date.now()}`,[]),children:e})}function ru(e){return!1}function iu({as:e,reference:t,onReference:n,onLink:r,onAnalysis:i,onDropReference:a,onDropLink:o,onDropAnalysis:s,onPasteReference:c,onPasteLink:l,onPasteAnalysis:f,...p}){let m=e||`div`,h=a||n,g=c||n,_=l||r,v=f||i,y=(0,u.useMemo)(()=>t,[t?.id,t?.type]),b=(0,u.useCallback)(function(e){e.defaultPrevented||(e.preventDefault(),e.clipboardData&&y&&y.id&&y.type&&e.clipboardData.setData(`application/json+vault`,JSON.stringify({id:y.id,type:y.type})))},[y]),x=(0,u.useCallback)(async function(e){if(!e.defaultPrevented&&(e.preventDefault(),e.clipboardData)){if(p.onLoading&&p.onLoading(),g){let t=e.clipboardData.getData(`application/json+vault`);if(t)try{let e=JSON.parse(t);e&&e.id&&e.type&&g(e)}catch{}}if(_||v){let t=e.clipboardData.getData(`text`);if(t.startsWith(`http`)){let e=t.split(`
|
|
1531
|
-
`);for(let t of e){if(v)try{let e=await
|
|
1555
|
+
`,bl=(0,u.memo)(function(e){let{resolveMessage:t}=(0,f.useEditorI18n)(),n=(0,f.useTranslations)(`shell`);if(e.layoutMode===`focused`)return(0,d.jsx)(ul,{...e});let r=q(),i=sr(),a=J(),o=Or(),{vault:s}=(0,u.useContext)(g.ReactVaultContext),c=s||void 0,p=(0,g.useVaultSelector)(e=>e.iiif),m=(0,u.useRef)(null),h=(0,u.useRef)(null),{loading:_,state:v,leftPanels:y,centerPanels:b,rightPanels:x,modals:S=[],actions:C}=o,w=(0,u.useMemo)(()=>({rootResource:a,vault:c,app:r,layoutState:v,appState:i}),[a,c,r,v,i,p]),T=(0,u.useMemo)(()=>ol(y,w,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[y,w]),E=(0,u.useMemo)(()=>ol(b,w,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[b,w]),D=(0,u.useMemo)(()=>ol(x,w,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[x,w]),O=(0,u.useMemo)(()=>ol(S,w,(e,t)=>{console.error(`Layout panel "${e.id}" failed support check`,t)}),[S,w]),k=(0,u.useMemo)(()=>T.filter(e=>e.modal),[T]),A=(0,u.useMemo)(()=>T.filter(e=>!e.modal),[T]),j=(0,u.useMemo)(()=>[...O,...k],[O,k]),N=(0,u.useMemo)(()=>({...o,leftPanels:T,centerPanels:E,rightPanels:D,modals:j}),[o,T,E,D,j]),P=A.find(e=>e.id===v.leftPanel.current),I=D.find(e=>e.id===v.rightPanel.current),L=E.find(e=>e.id===v.centerPanel.current),R=j.find(e=>e.id===v.modal.current),te=v.modal.open&&k.some(e=>e.id===v.modal.current)?v.modal.current:v.leftPanel.current,z=v.pinnedRightPanel.pinned?D.find(e=>e.id===v.pinnedRightPanel.current):void 0,[B]=Tc([`(max-width: 1020px)`]),ne=e.isLoading||!1,re=(0,u.useMemo)(()=>(o.background||[]).map((e,t)=>(0,d.jsx)(u.Fragment,{children:e.render()},t)),[o.background]),V=Bc(`left-panel/${P?.id}`,{left:!0,marginLeft:60,minWidthPx:P?.options?.minWidth||200,maxWidthPx:P?.options?.maxWidth||720,loading:_}),H=Bc(`right-panel/${I?.id}`,{left:!1,minWidthPx:I?.options?.minWidth||320,maxWidthPx:I?.options?.maxWidth||720,loading:_}),ie=I&&(z?.id!==I.id||!(0,ee.default)(v.pinnedRightPanel.state,v.rightPanel.state)),ae=V.widthB===`auto`?void 0:()=>V.setWidths({widthA:`auto`,widthB:Jo({options:P?.options,fallback:320})}),oe=H.widthB===`auto`?void 0:()=>H.setWidths({widthA:`auto`,widthB:Jo({options:I?.options,fallback:320})});if((0,u.useLayoutEffect)(()=>{B&&v.leftPanel.open&&v.rightPanel.open&&(C.leftPanel.close(),C.rightPanel.close())},[B]),(0,u.useLayoutEffect)(()=>{if(L&&L.onMount)return L.onMount(v.centerPanel.state||L.defaultState||{},{...N,current:C.centerPanel,vault:c},i)},[v.centerPanel.current,L?.id]),(0,u.useLayoutEffect)(()=>{if(v.leftPanel.current&&!P){let e=sl(A,v.leftPanel.current);e?C.leftPanel.change({id:e}):C.leftPanel.close()}if(v.centerPanel.current&&!L){let e=sl(E,v.centerPanel.current);e?C.centerPanel.change({id:e}):C.centerPanel.close()}if(v.rightPanel.current&&!I){let e=sl(D,v.rightPanel.current);e?C.rightPanel.change({id:e}):C.rightPanel.close()}if(v.modal.current&&!R){let e=sl(j,v.modal.current);e?C.modal.change({id:e}):C.modal.close()}},[v.leftPanel.current,v.centerPanel.current,v.rightPanel.current,v.modal.current,P?.id,L?.id,I?.id,R?.id,cl(A),cl(E),cl(D),cl(j)]),(0,u.useLayoutEffect)(()=>{D.length&&C.rightPanel.change({id:D[0].id}),A.length&&C.leftPanel.change({id:A[0].id}),E.length&&C.centerPanel.change({id:E[0].id})},[]),_)return null;let se=t=>(0,d.jsx)(rl,{$menu:e.leftPanelMenuPosition||`bottom`,ref:V.refs.resizableDiv,className:[`manifest-editor`,t?`transition transition-${t}`:``].join(` `),style:{width:v.leftPanel.open||t!==`exited`?V.widthB:void 0,minWidth:P?.options?.minWidth},children:ne?(0,d.jsx)(al,{children:(0,d.jsx)(Ic,{})}):(0,d.jsxs)(d.Fragment,{children:[e.leftPanelMenu?(0,d.jsx)(il,{$open:v.leftPanel.open&&t!==`exited`,$position:e.leftPanelMenuPosition||`bottom`,children:e.leftPanelMenu}):null,(0,d.jsx)(al,{children:v.leftPanel.open||t!==`exited`?(0,d.jsx)(d.Fragment,{children:P?(0,d.jsx)(as,{isLeft:!0,noHeader:!0,transition:t,panel:P,state:v.leftPanel,actions:C.leftPanel}):null}):null})]})}),ce=()=>R?(0,d.jsx)(l.Modal,{title:t(R?.labelMessage,R.label),open:v.modal.open,onClose:()=>C.modal.close(),children:R.modal?(0,d.jsx)(`div`,{className:`h-[70vh] min-h-[60vh] max-h-full flex w-full`,children:(0,d.jsx)(as,{isLeft:!0,isModal:!0,noHeader:!0,panel:R,state:v.modal,actions:C.modal})}):Yo(R.render(v.modal.state||R.defaultState||{},{...N,current:C.modal,vault:c,isModal:!0},i))}):null,le=()=>(0,d.jsxs)(rl,{$menu:e.centerPanelMenuPosition||`top`,children:[e.centerPanelMenu?(0,d.jsx)(il,{$open:v.centerPanel.open,$position:e.centerPanelMenuPosition||`top`,children:e.centerPanelMenu}):null,(0,d.jsx)(al,{children:(0,d.jsx)(M.ErrorBoundary,{resetKeys:[L?.id],FallbackComponent:Xo,children:ne?(0,d.jsx)(`div`,{style:{display:`flex`,flex:1,justifyContent:`center`,alignItems:`center`},children:(0,d.jsx)(Pc,{stroke:`rgba(0,0,0,.3)`,fontSize:`2em`})}):v.centerPanel.open&&L?Yo(L.render(v.centerPanel.state||L.defaultState||{},{...N,current:C.centerPanel,vault:c},i)):null})})]}),ue=t=>(0,d.jsx)(rl,{$menu:e.rightPanelMenuPosition||`bottom`,ref:H.refs.resizableDiv,className:t?`transition transition-${t}`:``,style:{width:v.rightPanel.open||t!==`exited`?H.widthB:void 0,minWidth:I?.options?.minWidth},children:ne?(0,d.jsx)(al,{children:(0,d.jsx)(Ic,{})}):(0,d.jsxs)(d.Fragment,{children:[e.rightPanelMenu?(0,d.jsx)(il,{$open:v.rightPanel.open,$position:e.rightPanelMenuPosition||`bottom`,children:e.rightPanelMenu}):null,(0,d.jsx)(al,{children:v.rightPanel.open||t!==`exited`?(0,d.jsxs)(d.Fragment,{children:[ie?(0,d.jsx)(as,{panel:I,state:v.rightPanel,actions:C.rightPanel,pinActions:C.pinnedRightPanel,available:D}):null,z?(0,d.jsx)(as,{panel:z,state:v.pinnedRightPanel,actions:C.pinnedRightPanel,close:C.rightPanel.close}):null]}):null})]})});return B?(0,d.jsxs)(Xc,{children:[e.hideHeader?null:(0,d.jsxs)(Zc,{children:[e.header||(0,d.jsx)(Yr,{}),e.menu?(0,d.jsx)(`menu`,{children:e.menu}):null]}),(0,d.jsx)($c,{children:(0,d.jsxs)(dl,{children:[(0,d.jsxs)(pl,{children:[A.length>0?(0,d.jsx)(ml,{type:`button`,"aria-expanded":v.leftPanel.open,onClick:()=>{C.rightPanel.close(),C.leftPanel.toggle()},children:t(P?.labelMessage,P?.label)}):null,D.length>0?(0,d.jsx)(hl,{children:(0,d.jsxs)(gl,{type:`button`,"aria-expanded":v.rightPanel.open,onClick:()=>{C.leftPanel.close(),C.rightPanel.toggle()},children:[(0,d.jsx)(ai,{"aria-hidden":`true`,rotate:90}),t(I?.labelMessage,I?.label)]})}):null]}),(0,d.jsx)(fl,{children:le()}),D.length>0?(0,d.jsx)(_l,{$open:v.rightPanel.open,children:ue()}):null,A.length>0?(0,d.jsxs)(vl,{$open:v.leftPanel.open,children:[(0,d.jsx)(`nav`,{"aria-label":n(`panels.leftTabs`),className:`flex flex-none overflow-x-auto border-b border-gray-300`,children:A.map(e=>(0,d.jsxs)(`button`,{type:`button`,"aria-pressed":v.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 ${v.leftPanel.current===e.id?`border-b-[#b83265] bg-[#f9e8ef]`:`border-b-transparent bg-white`}`,onClick:()=>{C.rightPanel.close(),C.leftPanel.open({id:e.id,state:e.defaultState})},children:[e.icon,t(e?.labelMessage,e.label)]},e.id))}),se()]}):null,T.length>0||D.length>0?(0,d.jsx)(yl,{type:`button`,"aria-label":n(`panels.closeAll`),$open:v.leftPanel.open||v.rightPanel.open,onClick:()=>{C.leftPanel.close(),C.rightPanel.close()}}):null]})}),(0,d.jsx)(`div`,{className:`hidden`,children:re}),(0,d.jsx)(Ga,{}),(0,d.jsx)(qa,{}),(0,d.jsx)(d.Fragment,{children:ce()}),(0,d.jsx)(vo,{})]}):(0,d.jsxs)(Xc,{id:e.htmlId||`manifest-editor-container`,className:`manifest-editor ${e.className||``}`,children:[e.hideHeader?null:(0,d.jsxs)(Zc,{children:[e.header||(0,d.jsx)(Yr,{}),e.menu?(0,d.jsx)(`menu`,{children:e.menu}):null]}),(0,d.jsxs)($c,{ref:e=>{V.refs.container.current=e,H.refs.container.current=e},children:[T.length>0?(0,d.jsx)(l.PanelSideMenu,{current:te,items:T.map(e=>({id:e.id,label:t(e?.labelMessage,e.label),icon:e.icon,divide:e.divide,separator:e.separator,onClick:()=>{if(e.modal){v.modal.open&&v.modal.current===e.id?C.modal.close():C.modal.open({id:e.id,state:e.defaultState});return}v.leftPanel.current===e.id?C.leftPanel.toggle():C.leftPanel.change({id:e.id})}})),open:v.leftPanel.open}):null,A.length>0?(0,d.jsx)(F.Transition,{nodeRef:m,in:v.leftPanel.open,timeout:400,unmountOnExit:!1,children:e=>(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(el,{ref:m,$width:V.widthB,$state:e,$motion:!0,children:se(e)}),(0,d.jsx)(Nc,{ref:V.refs.resizer,reset:ae,dir:`left`,transition:e,open:v.leftPanel.open||e!==`exited`,actions:C.leftPanel})]})}):null,(0,d.jsx)(tl,{children:le()}),D.length>0?(0,d.jsx)(F.Transition,{nodeRef:h,in:v.rightPanel.open,timeout:400,unmountOnExit:!1,children:e=>(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(Nc,{ref:H.refs.resizer,dir:`right`,reset:oe,open:v.rightPanel.open,actions:C.rightPanel}),(0,d.jsx)(nl,{ref:h,$width:H.widthB,$state:e,$motion:!0,children:ue(e)})]})}):null]}),(0,d.jsx)(Qc,{children:e.footer||null}),(0,d.jsx)(`div`,{className:`hidden`,children:re}),(0,d.jsx)(Ga,{}),(0,d.jsx)(qa,{}),(0,d.jsx)(d.Fragment,{children:ce()}),(0,d.jsx)(vo,{})]})});function xl(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 d(){t({type:`resetSize`,panel:e,payload:void 0})}function f(n){t({type:`pin`,panel:e,payload:n})}function p(){t({type:`unpin`,panel:e,payload:void 0})}return(0,u.useMemo)(()=>({popStack:n,change:r,open:i,close:a,toggle:o,minimise:s,maximise:c,setCustomWidth:l,resetSize:d,pin:f,unpin:p}),[])}function Sl(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?{...(0,O.original)(e.state)}:{}})}}else e.stack=[]}function Cl(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&&Sl(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&&Sl(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(qo(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 wl=(0,O.produce)((e,t)=>{switch(t.panel){case`centerPanel`:Cl(e.centerPanel,t);break;case`leftPanel`:Cl(e.leftPanel,t);break;case`rightPanel`:Cl(e.rightPanel,t);break;case`modal`:Cl(e.modal,t);break;case`pinnedRightPanel`:Cl(e.pinnedRightPanel,t)}});function Tl(){return{customWidth:void 0,minimised:!1,open:!0,current:null,state:null,stack:[]}}function El(){return{leftPanel:Tl(),centerPanel:Tl(),rightPanel:Tl(),modal:Tl(),pinnedRightPanel:{...Tl(),pinnable:!0,pinned:!1}}}function Dl({className:e,variant:t=`light`}){let n=(0,f.useTranslations)(`shell`),{locale:r,profile:i}=(0,f.useEditorI18n)(),a=(0,g.useManifest)(),o=(0,g.useVault)(),{edit:s}=Tr(),c=qi(),l=Ji(),p=a?.items||[],m=a?.viewingDirection===`right-to-left`||a?.viewingDirection===`bottom-to-top`,h=a?.viewingDirection===`top-to-bottom`||a?.viewingDirection===`bottom-to-top`,_=Ol(c)||l.map(Ol).find(Boolean)||p[0]?.id||``,y=Math.max(0,p.findIndex(e=>e.id===_)),b=p[y]?.id||``,x=y+1,S=(0,u.useMemo)(()=>p.map((e,t)=>{let r=o.get({id:e.id,type:`Canvas`});return{id:e.id,pageNumber:t+1,labelText:(0,v.getValue)(r?.label)||n(`navigation.page`,{number:t+1})}}),[p,o,n,r,i]),C=e=>{let t=p.findIndex(t=>t.id===e),n=p[t];!n||!a||s({id:n.id,type:`Canvas`},{parent:{id:a.id,type:`Manifest`},property:`items`,index:t},{forceOpen:!1})};if(!a||p.length<2)return(0,d.jsx)(`div`,{className:e});let w=p[y-1],T=p[y+1],E=t===`dark`;return(0,d.jsxs)(`nav`,{"aria-label":n(`navigation.title`),className:Ml(`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`,m&&`flex-row-reverse`,E?`border-white/20 bg-white/10 text-white`:`border-me-gray-300 bg-white text-me-gray-900`,e),children:[(0,d.jsx)(kl,{ariaLabel:n(`navigation.previous`),disabled:!w,onClick:()=>w&&C(w.id),dark:E,children:(0,d.jsx)(Al,{reverse:m,vertical:h})}),(0,d.jsxs)(`label`,{htmlFor:`manifest-pagination-page-select`,"aria-label":`Page ${x} of ${p.length}`,className:Ml(`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`,E?`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:[(0,d.jsxs)(`span`,{children:[x,` / `,p.length]}),(0,d.jsx)(jl,{className:Ml(`shrink-0 text-base`,E?`text-white/60`:`text-me-gray-500`)}),(0,d.jsx)(`select`,{id:`manifest-pagination-page-select`,"aria-label":n(`navigation.jump`),value:b,onChange:e=>C(e.target.value),className:`absolute inset-0 cursor-pointer appearance-none border-0 bg-white opacity-0`,children:S.map(e=>(0,d.jsx)(`option`,{value:e.id,children:n(`navigation.option`,{number:e.pageNumber,label:e.labelText})},e.id))})]}),(0,d.jsx)(kl,{ariaLabel:n(`navigation.next`),disabled:!T,onClick:()=>T&&C(T.id),dark:E,children:(0,d.jsx)(Al,{reverse:!m,vertical:h})})]})}function Ol(e){let t=e?.resource?.source;return t?.type===`Canvas`?t.id:null}function kl({ariaLabel:e,children:t,dark:n,disabled:r,onClick:i}){return(0,d.jsx)(`button`,{type:`button`,"aria-label":e,disabled:r,onClick:i,className:Ml(`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 Al({reverse:e,vertical:t}){return(0,d.jsx)(e?l.ArrowRightIcon:l.BackIcon,{"aria-hidden":!0,className:Ml(`block`,t&&`rotate-90`)})}function jl(e){return(0,d.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,viewBox:`0 0 24 24`,"aria-hidden":!0,...e,children:(0,d.jsx)(`path`,{fill:`currentColor`,d:`m7 10l5 5l5-5z`})})}function Ml(...e){return e.filter(Boolean).join(` `)}const Nl=new WeakMap;function Pl(e,t){let n={port:t,lastActionId:`@genesis`},r=Fl(e);function i(e){t.postMessage(typeof e==`string`?e:JSON.stringify(e))}function a(){i({_id:Zt(),_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=Ll(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,Nl.delete(e)),t.close()}}function Fl(e){let t=Nl.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)Il(t,e);return t}),a={originalDispatch:n,patchedDispatch:i,targets:r};return e.dispatch=i,Nl.set(e,a),a}function Il(e,t){let n={_id:Zt(),_type:`vault-action`,_lastActionId:e.lastActionId,action:t};e.lastActionId=n._id,e.port.postMessage(JSON.stringify(n))}function Ll(e){try{if(typeof e==`string`)return JSON.parse(e);if(typeof e==`object`&&e)return e}catch{return null}return null}const Rl=(0,u.createContext)(null);function zl({children:e}){let t=(0,g.useVault)(),n=(0,u.useRef)(null),r=(0,u.useRef)(null),i=(0,u.useRef)(null),a=(0,u.useRef)(!1),[o,s]=(0,u.useState)(!0),c=(0,u.useCallback)(()=>{if(!n.current||n.current.closed||!r.current)return;i.current?.();let e=new MessageChannel;i.current=Pl(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]);(0,u.useEffect)(()=>{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=(0,u.useCallback)(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)},[]),f=(0,u.useCallback)(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)}},[]),p=(0,u.useCallback)(()=>{n.current&&!n.current.closed&&n.current.focus()},[]);return(0,d.jsx)(Rl.Provider,{value:{open:l,update:f,focus:p,isClosed:o},children:e})}function Bl(){let e=(0,u.useContext)(Rl);return z(e,`usePreviewWindow() can only be called from inside <PreviewWindowProvider />`),e}function Vl({children:e,localisation:t,preset:n}){let{uiI18n:r}=U(),i=(0,f.useOptionalEditorI18nInstance)(),a=(0,f.useEditorI18n)(),o=(0,u.useRef)(null),s=a.availableLocales.map(e=>e.id).join(`|`)+`;`+a.availableProfiles.join(`|`),c=JSON.stringify(r),l=!!(r||t||n),p=(0,u.useMemo)(()=>{if(i&&!l)return i;let e=o.current?.getSnapshot(),s=i?[{availableLocales:a.availableLocales.map(e=>e.id),availableProfiles:a.availableProfiles}]:[],c=ne(n,t),u=(0,m.createEditorI18n)({...c,locale:i?void 0:c?.locale,profile:i?void 0:c?.profile,locales:c?.locales||(i?a.availableLocales:void 0),config:{...n?.config,...t?.config,...r},policies:[...s,...n?.policies||[],...t?.policies||[]],presets:[...n?.presets||[],...t?.presets||[]],requiredNamespaces:[...new Set([`shell`,`editor-api`,...n?.requiredNamespaces||[],...t?.requiredNamespaces||[],...r?.requiredNamespaces||[]])],registrations:[...n?.registrations||[],...t?.registrations||[]],persistedLocale:i?a.locale:e?.locale,persistedProfile:i?a.profile:e?.profile});return o.current=u,u},[i,l,c,t,n,s]),h=p.getSnapshot(),g=i?h.availableLocales.some(e=>e.id===a.locale)?a.locale:h.locale:void 0,_=i?h.availableProfiles.includes(a.profile)?a.profile:h.profile:void 0;return(0,d.jsx)(f.EditorI18nProvider,{instance:p,locale:g,profile:_,onLocaleChange:i?e=>{if(!h.availableLocales.some(t=>t.id===e))throw RangeError(`Unavailable shell locale: ${e}`);return a.setLocale(e)}:void 0,onProfileChange:i?e=>{if(!h.availableProfiles.includes(e))throw RangeError(`Unavailable shell profile: ${e}`);return a.setProfile(e)}:void 0,children:e})}var Hl=class extends u.Component{constructor(...e){super(...e),Y(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?(0,d.jsx)(Ul,{}):this.props.children}};function Ul(){let e=(0,f.useTranslations)(`ui`);return(0,d.jsx)(`h1`,{role:`alert`,children:e(`error.title`)})}function Wl(e,t){return typeof e==`string`?{id:e,state:t}:e}const Gl=(0,u.memo)(function(e){let t=q(),n=Cc(),r=t.layout,[i,a]=(0,u.useReducer)(wl,void 0,El),o={centerPanel:xl(`centerPanel`,a),leftPanel:xl(`leftPanel`,a),rightPanel:xl(`rightPanel`,a),pinnedRightPanel:xl(`pinnedRightPanel`,a),modal:xl(`modal`,a),editingStack:Ki()};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];z(!1,`Was not able to find panel with id "${e}"`)}function c(e,t){let{id:r,state:i,stacked:a}=Wl(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}=Wl(e,t),[a,o]=s(r),c={id:r,state:{...a.defaultState||{},...i||{}},stacked:!0};n.emit(`layout.open`,c),o.open(c)}function f(e,t){let{id:r,state:i,stacked:a}=Wl(e,t),[o,c]=s(r),l={id:r,state:{...o.defaultState||{},...i||{}},stacked:a};n.emit(`layout.change`,l),c.change(l)}function p(e,t){let{id:r}=Wl(e,t),[,i]=s(r);n.emit(`layout.close`,{id:r}),i.close()}function m(e,t){let{id:r}=Wl(e,t),[,i]=s(r);n.emit(`layout.toggle`,{id:r}),i.toggle()}function h(e,t={},{reset:i,property:a,stacked:s,forceOpen:c,selectedTab:l}={}){let u={resource:(0,_.isSpecificResource)(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 g(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 v={open:c,change:f,close:p,toggle:m,stack:l,edit:h,create:g};return(0,d.jsx)(xr.Provider,{value:(0,u.useMemo)(()=>({...o,...v}),[r]),children:(0,d.jsx)(Sr.Provider,{value:i,children:e.children})})}),Kl=[{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`}],ql=new I.ImageServiceLoader({approximateServices:!0,verificationsRequired:8,enableFetching:!0});function Jl({config:e,saveConfig:t,children:n,theme:r,previews:i,resource:a,editing:o,backgroundActionPersistence:s,localisation:c}){let l=or(),f=q(),p=U(),m=(0,u.useMemo)(()=>{let t=e?.previews||(p.previews?.length?p.previews:Kl);return ce(p,{previews:t},e)},[p,e]),h=(0,u.useMemo)(()=>({appId:l.appId,instanceId:l.instanceId,rootResource:{id:a.id,type:a.type}}),[l.appId,l.instanceId,a.id,a.type]);return(0,d.jsx)(Hl,{children:(0,d.jsx)(g.ImageServiceLoaderContext.Provider,{value:ql,children:(0,d.jsx)(br,{resource:a,children:(0,d.jsx)(Fr,{children:(0,d.jsx)(y.ThemeProvider,{theme:r||ws,children:(0,d.jsx)(fe,{config:m,saveConfig:t,children:(0,d.jsxs)(Vl,{localisation:c,preset:f.preset?.localisation,children:[(0,d.jsx)(Qn,{config:m}),(0,d.jsx)(nr,{}),(0,d.jsx)(qr,{}),(0,d.jsx)(na,{children:(0,d.jsx)(Gl,{children:(0,d.jsx)(Ut,{persistence:s,persistenceKey:h,children:(0,d.jsx)(qs,{children:(0,d.jsx)(Fa,{children:(0,d.jsx)(yi,{previews:i||[],configs:m.previews,children:(0,d.jsx)(zl,{children:(0,d.jsxs)(g.AtlasStoreProvider,{children:[(0,d.jsx)(To,{}),n]})})})})})})})})]})})})})})})})}const Yl=new Set([`Collection`,`Manifest`,`Canvas`,`Range`,`AnnotationPage`,`Annotation`,`ContentResource`,`Agent`]),Xl={satisfied:0,missing:0,invalid:0,disallowed:0,"not-applicable":0},Zl=new Set([`label`,`summary`,`language`,`navDate`,`provider`,`requiredStatement`,`rights`,`thumbnail`]);function Ql(e){return e?Array.isArray(e)?e.filter(Boolean):e.split(`.`).filter(Boolean):[]}function $l(e,t){let n=Ql(e),r=Ql(t);return n.length===r.length&&n.every((e,t)=>e===r[t])}function eu(e,t){let n=e;for(let e of Ql(t)){if(n==null)return;n=n[e]}return n}function tu(e,t,n){let r=Ql(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 nu(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=>nu(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])=>nu(e)):!1}function ru(e){return Array.isArray(e)?e.map(ru):e&&typeof e==`object`?Object.keys(e).sort().reduce((t,n)=>(t[n]=ru(e[n]),t),{}):e}function iu(e,t){return JSON.stringify(ru(e))===JSON.stringify(ru(t))}function au(e,t,n,r,i){let a=Ql(n);for(let n of e||[])for(let e of n.terminology?.properties||[])if(!(e.entityType&&e.entityType!==t)&&$l(e.path,a))return i?i.resolveMessage(e.labelMessage,e.label):e.label;return i?i.translate(`editor-api`)(`fields.${a.join(`.`)}`,void 0,{defaultValue:r||Nu(a)}):r||Nu(a)}function ou(e,t,n,r){let i=Ql(n),a=[],o,s,c=!1,l=!1;if(!t||!Yl.has(t.type))return{entityType:t?.type,path:i,label:au(e,t?.type,i,void 0,r),disallowed:!1,required:!1,rules:a};for(let n of e||[])for(let e of n.rules||[])!(`entityType`in e)||!(`path`in e)||e.entityType===t.type&&$l(e.path,i)&&(a.push(e),e.type===`disallow-property`&&(c=!0),e.type===`require-non-empty`&&(l=!0),e.type===`fixed-value`&&!s&&(o=e.value,s=e,l=!0));return{entityType:t.type,path:i,label:au(e,t.type,i,void 0,r),disallowed:c,required:l,fixedValue:o,fixedValueRule:s,rules:a}}function su(e,t,n,r){let i=e||[],a=cu(t,n),o=[];for(let e of i)for(let[n,r]of(e.rules||[]).entries())o.push(...lu(e,r,n,a,t));return{specifications:i,results:r?o.map(e=>{let t=i.find(t=>t.id===e.specificationId),n=t?.rules[e.ruleIndex],a=e.ruleType===`iiif:metadata-template`?e.displayLabel:e.path?au(t?[t]:[],e.target?.type,e.path,e.displayLabel,r):e.ruleType===`iiif:canvas-with-image-service`&&!n?.label?r.translate(`shell`)(`specificationFields.canvasImageService`):e.displayLabel,o=e.messageReference?.values?.label===e.displayLabel?{...e.messageReference,values:{...e.messageReference.values,label:a}}:e.messageReference;return{...e,displayLabel:a,ruleLabel:n?.label||a,specificationLabel:r.resolveMessage(t?.labelMessage,e.specificationLabel),messageReference:o,message:r.resolveMessage(o,e.message)}}):o,counts:vu(o)}}function cu(e,t){let n=[],r=new Set;function i(t){let a=bu(t);if(!a)return;if(a.type===`SpecificResource`){i(t?.source);return}let o=yu(e,t)||yu(e,a);if(!o||!o.type)return;let s=`${o.type}:${o.id||JSON.stringify(a)}`;if(!r.has(s)){r.add(s),Yl.has(o.type)&&n.push({ref:{id:o.id,type:o.type},resource:o});for(let e of xu(o))i(e)}}return i(t),n}function lu(e,t,n,r,i){switch(t.type){case`disallow-property`:case`require-non-empty`:case`fixed-value`:return uu(e,t,n,r);case`iiif:canvas-with-image-service`:return[du(e,t,n,r,i)];case`iiif:thumbnail-from-body-service`:return fu(e,t,n,r,i);case`iiif:valid-rights`:return pu(e,t,n,r);case`iiif:required-statement`:return mu(e,t,n,r);case`iiif:metadata-template`:return hu(e,t,n,r);default:return[]}}function uu(e,t,n,r){let i=r.filter(e=>e.ref.type===t.entityType),a=au(e?[e]:[],t.entityType,t.path);return i.length?i.map(({ref:r,resource:i})=>{let o=eu(i,t.path),s=nu(o);if(t.type===`disallow-property`)return gu(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.`,messageReference:s?{namespace:`shell`,key:`specification.disallowed`,defaultValue:`{{label}} is present but is not allowed.`,values:{label:a}}:{namespace:`shell`,key:`specification.absent`,defaultValue:`{{label}} is not present.`,values:{label:a}},editorTarget:_u(r,t.path)});if(t.type===`require-non-empty`)return gu(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.`,messageReference:s?{namespace:`shell`,key:`specification.hasValue`,defaultValue:`{{label}} has a value.`,values:{label:a}}:{namespace:`shell`,key:`specification.required`,defaultValue:`{{label}} must be filled in.`,values:{label:a}},editorTarget:_u(r,t.path)});let c=iu(o,t.value);return gu(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.`,messageReference:c?{namespace:`shell`,key:`specification.matches`,defaultValue:`{{label}} matches the required value.`,values:{label:a}}:s?{namespace:`shell`,key:`specification.mismatch`,defaultValue:`{{label}} does not match the required value.`,values:{label:a}}:{namespace:`shell`,key:`specification.fixed`,defaultValue:`{{label}} must use the required value.`,values:{label:a}},editorTarget:_u(r,t.path)})}):[gu(e,t,n,{status:`not-applicable`,displayLabel:a,message:`No ${t.entityType} resources were found for ${a}.`,messageReference:{namespace:`shell`,key:`specification.noResources`,defaultValue:`No {{type}} resources were found for {{label}}.`,values:{type:t.entityType,label:a}},path:t.path})]}function du(e,t,n,r,i){let a=r.filter(e=>e.ref.type===`Canvas`),o=Su(t),s=a.find(({resource:e})=>Cu(wu(e,i),o));return gu(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.`,messageReference:s?{namespace:`shell`,key:`specification.servicePresent`,defaultValue:`A canvas contains the required image service.`}:o.length?{namespace:`shell`,key:`specification.serviceList`,defaultValue:`A canvas must contain one of the required image services: {{services}}.`,values:{services:o.join(`, `)}}:{namespace:`shell`,key:`specification.serviceRequired`,defaultValue:`A canvas must contain a painting body with an image service.`},editorTarget:s?_u(s.ref,[`items`]):void 0})}function fu(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=>wu(e.resource,i)):wu(s,i),l=Tu(s,c,i),u=nu(s.thumbnail);return gu(e,t,n,{target:o,path:[`thumbnail`],status:l?`satisfied`:c.length?u?`invalid`:t.requireThumbnail===!1?`not-applicable`:`missing`:`not-applicable`,displayLabel:au([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.`,messageReference:l?{namespace:`shell`,key:`specification.thumbnailMatches`,defaultValue:`Thumbnail uses the same image service as the painting content.`}:c.length?u?{namespace:`shell`,key:`specification.thumbnailMismatch`,defaultValue:`Thumbnail does not use the same image service as the painting content.`}:{namespace:`shell`,key:`specification.thumbnailRequired`,defaultValue:`Thumbnail must be created from the painting image service.`}:{namespace:`shell`,key:`specification.noPaintingService`,defaultValue:`No painting image service was found to compare against.`},editorTarget:_u(o,[`thumbnail`])})}):[gu(e,t,n,{status:`not-applicable`,displayLabel:`Thumbnail`,message:`No ${a} resources were found for thumbnail checks.`,messageReference:{namespace:`shell`,key:`specification.noThumbnails`,defaultValue:`No {{type}} resources were found for thumbnail checks.`,values:{type:a}}})]}function pu(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=nu(a),c=typeof a==`string`&&o.map(ku).includes(ku(a));return gu(e,t,n,{target:r,path:[`rights`],status:c?`satisfied`:!s&&t.required!==!1?`missing`:`invalid`,displayLabel:au([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.`,messageReference:c?{namespace:`shell`,key:`specification.rightsValid`,defaultValue:`Rights uses an allowed URI.`}:!s&&t.required!==!1?{namespace:`shell`,key:`specification.rightsRequired`,defaultValue:`Rights must use an allowed URI.`}:{namespace:`shell`,key:`specification.rightsInvalid`,defaultValue:`Rights is not one of the allowed URIs.`},editorTarget:_u(r,[`rights`])})})}function mu(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?Au(a?.label,t.label):nu(a?.label),s=t.value||t.valueRequired!==!1,c=t.value?Au(a?.value,t.value):!s||nu(a?.value),l=nu(a);return gu(e,t,n,{target:r,path:[`requiredStatement`],status:o&&c?`satisfied`:l?`invalid`:`missing`,displayLabel:au([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.`,messageReference:o&&c?{namespace:`shell`,key:`specification.statementComplete`,defaultValue:`Required statement is complete.`}:l?{namespace:`shell`,key:`specification.statementInvalid`,defaultValue:`Required statement does not match the specification.`}:{namespace:`shell`,key:`specification.statementRequired`,defaultValue:`Required statement must be filled in.`},editorTarget:_u(r,[`requiredStatement`])})})}function hu(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=>Au(e?.label,i.label)),l=i.value?Au(c?.value,i.value):!i.valueRequired||nu(c?.value),u=c&&l?`satisfied`:c&&i.value?`invalid`:`missing`,d=Mu(i.label);o.push(gu(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.`,messageReference:c&&l?{namespace:`shell`,key:`specification.metadataPresent`,defaultValue:`{{label}} is present.`,values:{label:d||`Metadata`}}:c?{namespace:`shell`,key:`specification.metadataValue`,defaultValue:`{{label}} needs a value.`,values:{label:d||`Metadata`}}:{namespace:`shell`,key:`specification.metadataRequired`,defaultValue:`{{label}} metadata must be added.`,values:{label:d||`Metadata`}},editorTarget:_u(r,[`metadata`])}))})}return o}function gu(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,messageReference:t.messageReference||(t.message?void 0:r.messageReference),expected:r.expected,actual:r.actual,editorTarget:r.editorTarget}}function _u(e,t){let n=t[0];return{resource:e,propertyPath:t,selectedTab:n===`metadata`?`@manifest-editor/metadata`:n&&Zl.has(n)?`@manifest-editor/descriptive-properties`:void 0}}function vu(e){let t={...Xl};for(let n of e)t[n.status]+=1;return t}function yu(e,t){let n=bu(t);if(!n)return t;try{return e.get(n,{skipSelfReturn:!1})||t}catch{try{return e.get(n)||t}catch{return t}}}function bu(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 xu(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 Su(e){return[...e.serviceIds||[],...e.serviceId?[e.serviceId]:[]].filter(Boolean)}function Cu(e,t){let n=new Set(e.filter(Boolean));return t.length?t.some(e=>n.has(e)):n.size>0}function wu(e,t){let n=Ou(t,e?.items),r=[];for(let e of n){let n=Ou(t,e?.items);for(let e of n)if((Array.isArray(e?.motivation)?e.motivation:[e?.motivation]).includes(`painting`))for(let n of Eu(e?.body,t))r.push(...Du(n))}return Array.from(new Set(r))}function Tu(e,t,n){let r=Ou(n,e?.thumbnail);if(!r.length||!t.length)return!1;for(let e of r){let n=Du(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 Eu(e,t){let n=yu(t,e);return n?Array.isArray(n)?n.flatMap(e=>Eu(e,t)):n.type===`SpecificResource`?Eu(n.source,t):n.type===`Choice`?n.items?.flatMap(e=>Eu(e,t))||[]:[n]:[]}function Du(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 Ou(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=>yu(e,t)).filter(Boolean)}function ku(e){return e.replace(/^https:/,`http:`).replace(/\/?$/,`/`)}function Au(e,t){return typeof t==`string`?ju(e).some(e=>e===t):iu(e,t)}function ju(e){return e?typeof e==`string`?[e.trim()].filter(Boolean):Array.isArray(e)?e.flatMap(ju):typeof e==`object`?Object.values(e).flatMap(ju):[]:[]}function Mu(e){return typeof e==`string`?e:ju(e)[0]||``}function Nu(e){return(e[e.length-1]||`Property`).replace(/([A-Z])/g,` $1`).replace(/[-_]/g,` `).replace(/^./,e=>e.toUpperCase())}const Pu=(0,u.createContext)([]);function Fu({children:e,specifications:t}){let n=(0,u.useMemo)(()=>t||[],[t]);return(0,d.jsx)(Pu.Provider,{value:n,children:e})}function Iu(){return(0,u.useContext)(Pu)}function Lu(e){let{resolveMessage:t,translate:n,locale:r,profile:i}=(0,f.useEditorI18n)(),a=J(),o=Iu(),s=e||a;return(0,g.useVaultSelector)((e,r)=>su(o,r,s,{resolveMessage:t,translate:n}),[o,s.id,s.type,t,n,r,i])}function Ru(){let{resolveMessage:e,translate:t,locale:n,profile:r}=(0,f.useEditorI18n)(),i=Iu();return(0,u.useMemo)(()=>({getLabel(n,r,a){return au(i,n,r,a,{resolveMessage:e,translate:t})}}),[i,e,t,n,r])}function zu(e,t){let n=Iu(),{resolveMessage:r,translate:i,locale:a,profile:o}=(0,f.useEditorI18n)();return(0,u.useMemo)(()=>ou(n,e,t,{resolveMessage:r,translate:i}),[n,r,i,a,o,e?.id,e?.type,JSON.stringify(t)])}const Bu={},Vu=(0,u.createContext)(`global`);function Hu(){return(0,u.useContext)(Vu)}function Uu(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function Wu(e){let t=Hu(),[,n]=(0,u.useReducer)(e=>e+1,0),r=(0,u.useMemo)(()=>(Bu[t]||(Bu[t]={}),Bu[t][e]||(Bu[t][e]={name:e,emitter:(0,N.default)(),status:`idle`,promise:Promise.resolve(),abort:new AbortController,reject:()=>void 0,resolve:()=>void 0}),Bu[t][e]),[t,e]);return Gu(r,`abort`,n),Gu(r,`error`,n),Gu(r,`complete`,n),Gu(r,`running`,n),r}function Gu(e,t,n){let r=(0,u.useCallback)(()=>n(e),[n]);(0,u.useEffect)(()=>{let n=e.emitter;return n.on(t,r),()=>n.off(t,r)},[t,r,e.emitter])}const Ku=()=>void 0;function qu(e,t){let n=Wu(e);return Gu(n,`complete`,t||Ku),[e=>{n.status===`running`&&(n.abort.abort(),n.emitter.emit(`abort`)),n.error&&(n.error=``);let t=Uu();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 Ju(e,t){let n=Wu(e);return Gu(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 Yu({children:e}){return(0,d.jsx)(Vu.Provider,{value:(0,u.useMemo)(()=>`id-${Date.now()}`,[]),children:e})}function Xu(e){return!1}function Zu({as:e,reference:t,onReference:n,onLink:r,onAnalysis:i,onDropReference:a,onDropLink:o,onDropAnalysis:s,onPasteReference:c,onPasteLink:l,onPasteAnalysis:f,...p}){let m=e||`div`,h=a||n,g=c||n,_=l||r,v=f||i,y=(0,u.useMemo)(()=>t,[t?.id,t?.type]),b=(0,u.useCallback)(function(e){e.defaultPrevented||(e.preventDefault(),e.clipboardData&&y&&y.id&&y.type&&e.clipboardData.setData(`application/json+vault`,JSON.stringify({id:y.id,type:y.type})))},[y]),x=(0,u.useCallback)(async function(e){if(!e.defaultPrevented&&(e.preventDefault(),e.clipboardData)){if(p.onLoading&&p.onLoading(),g){let t=e.clipboardData.getData(`application/json+vault`);if(t)try{let e=JSON.parse(t);e&&e.id&&e.type&&g(e)}catch{}}if(_||v){let t=e.clipboardData.getData(`text`);if(t.startsWith(`http`)){let e=t.split(`
|
|
1556
|
+
`);for(let t of e){if(v)try{let e=await Xu(t);if(e){v(e);continue}}catch{}_&&_(t)}}}p.onComplete&&p.onComplete()}},[]),S=(0,u.useCallback)(function(e){e.defaultPrevented||(e.preventDefault(),e.dataTransfer&&p.draggable&&(e.dataTransfer.effectAllowed=`all`,y&&y.id&&y.type&&e.dataTransfer.setData(`application/json+vault`,JSON.stringify({id:y.id,type:y.type}))))},[]),C=(0,u.useCallback)(async function(e){if(e.preventDefault(),e.dataTransfer){if(h){let t=e.dataTransfer.getData(`application/json+vault`);if(t)try{let n=JSON.parse(t);n&&n.id&&n.type&&h(n,e)}catch{return}}let t=e.dataTransfer.getData(`application/json`);if(t){JSON.parse(t);return}if(e.dataTransfer.getData(`text/plain`))return}},[]),w=(0,u.useCallback)(e=>{e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`)},[]);return(0,d.jsx)(m,{onCopy:b,onPaste:x,onDrop:C,onDragOver:w,onDragStart:S,tabIndex:-1,...p})}exports.AnnotationRequestCleanup=To,exports.AppHeader=yo,exports.AppMenuProvider=Co,exports.AppProvider=dr,exports.AppReactContext=ir,exports.AppResourceInstanceProvider=yr,exports.AppResourceProvider=br,exports.AppStateReactContext=ar,exports.AtlasStoreProvider=g.AtlasStoreProvider,exports.AtlasStoreReactContext=g.AtlasStoreReactContext,exports.BackgroundActionToasts=qa,exports.BackgroundActionsMenu=ao,exports.BackgroundActionsMount=Ga,exports.BackgroundActionsProvider=Ut,exports.BackgroundActionsReactContext=Ht,exports.BaseAnnotationCreator=Ts,exports.BaseEditor=ks,exports.BaseEditorBackButton=Es,exports.BaseEditorCloseButton=Ds,exports.ButtonChange=Ei,exports.ButtonContainer=wi,exports.ButtonEmpty=Ni,exports.ButtonMain=Ti,exports.CANVAS_PROGRESS_META_NAMESPACE=ye,exports.CANVAS_PROGRESS_STATUS_META_KEY=be,exports.ConfigEditor=Hs,exports.ConfigProvider=fe,exports.ConfigReactContext=le,exports.ContextMenuProvider=qs,exports.ContextMenuReactContext=Ks,exports.CreatorInitialData=ds,exports.CreatorSettings=Ws,exports.EditingStack=na,exports.EditingStackContext=Wi,exports.EventEmitterProvider=Sc,exports.ExportPanel=vc,exports.FLAG_TAG=oa,exports.HOMEPAGE_COLLECTION=Nr,exports.HandleContainer=Oc,exports.HandleControls=Nc,exports.IIIFOptions=Vs,exports.InlineEditingStack=ra,exports.Layout=bl,exports.LayoutActionsReactContext=xr,exports.LayoutModeReactContext=Cr,exports.LayoutStateReactContext=Sr,exports.ManifestEditorCanvasProgressOverlay=ze,exports.ManifestEditorTagBadge=ka,exports.ManifestEditorTagIcon=Oa,exports.ManifestEditorTagOverlay=Aa,exports.ManifestPaginationNavigation=Dl,exports.MenuContainer=Di,exports.MenuItem=Oi,exports.MenuItemClose=Mi,exports.MenuItemLabel=ji,exports.MenuItemStatus=Ai,Object.defineProperty(exports,"MessagePortClientVault",{enumerable:!0,get:function(){return L.MessagePortClientVault}}),exports.ModularPanel=as,exports.ModularPanelHeader=es,exports.ModulePanelButton=ts,exports.MultiAppProvider=hr,exports.NOTEBOOK_PANEL_ID=Wr,exports.NotebookCreatorSources=ei,exports.NotebookIcon=Gr,exports.PanelError=Xo,exports.PluginConfigBridge=Qn,exports.PluginGlobalConfigReactContext=zn,exports.PluginI18nBridge=nr,exports.PluginManager=Rs,exports.PluginProvider=Bn,exports.PluginReactContext=Rn,exports.PresetOnboarding=vo,exports.PresetOnboardingButton=go,exports.PresetPreviewButton=_o,exports.PreviewButton=Fi,exports.PreviewProvider=yi,exports.PreviewVaultBoundary=Ir,exports.PreviewVaultContext=Fr,exports.PreviewWindowProvider=zl,exports.PrimeAppReactContext=rr,exports.ProjectNotebookButton=Xr,exports.ProjectNotebookHeader=Yr,exports.ProjectNotebookPanel=Qr,exports.ProjectNotebookSync=qr,exports.ReactEmitterContext=xc,exports.ResourceEditingProvider=Bi,exports.ResourceEditingReactContext=Ii,exports.SaveConfigReactContext=ue,exports.ShellI18nBoundary=Vl,exports.ShellProvider=Jl,exports.SpecificationProvider=Fu,exports.TAGS_META_KEY=aa,exports.TAGS_META_NAMESPACE=ia,exports.TaskBridge=Yu,exports.ToastProvider=Fa,exports.UniversalCopyTarget=Zu,exports.addResourceTag=ya,exports.analyse=Ao,exports.analyseJson=Mo,exports.applyPlugins=In,exports.backgroundActionFormatter=ge,exports.backgroundActionLabel=_e,exports.backgroundActionStatus=ve,exports.baseCreator=Cs,exports.baseEditor=As,exports.clearCanvasProgressStatus=Oe,exports.clearCanvasProgressStatuses=Ae,exports.collectSpecificationResources=cu,exports.copyToClipboard=Xt,exports.createActionIdentity=Jt,exports.createBackgroundActionsStore=Nt,exports.createDownload=Yt,exports.createIframeVaultBridge=Pl,exports.createLocalForageBackgroundActionPersistence=Bt,exports.createManifestEditorCanvasProgressApi=je,exports.createManifestEditorTagsApi=Ta,exports.createPluginRuntimeApi=An,exports.createPluginStore=Ln,exports.createPreviewVault=kr,exports.createTrackingCanvasProgressApi=Me,exports.detectMedia=ko,exports.disablePluginInConfig=un,exports.editBasedOnResource=Os,exports.enablePluginAndDependenciesInConfig=jn,exports.enablePluginInConfig=ln,exports.ensureProjectNote=Ur,exports.evaluateSpecifications=su,exports.extendApp=en,exports.filterSupportedPanels=ol,exports.getAvailableBackgroundActionGroups=Je,exports.getBackgroundActionInstanceKey=He,exports.getCanvasProgressStatus=Te,exports.getCanvasProgressStatusFromState=Ee,exports.getDefaultLayoutState=El,exports.getDefaultPanelState=Tl,exports.getEffectivePluginSettings=kn,exports.getEmptyPluginState=rn,exports.getEnabledPluginsForApp=wn,exports.getFormat=Fo,exports.getImageDimensions=Io,exports.getManifestNomalized=qt,exports.getPluginCompatibilityReason=xn,exports.getPluginDefaultSettings=On,exports.getPluginSelectionSource=Cn,exports.getPluginSettingsFromConfig=Tn,exports.getPresetOnboardingDismissalKey=mo,exports.getProjectNotebook=Rr,exports.getPropertyPolicy=ou,exports.getResourceTag=ba,exports.getResourceTagGroups=Sa,exports.getResourceTags=ga,exports.getResourceTagsFromState=_a,exports.getSelectedPresetTemplate=cr,exports.getSupportedPanelFallback=sl,exports.getTerminologyLabel=au,exports.getValueAtPath=eu,exports.hasMeaningfulValue=nu,exports.hasPreviewOption=Pi,exports.hasResourceTag=Ca,exports.isLazyPlugin=gn,exports.isMappedPlugin=hn,exports.isPinnableState=qo,exports.isPluginCompatible=bn,exports.isPluginSelected=Sn,exports.layoutReducer=wl,exports.mapApp=Qt,exports.mapLazyPlugin=mn,exports.mapPlugin=pn,exports.mergeBackgroundActionDefinitions=Ue,exports.mergeConfig=ce,exports.mergeLocalisation=ne,exports.mergePartialConfig=se,exports.mergePresetConfig=$t,exports.mergeProviderPlugins=yn,exports.mergeUiI18n=B,exports.normaliseBackgroundActionError=Ge,exports.normaliseJsonValue=ru,exports.normalisePlugin=_n,exports.normalisePluginAppConfig=sn,exports.normalisePluginAppsConfig=cn,exports.normalisePlugins=vn,exports.normaliseSpecificationPath=Ql,exports.notebookResourceInput=Vr,exports.panelIds=cl,exports.panelSizing=Jo,exports.parseNotebookMarkdown=zr,exports.pluginAppConfigEquals=fn,exports.polygonToBoundingBox=Eo,exports.projectNotebookSources=Hr,exports.randomId=Zt,exports.removeResourceTag=xa,exports.renderHelper=Yo,exports.resetPluginInConfig=dn,exports.resetPluginSettingsInConfig=Dn,exports.runBackgroundAction=It,exports.seedProjectNotebook=Br,exports.setCanvasProgressStatus=De,exports.setCanvasProgressStatuses=ke,exports.setPluginSettingsInConfig=En,exports.setResourceTags=va,exports.setValueAtPath=tu,exports.shellTaskMessage=W,exports.shellUiI18nSchema=re,exports.sortBackgroundActionDefinitions=We,exports.specificationJsonEquals=iu,exports.specificationPathEquals=$l,exports.toggleResourceTag=wa,exports.useAnnotationCreatorState=yc,exports.useAnnotationPageEditor=$i,exports.useApp=q,exports.useAppInstance=or,exports.useAppMenu=xo,exports.useAppMenuItem=So,exports.useAppResource=J,exports.useAppResourceInstance=vr,exports.useAppState=sr,exports.useApps=pr,exports.useAtlasStore=wo,exports.useAvailableBackgroundActions=Wa,exports.useAvailableLayouts=Dr,exports.useBackgroundActionFormatter=Ha,exports.useBackgroundActionHistory=Kt,exports.useBackgroundActionInstance=Gt,exports.useBackgroundActionsStore=K,exports.useBackgroundActionsStoreApi=Wt,exports.useCanvasProgressActions=Pe,exports.useCanvasProgressStatus=Ne,exports.useCollectionEditor=Zi,exports.useConfig=U,exports.useCreatingResource=Yi,exports.useCreator=os,exports.useCustomContextMenu=Zs,exports.useDecayState=js,exports.useEditingContext=Li,exports.useEditingResource=qi,exports.useEditingResourceStack=Ji,exports.useEditingStack=Ki,exports.useEditor=ea,exports.useEmitter=Cc,exports.useEnabledPlugins=Gn,exports.useEvent=wc,exports.useGenericEditor=Qi,exports.useHighlightedImageResource=Lo,exports.useHoverHighlightImageResource=zo,exports.useInitialData=us,exports.useInlineCreator=ss,exports.useLayoutActions=Tr,exports.useLayoutMode=Er,exports.useLayoutProvider=Or,exports.useLayoutState=wr,exports.useLocalStorage=l.useLocalStorage,exports.useManifestEditor=Xi,exports.useMatchMedia=Tc,exports.useNotebookBrowserPlugins=Jr,exports.useOpenPresetOnboarding=ho,exports.useOptionalLocalStorage=l.useOptionalLocalStorage,exports.useOptionalPluginStoreApi=Vn,exports.useOptionalResource=zi,exports.usePanelActions=xl,exports.usePluginActions=Kn,exports.usePluginConfigApi=Yn,exports.usePluginRuntimeApi=qn,exports.usePluginSettings=Jn,exports.usePluginStoreApi=Hn,exports.usePlugins=Wn,exports.usePresetTemplateSelection=lr,exports.usePreviewContext=xi,exports.usePreviewHistory=Pr,exports.usePreviewVault=Ar,exports.usePreviewWindow=Bl,exports.usePreviews=bi,exports.useProjectNotebook=Kr,exports.useResolvedPluginApp=Xn,exports.useResource=Ri,exports.useResourceContextMenuItems=Ys,exports.useResourceTagActions=Da,exports.useResourceTags=Ea,exports.useSaveConfig=de,exports.useSaveVault=Ec,exports.useSetCustomTitle=Qo,exports.useSpecificationPropertyPolicy=zu,exports.useSpecificationReport=Lu,exports.useSpecificationTerminology=Ru,exports.useSpecifications=Iu,exports.useSvgTools=Dc,exports.useTask=Wu,exports.useTaskDispatch=qu,exports.useTaskEvent=Gu,exports.useTaskRunner=Ju,exports.useTemporaryHighlight=Ro,exports.useToasts=Ia,exports.validateShellUiI18n=V;
|
|
1532
1557
|
//# sourceMappingURL=index.cjs.map
|