@obelism/content 0.26.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -10
- package/dist/bin/content.js +1 -1
- package/dist/bridge.d.mts +55 -11
- package/dist/bridge.d.mts.map +1 -1
- package/dist/bridge.d.ts +55 -11
- package/dist/bridge.d.ts.map +1 -1
- package/dist/bridge.global.js +347 -29
- package/dist/bridge.js +1799 -313
- package/dist/bridge.mjs +1798 -314
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/{types-m08zzac6.d.ts → types-c7464prw.d.ts} +22 -2
- package/dist/{types-m08zzac6.d.ts.map → types-c7464prw.d.ts.map} +1 -1
- package/package.json +1 -1
package/dist/bridge.global.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
!/*! Obelism Content bridge (@obelism/content), MIT. https://content.obelism.studio/docs/guides/canvas */function(){"use strict";var e;let t="data-cms-uid",r="data-cms-entry",
|
|
1
|
+
!/*! Obelism Content bridge (@obelism/content), MIT. https://content.obelism.studio/docs/guides/canvas */function(){"use strict";var e;let t="data-cms-uid",r="data-cms-entry",n="data-cms-product",a="data-cms-collection",i="cms_environment",o={clicked:"{rate}% clicked",title:"{clickers} of {viewers} visitors of its page clicked it in the last 30 days ({clicks} clicks)"},s=(e,t)=>e.replace(/\{(\w+)\}/g,(e,r)=>r in t?String(t[r]):e),l=`
|
|
2
2
|
:host { all: initial; }
|
|
3
3
|
.layer {
|
|
4
4
|
position: fixed; inset: 0; pointer-events: none;
|
|
5
5
|
z-index: 2147483646;
|
|
6
|
-
font: 600 12px/1 '
|
|
6
|
+
font: 600 12px/1 'Geist', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
7
7
|
-webkit-font-smoothing: antialiased;
|
|
8
8
|
}
|
|
9
9
|
.badge {
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
display: inline-flex; gap: 6px; align-items: center;
|
|
12
12
|
padding: 6px 10px; white-space: nowrap; cursor: pointer;
|
|
13
13
|
pointer-events: auto; border: 0;
|
|
14
|
-
color: rgb(
|
|
15
|
-
border-radius: 5em; box-shadow: 0 6px 16px -8px rgb(
|
|
14
|
+
color: rgb(242 240 236); background: rgb(23 22 20 / .88);
|
|
15
|
+
border-radius: 5em; box-shadow: 0 6px 16px -8px rgb(23 22 20 / .5);
|
|
16
16
|
font: inherit;
|
|
17
17
|
}
|
|
18
18
|
.badge::before {
|
|
@@ -22,30 +22,26 @@
|
|
|
22
22
|
.badge[data-place='beside'] { transform: translateY(-50%); }
|
|
23
23
|
.badge[data-place='above'] { transform: translate(-100%, -100%); }
|
|
24
24
|
.badge:focus-visible { outline: 2px solid rgb(212 130 30); outline-offset: 2px; }
|
|
25
|
-
`,d=(e,t)=>e.height>=64?{place:"inside",top:Math.max(e.top,0)+8,left:e.right-8}:e.right+8+140<=t?{place:"beside",top:e.top+e.height/2,left:e.right+8}:{place:"above",top:e.top-4,left:e.right},c=/(-?\d*\.?\d+)(?:s|l|d)?vh\b/g,p=(e,t)=>(c.lastIndex=0,c.test(e))?e.replace(c,(e,r)=>`${Math.round(Number(r)*t/100*100)/100}px`):null,g=(e,t)=>{for(let r=0;r<e.length;r++){let o=e.item(r),n=p(e.getPropertyValue(o),t);null!==n&&e.setProperty(o,n,e.getPropertyPriority(o))}},u=(e,t)=>{for(let r of Array.from(e)){let{style:e,cssRules:o}=r;e&&g(e,t),o&&u(o,t)}},h="obelism-content-bridge",m="#d58a1f",b=(e="")=>`${e}[${t}]{cursor:pointer;transition:outline-color .15s}${e}[${t}]:hover{outline:2px dashed ${m};outline-offset:2px}${e}[${t}][data-cms-selected]{outline:2px solid ${m};outline-offset:2px}`,f={features:[],selectedUid:null,prompting:!1,canUndo:!1,unsaved:!1,saving:!1,publishing:!1,selecting:!1,stats:{},statsVisible:!1},v=()=>{let e={update:new Set,saved:new Set,published:new Set,change:new Set};return{listeners:e,on:(t,r)=>(e[t].add(r),()=>{e[t].delete(r)}),emit(t,r){for(let o of e[t])try{o(r)}catch(e){console.error("[@obelism/content bridge]",e)}}}},y=()=>Promise.reject(Error("Save and publish in the visual editor itself")),x=()=>Promise.reject(Error("Only while signed in to edit on the site")),w={prompt:()=>Promise.reject(Error("Prompts only work inside the visual editor")),createPage:()=>Promise.reject(Error("New pages are made on the site itself")),createProductPage:()=>Promise.reject(Error("Product pages are made on the site itself")),createCollectionPage:()=>Promise.reject(Error("Collection pages are made on the site itself")),view:x,applyJson:x,openForm:(e,t={})=>(queueMicrotask(()=>t.onError?.("Only while signed in to edit on the site")),{close:()=>{}}),pages:x,openPage:()=>{},undo:()=>{},save:y,publish:y,signOut:()=>{},select:()=>{},setSelecting:()=>{}},k=e=>"number"==typeof e&&Number.isFinite(e)&&e>=0,E=e=>`[${t}="${e.replace(/["\\]/g,"\\$&")}"]`,C=(e,t)=>{let r=v();e.on("saved",()=>r.emit("saved",{})),e.on("published",()=>r.emit("published",{}));let o=!1;return{isEditing:e.isEditing,mode:e.isEditing?"editor":null,entryId:e.entryId,environment:t.get(a),product:null,collection:null,on:(t,n)=>("update"!==t||o||(o=!0,e.on("update",e=>{let t=e?.entry;t&&r.emit("update",{entry:t,selectedUid:null})})),r.on(t,n)),getState:()=>f,...w,destroy:()=>{}}},P={open:"Edit with a prompt",placeholder:"Describe a change, e.g. “make the heading shorter”",send:"Apply",undo:"Undo",close:"Close",minimize:"Minimize, to see the page",expand:"Expand",scopeEntry:"Whole page",scopeNoPage:"Whole page",scopeBlock:"Selected block",clearBlock:"Edit the whole page instead",working:"Working on it…",save:"Save",publish:"Publish",saving:"Saving…",publishing:"Publishing…",saved:"Saved as a draft",published:"Published",unsaved:"Unsaved changes",signOut:"Exit editing",viewingDrafts:"Viewing drafts",selectHint:"Click a block to change only that block",newPage:"New page",newPageCancel:"Edit this page instead",newPagePlaceholder:"Describe the new page, e.g. “a pricing page for agencies”",path:"Path",pathPlaceholder:"/pricing",creating:"Writing the page…",created:"Opening the new page…",modes:"Edit with",modePrompt:"Prompt",form:"Form",formTitle:"The content form",formLoading:"Opening the form…",pages:"Pages",pagesSearch:"Find a page",pagesLoading:"Loading pages…",pagesEmpty:"No pages match",pageCurrent:"This page",pageDraft:"Draft",pageChanged:"Changed",addProductPage:"Add a product page",addingProductPage:"Making the product page…",addedProductPage:"Opening the product page…",productPageHint:"This product has no page yet. Add one for what the store doesn’t say.",addCollectionPage:"Add a collection page",addingCollectionPage:"Making the collection page…",addedCollectionPage:"Opening the collection page…",collectionPageHint:"This collection has no page yet. Add one for what goes around its products."},A="obelism-content-prompt-side",L={page:'<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/>',newPage:'<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="M9 15h6"/><path d="M12 18v-6"/>',block:'<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 8h10"/><path d="M7 12h6"/>',undo:'<path d="M9 14 4 9l5-5"/><path d="M4 9h10.5a5.5 5.5 0 0 1 0 11H11"/>',close:'<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',minimize:'<path d="m6 9 6 6 6-6"/>',expand:'<path d="m18 15-6-6-6 6"/>',chevrons:'<path d="m7 15 5 5 5-5"/><path d="m7 9 5-5 5 5"/>',search:'<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>',check:'<path d="M20 6 9 17l-5-5"/>',mark:'<path d="M12 3v18M3 12h18"/><g fill="currentColor" stroke="none"><circle cx="7" cy="7" r="1.75"/><circle cx="17" cy="7" r="1.75"/><circle cx="7" cy="17" r="1.75"/><circle cx="17" cy="17" r="1.75"/></g>',send:'<path d="M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z"/><path d="M6 12h16"/>'},S=`
|
|
25
|
+
`,d=(e,t)=>e.height>=64?{place:"inside",top:Math.max(e.top,0)+8,left:e.right-8}:e.right+8+140<=t?{place:"beside",top:e.top+e.height/2,left:e.right+8}:{place:"above",top:e.top-4,left:e.right},p=/(-?\d*\.?\d+)(?:s|l|d)?vh\b/g,c=(e,t)=>(p.lastIndex=0,p.test(e))?e.replace(p,(e,r)=>`${Math.round(Number(r)*t/100*100)/100}px`):null,u=(e,t)=>{for(let r=0;r<e.length;r++){let n=e.item(r),a=c(e.getPropertyValue(n),t);null!==a&&e.setProperty(n,a,e.getPropertyPriority(n))}},g=(e,t)=>{for(let r of Array.from(e)){let{style:e,cssRules:n}=r;e&&u(e,t),n&&g(n,t)}},h="obelism-content-bridge",b="#d58a1f",m=(e="")=>`${e}[${t}]{cursor:pointer;transition:outline-color .15s}${e}[${t}]:hover{outline:2px dashed ${b};outline-offset:2px}${e}[${t}][data-cms-selected]{outline:2px solid ${b};outline-offset:2px}`,f={features:[],selectedUid:null,prompting:!1,canUndo:!1,unsaved:!1,saving:!1,publishing:!1,selecting:!1,stats:{},statsVisible:!1},v=()=>{let e={update:new Set,saved:new Set,published:new Set,change:new Set};return{listeners:e,on:(t,r)=>(e[t].add(r),()=>{e[t].delete(r)}),emit(t,r){for(let n of e[t])try{n(r)}catch(e){console.error("[@obelism/content bridge]",e)}}}},x=()=>Promise.reject(Error("Save and publish in the visual editor itself")),y=()=>Promise.reject(Error("Only while signed in to edit on the site")),w={prompt:()=>Promise.reject(Error("Prompts only work inside the visual editor")),createPage:()=>Promise.reject(Error("New pages are made on the site itself")),createProductPage:()=>Promise.reject(Error("Product pages are made on the site itself")),createCollectionPage:()=>Promise.reject(Error("Collection pages are made on the site itself")),view:y,applyJson:y,openForm:(e,t={})=>(queueMicrotask(()=>t.onError?.("Only while signed in to edit on the site")),{close:()=>{}}),pages:y,openPage:()=>{},undo:()=>{},save:x,publish:x,signOut:()=>{},select:()=>{},setSelecting:()=>{}},k=e=>"number"==typeof e&&Number.isFinite(e)&&e>=0,E=e=>`[${t}="${e.replace(/["\\]/g,"\\$&")}"]`,C=(e,t)=>{let r=v();e.on("saved",()=>r.emit("saved",{})),e.on("published",()=>r.emit("published",{}));let n=!1;return{isEditing:e.isEditing,mode:e.isEditing?"editor":null,entryId:e.entryId,environment:t.get(i),product:null,collection:null,on:(t,a)=>("update"!==t||n||(n=!0,e.on("update",e=>{let t=e?.entry;t&&r.emit("update",{entry:t,selectedUid:null})})),r.on(t,a)),getState:()=>f,...w,destroy:()=>{}}},A=(e,t,r={},...n)=>{let a=e.createElement(t);for(let t of(Object.assign(a,r),n))a.appendChild("string"==typeof t?e.createTextNode(t):t);return a},N='<rect x="10" y="2" width="4" height="20"/><rect x="2" y="10" width="20" height="4"/><circle cx="6" cy="6" r="2.6"/><circle cx="18" cy="6" r="2.6"/><circle cx="6" cy="18" r="2.6"/><circle cx="18" cy="18" r="2.6"/>',L='<circle cx="6" cy="6" r="2.2"/><circle cx="18" cy="6" r="2.2"/><circle cx="12" cy="12" r="2.2" class="accent"/><circle cx="6" cy="18" r="2.2"/><circle cx="18" cy="18" r="2.2"/>',P=(e,t,r)=>{let n=A(e,"span",{className:t});return n.setAttribute("aria-hidden","true"),n.innerHTML=`<svg viewBox="0 0 24 24">${r}</svg>`,n},S=(e,t)=>e.replace(/\{(\w+)\}/g,(e,r)=>r in t?String(t[r]):e),$={page:'<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/>',newPage:'<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="M9 15h6"/><path d="M12 18v-6"/>',block:'<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 8h10"/><path d="M7 12h6"/>',undo:'<path d="M9 14 4 9l5-5"/><path d="M4 9h10.5a5.5 5.5 0 0 1 0 11H11"/>',close:'<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',minimize:'<path d="m6 9 6 6 6-6"/>',expand:'<path d="m18 15-6-6-6 6"/>',chevrons:'<path d="m7 15 5 5 5-5"/><path d="m7 9 5-5 5 5"/>',search:'<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>',check:'<path d="M20 6 9 17l-5-5"/>',mark:`<g fill="currentColor" stroke="none">${N}</g>`,send:'<path d="M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z"/><path d="M6 12h16"/>',arrowUp:'<path d="M12 19V5"/><path d="m5 12 7-7 7 7"/>',dash:'<path d="M5 12h14"/>',eye:'<path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z"/><circle cx="12" cy="12" r="3"/>',eyeOff:'<path d="M10.7 5.1A10 10 0 0 1 12 5c6.5 0 10 7 10 7a17 17 0 0 1-2.2 3.2"/><path d="M6.6 6.6A17 17 0 0 0 2 12s3.5 7 10 7a9.7 9.7 0 0 0 5.4-1.6"/><path d="M9.9 9.9a3 3 0 0 0 4.2 4.2"/><path d="m2 2 20 20"/>',plus:'<path d="M5 12h14"/><path d="M12 5v14"/>',scope:'<rect x="3" y="3" width="18" height="18" rx="3" stroke-dasharray="3 3"/>',alert:'<circle cx="12" cy="12" r="10"/><path d="M12 8v4"/><path d="M12 16h.01"/>'},M=(e,t)=>P(e,"icon",$[t]),U=(e,t,r,{onReady:n,onError:a,onEscape:i})=>{let o=null,s=!1,l=null;return{get mounted(){return null!==o},get loading(){return s},get error(){return l},mount(){s=!0,l=null;let d=e.openForm(t,{title:r,onReady:()=>{o===d&&(s=!1,n())},onError:e=>{o===d&&(s=!1,l=e,a(e))},onEscape:()=>{o===d&&i?.()}});o=d},unmount(){o?.close(),o=null,s=!1,l=null}}},z={open:"Edit with a prompt",placeholder:"Describe a change, like “make it warmer”",send:"Apply",undo:"Undo",minimize:"Minimize, to see the page",scopeEntry:"Whole page",working:"Working on it…",publish:"Publish",saving:"Saving…",publishing:"Publishing…",saved:"Saved as a draft",published:"Published",unsaved:"Unsaved changes",signOut:"Exit",viewingDrafts:"Viewing drafts",newPage:"New page",newPageCancel:"Edit this page instead",newPagePlaceholder:"Describe the new page, e.g. “a pricing page for agencies”",path:"Path",pathPlaceholder:"/pricing",creating:"Writing the page…",created:"Opening the new page…",modes:"Edit with",modePrompt:"Ask",form:"Edit fields",formTitle:"The content form",formLoading:"Opening the form…",pages:"Pages",pagesSearch:"Find a page",pagesLoading:"Loading pages…",pagesEmpty:"No pages match",pageCurrent:"This page",pageDraft:"Draft",pageChanged:"Changed",addProductPage:"Add a product page",addingProductPage:"Making the product page…",addedProductPage:"Opening the product page…",productPageHint:"This product has no page yet. Add one for what the store doesn’t say.",addCollectionPage:"Add a collection page",addingCollectionPage:"Making the collection page…",addedCollectionPage:"Opening the collection page…",collectionPageHint:"This collection has no page yet. Add one for what goes around its products."},I={...z,close:"Close",expand:"Expand",scopeNoPage:"Whole page",scopeBlock:"Selected block",clearBlock:"Edit the whole page instead",save:"Save",selectHint:"Click a block to change only that block"},O={...z,editor:"Obelism editor",editing:"Editing",hideOutlines:"Show the page without outlines",environment:"Environment",envProduction:"live",scopeNoteBlock:"Working on {name}. Click another block to switch.",scopeNotePage:"Working on the whole page. Click a block to change only that block.",block:"Block",previewChip:"{name} \xb7 preview",askIntro:"Describe a change and Obelism shows it on the page. Nothing is stored until you keep it and save.",you:"You",obelism:"Obelism",suggested:"Suggested by Obelism",keep:"Keep it",retry:"Try another",retryPrompt:"{prompt}\n\nWrite a different version than the last one.",kept:"Kept",undone:"Undone",before:"Before",after:"After",emptyValue:"Empty",moreChanges:"{count} more changed",keepFirst:"Keep or undo the suggestion to save",keepBeforeFields:"Keep or undo the suggestion before editing fields.",saveDraft:"Save draft",upToDate:"No unsaved changes",saveFailed:"Couldn’t save",publishFailed:"Couldn’t publish",tryAgain:"Try again"},j=(e,t,r,{onLoad:n,onClose:a})=>{let i=A(e,"input",{type:"text",placeholder:r.pagesSearch,autocomplete:"off",spellcheck:!1});i.setAttribute("role","combobox"),i.setAttribute("aria-label",r.pagesSearch),i.setAttribute("aria-autocomplete","list"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-controls","obelism-pages");let o=A(e,"label",{className:"search"},M(e,"search"),i),s=A(e,"ul",{className:"options",id:"obelism-pages"});s.setAttribute("role","listbox"),s.setAttribute("aria-label",r.pages);let l=A(e,"p",{className:"empty"}),d=null,p=null,c=null,u=0,g=()=>{let e=i.value.trim().toLowerCase();return(d??[]).filter(t=>!e||t.name.toLowerCase().includes(e)||t.url.toLowerCase().includes(e)||`/${t.path}`.toLowerCase().includes(e))},h=e=>{if(e.entryId===t.entryId)return a();t.openPage(e)},b=()=>{let n=g();u=Math.max(0,Math.min(u,n.length-1)),s.textContent="",n.forEach((n,a)=>{let i=A(e,"li",{className:`option${a===u?" active":""}`,id:`obelism-page-${a}`},A(e,"span",{className:"option-text"},A(e,"span",{textContent:n.name}),A(e,"span",{className:"option-path",textContent:n.url})));if(i.setAttribute("role","option"),i.setAttribute("aria-selected",String(a===u)),"published"!==n.status&&i.appendChild(A(e,"span",{className:"badge",textContent:"draft"===n.status?r.pageDraft:r.pageChanged})),n.entryId===t.entryId){i.setAttribute("aria-current","page");let t=M(e,"check");t.removeAttribute("aria-hidden"),t.setAttribute("role","img"),t.setAttribute("aria-label",r.pageCurrent),i.appendChild(t)}i.addEventListener("click",()=>h(n)),s.appendChild(i)});let a=s.children[u];a?(i.setAttribute("aria-activedescendant",a.id),a.scrollIntoView?.({block:"nearest"})):i.removeAttribute("aria-activedescendant"),l.textContent=(c??(d?"":r.pagesLoading))||(0===n.length?r.pagesEmpty:""),l.hidden=!l.textContent,l.className=`empty${c?" error":""}`},m=()=>(p??(p=t.pages().then(e=>{d=e,c=null,b(),n()},e=>{p=null,c=e instanceof Error?e.message:String(e),b(),n()})),p);return i.addEventListener("input",()=>{u=0,b()}),i.addEventListener("keydown",e=>{let t=s.children.length;if("ArrowDown"===e.key||"ArrowUp"===e.key){if(e.preventDefault(),0===t)return;u=(u+("ArrowDown"===e.key?1:-1)+t)%t,b()}else if("Enter"!==e.key||e.isComposing)"Escape"===e.key&&(e.preventDefault(),a());else{e.preventDefault();let t=g()[u];t&&h(t)}}),{searchRow:o,search:i,list:s,note:l,get pages(){return d},get error(){return c},current:()=>d?.find(({entryId:e})=>e===t.entryId)??null,fetch:m,forget(){d=null,p=null},reset(){i.value="",u=Math.max(0,(d??[]).findIndex(({entryId:e})=>e===t.entryId)),m(),b()},render:b}},R=e=>e instanceof Error?e.message:String(e),D=(e,t,r)=>{let n="site"===e.mode,a=n&&t.features.includes("create"),i=n&&null===e.entryId,o=i&&a?e.product?"product":e.collection?"collection":null:null;return{site:n,canCreate:a,pageless:i,shopHere:o,onlyNew:i&&a&&!o&&!r}},T=(e,t)=>"collection"===t?{add:e.addCollectionPage,adding:e.addingCollectionPage,hint:e.collectionPageHint}:{add:e.addProductPage,adding:e.addingProductPage,hint:e.productPageHint},q=async(e,t)=>{try{if(e.product)return await e.createProductPage(),{text:t.addedProductPage,error:!1};return await e.createCollectionPage(),{text:t.addedCollectionPage,error:!1}}catch(e){return{text:R(e),error:!0}}},F=async(e,t)=>{try{return await e[t](),null}catch(e){return R(e)}},B="obelism-content-prompt-side",H=`
|
|
26
26
|
:host { all: initial; }
|
|
27
27
|
* { box-sizing: border-box; font: inherit; color: inherit; margin: 0; }
|
|
28
28
|
.root {
|
|
29
|
-
--
|
|
30
|
-
--
|
|
31
|
-
--
|
|
32
|
-
--
|
|
33
|
-
--theme-
|
|
34
|
-
--theme-
|
|
35
|
-
--theme-
|
|
36
|
-
--theme-border-rgb: var(--color-grey-light-rgb);
|
|
37
|
-
--theme-accent-rgb: var(--color-orange-rgb);
|
|
38
|
-
--theme-foreground-muted-rgb: var(--color-grey-mid-rgb);
|
|
39
|
-
--theme-error: #b3261e;
|
|
29
|
+
--theme-foreground-rgb: 23 22 20;
|
|
30
|
+
--theme-background-alt-rgb: 255 255 255;
|
|
31
|
+
--theme-background-actions-rgb: 232 229 223;
|
|
32
|
+
--theme-border-rgb: 138 132 124;
|
|
33
|
+
--theme-accent-rgb: 212 130 30;
|
|
34
|
+
--theme-foreground-muted-rgb: 105 100 94;
|
|
35
|
+
--theme-error: rgb(184 46 46);
|
|
40
36
|
--border-radius-medium: 20px; --border-radius-pill: 5em;
|
|
41
37
|
--ease-roll: cubic-bezier(0.65, 0, 0.35, 1);
|
|
42
|
-
--shadow: 0
|
|
43
|
-
--font-
|
|
44
|
-
Roboto, 'Helvetica Neue', Arial,
|
|
38
|
+
--shadow: 0 0 0 1px rgb(23 22 20 / .08), 0 12px 32px rgb(23 22 20 / .14);
|
|
39
|
+
--font-base: 'Geist', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
|
|
40
|
+
Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
45
41
|
position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
|
|
46
42
|
transition: translate .45s cubic-bezier(0.34, 1.3, 0.64, 1);
|
|
47
43
|
z-index: 2147483647; width: min(640px, calc(100vw - 32px)); color-scheme: light dark;
|
|
48
|
-
font: 400 14px/1.4 var(--font-
|
|
44
|
+
font: 400 14px/1.4 var(--font-base); color: rgb(var(--theme-foreground-rgb));
|
|
49
45
|
-webkit-font-smoothing: antialiased;
|
|
50
46
|
}
|
|
51
47
|
/* Dragged to a side of the screen, it stays there, springing into place. */
|
|
@@ -59,13 +55,13 @@
|
|
|
59
55
|
.pill { touch-action: none; }
|
|
60
56
|
@media (prefers-color-scheme: dark) {
|
|
61
57
|
.root {
|
|
62
|
-
--theme-foreground-rgb:
|
|
63
|
-
--theme-background-alt-rgb:
|
|
64
|
-
--theme-background-actions-rgb:
|
|
65
|
-
--theme-border-rgb:
|
|
66
|
-
--theme-foreground-muted-rgb:
|
|
67
|
-
--theme-error: rgb(
|
|
68
|
-
--shadow: 0
|
|
58
|
+
--theme-foreground-rgb: 242 240 236;
|
|
59
|
+
--theme-background-alt-rgb: 27 26 24;
|
|
60
|
+
--theme-background-actions-rgb: 45 43 40;
|
|
61
|
+
--theme-border-rgb: 112 108 102;
|
|
62
|
+
--theme-foreground-muted-rgb: 160 154 146;
|
|
63
|
+
--theme-error: rgb(240 110 110);
|
|
64
|
+
--shadow: 0 0 0 1px rgb(255 255 255 / .06), 0 12px 32px rgb(0 0 0 / .5);
|
|
69
65
|
}
|
|
70
66
|
}
|
|
71
67
|
.icon { display: inline-flex; flex: none; }
|
|
@@ -206,7 +202,7 @@ button.chip:disabled { opacity: .5; }
|
|
|
206
202
|
.modes button:hover { color: rgb(var(--theme-foreground-rgb)); }
|
|
207
203
|
.modes button[aria-pressed='true'] {
|
|
208
204
|
background: rgb(var(--theme-background-alt-rgb)); color: rgb(var(--theme-foreground-rgb));
|
|
209
|
-
box-shadow: 0 1px 2px rgb(
|
|
205
|
+
box-shadow: 0 1px 2px rgb(23 22 20 / .08);
|
|
210
206
|
}
|
|
211
207
|
.divider { width: 1px; height: 20px; background: rgb(var(--theme-border-rgb) / .3); margin: 0 4px; }
|
|
212
208
|
|
|
@@ -257,4 +253,326 @@ button.chip:disabled { opacity: .5; }
|
|
|
257
253
|
.empty { padding: 8px 12px; color: rgb(var(--theme-foreground-muted-rgb)); }
|
|
258
254
|
.empty.error { color: var(--theme-error); }
|
|
259
255
|
[hidden] { display: none !important; }
|
|
260
|
-
`,N=(e,t,r={},...o)=>{let n=e.createElement(t);for(let t of(Object.assign(n,r),o))n.appendChild("string"==typeof t?e.createTextNode(t):t);return n},M=(e,t)=>{let r=N(e,"span",{className:"icon"});return r.setAttribute("aria-hidden","true"),r.innerHTML=`<svg viewBox="0 0 24 24">${L[t]}</svg>`,r},I=(e,t,r={})=>{let o,n={...P,...r.labels},a=N(e,"div");a.setAttribute("data-obelism-content-prompt","");let i=a.attachShadow({mode:"open"}),l="site"===t.mode,s=N(e,"span",{textContent:n.open}),d=N(e,"button",{className:"pill",type:"button"},s,((o=M(e,"mark")).classList.add("mark"),o)),c=N(e,"span",{className:"pill compact"},`${n.viewingDrafts} \xb7 `),p=N(e,"button",{className:"link",type:"button",textContent:n.signOut});c.appendChild(p);let g=N(e,"p",{className:"status"});g.setAttribute("role","status");let u=N(e,"textarea",{placeholder:n.placeholder,rows:1});u.setAttribute("aria-label",n.open);let h=N(e,"div",{className:"form-loader",textContent:n.formLoading});h.setAttribute("role","status");let m=N(e,"div",{className:"form"},h),b=M(e,"page"),f=M(e,"block"),v=N(e,"span"),y=N(e,"button",{type:"button",title:n.clearBlock});y.setAttribute("aria-label",n.clearBlock),y.appendChild(M(e,"close"));let x=N(e,"span",{className:"chip scope"},b,f,v,y),w=N(e,"button",{className:"action chip",type:"button"},M(e,"undo"),n.undo),k=t=>{let r=N(e,"button",{type:"button",textContent:t});return r.setAttribute("aria-pressed","false"),r},E=k(n.modePrompt),C=k(n.form),L=N(e,"span",{className:"modes"},E,C);L.setAttribute("role","group"),L.setAttribute("aria-label",n.modes);let I=N(e,"button",{className:"action chip",type:"button"},M(e,"newPage"),n.newPage),U=N(e,"button",{className:"action chip product",type:"button"},M(e,"newPage"),n.addProductPage),$=N(e,"button",{type:"button",title:n.newPageCancel});$.setAttribute("aria-label",n.newPageCancel),$.appendChild(M(e,"close"));let O=N(e,"span",{className:"chip scope"},M(e,"newPage"),N(e,"span",{textContent:n.newPage}),$),R=N(e,"input",{type:"text",placeholder:n.pathPlaceholder,autocomplete:"off",spellcheck:!1}),j=N(e,"label",{className:"path"},N(e,"span",{textContent:n.path}),R),z=N(e,"button",{className:"close icon-button",type:"button",title:n.close},M(e,"close"));z.setAttribute("aria-label",n.close);let T=M(e,"minimize"),D=M(e,"expand"),F=N(e,"button",{className:"icon-button",type:"button"},T,D),q=N(e,"button",{className:"action primary icon-button",type:"submit"},N(e,"span",{className:"visually-hidden",textContent:n.send}),M(e,"send"));q.title=n.send;let V=N(e,"span",{className:"divider"}),B=N(e,"div",{className:"toolbar"},x,O,L,w,U,I,N(e,"span",{className:"spacer"}),F,z,V,q),H=N(e,"span",{textContent:n.pages}),W=N(e,"button",{className:"chip page-chip",type:"button",title:n.pages},M(e,"page"),H,M(e,"chevrons"));W.setAttribute("aria-haspopup","listbox"),W.setAttribute("aria-expanded","false"),W.setAttribute("aria-controls","obelism-pages");let Y=N(e,"input",{type:"text",placeholder:n.pagesSearch,autocomplete:"off",spellcheck:!1});Y.setAttribute("role","combobox"),Y.setAttribute("aria-label",n.pagesSearch),Y.setAttribute("aria-autocomplete","list"),Y.setAttribute("aria-expanded","true"),Y.setAttribute("aria-controls","obelism-pages");let X=N(e,"ul",{className:"options",id:"obelism-pages"});X.setAttribute("role","listbox"),X.setAttribute("aria-label",n.pages);let _=N(e,"p",{className:"empty"}),J=N(e,"div",{className:"pages"},N(e,"label",{className:"search"},M(e,"search"),Y),X,_),Z=N(e,"slot");Z.name="actions-footer";let K=N(e,"slot");K.name="actions-bar",r.actions&&(r.actions.slot="actions-bar",a.appendChild(r.actions));let G=N(e,"span",{className:"unsaved"});G.appendChild(N(e,"span",{className:"dot"})),G.appendChild(e.createTextNode(n.unsaved));let Q=N(e,"button",{className:"link",type:"button",textContent:n.signOut}),ee=N(e,"button",{className:"action chip",type:"button",textContent:n.save}),et=N(e,"button",{className:"action chip",type:"button",textContent:n.publish}),er=N(e,"div",{className:"footer"},W,G,N(e,"span",{className:"spacer"}),Z,Q,ee,et),eo=N(e,"form",{className:"panel"},g,j,u,m,B,J,er),en=N(e,"div",{className:"root"},N(e,"div",{className:"bar"},d,c,K),eo);i.append(N(e,"style",{textContent:S}),en);let ea=e.defaultView,ei=e=>{"center"===e?delete en.dataset.side:en.dataset.side=e};ei((()=>{try{let e=ea?.localStorage.getItem(A);return"left"===e||"right"===e?e:"center"}catch{return"center"}})());let el=null,es=!1;en.addEventListener("pointerdown",e=>{if(es=!1,0!==e.button||!e.isPrimary)return;let t=e.target.closest("button, input, textarea, select, iframe, a, label, .pages, .form");if(t&&t!==d)return;let{left:r,right:o}=en.getBoundingClientRect();el={id:e.pointerId,startX:e.clientX,x:e.clientX,velocity:0,time:e.timeStamp,moved:!1,min:Math.min(0,16-r),max:Math.max(0,(ea?.innerWidth??0)-16-o)}}),en.addEventListener("pointermove",e=>{if(!el||e.pointerId!==el.id)return;let t=e.clientX-el.startX;if(!el.moved){if(6>Math.abs(t))return;el.moved=!0,en.classList.add("dragging");try{en.setPointerCapture(e.pointerId)}catch{}}let r=e.timeStamp-el.time;r>0&&(el.velocity=(e.clientX-el.x)/r),el.x=e.clientX,el.time=e.timeStamp;let o=Math.min(Math.max(t,el.min),el.max);en.style.translate=`${o+(t-o)/3}px 0`});let ed=e=>{if(!el||e.pointerId!==el.id)return;let{moved:t,x:r,velocity:o,time:n}=el;if(el=null,!t)return;es=!0;let a=en.getBoundingClientRect().left,i=ea?.innerWidth??0,l=r+(e.timeStamp-n>80?0:Math.min(Math.max(150*o,-120),120)),s=l<i/3?"left":l>2*i/3?"right":"center";ei(s),en.style.translate="";let d=en.getBoundingClientRect().left;en.style.translate=`${a-d}px 0`,en.offsetWidth,en.classList.remove("dragging"),en.style.translate="";try{ea?.localStorage.setItem(A,s)}catch{}};en.addEventListener("pointerup",ed),en.addEventListener("pointercancel",ed),en.addEventListener("click",e=>{es&&(es=!1,e.preventDefault(),e.stopPropagation())},!0);let ec=!1,ep=!1,eg=!1,eu=null,eh=!1,em=null,eb=!1,ef=!1,ev=null,ey=null,ex=null,ew=0,ek=e=>({text:e instanceof Error?e.message:String(e),error:!0}),eE=e=>{let o=e.features.includes("prompt"),a=e.saving||e.publishing,i=e.prompting||a;en.hidden=!o&&!l,d.hidden=ec||!o,c.hidden=o||!l,eo.hidden=!ec||!o;let k=l&&e.features.includes("create"),P=l&&null===t.entryId,A=P&&k?t.product?"product":t.collection?"collection":null:null,S=null!==A,N="collection"===A?{add:n.addCollectionPage,adding:n.addingCollectionPage,hint:n.collectionPageHint}:{add:n.addProductPage,adding:n.addingProductPage,hint:n.productPageHint};U.lastChild.textContent=N.add;let M=P&&k&&!S&&!r.promptWithoutPage;k||(eg=!1),M&&(eg=!0),(eg||P||!l)&&(eh=!1);let z=ec&&o&&eh;z&&!em?eA():!z&&em&&eL();let Y=S&&!eg;s.textContent=Y?N.add:M?n.newPage:n.open,$.hidden=M,x.hidden=eg||Y,O.hidden=!eg,U.hidden=!Y,U.disabled=i,I.hidden=eg||eh||!k,I.disabled=i,ep&&(ef=!1),j.hidden=!eg||ef||ep,R.disabled=i,u.hidden=eh||ef||ep||Y,m.hidden=!eh||ef||ep,m.classList.toggle("loading",eb),h.hidden=!eb,B.hidden=ef,J.hidden=!ef,u.placeholder=eg?n.newPagePlaceholder:n.placeholder,v.textContent=e.selectedUid?n.scopeBlock:P?n.scopeNoPage:n.scopeEntry,y.hidden=!e.selectedUid,b.hidden=!!e.selectedUid,f.hidden=!e.selectedUid,L.hidden=!l||eg||P||!e.features.includes("form"),E.setAttribute("aria-pressed",String(!eh)),C.setAttribute("aria-pressed",String(eh)),L.querySelectorAll("button").forEach(e=>{e.disabled=i}),w.hidden=eg||!e.canUndo,w.disabled=i,q.hidden=eh||ep||Y,V.hidden=eh||ep||Y;let X=ep?n.expand:n.minimize;F.title=X,F.setAttribute("aria-label",X),F.setAttribute("aria-expanded",String(!ep)),T.hidden=ep,D.hidden=!ep,q.disabled=i||""===u.value.trim()||eg&&""===R.value.trim(),u.disabled=i,ee.hidden=!e.features.includes("save")||P,ee.disabled=i||!e.unsaved,ee.textContent=e.saving?n.saving:n.save,et.hidden=!e.features.includes("publish")||P,et.disabled=i,et.textContent=e.publishing?n.publishing:n.publish,Q.hidden=!l||!1===r.signOut,p.hidden=!1===r.signOut,r.actions&&(r.actions.slot=ec&&o?"actions-footer":"actions-bar"),er.hidden=!l,G.hidden=!e.unsaved,W.hidden=!l,W.setAttribute("aria-expanded",String(ef)),H.textContent=ev?.find(({entryId:e})=>e===t.entryId)?.name??n.pages;let _=eh&&eb&&!ef,Z=e.prompting,K=e.prompting?eg?n.creating:Y?N.adding:n.working:_?"":eu?.text??(Y?N.hint:!l||eg||ef||e.selectedUid?"":n.selectHint);g.textContent=K,g.hidden=!K||ep,g.className=`status${Z?" working":""}${!i&&!_&&eu?.error?" error":""}`},eC=()=>eE(t.getState()),eP=()=>{u.style.height="auto",u.style.height=`${u.scrollHeight}px`},eA=()=>{eb=!0,m.classList.add("loading");let e=t.openForm(m,{title:n.formTitle,onReady:()=>{em===e&&(eb=!1,eu=null,eC())},onError:t=>{em===e&&(eb=!1,eu={text:t,error:!0},eC())}});em=e},eL=()=>{em?.close(),em=null,eb=!1},eS=e=>{eh!==e&&(eh=e,eu=null,eC(),eh||u.focus())},eN=async()=>{if(eh)return;let e=u.value.trim();if(e&&!t.getState().prompting){eu=null;try{if(eg){let r=R.value.trim();if(!r)return R.focus();await t.createPage(r,e),ev=null,ey=null,eu={text:n.created,error:!1}}else{let{summary:r}=await t.prompt(e);eu={text:r,error:!1}}u.value="",eP()}catch(e){eu=ek(e)}eC(),u.focus()}},eM=()=>(ey??(ey=t.pages().then(e=>{ev=e,ex=null,eU(),eC()},e=>{ey=null,ex=ek(e).text,eU()})),ey),eI=()=>{let e=Y.value.trim().toLowerCase();return(ev??[]).filter(t=>!e||t.name.toLowerCase().includes(e)||t.url.toLowerCase().includes(e)||`/${t.path}`.toLowerCase().includes(e))},eU=()=>{let r=eI();ew=Math.max(0,Math.min(ew,r.length-1)),X.textContent="",r.forEach((r,o)=>{let a=r.entryId===t.entryId,i=N(e,"li",{className:`option${o===ew?" active":""}`,id:`obelism-page-${o}`},N(e,"span",{className:"option-text"},N(e,"span",{textContent:r.name}),N(e,"span",{className:"option-path",textContent:r.url})));if(i.setAttribute("role","option"),i.setAttribute("aria-selected",String(o===ew)),"published"!==r.status&&i.appendChild(N(e,"span",{className:"badge",textContent:"draft"===r.status?n.pageDraft:n.pageChanged})),a){i.setAttribute("aria-current","page");let t=M(e,"check");t.removeAttribute("aria-hidden"),t.setAttribute("role","img"),t.setAttribute("aria-label",n.pageCurrent),i.appendChild(t)}i.addEventListener("click",()=>eO(r)),X.appendChild(i)});let o=X.children[ew];o?(Y.setAttribute("aria-activedescendant",o.id),o.scrollIntoView?.({block:"nearest"})):Y.removeAttribute("aria-activedescendant"),_.textContent=(ex??(ev?"":n.pagesLoading))||(0===r.length?n.pagesEmpty:""),_.hidden=!_.textContent,_.className=`empty${ex?" error":""}`},e$=e=>{eu=null,(ef=e)&&(Y.value="",ew=Math.max(0,(ev??[]).findIndex(({entryId:e})=>e===t.entryId)),eM(),eU()),eC(),(ef?Y:W).focus()},eO=e=>{if(e.entryId===t.entryId)return e$(!1);t.openPage(e)},eR=e=>{(ec=e)||(ef=!1,ep=!1),eC(),l&&t.setSelecting(ec&&!eg),ec&&l&&eM()},ej=e=>{eg=e,eu=null,t.setSelecting(ec&&!eg),eg&&t.select(null),eC(),(eg?R:u).focus()},ez=async e=>{eu=null;try{await t[e](),eu={text:"save"===e?n.saved:n.published,error:!1}}catch(e){eu=ek(e)}eC()};d.addEventListener("click",()=>{eR(!0),eh||(eg?R:u).focus()}),z.addEventListener("click",()=>eR(!1)),F.addEventListener("click",()=>{ep=!ep,eC(),ep||(eh?F:u).focus()}),eo.addEventListener("click",e=>{if(!ep)return;let t=e.target.closest("button");t&&t!==F&&t!==z&&(ep=!1,eC())},!0),ee.addEventListener("click",()=>void ez("save")),et.addEventListener("click",()=>void ez("publish")),Q.addEventListener("click",()=>t.signOut()),p.addEventListener("click",()=>t.signOut()),y.addEventListener("click",()=>t.select(null)),I.addEventListener("click",()=>ej(!0)),U.addEventListener("click",async()=>{eu=null;try{t.product?(await t.createProductPage(),eu={text:n.addedProductPage,error:!1}):(await t.createCollectionPage(),eu={text:n.addedCollectionPage,error:!1})}catch(e){eu=ek(e)}eC()}),$.addEventListener("click",()=>ej(!1)),E.addEventListener("click",()=>eS(!1)),C.addEventListener("click",()=>eS(!0)),W.addEventListener("click",()=>e$(!ef)),R.addEventListener("input",eC),R.addEventListener("keydown",e=>{"Enter"!==e.key||e.isComposing?"Escape"===e.key&&eR(!1):(e.preventDefault(),u.focus())}),Y.addEventListener("input",()=>{ew=0,eU()}),Y.addEventListener("keydown",e=>{let t=X.children.length;if("ArrowDown"===e.key||"ArrowUp"===e.key){if(e.preventDefault(),0===t)return;ew=(ew+("ArrowDown"===e.key?1:-1)+t)%t,eU()}else if("Enter"!==e.key||e.isComposing)"Escape"===e.key&&(e.preventDefault(),e$(!1));else{e.preventDefault();let t=eI()[ew];t&&eO(t)}}),w.addEventListener("click",()=>{eu=null,t.undo()}),eo.addEventListener("submit",e=>{e.preventDefault(),eN()}),u.addEventListener("input",()=>{eP(),eC()}),u.addEventListener("keydown",e=>{"Enter"!==e.key||e.shiftKey||e.isComposing?"Escape"===e.key&&eR(!1):(e.preventDefault(),eN())});let eT=t.on("change",eE);return eC(),e.body.appendChild(a),()=>{eT(),eL(),a.remove()}},U="https://content.obelism.studio",$=/^(?:\/[\w.~-]+)+$/,O=e=>{let{protocol:t}=new URL(e,"https://site.invalid");if("https:"!==t&&"http:"!==t)throw Error(`Not a page address: ${e}`);return e},R=(e,t)=>JSON.stringify(e)===JSON.stringify(t),j=Symbol.for("@obelism/content/bridge"),z=C({isEditing:!1,entryId:null,on:()=>{}},new URLSearchParams),T=({url:e,prompt:c=!0,pagePath:p,productPath:m,collectionPath:y}={})=>{let x;if("u"<typeof window)return z;let P=window;if(P[j])return P[j];if(P.ObelismBridge)x=C(P.ObelismBridge,new URLSearchParams(P.location.search));else{let C=(x=((e,r)=>{let o,n,c,p,m,y=new URLSearchParams(e.location.search),x=e.parent!==e&&y.has("cms_preview"),C=v(),P=[],A={...f,selecting:!0},L=e=>{A={...A,...e},C.emit("change",A)},S={isEditing:x,mode:x?"editor":null,entryId:y.get("cms_entry"),environment:y.get(a),product:null,collection:null,on:C.on,getState:()=>A,...w,destroy:()=>{P.splice(0).forEach(e=>e())}};if(!x)return S;let N=e.document,M=(t,o={})=>{e.parent.postMessage({source:h,type:t,...o},r)},I=N.createElement("style");I.textContent=b(),N.head.appendChild(I),P.push(()=>I.remove());let U=(e,t)=>{if(N.querySelectorAll("[data-cms-selected]").forEach(e=>{e.removeAttribute("data-cms-selected")}),A.selectedUid!==(e??null)&&L({selectedUid:e??null}),!e)return;let r=N.querySelector(E(e));r&&(r.setAttribute("data-cms-selected",""),t&&r.scrollIntoView({behavior:"smooth",block:"center"}))},$=e=>{let r=e.target,o=r?.closest?.(`[${t}]`);if(!o)return;e.preventDefault(),e.stopPropagation();let n=o.getAttribute(t);U(n,!1),M("select",{uid:n})};N.addEventListener("click",$,!0),P.push(()=>N.removeEventListener("click",$,!0));let O=()=>Math.ceil(Math.max(N.documentElement.scrollHeight,N.body?.scrollHeight??0)),R=0,j=()=>{R=O(),M("ready",{url:e.location.href,height:R})},z=e.ResizeObserver;if("function"==typeof z){let e=new z(()=>{let e=O();e!==R&&(R=e,M("size",{height:e}))});e.observe(N.documentElement),N.body&&e.observe(N.body),P.push(()=>e.disconnect())}let T=new Map,D=0,F=e=>{let t=T.get(e);return t?(clearTimeout(t.timer),T.delete(e),0===T.size&&L({prompting:!1}),t):null};S.prompt=(e,t={})=>{let r=e.trim();if(!r)return Promise.reject(Error("Say what to change"));if(!A.features.includes("prompt"))return Promise.reject(Error("The editor does not offer prompts here"));let o=`prompt_${++D}`,n=void 0===t.uid?A.selectedUid:t.uid;return new Promise((e,t)=>{let a=setTimeout(()=>{F(o)?.reject(Error("The editor did not answer in time"))},12e4);T.set(o,{resolve:e,reject:t,timer:a}),L({prompting:!0}),M("prompt",{id:o,prompt:r,uid:n})})},S.undo=()=>M("undo"),S.select=e=>{U(e,!1),M("select",{uid:e})};let q=null;P.push(()=>q?.destroy()),P.push(()=>{for(let e of T.keys())F(e)?.reject(Error("The bridge was destroyed"))});let V=(o=new WeakSet,n=null,c=null,p=!1,m=()=>{if(null!==n){for(let e of Array.from(N.styleSheets)){let t;if(!o.has(e)){try{t=e.cssRules}catch{continue}o.add(e),u(t,n)}}N.querySelectorAll('[style*="vh"]').forEach(e=>{g(e.style,n)})}},{freeze(e){if(null!==n||!(e>0))return;n=e,m();let t=N.defaultView?.MutationObserver;t&&(c=new t(()=>{if(p)return;p=!0;let e=()=>{p=!1,m()};N.defaultView?.requestAnimationFrame?N.defaultView.requestAnimationFrame(e):e()})).observe(N.documentElement,{childList:!0,subtree:!0})},destroy(){c?.disconnect()}});P.push(()=>V.destroy());let B=t=>{if(t.origin!==r||t.source!==e.parent)return;let o=t.data;if(o&&"obelism-content-editor"===o.source){if("connect"===o.type)j();else if("update"===o.type&&o.entry)C.emit("update",{entry:o.entry,selectedUid:o.selectedUid??null}),e.requestAnimationFrame(()=>U(o.selectedUid,!1)),q?.refresh();else if("select"===o.type)U(o.uid,!0);else if("saved"===o.type||"published"===o.type)C.emit(o.type,{}),0===C.listeners.update.size&&e.location.reload();else if("features"===o.type&&Array.isArray(o.features))L({features:o.features.filter(e=>"string"==typeof e)});else if("stats"===o.type)L({stats:(e=>{if(!e||"object"!=typeof e||Array.isArray(e))return{};let t={};for(let[r,o]of Object.entries(e)){let{clicks:e,clickers:n,viewers:a,rate:i}=o??{};k(e)&&k(n)&&k(a)&&k(i)&&(t[r]={clicks:e,clickers:n,viewers:a,rate:i})}return t})(o.stats),statsVisible:!1!==o.visible}),(q||Object.keys(A.stats).length)&&(q??(q=((e,{selector:t,onSelect:r,labels:o})=>{let n=e.document,a={...i,...o},c=n.createElement("div");c.setAttribute("data-obelism-stats","");let p=c.attachShadow({mode:"open"}),g=n.createElement("style");g.textContent=s;let u=n.createElement("div");u.className="layer",p.append(g,u),n.body.appendChild(c);let h={},m=!1,b=null,f=()=>{if(b=null,u.replaceChildren(),u.hidden=!m,!m)return;let o=e.innerHeight;for(let[i,s]of Object.entries(h)){let c=n.querySelector(t(i));if(!c)continue;let p=c.getBoundingClientRect();if(!p.width&&!p.height||p.bottom<0||p.top>o)continue;let g=n.createElement("button");g.type="button",g.className="badge",g.dataset.uid=i,g.textContent=l(a.clicked,{rate:Math.round(100*s.rate)}),g.title=l(a.title,{clickers:s.clickers,viewers:s.viewers,clicks:s.clicks});let{place:h,top:m,left:b}=d(p,e.innerWidth);g.dataset.place=h,g.style.top=`${m}px`,g.style.left=`${b}px`,g.addEventListener("click",()=>r(i)),u.appendChild(g)}},v=()=>{null===b&&m&&(b=e.requestAnimationFrame(f))};e.addEventListener("scroll",v,{capture:!0,passive:!0}),e.addEventListener("resize",v);let y=e.MutationObserver,x="function"==typeof y?new y(v):null;return x?.observe(n.body,{childList:!0,subtree:!0}),{update(t,r){h=t,m=r,null!==b&&(e.cancelAnimationFrame?.(b),b=null),f()},refresh:v,destroy(){null!==b&&e.cancelAnimationFrame?.(b),e.removeEventListener("scroll",v,{capture:!0}),e.removeEventListener("resize",v),x?.disconnect(),c.remove()}}})(e,{selector:E,onSelect:e=>S.select(e)})),q.update(A.stats,A.statsVisible));else if("viewport"===o.type&&"number"==typeof o.height)V.freeze(o.height);else if("promptState"===o.type)L({canUndo:!0===o.canUndo});else if("promptResult"===o.type&&"string"==typeof o.id){let e=F(o.id);if(!e)return;!0===o.ok?e.resolve({summary:"string"==typeof o.summary?o.summary:""}):e.reject(Error("string"==typeof o.error?o.error:"The prompt failed"))}}};return e.addEventListener("message",B),P.push(()=>e.removeEventListener("message",B)),"loading"===N.readyState?(N.addEventListener("DOMContentLoaded",j,{once:!0}),P.push(()=>N.removeEventListener("DOMContentLoaded",j))):j(),S})(P,new URL(e||U).origin)).isEditing||P.parent!==P?null:(e=>{for(let t of e.cookie.split(";")){let[e,...r]=t.trim().split("=");if("obelism_content_editing"===e)try{let e=decodeURIComponent(r.join("="));return $.test(e)?e:null}catch{break}}return null})(P.document);if(C&&(x=((e,a,{pagePath:i=e=>`/${e.replace(/^\/+/,"")}`,productPath:l,collectionPath:s}={})=>{let d=e.document,c=v(),p=[],g=new Map,u=[],m=new Set,y=null,x=null,w=-1/0,k=new Map,C=f,P=e=>{C={...C,...e},c.emit("change",C)},A=()=>P({unsaved:[...g.values()].some(({content:e,saved:t})=>!R(e,t)),canUndo:u.length>0}),L=async(t,r)=>{let o=await e.fetch(`${a}/api/${t}`,void 0===r?{credentials:"same-origin"}:{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json","x-obelism-content":"1"},body:JSON.stringify(r)}),n=await o.json().catch(()=>({}));if(401===o.status)throw P({features:[]}),Error("You were signed out. Sign in again to edit.");if(!o.ok)throw Error("string"==typeof n.error?n.error:`Obelism Content answered ${o.status}`);return n},S=()=>d.querySelector(`[${r}]`)?.getAttribute(r)??null,N=()=>{let e=d.querySelector(`[${o}]`),t=e?.getAttribute(o),r=e?.getAttribute("data-cms-product-handle");return t&&r?{id:t,handle:r}:null},M=()=>{let e=d.querySelector(`[${n}]`),t=e?.getAttribute(n),r=e?.getAttribute("data-cms-collection-handle");return t&&r?{id:t,handle:r}:null},I=e=>{let t=e?d.querySelector(E(e)):null;return t?.closest(`[${r}]`)?.getAttribute(r)??S()},U=()=>{if(!y)return;let e=y.space.locales.map(({code:e})=>e),t=d.documentElement.lang;if(e.includes(t))return t;let r=t.split("-")[0]??"";return e.includes(r)?r:y.space.defaultLocale},$=new Map,j=async e=>{let t=g.get(e);if(t)return t;let r=$.get(e);return r||(r=L(`entries/${encodeURIComponent(e)}`).then(t=>{let r=g.get(e)??{content:t.content,saved:t.content,revision:t.draftRevision};return g.set(e,r),r}).finally(()=>$.delete(e)),$.set(e,r)),r},z=e=>{let t=void 0===e?C.selectedUid:e,r=I(t);if(!r)throw Error("Nothing on this page is marked as an entry: add editable(entry)");return{uid:t,entryId:r}},T=e=>{d.querySelectorAll("[data-cms-selected]").forEach(e=>{e.removeAttribute("data-cms-selected")}),C.selectedUid!==e&&P({selectedUid:e}),e&&d.querySelector(E(e))?.setAttribute("data-cms-selected","")},D=async t=>{if(0===c.listeners.update.size)return;let r=g.get(t)?.content,{entry:o}=await L(`entries/${encodeURIComponent(t)}/preview`,{content:r,locale:U()});c.emit("update",{entry:o,selectedUid:C.selectedUid}),e.requestAnimationFrame(()=>T(C.selectedUid))},F=e=>console.error("[@obelism/content bridge]",e),q=t=>{c.emit(t,{}),0===c.listeners.update.size&&e.location.reload()},V=async()=>{for(let[e,t]of g){if(R(t.content,t.saved))continue;let{draftRevision:r}=await L(`entries/${encodeURIComponent(e)}/save`,{content:t.content,baseRevision:t.revision});t.saved=t.content,t.revision=r,m.add(e)}u.length=0,w=-1/0,A()},B={isEditing:!0,mode:"site",get entryId(){return S()},get product(){return N()},get collection(){return M()},environment:null,on:c.on,getState:()=>C,async prompt(e,t={}){let r=e.trim();if(!r)throw Error("Say what to change");if(!C.features.includes("prompt"))throw Error("You may not edit content here");let{uid:o,entryId:n}=z(t.uid);P({prompting:!0});try{let e=await j(n),t=await L(`entries/${encodeURIComponent(n)}/prompt`,{prompt:r,content:e.content,locale:U(),uid:o});return u.push({entryId:n,content:e.content}),w=-1/0,e.content=t.content,A(),await D(n),{summary:t.summary}}finally{P({prompting:!1})}},async createPage(t,r){let o=r.trim();if(!o)throw Error("Say what the page is for");if(!t.trim())throw Error("Say where the page goes, like /pricing");if(!C.features.includes("create"))throw Error("You may not add pages here");if(C.unsaved)throw Error("Save or undo your changes before adding a page");P({prompting:!0});try{let r=await L("entries",{path:t,prompt:o,locale:U(),from:S()}),n=i(r.path,U()??"");return e.location.assign(O(n)),{summary:r.summary,entryId:r.entryId,path:r.path,url:n}}finally{P({prompting:!1})}},async createProductPage(t=N()??void 0){if(!t)throw Error("Nothing on this page is marked as a product: add editableProduct(product)");if(!C.features.includes("create"))throw Error("You may not add pages here");if(C.unsaved)throw Error("Save or undo your changes before adding a page");P({prompting:!0});try{let r=await L("product-pages",{product:{id:t.id,handle:t.handle}});return e.location.reload(),r}finally{P({prompting:!1})}},async createCollectionPage(t=M()??void 0){if(!t)throw Error("Nothing on this page is marked as a collection: add editableCollection(collection)");if(!C.features.includes("create"))throw Error("You may not add pages here");if(C.unsaved)throw Error("Save or undo your changes before adding a page");P({prompting:!0});try{let r=await L("collection-pages",{collection:{id:t.id,handle:t.handle}});return e.location.reload(),r}finally{P({prompting:!1})}},async view(e={}){let{uid:t,entryId:r}=z(e.uid),o=await j(r),{view:n}=await L(`entries/${encodeURIComponent(r)}/view`,{content:o.content,locale:U(),uid:t});return n},async applyJson(e,t={}){if(!C.features.includes("prompt"))throw Error("You may not edit content here");if(!e||"object"!=typeof e||Array.isArray(e))throw Error("Send the fields to change as an object");let{uid:r,entryId:o}=z(t.uid);P({prompting:!0});try{let t=await j(o),n=await L(`entries/${encodeURIComponent(o)}/apply`,{changes:e,content:t.content,locale:U(),uid:r});return R(n.content,t.content)||(u.push({entryId:o,content:t.content}),w=-1/0,t.content=n.content,A(),await D(o)),{changed:n.changed??[],...n.view&&{view:n.view}}}finally{P({prompting:!1})}},openForm(t,r={}){let{title:o="Content form",onReady:n,onError:a}=r;x?.();let i=!1,l=null,s=null,d=()=>{},p=e=>{i||a?.(e instanceof Error?e.message:String(e))},m=()=>{i||(i=!0,d(),l?.destroy(),x===m&&(x=null))};x=m;let b=()=>{if(i||!l)return;let e=I(C.selectedUid);if(!e)return;let t=g.get(e);if(!t)return void j(e).then(b,p);let r={entryId:e,content:t.content,locale:U(),selectedUid:C.selectedUid};s&&s.entryId===r.entryId&&s.content===r.content&&s.locale===r.locale&&s.selectedUid===r.selectedUid||(s=r,l.show(r))},f=(e,t)=>{let r=t??s?.entryId,o=void 0===r?void 0:g.get(r);if(i||void 0===r||!o||R(e,o.content))return;let n=Date.now();n-w>=1e3&&u.push({entryId:r,content:o.content}),w=n,o.content=e,s?.entryId===r&&(s={...s,content:e}),A(),clearTimeout(k.get(r)),k.set(r,setTimeout(()=>{k.delete(r),D(r).catch(F)},300))};return(async()=>{if(!C.features.includes("form"))throw Error("You may not edit content here");await j(z(void 0).entryId);let{url:r}=await L("form",{});i||(l=((e,t,r,o,n)=>{let a=null;try{a=new URL(r)}catch{}if(!a||!/^https?:$/.test(a.protocol))throw Error("Obelism Content sent no form to open");let i=a.origin,l=t.ownerDocument.createElement("iframe");l.title=o,l.src=r;let s=!1,d=!1,c=null,p=()=>{s&&c&&l.contentWindow?.postMessage({source:h,type:"content",...c},i)},g=setTimeout(()=>{d||n.onError("The form did not open")},3e4),u=()=>{d=!0,clearTimeout(g),n.onReady()},m=e=>{if(e.origin!==i||!l.contentWindow||e.source!==l.contentWindow)return;let t=e.data;if(t&&"obelism-content-form"===t.source)if("ready"===t.type)s=!0,p(),!0!==t.loading&&u();else if("loaded"===t.type)s&&u();else{let e;if("change"!==t.type||!(e=t.content)||"object"!=typeof e||Array.isArray(e))if("height"===t.type){let e=t.height;if("number"==typeof e&&Number.isFinite(e)){let t=Math.round(Math.min(Math.max(e,80),4e3));l.style.height=`min(${t}px, 60vh)`}}else"error"===t.type&&n.onError("string"==typeof t.message&&t.message?t.message:"The form failed");else n.onChange(t.content,"string"==typeof t.entryId?t.entryId:void 0)}};return e.addEventListener("message",m),t.appendChild(l),{show(e){c=e,p()},destroy(){clearTimeout(g),e.removeEventListener("message",m),l.remove()}}})(e,t,"string"==typeof r?r:"",o,{onReady:()=>n?.(),onChange:f,onError:e=>a?.(e)}),d=c.on("change",b),b())})().catch(p),{close:m}},async pages(){let{pages:e}=await L("pages"),t=[U(),y?.space.defaultLocale];return e.flatMap(e=>{let r,o,n=t.find(t=>void 0!==t&&void 0!==e.paths[t])??Object.keys(e.paths)[0],a=void 0===n?void 0:e.paths[n];return void 0===n||void 0===a?[]:[{entryId:e.entryId,name:e.name,contentType:e.contentType,status:e.status,path:a,url:e.product?(r=e.product.handle,l?l(r,n):(y?.productPath??"/products/{handle}").replaceAll("{handle}",encodeURIComponent(r))):e.collection?(o=e.collection.handle,s?s(o,n):(y?.collectionPath??"/collections/{handle}").replaceAll("{handle}",encodeURIComponent(o))):i(a,n),product:e.product??null,collection:e.collection??null}]})},openPage(t){(!C.unsaved||e.confirm("Leave this page and lose the changes you have not saved?"))&&(g.clear(),u.length=0,A(),e.location.assign(O(t.url)))},undo(){let e=u.pop(),t=e&&g.get(e.entryId);e&&t&&(w=-1/0,t.content=e.content,A(),D(e.entryId).catch(F))},async save(){if(!C.features.includes("save"))throw Error("You may not edit content here");P({saving:!0});try{await V()}finally{P({saving:!1})}q("saved")},async publish(){if(!C.features.includes("publish"))throw Error("You may not publish here");P({publishing:!0});try{await V();let e=S(),t=m.size>0?[...m]:e?[e]:[];if(0===t.length)throw Error("Nothing on this page is marked as an entry: add editable(entry)");for(let e of t)await L(`entries/${encodeURIComponent(e)}/publish`,{}),m.delete(e)}finally{P({publishing:!1})}q("published")},signOut(){if(C.unsaved&&!e.confirm("Sign out and lose the changes you have not saved?"))return;g.clear(),A();let t=e.location.pathname+e.location.search;e.location.href=`${a}/logout?return_to=${encodeURIComponent(t)}`},select(e){T(e)},setSelecting(e){e?d.documentElement.setAttribute("data-cms-selecting",""):d.documentElement.removeAttribute("data-cms-selecting"),P({selecting:e})},destroy(){x?.(),k.forEach(e=>clearTimeout(e)),k.clear(),p.splice(0).forEach(e=>e())}},H=d.createElement("style");H.textContent=b("html[data-cms-selecting] "),d.head.appendChild(H),p.push(()=>H.remove()),p.push(()=>d.documentElement.removeAttribute("data-cms-selecting"));let W=e=>{if(!C.selecting)return;let r=e.target,o=r?.closest?.(`[${t}]`);o&&(e.preventDefault(),e.stopPropagation(),T(o.getAttribute(t)))};d.addEventListener("click",W,!0),p.push(()=>d.removeEventListener("click",W,!0));let Y=e=>{C.unsaved&&(e.preventDefault(),e.returnValue="")};return e.addEventListener("beforeunload",Y),p.push(()=>e.removeEventListener("beforeunload",Y)),L("session").then(e=>{y=e,P({features:e.features})}).catch(e=>console.error("[@obelism/content bridge]",e)),B})(P,C,{pagePath:p,productPath:m,collectionPath:y})),x.isEditing&&c){let e=P.document,t=()=>{},r=!1,o=()=>{r||(t=I(e,x,!0===c?{}:c))};e.body?o():e.addEventListener("DOMContentLoaded",o,{once:!0});let n=x.destroy;x.destroy=()=>{r=!0,e.removeEventListener("DOMContentLoaded",o),t(),n()}}}return P[j]=x,x};(e=window).ObelismBridge=T((e=>{let t=e?.dataset.url,r=t||U;if(!t&&e?.src){let t=new URL(e.src);"/bridge.js"===t.pathname&&(r=t.origin)}return{url:r,prompt:e?.dataset.prompt!=="false"}})(document.currentScript)),e.ObelismContent={getContentBridge:T,mountPromptBox:I}}();
|
|
256
|
+
`,_=(e,t,r={})=>{let n,a={...I,...r.labels},i=A(e,"div");i.setAttribute("data-obelism-content-prompt","");let o=i.attachShadow({mode:"open"}),s="site"===t.mode,l=A(e,"span",{textContent:a.open}),d=A(e,"button",{className:"pill",type:"button"},l,((n=M(e,"mark")).classList.add("mark"),n)),p=A(e,"span",{className:"pill compact"},`${a.viewingDrafts} \xb7 `),c=A(e,"button",{className:"link",type:"button",textContent:a.signOut});p.appendChild(c);let u=A(e,"p",{className:"status"});u.setAttribute("role","status");let g=A(e,"textarea",{placeholder:a.placeholder,rows:1});g.setAttribute("aria-label",a.open);let h=A(e,"div",{className:"form-loader",textContent:a.formLoading});h.setAttribute("role","status");let b=A(e,"div",{className:"form"},h),m=M(e,"page"),f=M(e,"block"),v=A(e,"span"),x=A(e,"button",{type:"button",title:a.clearBlock});x.setAttribute("aria-label",a.clearBlock),x.appendChild(M(e,"close"));let y=A(e,"span",{className:"chip scope"},m,f,v,x),w=A(e,"button",{className:"action chip",type:"button"},M(e,"undo"),a.undo),k=t=>{let r=A(e,"button",{type:"button",textContent:t});return r.setAttribute("aria-pressed","false"),r},E=k(a.modePrompt),C=k(a.form),N=A(e,"span",{className:"modes"},E,C);N.setAttribute("role","group"),N.setAttribute("aria-label",a.modes);let L=A(e,"button",{className:"action chip",type:"button"},M(e,"newPage"),a.newPage),P=A(e,"button",{className:"action chip product",type:"button"},M(e,"newPage"),a.addProductPage),S=A(e,"button",{type:"button",title:a.newPageCancel});S.setAttribute("aria-label",a.newPageCancel),S.appendChild(M(e,"close"));let $=A(e,"span",{className:"chip scope"},M(e,"newPage"),A(e,"span",{textContent:a.newPage}),S),z=A(e,"input",{type:"text",placeholder:a.pathPlaceholder,autocomplete:"off",spellcheck:!1}),O=A(e,"label",{className:"path"},A(e,"span",{textContent:a.path}),z),_=A(e,"button",{className:"close icon-button",type:"button",title:a.close},M(e,"close"));_.setAttribute("aria-label",a.close);let V=M(e,"minimize"),W=M(e,"expand"),Y=A(e,"button",{className:"icon-button",type:"button"},V,W),X=A(e,"button",{className:"action primary icon-button",type:"submit"},A(e,"span",{className:"visually-hidden",textContent:a.send}),M(e,"send"));X.title=a.send;let K=A(e,"span",{className:"divider"}),J=A(e,"div",{className:"toolbar"},y,$,N,w,P,L,A(e,"span",{className:"spacer"}),Y,_,K,X),Z=A(e,"span",{textContent:a.pages}),G=A(e,"button",{className:"chip page-chip",type:"button",title:a.pages},M(e,"page"),Z,M(e,"chevrons"));G.setAttribute("aria-haspopup","listbox"),G.setAttribute("aria-expanded","false"),G.setAttribute("aria-controls","obelism-pages");let Q=j(e,t,a,{onLoad:()=>eE(),onClose:()=>eL(!1)}),ee=A(e,"div",{className:"pages"},Q.searchRow,Q.list,Q.note),et=A(e,"slot");et.name="actions-footer";let er=A(e,"slot");er.name="actions-bar",r.actions&&(r.actions.slot="actions-bar",i.appendChild(r.actions));let en=A(e,"span",{className:"unsaved"});en.appendChild(A(e,"span",{className:"dot"})),en.appendChild(e.createTextNode(a.unsaved));let ea=A(e,"button",{className:"link",type:"button",textContent:a.signOut}),ei=A(e,"button",{className:"action chip",type:"button",textContent:a.save}),eo=A(e,"button",{className:"action chip",type:"button",textContent:a.publish}),es=A(e,"div",{className:"footer"},G,en,A(e,"span",{className:"spacer"}),et,ea,ei,eo),el=A(e,"form",{className:"panel"},u,O,g,b,J,ee,es),ed=A(e,"div",{className:"root"},A(e,"div",{className:"bar"},d,p,er),el);o.append(A(e,"style",{textContent:H}),ed);let ep=e.defaultView,ec=e=>{"center"===e?delete ed.dataset.side:ed.dataset.side=e};ec((()=>{try{let e=ep?.localStorage.getItem(B);return"left"===e||"right"===e?e:"center"}catch{return"center"}})());let eu=null,eg=!1;ed.addEventListener("pointerdown",e=>{if(eg=!1,0!==e.button||!e.isPrimary)return;let t=e.target.closest("button, input, textarea, select, iframe, a, label, .pages, .form");if(t&&t!==d)return;let{left:r,right:n}=ed.getBoundingClientRect();eu={id:e.pointerId,startX:e.clientX,x:e.clientX,velocity:0,time:e.timeStamp,moved:!1,min:Math.min(0,16-r),max:Math.max(0,(ep?.innerWidth??0)-16-n)}}),ed.addEventListener("pointermove",e=>{if(!eu||e.pointerId!==eu.id)return;let t=e.clientX-eu.startX;if(!eu.moved){if(6>Math.abs(t))return;eu.moved=!0,ed.classList.add("dragging");try{ed.setPointerCapture(e.pointerId)}catch{}}let r=e.timeStamp-eu.time;r>0&&(eu.velocity=(e.clientX-eu.x)/r),eu.x=e.clientX,eu.time=e.timeStamp;let n=Math.min(Math.max(t,eu.min),eu.max);ed.style.translate=`${n+(t-n)/3}px 0`});let eh=e=>{if(!eu||e.pointerId!==eu.id)return;let{moved:t,x:r,velocity:n,time:a}=eu;if(eu=null,!t)return;eg=!0;let i=ed.getBoundingClientRect().left,o=ep?.innerWidth??0,s=r+(e.timeStamp-a>80?0:Math.min(Math.max(150*n,-120),120)),l=s<o/3?"left":s>2*o/3?"right":"center";ec(l),ed.style.translate="";let d=ed.getBoundingClientRect().left;ed.style.translate=`${i-d}px 0`,ed.offsetWidth,ed.classList.remove("dragging"),ed.style.translate="";try{ep?.localStorage.setItem(B,l)}catch{}};ed.addEventListener("pointerup",eh),ed.addEventListener("pointercancel",eh),ed.addEventListener("click",e=>{eg&&(eg=!1,e.preventDefault(),e.stopPropagation())},!0);let eb=!1,em=!1,ef=!1,ev=null,ex=!1,ey=U(t,b,a.formTitle,{onReady:()=>{ev=null,eE()},onError:e=>{ev={text:e,error:!0},eE()}}),ew=!1,ek=e=>{let n=e.features.includes("prompt"),i=e.saving||e.publishing,o=e.prompting||i;ed.hidden=!n&&!s,d.hidden=eb||!n,p.hidden=n||!s,el.hidden=!eb||!n;let{canCreate:k,pageless:A,shopHere:M,onlyNew:U}=D(t,e,r.promptWithoutPage),I=null!==M,j=T(a,M);P.lastChild.textContent=j.add,k||(ef=!1),U&&(ef=!0),(ef||A||!s)&&(ex=!1);let R=eb&&n&&ex;R&&!ey.mounted?ey.mount():!R&&ey.mounted&&ey.unmount();let q=I&&!ef;l.textContent=q?j.add:U?a.newPage:a.open,S.hidden=U,y.hidden=ef||q,$.hidden=!ef,P.hidden=!q,P.disabled=o,L.hidden=ef||ex||!k,L.disabled=o,em&&(ew=!1),O.hidden=!ef||ew||em,z.disabled=o,g.hidden=ex||ew||em||q,b.hidden=!ex||ew||em,b.classList.toggle("loading",ey.loading),h.hidden=!ey.loading,J.hidden=ew,ee.hidden=!ew,g.placeholder=ef?a.newPagePlaceholder:a.placeholder,v.textContent=e.selectedUid?a.scopeBlock:A?a.scopeNoPage:a.scopeEntry,x.hidden=!e.selectedUid,m.hidden=!!e.selectedUid,f.hidden=!e.selectedUid,N.hidden=!s||ef||A||!e.features.includes("form"),E.setAttribute("aria-pressed",String(!ex)),C.setAttribute("aria-pressed",String(ex)),N.querySelectorAll("button").forEach(e=>{e.disabled=o}),w.hidden=ef||!e.canUndo,w.disabled=o,X.hidden=ex||em||q,K.hidden=ex||em||q;let F=em?a.expand:a.minimize;Y.title=F,Y.setAttribute("aria-label",F),Y.setAttribute("aria-expanded",String(!em)),V.hidden=em,W.hidden=!em,X.disabled=o||""===g.value.trim()||ef&&""===z.value.trim(),g.disabled=o,ei.hidden=!e.features.includes("save")||A,ei.disabled=o||!e.unsaved,ei.textContent=e.saving?a.saving:a.save,eo.hidden=!e.features.includes("publish")||A,eo.disabled=o,eo.textContent=e.publishing?a.publishing:a.publish,ea.hidden=!s||!1===r.signOut,c.hidden=!1===r.signOut,r.actions&&(r.actions.slot=eb&&n?"actions-footer":"actions-bar"),es.hidden=!s,en.hidden=!e.unsaved,G.hidden=!s,G.setAttribute("aria-expanded",String(ew)),Z.textContent=Q.current()?.name??a.pages;let B=ex&&ey.loading&&!ew,H=e.prompting,_=e.prompting?ef?a.creating:q?j.adding:a.working:B?"":ev?.text??(q?j.hint:!s||ef||ew||e.selectedUid?"":a.selectHint);u.textContent=_,u.hidden=!_||em,u.className=`status${H?" working":""}${!o&&!B&&ev?.error?" error":""}`},eE=()=>ek(t.getState()),eC=()=>{g.style.height="auto",g.style.height=`${g.scrollHeight}px`},eA=e=>{ex!==e&&(ex=e,ev=null,eE(),ex||g.focus())},eN=async()=>{if(ex)return;let e=g.value.trim();if(e&&!t.getState().prompting){ev=null;try{if(ef){let r=z.value.trim();if(!r)return z.focus();await t.createPage(r,e),Q.forget(),ev={text:a.created,error:!1}}else{let{summary:r}=await t.prompt(e);ev={text:r,error:!1}}g.value="",eC()}catch(e){ev={text:R(e),error:!0}}eE(),g.focus()}},eL=e=>{ev=null,(ew=e)&&Q.reset(),eE(),(ew?Q.search:G).focus()},eP=e=>{(eb=e)||(ew=!1,em=!1),eE(),s&&t.setSelecting(eb&&!ef),eb&&s&&Q.fetch()},eS=e=>{ef=e,ev=null,t.setSelecting(eb&&!ef),ef&&t.select(null),eE(),(ef?z:g).focus()},e$=async e=>{ev=null;let r=await F(t,e);ev=r?{text:r,error:!0}:{text:"save"===e?a.saved:a.published,error:!1},eE()};d.addEventListener("click",()=>{eP(!0),ex||(ef?z:g).focus()}),_.addEventListener("click",()=>eP(!1)),Y.addEventListener("click",()=>{em=!em,eE(),em||(ex?Y:g).focus()}),el.addEventListener("click",e=>{if(!em)return;let t=e.target.closest("button");t&&t!==Y&&t!==_&&(em=!1,eE())},!0),ei.addEventListener("click",()=>void e$("save")),eo.addEventListener("click",()=>void e$("publish")),ea.addEventListener("click",()=>t.signOut()),c.addEventListener("click",()=>t.signOut()),x.addEventListener("click",()=>t.select(null)),L.addEventListener("click",()=>eS(!0)),P.addEventListener("click",async()=>{ev=null,ev=await q(t,a),eE()}),S.addEventListener("click",()=>eS(!1)),E.addEventListener("click",()=>eA(!1)),C.addEventListener("click",()=>eA(!0)),G.addEventListener("click",()=>eL(!ew)),z.addEventListener("input",eE),z.addEventListener("keydown",e=>{"Enter"!==e.key||e.isComposing?"Escape"===e.key&&eP(!1):(e.preventDefault(),g.focus())}),w.addEventListener("click",()=>{ev=null,t.undo()}),el.addEventListener("submit",e=>{e.preventDefault(),eN()}),g.addEventListener("input",()=>{eC(),eE()}),g.addEventListener("keydown",e=>{"Enter"!==e.key||e.shiftKey||e.isComposing?"Escape"===e.key&&eP(!1):(e.preventDefault(),eN())});let eM=t.on("change",ek);return eE(),e.body.appendChild(i),()=>{eM(),ey.unmount(),i.remove()}},V="https://content.obelism.studio",W=/^(?:\/[\w.~-]+)+$/,Y=e=>{let{protocol:t}=new URL(e,"https://site.invalid");if("https:"!==t&&"http:"!==t)throw Error(`Not a page address: ${e}`);return e},X=(e,t)=>JSON.stringify(e)===JSON.stringify(t),K="obelism-content-editor",J=`
|
|
257
|
+
:host { all: initial; }
|
|
258
|
+
* { box-sizing: border-box; font: inherit; color: inherit; margin: 0; }
|
|
259
|
+
.root {
|
|
260
|
+
--bg: 255 255 255; --subtle: 250 249 247; --paper: 242 240 236; --actions: 232 229 223;
|
|
261
|
+
--fg: 23 22 20; --soft: 68 64 60; --muted: 105 100 94;
|
|
262
|
+
--hairline: 236 233 228; --border-soft: 220 216 209; --border: 138 132 124;
|
|
263
|
+
--accent: 212 130 30; --focus: 176 98 0; --ink: 23 22 20;
|
|
264
|
+
--positive: 30 112 45; --negative: 184 46 46; --warning: 150 88 0;
|
|
265
|
+
--coral: 251 217 203; --coral-wash: 255 243 236; --coral-ink: 122 46 20;
|
|
266
|
+
--mint-wash: 237 247 240; --mint-ink: 20 83 45;
|
|
267
|
+
--butter-wash: 253 248 228; --butter-ink: 107 78 7;
|
|
268
|
+
--env-develop: 22 163 74; --env-staging: 217 119 6; --env-live: 220 38 38;
|
|
269
|
+
--tile: 23 22 20;
|
|
270
|
+
--shadow-small: 0 1px 2px rgb(23 22 20 / .06);
|
|
271
|
+
--shadow-medium: 0 0 0 1px rgb(23 22 20 / .08), 0 12px 32px rgb(23 22 20 / .14);
|
|
272
|
+
--shadow-large: 0 0 0 1px rgb(23 22 20 / .08), 0 32px 80px rgb(23 22 20 / .28);
|
|
273
|
+
--ease: cubic-bezier(0.2, 0.8, 0.2, 1);
|
|
274
|
+
--font-base: 'Geist', 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
|
|
275
|
+
'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
276
|
+
font: 400 14px/20px var(--font-base); color: rgb(var(--fg)); color-scheme: light dark;
|
|
277
|
+
-webkit-font-smoothing: antialiased;
|
|
278
|
+
}
|
|
279
|
+
@media (prefers-color-scheme: dark) {
|
|
280
|
+
.root {
|
|
281
|
+
--bg: 27 26 24; --subtle: 33 31 29; --paper: 17 16 15; --actions: 45 43 40;
|
|
282
|
+
--fg: 242 240 236; --soft: 214 210 204; --muted: 160 154 146;
|
|
283
|
+
--hairline: 44 42 39; --border-soft: 64 61 57; --border: 112 108 102;
|
|
284
|
+
--focus: 212 130 30;
|
|
285
|
+
--positive: 125 190 122; --negative: 240 110 110; --warning: 230 160 60;
|
|
286
|
+
--coral: 92 46 30; --coral-wash: 46 30 24; --coral-ink: 251 196 172;
|
|
287
|
+
--mint-wash: 24 40 30; --mint-ink: 176 226 190;
|
|
288
|
+
--butter-wash: 42 36 20; --butter-ink: 245 222 140;
|
|
289
|
+
--env-develop: 74 222 128; --env-staging: 251 191 36; --env-live: 248 113 113;
|
|
290
|
+
--tile: 45 43 40;
|
|
291
|
+
--shadow-small: 0 1px 2px rgb(0 0 0 / .4);
|
|
292
|
+
--shadow-medium: 0 0 0 1px rgb(255 255 255 / .06), 0 12px 32px rgb(0 0 0 / .5);
|
|
293
|
+
--shadow-large: 0 0 0 1px rgb(255 255 255 / .08), 0 32px 80px rgb(0 0 0 / .6);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
[hidden] { display: none !important; }
|
|
297
|
+
.visually-hidden {
|
|
298
|
+
position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
|
|
299
|
+
}
|
|
300
|
+
.icon { display: inline-flex; flex: none; }
|
|
301
|
+
.icon svg {
|
|
302
|
+
width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5;
|
|
303
|
+
stroke-linecap: round; stroke-linejoin: round;
|
|
304
|
+
}
|
|
305
|
+
.mark { display: inline-flex; flex: none; color: rgb(var(--accent)); }
|
|
306
|
+
.mark svg { width: 16px; height: 16px; fill: currentColor; }
|
|
307
|
+
.working svg { width: 16px; height: 16px; fill: rgb(var(--muted)); }
|
|
308
|
+
.working .accent { fill: rgb(var(--accent)); }
|
|
309
|
+
.working svg { animation: pulse 1.2s ease-in-out infinite; }
|
|
310
|
+
@keyframes pulse { 50% { opacity: .35; } }
|
|
311
|
+
button { cursor: pointer; background: none; border: 0; padding: 0; position: relative; }
|
|
312
|
+
button:disabled { cursor: not-allowed; }
|
|
313
|
+
:focus-visible { outline: 2px solid rgb(var(--focus)); outline-offset: 2px; }
|
|
314
|
+
/* 44px targets around smaller-looking controls. */
|
|
315
|
+
.hit::after { content: ''; position: absolute; inset: -4px; }
|
|
316
|
+
|
|
317
|
+
.panel {
|
|
318
|
+
position: fixed; top: 16px; right: 16px; bottom: 16px; width: 404px; z-index: 2147483647;
|
|
319
|
+
display: flex; flex-direction: column; overflow: hidden;
|
|
320
|
+
background: rgb(var(--bg)); border-radius: 22px; box-shadow: var(--shadow-large);
|
|
321
|
+
transition: transform .3s var(--ease), opacity .3s var(--ease), visibility 0s;
|
|
322
|
+
}
|
|
323
|
+
.panel[data-closed] {
|
|
324
|
+
transform: translateX(calc(100% + 24px)); opacity: 0; visibility: hidden;
|
|
325
|
+
transition: transform .3s var(--ease), opacity .3s var(--ease), visibility 0s .3s;
|
|
326
|
+
}
|
|
327
|
+
@media (max-width: 767px) {
|
|
328
|
+
.panel { top: auto; left: 8px; right: 8px; bottom: 64px; width: auto; height: min(60vh, 520px); }
|
|
329
|
+
.panel[data-closed] { transform: translateY(24px); }
|
|
330
|
+
}
|
|
331
|
+
@media (prefers-reduced-motion: reduce) {
|
|
332
|
+
.panel, .panel[data-closed] { transform: none; transition: opacity .2s linear, visibility 0s; }
|
|
333
|
+
.panel[data-closed] { transition: opacity .2s linear, visibility 0s .2s; }
|
|
334
|
+
.working svg { animation: none; }
|
|
335
|
+
}
|
|
336
|
+
.head {
|
|
337
|
+
display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 14px;
|
|
338
|
+
border-bottom: 1px solid rgb(var(--hairline));
|
|
339
|
+
}
|
|
340
|
+
.tile {
|
|
341
|
+
display: inline-flex; align-items: center; justify-content: center; flex: none;
|
|
342
|
+
width: 28px; height: 28px; border-radius: 8px; background: rgb(var(--tile));
|
|
343
|
+
}
|
|
344
|
+
.tile .mark svg { width: 15px; height: 15px; }
|
|
345
|
+
.page-button, .page-name {
|
|
346
|
+
display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 190px; height: 32px;
|
|
347
|
+
padding: 0 10px; border-radius: 999px; background: rgb(var(--paper)); font-size: 13px; font-weight: 500;
|
|
348
|
+
}
|
|
349
|
+
.page-button:hover { background: rgb(var(--actions)); }
|
|
350
|
+
.page-button > span:first-child, .page-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
351
|
+
.page-name { display: block; line-height: 32px; }
|
|
352
|
+
.page-button .icon svg { width: 12px; height: 12px; stroke-width: 1.75; }
|
|
353
|
+
.env {
|
|
354
|
+
display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; flex: none;
|
|
355
|
+
border-radius: 11px; font-size: 12px; font-weight: 500;
|
|
356
|
+
background: rgb(var(--paper)); color: rgb(var(--soft));
|
|
357
|
+
}
|
|
358
|
+
.env::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: rgb(var(--muted)); }
|
|
359
|
+
.env[data-env='develop'] { background: rgb(var(--mint-wash)); color: rgb(var(--mint-ink)); }
|
|
360
|
+
.env[data-env='develop']::before { background: rgb(var(--env-develop)); }
|
|
361
|
+
.env[data-env='staging'] { background: rgb(var(--butter-wash)); color: rgb(var(--butter-ink)); }
|
|
362
|
+
.env[data-env='staging']::before { background: rgb(var(--env-staging)); }
|
|
363
|
+
.env[data-env='production'] { background: rgb(var(--negative) / .1); color: rgb(var(--negative)); }
|
|
364
|
+
.env[data-env='production']::before { background: rgb(var(--env-live)); }
|
|
365
|
+
.spacer { flex: 1; }
|
|
366
|
+
.icon-button {
|
|
367
|
+
display: inline-flex; align-items: center; justify-content: center; flex: none;
|
|
368
|
+
width: 36px; height: 36px; border-radius: 50%; color: rgb(var(--muted));
|
|
369
|
+
}
|
|
370
|
+
.icon-button:hover { background: rgb(var(--paper)); color: rgb(var(--fg)); }
|
|
371
|
+
|
|
372
|
+
.pages {
|
|
373
|
+
position: absolute; top: 60px; left: 12px; right: 12px; z-index: 1; max-height: calc(100% - 140px);
|
|
374
|
+
display: flex; flex-direction: column; gap: 8px; padding: 10px;
|
|
375
|
+
background: rgb(var(--bg)); border-radius: 16px; box-shadow: var(--shadow-medium);
|
|
376
|
+
}
|
|
377
|
+
.search {
|
|
378
|
+
display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; flex: none;
|
|
379
|
+
border: 1px solid rgb(var(--border)); border-radius: 999px; color: rgb(var(--muted));
|
|
380
|
+
}
|
|
381
|
+
.search:focus-within { border-color: rgb(var(--accent)); }
|
|
382
|
+
.search input {
|
|
383
|
+
flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: rgb(var(--fg));
|
|
384
|
+
}
|
|
385
|
+
.search input::placeholder, textarea::placeholder, .path input::placeholder { color: rgb(var(--muted)); }
|
|
386
|
+
.options { list-style: none; padding: 0; overflow-y: auto; display: grid; gap: 2px; min-height: 0; }
|
|
387
|
+
.option {
|
|
388
|
+
display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 10px; border-radius: 12px; cursor: pointer;
|
|
389
|
+
}
|
|
390
|
+
.option:hover, .option.active { background: rgb(var(--paper)); }
|
|
391
|
+
.option-text { flex: 1; min-width: 0; display: grid; }
|
|
392
|
+
.option-text > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
393
|
+
.option-path { font-size: 12px; color: rgb(var(--muted)); }
|
|
394
|
+
.option .icon { color: rgb(var(--accent)); }
|
|
395
|
+
.badge {
|
|
396
|
+
flex: none; font-size: 12px; padding: 0 8px; border-radius: 999px;
|
|
397
|
+
background: rgb(var(--paper)); color: rgb(var(--soft));
|
|
398
|
+
}
|
|
399
|
+
.empty { padding: 4px 10px; color: rgb(var(--muted)); }
|
|
400
|
+
.empty.error { color: rgb(var(--negative)); }
|
|
401
|
+
.new-page { justify-content: flex-start; }
|
|
402
|
+
|
|
403
|
+
.tabs {
|
|
404
|
+
display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; flex: none;
|
|
405
|
+
margin: 12px 14px 0; padding: 3px; border-radius: 999px; background: rgb(var(--actions));
|
|
406
|
+
}
|
|
407
|
+
.tab {
|
|
408
|
+
display: flex; align-items: center; justify-content: center; gap: 6px; height: 38px;
|
|
409
|
+
border-radius: 999px; font-size: 13px; font-weight: 500; color: rgb(var(--soft));
|
|
410
|
+
}
|
|
411
|
+
.tab:hover { color: rgb(var(--fg)); }
|
|
412
|
+
.tab[aria-selected='true'] { background: rgb(var(--bg)); color: rgb(var(--fg)); box-shadow: var(--shadow-small); }
|
|
413
|
+
.tab .mark svg { width: 12px; height: 12px; }
|
|
414
|
+
.ask, .fields { flex: 1; min-height: 0; display: flex; flex-direction: column; }
|
|
415
|
+
.scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 14px; }
|
|
416
|
+
.note {
|
|
417
|
+
display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px;
|
|
418
|
+
background: rgb(var(--coral-wash)); color: rgb(var(--coral-ink)); font-size: 12px; line-height: 18px;
|
|
419
|
+
}
|
|
420
|
+
.note > span:not(.icon) { flex: 1; min-width: 0; }
|
|
421
|
+
.note strong { font-weight: 600; }
|
|
422
|
+
.note button {
|
|
423
|
+
flex: none; font-size: 12px; font-weight: 500; text-decoration: underline; text-underline-offset: 2px;
|
|
424
|
+
}
|
|
425
|
+
.note button::after { content: ''; position: absolute; inset: -13px -6px; }
|
|
426
|
+
.intro { color: rgb(var(--muted)); font-size: 13px; }
|
|
427
|
+
.gate {
|
|
428
|
+
display: grid; gap: 8px; margin: 10px 14px 0; padding: 10px 12px; border-radius: 12px;
|
|
429
|
+
background: rgb(var(--coral-wash)); color: rgb(var(--coral-ink)); font-size: 12px; line-height: 18px;
|
|
430
|
+
}
|
|
431
|
+
.shop { display: grid; gap: 10px; justify-items: start; padding: 12px; border-radius: 14px; background: rgb(var(--subtle)); }
|
|
432
|
+
.log { display: flex; flex-direction: column; gap: 14px; }
|
|
433
|
+
.bubble {
|
|
434
|
+
align-self: flex-end; max-width: 80%; padding: 10px 12px; border-radius: 16px 16px 4px 16px;
|
|
435
|
+
background: rgb(var(--fg)); color: rgb(var(--bg)); white-space: pre-wrap; overflow-wrap: anywhere;
|
|
436
|
+
}
|
|
437
|
+
.answer { display: flex; gap: 10px; align-items: flex-start; }
|
|
438
|
+
.answer > .chip {
|
|
439
|
+
display: inline-flex; align-items: center; justify-content: center; flex: none;
|
|
440
|
+
width: 26px; height: 26px; border-radius: 50%; background: rgb(var(--tile));
|
|
441
|
+
}
|
|
442
|
+
.answer > .chip .mark svg { width: 12px; height: 12px; }
|
|
443
|
+
.card { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
|
|
444
|
+
.answer[data-status='pending'] .card { padding: 12px; border-radius: 16px; background: rgb(var(--coral-wash)); }
|
|
445
|
+
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: rgb(var(--coral-ink)); }
|
|
446
|
+
.answer:not([data-status='pending']) .eyebrow { color: rgb(var(--muted)); }
|
|
447
|
+
.summary { color: rgb(var(--soft)); overflow-wrap: anywhere; }
|
|
448
|
+
.answer[data-status='undone'] .summary { color: rgb(var(--muted)); }
|
|
449
|
+
.status-line { display: flex; align-items: center; gap: 8px; color: rgb(var(--muted)); }
|
|
450
|
+
.failure { display: flex; align-items: flex-start; gap: 8px; color: rgb(var(--negative)); overflow-wrap: anywhere; }
|
|
451
|
+
.failure .icon { margin-top: 2px; }
|
|
452
|
+
.diff-field { display: grid; gap: 4px; }
|
|
453
|
+
.diff-label { font-size: 12px; font-weight: 500; color: rgb(var(--muted)); }
|
|
454
|
+
.diff { border-radius: 14px; overflow: hidden; box-shadow: inset 0 0 0 1px rgb(var(--hairline)); }
|
|
455
|
+
.diff > div { display: grid; gap: 2px; padding: 10px 12px; }
|
|
456
|
+
.diff .before { background: rgb(var(--negative) / .07); color: rgb(var(--negative)); }
|
|
457
|
+
.diff .after { background: rgb(var(--mint-wash)); color: rgb(var(--mint-ink)); }
|
|
458
|
+
.diff .tag { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
|
|
459
|
+
.diff .value {
|
|
460
|
+
white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical;
|
|
461
|
+
-webkit-line-clamp: 6; overflow: hidden;
|
|
462
|
+
}
|
|
463
|
+
.diff .before .value { text-decoration: line-through; text-decoration-color: rgb(var(--negative) / .5); }
|
|
464
|
+
.diff .after .value { font-weight: 500; }
|
|
465
|
+
.diff .value.none { text-decoration: none; font-style: italic; font-weight: 400; color: rgb(var(--muted)); }
|
|
466
|
+
.more { font-size: 12px; color: rgb(var(--muted)); }
|
|
467
|
+
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
468
|
+
|
|
469
|
+
.button {
|
|
470
|
+
display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px;
|
|
471
|
+
padding: 0 14px; border-radius: 999px; font-size: 13px; font-weight: 500; white-space: nowrap;
|
|
472
|
+
}
|
|
473
|
+
.button::after { content: ''; position: absolute; inset: -4px 0; }
|
|
474
|
+
.button.primary { background: rgb(var(--fg)); color: rgb(var(--bg)); }
|
|
475
|
+
.button.primary:hover:not(:disabled) { background: rgb(var(--soft)); }
|
|
476
|
+
.button.secondary { background: rgb(var(--bg)); box-shadow: inset 0 0 0 1px rgb(var(--border-soft)); }
|
|
477
|
+
.button.secondary:hover:not(:disabled) { background: rgb(var(--paper)); }
|
|
478
|
+
.button.quiet { color: rgb(var(--soft)); padding: 0 10px; }
|
|
479
|
+
.button.quiet:hover:not(:disabled) { background: rgb(var(--paper)); color: rgb(var(--fg)); }
|
|
480
|
+
.button:disabled { background: rgb(var(--actions)); color: rgb(var(--muted)); box-shadow: none; }
|
|
481
|
+
.button.quiet:disabled { background: none; }
|
|
482
|
+
|
|
483
|
+
.composer { flex: none; display: grid; gap: 8px; padding: 10px 14px 12px; }
|
|
484
|
+
.path { display: flex; align-items: center; gap: 10px; color: rgb(var(--muted)); font-size: 13px; }
|
|
485
|
+
.path input {
|
|
486
|
+
flex: 1; min-width: 0; height: 40px; padding: 0 14px; outline: 0; color: rgb(var(--fg));
|
|
487
|
+
border: 1px solid rgb(var(--border)); border-radius: 999px; background: rgb(var(--bg));
|
|
488
|
+
}
|
|
489
|
+
.path input:focus-visible { border-color: rgb(var(--accent)); }
|
|
490
|
+
.bar {
|
|
491
|
+
display: flex; align-items: flex-end; gap: 6px; padding: 0 0 0 14px; border-radius: 18px;
|
|
492
|
+
background: rgb(var(--paper)); box-shadow: inset 0 0 0 1px rgb(var(--hairline));
|
|
493
|
+
}
|
|
494
|
+
.bar:focus-within { box-shadow: inset 0 0 0 1px rgb(var(--accent)), 0 0 0 3px rgb(var(--accent) / .18); }
|
|
495
|
+
.bar > .mark { height: 44px; align-items: center; }
|
|
496
|
+
/* The bar's ring shows focus. */
|
|
497
|
+
textarea:focus-visible, .search input:focus-visible { outline: none; }
|
|
498
|
+
textarea {
|
|
499
|
+
flex: 1; min-width: 0; resize: none; min-height: 44px; max-height: 160px; padding: 12px 0;
|
|
500
|
+
border: 0; outline: 0; background: transparent; line-height: 20px; color: rgb(var(--fg));
|
|
501
|
+
}
|
|
502
|
+
textarea:disabled, .path input:disabled { opacity: .6; }
|
|
503
|
+
.send { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: none; }
|
|
504
|
+
.send::before {
|
|
505
|
+
content: ''; position: absolute; width: 34px; height: 34px; border-radius: 50%; background: rgb(var(--accent));
|
|
506
|
+
}
|
|
507
|
+
.send > .icon, .send > .working { position: relative; color: rgb(var(--ink)); }
|
|
508
|
+
.send:disabled::before { opacity: .4; }
|
|
509
|
+
.send .icon svg { stroke-width: 2; }
|
|
510
|
+
.send .working svg, .send .working .accent { fill: rgb(var(--ink)); }
|
|
511
|
+
|
|
512
|
+
.form { position: relative; flex: 1; min-height: 0; margin: 12px 14px 0; }
|
|
513
|
+
.form iframe {
|
|
514
|
+
display: block; width: 100%; height: 100% !important; border: 0; border-radius: 12px; background: rgb(var(--subtle));
|
|
515
|
+
}
|
|
516
|
+
.form.loading iframe { visibility: hidden; }
|
|
517
|
+
.form-note {
|
|
518
|
+
position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 8px;
|
|
519
|
+
padding: 16px; text-align: center; border-radius: 12px; background: rgb(var(--subtle)); color: rgb(var(--muted));
|
|
520
|
+
}
|
|
521
|
+
.form-note.error { color: rgb(var(--negative)); }
|
|
522
|
+
|
|
523
|
+
.foot {
|
|
524
|
+
display: flex; align-items: center; gap: 8px; flex: none; padding: 12px 14px;
|
|
525
|
+
border-top: 1px solid rgb(var(--hairline)); background: rgb(var(--subtle));
|
|
526
|
+
}
|
|
527
|
+
.save-state { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; font-size: 12px; line-height: 16px; color: rgb(var(--muted)); }
|
|
528
|
+
.save-state .dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: rgb(var(--warning)); }
|
|
529
|
+
.save-state[data-state='unsaved'] { color: rgb(var(--warning)); }
|
|
530
|
+
.save-state[data-state='saved'] { color: rgb(var(--positive)); }
|
|
531
|
+
.save-state[data-state='error'] { color: rgb(var(--negative)); }
|
|
532
|
+
.save-state .icon svg { width: 14px; height: 14px; }
|
|
533
|
+
.save-state .link { text-decoration: underline; text-underline-offset: 2px; font-weight: 500; flex: none; }
|
|
534
|
+
.save-state .link::after { content: ''; position: absolute; inset: -14px -6px; }
|
|
535
|
+
|
|
536
|
+
.launcher {
|
|
537
|
+
position: fixed; left: 20px; bottom: 20px; z-index: 2147483647;
|
|
538
|
+
display: flex; align-items: center; gap: 2px; padding: 2px; border-radius: 999px;
|
|
539
|
+
background: rgb(23 22 20); color: rgb(214 211 204); box-shadow: 0 8px 24px rgb(0 0 0 / .3);
|
|
540
|
+
}
|
|
541
|
+
@media (prefers-color-scheme: dark) { .launcher { box-shadow: 0 0 0 1px rgb(255 255 255 / .12), 0 8px 24px rgb(0 0 0 / .5); } }
|
|
542
|
+
@media (max-width: 767px) { .launcher { left: 8px; bottom: 8px; } }
|
|
543
|
+
.launcher button { height: 44px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; }
|
|
544
|
+
.launcher button:hover { background: rgb(255 255 255 / .08); color: rgb(244 243 240); }
|
|
545
|
+
.launcher :focus-visible { outline-color: rgb(212 130 30); }
|
|
546
|
+
.launch { gap: 8px; padding: 0 12px 0 6px; color: rgb(244 243 240); font-size: 13px; font-weight: 500; }
|
|
547
|
+
.launch-tile, .reading .launch-tile {
|
|
548
|
+
display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%;
|
|
549
|
+
background: rgb(44 42 39);
|
|
550
|
+
}
|
|
551
|
+
.launch-tile .mark svg { width: 15px; height: 15px; }
|
|
552
|
+
.reading { display: inline-flex; align-items: center; gap: 8px; padding: 0 8px 0 6px; color: rgb(244 243 240); font-size: 13px; font-weight: 500; }
|
|
553
|
+
.eye { width: 44px; }
|
|
554
|
+
.exit { padding: 0 14px; font-size: 13px; }
|
|
555
|
+
|
|
556
|
+
.layer { position: fixed; inset: 0; pointer-events: none; z-index: 2147483645; }
|
|
557
|
+
.box { position: absolute; border-radius: 4px; }
|
|
558
|
+
.box.hover { border: 1.5px dashed rgb(var(--border)); }
|
|
559
|
+
.box.preview { border: 2px solid rgb(var(--accent)); }
|
|
560
|
+
/* Its own layer, multiplied onto the page (a blend inside the marks layer
|
|
561
|
+
wouldn't reach it): the wash tints the block's background, not its text. */
|
|
562
|
+
.wash { position: fixed; inset: 0; pointer-events: none; z-index: 2147483644; mix-blend-mode: multiply; }
|
|
563
|
+
.box.fill { background: rgb(255 243 236); }
|
|
564
|
+
.name-tab {
|
|
565
|
+
position: absolute; height: 20px; padding: 0 8px; border-radius: 6px 6px 0 0; white-space: nowrap;
|
|
566
|
+
background: rgb(105 100 94); color: rgb(255 255 255); font-size: 11px; font-weight: 500; line-height: 20px;
|
|
567
|
+
}
|
|
568
|
+
.name-tab.inside { border-radius: 0 0 6px 0; }
|
|
569
|
+
.chips { position: absolute; display: flex; gap: 4px; }
|
|
570
|
+
.chips span {
|
|
571
|
+
display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px;
|
|
572
|
+
font-size: 12px; white-space: nowrap;
|
|
573
|
+
}
|
|
574
|
+
.chips .accent-chip { background: rgb(212 130 30); color: rgb(23 22 20); font-weight: 600; }
|
|
575
|
+
.chips .accent-chip .mark { color: rgb(23 22 20); }
|
|
576
|
+
.chips .accent-chip .mark svg { width: 11px; height: 11px; }
|
|
577
|
+
.chips .ink-chip { background: rgb(23 22 20); color: rgb(255 255 255); font-weight: 500; }
|
|
578
|
+
`,Z=e=>{let t=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)},G=e=>!!e&&"object"==typeof e&&!Array.isArray(e),Q=(e,t,r,n)=>{if(null!=e&&""!==e){if("object"!=typeof e)return void n.set(r,{label:t,text:String(e)});if(Array.isArray(e)){if(e.every(e=>null===e||"object"!=typeof e)){e.length&&n.set(r,{label:t,text:e.join(", ")});return}e.forEach((e,a)=>{let i=G(e)&&"string"==typeof e._uid?e._uid:a,o=G(e)&&"string"==typeof e._type?e._type:null;Q(e,o?Z(o):t,`${r}/${i}`,n)});return}for(let[a,i]of Object.entries(e))"_uid"!==a&&"_type"!==a&&Q(i,t?`${t} \xb7 ${Z(a)}`:Z(a),`${r}/${a}`,n)}},ee=(e,n,a={})=>{let i,o={...O,...a.labels},s=e.defaultView,l=e.documentElement,d=(t,...r)=>A(e,"button",{className:t,type:"button"},...r),p=A(e,"div");p.setAttribute("data-obelism-content-editor","");let c=p.attachShadow({mode:"open"}),u=A(e,"style",{textContent:(i=`[${t}]`,`html[data-obelism-editor]{transition:margin-right .3s cubic-bezier(.2,.8,.2,1)}html[data-obelism-docked]{margin-right:436px!important}html[data-obelism-docked] [data-obelism-dock]{right:436px!important;max-width:calc(100vw - 436px)!important}html[data-obelism-editor][data-cms-selecting] ${i}:hover:not([data-cms-selected]){outline:none}html[data-obelism-editor][data-cms-selecting] ${i}[data-cms-selected]{outline:2px solid rgb(212 130 30);outline-offset:2px}@media (prefers-reduced-motion:reduce){html[data-obelism-editor]{transition:none}}`)}),g=A(e,"span",{className:"tile"},P(e,"mark",N)),h=A(e,"span"),b=d("page-button hit",h,A(e,"span",{className:"visually-hidden",textContent:`, ${o.pages}`}),M(e,"chevrons"));b.setAttribute("aria-haspopup","listbox"),b.setAttribute("aria-expanded","false"),b.setAttribute("aria-controls","obelism-pages");let m=A(e,"span",{className:"page-name"}),f=A(e,"span"),v=A(e,"span",{className:"env"},A(e,"span",{className:"visually-hidden",textContent:`${o.environment}: `}),f),x=d("icon-button hit",M(e,"dash"));x.setAttribute("aria-label",o.minimize),x.title=o.minimize;let y=A(e,"div",{className:"head"},g,b,m,v,A(e,"span",{className:"spacer"}),x),w=j(e,n,o,{onLoad:()=>ti(),onClose:()=>tc(!1)}),k=d("button quiet new-page",M(e,"plus"),o.newPage),C=A(e,"div",{className:"pages"},w.searchRow,w.list,w.note,k),$=(e,t,...r)=>{let n=d("tab",...r);return n.id=e,n.setAttribute("role","tab"),n.setAttribute("aria-controls",t),n},z=$("obelism-tab-ask","obelism-ask",P(e,"mark",N),o.modePrompt),I=$("obelism-tab-fields","obelism-fields",o.form),B=A(e,"div",{className:"tabs"},z,I);B.setAttribute("role","tablist"),B.setAttribute("aria-label",o.modes);let H=d("button primary",o.keep),_=d("button quiet",o.undo),V=A(e,"div",{className:"gate"},A(e,"p",{textContent:o.keepBeforeFields}),A(e,"div",{className:"actions"},H,_));V.setAttribute("role","alert");let W=A(e,"span"),Y=d("",o.scopeEntry),X=d("",o.newPageCancel),ee=A(e,"div",{className:"note"},M(e,"scope"),W,Y,X),et=A(e,"p",{className:"intro",textContent:o.askIntro}),er=A(e,"p",{className:"summary"}),en=A(e,"span"),ea=d("button primary",M(e,"plus"),en),ei=A(e,"div",{className:"shop"},er,ea),eo=A(e,"div",{className:"log"});eo.setAttribute("role","log");let es=A(e,"div",{className:"scroll"},ee,et,ei,eo),el=A(e,"input",{type:"text",placeholder:o.pathPlaceholder,autocomplete:"off",spellcheck:!1}),ed=A(e,"label",{className:"path"},A(e,"span",{textContent:o.path}),el),ep=A(e,"textarea",{rows:1});ep.setAttribute("aria-label",o.open);let ec=M(e,"arrowUp"),eu=P(e,"working",L),eg=A(e,"button",{className:"send",type:"submit",title:o.send},A(e,"span",{className:"visually-hidden",textContent:o.send}),ec,eu),eh=A(e,"div",{className:"bar"},P(e,"mark",N),ep,eg),eb=A(e,"form",{className:"composer"},ed,eh),em=A(e,"div",{className:"ask",id:"obelism-ask"},es,eb);em.setAttribute("role","tabpanel"),em.setAttribute("aria-labelledby",z.id);let ef=A(e,"p",{className:"form-note"});ef.setAttribute("role","status");let ev=A(e,"div",{className:"form"},ef),ex=A(e,"div",{className:"fields",id:"obelism-fields"},ev);ex.setAttribute("role","tabpanel"),ex.setAttribute("aria-labelledby",I.id);let ey=A(e,"p",{className:"save-state"});ey.setAttribute("aria-live","polite");let ew=A(e,"slot");ew.name="actions-footer";let ek=d("button quiet",M(e,"undo"),o.undo),eE=d("button secondary",o.saveDraft),eC=d("button primary",o.publish),eA=A(e,"div",{className:"foot"},ey,ew,ek,eE,eC),eN=A(e,"p",{className:"visually-hidden"});eN.setAttribute("role","status");let eL=A(e,"aside",{className:"panel",id:"obelism-editor"},y,C,B,V,em,ex,eA,eN);eL.setAttribute("aria-label",o.editor);let eP=d("launch",A(e,"span",{className:"launch-tile"},P(e,"mark",N)),o.editing);eP.setAttribute("aria-controls",eL.id);let eS=A(e,"span",{className:"reading"},A(e,"span",{className:"launch-tile"},P(e,"mark",N)),o.viewingDrafts),e$=M(e,"eye"),eM=M(e,"eyeOff"),eU=d("eye",e$,eM);eU.setAttribute("aria-label",o.hideOutlines),eU.title=o.hideOutlines;let ez=A(e,"slot");ez.name="actions-bar";let eI=d("exit",o.signOut),eO=A(e,"div",{className:"launcher"},eP,eS,eU,ez,eI);a.actions&&p.appendChild(a.actions);let ej=A(e,"div",{className:"layer"});ej.setAttribute("aria-hidden","true");let eR=A(e,"div",{className:"wash"});eR.setAttribute("aria-hidden","true");let eD=A(e,"div",{className:"root"},eR,ej,eL,eO);c.append(A(e,"style",{textContent:J}),eD);let eT=(e=>{try{return e?.localStorage.getItem(K)!=="minimised"}catch{return!0}})(s),eq="ask",eF=!1,eB=!1,eH=!0,e_=!1,eV=null,eW=!1,eY=null,eX=[],eK=!0,eJ=null,eZ=new Map,eG="idle",eQ=!1,e0=U(n,ev,o.formTitle,{onReady:()=>ti(),onError:()=>ti(),onEscape:()=>tu()}),e1=()=>eX.filter(({status:e})=>"pending"===e),e2=()=>e1().slice(-1)[0]??null,e4=()=>eX.some(({status:e})=>"working"===e)?null:e2(),e6=e=>(eZ.has(e)||"loading"===eG||(eZ.set(e,null),n.view({uid:e}).then(t=>{"string"==typeof t._type&&eZ.set(e,Z(t._type)),ti()},()=>{})),eZ.get(e)??o.block),e5=e=>{Array.isArray(e)?e.forEach(e5):G(e)&&("string"==typeof e._uid&&"string"==typeof e._type&&eZ.set(e._uid,Z(e._type)),Object.values(e).forEach(e5))},e3=()=>w.current()?.name||e.title.trim(),e8=null,e7=()=>{null===e8&&s&&(e8=s.requestAnimationFrame(()=>{e8=null,(t=>{if(ej.replaceChildren(),eR.replaceChildren(),!te(t))return;let n=t=>{let r=e.querySelector(t),n=r?.getBoundingClientRect();return n&&(n.width||n.height)?n:null},a=(t,r,n=ej)=>{let a=A(e,"div",{className:`box ${r}`});Object.assign(a.style,{top:`${t.top-3}px`,left:`${t.left-3}px`,width:`${t.width+6}px`,height:`${t.height+6}px`}),n.appendChild(a)},i=(t,...r)=>{let n=A(e,"div",{className:"chips"},...r),a=t.top-34<0?t.top+6:t.top-34;Object.assign(n.style,{top:`${a}px`,left:`${t.left-3}px`}),ej.appendChild(n)},s=(t,r)=>{let n=A(e,"span",{className:"accent-chip"});return r&&n.appendChild(P(e,"mark",N)),n.appendChild(e.createTextNode(t)),n},l=e2(),d=l?l.uid?E(l.uid):`[${r}]`:null,p=d?n(d):null;if(p&&a(p,"fill",eR),eJ&&eJ!==t.selectedUid){let t=n(E(eJ));if(t){a(t,"hover");let r=t.top-23<0,n=A(e,"span",{className:`name-tab${r?" inside":""}`,textContent:e6(eJ)});Object.assign(n.style,{top:`${r?t.top-1.5:t.top-23}px`,left:`${t.left-3}px`}),ej.appendChild(n)}}let c=!!l&&l.uid===t.selectedUid;if(t.selectedUid){let r=n(E(t.selectedUid));if(r){let n=e6(t.selectedUid),a=e3();i(r,s(c?S(o.previewChip,{name:n}):n,c),...a?[A(e,"span",{className:"ink-chip",textContent:a})]:[])}}if(p&&!c){a(p,"preview");let e=l.uid?e6(l.uid):e3()||o.pages;i(p,s(S(o.previewChip,{name:e}),!0))}})(n.getState())}))},e9=e=>e.features.includes("prompt")&&eT,te=e=>e9(e)&&eH&&!eB,tt=t=>A(e,"span",{className:`value${t?"":" none"}`,textContent:t||o.emptyValue}),tr=t=>{let r=t.node.querySelector(".card");if(r.querySelector(".status-line")?.remove(),"failed"===t.status)return void r.appendChild(A(e,"p",{className:"failure"},M(e,"alert"),t.summary));for(let n of(r.appendChild(t.eyebrow),t.summary&&r.appendChild(A(e,"p",{className:"summary",textContent:t.summary})),t.diffs.slice(0,3))){let a=A(e,"div",{className:"diff-field"},A(e,"span",{className:"diff-label",textContent:n.label}),A(e,"div",{className:"diff"},A(e,"div",{className:"before"},A(e,"span",{className:"tag",textContent:o.before}),tt(n.before)),A(e,"div",{className:"after"},A(e,"span",{className:"tag",textContent:o.after}),tt(n.after))));t.details.push(a),r.appendChild(a)}if(t.diffs.length>3){let n=A(e,"p",{className:"more",textContent:S(o.moreChanges,{count:t.diffs.length-3})});t.details.push(n),r.appendChild(n)}if("pending"===t.status){let n=d("button primary",o.keep),a=d("button secondary",o.retry),i=d("button quiet",o.undo);n.addEventListener("click",()=>tg()),a.addEventListener("click",()=>void tm(t)),i.addEventListener("click",()=>th(t)),t.actions=A(e,"div",{className:"actions"},n,a,i),r.appendChild(t.actions)}},tn=(t,r)=>{let n=A(e,"div",{className:"card"},A(e,"span",{className:"visually-hidden",textContent:`${o.obelism}: `}),A(e,"p",{className:"status-line"},P(e,"working",L),eB?o.creating:o.working)),a=A(e,"div",{className:"answer"},A(e,"span",{className:"chip"},P(e,"mark",N)),n);a.dataset.status="working";let i={prompt:t,uid:r,status:"working",summary:"",diffs:[],step:null,node:a,eyebrow:A(e,"p",{className:"eyebrow"}),actions:null,details:[]};return eX.push(i),eo.appendChild(a),i},ta=t=>{if(eQ)return;let r=t.features.includes("prompt"),i=t.saving||t.publishing,s=t.prompting||i,p=r&&eT,{site:c,canCreate:u,pageless:g,shopHere:x,onlyNew:y}=D(n,t,a.promptWithoutPage);u||(eB=!1),y&&(eB=!0);let E=c&&!eB&&!g&&t.features.includes("form");E||(eq="ask");let N=e1().length>0;for(let e of(N&&"fields"!==eq||(eF=!1),eX))null!==e.step&&e.step>(t.undoSteps??0)&&(e.step=null);eD.hidden=!r&&!c,eL.toggleAttribute("data-closed",!p),eL.inert=!p,eP.hidden=!r,eP.setAttribute("aria-expanded",String(p)),eS.hidden=r,eU.hidden=!p,eU.setAttribute("aria-pressed",String(!eH)),e$.hidden=!eH,eM.hidden=eH,eI.hidden=!1===a.signOut;let S=p&&eK;l.toggleAttribute("data-obelism-docked",S),l.style.setProperty("--obelism-dock",`${436*!!S}px`);let $=p&&eH&&!eB;t.selecting!==$&&n.setSelecting($);let U=p&&"fields"===eq;U&&!e0.mounted?e0.mount():!U&&e0.mounted&&e0.unmount(),e_&&!p&&(e_=!1),h.textContent=e3()||o.pages,b.hidden=null===w.pages&&null!==w.error,m.hidden=!b.hidden,m.textContent=e3()||o.pages,b.setAttribute("aria-expanded",String(e_)),C.hidden=!e_,k.hidden=!u||eB,k.disabled=s;let O=n.environment;v.hidden=!O,v.dataset.env=O??"",f.textContent="production"===O?o.envProduction:O??"",B.hidden=!E,z.setAttribute("aria-selected",String("ask"===eq)),I.setAttribute("aria-selected",String("fields"===eq)),z.disabled=I.disabled=s,z.tabIndex="ask"===eq?0:-1,I.tabIndex="fields"===eq?0:-1,V.hidden=!eF,H.disabled=_.disabled=s,em.hidden="ask"!==eq,ex.hidden="fields"!==eq;let j=null!==x&&!eB;if(eB)W.textContent=o.newPage;else if(t.selectedUid){let[r,n=""]=o.scopeNoteBlock.split("{name}");W.replaceChildren(r??"",A(e,"strong",{textContent:e6(t.selectedUid)}),n)}else W.textContent=o.scopeNotePage;ee.hidden=j||g&&!eB&&!a.promptWithoutPage,Y.hidden=eB||!t.selectedUid,X.hidden=!eB||y,et.hidden=eX.length>0||j||eB,ei.hidden=!j;let R=T(o,x);en.textContent=t.prompting&&j?R.adding:R.add,ea.disabled=s,er.textContent=eY?.text??R.hint,er.className=eY?.error?"failure":"summary",eb.hidden=j,ed.hidden=!eB,el.disabled=s,ep.placeholder=eB?o.newPagePlaceholder:o.placeholder,ep.disabled=s,eg.disabled=s||""===ep.value.trim()||eB&&""===el.value.trim(),eg.setAttribute("aria-busy",String(t.prompting)),ec.hidden=t.prompting,eu.hidden=!t.prompting,ek.hidden=N||!t.canUndo||eB,ek.disabled=s,eE.hidden=!t.features.includes("save")||g,eE.disabled=s||N||!t.unsaved,eC.hidden=!t.features.includes("publish")||g,eC.disabled=s||N,a.actions&&(a.actions.slot=p?"actions-footer":"actions-bar"),eA.hidden=!c,t.unsaved&&!eW&&(eV=null),eW=t.unsaved;let q=i?P(e,"working",L):eV?.kind==="error"?M(e,"alert"):N||t.unsaved?A(e,"span",{className:"dot"}):M(e,"check"),F=t.saving?o.saving:t.publishing?o.publishing:eV?.kind==="error"?`${"save"===eV.action?o.saveFailed:o.publishFailed}: ${eV.text}`:N?o.keepFirst:t.unsaved?o.unsaved:eV?.kind==="saved"?o.saved:eV?.kind==="published"?o.published:o.upToDate,K=i?"saving":eV?.kind==="error"?"error":N||t.unsaved?"unsaved":"saved";if((ey.dataset.state!==K||ey.dataset.text!==F)&&(ey.dataset.state=K,ey.dataset.text=F,ey.replaceChildren(q,A(e,"span",{textContent:F})),eV?.kind==="error"&&!i)){let e=eV.action,t=d("link",o.tryAgain);t.addEventListener("click",()=>void tv(e)),ey.appendChild(t)}ev.classList.toggle("loading",e0.loading||null!==e0.error),ef.hidden=!e0.loading&&null===e0.error,ef.className=`form-note${null!==e0.error?" error":""}`,ef.textContent=e0.error??o.formLoading;let J=e4();for(let e of eX){if("working"===e.status||"failed"===e.status)continue;e.node.dataset.status=e.status;let t="pending"===e.status?o.suggested:"kept"===e.status?o.kept:o.undone;for(let r of(e.eyebrow.textContent!==t&&(e.eyebrow.textContent=t),e.actions&&(e.actions.hidden=e!==J),e.details))r.hidden="undone"===e.status}p&&((()=>{if("idle"!==eG||null===n.entryId)return;eG="loading";let e=()=>{eG="done",ti()};n.view({uid:null}).then(t=>{e5(t),e()},e)})(),null===w.pages&&null===w.error&&w.fetch()),e7()},ti=()=>ta(n.getState()),to=()=>{ep.style.height="auto",ep.style.height=`${ep.scrollHeight}px`},ts=()=>{es.scrollTop=es.scrollHeight},tl=e=>{eT=e;try{s?.localStorage.setItem(K,eT?"open":"minimised")}catch{}eT||(e_=!1),ti(),eT?("fields"===eq?I:eB?el:ep).focus():eP.focus()},td=e=>{if("fields"===e&&e1().length>0){eF=!0,ti(),H.focus();return}if(eF=!1,eq===e)return ti();eq=e,ti()},tp=e=>{e_=!1,(eB=e)&&n.select(null),ti(),(eB?el:ep).focus()},tc=e=>{(e_=e)&&w.reset(),ti(),(e_?w.search:b).focus()},tu=()=>{let e=n.getState();if(!e9(e))return!1;if(e_)tc(!1);else{if(!e.selectedUid)return!1;n.select(null)}return!0},tg=(e=!0)=>{let t=e1();t.length&&e4()&&(t.forEach(e=>{e.status="kept"}),ti(),e&&ep.focus())},th=(e,t=!0)=>{e===e4()&&(n.undo(),e.status="undone",ti(),t&&ep.focus())},tb=async(e,t)=>{let r={uid:e.uid},a=await n.view(r).catch(()=>null);try{let{summary:i}=await n.prompt(t,r);e.step=n.getState().undoSteps??null;let o=a?await n.view(r).catch(()=>null):null;e.summary=i,e.diffs=a&&o?((e,t)=>{let r=new Map,n=new Map;Q(e,"","",r),Q(t,"","",n);let a=[];for(let e of new Set([...r.keys(),...n.keys()])){let t=r.get(e),i=n.get(e);t?.text!==i?.text&&a.push({label:(i??t).label,before:t?.text??"",after:i?.text??""})}return a})(a,o):[],e.status="pending"}catch(t){e.summary=R(t),e.status="failed"}tr(e),ti(),ts()},tm=async e=>{if(e!==e4())return;n.undo(),e.status="undone";let t=tn(e.prompt,e.uid);ti(),ts(),ep.focus(),await tb(t,S(o.retryPrompt,{prompt:e.prompt}))},tf=async()=>{let t=ep.value.trim(),r=n.getState();if(!t||r.prompting)return;let a=el.value.trim();if(eB&&!a)return el.focus();let i=eB?null:r.selectedUid,s=eB?`${o.newPage} \xb7 ${a}`:i?e6(i):o.scopeEntry;eo.appendChild(A(e,"p",{className:"bubble"},A(e,"span",{className:"visually-hidden",textContent:`${o.you} (${s}): `}),t)),ep.value="",to();let l=tn(t,i);if(ti(),ts(),eB){try{await n.createPage(a,t),w.forget(),l.summary=o.created,l.status="kept"}catch(e){l.summary=R(e),l.status="failed"}tr(l),ti()}else await tb(l,t);ep.focus()},tv=async e=>{eV=null;let t=await F(n,e);eV=t?{kind:"error",action:e,text:t}:{kind:"save"===e?"saved":"published"},ti()};eP.addEventListener("click",()=>tl(!eT)),x.addEventListener("click",()=>tl(!1)),eU.addEventListener("click",()=>{eH=!eH,ti()}),eI.addEventListener("click",()=>n.signOut()),b.addEventListener("click",()=>tc(!e_)),k.addEventListener("click",()=>tp(!0)),X.addEventListener("click",()=>tp(!1)),Y.addEventListener("click",()=>{n.select(null),ep.focus()}),ea.addEventListener("click",async()=>{eY=null,eY=await q(n,o),ti()}),z.addEventListener("click",()=>td("ask")),I.addEventListener("click",()=>td("fields")),B.addEventListener("keydown",e=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(e.key))return;e.preventDefault();let t=c.activeElement===z;("Home"===e.key?z:"End"===e.key||t?I:z).focus()}),H.addEventListener("click",()=>{tg(!1),td("fields"),I.focus()}),_.addEventListener("click",()=>{for(let e=e4();e;e=e4())th(e,!1);td("fields"),I.focus()}),ek.addEventListener("click",()=>{let e=n.getState().undoSteps,t=void 0===e?void 0:eX.find(t=>"kept"===t.status&&t.step===e);if(n.undo(),t){var r;t.status="undone",ti(),r=`${o.undone}: ${t.summary}`,eN.textContent="",eN.textContent=r}ek.hidden&&ep.focus()}),eE.addEventListener("click",()=>void tv("save")),eC.addEventListener("click",()=>void tv("publish")),eb.addEventListener("submit",e=>{e.preventDefault(),tf()}),ep.addEventListener("input",()=>{to(),ti()}),ep.addEventListener("keydown",e=>{"Enter"!==e.key||e.shiftKey||e.isComposing||(e.preventDefault(),tf())}),el.addEventListener("input",ti),el.addEventListener("keydown",e=>{"Enter"!==e.key||e.isComposing||(e.preventDefault(),ep.focus())});let tx=e=>{"Escape"===e.key&&!e.defaultPrevented&&tu()&&e.preventDefault()};e.addEventListener("keydown",tx);let ty=e=>{let r=e.target,n=r?.closest?.(`[${t}]`),a=n?.getAttribute(t)??null;a!==eJ&&(eJ=a,e7())},tw=()=>{eJ=null,e7()};e.addEventListener("pointerover",ty),l.addEventListener("pointerleave",tw),s?.addEventListener("scroll",e7,{capture:!0,passive:!0}),s?.addEventListener("resize",e7);let tk=s?.MutationObserver,tE="function"==typeof tk?new tk(e7):null;tE?.observe(e.body,{childList:!0,subtree:!0});let tC=s?.ResizeObserver,tA="function"==typeof tC?new tC(e7):null;tA?.observe(l);let tN=s?.matchMedia?.("(min-width: 768px)")??null;eK=tN?.matches??!0;let tL=()=>{eK=tN?.matches??!0,ti()};tN?.addEventListener?.("change",tL);let tP=n.on("change",ta);return l.setAttribute("data-obelism-editor",""),e.head.appendChild(u),e.body.appendChild(p),ti(),()=>{eQ=!0,tP(),e0.unmount(),null!==e8&&s?.cancelAnimationFrame?.(e8),e.removeEventListener("keydown",tx),e.removeEventListener("pointerover",ty),l.removeEventListener("pointerleave",tw),s?.removeEventListener("scroll",e7,{capture:!0}),s?.removeEventListener("resize",e7),tN?.removeEventListener?.("change",tL),tE?.disconnect(),tA?.disconnect(),n.setSelecting(!1),l.removeAttribute("data-obelism-editor"),l.removeAttribute("data-obelism-docked"),l.style.removeProperty("--obelism-dock"),u.remove(),p.remove()}},et=Symbol.for("@obelism/content/bridge"),er=C({isEditing:!1,entryId:null,on:()=>{}},new URLSearchParams),en=({url:e,prompt:p=!0,pagePath:c,productPath:b,collectionPath:x}={})=>{let y;if("u"<typeof window)return er;let A=window;if(A[et])return A[et];if(A.ObelismBridge)y=C(A.ObelismBridge,new URLSearchParams(A.location.search));else{let C=(y=((e,r)=>{let n,a,p,c,b,x=new URLSearchParams(e.location.search),y=e.parent!==e&&x.has("cms_preview"),C=v(),A=[],N={...f,selecting:!0},L=e=>{N={...N,...e},C.emit("change",N)},P={isEditing:y,mode:y?"editor":null,entryId:x.get("cms_entry"),environment:x.get(i),product:null,collection:null,on:C.on,getState:()=>N,...w,destroy:()=>{A.splice(0).forEach(e=>e())}};if(!y)return P;let S=e.document,$=(t,n={})=>{e.parent.postMessage({source:h,type:t,...n},r)},M=S.createElement("style");M.textContent=m(),S.head.appendChild(M),A.push(()=>M.remove());let U=(e,t)=>{if(S.querySelectorAll("[data-cms-selected]").forEach(e=>{e.removeAttribute("data-cms-selected")}),N.selectedUid!==(e??null)&&L({selectedUid:e??null}),!e)return;let r=S.querySelector(E(e));r&&(r.setAttribute("data-cms-selected",""),t&&r.scrollIntoView({behavior:"smooth",block:"center"}))},z=e=>{let r=e.target,n=r?.closest?.(`[${t}]`);if(!n)return;e.preventDefault(),e.stopPropagation();let a=n.getAttribute(t);U(a,!1),$("select",{uid:a})};S.addEventListener("click",z,!0),A.push(()=>S.removeEventListener("click",z,!0));let I=()=>Math.ceil(Math.max(S.documentElement.scrollHeight,S.body?.scrollHeight??0)),O=0,j=()=>{O=I(),$("ready",{url:e.location.href,height:O})},R=e.ResizeObserver;if("function"==typeof R){let e=new R(()=>{let e=I();e!==O&&(O=e,$("size",{height:e}))});e.observe(S.documentElement),S.body&&e.observe(S.body),A.push(()=>e.disconnect())}let D=new Map,T=0,q=e=>{let t=D.get(e);return t?(clearTimeout(t.timer),D.delete(e),0===D.size&&L({prompting:!1}),t):null};P.prompt=(e,t={})=>{let r=e.trim();if(!r)return Promise.reject(Error("Say what to change"));if(!N.features.includes("prompt"))return Promise.reject(Error("The editor does not offer prompts here"));let n=`prompt_${++T}`,a=void 0===t.uid?N.selectedUid:t.uid;return new Promise((e,t)=>{let i=setTimeout(()=>{q(n)?.reject(Error("The editor did not answer in time"))},12e4);D.set(n,{resolve:e,reject:t,timer:i}),L({prompting:!0}),$("prompt",{id:n,prompt:r,uid:a})})},P.undo=()=>$("undo"),P.select=e=>{U(e,!1),$("select",{uid:e})};let F=null;A.push(()=>F?.destroy()),A.push(()=>{for(let e of D.keys())q(e)?.reject(Error("The bridge was destroyed"))});let B=(n=new WeakSet,a=null,p=null,c=!1,b=()=>{if(null!==a){for(let e of Array.from(S.styleSheets)){let t;if(!n.has(e)){try{t=e.cssRules}catch{continue}n.add(e),g(t,a)}}S.querySelectorAll('[style*="vh"]').forEach(e=>{u(e.style,a)})}},{freeze(e){if(null!==a||!(e>0))return;a=e,b();let t=S.defaultView?.MutationObserver;t&&(p=new t(()=>{if(c)return;c=!0;let e=()=>{c=!1,b()};S.defaultView?.requestAnimationFrame?S.defaultView.requestAnimationFrame(e):e()})).observe(S.documentElement,{childList:!0,subtree:!0})},destroy(){p?.disconnect()}});A.push(()=>B.destroy());let H=t=>{if(t.origin!==r||t.source!==e.parent)return;let n=t.data;if(n&&"obelism-content-editor"===n.source){if("connect"===n.type)j();else if("update"===n.type&&n.entry)C.emit("update",{entry:n.entry,selectedUid:n.selectedUid??null}),e.requestAnimationFrame(()=>U(n.selectedUid,!1)),F?.refresh();else if("select"===n.type)U(n.uid,!0);else if("saved"===n.type||"published"===n.type)C.emit(n.type,{}),0===C.listeners.update.size&&e.location.reload();else if("features"===n.type&&Array.isArray(n.features))L({features:n.features.filter(e=>"string"==typeof e)});else if("stats"===n.type)L({stats:(e=>{if(!e||"object"!=typeof e||Array.isArray(e))return{};let t={};for(let[r,n]of Object.entries(e)){let{clicks:e,clickers:a,viewers:i,rate:o}=n??{};k(e)&&k(a)&&k(i)&&k(o)&&(t[r]={clicks:e,clickers:a,viewers:i,rate:o})}return t})(n.stats),statsVisible:!1!==n.visible}),(F||Object.keys(N.stats).length)&&(F??(F=((e,{selector:t,onSelect:r,labels:n})=>{let a=e.document,i={...o,...n},p=a.createElement("div");p.setAttribute("data-obelism-stats","");let c=p.attachShadow({mode:"open"}),u=a.createElement("style");u.textContent=l;let g=a.createElement("div");g.className="layer",c.append(u,g),a.body.appendChild(p);let h={},b=!1,m=null,f=()=>{if(m=null,g.replaceChildren(),g.hidden=!b,!b)return;let n=e.innerHeight;for(let[o,l]of Object.entries(h)){let p=a.querySelector(t(o));if(!p)continue;let c=p.getBoundingClientRect();if(!c.width&&!c.height||c.bottom<0||c.top>n)continue;let u=a.createElement("button");u.type="button",u.className="badge",u.dataset.uid=o,u.textContent=s(i.clicked,{rate:Math.round(100*l.rate)}),u.title=s(i.title,{clickers:l.clickers,viewers:l.viewers,clicks:l.clicks});let{place:h,top:b,left:m}=d(c,e.innerWidth);u.dataset.place=h,u.style.top=`${b}px`,u.style.left=`${m}px`,u.addEventListener("click",()=>r(o)),g.appendChild(u)}},v=()=>{null===m&&b&&(m=e.requestAnimationFrame(f))};e.addEventListener("scroll",v,{capture:!0,passive:!0}),e.addEventListener("resize",v);let x=e.MutationObserver,y="function"==typeof x?new x(v):null;return y?.observe(a.body,{childList:!0,subtree:!0}),{update(t,r){h=t,b=r,null!==m&&(e.cancelAnimationFrame?.(m),m=null),f()},refresh:v,destroy(){null!==m&&e.cancelAnimationFrame?.(m),e.removeEventListener("scroll",v,{capture:!0}),e.removeEventListener("resize",v),y?.disconnect(),p.remove()}}})(e,{selector:E,onSelect:e=>P.select(e)})),F.update(N.stats,N.statsVisible));else if("viewport"===n.type&&"number"==typeof n.height)B.freeze(n.height);else if("promptState"===n.type)L({canUndo:!0===n.canUndo});else if("promptResult"===n.type&&"string"==typeof n.id){let e=q(n.id);if(!e)return;!0===n.ok?e.resolve({summary:"string"==typeof n.summary?n.summary:""}):e.reject(Error("string"==typeof n.error?n.error:"The prompt failed"))}}};return e.addEventListener("message",H),A.push(()=>e.removeEventListener("message",H)),"loading"===S.readyState?(S.addEventListener("DOMContentLoaded",j,{once:!0}),A.push(()=>S.removeEventListener("DOMContentLoaded",j))):j(),P})(A,new URL(e||V).origin)).isEditing||A.parent!==A?null:(e=>{for(let t of e.cookie.split(";")){let[e,...r]=t.trim().split("=");if("obelism_content_editing"===e)try{let e=decodeURIComponent(r.join("="));return W.test(e)?e:null}catch{break}}return null})(A.document);if(C&&(y=((e,i,{pagePath:o=e=>`/${e.replace(/^\/+/,"")}`,productPath:s,collectionPath:l}={})=>{let d=e.document,p=v(),c=[],u=new Map,g=[],b=new Set,x=null,y=null,w=-1/0,k=new Map,C=f,A=e=>{C={...C,...e},p.emit("change",C)},N=()=>A({unsaved:[...u.values()].some(({content:e,saved:t})=>!X(e,t)),canUndo:g.length>0,undoSteps:g.length}),L=async(t,r)=>{let n=await e.fetch(`${i}/api/${t}`,void 0===r?{credentials:"same-origin"}:{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json","x-obelism-content":"1"},body:JSON.stringify(r)}),a=await n.json().catch(()=>({}));if(401===n.status)throw A({features:[]}),Error("You were signed out. Sign in again to edit.");if(!n.ok)throw Error("string"==typeof a.error?a.error:`Obelism Content answered ${n.status}`);return a},P=()=>d.querySelector(`[${r}]`)?.getAttribute(r)??null,S=()=>{let e=d.querySelector(`[${n}]`),t=e?.getAttribute(n),r=e?.getAttribute("data-cms-product-handle");return t&&r?{id:t,handle:r}:null},$=()=>{let e=d.querySelector(`[${a}]`),t=e?.getAttribute(a),r=e?.getAttribute("data-cms-collection-handle");return t&&r?{id:t,handle:r}:null},M=e=>{let t=e?d.querySelector(E(e)):null;return t?.closest(`[${r}]`)?.getAttribute(r)??P()},U=()=>{if(!x)return;let e=x.space.locales.map(({code:e})=>e),t=d.documentElement.lang;if(e.includes(t))return t;let r=t.split("-")[0]??"";return e.includes(r)?r:x.space.defaultLocale},z=new Map,I=async e=>{let t=u.get(e);if(t)return t;let r=z.get(e);return r||(r=L(`entries/${encodeURIComponent(e)}`).then(t=>{let r=u.get(e)??{content:t.content,saved:t.content,revision:t.draftRevision};return u.set(e,r),r}).finally(()=>z.delete(e)),z.set(e,r)),r},O=e=>{let t=void 0===e?C.selectedUid:e,r=M(t);if(!r)throw Error("Nothing on this page is marked as an entry: add editable(entry)");return{uid:t,entryId:r}},j=e=>{d.querySelectorAll("[data-cms-selected]").forEach(e=>{e.removeAttribute("data-cms-selected")}),C.selectedUid!==e&&A({selectedUid:e}),e&&d.querySelector(E(e))?.setAttribute("data-cms-selected","")},R=async t=>{if(0===p.listeners.update.size)return;let r=u.get(t)?.content,{entry:n}=await L(`entries/${encodeURIComponent(t)}/preview`,{content:r,locale:U()});p.emit("update",{entry:n,selectedUid:C.selectedUid}),e.requestAnimationFrame(()=>j(C.selectedUid))},D=e=>console.error("[@obelism/content bridge]",e),T=t=>{p.emit(t,{}),0===p.listeners.update.size&&e.location.reload()},q=async()=>{for(let[e,t]of u){if(X(t.content,t.saved))continue;let{draftRevision:r}=await L(`entries/${encodeURIComponent(e)}/save`,{content:t.content,baseRevision:t.revision});t.saved=t.content,t.revision=r,b.add(e)}g.length=0,w=-1/0,N()},F={isEditing:!0,mode:"site",get entryId(){return P()},get product(){return S()},get collection(){return $()},get environment(){return x?.environment??null},on:p.on,getState:()=>C,async prompt(e,t={}){let r=e.trim();if(!r)throw Error("Say what to change");if(!C.features.includes("prompt"))throw Error("You may not edit content here");let{uid:n,entryId:a}=O(t.uid);A({prompting:!0});try{let e=await I(a),t=await L(`entries/${encodeURIComponent(a)}/prompt`,{prompt:r,content:e.content,locale:U(),uid:n});return g.push({entryId:a,content:e.content}),w=-1/0,e.content=t.content,N(),await R(a),{summary:t.summary}}finally{A({prompting:!1})}},async createPage(t,r){let n=r.trim();if(!n)throw Error("Say what the page is for");if(!t.trim())throw Error("Say where the page goes, like /pricing");if(!C.features.includes("create"))throw Error("You may not add pages here");if(C.unsaved)throw Error("Save or undo your changes before adding a page");A({prompting:!0});try{let r=await L("entries",{path:t,prompt:n,locale:U(),from:P()}),a=o(r.path,U()??"");return e.location.assign(Y(a)),{summary:r.summary,entryId:r.entryId,path:r.path,url:a}}finally{A({prompting:!1})}},async createProductPage(t=S()??void 0){if(!t)throw Error("Nothing on this page is marked as a product: add editableProduct(product)");if(!C.features.includes("create"))throw Error("You may not add pages here");if(C.unsaved)throw Error("Save or undo your changes before adding a page");A({prompting:!0});try{let r=await L("product-pages",{product:{id:t.id,handle:t.handle}});return e.location.reload(),r}finally{A({prompting:!1})}},async createCollectionPage(t=$()??void 0){if(!t)throw Error("Nothing on this page is marked as a collection: add editableCollection(collection)");if(!C.features.includes("create"))throw Error("You may not add pages here");if(C.unsaved)throw Error("Save or undo your changes before adding a page");A({prompting:!0});try{let r=await L("collection-pages",{collection:{id:t.id,handle:t.handle}});return e.location.reload(),r}finally{A({prompting:!1})}},async view(e={}){let{uid:t,entryId:r}=O(e.uid),n=await I(r),{view:a}=await L(`entries/${encodeURIComponent(r)}/view`,{content:n.content,locale:U(),uid:t});return a},async applyJson(e,t={}){if(!C.features.includes("prompt"))throw Error("You may not edit content here");if(!e||"object"!=typeof e||Array.isArray(e))throw Error("Send the fields to change as an object");let{uid:r,entryId:n}=O(t.uid);A({prompting:!0});try{let t=await I(n),a=await L(`entries/${encodeURIComponent(n)}/apply`,{changes:e,content:t.content,locale:U(),uid:r});return X(a.content,t.content)||(g.push({entryId:n,content:t.content}),w=-1/0,t.content=a.content,N(),await R(n)),{changed:a.changed??[],...a.view&&{view:a.view}}}finally{A({prompting:!1})}},openForm(t,r={}){let{title:n="Content form",onReady:a,onError:i,onEscape:o}=r;y?.();let s=!1,l=null,d=null,c=()=>{},b=e=>{s||i?.(e instanceof Error?e.message:String(e))},m=()=>{s||(s=!0,c(),l?.destroy(),y===m&&(y=null))};y=m;let f=()=>{if(s||!l)return;let e=M(C.selectedUid);if(!e)return;let t=u.get(e);if(!t)return void I(e).then(f,b);let r={entryId:e,content:t.content,locale:U(),selectedUid:C.selectedUid};d&&d.entryId===r.entryId&&d.content===r.content&&d.locale===r.locale&&d.selectedUid===r.selectedUid||(d=r,l.show(r))},v=(e,t)=>{let r=t??d?.entryId,n=void 0===r?void 0:u.get(r);if(s||void 0===r||!n||X(e,n.content))return;let a=Date.now();a-w>=1e3&&g.push({entryId:r,content:n.content}),w=a,n.content=e,d?.entryId===r&&(d={...d,content:e}),N(),clearTimeout(k.get(r)),k.set(r,setTimeout(()=>{k.delete(r),R(r).catch(D)},300))};return(async()=>{if(!C.features.includes("form"))throw Error("You may not edit content here");await I(O(void 0).entryId);let{url:r}=await L("form",{});s||(l=((e,t,r,n,a)=>{let i=null;try{i=new URL(r)}catch{}if(!i||!/^https?:$/.test(i.protocol))throw Error("Obelism Content sent no form to open");let o=i.origin,s=t.ownerDocument.createElement("iframe");s.title=n,s.src=r;let l=!1,d=!1,p=null,c=()=>{l&&p&&s.contentWindow?.postMessage({source:h,type:"content",...p},o)},u=setTimeout(()=>{d||a.onError("The form did not open")},3e4),g=()=>{d=!0,clearTimeout(u),a.onReady()},b=e=>{if(e.origin!==o||!s.contentWindow||e.source!==s.contentWindow)return;let t=e.data;if(t&&"obelism-content-form"===t.source)if("ready"===t.type)l=!0,c(),!0!==t.loading&&g();else if("loaded"===t.type)l&&g();else{let e;if("change"!==t.type||!(e=t.content)||"object"!=typeof e||Array.isArray(e))if("height"===t.type){let e=t.height;if("number"==typeof e&&Number.isFinite(e)){let t=Math.round(Math.min(Math.max(e,80),4e3));s.style.height=`min(${t}px, 60vh)`}}else"escape"===t.type?a.onEscape?.():"error"===t.type&&a.onError("string"==typeof t.message&&t.message?t.message:"The form failed");else a.onChange(t.content,"string"==typeof t.entryId?t.entryId:void 0)}};return e.addEventListener("message",b),t.appendChild(s),{show(e){p=e,c()},destroy(){clearTimeout(u),e.removeEventListener("message",b),s.remove()}}})(e,t,"string"==typeof r?r:"",n,{onReady:()=>a?.(),onChange:v,onError:e=>i?.(e),onEscape:()=>o?.()}),c=p.on("change",f),f())})().catch(b),{close:m}},async pages(){let{pages:e}=await L("pages"),t=[U(),x?.space.defaultLocale];return e.flatMap(e=>{let r,n,a=t.find(t=>void 0!==t&&void 0!==e.paths[t])??Object.keys(e.paths)[0],i=void 0===a?void 0:e.paths[a];return void 0===a||void 0===i?[]:[{entryId:e.entryId,name:e.name,contentType:e.contentType,status:e.status,path:i,url:e.product?(r=e.product.handle,s?s(r,a):(x?.productPath??"/products/{handle}").replaceAll("{handle}",encodeURIComponent(r))):e.collection?(n=e.collection.handle,l?l(n,a):(x?.collectionPath??"/collections/{handle}").replaceAll("{handle}",encodeURIComponent(n))):o(i,a),product:e.product??null,collection:e.collection??null}]})},openPage(t){(!C.unsaved||e.confirm("Leave this page and lose the changes you have not saved?"))&&(u.clear(),g.length=0,N(),e.location.assign(Y(t.url)))},undo(){let e=g.pop(),t=e&&u.get(e.entryId);e&&t&&(w=-1/0,t.content=e.content,N(),R(e.entryId).catch(D))},async save(){if(!C.features.includes("save"))throw Error("You may not edit content here");A({saving:!0});try{await q()}finally{A({saving:!1})}T("saved")},async publish(){if(!C.features.includes("publish"))throw Error("You may not publish here");A({publishing:!0});try{await q();let e=P(),t=b.size>0?[...b]:e?[e]:[];if(0===t.length)throw Error("Nothing on this page is marked as an entry: add editable(entry)");for(let e of t)await L(`entries/${encodeURIComponent(e)}/publish`,{}),b.delete(e)}finally{A({publishing:!1})}T("published")},signOut(){if(C.unsaved&&!e.confirm("Sign out and lose the changes you have not saved?"))return;u.clear(),N();let t=e.location.pathname+e.location.search;e.location.href=`${i}/logout?return_to=${encodeURIComponent(t)}`},select(e){j(e)},setSelecting(e){e?d.documentElement.setAttribute("data-cms-selecting",""):d.documentElement.removeAttribute("data-cms-selecting"),A({selecting:e})},destroy(){y?.(),k.forEach(e=>clearTimeout(e)),k.clear(),c.splice(0).forEach(e=>e())}},B=d.createElement("style");B.textContent=m("html[data-cms-selecting] "),d.head.appendChild(B),c.push(()=>B.remove()),c.push(()=>d.documentElement.removeAttribute("data-cms-selecting"));let H=e=>{if(!C.selecting)return;let r=e.target,n=r?.closest?.(`[${t}]`);n&&(e.preventDefault(),e.stopPropagation(),j(n.getAttribute(t)))};d.addEventListener("click",H,!0),c.push(()=>d.removeEventListener("click",H,!0));let _=e=>{C.unsaved&&(e.preventDefault(),e.returnValue="")};return e.addEventListener("beforeunload",_),c.push(()=>e.removeEventListener("beforeunload",_)),L("session").then(e=>{x=e,A({features:e.features})}).catch(e=>console.error("[@obelism/content bridge]",e)),F})(A,C,{pagePath:c,productPath:b,collectionPath:x})),y.isEditing&&p){let e=A.document,t=()=>{},r=!1,n=C?ee:_,a=()=>{r||(t=n(e,y,!0===p?{}:p))};e.body?a():e.addEventListener("DOMContentLoaded",a,{once:!0});let i=y.destroy;y.destroy=()=>{r=!0,e.removeEventListener("DOMContentLoaded",a),t(),i()}}}return A[et]=y,y};(e=window).ObelismBridge=en((e=>{let t=e?.dataset.url,r=t||V;if(!t&&e?.src){let t=new URL(e.src);"/bridge.js"===t.pathname&&(r=t.origin)}return{url:r,prompt:e?.dataset.prompt!=="false"}})(document.currentScript)),e.ObelismContent={getContentBridge:en,mountPromptBox:_,mountSiteEditor:ee}}();
|