mnfst 0.5.319 → 0.5.320

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.
@@ -1103,7 +1103,10 @@
1103
1103
  const c = el.cloneNode(true);
1104
1104
  const src = [el, ...el.querySelectorAll('*')], dst = [c, ...c.querySelectorAll('*')];
1105
1105
  dst.forEach((n, i) => { if (addedTab.has(src[i])) n.removeAttribute('tabindex'); });
1106
+ // x-for / x-if output re-renders from the copied template
1107
+ const gen = dst.filter((n, i) => i > 0 && isGenerated(src[i]));
1106
1108
  unrich(el, c);
1109
+ gen.forEach(n => n.remove());
1107
1110
  c.querySelectorAll('[data-edit-handle], [data-edit-live], [data-edit-ghost]').forEach(n => n.remove());
1108
1111
  [c, ...c.querySelectorAll('*')].forEach(n => {
1109
1112
  [...n.attributes].forEach(a => { if (a.name.startsWith('data-edit-') && !(keepKeys && a.name === 'data-edit-key')) n.removeAttribute(a.name); });
@@ -2582,7 +2585,7 @@
2582
2585
  if (ids && ids[originOf(id)]) n.fp = ids[originOf(id)];
2583
2586
  const e = editsFor(id); if (e) n.edits = e;
2584
2587
  if (scoped.has(el)) n.edits = Object.assign({}, n.edits, { style: ownStyle(el) || null });
2585
- if (!(e && 'text' in e) && !isRendered(el) && !el.hasAttribute('data-rich-text')) {
2588
+ if (!(e && 'text' in e) && !isRendered(el) && el.tagName !== 'TEMPLATE' && !el.hasAttribute('data-rich-text')) {
2586
2589
  const kids = treeKids(el).map(c => build(c)).filter(Boolean);
2587
2590
  const structural = ss.touched.has(isRoot ? '#' + region : id);
2588
2591
  if (id[0] === '~' || structural) { n.children = kids; const b = structural && id[0] !== '~' && baseOf(isRoot ? '' : id); if (b) n.base = b; }
@@ -1,2 +1,2 @@
1
- !function(){const t=t=>"mnfst-edit-log:"+(t||location.pathname);let e=location.pathname;const n=["text","move","size","data"],r=["text","move"],o=["move","remove","duplicate","text","attrs","size"],i={sort:".move",authoring:"nothing (visuals are on by default; use .bare to hide them, .persist to keep edits)",style:"$edit.classes / $edit.attr",none:".lock"};let s=null,a=0,l=[],c=0;const d={},u=new WeakSet,f=["x-html","x-text","x-markdown","x-icon","x-svg","x-code","x-code-group","x-chart","x-anchors","x-carousel","x-color","x-colorpicker","x-combobox","x-date","x-defer","x-virtual","x-import"],m=t=>[...t.attributes].some(t=>{const e=t.name.toLowerCase();return f.some(t=>e===t||e.startsWith(t+"."))}),p=new Set(["SCRIPT","STYLE","TEXTAREA","TITLE","NOSCRIPT","TEMPLATE","XMP","IFRAME","NOEMBED","NOFRAMES"]),h=t=>[...t.children].find(t=>"TEMPLATE"===t.tagName&&t.hasAttribute("x-for"))||null;function g(t){if(m(t))return"";let e="";for(const n of t.childNodes)3===n.nodeType?e+=n.textContent:1!==n.nodeType||bt(n)||"TEMPLATE"===n.tagName||A(n)||n._manifestComponent||(e+=g(n));return e}const b=t=>t.tagName.toUpperCase()+":"+g(t).replace(/\s+/g," ").trim().slice(0,24),y=(t,e)=>"@"+encodeURIComponent(t)+"@"+e,v=t=>t&&"~"===t[0]?t.slice(t.indexOf("~",1)+1):t;let E=0;const w=()=>Date.now().toString(36)+(++E).toString(36)+Math.random().toString(36).slice(2,6);function A(t){for(let e=t.previousElementSibling;e;e=e.previousElementSibling){if("TEMPLATE"!==e.tagName)continue;if(e._x_currentIfEl===t)return!0;const n=e._x_lookup;if(n&&(n instanceof Map?[...n.values()]:Object.values(n)).includes(t))return!0}return!1}function k(t){const e=Object.create(null);return kt(t).map(t=>{const n=t.getAttribute("data-edit-host")||t.getAttribute("data-edit-key");if(n)return n;const r=b(t),o=e[r]=(e[r]||0)+1;return o>1?r+"#"+o:r})}let _=[];const x=new WeakSet,S=new Set([location.pathname]),T=e=>{if(l.length>400){const t=l.length-400;l.splice(0,t),c=Math.max(0,c-t)}const n=l.slice(0,c).filter(t=>u.has(t)),r=l.slice(c).filter(t=>u.has(t));S.add(e||location.pathname);const o=_.filter(t=>x.has(t));(e?[e]:[...S]).forEach(e=>{try{n.length||r.length||o.length?localStorage.setItem(t(e),JSON.stringify(Object.assign({v:8,log:[...n,...r],cursor:n.length},o.length?{conflicts:o}:{}))):localStorage.removeItem(t(e))}catch{}})},C=(t,e)=>JSON.stringify(t)===JSON.stringify(e);function O(t,e){for(let n=t;n&&1===n.nodeType;n=n.parentElement){const t=getComputedStyle(n).getPropertyValue(e).trim();if(t)return t}return""}function L(t,e,n){const r=O(t,e);return r?"none"===r&&"--edit-size"!==e?n??"":r:n??""}function M(t,e){if(!e&&!/--rich-text-/.test(t))return t;const n=document.createElement("div");n.setAttribute("style",t),e&&n.style.removeProperty("position");const r=[];for(let t=0;t<n.style.length;t++)r.push(n.style.item(t));return r.filter(t=>t.startsWith("--rich-text-")).forEach(t=>n.style.removeProperty(t)),n.getAttribute("style")||""}const P=t=>M(t.getAttribute("style")||"",!!t._editPos),R=t=>t?t.tagName.toLowerCase():"",j=new Set(["B","I","EM","STRONG","U","S","SMALL","CODE","MARK","SUB","SUP","BR","SPAN","A"]),$=t=>!!t&&1===t.nodeType&&t.hasAttribute("data-rich-text")&&!t._editRt,N=t=>window.ManifestRichText.sanitize(t,!1,!0);let B=!1;const H=t=>{const e=document.createTreeWalker(t,NodeFilter.SHOW_COMMENT),n=[];for(let t=e.nextNode();t;t=e.nextNode())n.push(t);return n},q=(t,e)=>!(X(e.name,e.value,t.tagName)||"style"===e.name&&/expression|url\s*\(|javascript:|@import/i.test(e.value));function D(t){const e=Nt.interactive.join(","),n=!!t.closest("a, button");return[...t.querySelectorAll(e)].forEach(r=>{const o=r.parentElement&&r.parentElement.closest(e);(n||o&&t.contains(o))&&r.replaceWith(...r.childNodes)}),t.innerHTML.trim()}const W=(t,e)=>window.ManifestRichText?$(t)?window.ManifestRichText.sanitize(e,!0,!0):function(t,e){const n=document.createElement("template");n.innerHTML=String(null==t?"":t);const r=[],o="mnfst"+Math.random().toString(36).slice(2)+Date.now().toString(36),i=new RegExp("("+o+"\\d+_)");if(H(n.content).forEach(t=>{if(e=t.data,!/^-?>|-->|--!>|<!-$/.test(e))return t.replaceWith(o+r.length+"_"),void r.push(t.data);var e;t.remove(),B||(B=!0,console.warn("[edit] a comment that cannot be written back as it is was left out of edited text"))}),n.innerHTML=N(n.innerHTML),r.length){const t=document.createTreeWalker(n.content,NodeFilter.SHOW_TEXT),e=[];for(let n=t.nextNode();n;n=t.nextNode())n.nodeValue.includes(o)&&e.push(n);e.forEach(t=>t.replaceWith(...t.nodeValue.split(i).filter(Boolean).map(t=>i.test(t)&&t.startsWith(o)?document.createComment(r[parseInt(t.slice(o.length),10)]):document.createTextNode(t))))}!function(t){const e=t=>{let e=t.lastChild;for(;e&&8===e.nodeType;)e=e.previousSibling;return e};for(let n=0;n<1e3;n++){let n=e(t);for(;n&&1===n.nodeType&&"BR"!==n.tagName&&e(n);)n=e(n);if(!n||n===t)return;if(!(3===n.nodeType?!n.nodeValue.trim():"BR"===n.tagName||!e(n)&&!/^(IMG|WBR)$/.test(n.tagName)))return;n.remove()}}(n.content),n.content.querySelectorAll("*").forEach(t=>[...t.attributes].forEach(e=>{q(t,e)||t.removeAttribute(e.name)}));const s=Nt.interactive.join(","),a=!!(e&&e.closest&&e.closest("a, button"));return[...n.content.querySelectorAll(s)].forEach(t=>{(a||t.parentElement&&t.parentElement.closest(s))&&t.replaceWith(...t.childNodes)}),n.content.querySelectorAll("a").forEach(t=>{t.textContent.trim()||t.querySelector("img")||t.replaceWith(...t.childNodes)}),n.innerHTML.trim()}(e,t):function(t){const e=document.createElement("template");e.innerHTML=String(null==t?"":t);const n=t=>[...t.childNodes].forEach(t=>{if(8===t.nodeType)return t.remove();1===t.nodeType&&(j.has(t.tagName)?([...t.attributes].forEach(e=>{const n=e.name.toLowerCase();("A"!==t.tagName||"href"!==n||X("href",e.value,"A"))&&t.removeAttribute(e.name)}),n(t)):t.replaceWith(document.createTextNode(t.textContent)))});return n(e.content),e.innerHTML}(e);function I(t,e){const n=W(t,e);t.innerHTML===n||$(t)&&W(t,t.innerHTML.trim())===n||(t.innerHTML=n,t._rt&&"function"==typeof t._rt.settle&&t._rt.settle())}const z={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" ",tab:"\t",newline:"\n",colon:":"},F=t=>String(t).replace(/&(#x[0-9a-f]+|#\d+|[a-z]+);?/gi,(t,e)=>{if("#"===e[0]){const n=/^#x/i.test(e)?parseInt(e.slice(2),16):parseInt(e.slice(1),10);return n>=0&&n<1114112?String.fromCodePoint(n):t}const n=z[e.toLowerCase()];return void 0===n?t:n}),K={script:["src","type"],iframe:["src","srcdoc"],embed:["src","srcdoc"],object:["src","srcdoc","data"],frame:["src","srcdoc"],link:["href","rel"],base:["href","rel"],meta:["http-equiv","content"]},U=new Set(["set","animate","animatetransform","animatemotion"]),J=/^data:image\/(png|jpeg|gif|webp|avif)[;,]/;function X(t,e,n){const r=String(t||"").trim().toLowerCase(),o=String(n||"").toLowerCase();if(!r||!/^[a-z_][\w:.-]*$/i.test(r))return/^[@:]/.test(r)?"Alpine directive":"invalid name";if("text"===r)return"reserved name";if("action"===r||"formaction"===r)return"form target";if(r.startsWith("on"))return"event handler attribute";if(r.startsWith("x-"))return"Alpine directive";if(r.startsWith("data-edit-"))return"plugin attribute";if("srcdoc"===r)return"inline document";if(U.has(o)&&["attributename","to","values","from","by"].includes(r))return"SVG animation target";if(K[o]&&K[o].includes(r))return"loads or runs content";if(null==e)return null;for(const t of[String(e),F(e)]){const e=t.replace(/[\u0000-\u0020\u007f]/g,"").toLowerCase();if(/(^|[,(;'"=])(javascript|vbscript):/.test(e))return"script URL";const n=e.match(/(^|[,(;'"=])data:[^,)]*/g)||[];if(n.length&&("img"!==o&&"source"!==o||"src"!==r&&"srcset"!==r||!n.every(t=>J.test(t.replace(/^[,(;'"=]/,"")))))return"data URL"}return null}const V=new Set,Y={},G=new Set,Q=t=>{const e=ct(t);for(let n=t&&t.parentElement;n;n=n.parentElement){if(m(n))return!0;if(n===e)break}return!1},Z=f.filter(t=>"x-code-group"!==t&&"x-carousel"!==t&&"x-defer"!==t);function tt(t){for(let e=t&&t.parentElement;e;e=e.parentElement){if(1!==e.nodeType)continue;const t=[...e.attributes].map(t=>t.name.toLowerCase()).find(t=>Z.some(e=>t===e||t.startsWith(e+".")));if(t)return t.split(".")[0]}return null}function et(t,e,s){if(e.includes("cssvar"))return function(t,e,n){const r=(e||"").trim(),o=r.match(/^([\w-]+)\s*:\s*(--[\w-]+)$/);t._cssvar=o?{scope:o[1],var:o[2]}:{scope:null,var:r},t._cssvar.persist=!(!n||!n.includes("persist")),Lr.add(t)}(t,s,e);if(e.forEach(t=>{i[t]&&!G.has(t)&&(G.add(t),console.warn(`[edit] x-edit.${t} was removed — use ${i[t]}`))}),e.includes("grab"))return;if(e.includes("lock")){const n=e.filter(t=>o.includes(t));return void(t._editLock=new Set(n.length?n:["*"]))}const l=new Set(n.filter(t=>e.includes(t))),c=e.includes("theme"),d=(s||"").trim()||"area-"+ ++a;if(c&&(Y[d]=t),c&&!l.size)return void(e.includes("persist")&&(t._editPersist=!0));l.size||r.forEach(t=>l.add(t)),(s||"").trim()&&[...V].some(e=>e!==t&&e._edit&&e._edit.key===d)&&console.warn("[edit] duplicate x-edit key (deltas will mis-route):",d);const u=e.includes("bare");t._edit={key:d,caps:l,gated:e.includes("gated"),theme:c,persist:e.includes("persist"),bare:u,rendered:tt(t)},t.setAttribute("data-edit-area",u?"bare":""),V.add(t),ot()}let nt=null;const rt=()=>nt||(nt=[...V].filter(t=>{for(let e=t;e;e=e.parentElement){if(e!==t&&e._edit)return!1;if(e._manifestComponent||e!==t&&m(e))return!0}return!0})),ot=()=>{nt=null},it=t=>rt().find(e=>e._edit.key===t),st=t=>rt().filter(e=>e._edit.key===t._edit.key).length>1;function at(t){if(void 0!==t._editSrc)return t._editSrc;let e=null;for(let n=t;n;n=n.parentElement){if(!n._manifestComponent)continue;const r=n===t&&window.ManifestComponentsLoader&&window.ManifestComponentsLoader.cache[n._manifestComponent],o=new RegExp("\\sx-edit(?:\\.[\\w-]+)*\\s*=\\s*([\"'])"+t._edit.key.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"\\1");(n!==t||r&&o.test(r))&&(e=n._manifestComponent);break}return t._editSrc=e}const lt=t=>{const e=at(t);return e?function(t){const e=window.ManifestComponentsRegistry&&window.ManifestComponentsRegistry.manifest||{},n=[...e.preloadedComponents||[],...e.components||[]].find(e=>String(e).split("/").pop().replace(".html","")===t);return String(n||"components/"+t+".html").replace(/^\/+/,"")}(e):"index.html"},ct=t=>t&&rt().reduce((e,n)=>n!==t&&!n.contains(t)||e&&!e.contains(n)?e:n,null),dt=t=>t._edit.key,ut=(t,e)=>{const n=function(t){for(let e=t;e;e=e.parentElement)if(e._edit)return e._edit;return null}(t);return!!n&&n.caps.has(e)&&!ke(t,e)},ft=t=>{const e=null!=t&&it(t);return!(!e||!e._edit.persist)};function mt(t){return h(t)?"data":t.matches("[data-component]")&&!at(t)||pt(t)?"component":"static"}const pt=t=>{const e=At(t).filter(t=>"TEMPLATE"!==t.tagName),n=e[0];return 1!==e.length||!n.matches("[data-component]")||n._edit||n.querySelector("[data-edit-area]")?null:n};function ht(t){const e=h(t),n=e&&e.getAttribute("x-for").match(/\bin\s+(.+)$/);return n?n[1].trim():null}const gt=t=>{const e=ht(t),n=e&&e.match(/\$x\.(\w+)/);return n?n[1]:e||"source"},bt=t=>t.hasAttribute("data-edit-handle")||t.hasAttribute("data-edit-ghost"),yt=t=>t&&t._manifestHost&&t._manifestHost.roots&&t._manifestHost.roots[0]===t?t._manifestHost.roots.slice():[t],vt=t=>!!t._manifestHost&&!!t._manifestHost.roots&&t._manifestHost.roots[0]!==t,Et=t=>!!t&&1===t.nodeType&&t.hasAttribute("data-edit-host"),wt=t=>t.getAttribute("data-edit-host")||t.getAttribute("data-edit-key"),At=t=>Array.from(t.children).filter(t=>!bt(t)&&!vt(t)),kt=t=>At(t).filter(t=>"TEMPLATE"!==t.tagName);let _t=!1;function xt(t,e){const n=t.getAttribute("data-key");if(null!=n)return n;const r=h(e),o=r&&r._x_keyExpression;if(o)try{const e=window.Alpine.evaluate(t,o);if(null!=e)return String(e)}catch{}return _t||(_t=!0,console.warn("[edit] data area rows have no identity — add :key to the x-for or :data-key to the row, or the order cannot be stored")),null}const St=new Set(["P","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE","SPAN","A","LABEL","STRONG","EM","B","I","U","S","SMALL","CODE","MARK","SUB","SUP","Q","CITE","ABBR","TIME","DT","DD","FIGCAPTION","CAPTION","LEGEND","SUMMARY","BUTTON","OPTION"]),Tt=new Set(["AREA","BASE","BR","COL","EMBED","HR","IMG","INPUT","LINK","META","PARAM","SOURCE","TRACK","WBR","VIDEO","AUDIO","CANVAS","SVG","svg","IFRAME","OBJECT","SELECT","TEXTAREA","PICTURE","MATH","math","TEMPLATE","SCRIPT","STYLE","NOSCRIPT","TITLE","XMP"]),Ct=new Set([...St,"LI","TD","TH"]);function Ot(t){if(!window.ManifestRichText)return!1;const e=t.cloneNode(!0);return e.querySelectorAll("[data-edit-handle], [data-edit-ghost]").forEach(t=>t.remove()),H(e).forEach(t=>t.remove()),!e.children.length||(e.querySelectorAll("*").forEach(t=>[...t.attributes].forEach(e=>{e.name.startsWith("data-edit-")&&t.removeAttribute(e.name)})),N(e.innerHTML)===e.innerHTML&&[...e.querySelectorAll("*")].every(t=>[...t.attributes].every(e=>q(t,e))))}const Lt=t=>Ct.has(t.tagName)&&At(t).length>0&&!!t.textContent.trim()&&Ot(t),Mt=t=>{for(let e=t&&t.parentElement;e&&1===e.nodeType;e=e.parentElement){if(e._editRtFormat)return e;if(e._edit)break}return null};function Pt(t){return!(!t||1!==t.nodeType||Tt.has(t.tagName)||bt(t)||(t=>St.has(t.tagName)||t.hasAttribute("data-rich-text")||(t=>[...t.childNodes].some(t=>3===t.nodeType&&t.textContent.trim()))(t)||Lt(t))(t))}function Rt(t){const e=[];let n=t.previousSibling;for(;;){let t=null;if(n&&3===n.nodeType){if(!/^[ \t]*(\r?\n)?[ \t]*$/.test(n.textContent))break;t=n,n=n.previousSibling}if(!n||8!==n.nodeType)break;let r=n.previousSibling;for(;r&&3===r.nodeType&&!r.textContent.trim();)r=r.previousSibling;if(!r)break;e.unshift(n,...t?[t]:[]),n=n.previousSibling}return e}const jt=t=>t?Rt(t)[0]||t:null;function $t(t,e){const n=Rt(t),r=yt(t).slice(1);e(t),n.length&&t.before(...n),r.length&&t.after(...r)}const Nt={only:{table:["caption","colgroup","thead","tbody","tfoot","script","template","style"],thead:["tr","script","template"],tbody:["tr","script","template"],tfoot:["tr","script","template"],tr:["td","th","script","template"],colgroup:["col","template"],ul:["li","script","template"],ol:["li","script","template"],menu:["li","script","template"],dl:["dt","dd","div","script","template"],select:["option","optgroup","hr","script","template"],datalist:["option","script","template"],optgroup:["option","script","template"]},parent:{tr:["thead","tbody","tfoot"],td:["tr"],th:["tr"],caption:["table"],colgroup:["table"],col:["colgroup"],thead:["table"],tbody:["table"],tfoot:["table"],li:["ul","ol","menu"],dt:["dl","div"],dd:["dl","div"],option:["select","datalist","optgroup"],optgroup:["select"]},interactive:["a","button","input","select","textarea","details","label","iframe","embed","object","audio","video","keygen"],phrasingOnly:["p","h1","h2","h3","h4","h5","h6","pre"],block:["address","article","aside","blockquote","details","dialog","div","dl","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","main","menu","nav","ol","p","pre","search","section","table","ul","li","dd","dt"]};function Bt(t,e){if(!t||!e)return!1;if(t.parentElement===e)return!0;const n=[];for(let t=e;t&&1===t.nodeType;t=t.parentElement)n.push(t.tagName.toLowerCase());const r=new Set,o=t=>[t,...t.querySelectorAll("*")].forEach(t=>{1===t.nodeType&&(r.add(t.tagName.toLowerCase()),"TEMPLATE"===t.tagName&&t.content&&[...t.content.children].forEach(o))});yt(t).forEach(o);const i=new Set;for(let t=e;t;t=t.parentElement)t._manifestComponent&&i.add(t._manifestComponent);return!(i.size&&yt(t).some(t=>[t,...t.querySelectorAll("*")].some(t=>t._manifestComponent&&i.has(t._manifestComponent)))||function(t,e,n,r){const o=Nt;return o.only[e]&&!o.only[e].includes(t)?`<${e}> takes only ${o.only[e].filter(t=>"script"!==t&&"template"!==t&&"style"!==t).join(", ")}`:o.parent[t]&&!o.parent[t].includes(e)?`<${t}> belongs in ${o.parent[t].join(" or ")}`:"dt"!==t&&"dd"!==t||"div"!==e||"dl"===n[1]?r.has("form")&&n.includes("form")?"a form cannot contain a form":(n.includes("a")||n.includes("button"))&&o.interactive.some(t=>r.has(t))?"interactive content cannot go inside a link or button":o.phrasingOnly.includes(e)&&o.block.some(t=>r.has(t))?`<${e}> takes only inline content`:null:`<${t}> belongs in a dl`}(t.tagName.toLowerCase(),e.tagName.toLowerCase(),n,r))}const Ht=t=>{const e=String(t||"").match(/[a-z%]+$/i);return e?e[0]:null};function qt(t,e,n,r,o){if("rem"===e)return+(t/parseFloat(getComputedStyle(document.documentElement).fontSize)).toFixed(2);if("em"===e)return+(t/parseFloat(getComputedStyle(n).fontSize)).toFixed(2);if("%"===e){const e=(r||n.parentElement).getBoundingClientRect(),i="w"===o?e.width:e.height;return i?+(t/i*100).toFixed(2):0}return Math.round(t)}function Dt(t,e,n){const r=parseFloat(t);if(isNaN(r))return null;const o=Ht(t)||"px";if("rem"===o)return r*parseFloat(getComputedStyle(document.documentElement).fontSize);if("em"===o)return r*parseFloat(getComputedStyle(e).fontSize);if("%"===o){const t=(e.parentElement||e).getBoundingClientRect();return r/100*("h"===n?t.height:t.width)}return r}const Wt=(t,e,n)=>Math.min(Math.max(t,e),n),It="∅revert";let zt=0;const Ft=new WeakMap;function Kt(t,e){return l.splice(c),l.push(t),c=l.length,zt++,void 0===e&&(e=function(t){return"data-splice"!==t.kind&&"show"!==t.kind&&("st-move"===t.kind?ft(t.from)&&ft(t.to):null!=t.region&&ft(t.region))}(t)),e&&u.add(t),T(),jo(),t}function Ut(t,e){return"data"===e?{source:gt(t),order:kt(t).map(e=>xt(e,t))}:{}}async function Jt(t,e,n){t&&n&&("data"===e&&Xt(t,n.order),Qr(t)&&Jr(t))}function Xt(t,e){const n=ht(t),r=h(t);try{const t=window.Alpine.evaluate(r,n);if(!Array.isArray(t))return;const o=new Map(t.map(t=>[String(t.id),t])),i=e.map(t=>o.get(String(t))).filter(Boolean);t.forEach(t=>{e.map(String).includes(String(t.id))||i.push(t)}),t.splice(0,t.length,...i)}catch{}}function Vt(){const t={},e={},n={},r={};for(let o=0;o<c;o++){const i=l[o];if("cmp-main"!==i.kind&&"cmp-inst"!==i.kind||i.sig&&(r[i.component+"|"+i.path]=i.sig),"cmp-main"===i.kind)t[i.component]=t[i.component]||{},(t[i.component][i.path]=t[i.component][i.path]||{})[i.prop]=i.value;else if("cmp-inst"===i.kind){const t=i.region;i.value===It?(n[t]=n[t]||new Set,"*"===i.path?(delete e[t],n[t]=new Set(["*"])):(e[t]&&delete e[t][i.path],n[t].add(i.path))):(e[t]=e[t]||{},(e[t][i.path]=e[t][i.path]||{})[i.prop]=i.value,n[t]&&(n[t].delete(i.path),n[t].delete("*")))}}return{main:t,inst:e,reverts:n,sigs:r}}const Yt=t=>[t,...t.querySelectorAll("*")].filter(t=>null!=t._editPath);function Gt(){const{main:t,inst:e,sigs:n}=Vt();rt().forEach(r=>{if("component"!==mt(r))return;const o=fr(r),i=dt(r),s=pt(r);s&&Yt(s).forEach(s=>{const a=s._editPath,l=n[o+"|"+a];if(l&&R(s)!==l)return void console.warn("[edit] skip stale node (structure changed):",o,a);const c=e[i]&&e[i][a]||{},d=t[o]&&t[o][a]||{},u=r._baseText||{},f=r._baseClass||{},m=r._baseStyle||{},p=(t,e)=>void 0!==c[t]?c[t]:void 0!==d[t]?d[t]:e,h=p("text",u[a]),g=p("class",f[a]),b=p("style",m[a]);void 0!==h&&I(s,h),void 0!==g&&wr(s,g),void 0!==b&&s.getAttribute("style")!==b&&(""===b?s.removeAttribute("style"):s.setAttribute("style",b))})})}function Qt(t,e,n,r,o){const i=e._editPath,s=t._editScope||"instance",a=fr(t),l=dt(t);if(null==i)return!1;if("text"===n&&(r=W(e,r)),void 0===o&&(o="text"===n?e._preEdit:"style"===n?e._preStyle:e._preClass),o===r||"text"===n&&null!=o&&W(e,o)===r)return!1;const c=R(e);return Kt("main"===s?{kind:"cmp-main",component:a,path:i,prop:n,value:r,before:o,sig:c,region:l}:{kind:"cmp-inst",component:a,region:l,path:i,prop:n,value:r,before:o,sig:c}),Gt(),!0}function Zt(){const t={},e={},n={},r={},o={},i={},s=(t,e,n,r,o)=>{if(!r)return;const i=t[e]=t[e]||{},s=n||"";o&&s in i||(i[s]=r.slice())};for(let t=0;t<l.length;t++){const e=l[t];if("st-children"===e.kind)e.html&&Object.assign(i,e.html),s(n,e.region,e.parent,e.before,!0);else if("st-order"===e.kind)s(n,e.region,e.parent,e.before,!0);else if("st-move"===e.kind)s(n,e.from,e.fromParent,e.fromBefore,!0),s(n,e.to,e.toParent,e.toBefore,!0);else if("st-node"===e.kind){const t=o[e.path]=o[e.path]||{};e.prop in t||(t[e.prop]=e.before),e.sig&&(r[e.path]=e.sig)}}const a=new Set;for(let n=0;n<c;n++){const r=l[n];"st-node"===r.kind?(t[r.path]=t[r.path]||{})[r.prop]=r.value:"st-order"===r.kind||"st-children"===r.kind?(s(e,r.region,r.parent,r.order),a.add(r.parent||"#"+r.region),r.copies&&Object.entries(r.copies).forEach(([e,n])=>{t[e]=Object.assign({},n,t[e])})):"st-move"===r.kind&&(s(e,r.from,r.fromParent,r.fromOrder),s(e,r.to,r.toParent,r.toOrder),a.add(r.fromParent||"#"+r.from),a.add(r.toParent||"#"+r.to))}return{node:t,order:e,orderBase:n,sigs:r,base:o,html:i,touched:a}}function te(t,e,n,r){Kt({kind:"data-splice",region:dt(t),source:gt(t),index:e,op:r,record:JSON.parse(JSON.stringify(n))}),setTimeout(()=>{d[dt(t)]=Ut(t,mt(t))},0)}const ee=(t,e)=>t===e?"":t.getAttribute("data-edit-key")||"";function ne(t,e,n,r,o){const i=k(e);if(C(n,i)&&!Object.keys(r||{}).length)return;const s={kind:"st-children",region:dt(t),parent:ee(e,t),order:i,before:n,html:r||{}};o&&Object.keys(o).length&&(s.copies=o),Kt(s)}const re=(t,e)=>{if(!t)return null;const n=document.createElement("template");n.innerHTML=t.trim();const r=n.content.firstElementChild;return r&&e&&r.setAttribute(/^[^@]*@[^@]*@X-[\w-]+:/.test(v(e))?"data-edit-host":"data-edit-key",e),r},oe=()=>rt().filter(t=>"static"===mt(t)&&!st(t)),ie=new Map;function se(t){const e=new Map;return t.forEach(t=>[t,...t.querySelectorAll("[data-edit-key]")].forEach(t=>{if(t.closest("[data-edit-ghost]"))return;const n=t.getAttribute("data-edit-key");null==n||e.has(n)||e.set(n,t)})),t.forEach(t=>t.querySelectorAll("[data-edit-host]").forEach(t=>{const n=t.getAttribute("data-edit-host");e.has(n)||e.set(n,t)})),e}function ae(t){const e=se(oe()),n=[],r=new Set(t.filter(t=>t._marked).map(dt)),o=t=>r.has(t)&&!!it(t)&&"static"===mt(it(t)),i=new Map,s=new Map,a=new Map,d=(t,e,n)=>{const r=JSON.stringify([t,e]);!i.has(r)&&o(t)&&i.set(r,[t,e,n||[]])};l.forEach(t=>{"st-order"!==t.kind&&"st-children"!==t.kind||d(t.region,t.parent,t.before),"st-move"===t.kind&&(d(t.from,t.fromParent,t.fromBefore),d(t.to,t.toParent,t.toBefore))});const u=t=>String(t).slice(String(t).indexOf("@",1)+1).split(":")[0],f=(t,e)=>{const n=new Set,r=(t,e)=>{e=e||[],(t=t||[]).forEach(t=>{e.includes(t)||n.add(t)}),e.forEach(e=>{t.includes(e)||n.add(e)});const r=e.filter(e=>t.includes(e)).map(e=>t.indexOf(e)),o=[],i=new Array(r.length).fill(-1);r.forEach((t,e)=>{let n=0,s=o.length;for(;n<s;){const e=n+s>>1;r[o[e]]<t?n=e+1:s=e}n>0&&(i[e]=o[n-1]),o[n]=e});const s=new Set;for(let t=o.length?o[o.length-1]:-1;t>=0;t=i[t])s.add(t);e.filter(e=>t.includes(e)).forEach((t,e)=>{s.has(e)||n.add(t)})};return l.forEach(o=>{"st-order"!==o.kind&&"st-children"!==o.kind||o.region!==t||(o.parent||"")!==e||r(o.before,o.order),"st-move"===o.kind&&(o.from===t&&(o.fromParent||"")===e&&(n.add(o.key),r(o.fromBefore,o.fromOrder)),o.to===t&&(o.toParent||"")===e&&(n.add(o.key),r(o.toBefore,o.toOrder)))}),n};i.forEach(([t,n,r])=>{let o=""===n?it(t):e.get(n),i=null;if(!o&&""!==n){const t=new Set(r.map(t=>e.get(t)).filter(Boolean).map(t=>t.parentElement));1===t.size&&(o=[...t][0],i=o.getAttribute("data-edit-key"))}const c=o?k(o):[];if(o&&c.join("\n")===r.join("\n")&&!i)return;const d=[];r.forEach((t,e)=>{c[e]!==t&&d.push({was:t,now:c[e]??null})}),c.slice(r.length).forEach(t=>d.push({was:null,now:t}));const m=f(t,n),p=!!o&&c.length===r.length&&r.every((t,e)=>u(t)===u(c[e])),h=new Set;l.forEach(t=>[t.before,t.order,t.fromBefore,t.toBefore,t.fromOrder,t.toOrder].forEach(t=>Array.isArray(t)&&t.forEach(t=>h.add(t))));const g=t=>{const e=t.cloneNode(!1);return[...e.attributes].forEach(t=>{/^(data-edit-|data-rich-text|contenteditable$|role$|aria-multiline$|tabindex$)/.test(t.name)&&e.removeAttribute(t.name)}),e.outerHTML.replace(/<\/[^>]+>$/,"")},b=t=>!!t.was&&!!t.now&&"@"===t.was[0]&&!e.has(t.was)&&!h.has(t.now)&&(()=>{const n=(t=>{for(const e of l)if("st-children"===e.kind&&e.html)for(const[n,r]of Object.entries(e.html))if("~"===n[0]&&v(n)===t){const t=document.createElement("template");t.innerHTML=r;const e=t.content.firstElementChild;if(e)return g(e)}return null})(t.was),r=e.get(t.now);return!n||!r||n===g(r)})();if(p&&d.every(t=>b(t)&&!m.has(t.was))){const e=a.get(t)||new Map;d.forEach(t=>e.set(t.was,t.now)),i&&i!==n&&e.set(n,i),a.set(t,e)}else s.set(t,[...s.get(t)||[],{container:n,changed:d.map(t=>({was:t.was&&u(t.was)&&t.was.slice(t.was.indexOf("@",1)+1),now:t.now&&t.now.slice(t.now.indexOf("@",1)+1)}))}])}),a.forEach((t,n)=>{if(s.has(n))return;const r=e=>"string"!=typeof e?e:t.has(e)?t.get(e):"~"===e[0]&&t.has(v(e))?e.slice(0,e.length-v(e).length)+t.get(v(e)):e,o=t=>Array.isArray(t)?t.map(r):t,i=t=>"string"==typeof t?t.replace(/data-edit-key="([^"]*)"/g,(t,e)=>`data-edit-key="${(t=>t.replace(/&/g,"&amp;").replace(/"/g,"&quot;"))(r((t=>t.replace(/&quot;/g,'"').replace(/&amp;/g,"&"))(e)))}"`):t,a=(n,r)=>{if("~"!==n[0]||!t.has(v(n))||(t=>l.some(e=>"st-node"===e.kind&&e.path===t&&"text"===e.prop))(n))return i(r);const o=e.get(t.get(v(n)));if(!o)return i(r);const s=document.createElement("template");s.innerHTML=We(o,!0);const a=n.slice(0,n.length-v(n).length);return[s.content.firstElementChild,...s.content.firstElementChild.querySelectorAll("[data-edit-key]")].forEach(t=>{const e=t.getAttribute("data-edit-key");e&&"@"===e[0]&&t.setAttribute("data-edit-key",a+e)}),s.innerHTML};l.forEach(t=>{var e;"st-order"!==t.kind&&"st-children"!==t.kind||t.region!==n||(t.parent=r(t.parent),t.before=o(t.before),t.order=o(t.order),t.html&&(t.html=(e=t.html)&&"object"==typeof e?Object.fromEntries(Object.entries(e).map(([t,e])=>[r(t),a(t,e)])):e),t.copies&&(t.copies=Object.fromEntries(Object.entries(t.copies).map(([t,e])=>[r(t),e])))),"st-node"===t.kind&&t.region===n&&"string"==typeof t.path&&"~"===t.path[0]&&(t.path=r(t.path)),"st-move"!==t.kind||t.from!==n&&t.to!==n||(t.key=r(t.key),t.fromParent=r(t.fromParent),t.toParent=r(t.toParent),t.fromBefore=o(t.fromBefore),t.toBefore=o(t.toBefore),t.fromOrder=o(t.fromOrder),t.toOrder=o(t.toOrder)),"lock"===t.kind&&t.region===n&&(t.key=r(t.key))}),zt++});const m=t=>("st-order"===t.kind||"st-children"===t.kind)&&s.has(t.region)||"st-move"===t.kind&&(s.has(t.from)||s.has(t.to))||"st-node"===t.kind&&s.has(t.region)&&"string"==typeof t.path&&"~"===t.path[0],p=t=>"st-node"===t.kind&&"string"==typeof t.path&&"@"===t.path[0]&&o(t.region)&&!e.has(t.path)||m(t);if(l.forEach((t,e)=>{p(t)&&e<c&&"st-node"===t.kind&&"@"===t.path[0]&&n.push(t)}),!l.some(p))return a.size&&T(),[];const h=new Map;n.forEach(t=>h.set(t.path+"|"+t.prop,t));const g=t=>"string"==typeof t?v(t).slice(v(t).indexOf("@",1)+1):"",b=[...h.values()].map(t=>({region:t.region,key:t.path,element:g(t.path),prop:t.prop,value:t.value,before:t.before,reason:`${g(t.path)} changed in the source, so the ${"text"===t.prop?"text":t.prop} edited into it was not applied`}));s.forEach((t,e)=>{const n=l.filter((t,n)=>n<c&&m(t)&&(t.region===e||t.from===e||t.to===e)),r=new Set,o=[];n.forEach(t=>{"st-move"===t.kind&&r.add(t.key),"st-order"!==t.kind&&"st-children"!==t.kind||f(e,t.parent||"").forEach(t=>r.add(t)),"st-children"===t.kind&&t.html&&Object.entries(t.html).forEach(([t,e])=>{if("~"!==t[0])return;const n=document.createElement("template");n.innerHTML=e;const r=l.filter((e,n)=>n<c&&"st-node"===e.kind&&e.path===t&&"text"===e.prop).pop();o.push({of:g(t),html:e,text:r?r.value:n.content.textContent.trim()})})});const i=t.flatMap(t=>t.changed),s=[...new Set(i.map(t=>t.was||t.now))],a=[...new Set([...r].filter(t=>t&&"@"===t[0]).map(g))],d=[a.length&&`moved ${a.join(", ")}`,o.length&&`copied ${o.map(t=>`${t.of} ("${String(t.text).slice(0,40)}")`).join(", ")}`].filter(Boolean).join("; ");b.push({region:e,key:"",element:t.map(t=>t.container?g(t.container):e).join(", "),prop:"structure",value:{changed:i,moved:a,copies:o},before:null,reason:`${s.join(", ")} changed in the source where the layout was edited, so the layout edits (${d||"reordering"}) were not applied`})}),b.forEach(t=>{_.push(t),ft(t.region)&&x.add(t)});let y=0;return l=l.filter((t,e)=>{const n=!p(t);return n&&e<c&&y++,n}),c=y,zt++,T(),jo(),b.length&&(Vr&&(Vr.conflicts=_.slice()),console.warn("[edit] edits to elements that changed in the source were dropped:\n"+b.map(t=>" "+t.reason+("structure"===t.prop?"":`: "${String(t.value).slice(0,80)}"`)).join("\n")),document.dispatchEvent(new CustomEvent("edit:conflict",{detail:{conflicts:b}}))),b}function le(){const{node:t,order:e,orderBase:n,sigs:r,base:o,html:i}=Zt(),s=se(oe()),a=[];new Set([...Object.keys(n),...Object.keys(e)]).forEach(t=>{const r=Object.assign({},n[t]||{},e[t]||{});Object.entries(r).forEach(([e,n])=>a.push([t,e,n]))});const l=new Set;a.forEach(([,,t])=>t.forEach(t=>l.add(t)));const c=new Set,d=t=>{let e=s.get(t);return!e&&ie.has(t)&&(e=ie.get(t),ie.delete(t),s.set(t,e)),!e&&i[t]&&(e=re(i[t],t),e&&(s.set(t,e),e.querySelectorAll("[data-edit-key]").forEach(t=>{const e=t.getAttribute("data-edit-key");s.has(e)||s.set(e,t)}))),e};let u=!0;for(;a.length&&u;){u=!1;for(let t=0;t<a.length;t++){const[e,n,r]=a[t],o=n?s.get(n):it(e);if(!o||!o.isConnected)continue;a.splice(t--,1),u=!0;let f=kt(o);const m=r.map(d).filter(t=>t&&t!==o&&!t.contains(o)),p=f.filter(t=>!m.includes(t)&&!l.has(wt(t))&&!i[wt(t)]),h=[...m,...p].flatMap(yt);if(f=f.flatMap(yt),h.length===f.length&&h.every((t,e)=>t===f[e]))continue;const g=f.length?f[f.length-1].nextSibling:Array.from(o.children).find(bt)||null,b=new Map(h.map(t=>[t,t.isConnected?Rt(t):t._editLead||[]]));f.forEach(t=>{if(h.includes(t))return;t._editLead=Rt(t),t._editLead.forEach(t=>t.remove()),t.remove();const e=wt(t);e&&ie.set(e,t)}),h.forEach(t=>{const e=ct(t);e&&c.add(e),o.insertBefore(t,g&&g.parentNode===o?g:null);const n=b.get(t);n.length&&t.before(...n)});const y=ct(o);y&&c.add(y)}}c.size&&ot(),(c.size?se(oe()):s).forEach((e,n)=>{const i=t[n],s=o[n];if(!i&&!s)return;const a=r[n];a&&R(e)!==a?console.warn("[edit] skip stale static node",n):new Set([...Object.keys(i||{}),...Object.keys(s||{})]).forEach(t=>function(t,e,n){if(void 0!==n){if("text"===e)return I(t,n);if(!X(e,n,t.tagName))return"class"===e?wr(t,n):"style"===e?function(t,e){null==e||""===e?t.removeAttribute("style"):t.getAttribute("style")!==e&&t.setAttribute("style",e),t._editPos&&!t.style.position&&(t.style.position="relative")}(t,n):void(null!==n?t.getAttribute(e)!==n&&t.setAttribute(e,n):t.removeAttribute(e))}}(e,t,i&&void 0!==i[t]?i[t]:s&&s[t]))}),c.forEach(t=>{t.isConnected&&(zr(t),t._armed&&Qr(t)&&Jr(t))})}function ce(t,e,n,r,o={}){const i=dt(t),s=e.getAttribute("data-edit-key");if(!s||"!"===s[0])return!1;if("text"===n&&p.has(e.tagName))return!1;"text"===n&&(r=W(e,r));let a=o.before;if(void 0===a){const r="text"===n?t._baseText&&t._baseText[s]:"class"===n?t._baseClass&&t._baseClass[s]:"style"===n?t._baseStyle&&t._baseStyle[s]:e.getAttribute(n),o="text"===n?e._preEdit:"class"===n?e._preClass:"style"===n?e._preStyle:void 0;a=void 0!==o?o:r}if(a===r||"text"===n&&null!=a&&W(e,a)===r)return!1;"text"!==n||document.activeElement===e||$(e)||I(e,r);const d=l[c-1];if(o.coalesce&&d&&c===l.length&&"st-node"===d.kind&&d.region===i&&d.path===s&&d.prop===n&&Date.now()-(Ft.get(d)||0)<1e3)return d.before===r?(l.pop(),c--):(d.value=r,Ft.set(d,Date.now())),zt++,T(),jo(),!0;const u=Kt(Object.assign({kind:"st-node",region:i,path:s,prop:n,value:r,before:a,sig:R(e)},o.join?{join:!0}:{}));return o.coalesce&&Ft.set(u,Date.now()),!0}function de(){const t={};for(let e=0;e<c;e++){const n=l[e];"data-val"===n.kind&&(((t[n.source]=t[n.source]||{})[n.id]=t[n.source][n.id]||{})[n.field]=n.value)}return t}function ue(){const t=de(),e=new Map;l.forEach(t=>{if("data-val"===t.kind){const n=JSON.stringify([t.source,t.id,t.field]);e.has(n)||e.set(n,t)}}),e.forEach(e=>{const n=(t[e.source]=t[e.source]||{})[e.id]=t[e.source][e.id]||{};e.field in n||void 0===e.before||(n[e.field]=e.before)}),rt().forEach(e=>{if("data"!==mt(e))return;const n=gt(e),r=t[n];if(!r)return;const o=h(e),i=ht(e);try{const t=window.Alpine.evaluate(o,i);Array.isArray(t)&&Object.entries(r).forEach(([e,n])=>{const r=t.find(t=>String(t.id)===String(e));r&&Object.entries(n).forEach(([t,e])=>{r[t]!==e&&(r[t]=e)})})}catch{}Qr(e)&&setTimeout(()=>ur(e),0)})}function fe(t,e,n){const r=P(e),o=mt(t);return"component"===o?Qt(t,e,"style",r):"static"===o&&ce(t,e,"style",r,n)}function me(t,e,n){const r=k(e);return!C(n,r)&&(Kt({kind:"st-order",region:dt(t),parent:ee(e,t),order:r,before:n}),!0)}function pe(t,e,n,r,o,i,s={}){const a=n.parentElement,l={kind:"st-move",from:dt(t),to:dt(e),fromParent:ee(r,t),toParent:ee(a,e),key:wt(n),fromOrder:k(r),toOrder:k(a),fromBefore:o,toBefore:i};return s.join&&(l.join=!0),Kt(l),ot(),zr(e),Qr(t)&&Jr(t),e!==t&&Qr(e)&&Jr(e),l}const he=(t,e)=>/^[~@]/.test(e)?e:t+"|"+e;let ge=-1,be=new Map;function ye(){if(ge===zt)return be;be=new Map;for(let t=0;t<c;t++){const e=l[t];if("lock"!==e.kind)continue;const n=he(e.region,e.key),r=be.get(n)||new Map;be.set(n,r),(e.actions&&e.actions.length?e.actions:o).forEach(t=>r.set(t,e.value))}return ge=zt,be}const ve=()=>ye();function Ee(t,e){const n=mt(e);if("static"===n)return t.getAttribute("data-edit-key");if(t===e)return"";if("component"===n)return null!=t._editPath?"path:"+t._editPath:null;const r=h(e);if(r&&t.parentElement===r.parentElement){const n=xt(t,e);return null==n?null:"row:"+n}return null}const we=t=>"data"===t?"text":"class"===t?"attrs":t,Ae=t=>Et(t)?t:vt(t)?t._manifestHost.roots[0]:null;function ke(t,e){const n=we(e),r=t&&1===t.nodeType&&Ae(t);r&&(t=r);let o=r?Be(r):ct(t);const i=ye();for(let e=t;e&&1===e.nodeType;e=e.parentElement){let t;const s=Ae(e);if(s&&i.size){const e=i.get(s.getAttribute("data-edit-host"));e&&e.has(n)&&(t=e.get(n))}if(void 0===t&&o&&i.size&&(!s||e!==r)){const r=Ee(e,o),s=null!=r&&i.get(he(dt(o),r));s&&s.has(n)&&(t=s.get(n))}if(void 0===t&&e._editLock&&(t=e._editLock.has("*")||e._editLock.has(n)),t)return!0;if(e===o){if(s&&e!==r&&(o=Be(e),o))continue;break}}return!1}function _e(t,e,n){if(!t||1!==t.nodeType)return!1;const r=Ae(t),i=r?Be(r):ct(t);if(!i)return!1;if(null!=e&&!o.includes(e))return console.warn("[edit] unknown lock action:",e),!1;if(r)return Kt({kind:"lock",region:dt(i),key:r.getAttribute("data-edit-host"),actions:e?[e]:[],value:!!n}),xe(i),r._edit&&xe(r),!0;const s=Ee(t,i);return null==s?(console.warn("[edit] this element has no stable identity to lock"),!1):(Kt({kind:"lock",region:dt(i),key:s,actions:e?[e]:[],value:!!n}),xe(i),!0)}function xe(t){t&&t._armed&&(Xr(t),Qr(t)&&Jr(t))}const Se=t=>{"cmp-main"===t.kind||"cmp-inst"===t.kind?Gt():"data-val"===t.kind?ue():"theme"===t.kind?Dr():"lock"===t.kind?xe(it(t.region)):le()};function Te(t,e){if("show"===t.kind)return function(t,e){const n=it(t.region);if(!n)return;const r=""===t.key?n:[n,...n.querySelectorAll("[x-show]")].find(e=>Ee(e,n)===t.key);if(r)try{Vn(r,t.expr,e?t.before:t.value)}catch{}}(t,e),null;if("data-splice"===t.kind)!function(t,e){const n=it(t.region);if(!n)return;const r=h(n),o=ht(n);if(!r||!o)return;let i;try{i=window.Alpine.evaluate(r,o)}catch{return}Array.isArray(i)&&((e?"remove"===t.op:"insert"===t.op)?i.splice(Math.min(t.index,i.length),0,JSON.parse(JSON.stringify(t.record))):i.splice(t.index,1),setTimeout(()=>{d[t.region]=Ut(n,mt(n))},0))}(t,e);else{if("data"===t.kind){const n=e?t.before:t.after;return d[t.region]=n,Jt(it(t.region),t.kind,n)}Se(t)}return null}async function Ce(){if(0===c)return;let t;do{t=l[--c],zt++;const e=Te(t,!0);e&&await e}while(t.join&&c>0);Bo(),T(),jo()}async function Oe(){if(!(c>=l.length)){do{const t=l[c++];zt++;const e=Te(t,!1);e&&await e}while(c<l.length&&l[c].join);Bo(),T(),jo()}}function Le(){const t={};for(let e=0;e<c;e++){const n=l[e];"data"===n.kind&&(t[n.region]={kind:n.kind,snap:n.after})}return t}let Me=null,Pe=null;const Re=()=>{Vr&&(Vr.version=(Vr.version||0)+1)},je=t=>{Pe=t,Re()};function $e(t){t&&1!==t.nodeType&&(t=t.parentElement);const e=ct(t);if(Et(t)&&Be(t)&&"static"===mt(Be(t)))return t;if(!e||t===e)return null;const n=mt(e);if("data"===n){const n=h(e),r=n&&n.parentElement;for(let n=t;n&&n!==e;n=n.parentElement)if(n.parentElement===r)return n;return null}if("component"===n){for(let n=t;n&&n!==e;n=n.parentElement)if(null!=n._editPath)return n;return null}let r=null;for(let n=t;n&&n!==e;n=n.parentElement)(Et(n)||vt(n))&&(r=Et(n)?n:n._manifestHost.roots[0]);if(r)return r;for(let n=t;n&&n!==e;n=n.parentElement){if(bt(n))return null;if(Pt(n.parentElement))return n}return null}const Ne=t=>(t=>!!t&&1===t.nodeType&&$e(t)===t)(t)?t:$e(t),Be=t=>t&&ct(t.parentElement),He=t=>!!t&&(!!t._edit||t.hasAttribute("data-edit-area")),qe=t=>!!t&&!!t.parentElement&&!bt(t)&&!Q(t)&&ut(t.parentElement,"move")&&!ke(t,"move")&&"component"!==mt(ct(t.parentElement));function De(t){if(!t||1!==t.nodeType)return!1;const e=ct(t);if(!e||!Qr(e)||!Pt(t))return!1;for(let n=t;n&&n!==e;n=n.parentElement)if(n._manifestComponent)return!1;return ut(t,"move")}function We(t,e){const n=t.cloneNode(!0),r=[t,...t.querySelectorAll("*")];return[n,...n.querySelectorAll("*")].forEach((t,e)=>{sn.has(r[e])&&t.removeAttribute("tabindex")}),ar(t,n),n.querySelectorAll("[data-edit-handle], [data-edit-live], [data-edit-ghost]").forEach(t=>t.remove()),[n,...n.querySelectorAll("*")].forEach(t=>{[...t.attributes].forEach(n=>{!n.name.startsWith("data-edit-")||e&&"data-edit-key"===n.name||t.removeAttribute(n.name)}),t.removeAttribute("contenteditable"),t.removeAttribute("draggable")}),n.outerHTML}function Ie(t){const e=h(t),n=ht(t);if(!e||!n)return null;try{const t=window.Alpine.evaluate(e,n);return Array.isArray(t)?t:null}catch{return null}}const ze=(t,e)=>{const n=Ie(t);if(!n)return-1;const r=xt(e,t);return n.findIndex(t=>String(t&&null!=t.id?t.id:t)===String(r))};function Fe(t,e){const n=new Set(t.map(t=>String(t&&t.id)));if(!n.has(String(e)))return String(e);let r=2,o=`${e}-copy`;for(;n.has(o);)o=`${e}-copy-${r++}`;return o}const Ke=["move","remove","duplicate","text","attrs","class","size","copy","cut","paste"],Ue=t=>!(!t||!Me||"static"===mt(t)&&"static"!==Me.kind);function Je(t){const e=t?Ne(t):null;return e?De(e.parentElement)?e.parentElement:null:rt().find(t=>Qr(t)&&De(t))||null}function Xe(t,e){if(!Ke.includes(t))return!1;if("paste"===t){const t=Me&&Je(e);return!!t&&Ue(ct(t))}if(!e||1!==e.nodeType||Q(e))return!1;if(Et(e)&&("move"===t||"duplicate"===t||"remove"===t)){const n=Be(e);return!(!n||!Qr(n))&&("move"===t?qe(e):ut(e.parentElement,"move")&&!ke(e,t))}const n=ct(e);if(!n||!Qr(n))return!1;const r=mt(n);if("size"===t)return!!e._edit&&e._edit.caps.has("size")&&!ke(e,"size");if("text"===t)return ut(e,"text")&&!e.hasAttribute("x-text")&&!e.hasAttribute("x-html")&&("true"===e.getAttribute("contenteditable")||!!e._pieceMode||e.hasAttribute("data-rich-text")||null!=e._editField&&ut(e,"data"));if(("attrs"===t||"class"===t)&&"static"===r&&e._manifestComponent)return!1;if("attrs"===t||"class"===t){if("data"===r||ke(e,"attrs"))return!1;const n=Mt(e);if(n)return"attrs"===t&&ut(n,"text");if("component"===r)return"class"===t&&null!=e._editPath;const o=e.getAttribute("data-edit-key");return!!o&&"!"!==o[0]}if("component"===r)return!1;const o=Ne(e);if(!o)return!1;if("copy"===t)return!Et(o);if("cut"===t)return Xe("copy",o)&&Xe("remove",o);if("move"===t)return qe(o);const i="duplicate"===t?"duplicate":"remove";return ut(o.parentElement,"move")&&!ke(o,i)}function Ve(t){const e=Ne(void 0===t?Pe:t);if(!e)return!1;const n=Be(e);return!!n&&(Me={html:We(e,!0),ops:Ye(e),source:dt(n),kind:mt(n)},Re(),!0)}function Ye(t){const e=Zt(),n={};return[t,...t.querySelectorAll("[data-edit-key]")].forEach(t=>{const r=t.getAttribute("data-edit-key");r&&e.node[r]&&(n[r]=Object.assign({},e.node[r]))}),n}function Ge(t,e,n,r,o){const i=k(e),s=function(t,e){const n=w(),r={};return[t,...t.querySelectorAll("[data-edit-key]")].forEach(t=>{const o=t.getAttribute("data-edit-key");if(!o||"!"===o[0])return void t.setAttribute("data-edit-key","!"+w());const i="~"+n+"~"+v(o);t.setAttribute("data-edit-key",i),e&&e[o]&&(r[i]=Object.assign({},e[o]))}),r}(n,o);r?r.after(n):e.appendChild(n),zr(t),Jr(t),ne(t,e,i,{[n.getAttribute("data-edit-key")]:We(n,!0)},s)}function Qe(t){const e=Ne(void 0===t?Pe:t);if(!Xe("duplicate",e))return!1;const n=Be(e);if("data"===mt(n)){const t=Ie(n),r=ze(n,e);if(!t||r<0)return!1;const o=JSON.parse(JSON.stringify(t[r]));return o&&null!=o.id&&(o.id=Fe(t,o.id)),t.splice(r+1,0,o),te(n,r+1,o,"insert"),!0}if(Et(e))return function(t,e){const n=e.parentElement,r=k(n),o=yt(e),i=o.map(t=>re(We(t)));if(i.some(t=>!t))return!1;const s={roots:i},a="~"+w()+"~"+v(wt(e));return i.forEach(t=>{t._manifestComponent=e._manifestComponent,t._manifestHost=s,t.removeAttribute("data-component")}),i[0].setAttribute("data-edit-host",a),o[o.length-1].after(...i),zr(t),Jr(t),ne(t,n,r,{[a]:i[0].outerHTML}),!0}(n,e);const r=re(We(e,!0));return!!r&&(Ge(n,e.parentElement,r,e,Ye(e)),!0)}function Ze(t){const e=Ne(void 0===t?Pe:t);if(!Xe("remove",e))return!1;const n=Be(e);if("data"===mt(n)){const t=Ie(n),r=ze(n,e);if(!t||r<0)return!1;const o=t[r];return t.splice(r,1),te(n,r,o,"remove"),Pe===e&&je(null),!0}const r=e.parentElement,o=k(r),i=wt(e),s=Et(e)?e.outerHTML:We(e,!0);return e._editLead=Rt(e),e._editLead.forEach(t=>t.remove()),yt(e).slice(1).forEach(t=>t.remove()),e.remove(),ie.set(i,e),(Pe===e||Pe&&e.contains(Pe))&&je(null),ne(n,r,o,{[i]:s}),!0}const tn=t=>{const e=Ne(void 0===t?Pe:t);return Xe("remove",e)&&Ve(e)&&Ze(e)};function en(t){if(!Me)return!1;const e=Je(void 0===t?Pe:t);if(!e)return!1;const n=Ne(void 0===t?Pe:t),r=ct(e);if(!Ue(r))return!1;if("data"===mt(r)){const t=Ie(r);if(!t)return!1;const e=n?ze(r,n)+1:t.length,o=document.createElement("template");o.innerHTML=Me.html;const i={id:Fe(t,"pasted"),label:(o.content.textContent||"").trim()};return t.splice(e,0,i),te(r,e,i,"insert"),!0}if("static"!==mt(r))return!1;const o=re(Me.html);return!(!o||!Bt(o,e)||(Ge(r,e,o,n&&n.parentElement===e?n:null,Me.ops),0))}const nn=t=>t.target.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.target.tagName);function rn(t){const e=ct(t.target&&1===t.target.nodeType?t.target:t.target&&t.target.parentElement);e&&Qr(e)&&je($e(t.target))}const on=t=>{const e=getComputedStyle(t).position;return"absolute"===e||"fixed"===e},sn=new WeakSet;let an,ln=null;function cn(t){an&&an.isConnected||(an=document.createElement("div"),an.setAttribute("data-edit-live",""),an.setAttribute("aria-live","polite"),document.body.appendChild(an)),an.textContent=t}function dn(t){t.removeAttribute("data-edit-piece"),t.removeAttribute("data-edit-grabbable"),sn.has(t)&&(t.removeAttribute("tabindex"),sn.delete(t))}function un(t){const e=new Set(function(t){const e=mt(t);if("component"===e)return[];if("data"===e){const e=h(t);return e?kt(e.parentElement):[]}const n=[],r=t=>kt(t).forEach(t=>{t.closest("[data-edit-ghost], [x-edit\\.grab]")||(t._manifestComponent?Et(t)&&n.push(t):(n.push(t),Pt(t)&&!m(t)&&r(t)))});return Pt(t)&&r(t),n}(t).filter(qe));t.querySelectorAll("[data-edit-piece]").forEach(n=>{e.has(n)||ct(n.parentElement)!==t||dn(n)}),e.forEach(t=>{t.setAttribute("data-edit-piece",""),t.toggleAttribute("data-edit-grabbable",!!kn(t)),t.hasAttribute("tabindex")||(t.tabIndex=0,sn.add(t))})}const fn=t=>{const e=getComputedStyle(t);return/grid/.test(e.display)||/flex/.test(e.display)&&!String(e.flexDirection||"").startsWith("column")?"x":"y"};function mn(t,e,n,r){const o=t.getBoundingClientRect();let i=("x"===fn(r)?e<o.left+o.width/2:n<o.top+o.height/2)?t:yt(t).pop().nextElementSibling;for(;i&&(i===s||i.hasAttribute("data-edit-dragging"));)i=i.nextElementSibling;return{container:r,ref:i}}function pn(t,e,n,r){const o=e?t.left:t.top,i=e?t.width:t.height,s=e?n:r;if(!i)return!0;const a=Math.min(.25*i,24);return s>=o+a&&s<=o+i-a}const hn=(t,e,n,r)=>pn(t.getBoundingClientRect(),"x"===fn(r),e,n),gn=t=>!!t&&!!t._edit&&De(t)&&"static"===mt(t)&&(t=>!!t&&rt().includes(t))(t);function bn(t,e,n){if(n.dataList)return{container:n.home,ref:yn(n.home,t,e)};const r=n.nested;if(r&&r.el.isConnected&&n.ghost.parentElement===r.el&&t>=r.rect.left&&t<=r.rect.right&&e>=r.rect.top&&e<=r.rect.bottom&&pn(r.rect,r.horiz,t,e))return{container:r.el,ref:yn(r.el,t,e)};n.nested=null;const o=n.crossOK?function(t,e,n){const r=document.elementFromPoint?document.elementFromPoint(t,e):null;let o=r&&ct(r);if(o&&o!==n&&n.contains(o)&&(o=n),o&&gn(o))return o;const i=[n,...document.querySelectorAll("[data-edit-drop-target]")].filter((t,e,n)=>gn(t)&&n.indexOf(t)===e),s=(n,r)=>t>=n.left-r&&t<=n.right+r&&e>=n.top-r&&e<=n.bottom+r;let a=null,l=1/0;for(const n of i){const r=n.getBoundingClientRect(),o=Math.hypot(Math.max(r.left-t,0,t-r.right),Math.max(r.top-e,0,e-r.bottom)),c=Dt(L(n,"--edit-drop-reach",""),n,"w")??48,d=n.parentElement,u=d&&d!==document.body&&d!==document.documentElement&&!i.some(t=>t!==n&&d.contains(t))&&s(d.getBoundingClientRect(),0);(s(r,c)||u)&&o<l&&(a=n,l=o)}return a}(t,e,n.area):n.area;if(!o)return null;const i=document.elementFromPoint?document.elementFromPoint(t,e):null;if(i&&n.ghost&&(i===n.ghost||n.ghost.contains(i)))return null;if(i&&i!==o&&o.contains(i)){let r=i;for(let t=i;t&&t!==o;t=t.parentElement)(Et(t)||vt(t))&&(r=Et(t)?t:t._manifestHost.roots[0]);for(let i=r;i&&i!==o;i=i.parentElement){if(i===n.item||n.item.contains(i)||bt(i))continue;const r=i.parentElement;if(Pt(r))if(Et(i)){if(De(r)&&Bt(n.item,r)&&!n.item.contains(r))return mn(i,t,e,r)}else{if(n.ghost&&(i===n.home||i.contains(n.ghost))&&De(i)&&Bt(n.item,i))return{container:i,ref:yn(i,t,e)};if(Pt(i)&&De(i)&&Bt(n.item,i)&&hn(i,t,e,r))return n.ghost&&n.ghost.parentElement!==i&&(n.nested={el:i,rect:i.getBoundingClientRect(),horiz:"x"===fn(r)}),{container:i,ref:yn(i,t,e)};if(De(r)&&Bt(n.item,r)&&!n.item.contains(r))return mn(i,t,e,r)}}}if(!(n.crossOK||i&&o.contains(i))){const r=n.ghost.parentElement;return{container:r,ref:yn(r,t,e)}}return De(o)&&Bt(n.item,o)?{container:o,ref:yn(o,t,e)}:null}function yn(t,e,n){const r="y"===fn(t);for(const o of kt(t)){if(o===s||o.hasAttribute("data-edit-dragging")||ke(o,"move"))continue;const t=o.getBoundingClientRect(),i=t.left+t.width/2,a=t.top+t.height/2;if(r&&!/inline/.test(getComputedStyle(o).display)){if(a>n)return o;continue}const l=Math.abs(a-n)<t.height/2;if(a-n>t.height/2||l&&i>e)return o}return null}function vn(t,e,n,r){const o=t.offsetParent||t.parentElement,i=o.getBoundingClientRect();let s=e-r.grabX-i.left-(o.clientLeft||0)+(o.scrollLeft||0),a=n-r.grabY-i.top-(o.clientTop||0)+(o.scrollTop||0);const l=o.clientWidth-t.offsetWidth,c=o.clientHeight-t.offsetHeight;s=l>0?Wt(s,0,l):Math.max(0,s),a=c>0?Wt(a,0,c):Math.max(0,a),t.style.left=qt(s,r.lu,t,o,"w")+r.lu,t.style.top=qt(a,r.tu,t,o,"h")+r.tu}const En=t=>{t.style.removeProperty("left"),t.style.removeProperty("top"),t.getAttribute("style")||t.removeAttribute("style")},wn=(t,e)=>k(t).filter((n,r)=>kt(t)[r]!==e);function An(t){const e=this;if(!Qr(e)||"mouse"===t.pointerType&&0!==t.button||t._editDrag)return;const n=t.target;if(!n||1!==n.nodeType||n.hasAttribute("data-edit-handle"))return;if(n._pieceMode)return void gr(n);let r=null;for(let t=n;t&&t!==e;t=t.parentElement)if(t.hasAttribute("data-edit-piece")&&qe(t)){r=t;break}if(!r)return;const o=kn(r);if(o){if(!o.contains(n))return;t.preventDefault()}else if(_n(n))return;t._editDrag=!0,function(t,e,n){const r=e.parentElement,o=yt(e).pop().nextElementSibling,i=yt(e).slice(1),a="data"===mt(n),l={item:e,area:n,home:r,dataList:a,ghost:null,crossOK:!a&&"static"===mt(n)&&(Et(e)||!He(e)),homeBefore:a?null:k(r),lu:Ht(e.style.left)||"px",tu:Ht(e.style.top)||"px"},c=e.getBoundingClientRect(),d=e.getAttribute("style"),u=P(e),f=Rt(e);l.grabX=t.clientX-c.left,l.grabY=t.clientY-c.top;const m=t.clientX,p=t.clientY;let h=!1,g=0,b=m,y=p,v=null;const E=t=>{const r=document.activeElement;r&&e.contains(r)&&r.isContentEditable&&r.blur();try{window.getSelection().removeAllRanges()}catch{}l.crossOK&&rt().forEach(t=>{t!==n&&gn(t)&&t.setAttribute("data-edit-drop-target","")});const o=l.ghost=e.cloneNode(!0);ar(e,o),o.setAttribute("data-edit-ghost",""),o.setAttribute("x-ignore",""),o.removeAttribute("id"),o.querySelectorAll("[id]").forEach(t=>t.removeAttribute("id")),[o,...o.querySelectorAll("*")].forEach(t=>{[...t.attributes].forEach(e=>{e.name.startsWith("data-edit-")&&"data-edit-ghost"!==e.name&&t.removeAttribute(e.name)}),t.removeAttribute("contenteditable"),t.removeAttribute("tabindex"),t.removeAttribute("draggable")}),e.before(o),Object.assign(e.style,{position:"fixed",width:c.width+"px",height:c.height+"px",margin:"0",pointerEvents:"none"}),e.setAttribute("data-edit-dragging",""),s=o;try{e.setPointerCapture(t.pointerId)}catch{}},w=()=>{g=0,e.style.left=b-l.grabX+"px",e.style.top=y-l.grabY+"px"},A=t=>{const n=l.ghost,{container:o,ref:i}=t,s=v&&v.container===o&&v.ref===i;v=t,s||o.insertBefore(n,i&&i.parentElement===o?jt(i):null),on(n)?(s||(o===r&&e.parentElement===r?r.insertBefore(n,e):n.nextElementSibling&&o.appendChild(n)),vn(n,b,y,l)):(n.style.left||n.style.top)&&En(n)},_=t=>{if(b=t.clientX,y=t.clientY,!h){if(Math.hypot(b-m,y-p)<5)return;h=!0,E(t),w()}t.preventDefault();const e=bn(b,y,l);e&&A(e),g||(g=requestAnimationFrame(w))},x=t=>{if(document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",S),document.removeEventListener("pointercancel",T),document.removeEventListener("keydown",C,!0),g&&cancelAnimationFrame(g),!h)return;document.querySelectorAll("[data-edit-drop-target]").forEach(t=>t.removeAttribute("data-edit-drop-target")),e.removeAttribute("data-edit-dragging"),t?l.ghost.remove():(l.ghost.replaceWith(e),f.length&&e.before(...f),i.length&&e.after(...i)),null==d?e.removeAttribute("style"):e.setAttribute("style",d),l.ghost=null,s=null;const a=()=>{o&&o.parentElement===r?r.insertBefore(e,jt(o)):r.appendChild(e),f.length&&e.before(...f),i.length&&e.after(...i)};if(t)return a(),void cn("Cancelled");const c=e.parentElement,m=ct(c);if(c!==r&&(l.dataList||!De(c)||!Bt(e,c)||!m||m!==n&&(!l.crossOK||!gn(m))))return a(),void cn("Cancelled");on(e)?vn(e,b,y,l):(e.style.left||e.style.top)&&En(e);const p=P(e)!==u;if(l.dataList)return xn(n,r),void cn("Dropped");let v=!1;c===r?v=me(n,r,l.homeBefore):(pe(n,m,e,r,l.homeBefore,wn(c,e)),v=!0),p&&fe(ct(e),e,{before:u,join:v}),cn(m!==n?"Moved to "+dt(m):"Dropped")},S=()=>x(!1),T=()=>x(!0),C=t=>{"Escape"===t.key&&(t.preventDefault(),t.stopPropagation(),x(!0))};document.addEventListener("pointermove",_),document.addEventListener("pointerup",S),document.addEventListener("pointercancel",T),document.addEventListener("keydown",C,!0)}(t,r,e)}const kn=t=>[...t.querySelectorAll("[x-edit\\.grab]")].find(e=>e.closest("[data-edit-piece]")===t)||null,_n=t=>{const e=document.activeElement;return!!e&&e!==document.body&&e.isContentEditable&&(e===t||e.contains(t))};function xn(t,e){return"data"===mt(t)&&(Xt(t,kt(e).map(e=>xt(e,t))),function(t){if(!t)return;const e=dt(t),n=mt(t),r=Ut(t,n),o=d[e];o&&C(o,r)||(Kt({region:e,kind:n,before:o??r,after:r}),d[e]=r)}(t),!0)}const Sn=(t,e)=>t.target!==e&&!!t.target.closest&&e.contains(t.target.closest('a[href], button, summary, [role="button"], [role="link"]')),Tn=t=>kt(t.parentElement).filter(e=>e===t||!ke(e,"move"));function Cn(t){if(document.activeElement!==t)try{t.focus()}catch{}}function On(t,e){if(t._editRow)return;const n=t.target;if("Enter"===t.key&&n.matches&&n.matches("a[href]")&&Gn(n,e))return;if(n._pieceMode&&"Enter"===t.key)return t._editRow=!0,t.preventDefault(),void gr(n,!0);let r=null;for(let t=n;t&&t!==e;t=t.parentElement)if(t.hasAttribute&&t.hasAttribute("data-edit-piece")&&qe(t)){r=t;break}if(!ln){const e=Ne(n);if(e&&function(t,e){if(nn(t))return!1;const n=t.metaKey||t.ctrlKey,r=(t.key||"").toLowerCase();return n&&"c"===r?Ve(e):n&&"x"===r?tn(e):n&&"v"===r?en(e):n&&"d"===r?Qe(e):!(n||"Delete"!==t.key&&"Backspace"!==t.key)&&Ze(e)}(t,e))return t._editRow=!0,t.preventDefault(),void t.stopPropagation()}if(!r)return;const o={ArrowUp:-1,ArrowDown:1}[t.key],i={ArrowLeft:-1,ArrowRight:1}[t.key],s=t.altKey&&!t.shiftKey&&!t.metaKey&&!t.ctrlKey;if(s&&null!=o&&(!ln||ln.item!==r))return t._editRow=!0,t.preventDefault(),void function(t,e){const n=Be(t),r=t.parentElement,o=Tn(t),i=o.indexOf(t),s=i+e;if(i<0||s<0||s>=o.length)return void cn(`Position ${i+1} of ${o.length}`);const a="data"===mt(n)?null:k(r),l=o[s],c=[];for(let n=e>0?t.nextElementSibling:t.previousElementSibling;n&&n!==l;n=e>0?n.nextElementSibling:n.previousElementSibling)c.push(n);const d=t=>[...Rt(t),...yt(t)];if(e>0){const e=jt(t);[l,...c].filter(t=>!vt(t)).forEach(t=>e.before(...d(t)))}else{let e=yt(t).pop();[...c.slice().reverse(),l].filter(t=>!vt(t)).forEach(t=>{e.after(...d(t)),e=yt(t).pop()})}const u=document.activeElement,f=window.getSelection&&window.getSelection(),m=f&&f.rangeCount?f.getRangeAt(0).cloneRange():null;if(a?me(n,r,a):xn(n,r),u&&u.isConnected&&document.activeElement!==u&&(u.focus(),m))try{f.removeAllRanges(),f.addRange(m)}catch{}cn(`Moved to position ${s+1} of ${o.length}`)}(r,o);if(s&&null!=i&&!nn(t))return t._editRow=!0,t.preventDefault(),void(i>0?Pn(r):Rn(r));if(!(" "!==t.key&&"Enter"!==t.key||nn(t)||Sn(t,r)||t.altKey||t.metaKey||t.ctrlKey))return t._editRow=!0,t.preventDefault(),void(ln&&ln.item===r?(function(){const t=ln;ln=null,t&&(t.item.removeAttribute("data-edit-dragging"),t.before?me(t.area,t.container,t.before):xn(t.area,t.container))}(),Cn(r),cn("Dropped")):(ln&&Ln(),ln={item:r,area:Be(r),container:r.parentElement,next:yt(r).pop().nextElementSibling,before:"data"===mt(Be(r))?null:k(r.parentElement)},r.setAttribute("data-edit-dragging","keyboard"),cn("Grabbed — arrow keys to move, Enter to drop")));if(ln&&ln.item===r){if("Escape"===t.key)return t._editRow=!0,t.preventDefault(),Ln(),Cn(r),void cn("Cancelled");const e=o??i;if(null==e)return;t._editRow=!0,t.preventDefault();const n=Tn(r),s=n.indexOf(r)+e;if(s<0||s>=n.length)return;return $t(r,t=>{e>0?yt(n[s]).pop().after(t):jt(n[s]).before(t)}),Cn(r),void cn(`Position ${s+1} of ${n.length}`)}n!==r||nn(t)||t.altKey||t.metaKey||t.ctrlKey||null==o&&null==i||!on(r)||(t._editRow=!0,function(t,e){const n={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[t.key];if(!n)return;t.preventDefault(),e._moveTimer||(e._preStyle=P(e));const r=t.shiftKey?16:4,o=getComputedStyle(e),i=e.offsetParent||e.parentElement,s=Ht(e.style.left)||"px",a=Ht(e.style.top)||"px",l=Math.max(0,i.clientWidth-e.offsetWidth),c=Math.max(0,i.clientHeight-e.offsetHeight),d=Math.max(0,(parseFloat(o.left)||0)+n[0]*r),u=Math.max(0,(parseFloat(o.top)||0)+n[1]*r);n[0]&&(e.style.left=qt(l?Math.min(l,d):d,s,e,i,"w")+s),n[1]&&(e.style.top=qt(c?Math.min(c,u):u,a,e,i,"h")+a),clearTimeout(e._moveTimer),e._moveTimer=setTimeout(()=>{e._moveTimer=null;const t=e.isConnected&&ct(e);t&&fe(t,e)},350)}(t,r))}function Ln(){const t=ln;ln=null,t&&(t.item.removeAttribute("data-edit-dragging"),$t(t.item,e=>{t.next&&t.next.parentElement===t.container?t.container.insertBefore(e,jt(t.next)):t.container.appendChild(e)}))}const Mn=t=>t===ct(t)?dt(t):t.tagName.toLowerCase();function Pn(t){const e=Be(t);if("static"!==mt(e))return cn("Records stay in their list"),!1;let n=t.previousElementSibling;for(;n&&(bt(n)||"TEMPLATE"===n.tagName||vt(n));)n=n.previousElementSibling;if(!n||Et(n)||!De(n)||!Bt(t,n))return cn("Nothing to nest into"),!1;const r=t.parentElement,o=k(r),i=k(n);return $t(t,t=>n.appendChild(t)),pe(e,e,t,r,o,i),Cn(t),cn("Nested in "+Mn(n)),!0}function Rn(t){const e=Be(t),n=t.parentElement;if("static"!==mt(e))return cn("Records stay in their list"),!1;const r=n&&n!==e?n.parentElement:null;if(!r||r!==e&&!e.contains(r)||!De(r))return cn("Already at the top level"),!1;if(!Bt(t,r))return cn("Cannot move out here"),!1;const o=k(n),i=k(r);return $t(t,t=>yt(n).pop().after(t)),pe(e,e,t,n,o,i),Cn(t),cn("Moved out to "+Mn(r)),!0}let jn;function $n(t,e){const n=t.getBoundingClientRect();t.dispatchEvent(new CustomEvent("edit:size",{bubbles:!0,detail:{width:n.width,height:n.height,css:{width:t.style.width,height:t.style.height},done:e}}))}const Nn=t=>"rtl"===getComputedStyle(t).direction;function Bn(t,e){const n=getComputedStyle(t).position;if("fixed"===n)return"w"===e?document.documentElement.clientWidth:document.documentElement.clientHeight;const r="absolute"===n&&t.offsetParent||t.parentElement;if(!r)return null;const o=getComputedStyle(r),i="w"===e,s=i?r.clientWidth:r.clientHeight;return"absolute"===n?s:i||function(t){for(let e=t,n=0;e&&n<32;e=e.parentElement,n++){if(e===document.documentElement)return!0;const t=getComputedStyle(e).position;if("absolute"===t||"fixed"===t)return!0;let n;if(e.computedStyleMap)try{n=String(e.computedStyleMap().get("height")).trim()}catch{}if(null==n&&(n=(e.style&&e.style.height||"").trim()||"auto"),"auto"===n||""===n)return!1;if(!n.endsWith("%"))return!0}return!1}(r)?s-(parseFloat(i?o.paddingLeft:o.paddingTop)||0)-(parseFloat(i?o.paddingRight:o.paddingBottom)||0):null}function Hn(t,e,n,r){if(!(t=String(t||"").trim())||"none"===t||"auto"===t)return r;if(/^-?[\d.]+%$/.test(t)){const o=Bn(e,n);return null==o?r:parseFloat(t)/100*o}const o=Dt(t,e,n);return null==o?r:o}function qn(t,e){const n=Hn(e.minWidth,t,"w",0),r=Hn(e.minHeight,t,"h",0);return{minW:n,minH:r,maxW:Math.max(n,Hn(e.maxWidth,t,"w",1/0)),maxH:Math.max(r,Hn(e.maxHeight,t,"h",1/0))}}const Dn=t=>"x"===t?["left","right"]:"y"===t?["top","bottom"]:["top","right","bottom","left","top-left","top-right","bottom-left","bottom-right"];function Wn(t){const e=L(t,"--edit-size","both");if("none"===e)return;if(t._sizeBound)return;t._sizeBound=!0;const n=getComputedStyle(t).position;n&&"static"!==n||(t.style.position="relative",t._editPos=!0),(L(t,"--edit-size-edges","")||Dn(e).join(" ")).split(/\s+/).filter(Boolean).forEach(e=>{const n=function(t,e){const n=Nn(e);return t.replace(/start/g,n?"right":"left").replace(/end/g,n?"left":"right")}(e,t),r=document.createElement("span");r.setAttribute("data-edit-handle",e),r.tabIndex=0,r.setAttribute("role","slider"),r.setAttribute("aria-label",`Resize ${e}`),r.addEventListener("pointerdown",e=>function(t,e,n){const r=ct(e);if(!Qr(r)||"mouse"===t.pointerType&&0!==t.button||t.button>0)return;t.preventDefault(),t.stopPropagation();const o=e.getAttribute("style");e._preStyle=P(e);const i=getComputedStyle(e),s=e.getBoundingClientRect(),a=Ht(e.style.width)||"px",l=Ht(e.style.height)||"px",c=parseFloat(i.width)||s.width,d=parseFloat(i.height)||s.height,u=t.clientX,f=t.clientY,{minW:m,maxW:p,minH:h,maxH:g}=qn(e,i),b=n.includes("right"),y=n.includes("left"),v=n.includes("bottom"),E=n.includes("top"),w=Kn(e,"--edit-size-snap-distance","x","w"),A=Kn(e,"--edit-size-snap-distance","y","h"),k=zn(e,"x","w"),_=zn(e,"y","h"),x=Kn(e,"--edit-size-close","x","w"),S=Kn(e,"--edit-size-close","y","h"),T=null!=x||null!=S?function(t){const e=t.getAttribute("x-show");return null==e?null:Un.test(e)?e:(Jn.has(t)||(Jn.add(t),console.warn('[edit] --edit-size-close needs an assignable x-show expression (e.g. x-show="open"); close is off here:',e)),null)}(e):null;let C;if(T)try{C=Xn(window.Alpine.evaluate(e,T))}catch{}const O=t.target;try{O.setPointerCapture&&O.setPointerCapture(t.pointerId)}catch{}O.setAttribute("data-edit-resizing",""),jn||(jn=document.createElement("div"),jn.setAttribute("data-edit-overlay",""),document.body.appendChild(jn)),jn.style.display="block";let L=c,M=d,R=!1;const j=()=>(b||y)&&null!=x&&L<x||(E||v)&&null!=S&&M<S,$=t=>{if(t!==R&&T){R=t;try{Vn(e,T,!t&&C)}catch{}}},N=t=>{const n=t.clientX-u,r=t.clientY-f;(b||y)&&(L=c+(b?n:-n)),(E||v)&&(M=d+(v?r:-r)),$(j());let o=!1;if(b||y){const t=Wt(L,m,p),n=Fn(t,k,w);o=o||k.length>0&&n!==t,e.style.width=qt(n,a,e,e.parentElement,"w")+a}if(E||v){const t=Wt(M,h,g),n=Fn(t,_,A);o=o||_.length>0&&n!==t,e.style.height=qt(n,l,e,e.parentElement,"h")+l}e.toggleAttribute("data-edit-snapped",o&&!R),O.toggleAttribute("data-edit-snapped",o&&!R),$n(e,!1)},B=()=>{document.removeEventListener("pointermove",N),document.removeEventListener("pointerup",D),document.removeEventListener("pointercancel",q),jn&&(jn.style.display="none"),["data-edit-snapped","data-edit-resizing"].forEach(t=>O.removeAttribute(t)),e.removeAttribute("data-edit-snapped")},H=()=>{null==o?e.removeAttribute("style"):e.setAttribute("style",o)},q=()=>{B(),$(!1),H(),$n(e,!0)},D=()=>{B();const t=(b||y)&&null!=x&&L<x,n=(E||v)&&null!=S&&M<S;if((t||n)&&T){const o=(t?m:0)>0||(n?h:0)>0,i=e.style.display;H(),o&&(t&&m>0&&(e.style.width=qt(m,a,e,e.parentElement,"w")+a),n&&h>0&&(e.style.height=qt(h,l,e,e.parentElement,"h")+l));const s=fe(r,e);return $n(e,!0),"none"===i&&(e.style.display="none"),void function(t,e,n,r,o){let i=o;try{void 0===i&&(i=Xn(window.Alpine.evaluate(e,n))),Vn(e,n,!1)}catch(t){return console.warn("[edit] could not close via x-show:",t),!1}const s=Ee(e,t);null!=s&&Kt(Object.assign({kind:"show",region:dt(t),key:s,expr:n,before:i,value:!1},r?{join:!0}:{}))}(r,e,T,s,C)}if(t||n)return H(),void $n(e,!0);fe(r,e),$n(e,!0)};document.addEventListener("pointermove",N),document.addEventListener("pointerup",D),document.addEventListener("pointercancel",q)}(e,t,n)),r.addEventListener("keydown",e=>function(t,e,n){const r={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]};if(!r[t.key])return;const o=ct(e);if(!Qr(o))return;t.preventDefault(),t.stopPropagation(),e._keyTimer||(e._preStyle=P(e));const[i,s]=r[t.key],a=t.shiftKey?32:8,l=getComputedStyle(e),c=n.includes("right"),d=n.includes("left"),u=n.includes("top"),f=n.includes("bottom"),m=Ht(e.style.width)||"px",p=Ht(e.style.height)||"px",{minW:h,maxW:g,minH:b,maxH:y}=qn(e,l);if((c||d)&&i){const t=Wt((parseFloat(l.width)||0)+i*a*(c?1:-1),h,g);e.style.width=qt(t,m,e,e.parentElement,"w")+m}if((u||f)&&s){const t=Wt((parseFloat(l.height)||0)+s*a*(f?1:-1),b,y);e.style.height=qt(t,p,e,e.parentElement,"h")+p}$n(e,!1),clearTimeout(e._keyTimer),e._keyTimer=setTimeout(()=>{e._keyTimer=null;const t=e.isConnected&&ct(e);t&&(fe(t,e),$n(e,!0))},350)}(e,t,n)),t.appendChild(r)})}function In(t,e,n){const r=O(t,`${e}-${n}`);if(r)return"none"===r?"":r;const o=O(t,e);return"none"===o?"":o}function zn(t,e,n){return In(t,"--edit-size-snap",e).split(/\s+/).filter(Boolean).map(e=>Dt(e,t,n)).filter(t=>null!=t)}function Fn(t,e,n){if(!e.length)return t;let r=t,o=1/0;for(const n of e){const e=Math.abs(t-n);e<o&&(o=e,r=n)}return null==n||o<=n?r:t}const Kn=(t,e,n,r)=>{const o=In(t,e,n);return o?Dt(o,t,r):null},Un=/^\s*[A-Za-z_$][\w$]*(?:\s*\.\s*[A-Za-z_$][\w$]*|\s*\[\s*(?:'[^'\\]*'|"[^"\\]*"|\d+)\s*\])*\s*$/,Jn=new WeakSet,Xn=t=>{try{return void 0===JSON.stringify(t)||JSON.parse(JSON.stringify(t))}catch{return!0}};function Vn(t,e,n){window.Alpine.evaluate(t,`${e} = ${JSON.stringify(n)}`)}function Yn(t){requestAnimationFrame(()=>{if(!s&&!ln&&document.activeElement===t)try{const e=document.createRange();e.selectNodeContents(t);const n=window.getSelection();n.removeAllRanges(),n.addRange(e)}catch{}})}function Gn(t,e){const n=t.closest('[contenteditable="false"]');return!!n&&e.contains(n)&&!n.hasAttribute("data-edit-piece-mode")}function Qn(t){const e=t.target&&t.target.closest&&t.target.closest("a[href]"),n=e&&ct(e);n&&Qr(n)&&!Gn(e,n)&&t.preventDefault()}const Zn=new Set;let tr=!1;function er(t,e){if(t._editRtFormat=e,t._editRt||t._pieceMode)return;const n=function(){const t=window.ManifestRichText;return t&&"function"==typeof t.attach?t:(tr||(tr=!0,console.warn("[edit] Rich Text is not loaded; text leaves fall back to plain contenteditable")),null)}();t._editRtPrior=["role","aria-multiline"].map(e=>[e,t.getAttribute(e)]);const r=n&&n.attach(t,{mode:"inline",breaks:!0,enter:"break",all:!1,format:e,onChange:()=>{}});r?(t._editRt=r,t.setAttribute("data-edit-text",""),Zn.add(t)):t.setAttribute("contenteditable","true")}function nr(t){const e=t._editRt;e&&(t._editRt=null,Zn.delete(t),t.removeAttribute("data-edit-text"),e.detach())}const rr=t=>Zn.forEach(e=>{(!e.isConnected||t&&t.contains(e))&&nr(e)}),or=t=>{const e=t._editRt;e&&(e.value=e.value)};function ir(t){const e=this,n=e._editRt,r=Ho(t);if(!n||!r)return;if(n.can(r))return t.preventDefault(),t.stopImmediatePropagation(),void n[r]();const o=ct(e);"undo"===r&&o&&Qr(o)&&!No(e)&&function(t){const e=t._editRt;if(!e||!e.can("redo")||!t._commitText)return;const n=function(t){const e=t._editRt.newest();if(!t._editField||t._editRich)return e.trim();const n=document.createElement("template");return n.innerHTML=e,n.content.textContent}(t);t._commitText(n)&&Ce()}(e),qo(t),t.defaultPrevented&&t.stopImmediatePropagation()}function sr(t){t.addEventListener("drop",e=>{const n=ct(t);n&&Qr(n)&&(e.preventDefault(),e.stopImmediatePropagation())})}function ar(t,e){const n=[t,...t.querySelectorAll("*")],r=[e,...e.querySelectorAll("*")];r.forEach(t=>{const e=t.getAttribute("style");if(e&&/--rich-text-/.test(e)){const n=M(e);n?t.setAttribute("style",n):t.removeAttribute("style")}}),n.forEach((t,e)=>{t._editRt&&r[e]&&([...r[e].attributes].forEach(t=>{t.name.startsWith("data-rich-text")&&r[e].removeAttribute(t.name)}),(t._editRtPrior||[]).forEach(([t,n])=>null==n?r[e].removeAttribute(t):r[e].setAttribute(t,n)))})}function lr(t,e,n){t._textBound||(t._textBound=!0,t._commitText=e,t.addEventListener("focus",()=>{or(t),t._preEdit=$o(t),Yn(t)}),t.addEventListener("keydown",e=>{t.isContentEditable&&("Escape"===e.key?(e.preventDefault(),e.stopImmediatePropagation(),t.blur()):"Enter"!==e.key||!e.altKey||e.shiftKey||e.metaKey||e.ctrlKey||(e.preventDefault(),e.stopImmediatePropagation(),function(t){t.blur();const e=[t,...hr(t)].find(t=>t.hasAttribute&&t.hasAttribute("data-edit-piece"));if(e){e.isContentEditable&&(e._pieceMode=!0,e.setAttribute("data-edit-piece-mode",""),nr(e),e.setAttribute("contenteditable","false"),e.addEventListener("focusout",()=>gr(e),{once:!0}));try{e.focus()}catch{}}}(t)))}),t.addEventListener("keydown",ir),sr(t),n&&t.addEventListener("input",n),t.addEventListener("blur",()=>e()))}const cr=t=>{const e=t.closest("[data-rich-text]");return!(!e||e===t&&t._editRt)};function dr(t){t.querySelectorAll("[data-rich-text]:not([data-rich-text-bound])").forEach(e=>{!e._editRt&&ut(e,"text")&&/^[@~]/.test(e.getAttribute("data-edit-key")||"")&&(e._richBound||(e._richBound=!0,e.addEventListener("focusin",()=>{e._preEdit=$o(e)}),e.addEventListener("blur",()=>{const n=ct(e)||t;("component"===mt(n)?Qt:ce)(n,e,"text",e.innerHTML.trim())},!0)))})}function ur(t){const e=h(t);if(!e)return;const n=(e.getAttribute("x-for").match(/^\s*([\w$]+)\s+in\b/)||[])[1];if(!n)return;const r=gt(t),o=new RegExp("^\\s*"+n+"\\.([\\w$]+)\\s*$");kt(t).forEach(e=>{let i=e.getAttribute("data-key");if(null==i){let t=null;try{t=window.Alpine.$data(e)[n]}catch{}t&&null!=t.id&&(i=String(t.id))}null!=i&&[e,...e.querySelectorAll("*")].forEach(e=>{const n=e.hasAttribute("x-html");if(e.children.length&&(!n||!Ot(e))||e.hasAttribute("data-edit-handle"))return;const s=e.getAttribute("x-text")||e.getAttribute("x-html");if(!s)return;const a=s.match(o);if(!a)return;const l=a[1];if(e._editField=l,e._editRich=n,!e._dvBound){e._dvBound=!0;const o=()=>n?D(e):e.textContent;e._commitText=n=>function(t,e,n,r,o,i){o=String(o),i&&i._editRich&&(o=W(i,o));const s=i?i._preEdit:void 0;return!(s===o||i&&i._editRich&&null!=s&&W(i,s)===o||(Kt({kind:"data-val",region:dt(t),source:e,id:n,field:r,value:o,before:s}),ue(),0))}(t,r,i,l,n??o(),e),e.addEventListener("focus",()=>{or(e),e._preEdit=$o(e),$(e)||Yn(e)}),e.addEventListener("focusin",()=>{e._preEdit=$o(e)}),e.addEventListener("keydown",ir),sr(e),e.addEventListener("blur",()=>e._commitText(),!0)}$(e)||er(e,n?"html":"plain")})})}const fr=t=>{const e=pt(t);return(e?.getAttribute("data-component")||"").replace(/-\d+$/,"")};function mr(t,e,n,r){if("main"!==(t._editScope||"instance"))return;const o=fr(t),i=e._editPath,{inst:s}=Vt();rt().forEach(t=>{if("component"!==mt(t)||fr(t)!==o)return;const a=pt(t);if(!a)return;const l=""===i?a:function(t,e){let n=t;for(const t of e.split(".").map(Number))if(n=At(n)[t],!n)return null;return n}(a,i);l&&l!==e&&void 0===(s[dt(t)]&&s[dt(t)][i]||{})[n]&&("class"===n?wr(l,r):l.innerHTML!==r&&(l.innerHTML=r))})}function pr(t){const e=pt(t);if(!e)return;t._editScope||(t._editScope="instance"),t._baseText=t._baseText||{},t._baseClass=t._baseClass||{},t._baseStyle=t._baseStyle||{};const n=n=>{const r=function(t,e){const n=[];let r=t;for(;r&&r!==e&&r.parentElement;)n.unshift(At(r.parentElement).indexOf(r)),r=r.parentElement;return n.join(".")}(n,e);n._editPath=r,r in t._baseClass||(t._baseClass[r]=n.getAttribute("class")||""),r in t._baseStyle||(t._baseStyle[r]=n.getAttribute("style")||"")};n(e),e.querySelectorAll("*").forEach(t=>{t.hasAttribute("data-edit-handle")||n(t)}),dr(t),Yt(e).forEach(e=>{if(e.children.length&&!Lt(e)||!e.textContent.trim()||!ut(e,"text"))return;if(cr(e))return;const n=e._editPath;n in t._baseText||(t._baseText[n]=e.innerHTML.trim()),lr(e,n=>Qt(t,e,"text",n??D(e)),()=>mr(t,e,"text",e.innerHTML)),er(e,"html")})}const hr=t=>{const e=[],n=ct(t);for(let r=t.parentElement;r&&r!==n;r=r.parentElement)e.push(r);return e};function gr(t,e){if(t._pieceMode&&(t._pieceMode=!1,t.removeAttribute("data-edit-piece-mode"),"false"===t.getAttribute("contenteditable")&&(t.removeAttribute("contenteditable"),er(t,t._editRtFormat||"html")),e)){try{t.focus()}catch{}Yn(t)}}const br=(t,e)=>t.getAttribute(":"+e)??t.getAttribute("x-bind:"+e);function yr(t){const e=br(t,"class");if(null==e)return[];let n;try{n=window.Alpine.evaluate(t,e)}catch{return[]}const r=[],o=t=>String(t).split(/\s+/).filter(Boolean).forEach(t=>r.push(t));return"string"==typeof n?o(n):Array.isArray(n)?n.flat(1/0).filter(Boolean).forEach(o):n&&"object"==typeof n&&Object.entries(n).forEach(([t,e])=>{e&&o(t)}),r}const vr=t=>String(t||"").split(/\s+/).filter(Boolean);function Er(t){const e=new Set(yr(t));return vr(t.getAttribute("class")).filter(t=>!e.has(t)).join(" ")}function wr(t,e){const n=yr(t),r=[...new Set([...vr(e),...n])].join(" ");r?t.getAttribute("class")!==r&&t.setAttribute("class",r):t.hasAttribute("class")&&t.removeAttribute("class")}function Ar(t){if(null==t&&(t=Pe),!t||1!==t.nodeType)return null;const e=ct(t);if(!e||!Qr(e))return null;const n=mt(e);return"static"===n&&t._manifestComponent?null:{el:t,area:e,kind:n}}function kr(t,e,n){const r=Ar(n);if(!r)return!1;t=String(t||"").trim().toLowerCase();const o=!0===e?"":!1===e||null==e?null:String(e),i=X(t,o,r.el.tagName);if(i)return console.warn(`[edit] attribute refused (${i}):`,t),!1;if(ke(r.el,"attrs"))return!1;const s="data"!==r.kind&&Mt(r.el);if(s)return function(t,e,n,r){if(ke(e,"text")||t.el.getAttribute(n)===r)return!1;const o=document.activeElement===e,i=o&&void 0!==e._preEdit?e._preEdit:$o(e),s=t.el.getAttribute(n),a=$o(e),l=e=>null===e?t.el.removeAttribute(n):t.el.setAttribute(n,e);if(l(r),$o(e)===a)return l(s),console.warn(`[edit] ${n} is not kept inside text`),!1;const c=D(e),d="component"===t.kind?Qt(t.area,e,"text",c,i):ce(ct(e),e,"text",c,{before:i});return o&&(or(e),e._preEdit=$o(e)),d}(r,s,t,o);if("class"===t)return _r(r,o||"");if("data"===r.kind)return console.warn("[edit] list rows are rendered from data; attributes on them are not editable"),!1;if("component"===r.kind)return console.warn("[edit] component nodes take class changes only"),!1;if(!/^[@~]/.test(r.el.getAttribute("data-edit-key")||""))return!1;null!=br(r.el,t)&&console.warn(`[edit] ${t} is bound on this element; the binding will override the edited value`);const a=r.el.getAttribute(t);return a!==o&&(null===o?r.el.removeAttribute(t):r.el.setAttribute(t,o),ce(r.area,r.el,t,o,{before:a,coalesce:!0}))}function _r(t,e){if("data"===t.kind)return console.warn("[edit] list rows are rendered from data; attributes on them are not editable"),!1;if(Mt(t.el))return console.warn("[edit] class is not kept inside text"),!1;const n=Er(t.el);return n!==(e=vr(e).join(" "))&&(wr(t.el,e),"component"===t.kind?null!=t.el._editPath&&(mr(t.area,t.el,"class",t.el.getAttribute("class")||""),Qt(t.area,t.el,"class",e,n)):!!/^[@~]/.test(t.el.getAttribute("data-edit-key")||"")&&ce(t.area,t.el,"class",e,{before:n,coalesce:!0}))}function xr(t,e){const n=Ar(t);if(!n)return!1;if(ke(n.el,"attrs"))return!1;const r=e(vr(Er(n.el)));return!!r&&_r(n,r.join(" "))}const Sr={add(t,e){const n=vr(t);return xr(e,t=>[...t,...n.filter(e=>!t.includes(e))])},remove(t,e){const n=new Set(vr(t));return xr(e,t=>t.filter(t=>!n.has(t)))},toggle(t,e,n){const r=Ar(e);if(!r)return!1;const o=vr(t);return n??!o.every(t=>r.el.classList.contains(t))?Sr.add(t,r.el):Sr.remove(t,r.el)},set(t,e){const n=Ar(e);return!!n&&!ke(n.el,"attrs")&&_r(n,t||"")},has(t,e){Vr&&Vr.version;const n=null==e?Pe:e;return!!n&&1===n.nodeType&&vr(t).every(t=>n.classList.contains(t))},list(t){Vr&&Vr.version;const e=null==t?Pe:t;return e&&1===e.nodeType?vr(Er(e)):[]}},Tr=t=>{const e=t&&ct(t);return e&&"component"===mt(e)?e:null};function Cr(t){const e=Tr(null==t?Pe:t);return e?e._editScope||"instance":null}function Or(t){null==t&&(t=Pe);const e=Tr(t);if(!e)return!1;if(t===e)Kt({kind:"cmp-inst",component:fr(n=e),region:dt(n),path:"*",prop:"*",value:It}),Gt();else{if(null==t._editPath)return!1;!function(t,e){Kt({kind:"cmp-inst",component:fr(t),region:dt(t),path:e._editPath,prop:"*",value:It}),Gt()}(e,t)}var n;return!0}const Lr=new Set,Mr={},Pr=new Set,Rr=(t,e)=>(t||"")+"|"+e,jr=t=>t&&Y[t]||document.documentElement,$r=t=>t.value+(t.dataset.unit||"");let Nr=null;function Br(t){const e=t._cssvar;if(!e||!("value"in t))return;const n=getComputedStyle(jr(e.scope)).getPropertyValue(e.var).trim();if(!n)return;const r="color"===t.type?function(t){if(/^#[0-9a-f]{6}$/i.test(t))return t.toLowerCase();try{Nr=Nr||document.createElement("canvas");const e=Nr.getContext&&Nr.getContext("2d",{willReadFrequently:!0});if(!e)return null;const n=document.createElement("i");return n.style.color=t,n.style.color?(e.clearRect(0,0,1,1),e.fillStyle="#000",e.fillStyle=t,e.fillRect(0,0,1,1),"#"+[...e.getImageData(0,0,1,1).data.slice(0,3)].map(t=>t.toString(16).padStart(2,"0")).join("")):null}catch{return null}}(n):t.dataset.unit?String(parseFloat(n)):n;null!=r&&t.value!==r&&(t.value=r)}function Hr(t){const e=t._cssvar;if(!e||!e.var)return;const n=Rr(e.scope,e.var);n in Mr||(Mr[n]=jr(e.scope).style.getPropertyValue(e.var)),Br(t),t._cvBound||(t._cvBound=!0,t.addEventListener("input",()=>jr(e.scope).style.setProperty(e.var,$r(t))),t.addEventListener("change",()=>{return function(t,e,n,r){if(!/^--[\w-]+$/.test(e||""))return void console.warn("[edit] x-edit.cssvar needs a custom property name (--name):",e);const o=function(t){const e=String(null==t?"":t);if(!e.trim())return"empty";if(/expression\s*\(/i.test(e))return"expression()";const n=[];for(let t=0;t<e.length;t++){const r=e[t];if('"'===r||"'"===r){let n=t+1;for(;n<e.length&&e[n]!==r;n++)if("\\"===e[n])n++;else if("\n"===e[n])return"unbalanced quotes";if(n>=e.length)return"unbalanced quotes";t=n;continue}if(/^url\(/i.test(e.slice(t,t+4))&&!/[\w-]/.test(e[t-1]||"")){let n=t+4,r=null,o="";for(;n<e.length;n++){const t=e[n];if(r){if("\\"===t){o+=e[++n]||"";continue}if(t===r){r=null;continue}o+=t}else if('"'!==t&&"'"!==t){if(")"===t)break;o+=t}else r=t}if(n>=e.length)return"unterminated url()";const i=o.replace(/[\u0000-\u0020\u007f]/g,"").toLowerCase();if(/^(javascript|vbscript):/.test(i))return"script URL";if(i.startsWith("data:")&&!i.startsWith("data:image/"))return"data URL";t=n;continue}if(";"===r||"{"===r||"}"===r)return`contains ${r}`;if(e.startsWith("/*",t)||e.startsWith("\x3c!--",t)||e.startsWith("</",t))return"contains a comment or markup";if("("===r||"["===r)n.push(r);else if((")"===r||"]"===r)&&n.pop()!==(")"===r?"(":"["))return"unbalanced brackets"}return n.length?"unbalanced brackets":null}(n);if(o)return void console.warn(`[edit] theme value refused (${o}):`,n);const i=Rr(t,e);Pr.add(i),jr(t).style.setProperty(e,n);const s=qr()[i];s&&s.value===n||Kt({kind:"theme",scope:t||null,var:e,value:n},!!r)}(e.scope,e.var,$r(t),e.persist||!!(n=e.scope&&Y[e.scope])&&!!(n._editPersist||n._edit&&n._edit.persist));var n}))}function qr(){const t={};for(let e=0;e<c;e++){const n=l[e];"theme"===n.kind&&(t[Rr(n.scope,n.var)]=n)}return t}function Dr(){const t=qr();new Set([...Pr,...Object.keys(t)]).forEach(e=>{Pr.add(e);const n=e.indexOf("|"),r=e.slice(0,n)||null,o=e.slice(n+1),i=jr(r),s=t[e]?t[e].value:Mr[e];s?i.style.setProperty(o,s):i.style.removeProperty(o)}),Lr.forEach(Br)}function Wr(t){const e=t&&Y[t];if(!e||tt(e))return null;const n=ct(e),r=e.getAttribute("data-edit-key");if(n&&"static"===mt(n)&&!st(n)&&r&&/^[@~]/.test(r))return"area";if(n&&n!==e)return null;const o=it(t);return o&&o!==e?null:"own"}const Ir=new Map;function zr(t){const e=dt(t),n=!t._marked;t._marked=!0,t._baseClass=t._baseClass||{},t._baseStyle=t._baseStyle||{},t._baseText=t._baseText||{};const r=Object.create(null),o=t=>{for(const e of t.children){const t=b(e);r[t]=(r[t]||0)+1,o(e)}},i=(s,a)=>{if(((o,i)=>{let s=o.getAttribute("data-edit-key");if(!s){if(n){const t=b(o),n=r[t]=(r[t]||0)+1;s=y(e,n>1?t+"#"+n:t),Ir.set(s,i)}else s="!"+w();o.setAttribute("data-edit-key",s)}s in t._baseClass||(t._baseClass[s]=Er(o)),s in t._baseStyle||(t._baseStyle[s]=P(o)),s in t._baseText||o.children.length||(t._baseText[s]=o.innerHTML.trim())})(s,a),s!==t&&(t=>$(t)||m(t)||[...t.attributes].some(t=>t.name.startsWith("x-rich-text")))(s))return;if(s._editRt||(n||s._editRtFormat)&&Lt(s)&&ut(s,"text")&&!m(s))return void(n&&o(s));let l=0;for(const t of s.children){if(bt(t)||t.closest("[data-edit-ghost]")||A(t))continue;const o=""===a?String(l):a+"."+l;if(t._manifestComponent){if(vt(t))continue;if(!t.hasAttribute("data-edit-host")){const i=t.getAttribute("data-edit-key"),s=y(e,"X-"+t._manifestComponent.toUpperCase()+":");let a=i&&(i===s||i.startsWith(s+"#"))?i:"!"+w();if(n&&"!"===a[0]){const n="X-"+t._manifestComponent.toUpperCase()+":",i=r[n]=(r[n]||0)+1;a=y(e,i>1?n+"#"+i:n),Ir.set(a,o)}t.setAttribute("data-edit-host",a)}l++}else i(t,o),l++}};i(t,"")}const Fr=new Set,Kr=new Set,Ur=new Map;function Jr(t){const e=function(t){if("data"!==mt(t))return null;const e=(ht(t)||"").match(/\$x\.([\w$]+)/);if(!e)return"inline x-data list: mnfst-run writes data only to CSV/JSON/YAML sources declared in manifest.json";const n=window.ManifestComponentsRegistry&&window.ManifestComponentsRegistry.manifest;if(!n)return null;const r=(n.data||{})[e[1]];return null==r?`data source '${e[1]}' is not declared in manifest.json: mnfst-run writes data only to CSV/JSON/YAML files declared there`:"string"==typeof r?null:`data source '${e[1]}' is not a file (a cloud or remote source): save it with $x.${e[1]}.$update, not mnfst-run`}(t);e&&(Kr.add(dt(t)),Ur.set(dt(t),e),Fr.has(dt(t))||(Fr.add(dt(t)),console.warn(`[edit] x-edit="${dt(t)}": ${e}; its edits stay on the page (and reach onPublish)`))),t._edit.rendered&&Kr.add(dt(t)),t._edit.rendered&&!Fr.has(dt(t))&&(Fr.add(dt(t)),console.warn(`[edit] x-edit="${dt(t)}" is inside content ${t._edit.rendered} renders: it edits on the page (and reaches onPublish), but mnfst-run cannot write it to a source file`)),rr(null);const n=mt(t);"static"===n&&zr(t),un(t),[t,...t.querySelectorAll("[data-edit-area]")].forEach(t=>{var e,n;n="size",(e=t)._edit&&e._edit.caps.has(n)&&!ke(e,n)&&Wn(t)}),"component"===n?pr(t):"static"===n&&function(t){dr(t);const e=[...t.querySelectorAll("*")];At(t).length&&!Lt(t)||e.unshift(t),e.forEach(e=>{At(e).length&&!Lt(e)||!e.textContent.trim()||e.closest("template")||e.closest("[data-edit-handle], [x-edit\\.grab]")||e._manifestComponent&&e!==t||cr(e)||e.closest('[contenteditable="false"]:not([data-edit-piece-mode])')||!ut(e,"text")||m(e)||p.has(e.tagName)||/^[@~]/.test(e.getAttribute("data-edit-key")||"")&&(lr(e,n=>ce(ct(e)||t,e,"text",n??D(e))),er(e,"html"))})}(t),"data"===n&&ut(t,"data")&&ur(t),t._editBound||(t._editBound=!0,t.addEventListener("pointerdown",An),t.addEventListener("keydown",e=>{Qr(t)&&On(e,t)}),t.addEventListener("dragstart",e=>{Qr(t)&&e.preventDefault()}),t.addEventListener("drop",e=>{Qr(t)&&e.preventDefault()})),t._editObserver||(t._editObserver=new MutationObserver(e=>{s||t._rearmQueued||e.every(t=>t.target.isContentEditable)||(t._rearmQueued=!0,queueMicrotask(()=>{t._rearmQueued=!1,t._armed&&Qr(t)&&!s&&Jr(t)}))}),t._editObserver.observe(t,{childList:!0,subtree:!0}))}function Xr(t){[t,...t.querySelectorAll("[data-edit-area]")].forEach(t=>{t._editPos&&(t.style.removeProperty("position"),t._editPos=!1)}),t.querySelectorAll("[data-edit-handle]").forEach(t=>t.remove()),rr(t),[t,...t.querySelectorAll("[contenteditable]")].forEach(t=>{t.hasAttribute("contenteditable")&&t.removeAttribute("contenteditable"),t._pieceMode=!1,t.removeAttribute("data-edit-piece-mode")}),t.querySelectorAll("[data-edit-piece]").forEach(dn),[t,...t.querySelectorAll("[data-edit-area]")].forEach(t=>{t._sizeBound=!1}),ln&&t.contains(ln.item)&&Ln()}let Vr,Yr=!1,Gr=!1;const Qr=t=>!(!t||!t._edit||t._edit.gated&&(!Vr||!Vr.active)||st(t)),Zr=new Set;function to(){const t=[];rt().forEach(t=>{st(t)&&(Zr.has(dt(t))||(Zr.add(dt(t)),console.warn(`[edit] x-edit="${dt(t)}" is on the page more than once (a component used several times); it is not editable here`)),t._armed&&(Xr(t),t._armed=!1))}),rt().forEach(e=>{Qr(e)&&!e._armed&&(e._editBound||t.push(e),d[dt(e)]=Ut(e,mt(e)),Jr(e),e._armed=!0)}),Yr&&t.length&&(l.some(t=>/^st-/.test(t.kind))&&(ae(t),le()),l.some(t=>"cmp-main"===t.kind||"cmp-inst"===t.kind)&&Gt()),Lr.forEach(Hr),jo(),Yr=!0}function eo(t){const e=[],n=t=>t.edits||t.children||"~"===t.key[0],r=se(oe()),o=new Set(Object.values(qr()).filter(t=>t.scope&&"area"===Wr(t.scope)).map(t=>Y[t.scope]));oe().forEach(r=>{const i=dt(r),s=at(r),a=new Proxy({},{get:(t,e)=>{const n=v(String(e)),r=it(decodeURIComponent(n.slice(1,n.indexOf("@",1)))),o=so&&r&&so[lt(r)];return o?o[n]:void 0}}),l=(e,r)=>{const s=!r&&e.getAttribute("data-edit-host");if(s){if("!"===s[0])return null;const t={key:s},e=Ir.get(s);return null!=e&&(t.at=e),a&&a[s]&&(t.fp=a[s]),t}if(!r&&e._manifestComponent)return null;const c=e.getAttribute("data-edit-key");if(!c||"!"===c[0])return null;const d={key:c},u=Ir.get(v(c));null!=u&&(d.at=u),a&&a[v(c)]&&(d.fp=a[v(c)]);const f=(e=>{const n=t.node[e];if(!n)return null;const r={};return Object.entries(n).forEach(([t,e])=>{r[t]="class"!==t&&"style"!==t||""!==e?e:null}),Object.keys(r).length?r:null})(c);if(f&&(d.edits=f),o.has(e)&&(d.edits=Object.assign({},d.edits,{style:P(e)||null})),!(f&&"text"in f||m(e)||e.hasAttribute("data-rich-text"))){const o=(t=>At(t).filter(t=>!A(t)))(e).map(t=>l(t)).filter(Boolean),s=t.touched.has(r?"#"+i:c);if("~"===c[0]||s){d.children=o;const e=s&&"~"!==c[0]&&(e=>{const n=""===e?(t.orderBase[i]||{})[""]:Object.values(t.orderBase).map(t=>t[e]).find(Boolean);return n?n.filter(t=>"@"===t[0]).map(t=>{const e={key:t},n=Ir.get(t);return null!=n&&(e.at=n),a&&a[t]&&(e.fp=a[t]),e}):null})(r?"":c);e&&(d.base=e)}else o.some(n)&&(d.children=o.filter(n),d.path=!0)}return d},c=l(r,!0);c&&(c.edits||c.children)&&(delete c.at,delete c.fp,e.push(s?{kind:"static-tree",region:i,component:s,tree:c}:{kind:"static-tree",region:i,tree:c}))});const i=new Set;new Set([...Object.keys(t.orderBase),...Object.keys(t.order)]).forEach(e=>{Object.values(Object.assign({},t.orderBase[e]||{},t.order[e]||{})).forEach(t=>t.forEach(t=>i.add(t)))});const s=new Set;for(let t=0;t<c;t++){const e=l[t];"st-children"===e.kind&&e.before.forEach(t=>{!t||"@"!==t[0]||i.has(t)||r.has(t)||s.add(t)})}return s.forEach(t=>{const n=(t=>decodeURIComponent(t.slice(1,t.indexOf("@",1))))(t);let r=e.find(t=>t.region===n);if(!r){const t=it(n);if(!t||st(t))return;const o=at(t);r=o?{kind:"static-tree",region:n,component:o,tree:{key:""}}:{kind:"static-tree",region:n,tree:{key:""}},e.push(r)}(r.removed=r.removed||[]).push(t)}),e}function no(){const t=Object.entries(Le()).map(([t,e])=>{return n=t,r=e.kind,o=e.snap,{region:n,kind:r,op:"reorderData",source:o.source,order:o.order};var n,r,o});eo(Zt()).forEach(e=>t.push(e));const e=t=>{const e=[];return Object.entries(t).forEach(([t,n])=>Object.entries(n).forEach(([n,r])=>e.push({path:t,key:t,prop:n,value:r}))),e},n=de(),r={};l.slice(0,c).forEach(t=>{"data-val"===t.kind&&(r[t.source]=t.region)}),Object.entries(n).forEach(([e,n])=>Object.entries(n).forEach(([n,o])=>Object.entries(o).forEach(([o,i])=>t.push({kind:"data-val",region:r[e],source:e,id:n,field:o,value:i}))));const{main:o,inst:i,reverts:s}=Vt();return Object.entries(o).forEach(([n,r])=>{const o=e(r);o.length&&t.push({kind:"component",scope:"main",component:n,edits:o})}),new Set([...Object.keys(i),...Object.keys(s)]).forEach(n=>{const r=it(n);if(!r)return;const o=e(i[n]||{}),a=[...s[n]||[]];(o.length||a.length)&&t.push({kind:"component",scope:"instance",component:fr(r),region:n,edits:o,reverts:a})}),function(){const t=Object.values(qr()),e=[];return t.filter(t=>!Wr(t.scope)).forEach(t=>e.push({kind:"theme",scope:t.scope||null,var:t.var,value:t.value,file:null})),new Set(t.filter(t=>t.scope&&"own"===Wr(t.scope)).map(t=>t.scope)).forEach(t=>{const n=Y[t],r=(t=>{for(let e=t;e;e=e.parentElement)if(e._manifestComponent)return e._manifestComponent;return null})(n),o={key:"",edits:{style:P(n)||null}};e.push(r?{kind:"static-tree",region:t,component:r,tree:o}:{kind:"static-tree",region:t,tree:o})}),e}().forEach(e=>t.push(e)),t}function ro(t){const e=e=>"theme"===e.kind?!!t&&(t.has("theme|"+(e.scope||"")+"|"+e.var)||t.has(e.scope)):("st-move"===e.kind?[e.from,e.to]:[e.region]).some(e=>!(e=>null==e||!!it(e)&&!(t&&t.has(e)))(e)),n=[],r=ve();se(oe().filter(e=>!(t&&t.has(dt(e))))).forEach((t,e)=>{const o=r.get(e);o&&o.size&&n.push([t,new Map(o),e===t.getAttribute("data-edit-host")])});const i=l.slice(0,c).filter(t=>"lock"===t.kind&&!/^[~@]/.test(t.key)&&!e(t));let s=0;l=l.filter((t,n)=>{const r=e(t);return r&&n<c&&s++,r}),c=s,zt++,T();const a=t?[...Ir].filter(([e])=>t.has(decodeURIComponent(e.slice(1,e.indexOf("@",1))))):[];Ir.clear(),a.forEach(([t,e])=>Ir.set(t,e)),rt().forEach(e=>{if(t&&t.has(dt(e)))return;const n=mt(e);e._baseText={},e._baseClass={},e._baseStyle={},"static"===n&&([e,...e.querySelectorAll("[data-edit-key]")].forEach(t=>{ct(t)===e&&t.removeAttribute("data-edit-key")}),e.querySelectorAll("[data-edit-host]").forEach(t=>{ct(t.parentElement)===e&&t.removeAttribute("data-edit-host")}),e._marked=!1,zr(e)),"component"===n&&e._armed&&pr(e),d[dt(e)]=Ut(e,n)}),function(t){Object.keys(Mr).forEach(e=>{if(t&&t.has("theme|"+e))return;const n=e.indexOf("|");Mr[e]=jr(e.slice(0,n)||null).style.getPropertyValue(e.slice(n+1))}),[...Pr].forEach(e=>{t&&t.has("theme|"+e)||Pr.delete(e)})}(t),(()=>{const t=t=>{l.splice(c,0,t),c++,ft(t.region)&&u.add(t)};i.forEach(t),n.forEach(([e,n,r])=>{const i=r?Be(e):ct(e),s=e.getAttribute(r?"data-edit-host":"data-edit-key");i&&s&&[!0,!1].forEach(e=>{const r=[...n].filter(([,t])=>t===e).map(([t])=>t);r.length&&t({kind:"lock",region:dt(i),key:s,actions:r.length===o.length?[]:r,value:e})})}),zt++})(),T(),jo()}const oo=t=>!(t&&Array.isArray(t.results)&&t.results.some(t=>t&&"error"===t.status));let io=null,so=null;function ao(t){return/^https?:$/.test(location.protocol)&&"function"==typeof fetch?fetch("/__edit/base",{cache:"no-store"}).then(t=>t.ok?t.json():null).then(e=>(e&&e.files&&(io=e.files),e&&e.ids&&!t&&(so=e.ids),io)).catch(()=>null):Promise.resolve(null)}let lo=!1;window.addEventListener("manifest:source-change",t=>{const e=t.detail||{},n=/\.html?$/i.test(e.file||"");n&&!so&&(lo=!0),io&&e.file&&e.hash&&!n&&(io[e.file]=e.hash)});let co=null,uo=0,fo=[],mo=!1,po=null;const ho=t=>!mo&&!!co&&Date.now()<co.until&&t.length>0&&t.every(t=>t&&co.files[t.rel]&&co.files[t.rel]===t.hash);function go(t){const e=document.activeElement;if(!e||!e._commitText||void 0===e._preEdit||!e.isContentEditable||$o(e)===e._preEdit)return!0;const n=ct(e);return!(!n||!t&&!n._edit.persist||(e._commitText(),or(e),e._preEdit=$o(e),0))}function bo(t){const e=new Map;for(let n=!0;n;)n=!1,l.slice(0,c).forEach(r=>{if("st-move"!==r.kind||t.has(r.from)===t.has(r.to))return;const[o,i]=t.has(r.from)?[r.from,r.to]:[r.to,r.from];t.add(i),e.set(i,e.get(o)||o),n=!0});return t.via=e,t}const yo=t=>{if("string"!=typeof t)return null;const e=v(t);return"@"===e[0]?e.slice(1,e.indexOf("@",1)):null},vo=t=>Kr.has(t.region)||Kr.has(t.from)||Kr.has(t.to)||Kr.has(yo(t.path))||Kr.has(yo(t.key)),Eo=t=>[...new Set(t.flatMap(t=>[t.region,t.from,t.to]).filter(Boolean))],wo=()=>l.slice(0,c).filter(t=>"lock"!==t.kind&&!u.has(t));function Ao(){const t=document.activeElement,e=t&&t._commitText&&ct(t);return e?dt(e):null}function ko(){return!(!go(!1)&&!Kr.has(Ao()))&&wo().every(vo)}function _o(){const t=Ao(),e=Eo(wo().filter(vo));t&&Kr.has(t)&&!go(!1)&&!e.includes(t)&&e.push(t),e.length&&console.warn(`[edit] the source changed: reloading discards the unpublished edits of ${e.map(t=>`x-edit="${t}"`).join(", ")} that mnfst-run can't write (generated content, or a piece moved from it); .persist keeps them`)}function xo(){_o(),location.reload()}function So(){po&&ko()&&(po=null,xo())}function To(t){if(ko())return xo();po=t;const e=t.map(t=>t&&t.rel).filter(Boolean);Vr&&(Vr.stale=[...new Set([...Vr.stale||[],...e])]);const n=Eo(wo().filter(t=>!vo(t))).filter(t=>!Kr.has(t)),r=Ao();!r||Kr.has(r)||n.includes(r)||go(!1)||n.push(r);const o=bo(new Set(Kr)),i=n.filter(t=>o.has(t)),s=t=>t.map(t=>`x-edit="${t}"`).join(", ");console.warn(`[edit] the source changed, but a reload would lose unpublished edits${n.length?" to "+s(n):""}: publish (with rebase), then reload`+(i.length?`. ${s(i)} ${i.length>1?"are":"is"} tied by a move to ${s([...new Set(i.map(t=>o.via.get(t)))])}, which mnfst-run can't write: undo that move to publish ${i.length>1?"them":"it"}, or publish the rest`:"")),document.dispatchEvent(new CustomEvent("edit:stale",{detail:{files:e}}))}function Co(t,e){if(uo=Math.max(0,uo-1),t&&t.base&&(co={files:Object.assign({},t.base),until:Date.now()+3e3}),t&&Array.isArray(t.stale)&&t.stale.length&&(mo=!0),e&&oo(t)&&t.base&&(mo=!0,setTimeout(()=>{mo&&To(Object.keys(t.base).map(t=>({rel:t})))},1500)),uo)return;const n=fo;fo=[],n.some(t=>!ho(t))&&To(n.flat())}window.addEventListener("manifest:live-reload",t=>{const e=t.detail&&t.detail.files||[];if(uo)return t.preventDefault(),void fo.push(e);ho(e)?t.preventDefault():ko()?_o():(t.preventDefault(),To(e))});let Oo=Promise.resolve();function Lo(t){const e=Oo.then(()=>function(t){const e=(t,e,n)=>{t&&t.base&&io&&Object.entries(t.base).forEach(([t,e])=>{Mo&&/\.html?$/i.test(t)||(io[t]=e)}),t&&t.ids&&so&&(Mo?Object.entries(t.ids).forEach(([t,e])=>{so[t]=Object.assign({},so[t]),Object.entries(e||{}).forEach(([e,n])=>{String(n).includes(".")||(so[t][e]=n)})}):so=t.ids);const r=t&&Array.isArray(t.stale)?t.stale:[];return Vr&&(Vr.stale=r),r.length&&document.dispatchEvent(new CustomEvent("edit:stale",{detail:{files:r}})),oo(e?{results:t.results.filter(t=>!(t&&(e.has(t.region)||n&&n.has(t))))}:t)&&ro(e),So(),t},n=(t,e)=>{if(!t||!Array.isArray(t.results)||Array.isArray(t.stale)&&t.stale.length)return null;const n=new Set(t.results.filter(t=>t&&null!=t.failed).map(t=>t.failed)),r=new Set(e.filter((e,n)=>t.results[n]&&"error"===t.results[n].status&&null==t.results[n].failed&&"static-tree"!==e.kind));if(!n.size&&!r.size||t.results.some((t,o)=>t&&"error"===t.status&&!n.has(e[o]&&e[o].region)&&!r.has(e[o])))return null;bo(n);const o=t=>r.has(t)||null!=t.region&&n.has(t.region);return e.some(t=>!o(t))?Object.assign(n,{own:r,out:o}):null},r=t=>"theme"===t.kind?"theme|"+(t.scope||"")+"|"+t.var:t.region,o=t=>{const e=it(t);return e&&e._edit.rendered},i=t=>null!=t.region&&"theme"!==t.kind&&Kr.has(t.region),s=()=>{go(!0);const s=no();if(Vr&&"function"==typeof Vr.onPublish)return Promise.resolve(Vr.onPublish(s,{log:l,cursor:c})).then(e);if(!s.length)return So(),Promise.resolve({results:[]});const a=t=>(uo++,fetch("/__edit/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({patches:t,base:io})}).then(t=>t.json()).catch(t=>{throw Co(null),t})),d=bo(new Set(s.filter(i).map(t=>t.region))),u=t=>({region:t.region,status:"error",reason:Ur.has(t.region)&&i(t)?`x-edit="${t.region}": ${Ur.get(t.region)}`:o(t.region)&&i(t)?`x-edit="${t.region}" is inside content ${o(t.region)} renders, so mnfst-run can't write it to a source file`:`not published: tied by a move to x-edit="${d.via.get(t.region)}", which mnfst-run can't write`}),f=s.filter(t=>!d.has(t.region)),m=(n,o,i)=>{const a=new Set([...d,...o||[],...o?i.filter(o.out).map(r):[]]),l=new Set,c=s.map(t=>{if(d.has(t.region)){const e=u(t);return l.add(e),e}const e=n.results[i.indexOf(t)];return o&&o.out(t)&&l.add(e),e}),f=e(Object.assign({},n,{results:c}),a.size?a:void 0,l);return Co(n,!(!t||!t.rebase)),f};if(!f.length){const t=e({results:s.map(u)},d);return Promise.resolve(t)}return a(f).then(t=>{const e=n(t,f);if(!e)return m(t,null,f);Co(t,!1);const r=f.filter(t=>!e.out(t));return a(r).then(n=>{const o=f.map((o,i)=>e.out(o)?t.results[i]&&"error"===t.results[i].status?t.results[i]:{region:o.region,status:"error",reason:`not published: tied by a move to x-edit="${e.via.get(o.region)||[...e].find(t=>!e.via.has(t))}", which failed`}:n.results[r.indexOf(o)]);return m(Object.assign({},n,{results:o}),e,f)})})},a=t=>{const n=no();return n.length?e({results:n.map(e=>({region:e.region,status:"error",reason:t}))}):{results:[]}},d=Vr&&"function"==typeof Vr.onPublish||io&&so?Promise.resolve(null):lo?Promise.resolve("the source changed before this page could read its base from the dev server; reload to continue"):ao().then(()=>io&&so?null:"the dev server's base (/__edit/base) could not be read, so nothing can be checked against the source; nothing was published"),u=()=>{const t=Object.assign({},io);return ao(!0).then(()=>(Object.keys(io||{}).some(e=>/\.html?$/i.test(e)&&t[e]!==io[e])&&(Mo=!0),s()))};return d.then(e=>e?a(e):t&&t.rebase?u():s())}(t));return Oo=e.catch(()=>{}),e}let Mo=!1;function Po(){Vr&&(Vr.active=!0),to()}function Ro(){Vr&&(Vr.active=!1),rt().forEach(t=>{t._edit.gated&&t._armed&&(Xr(t),t._armed=!1)}),jo()}function jo(){Vr&&(Vr.canUndo=c>0,Vr.canRedo=c<l.length,Vr.version=(Vr.version||0)+1,po&&setTimeout(So,0))}const $o=t=>t._editField&&!t._editRich?t.textContent:W(t,t.innerHTML.trim()),No=t=>!!t.closest('[data-edit-hotkeys="off"]');function Bo(){const t=document.activeElement;if(!t||void 0===t._preEdit||!t.isContentEditable)return;const e=()=>{document.activeElement===t&&(or(t),t._preEdit=$o(t))};e(),setTimeout(e,0)}function Ho(t){if(t.altKey||!t.metaKey&&!t.ctrlKey)return null;const e=(t.key||"").toLowerCase();return"z"===e?t.shiftKey?"redo":"undo":"y"!==e||!t.ctrlKey||t.metaKey||t.shiftKey?null:"redo"}function qo(t){if(t.defaultPrevented||s)return;const e=Ho(t);if(!e)return;const n="redo"===e,r=t.target&&1===t.target.nodeType?t.target:document.body;if(/^(INPUT|TEXTAREA|SELECT)$/.test(r.tagName)||$(r.closest("[data-rich-text]")))return;const o=r.closest("[data-edit-area]");if(o){const t=ct(o);if(!t||!Qr(t)||No(o))return}else{if(r.isContentEditable)return;if(!rt().some(t=>Qr(t)&&!No(t)))return}r.isContentEditable&&void 0!==r._preEdit&&$o(r)!==r._preEdit||(n?c>=l.length:0===c)||(t.preventDefault(),n?Oe():Ce())}function Do(){if(l.length){!function(){const t=t=>("st-move"===t.kind?[t.from,t.to]:null!=t.region?[t.region]:[]).some(t=>{const e=it(t);return e&&!e._edit.persist});if(!l.some(t))return;let e=0;const n=l.filter((n,r)=>{const o=!t(n);return o&&r<c&&e++,o});l=n,c=e,zt++,T()}();for(const[t,e]of Object.entries(Le())){const n=it(t);n&&"data"===e.kind&&Wo(n,()=>Jt(n,"data",e.snap))}if(l.some(t=>/^st-/.test(t.kind))&&(ae(rt()),le()),l.some(t=>"cmp-main"===t.kind||"cmp-inst"===t.kind)&&Gt(),l.some(t=>"data-val"===t.kind)){const t=rt().find(t=>"data"===mt(t));t&&Wo(t,ue)}l.some(t=>"theme"===t.kind)&&Dr(),l.some(t=>"lock"===t.kind)&&rt().forEach(xe),jo()}}function Wo(t,e){const n=ht(t),r=h(t);let o=0;const i=setInterval(()=>{let t=!1;try{t=Array.isArray(window.Alpine.evaluate(r,n))}catch{}t?(clearInterval(i),e()):++o>100&&clearInterval(i)},50)}let Io=!1;function zo(){if(Io||!window.Alpine||!Alpine.directive)return;Io=!0,document.body&&!document.body.hasAttribute("x-data")&&document.body.setAttribute("x-data","{}"),Alpine.directive("edit",(t,{modifiers:e,expression:n},{cleanup:r})=>{et(t,e,n),Yr&&!Gr&&(Gr=!0,queueMicrotask(()=>{Gr=!1,to()})),r(()=>function(t){Object.keys(Y).forEach(e=>{Y[e]===t&&delete Y[e]}),Lr.delete(t),V.has(t)&&(t._armed&&(Xr(t),t._armed=!1),t._editObserver&&(t._editObserver.disconnect(),t._editObserver=null),V.delete(t),delete t._edit,ot(),t.removeAttribute("data-edit-area"),Pe&&(Pe===t||t.contains(Pe))&&je(null),jo())}(t))}),Alpine.store("edit",{active:!1,canUndo:!1,canRedo:!1,version:0,stale:[],conflicts:[],onPublish:null,toggle(){this.active?Ro():Po()},on(){Po()},off(){Ro()},undo:()=>Ce(),redo:()=>Oe(),publish:t=>Lo(t),patches:()=>no(),export:()=>JSON.parse(JSON.stringify({log:l,cursor:c})),get target(){return this.version,Pe},set target(t){(t=>{je(t&&1===t.nodeType?Ne(t)||t:null)})(t)},can(t,e){return this.version,Xe(t,void 0===e?Pe:e)},lock:(t,e)=>_e(void 0===t?Pe:t,e,!0),unlock:(t,e)=>_e(void 0===t?Pe:t,e,!1),copy:t=>Ve(t),cut:t=>tn(t),paste:t=>en(t),duplicate:t=>Qe(t),remove:t=>Ze(t),move:(t,e,n)=>function(t,e,n){const r=Ne(null==t?Pe:t);if(!r||!qe(r))return!1;const o=Be(r),i="string"==typeof e?it(e):e;if(!i||1!==i.nodeType||i===r||r.contains(i))return!1;const s=ct(i);if(!(o&&s&&Qr(o)&&Qr(s)&&De(i)))return!1;n&&n.parentElement!==i&&(n=null);const a=r.parentElement;if(!Bt(r,i))return!1;if("data"===mt(o))return i===a&&($t(r,t=>i.insertBefore(t,n?jt(n):null)),xn(o,i),!0);if("static"!==mt(o)||"static"!==mt(s))return!1;if(o!==s&&He(r)&&!Et(r))return!1;const l=k(a),c=k(i);return $t(r,t=>i.insertBefore(t,n?jt(n):null)),i===a?me(o,i,l):(pe(o,s,r,a,l,c),!0)}(t,e,n),nest(t){const e=Ne(void 0===t?Pe:t);return!!e&&qe(e)&&Pn(e)},unnest(t){const e=Ne(void 0===t?Pe:t);return!!e&&qe(e)&&Rn(e)},block:t=>$e(t),attr:(t,e,n)=>kr(t,e,n),classes:Sr,scope(t,e){return this.version,t&&1===t.nodeType?Cr(t):null==t?Cr(e):function(t,e){const n=Tr(null==e?Pe:e);return!(!n||"instance"!==t&&"main"!==t||(n._editScope=t,Re(),0))}(t,e)},revert:t=>Or(t),clearConflicts(){_=[],this.conflicts=[],T()}}),Vr=Alpine.store("edit");const n=()=>Alpine.store("edit");Alpine.magic("edit",n),window.__manifestEditMagic=n;const r=window.__manifestEditStubWrites;r&&Object.keys(r).forEach(t=>{try{Vr[t]=r[t]}catch{}delete r[t]}),window.__manifestEditStub&&setTimeout(()=>{window.__manifestEditStub.v++},0),(()=>{try{e=location.pathname;const n=JSON.parse(localStorage.getItem(t(e)));n&&8===n.v?(l=n.log||[],c=n.cursor??l.length,l.forEach(t=>u.add(t)),_=Array.isArray(n.conflicts)?n.conflicts:[],_.forEach(t=>x.add(t)),Vr&&(Vr.conflicts=_.slice())):n&&localStorage.removeItem(t(e))}catch{}})(),window.__mnfstEdit&&ao(),setTimeout(()=>{to(),Do()},450),document.addEventListener("keydown",qo),window.addEventListener("click",Qn,!0),window.addEventListener("auxclick",Qn,!0),document.addEventListener("contextmenu",rn,!0),document.addEventListener("dropdown:context",rn,!0),window.addEventListener("manifest:route-change",()=>{e!==location.pathname&&(e=location.pathname,T())}),function(){if(!window.__manifestAlpineStarted&&![...document.querySelectorAll("[x-data]")].some(t=>t._x_marker))return;const t=t=>/^x-edit(\.|$)/.test(t),e=[...document.querySelectorAll("*")].filter(e=>!e._edit&&[...e.attributes].some(e=>t(e.name)));e.forEach(e=>{e._x_marker&&[...e.attributes].filter(e=>t(e.name)).forEach(t=>e.setAttribute(t.name,t.value))}),e.some(t=>!t._x_marker)&&Alpine.initTree(document.body)}()}document.addEventListener("alpine:init",zo),window.Alpine&&Alpine.directive&&setTimeout(zo,0)}();
1
+ !function(){const t=t=>"mnfst-edit-log:"+(t||location.pathname);let e=location.pathname;const n=["text","move","size","data"],r=["text","move"],o=["move","remove","duplicate","text","attrs","size"],i={sort:".move",authoring:"nothing (visuals are on by default; use .bare to hide them, .persist to keep edits)",style:"$edit.classes / $edit.attr",none:".lock"};let s=null,a=0,l=[],c=0;const d={},u=new WeakSet,f=["x-html","x-text","x-markdown","x-icon","x-svg","x-code","x-code-group","x-chart","x-anchors","x-carousel","x-color","x-colorpicker","x-combobox","x-date","x-defer","x-virtual","x-import"],m=t=>[...t.attributes].some(t=>{const e=t.name.toLowerCase();return f.some(t=>e===t||e.startsWith(t+"."))}),p=new Set(["SCRIPT","STYLE","TEXTAREA","TITLE","NOSCRIPT","TEMPLATE","XMP","IFRAME","NOEMBED","NOFRAMES"]),h=t=>[...t.children].find(t=>"TEMPLATE"===t.tagName&&t.hasAttribute("x-for"))||null;function g(t){if(m(t))return"";let e="";for(const n of t.childNodes)3===n.nodeType?e+=n.textContent:1!==n.nodeType||bt(n)||"TEMPLATE"===n.tagName||A(n)||n._manifestComponent||(e+=g(n));return e}const b=t=>t.tagName.toUpperCase()+":"+g(t).replace(/\s+/g," ").trim().slice(0,24),y=(t,e)=>"@"+encodeURIComponent(t)+"@"+e,v=t=>t&&"~"===t[0]?t.slice(t.indexOf("~",1)+1):t;let E=0;const w=()=>Date.now().toString(36)+(++E).toString(36)+Math.random().toString(36).slice(2,6);function A(t){for(let e=t.previousElementSibling;e;e=e.previousElementSibling){if("TEMPLATE"!==e.tagName)continue;if(e._x_currentIfEl===t)return!0;const n=e._x_lookup;if(n&&(n instanceof Map?[...n.values()]:Object.values(n)).includes(t))return!0}return!1}function k(t){const e=Object.create(null);return kt(t).map(t=>{const n=t.getAttribute("data-edit-host")||t.getAttribute("data-edit-key");if(n)return n;const r=b(t),o=e[r]=(e[r]||0)+1;return o>1?r+"#"+o:r})}let _=[];const x=new WeakSet,S=new Set([location.pathname]),T=e=>{if(l.length>400){const t=l.length-400;l.splice(0,t),c=Math.max(0,c-t)}const n=l.slice(0,c).filter(t=>u.has(t)),r=l.slice(c).filter(t=>u.has(t));S.add(e||location.pathname);const o=_.filter(t=>x.has(t));(e?[e]:[...S]).forEach(e=>{try{n.length||r.length||o.length?localStorage.setItem(t(e),JSON.stringify(Object.assign({v:8,log:[...n,...r],cursor:n.length},o.length?{conflicts:o}:{}))):localStorage.removeItem(t(e))}catch{}})},C=(t,e)=>JSON.stringify(t)===JSON.stringify(e);function O(t,e){for(let n=t;n&&1===n.nodeType;n=n.parentElement){const t=getComputedStyle(n).getPropertyValue(e).trim();if(t)return t}return""}function L(t,e,n){const r=O(t,e);return r?"none"===r&&"--edit-size"!==e?n??"":r:n??""}function M(t,e){if(!e&&!/--rich-text-/.test(t))return t;const n=document.createElement("div");n.setAttribute("style",t),e&&n.style.removeProperty("position");const r=[];for(let t=0;t<n.style.length;t++)r.push(n.style.item(t));return r.filter(t=>t.startsWith("--rich-text-")).forEach(t=>n.style.removeProperty(t)),n.getAttribute("style")||""}const P=t=>M(t.getAttribute("style")||"",!!t._editPos),R=t=>t?t.tagName.toLowerCase():"",j=new Set(["B","I","EM","STRONG","U","S","SMALL","CODE","MARK","SUB","SUP","BR","SPAN","A"]),$=t=>!!t&&1===t.nodeType&&t.hasAttribute("data-rich-text")&&!t._editRt,N=t=>window.ManifestRichText.sanitize(t,!1,!0);let B=!1;const H=t=>{const e=document.createTreeWalker(t,NodeFilter.SHOW_COMMENT),n=[];for(let t=e.nextNode();t;t=e.nextNode())n.push(t);return n},q=(t,e)=>!(X(e.name,e.value,t.tagName)||"style"===e.name&&/expression|url\s*\(|javascript:|@import/i.test(e.value));function D(t){const e=Nt.interactive.join(","),n=!!t.closest("a, button");return[...t.querySelectorAll(e)].forEach(r=>{const o=r.parentElement&&r.parentElement.closest(e);(n||o&&t.contains(o))&&r.replaceWith(...r.childNodes)}),t.innerHTML.trim()}const W=(t,e)=>window.ManifestRichText?$(t)?window.ManifestRichText.sanitize(e,!0,!0):function(t,e){const n=document.createElement("template");n.innerHTML=String(null==t?"":t);const r=[],o="mnfst"+Math.random().toString(36).slice(2)+Date.now().toString(36),i=new RegExp("("+o+"\\d+_)");if(H(n.content).forEach(t=>{if(e=t.data,!/^-?>|-->|--!>|<!-$/.test(e))return t.replaceWith(o+r.length+"_"),void r.push(t.data);var e;t.remove(),B||(B=!0,console.warn("[edit] a comment that cannot be written back as it is was left out of edited text"))}),n.innerHTML=N(n.innerHTML),r.length){const t=document.createTreeWalker(n.content,NodeFilter.SHOW_TEXT),e=[];for(let n=t.nextNode();n;n=t.nextNode())n.nodeValue.includes(o)&&e.push(n);e.forEach(t=>t.replaceWith(...t.nodeValue.split(i).filter(Boolean).map(t=>i.test(t)&&t.startsWith(o)?document.createComment(r[parseInt(t.slice(o.length),10)]):document.createTextNode(t))))}!function(t){const e=t=>{let e=t.lastChild;for(;e&&8===e.nodeType;)e=e.previousSibling;return e};for(let n=0;n<1e3;n++){let n=e(t);for(;n&&1===n.nodeType&&"BR"!==n.tagName&&e(n);)n=e(n);if(!n||n===t)return;if(!(3===n.nodeType?!n.nodeValue.trim():"BR"===n.tagName||!e(n)&&!/^(IMG|WBR)$/.test(n.tagName)))return;n.remove()}}(n.content),n.content.querySelectorAll("*").forEach(t=>[...t.attributes].forEach(e=>{q(t,e)||t.removeAttribute(e.name)}));const s=Nt.interactive.join(","),a=!!(e&&e.closest&&e.closest("a, button"));return[...n.content.querySelectorAll(s)].forEach(t=>{(a||t.parentElement&&t.parentElement.closest(s))&&t.replaceWith(...t.childNodes)}),n.content.querySelectorAll("a").forEach(t=>{t.textContent.trim()||t.querySelector("img")||t.replaceWith(...t.childNodes)}),n.innerHTML.trim()}(e,t):function(t){const e=document.createElement("template");e.innerHTML=String(null==t?"":t);const n=t=>[...t.childNodes].forEach(t=>{if(8===t.nodeType)return t.remove();1===t.nodeType&&(j.has(t.tagName)?([...t.attributes].forEach(e=>{const n=e.name.toLowerCase();("A"!==t.tagName||"href"!==n||X("href",e.value,"A"))&&t.removeAttribute(e.name)}),n(t)):t.replaceWith(document.createTextNode(t.textContent)))});return n(e.content),e.innerHTML}(e);function I(t,e){const n=W(t,e);t.innerHTML===n||$(t)&&W(t,t.innerHTML.trim())===n||(t.innerHTML=n,t._rt&&"function"==typeof t._rt.settle&&t._rt.settle())}const z={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" ",tab:"\t",newline:"\n",colon:":"},F=t=>String(t).replace(/&(#x[0-9a-f]+|#\d+|[a-z]+);?/gi,(t,e)=>{if("#"===e[0]){const n=/^#x/i.test(e)?parseInt(e.slice(2),16):parseInt(e.slice(1),10);return n>=0&&n<1114112?String.fromCodePoint(n):t}const n=z[e.toLowerCase()];return void 0===n?t:n}),K={script:["src","type"],iframe:["src","srcdoc"],embed:["src","srcdoc"],object:["src","srcdoc","data"],frame:["src","srcdoc"],link:["href","rel"],base:["href","rel"],meta:["http-equiv","content"]},U=new Set(["set","animate","animatetransform","animatemotion"]),J=/^data:image\/(png|jpeg|gif|webp|avif)[;,]/;function X(t,e,n){const r=String(t||"").trim().toLowerCase(),o=String(n||"").toLowerCase();if(!r||!/^[a-z_][\w:.-]*$/i.test(r))return/^[@:]/.test(r)?"Alpine directive":"invalid name";if("text"===r)return"reserved name";if("action"===r||"formaction"===r)return"form target";if(r.startsWith("on"))return"event handler attribute";if(r.startsWith("x-"))return"Alpine directive";if(r.startsWith("data-edit-"))return"plugin attribute";if("srcdoc"===r)return"inline document";if(U.has(o)&&["attributename","to","values","from","by"].includes(r))return"SVG animation target";if(K[o]&&K[o].includes(r))return"loads or runs content";if(null==e)return null;for(const t of[String(e),F(e)]){const e=t.replace(/[\u0000-\u0020\u007f]/g,"").toLowerCase();if(/(^|[,(;'"=])(javascript|vbscript):/.test(e))return"script URL";const n=e.match(/(^|[,(;'"=])data:[^,)]*/g)||[];if(n.length&&("img"!==o&&"source"!==o||"src"!==r&&"srcset"!==r||!n.every(t=>J.test(t.replace(/^[,(;'"=]/,"")))))return"data URL"}return null}const V=new Set,Y={},G=new Set,Q=t=>{const e=ct(t);for(let n=t&&t.parentElement;n;n=n.parentElement){if(m(n))return!0;if(n===e)break}return!1},Z=f.filter(t=>"x-code-group"!==t&&"x-carousel"!==t&&"x-defer"!==t);function tt(t){for(let e=t&&t.parentElement;e;e=e.parentElement){if(1!==e.nodeType)continue;const t=[...e.attributes].map(t=>t.name.toLowerCase()).find(t=>Z.some(e=>t===e||t.startsWith(e+".")));if(t)return t.split(".")[0]}return null}function et(t,e,s){if(e.includes("cssvar"))return function(t,e,n){const r=(e||"").trim(),o=r.match(/^([\w-]+)\s*:\s*(--[\w-]+)$/);t._cssvar=o?{scope:o[1],var:o[2]}:{scope:null,var:r},t._cssvar.persist=!(!n||!n.includes("persist")),Lr.add(t)}(t,s,e);if(e.forEach(t=>{i[t]&&!G.has(t)&&(G.add(t),console.warn(`[edit] x-edit.${t} was removed — use ${i[t]}`))}),e.includes("grab"))return;if(e.includes("lock")){const n=e.filter(t=>o.includes(t));return void(t._editLock=new Set(n.length?n:["*"]))}const l=new Set(n.filter(t=>e.includes(t))),c=e.includes("theme"),d=(s||"").trim()||"area-"+ ++a;if(c&&(Y[d]=t),c&&!l.size)return void(e.includes("persist")&&(t._editPersist=!0));l.size||r.forEach(t=>l.add(t)),(s||"").trim()&&[...V].some(e=>e!==t&&e._edit&&e._edit.key===d)&&console.warn("[edit] duplicate x-edit key (deltas will mis-route):",d);const u=e.includes("bare");t._edit={key:d,caps:l,gated:e.includes("gated"),theme:c,persist:e.includes("persist"),bare:u,rendered:tt(t)},t.setAttribute("data-edit-area",u?"bare":""),V.add(t),ot()}let nt=null;const rt=()=>nt||(nt=[...V].filter(t=>{for(let e=t;e;e=e.parentElement){if(e!==t&&e._edit)return!1;if(e._manifestComponent||e!==t&&m(e))return!0}return!0})),ot=()=>{nt=null},it=t=>rt().find(e=>e._edit.key===t),st=t=>rt().filter(e=>e._edit.key===t._edit.key).length>1;function at(t){if(void 0!==t._editSrc)return t._editSrc;let e=null;for(let n=t;n;n=n.parentElement){if(!n._manifestComponent)continue;const r=n===t&&window.ManifestComponentsLoader&&window.ManifestComponentsLoader.cache[n._manifestComponent],o=new RegExp("\\sx-edit(?:\\.[\\w-]+)*\\s*=\\s*([\"'])"+t._edit.key.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"\\1");(n!==t||r&&o.test(r))&&(e=n._manifestComponent);break}return t._editSrc=e}const lt=t=>{const e=at(t);return e?function(t){const e=window.ManifestComponentsRegistry&&window.ManifestComponentsRegistry.manifest||{},n=[...e.preloadedComponents||[],...e.components||[]].find(e=>String(e).split("/").pop().replace(".html","")===t);return String(n||"components/"+t+".html").replace(/^\/+/,"")}(e):"index.html"},ct=t=>t&&rt().reduce((e,n)=>n!==t&&!n.contains(t)||e&&!e.contains(n)?e:n,null),dt=t=>t._edit.key,ut=(t,e)=>{const n=function(t){for(let e=t;e;e=e.parentElement)if(e._edit)return e._edit;return null}(t);return!!n&&n.caps.has(e)&&!ke(t,e)},ft=t=>{const e=null!=t&&it(t);return!(!e||!e._edit.persist)};function mt(t){return h(t)?"data":t.matches("[data-component]")&&!at(t)||pt(t)?"component":"static"}const pt=t=>{const e=At(t).filter(t=>"TEMPLATE"!==t.tagName),n=e[0];return 1!==e.length||!n.matches("[data-component]")||n._edit||n.querySelector("[data-edit-area]")?null:n};function ht(t){const e=h(t),n=e&&e.getAttribute("x-for").match(/\bin\s+(.+)$/);return n?n[1].trim():null}const gt=t=>{const e=ht(t),n=e&&e.match(/\$x\.(\w+)/);return n?n[1]:e||"source"},bt=t=>t.hasAttribute("data-edit-handle")||t.hasAttribute("data-edit-ghost"),yt=t=>t&&t._manifestHost&&t._manifestHost.roots&&t._manifestHost.roots[0]===t?t._manifestHost.roots.slice():[t],vt=t=>!!t._manifestHost&&!!t._manifestHost.roots&&t._manifestHost.roots[0]!==t,Et=t=>!!t&&1===t.nodeType&&t.hasAttribute("data-edit-host"),wt=t=>t.getAttribute("data-edit-host")||t.getAttribute("data-edit-key"),At=t=>Array.from(t.children).filter(t=>!bt(t)&&!vt(t)),kt=t=>At(t).filter(t=>"TEMPLATE"!==t.tagName);let _t=!1;function xt(t,e){const n=t.getAttribute("data-key");if(null!=n)return n;const r=h(e),o=r&&r._x_keyExpression;if(o)try{const e=window.Alpine.evaluate(t,o);if(null!=e)return String(e)}catch{}return _t||(_t=!0,console.warn("[edit] data area rows have no identity — add :key to the x-for or :data-key to the row, or the order cannot be stored")),null}const St=new Set(["P","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE","SPAN","A","LABEL","STRONG","EM","B","I","U","S","SMALL","CODE","MARK","SUB","SUP","Q","CITE","ABBR","TIME","DT","DD","FIGCAPTION","CAPTION","LEGEND","SUMMARY","BUTTON","OPTION"]),Tt=new Set(["AREA","BASE","BR","COL","EMBED","HR","IMG","INPUT","LINK","META","PARAM","SOURCE","TRACK","WBR","VIDEO","AUDIO","CANVAS","SVG","svg","IFRAME","OBJECT","SELECT","TEXTAREA","PICTURE","MATH","math","TEMPLATE","SCRIPT","STYLE","NOSCRIPT","TITLE","XMP"]),Ct=new Set([...St,"LI","TD","TH"]);function Ot(t){if(!window.ManifestRichText)return!1;const e=t.cloneNode(!0);return e.querySelectorAll("[data-edit-handle], [data-edit-ghost]").forEach(t=>t.remove()),H(e).forEach(t=>t.remove()),!e.children.length||(e.querySelectorAll("*").forEach(t=>[...t.attributes].forEach(e=>{e.name.startsWith("data-edit-")&&t.removeAttribute(e.name)})),N(e.innerHTML)===e.innerHTML&&[...e.querySelectorAll("*")].every(t=>[...t.attributes].every(e=>q(t,e))))}const Lt=t=>Ct.has(t.tagName)&&At(t).length>0&&!!t.textContent.trim()&&Ot(t),Mt=t=>{for(let e=t&&t.parentElement;e&&1===e.nodeType;e=e.parentElement){if(e._editRtFormat)return e;if(e._edit)break}return null};function Pt(t){return!(!t||1!==t.nodeType||Tt.has(t.tagName)||bt(t)||(t=>St.has(t.tagName)||t.hasAttribute("data-rich-text")||(t=>[...t.childNodes].some(t=>3===t.nodeType&&t.textContent.trim()))(t)||Lt(t))(t))}function Rt(t){const e=[];let n=t.previousSibling;for(;;){let t=null;if(n&&3===n.nodeType){if(!/^[ \t]*(\r?\n)?[ \t]*$/.test(n.textContent))break;t=n,n=n.previousSibling}if(!n||8!==n.nodeType)break;let r=n.previousSibling;for(;r&&3===r.nodeType&&!r.textContent.trim();)r=r.previousSibling;if(!r)break;e.unshift(n,...t?[t]:[]),n=n.previousSibling}return e}const jt=t=>t?Rt(t)[0]||t:null;function $t(t,e){const n=Rt(t),r=yt(t).slice(1);e(t),n.length&&t.before(...n),r.length&&t.after(...r)}const Nt={only:{table:["caption","colgroup","thead","tbody","tfoot","script","template","style"],thead:["tr","script","template"],tbody:["tr","script","template"],tfoot:["tr","script","template"],tr:["td","th","script","template"],colgroup:["col","template"],ul:["li","script","template"],ol:["li","script","template"],menu:["li","script","template"],dl:["dt","dd","div","script","template"],select:["option","optgroup","hr","script","template"],datalist:["option","script","template"],optgroup:["option","script","template"]},parent:{tr:["thead","tbody","tfoot"],td:["tr"],th:["tr"],caption:["table"],colgroup:["table"],col:["colgroup"],thead:["table"],tbody:["table"],tfoot:["table"],li:["ul","ol","menu"],dt:["dl","div"],dd:["dl","div"],option:["select","datalist","optgroup"],optgroup:["select"]},interactive:["a","button","input","select","textarea","details","label","iframe","embed","object","audio","video","keygen"],phrasingOnly:["p","h1","h2","h3","h4","h5","h6","pre"],block:["address","article","aside","blockquote","details","dialog","div","dl","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","main","menu","nav","ol","p","pre","search","section","table","ul","li","dd","dt"]};function Bt(t,e){if(!t||!e)return!1;if(t.parentElement===e)return!0;const n=[];for(let t=e;t&&1===t.nodeType;t=t.parentElement)n.push(t.tagName.toLowerCase());const r=new Set,o=t=>[t,...t.querySelectorAll("*")].forEach(t=>{1===t.nodeType&&(r.add(t.tagName.toLowerCase()),"TEMPLATE"===t.tagName&&t.content&&[...t.content.children].forEach(o))});yt(t).forEach(o);const i=new Set;for(let t=e;t;t=t.parentElement)t._manifestComponent&&i.add(t._manifestComponent);return!(i.size&&yt(t).some(t=>[t,...t.querySelectorAll("*")].some(t=>t._manifestComponent&&i.has(t._manifestComponent)))||function(t,e,n,r){const o=Nt;return o.only[e]&&!o.only[e].includes(t)?`<${e}> takes only ${o.only[e].filter(t=>"script"!==t&&"template"!==t&&"style"!==t).join(", ")}`:o.parent[t]&&!o.parent[t].includes(e)?`<${t}> belongs in ${o.parent[t].join(" or ")}`:"dt"!==t&&"dd"!==t||"div"!==e||"dl"===n[1]?r.has("form")&&n.includes("form")?"a form cannot contain a form":(n.includes("a")||n.includes("button"))&&o.interactive.some(t=>r.has(t))?"interactive content cannot go inside a link or button":o.phrasingOnly.includes(e)&&o.block.some(t=>r.has(t))?`<${e}> takes only inline content`:null:`<${t}> belongs in a dl`}(t.tagName.toLowerCase(),e.tagName.toLowerCase(),n,r))}const Ht=t=>{const e=String(t||"").match(/[a-z%]+$/i);return e?e[0]:null};function qt(t,e,n,r,o){if("rem"===e)return+(t/parseFloat(getComputedStyle(document.documentElement).fontSize)).toFixed(2);if("em"===e)return+(t/parseFloat(getComputedStyle(n).fontSize)).toFixed(2);if("%"===e){const e=(r||n.parentElement).getBoundingClientRect(),i="w"===o?e.width:e.height;return i?+(t/i*100).toFixed(2):0}return Math.round(t)}function Dt(t,e,n){const r=parseFloat(t);if(isNaN(r))return null;const o=Ht(t)||"px";if("rem"===o)return r*parseFloat(getComputedStyle(document.documentElement).fontSize);if("em"===o)return r*parseFloat(getComputedStyle(e).fontSize);if("%"===o){const t=(e.parentElement||e).getBoundingClientRect();return r/100*("h"===n?t.height:t.width)}return r}const Wt=(t,e,n)=>Math.min(Math.max(t,e),n),It="∅revert";let zt=0;const Ft=new WeakMap;function Kt(t,e){return l.splice(c),l.push(t),c=l.length,zt++,void 0===e&&(e=function(t){return"data-splice"!==t.kind&&"show"!==t.kind&&("st-move"===t.kind?ft(t.from)&&ft(t.to):null!=t.region&&ft(t.region))}(t)),e&&u.add(t),T(),jo(),t}function Ut(t,e){return"data"===e?{source:gt(t),order:kt(t).map(e=>xt(e,t))}:{}}async function Jt(t,e,n){t&&n&&("data"===e&&Xt(t,n.order),Qr(t)&&Jr(t))}function Xt(t,e){const n=ht(t),r=h(t);try{const t=window.Alpine.evaluate(r,n);if(!Array.isArray(t))return;const o=new Map(t.map(t=>[String(t.id),t])),i=e.map(t=>o.get(String(t))).filter(Boolean);t.forEach(t=>{e.map(String).includes(String(t.id))||i.push(t)}),t.splice(0,t.length,...i)}catch{}}function Vt(){const t={},e={},n={},r={};for(let o=0;o<c;o++){const i=l[o];if("cmp-main"!==i.kind&&"cmp-inst"!==i.kind||i.sig&&(r[i.component+"|"+i.path]=i.sig),"cmp-main"===i.kind)t[i.component]=t[i.component]||{},(t[i.component][i.path]=t[i.component][i.path]||{})[i.prop]=i.value;else if("cmp-inst"===i.kind){const t=i.region;i.value===It?(n[t]=n[t]||new Set,"*"===i.path?(delete e[t],n[t]=new Set(["*"])):(e[t]&&delete e[t][i.path],n[t].add(i.path))):(e[t]=e[t]||{},(e[t][i.path]=e[t][i.path]||{})[i.prop]=i.value,n[t]&&(n[t].delete(i.path),n[t].delete("*")))}}return{main:t,inst:e,reverts:n,sigs:r}}const Yt=t=>[t,...t.querySelectorAll("*")].filter(t=>null!=t._editPath);function Gt(){const{main:t,inst:e,sigs:n}=Vt();rt().forEach(r=>{if("component"!==mt(r))return;const o=fr(r),i=dt(r),s=pt(r);s&&Yt(s).forEach(s=>{const a=s._editPath,l=n[o+"|"+a];if(l&&R(s)!==l)return void console.warn("[edit] skip stale node (structure changed):",o,a);const c=e[i]&&e[i][a]||{},d=t[o]&&t[o][a]||{},u=r._baseText||{},f=r._baseClass||{},m=r._baseStyle||{},p=(t,e)=>void 0!==c[t]?c[t]:void 0!==d[t]?d[t]:e,h=p("text",u[a]),g=p("class",f[a]),b=p("style",m[a]);void 0!==h&&I(s,h),void 0!==g&&wr(s,g),void 0!==b&&s.getAttribute("style")!==b&&(""===b?s.removeAttribute("style"):s.setAttribute("style",b))})})}function Qt(t,e,n,r,o){const i=e._editPath,s=t._editScope||"instance",a=fr(t),l=dt(t);if(null==i)return!1;if("text"===n&&(r=W(e,r)),void 0===o&&(o="text"===n?e._preEdit:"style"===n?e._preStyle:e._preClass),o===r||"text"===n&&null!=o&&W(e,o)===r)return!1;const c=R(e);return Kt("main"===s?{kind:"cmp-main",component:a,path:i,prop:n,value:r,before:o,sig:c,region:l}:{kind:"cmp-inst",component:a,region:l,path:i,prop:n,value:r,before:o,sig:c}),Gt(),!0}function Zt(){const t={},e={},n={},r={},o={},i={},s=(t,e,n,r,o)=>{if(!r)return;const i=t[e]=t[e]||{},s=n||"";o&&s in i||(i[s]=r.slice())};for(let t=0;t<l.length;t++){const e=l[t];if("st-children"===e.kind)e.html&&Object.assign(i,e.html),s(n,e.region,e.parent,e.before,!0);else if("st-order"===e.kind)s(n,e.region,e.parent,e.before,!0);else if("st-move"===e.kind)s(n,e.from,e.fromParent,e.fromBefore,!0),s(n,e.to,e.toParent,e.toBefore,!0);else if("st-node"===e.kind){const t=o[e.path]=o[e.path]||{};e.prop in t||(t[e.prop]=e.before),e.sig&&(r[e.path]=e.sig)}}const a=new Set;for(let n=0;n<c;n++){const r=l[n];"st-node"===r.kind?(t[r.path]=t[r.path]||{})[r.prop]=r.value:"st-order"===r.kind||"st-children"===r.kind?(s(e,r.region,r.parent,r.order),a.add(r.parent||"#"+r.region),r.copies&&Object.entries(r.copies).forEach(([e,n])=>{t[e]=Object.assign({},n,t[e])})):"st-move"===r.kind&&(s(e,r.from,r.fromParent,r.fromOrder),s(e,r.to,r.toParent,r.toOrder),a.add(r.fromParent||"#"+r.from),a.add(r.toParent||"#"+r.to))}return{node:t,order:e,orderBase:n,sigs:r,base:o,html:i,touched:a}}function te(t,e,n,r){Kt({kind:"data-splice",region:dt(t),source:gt(t),index:e,op:r,record:JSON.parse(JSON.stringify(n))}),setTimeout(()=>{d[dt(t)]=Ut(t,mt(t))},0)}const ee=(t,e)=>t===e?"":t.getAttribute("data-edit-key")||"";function ne(t,e,n,r,o){const i=k(e);if(C(n,i)&&!Object.keys(r||{}).length)return;const s={kind:"st-children",region:dt(t),parent:ee(e,t),order:i,before:n,html:r||{}};o&&Object.keys(o).length&&(s.copies=o),Kt(s)}const re=(t,e)=>{if(!t)return null;const n=document.createElement("template");n.innerHTML=t.trim();const r=n.content.firstElementChild;return r&&e&&r.setAttribute(/^[^@]*@[^@]*@X-[\w-]+:/.test(v(e))?"data-edit-host":"data-edit-key",e),r},oe=()=>rt().filter(t=>"static"===mt(t)&&!st(t)),ie=new Map;function se(t){const e=new Map;return t.forEach(t=>[t,...t.querySelectorAll("[data-edit-key]")].forEach(t=>{if(t.closest("[data-edit-ghost]"))return;const n=t.getAttribute("data-edit-key");null==n||e.has(n)||e.set(n,t)})),t.forEach(t=>t.querySelectorAll("[data-edit-host]").forEach(t=>{const n=t.getAttribute("data-edit-host");e.has(n)||e.set(n,t)})),e}function ae(t){const e=se(oe()),n=[],r=new Set(t.filter(t=>t._marked).map(dt)),o=t=>r.has(t)&&!!it(t)&&"static"===mt(it(t)),i=new Map,s=new Map,a=new Map,d=(t,e,n)=>{const r=JSON.stringify([t,e]);!i.has(r)&&o(t)&&i.set(r,[t,e,n||[]])};l.forEach(t=>{"st-order"!==t.kind&&"st-children"!==t.kind||d(t.region,t.parent,t.before),"st-move"===t.kind&&(d(t.from,t.fromParent,t.fromBefore),d(t.to,t.toParent,t.toBefore))});const u=t=>String(t).slice(String(t).indexOf("@",1)+1).split(":")[0],f=(t,e)=>{const n=new Set,r=(t,e)=>{e=e||[],(t=t||[]).forEach(t=>{e.includes(t)||n.add(t)}),e.forEach(e=>{t.includes(e)||n.add(e)});const r=e.filter(e=>t.includes(e)).map(e=>t.indexOf(e)),o=[],i=new Array(r.length).fill(-1);r.forEach((t,e)=>{let n=0,s=o.length;for(;n<s;){const e=n+s>>1;r[o[e]]<t?n=e+1:s=e}n>0&&(i[e]=o[n-1]),o[n]=e});const s=new Set;for(let t=o.length?o[o.length-1]:-1;t>=0;t=i[t])s.add(t);e.filter(e=>t.includes(e)).forEach((t,e)=>{s.has(e)||n.add(t)})};return l.forEach(o=>{"st-order"!==o.kind&&"st-children"!==o.kind||o.region!==t||(o.parent||"")!==e||r(o.before,o.order),"st-move"===o.kind&&(o.from===t&&(o.fromParent||"")===e&&(n.add(o.key),r(o.fromBefore,o.fromOrder)),o.to===t&&(o.toParent||"")===e&&(n.add(o.key),r(o.toBefore,o.toOrder)))}),n};i.forEach(([t,n,r])=>{let o=""===n?it(t):e.get(n),i=null;if(!o&&""!==n){const t=new Set(r.map(t=>e.get(t)).filter(Boolean).map(t=>t.parentElement));1===t.size&&(o=[...t][0],i=o.getAttribute("data-edit-key"))}const c=o?k(o):[];if(o&&c.join("\n")===r.join("\n")&&!i)return;const d=[];r.forEach((t,e)=>{c[e]!==t&&d.push({was:t,now:c[e]??null})}),c.slice(r.length).forEach(t=>d.push({was:null,now:t}));const m=f(t,n),p=!!o&&c.length===r.length&&r.every((t,e)=>u(t)===u(c[e])),h=new Set;l.forEach(t=>[t.before,t.order,t.fromBefore,t.toBefore,t.fromOrder,t.toOrder].forEach(t=>Array.isArray(t)&&t.forEach(t=>h.add(t))));const g=t=>{const e=t.cloneNode(!1);return[...e.attributes].forEach(t=>{/^(data-edit-|data-rich-text|contenteditable$|role$|aria-multiline$|tabindex$)/.test(t.name)&&e.removeAttribute(t.name)}),e.outerHTML.replace(/<\/[^>]+>$/,"")},b=t=>!!t.was&&!!t.now&&"@"===t.was[0]&&!e.has(t.was)&&!h.has(t.now)&&(()=>{const n=(t=>{for(const e of l)if("st-children"===e.kind&&e.html)for(const[n,r]of Object.entries(e.html))if("~"===n[0]&&v(n)===t){const t=document.createElement("template");t.innerHTML=r;const e=t.content.firstElementChild;if(e)return g(e)}return null})(t.was),r=e.get(t.now);return!n||!r||n===g(r)})();if(p&&d.every(t=>b(t)&&!m.has(t.was))){const e=a.get(t)||new Map;d.forEach(t=>e.set(t.was,t.now)),i&&i!==n&&e.set(n,i),a.set(t,e)}else s.set(t,[...s.get(t)||[],{container:n,changed:d.map(t=>({was:t.was&&u(t.was)&&t.was.slice(t.was.indexOf("@",1)+1),now:t.now&&t.now.slice(t.now.indexOf("@",1)+1)}))}])}),a.forEach((t,n)=>{if(s.has(n))return;const r=e=>"string"!=typeof e?e:t.has(e)?t.get(e):"~"===e[0]&&t.has(v(e))?e.slice(0,e.length-v(e).length)+t.get(v(e)):e,o=t=>Array.isArray(t)?t.map(r):t,i=t=>"string"==typeof t?t.replace(/data-edit-key="([^"]*)"/g,(t,e)=>`data-edit-key="${(t=>t.replace(/&/g,"&amp;").replace(/"/g,"&quot;"))(r((t=>t.replace(/&quot;/g,'"').replace(/&amp;/g,"&"))(e)))}"`):t,a=(n,r)=>{if("~"!==n[0]||!t.has(v(n))||(t=>l.some(e=>"st-node"===e.kind&&e.path===t&&"text"===e.prop))(n))return i(r);const o=e.get(t.get(v(n)));if(!o)return i(r);const s=document.createElement("template");s.innerHTML=We(o,!0);const a=n.slice(0,n.length-v(n).length);return[s.content.firstElementChild,...s.content.firstElementChild.querySelectorAll("[data-edit-key]")].forEach(t=>{const e=t.getAttribute("data-edit-key");e&&"@"===e[0]&&t.setAttribute("data-edit-key",a+e)}),s.innerHTML};l.forEach(t=>{var e;"st-order"!==t.kind&&"st-children"!==t.kind||t.region!==n||(t.parent=r(t.parent),t.before=o(t.before),t.order=o(t.order),t.html&&(t.html=(e=t.html)&&"object"==typeof e?Object.fromEntries(Object.entries(e).map(([t,e])=>[r(t),a(t,e)])):e),t.copies&&(t.copies=Object.fromEntries(Object.entries(t.copies).map(([t,e])=>[r(t),e])))),"st-node"===t.kind&&t.region===n&&"string"==typeof t.path&&"~"===t.path[0]&&(t.path=r(t.path)),"st-move"!==t.kind||t.from!==n&&t.to!==n||(t.key=r(t.key),t.fromParent=r(t.fromParent),t.toParent=r(t.toParent),t.fromBefore=o(t.fromBefore),t.toBefore=o(t.toBefore),t.fromOrder=o(t.fromOrder),t.toOrder=o(t.toOrder)),"lock"===t.kind&&t.region===n&&(t.key=r(t.key))}),zt++});const m=t=>("st-order"===t.kind||"st-children"===t.kind)&&s.has(t.region)||"st-move"===t.kind&&(s.has(t.from)||s.has(t.to))||"st-node"===t.kind&&s.has(t.region)&&"string"==typeof t.path&&"~"===t.path[0],p=t=>"st-node"===t.kind&&"string"==typeof t.path&&"@"===t.path[0]&&o(t.region)&&!e.has(t.path)||m(t);if(l.forEach((t,e)=>{p(t)&&e<c&&"st-node"===t.kind&&"@"===t.path[0]&&n.push(t)}),!l.some(p))return a.size&&T(),[];const h=new Map;n.forEach(t=>h.set(t.path+"|"+t.prop,t));const g=t=>"string"==typeof t?v(t).slice(v(t).indexOf("@",1)+1):"",b=[...h.values()].map(t=>({region:t.region,key:t.path,element:g(t.path),prop:t.prop,value:t.value,before:t.before,reason:`${g(t.path)} changed in the source, so the ${"text"===t.prop?"text":t.prop} edited into it was not applied`}));s.forEach((t,e)=>{const n=l.filter((t,n)=>n<c&&m(t)&&(t.region===e||t.from===e||t.to===e)),r=new Set,o=[];n.forEach(t=>{"st-move"===t.kind&&r.add(t.key),"st-order"!==t.kind&&"st-children"!==t.kind||f(e,t.parent||"").forEach(t=>r.add(t)),"st-children"===t.kind&&t.html&&Object.entries(t.html).forEach(([t,e])=>{if("~"!==t[0])return;const n=document.createElement("template");n.innerHTML=e;const r=l.filter((e,n)=>n<c&&"st-node"===e.kind&&e.path===t&&"text"===e.prop).pop();o.push({of:g(t),html:e,text:r?r.value:n.content.textContent.trim()})})});const i=t.flatMap(t=>t.changed),s=[...new Set(i.map(t=>t.was||t.now))],a=[...new Set([...r].filter(t=>t&&"@"===t[0]).map(g))],d=[a.length&&`moved ${a.join(", ")}`,o.length&&`copied ${o.map(t=>`${t.of} ("${String(t.text).slice(0,40)}")`).join(", ")}`].filter(Boolean).join("; ");b.push({region:e,key:"",element:t.map(t=>t.container?g(t.container):e).join(", "),prop:"structure",value:{changed:i,moved:a,copies:o},before:null,reason:`${s.join(", ")} changed in the source where the layout was edited, so the layout edits (${d||"reordering"}) were not applied`})}),b.forEach(t=>{_.push(t),ft(t.region)&&x.add(t)});let y=0;return l=l.filter((t,e)=>{const n=!p(t);return n&&e<c&&y++,n}),c=y,zt++,T(),jo(),b.length&&(Vr&&(Vr.conflicts=_.slice()),console.warn("[edit] edits to elements that changed in the source were dropped:\n"+b.map(t=>" "+t.reason+("structure"===t.prop?"":`: "${String(t.value).slice(0,80)}"`)).join("\n")),document.dispatchEvent(new CustomEvent("edit:conflict",{detail:{conflicts:b}}))),b}function le(){const{node:t,order:e,orderBase:n,sigs:r,base:o,html:i}=Zt(),s=se(oe()),a=[];new Set([...Object.keys(n),...Object.keys(e)]).forEach(t=>{const r=Object.assign({},n[t]||{},e[t]||{});Object.entries(r).forEach(([e,n])=>a.push([t,e,n]))});const l=new Set;a.forEach(([,,t])=>t.forEach(t=>l.add(t)));const c=new Set,d=t=>{let e=s.get(t);return!e&&ie.has(t)&&(e=ie.get(t),ie.delete(t),s.set(t,e)),!e&&i[t]&&(e=re(i[t],t),e&&(s.set(t,e),e.querySelectorAll("[data-edit-key]").forEach(t=>{const e=t.getAttribute("data-edit-key");s.has(e)||s.set(e,t)}))),e};let u=!0;for(;a.length&&u;){u=!1;for(let t=0;t<a.length;t++){const[e,n,r]=a[t],o=n?s.get(n):it(e);if(!o||!o.isConnected)continue;a.splice(t--,1),u=!0;let f=kt(o);const m=r.map(d).filter(t=>t&&t!==o&&!t.contains(o)),p=f.filter(t=>!m.includes(t)&&!l.has(wt(t))&&!i[wt(t)]),h=[...m,...p].flatMap(yt);if(f=f.flatMap(yt),h.length===f.length&&h.every((t,e)=>t===f[e]))continue;const g=f.length?f[f.length-1].nextSibling:Array.from(o.children).find(bt)||null,b=new Map(h.map(t=>[t,t.isConnected?Rt(t):t._editLead||[]]));f.forEach(t=>{if(h.includes(t))return;t._editLead=Rt(t),t._editLead.forEach(t=>t.remove()),t.remove();const e=wt(t);e&&ie.set(e,t)}),h.forEach(t=>{const e=ct(t);e&&c.add(e),o.insertBefore(t,g&&g.parentNode===o?g:null);const n=b.get(t);n.length&&t.before(...n)});const y=ct(o);y&&c.add(y)}}c.size&&ot(),(c.size?se(oe()):s).forEach((e,n)=>{const i=t[n],s=o[n];if(!i&&!s)return;const a=r[n];a&&R(e)!==a?console.warn("[edit] skip stale static node",n):new Set([...Object.keys(i||{}),...Object.keys(s||{})]).forEach(t=>function(t,e,n){if(void 0!==n){if("text"===e)return I(t,n);if(!X(e,n,t.tagName))return"class"===e?wr(t,n):"style"===e?function(t,e){null==e||""===e?t.removeAttribute("style"):t.getAttribute("style")!==e&&t.setAttribute("style",e),t._editPos&&!t.style.position&&(t.style.position="relative")}(t,n):void(null!==n?t.getAttribute(e)!==n&&t.setAttribute(e,n):t.removeAttribute(e))}}(e,t,i&&void 0!==i[t]?i[t]:s&&s[t]))}),c.forEach(t=>{t.isConnected&&(zr(t),t._armed&&Qr(t)&&Jr(t))})}function ce(t,e,n,r,o={}){const i=dt(t),s=e.getAttribute("data-edit-key");if(!s||"!"===s[0])return!1;if("text"===n&&p.has(e.tagName))return!1;"text"===n&&(r=W(e,r));let a=o.before;if(void 0===a){const r="text"===n?t._baseText&&t._baseText[s]:"class"===n?t._baseClass&&t._baseClass[s]:"style"===n?t._baseStyle&&t._baseStyle[s]:e.getAttribute(n),o="text"===n?e._preEdit:"class"===n?e._preClass:"style"===n?e._preStyle:void 0;a=void 0!==o?o:r}if(a===r||"text"===n&&null!=a&&W(e,a)===r)return!1;"text"!==n||document.activeElement===e||$(e)||I(e,r);const d=l[c-1];if(o.coalesce&&d&&c===l.length&&"st-node"===d.kind&&d.region===i&&d.path===s&&d.prop===n&&Date.now()-(Ft.get(d)||0)<1e3)return d.before===r?(l.pop(),c--):(d.value=r,Ft.set(d,Date.now())),zt++,T(),jo(),!0;const u=Kt(Object.assign({kind:"st-node",region:i,path:s,prop:n,value:r,before:a,sig:R(e)},o.join?{join:!0}:{}));return o.coalesce&&Ft.set(u,Date.now()),!0}function de(){const t={};for(let e=0;e<c;e++){const n=l[e];"data-val"===n.kind&&(((t[n.source]=t[n.source]||{})[n.id]=t[n.source][n.id]||{})[n.field]=n.value)}return t}function ue(){const t=de(),e=new Map;l.forEach(t=>{if("data-val"===t.kind){const n=JSON.stringify([t.source,t.id,t.field]);e.has(n)||e.set(n,t)}}),e.forEach(e=>{const n=(t[e.source]=t[e.source]||{})[e.id]=t[e.source][e.id]||{};e.field in n||void 0===e.before||(n[e.field]=e.before)}),rt().forEach(e=>{if("data"!==mt(e))return;const n=gt(e),r=t[n];if(!r)return;const o=h(e),i=ht(e);try{const t=window.Alpine.evaluate(o,i);Array.isArray(t)&&Object.entries(r).forEach(([e,n])=>{const r=t.find(t=>String(t.id)===String(e));r&&Object.entries(n).forEach(([t,e])=>{r[t]!==e&&(r[t]=e)})})}catch{}Qr(e)&&setTimeout(()=>ur(e),0)})}function fe(t,e,n){const r=P(e),o=mt(t);return"component"===o?Qt(t,e,"style",r):"static"===o&&ce(t,e,"style",r,n)}function me(t,e,n){const r=k(e);return!C(n,r)&&(Kt({kind:"st-order",region:dt(t),parent:ee(e,t),order:r,before:n}),!0)}function pe(t,e,n,r,o,i,s={}){const a=n.parentElement,l={kind:"st-move",from:dt(t),to:dt(e),fromParent:ee(r,t),toParent:ee(a,e),key:wt(n),fromOrder:k(r),toOrder:k(a),fromBefore:o,toBefore:i};return s.join&&(l.join=!0),Kt(l),ot(),zr(e),Qr(t)&&Jr(t),e!==t&&Qr(e)&&Jr(e),l}const he=(t,e)=>/^[~@]/.test(e)?e:t+"|"+e;let ge=-1,be=new Map;function ye(){if(ge===zt)return be;be=new Map;for(let t=0;t<c;t++){const e=l[t];if("lock"!==e.kind)continue;const n=he(e.region,e.key),r=be.get(n)||new Map;be.set(n,r),(e.actions&&e.actions.length?e.actions:o).forEach(t=>r.set(t,e.value))}return ge=zt,be}const ve=()=>ye();function Ee(t,e){const n=mt(e);if("static"===n)return t.getAttribute("data-edit-key");if(t===e)return"";if("component"===n)return null!=t._editPath?"path:"+t._editPath:null;const r=h(e);if(r&&t.parentElement===r.parentElement){const n=xt(t,e);return null==n?null:"row:"+n}return null}const we=t=>"data"===t?"text":"class"===t?"attrs":t,Ae=t=>Et(t)?t:vt(t)?t._manifestHost.roots[0]:null;function ke(t,e){const n=we(e),r=t&&1===t.nodeType&&Ae(t);r&&(t=r);let o=r?Be(r):ct(t);const i=ye();for(let e=t;e&&1===e.nodeType;e=e.parentElement){let t;const s=Ae(e);if(s&&i.size){const e=i.get(s.getAttribute("data-edit-host"));e&&e.has(n)&&(t=e.get(n))}if(void 0===t&&o&&i.size&&(!s||e!==r)){const r=Ee(e,o),s=null!=r&&i.get(he(dt(o),r));s&&s.has(n)&&(t=s.get(n))}if(void 0===t&&e._editLock&&(t=e._editLock.has("*")||e._editLock.has(n)),t)return!0;if(e===o){if(s&&e!==r&&(o=Be(e),o))continue;break}}return!1}function _e(t,e,n){if(!t||1!==t.nodeType)return!1;const r=Ae(t),i=r?Be(r):ct(t);if(!i)return!1;if(null!=e&&!o.includes(e))return console.warn("[edit] unknown lock action:",e),!1;if(r)return Kt({kind:"lock",region:dt(i),key:r.getAttribute("data-edit-host"),actions:e?[e]:[],value:!!n}),xe(i),r._edit&&xe(r),!0;const s=Ee(t,i);return null==s?(console.warn("[edit] this element has no stable identity to lock"),!1):(Kt({kind:"lock",region:dt(i),key:s,actions:e?[e]:[],value:!!n}),xe(i),!0)}function xe(t){t&&t._armed&&(Xr(t),Qr(t)&&Jr(t))}const Se=t=>{"cmp-main"===t.kind||"cmp-inst"===t.kind?Gt():"data-val"===t.kind?ue():"theme"===t.kind?Dr():"lock"===t.kind?xe(it(t.region)):le()};function Te(t,e){if("show"===t.kind)return function(t,e){const n=it(t.region);if(!n)return;const r=""===t.key?n:[n,...n.querySelectorAll("[x-show]")].find(e=>Ee(e,n)===t.key);if(r)try{Vn(r,t.expr,e?t.before:t.value)}catch{}}(t,e),null;if("data-splice"===t.kind)!function(t,e){const n=it(t.region);if(!n)return;const r=h(n),o=ht(n);if(!r||!o)return;let i;try{i=window.Alpine.evaluate(r,o)}catch{return}Array.isArray(i)&&((e?"remove"===t.op:"insert"===t.op)?i.splice(Math.min(t.index,i.length),0,JSON.parse(JSON.stringify(t.record))):i.splice(t.index,1),setTimeout(()=>{d[t.region]=Ut(n,mt(n))},0))}(t,e);else{if("data"===t.kind){const n=e?t.before:t.after;return d[t.region]=n,Jt(it(t.region),t.kind,n)}Se(t)}return null}async function Ce(){if(0===c)return;let t;do{t=l[--c],zt++;const e=Te(t,!0);e&&await e}while(t.join&&c>0);Bo(),T(),jo()}async function Oe(){if(!(c>=l.length)){do{const t=l[c++];zt++;const e=Te(t,!1);e&&await e}while(c<l.length&&l[c].join);Bo(),T(),jo()}}function Le(){const t={};for(let e=0;e<c;e++){const n=l[e];"data"===n.kind&&(t[n.region]={kind:n.kind,snap:n.after})}return t}let Me=null,Pe=null;const Re=()=>{Vr&&(Vr.version=(Vr.version||0)+1)},je=t=>{Pe=t,Re()};function $e(t){t&&1!==t.nodeType&&(t=t.parentElement);const e=ct(t);if(Et(t)&&Be(t)&&"static"===mt(Be(t)))return t;if(!e||t===e)return null;const n=mt(e);if("data"===n){const n=h(e),r=n&&n.parentElement;for(let n=t;n&&n!==e;n=n.parentElement)if(n.parentElement===r)return n;return null}if("component"===n){for(let n=t;n&&n!==e;n=n.parentElement)if(null!=n._editPath)return n;return null}let r=null;for(let n=t;n&&n!==e;n=n.parentElement)(Et(n)||vt(n))&&(r=Et(n)?n:n._manifestHost.roots[0]);if(r)return r;for(let n=t;n&&n!==e;n=n.parentElement){if(bt(n))return null;if(Pt(n.parentElement))return n}return null}const Ne=t=>(t=>!!t&&1===t.nodeType&&$e(t)===t)(t)?t:$e(t),Be=t=>t&&ct(t.parentElement),He=t=>!!t&&(!!t._edit||t.hasAttribute("data-edit-area")),qe=t=>!!t&&!!t.parentElement&&!bt(t)&&!Q(t)&&ut(t.parentElement,"move")&&!ke(t,"move")&&"component"!==mt(ct(t.parentElement));function De(t){if(!t||1!==t.nodeType)return!1;const e=ct(t);if(!e||!Qr(e)||!Pt(t))return!1;for(let n=t;n&&n!==e;n=n.parentElement)if(n._manifestComponent)return!1;return ut(t,"move")}function We(t,e){const n=t.cloneNode(!0),r=[t,...t.querySelectorAll("*")],o=[n,...n.querySelectorAll("*")];o.forEach((t,e)=>{sn.has(r[e])&&t.removeAttribute("tabindex")});const i=o.filter((t,e)=>e>0&&A(r[e]));return ar(t,n),i.forEach(t=>t.remove()),n.querySelectorAll("[data-edit-handle], [data-edit-live], [data-edit-ghost]").forEach(t=>t.remove()),[n,...n.querySelectorAll("*")].forEach(t=>{[...t.attributes].forEach(n=>{!n.name.startsWith("data-edit-")||e&&"data-edit-key"===n.name||t.removeAttribute(n.name)}),t.removeAttribute("contenteditable"),t.removeAttribute("draggable")}),n.outerHTML}function Ie(t){const e=h(t),n=ht(t);if(!e||!n)return null;try{const t=window.Alpine.evaluate(e,n);return Array.isArray(t)?t:null}catch{return null}}const ze=(t,e)=>{const n=Ie(t);if(!n)return-1;const r=xt(e,t);return n.findIndex(t=>String(t&&null!=t.id?t.id:t)===String(r))};function Fe(t,e){const n=new Set(t.map(t=>String(t&&t.id)));if(!n.has(String(e)))return String(e);let r=2,o=`${e}-copy`;for(;n.has(o);)o=`${e}-copy-${r++}`;return o}const Ke=["move","remove","duplicate","text","attrs","class","size","copy","cut","paste"],Ue=t=>!(!t||!Me||"static"===mt(t)&&"static"!==Me.kind);function Je(t){const e=t?Ne(t):null;return e?De(e.parentElement)?e.parentElement:null:rt().find(t=>Qr(t)&&De(t))||null}function Xe(t,e){if(!Ke.includes(t))return!1;if("paste"===t){const t=Me&&Je(e);return!!t&&Ue(ct(t))}if(!e||1!==e.nodeType||Q(e))return!1;if(Et(e)&&("move"===t||"duplicate"===t||"remove"===t)){const n=Be(e);return!(!n||!Qr(n))&&("move"===t?qe(e):ut(e.parentElement,"move")&&!ke(e,t))}const n=ct(e);if(!n||!Qr(n))return!1;const r=mt(n);if("size"===t)return!!e._edit&&e._edit.caps.has("size")&&!ke(e,"size");if("text"===t)return ut(e,"text")&&!e.hasAttribute("x-text")&&!e.hasAttribute("x-html")&&("true"===e.getAttribute("contenteditable")||!!e._pieceMode||e.hasAttribute("data-rich-text")||null!=e._editField&&ut(e,"data"));if(("attrs"===t||"class"===t)&&"static"===r&&e._manifestComponent)return!1;if("attrs"===t||"class"===t){if("data"===r||ke(e,"attrs"))return!1;const n=Mt(e);if(n)return"attrs"===t&&ut(n,"text");if("component"===r)return"class"===t&&null!=e._editPath;const o=e.getAttribute("data-edit-key");return!!o&&"!"!==o[0]}if("component"===r)return!1;const o=Ne(e);if(!o)return!1;if("copy"===t)return!Et(o);if("cut"===t)return Xe("copy",o)&&Xe("remove",o);if("move"===t)return qe(o);const i="duplicate"===t?"duplicate":"remove";return ut(o.parentElement,"move")&&!ke(o,i)}function Ve(t){const e=Ne(void 0===t?Pe:t);if(!e)return!1;const n=Be(e);return!!n&&(Me={html:We(e,!0),ops:Ye(e),source:dt(n),kind:mt(n)},Re(),!0)}function Ye(t){const e=Zt(),n={};return[t,...t.querySelectorAll("[data-edit-key]")].forEach(t=>{const r=t.getAttribute("data-edit-key");r&&e.node[r]&&(n[r]=Object.assign({},e.node[r]))}),n}function Ge(t,e,n,r,o){const i=k(e),s=function(t,e){const n=w(),r={};return[t,...t.querySelectorAll("[data-edit-key]")].forEach(t=>{const o=t.getAttribute("data-edit-key");if(!o||"!"===o[0])return void t.setAttribute("data-edit-key","!"+w());const i="~"+n+"~"+v(o);t.setAttribute("data-edit-key",i),e&&e[o]&&(r[i]=Object.assign({},e[o]))}),r}(n,o);r?r.after(n):e.appendChild(n),zr(t),Jr(t),ne(t,e,i,{[n.getAttribute("data-edit-key")]:We(n,!0)},s)}function Qe(t){const e=Ne(void 0===t?Pe:t);if(!Xe("duplicate",e))return!1;const n=Be(e);if("data"===mt(n)){const t=Ie(n),r=ze(n,e);if(!t||r<0)return!1;const o=JSON.parse(JSON.stringify(t[r]));return o&&null!=o.id&&(o.id=Fe(t,o.id)),t.splice(r+1,0,o),te(n,r+1,o,"insert"),!0}if(Et(e))return function(t,e){const n=e.parentElement,r=k(n),o=yt(e),i=o.map(t=>re(We(t)));if(i.some(t=>!t))return!1;const s={roots:i},a="~"+w()+"~"+v(wt(e));return i.forEach(t=>{t._manifestComponent=e._manifestComponent,t._manifestHost=s,t.removeAttribute("data-component")}),i[0].setAttribute("data-edit-host",a),o[o.length-1].after(...i),zr(t),Jr(t),ne(t,n,r,{[a]:i[0].outerHTML}),!0}(n,e);const r=re(We(e,!0));return!!r&&(Ge(n,e.parentElement,r,e,Ye(e)),!0)}function Ze(t){const e=Ne(void 0===t?Pe:t);if(!Xe("remove",e))return!1;const n=Be(e);if("data"===mt(n)){const t=Ie(n),r=ze(n,e);if(!t||r<0)return!1;const o=t[r];return t.splice(r,1),te(n,r,o,"remove"),Pe===e&&je(null),!0}const r=e.parentElement,o=k(r),i=wt(e),s=Et(e)?e.outerHTML:We(e,!0);return e._editLead=Rt(e),e._editLead.forEach(t=>t.remove()),yt(e).slice(1).forEach(t=>t.remove()),e.remove(),ie.set(i,e),(Pe===e||Pe&&e.contains(Pe))&&je(null),ne(n,r,o,{[i]:s}),!0}const tn=t=>{const e=Ne(void 0===t?Pe:t);return Xe("remove",e)&&Ve(e)&&Ze(e)};function en(t){if(!Me)return!1;const e=Je(void 0===t?Pe:t);if(!e)return!1;const n=Ne(void 0===t?Pe:t),r=ct(e);if(!Ue(r))return!1;if("data"===mt(r)){const t=Ie(r);if(!t)return!1;const e=n?ze(r,n)+1:t.length,o=document.createElement("template");o.innerHTML=Me.html;const i={id:Fe(t,"pasted"),label:(o.content.textContent||"").trim()};return t.splice(e,0,i),te(r,e,i,"insert"),!0}if("static"!==mt(r))return!1;const o=re(Me.html);return!(!o||!Bt(o,e)||(Ge(r,e,o,n&&n.parentElement===e?n:null,Me.ops),0))}const nn=t=>t.target.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.target.tagName);function rn(t){const e=ct(t.target&&1===t.target.nodeType?t.target:t.target&&t.target.parentElement);e&&Qr(e)&&je($e(t.target))}const on=t=>{const e=getComputedStyle(t).position;return"absolute"===e||"fixed"===e},sn=new WeakSet;let an,ln=null;function cn(t){an&&an.isConnected||(an=document.createElement("div"),an.setAttribute("data-edit-live",""),an.setAttribute("aria-live","polite"),document.body.appendChild(an)),an.textContent=t}function dn(t){t.removeAttribute("data-edit-piece"),t.removeAttribute("data-edit-grabbable"),sn.has(t)&&(t.removeAttribute("tabindex"),sn.delete(t))}function un(t){const e=new Set(function(t){const e=mt(t);if("component"===e)return[];if("data"===e){const e=h(t);return e?kt(e.parentElement):[]}const n=[],r=t=>kt(t).forEach(t=>{t.closest("[data-edit-ghost], [x-edit\\.grab]")||(t._manifestComponent?Et(t)&&n.push(t):(n.push(t),Pt(t)&&!m(t)&&r(t)))});return Pt(t)&&r(t),n}(t).filter(qe));t.querySelectorAll("[data-edit-piece]").forEach(n=>{e.has(n)||ct(n.parentElement)!==t||dn(n)}),e.forEach(t=>{t.setAttribute("data-edit-piece",""),t.toggleAttribute("data-edit-grabbable",!!kn(t)),t.hasAttribute("tabindex")||(t.tabIndex=0,sn.add(t))})}const fn=t=>{const e=getComputedStyle(t);return/grid/.test(e.display)||/flex/.test(e.display)&&!String(e.flexDirection||"").startsWith("column")?"x":"y"};function mn(t,e,n,r){const o=t.getBoundingClientRect();let i=("x"===fn(r)?e<o.left+o.width/2:n<o.top+o.height/2)?t:yt(t).pop().nextElementSibling;for(;i&&(i===s||i.hasAttribute("data-edit-dragging"));)i=i.nextElementSibling;return{container:r,ref:i}}function pn(t,e,n,r){const o=e?t.left:t.top,i=e?t.width:t.height,s=e?n:r;if(!i)return!0;const a=Math.min(.25*i,24);return s>=o+a&&s<=o+i-a}const hn=(t,e,n,r)=>pn(t.getBoundingClientRect(),"x"===fn(r),e,n),gn=t=>!!t&&!!t._edit&&De(t)&&"static"===mt(t)&&(t=>!!t&&rt().includes(t))(t);function bn(t,e,n){if(n.dataList)return{container:n.home,ref:yn(n.home,t,e)};const r=n.nested;if(r&&r.el.isConnected&&n.ghost.parentElement===r.el&&t>=r.rect.left&&t<=r.rect.right&&e>=r.rect.top&&e<=r.rect.bottom&&pn(r.rect,r.horiz,t,e))return{container:r.el,ref:yn(r.el,t,e)};n.nested=null;const o=n.crossOK?function(t,e,n){const r=document.elementFromPoint?document.elementFromPoint(t,e):null;let o=r&&ct(r);if(o&&o!==n&&n.contains(o)&&(o=n),o&&gn(o))return o;const i=[n,...document.querySelectorAll("[data-edit-drop-target]")].filter((t,e,n)=>gn(t)&&n.indexOf(t)===e),s=(n,r)=>t>=n.left-r&&t<=n.right+r&&e>=n.top-r&&e<=n.bottom+r;let a=null,l=1/0;for(const n of i){const r=n.getBoundingClientRect(),o=Math.hypot(Math.max(r.left-t,0,t-r.right),Math.max(r.top-e,0,e-r.bottom)),c=Dt(L(n,"--edit-drop-reach",""),n,"w")??48,d=n.parentElement,u=d&&d!==document.body&&d!==document.documentElement&&!i.some(t=>t!==n&&d.contains(t))&&s(d.getBoundingClientRect(),0);(s(r,c)||u)&&o<l&&(a=n,l=o)}return a}(t,e,n.area):n.area;if(!o)return null;const i=document.elementFromPoint?document.elementFromPoint(t,e):null;if(i&&n.ghost&&(i===n.ghost||n.ghost.contains(i)))return null;if(i&&i!==o&&o.contains(i)){let r=i;for(let t=i;t&&t!==o;t=t.parentElement)(Et(t)||vt(t))&&(r=Et(t)?t:t._manifestHost.roots[0]);for(let i=r;i&&i!==o;i=i.parentElement){if(i===n.item||n.item.contains(i)||bt(i))continue;const r=i.parentElement;if(Pt(r))if(Et(i)){if(De(r)&&Bt(n.item,r)&&!n.item.contains(r))return mn(i,t,e,r)}else{if(n.ghost&&(i===n.home||i.contains(n.ghost))&&De(i)&&Bt(n.item,i))return{container:i,ref:yn(i,t,e)};if(Pt(i)&&De(i)&&Bt(n.item,i)&&hn(i,t,e,r))return n.ghost&&n.ghost.parentElement!==i&&(n.nested={el:i,rect:i.getBoundingClientRect(),horiz:"x"===fn(r)}),{container:i,ref:yn(i,t,e)};if(De(r)&&Bt(n.item,r)&&!n.item.contains(r))return mn(i,t,e,r)}}}if(!(n.crossOK||i&&o.contains(i))){const r=n.ghost.parentElement;return{container:r,ref:yn(r,t,e)}}return De(o)&&Bt(n.item,o)?{container:o,ref:yn(o,t,e)}:null}function yn(t,e,n){const r="y"===fn(t);for(const o of kt(t)){if(o===s||o.hasAttribute("data-edit-dragging")||ke(o,"move"))continue;const t=o.getBoundingClientRect(),i=t.left+t.width/2,a=t.top+t.height/2;if(r&&!/inline/.test(getComputedStyle(o).display)){if(a>n)return o;continue}const l=Math.abs(a-n)<t.height/2;if(a-n>t.height/2||l&&i>e)return o}return null}function vn(t,e,n,r){const o=t.offsetParent||t.parentElement,i=o.getBoundingClientRect();let s=e-r.grabX-i.left-(o.clientLeft||0)+(o.scrollLeft||0),a=n-r.grabY-i.top-(o.clientTop||0)+(o.scrollTop||0);const l=o.clientWidth-t.offsetWidth,c=o.clientHeight-t.offsetHeight;s=l>0?Wt(s,0,l):Math.max(0,s),a=c>0?Wt(a,0,c):Math.max(0,a),t.style.left=qt(s,r.lu,t,o,"w")+r.lu,t.style.top=qt(a,r.tu,t,o,"h")+r.tu}const En=t=>{t.style.removeProperty("left"),t.style.removeProperty("top"),t.getAttribute("style")||t.removeAttribute("style")},wn=(t,e)=>k(t).filter((n,r)=>kt(t)[r]!==e);function An(t){const e=this;if(!Qr(e)||"mouse"===t.pointerType&&0!==t.button||t._editDrag)return;const n=t.target;if(!n||1!==n.nodeType||n.hasAttribute("data-edit-handle"))return;if(n._pieceMode)return void gr(n);let r=null;for(let t=n;t&&t!==e;t=t.parentElement)if(t.hasAttribute("data-edit-piece")&&qe(t)){r=t;break}if(!r)return;const o=kn(r);if(o){if(!o.contains(n))return;t.preventDefault()}else if(_n(n))return;t._editDrag=!0,function(t,e,n){const r=e.parentElement,o=yt(e).pop().nextElementSibling,i=yt(e).slice(1),a="data"===mt(n),l={item:e,area:n,home:r,dataList:a,ghost:null,crossOK:!a&&"static"===mt(n)&&(Et(e)||!He(e)),homeBefore:a?null:k(r),lu:Ht(e.style.left)||"px",tu:Ht(e.style.top)||"px"},c=e.getBoundingClientRect(),d=e.getAttribute("style"),u=P(e),f=Rt(e);l.grabX=t.clientX-c.left,l.grabY=t.clientY-c.top;const m=t.clientX,p=t.clientY;let h=!1,g=0,b=m,y=p,v=null;const E=t=>{const r=document.activeElement;r&&e.contains(r)&&r.isContentEditable&&r.blur();try{window.getSelection().removeAllRanges()}catch{}l.crossOK&&rt().forEach(t=>{t!==n&&gn(t)&&t.setAttribute("data-edit-drop-target","")});const o=l.ghost=e.cloneNode(!0);ar(e,o),o.setAttribute("data-edit-ghost",""),o.setAttribute("x-ignore",""),o.removeAttribute("id"),o.querySelectorAll("[id]").forEach(t=>t.removeAttribute("id")),[o,...o.querySelectorAll("*")].forEach(t=>{[...t.attributes].forEach(e=>{e.name.startsWith("data-edit-")&&"data-edit-ghost"!==e.name&&t.removeAttribute(e.name)}),t.removeAttribute("contenteditable"),t.removeAttribute("tabindex"),t.removeAttribute("draggable")}),e.before(o),Object.assign(e.style,{position:"fixed",width:c.width+"px",height:c.height+"px",margin:"0",pointerEvents:"none"}),e.setAttribute("data-edit-dragging",""),s=o;try{e.setPointerCapture(t.pointerId)}catch{}},w=()=>{g=0,e.style.left=b-l.grabX+"px",e.style.top=y-l.grabY+"px"},A=t=>{const n=l.ghost,{container:o,ref:i}=t,s=v&&v.container===o&&v.ref===i;v=t,s||o.insertBefore(n,i&&i.parentElement===o?jt(i):null),on(n)?(s||(o===r&&e.parentElement===r?r.insertBefore(n,e):n.nextElementSibling&&o.appendChild(n)),vn(n,b,y,l)):(n.style.left||n.style.top)&&En(n)},_=t=>{if(b=t.clientX,y=t.clientY,!h){if(Math.hypot(b-m,y-p)<5)return;h=!0,E(t),w()}t.preventDefault();const e=bn(b,y,l);e&&A(e),g||(g=requestAnimationFrame(w))},x=t=>{if(document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",S),document.removeEventListener("pointercancel",T),document.removeEventListener("keydown",C,!0),g&&cancelAnimationFrame(g),!h)return;document.querySelectorAll("[data-edit-drop-target]").forEach(t=>t.removeAttribute("data-edit-drop-target")),e.removeAttribute("data-edit-dragging"),t?l.ghost.remove():(l.ghost.replaceWith(e),f.length&&e.before(...f),i.length&&e.after(...i)),null==d?e.removeAttribute("style"):e.setAttribute("style",d),l.ghost=null,s=null;const a=()=>{o&&o.parentElement===r?r.insertBefore(e,jt(o)):r.appendChild(e),f.length&&e.before(...f),i.length&&e.after(...i)};if(t)return a(),void cn("Cancelled");const c=e.parentElement,m=ct(c);if(c!==r&&(l.dataList||!De(c)||!Bt(e,c)||!m||m!==n&&(!l.crossOK||!gn(m))))return a(),void cn("Cancelled");on(e)?vn(e,b,y,l):(e.style.left||e.style.top)&&En(e);const p=P(e)!==u;if(l.dataList)return xn(n,r),void cn("Dropped");let v=!1;c===r?v=me(n,r,l.homeBefore):(pe(n,m,e,r,l.homeBefore,wn(c,e)),v=!0),p&&fe(ct(e),e,{before:u,join:v}),cn(m!==n?"Moved to "+dt(m):"Dropped")},S=()=>x(!1),T=()=>x(!0),C=t=>{"Escape"===t.key&&(t.preventDefault(),t.stopPropagation(),x(!0))};document.addEventListener("pointermove",_),document.addEventListener("pointerup",S),document.addEventListener("pointercancel",T),document.addEventListener("keydown",C,!0)}(t,r,e)}const kn=t=>[...t.querySelectorAll("[x-edit\\.grab]")].find(e=>e.closest("[data-edit-piece]")===t)||null,_n=t=>{const e=document.activeElement;return!!e&&e!==document.body&&e.isContentEditable&&(e===t||e.contains(t))};function xn(t,e){return"data"===mt(t)&&(Xt(t,kt(e).map(e=>xt(e,t))),function(t){if(!t)return;const e=dt(t),n=mt(t),r=Ut(t,n),o=d[e];o&&C(o,r)||(Kt({region:e,kind:n,before:o??r,after:r}),d[e]=r)}(t),!0)}const Sn=(t,e)=>t.target!==e&&!!t.target.closest&&e.contains(t.target.closest('a[href], button, summary, [role="button"], [role="link"]')),Tn=t=>kt(t.parentElement).filter(e=>e===t||!ke(e,"move"));function Cn(t){if(document.activeElement!==t)try{t.focus()}catch{}}function On(t,e){if(t._editRow)return;const n=t.target;if("Enter"===t.key&&n.matches&&n.matches("a[href]")&&Gn(n,e))return;if(n._pieceMode&&"Enter"===t.key)return t._editRow=!0,t.preventDefault(),void gr(n,!0);let r=null;for(let t=n;t&&t!==e;t=t.parentElement)if(t.hasAttribute&&t.hasAttribute("data-edit-piece")&&qe(t)){r=t;break}if(!ln){const e=Ne(n);if(e&&function(t,e){if(nn(t))return!1;const n=t.metaKey||t.ctrlKey,r=(t.key||"").toLowerCase();return n&&"c"===r?Ve(e):n&&"x"===r?tn(e):n&&"v"===r?en(e):n&&"d"===r?Qe(e):!(n||"Delete"!==t.key&&"Backspace"!==t.key)&&Ze(e)}(t,e))return t._editRow=!0,t.preventDefault(),void t.stopPropagation()}if(!r)return;const o={ArrowUp:-1,ArrowDown:1}[t.key],i={ArrowLeft:-1,ArrowRight:1}[t.key],s=t.altKey&&!t.shiftKey&&!t.metaKey&&!t.ctrlKey;if(s&&null!=o&&(!ln||ln.item!==r))return t._editRow=!0,t.preventDefault(),void function(t,e){const n=Be(t),r=t.parentElement,o=Tn(t),i=o.indexOf(t),s=i+e;if(i<0||s<0||s>=o.length)return void cn(`Position ${i+1} of ${o.length}`);const a="data"===mt(n)?null:k(r),l=o[s],c=[];for(let n=e>0?t.nextElementSibling:t.previousElementSibling;n&&n!==l;n=e>0?n.nextElementSibling:n.previousElementSibling)c.push(n);const d=t=>[...Rt(t),...yt(t)];if(e>0){const e=jt(t);[l,...c].filter(t=>!vt(t)).forEach(t=>e.before(...d(t)))}else{let e=yt(t).pop();[...c.slice().reverse(),l].filter(t=>!vt(t)).forEach(t=>{e.after(...d(t)),e=yt(t).pop()})}const u=document.activeElement,f=window.getSelection&&window.getSelection(),m=f&&f.rangeCount?f.getRangeAt(0).cloneRange():null;if(a?me(n,r,a):xn(n,r),u&&u.isConnected&&document.activeElement!==u&&(u.focus(),m))try{f.removeAllRanges(),f.addRange(m)}catch{}cn(`Moved to position ${s+1} of ${o.length}`)}(r,o);if(s&&null!=i&&!nn(t))return t._editRow=!0,t.preventDefault(),void(i>0?Pn(r):Rn(r));if(!(" "!==t.key&&"Enter"!==t.key||nn(t)||Sn(t,r)||t.altKey||t.metaKey||t.ctrlKey))return t._editRow=!0,t.preventDefault(),void(ln&&ln.item===r?(function(){const t=ln;ln=null,t&&(t.item.removeAttribute("data-edit-dragging"),t.before?me(t.area,t.container,t.before):xn(t.area,t.container))}(),Cn(r),cn("Dropped")):(ln&&Ln(),ln={item:r,area:Be(r),container:r.parentElement,next:yt(r).pop().nextElementSibling,before:"data"===mt(Be(r))?null:k(r.parentElement)},r.setAttribute("data-edit-dragging","keyboard"),cn("Grabbed — arrow keys to move, Enter to drop")));if(ln&&ln.item===r){if("Escape"===t.key)return t._editRow=!0,t.preventDefault(),Ln(),Cn(r),void cn("Cancelled");const e=o??i;if(null==e)return;t._editRow=!0,t.preventDefault();const n=Tn(r),s=n.indexOf(r)+e;if(s<0||s>=n.length)return;return $t(r,t=>{e>0?yt(n[s]).pop().after(t):jt(n[s]).before(t)}),Cn(r),void cn(`Position ${s+1} of ${n.length}`)}n!==r||nn(t)||t.altKey||t.metaKey||t.ctrlKey||null==o&&null==i||!on(r)||(t._editRow=!0,function(t,e){const n={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[t.key];if(!n)return;t.preventDefault(),e._moveTimer||(e._preStyle=P(e));const r=t.shiftKey?16:4,o=getComputedStyle(e),i=e.offsetParent||e.parentElement,s=Ht(e.style.left)||"px",a=Ht(e.style.top)||"px",l=Math.max(0,i.clientWidth-e.offsetWidth),c=Math.max(0,i.clientHeight-e.offsetHeight),d=Math.max(0,(parseFloat(o.left)||0)+n[0]*r),u=Math.max(0,(parseFloat(o.top)||0)+n[1]*r);n[0]&&(e.style.left=qt(l?Math.min(l,d):d,s,e,i,"w")+s),n[1]&&(e.style.top=qt(c?Math.min(c,u):u,a,e,i,"h")+a),clearTimeout(e._moveTimer),e._moveTimer=setTimeout(()=>{e._moveTimer=null;const t=e.isConnected&&ct(e);t&&fe(t,e)},350)}(t,r))}function Ln(){const t=ln;ln=null,t&&(t.item.removeAttribute("data-edit-dragging"),$t(t.item,e=>{t.next&&t.next.parentElement===t.container?t.container.insertBefore(e,jt(t.next)):t.container.appendChild(e)}))}const Mn=t=>t===ct(t)?dt(t):t.tagName.toLowerCase();function Pn(t){const e=Be(t);if("static"!==mt(e))return cn("Records stay in their list"),!1;let n=t.previousElementSibling;for(;n&&(bt(n)||"TEMPLATE"===n.tagName||vt(n));)n=n.previousElementSibling;if(!n||Et(n)||!De(n)||!Bt(t,n))return cn("Nothing to nest into"),!1;const r=t.parentElement,o=k(r),i=k(n);return $t(t,t=>n.appendChild(t)),pe(e,e,t,r,o,i),Cn(t),cn("Nested in "+Mn(n)),!0}function Rn(t){const e=Be(t),n=t.parentElement;if("static"!==mt(e))return cn("Records stay in their list"),!1;const r=n&&n!==e?n.parentElement:null;if(!r||r!==e&&!e.contains(r)||!De(r))return cn("Already at the top level"),!1;if(!Bt(t,r))return cn("Cannot move out here"),!1;const o=k(n),i=k(r);return $t(t,t=>yt(n).pop().after(t)),pe(e,e,t,n,o,i),Cn(t),cn("Moved out to "+Mn(r)),!0}let jn;function $n(t,e){const n=t.getBoundingClientRect();t.dispatchEvent(new CustomEvent("edit:size",{bubbles:!0,detail:{width:n.width,height:n.height,css:{width:t.style.width,height:t.style.height},done:e}}))}const Nn=t=>"rtl"===getComputedStyle(t).direction;function Bn(t,e){const n=getComputedStyle(t).position;if("fixed"===n)return"w"===e?document.documentElement.clientWidth:document.documentElement.clientHeight;const r="absolute"===n&&t.offsetParent||t.parentElement;if(!r)return null;const o=getComputedStyle(r),i="w"===e,s=i?r.clientWidth:r.clientHeight;return"absolute"===n?s:i||function(t){for(let e=t,n=0;e&&n<32;e=e.parentElement,n++){if(e===document.documentElement)return!0;const t=getComputedStyle(e).position;if("absolute"===t||"fixed"===t)return!0;let n;if(e.computedStyleMap)try{n=String(e.computedStyleMap().get("height")).trim()}catch{}if(null==n&&(n=(e.style&&e.style.height||"").trim()||"auto"),"auto"===n||""===n)return!1;if(!n.endsWith("%"))return!0}return!1}(r)?s-(parseFloat(i?o.paddingLeft:o.paddingTop)||0)-(parseFloat(i?o.paddingRight:o.paddingBottom)||0):null}function Hn(t,e,n,r){if(!(t=String(t||"").trim())||"none"===t||"auto"===t)return r;if(/^-?[\d.]+%$/.test(t)){const o=Bn(e,n);return null==o?r:parseFloat(t)/100*o}const o=Dt(t,e,n);return null==o?r:o}function qn(t,e){const n=Hn(e.minWidth,t,"w",0),r=Hn(e.minHeight,t,"h",0);return{minW:n,minH:r,maxW:Math.max(n,Hn(e.maxWidth,t,"w",1/0)),maxH:Math.max(r,Hn(e.maxHeight,t,"h",1/0))}}const Dn=t=>"x"===t?["left","right"]:"y"===t?["top","bottom"]:["top","right","bottom","left","top-left","top-right","bottom-left","bottom-right"];function Wn(t){const e=L(t,"--edit-size","both");if("none"===e)return;if(t._sizeBound)return;t._sizeBound=!0;const n=getComputedStyle(t).position;n&&"static"!==n||(t.style.position="relative",t._editPos=!0),(L(t,"--edit-size-edges","")||Dn(e).join(" ")).split(/\s+/).filter(Boolean).forEach(e=>{const n=function(t,e){const n=Nn(e);return t.replace(/start/g,n?"right":"left").replace(/end/g,n?"left":"right")}(e,t),r=document.createElement("span");r.setAttribute("data-edit-handle",e),r.tabIndex=0,r.setAttribute("role","slider"),r.setAttribute("aria-label",`Resize ${e}`),r.addEventListener("pointerdown",e=>function(t,e,n){const r=ct(e);if(!Qr(r)||"mouse"===t.pointerType&&0!==t.button||t.button>0)return;t.preventDefault(),t.stopPropagation();const o=e.getAttribute("style");e._preStyle=P(e);const i=getComputedStyle(e),s=e.getBoundingClientRect(),a=Ht(e.style.width)||"px",l=Ht(e.style.height)||"px",c=parseFloat(i.width)||s.width,d=parseFloat(i.height)||s.height,u=t.clientX,f=t.clientY,{minW:m,maxW:p,minH:h,maxH:g}=qn(e,i),b=n.includes("right"),y=n.includes("left"),v=n.includes("bottom"),E=n.includes("top"),w=Kn(e,"--edit-size-snap-distance","x","w"),A=Kn(e,"--edit-size-snap-distance","y","h"),k=zn(e,"x","w"),_=zn(e,"y","h"),x=Kn(e,"--edit-size-close","x","w"),S=Kn(e,"--edit-size-close","y","h"),T=null!=x||null!=S?function(t){const e=t.getAttribute("x-show");return null==e?null:Un.test(e)?e:(Jn.has(t)||(Jn.add(t),console.warn('[edit] --edit-size-close needs an assignable x-show expression (e.g. x-show="open"); close is off here:',e)),null)}(e):null;let C;if(T)try{C=Xn(window.Alpine.evaluate(e,T))}catch{}const O=t.target;try{O.setPointerCapture&&O.setPointerCapture(t.pointerId)}catch{}O.setAttribute("data-edit-resizing",""),jn||(jn=document.createElement("div"),jn.setAttribute("data-edit-overlay",""),document.body.appendChild(jn)),jn.style.display="block";let L=c,M=d,R=!1;const j=()=>(b||y)&&null!=x&&L<x||(E||v)&&null!=S&&M<S,$=t=>{if(t!==R&&T){R=t;try{Vn(e,T,!t&&C)}catch{}}},N=t=>{const n=t.clientX-u,r=t.clientY-f;(b||y)&&(L=c+(b?n:-n)),(E||v)&&(M=d+(v?r:-r)),$(j());let o=!1;if(b||y){const t=Wt(L,m,p),n=Fn(t,k,w);o=o||k.length>0&&n!==t,e.style.width=qt(n,a,e,e.parentElement,"w")+a}if(E||v){const t=Wt(M,h,g),n=Fn(t,_,A);o=o||_.length>0&&n!==t,e.style.height=qt(n,l,e,e.parentElement,"h")+l}e.toggleAttribute("data-edit-snapped",o&&!R),O.toggleAttribute("data-edit-snapped",o&&!R),$n(e,!1)},B=()=>{document.removeEventListener("pointermove",N),document.removeEventListener("pointerup",D),document.removeEventListener("pointercancel",q),jn&&(jn.style.display="none"),["data-edit-snapped","data-edit-resizing"].forEach(t=>O.removeAttribute(t)),e.removeAttribute("data-edit-snapped")},H=()=>{null==o?e.removeAttribute("style"):e.setAttribute("style",o)},q=()=>{B(),$(!1),H(),$n(e,!0)},D=()=>{B();const t=(b||y)&&null!=x&&L<x,n=(E||v)&&null!=S&&M<S;if((t||n)&&T){const o=(t?m:0)>0||(n?h:0)>0,i=e.style.display;H(),o&&(t&&m>0&&(e.style.width=qt(m,a,e,e.parentElement,"w")+a),n&&h>0&&(e.style.height=qt(h,l,e,e.parentElement,"h")+l));const s=fe(r,e);return $n(e,!0),"none"===i&&(e.style.display="none"),void function(t,e,n,r,o){let i=o;try{void 0===i&&(i=Xn(window.Alpine.evaluate(e,n))),Vn(e,n,!1)}catch(t){return console.warn("[edit] could not close via x-show:",t),!1}const s=Ee(e,t);null!=s&&Kt(Object.assign({kind:"show",region:dt(t),key:s,expr:n,before:i,value:!1},r?{join:!0}:{}))}(r,e,T,s,C)}if(t||n)return H(),void $n(e,!0);fe(r,e),$n(e,!0)};document.addEventListener("pointermove",N),document.addEventListener("pointerup",D),document.addEventListener("pointercancel",q)}(e,t,n)),r.addEventListener("keydown",e=>function(t,e,n){const r={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]};if(!r[t.key])return;const o=ct(e);if(!Qr(o))return;t.preventDefault(),t.stopPropagation(),e._keyTimer||(e._preStyle=P(e));const[i,s]=r[t.key],a=t.shiftKey?32:8,l=getComputedStyle(e),c=n.includes("right"),d=n.includes("left"),u=n.includes("top"),f=n.includes("bottom"),m=Ht(e.style.width)||"px",p=Ht(e.style.height)||"px",{minW:h,maxW:g,minH:b,maxH:y}=qn(e,l);if((c||d)&&i){const t=Wt((parseFloat(l.width)||0)+i*a*(c?1:-1),h,g);e.style.width=qt(t,m,e,e.parentElement,"w")+m}if((u||f)&&s){const t=Wt((parseFloat(l.height)||0)+s*a*(f?1:-1),b,y);e.style.height=qt(t,p,e,e.parentElement,"h")+p}$n(e,!1),clearTimeout(e._keyTimer),e._keyTimer=setTimeout(()=>{e._keyTimer=null;const t=e.isConnected&&ct(e);t&&(fe(t,e),$n(e,!0))},350)}(e,t,n)),t.appendChild(r)})}function In(t,e,n){const r=O(t,`${e}-${n}`);if(r)return"none"===r?"":r;const o=O(t,e);return"none"===o?"":o}function zn(t,e,n){return In(t,"--edit-size-snap",e).split(/\s+/).filter(Boolean).map(e=>Dt(e,t,n)).filter(t=>null!=t)}function Fn(t,e,n){if(!e.length)return t;let r=t,o=1/0;for(const n of e){const e=Math.abs(t-n);e<o&&(o=e,r=n)}return null==n||o<=n?r:t}const Kn=(t,e,n,r)=>{const o=In(t,e,n);return o?Dt(o,t,r):null},Un=/^\s*[A-Za-z_$][\w$]*(?:\s*\.\s*[A-Za-z_$][\w$]*|\s*\[\s*(?:'[^'\\]*'|"[^"\\]*"|\d+)\s*\])*\s*$/,Jn=new WeakSet,Xn=t=>{try{return void 0===JSON.stringify(t)||JSON.parse(JSON.stringify(t))}catch{return!0}};function Vn(t,e,n){window.Alpine.evaluate(t,`${e} = ${JSON.stringify(n)}`)}function Yn(t){requestAnimationFrame(()=>{if(!s&&!ln&&document.activeElement===t)try{const e=document.createRange();e.selectNodeContents(t);const n=window.getSelection();n.removeAllRanges(),n.addRange(e)}catch{}})}function Gn(t,e){const n=t.closest('[contenteditable="false"]');return!!n&&e.contains(n)&&!n.hasAttribute("data-edit-piece-mode")}function Qn(t){const e=t.target&&t.target.closest&&t.target.closest("a[href]"),n=e&&ct(e);n&&Qr(n)&&!Gn(e,n)&&t.preventDefault()}const Zn=new Set;let tr=!1;function er(t,e){if(t._editRtFormat=e,t._editRt||t._pieceMode)return;const n=function(){const t=window.ManifestRichText;return t&&"function"==typeof t.attach?t:(tr||(tr=!0,console.warn("[edit] Rich Text is not loaded; text leaves fall back to plain contenteditable")),null)}();t._editRtPrior=["role","aria-multiline"].map(e=>[e,t.getAttribute(e)]);const r=n&&n.attach(t,{mode:"inline",breaks:!0,enter:"break",all:!1,format:e,onChange:()=>{}});r?(t._editRt=r,t.setAttribute("data-edit-text",""),Zn.add(t)):t.setAttribute("contenteditable","true")}function nr(t){const e=t._editRt;e&&(t._editRt=null,Zn.delete(t),t.removeAttribute("data-edit-text"),e.detach())}const rr=t=>Zn.forEach(e=>{(!e.isConnected||t&&t.contains(e))&&nr(e)}),or=t=>{const e=t._editRt;e&&(e.value=e.value)};function ir(t){const e=this,n=e._editRt,r=Ho(t);if(!n||!r)return;if(n.can(r))return t.preventDefault(),t.stopImmediatePropagation(),void n[r]();const o=ct(e);"undo"===r&&o&&Qr(o)&&!No(e)&&function(t){const e=t._editRt;if(!e||!e.can("redo")||!t._commitText)return;const n=function(t){const e=t._editRt.newest();if(!t._editField||t._editRich)return e.trim();const n=document.createElement("template");return n.innerHTML=e,n.content.textContent}(t);t._commitText(n)&&Ce()}(e),qo(t),t.defaultPrevented&&t.stopImmediatePropagation()}function sr(t){t.addEventListener("drop",e=>{const n=ct(t);n&&Qr(n)&&(e.preventDefault(),e.stopImmediatePropagation())})}function ar(t,e){const n=[t,...t.querySelectorAll("*")],r=[e,...e.querySelectorAll("*")];r.forEach(t=>{const e=t.getAttribute("style");if(e&&/--rich-text-/.test(e)){const n=M(e);n?t.setAttribute("style",n):t.removeAttribute("style")}}),n.forEach((t,e)=>{t._editRt&&r[e]&&([...r[e].attributes].forEach(t=>{t.name.startsWith("data-rich-text")&&r[e].removeAttribute(t.name)}),(t._editRtPrior||[]).forEach(([t,n])=>null==n?r[e].removeAttribute(t):r[e].setAttribute(t,n)))})}function lr(t,e,n){t._textBound||(t._textBound=!0,t._commitText=e,t.addEventListener("focus",()=>{or(t),t._preEdit=$o(t),Yn(t)}),t.addEventListener("keydown",e=>{t.isContentEditable&&("Escape"===e.key?(e.preventDefault(),e.stopImmediatePropagation(),t.blur()):"Enter"!==e.key||!e.altKey||e.shiftKey||e.metaKey||e.ctrlKey||(e.preventDefault(),e.stopImmediatePropagation(),function(t){t.blur();const e=[t,...hr(t)].find(t=>t.hasAttribute&&t.hasAttribute("data-edit-piece"));if(e){e.isContentEditable&&(e._pieceMode=!0,e.setAttribute("data-edit-piece-mode",""),nr(e),e.setAttribute("contenteditable","false"),e.addEventListener("focusout",()=>gr(e),{once:!0}));try{e.focus()}catch{}}}(t)))}),t.addEventListener("keydown",ir),sr(t),n&&t.addEventListener("input",n),t.addEventListener("blur",()=>e()))}const cr=t=>{const e=t.closest("[data-rich-text]");return!(!e||e===t&&t._editRt)};function dr(t){t.querySelectorAll("[data-rich-text]:not([data-rich-text-bound])").forEach(e=>{!e._editRt&&ut(e,"text")&&/^[@~]/.test(e.getAttribute("data-edit-key")||"")&&(e._richBound||(e._richBound=!0,e.addEventListener("focusin",()=>{e._preEdit=$o(e)}),e.addEventListener("blur",()=>{const n=ct(e)||t;("component"===mt(n)?Qt:ce)(n,e,"text",e.innerHTML.trim())},!0)))})}function ur(t){const e=h(t);if(!e)return;const n=(e.getAttribute("x-for").match(/^\s*([\w$]+)\s+in\b/)||[])[1];if(!n)return;const r=gt(t),o=new RegExp("^\\s*"+n+"\\.([\\w$]+)\\s*$");kt(t).forEach(e=>{let i=e.getAttribute("data-key");if(null==i){let t=null;try{t=window.Alpine.$data(e)[n]}catch{}t&&null!=t.id&&(i=String(t.id))}null!=i&&[e,...e.querySelectorAll("*")].forEach(e=>{const n=e.hasAttribute("x-html");if(e.children.length&&(!n||!Ot(e))||e.hasAttribute("data-edit-handle"))return;const s=e.getAttribute("x-text")||e.getAttribute("x-html");if(!s)return;const a=s.match(o);if(!a)return;const l=a[1];if(e._editField=l,e._editRich=n,!e._dvBound){e._dvBound=!0;const o=()=>n?D(e):e.textContent;e._commitText=n=>function(t,e,n,r,o,i){o=String(o),i&&i._editRich&&(o=W(i,o));const s=i?i._preEdit:void 0;return!(s===o||i&&i._editRich&&null!=s&&W(i,s)===o||(Kt({kind:"data-val",region:dt(t),source:e,id:n,field:r,value:o,before:s}),ue(),0))}(t,r,i,l,n??o(),e),e.addEventListener("focus",()=>{or(e),e._preEdit=$o(e),$(e)||Yn(e)}),e.addEventListener("focusin",()=>{e._preEdit=$o(e)}),e.addEventListener("keydown",ir),sr(e),e.addEventListener("blur",()=>e._commitText(),!0)}$(e)||er(e,n?"html":"plain")})})}const fr=t=>{const e=pt(t);return(e?.getAttribute("data-component")||"").replace(/-\d+$/,"")};function mr(t,e,n,r){if("main"!==(t._editScope||"instance"))return;const o=fr(t),i=e._editPath,{inst:s}=Vt();rt().forEach(t=>{if("component"!==mt(t)||fr(t)!==o)return;const a=pt(t);if(!a)return;const l=""===i?a:function(t,e){let n=t;for(const t of e.split(".").map(Number))if(n=At(n)[t],!n)return null;return n}(a,i);l&&l!==e&&void 0===(s[dt(t)]&&s[dt(t)][i]||{})[n]&&("class"===n?wr(l,r):l.innerHTML!==r&&(l.innerHTML=r))})}function pr(t){const e=pt(t);if(!e)return;t._editScope||(t._editScope="instance"),t._baseText=t._baseText||{},t._baseClass=t._baseClass||{},t._baseStyle=t._baseStyle||{};const n=n=>{const r=function(t,e){const n=[];let r=t;for(;r&&r!==e&&r.parentElement;)n.unshift(At(r.parentElement).indexOf(r)),r=r.parentElement;return n.join(".")}(n,e);n._editPath=r,r in t._baseClass||(t._baseClass[r]=n.getAttribute("class")||""),r in t._baseStyle||(t._baseStyle[r]=n.getAttribute("style")||"")};n(e),e.querySelectorAll("*").forEach(t=>{t.hasAttribute("data-edit-handle")||n(t)}),dr(t),Yt(e).forEach(e=>{if(e.children.length&&!Lt(e)||!e.textContent.trim()||!ut(e,"text"))return;if(cr(e))return;const n=e._editPath;n in t._baseText||(t._baseText[n]=e.innerHTML.trim()),lr(e,n=>Qt(t,e,"text",n??D(e)),()=>mr(t,e,"text",e.innerHTML)),er(e,"html")})}const hr=t=>{const e=[],n=ct(t);for(let r=t.parentElement;r&&r!==n;r=r.parentElement)e.push(r);return e};function gr(t,e){if(t._pieceMode&&(t._pieceMode=!1,t.removeAttribute("data-edit-piece-mode"),"false"===t.getAttribute("contenteditable")&&(t.removeAttribute("contenteditable"),er(t,t._editRtFormat||"html")),e)){try{t.focus()}catch{}Yn(t)}}const br=(t,e)=>t.getAttribute(":"+e)??t.getAttribute("x-bind:"+e);function yr(t){const e=br(t,"class");if(null==e)return[];let n;try{n=window.Alpine.evaluate(t,e)}catch{return[]}const r=[],o=t=>String(t).split(/\s+/).filter(Boolean).forEach(t=>r.push(t));return"string"==typeof n?o(n):Array.isArray(n)?n.flat(1/0).filter(Boolean).forEach(o):n&&"object"==typeof n&&Object.entries(n).forEach(([t,e])=>{e&&o(t)}),r}const vr=t=>String(t||"").split(/\s+/).filter(Boolean);function Er(t){const e=new Set(yr(t));return vr(t.getAttribute("class")).filter(t=>!e.has(t)).join(" ")}function wr(t,e){const n=yr(t),r=[...new Set([...vr(e),...n])].join(" ");r?t.getAttribute("class")!==r&&t.setAttribute("class",r):t.hasAttribute("class")&&t.removeAttribute("class")}function Ar(t){if(null==t&&(t=Pe),!t||1!==t.nodeType)return null;const e=ct(t);if(!e||!Qr(e))return null;const n=mt(e);return"static"===n&&t._manifestComponent?null:{el:t,area:e,kind:n}}function kr(t,e,n){const r=Ar(n);if(!r)return!1;t=String(t||"").trim().toLowerCase();const o=!0===e?"":!1===e||null==e?null:String(e),i=X(t,o,r.el.tagName);if(i)return console.warn(`[edit] attribute refused (${i}):`,t),!1;if(ke(r.el,"attrs"))return!1;const s="data"!==r.kind&&Mt(r.el);if(s)return function(t,e,n,r){if(ke(e,"text")||t.el.getAttribute(n)===r)return!1;const o=document.activeElement===e,i=o&&void 0!==e._preEdit?e._preEdit:$o(e),s=t.el.getAttribute(n),a=$o(e),l=e=>null===e?t.el.removeAttribute(n):t.el.setAttribute(n,e);if(l(r),$o(e)===a)return l(s),console.warn(`[edit] ${n} is not kept inside text`),!1;const c=D(e),d="component"===t.kind?Qt(t.area,e,"text",c,i):ce(ct(e),e,"text",c,{before:i});return o&&(or(e),e._preEdit=$o(e)),d}(r,s,t,o);if("class"===t)return _r(r,o||"");if("data"===r.kind)return console.warn("[edit] list rows are rendered from data; attributes on them are not editable"),!1;if("component"===r.kind)return console.warn("[edit] component nodes take class changes only"),!1;if(!/^[@~]/.test(r.el.getAttribute("data-edit-key")||""))return!1;null!=br(r.el,t)&&console.warn(`[edit] ${t} is bound on this element; the binding will override the edited value`);const a=r.el.getAttribute(t);return a!==o&&(null===o?r.el.removeAttribute(t):r.el.setAttribute(t,o),ce(r.area,r.el,t,o,{before:a,coalesce:!0}))}function _r(t,e){if("data"===t.kind)return console.warn("[edit] list rows are rendered from data; attributes on them are not editable"),!1;if(Mt(t.el))return console.warn("[edit] class is not kept inside text"),!1;const n=Er(t.el);return n!==(e=vr(e).join(" "))&&(wr(t.el,e),"component"===t.kind?null!=t.el._editPath&&(mr(t.area,t.el,"class",t.el.getAttribute("class")||""),Qt(t.area,t.el,"class",e,n)):!!/^[@~]/.test(t.el.getAttribute("data-edit-key")||"")&&ce(t.area,t.el,"class",e,{before:n,coalesce:!0}))}function xr(t,e){const n=Ar(t);if(!n)return!1;if(ke(n.el,"attrs"))return!1;const r=e(vr(Er(n.el)));return!!r&&_r(n,r.join(" "))}const Sr={add(t,e){const n=vr(t);return xr(e,t=>[...t,...n.filter(e=>!t.includes(e))])},remove(t,e){const n=new Set(vr(t));return xr(e,t=>t.filter(t=>!n.has(t)))},toggle(t,e,n){const r=Ar(e);if(!r)return!1;const o=vr(t);return n??!o.every(t=>r.el.classList.contains(t))?Sr.add(t,r.el):Sr.remove(t,r.el)},set(t,e){const n=Ar(e);return!!n&&!ke(n.el,"attrs")&&_r(n,t||"")},has(t,e){Vr&&Vr.version;const n=null==e?Pe:e;return!!n&&1===n.nodeType&&vr(t).every(t=>n.classList.contains(t))},list(t){Vr&&Vr.version;const e=null==t?Pe:t;return e&&1===e.nodeType?vr(Er(e)):[]}},Tr=t=>{const e=t&&ct(t);return e&&"component"===mt(e)?e:null};function Cr(t){const e=Tr(null==t?Pe:t);return e?e._editScope||"instance":null}function Or(t){null==t&&(t=Pe);const e=Tr(t);if(!e)return!1;if(t===e)Kt({kind:"cmp-inst",component:fr(n=e),region:dt(n),path:"*",prop:"*",value:It}),Gt();else{if(null==t._editPath)return!1;!function(t,e){Kt({kind:"cmp-inst",component:fr(t),region:dt(t),path:e._editPath,prop:"*",value:It}),Gt()}(e,t)}var n;return!0}const Lr=new Set,Mr={},Pr=new Set,Rr=(t,e)=>(t||"")+"|"+e,jr=t=>t&&Y[t]||document.documentElement,$r=t=>t.value+(t.dataset.unit||"");let Nr=null;function Br(t){const e=t._cssvar;if(!e||!("value"in t))return;const n=getComputedStyle(jr(e.scope)).getPropertyValue(e.var).trim();if(!n)return;const r="color"===t.type?function(t){if(/^#[0-9a-f]{6}$/i.test(t))return t.toLowerCase();try{Nr=Nr||document.createElement("canvas");const e=Nr.getContext&&Nr.getContext("2d",{willReadFrequently:!0});if(!e)return null;const n=document.createElement("i");return n.style.color=t,n.style.color?(e.clearRect(0,0,1,1),e.fillStyle="#000",e.fillStyle=t,e.fillRect(0,0,1,1),"#"+[...e.getImageData(0,0,1,1).data.slice(0,3)].map(t=>t.toString(16).padStart(2,"0")).join("")):null}catch{return null}}(n):t.dataset.unit?String(parseFloat(n)):n;null!=r&&t.value!==r&&(t.value=r)}function Hr(t){const e=t._cssvar;if(!e||!e.var)return;const n=Rr(e.scope,e.var);n in Mr||(Mr[n]=jr(e.scope).style.getPropertyValue(e.var)),Br(t),t._cvBound||(t._cvBound=!0,t.addEventListener("input",()=>jr(e.scope).style.setProperty(e.var,$r(t))),t.addEventListener("change",()=>{return function(t,e,n,r){if(!/^--[\w-]+$/.test(e||""))return void console.warn("[edit] x-edit.cssvar needs a custom property name (--name):",e);const o=function(t){const e=String(null==t?"":t);if(!e.trim())return"empty";if(/expression\s*\(/i.test(e))return"expression()";const n=[];for(let t=0;t<e.length;t++){const r=e[t];if('"'===r||"'"===r){let n=t+1;for(;n<e.length&&e[n]!==r;n++)if("\\"===e[n])n++;else if("\n"===e[n])return"unbalanced quotes";if(n>=e.length)return"unbalanced quotes";t=n;continue}if(/^url\(/i.test(e.slice(t,t+4))&&!/[\w-]/.test(e[t-1]||"")){let n=t+4,r=null,o="";for(;n<e.length;n++){const t=e[n];if(r){if("\\"===t){o+=e[++n]||"";continue}if(t===r){r=null;continue}o+=t}else if('"'!==t&&"'"!==t){if(")"===t)break;o+=t}else r=t}if(n>=e.length)return"unterminated url()";const i=o.replace(/[\u0000-\u0020\u007f]/g,"").toLowerCase();if(/^(javascript|vbscript):/.test(i))return"script URL";if(i.startsWith("data:")&&!i.startsWith("data:image/"))return"data URL";t=n;continue}if(";"===r||"{"===r||"}"===r)return`contains ${r}`;if(e.startsWith("/*",t)||e.startsWith("\x3c!--",t)||e.startsWith("</",t))return"contains a comment or markup";if("("===r||"["===r)n.push(r);else if((")"===r||"]"===r)&&n.pop()!==(")"===r?"(":"["))return"unbalanced brackets"}return n.length?"unbalanced brackets":null}(n);if(o)return void console.warn(`[edit] theme value refused (${o}):`,n);const i=Rr(t,e);Pr.add(i),jr(t).style.setProperty(e,n);const s=qr()[i];s&&s.value===n||Kt({kind:"theme",scope:t||null,var:e,value:n},!!r)}(e.scope,e.var,$r(t),e.persist||!!(n=e.scope&&Y[e.scope])&&!!(n._editPersist||n._edit&&n._edit.persist));var n}))}function qr(){const t={};for(let e=0;e<c;e++){const n=l[e];"theme"===n.kind&&(t[Rr(n.scope,n.var)]=n)}return t}function Dr(){const t=qr();new Set([...Pr,...Object.keys(t)]).forEach(e=>{Pr.add(e);const n=e.indexOf("|"),r=e.slice(0,n)||null,o=e.slice(n+1),i=jr(r),s=t[e]?t[e].value:Mr[e];s?i.style.setProperty(o,s):i.style.removeProperty(o)}),Lr.forEach(Br)}function Wr(t){const e=t&&Y[t];if(!e||tt(e))return null;const n=ct(e),r=e.getAttribute("data-edit-key");if(n&&"static"===mt(n)&&!st(n)&&r&&/^[@~]/.test(r))return"area";if(n&&n!==e)return null;const o=it(t);return o&&o!==e?null:"own"}const Ir=new Map;function zr(t){const e=dt(t),n=!t._marked;t._marked=!0,t._baseClass=t._baseClass||{},t._baseStyle=t._baseStyle||{},t._baseText=t._baseText||{};const r=Object.create(null),o=t=>{for(const e of t.children){const t=b(e);r[t]=(r[t]||0)+1,o(e)}},i=(s,a)=>{if(((o,i)=>{let s=o.getAttribute("data-edit-key");if(!s){if(n){const t=b(o),n=r[t]=(r[t]||0)+1;s=y(e,n>1?t+"#"+n:t),Ir.set(s,i)}else s="!"+w();o.setAttribute("data-edit-key",s)}s in t._baseClass||(t._baseClass[s]=Er(o)),s in t._baseStyle||(t._baseStyle[s]=P(o)),s in t._baseText||o.children.length||(t._baseText[s]=o.innerHTML.trim())})(s,a),s!==t&&(t=>$(t)||m(t)||[...t.attributes].some(t=>t.name.startsWith("x-rich-text")))(s))return;if(s._editRt||(n||s._editRtFormat)&&Lt(s)&&ut(s,"text")&&!m(s))return void(n&&o(s));let l=0;for(const t of s.children){if(bt(t)||t.closest("[data-edit-ghost]")||A(t))continue;const o=""===a?String(l):a+"."+l;if(t._manifestComponent){if(vt(t))continue;if(!t.hasAttribute("data-edit-host")){const i=t.getAttribute("data-edit-key"),s=y(e,"X-"+t._manifestComponent.toUpperCase()+":");let a=i&&(i===s||i.startsWith(s+"#"))?i:"!"+w();if(n&&"!"===a[0]){const n="X-"+t._manifestComponent.toUpperCase()+":",i=r[n]=(r[n]||0)+1;a=y(e,i>1?n+"#"+i:n),Ir.set(a,o)}t.setAttribute("data-edit-host",a)}l++}else i(t,o),l++}};i(t,"")}const Fr=new Set,Kr=new Set,Ur=new Map;function Jr(t){const e=function(t){if("data"!==mt(t))return null;const e=(ht(t)||"").match(/\$x\.([\w$]+)/);if(!e)return"inline x-data list: mnfst-run writes data only to CSV/JSON/YAML sources declared in manifest.json";const n=window.ManifestComponentsRegistry&&window.ManifestComponentsRegistry.manifest;if(!n)return null;const r=(n.data||{})[e[1]];return null==r?`data source '${e[1]}' is not declared in manifest.json: mnfst-run writes data only to CSV/JSON/YAML files declared there`:"string"==typeof r?null:`data source '${e[1]}' is not a file (a cloud or remote source): save it with $x.${e[1]}.$update, not mnfst-run`}(t);e&&(Kr.add(dt(t)),Ur.set(dt(t),e),Fr.has(dt(t))||(Fr.add(dt(t)),console.warn(`[edit] x-edit="${dt(t)}": ${e}; its edits stay on the page (and reach onPublish)`))),t._edit.rendered&&Kr.add(dt(t)),t._edit.rendered&&!Fr.has(dt(t))&&(Fr.add(dt(t)),console.warn(`[edit] x-edit="${dt(t)}" is inside content ${t._edit.rendered} renders: it edits on the page (and reaches onPublish), but mnfst-run cannot write it to a source file`)),rr(null);const n=mt(t);"static"===n&&zr(t),un(t),[t,...t.querySelectorAll("[data-edit-area]")].forEach(t=>{var e,n;n="size",(e=t)._edit&&e._edit.caps.has(n)&&!ke(e,n)&&Wn(t)}),"component"===n?pr(t):"static"===n&&function(t){dr(t);const e=[...t.querySelectorAll("*")];At(t).length&&!Lt(t)||e.unshift(t),e.forEach(e=>{At(e).length&&!Lt(e)||!e.textContent.trim()||e.closest("template")||e.closest("[data-edit-handle], [x-edit\\.grab]")||e._manifestComponent&&e!==t||cr(e)||e.closest('[contenteditable="false"]:not([data-edit-piece-mode])')||!ut(e,"text")||m(e)||p.has(e.tagName)||/^[@~]/.test(e.getAttribute("data-edit-key")||"")&&(lr(e,n=>ce(ct(e)||t,e,"text",n??D(e))),er(e,"html"))})}(t),"data"===n&&ut(t,"data")&&ur(t),t._editBound||(t._editBound=!0,t.addEventListener("pointerdown",An),t.addEventListener("keydown",e=>{Qr(t)&&On(e,t)}),t.addEventListener("dragstart",e=>{Qr(t)&&e.preventDefault()}),t.addEventListener("drop",e=>{Qr(t)&&e.preventDefault()})),t._editObserver||(t._editObserver=new MutationObserver(e=>{s||t._rearmQueued||e.every(t=>t.target.isContentEditable)||(t._rearmQueued=!0,queueMicrotask(()=>{t._rearmQueued=!1,t._armed&&Qr(t)&&!s&&Jr(t)}))}),t._editObserver.observe(t,{childList:!0,subtree:!0}))}function Xr(t){[t,...t.querySelectorAll("[data-edit-area]")].forEach(t=>{t._editPos&&(t.style.removeProperty("position"),t._editPos=!1)}),t.querySelectorAll("[data-edit-handle]").forEach(t=>t.remove()),rr(t),[t,...t.querySelectorAll("[contenteditable]")].forEach(t=>{t.hasAttribute("contenteditable")&&t.removeAttribute("contenteditable"),t._pieceMode=!1,t.removeAttribute("data-edit-piece-mode")}),t.querySelectorAll("[data-edit-piece]").forEach(dn),[t,...t.querySelectorAll("[data-edit-area]")].forEach(t=>{t._sizeBound=!1}),ln&&t.contains(ln.item)&&Ln()}let Vr,Yr=!1,Gr=!1;const Qr=t=>!(!t||!t._edit||t._edit.gated&&(!Vr||!Vr.active)||st(t)),Zr=new Set;function to(){const t=[];rt().forEach(t=>{st(t)&&(Zr.has(dt(t))||(Zr.add(dt(t)),console.warn(`[edit] x-edit="${dt(t)}" is on the page more than once (a component used several times); it is not editable here`)),t._armed&&(Xr(t),t._armed=!1))}),rt().forEach(e=>{Qr(e)&&!e._armed&&(e._editBound||t.push(e),d[dt(e)]=Ut(e,mt(e)),Jr(e),e._armed=!0)}),Yr&&t.length&&(l.some(t=>/^st-/.test(t.kind))&&(ae(t),le()),l.some(t=>"cmp-main"===t.kind||"cmp-inst"===t.kind)&&Gt()),Lr.forEach(Hr),jo(),Yr=!0}function eo(t){const e=[],n=t=>t.edits||t.children||"~"===t.key[0],r=se(oe()),o=new Set(Object.values(qr()).filter(t=>t.scope&&"area"===Wr(t.scope)).map(t=>Y[t.scope]));oe().forEach(r=>{const i=dt(r),s=at(r),a=new Proxy({},{get:(t,e)=>{const n=v(String(e)),r=it(decodeURIComponent(n.slice(1,n.indexOf("@",1)))),o=so&&r&&so[lt(r)];return o?o[n]:void 0}}),l=(e,r)=>{const s=!r&&e.getAttribute("data-edit-host");if(s){if("!"===s[0])return null;const t={key:s},e=Ir.get(s);return null!=e&&(t.at=e),a&&a[s]&&(t.fp=a[s]),t}if(!r&&e._manifestComponent)return null;const c=e.getAttribute("data-edit-key");if(!c||"!"===c[0])return null;const d={key:c},u=Ir.get(v(c));null!=u&&(d.at=u),a&&a[v(c)]&&(d.fp=a[v(c)]);const f=(e=>{const n=t.node[e];if(!n)return null;const r={};return Object.entries(n).forEach(([t,e])=>{r[t]="class"!==t&&"style"!==t||""!==e?e:null}),Object.keys(r).length?r:null})(c);if(f&&(d.edits=f),o.has(e)&&(d.edits=Object.assign({},d.edits,{style:P(e)||null})),!(f&&"text"in f||m(e)||"TEMPLATE"===e.tagName||e.hasAttribute("data-rich-text"))){const o=(t=>At(t).filter(t=>!A(t)))(e).map(t=>l(t)).filter(Boolean),s=t.touched.has(r?"#"+i:c);if("~"===c[0]||s){d.children=o;const e=s&&"~"!==c[0]&&(e=>{const n=""===e?(t.orderBase[i]||{})[""]:Object.values(t.orderBase).map(t=>t[e]).find(Boolean);return n?n.filter(t=>"@"===t[0]).map(t=>{const e={key:t},n=Ir.get(t);return null!=n&&(e.at=n),a&&a[t]&&(e.fp=a[t]),e}):null})(r?"":c);e&&(d.base=e)}else o.some(n)&&(d.children=o.filter(n),d.path=!0)}return d},c=l(r,!0);c&&(c.edits||c.children)&&(delete c.at,delete c.fp,e.push(s?{kind:"static-tree",region:i,component:s,tree:c}:{kind:"static-tree",region:i,tree:c}))});const i=new Set;new Set([...Object.keys(t.orderBase),...Object.keys(t.order)]).forEach(e=>{Object.values(Object.assign({},t.orderBase[e]||{},t.order[e]||{})).forEach(t=>t.forEach(t=>i.add(t)))});const s=new Set;for(let t=0;t<c;t++){const e=l[t];"st-children"===e.kind&&e.before.forEach(t=>{!t||"@"!==t[0]||i.has(t)||r.has(t)||s.add(t)})}return s.forEach(t=>{const n=(t=>decodeURIComponent(t.slice(1,t.indexOf("@",1))))(t);let r=e.find(t=>t.region===n);if(!r){const t=it(n);if(!t||st(t))return;const o=at(t);r=o?{kind:"static-tree",region:n,component:o,tree:{key:""}}:{kind:"static-tree",region:n,tree:{key:""}},e.push(r)}(r.removed=r.removed||[]).push(t)}),e}function no(){const t=Object.entries(Le()).map(([t,e])=>{return n=t,r=e.kind,o=e.snap,{region:n,kind:r,op:"reorderData",source:o.source,order:o.order};var n,r,o});eo(Zt()).forEach(e=>t.push(e));const e=t=>{const e=[];return Object.entries(t).forEach(([t,n])=>Object.entries(n).forEach(([n,r])=>e.push({path:t,key:t,prop:n,value:r}))),e},n=de(),r={};l.slice(0,c).forEach(t=>{"data-val"===t.kind&&(r[t.source]=t.region)}),Object.entries(n).forEach(([e,n])=>Object.entries(n).forEach(([n,o])=>Object.entries(o).forEach(([o,i])=>t.push({kind:"data-val",region:r[e],source:e,id:n,field:o,value:i}))));const{main:o,inst:i,reverts:s}=Vt();return Object.entries(o).forEach(([n,r])=>{const o=e(r);o.length&&t.push({kind:"component",scope:"main",component:n,edits:o})}),new Set([...Object.keys(i),...Object.keys(s)]).forEach(n=>{const r=it(n);if(!r)return;const o=e(i[n]||{}),a=[...s[n]||[]];(o.length||a.length)&&t.push({kind:"component",scope:"instance",component:fr(r),region:n,edits:o,reverts:a})}),function(){const t=Object.values(qr()),e=[];return t.filter(t=>!Wr(t.scope)).forEach(t=>e.push({kind:"theme",scope:t.scope||null,var:t.var,value:t.value,file:null})),new Set(t.filter(t=>t.scope&&"own"===Wr(t.scope)).map(t=>t.scope)).forEach(t=>{const n=Y[t],r=(t=>{for(let e=t;e;e=e.parentElement)if(e._manifestComponent)return e._manifestComponent;return null})(n),o={key:"",edits:{style:P(n)||null}};e.push(r?{kind:"static-tree",region:t,component:r,tree:o}:{kind:"static-tree",region:t,tree:o})}),e}().forEach(e=>t.push(e)),t}function ro(t){const e=e=>"theme"===e.kind?!!t&&(t.has("theme|"+(e.scope||"")+"|"+e.var)||t.has(e.scope)):("st-move"===e.kind?[e.from,e.to]:[e.region]).some(e=>!(e=>null==e||!!it(e)&&!(t&&t.has(e)))(e)),n=[],r=ve();se(oe().filter(e=>!(t&&t.has(dt(e))))).forEach((t,e)=>{const o=r.get(e);o&&o.size&&n.push([t,new Map(o),e===t.getAttribute("data-edit-host")])});const i=l.slice(0,c).filter(t=>"lock"===t.kind&&!/^[~@]/.test(t.key)&&!e(t));let s=0;l=l.filter((t,n)=>{const r=e(t);return r&&n<c&&s++,r}),c=s,zt++,T();const a=t?[...Ir].filter(([e])=>t.has(decodeURIComponent(e.slice(1,e.indexOf("@",1))))):[];Ir.clear(),a.forEach(([t,e])=>Ir.set(t,e)),rt().forEach(e=>{if(t&&t.has(dt(e)))return;const n=mt(e);e._baseText={},e._baseClass={},e._baseStyle={},"static"===n&&([e,...e.querySelectorAll("[data-edit-key]")].forEach(t=>{ct(t)===e&&t.removeAttribute("data-edit-key")}),e.querySelectorAll("[data-edit-host]").forEach(t=>{ct(t.parentElement)===e&&t.removeAttribute("data-edit-host")}),e._marked=!1,zr(e)),"component"===n&&e._armed&&pr(e),d[dt(e)]=Ut(e,n)}),function(t){Object.keys(Mr).forEach(e=>{if(t&&t.has("theme|"+e))return;const n=e.indexOf("|");Mr[e]=jr(e.slice(0,n)||null).style.getPropertyValue(e.slice(n+1))}),[...Pr].forEach(e=>{t&&t.has("theme|"+e)||Pr.delete(e)})}(t),(()=>{const t=t=>{l.splice(c,0,t),c++,ft(t.region)&&u.add(t)};i.forEach(t),n.forEach(([e,n,r])=>{const i=r?Be(e):ct(e),s=e.getAttribute(r?"data-edit-host":"data-edit-key");i&&s&&[!0,!1].forEach(e=>{const r=[...n].filter(([,t])=>t===e).map(([t])=>t);r.length&&t({kind:"lock",region:dt(i),key:s,actions:r.length===o.length?[]:r,value:e})})}),zt++})(),T(),jo()}const oo=t=>!(t&&Array.isArray(t.results)&&t.results.some(t=>t&&"error"===t.status));let io=null,so=null;function ao(t){return/^https?:$/.test(location.protocol)&&"function"==typeof fetch?fetch("/__edit/base",{cache:"no-store"}).then(t=>t.ok?t.json():null).then(e=>(e&&e.files&&(io=e.files),e&&e.ids&&!t&&(so=e.ids),io)).catch(()=>null):Promise.resolve(null)}let lo=!1;window.addEventListener("manifest:source-change",t=>{const e=t.detail||{},n=/\.html?$/i.test(e.file||"");n&&!so&&(lo=!0),io&&e.file&&e.hash&&!n&&(io[e.file]=e.hash)});let co=null,uo=0,fo=[],mo=!1,po=null;const ho=t=>!mo&&!!co&&Date.now()<co.until&&t.length>0&&t.every(t=>t&&co.files[t.rel]&&co.files[t.rel]===t.hash);function go(t){const e=document.activeElement;if(!e||!e._commitText||void 0===e._preEdit||!e.isContentEditable||$o(e)===e._preEdit)return!0;const n=ct(e);return!(!n||!t&&!n._edit.persist||(e._commitText(),or(e),e._preEdit=$o(e),0))}function bo(t){const e=new Map;for(let n=!0;n;)n=!1,l.slice(0,c).forEach(r=>{if("st-move"!==r.kind||t.has(r.from)===t.has(r.to))return;const[o,i]=t.has(r.from)?[r.from,r.to]:[r.to,r.from];t.add(i),e.set(i,e.get(o)||o),n=!0});return t.via=e,t}const yo=t=>{if("string"!=typeof t)return null;const e=v(t);return"@"===e[0]?e.slice(1,e.indexOf("@",1)):null},vo=t=>Kr.has(t.region)||Kr.has(t.from)||Kr.has(t.to)||Kr.has(yo(t.path))||Kr.has(yo(t.key)),Eo=t=>[...new Set(t.flatMap(t=>[t.region,t.from,t.to]).filter(Boolean))],wo=()=>l.slice(0,c).filter(t=>"lock"!==t.kind&&!u.has(t));function Ao(){const t=document.activeElement,e=t&&t._commitText&&ct(t);return e?dt(e):null}function ko(){return!(!go(!1)&&!Kr.has(Ao()))&&wo().every(vo)}function _o(){const t=Ao(),e=Eo(wo().filter(vo));t&&Kr.has(t)&&!go(!1)&&!e.includes(t)&&e.push(t),e.length&&console.warn(`[edit] the source changed: reloading discards the unpublished edits of ${e.map(t=>`x-edit="${t}"`).join(", ")} that mnfst-run can't write (generated content, or a piece moved from it); .persist keeps them`)}function xo(){_o(),location.reload()}function So(){po&&ko()&&(po=null,xo())}function To(t){if(ko())return xo();po=t;const e=t.map(t=>t&&t.rel).filter(Boolean);Vr&&(Vr.stale=[...new Set([...Vr.stale||[],...e])]);const n=Eo(wo().filter(t=>!vo(t))).filter(t=>!Kr.has(t)),r=Ao();!r||Kr.has(r)||n.includes(r)||go(!1)||n.push(r);const o=bo(new Set(Kr)),i=n.filter(t=>o.has(t)),s=t=>t.map(t=>`x-edit="${t}"`).join(", ");console.warn(`[edit] the source changed, but a reload would lose unpublished edits${n.length?" to "+s(n):""}: publish (with rebase), then reload`+(i.length?`. ${s(i)} ${i.length>1?"are":"is"} tied by a move to ${s([...new Set(i.map(t=>o.via.get(t)))])}, which mnfst-run can't write: undo that move to publish ${i.length>1?"them":"it"}, or publish the rest`:"")),document.dispatchEvent(new CustomEvent("edit:stale",{detail:{files:e}}))}function Co(t,e){if(uo=Math.max(0,uo-1),t&&t.base&&(co={files:Object.assign({},t.base),until:Date.now()+3e3}),t&&Array.isArray(t.stale)&&t.stale.length&&(mo=!0),e&&oo(t)&&t.base&&(mo=!0,setTimeout(()=>{mo&&To(Object.keys(t.base).map(t=>({rel:t})))},1500)),uo)return;const n=fo;fo=[],n.some(t=>!ho(t))&&To(n.flat())}window.addEventListener("manifest:live-reload",t=>{const e=t.detail&&t.detail.files||[];if(uo)return t.preventDefault(),void fo.push(e);ho(e)?t.preventDefault():ko()?_o():(t.preventDefault(),To(e))});let Oo=Promise.resolve();function Lo(t){const e=Oo.then(()=>function(t){const e=(t,e,n)=>{t&&t.base&&io&&Object.entries(t.base).forEach(([t,e])=>{Mo&&/\.html?$/i.test(t)||(io[t]=e)}),t&&t.ids&&so&&(Mo?Object.entries(t.ids).forEach(([t,e])=>{so[t]=Object.assign({},so[t]),Object.entries(e||{}).forEach(([e,n])=>{String(n).includes(".")||(so[t][e]=n)})}):so=t.ids);const r=t&&Array.isArray(t.stale)?t.stale:[];return Vr&&(Vr.stale=r),r.length&&document.dispatchEvent(new CustomEvent("edit:stale",{detail:{files:r}})),oo(e?{results:t.results.filter(t=>!(t&&(e.has(t.region)||n&&n.has(t))))}:t)&&ro(e),So(),t},n=(t,e)=>{if(!t||!Array.isArray(t.results)||Array.isArray(t.stale)&&t.stale.length)return null;const n=new Set(t.results.filter(t=>t&&null!=t.failed).map(t=>t.failed)),r=new Set(e.filter((e,n)=>t.results[n]&&"error"===t.results[n].status&&null==t.results[n].failed&&"static-tree"!==e.kind));if(!n.size&&!r.size||t.results.some((t,o)=>t&&"error"===t.status&&!n.has(e[o]&&e[o].region)&&!r.has(e[o])))return null;bo(n);const o=t=>r.has(t)||null!=t.region&&n.has(t.region);return e.some(t=>!o(t))?Object.assign(n,{own:r,out:o}):null},r=t=>"theme"===t.kind?"theme|"+(t.scope||"")+"|"+t.var:t.region,o=t=>{const e=it(t);return e&&e._edit.rendered},i=t=>null!=t.region&&"theme"!==t.kind&&Kr.has(t.region),s=()=>{go(!0);const s=no();if(Vr&&"function"==typeof Vr.onPublish)return Promise.resolve(Vr.onPublish(s,{log:l,cursor:c})).then(e);if(!s.length)return So(),Promise.resolve({results:[]});const a=t=>(uo++,fetch("/__edit/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({patches:t,base:io})}).then(t=>t.json()).catch(t=>{throw Co(null),t})),d=bo(new Set(s.filter(i).map(t=>t.region))),u=t=>({region:t.region,status:"error",reason:Ur.has(t.region)&&i(t)?`x-edit="${t.region}": ${Ur.get(t.region)}`:o(t.region)&&i(t)?`x-edit="${t.region}" is inside content ${o(t.region)} renders, so mnfst-run can't write it to a source file`:`not published: tied by a move to x-edit="${d.via.get(t.region)}", which mnfst-run can't write`}),f=s.filter(t=>!d.has(t.region)),m=(n,o,i)=>{const a=new Set([...d,...o||[],...o?i.filter(o.out).map(r):[]]),l=new Set,c=s.map(t=>{if(d.has(t.region)){const e=u(t);return l.add(e),e}const e=n.results[i.indexOf(t)];return o&&o.out(t)&&l.add(e),e}),f=e(Object.assign({},n,{results:c}),a.size?a:void 0,l);return Co(n,!(!t||!t.rebase)),f};if(!f.length){const t=e({results:s.map(u)},d);return Promise.resolve(t)}return a(f).then(t=>{const e=n(t,f);if(!e)return m(t,null,f);Co(t,!1);const r=f.filter(t=>!e.out(t));return a(r).then(n=>{const o=f.map((o,i)=>e.out(o)?t.results[i]&&"error"===t.results[i].status?t.results[i]:{region:o.region,status:"error",reason:`not published: tied by a move to x-edit="${e.via.get(o.region)||[...e].find(t=>!e.via.has(t))}", which failed`}:n.results[r.indexOf(o)]);return m(Object.assign({},n,{results:o}),e,f)})})},a=t=>{const n=no();return n.length?e({results:n.map(e=>({region:e.region,status:"error",reason:t}))}):{results:[]}},d=Vr&&"function"==typeof Vr.onPublish||io&&so?Promise.resolve(null):lo?Promise.resolve("the source changed before this page could read its base from the dev server; reload to continue"):ao().then(()=>io&&so?null:"the dev server's base (/__edit/base) could not be read, so nothing can be checked against the source; nothing was published"),u=()=>{const t=Object.assign({},io);return ao(!0).then(()=>(Object.keys(io||{}).some(e=>/\.html?$/i.test(e)&&t[e]!==io[e])&&(Mo=!0),s()))};return d.then(e=>e?a(e):t&&t.rebase?u():s())}(t));return Oo=e.catch(()=>{}),e}let Mo=!1;function Po(){Vr&&(Vr.active=!0),to()}function Ro(){Vr&&(Vr.active=!1),rt().forEach(t=>{t._edit.gated&&t._armed&&(Xr(t),t._armed=!1)}),jo()}function jo(){Vr&&(Vr.canUndo=c>0,Vr.canRedo=c<l.length,Vr.version=(Vr.version||0)+1,po&&setTimeout(So,0))}const $o=t=>t._editField&&!t._editRich?t.textContent:W(t,t.innerHTML.trim()),No=t=>!!t.closest('[data-edit-hotkeys="off"]');function Bo(){const t=document.activeElement;if(!t||void 0===t._preEdit||!t.isContentEditable)return;const e=()=>{document.activeElement===t&&(or(t),t._preEdit=$o(t))};e(),setTimeout(e,0)}function Ho(t){if(t.altKey||!t.metaKey&&!t.ctrlKey)return null;const e=(t.key||"").toLowerCase();return"z"===e?t.shiftKey?"redo":"undo":"y"!==e||!t.ctrlKey||t.metaKey||t.shiftKey?null:"redo"}function qo(t){if(t.defaultPrevented||s)return;const e=Ho(t);if(!e)return;const n="redo"===e,r=t.target&&1===t.target.nodeType?t.target:document.body;if(/^(INPUT|TEXTAREA|SELECT)$/.test(r.tagName)||$(r.closest("[data-rich-text]")))return;const o=r.closest("[data-edit-area]");if(o){const t=ct(o);if(!t||!Qr(t)||No(o))return}else{if(r.isContentEditable)return;if(!rt().some(t=>Qr(t)&&!No(t)))return}r.isContentEditable&&void 0!==r._preEdit&&$o(r)!==r._preEdit||(n?c>=l.length:0===c)||(t.preventDefault(),n?Oe():Ce())}function Do(){if(l.length){!function(){const t=t=>("st-move"===t.kind?[t.from,t.to]:null!=t.region?[t.region]:[]).some(t=>{const e=it(t);return e&&!e._edit.persist});if(!l.some(t))return;let e=0;const n=l.filter((n,r)=>{const o=!t(n);return o&&r<c&&e++,o});l=n,c=e,zt++,T()}();for(const[t,e]of Object.entries(Le())){const n=it(t);n&&"data"===e.kind&&Wo(n,()=>Jt(n,"data",e.snap))}if(l.some(t=>/^st-/.test(t.kind))&&(ae(rt()),le()),l.some(t=>"cmp-main"===t.kind||"cmp-inst"===t.kind)&&Gt(),l.some(t=>"data-val"===t.kind)){const t=rt().find(t=>"data"===mt(t));t&&Wo(t,ue)}l.some(t=>"theme"===t.kind)&&Dr(),l.some(t=>"lock"===t.kind)&&rt().forEach(xe),jo()}}function Wo(t,e){const n=ht(t),r=h(t);let o=0;const i=setInterval(()=>{let t=!1;try{t=Array.isArray(window.Alpine.evaluate(r,n))}catch{}t?(clearInterval(i),e()):++o>100&&clearInterval(i)},50)}let Io=!1;function zo(){if(Io||!window.Alpine||!Alpine.directive)return;Io=!0,document.body&&!document.body.hasAttribute("x-data")&&document.body.setAttribute("x-data","{}"),Alpine.directive("edit",(t,{modifiers:e,expression:n},{cleanup:r})=>{et(t,e,n),Yr&&!Gr&&(Gr=!0,queueMicrotask(()=>{Gr=!1,to()})),r(()=>function(t){Object.keys(Y).forEach(e=>{Y[e]===t&&delete Y[e]}),Lr.delete(t),V.has(t)&&(t._armed&&(Xr(t),t._armed=!1),t._editObserver&&(t._editObserver.disconnect(),t._editObserver=null),V.delete(t),delete t._edit,ot(),t.removeAttribute("data-edit-area"),Pe&&(Pe===t||t.contains(Pe))&&je(null),jo())}(t))}),Alpine.store("edit",{active:!1,canUndo:!1,canRedo:!1,version:0,stale:[],conflicts:[],onPublish:null,toggle(){this.active?Ro():Po()},on(){Po()},off(){Ro()},undo:()=>Ce(),redo:()=>Oe(),publish:t=>Lo(t),patches:()=>no(),export:()=>JSON.parse(JSON.stringify({log:l,cursor:c})),get target(){return this.version,Pe},set target(t){(t=>{je(t&&1===t.nodeType?Ne(t)||t:null)})(t)},can(t,e){return this.version,Xe(t,void 0===e?Pe:e)},lock:(t,e)=>_e(void 0===t?Pe:t,e,!0),unlock:(t,e)=>_e(void 0===t?Pe:t,e,!1),copy:t=>Ve(t),cut:t=>tn(t),paste:t=>en(t),duplicate:t=>Qe(t),remove:t=>Ze(t),move:(t,e,n)=>function(t,e,n){const r=Ne(null==t?Pe:t);if(!r||!qe(r))return!1;const o=Be(r),i="string"==typeof e?it(e):e;if(!i||1!==i.nodeType||i===r||r.contains(i))return!1;const s=ct(i);if(!(o&&s&&Qr(o)&&Qr(s)&&De(i)))return!1;n&&n.parentElement!==i&&(n=null);const a=r.parentElement;if(!Bt(r,i))return!1;if("data"===mt(o))return i===a&&($t(r,t=>i.insertBefore(t,n?jt(n):null)),xn(o,i),!0);if("static"!==mt(o)||"static"!==mt(s))return!1;if(o!==s&&He(r)&&!Et(r))return!1;const l=k(a),c=k(i);return $t(r,t=>i.insertBefore(t,n?jt(n):null)),i===a?me(o,i,l):(pe(o,s,r,a,l,c),!0)}(t,e,n),nest(t){const e=Ne(void 0===t?Pe:t);return!!e&&qe(e)&&Pn(e)},unnest(t){const e=Ne(void 0===t?Pe:t);return!!e&&qe(e)&&Rn(e)},block:t=>$e(t),attr:(t,e,n)=>kr(t,e,n),classes:Sr,scope(t,e){return this.version,t&&1===t.nodeType?Cr(t):null==t?Cr(e):function(t,e){const n=Tr(null==e?Pe:e);return!(!n||"instance"!==t&&"main"!==t||(n._editScope=t,Re(),0))}(t,e)},revert:t=>Or(t),clearConflicts(){_=[],this.conflicts=[],T()}}),Vr=Alpine.store("edit");const n=()=>Alpine.store("edit");Alpine.magic("edit",n),window.__manifestEditMagic=n;const r=window.__manifestEditStubWrites;r&&Object.keys(r).forEach(t=>{try{Vr[t]=r[t]}catch{}delete r[t]}),window.__manifestEditStub&&setTimeout(()=>{window.__manifestEditStub.v++},0),(()=>{try{e=location.pathname;const n=JSON.parse(localStorage.getItem(t(e)));n&&8===n.v?(l=n.log||[],c=n.cursor??l.length,l.forEach(t=>u.add(t)),_=Array.isArray(n.conflicts)?n.conflicts:[],_.forEach(t=>x.add(t)),Vr&&(Vr.conflicts=_.slice())):n&&localStorage.removeItem(t(e))}catch{}})(),window.__mnfstEdit&&ao(),setTimeout(()=>{to(),Do()},450),document.addEventListener("keydown",qo),window.addEventListener("click",Qn,!0),window.addEventListener("auxclick",Qn,!0),document.addEventListener("contextmenu",rn,!0),document.addEventListener("dropdown:context",rn,!0),window.addEventListener("manifest:route-change",()=>{e!==location.pathname&&(e=location.pathname,T())}),function(){if(!window.__manifestAlpineStarted&&![...document.querySelectorAll("[x-data]")].some(t=>t._x_marker))return;const t=t=>/^x-edit(\.|$)/.test(t),e=[...document.querySelectorAll("*")].filter(e=>!e._edit&&[...e.attributes].some(e=>t(e.name)));e.forEach(e=>{e._x_marker&&[...e.attributes].filter(e=>t(e.name)).forEach(t=>e.setAttribute(t.name,t.value))}),e.some(t=>!t._x_marker)&&Alpine.initTree(document.body)}()}document.addEventListener("alpine:init",zo),window.Alpine&&Alpine.directive&&setTimeout(zo,0)}();
2
2
  //# sourceMappingURL=manifest.edit.min.js.map