mnfst 0.5.321 → 0.5.322
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/manifest.appwrite.data.js +1 -1
- package/lib/manifest.data.js +1 -1
- package/lib/manifest.data.min.js +1 -1
- package/lib/manifest.edit.js +6 -4
- package/lib/manifest.edit.min.js +1 -1
- package/lib/manifest.edit.min.js.map +1 -1
- package/lib/manifest.integrity.json +10 -10
- package/lib/manifest.js +2 -2
- package/lib/manifest.min.js +1 -1
- package/lib/manifest.modules.integrity.json +7 -7
- package/lib/manifest.sw.js +1 -1
- package/lib/manifest.sw.min.js +1 -1
- package/package.json +1 -1
package/lib/manifest.edit.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(){const e=e=>"mnfst-edit-log:"+(e||location.pathname);let t=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=e=>[...e.attributes].some(e=>{const t=e.name.toLowerCase();return f.some(e=>t===e||t.startsWith(e+"."))}),p=new Set(["SCRIPT","STYLE","TEXTAREA","TITLE","NOSCRIPT","TEMPLATE","XMP","IFRAME","NOEMBED","NOFRAMES"]),h=e=>[...e.children].find(e=>"TEMPLATE"===e.tagName&&e.hasAttribute("x-for"))||null;function g(e){if(m(e))return"";let t="";for(const n of e.childNodes)3===n.nodeType?t+=n.textContent:1!==n.nodeType||be(n)||"TEMPLATE"===n.tagName||k(n)||n._manifestComponent||(t+=g(n));return t}const b=e=>e.tagName.toUpperCase()+":"+g(e).replace(/\s+/g," ").trim().slice(0,24),y=(e,t)=>"@"+encodeURIComponent(e)+"@"+t,v=e=>e&&"~"===e[0]?e.slice(e.indexOf("~",1)+1):e;let E=0;const w=()=>Date.now().toString(36)+(++E).toString(36)+Math.random().toString(36).slice(2,6);function k(e){for(let t=e.previousElementSibling;t;t=t.previousElementSibling){if("TEMPLATE"!==t.tagName)continue;if(t._x_currentIfEl===e)return!0;const n=t._x_lookup;if(n&&(n instanceof Map?[...n.values()]:Object.values(n)).includes(e))return!0}return!1}function A(e){const t=Object.create(null);return Ae(e).map(e=>{const n=e.getAttribute("data-edit-host")||e.getAttribute("data-edit-key");if(n)return n;const r=b(e),o=t[r]=(t[r]||0)+1;return o>1?r+"#"+o:r})}let _=[];const x=new WeakSet,S=new Set([location.pathname]),T=t=>{if(l.length>400){const e=l.length-400;l.splice(0,e),c=Math.max(0,c-e)}const n=l.slice(0,c).filter(e=>u.has(e)),r=l.slice(c).filter(e=>u.has(e));S.add(t||location.pathname);const o=_.filter(e=>x.has(e));(t?[t]:[...S]).forEach(t=>{try{n.length||r.length||o.length?localStorage.setItem(e(t),JSON.stringify(Object.assign({v:8,log:[...n,...r],cursor:n.length},o.length?{conflicts:o}:{}))):localStorage.removeItem(e(t))}catch{}})},C=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function O(e,t){for(let n=e;n&&1===n.nodeType;n=n.parentElement){const e=getComputedStyle(n).getPropertyValue(t).trim();if(e)return e}return""}function L(e,t,n){const r=O(e,t);return r?"none"===r&&"--edit-size"!==t?n??"":r:n??""}function M(e,t){if(!t&&!/--rich-text-/.test(e))return e;const n=document.createElement("div");n.setAttribute("style",e),t&&n.style.removeProperty("position");const r=[];for(let e=0;e<n.style.length;e++)r.push(n.style.item(e));return r.filter(e=>e.startsWith("--rich-text-")).forEach(e=>n.style.removeProperty(e)),n.getAttribute("style")||""}const j=e=>M(e.getAttribute("style")||"",!!e._editPos),P=e=>e?e.tagName.toLowerCase():"",R=new Set(["B","I","EM","STRONG","U","S","SMALL","CODE","MARK","SUB","SUP","BR","SPAN","A"]),$=e=>!!e&&1===e.nodeType&&e.hasAttribute("data-rich-text")&&!e._editRt,N=e=>window.ManifestRichText.sanitize(e,!1,!0);let B=!1;const H=e=>{const t=document.createTreeWalker(e,NodeFilter.SHOW_COMMENT),n=[];for(let e=t.nextNode();e;e=t.nextNode())n.push(e);return n},q=(e,t)=>!(X(t.name,t.value,e.tagName)||"style"===t.name&&/expression|url\s*\(|javascript:|@import/i.test(t.value));function z(e){const t=Ne.interactive.join(","),n=!!e.closest("a, button");return[...e.querySelectorAll(t)].forEach(r=>{const o=r.parentElement&&r.parentElement.closest(t);(n||o&&e.contains(o))&&r.replaceWith(...r.childNodes)}),e.innerHTML.trim()}const I=(e,t)=>window.ManifestRichText?$(e)?window.ManifestRichText.sanitize(t,!0,!0):function(e,t){const n=document.createElement("template");n.innerHTML=String(null==e?"":e);const r=[],o="mnfst"+Math.random().toString(36).slice(2)+Date.now().toString(36),i=new RegExp("("+o+"\\d+_)");if(H(n.content).forEach(e=>{if(t=e.data,!/^-?>|-->|--!>|<!-$/.test(t))return e.replaceWith(o+r.length+"_"),void r.push(e.data);var t;e.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 e=document.createTreeWalker(n.content,NodeFilter.SHOW_TEXT),t=[];for(let n=e.nextNode();n;n=e.nextNode())n.nodeValue.includes(o)&&t.push(n);t.forEach(e=>e.replaceWith(...e.nodeValue.split(i).filter(Boolean).map(e=>i.test(e)&&e.startsWith(o)?document.createComment(r[parseInt(e.slice(o.length),10)]):document.createTextNode(e))))}!function(e){const t=e=>{let t=e.lastChild;for(;t&&8===t.nodeType;)t=t.previousSibling;return t};for(let n=0;n<1e3;n++){let n=t(e);for(;n&&1===n.nodeType&&"BR"!==n.tagName&&t(n);)n=t(n);if(!n||n===e)return;if(!(3===n.nodeType?!n.nodeValue.trim():"BR"===n.tagName||!t(n)&&!/^(IMG|WBR)$/.test(n.tagName)))return;n.remove()}}(n.content),n.content.querySelectorAll("*").forEach(e=>[...e.attributes].forEach(t=>{q(e,t)||e.removeAttribute(t.name)}));const s=Ne.interactive.join(","),a=!!(t&&t.closest&&t.closest("a, button"));return[...n.content.querySelectorAll(s)].forEach(e=>{(a||e.parentElement&&e.parentElement.closest(s))&&e.replaceWith(...e.childNodes)}),n.content.querySelectorAll("a").forEach(e=>{e.textContent.trim()||e.querySelector("img")||e.replaceWith(...e.childNodes)}),n.innerHTML.trim()}(t,e):function(e){const t=document.createElement("template");t.innerHTML=String(null==e?"":e);const n=e=>[...e.childNodes].forEach(e=>{if(8===e.nodeType)return e.remove();1===e.nodeType&&(R.has(e.tagName)?([...e.attributes].forEach(t=>{const n=t.name.toLowerCase();("A"!==e.tagName||"href"!==n||X("href",t.value,"A"))&&e.removeAttribute(t.name)}),n(e)):e.replaceWith(document.createTextNode(e.textContent)))});return n(t.content),t.innerHTML}(t);function D(e,t){const n=I(e,t);e.innerHTML===n||$(e)&&I(e,e.innerHTML.trim())===n||(e.innerHTML=n,e._rt&&"function"==typeof e._rt.settle&&e._rt.settle())}const W={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" ",tab:"\t",newline:"\n",colon:":"},F=e=>String(e).replace(/&(#x[0-9a-f]+|#\d+|[a-z]+);?/gi,(e,t)=>{if("#"===t[0]){const n=/^#x/i.test(t)?parseInt(t.slice(2),16):parseInt(t.slice(1),10);return n>=0&&n<1114112?String.fromCodePoint(n):e}const n=W[t.toLowerCase()];return void 0===n?e: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(e,t,n){const r=String(e||"").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==t)return null;for(const e of[String(t),F(t)]){const t=e.replace(/[\u0000-\u0020\u007f]/g,"").toLowerCase();if(/(^|[,(;'"=])(javascript|vbscript):/.test(t))return"script URL";const n=t.match(/(^|[,(;'"=])data:[^,)]*/g)||[];if(n.length&&("img"!==o&&"source"!==o||"src"!==r&&"srcset"!==r||!n.every(e=>J.test(e.replace(/^[,(;'"=]/,"")))))return"data URL"}return null}const V=new Set,Y={},G=new Set,Q=e=>{const t=ce(e);for(let n=e&&e.parentElement;n;n=n.parentElement){if(m(n))return!0;if(n===t)break}return!1},Z=f.filter(e=>"x-code-group"!==e&&"x-carousel"!==e&&"x-defer"!==e);function ee(e){for(let t=e&&e.parentElement;t;t=t.parentElement){if(1!==t.nodeType)continue;const e=[...t.attributes].map(e=>e.name.toLowerCase()).find(e=>Z.some(t=>e===t||e.startsWith(t+".")));if(e)return e.split(".")[0]}return null}function te(e,t,s){if(t.includes("cssvar"))return function(e,t,n){const r=(t||"").trim(),o=r.match(/^([\w-]+)\s*:\s*(--[\w-]+)$/);e._cssvar=o?{scope:o[1],var:o[2]}:{scope:null,var:r},e._cssvar.persist=!(!n||!n.includes("persist")),Br.add(e)}(e,s,t);if(t.forEach(e=>{i[e]&&!G.has(e)&&(G.add(e),console.warn(`[edit] x-edit.${e} was removed — use ${i[e]}`))}),t.includes("grab"))return;if(t.includes("lock")){const n=t.filter(e=>o.includes(e));return void(e._editLock=new Set(n.length?n:["*"]))}const l=new Set(n.filter(e=>t.includes(e))),c=t.includes("theme"),d=(s||"").trim()||"area-"+ ++a;if(c&&(Y[d]=e),c&&!l.size)return void(t.includes("persist")&&(e._editPersist=!0));l.size||r.forEach(e=>l.add(e)),(s||"").trim()&&[...V].some(t=>t!==e&&t._edit&&t._edit.key===d)&&console.warn("[edit] duplicate x-edit key (deltas will mis-route):",d);const u=t.includes("bare");e._edit={key:d,caps:l,gated:t.includes("gated"),theme:c,persist:t.includes("persist"),bare:u,rendered:ee(e)},e.setAttribute("data-edit-area",u?"bare":""),V.add(e),oe()}let ne=null;const re=()=>ne||(ne=[...V].filter(e=>{for(let t=e;t;t=t.parentElement){if(t!==e&&t._edit)return!1;if(t._manifestComponent||t!==e&&m(t))return!0}return!0})),oe=()=>{ne=null},ie=e=>re().find(t=>t._edit.key===e),se=e=>re().filter(t=>t._edit.key===e._edit.key).length>1;function ae(e){if(void 0!==e._editSrc)return e._editSrc;let t=null;for(let n=e;n;n=n.parentElement){if(!n._manifestComponent)continue;const r=n===e&&window.ManifestComponentsLoader&&window.ManifestComponentsLoader.cache[n._manifestComponent],o=new RegExp("\\sx-edit(?:\\.[\\w-]+)*\\s*=\\s*([\"'])"+e._edit.key.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"\\1");(n!==e||r&&o.test(r))&&(t=n._manifestComponent);break}return e._editSrc=t}const le=e=>{const t=ae(e);return t?function(e){const t=window.ManifestComponentsRegistry&&window.ManifestComponentsRegistry.manifest||{},n=[...t.preloadedComponents||[],...t.components||[]].find(t=>String(t).split("/").pop().replace(".html","")===e);return String(n||"components/"+e+".html").replace(/^\/+/,"")}(t):"index.html"},ce=e=>e&&re().reduce((t,n)=>n!==e&&!n.contains(e)||t&&!t.contains(n)?t:n,null),de=e=>e._edit.key,ue=(e,t)=>{const n=function(e){for(let t=e;t;t=t.parentElement)if(t._edit)return t._edit;return null}(e);return!!n&&n.caps.has(t)&&!Lt(e,t)},fe=e=>{const t=null!=e&&ie(e);return!(!t||!t._edit.persist)};function me(e){return h(e)?"data":e.matches("[data-component]")&&!ae(e)||pe(e)?"component":"static"}const pe=e=>{const t=ke(e).filter(e=>"TEMPLATE"!==e.tagName),n=t[0];return 1!==t.length||!n.matches("[data-component]")||n._edit||n.querySelector("[data-edit-area]")?null:n};function he(e){const t=h(e),n=t&&t.getAttribute("x-for").match(/\bin\s+(.+)$/);return n?n[1].trim():null}const ge=e=>{const t=he(e),n=t&&t.match(/\$x\.(\w+)/);return n?n[1]:t||"source"},be=e=>e.hasAttribute("data-edit-handle")||e.hasAttribute("data-edit-ghost"),ye=e=>e&&e._manifestHost&&e._manifestHost.roots&&e._manifestHost.roots[0]===e?e._manifestHost.roots.slice():[e],ve=e=>!!e._manifestHost&&!!e._manifestHost.roots&&e._manifestHost.roots[0]!==e,Ee=e=>!!e&&1===e.nodeType&&e.hasAttribute("data-edit-host"),we=e=>e.getAttribute("data-edit-host")||e.getAttribute("data-edit-key"),ke=e=>Array.from(e.children).filter(e=>!be(e)&&!ve(e)),Ae=e=>ke(e).filter(e=>"TEMPLATE"!==e.tagName);let _e=!1;function xe(e,t){const n=e.getAttribute("data-key");if(null!=n)return n;const r=h(t),o=r&&r._x_keyExpression;if(o)try{const t=window.Alpine.evaluate(e,o);if(null!=t)return String(t)}catch{}return _e||(_e=!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 Se=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"]),Te=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"]),Ce=new Set([...Se,"LI","TD","TH"]);function Oe(e){if(!window.ManifestRichText)return!1;const t=e.cloneNode(!0);return t.querySelectorAll("[data-edit-handle], [data-edit-ghost]").forEach(e=>e.remove()),H(t).forEach(e=>e.remove()),!t.children.length||(t.querySelectorAll("*").forEach(e=>[...e.attributes].forEach(t=>{t.name.startsWith("data-edit-")&&e.removeAttribute(t.name)})),N(t.innerHTML)===t.innerHTML&&[...t.querySelectorAll("*")].every(e=>[...e.attributes].every(t=>q(e,t))))}const Le=e=>Ce.has(e.tagName)&&ke(e).length>0&&!!e.textContent.trim()&&Oe(e),Me=e=>{for(let t=e&&e.parentElement;t&&1===t.nodeType;t=t.parentElement){if(t._editRtFormat)return t;if(t._edit)break}return null};function je(e){return!(!e||1!==e.nodeType||Te.has(e.tagName)||be(e)||(e=>Se.has(e.tagName)||e.hasAttribute("data-rich-text")||(e=>[...e.childNodes].some(e=>3===e.nodeType&&e.textContent.trim()))(e)||Le(e))(e))}function Pe(e){const t=[];let n=e.previousSibling;for(;;){let e=null;if(n&&3===n.nodeType){if(!/^[ \t]*(\r?\n)?[ \t]*$/.test(n.textContent))break;e=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;t.unshift(n,...e?[e]:[]),n=n.previousSibling}return t}const Re=e=>e?Pe(e)[0]||e:null;function $e(e,t){const n=Pe(e),r=ye(e).slice(1);t(e),n.length&&e.before(...n),r.length&&e.after(...r)}const Ne={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 Be(e,t){if(!e||!t)return!1;if(e.parentElement===t)return!0;const n=[];for(let e=t;e&&1===e.nodeType;e=e.parentElement)n.push(e.tagName.toLowerCase());const r=new Set,o=e=>[e,...e.querySelectorAll("*")].forEach(e=>{1===e.nodeType&&(r.add(e.tagName.toLowerCase()),"TEMPLATE"===e.tagName&&e.content&&[...e.content.children].forEach(o))});ye(e).forEach(o);const i=new Set;for(let e=t;e;e=e.parentElement)e._manifestComponent&&i.add(e._manifestComponent);return!(i.size&&ye(e).some(e=>[e,...e.querySelectorAll("*")].some(e=>e._manifestComponent&&i.has(e._manifestComponent)))||function(e,t,n,r){const o=Ne;return o.only[t]&&!o.only[t].includes(e)?`<${t}> takes only ${o.only[t].filter(e=>"script"!==e&&"template"!==e&&"style"!==e).join(", ")}`:o.parent[e]&&!o.parent[e].includes(t)?`<${e}> belongs in ${o.parent[e].join(" or ")}`:"dt"!==e&&"dd"!==e||"div"!==t||"dl"===n[1]?r.has("form")&&n.includes("form")?"a form cannot contain a form":(n.includes("a")||n.includes("button"))&&o.interactive.some(e=>r.has(e))?"interactive content cannot go inside a link or button":o.phrasingOnly.includes(t)&&o.block.some(e=>r.has(e))?`<${t}> takes only inline content`:null:`<${e}> belongs in a dl`}(e.tagName.toLowerCase(),t.tagName.toLowerCase(),n,r))}const He=e=>{const t=String(e||"").match(/[a-z%]+$/i);return t?t[0]:null};function qe(e,t,n,r,o){if("rem"===t)return+(e/parseFloat(getComputedStyle(document.documentElement).fontSize)).toFixed(2);if("em"===t)return+(e/parseFloat(getComputedStyle(n).fontSize)).toFixed(2);if("%"===t){const t=(r||n.parentElement).getBoundingClientRect(),i="w"===o?t.width:t.height;return i?+(e/i*100).toFixed(2):0}return Math.round(e)}function ze(e,t,n){const r=parseFloat(e);if(isNaN(r))return null;const o=He(e)||"px";if("rem"===o)return r*parseFloat(getComputedStyle(document.documentElement).fontSize);if("em"===o)return r*parseFloat(getComputedStyle(t).fontSize);if("%"===o){const e=(t.parentElement||t).getBoundingClientRect();return r/100*("h"===n?e.height:e.width)}return r}const Ie=(e,t,n)=>Math.min(Math.max(e,t),n),De="∅revert";let We=0;const Fe=new WeakMap;function Ke(e,t){return l.splice(c),l.push(e),c=l.length,We++,void 0===t&&(t=function(e){return"data-splice"!==e.kind&&"show"!==e.kind&&("st-move"===e.kind?fe(e.from)&&fe(e.to):null!=e.region&&fe(e.region))}(e)),t&&u.add(e),T(),Ko(),e}function Ue(e,t){return"data"===t?{source:ge(e),order:Ae(e).map(t=>xe(t,e))}:{}}async function Je(e,t,n){e&&n&&("data"===t&&Xe(e,n.order),io(e)&&eo(e))}function Xe(e,t){const n=he(e),r=h(e);try{const e=window.Alpine.evaluate(r,n);if(!Array.isArray(e))return;const o=new Map(e.map(e=>[String(e.id),e])),i=t.map(e=>o.get(String(e))).filter(Boolean);e.forEach(e=>{t.map(String).includes(String(e.id))||i.push(e)}),e.splice(0,e.length,...i)}catch{}}function Ve(){const e={},t={},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)e[i.component]=e[i.component]||{},(e[i.component][i.path]=e[i.component][i.path]||{})[i.prop]=i.value;else if("cmp-inst"===i.kind){const e=i.region;i.value===De?(n[e]=n[e]||new Set,"*"===i.path?(delete t[e],n[e]=new Set(["*"])):(t[e]&&delete t[e][i.path],n[e].add(i.path))):(t[e]=t[e]||{},(t[e][i.path]=t[e][i.path]||{})[i.prop]=i.value,n[e]&&(n[e].delete(i.path),n[e].delete("*")))}}return{main:e,inst:t,reverts:n,sigs:r}}const Ye=e=>[e,...e.querySelectorAll("*")].filter(e=>null!=e._editPath);function Ge(){const{main:e,inst:t,sigs:n}=Ve();re().forEach(r=>{if("component"!==me(r))return;const o=vr(r),i=de(r),s=pe(r);s&&Ye(s).forEach(s=>{const a=s._editPath,l=n[o+"|"+a];if(l&&P(s)!==l)return void console.warn("[edit] skip stale node (structure changed):",o,a);const c=t[i]&&t[i][a]||{},d=e[o]&&e[o][a]||{},u=r._baseText||{},f=r._baseClass||{},m=r._baseStyle||{},p=(e,t)=>void 0!==c[e]?c[e]:void 0!==d[e]?d[e]:t,h=p("text",u[a]),g=p("class",f[a]),b=p("style",m[a]);void 0!==h&&D(s,h),void 0!==g&&Cr(s,g),void 0!==b&&s.getAttribute("style")!==b&&(""===b?s.removeAttribute("style"):s.setAttribute("style",b))})})}function Qe(e,t,n,r,o){const i=t._editPath,s=e._editScope||"instance",a=vr(e),l=de(e);if(null==i)return!1;if("text"===n&&(r=I(t,r)),void 0===o&&(o="text"===n?t._preEdit:"style"===n?t._preStyle:t._preClass),o===r||"text"===n&&null!=o&&I(t,o)===r)return!1;const c=P(t);return Ke("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}),Ge(),!0}function Ze(){const e={},t={},n={},r={},o={},i={},s=(e,t,n,r,o)=>{if(!r)return;const i=e[t]=e[t]||{},s=n||"";o&&s in i||(i[s]=r.slice())};for(let e=0;e<l.length;e++){const t=l[e];if("st-children"===t.kind)t.html&&Object.assign(i,t.html),s(n,t.region,t.parent,t.before,!0);else if("st-order"===t.kind)s(n,t.region,t.parent,t.before,!0);else if("st-move"===t.kind)s(n,t.from,t.fromParent,t.fromBefore,!0),s(n,t.to,t.toParent,t.toBefore,!0);else if("st-node"===t.kind){const e=o[t.path]=o[t.path]||{};t.prop in e||(e[t.prop]=t.before),t.sig&&(r[t.path]=t.sig)}}const a=new Set;for(let n=0;n<c;n++){const r=l[n];"st-node"===r.kind?(e[r.path]=e[r.path]||{})[r.prop]=r.value:"st-order"===r.kind||"st-children"===r.kind?(s(t,r.region,r.parent,r.order),a.add(r.parent||"#"+r.region),r.copies&&Object.entries(r.copies).forEach(([t,n])=>{e[t]=Object.assign({},n,e[t])})):"st-move"===r.kind&&(s(t,r.from,r.fromParent,r.fromOrder),s(t,r.to,r.toParent,r.toOrder),a.add(r.fromParent||"#"+r.from),a.add(r.toParent||"#"+r.to))}return{node:e,order:t,orderBase:n,sigs:r,base:o,html:i,touched:a}}function et(e,t,n,r){Ke({kind:"data-splice",region:de(e),source:ge(e),index:t,op:r,record:JSON.parse(JSON.stringify(n))}),setTimeout(()=>{d[de(e)]=Ue(e,me(e))},0)}const tt=(e,t)=>e===t?"":e.getAttribute("data-edit-key")||"";function nt(e,t,n,r,o){const i=A(t);if(C(n,i)&&!Object.keys(r||{}).length)return;const s={kind:"st-children",region:de(e),parent:tt(t,e),order:i,before:n,html:r||{}};o&&Object.keys(o).length&&(s.copies=o),ct(s,[...n,...i.filter(e=>"~"===e[0]).map(v)]),Ke(s)}function rt(e,t){l.forEach(n=>{t&&!t(n)||(["before","order","fromBefore","toBefore","fromOrder","toOrder","unsure"].forEach(t=>{var r;n[t]&&(n[t]=(r=n[t],Array.isArray(r)?r.map(e):r))}),["parent","fromParent","toParent","key","path"].forEach(t=>{"string"==typeof n[t]&&(n[t]=e(n[t]))}),n.html&&(n.html=Object.fromEntries(Object.entries(n.html).map(([t,n])=>[e(t),"string"==typeof n?n.replace(/data-edit-key="([^"]*)"/g,(t,n)=>`data-edit-key="${(e=>e.replace(/&/g,"&").replace(/"/g,"""))(e((e=>e.replace(/"/g,'"').replace(/&/g,"&"))(n)))}"`):n]))),n.copies&&(n.copies=Object.fromEntries(Object.entries(n.copies).map(([t,n])=>[e(t),n]))))})}const ot=e=>String(e).replace(/#\d+$/,""),it=e=>{const t=/#(\d+)$/.exec(e);return t?+t[1]:1},st=(e,t)=>it(e)-it(t);function at(e,t,n){const r=e[n];if(null==r||null==t[n]||t[n]===r||e.some((e,t)=>t!==n&&e===r))return null;if(t.length===e.length)return t.map((e,t)=>t).filter(o=>o!==n&&t[o]===r&&t[o]!==e[o]);const o=[];for(let r=-n;r<t.length-n;r++){if(!r)continue;let i=!0;for(let o=n;o<e.length&&i;o++)i=o+r>=0&&o+r<t.length&&t[o+r]===e[o];i&&o.push(n+r)}return o}const lt=e=>"string"==typeof e&&"@"===e[0]&&(/#\d+$/.test(e)||mt(ut()).has(e+"#2"));function ct(e,t){const n={},r=new Set;return t.forEach(e=>{if(!lt(e)||n[e])return;const t=v(e),o=ie(decodeURIComponent(t.slice(1,t.indexOf("@",1)))),i=o&&le(o),s=ho&&i&&ho[i];bo.has(ot(t))?r.add(t):s&&Object.keys(s).forEach(e=>{ot(e)===ot(t)&&(n[e]=s[e])})}),Object.keys(n).length&&(e.ids=n),r.size&&(e.unsure=[...r]),e}const dt=(e,t)=>{if(!e)return null;const n=document.createElement("template");n.innerHTML=e.trim();const r=n.content.firstElementChild;return r&&t&&r.setAttribute(/^[^@]*@[^@]*@X-[\w-]+:/.test(v(t))?"data-edit-host":"data-edit-key",t),r},ut=()=>re().filter(e=>"static"===me(e)&&!se(e)),ft=new Map;function mt(e){const t=new Map;return e.forEach(e=>[e,...e.querySelectorAll("[data-edit-key]")].forEach(e=>{if(e.closest("[data-edit-ghost]"))return;const n=e.getAttribute("data-edit-key");null==n||t.has(n)||t.set(n,e)})),e.forEach(e=>e.querySelectorAll("[data-edit-host]").forEach(e=>{const n=e.getAttribute("data-edit-host");t.has(n)||t.set(n,e)})),t}function pt(e){const t=mt(ut()),n=[],r=new Set(e.filter(e=>e._marked).map(de)),o=e=>r.has(e)&&!!ie(e)&&"static"===me(ie(e)),i=new Map,s=new Map,a=new Map,d=[],u={},f=e=>"string"==typeof e&&/^[0-9a-f]{12}$/.test(e);l.forEach(e=>{e.ids&&Object.entries(e.ids).forEach(([e,t])=>{!(e in u)&&f(t)&&(u[e]=t)})});const m=ot,p=(e,t=u[e])=>{if(!f(t))return null;const n=Object.keys(u).filter(t=>m(t)===m(e)).sort(st),r=n.indexOf(e);if(r<0)return null;const o=ie(g(e)),i=ho&&o&&ho[le(o)],s=Object.keys(i||{}).filter(t=>m(t)===m(e)).sort(st),a=at(n.map(n=>n===e?t:u[n]),s.map(b),r);return a&&a.map(e=>s[e])},h=new Set;l.forEach(e=>(e.unsure||[]).forEach(e=>h.add(e)));const g=e=>decodeURIComponent(e.slice(1,e.indexOf("@",1))),b=e=>"string"==typeof e&&"@"===e[0]&&r.has(g(e))&&t.has(e)?yo(e):null,y=(e,t,n)=>{const r=JSON.stringify([e,t]);!i.has(r)&&o(e)&&i.set(r,[e,t,n||[]])};l.forEach(e=>{"st-order"!==e.kind&&"st-children"!==e.kind||y(e.region,e.parent,e.before),"st-move"===e.kind&&(y(e.from,e.fromParent,e.fromBefore),y(e.to,e.toParent,e.toBefore))});const E=e=>String(e).slice(String(e).indexOf("@",1)+1).split(":")[0],w=(e,t)=>{const n=new Set,r=(e,t)=>{t=t||[],(e=e||[]).forEach(e=>{t.includes(e)||n.add(e)}),t.forEach(t=>{e.includes(t)||n.add(t)});const r=t.filter(t=>e.includes(t)).map(t=>e.indexOf(t)),o=[],i=new Array(r.length).fill(-1);r.forEach((e,t)=>{let n=0,s=o.length;for(;n<s;){const t=n+s>>1;r[o[t]]<e?n=t+1:s=t}n>0&&(i[t]=o[n-1]),o[n]=t});const s=new Set;for(let e=o.length?o[o.length-1]:-1;e>=0;e=i[e])s.add(e);t.filter(t=>e.includes(t)).forEach((e,t)=>{s.has(t)||n.add(e)})};return l.forEach(o=>{"st-order"!==o.kind&&"st-children"!==o.kind||o.region!==e||(o.parent||"")!==t||r(o.before,o.order),"st-move"===o.kind&&(o.from===e&&(o.fromParent||"")===t&&(n.add(o.key),r(o.fromBefore,o.fromOrder)),o.to===e&&(o.toParent||"")===t&&(n.add(o.key),r(o.toBefore,o.toOrder)))}),n};i.forEach(([e,n,r])=>{let o=""===n?ie(e):t.get(n),i=null;if(!o&&""!==n){const e=new Set(r.map(e=>t.get(e)).filter(Boolean).map(e=>e.parentElement));1===e.size&&(o=[...e][0],i=o.getAttribute("data-edit-key"))}const c=o?A(o):[],f=[...w(e,n)].filter(e=>"string"==typeof e&&"@"===e[0]),g=f.filter(e=>h.has(e)),b=f.filter(e=>{const t=p(e);return t&&t.length});if(g.length||b.length){const t=Object.keys(u).filter(e=>m(e)&&r.includes(e)&&(p(e)||[]).length);let o=g.length||i||c.join("\n")!==r.join("\n")||!((e,t)=>l.every(n=>{if("st-move"===n.kind)return!(n.from===e&&(n.fromParent||"")===t||n.to===e&&(n.toParent||"")===t);if("st-order"!==n.kind&&"st-children"!==n.kind||n.region!==e||(n.parent||"")!==t)return!0;if("st-order"===n.kind||n.order.some(e=>"@"!==e[0]))return!1;let r=0;for(const e of n.before)e===n.order[r]&&r++;return r===n.order.length}))(e,n)?null:new Map;if(o)for(const e of t){const n=p(e).filter(e=>t.includes(e));if(1!==n.length){o=null;break}o.set(e,n[0])}return o&&new Set(o.values()).size===t.length?void d.push([e,n,c,o]):void s.set(e,[...s.get(e)||[],{container:n,changed:[...new Set([...b,...g])].map(e=>{const t=e.slice(e.indexOf("@",1)+1);return{was:t,now:t}})}])}if(o&&c.join("\n")===r.join("\n")&&!i)return;const y=[];r.forEach((e,t)=>{c[t]!==e&&y.push({was:e,now:c[t]??null})}),c.slice(r.length).forEach(e=>y.push({was:null,now:e}));const k=w(e,n),_=!!o&&c.length===r.length&&r.every((e,t)=>E(e)===E(c[t])),x=new Set;l.forEach(e=>[e.before,e.order,e.fromBefore,e.toBefore,e.fromOrder,e.toOrder].forEach(e=>Array.isArray(e)&&e.forEach(e=>x.add(e))));const S=e=>{const t=e.cloneNode(!1);return[...t.attributes].forEach(e=>{/^(data-edit-|data-rich-text|contenteditable$|role$|aria-multiline$|tabindex$)/.test(e.name)&&t.removeAttribute(e.name)}),t.outerHTML.replace(/<\/[^>]+>$/,"")},T=e=>!!e.was&&!!e.now&&"@"===e.was[0]&&!t.has(e.was)&&!x.has(e.now)&&(()=>{const n=(e=>{for(const t of l)if("st-children"===t.kind&&t.html)for(const[n,r]of Object.entries(t.html))if("~"===n[0]&&v(n)===e){const e=document.createElement("template");e.innerHTML=r;const t=e.content.firstElementChild;if(t)return S(t)}return null})(e.was),r=t.get(e.now);return!n||!r||n===S(r)})();if(_&&y.every(e=>T(e)&&!k.has(e.was))){const t=a.get(e)||new Map;y.forEach(e=>t.set(e.was,e.now)),i&&i!==n&&t.set(n,i),a.set(e,t)}else s.set(e,[...s.get(e)||[],{container:n,changed:y.map(e=>({was:e.was&&E(e.was)&&e.was.slice(e.was.indexOf("@",1)+1),now:e.now&&e.now.slice(e.now.indexOf("@",1)+1)}))}])});const k=new Map;l.forEach(e=>{const t="st-move"===e.kind?e.to:e.region;[e.order,e.toOrder,e.fromOrder,e.before,Object.keys(e.html||{})].forEach(e=>Array.isArray(e)&&e.forEach(e=>{if("string"!=typeof e||"~"!==e[0])return;const n=v(e);k.has(n)||k.set(n,new Set),k.get(n).add(t)}))});const S=new Map;k.forEach((e,n)=>{if(!r.has(g(n)))return;const i=h.has(n)?null:p(n);if(i&&!i.length)return;if(i&&1===i.length&&t.has(i[0]))return void S.set(n,i[0]);if(!i&&!h.has(n))return;const a=n.slice(n.indexOf("@",1)+1);e.forEach(e=>{o(e)&&s.set(e,[...s.get(e)||[],{container:"",changed:[{was:a,now:a}],copy:!0}])})}),S.size&&(rt(e=>"string"==typeof e&&"~"===e[0]&&S.has(v(e))?e.slice(0,e.length-v(e).length)+S.get(v(e)):e,e=>!s.has("st-move"===e.kind?e.to:e.region)),We++),d.forEach(([e,t,n,r])=>{if(s.has(e))return;const o=e=>"string"==typeof e&&r.has(e)?r.get(e):e;let i=n.slice();l.forEach(n=>{if("st-children"===n.kind&&n.region===e&&(n.parent||"")===t){const e=n.before.filter(e=>!n.order.includes(e)).map(o);n.before=i.slice(),i=i.filter(t=>!e.includes(t)),n.order=i.slice(),n.html&&(n.html=Object.fromEntries(Object.entries(n.html).map(([e,t])=>[o(e),"string"==typeof t?t.replace(/data-edit-key="([^"]*)"/g,(e,t)=>`data-edit-key="${(e=>e.replace(/&/g,"&").replace(/"/g,"""))(o((e=>e.replace(/"/g,'"').replace(/&/g,"&"))(t)))}"`):t])))}n.ids&&n.region===e&&(n.ids=Object.fromEntries(Object.entries(n.ids).map(([e,t])=>[o(e),t]))),"st-node"===n.kind&&n.region===e&&"string"==typeof n.path&&(n.path=o(n.path)),"lock"===n.kind&&n.region===e&&(n.key=o(n.key))}),We++}),a.forEach((e,n)=>{if(s.has(n))return;const r=t=>"string"!=typeof t?t:e.has(t)?e.get(t):"~"===t[0]&&e.has(v(t))?t.slice(0,t.length-v(t).length)+e.get(v(t)):t,o=e=>Array.isArray(e)?e.map(r):e,i=e=>"string"==typeof e?e.replace(/data-edit-key="([^"]*)"/g,(e,t)=>`data-edit-key="${(e=>e.replace(/&/g,"&").replace(/"/g,"""))(r((e=>e.replace(/"/g,'"').replace(/&/g,"&"))(t)))}"`):e,a=(n,r)=>{if("~"!==n[0]||!e.has(v(n))||(e=>l.some(t=>"st-node"===t.kind&&t.path===e&&"text"===t.prop))(n))return i(r);const o=t.get(e.get(v(n)));if(!o)return i(r);const s=document.createElement("template");s.innerHTML=Xt(o,!0);const a=n.slice(0,n.length-v(n).length);return[s.content.firstElementChild,...s.content.firstElementChild.querySelectorAll("[data-edit-key]")].forEach(e=>{const t=e.getAttribute("data-edit-key");t&&"@"===t[0]&&e.setAttribute("data-edit-key",a+t)}),s.innerHTML};l.forEach(e=>{var t;"st-order"!==e.kind&&"st-children"!==e.kind||e.region!==n||(e.parent=r(e.parent),e.before=o(e.before),e.order=o(e.order),e.html&&(e.html=(t=e.html)&&"object"==typeof t?Object.fromEntries(Object.entries(t).map(([e,t])=>[r(e),a(e,t)])):t),e.copies&&(e.copies=Object.fromEntries(Object.entries(e.copies).map(([e,t])=>[r(e),t])))),"st-node"===e.kind&&e.region===n&&"string"==typeof e.path&&"~"===e.path[0]&&(e.path=r(e.path)),"st-move"!==e.kind||e.from!==n&&e.to!==n||(e.key=r(e.key),e.fromParent=r(e.fromParent),e.toParent=r(e.toParent),e.fromBefore=o(e.fromBefore),e.toBefore=o(e.toBefore),e.fromOrder=o(e.fromOrder),e.toOrder=o(e.toOrder)),"lock"===e.kind&&e.region===n&&(e.key=r(e.key))}),We++});const C=e=>("st-order"===e.kind||"st-children"===e.kind)&&s.has(e.region)||"st-move"===e.kind&&(s.has(e.from)||s.has(e.to))||"st-node"===e.kind&&s.has(e.region)&&"string"==typeof e.path&&"~"===e.path[0],O=e=>"st-node"===e.kind&&"string"==typeof e.path&&"@"===e.path[0]&&o(e.region)&&(!t.has(e.path)||(e=>(e.unsure||[]).includes(e.path)||(p(e.path,e.id)||[]).length>0)(e))||C(e);l.forEach((e,t)=>{O(e)&&t<c&&"st-node"===e.kind&&"@"===e.path[0]&&n.push(e)});const L=()=>l.forEach(e=>{e.ids&&Object.keys(e.ids).forEach(t=>{const n=b(t);n&&(e.ids[t]=n)})});if(!l.some(O))return L(),(a.size||d.length||S.size||l.some(e=>e.ids))&&T(),[];const M=new Map;n.forEach(e=>M.set(e.path+"|"+e.prop,e));const j=e=>"string"==typeof e?v(e).slice(v(e).indexOf("@",1)+1):"",P=[...M.values()].map(e=>({region:e.region,key:e.path,element:j(e.path),prop:e.prop,value:e.value,before:e.before,reason:`${j(e.path)} changed in the source, so the ${"text"===e.prop?"text":e.prop} edited into it was not applied`}));s.forEach((e,t)=>{const n=l.filter((e,n)=>n<c&&C(e)&&(e.region===t||e.from===t||e.to===t)),r=new Set,o=new Set,i=[];n.forEach(e=>{"st-move"===e.kind&&r.add(e.key),"st-order"!==e.kind&&"st-children"!==e.kind||w(t,e.parent||"").forEach(e=>r.add(e)),"st-children"===e.kind&&e.before.forEach(t=>{"@"!==t[0]||e.order.includes(t)||o.add(t)}),"st-children"===e.kind&&e.html&&Object.entries(e.html).forEach(([e,t])=>{if("~"!==e[0])return;const n=document.createElement("template");n.innerHTML=t;const r=l.filter((t,n)=>n<c&&"st-node"===t.kind&&t.path===e&&"text"===t.prop).pop();i.push({of:j(e),html:t,text:r?r.value:n.content.textContent.trim()})})});const s=e.flatMap(e=>e.changed),a=e=>String(e).replace(/^([A-Za-z][\w-]*):(#\d+)?$/,(e,t,n)=>`<${t.toLowerCase()}>${n?" "+n:""}`),d=[...new Set(s.map(e=>a(e.was||e.now)))],u=[...new Set([...r].filter(e=>e&&"@"===e[0]&&!o.has(e)).map(e=>a(j(e))))],f=[...new Set([...o].map(e=>a(j(e))))],m=[f.length&&`deleted ${f.join(", ")}`,u.length&&`moved ${u.join(", ")}`,i.length&&`copied ${i.map(e=>`${a(e.of)} ("${String(e.text).slice(0,40)}")`).join(", ")}`].filter(Boolean).join("; ");P.push({region:t,key:"",element:e.map(e=>e.container?j(e.container):t).join(", "),prop:"structure",value:{changed:s,moved:u,copies:i},before:null,reason:e.some(e=>e.copy)&&s.every(e=>e.was===e.now)?`the copied element ${d.join(", ")} has identical twins that were reordered or replaced in the source, so the layout edits (${m||"reordering"}) were not applied`:s.every(e=>e.was===e.now)?`identical elements ${d.join(", ")} were reordered or replaced in the source where the layout was edited, so the layout edits (${m||"reordering"}) were not applied`:`${d.join(", ")} changed in the source where the layout was edited, so the layout edits (${m||"reordering"}) were not applied`})}),P.forEach(e=>{_.push(e),fe(e.region)&&x.add(e)});let R=0;return l=l.filter((e,t)=>{const n=!O(e);return n&&t<c&&R++,n}),c=R,We++,L(),T(),Ko(),P.length&&(no&&(no.conflicts=_.slice()),console.warn("[edit] edits to elements that changed in the source were dropped:\n"+P.map(e=>" "+e.reason+("structure"===e.prop?"":`: "${String(e.value).slice(0,80)}"`)).join("\n")),document.dispatchEvent(new CustomEvent("edit:conflict",{detail:{conflicts:P}}))),P}function ht(){const{node:e,order:t,orderBase:n,sigs:r,base:o,html:i}=Ze(),s=mt(ut()),a=[];new Set([...Object.keys(n),...Object.keys(t)]).forEach(e=>{const r=Object.assign({},n[e]||{},t[e]||{});Object.entries(r).forEach(([t,n])=>a.push([e,t,n]))});const l=new Set;a.forEach(([,,e])=>e.forEach(e=>l.add(e)));const c=new Set,d=e=>{let t=s.get(e);return!t&&ft.has(e)&&(t=ft.get(e),ft.delete(e),s.set(e,t)),!t&&i[e]&&(t=dt(i[e],e),t&&(s.set(e,t),t.querySelectorAll("[data-edit-key]").forEach(e=>{const t=e.getAttribute("data-edit-key");s.has(t)||s.set(t,e)}))),t};let u=!0;for(;a.length&&u;){u=!1;for(let e=0;e<a.length;e++){const[t,n,r]=a[e],o=n?s.get(n):ie(t);if(!o||!o.isConnected)continue;a.splice(e--,1),u=!0;let f=Ae(o);const m=r.map(d).filter(e=>e&&e!==o&&!e.contains(o)),p=f.filter(e=>!m.includes(e)&&!l.has(we(e))&&!i[we(e)]),h=[...m,...p].flatMap(ye);if(f=f.flatMap(ye),h.length===f.length&&h.every((e,t)=>e===f[t]))continue;const g=f.length?f[f.length-1].nextSibling:Array.from(o.children).find(be)||null,b=new Map(h.map(e=>[e,e.isConnected?Pe(e):e._editLead||[]]));f.forEach(e=>{if(h.includes(e))return;e._editLead=Pe(e),e._editLead.forEach(e=>e.remove()),e.remove();const t=we(e);t&&ft.set(t,e)}),h.forEach(e=>{const t=ce(e);t&&c.add(t),o.insertBefore(e,g&&g.parentNode===o?g:null);const n=b.get(e);n.length&&e.before(...n)});const y=ce(o);y&&c.add(y)}}c.size&&oe(),(c.size?mt(ut()):s).forEach((t,n)=>{const i=e[n],s=o[n];if(!i&&!s)return;const a=r[n];a&&P(t)!==a?console.warn("[edit] skip stale static node",n):new Set([...Object.keys(i||{}),...Object.keys(s||{})]).forEach(e=>function(e,t,n){if(void 0!==n){if("text"===t)return D(e,n);if(!X(t,n,e.tagName))return"class"===t?Cr(e,n):"style"===t?function(e,t){null==t||""===t?e.removeAttribute("style"):e.getAttribute("style")!==t&&e.setAttribute("style",t),e._editPos&&!e.style.position&&(e.style.position="relative")}(e,n):void(null!==n?e.getAttribute(t)!==n&&e.setAttribute(t,n):e.removeAttribute(t))}}(t,e,i&&void 0!==i[e]?i[e]:s&&s[e]))}),c.forEach(e=>{e.isConnected&&(Yr(e),e._armed&&io(e)&&eo(e))})}function gt(e,t,n,r,o={}){const i=de(e),s=t.getAttribute("data-edit-key");if(!s||"!"===s[0])return!1;if("text"===n&&p.has(t.tagName))return!1;"text"===n&&(r=I(t,r));let a=o.before;if(void 0===a){const r="text"===n?e._baseText&&e._baseText[s]:"class"===n?e._baseClass&&e._baseClass[s]:"style"===n?e._baseStyle&&e._baseStyle[s]:t.getAttribute(n),o="text"===n?t._preEdit:"class"===n?t._preClass:"style"===n?t._preStyle:void 0;a=void 0!==o?o:r}if(a===r||"text"===n&&null!=a&&I(t,a)===r)return!1;"text"!==n||document.activeElement===t||$(t)||D(t,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()-(Fe.get(d)||0)<1e3)return d.before===r?(l.pop(),c--):(d.value=r,Fe.set(d,Date.now())),We++,T(),Ko(),!0;const u=Ke(Object.assign({kind:"st-node",region:i,path:s,prop:n,value:r,before:a,sig:P(t)},lt(s)?(()=>{const e=ct({},[s]);return e.ids&&e.ids[s]&&(e.id=e.ids[s]),e})():{},o.join?{join:!0}:{}));return o.coalesce&&Fe.set(u,Date.now()),!0}function bt(){const e={};for(let t=0;t<c;t++){const n=l[t];"data-val"===n.kind&&(((e[n.source]=e[n.source]||{})[n.id]=e[n.source][n.id]||{})[n.field]=n.value)}return e}function yt(){const e=bt(),t=new Map;l.forEach(e=>{if("data-val"===e.kind){const n=JSON.stringify([e.source,e.id,e.field]);t.has(n)||t.set(n,e)}}),t.forEach(t=>{const n=(e[t.source]=e[t.source]||{})[t.id]=e[t.source][t.id]||{};t.field in n||void 0===t.before||(n[t.field]=t.before)}),re().forEach(t=>{if("data"!==me(t))return;const n=ge(t),r=e[n];if(!r)return;const o=h(t),i=he(t);try{const e=window.Alpine.evaluate(o,i);Array.isArray(e)&&Object.entries(r).forEach(([t,n])=>{const r=e.find(e=>String(e.id)===String(t));r&&Object.entries(n).forEach(([e,t])=>{r[e]!==t&&(r[e]=t)})})}catch{}io(t)&&setTimeout(()=>yr(t),0)})}function vt(e,t,n){const r=j(t),o=me(e);return"component"===o?Qe(e,t,"style",r):"static"===o&>(e,t,"style",r,n)}function Et(e,t,n){const r=A(t);return!C(n,r)&&(Ke(ct({kind:"st-order",region:de(e),parent:tt(t,e),order:r,before:n},n)),!0)}function wt(e,t,n,r,o,i,s={}){const a=n.parentElement,l={kind:"st-move",from:de(e),to:de(t),fromParent:tt(r,e),toParent:tt(a,t),key:we(n),fromOrder:A(r),toOrder:A(a),fromBefore:o,toBefore:i};return s.join&&(l.join=!0),ct(l,[v(l.key),...o,...i]),Ke(l),oe(),Yr(t),io(e)&&eo(e),t!==e&&io(t)&&eo(t),l}const kt=(e,t)=>/^[~@]/.test(t)?t:e+"|"+t;let At=-1,_t=new Map;function xt(){if(At===We)return _t;_t=new Map;for(let e=0;e<c;e++){const t=l[e];if("lock"!==t.kind)continue;const n=kt(t.region,t.key),r=_t.get(n)||new Map;_t.set(n,r),(t.actions&&t.actions.length?t.actions:o).forEach(e=>r.set(e,t.value))}return At=We,_t}const St=()=>xt();function Tt(e,t){const n=me(t);if("static"===n)return e.getAttribute("data-edit-key");if(e===t)return"";if("component"===n)return null!=e._editPath?"path:"+e._editPath:null;const r=h(t);if(r&&e.parentElement===r.parentElement){const n=xe(e,t);return null==n?null:"row:"+n}return null}const Ct=e=>"data"===e?"text":"class"===e?"attrs":e,Ot=e=>Ee(e)?e:ve(e)?e._manifestHost.roots[0]:null;function Lt(e,t){const n=Ct(t),r=e&&1===e.nodeType&&Ot(e);r&&(e=r);let o=r?Ft(r):ce(e);const i=xt();for(let t=e;t&&1===t.nodeType;t=t.parentElement){let e;const s=Ot(t);if(s&&i.size){const t=i.get(s.getAttribute("data-edit-host"));t&&t.has(n)&&(e=t.get(n))}if(void 0===e&&o&&i.size&&(!s||t!==r)){const r=Tt(t,o),s=null!=r&&i.get(kt(de(o),r));s&&s.has(n)&&(e=s.get(n))}if(void 0===e&&t._editLock&&(e=t._editLock.has("*")||t._editLock.has(n)),e)return!0;if(t===o){if(s&&t!==r&&(o=Ft(t),o))continue;break}}return!1}function Mt(e,t,n){if(!e||1!==e.nodeType)return!1;const r=Ot(e),i=r?Ft(r):ce(e);if(!i)return!1;if(null!=t&&!o.includes(t))return console.warn("[edit] unknown lock action:",t),!1;if(r)return Ke({kind:"lock",region:de(i),key:r.getAttribute("data-edit-host"),actions:t?[t]:[],value:!!n}),jt(i),r._edit&&jt(r),!0;const s=Tt(e,i);return null==s?(console.warn("[edit] this element has no stable identity to lock"),!1):(Ke({kind:"lock",region:de(i),key:s,actions:t?[t]:[],value:!!n}),jt(i),!0)}function jt(e){e&&e._armed&&(to(e),io(e)&&eo(e))}const Pt=e=>{"cmp-main"===e.kind||"cmp-inst"===e.kind?Ge():"data-val"===e.kind?yt():"theme"===e.kind?Jr():"lock"===e.kind?jt(ie(e.region)):ht()};function Rt(e,t){if("show"===e.kind)return function(e,t){const n=ie(e.region);if(!n)return;const r=""===e.key?n:[n,...n.querySelectorAll("[x-show]")].find(t=>Tt(t,n)===e.key);if(r)try{nr(r,e.expr,t?e.before:e.value)}catch{}}(e,t),null;if("data-splice"===e.kind)!function(e,t){const n=ie(e.region);if(!n)return;const r=h(n),o=he(n);if(!r||!o)return;let i;try{i=window.Alpine.evaluate(r,o)}catch{return}Array.isArray(i)&&((t?"remove"===e.op:"insert"===e.op)?i.splice(Math.min(e.index,i.length),0,JSON.parse(JSON.stringify(e.record))):i.splice(e.index,1),setTimeout(()=>{d[e.region]=Ue(n,me(n))},0))}(e,t);else{if("data"===e.kind){const n=t?e.before:e.after;return d[e.region]=n,Je(ie(e.region),e.kind,n)}Pt(e)}return null}async function $t(){if(0===c)return;let e;do{e=l[--c],We++;const t=Rt(e,!0);t&&await t}while(e.join&&c>0);Xo(),T(),Ko()}async function Nt(){if(!(c>=l.length)){do{const e=l[c++];We++;const t=Rt(e,!1);t&&await t}while(c<l.length&&l[c].join);Xo(),T(),Ko()}}function Bt(){const e={};for(let t=0;t<c;t++){const n=l[t];"data"===n.kind&&(e[n.region]={kind:n.kind,snap:n.after})}return e}let Ht=null,qt=null;const zt=()=>{no&&(no.version=(no.version||0)+1)},It=e=>{qt=e,zt()};function Dt(e){e&&1!==e.nodeType&&(e=e.parentElement);const t=ce(e);if(Ee(e)&&Ft(e)&&"static"===me(Ft(e)))return e;if(!t||e===t)return null;const n=me(t);if("data"===n){const n=h(t),r=n&&n.parentElement;for(let n=e;n&&n!==t;n=n.parentElement)if(n.parentElement===r)return n;return null}if("component"===n){for(let n=e;n&&n!==t;n=n.parentElement)if(null!=n._editPath)return n;return null}let r=null;for(let n=e;n&&n!==t;n=n.parentElement)(Ee(n)||ve(n))&&(r=Ee(n)?n:n._manifestHost.roots[0]);if(r)return r;for(let n=e;n&&n!==t;n=n.parentElement){if(be(n))return null;if(je(n.parentElement))return n}return null}const Wt=e=>(e=>!!e&&1===e.nodeType&&Dt(e)===e)(e)?e:Dt(e),Ft=e=>e&&ce(e.parentElement),Kt=e=>!!e&&(!!e._edit||e.hasAttribute("data-edit-area")),Ut=e=>!!e&&!!e.parentElement&&!be(e)&&!Q(e)&&ue(e.parentElement,"move")&&!Lt(e,"move")&&"component"!==me(ce(e.parentElement));function Jt(e){if(!e||1!==e.nodeType)return!1;const t=ce(e);if(!t||!io(t)||!je(e))return!1;for(let n=e;n&&n!==t;n=n.parentElement)if(n._manifestComponent)return!1;return ue(e,"move")}function Xt(e,t){const n=e.cloneNode(!0),r=[e,...e.querySelectorAll("*")],o=[n,...n.querySelectorAll("*")];o.forEach((e,t)=>{mn.has(r[t])&&e.removeAttribute("tabindex")});const i=o.filter((e,t)=>t>0&&k(r[t]));return pr(e,n),i.forEach(e=>e.remove()),n.querySelectorAll("[data-edit-handle], [data-edit-live], [data-edit-ghost]").forEach(e=>e.remove()),[n,...n.querySelectorAll("*")].forEach(e=>{[...e.attributes].forEach(n=>{!n.name.startsWith("data-edit-")||t&&"data-edit-key"===n.name||e.removeAttribute(n.name)}),e.removeAttribute("contenteditable"),e.removeAttribute("draggable")}),n.outerHTML}function Vt(e){const t=h(e),n=he(e);if(!t||!n)return null;try{const e=window.Alpine.evaluate(t,n);return Array.isArray(e)?e:null}catch{return null}}const Yt=(e,t)=>{const n=Vt(e);if(!n)return-1;const r=xe(t,e);return n.findIndex(e=>String(e&&null!=e.id?e.id:e)===String(r))};function Gt(e,t){const n=new Set(e.map(e=>String(e&&e.id)));if(!n.has(String(t)))return String(t);let r=2,o=`${t}-copy`;for(;n.has(o);)o=`${t}-copy-${r++}`;return o}const Qt=["move","remove","duplicate","text","attrs","class","size","copy","cut","paste"],Zt=e=>!(!e||!Ht||"static"===me(e)&&"static"!==Ht.kind);function en(e){const t=e?Wt(e):null;return t?Jt(t.parentElement)?t.parentElement:null:re().find(e=>io(e)&&Jt(e))||null}function tn(e,t){if(!Qt.includes(e))return!1;if("paste"===e){const e=Ht&&en(t);return!!e&&Zt(ce(e))}if(!t||1!==t.nodeType||Q(t))return!1;if(Ee(t)&&("move"===e||"duplicate"===e||"remove"===e)){const n=Ft(t);return!(!n||!io(n))&&("move"===e?Ut(t):ue(t.parentElement,"move")&&!Lt(t,e))}const n=ce(t);if(!n||!io(n))return!1;const r=me(n);if("size"===e)return!!t._edit&&t._edit.caps.has("size")&&!Lt(t,"size");if("text"===e)return ue(t,"text")&&!t.hasAttribute("x-text")&&!t.hasAttribute("x-html")&&("true"===t.getAttribute("contenteditable")||!!t._pieceMode||t.hasAttribute("data-rich-text")||null!=t._editField&&ue(t,"data"));if(("attrs"===e||"class"===e)&&"static"===r&&t._manifestComponent)return!1;if("attrs"===e||"class"===e){if("data"===r||Lt(t,"attrs"))return!1;const n=Me(t);if(n)return"attrs"===e&&ue(n,"text");if("component"===r)return"class"===e&&null!=t._editPath;const o=t.getAttribute("data-edit-key");return!!o&&"!"!==o[0]}if("component"===r)return!1;const o=Wt(t);if(!o)return!1;if("copy"===e)return!Ee(o);if("cut"===e)return tn("copy",o)&&tn("remove",o);if("move"===e)return Ut(o);const i="duplicate"===e?"duplicate":"remove";return ue(o.parentElement,"move")&&!Lt(o,i)}function nn(e){const t=Wt(void 0===e?qt:e);if(!t)return!1;const n=Ft(t);return!!n&&(Ht={html:Xt(t,!0),ops:rn(t),source:de(n),kind:me(n)},zt(),!0)}function rn(e){const t=Ze(),n={};return[e,...e.querySelectorAll("[data-edit-key]")].forEach(e=>{const r=e.getAttribute("data-edit-key");r&&t.node[r]&&(n[r]=Object.assign({},t.node[r]))}),n}function on(e,t,n,r,o){const i=A(t),s=function(e,t){const n=w(),r={};return[e,...e.querySelectorAll("[data-edit-key]")].forEach(e=>{const o=e.getAttribute("data-edit-key");if(!o||"!"===o[0])return void e.setAttribute("data-edit-key","!"+w());const i="~"+n+"~"+v(o);e.setAttribute("data-edit-key",i),t&&t[o]&&(r[i]=Object.assign({},t[o]))}),r}(n,o);r?r.after(n):t.appendChild(n),Yr(e),eo(e),nt(e,t,i,{[n.getAttribute("data-edit-key")]:Xt(n,!0)},s)}function sn(e){const t=Wt(void 0===e?qt:e);if(!tn("duplicate",t))return!1;const n=Ft(t);if("data"===me(n)){const e=Vt(n),r=Yt(n,t);if(!e||r<0)return!1;const o=JSON.parse(JSON.stringify(e[r]));return o&&null!=o.id&&(o.id=Gt(e,o.id)),e.splice(r+1,0,o),et(n,r+1,o,"insert"),!0}if(Ee(t))return function(e,t){const n=t.parentElement,r=A(n),o=ye(t),i=o.map(e=>dt(Xt(e)));if(i.some(e=>!e))return!1;const s={roots:i},a="~"+w()+"~"+v(we(t));return i.forEach(e=>{e._manifestComponent=t._manifestComponent,e._manifestHost=s,e.removeAttribute("data-component")}),i[0].setAttribute("data-edit-host",a),o[o.length-1].after(...i),Yr(e),eo(e),nt(e,n,r,{[a]:i[0].outerHTML}),!0}(n,t);const r=dt(Xt(t,!0));return!!r&&(on(n,t.parentElement,r,t,rn(t)),!0)}function an(e){const t=Wt(void 0===e?qt:e);if(!tn("remove",t))return!1;const n=Ft(t);if("data"===me(n)){const e=Vt(n),r=Yt(n,t);if(!e||r<0)return!1;const o=e[r];return e.splice(r,1),et(n,r,o,"remove"),qt===t&&It(null),!0}const r=t.parentElement,o=A(r),i=we(t),s=Ee(t)?t.outerHTML:Xt(t,!0);return t._editLead=Pe(t),t._editLead.forEach(e=>e.remove()),ye(t).slice(1).forEach(e=>e.remove()),t.remove(),ft.set(i,t),(qt===t||qt&&t.contains(qt))&&It(null),nt(n,r,o,{[i]:s}),!0}const ln=e=>{const t=Wt(void 0===e?qt:e);return tn("remove",t)&&nn(t)&&an(t)};function cn(e){if(!Ht)return!1;const t=en(void 0===e?qt:e);if(!t)return!1;const n=Wt(void 0===e?qt:e),r=ce(t);if(!Zt(r))return!1;if("data"===me(r)){const e=Vt(r);if(!e)return!1;const t=n?Yt(r,n)+1:e.length,o=document.createElement("template");o.innerHTML=Ht.html;const i={id:Gt(e,"pasted"),label:(o.content.textContent||"").trim()};return e.splice(t,0,i),et(r,t,i,"insert"),!0}if("static"!==me(r))return!1;const o=dt(Ht.html);return!(!o||!Be(o,t)||(on(r,t,o,n&&n.parentElement===t?n:null,Ht.ops),0))}const dn=e=>e.target.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.target.tagName);function un(e){const t=ce(e.target&&1===e.target.nodeType?e.target:e.target&&e.target.parentElement);t&&io(t)&&It(Dt(e.target))}const fn=e=>{const t=getComputedStyle(e).position;return"absolute"===t||"fixed"===t},mn=new WeakSet;let pn,hn=null;function gn(e){pn&&pn.isConnected||(pn=document.createElement("div"),pn.setAttribute("data-edit-live",""),pn.setAttribute("aria-live","polite"),document.body.appendChild(pn)),pn.textContent=e}function bn(e){e.removeAttribute("data-edit-piece"),e.removeAttribute("data-edit-grabbable"),mn.has(e)&&(e.removeAttribute("tabindex"),mn.delete(e))}function yn(e){const t=new Set(function(e){const t=me(e);if("component"===t)return[];if("data"===t){const t=h(e);return t?Ae(t.parentElement):[]}const n=[],r=e=>Ae(e).forEach(e=>{e.closest("[data-edit-ghost], [x-edit\\.grab]")||(e._manifestComponent?Ee(e)&&n.push(e):(n.push(e),je(e)&&!m(e)&&r(e)))});return je(e)&&r(e),n}(e).filter(Ut));e.querySelectorAll("[data-edit-piece]").forEach(n=>{t.has(n)||ce(n.parentElement)!==e||bn(n)}),t.forEach(e=>{e.setAttribute("data-edit-piece",""),e.toggleAttribute("data-edit-grabbable",!!Ln(e)),e.hasAttribute("tabindex")||(e.tabIndex=0,mn.add(e))})}const vn=e=>{const t=getComputedStyle(e);return/grid/.test(t.display)||/flex/.test(t.display)&&!String(t.flexDirection||"").startsWith("column")?"x":"y"};function En(e,t,n,r){const o=e.getBoundingClientRect();let i=("x"===vn(r)?t<o.left+o.width/2:n<o.top+o.height/2)?e:ye(e).pop().nextElementSibling;for(;i&&(i===s||i.hasAttribute("data-edit-dragging"));)i=i.nextElementSibling;return{container:r,ref:i}}function wn(e,t,n,r){const o=t?e.left:e.top,i=t?e.width:e.height,s=t?n:r;if(!i)return!0;const a=Math.min(.25*i,24);return s>=o+a&&s<=o+i-a}const kn=(e,t,n,r)=>wn(e.getBoundingClientRect(),"x"===vn(r),t,n),An=e=>!!e&&!!e._edit&&Jt(e)&&"static"===me(e)&&(e=>!!e&&re().includes(e))(e);function _n(e,t,n){if(n.dataList)return{container:n.home,ref:xn(n.home,e,t)};const r=n.nested;if(r&&r.el.isConnected&&n.ghost.parentElement===r.el&&e>=r.rect.left&&e<=r.rect.right&&t>=r.rect.top&&t<=r.rect.bottom&&wn(r.rect,r.horiz,e,t))return{container:r.el,ref:xn(r.el,e,t)};n.nested=null;const o=n.crossOK?function(e,t,n){const r=document.elementFromPoint?document.elementFromPoint(e,t):null;let o=r&&ce(r);if(o&&o!==n&&n.contains(o)&&(o=n),o&&An(o))return o;const i=[n,...document.querySelectorAll("[data-edit-drop-target]")].filter((e,t,n)=>An(e)&&n.indexOf(e)===t),s=(n,r)=>e>=n.left-r&&e<=n.right+r&&t>=n.top-r&&t<=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-e,0,e-r.right),Math.max(r.top-t,0,t-r.bottom)),c=ze(L(n,"--edit-drop-reach",""),n,"w")??48,d=n.parentElement,u=d&&d!==document.body&&d!==document.documentElement&&!i.some(e=>e!==n&&d.contains(e))&&s(d.getBoundingClientRect(),0);(s(r,c)||u)&&o<l&&(a=n,l=o)}return a}(e,t,n.area):n.area;if(!o)return null;const i=document.elementFromPoint?document.elementFromPoint(e,t):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 e=i;e&&e!==o;e=e.parentElement)(Ee(e)||ve(e))&&(r=Ee(e)?e:e._manifestHost.roots[0]);for(let i=r;i&&i!==o;i=i.parentElement){if(i===n.item||n.item.contains(i)||be(i))continue;const r=i.parentElement;if(je(r))if(Ee(i)){if(Jt(r)&&Be(n.item,r)&&!n.item.contains(r))return En(i,e,t,r)}else{if(n.ghost&&(i===n.home||i.contains(n.ghost))&&Jt(i)&&Be(n.item,i))return{container:i,ref:xn(i,e,t)};if(je(i)&&Jt(i)&&Be(n.item,i)&&kn(i,e,t,r))return n.ghost&&n.ghost.parentElement!==i&&(n.nested={el:i,rect:i.getBoundingClientRect(),horiz:"x"===vn(r)}),{container:i,ref:xn(i,e,t)};if(Jt(r)&&Be(n.item,r)&&!n.item.contains(r))return En(i,e,t,r)}}}if(!(n.crossOK||i&&o.contains(i))){const r=n.ghost.parentElement;return{container:r,ref:xn(r,e,t)}}return Jt(o)&&Be(n.item,o)?{container:o,ref:xn(o,e,t)}:null}function xn(e,t,n){const r="y"===vn(e);for(const o of Ae(e)){if(o===s||o.hasAttribute("data-edit-dragging")||Lt(o,"move"))continue;const e=o.getBoundingClientRect(),i=e.left+e.width/2,a=e.top+e.height/2;if(r&&!/inline/.test(getComputedStyle(o).display)){if(a>n)return o;continue}const l=Math.abs(a-n)<e.height/2;if(a-n>e.height/2||l&&i>t)return o}return null}function Sn(e,t,n,r){const o=e.offsetParent||e.parentElement,i=o.getBoundingClientRect();let s=t-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-e.offsetWidth,c=o.clientHeight-e.offsetHeight;s=l>0?Ie(s,0,l):Math.max(0,s),a=c>0?Ie(a,0,c):Math.max(0,a),e.style.left=qe(s,r.lu,e,o,"w")+r.lu,e.style.top=qe(a,r.tu,e,o,"h")+r.tu}const Tn=e=>{e.style.removeProperty("left"),e.style.removeProperty("top"),e.getAttribute("style")||e.removeAttribute("style")},Cn=(e,t)=>A(e).filter((n,r)=>Ae(e)[r]!==t);function On(e){const t=this;if(!io(t)||"mouse"===e.pointerType&&0!==e.button||e._editDrag)return;const n=e.target;if(!n||1!==n.nodeType||n.hasAttribute("data-edit-handle"))return;if(n._pieceMode)return void Ar(n);let r=null;for(let e=n;e&&e!==t;e=e.parentElement)if(e.hasAttribute("data-edit-piece")&&Ut(e)){r=e;break}if(!r)return;const o=Ln(r);if(o){if(!o.contains(n))return;e.preventDefault()}else if(Mn(n))return;e._editDrag=!0,function(e,t,n){const r=t.parentElement,o=ye(t).pop().nextElementSibling,i=ye(t).slice(1),a="data"===me(n),l={item:t,area:n,home:r,dataList:a,ghost:null,crossOK:!a&&"static"===me(n)&&(Ee(t)||!Kt(t)),homeBefore:a?null:A(r),lu:He(t.style.left)||"px",tu:He(t.style.top)||"px"},c=t.getBoundingClientRect(),d=t.getAttribute("style"),u=j(t),f=Pe(t);l.grabX=e.clientX-c.left,l.grabY=e.clientY-c.top;const m=e.clientX,p=e.clientY;let h=!1,g=0,b=m,y=p,v=null;const E=e=>{const r=document.activeElement;r&&t.contains(r)&&r.isContentEditable&&r.blur();try{window.getSelection().removeAllRanges()}catch{}l.crossOK&&re().forEach(e=>{e!==n&&An(e)&&e.setAttribute("data-edit-drop-target","")});const o=l.ghost=t.cloneNode(!0);pr(t,o),o.setAttribute("data-edit-ghost",""),o.setAttribute("x-ignore",""),o.removeAttribute("id"),o.querySelectorAll("[id]").forEach(e=>e.removeAttribute("id")),[o,...o.querySelectorAll("*")].forEach(e=>{[...e.attributes].forEach(t=>{t.name.startsWith("data-edit-")&&"data-edit-ghost"!==t.name&&e.removeAttribute(t.name)}),e.removeAttribute("contenteditable"),e.removeAttribute("tabindex"),e.removeAttribute("draggable")}),t.before(o),Object.assign(t.style,{position:"fixed",width:c.width+"px",height:c.height+"px",margin:"0",pointerEvents:"none"}),t.setAttribute("data-edit-dragging",""),s=o;try{t.setPointerCapture(e.pointerId)}catch{}},w=()=>{g=0,t.style.left=b-l.grabX+"px",t.style.top=y-l.grabY+"px"},k=e=>{const n=l.ghost,{container:o,ref:i}=e,s=v&&v.container===o&&v.ref===i;v=e,s||o.insertBefore(n,i&&i.parentElement===o?Re(i):null),fn(n)?(s||(o===r&&t.parentElement===r?r.insertBefore(n,t):n.nextElementSibling&&o.appendChild(n)),Sn(n,b,y,l)):(n.style.left||n.style.top)&&Tn(n)},_=e=>{if(b=e.clientX,y=e.clientY,!h){if(Math.hypot(b-m,y-p)<5)return;h=!0,E(e),w()}e.preventDefault();const t=_n(b,y,l);t&&k(t),g||(g=requestAnimationFrame(w))},x=e=>{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(e=>e.removeAttribute("data-edit-drop-target")),t.removeAttribute("data-edit-dragging"),e?l.ghost.remove():(l.ghost.replaceWith(t),f.length&&t.before(...f),i.length&&t.after(...i)),null==d?t.removeAttribute("style"):t.setAttribute("style",d),l.ghost=null,s=null;const a=()=>{o&&o.parentElement===r?r.insertBefore(t,Re(o)):r.appendChild(t),f.length&&t.before(...f),i.length&&t.after(...i)};if(e)return a(),void gn("Cancelled");const c=t.parentElement,m=ce(c);if(c!==r&&(l.dataList||!Jt(c)||!Be(t,c)||!m||m!==n&&(!l.crossOK||!An(m))))return a(),void gn("Cancelled");fn(t)?Sn(t,b,y,l):(t.style.left||t.style.top)&&Tn(t);const p=j(t)!==u;if(l.dataList)return jn(n,r),void gn("Dropped");let v=!1;c===r?v=Et(n,r,l.homeBefore):(wt(n,m,t,r,l.homeBefore,Cn(c,t)),v=!0),p&&vt(ce(t),t,{before:u,join:v}),gn(m!==n?"Moved to "+de(m):"Dropped")},S=()=>x(!1),T=()=>x(!0),C=e=>{"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),x(!0))};document.addEventListener("pointermove",_),document.addEventListener("pointerup",S),document.addEventListener("pointercancel",T),document.addEventListener("keydown",C,!0)}(e,r,t)}const Ln=e=>[...e.querySelectorAll("[x-edit\\.grab]")].find(t=>t.closest("[data-edit-piece]")===e)||null,Mn=e=>{const t=document.activeElement;return!!t&&t!==document.body&&t.isContentEditable&&(t===e||t.contains(e))};function jn(e,t){return"data"===me(e)&&(Xe(e,Ae(t).map(t=>xe(t,e))),function(e){if(!e)return;const t=de(e),n=me(e),r=Ue(e,n),o=d[t];o&&C(o,r)||(Ke({region:t,kind:n,before:o??r,after:r}),d[t]=r)}(e),!0)}const Pn=(e,t)=>e.target!==t&&!!e.target.closest&&t.contains(e.target.closest('a[href], button, summary, [role="button"], [role="link"]')),Rn=e=>Ae(e.parentElement).filter(t=>t===e||!Lt(t,"move"));function $n(e){if(document.activeElement!==e)try{e.focus()}catch{}}function Nn(e,t){if(e._editRow)return;const n=e.target;if("Enter"===e.key&&n.matches&&n.matches("a[href]")&&or(n,t))return;if(n._pieceMode&&"Enter"===e.key)return e._editRow=!0,e.preventDefault(),void Ar(n,!0);let r=null;for(let e=n;e&&e!==t;e=e.parentElement)if(e.hasAttribute&&e.hasAttribute("data-edit-piece")&&Ut(e)){r=e;break}if(!hn){const t=Wt(n);if(t&&function(e,t){if(dn(e))return!1;const n=e.metaKey||e.ctrlKey,r=(e.key||"").toLowerCase();return n&&"c"===r?nn(t):n&&"x"===r?ln(t):n&&"v"===r?cn(t):n&&"d"===r?sn(t):!(n||"Delete"!==e.key&&"Backspace"!==e.key)&&an(t)}(e,t))return e._editRow=!0,e.preventDefault(),void e.stopPropagation()}if(!r)return;const o={ArrowUp:-1,ArrowDown:1}[e.key],i={ArrowLeft:-1,ArrowRight:1}[e.key],s=e.altKey&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey;if(s&&null!=o&&(!hn||hn.item!==r))return e._editRow=!0,e.preventDefault(),void function(e,t){const n=Ft(e),r=e.parentElement,o=Rn(e),i=o.indexOf(e),s=i+t;if(i<0||s<0||s>=o.length)return void gn(`Position ${i+1} of ${o.length}`);const a="data"===me(n)?null:A(r),l=o[s],c=[];for(let n=t>0?e.nextElementSibling:e.previousElementSibling;n&&n!==l;n=t>0?n.nextElementSibling:n.previousElementSibling)c.push(n);const d=e=>[...Pe(e),...ye(e)];if(t>0){const t=Re(e);[l,...c].filter(e=>!ve(e)).forEach(e=>t.before(...d(e)))}else{let t=ye(e).pop();[...c.slice().reverse(),l].filter(e=>!ve(e)).forEach(e=>{t.after(...d(e)),t=ye(e).pop()})}const u=document.activeElement,f=window.getSelection&&window.getSelection(),m=f&&f.rangeCount?f.getRangeAt(0).cloneRange():null;if(a?Et(n,r,a):jn(n,r),u&&u.isConnected&&document.activeElement!==u&&(u.focus(),m))try{f.removeAllRanges(),f.addRange(m)}catch{}gn(`Moved to position ${s+1} of ${o.length}`)}(r,o);if(s&&null!=i&&!dn(e))return e._editRow=!0,e.preventDefault(),void(i>0?qn(r):zn(r));if(!(" "!==e.key&&"Enter"!==e.key||dn(e)||Pn(e,r)||e.altKey||e.metaKey||e.ctrlKey))return e._editRow=!0,e.preventDefault(),void(hn&&hn.item===r?(function(){const e=hn;hn=null,e&&(e.item.removeAttribute("data-edit-dragging"),e.before?Et(e.area,e.container,e.before):jn(e.area,e.container))}(),$n(r),gn("Dropped")):(hn&&Bn(),hn={item:r,area:Ft(r),container:r.parentElement,next:ye(r).pop().nextElementSibling,before:"data"===me(Ft(r))?null:A(r.parentElement)},r.setAttribute("data-edit-dragging","keyboard"),gn("Grabbed — arrow keys to move, Enter to drop")));if(hn&&hn.item===r){if("Escape"===e.key)return e._editRow=!0,e.preventDefault(),Bn(),$n(r),void gn("Cancelled");const t=o??i;if(null==t)return;e._editRow=!0,e.preventDefault();const n=Rn(r),s=n.indexOf(r)+t;if(s<0||s>=n.length)return;return $e(r,e=>{t>0?ye(n[s]).pop().after(e):Re(n[s]).before(e)}),$n(r),void gn(`Position ${s+1} of ${n.length}`)}n!==r||dn(e)||e.altKey||e.metaKey||e.ctrlKey||null==o&&null==i||!fn(r)||(e._editRow=!0,function(e,t){const n={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[e.key];if(!n)return;e.preventDefault(),t._moveTimer||(t._preStyle=j(t));const r=e.shiftKey?16:4,o=getComputedStyle(t),i=t.offsetParent||t.parentElement,s=He(t.style.left)||"px",a=He(t.style.top)||"px",l=Math.max(0,i.clientWidth-t.offsetWidth),c=Math.max(0,i.clientHeight-t.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]&&(t.style.left=qe(l?Math.min(l,d):d,s,t,i,"w")+s),n[1]&&(t.style.top=qe(c?Math.min(c,u):u,a,t,i,"h")+a),clearTimeout(t._moveTimer),t._moveTimer=setTimeout(()=>{t._moveTimer=null;const e=t.isConnected&&ce(t);e&&vt(e,t)},350)}(e,r))}function Bn(){const e=hn;hn=null,e&&(e.item.removeAttribute("data-edit-dragging"),$e(e.item,t=>{e.next&&e.next.parentElement===e.container?e.container.insertBefore(t,Re(e.next)):e.container.appendChild(t)}))}const Hn=e=>e===ce(e)?de(e):e.tagName.toLowerCase();function qn(e){const t=Ft(e);if("static"!==me(t))return gn("Records stay in their list"),!1;let n=e.previousElementSibling;for(;n&&(be(n)||"TEMPLATE"===n.tagName||ve(n));)n=n.previousElementSibling;if(!n||Ee(n)||!Jt(n)||!Be(e,n))return gn("Nothing to nest into"),!1;const r=e.parentElement,o=A(r),i=A(n);return $e(e,e=>n.appendChild(e)),wt(t,t,e,r,o,i),$n(e),gn("Nested in "+Hn(n)),!0}function zn(e){const t=Ft(e),n=e.parentElement;if("static"!==me(t))return gn("Records stay in their list"),!1;const r=n&&n!==t?n.parentElement:null;if(!r||r!==t&&!t.contains(r)||!Jt(r))return gn("Already at the top level"),!1;if(!Be(e,r))return gn("Cannot move out here"),!1;const o=A(n),i=A(r);return $e(e,e=>ye(n).pop().after(e)),wt(t,t,e,n,o,i),$n(e),gn("Moved out to "+Hn(r)),!0}let In;function Dn(e,t){const n=e.getBoundingClientRect();e.dispatchEvent(new CustomEvent("edit:size",{bubbles:!0,detail:{width:n.width,height:n.height,css:{width:e.style.width,height:e.style.height},done:t}}))}const Wn=e=>"rtl"===getComputedStyle(e).direction;function Fn(e,t){const n=getComputedStyle(e).position;if("fixed"===n)return"w"===t?document.documentElement.clientWidth:document.documentElement.clientHeight;const r="absolute"===n&&e.offsetParent||e.parentElement;if(!r)return null;const o=getComputedStyle(r),i="w"===t,s=i?r.clientWidth:r.clientHeight;return"absolute"===n?s:i||function(e){for(let t=e,n=0;t&&n<32;t=t.parentElement,n++){if(t===document.documentElement)return!0;const e=getComputedStyle(t).position;if("absolute"===e||"fixed"===e)return!0;let n;if(t.computedStyleMap)try{n=String(t.computedStyleMap().get("height")).trim()}catch{}if(null==n&&(n=(t.style&&t.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 Kn(e,t,n,r){if(!(e=String(e||"").trim())||"none"===e||"auto"===e)return r;if(/^-?[\d.]+%$/.test(e)){const o=Fn(t,n);return null==o?r:parseFloat(e)/100*o}const o=ze(e,t,n);return null==o?r:o}function Un(e,t){const n=Kn(t.minWidth,e,"w",0),r=Kn(t.minHeight,e,"h",0);return{minW:n,minH:r,maxW:Math.max(n,Kn(t.maxWidth,e,"w",1/0)),maxH:Math.max(r,Kn(t.maxHeight,e,"h",1/0))}}const Jn=e=>"x"===e?["left","right"]:"y"===e?["top","bottom"]:["top","right","bottom","left","top-left","top-right","bottom-left","bottom-right"];function Xn(e){const t=L(e,"--edit-size","both");if("none"===t)return;if(e._sizeBound)return;e._sizeBound=!0;const n=getComputedStyle(e).position;n&&"static"!==n||(e.style.position="relative",e._editPos=!0),(L(e,"--edit-size-edges","")||Jn(t).join(" ")).split(/\s+/).filter(Boolean).forEach(t=>{const n=function(e,t){const n=Wn(t);return e.replace(/start/g,n?"right":"left").replace(/end/g,n?"left":"right")}(t,e),r=document.createElement("span");r.setAttribute("data-edit-handle",t),r.tabIndex=0,r.setAttribute("role","slider"),r.setAttribute("aria-label",`Resize ${t}`),r.addEventListener("pointerdown",t=>function(e,t,n){const r=ce(t);if(!io(r)||"mouse"===e.pointerType&&0!==e.button||e.button>0)return;e.preventDefault(),e.stopPropagation();const o=t.getAttribute("style");t._preStyle=j(t);const i=getComputedStyle(t),s=t.getBoundingClientRect(),a=He(t.style.width)||"px",l=He(t.style.height)||"px",c=parseFloat(i.width)||s.width,d=parseFloat(i.height)||s.height,u=e.clientX,f=e.clientY,{minW:m,maxW:p,minH:h,maxH:g}=Un(t,i),b=n.includes("right"),y=n.includes("left"),v=n.includes("bottom"),E=n.includes("top"),w=Qn(t,"--edit-size-snap-distance","x","w"),k=Qn(t,"--edit-size-snap-distance","y","h"),A=Yn(t,"x","w"),_=Yn(t,"y","h"),x=Qn(t,"--edit-size-close","x","w"),S=Qn(t,"--edit-size-close","y","h"),T=null!=x||null!=S?function(e){const t=e.getAttribute("x-show");return null==t?null:Zn.test(t)?t:(er.has(e)||(er.add(e),console.warn('[edit] --edit-size-close needs an assignable x-show expression (e.g. x-show="open"); close is off here:',t)),null)}(t):null;let C;if(T)try{C=tr(window.Alpine.evaluate(t,T))}catch{}const O=e.target;try{O.setPointerCapture&&O.setPointerCapture(e.pointerId)}catch{}O.setAttribute("data-edit-resizing",""),In||(In=document.createElement("div"),In.setAttribute("data-edit-overlay",""),document.body.appendChild(In)),In.style.display="block";let L=c,M=d,P=!1;const R=()=>(b||y)&&null!=x&&L<x||(E||v)&&null!=S&&M<S,$=e=>{if(e!==P&&T){P=e;try{nr(t,T,!e&&C)}catch{}}},N=e=>{const n=e.clientX-u,r=e.clientY-f;(b||y)&&(L=c+(b?n:-n)),(E||v)&&(M=d+(v?r:-r)),$(R());let o=!1;if(b||y){const e=Ie(L,m,p),n=Gn(e,A,w);o=o||A.length>0&&n!==e,t.style.width=qe(n,a,t,t.parentElement,"w")+a}if(E||v){const e=Ie(M,h,g),n=Gn(e,_,k);o=o||_.length>0&&n!==e,t.style.height=qe(n,l,t,t.parentElement,"h")+l}t.toggleAttribute("data-edit-snapped",o&&!P),O.toggleAttribute("data-edit-snapped",o&&!P),Dn(t,!1)},B=()=>{document.removeEventListener("pointermove",N),document.removeEventListener("pointerup",z),document.removeEventListener("pointercancel",q),In&&(In.style.display="none"),["data-edit-snapped","data-edit-resizing"].forEach(e=>O.removeAttribute(e)),t.removeAttribute("data-edit-snapped")},H=()=>{null==o?t.removeAttribute("style"):t.setAttribute("style",o)},q=()=>{B(),$(!1),H(),Dn(t,!0)},z=()=>{B();const e=(b||y)&&null!=x&&L<x,n=(E||v)&&null!=S&&M<S;if((e||n)&&T){const o=(e?m:0)>0||(n?h:0)>0,i=t.style.display;H(),o&&(e&&m>0&&(t.style.width=qe(m,a,t,t.parentElement,"w")+a),n&&h>0&&(t.style.height=qe(h,l,t,t.parentElement,"h")+l));const s=vt(r,t);return Dn(t,!0),"none"===i&&(t.style.display="none"),void function(e,t,n,r,o){let i=o;try{void 0===i&&(i=tr(window.Alpine.evaluate(t,n))),nr(t,n,!1)}catch(e){return console.warn("[edit] could not close via x-show:",e),!1}const s=Tt(t,e);null!=s&&Ke(Object.assign({kind:"show",region:de(e),key:s,expr:n,before:i,value:!1},r?{join:!0}:{}))}(r,t,T,s,C)}if(e||n)return H(),void Dn(t,!0);vt(r,t),Dn(t,!0)};document.addEventListener("pointermove",N),document.addEventListener("pointerup",z),document.addEventListener("pointercancel",q)}(t,e,n)),r.addEventListener("keydown",t=>function(e,t,n){const r={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]};if(!r[e.key])return;const o=ce(t);if(!io(o))return;e.preventDefault(),e.stopPropagation(),t._keyTimer||(t._preStyle=j(t));const[i,s]=r[e.key],a=e.shiftKey?32:8,l=getComputedStyle(t),c=n.includes("right"),d=n.includes("left"),u=n.includes("top"),f=n.includes("bottom"),m=He(t.style.width)||"px",p=He(t.style.height)||"px",{minW:h,maxW:g,minH:b,maxH:y}=Un(t,l);if((c||d)&&i){const e=Ie((parseFloat(l.width)||0)+i*a*(c?1:-1),h,g);t.style.width=qe(e,m,t,t.parentElement,"w")+m}if((u||f)&&s){const e=Ie((parseFloat(l.height)||0)+s*a*(f?1:-1),b,y);t.style.height=qe(e,p,t,t.parentElement,"h")+p}Dn(t,!1),clearTimeout(t._keyTimer),t._keyTimer=setTimeout(()=>{t._keyTimer=null;const e=t.isConnected&&ce(t);e&&(vt(e,t),Dn(t,!0))},350)}(t,e,n)),e.appendChild(r)})}function Vn(e,t,n){const r=O(e,`${t}-${n}`);if(r)return"none"===r?"":r;const o=O(e,t);return"none"===o?"":o}function Yn(e,t,n){return Vn(e,"--edit-size-snap",t).split(/\s+/).filter(Boolean).map(t=>ze(t,e,n)).filter(e=>null!=e)}function Gn(e,t,n){if(!t.length)return e;let r=e,o=1/0;for(const n of t){const t=Math.abs(e-n);t<o&&(o=t,r=n)}return null==n||o<=n?r:e}const Qn=(e,t,n,r)=>{const o=Vn(e,t,n);return o?ze(o,e,r):null},Zn=/^\s*[A-Za-z_$][\w$]*(?:\s*\.\s*[A-Za-z_$][\w$]*|\s*\[\s*(?:'[^'\\]*'|"[^"\\]*"|\d+)\s*\])*\s*$/,er=new WeakSet,tr=e=>{try{return void 0===JSON.stringify(e)||JSON.parse(JSON.stringify(e))}catch{return!0}};function nr(e,t,n){window.Alpine.evaluate(e,`${t} = ${JSON.stringify(n)}`)}function rr(e){requestAnimationFrame(()=>{if(!s&&!hn&&document.activeElement===e)try{const t=document.createRange();t.selectNodeContents(e);const n=window.getSelection();n.removeAllRanges(),n.addRange(t)}catch{}})}function or(e,t){const n=e.closest('[contenteditable="false"]');return!!n&&t.contains(n)&&!n.hasAttribute("data-edit-piece-mode")}function ir(e){const t=e.target&&e.target.closest&&e.target.closest("a[href]"),n=t&&ce(t);n&&io(n)&&!or(t,n)&&e.preventDefault()}const sr=new Set;let ar=!1;function lr(e,t){if(e._editRtFormat=t,e._editRt||e._pieceMode)return;const n=function(){const e=window.ManifestRichText;return e&&"function"==typeof e.attach?e:(ar||(ar=!0,console.warn("[edit] Rich Text is not loaded; text leaves fall back to plain contenteditable")),null)}();e._editRtPrior=["role","aria-multiline"].map(t=>[t,e.getAttribute(t)]);const r=n&&n.attach(e,{mode:"inline",breaks:!0,enter:"break",all:!1,format:t,onChange:()=>{}});r?(e._editRt=r,e.setAttribute("data-edit-text",""),sr.add(e)):e.setAttribute("contenteditable","true")}function cr(e){const t=e._editRt;t&&(e._editRt=null,sr.delete(e),e.removeAttribute("data-edit-text"),t.detach())}const dr=e=>sr.forEach(t=>{(!t.isConnected||e&&e.contains(t))&&cr(t)}),ur=e=>{const t=e._editRt;t&&(t.value=t.value)};function fr(e){const t=this,n=t._editRt,r=Vo(e);if(!n||!r)return;if(n.can(r))return e.preventDefault(),e.stopImmediatePropagation(),void n[r]();const o=ce(t);"undo"===r&&o&&io(o)&&!Jo(t)&&function(e){const t=e._editRt;if(!t||!t.can("redo")||!e._commitText)return;const n=function(e){const t=e._editRt.newest();if(!e._editField||e._editRich)return t.trim();const n=document.createElement("template");return n.innerHTML=t,n.content.textContent}(e);e._commitText(n)&&$t()}(t),Yo(e),e.defaultPrevented&&e.stopImmediatePropagation()}function mr(e){e.addEventListener("drop",t=>{const n=ce(e);n&&io(n)&&(t.preventDefault(),t.stopImmediatePropagation())})}function pr(e,t){const n=[e,...e.querySelectorAll("*")],r=[t,...t.querySelectorAll("*")];r.forEach(e=>{const t=e.getAttribute("style");if(t&&/--rich-text-/.test(t)){const n=M(t);n?e.setAttribute("style",n):e.removeAttribute("style")}}),n.forEach((e,t)=>{e._editRt&&r[t]&&([...r[t].attributes].forEach(e=>{e.name.startsWith("data-rich-text")&&r[t].removeAttribute(e.name)}),(e._editRtPrior||[]).forEach(([e,n])=>null==n?r[t].removeAttribute(e):r[t].setAttribute(e,n)))})}function hr(e,t,n){e._textBound||(e._textBound=!0,e._commitText=t,e.addEventListener("focus",()=>{ur(e),e._preEdit=Uo(e),rr(e)}),e.addEventListener("keydown",t=>{e.isContentEditable&&("Escape"===t.key?(t.preventDefault(),t.stopImmediatePropagation(),e.blur()):"Enter"!==t.key||!t.altKey||t.shiftKey||t.metaKey||t.ctrlKey||(t.preventDefault(),t.stopImmediatePropagation(),function(e){e.blur();const t=[e,...kr(e)].find(e=>e.hasAttribute&&e.hasAttribute("data-edit-piece"));if(t){t.isContentEditable&&(t._pieceMode=!0,t.setAttribute("data-edit-piece-mode",""),cr(t),t.setAttribute("contenteditable","false"),t.addEventListener("focusout",()=>Ar(t),{once:!0}));try{t.focus()}catch{}}}(e)))}),e.addEventListener("keydown",fr),mr(e),n&&e.addEventListener("input",n),e.addEventListener("blur",()=>t()))}const gr=e=>{const t=e.closest("[data-rich-text]");return!(!t||t===e&&e._editRt)};function br(e){e.querySelectorAll("[data-rich-text]:not([data-rich-text-bound])").forEach(t=>{!t._editRt&&ue(t,"text")&&/^[@~]/.test(t.getAttribute("data-edit-key")||"")&&(t._richBound||(t._richBound=!0,t.addEventListener("focusin",()=>{t._preEdit=Uo(t)}),t.addEventListener("blur",()=>{const n=ce(t)||e;("component"===me(n)?Qe:gt)(n,t,"text",t.innerHTML.trim())},!0)))})}function yr(e){const t=h(e);if(!t)return;const n=(t.getAttribute("x-for").match(/^\s*([\w$]+)\s+in\b/)||[])[1];if(!n)return;const r=ge(e),o=new RegExp("^\\s*"+n+"\\.([\\w$]+)\\s*$");Ae(e).forEach(t=>{let i=t.getAttribute("data-key");if(null==i){let e=null;try{e=window.Alpine.$data(t)[n]}catch{}e&&null!=e.id&&(i=String(e.id))}null!=i&&[t,...t.querySelectorAll("*")].forEach(t=>{const n=t.hasAttribute("x-html");if(t.children.length&&(!n||!Oe(t))||t.hasAttribute("data-edit-handle"))return;const s=t.getAttribute("x-text")||t.getAttribute("x-html");if(!s)return;const a=s.match(o);if(!a)return;const l=a[1];if(t._editField=l,t._editRich=n,!t._dvBound){t._dvBound=!0;const o=()=>n?z(t):t.textContent;t._commitText=n=>function(e,t,n,r,o,i){o=String(o),i&&i._editRich&&(o=I(i,o));const s=i?i._preEdit:void 0;return!(s===o||i&&i._editRich&&null!=s&&I(i,s)===o||(Ke({kind:"data-val",region:de(e),source:t,id:n,field:r,value:o,before:s}),yt(),0))}(e,r,i,l,n??o(),t),t.addEventListener("focus",()=>{ur(t),t._preEdit=Uo(t),$(t)||rr(t)}),t.addEventListener("focusin",()=>{t._preEdit=Uo(t)}),t.addEventListener("keydown",fr),mr(t),t.addEventListener("blur",()=>t._commitText(),!0)}$(t)||lr(t,n?"html":"plain")})})}const vr=e=>{const t=pe(e);return(t?.getAttribute("data-component")||"").replace(/-\d+$/,"")};function Er(e,t,n,r){if("main"!==(e._editScope||"instance"))return;const o=vr(e),i=t._editPath,{inst:s}=Ve();re().forEach(e=>{if("component"!==me(e)||vr(e)!==o)return;const a=pe(e);if(!a)return;const l=""===i?a:function(e,t){let n=e;for(const e of t.split(".").map(Number))if(n=ke(n)[e],!n)return null;return n}(a,i);l&&l!==t&&void 0===(s[de(e)]&&s[de(e)][i]||{})[n]&&("class"===n?Cr(l,r):l.innerHTML!==r&&(l.innerHTML=r))})}function wr(e){const t=pe(e);if(!t)return;e._editScope||(e._editScope="instance"),e._baseText=e._baseText||{},e._baseClass=e._baseClass||{},e._baseStyle=e._baseStyle||{};const n=n=>{const r=function(e,t){const n=[];let r=e;for(;r&&r!==t&&r.parentElement;)n.unshift(ke(r.parentElement).indexOf(r)),r=r.parentElement;return n.join(".")}(n,t);n._editPath=r,r in e._baseClass||(e._baseClass[r]=n.getAttribute("class")||""),r in e._baseStyle||(e._baseStyle[r]=n.getAttribute("style")||"")};n(t),t.querySelectorAll("*").forEach(e=>{e.hasAttribute("data-edit-handle")||n(e)}),br(e),Ye(t).forEach(t=>{if(t.children.length&&!Le(t)||!t.textContent.trim()||!ue(t,"text"))return;if(gr(t))return;const n=t._editPath;n in e._baseText||(e._baseText[n]=t.innerHTML.trim()),hr(t,n=>Qe(e,t,"text",n??z(t)),()=>Er(e,t,"text",t.innerHTML)),lr(t,"html")})}const kr=e=>{const t=[],n=ce(e);for(let r=e.parentElement;r&&r!==n;r=r.parentElement)t.push(r);return t};function Ar(e,t){if(e._pieceMode&&(e._pieceMode=!1,e.removeAttribute("data-edit-piece-mode"),"false"===e.getAttribute("contenteditable")&&(e.removeAttribute("contenteditable"),lr(e,e._editRtFormat||"html")),t)){try{e.focus()}catch{}rr(e)}}const _r=(e,t)=>e.getAttribute(":"+t)??e.getAttribute("x-bind:"+t);function xr(e){const t=_r(e,"class");if(null==t)return[];let n;try{n=window.Alpine.evaluate(e,t)}catch{return[]}const r=[],o=e=>String(e).split(/\s+/).filter(Boolean).forEach(e=>r.push(e));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(([e,t])=>{t&&o(e)}),r}const Sr=e=>String(e||"").split(/\s+/).filter(Boolean);function Tr(e){const t=new Set(xr(e));return Sr(e.getAttribute("class")).filter(e=>!t.has(e)).join(" ")}function Cr(e,t){const n=xr(e),r=[...new Set([...Sr(t),...n])].join(" ");r?e.getAttribute("class")!==r&&e.setAttribute("class",r):e.hasAttribute("class")&&e.removeAttribute("class")}function Or(e){if(null==e&&(e=qt),!e||1!==e.nodeType)return null;const t=ce(e);if(!t||!io(t))return null;const n=me(t);return"static"===n&&e._manifestComponent?null:{el:e,area:t,kind:n}}function Lr(e,t,n){const r=Or(n);if(!r)return!1;e=String(e||"").trim().toLowerCase();const o=!0===t?"":!1===t||null==t?null:String(t),i=X(e,o,r.el.tagName);if(i)return console.warn(`[edit] attribute refused (${i}):`,e),!1;if(Lt(r.el,"attrs"))return!1;const s="data"!==r.kind&&Me(r.el);if(s)return function(e,t,n,r){if(Lt(t,"text")||e.el.getAttribute(n)===r)return!1;const o=document.activeElement===t,i=o&&void 0!==t._preEdit?t._preEdit:Uo(t),s=e.el.getAttribute(n),a=Uo(t),l=t=>null===t?e.el.removeAttribute(n):e.el.setAttribute(n,t);if(l(r),Uo(t)===a)return l(s),console.warn(`[edit] ${n} is not kept inside text`),!1;const c=z(t),d="component"===e.kind?Qe(e.area,t,"text",c,i):gt(ce(t),t,"text",c,{before:i});return o&&(ur(t),t._preEdit=Uo(t)),d}(r,s,e,o);if("class"===e)return Mr(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!=_r(r.el,e)&&console.warn(`[edit] ${e} is bound on this element; the binding will override the edited value`);const a=r.el.getAttribute(e);return a!==o&&(null===o?r.el.removeAttribute(e):r.el.setAttribute(e,o),gt(r.area,r.el,e,o,{before:a,coalesce:!0}))}function Mr(e,t){if("data"===e.kind)return console.warn("[edit] list rows are rendered from data; attributes on them are not editable"),!1;if(Me(e.el))return console.warn("[edit] class is not kept inside text"),!1;const n=Tr(e.el);return n!==(t=Sr(t).join(" "))&&(Cr(e.el,t),"component"===e.kind?null!=e.el._editPath&&(Er(e.area,e.el,"class",e.el.getAttribute("class")||""),Qe(e.area,e.el,"class",t,n)):!!/^[@~]/.test(e.el.getAttribute("data-edit-key")||"")&>(e.area,e.el,"class",t,{before:n,coalesce:!0}))}function jr(e,t){const n=Or(e);if(!n)return!1;if(Lt(n.el,"attrs"))return!1;const r=t(Sr(Tr(n.el)));return!!r&&Mr(n,r.join(" "))}const Pr={add(e,t){const n=Sr(e);return jr(t,e=>[...e,...n.filter(t=>!e.includes(t))])},remove(e,t){const n=new Set(Sr(e));return jr(t,e=>e.filter(e=>!n.has(e)))},toggle(e,t,n){const r=Or(t);if(!r)return!1;const o=Sr(e);return n??!o.every(e=>r.el.classList.contains(e))?Pr.add(e,r.el):Pr.remove(e,r.el)},set(e,t){const n=Or(t);return!!n&&!Lt(n.el,"attrs")&&Mr(n,e||"")},has(e,t){no&&no.version;const n=null==t?qt:t;return!!n&&1===n.nodeType&&Sr(e).every(e=>n.classList.contains(e))},list(e){no&&no.version;const t=null==e?qt:e;return t&&1===t.nodeType?Sr(Tr(t)):[]}},Rr=e=>{const t=e&&ce(e);return t&&"component"===me(t)?t:null};function $r(e){const t=Rr(null==e?qt:e);return t?t._editScope||"instance":null}function Nr(e){null==e&&(e=qt);const t=Rr(e);if(!t)return!1;if(e===t)Ke({kind:"cmp-inst",component:vr(n=t),region:de(n),path:"*",prop:"*",value:De}),Ge();else{if(null==e._editPath)return!1;!function(e,t){Ke({kind:"cmp-inst",component:vr(e),region:de(e),path:t._editPath,prop:"*",value:De}),Ge()}(t,e)}var n;return!0}const Br=new Set,Hr={},qr=new Set,zr=(e,t)=>(e||"")+"|"+t,Ir=e=>e&&Y[e]||document.documentElement,Dr=e=>e.value+(e.dataset.unit||"");let Wr=null;function Fr(e){const t=e._cssvar;if(!t||!("value"in e))return;const n=getComputedStyle(Ir(t.scope)).getPropertyValue(t.var).trim();if(!n)return;const r="color"===e.type?function(e){if(/^#[0-9a-f]{6}$/i.test(e))return e.toLowerCase();try{Wr=Wr||document.createElement("canvas");const t=Wr.getContext&&Wr.getContext("2d",{willReadFrequently:!0});if(!t)return null;const n=document.createElement("i");return n.style.color=e,n.style.color?(t.clearRect(0,0,1,1),t.fillStyle="#000",t.fillStyle=e,t.fillRect(0,0,1,1),"#"+[...t.getImageData(0,0,1,1).data.slice(0,3)].map(e=>e.toString(16).padStart(2,"0")).join("")):null}catch{return null}}(n):e.dataset.unit?String(parseFloat(n)):n;null!=r&&e.value!==r&&(e.value=r)}function Kr(e){const t=e._cssvar;if(!t||!t.var)return;const n=zr(t.scope,t.var);n in Hr||(Hr[n]=Ir(t.scope).style.getPropertyValue(t.var)),Fr(e),e._cvBound||(e._cvBound=!0,e.addEventListener("input",()=>Ir(t.scope).style.setProperty(t.var,Dr(e))),e.addEventListener("change",()=>{return function(e,t,n,r){if(!/^--[\w-]+$/.test(t||""))return void console.warn("[edit] x-edit.cssvar needs a custom property name (--name):",t);const o=function(e){const t=String(null==e?"":e);if(!t.trim())return"empty";if(/expression\s*\(/i.test(t))return"expression()";const n=[];for(let e=0;e<t.length;e++){const r=t[e];if('"'===r||"'"===r){let n=e+1;for(;n<t.length&&t[n]!==r;n++)if("\\"===t[n])n++;else if("\n"===t[n])return"unbalanced quotes";if(n>=t.length)return"unbalanced quotes";e=n;continue}if(/^url\(/i.test(t.slice(e,e+4))&&!/[\w-]/.test(t[e-1]||"")){let n=e+4,r=null,o="";for(;n<t.length;n++){const e=t[n];if(r){if("\\"===e){o+=t[++n]||"";continue}if(e===r){r=null;continue}o+=e}else if('"'!==e&&"'"!==e){if(")"===e)break;o+=e}else r=e}if(n>=t.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";e=n;continue}if(";"===r||"{"===r||"}"===r)return`contains ${r}`;if(t.startsWith("/*",e)||t.startsWith("\x3c!--",e)||t.startsWith("</",e))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=zr(e,t);qr.add(i),Ir(e).style.setProperty(t,n);const s=Ur()[i];s&&s.value===n||Ke({kind:"theme",scope:e||null,var:t,value:n},!!r)}(t.scope,t.var,Dr(e),t.persist||!!(n=t.scope&&Y[t.scope])&&!!(n._editPersist||n._edit&&n._edit.persist));var n}))}function Ur(){const e={};for(let t=0;t<c;t++){const n=l[t];"theme"===n.kind&&(e[zr(n.scope,n.var)]=n)}return e}function Jr(){const e=Ur();new Set([...qr,...Object.keys(e)]).forEach(t=>{qr.add(t);const n=t.indexOf("|"),r=t.slice(0,n)||null,o=t.slice(n+1),i=Ir(r),s=e[t]?e[t].value:Hr[t];s?i.style.setProperty(o,s):i.style.removeProperty(o)}),Br.forEach(Fr)}function Xr(e){const t=e&&Y[e];if(!t||ee(t))return null;const n=ce(t),r=t.getAttribute("data-edit-key");if(n&&"static"===me(n)&&!se(n)&&r&&/^[@~]/.test(r))return"area";if(n&&n!==t)return null;const o=ie(e);return o&&o!==t?null:"own"}const Vr=new Map;function Yr(e){const t=de(e),n=!e._marked;e._marked=!0,e._baseClass=e._baseClass||{},e._baseStyle=e._baseStyle||{},e._baseText=e._baseText||{};const r=Object.create(null),o=e=>{for(const t of e.children){const e=b(t);r[e]=(r[e]||0)+1,o(t)}},i=(s,a)=>{if(((o,i)=>{let s=o.getAttribute("data-edit-key");if(!s){if(n){const e=b(o),n=r[e]=(r[e]||0)+1;s=y(t,n>1?e+"#"+n:e),Vr.set(s,i)}else s="!"+w();o.setAttribute("data-edit-key",s)}s in e._baseClass||(e._baseClass[s]=Tr(o)),s in e._baseStyle||(e._baseStyle[s]=j(o)),s in e._baseText||o.children.length||(e._baseText[s]=o.innerHTML.trim())})(s,a),s!==e&&(e=>$(e)||m(e)||[...e.attributes].some(e=>e.name.startsWith("x-rich-text")))(s))return;if(s._editRt||(n||s._editRtFormat)&&Le(s)&&ue(s,"text")&&!m(s))return void(n&&o(s));let l=0;for(const e of s.children){if(be(e)||e.closest("[data-edit-ghost]")||k(e))continue;const o=""===a?String(l):a+"."+l;if(e._manifestComponent){if(ve(e))continue;if(!e.hasAttribute("data-edit-host")){const i=e.getAttribute("data-edit-key"),s=y(t,"X-"+e._manifestComponent.toUpperCase()+":");let a=i&&(i===s||i.startsWith(s+"#"))?i:"!"+w();if(n&&"!"===a[0]){const n="X-"+e._manifestComponent.toUpperCase()+":",i=r[n]=(r[n]||0)+1;a=y(t,i>1?n+"#"+i:n),Vr.set(a,o)}e.setAttribute("data-edit-host",a)}l++}else i(e,o),l++}};i(e,"")}const Gr=new Set,Qr=new Set,Zr=new Map;function eo(e){const t=function(e){if("data"!==me(e))return null;const t=(he(e)||"").match(/\$x\.([\w$]+)/);if(!t)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||{})[t[1]];return null==r?`data source '${t[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 '${t[1]}' is not a file (a cloud or remote source): save it with $x.${t[1]}.$update, not mnfst-run`}(e);t&&(Qr.add(de(e)),Zr.set(de(e),t),Gr.has(de(e))||(Gr.add(de(e)),console.warn(`[edit] x-edit="${de(e)}": ${t}; its edits stay on the page (and reach onPublish)`))),e._edit.rendered&&Qr.add(de(e)),e._edit.rendered&&!Gr.has(de(e))&&(Gr.add(de(e)),console.warn(`[edit] x-edit="${de(e)}" is inside content ${e._edit.rendered} renders: it edits on the page (and reaches onPublish), but mnfst-run cannot write it to a source file`)),dr(null);const n=me(e);"static"===n&&Yr(e),yn(e),[e,...e.querySelectorAll("[data-edit-area]")].forEach(e=>{var t,n;n="size",(t=e)._edit&&t._edit.caps.has(n)&&!Lt(t,n)&&Xn(e)}),"component"===n?wr(e):"static"===n&&function(e){br(e);const t=[...e.querySelectorAll("*")];ke(e).length&&!Le(e)||t.unshift(e),t.forEach(t=>{ke(t).length&&!Le(t)||!t.textContent.trim()||t.closest("template")||t.closest("[data-edit-handle], [x-edit\\.grab]")||t._manifestComponent&&t!==e||gr(t)||t.closest('[contenteditable="false"]:not([data-edit-piece-mode])')||!ue(t,"text")||m(t)||p.has(t.tagName)||/^[@~]/.test(t.getAttribute("data-edit-key")||"")&&(hr(t,n=>gt(ce(t)||e,t,"text",n??z(t))),lr(t,"html"))})}(e),"data"===n&&ue(e,"data")&&yr(e),e._editBound||(e._editBound=!0,e.addEventListener("pointerdown",On),e.addEventListener("keydown",t=>{io(e)&&Nn(t,e)}),e.addEventListener("dragstart",t=>{io(e)&&t.preventDefault()}),e.addEventListener("drop",t=>{io(e)&&t.preventDefault()})),e._editObserver||(e._editObserver=new MutationObserver(t=>{s||e._rearmQueued||t.every(e=>e.target.isContentEditable)||(e._rearmQueued=!0,queueMicrotask(()=>{e._rearmQueued=!1,e._armed&&io(e)&&!s&&eo(e)}))}),e._editObserver.observe(e,{childList:!0,subtree:!0}))}function to(e){[e,...e.querySelectorAll("[data-edit-area]")].forEach(e=>{e._editPos&&(e.style.removeProperty("position"),e._editPos=!1)}),e.querySelectorAll("[data-edit-handle]").forEach(e=>e.remove()),dr(e),[e,...e.querySelectorAll("[contenteditable]")].forEach(e=>{e.hasAttribute("contenteditable")&&e.removeAttribute("contenteditable"),e._pieceMode=!1,e.removeAttribute("data-edit-piece-mode")}),e.querySelectorAll("[data-edit-piece]").forEach(bn),[e,...e.querySelectorAll("[data-edit-area]")].forEach(e=>{e._sizeBound=!1}),hn&&e.contains(hn.item)&&Bn()}let no,ro=!1,oo=!1;const io=e=>!(!e||!e._edit||e._edit.gated&&(!no||!no.active)||se(e)),so=new Set;function ao(){const e=[];re().forEach(e=>{se(e)&&(so.has(de(e))||(so.add(de(e)),console.warn(`[edit] x-edit="${de(e)}" is on the page more than once (a component used several times); it is not editable here`)),e._armed&&(to(e),e._armed=!1))}),re().forEach(t=>{io(t)&&!t._armed&&(t._editBound||e.push(t),d[de(t)]=Ue(t,me(t)),eo(t),t._armed=!0)}),ro&&e.length&&(l.some(e=>/^st-/.test(e.kind))&&(pt(e),ht()),l.some(e=>"cmp-main"===e.kind||"cmp-inst"===e.kind)&&Ge()),Br.forEach(Kr),Ko(),ro=!0}function lo(e){const t=[],n=e=>e.edits||e.children||"~"===e.key[0],r=mt(ut()),o=new Set(Object.values(Ur()).filter(e=>e.scope&&"area"===Xr(e.scope)).map(e=>Y[e.scope]));ut().forEach(r=>{const i=de(r),s=ae(r),a=new Proxy({},{get:(e,t)=>{const n=v(String(t)),r=ie(decodeURIComponent(n.slice(1,n.indexOf("@",1)))),o=po&&r&&po[le(r)];return o?o[n]:void 0}}),l=(t,r)=>{const s=!r&&t.getAttribute("data-edit-host");if(s){if("!"===s[0])return null;const e={key:s},t=Vr.get(s);return null!=t&&(e.at=t),a&&a[s]&&(e.fp=a[s]),e}if(!r&&t._manifestComponent)return null;const c=t.getAttribute("data-edit-key");if(!c||"!"===c[0])return null;const d={key:c},u=Vr.get(v(c));null!=u&&(d.at=u),a&&a[v(c)]&&(d.fp=a[v(c)]);const f=(t=>{const n=e.node[t];if(!n)return null;const r={};return Object.entries(n).forEach(([e,t])=>{r[e]="class"!==e&&"style"!==e||""!==t?t:null}),Object.keys(r).length?r:null})(c);if(f&&(d.edits=f),o.has(t)&&(d.edits=Object.assign({},d.edits,{style:j(t)||null})),!(f&&"text"in f||m(t)||"TEMPLATE"===t.tagName||t.hasAttribute("data-rich-text"))){const o=(e=>ke(e).filter(e=>!k(e)))(t).map(e=>l(e)).filter(Boolean),s=e.touched.has(r?"#"+i:c);if("~"===c[0]||s){d.children=o;const t=s&&"~"!==c[0]&&(t=>{const n=""===t?(e.orderBase[i]||{})[""]:Object.values(e.orderBase).map(e=>e[t]).find(Boolean);return n?n.filter(e=>"@"===e[0]).map(e=>{const t={key:e},n=Vr.get(e);return null!=n&&(t.at=n),a&&a[e]&&(t.fp=a[e]),t}):null})(r?"":c);t&&(d.base=t)}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,t.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(e.orderBase),...Object.keys(e.order)]).forEach(t=>{Object.values(Object.assign({},e.orderBase[t]||{},e.order[t]||{})).forEach(e=>e.forEach(e=>i.add(e)))});const s=new Set;for(let e=0;e<c;e++){const t=l[e];"st-children"===t.kind&&t.before.forEach(e=>{!e||"@"!==e[0]||i.has(e)||r.has(e)||s.add(e)})}return s.forEach(e=>{const n=(e=>decodeURIComponent(e.slice(1,e.indexOf("@",1))))(e);let r=t.find(e=>e.region===n);if(!r){const e=ie(n);if(!e||se(e))return;const o=ae(e);r=o?{kind:"static-tree",region:n,component:o,tree:{key:""}}:{kind:"static-tree",region:n,tree:{key:""}},t.push(r)}(r.removed=r.removed||[]).push(e)}),t}function co(){const e=Object.entries(Bt()).map(([e,t])=>{return n=e,r=t.kind,o=t.snap,{region:n,kind:r,op:"reorderData",source:o.source,order:o.order};var n,r,o});lo(Ze()).forEach(t=>e.push(t));const t=e=>{const t=[];return Object.entries(e).forEach(([e,n])=>Object.entries(n).forEach(([n,r])=>t.push({path:e,key:e,prop:n,value:r}))),t},n=bt(),r={};l.slice(0,c).forEach(e=>{"data-val"===e.kind&&(r[e.source]=e.region)}),Object.entries(n).forEach(([t,n])=>Object.entries(n).forEach(([n,o])=>Object.entries(o).forEach(([o,i])=>e.push({kind:"data-val",region:r[t],source:t,id:n,field:o,value:i}))));const{main:o,inst:i,reverts:s}=Ve();return Object.entries(o).forEach(([n,r])=>{const o=t(r);o.length&&e.push({kind:"component",scope:"main",component:n,edits:o})}),new Set([...Object.keys(i),...Object.keys(s)]).forEach(n=>{const r=ie(n);if(!r)return;const o=t(i[n]||{}),a=[...s[n]||[]];(o.length||a.length)&&e.push({kind:"component",scope:"instance",component:vr(r),region:n,edits:o,reverts:a})}),function(){const e=Object.values(Ur()),t=[];return e.filter(e=>!Xr(e.scope)).forEach(e=>t.push({kind:"theme",scope:e.scope||null,var:e.var,value:e.value,file:null})),new Set(e.filter(e=>e.scope&&"own"===Xr(e.scope)).map(e=>e.scope)).forEach(e=>{const n=Y[e],r=(e=>{for(let t=e;t;t=t.parentElement)if(t._manifestComponent)return t._manifestComponent;return null})(n),o={key:"",edits:{style:j(n)||null}};t.push(r?{kind:"static-tree",region:e,component:r,tree:o}:{kind:"static-tree",region:e,tree:o})}),t}().forEach(t=>e.push(t)),e}function uo(e){const t=t=>"theme"===t.kind?!!e&&(e.has("theme|"+(t.scope||"")+"|"+t.var)||e.has(t.scope)):("st-move"===t.kind?[t.from,t.to]:[t.region]).some(t=>!(t=>null==t||!!ie(t)&&!(e&&e.has(t)))(t)),n=[],r=St();mt(ut().filter(t=>!(e&&e.has(de(t))))).forEach((e,t)=>{const o=r.get(t);o&&o.size&&n.push([e,new Map(o),t===e.getAttribute("data-edit-host")])});const i=l.slice(0,c).filter(e=>"lock"===e.kind&&!/^[~@]/.test(e.key)&&!t(e));let s=0;l=l.filter((e,n)=>{const r=t(e);return r&&n<c&&s++,r}),c=s,We++,T();const a=e?[...Vr].filter(([t])=>e.has(decodeURIComponent(t.slice(1,t.indexOf("@",1))))):[];Vr.clear(),a.forEach(([e,t])=>Vr.set(e,t)),re().forEach(t=>{if(e&&e.has(de(t)))return;const n=me(t);t._baseText={},t._baseClass={},t._baseStyle={},"static"===n&&([t,...t.querySelectorAll("[data-edit-key]")].forEach(e=>{ce(e)===t&&e.removeAttribute("data-edit-key")}),t.querySelectorAll("[data-edit-host]").forEach(e=>{ce(e.parentElement)===t&&e.removeAttribute("data-edit-host")}),t._marked=!1,Yr(t)),"component"===n&&t._armed&&wr(t),d[de(t)]=Ue(t,n)}),function(e){Object.keys(Hr).forEach(t=>{if(e&&e.has("theme|"+t))return;const n=t.indexOf("|");Hr[t]=Ir(t.slice(0,n)||null).style.getPropertyValue(t.slice(n+1))}),[...qr].forEach(t=>{e&&e.has("theme|"+t)||qr.delete(t)})}(e),(()=>{const e=e=>{l.splice(c,0,e),c++,fe(e.region)&&u.add(e)};i.forEach(e),n.forEach(([t,n,r])=>{const i=r?Ft(t):ce(t),s=t.getAttribute(r?"data-edit-host":"data-edit-key");i&&s&&[!0,!1].forEach(t=>{const r=[...n].filter(([,e])=>e===t).map(([e])=>e);r.length&&e({kind:"lock",region:de(i),key:s,actions:r.length===o.length?[]:r,value:t})})}),We++})(),T(),Ko()}const fo=e=>!(e&&Array.isArray(e.results)&&e.results.some(e=>e&&"error"===e.status));let mo=null,po=null,ho=null,go=null;const bo=new Set,yo=e=>{const t=v(e);if("string"!=typeof t||"@"!==t[0])return null;const n=ie(decodeURIComponent(t.slice(1,t.indexOf("@",1)))),r=ho&&n&&ho[le(n)];return r&&r[t]||null};function vo(e){if(!/^https?:$/.test(location.protocol)||"function"!=typeof fetch)return Promise.resolve(null);const t=fetch("/__edit/base",{cache:"no-store"}).then(e=>e.ok?e.json():null).then(t=>(t&&t.files&&(mo=t.files),t&&t.ids&&!e&&(po=t.ids,ho=t.cids||null),mo)).catch(()=>null);return e||(go=t),t}let Eo=!1;window.addEventListener("manifest:source-change",e=>{const t=e.detail||{},n=/\.html?$/i.test(t.file||"");n&&!po&&(Eo=!0),mo&&t.file&&t.hash&&!n&&(mo[t.file]=t.hash)});let wo=null,ko=0,Ao=[],_o=!1,xo=null;const So=e=>!_o&&!!wo&&Date.now()<wo.until&&e.length>0&&e.every(e=>e&&wo.files[e.rel]&&wo.files[e.rel]===e.hash);function To(e){const t=document.activeElement;if(!t||!t._commitText||void 0===t._preEdit||!t.isContentEditable||Uo(t)===t._preEdit)return!0;const n=ce(t);return!(!n||!e&&!n._edit.persist||(t._commitText(),ur(t),t._preEdit=Uo(t),0))}function Co(e){const t=new Map;for(let n=!0;n;)n=!1,l.slice(0,c).forEach(r=>{if("st-move"!==r.kind||e.has(r.from)===e.has(r.to))return;const[o,i]=e.has(r.from)?[r.from,r.to]:[r.to,r.from];e.add(i),t.set(i,t.get(o)||o),n=!0});return e.via=t,e}const Oo=e=>{if("string"!=typeof e)return null;const t=v(e);return"@"===t[0]?t.slice(1,t.indexOf("@",1)):null},Lo=e=>Qr.has(e.region)||Qr.has(e.from)||Qr.has(e.to)||Qr.has(Oo(e.path))||Qr.has(Oo(e.key)),Mo=e=>[...new Set(e.flatMap(e=>[e.region,e.from,e.to]).filter(Boolean))],jo=()=>l.slice(0,c).filter(e=>"lock"!==e.kind&&!u.has(e));function Po(){const e=document.activeElement,t=e&&e._commitText&&ce(e);return t?de(t):null}function Ro(){return!(!To(!1)&&!Qr.has(Po()))&&jo().every(Lo)}function $o(){const e=Po(),t=Mo(jo().filter(Lo));e&&Qr.has(e)&&!To(!1)&&!t.includes(e)&&t.push(e),t.length&&console.warn(`[edit] the source changed: reloading discards the unpublished edits of ${t.map(e=>`x-edit="${e}"`).join(", ")} that mnfst-run can't write (generated content, or a piece moved from it); .persist keeps them`)}function No(){$o(),location.reload()}function Bo(){xo&&Ro()&&(xo=null,No())}function Ho(e){if(Ro())return No();xo=e;const t=e.map(e=>e&&e.rel).filter(Boolean);no&&(no.stale=[...new Set([...no.stale||[],...t])]);const n=Mo(jo().filter(e=>!Lo(e))).filter(e=>!Qr.has(e)),r=Po();!r||Qr.has(r)||n.includes(r)||To(!1)||n.push(r);const o=Co(new Set(Qr)),i=n.filter(e=>o.has(e)),s=e=>e.map(e=>`x-edit="${e}"`).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(e=>o.via.get(e)))])}, 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:t}}))}function qo(e,t){if(ko=Math.max(0,ko-1),e&&e.base&&(wo={files:Object.assign({},e.base),until:Date.now()+3e3}),e&&Array.isArray(e.stale)&&e.stale.length&&(_o=!0),t&&fo(e)&&e.base&&(_o=!0,setTimeout(()=>{_o&&Ho(Object.keys(e.base).map(e=>({rel:e})))},1500)),ko)return;const n=Ao;Ao=[],n.some(e=>!So(e))&&Ho(n.flat())}window.addEventListener("manifest:live-reload",e=>{const t=e.detail&&e.detail.files||[];if(ko)return e.preventDefault(),void Ao.push(t);So(t)?e.preventDefault():Ro()?$o():(e.preventDefault(),Ho(t))});let zo=Promise.resolve();function Io(e){const t=zo.then(()=>function(e){const t=(e,t,n)=>{e&&e.base&&mo&&Object.entries(e.base).forEach(([e,t])=>{Do&&/\.html?$/i.test(e)||(mo[e]=t)}),e&&e.ids&&po&&(Do?Object.entries(e.ids).forEach(([e,t])=>{po[e]=Object.assign({},po[e]),Object.entries(t||{}).forEach(([t,n])=>{String(n).includes(".")||(po[e][t]=n)})}):po=e.ids,Do||(ho=e.cids||null,bo.clear()));const r=Do&&e&&e.cids&&ho?e.cids:null,o=r?function(){const e=l.slice(0,c),t=mt(ut()),n=new Map,r=new Set(e.filter(e=>"st-node"===e.kind).map(e=>e.path)),o=new Set;e.forEach(e=>{"st-children"!==e.kind&&"st-order"!==e.kind||o.add(e.parent),"st-move"===e.kind&&(o.add(e.fromParent),o.add(e.toParent))});const i=e=>!!e&&([e,...e.querySelectorAll("[data-edit-key]")].some(e=>r.has(e.getAttribute("data-edit-key")))||[...o].some(n=>{if(!n)return!1;const r=t.get(n);return!!r&&(r===e||e.contains(r))}));return t.forEach((e,o)=>{if("!"===o[0]||i(e))return n.set(e,null);if("~"===o[0]){const s=v(o);if(r.has(s)||[...r].some(e=>{const n=t.get(e),r=t.get(s);return n&&r&&r.contains(n)})||i(t.get(s)))return n.set(e,null)}n.set(e,yo(v(o)))}),n}():null,i=e&&Array.isArray(e.stale)?e.stale:[];return no&&(no.stale=i),i.length&&document.dispatchEvent(new CustomEvent("edit:stale",{detail:{files:i}})),fo(t?{results:e.results.filter(e=>!(e&&(t.has(e.region)||n&&n.has(e))))}:e)&&(uo(t),r&&function(e,t){const n=mt(ut());Object.entries(e).forEach(([e,r])=>{if(!/\.html?$/i.test(e))return;r=r||{};const o={};new Set(Object.keys(r).map(ot)).forEach(i=>{const s=Object.keys(r).filter(e=>ot(e)===i).sort(st),a=[...n.keys()].filter(t=>ot(t)===i&&(()=>{const r=ce(n.get(t));return r&&le(r)===e})()).sort(st).map(e=>t.has(n.get(e))?t.get(n.get(e)):null),l=s.map(e=>r[e]);!a.includes(null)&&a.some((e,t)=>(at(a,l,t)||[]).length)?bo.add(i):s.forEach(e=>{o[e]=r[e]})}),ho[e]=o})}(r,o)),Bo(),e},n=(e,t)=>{if(!e||!Array.isArray(e.results)||Array.isArray(e.stale)&&e.stale.length)return null;const n=new Set(e.results.filter(e=>e&&null!=e.failed).map(e=>e.failed)),r=new Set(t.filter((t,n)=>e.results[n]&&"error"===e.results[n].status&&null==e.results[n].failed&&"static-tree"!==t.kind));if(!n.size&&!r.size||e.results.some((e,o)=>e&&"error"===e.status&&!n.has(t[o]&&t[o].region)&&!r.has(t[o])))return null;Co(n);const o=e=>r.has(e)||null!=e.region&&n.has(e.region);return t.some(e=>!o(e))?Object.assign(n,{own:r,out:o}):null},r=e=>"theme"===e.kind?"theme|"+(e.scope||"")+"|"+e.var:e.region,o=e=>{const t=ie(e);return t&&t._edit.rendered},i=e=>null!=e.region&&"theme"!==e.kind&&Qr.has(e.region),s=()=>{To(!0);const s=co();if(no&&"function"==typeof no.onPublish)return Promise.resolve(no.onPublish(s,{log:l,cursor:c})).then(t);if(!s.length)return Bo(),Promise.resolve({results:[]});const a=e=>(ko++,fetch("/__edit/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({patches:e,base:mo})}).then(e=>e.json()).catch(e=>{throw qo(null),e})),d=Co(new Set(s.filter(i).map(e=>e.region))),u=e=>({region:e.region,status:"error",reason:Zr.has(e.region)&&i(e)?`x-edit="${e.region}": ${Zr.get(e.region)}`:o(e.region)&&i(e)?`x-edit="${e.region}" is inside content ${o(e.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(e.region)}", which mnfst-run can't write`}),f=s.filter(e=>!d.has(e.region)),m=(n,o,i)=>{const a=new Set([...d,...o||[],...o?i.filter(o.out).map(r):[]]),l=new Set,c=s.map(e=>{if(d.has(e.region)){const t=u(e);return l.add(t),t}const t=n.results[i.indexOf(e)];return o&&o.out(e)&&l.add(t),t}),f=t(Object.assign({},n,{results:c}),a.size?a:void 0,l);return qo(n,!(!e||!e.rebase)),f};if(!f.length){const e=t({results:s.map(u)},d);return Promise.resolve(e)}return a(f).then(e=>{const t=n(e,f);if(!t)return m(e,null,f);qo(e,!1);const r=f.filter(e=>!t.out(e));return a(r).then(n=>{const o=f.map((o,i)=>t.out(o)?e.results[i]&&"error"===e.results[i].status?e.results[i]:{region:o.region,status:"error",reason:`not published: tied by a move to x-edit="${t.via.get(o.region)||[...t].find(e=>!t.via.has(e))}", which failed`}:n.results[r.indexOf(o)]);return m(Object.assign({},n,{results:o}),t,f)})})},a=e=>{const n=co();return n.length?t({results:n.map(t=>({region:t.region,status:"error",reason:e}))}):{results:[]}},d=no&&"function"==typeof no.onPublish||mo&&po?Promise.resolve(null):Eo?Promise.resolve("the source changed before this page could read its base from the dev server; reload to continue"):vo().then(()=>mo&&po?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 e=Object.assign({},mo);return vo(!0).then(()=>(Object.keys(mo||{}).some(t=>/\.html?$/i.test(t)&&e[t]!==mo[t])&&(Do=!0),s()))};return d.then(t=>t?a(t):e&&e.rebase?u():s())}(e));return zo=t.catch(()=>{}),t}let Do=!1;function Wo(){no&&(no.active=!0),ao()}function Fo(){no&&(no.active=!1),re().forEach(e=>{e._edit.gated&&e._armed&&(to(e),e._armed=!1)}),Ko()}function Ko(){no&&(no.canUndo=c>0,no.canRedo=c<l.length,no.version=(no.version||0)+1,xo&&setTimeout(Bo,0))}const Uo=e=>e._editField&&!e._editRich?e.textContent:I(e,e.innerHTML.trim()),Jo=e=>!!e.closest('[data-edit-hotkeys="off"]');function Xo(){const e=document.activeElement;if(!e||void 0===e._preEdit||!e.isContentEditable)return;const t=()=>{document.activeElement===e&&(ur(e),e._preEdit=Uo(e))};t(),setTimeout(t,0)}function Vo(e){if(e.altKey||!e.metaKey&&!e.ctrlKey)return null;const t=(e.key||"").toLowerCase();return"z"===t?e.shiftKey?"redo":"undo":"y"!==t||!e.ctrlKey||e.metaKey||e.shiftKey?null:"redo"}function Yo(e){if(e.defaultPrevented||s)return;const t=Vo(e);if(!t)return;const n="redo"===t,r=e.target&&1===e.target.nodeType?e.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 e=ce(o);if(!e||!io(e)||Jo(o))return}else{if(r.isContentEditable)return;if(!re().some(e=>io(e)&&!Jo(e)))return}r.isContentEditable&&void 0!==r._preEdit&&Uo(r)!==r._preEdit||(n?c>=l.length:0===c)||(e.preventDefault(),n?Nt():$t())}function Go(){if(l.length){if(!ho&&go&&l.some(e=>e.ids||e.id)){const e=go;return go=null,void Promise.race([e,new Promise(e=>setTimeout(e,4e3))]).then(Go,Go)}!function(){const e=e=>("st-move"===e.kind?[e.from,e.to]:null!=e.region?[e.region]:[]).some(e=>{const t=ie(e);return t&&!t._edit.persist});if(!l.some(e))return;let t=0;const n=l.filter((n,r)=>{const o=!e(n);return o&&r<c&&t++,o});l=n,c=t,We++,T()}();for(const[e,t]of Object.entries(Bt())){const n=ie(e);n&&"data"===t.kind&&Qo(n,()=>Je(n,"data",t.snap))}if(l.some(e=>/^st-/.test(e.kind))&&(pt(re()),ht()),l.some(e=>"cmp-main"===e.kind||"cmp-inst"===e.kind)&&Ge(),l.some(e=>"data-val"===e.kind)){const e=re().find(e=>"data"===me(e));e&&Qo(e,yt)}l.some(e=>"theme"===e.kind)&&Jr(),l.some(e=>"lock"===e.kind)&&re().forEach(jt),Ko()}}function Qo(e,t){const n=he(e),r=h(e);let o=0;const i=setInterval(()=>{let e=!1;try{e=Array.isArray(window.Alpine.evaluate(r,n))}catch{}e?(clearInterval(i),t()):++o>100&&clearInterval(i)},50)}let Zo=!1;function ei(){if(Zo||!window.Alpine||!Alpine.directive)return;Zo=!0,document.body&&!document.body.hasAttribute("x-data")&&document.body.setAttribute("x-data","{}"),Alpine.directive("edit",(e,{modifiers:t,expression:n},{cleanup:r})=>{te(e,t,n),ro&&!oo&&(oo=!0,queueMicrotask(()=>{oo=!1,ao()})),r(()=>function(e){Object.keys(Y).forEach(t=>{Y[t]===e&&delete Y[t]}),Br.delete(e),V.has(e)&&(e._armed&&(to(e),e._armed=!1),e._editObserver&&(e._editObserver.disconnect(),e._editObserver=null),V.delete(e),delete e._edit,oe(),e.removeAttribute("data-edit-area"),qt&&(qt===e||e.contains(qt))&&It(null),Ko())}(e))}),Alpine.store("edit",{active:!1,canUndo:!1,canRedo:!1,version:0,stale:[],conflicts:[],onPublish:null,toggle(){this.active?Fo():Wo()},on(){Wo()},off(){Fo()},undo:()=>$t(),redo:()=>Nt(),publish:e=>Io(e),patches:()=>co(),export:()=>JSON.parse(JSON.stringify({log:l,cursor:c})),get target(){return this.version,qt},set target(e){(e=>{It(e&&1===e.nodeType?Wt(e)||e:null)})(e)},can(e,t){return this.version,tn(e,void 0===t?qt:t)},lock:(e,t)=>Mt(void 0===e?qt:e,t,!0),unlock:(e,t)=>Mt(void 0===e?qt:e,t,!1),copy:e=>nn(e),cut:e=>ln(e),paste:e=>cn(e),duplicate:e=>sn(e),remove:e=>an(e),move:(e,t,n)=>function(e,t,n){const r=Wt(null==e?qt:e);if(!r||!Ut(r))return!1;const o=Ft(r),i="string"==typeof t?ie(t):t;if(!i||1!==i.nodeType||i===r||r.contains(i))return!1;const s=ce(i);if(!(o&&s&&io(o)&&io(s)&&Jt(i)))return!1;n&&n.parentElement!==i&&(n=null);const a=r.parentElement;if(!Be(r,i))return!1;if("data"===me(o))return i===a&&($e(r,e=>i.insertBefore(e,n?Re(n):null)),jn(o,i),!0);if("static"!==me(o)||"static"!==me(s))return!1;if(o!==s&&Kt(r)&&!Ee(r))return!1;const l=A(a),c=A(i);return $e(r,e=>i.insertBefore(e,n?Re(n):null)),i===a?Et(o,i,l):(wt(o,s,r,a,l,c),!0)}(e,t,n),nest(e){const t=Wt(void 0===e?qt:e);return!!t&&Ut(t)&&qn(t)},unnest(e){const t=Wt(void 0===e?qt:e);return!!t&&Ut(t)&&zn(t)},block:e=>Dt(e),attr:(e,t,n)=>Lr(e,t,n),classes:Pr,scope(e,t){return this.version,e&&1===e.nodeType?$r(e):null==e?$r(t):function(e,t){const n=Rr(null==t?qt:t);return!(!n||"instance"!==e&&"main"!==e||(n._editScope=e,zt(),0))}(e,t)},revert:e=>Nr(e),clearConflicts(){_=[],this.conflicts=[],T()}}),no=Alpine.store("edit");const n=()=>Alpine.store("edit");Alpine.magic("edit",n),window.__manifestEditMagic=n;const r=window.__manifestEditStubWrites;r&&Object.keys(r).forEach(e=>{try{no[e]=r[e]}catch{}delete r[e]}),window.__manifestEditStub&&setTimeout(()=>{window.__manifestEditStub.v++},0),(()=>{try{t=location.pathname;const n=JSON.parse(localStorage.getItem(e(t)));n&&8===n.v?(l=n.log||[],c=n.cursor??l.length,l.forEach(e=>u.add(e)),_=Array.isArray(n.conflicts)?n.conflicts:[],_.forEach(e=>x.add(e)),no&&(no.conflicts=_.slice())):n&&localStorage.removeItem(e(t))}catch{}})(),window.__mnfstEdit&&vo(),setTimeout(()=>{const e=()=>{ao(),Go()};if(!ho&&go&&l.some(e=>e.ids||e.id)){const t=go;go=null,Promise.race([t,new Promise(e=>setTimeout(e,4e3))]).then(e,e)}else e()},450),document.addEventListener("keydown",Yo),window.addEventListener("click",ir,!0),window.addEventListener("auxclick",ir,!0),document.addEventListener("contextmenu",un,!0),document.addEventListener("dropdown:context",un,!0),window.addEventListener("manifest:route-change",()=>{t!==location.pathname&&(t=location.pathname,T())}),function(){if(!window.__manifestAlpineStarted&&![...document.querySelectorAll("[x-data]")].some(e=>e._x_marker))return;const e=e=>/^x-edit(\.|$)/.test(e),t=[...document.querySelectorAll("*")].filter(t=>!t._edit&&[...t.attributes].some(t=>e(t.name)));t.forEach(t=>{t._x_marker&&[...t.attributes].filter(t=>e(t.name)).forEach(e=>t.setAttribute(e.name,e.value))}),t.some(e=>!e._x_marker)&&Alpine.initTree(document.body)}()}document.addEventListener("alpine:init",ei),window.Alpine&&Alpine.directive&&setTimeout(ei,0)}();
|
|
1
|
+
!function(){const e=e=>"mnfst-edit-log:"+(e||location.pathname);let t=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=e=>[...e.attributes].some(e=>{const t=e.name.toLowerCase();return f.some(e=>t===e||t.startsWith(e+"."))}),p=new Set(["SCRIPT","STYLE","TEXTAREA","TITLE","NOSCRIPT","TEMPLATE","XMP","IFRAME","NOEMBED","NOFRAMES"]),h=e=>[...e.children].find(e=>"TEMPLATE"===e.tagName&&e.hasAttribute("x-for"))||null;function g(e){if(m(e))return"";let t="";for(const n of e.childNodes)3===n.nodeType?t+=n.textContent:1!==n.nodeType||be(n)||"TEMPLATE"===n.tagName||k(n)||n._manifestComponent||(t+=g(n));return t}const b=e=>e.tagName.toUpperCase()+":"+g(e).replace(/\s+/g," ").trim().slice(0,24),y=(e,t)=>"@"+encodeURIComponent(e)+"@"+t,v=e=>e&&"~"===e[0]?e.slice(e.indexOf("~",1)+1):e;let E=0;const w=()=>Date.now().toString(36)+(++E).toString(36)+Math.random().toString(36).slice(2,6);function k(e){for(let t=e.previousElementSibling;t;t=t.previousElementSibling){if("TEMPLATE"!==t.tagName)continue;if(t._x_currentIfEl===e)return!0;const n=t._x_lookup;if(n&&(n instanceof Map?[...n.values()]:Object.values(n)).includes(e))return!0}return!1}function A(e){const t=Object.create(null);return Ae(e).map(e=>{const n=e.getAttribute("data-edit-host")||e.getAttribute("data-edit-key");if(n)return n;const r=b(e),o=t[r]=(t[r]||0)+1;return o>1?r+"#"+o:r})}let _=[];const x=new WeakSet,S=new Set([location.pathname]),T=t=>{if(l.length>400){const e=l.length-400;l.splice(0,e),c=Math.max(0,c-e)}const n=l.slice(0,c).filter(e=>u.has(e)),r=l.slice(c).filter(e=>u.has(e));S.add(t||location.pathname);const o=_.filter(e=>x.has(e));(t?[t]:[...S]).forEach(t=>{try{n.length||r.length||o.length?localStorage.setItem(e(t),JSON.stringify(Object.assign({v:8,log:[...n,...r],cursor:n.length},o.length?{conflicts:o}:{}))):localStorage.removeItem(e(t))}catch{}})},C=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function O(e,t){for(let n=e;n&&1===n.nodeType;n=n.parentElement){const e=getComputedStyle(n).getPropertyValue(t).trim();if(e)return e}return""}function L(e,t,n){const r=O(e,t);return r?"none"===r&&"--edit-size"!==t?n??"":r:n??""}function M(e,t){if(!t&&!/--rich-text-/.test(e))return e;const n=document.createElement("div");n.setAttribute("style",e),t&&n.style.removeProperty("position");const r=[];for(let e=0;e<n.style.length;e++)r.push(n.style.item(e));return r.filter(e=>e.startsWith("--rich-text-")).forEach(e=>n.style.removeProperty(e)),n.getAttribute("style")||""}const j=e=>M(e.getAttribute("style")||"",!!e._editPos),P=e=>e?e.tagName.toLowerCase():"",R=new Set(["B","I","EM","STRONG","U","S","SMALL","CODE","MARK","SUB","SUP","BR","SPAN","A"]),$=e=>!!e&&1===e.nodeType&&e.hasAttribute("data-rich-text")&&!e._editRt,N=e=>window.ManifestRichText.sanitize(e,!1,!0);let B=!1;const H=e=>{const t=document.createTreeWalker(e,NodeFilter.SHOW_COMMENT),n=[];for(let e=t.nextNode();e;e=t.nextNode())n.push(e);return n},q=(e,t)=>!(X(t.name,t.value,e.tagName)||"style"===t.name&&/expression|url\s*\(|javascript:|@import/i.test(t.value));function z(e){const t=Ne.interactive.join(","),n=!!e.closest("a, button");return[...e.querySelectorAll(t)].forEach(r=>{const o=r.parentElement&&r.parentElement.closest(t);(n||o&&e.contains(o))&&r.replaceWith(...r.childNodes)}),e.innerHTML.trim()}const I=(e,t)=>window.ManifestRichText?$(e)?window.ManifestRichText.sanitize(t,!0,!0):function(e,t){const n=document.createElement("template");n.innerHTML=String(null==e?"":e);const r=[],o="mnfst"+Math.random().toString(36).slice(2)+Date.now().toString(36),i=new RegExp("("+o+"\\d+_)");if(H(n.content).forEach(e=>{if(t=e.data,!/^-?>|-->|--!>|<!-$/.test(t))return e.replaceWith(o+r.length+"_"),void r.push(e.data);var t;e.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 e=document.createTreeWalker(n.content,NodeFilter.SHOW_TEXT),t=[];for(let n=e.nextNode();n;n=e.nextNode())n.nodeValue.includes(o)&&t.push(n);t.forEach(e=>e.replaceWith(...e.nodeValue.split(i).filter(Boolean).map(e=>i.test(e)&&e.startsWith(o)?document.createComment(r[parseInt(e.slice(o.length),10)]):document.createTextNode(e))))}!function(e){const t=e=>{let t=e.lastChild;for(;t&&8===t.nodeType;)t=t.previousSibling;return t};for(let n=0;n<1e3;n++){let n=t(e);for(;n&&1===n.nodeType&&"BR"!==n.tagName&&t(n);)n=t(n);if(!n||n===e)return;if(!(3===n.nodeType?!n.nodeValue.trim():"BR"===n.tagName||!t(n)&&!/^(IMG|WBR)$/.test(n.tagName)))return;n.remove()}}(n.content),n.content.querySelectorAll("*").forEach(e=>[...e.attributes].forEach(t=>{q(e,t)||e.removeAttribute(t.name)}));const s=Ne.interactive.join(","),a=!!(t&&t.closest&&t.closest("a, button"));return[...n.content.querySelectorAll(s)].forEach(e=>{(a||e.parentElement&&e.parentElement.closest(s))&&e.replaceWith(...e.childNodes)}),n.content.querySelectorAll("a").forEach(e=>{e.textContent.trim()||e.querySelector("img")||e.replaceWith(...e.childNodes)}),n.innerHTML.trim()}(t,e):function(e){const t=document.createElement("template");t.innerHTML=String(null==e?"":e);const n=e=>[...e.childNodes].forEach(e=>{if(8===e.nodeType)return e.remove();1===e.nodeType&&(R.has(e.tagName)?([...e.attributes].forEach(t=>{const n=t.name.toLowerCase();("A"!==e.tagName||"href"!==n||X("href",t.value,"A"))&&e.removeAttribute(t.name)}),n(e)):e.replaceWith(document.createTextNode(e.textContent)))});return n(t.content),t.innerHTML}(t);function D(e,t){const n=I(e,t);e.innerHTML===n||$(e)&&I(e,e.innerHTML.trim())===n||(e.innerHTML=n,e._rt&&"function"==typeof e._rt.settle&&e._rt.settle())}const W={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" ",tab:"\t",newline:"\n",colon:":"},F=e=>String(e).replace(/&(#x[0-9a-f]+|#\d+|[a-z]+);?/gi,(e,t)=>{if("#"===t[0]){const n=/^#x/i.test(t)?parseInt(t.slice(2),16):parseInt(t.slice(1),10);return n>=0&&n<1114112?String.fromCodePoint(n):e}const n=W[t.toLowerCase()];return void 0===n?e: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(e,t,n){const r=String(e||"").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==t)return null;for(const e of[String(t),F(t)]){const t=e.replace(/[\u0000-\u0020\u007f]/g,"").toLowerCase();if(/(^|[,(;'"=])(javascript|vbscript):/.test(t))return"script URL";const n=t.match(/(^|[,(;'"=])data:[^,)]*/g)||[];if(n.length&&("img"!==o&&"source"!==o||"src"!==r&&"srcset"!==r||!n.every(e=>J.test(e.replace(/^[,(;'"=]/,"")))))return"data URL"}return null}const V=new Set,Y={},G=new Set,Q=e=>{const t=ce(e);for(let n=e&&e.parentElement;n;n=n.parentElement){if(m(n))return!0;if(n===t)break}return!1},Z=f.filter(e=>"x-code-group"!==e&&"x-carousel"!==e&&"x-defer"!==e);function ee(e){for(let t=e&&e.parentElement;t;t=t.parentElement){if(1!==t.nodeType)continue;const e=[...t.attributes].map(e=>e.name.toLowerCase()).find(e=>Z.some(t=>e===t||e.startsWith(t+".")));if(e)return e.split(".")[0]}return null}function te(e,t,s){if(t.includes("cssvar"))return function(e,t,n){const r=(t||"").trim(),o=r.match(/^([\w-]+)\s*:\s*(--[\w-]+)$/);e._cssvar=o?{scope:o[1],var:o[2]}:{scope:null,var:r},e._cssvar.persist=!(!n||!n.includes("persist")),Br.add(e)}(e,s,t);if(t.forEach(e=>{i[e]&&!G.has(e)&&(G.add(e),console.warn(`[edit] x-edit.${e} was removed — use ${i[e]}`))}),t.includes("grab"))return;if(t.includes("lock")){const n=t.filter(e=>o.includes(e));return void(e._editLock=new Set(n.length?n:["*"]))}const l=new Set(n.filter(e=>t.includes(e))),c=t.includes("theme"),d=(s||"").trim()||"area-"+ ++a;if(c&&(Y[d]=e),c&&!l.size)return void(t.includes("persist")&&(e._editPersist=!0));l.size||r.forEach(e=>l.add(e)),(s||"").trim()&&[...V].some(t=>t!==e&&t._edit&&t._edit.key===d)&&console.warn("[edit] duplicate x-edit key (deltas will mis-route):",d);const u=t.includes("bare");e._edit={key:d,caps:l,gated:t.includes("gated"),theme:c,persist:t.includes("persist"),bare:u,rendered:ee(e)},e.setAttribute("data-edit-area",u?"bare":""),V.add(e),oe()}let ne=null;const re=()=>ne||(ne=[...V].filter(e=>{for(let t=e;t;t=t.parentElement){if(t!==e&&t._edit)return!1;if(t._manifestComponent||t!==e&&m(t))return!0}return!0})),oe=()=>{ne=null},ie=e=>re().find(t=>t._edit.key===e),se=e=>re().filter(t=>t._edit.key===e._edit.key).length>1;function ae(e){if(void 0!==e._editSrc)return e._editSrc;let t=null;for(let n=e;n;n=n.parentElement){if(!n._manifestComponent)continue;const r=n===e&&window.ManifestComponentsLoader&&window.ManifestComponentsLoader.cache[n._manifestComponent],o=new RegExp("\\sx-edit(?:\\.[\\w-]+)*\\s*=\\s*([\"'])"+e._edit.key.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"\\1");(n!==e||r&&o.test(r))&&(t=n._manifestComponent);break}return e._editSrc=t}const le=e=>{const t=ae(e);return t?function(e){const t=window.ManifestComponentsRegistry&&window.ManifestComponentsRegistry.manifest||{},n=[...t.preloadedComponents||[],...t.components||[]].find(t=>String(t).split("/").pop().replace(".html","")===e);return String(n||"components/"+e+".html").replace(/^\/+/,"")}(t):"index.html"},ce=e=>e&&re().reduce((t,n)=>n!==e&&!n.contains(e)||t&&!t.contains(n)?t:n,null),de=e=>e._edit.key,ue=(e,t)=>{const n=function(e){for(let t=e;t;t=t.parentElement)if(t._edit)return t._edit;return null}(e);return!!n&&n.caps.has(t)&&!Lt(e,t)},fe=e=>{const t=null!=e&&ie(e);return!(!t||!t._edit.persist)};function me(e){return h(e)?"data":e.matches("[data-component]")&&!ae(e)||pe(e)?"component":"static"}const pe=e=>{const t=ke(e).filter(e=>"TEMPLATE"!==e.tagName),n=t[0];return 1!==t.length||!n.matches("[data-component]")||n._edit||n.querySelector("[data-edit-area]")?null:n};function he(e){const t=h(e),n=t&&t.getAttribute("x-for").match(/\bin\s+(.+)$/);return n?n[1].trim():null}const ge=e=>{const t=he(e),n=t&&t.match(/\$x\.(\w+)/);return n?n[1]:t||"source"},be=e=>e.hasAttribute("data-edit-handle")||e.hasAttribute("data-edit-ghost"),ye=e=>e&&e._manifestHost&&e._manifestHost.roots&&e._manifestHost.roots[0]===e?e._manifestHost.roots.slice():[e],ve=e=>!!e._manifestHost&&!!e._manifestHost.roots&&e._manifestHost.roots[0]!==e,Ee=e=>!!e&&1===e.nodeType&&e.hasAttribute("data-edit-host"),we=e=>e.getAttribute("data-edit-host")||e.getAttribute("data-edit-key"),ke=e=>Array.from(e.children).filter(e=>!be(e)&&!ve(e)),Ae=e=>ke(e).filter(e=>"TEMPLATE"!==e.tagName);let _e=!1;function xe(e,t){const n=e.getAttribute("data-key");if(null!=n)return n;const r=h(t),o=r&&r._x_keyExpression;if(o)try{const t=window.Alpine.evaluate(e,o);if(null!=t)return String(t)}catch{}return _e||(_e=!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 Se=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"]),Te=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"]),Ce=new Set([...Se,"LI","TD","TH"]);function Oe(e){if(!window.ManifestRichText)return!1;const t=e.cloneNode(!0);return t.querySelectorAll("[data-edit-handle], [data-edit-ghost]").forEach(e=>e.remove()),H(t).forEach(e=>e.remove()),!t.children.length||(t.querySelectorAll("*").forEach(e=>[...e.attributes].forEach(t=>{t.name.startsWith("data-edit-")&&e.removeAttribute(t.name)})),N(t.innerHTML)===t.innerHTML&&[...t.querySelectorAll("*")].every(e=>[...e.attributes].every(t=>q(e,t))))}const Le=e=>Ce.has(e.tagName)&&ke(e).length>0&&!!e.textContent.trim()&&Oe(e),Me=e=>{for(let t=e&&e.parentElement;t&&1===t.nodeType;t=t.parentElement){if(t._editRtFormat)return t;if(t._edit)break}return null};function je(e){return!(!e||1!==e.nodeType||Te.has(e.tagName)||be(e)||(e=>Se.has(e.tagName)||e.hasAttribute("data-rich-text")||(e=>[...e.childNodes].some(e=>3===e.nodeType&&e.textContent.trim()))(e)||Le(e))(e))}function Pe(e){const t=[];let n=e.previousSibling;for(;;){let e=null;if(n&&3===n.nodeType){if(!/^[ \t]*(\r?\n)?[ \t]*$/.test(n.textContent))break;e=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;t.unshift(n,...e?[e]:[]),n=n.previousSibling}return t}const Re=e=>e?Pe(e)[0]||e:null;function $e(e,t){const n=Pe(e),r=ye(e).slice(1);t(e),n.length&&e.before(...n),r.length&&e.after(...r)}const Ne={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 Be(e,t){if(!e||!t)return!1;if(e.parentElement===t)return!0;const n=[];for(let e=t;e&&1===e.nodeType;e=e.parentElement)n.push(e.tagName.toLowerCase());const r=new Set,o=e=>[e,...e.querySelectorAll("*")].forEach(e=>{1===e.nodeType&&(r.add(e.tagName.toLowerCase()),"TEMPLATE"===e.tagName&&e.content&&[...e.content.children].forEach(o))});ye(e).forEach(o);const i=new Set;for(let e=t;e;e=e.parentElement)e._manifestComponent&&i.add(e._manifestComponent);return!(i.size&&ye(e).some(e=>[e,...e.querySelectorAll("*")].some(e=>e._manifestComponent&&i.has(e._manifestComponent)))||function(e,t,n,r){const o=Ne;return o.only[t]&&!o.only[t].includes(e)?`<${t}> takes only ${o.only[t].filter(e=>"script"!==e&&"template"!==e&&"style"!==e).join(", ")}`:o.parent[e]&&!o.parent[e].includes(t)?`<${e}> belongs in ${o.parent[e].join(" or ")}`:"dt"!==e&&"dd"!==e||"div"!==t||"dl"===n[1]?r.has("form")&&n.includes("form")?"a form cannot contain a form":(n.includes("a")||n.includes("button"))&&o.interactive.some(e=>r.has(e))?"interactive content cannot go inside a link or button":o.phrasingOnly.includes(t)&&o.block.some(e=>r.has(e))?`<${t}> takes only inline content`:null:`<${e}> belongs in a dl`}(e.tagName.toLowerCase(),t.tagName.toLowerCase(),n,r))}const He=e=>{const t=String(e||"").match(/[a-z%]+$/i);return t?t[0]:null};function qe(e,t,n,r,o){if("rem"===t)return+(e/parseFloat(getComputedStyle(document.documentElement).fontSize)).toFixed(2);if("em"===t)return+(e/parseFloat(getComputedStyle(n).fontSize)).toFixed(2);if("%"===t){const t=(r||n.parentElement).getBoundingClientRect(),i="w"===o?t.width:t.height;return i?+(e/i*100).toFixed(2):0}return Math.round(e)}function ze(e,t,n){const r=parseFloat(e);if(isNaN(r))return null;const o=He(e)||"px";if("rem"===o)return r*parseFloat(getComputedStyle(document.documentElement).fontSize);if("em"===o)return r*parseFloat(getComputedStyle(t).fontSize);if("%"===o){const e=(t.parentElement||t).getBoundingClientRect();return r/100*("h"===n?e.height:e.width)}return r}const Ie=(e,t,n)=>Math.min(Math.max(e,t),n),De="∅revert";let We=0;const Fe=new WeakMap;function Ke(e,t){return l.splice(c),l.push(e),c=l.length,We++,void 0===t&&(t=function(e){return"data-splice"!==e.kind&&"show"!==e.kind&&("st-move"===e.kind?fe(e.from)&&fe(e.to):null!=e.region&&fe(e.region))}(e)),t&&u.add(e),T(),Ko(),e}function Ue(e,t){return"data"===t?{source:ge(e),order:Ae(e).map(t=>xe(t,e))}:{}}async function Je(e,t,n){e&&n&&("data"===t&&Xe(e,n.order),io(e)&&eo(e))}function Xe(e,t){const n=he(e),r=h(e);try{const e=window.Alpine.evaluate(r,n);if(!Array.isArray(e))return;const o=new Map(e.map(e=>[String(e.id),e])),i=t.map(e=>o.get(String(e))).filter(Boolean);e.forEach(e=>{t.map(String).includes(String(e.id))||i.push(e)}),e.splice(0,e.length,...i)}catch{}}function Ve(){const e={},t={},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)e[i.component]=e[i.component]||{},(e[i.component][i.path]=e[i.component][i.path]||{})[i.prop]=i.value;else if("cmp-inst"===i.kind){const e=i.region;i.value===De?(n[e]=n[e]||new Set,"*"===i.path?(delete t[e],n[e]=new Set(["*"])):(t[e]&&delete t[e][i.path],n[e].add(i.path))):(t[e]=t[e]||{},(t[e][i.path]=t[e][i.path]||{})[i.prop]=i.value,n[e]&&(n[e].delete(i.path),n[e].delete("*")))}}return{main:e,inst:t,reverts:n,sigs:r}}const Ye=e=>[e,...e.querySelectorAll("*")].filter(e=>null!=e._editPath);function Ge(){const{main:e,inst:t,sigs:n}=Ve();re().forEach(r=>{if("component"!==me(r))return;const o=vr(r),i=de(r),s=pe(r);s&&Ye(s).forEach(s=>{const a=s._editPath,l=n[o+"|"+a];if(l&&P(s)!==l)return void console.warn("[edit] skip stale node (structure changed):",o,a);const c=t[i]&&t[i][a]||{},d=e[o]&&e[o][a]||{},u=r._baseText||{},f=r._baseClass||{},m=r._baseStyle||{},p=(e,t)=>void 0!==c[e]?c[e]:void 0!==d[e]?d[e]:t,h=p("text",u[a]),g=p("class",f[a]),b=p("style",m[a]);void 0!==h&&D(s,h),void 0!==g&&Cr(s,g),void 0!==b&&s.getAttribute("style")!==b&&(""===b?s.removeAttribute("style"):s.setAttribute("style",b))})})}function Qe(e,t,n,r,o){const i=t._editPath,s=e._editScope||"instance",a=vr(e),l=de(e);if(null==i)return!1;if("text"===n&&(r=I(t,r)),void 0===o&&(o="text"===n?t._preEdit:"style"===n?t._preStyle:t._preClass),o===r||"text"===n&&null!=o&&I(t,o)===r)return!1;const c=P(t);return Ke("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}),Ge(),!0}function Ze(){const e={},t={},n={},r={},o={},i={},s=(e,t,n,r,o)=>{if(!r)return;const i=e[t]=e[t]||{},s=n||"";o&&s in i||(i[s]=r.slice())};for(let e=0;e<l.length;e++){const t=l[e];if("st-children"===t.kind)t.html&&Object.assign(i,t.html),s(n,t.region,t.parent,t.before,!0);else if("st-order"===t.kind)s(n,t.region,t.parent,t.before,!0);else if("st-move"===t.kind)s(n,t.from,t.fromParent,t.fromBefore,!0),s(n,t.to,t.toParent,t.toBefore,!0);else if("st-node"===t.kind){const e=o[t.path]=o[t.path]||{};t.prop in e||(e[t.prop]=t.before),t.sig&&(r[t.path]=t.sig)}}const a=new Set;for(let n=0;n<c;n++){const r=l[n];"st-node"===r.kind?(e[r.path]=e[r.path]||{})[r.prop]=r.value:"st-order"===r.kind||"st-children"===r.kind?(s(t,r.region,r.parent,r.order),a.add(r.parent||"#"+r.region),r.copies&&Object.entries(r.copies).forEach(([t,n])=>{e[t]=Object.assign({},n,e[t])})):"st-move"===r.kind&&(s(t,r.from,r.fromParent,r.fromOrder),s(t,r.to,r.toParent,r.toOrder),a.add(r.fromParent||"#"+r.from),a.add(r.toParent||"#"+r.to))}return{node:e,order:t,orderBase:n,sigs:r,base:o,html:i,touched:a}}function et(e,t,n,r){Ke({kind:"data-splice",region:de(e),source:ge(e),index:t,op:r,record:JSON.parse(JSON.stringify(n))}),setTimeout(()=>{d[de(e)]=Ue(e,me(e))},0)}const tt=(e,t)=>e===t?"":e.getAttribute("data-edit-key")||"";function nt(e,t,n,r,o){const i=A(t);if(C(n,i)&&!Object.keys(r||{}).length)return;const s={kind:"st-children",region:de(e),parent:tt(t,e),order:i,before:n,html:r||{}};o&&Object.keys(o).length&&(s.copies=o),ct(s,[...n,...i.filter(e=>"~"===e[0]).map(v)]),Ke(s)}function rt(e,t){l.forEach(n=>{t&&!t(n)||(["before","order","fromBefore","toBefore","fromOrder","toOrder","unsure"].forEach(t=>{var r;n[t]&&(n[t]=(r=n[t],Array.isArray(r)?r.map(e):r))}),["parent","fromParent","toParent","key","path"].forEach(t=>{"string"==typeof n[t]&&(n[t]=e(n[t]))}),n.html&&(n.html=Object.fromEntries(Object.entries(n.html).map(([t,n])=>[e(t),"string"==typeof n?n.replace(/data-edit-key="([^"]*)"/g,(t,n)=>`data-edit-key="${(e=>e.replace(/&/g,"&").replace(/"/g,"""))(e((e=>e.replace(/"/g,'"').replace(/&/g,"&"))(n)))}"`):n]))),n.copies&&(n.copies=Object.fromEntries(Object.entries(n.copies).map(([t,n])=>[e(t),n]))))})}const ot=e=>String(e).replace(/#\d+$/,""),it=e=>{const t=/#(\d+)$/.exec(e);return t?+t[1]:1},st=(e,t)=>it(e)-it(t);function at(e,t,n){const r=e[n];if(null==r||null==t[n]||t[n]===r||e.some((e,t)=>t!==n&&e===r))return null;if(t.length===e.length)return t.map((e,t)=>t).filter(o=>o!==n&&null!=e[o]&&t[o]===r&&t[o]!==e[o]);const o=[];for(let r=-n;r<t.length-n;r++){if(!r)continue;let i=!0;for(let o=n;o<e.length&&i;o++)i=o+r>=0&&o+r<t.length&&(null==e[o]||t[o+r]===e[o]);i&&(!e.includes(null)||n+r<e.length&&null!=e[n+r])&&o.push(n+r)}return o}const lt=e=>"string"==typeof e&&"@"===e[0]&&(/#\d+$/.test(e)||mt(ut()).has(e+"#2"));function ct(e,t){const n={},r=new Set;return t.forEach(e=>{if(!lt(e)||n[e])return;const t=v(e),o=ie(decodeURIComponent(t.slice(1,t.indexOf("@",1)))),i=o&&le(o),s=ho&&i&&ho[i];bo.has(ot(t))?r.add(t):s&&Object.keys(s).forEach(e=>{ot(e)===ot(t)&&(n[e]=s[e])})}),Object.keys(n).length&&(e.ids=n),r.size&&(e.unsure=[...r]),e}const dt=(e,t)=>{if(!e)return null;const n=document.createElement("template");n.innerHTML=e.trim();const r=n.content.firstElementChild;return r&&t&&r.setAttribute(/^[^@]*@[^@]*@X-[\w-]+:/.test(v(t))?"data-edit-host":"data-edit-key",t),r},ut=()=>re().filter(e=>"static"===me(e)&&!se(e)),ft=new Map;function mt(e){const t=new Map;return e.forEach(e=>[e,...e.querySelectorAll("[data-edit-key]")].forEach(e=>{if(e.closest("[data-edit-ghost]"))return;const n=e.getAttribute("data-edit-key");null==n||t.has(n)||t.set(n,e)})),e.forEach(e=>e.querySelectorAll("[data-edit-host]").forEach(e=>{const n=e.getAttribute("data-edit-host");t.has(n)||t.set(n,e)})),t}function pt(e){const t=mt(ut()),n=[],r=new Set(e.filter(e=>e._marked).map(de)),o=e=>r.has(e)&&!!ie(e)&&"static"===me(ie(e)),i=new Map,s=new Map,a=new Map,d=[],u={},f=e=>"string"==typeof e&&/^[0-9a-f]{12}$/.test(e);l.forEach(e=>{e.ids&&Object.entries(e.ids).forEach(([e,t])=>{!(e in u)&&f(t)&&(u[e]=t)})});const m=ot,p=(e,t=u[e])=>{if(!f(t))return null;const n=Object.keys(u).filter(t=>m(t)===m(e)).sort(st),r=n.indexOf(e);if(r<0)return null;const o=ie(g(e)),i=ho&&o&&ho[le(o)],s=Object.keys(i||{}).filter(t=>m(t)===m(e)).sort(st),a=at(n.map(n=>n===e?t:u[n]),s.map(b),r);return a&&a.map(e=>s[e])},h=new Set;l.forEach(e=>(e.unsure||[]).forEach(e=>h.add(e)));const g=e=>decodeURIComponent(e.slice(1,e.indexOf("@",1))),b=e=>"string"==typeof e&&"@"===e[0]&&r.has(g(e))&&t.has(e)?yo(e):null,y=(e,t,n)=>{const r=JSON.stringify([e,t]);!i.has(r)&&o(e)&&i.set(r,[e,t,n||[]])};l.forEach(e=>{"st-order"!==e.kind&&"st-children"!==e.kind||y(e.region,e.parent,e.before),"st-move"===e.kind&&(y(e.from,e.fromParent,e.fromBefore),y(e.to,e.toParent,e.toBefore))});const E=e=>String(e).slice(String(e).indexOf("@",1)+1).split(":")[0],w=(e,t)=>{const n=new Set,r=(e,t)=>{t=t||[],(e=e||[]).forEach(e=>{t.includes(e)||n.add(e)}),t.forEach(t=>{e.includes(t)||n.add(t)});const r=t.filter(t=>e.includes(t)).map(t=>e.indexOf(t)),o=[],i=new Array(r.length).fill(-1);r.forEach((e,t)=>{let n=0,s=o.length;for(;n<s;){const t=n+s>>1;r[o[t]]<e?n=t+1:s=t}n>0&&(i[t]=o[n-1]),o[n]=t});const s=new Set;for(let e=o.length?o[o.length-1]:-1;e>=0;e=i[e])s.add(e);t.filter(t=>e.includes(t)).forEach((e,t)=>{s.has(t)||n.add(e)})};return l.forEach(o=>{"st-order"!==o.kind&&"st-children"!==o.kind||o.region!==e||(o.parent||"")!==t||r(o.before,o.order),"st-move"===o.kind&&(o.from===e&&(o.fromParent||"")===t&&(n.add(o.key),r(o.fromBefore,o.fromOrder)),o.to===e&&(o.toParent||"")===t&&(n.add(o.key),r(o.toBefore,o.toOrder)))}),n};i.forEach(([e,n,r])=>{let o=""===n?ie(e):t.get(n),i=null;if(!o&&""!==n){const e=new Set(r.map(e=>t.get(e)).filter(Boolean).map(e=>e.parentElement));1===e.size&&(o=[...e][0],i=o.getAttribute("data-edit-key"))}const c=o?A(o):[],f=[...w(e,n)].filter(e=>"string"==typeof e&&"@"===e[0]),g=f.filter(e=>h.has(e)),b=f.filter(e=>{const t=p(e);return t&&t.length});if(g.length||b.length){const t=Object.keys(u).filter(e=>m(e)&&r.includes(e)&&(p(e)||[]).length);let o=g.length||i||c.join("\n")!==r.join("\n")||!((e,t)=>l.every(n=>{if("st-move"===n.kind)return!(n.from===e&&(n.fromParent||"")===t||n.to===e&&(n.toParent||"")===t);if("st-order"!==n.kind&&"st-children"!==n.kind||n.region!==e||(n.parent||"")!==t)return!0;if("st-order"===n.kind||n.order.some(e=>"@"!==e[0]))return!1;let r=0;for(const e of n.before)e===n.order[r]&&r++;return r===n.order.length}))(e,n)?null:new Map;if(o)for(const e of t){const n=p(e).filter(e=>t.includes(e));if(1!==n.length){o=null;break}o.set(e,n[0])}return o&&new Set(o.values()).size===t.length?void d.push([e,n,c,o]):void s.set(e,[...s.get(e)||[],{container:n,changed:[...new Set([...b,...g])].map(e=>{const t=e.slice(e.indexOf("@",1)+1);return{was:t,now:t}})}])}if(o&&c.join("\n")===r.join("\n")&&!i)return;const y=[];r.forEach((e,t)=>{c[t]!==e&&y.push({was:e,now:c[t]??null})}),c.slice(r.length).forEach(e=>y.push({was:null,now:e}));const k=w(e,n),_=!!o&&c.length===r.length&&r.every((e,t)=>E(e)===E(c[t])),x=new Set;l.forEach(e=>[e.before,e.order,e.fromBefore,e.toBefore,e.fromOrder,e.toOrder].forEach(e=>Array.isArray(e)&&e.forEach(e=>x.add(e))));const S=e=>{const t=e.cloneNode(!1);return[...t.attributes].forEach(e=>{/^(data-edit-|data-rich-text|contenteditable$|role$|aria-multiline$|tabindex$)/.test(e.name)&&t.removeAttribute(e.name)}),t.outerHTML.replace(/<\/[^>]+>$/,"")},T=e=>!!e.was&&!!e.now&&"@"===e.was[0]&&!t.has(e.was)&&!x.has(e.now)&&(()=>{const n=(e=>{for(const t of l)if("st-children"===t.kind&&t.html)for(const[n,r]of Object.entries(t.html))if("~"===n[0]&&v(n)===e){const e=document.createElement("template");e.innerHTML=r;const t=e.content.firstElementChild;if(t)return S(t)}return null})(e.was),r=t.get(e.now);return!n||!r||n===S(r)})();if(_&&y.every(e=>T(e)&&!k.has(e.was))){const t=a.get(e)||new Map;y.forEach(e=>t.set(e.was,e.now)),i&&i!==n&&t.set(n,i),a.set(e,t)}else s.set(e,[...s.get(e)||[],{container:n,changed:y.map(e=>({was:e.was&&E(e.was)&&e.was.slice(e.was.indexOf("@",1)+1),now:e.now&&e.now.slice(e.now.indexOf("@",1)+1)}))}])});const k=new Map;l.forEach(e=>{const t="st-move"===e.kind?e.to:e.region;[e.order,e.toOrder,e.fromOrder,e.before,Object.keys(e.html||{})].forEach(e=>Array.isArray(e)&&e.forEach(e=>{if("string"!=typeof e||"~"!==e[0])return;const n=v(e);k.has(n)||k.set(n,new Set),k.get(n).add(t)}))});const S=new Map;k.forEach((e,n)=>{if(!r.has(g(n)))return;const i=h.has(n)?null:p(n);if(i&&!i.length)return;if(i&&1===i.length&&t.has(i[0]))return void S.set(n,i[0]);if(!i&&!h.has(n))return;const a=n.slice(n.indexOf("@",1)+1);e.forEach(e=>{o(e)&&s.set(e,[...s.get(e)||[],{container:"",changed:[{was:a,now:a}],copy:!0}])})}),S.size&&(rt(e=>"string"==typeof e&&"~"===e[0]&&S.has(v(e))?e.slice(0,e.length-v(e).length)+S.get(v(e)):e,e=>!s.has("st-move"===e.kind?e.to:e.region)),We++),d.forEach(([e,t,n,r])=>{if(s.has(e))return;const o=e=>"string"==typeof e&&r.has(e)?r.get(e):e;let i=n.slice();l.forEach(n=>{if("st-children"===n.kind&&n.region===e&&(n.parent||"")===t){const e=n.before.filter(e=>!n.order.includes(e)).map(o);n.before=i.slice(),i=i.filter(t=>!e.includes(t)),n.order=i.slice(),n.html&&(n.html=Object.fromEntries(Object.entries(n.html).map(([e,t])=>[o(e),"string"==typeof t?t.replace(/data-edit-key="([^"]*)"/g,(e,t)=>`data-edit-key="${(e=>e.replace(/&/g,"&").replace(/"/g,"""))(o((e=>e.replace(/"/g,'"').replace(/&/g,"&"))(t)))}"`):t])))}n.ids&&n.region===e&&(n.ids=Object.fromEntries(Object.entries(n.ids).map(([e,t])=>[o(e),t]))),"st-node"===n.kind&&n.region===e&&"string"==typeof n.path&&(n.path=o(n.path)),"lock"===n.kind&&n.region===e&&(n.key=o(n.key))}),We++}),a.forEach((e,n)=>{if(s.has(n))return;const r=t=>"string"!=typeof t?t:e.has(t)?e.get(t):"~"===t[0]&&e.has(v(t))?t.slice(0,t.length-v(t).length)+e.get(v(t)):t,o=e=>Array.isArray(e)?e.map(r):e,i=e=>"string"==typeof e?e.replace(/data-edit-key="([^"]*)"/g,(e,t)=>`data-edit-key="${(e=>e.replace(/&/g,"&").replace(/"/g,"""))(r((e=>e.replace(/"/g,'"').replace(/&/g,"&"))(t)))}"`):e,a=(n,r)=>{if("~"!==n[0]||!e.has(v(n))||(e=>l.some(t=>"st-node"===t.kind&&t.path===e&&"text"===t.prop))(n))return i(r);const o=t.get(e.get(v(n)));if(!o)return i(r);const s=document.createElement("template");s.innerHTML=Xt(o,!0);const a=n.slice(0,n.length-v(n).length);return[s.content.firstElementChild,...s.content.firstElementChild.querySelectorAll("[data-edit-key]")].forEach(e=>{const t=e.getAttribute("data-edit-key");t&&"@"===t[0]&&e.setAttribute("data-edit-key",a+t)}),s.innerHTML};l.forEach(e=>{var t;"st-order"!==e.kind&&"st-children"!==e.kind||e.region!==n||(e.parent=r(e.parent),e.before=o(e.before),e.order=o(e.order),e.html&&(e.html=(t=e.html)&&"object"==typeof t?Object.fromEntries(Object.entries(t).map(([e,t])=>[r(e),a(e,t)])):t),e.copies&&(e.copies=Object.fromEntries(Object.entries(e.copies).map(([e,t])=>[r(e),t])))),"st-node"===e.kind&&e.region===n&&"string"==typeof e.path&&"~"===e.path[0]&&(e.path=r(e.path)),"st-move"!==e.kind||e.from!==n&&e.to!==n||(e.key=r(e.key),e.fromParent=r(e.fromParent),e.toParent=r(e.toParent),e.fromBefore=o(e.fromBefore),e.toBefore=o(e.toBefore),e.fromOrder=o(e.fromOrder),e.toOrder=o(e.toOrder)),"lock"===e.kind&&e.region===n&&(e.key=r(e.key))}),We++});const C=e=>("st-order"===e.kind||"st-children"===e.kind)&&s.has(e.region)||"st-move"===e.kind&&(s.has(e.from)||s.has(e.to))||"st-node"===e.kind&&s.has(e.region)&&"string"==typeof e.path&&"~"===e.path[0],O=e=>"st-node"===e.kind&&"string"==typeof e.path&&"@"===e.path[0]&&o(e.region)&&(!t.has(e.path)||(e=>(e.unsure||[]).includes(e.path)||(p(e.path,e.id)||[]).length>0)(e))||C(e);l.forEach((e,t)=>{O(e)&&t<c&&"st-node"===e.kind&&"@"===e.path[0]&&n.push(e)});const L=()=>l.forEach(e=>{e.ids&&Object.keys(e.ids).forEach(t=>{const n=b(t);n&&(e.ids[t]=n)})});if(!l.some(O))return L(),(a.size||d.length||S.size||l.some(e=>e.ids))&&T(),[];const M=new Map;n.forEach(e=>M.set(e.path+"|"+e.prop,e));const j=e=>"string"==typeof e?v(e).slice(v(e).indexOf("@",1)+1):"",P=[...M.values()].map(e=>({region:e.region,key:e.path,element:j(e.path),prop:e.prop,value:e.value,before:e.before,reason:`${j(e.path)} changed in the source, so the ${"text"===e.prop?"text":e.prop} edited into it was not applied`}));s.forEach((e,t)=>{const n=l.filter((e,n)=>n<c&&C(e)&&(e.region===t||e.from===t||e.to===t)),r=new Set,o=new Set,i=[];n.forEach(e=>{"st-move"===e.kind&&r.add(e.key),"st-order"!==e.kind&&"st-children"!==e.kind||w(t,e.parent||"").forEach(e=>r.add(e)),"st-children"===e.kind&&e.before.forEach(t=>{"@"!==t[0]||e.order.includes(t)||o.add(t)}),"st-children"===e.kind&&e.html&&Object.entries(e.html).forEach(([e,t])=>{if("~"!==e[0])return;const n=document.createElement("template");n.innerHTML=t;const r=l.filter((t,n)=>n<c&&"st-node"===t.kind&&t.path===e&&"text"===t.prop).pop();i.push({of:j(e),html:t,text:r?r.value:n.content.textContent.trim()})})});const s=e.flatMap(e=>e.changed),a=e=>String(e).replace(/^([A-Za-z][\w-]*):(#\d+)?$/,(e,t,n)=>`<${t.toLowerCase()}>${n?" "+n:""}`),d=[...new Set(s.map(e=>a(e.was||e.now)))],u=[...new Set([...r].filter(e=>e&&"@"===e[0]&&!o.has(e)).map(e=>a(j(e))))],f=[...new Set([...o].map(e=>a(j(e))))],m=[f.length&&`deleted ${f.join(", ")}`,u.length&&`moved ${u.join(", ")}`,i.length&&`copied ${i.map(e=>`${a(e.of)} ("${String(e.text).slice(0,40)}")`).join(", ")}`].filter(Boolean).join("; ");P.push({region:t,key:"",element:e.map(e=>e.container?j(e.container):t).join(", "),prop:"structure",value:{changed:s,moved:u,copies:i},before:null,reason:e.some(e=>e.copy)&&s.every(e=>e.was===e.now)?`the copied element ${d.join(", ")} has identical twins that were reordered or replaced in the source, so the layout edits (${m||"reordering"}) were not applied`:s.every(e=>e.was===e.now)?`identical elements ${d.join(", ")} were reordered or replaced in the source where the layout was edited, so the layout edits (${m||"reordering"}) were not applied`:`${d.join(", ")} changed in the source where the layout was edited, so the layout edits (${m||"reordering"}) were not applied`})}),P.forEach(e=>{_.push(e),fe(e.region)&&x.add(e)});let R=0;return l=l.filter((e,t)=>{const n=!O(e);return n&&t<c&&R++,n}),c=R,We++,L(),T(),Ko(),P.length&&(no&&(no.conflicts=_.slice()),console.warn("[edit] edits to elements that changed in the source were dropped:\n"+P.map(e=>" "+e.reason+("structure"===e.prop?"":`: "${String(e.value).slice(0,80)}"`)).join("\n")),document.dispatchEvent(new CustomEvent("edit:conflict",{detail:{conflicts:P}}))),P}function ht(){const{node:e,order:t,orderBase:n,sigs:r,base:o,html:i}=Ze(),s=mt(ut()),a=[];new Set([...Object.keys(n),...Object.keys(t)]).forEach(e=>{const r=Object.assign({},n[e]||{},t[e]||{});Object.entries(r).forEach(([t,n])=>a.push([e,t,n]))});const l=new Set;a.forEach(([,,e])=>e.forEach(e=>l.add(e)));const c=new Set,d=e=>{let t=s.get(e);return!t&&ft.has(e)&&(t=ft.get(e),ft.delete(e),s.set(e,t)),!t&&i[e]&&(t=dt(i[e],e),t&&(s.set(e,t),t.querySelectorAll("[data-edit-key]").forEach(e=>{const t=e.getAttribute("data-edit-key");s.has(t)||s.set(t,e)}))),t};let u=!0;for(;a.length&&u;){u=!1;for(let e=0;e<a.length;e++){const[t,n,r]=a[e],o=n?s.get(n):ie(t);if(!o||!o.isConnected)continue;a.splice(e--,1),u=!0;let f=Ae(o);const m=r.map(d).filter(e=>e&&e!==o&&!e.contains(o)),p=f.filter(e=>!m.includes(e)&&!l.has(we(e))&&!i[we(e)]),h=[...m,...p].flatMap(ye);if(f=f.flatMap(ye),h.length===f.length&&h.every((e,t)=>e===f[t]))continue;const g=f.length?f[f.length-1].nextSibling:Array.from(o.children).find(be)||null,b=new Map(h.map(e=>[e,e.isConnected?Pe(e):e._editLead||[]]));f.forEach(e=>{if(h.includes(e))return;e._editLead=Pe(e),e._editLead.forEach(e=>e.remove()),e.remove();const t=we(e);t&&ft.set(t,e)}),h.forEach(e=>{const t=ce(e);t&&c.add(t),o.insertBefore(e,g&&g.parentNode===o?g:null);const n=b.get(e);n.length&&e.before(...n)});const y=ce(o);y&&c.add(y)}}c.size&&oe(),(c.size?mt(ut()):s).forEach((t,n)=>{const i=e[n],s=o[n];if(!i&&!s)return;const a=r[n];a&&P(t)!==a?console.warn("[edit] skip stale static node",n):new Set([...Object.keys(i||{}),...Object.keys(s||{})]).forEach(e=>function(e,t,n){if(void 0!==n){if("text"===t)return D(e,n);if(!X(t,n,e.tagName))return"class"===t?Cr(e,n):"style"===t?function(e,t){null==t||""===t?e.removeAttribute("style"):e.getAttribute("style")!==t&&e.setAttribute("style",t),e._editPos&&!e.style.position&&(e.style.position="relative")}(e,n):void(null!==n?e.getAttribute(t)!==n&&e.setAttribute(t,n):e.removeAttribute(t))}}(t,e,i&&void 0!==i[e]?i[e]:s&&s[e]))}),c.forEach(e=>{e.isConnected&&(Yr(e),e._armed&&io(e)&&eo(e))})}function gt(e,t,n,r,o={}){const i=de(e),s=t.getAttribute("data-edit-key");if(!s||"!"===s[0])return!1;if("text"===n&&p.has(t.tagName))return!1;"text"===n&&(r=I(t,r));let a=o.before;if(void 0===a){const r="text"===n?e._baseText&&e._baseText[s]:"class"===n?e._baseClass&&e._baseClass[s]:"style"===n?e._baseStyle&&e._baseStyle[s]:t.getAttribute(n),o="text"===n?t._preEdit:"class"===n?t._preClass:"style"===n?t._preStyle:void 0;a=void 0!==o?o:r}if(a===r||"text"===n&&null!=a&&I(t,a)===r)return!1;"text"!==n||document.activeElement===t||$(t)||D(t,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()-(Fe.get(d)||0)<1e3)return d.before===r?(l.pop(),c--):(d.value=r,Fe.set(d,Date.now())),We++,T(),Ko(),!0;const u=Ke(Object.assign({kind:"st-node",region:i,path:s,prop:n,value:r,before:a,sig:P(t)},lt(s)?(()=>{const e=ct({},[s]);return e.ids&&e.ids[s]&&(e.id=e.ids[s]),e})():{},o.join?{join:!0}:{}));return o.coalesce&&Fe.set(u,Date.now()),!0}function bt(){const e={};for(let t=0;t<c;t++){const n=l[t];"data-val"===n.kind&&(((e[n.source]=e[n.source]||{})[n.id]=e[n.source][n.id]||{})[n.field]=n.value)}return e}function yt(){const e=bt(),t=new Map;l.forEach(e=>{if("data-val"===e.kind){const n=JSON.stringify([e.source,e.id,e.field]);t.has(n)||t.set(n,e)}}),t.forEach(t=>{const n=(e[t.source]=e[t.source]||{})[t.id]=e[t.source][t.id]||{};t.field in n||void 0===t.before||(n[t.field]=t.before)}),re().forEach(t=>{if("data"!==me(t))return;const n=ge(t),r=e[n];if(!r)return;const o=h(t),i=he(t);try{const e=window.Alpine.evaluate(o,i);Array.isArray(e)&&Object.entries(r).forEach(([t,n])=>{const r=e.find(e=>String(e.id)===String(t));r&&Object.entries(n).forEach(([e,t])=>{r[e]!==t&&(r[e]=t)})})}catch{}io(t)&&setTimeout(()=>yr(t),0)})}function vt(e,t,n){const r=j(t),o=me(e);return"component"===o?Qe(e,t,"style",r):"static"===o&>(e,t,"style",r,n)}function Et(e,t,n){const r=A(t);return!C(n,r)&&(Ke(ct({kind:"st-order",region:de(e),parent:tt(t,e),order:r,before:n},n)),!0)}function wt(e,t,n,r,o,i,s={}){const a=n.parentElement,l={kind:"st-move",from:de(e),to:de(t),fromParent:tt(r,e),toParent:tt(a,t),key:we(n),fromOrder:A(r),toOrder:A(a),fromBefore:o,toBefore:i};return s.join&&(l.join=!0),ct(l,[v(l.key),...o,...i]),Ke(l),oe(),Yr(t),io(e)&&eo(e),t!==e&&io(t)&&eo(t),l}const kt=(e,t)=>/^[~@]/.test(t)?t:e+"|"+t;let At=-1,_t=new Map;function xt(){if(At===We)return _t;_t=new Map;for(let e=0;e<c;e++){const t=l[e];if("lock"!==t.kind)continue;const n=kt(t.region,t.key),r=_t.get(n)||new Map;_t.set(n,r),(t.actions&&t.actions.length?t.actions:o).forEach(e=>r.set(e,t.value))}return At=We,_t}const St=()=>xt();function Tt(e,t){const n=me(t);if("static"===n)return e.getAttribute("data-edit-key");if(e===t)return"";if("component"===n)return null!=e._editPath?"path:"+e._editPath:null;const r=h(t);if(r&&e.parentElement===r.parentElement){const n=xe(e,t);return null==n?null:"row:"+n}return null}const Ct=e=>"data"===e?"text":"class"===e?"attrs":e,Ot=e=>Ee(e)?e:ve(e)?e._manifestHost.roots[0]:null;function Lt(e,t){const n=Ct(t),r=e&&1===e.nodeType&&Ot(e);r&&(e=r);let o=r?Ft(r):ce(e);const i=xt();for(let t=e;t&&1===t.nodeType;t=t.parentElement){let e;const s=Ot(t);if(s&&i.size){const t=i.get(s.getAttribute("data-edit-host"));t&&t.has(n)&&(e=t.get(n))}if(void 0===e&&o&&i.size&&(!s||t!==r)){const r=Tt(t,o),s=null!=r&&i.get(kt(de(o),r));s&&s.has(n)&&(e=s.get(n))}if(void 0===e&&t._editLock&&(e=t._editLock.has("*")||t._editLock.has(n)),e)return!0;if(t===o){if(s&&t!==r&&(o=Ft(t),o))continue;break}}return!1}function Mt(e,t,n){if(!e||1!==e.nodeType)return!1;const r=Ot(e),i=r?Ft(r):ce(e);if(!i)return!1;if(null!=t&&!o.includes(t))return console.warn("[edit] unknown lock action:",t),!1;if(r)return Ke({kind:"lock",region:de(i),key:r.getAttribute("data-edit-host"),actions:t?[t]:[],value:!!n}),jt(i),r._edit&&jt(r),!0;const s=Tt(e,i);return null==s?(console.warn("[edit] this element has no stable identity to lock"),!1):(Ke({kind:"lock",region:de(i),key:s,actions:t?[t]:[],value:!!n}),jt(i),!0)}function jt(e){e&&e._armed&&(to(e),io(e)&&eo(e))}const Pt=e=>{"cmp-main"===e.kind||"cmp-inst"===e.kind?Ge():"data-val"===e.kind?yt():"theme"===e.kind?Jr():"lock"===e.kind?jt(ie(e.region)):ht()};function Rt(e,t){if("show"===e.kind)return function(e,t){const n=ie(e.region);if(!n)return;const r=""===e.key?n:[n,...n.querySelectorAll("[x-show]")].find(t=>Tt(t,n)===e.key);if(r)try{nr(r,e.expr,t?e.before:e.value)}catch{}}(e,t),null;if("data-splice"===e.kind)!function(e,t){const n=ie(e.region);if(!n)return;const r=h(n),o=he(n);if(!r||!o)return;let i;try{i=window.Alpine.evaluate(r,o)}catch{return}Array.isArray(i)&&((t?"remove"===e.op:"insert"===e.op)?i.splice(Math.min(e.index,i.length),0,JSON.parse(JSON.stringify(e.record))):i.splice(e.index,1),setTimeout(()=>{d[e.region]=Ue(n,me(n))},0))}(e,t);else{if("data"===e.kind){const n=t?e.before:e.after;return d[e.region]=n,Je(ie(e.region),e.kind,n)}Pt(e)}return null}async function $t(){if(0===c)return;let e;do{e=l[--c],We++;const t=Rt(e,!0);t&&await t}while(e.join&&c>0);Xo(),T(),Ko()}async function Nt(){if(!(c>=l.length)){do{const e=l[c++];We++;const t=Rt(e,!1);t&&await t}while(c<l.length&&l[c].join);Xo(),T(),Ko()}}function Bt(){const e={};for(let t=0;t<c;t++){const n=l[t];"data"===n.kind&&(e[n.region]={kind:n.kind,snap:n.after})}return e}let Ht=null,qt=null;const zt=()=>{no&&(no.version=(no.version||0)+1)},It=e=>{qt=e,zt()};function Dt(e){e&&1!==e.nodeType&&(e=e.parentElement);const t=ce(e);if(Ee(e)&&Ft(e)&&"static"===me(Ft(e)))return e;if(!t||e===t)return null;const n=me(t);if("data"===n){const n=h(t),r=n&&n.parentElement;for(let n=e;n&&n!==t;n=n.parentElement)if(n.parentElement===r)return n;return null}if("component"===n){for(let n=e;n&&n!==t;n=n.parentElement)if(null!=n._editPath)return n;return null}let r=null;for(let n=e;n&&n!==t;n=n.parentElement)(Ee(n)||ve(n))&&(r=Ee(n)?n:n._manifestHost.roots[0]);if(r)return r;for(let n=e;n&&n!==t;n=n.parentElement){if(be(n))return null;if(je(n.parentElement))return n}return null}const Wt=e=>(e=>!!e&&1===e.nodeType&&Dt(e)===e)(e)?e:Dt(e),Ft=e=>e&&ce(e.parentElement),Kt=e=>!!e&&(!!e._edit||e.hasAttribute("data-edit-area")),Ut=e=>!!e&&!!e.parentElement&&!be(e)&&!Q(e)&&ue(e.parentElement,"move")&&!Lt(e,"move")&&"component"!==me(ce(e.parentElement));function Jt(e){if(!e||1!==e.nodeType)return!1;const t=ce(e);if(!t||!io(t)||!je(e))return!1;for(let n=e;n&&n!==t;n=n.parentElement)if(n._manifestComponent)return!1;return ue(e,"move")}function Xt(e,t){const n=e.cloneNode(!0),r=[e,...e.querySelectorAll("*")],o=[n,...n.querySelectorAll("*")];o.forEach((e,t)=>{mn.has(r[t])&&e.removeAttribute("tabindex")});const i=o.filter((e,t)=>t>0&&k(r[t]));return pr(e,n),i.forEach(e=>e.remove()),n.querySelectorAll("[data-edit-handle], [data-edit-live], [data-edit-ghost]").forEach(e=>e.remove()),[n,...n.querySelectorAll("*")].forEach(e=>{[...e.attributes].forEach(n=>{!n.name.startsWith("data-edit-")||t&&"data-edit-key"===n.name||e.removeAttribute(n.name)}),e.removeAttribute("contenteditable"),e.removeAttribute("draggable")}),n.outerHTML}function Vt(e){const t=h(e),n=he(e);if(!t||!n)return null;try{const e=window.Alpine.evaluate(t,n);return Array.isArray(e)?e:null}catch{return null}}const Yt=(e,t)=>{const n=Vt(e);if(!n)return-1;const r=xe(t,e);return n.findIndex(e=>String(e&&null!=e.id?e.id:e)===String(r))};function Gt(e,t){const n=new Set(e.map(e=>String(e&&e.id)));if(!n.has(String(t)))return String(t);let r=2,o=`${t}-copy`;for(;n.has(o);)o=`${t}-copy-${r++}`;return o}const Qt=["move","remove","duplicate","text","attrs","class","size","copy","cut","paste"],Zt=e=>!(!e||!Ht||"static"===me(e)&&"static"!==Ht.kind);function en(e){const t=e?Wt(e):null;return t?Jt(t.parentElement)?t.parentElement:null:re().find(e=>io(e)&&Jt(e))||null}function tn(e,t){if(!Qt.includes(e))return!1;if("paste"===e){const e=Ht&&en(t);return!!e&&Zt(ce(e))}if(!t||1!==t.nodeType||Q(t))return!1;if(Ee(t)&&("move"===e||"duplicate"===e||"remove"===e)){const n=Ft(t);return!(!n||!io(n))&&("move"===e?Ut(t):ue(t.parentElement,"move")&&!Lt(t,e))}const n=ce(t);if(!n||!io(n))return!1;const r=me(n);if("size"===e)return!!t._edit&&t._edit.caps.has("size")&&!Lt(t,"size");if("text"===e)return ue(t,"text")&&!t.hasAttribute("x-text")&&!t.hasAttribute("x-html")&&("true"===t.getAttribute("contenteditable")||!!t._pieceMode||t.hasAttribute("data-rich-text")||null!=t._editField&&ue(t,"data"));if(("attrs"===e||"class"===e)&&"static"===r&&t._manifestComponent)return!1;if("attrs"===e||"class"===e){if("data"===r||Lt(t,"attrs"))return!1;const n=Me(t);if(n)return"attrs"===e&&ue(n,"text");if("component"===r)return"class"===e&&null!=t._editPath;const o=t.getAttribute("data-edit-key");return!!o&&"!"!==o[0]}if("component"===r)return!1;const o=Wt(t);if(!o)return!1;if("copy"===e)return!Ee(o);if("cut"===e)return tn("copy",o)&&tn("remove",o);if("move"===e)return Ut(o);const i="duplicate"===e?"duplicate":"remove";return ue(o.parentElement,"move")&&!Lt(o,i)}function nn(e){const t=Wt(void 0===e?qt:e);if(!t)return!1;const n=Ft(t);return!!n&&(Ht={html:Xt(t,!0),ops:rn(t),source:de(n),kind:me(n)},zt(),!0)}function rn(e){const t=Ze(),n={};return[e,...e.querySelectorAll("[data-edit-key]")].forEach(e=>{const r=e.getAttribute("data-edit-key");r&&t.node[r]&&(n[r]=Object.assign({},t.node[r]))}),n}function on(e,t,n,r,o){const i=A(t),s=function(e,t){const n=w(),r={};return[e,...e.querySelectorAll("[data-edit-key]")].forEach(e=>{const o=e.getAttribute("data-edit-key");if(!o||"!"===o[0])return void e.setAttribute("data-edit-key","!"+w());const i="~"+n+"~"+v(o);e.setAttribute("data-edit-key",i),t&&t[o]&&(r[i]=Object.assign({},t[o]))}),r}(n,o);r?r.after(n):t.appendChild(n),Yr(e),eo(e),nt(e,t,i,{[n.getAttribute("data-edit-key")]:Xt(n,!0)},s)}function sn(e){const t=Wt(void 0===e?qt:e);if(!tn("duplicate",t))return!1;const n=Ft(t);if("data"===me(n)){const e=Vt(n),r=Yt(n,t);if(!e||r<0)return!1;const o=JSON.parse(JSON.stringify(e[r]));return o&&null!=o.id&&(o.id=Gt(e,o.id)),e.splice(r+1,0,o),et(n,r+1,o,"insert"),!0}if(Ee(t))return function(e,t){const n=t.parentElement,r=A(n),o=ye(t),i=o.map(e=>dt(Xt(e)));if(i.some(e=>!e))return!1;const s={roots:i},a="~"+w()+"~"+v(we(t));return i.forEach(e=>{e._manifestComponent=t._manifestComponent,e._manifestHost=s,e.removeAttribute("data-component")}),i[0].setAttribute("data-edit-host",a),o[o.length-1].after(...i),Yr(e),eo(e),nt(e,n,r,{[a]:i[0].outerHTML}),!0}(n,t);const r=dt(Xt(t,!0));return!!r&&(on(n,t.parentElement,r,t,rn(t)),!0)}function an(e){const t=Wt(void 0===e?qt:e);if(!tn("remove",t))return!1;const n=Ft(t);if("data"===me(n)){const e=Vt(n),r=Yt(n,t);if(!e||r<0)return!1;const o=e[r];return e.splice(r,1),et(n,r,o,"remove"),qt===t&&It(null),!0}const r=t.parentElement,o=A(r),i=we(t),s=Ee(t)?t.outerHTML:Xt(t,!0);return t._editLead=Pe(t),t._editLead.forEach(e=>e.remove()),ye(t).slice(1).forEach(e=>e.remove()),t.remove(),ft.set(i,t),(qt===t||qt&&t.contains(qt))&&It(null),nt(n,r,o,{[i]:s}),!0}const ln=e=>{const t=Wt(void 0===e?qt:e);return tn("remove",t)&&nn(t)&&an(t)};function cn(e){if(!Ht)return!1;const t=en(void 0===e?qt:e);if(!t)return!1;const n=Wt(void 0===e?qt:e),r=ce(t);if(!Zt(r))return!1;if("data"===me(r)){const e=Vt(r);if(!e)return!1;const t=n?Yt(r,n)+1:e.length,o=document.createElement("template");o.innerHTML=Ht.html;const i={id:Gt(e,"pasted"),label:(o.content.textContent||"").trim()};return e.splice(t,0,i),et(r,t,i,"insert"),!0}if("static"!==me(r))return!1;const o=dt(Ht.html);return!(!o||!Be(o,t)||(on(r,t,o,n&&n.parentElement===t?n:null,Ht.ops),0))}const dn=e=>e.target.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.target.tagName);function un(e){const t=ce(e.target&&1===e.target.nodeType?e.target:e.target&&e.target.parentElement);t&&io(t)&&It(Dt(e.target))}const fn=e=>{const t=getComputedStyle(e).position;return"absolute"===t||"fixed"===t},mn=new WeakSet;let pn,hn=null;function gn(e){pn&&pn.isConnected||(pn=document.createElement("div"),pn.setAttribute("data-edit-live",""),pn.setAttribute("aria-live","polite"),document.body.appendChild(pn)),pn.textContent=e}function bn(e){e.removeAttribute("data-edit-piece"),e.removeAttribute("data-edit-grabbable"),mn.has(e)&&(e.removeAttribute("tabindex"),mn.delete(e))}function yn(e){const t=new Set(function(e){const t=me(e);if("component"===t)return[];if("data"===t){const t=h(e);return t?Ae(t.parentElement):[]}const n=[],r=e=>Ae(e).forEach(e=>{e.closest("[data-edit-ghost], [x-edit\\.grab]")||(e._manifestComponent?Ee(e)&&n.push(e):(n.push(e),je(e)&&!m(e)&&r(e)))});return je(e)&&r(e),n}(e).filter(Ut));e.querySelectorAll("[data-edit-piece]").forEach(n=>{t.has(n)||ce(n.parentElement)!==e||bn(n)}),t.forEach(e=>{e.setAttribute("data-edit-piece",""),e.toggleAttribute("data-edit-grabbable",!!Ln(e)),e.hasAttribute("tabindex")||(e.tabIndex=0,mn.add(e))})}const vn=e=>{const t=getComputedStyle(e);return/grid/.test(t.display)||/flex/.test(t.display)&&!String(t.flexDirection||"").startsWith("column")?"x":"y"};function En(e,t,n,r){const o=e.getBoundingClientRect();let i=("x"===vn(r)?t<o.left+o.width/2:n<o.top+o.height/2)?e:ye(e).pop().nextElementSibling;for(;i&&(i===s||i.hasAttribute("data-edit-dragging"));)i=i.nextElementSibling;return{container:r,ref:i}}function wn(e,t,n,r){const o=t?e.left:e.top,i=t?e.width:e.height,s=t?n:r;if(!i)return!0;const a=Math.min(.25*i,24);return s>=o+a&&s<=o+i-a}const kn=(e,t,n,r)=>wn(e.getBoundingClientRect(),"x"===vn(r),t,n),An=e=>!!e&&!!e._edit&&Jt(e)&&"static"===me(e)&&(e=>!!e&&re().includes(e))(e);function _n(e,t,n){if(n.dataList)return{container:n.home,ref:xn(n.home,e,t)};const r=n.nested;if(r&&r.el.isConnected&&n.ghost.parentElement===r.el&&e>=r.rect.left&&e<=r.rect.right&&t>=r.rect.top&&t<=r.rect.bottom&&wn(r.rect,r.horiz,e,t))return{container:r.el,ref:xn(r.el,e,t)};n.nested=null;const o=n.crossOK?function(e,t,n){const r=document.elementFromPoint?document.elementFromPoint(e,t):null;let o=r&&ce(r);if(o&&o!==n&&n.contains(o)&&(o=n),o&&An(o))return o;const i=[n,...document.querySelectorAll("[data-edit-drop-target]")].filter((e,t,n)=>An(e)&&n.indexOf(e)===t),s=(n,r)=>e>=n.left-r&&e<=n.right+r&&t>=n.top-r&&t<=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-e,0,e-r.right),Math.max(r.top-t,0,t-r.bottom)),c=ze(L(n,"--edit-drop-reach",""),n,"w")??48,d=n.parentElement,u=d&&d!==document.body&&d!==document.documentElement&&!i.some(e=>e!==n&&d.contains(e))&&s(d.getBoundingClientRect(),0);(s(r,c)||u)&&o<l&&(a=n,l=o)}return a}(e,t,n.area):n.area;if(!o)return null;const i=document.elementFromPoint?document.elementFromPoint(e,t):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 e=i;e&&e!==o;e=e.parentElement)(Ee(e)||ve(e))&&(r=Ee(e)?e:e._manifestHost.roots[0]);for(let i=r;i&&i!==o;i=i.parentElement){if(i===n.item||n.item.contains(i)||be(i))continue;const r=i.parentElement;if(je(r))if(Ee(i)){if(Jt(r)&&Be(n.item,r)&&!n.item.contains(r))return En(i,e,t,r)}else{if(n.ghost&&(i===n.home||i.contains(n.ghost))&&Jt(i)&&Be(n.item,i))return{container:i,ref:xn(i,e,t)};if(je(i)&&Jt(i)&&Be(n.item,i)&&kn(i,e,t,r))return n.ghost&&n.ghost.parentElement!==i&&(n.nested={el:i,rect:i.getBoundingClientRect(),horiz:"x"===vn(r)}),{container:i,ref:xn(i,e,t)};if(Jt(r)&&Be(n.item,r)&&!n.item.contains(r))return En(i,e,t,r)}}}if(!(n.crossOK||i&&o.contains(i))){const r=n.ghost.parentElement;return{container:r,ref:xn(r,e,t)}}return Jt(o)&&Be(n.item,o)?{container:o,ref:xn(o,e,t)}:null}function xn(e,t,n){const r="y"===vn(e);for(const o of Ae(e)){if(o===s||o.hasAttribute("data-edit-dragging")||Lt(o,"move"))continue;const e=o.getBoundingClientRect(),i=e.left+e.width/2,a=e.top+e.height/2;if(r&&!/inline/.test(getComputedStyle(o).display)){if(a>n)return o;continue}const l=Math.abs(a-n)<e.height/2;if(a-n>e.height/2||l&&i>t)return o}return null}function Sn(e,t,n,r){const o=e.offsetParent||e.parentElement,i=o.getBoundingClientRect();let s=t-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-e.offsetWidth,c=o.clientHeight-e.offsetHeight;s=l>0?Ie(s,0,l):Math.max(0,s),a=c>0?Ie(a,0,c):Math.max(0,a),e.style.left=qe(s,r.lu,e,o,"w")+r.lu,e.style.top=qe(a,r.tu,e,o,"h")+r.tu}const Tn=e=>{e.style.removeProperty("left"),e.style.removeProperty("top"),e.getAttribute("style")||e.removeAttribute("style")},Cn=(e,t)=>A(e).filter((n,r)=>Ae(e)[r]!==t);function On(e){const t=this;if(!io(t)||"mouse"===e.pointerType&&0!==e.button||e._editDrag)return;const n=e.target;if(!n||1!==n.nodeType||n.hasAttribute("data-edit-handle"))return;if(n._pieceMode)return void Ar(n);let r=null;for(let e=n;e&&e!==t;e=e.parentElement)if(e.hasAttribute("data-edit-piece")&&Ut(e)){r=e;break}if(!r)return;const o=Ln(r);if(o){if(!o.contains(n))return;e.preventDefault()}else if(Mn(n))return;e._editDrag=!0,function(e,t,n){const r=t.parentElement,o=ye(t).pop().nextElementSibling,i=ye(t).slice(1),a="data"===me(n),l={item:t,area:n,home:r,dataList:a,ghost:null,crossOK:!a&&"static"===me(n)&&(Ee(t)||!Kt(t)),homeBefore:a?null:A(r),lu:He(t.style.left)||"px",tu:He(t.style.top)||"px"},c=t.getBoundingClientRect(),d=t.getAttribute("style"),u=j(t),f=Pe(t);l.grabX=e.clientX-c.left,l.grabY=e.clientY-c.top;const m=e.clientX,p=e.clientY;let h=!1,g=0,b=m,y=p,v=null;const E=e=>{const r=document.activeElement;r&&t.contains(r)&&r.isContentEditable&&r.blur();try{window.getSelection().removeAllRanges()}catch{}l.crossOK&&re().forEach(e=>{e!==n&&An(e)&&e.setAttribute("data-edit-drop-target","")});const o=l.ghost=t.cloneNode(!0);pr(t,o),o.setAttribute("data-edit-ghost",""),o.setAttribute("x-ignore",""),o.removeAttribute("id"),o.querySelectorAll("[id]").forEach(e=>e.removeAttribute("id")),[o,...o.querySelectorAll("*")].forEach(e=>{[...e.attributes].forEach(t=>{t.name.startsWith("data-edit-")&&"data-edit-ghost"!==t.name&&e.removeAttribute(t.name)}),e.removeAttribute("contenteditable"),e.removeAttribute("tabindex"),e.removeAttribute("draggable")}),t.before(o),Object.assign(t.style,{position:"fixed",width:c.width+"px",height:c.height+"px",margin:"0",pointerEvents:"none"}),t.setAttribute("data-edit-dragging",""),s=o;try{t.setPointerCapture(e.pointerId)}catch{}},w=()=>{g=0,t.style.left=b-l.grabX+"px",t.style.top=y-l.grabY+"px"},k=e=>{const n=l.ghost,{container:o,ref:i}=e,s=v&&v.container===o&&v.ref===i;v=e,s||o.insertBefore(n,i&&i.parentElement===o?Re(i):null),fn(n)?(s||(o===r&&t.parentElement===r?r.insertBefore(n,t):n.nextElementSibling&&o.appendChild(n)),Sn(n,b,y,l)):(n.style.left||n.style.top)&&Tn(n)},_=e=>{if(b=e.clientX,y=e.clientY,!h){if(Math.hypot(b-m,y-p)<5)return;h=!0,E(e),w()}e.preventDefault();const t=_n(b,y,l);t&&k(t),g||(g=requestAnimationFrame(w))},x=e=>{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(e=>e.removeAttribute("data-edit-drop-target")),t.removeAttribute("data-edit-dragging"),e?l.ghost.remove():(l.ghost.replaceWith(t),f.length&&t.before(...f),i.length&&t.after(...i)),null==d?t.removeAttribute("style"):t.setAttribute("style",d),l.ghost=null,s=null;const a=()=>{o&&o.parentElement===r?r.insertBefore(t,Re(o)):r.appendChild(t),f.length&&t.before(...f),i.length&&t.after(...i)};if(e)return a(),void gn("Cancelled");const c=t.parentElement,m=ce(c);if(c!==r&&(l.dataList||!Jt(c)||!Be(t,c)||!m||m!==n&&(!l.crossOK||!An(m))))return a(),void gn("Cancelled");fn(t)?Sn(t,b,y,l):(t.style.left||t.style.top)&&Tn(t);const p=j(t)!==u;if(l.dataList)return jn(n,r),void gn("Dropped");let v=!1;c===r?v=Et(n,r,l.homeBefore):(wt(n,m,t,r,l.homeBefore,Cn(c,t)),v=!0),p&&vt(ce(t),t,{before:u,join:v}),gn(m!==n?"Moved to "+de(m):"Dropped")},S=()=>x(!1),T=()=>x(!0),C=e=>{"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),x(!0))};document.addEventListener("pointermove",_),document.addEventListener("pointerup",S),document.addEventListener("pointercancel",T),document.addEventListener("keydown",C,!0)}(e,r,t)}const Ln=e=>[...e.querySelectorAll("[x-edit\\.grab]")].find(t=>t.closest("[data-edit-piece]")===e)||null,Mn=e=>{const t=document.activeElement;return!!t&&t!==document.body&&t.isContentEditable&&(t===e||t.contains(e))};function jn(e,t){return"data"===me(e)&&(Xe(e,Ae(t).map(t=>xe(t,e))),function(e){if(!e)return;const t=de(e),n=me(e),r=Ue(e,n),o=d[t];o&&C(o,r)||(Ke({region:t,kind:n,before:o??r,after:r}),d[t]=r)}(e),!0)}const Pn=(e,t)=>e.target!==t&&!!e.target.closest&&t.contains(e.target.closest('a[href], button, summary, [role="button"], [role="link"]')),Rn=e=>Ae(e.parentElement).filter(t=>t===e||!Lt(t,"move"));function $n(e){if(document.activeElement!==e)try{e.focus()}catch{}}function Nn(e,t){if(e._editRow)return;const n=e.target;if("Enter"===e.key&&n.matches&&n.matches("a[href]")&&or(n,t))return;if(n._pieceMode&&"Enter"===e.key)return e._editRow=!0,e.preventDefault(),void Ar(n,!0);let r=null;for(let e=n;e&&e!==t;e=e.parentElement)if(e.hasAttribute&&e.hasAttribute("data-edit-piece")&&Ut(e)){r=e;break}if(!hn){const t=Wt(n);if(t&&function(e,t){if(dn(e))return!1;const n=e.metaKey||e.ctrlKey,r=(e.key||"").toLowerCase();return n&&"c"===r?nn(t):n&&"x"===r?ln(t):n&&"v"===r?cn(t):n&&"d"===r?sn(t):!(n||"Delete"!==e.key&&"Backspace"!==e.key)&&an(t)}(e,t))return e._editRow=!0,e.preventDefault(),void e.stopPropagation()}if(!r)return;const o={ArrowUp:-1,ArrowDown:1}[e.key],i={ArrowLeft:-1,ArrowRight:1}[e.key],s=e.altKey&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey;if(s&&null!=o&&(!hn||hn.item!==r))return e._editRow=!0,e.preventDefault(),void function(e,t){const n=Ft(e),r=e.parentElement,o=Rn(e),i=o.indexOf(e),s=i+t;if(i<0||s<0||s>=o.length)return void gn(`Position ${i+1} of ${o.length}`);const a="data"===me(n)?null:A(r),l=o[s],c=[];for(let n=t>0?e.nextElementSibling:e.previousElementSibling;n&&n!==l;n=t>0?n.nextElementSibling:n.previousElementSibling)c.push(n);const d=e=>[...Pe(e),...ye(e)];if(t>0){const t=Re(e);[l,...c].filter(e=>!ve(e)).forEach(e=>t.before(...d(e)))}else{let t=ye(e).pop();[...c.slice().reverse(),l].filter(e=>!ve(e)).forEach(e=>{t.after(...d(e)),t=ye(e).pop()})}const u=document.activeElement,f=window.getSelection&&window.getSelection(),m=f&&f.rangeCount?f.getRangeAt(0).cloneRange():null;if(a?Et(n,r,a):jn(n,r),u&&u.isConnected&&document.activeElement!==u&&(u.focus(),m))try{f.removeAllRanges(),f.addRange(m)}catch{}gn(`Moved to position ${s+1} of ${o.length}`)}(r,o);if(s&&null!=i&&!dn(e))return e._editRow=!0,e.preventDefault(),void(i>0?qn(r):zn(r));if(!(" "!==e.key&&"Enter"!==e.key||dn(e)||Pn(e,r)||e.altKey||e.metaKey||e.ctrlKey))return e._editRow=!0,e.preventDefault(),void(hn&&hn.item===r?(function(){const e=hn;hn=null,e&&(e.item.removeAttribute("data-edit-dragging"),e.before?Et(e.area,e.container,e.before):jn(e.area,e.container))}(),$n(r),gn("Dropped")):(hn&&Bn(),hn={item:r,area:Ft(r),container:r.parentElement,next:ye(r).pop().nextElementSibling,before:"data"===me(Ft(r))?null:A(r.parentElement)},r.setAttribute("data-edit-dragging","keyboard"),gn("Grabbed — arrow keys to move, Enter to drop")));if(hn&&hn.item===r){if("Escape"===e.key)return e._editRow=!0,e.preventDefault(),Bn(),$n(r),void gn("Cancelled");const t=o??i;if(null==t)return;e._editRow=!0,e.preventDefault();const n=Rn(r),s=n.indexOf(r)+t;if(s<0||s>=n.length)return;return $e(r,e=>{t>0?ye(n[s]).pop().after(e):Re(n[s]).before(e)}),$n(r),void gn(`Position ${s+1} of ${n.length}`)}n!==r||dn(e)||e.altKey||e.metaKey||e.ctrlKey||null==o&&null==i||!fn(r)||(e._editRow=!0,function(e,t){const n={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[e.key];if(!n)return;e.preventDefault(),t._moveTimer||(t._preStyle=j(t));const r=e.shiftKey?16:4,o=getComputedStyle(t),i=t.offsetParent||t.parentElement,s=He(t.style.left)||"px",a=He(t.style.top)||"px",l=Math.max(0,i.clientWidth-t.offsetWidth),c=Math.max(0,i.clientHeight-t.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]&&(t.style.left=qe(l?Math.min(l,d):d,s,t,i,"w")+s),n[1]&&(t.style.top=qe(c?Math.min(c,u):u,a,t,i,"h")+a),clearTimeout(t._moveTimer),t._moveTimer=setTimeout(()=>{t._moveTimer=null;const e=t.isConnected&&ce(t);e&&vt(e,t)},350)}(e,r))}function Bn(){const e=hn;hn=null,e&&(e.item.removeAttribute("data-edit-dragging"),$e(e.item,t=>{e.next&&e.next.parentElement===e.container?e.container.insertBefore(t,Re(e.next)):e.container.appendChild(t)}))}const Hn=e=>e===ce(e)?de(e):e.tagName.toLowerCase();function qn(e){const t=Ft(e);if("static"!==me(t))return gn("Records stay in their list"),!1;let n=e.previousElementSibling;for(;n&&(be(n)||"TEMPLATE"===n.tagName||ve(n));)n=n.previousElementSibling;if(!n||Ee(n)||!Jt(n)||!Be(e,n))return gn("Nothing to nest into"),!1;const r=e.parentElement,o=A(r),i=A(n);return $e(e,e=>n.appendChild(e)),wt(t,t,e,r,o,i),$n(e),gn("Nested in "+Hn(n)),!0}function zn(e){const t=Ft(e),n=e.parentElement;if("static"!==me(t))return gn("Records stay in their list"),!1;const r=n&&n!==t?n.parentElement:null;if(!r||r!==t&&!t.contains(r)||!Jt(r))return gn("Already at the top level"),!1;if(!Be(e,r))return gn("Cannot move out here"),!1;const o=A(n),i=A(r);return $e(e,e=>ye(n).pop().after(e)),wt(t,t,e,n,o,i),$n(e),gn("Moved out to "+Hn(r)),!0}let In;function Dn(e,t){const n=e.getBoundingClientRect();e.dispatchEvent(new CustomEvent("edit:size",{bubbles:!0,detail:{width:n.width,height:n.height,css:{width:e.style.width,height:e.style.height},done:t}}))}const Wn=e=>"rtl"===getComputedStyle(e).direction;function Fn(e,t){const n=getComputedStyle(e).position;if("fixed"===n)return"w"===t?document.documentElement.clientWidth:document.documentElement.clientHeight;const r="absolute"===n&&e.offsetParent||e.parentElement;if(!r)return null;const o=getComputedStyle(r),i="w"===t,s=i?r.clientWidth:r.clientHeight;return"absolute"===n?s:i||function(e){for(let t=e,n=0;t&&n<32;t=t.parentElement,n++){if(t===document.documentElement)return!0;const e=getComputedStyle(t).position;if("absolute"===e||"fixed"===e)return!0;let n;if(t.computedStyleMap)try{n=String(t.computedStyleMap().get("height")).trim()}catch{}if(null==n&&(n=(t.style&&t.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 Kn(e,t,n,r){if(!(e=String(e||"").trim())||"none"===e||"auto"===e)return r;if(/^-?[\d.]+%$/.test(e)){const o=Fn(t,n);return null==o?r:parseFloat(e)/100*o}const o=ze(e,t,n);return null==o?r:o}function Un(e,t){const n=Kn(t.minWidth,e,"w",0),r=Kn(t.minHeight,e,"h",0);return{minW:n,minH:r,maxW:Math.max(n,Kn(t.maxWidth,e,"w",1/0)),maxH:Math.max(r,Kn(t.maxHeight,e,"h",1/0))}}const Jn=e=>"x"===e?["left","right"]:"y"===e?["top","bottom"]:["top","right","bottom","left","top-left","top-right","bottom-left","bottom-right"];function Xn(e){const t=L(e,"--edit-size","both");if("none"===t)return;if(e._sizeBound)return;e._sizeBound=!0;const n=getComputedStyle(e).position;n&&"static"!==n||(e.style.position="relative",e._editPos=!0),(L(e,"--edit-size-edges","")||Jn(t).join(" ")).split(/\s+/).filter(Boolean).forEach(t=>{const n=function(e,t){const n=Wn(t);return e.replace(/start/g,n?"right":"left").replace(/end/g,n?"left":"right")}(t,e),r=document.createElement("span");r.setAttribute("data-edit-handle",t),r.tabIndex=0,r.setAttribute("role","slider"),r.setAttribute("aria-label",`Resize ${t}`),r.addEventListener("pointerdown",t=>function(e,t,n){const r=ce(t);if(!io(r)||"mouse"===e.pointerType&&0!==e.button||e.button>0)return;e.preventDefault(),e.stopPropagation();const o=t.getAttribute("style");t._preStyle=j(t);const i=getComputedStyle(t),s=t.getBoundingClientRect(),a=He(t.style.width)||"px",l=He(t.style.height)||"px",c=parseFloat(i.width)||s.width,d=parseFloat(i.height)||s.height,u=e.clientX,f=e.clientY,{minW:m,maxW:p,minH:h,maxH:g}=Un(t,i),b=n.includes("right"),y=n.includes("left"),v=n.includes("bottom"),E=n.includes("top"),w=Qn(t,"--edit-size-snap-distance","x","w"),k=Qn(t,"--edit-size-snap-distance","y","h"),A=Yn(t,"x","w"),_=Yn(t,"y","h"),x=Qn(t,"--edit-size-close","x","w"),S=Qn(t,"--edit-size-close","y","h"),T=null!=x||null!=S?function(e){const t=e.getAttribute("x-show");return null==t?null:Zn.test(t)?t:(er.has(e)||(er.add(e),console.warn('[edit] --edit-size-close needs an assignable x-show expression (e.g. x-show="open"); close is off here:',t)),null)}(t):null;let C;if(T)try{C=tr(window.Alpine.evaluate(t,T))}catch{}const O=e.target;try{O.setPointerCapture&&O.setPointerCapture(e.pointerId)}catch{}O.setAttribute("data-edit-resizing",""),In||(In=document.createElement("div"),In.setAttribute("data-edit-overlay",""),document.body.appendChild(In)),In.style.display="block";let L=c,M=d,P=!1;const R=()=>(b||y)&&null!=x&&L<x||(E||v)&&null!=S&&M<S,$=e=>{if(e!==P&&T){P=e;try{nr(t,T,!e&&C)}catch{}}},N=e=>{const n=e.clientX-u,r=e.clientY-f;(b||y)&&(L=c+(b?n:-n)),(E||v)&&(M=d+(v?r:-r)),$(R());let o=!1;if(b||y){const e=Ie(L,m,p),n=Gn(e,A,w);o=o||A.length>0&&n!==e,t.style.width=qe(n,a,t,t.parentElement,"w")+a}if(E||v){const e=Ie(M,h,g),n=Gn(e,_,k);o=o||_.length>0&&n!==e,t.style.height=qe(n,l,t,t.parentElement,"h")+l}t.toggleAttribute("data-edit-snapped",o&&!P),O.toggleAttribute("data-edit-snapped",o&&!P),Dn(t,!1)},B=()=>{document.removeEventListener("pointermove",N),document.removeEventListener("pointerup",z),document.removeEventListener("pointercancel",q),In&&(In.style.display="none"),["data-edit-snapped","data-edit-resizing"].forEach(e=>O.removeAttribute(e)),t.removeAttribute("data-edit-snapped")},H=()=>{null==o?t.removeAttribute("style"):t.setAttribute("style",o)},q=()=>{B(),$(!1),H(),Dn(t,!0)},z=()=>{B();const e=(b||y)&&null!=x&&L<x,n=(E||v)&&null!=S&&M<S;if((e||n)&&T){const o=(e?m:0)>0||(n?h:0)>0,i=t.style.display;H(),o&&(e&&m>0&&(t.style.width=qe(m,a,t,t.parentElement,"w")+a),n&&h>0&&(t.style.height=qe(h,l,t,t.parentElement,"h")+l));const s=vt(r,t);return Dn(t,!0),"none"===i&&(t.style.display="none"),void function(e,t,n,r,o){let i=o;try{void 0===i&&(i=tr(window.Alpine.evaluate(t,n))),nr(t,n,!1)}catch(e){return console.warn("[edit] could not close via x-show:",e),!1}const s=Tt(t,e);null!=s&&Ke(Object.assign({kind:"show",region:de(e),key:s,expr:n,before:i,value:!1},r?{join:!0}:{}))}(r,t,T,s,C)}if(e||n)return H(),void Dn(t,!0);vt(r,t),Dn(t,!0)};document.addEventListener("pointermove",N),document.addEventListener("pointerup",z),document.addEventListener("pointercancel",q)}(t,e,n)),r.addEventListener("keydown",t=>function(e,t,n){const r={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]};if(!r[e.key])return;const o=ce(t);if(!io(o))return;e.preventDefault(),e.stopPropagation(),t._keyTimer||(t._preStyle=j(t));const[i,s]=r[e.key],a=e.shiftKey?32:8,l=getComputedStyle(t),c=n.includes("right"),d=n.includes("left"),u=n.includes("top"),f=n.includes("bottom"),m=He(t.style.width)||"px",p=He(t.style.height)||"px",{minW:h,maxW:g,minH:b,maxH:y}=Un(t,l);if((c||d)&&i){const e=Ie((parseFloat(l.width)||0)+i*a*(c?1:-1),h,g);t.style.width=qe(e,m,t,t.parentElement,"w")+m}if((u||f)&&s){const e=Ie((parseFloat(l.height)||0)+s*a*(f?1:-1),b,y);t.style.height=qe(e,p,t,t.parentElement,"h")+p}Dn(t,!1),clearTimeout(t._keyTimer),t._keyTimer=setTimeout(()=>{t._keyTimer=null;const e=t.isConnected&&ce(t);e&&(vt(e,t),Dn(t,!0))},350)}(t,e,n)),e.appendChild(r)})}function Vn(e,t,n){const r=O(e,`${t}-${n}`);if(r)return"none"===r?"":r;const o=O(e,t);return"none"===o?"":o}function Yn(e,t,n){return Vn(e,"--edit-size-snap",t).split(/\s+/).filter(Boolean).map(t=>ze(t,e,n)).filter(e=>null!=e)}function Gn(e,t,n){if(!t.length)return e;let r=e,o=1/0;for(const n of t){const t=Math.abs(e-n);t<o&&(o=t,r=n)}return null==n||o<=n?r:e}const Qn=(e,t,n,r)=>{const o=Vn(e,t,n);return o?ze(o,e,r):null},Zn=/^\s*[A-Za-z_$][\w$]*(?:\s*\.\s*[A-Za-z_$][\w$]*|\s*\[\s*(?:'[^'\\]*'|"[^"\\]*"|\d+)\s*\])*\s*$/,er=new WeakSet,tr=e=>{try{return void 0===JSON.stringify(e)||JSON.parse(JSON.stringify(e))}catch{return!0}};function nr(e,t,n){window.Alpine.evaluate(e,`${t} = ${JSON.stringify(n)}`)}function rr(e){requestAnimationFrame(()=>{if(!s&&!hn&&document.activeElement===e)try{const t=document.createRange();t.selectNodeContents(e);const n=window.getSelection();n.removeAllRanges(),n.addRange(t)}catch{}})}function or(e,t){const n=e.closest('[contenteditable="false"]');return!!n&&t.contains(n)&&!n.hasAttribute("data-edit-piece-mode")}function ir(e){const t=e.target&&e.target.closest&&e.target.closest("a[href]"),n=t&&ce(t);n&&io(n)&&!or(t,n)&&e.preventDefault()}const sr=new Set;let ar=!1;function lr(e,t){if(e._editRtFormat=t,e._editRt||e._pieceMode)return;const n=function(){const e=window.ManifestRichText;return e&&"function"==typeof e.attach?e:(ar||(ar=!0,console.warn("[edit] Rich Text is not loaded; text leaves fall back to plain contenteditable")),null)}();e._editRtPrior=["role","aria-multiline"].map(t=>[t,e.getAttribute(t)]);const r=n&&n.attach(e,{mode:"inline",breaks:!0,enter:"break",all:!1,format:t,onChange:()=>{}});r?(e._editRt=r,e.setAttribute("data-edit-text",""),sr.add(e)):e.setAttribute("contenteditable","true")}function cr(e){const t=e._editRt;t&&(e._editRt=null,sr.delete(e),e.removeAttribute("data-edit-text"),t.detach())}const dr=e=>sr.forEach(t=>{(!t.isConnected||e&&e.contains(t))&&cr(t)}),ur=e=>{const t=e._editRt;t&&(t.value=t.value)};function fr(e){const t=this,n=t._editRt,r=Vo(e);if(!n||!r)return;if(n.can(r))return e.preventDefault(),e.stopImmediatePropagation(),void n[r]();const o=ce(t);"undo"===r&&o&&io(o)&&!Jo(t)&&function(e){const t=e._editRt;if(!t||!t.can("redo")||!e._commitText)return;const n=function(e){const t=e._editRt.newest();if(!e._editField||e._editRich)return t.trim();const n=document.createElement("template");return n.innerHTML=t,n.content.textContent}(e);e._commitText(n)&&$t()}(t),Yo(e),e.defaultPrevented&&e.stopImmediatePropagation()}function mr(e){e.addEventListener("drop",t=>{const n=ce(e);n&&io(n)&&(t.preventDefault(),t.stopImmediatePropagation())})}function pr(e,t){const n=[e,...e.querySelectorAll("*")],r=[t,...t.querySelectorAll("*")];r.forEach(e=>{const t=e.getAttribute("style");if(t&&/--rich-text-/.test(t)){const n=M(t);n?e.setAttribute("style",n):e.removeAttribute("style")}}),n.forEach((e,t)=>{e._editRt&&r[t]&&([...r[t].attributes].forEach(e=>{e.name.startsWith("data-rich-text")&&r[t].removeAttribute(e.name)}),(e._editRtPrior||[]).forEach(([e,n])=>null==n?r[t].removeAttribute(e):r[t].setAttribute(e,n)))})}function hr(e,t,n){e._textBound||(e._textBound=!0,e._commitText=t,e.addEventListener("focus",()=>{ur(e),e._preEdit=Uo(e),rr(e)}),e.addEventListener("keydown",t=>{e.isContentEditable&&("Escape"===t.key?(t.preventDefault(),t.stopImmediatePropagation(),e.blur()):"Enter"!==t.key||!t.altKey||t.shiftKey||t.metaKey||t.ctrlKey||(t.preventDefault(),t.stopImmediatePropagation(),function(e){e.blur();const t=[e,...kr(e)].find(e=>e.hasAttribute&&e.hasAttribute("data-edit-piece"));if(t){t.isContentEditable&&(t._pieceMode=!0,t.setAttribute("data-edit-piece-mode",""),cr(t),t.setAttribute("contenteditable","false"),t.addEventListener("focusout",()=>Ar(t),{once:!0}));try{t.focus()}catch{}}}(e)))}),e.addEventListener("keydown",fr),mr(e),n&&e.addEventListener("input",n),e.addEventListener("blur",()=>t()))}const gr=e=>{const t=e.closest("[data-rich-text]");return!(!t||t===e&&e._editRt)};function br(e){e.querySelectorAll("[data-rich-text]:not([data-rich-text-bound])").forEach(t=>{!t._editRt&&ue(t,"text")&&/^[@~]/.test(t.getAttribute("data-edit-key")||"")&&(t._richBound||(t._richBound=!0,t.addEventListener("focusin",()=>{t._preEdit=Uo(t)}),t.addEventListener("blur",()=>{const n=ce(t)||e;("component"===me(n)?Qe:gt)(n,t,"text",t.innerHTML.trim())},!0)))})}function yr(e){const t=h(e);if(!t)return;const n=(t.getAttribute("x-for").match(/^\s*([\w$]+)\s+in\b/)||[])[1];if(!n)return;const r=ge(e),o=new RegExp("^\\s*"+n+"\\.([\\w$]+)\\s*$");Ae(e).forEach(t=>{let i=t.getAttribute("data-key");if(null==i){let e=null;try{e=window.Alpine.$data(t)[n]}catch{}e&&null!=e.id&&(i=String(e.id))}null!=i&&[t,...t.querySelectorAll("*")].forEach(t=>{const n=t.hasAttribute("x-html");if(t.children.length&&(!n||!Oe(t))||t.hasAttribute("data-edit-handle"))return;const s=t.getAttribute("x-text")||t.getAttribute("x-html");if(!s)return;const a=s.match(o);if(!a)return;const l=a[1];if(t._editField=l,t._editRich=n,!t._dvBound){t._dvBound=!0;const o=()=>n?z(t):t.textContent;t._commitText=n=>function(e,t,n,r,o,i){o=String(o),i&&i._editRich&&(o=I(i,o));const s=i?i._preEdit:void 0;return!(s===o||i&&i._editRich&&null!=s&&I(i,s)===o||(Ke({kind:"data-val",region:de(e),source:t,id:n,field:r,value:o,before:s}),yt(),0))}(e,r,i,l,n??o(),t),t.addEventListener("focus",()=>{ur(t),t._preEdit=Uo(t),$(t)||rr(t)}),t.addEventListener("focusin",()=>{t._preEdit=Uo(t)}),t.addEventListener("keydown",fr),mr(t),t.addEventListener("blur",()=>t._commitText(),!0)}$(t)||lr(t,n?"html":"plain")})})}const vr=e=>{const t=pe(e);return(t?.getAttribute("data-component")||"").replace(/-\d+$/,"")};function Er(e,t,n,r){if("main"!==(e._editScope||"instance"))return;const o=vr(e),i=t._editPath,{inst:s}=Ve();re().forEach(e=>{if("component"!==me(e)||vr(e)!==o)return;const a=pe(e);if(!a)return;const l=""===i?a:function(e,t){let n=e;for(const e of t.split(".").map(Number))if(n=ke(n)[e],!n)return null;return n}(a,i);l&&l!==t&&void 0===(s[de(e)]&&s[de(e)][i]||{})[n]&&("class"===n?Cr(l,r):l.innerHTML!==r&&(l.innerHTML=r))})}function wr(e){const t=pe(e);if(!t)return;e._editScope||(e._editScope="instance"),e._baseText=e._baseText||{},e._baseClass=e._baseClass||{},e._baseStyle=e._baseStyle||{};const n=n=>{const r=function(e,t){const n=[];let r=e;for(;r&&r!==t&&r.parentElement;)n.unshift(ke(r.parentElement).indexOf(r)),r=r.parentElement;return n.join(".")}(n,t);n._editPath=r,r in e._baseClass||(e._baseClass[r]=n.getAttribute("class")||""),r in e._baseStyle||(e._baseStyle[r]=n.getAttribute("style")||"")};n(t),t.querySelectorAll("*").forEach(e=>{e.hasAttribute("data-edit-handle")||n(e)}),br(e),Ye(t).forEach(t=>{if(t.children.length&&!Le(t)||!t.textContent.trim()||!ue(t,"text"))return;if(gr(t))return;const n=t._editPath;n in e._baseText||(e._baseText[n]=t.innerHTML.trim()),hr(t,n=>Qe(e,t,"text",n??z(t)),()=>Er(e,t,"text",t.innerHTML)),lr(t,"html")})}const kr=e=>{const t=[],n=ce(e);for(let r=e.parentElement;r&&r!==n;r=r.parentElement)t.push(r);return t};function Ar(e,t){if(e._pieceMode&&(e._pieceMode=!1,e.removeAttribute("data-edit-piece-mode"),"false"===e.getAttribute("contenteditable")&&(e.removeAttribute("contenteditable"),lr(e,e._editRtFormat||"html")),t)){try{e.focus()}catch{}rr(e)}}const _r=(e,t)=>e.getAttribute(":"+t)??e.getAttribute("x-bind:"+t);function xr(e){const t=_r(e,"class");if(null==t)return[];let n;try{n=window.Alpine.evaluate(e,t)}catch{return[]}const r=[],o=e=>String(e).split(/\s+/).filter(Boolean).forEach(e=>r.push(e));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(([e,t])=>{t&&o(e)}),r}const Sr=e=>String(e||"").split(/\s+/).filter(Boolean);function Tr(e){const t=new Set(xr(e));return Sr(e.getAttribute("class")).filter(e=>!t.has(e)).join(" ")}function Cr(e,t){const n=xr(e),r=[...new Set([...Sr(t),...n])].join(" ");r?e.getAttribute("class")!==r&&e.setAttribute("class",r):e.hasAttribute("class")&&e.removeAttribute("class")}function Or(e){if(null==e&&(e=qt),!e||1!==e.nodeType)return null;const t=ce(e);if(!t||!io(t))return null;const n=me(t);return"static"===n&&e._manifestComponent?null:{el:e,area:t,kind:n}}function Lr(e,t,n){const r=Or(n);if(!r)return!1;e=String(e||"").trim().toLowerCase();const o=!0===t?"":!1===t||null==t?null:String(t),i=X(e,o,r.el.tagName);if(i)return console.warn(`[edit] attribute refused (${i}):`,e),!1;if(Lt(r.el,"attrs"))return!1;const s="data"!==r.kind&&Me(r.el);if(s)return function(e,t,n,r){if(Lt(t,"text")||e.el.getAttribute(n)===r)return!1;const o=document.activeElement===t,i=o&&void 0!==t._preEdit?t._preEdit:Uo(t),s=e.el.getAttribute(n),a=Uo(t),l=t=>null===t?e.el.removeAttribute(n):e.el.setAttribute(n,t);if(l(r),Uo(t)===a)return l(s),console.warn(`[edit] ${n} is not kept inside text`),!1;const c=z(t),d="component"===e.kind?Qe(e.area,t,"text",c,i):gt(ce(t),t,"text",c,{before:i});return o&&(ur(t),t._preEdit=Uo(t)),d}(r,s,e,o);if("class"===e)return Mr(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!=_r(r.el,e)&&console.warn(`[edit] ${e} is bound on this element; the binding will override the edited value`);const a=r.el.getAttribute(e);return a!==o&&(null===o?r.el.removeAttribute(e):r.el.setAttribute(e,o),gt(r.area,r.el,e,o,{before:a,coalesce:!0}))}function Mr(e,t){if("data"===e.kind)return console.warn("[edit] list rows are rendered from data; attributes on them are not editable"),!1;if(Me(e.el))return console.warn("[edit] class is not kept inside text"),!1;const n=Tr(e.el);return n!==(t=Sr(t).join(" "))&&(Cr(e.el,t),"component"===e.kind?null!=e.el._editPath&&(Er(e.area,e.el,"class",e.el.getAttribute("class")||""),Qe(e.area,e.el,"class",t,n)):!!/^[@~]/.test(e.el.getAttribute("data-edit-key")||"")&>(e.area,e.el,"class",t,{before:n,coalesce:!0}))}function jr(e,t){const n=Or(e);if(!n)return!1;if(Lt(n.el,"attrs"))return!1;const r=t(Sr(Tr(n.el)));return!!r&&Mr(n,r.join(" "))}const Pr={add(e,t){const n=Sr(e);return jr(t,e=>[...e,...n.filter(t=>!e.includes(t))])},remove(e,t){const n=new Set(Sr(e));return jr(t,e=>e.filter(e=>!n.has(e)))},toggle(e,t,n){const r=Or(t);if(!r)return!1;const o=Sr(e);return n??!o.every(e=>r.el.classList.contains(e))?Pr.add(e,r.el):Pr.remove(e,r.el)},set(e,t){const n=Or(t);return!!n&&!Lt(n.el,"attrs")&&Mr(n,e||"")},has(e,t){no&&no.version;const n=null==t?qt:t;return!!n&&1===n.nodeType&&Sr(e).every(e=>n.classList.contains(e))},list(e){no&&no.version;const t=null==e?qt:e;return t&&1===t.nodeType?Sr(Tr(t)):[]}},Rr=e=>{const t=e&&ce(e);return t&&"component"===me(t)?t:null};function $r(e){const t=Rr(null==e?qt:e);return t?t._editScope||"instance":null}function Nr(e){null==e&&(e=qt);const t=Rr(e);if(!t)return!1;if(e===t)Ke({kind:"cmp-inst",component:vr(n=t),region:de(n),path:"*",prop:"*",value:De}),Ge();else{if(null==e._editPath)return!1;!function(e,t){Ke({kind:"cmp-inst",component:vr(e),region:de(e),path:t._editPath,prop:"*",value:De}),Ge()}(t,e)}var n;return!0}const Br=new Set,Hr={},qr=new Set,zr=(e,t)=>(e||"")+"|"+t,Ir=e=>e&&Y[e]||document.documentElement,Dr=e=>e.value+(e.dataset.unit||"");let Wr=null;function Fr(e){const t=e._cssvar;if(!t||!("value"in e))return;const n=getComputedStyle(Ir(t.scope)).getPropertyValue(t.var).trim();if(!n)return;const r="color"===e.type?function(e){if(/^#[0-9a-f]{6}$/i.test(e))return e.toLowerCase();try{Wr=Wr||document.createElement("canvas");const t=Wr.getContext&&Wr.getContext("2d",{willReadFrequently:!0});if(!t)return null;const n=document.createElement("i");return n.style.color=e,n.style.color?(t.clearRect(0,0,1,1),t.fillStyle="#000",t.fillStyle=e,t.fillRect(0,0,1,1),"#"+[...t.getImageData(0,0,1,1).data.slice(0,3)].map(e=>e.toString(16).padStart(2,"0")).join("")):null}catch{return null}}(n):e.dataset.unit?String(parseFloat(n)):n;null!=r&&e.value!==r&&(e.value=r)}function Kr(e){const t=e._cssvar;if(!t||!t.var)return;const n=zr(t.scope,t.var);n in Hr||(Hr[n]=Ir(t.scope).style.getPropertyValue(t.var)),Fr(e),e._cvBound||(e._cvBound=!0,e.addEventListener("input",()=>Ir(t.scope).style.setProperty(t.var,Dr(e))),e.addEventListener("change",()=>{return function(e,t,n,r){if(!/^--[\w-]+$/.test(t||""))return void console.warn("[edit] x-edit.cssvar needs a custom property name (--name):",t);const o=function(e){const t=String(null==e?"":e);if(!t.trim())return"empty";if(/expression\s*\(/i.test(t))return"expression()";const n=[];for(let e=0;e<t.length;e++){const r=t[e];if('"'===r||"'"===r){let n=e+1;for(;n<t.length&&t[n]!==r;n++)if("\\"===t[n])n++;else if("\n"===t[n])return"unbalanced quotes";if(n>=t.length)return"unbalanced quotes";e=n;continue}if(/^url\(/i.test(t.slice(e,e+4))&&!/[\w-]/.test(t[e-1]||"")){let n=e+4,r=null,o="";for(;n<t.length;n++){const e=t[n];if(r){if("\\"===e){o+=t[++n]||"";continue}if(e===r){r=null;continue}o+=e}else if('"'!==e&&"'"!==e){if(")"===e)break;o+=e}else r=e}if(n>=t.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";e=n;continue}if(";"===r||"{"===r||"}"===r)return`contains ${r}`;if(t.startsWith("/*",e)||t.startsWith("\x3c!--",e)||t.startsWith("</",e))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=zr(e,t);qr.add(i),Ir(e).style.setProperty(t,n);const s=Ur()[i];s&&s.value===n||Ke({kind:"theme",scope:e||null,var:t,value:n},!!r)}(t.scope,t.var,Dr(e),t.persist||!!(n=t.scope&&Y[t.scope])&&!!(n._editPersist||n._edit&&n._edit.persist));var n}))}function Ur(){const e={};for(let t=0;t<c;t++){const n=l[t];"theme"===n.kind&&(e[zr(n.scope,n.var)]=n)}return e}function Jr(){const e=Ur();new Set([...qr,...Object.keys(e)]).forEach(t=>{qr.add(t);const n=t.indexOf("|"),r=t.slice(0,n)||null,o=t.slice(n+1),i=Ir(r),s=e[t]?e[t].value:Hr[t];s?i.style.setProperty(o,s):i.style.removeProperty(o)}),Br.forEach(Fr)}function Xr(e){const t=e&&Y[e];if(!t||ee(t))return null;const n=ce(t),r=t.getAttribute("data-edit-key");if(n&&"static"===me(n)&&!se(n)&&r&&/^[@~]/.test(r))return"area";if(n&&n!==t)return null;const o=ie(e);return o&&o!==t?null:"own"}const Vr=new Map;function Yr(e){const t=de(e),n=!e._marked;e._marked=!0,e._baseClass=e._baseClass||{},e._baseStyle=e._baseStyle||{},e._baseText=e._baseText||{};const r=Object.create(null),o=e=>{for(const t of e.children){const e=b(t);r[e]=(r[e]||0)+1,o(t)}},i=(s,a)=>{if(((o,i)=>{let s=o.getAttribute("data-edit-key");if(!s){if(n){const e=b(o),n=r[e]=(r[e]||0)+1;s=y(t,n>1?e+"#"+n:e),Vr.set(s,i)}else s="!"+w();o.setAttribute("data-edit-key",s)}s in e._baseClass||(e._baseClass[s]=Tr(o)),s in e._baseStyle||(e._baseStyle[s]=j(o)),s in e._baseText||o.children.length||(e._baseText[s]=o.innerHTML.trim())})(s,a),s!==e&&(e=>$(e)||m(e)||[...e.attributes].some(e=>e.name.startsWith("x-rich-text")))(s))return;if(s._editRt||(n||s._editRtFormat)&&Le(s)&&ue(s,"text")&&!m(s))return void(n&&o(s));let l=0;for(const e of s.children){if(be(e)||e.closest("[data-edit-ghost]")||k(e))continue;const o=""===a?String(l):a+"."+l;if(e._manifestComponent){if(ve(e))continue;if(!e.hasAttribute("data-edit-host")){const i=e.getAttribute("data-edit-key"),s=y(t,"X-"+e._manifestComponent.toUpperCase()+":");let a=i&&(i===s||i.startsWith(s+"#"))?i:"!"+w();if(n&&"!"===a[0]){const n="X-"+e._manifestComponent.toUpperCase()+":",i=r[n]=(r[n]||0)+1;a=y(t,i>1?n+"#"+i:n),Vr.set(a,o)}e.setAttribute("data-edit-host",a)}l++}else i(e,o),l++}};i(e,"")}const Gr=new Set,Qr=new Set,Zr=new Map;function eo(e){const t=function(e){if("data"!==me(e))return null;const t=(he(e)||"").match(/\$x\.([\w$]+)/);if(!t)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||{})[t[1]];return null==r?`data source '${t[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 '${t[1]}' is not a file (a cloud or remote source): save it with $x.${t[1]}.$update, not mnfst-run`}(e);t&&(Qr.add(de(e)),Zr.set(de(e),t),Gr.has(de(e))||(Gr.add(de(e)),console.warn(`[edit] x-edit="${de(e)}": ${t}; its edits stay on the page (and reach onPublish)`))),e._edit.rendered&&Qr.add(de(e)),e._edit.rendered&&!Gr.has(de(e))&&(Gr.add(de(e)),console.warn(`[edit] x-edit="${de(e)}" is inside content ${e._edit.rendered} renders: it edits on the page (and reaches onPublish), but mnfst-run cannot write it to a source file`)),dr(null);const n=me(e);"static"===n&&Yr(e),yn(e),[e,...e.querySelectorAll("[data-edit-area]")].forEach(e=>{var t,n;n="size",(t=e)._edit&&t._edit.caps.has(n)&&!Lt(t,n)&&Xn(e)}),"component"===n?wr(e):"static"===n&&function(e){br(e);const t=[...e.querySelectorAll("*")];ke(e).length&&!Le(e)||t.unshift(e),t.forEach(t=>{ke(t).length&&!Le(t)||!t.textContent.trim()||t.closest("template")||t.closest("[data-edit-handle], [x-edit\\.grab]")||t._manifestComponent&&t!==e||gr(t)||t.closest('[contenteditable="false"]:not([data-edit-piece-mode])')||!ue(t,"text")||m(t)||p.has(t.tagName)||/^[@~]/.test(t.getAttribute("data-edit-key")||"")&&(hr(t,n=>gt(ce(t)||e,t,"text",n??z(t))),lr(t,"html"))})}(e),"data"===n&&ue(e,"data")&&yr(e),e._editBound||(e._editBound=!0,e.addEventListener("pointerdown",On),e.addEventListener("keydown",t=>{io(e)&&Nn(t,e)}),e.addEventListener("dragstart",t=>{io(e)&&t.preventDefault()}),e.addEventListener("drop",t=>{io(e)&&t.preventDefault()})),e._editObserver||(e._editObserver=new MutationObserver(t=>{s||e._rearmQueued||t.every(e=>e.target.isContentEditable)||(e._rearmQueued=!0,queueMicrotask(()=>{e._rearmQueued=!1,e._armed&&io(e)&&!s&&eo(e)}))}),e._editObserver.observe(e,{childList:!0,subtree:!0}))}function to(e){[e,...e.querySelectorAll("[data-edit-area]")].forEach(e=>{e._editPos&&(e.style.removeProperty("position"),e._editPos=!1)}),e.querySelectorAll("[data-edit-handle]").forEach(e=>e.remove()),dr(e),[e,...e.querySelectorAll("[contenteditable]")].forEach(e=>{e.hasAttribute("contenteditable")&&e.removeAttribute("contenteditable"),e._pieceMode=!1,e.removeAttribute("data-edit-piece-mode")}),e.querySelectorAll("[data-edit-piece]").forEach(bn),[e,...e.querySelectorAll("[data-edit-area]")].forEach(e=>{e._sizeBound=!1}),hn&&e.contains(hn.item)&&Bn()}let no,ro=!1,oo=!1;const io=e=>!(!e||!e._edit||e._edit.gated&&(!no||!no.active)||se(e)),so=new Set;function ao(){const e=[];re().forEach(e=>{se(e)&&(so.has(de(e))||(so.add(de(e)),console.warn(`[edit] x-edit="${de(e)}" is on the page more than once (a component used several times); it is not editable here`)),e._armed&&(to(e),e._armed=!1))}),re().forEach(t=>{io(t)&&!t._armed&&(t._editBound||e.push(t),d[de(t)]=Ue(t,me(t)),eo(t),t._armed=!0)}),ro&&e.length&&(l.some(e=>/^st-/.test(e.kind))&&(pt(e),ht()),l.some(e=>"cmp-main"===e.kind||"cmp-inst"===e.kind)&&Ge()),Br.forEach(Kr),Ko(),ro=!0}function lo(e){const t=[],n=e=>e.edits||e.children||"~"===e.key[0],r=mt(ut()),o=new Set(Object.values(Ur()).filter(e=>e.scope&&"area"===Xr(e.scope)).map(e=>Y[e.scope]));ut().forEach(r=>{const i=de(r),s=ae(r),a=new Proxy({},{get:(e,t)=>{const n=v(String(t)),r=ie(decodeURIComponent(n.slice(1,n.indexOf("@",1)))),o=po&&r&&po[le(r)];return o?o[n]:void 0}}),l=(t,r)=>{const s=!r&&t.getAttribute("data-edit-host");if(s){if("!"===s[0])return null;const e={key:s},t=Vr.get(s);return null!=t&&(e.at=t),a&&a[s]&&(e.fp=a[s]),e}if(!r&&t._manifestComponent)return null;const c=t.getAttribute("data-edit-key");if(!c||"!"===c[0])return null;const d={key:c},u=Vr.get(v(c));null!=u&&(d.at=u),a&&a[v(c)]&&(d.fp=a[v(c)]);const f=(t=>{const n=e.node[t];if(!n)return null;const r={};return Object.entries(n).forEach(([e,t])=>{r[e]="class"!==e&&"style"!==e||""!==t?t:null}),Object.keys(r).length?r:null})(c);if(f&&(d.edits=f),o.has(t)&&(d.edits=Object.assign({},d.edits,{style:j(t)||null})),!(f&&"text"in f||m(t)||"TEMPLATE"===t.tagName||t.hasAttribute("data-rich-text"))){const o=(e=>ke(e).filter(e=>!k(e)))(t).map(e=>l(e)).filter(Boolean),s=e.touched.has(r?"#"+i:c);if("~"===c[0]||s){d.children=o;const t=s&&"~"!==c[0]&&(t=>{const n=""===t?(e.orderBase[i]||{})[""]:Object.values(e.orderBase).map(e=>e[t]).find(Boolean);return n?n.filter(e=>"@"===e[0]).map(e=>{const t={key:e},n=Vr.get(e);return null!=n&&(t.at=n),a&&a[e]&&(t.fp=a[e]),t}):null})(r?"":c);t&&(d.base=t)}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,t.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(e.orderBase),...Object.keys(e.order)]).forEach(t=>{Object.values(Object.assign({},e.orderBase[t]||{},e.order[t]||{})).forEach(e=>e.forEach(e=>i.add(e)))});const s=new Set;for(let e=0;e<c;e++){const t=l[e];"st-children"===t.kind&&t.before.forEach(e=>{!e||"@"!==e[0]||i.has(e)||r.has(e)||s.add(e)})}return s.forEach(e=>{const n=(e=>decodeURIComponent(e.slice(1,e.indexOf("@",1))))(e);let r=t.find(e=>e.region===n);if(!r){const e=ie(n);if(!e||se(e))return;const o=ae(e);r=o?{kind:"static-tree",region:n,component:o,tree:{key:""}}:{kind:"static-tree",region:n,tree:{key:""}},t.push(r)}(r.removed=r.removed||[]).push(e)}),t}function co(){const e=Object.entries(Bt()).map(([e,t])=>{return n=e,r=t.kind,o=t.snap,{region:n,kind:r,op:"reorderData",source:o.source,order:o.order};var n,r,o});lo(Ze()).forEach(t=>e.push(t));const t=e=>{const t=[];return Object.entries(e).forEach(([e,n])=>Object.entries(n).forEach(([n,r])=>t.push({path:e,key:e,prop:n,value:r}))),t},n=bt(),r={};l.slice(0,c).forEach(e=>{"data-val"===e.kind&&(r[e.source]=e.region)}),Object.entries(n).forEach(([t,n])=>Object.entries(n).forEach(([n,o])=>Object.entries(o).forEach(([o,i])=>e.push({kind:"data-val",region:r[t],source:t,id:n,field:o,value:i}))));const{main:o,inst:i,reverts:s}=Ve();return Object.entries(o).forEach(([n,r])=>{const o=t(r);o.length&&e.push({kind:"component",scope:"main",component:n,edits:o})}),new Set([...Object.keys(i),...Object.keys(s)]).forEach(n=>{const r=ie(n);if(!r)return;const o=t(i[n]||{}),a=[...s[n]||[]];(o.length||a.length)&&e.push({kind:"component",scope:"instance",component:vr(r),region:n,edits:o,reverts:a})}),function(){const e=Object.values(Ur()),t=[];return e.filter(e=>!Xr(e.scope)).forEach(e=>t.push({kind:"theme",scope:e.scope||null,var:e.var,value:e.value,file:null})),new Set(e.filter(e=>e.scope&&"own"===Xr(e.scope)).map(e=>e.scope)).forEach(e=>{const n=Y[e],r=(e=>{for(let t=e;t;t=t.parentElement)if(t._manifestComponent)return t._manifestComponent;return null})(n),o={key:"",edits:{style:j(n)||null}};t.push(r?{kind:"static-tree",region:e,component:r,tree:o}:{kind:"static-tree",region:e,tree:o})}),t}().forEach(t=>e.push(t)),e}function uo(e){const t=t=>"theme"===t.kind?!!e&&(e.has("theme|"+(t.scope||"")+"|"+t.var)||e.has(t.scope)):("st-move"===t.kind?[t.from,t.to]:[t.region]).some(t=>!(t=>null==t||!!ie(t)&&!(e&&e.has(t)))(t)),n=[],r=St();mt(ut().filter(t=>!(e&&e.has(de(t))))).forEach((e,t)=>{const o=r.get(t);o&&o.size&&n.push([e,new Map(o),t===e.getAttribute("data-edit-host")])});const i=l.slice(0,c).filter(e=>"lock"===e.kind&&!/^[~@]/.test(e.key)&&!t(e));let s=0;l=l.filter((e,n)=>{const r=t(e);return r&&n<c&&s++,r}),c=s,We++,T();const a=e?[...Vr].filter(([t])=>e.has(decodeURIComponent(t.slice(1,t.indexOf("@",1))))):[];Vr.clear(),a.forEach(([e,t])=>Vr.set(e,t)),re().forEach(t=>{if(e&&e.has(de(t)))return;const n=me(t);t._baseText={},t._baseClass={},t._baseStyle={},"static"===n&&([t,...t.querySelectorAll("[data-edit-key]")].forEach(e=>{ce(e)===t&&e.removeAttribute("data-edit-key")}),t.querySelectorAll("[data-edit-host]").forEach(e=>{ce(e.parentElement)===t&&e.removeAttribute("data-edit-host")}),t._marked=!1,Yr(t)),"component"===n&&t._armed&&wr(t),d[de(t)]=Ue(t,n)}),function(e){Object.keys(Hr).forEach(t=>{if(e&&e.has("theme|"+t))return;const n=t.indexOf("|");Hr[t]=Ir(t.slice(0,n)||null).style.getPropertyValue(t.slice(n+1))}),[...qr].forEach(t=>{e&&e.has("theme|"+t)||qr.delete(t)})}(e),(()=>{const e=e=>{l.splice(c,0,e),c++,fe(e.region)&&u.add(e)};i.forEach(e),n.forEach(([t,n,r])=>{const i=r?Ft(t):ce(t),s=t.getAttribute(r?"data-edit-host":"data-edit-key");i&&s&&[!0,!1].forEach(t=>{const r=[...n].filter(([,e])=>e===t).map(([e])=>e);r.length&&e({kind:"lock",region:de(i),key:s,actions:r.length===o.length?[]:r,value:t})})}),We++})(),T(),Ko()}const fo=e=>!(e&&Array.isArray(e.results)&&e.results.some(e=>e&&"error"===e.status));let mo=null,po=null,ho=null,go=null;const bo=new Set,yo=e=>{const t=v(e);if("string"!=typeof t||"@"!==t[0])return null;const n=ie(decodeURIComponent(t.slice(1,t.indexOf("@",1)))),r=ho&&n&&ho[le(n)];return r&&r[t]||null};function vo(e){if(!/^https?:$/.test(location.protocol)||"function"!=typeof fetch)return Promise.resolve(null);const t=fetch("/__edit/base",{cache:"no-store"}).then(e=>e.ok?e.json():null).then(t=>(t&&t.files&&(mo=t.files),t&&t.ids&&!e&&(po=t.ids,ho=t.cids||null),mo)).catch(()=>null);return e||(go=t),t}let Eo=!1;window.addEventListener("manifest:source-change",e=>{const t=e.detail||{},n=/\.html?$/i.test(t.file||"");n&&!po&&(Eo=!0),mo&&t.file&&t.hash&&!n&&(mo[t.file]=t.hash)});let wo=null,ko=0,Ao=[],_o=!1,xo=null;const So=e=>!_o&&!!wo&&Date.now()<wo.until&&e.length>0&&e.every(e=>e&&wo.files[e.rel]&&wo.files[e.rel]===e.hash);function To(e){const t=document.activeElement;if(!t||!t._commitText||void 0===t._preEdit||!t.isContentEditable||Uo(t)===t._preEdit)return!0;const n=ce(t);return!(!n||!e&&!n._edit.persist||(t._commitText(),ur(t),t._preEdit=Uo(t),0))}function Co(e){const t=new Map;for(let n=!0;n;)n=!1,l.slice(0,c).forEach(r=>{if("st-move"!==r.kind||e.has(r.from)===e.has(r.to))return;const[o,i]=e.has(r.from)?[r.from,r.to]:[r.to,r.from];e.add(i),t.set(i,t.get(o)||o),n=!0});return e.via=t,e}const Oo=e=>{if("string"!=typeof e)return null;const t=v(e);return"@"===t[0]?t.slice(1,t.indexOf("@",1)):null},Lo=e=>Qr.has(e.region)||Qr.has(e.from)||Qr.has(e.to)||Qr.has(Oo(e.path))||Qr.has(Oo(e.key)),Mo=e=>[...new Set(e.flatMap(e=>[e.region,e.from,e.to]).filter(Boolean))],jo=()=>l.slice(0,c).filter(e=>"lock"!==e.kind&&!u.has(e));function Po(){const e=document.activeElement,t=e&&e._commitText&&ce(e);return t?de(t):null}function Ro(){return!(!To(!1)&&!Qr.has(Po()))&&jo().every(Lo)}function $o(){const e=Po(),t=Mo(jo().filter(Lo));e&&Qr.has(e)&&!To(!1)&&!t.includes(e)&&t.push(e),t.length&&console.warn(`[edit] the source changed: reloading discards the unpublished edits of ${t.map(e=>`x-edit="${e}"`).join(", ")} that mnfst-run can't write (generated content, or a piece moved from it); .persist keeps them`)}function No(){$o(),location.reload()}function Bo(){xo&&Ro()&&(xo=null,No())}function Ho(e){if(Ro())return No();xo=e;const t=e.map(e=>e&&e.rel).filter(Boolean);no&&(no.stale=[...new Set([...no.stale||[],...t])]);const n=Mo(jo().filter(e=>!Lo(e))).filter(e=>!Qr.has(e)),r=Po();!r||Qr.has(r)||n.includes(r)||To(!1)||n.push(r);const o=Co(new Set(Qr)),i=n.filter(e=>o.has(e)),s=e=>e.map(e=>`x-edit="${e}"`).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(e=>o.via.get(e)))])}, 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:t}}))}function qo(e,t){if(ko=Math.max(0,ko-1),e&&e.base&&(wo={files:Object.assign({},e.base),until:Date.now()+3e3}),e&&Array.isArray(e.stale)&&e.stale.length&&(_o=!0),t&&fo(e)&&e.base&&(_o=!0,setTimeout(()=>{_o&&Ho(Object.keys(e.base).map(e=>({rel:e})))},1500)),ko)return;const n=Ao;Ao=[],n.some(e=>!So(e))&&Ho(n.flat())}window.addEventListener("manifest:live-reload",e=>{const t=e.detail&&e.detail.files||[];if(ko)return e.preventDefault(),void Ao.push(t);So(t)?e.preventDefault():Ro()?$o():(e.preventDefault(),Ho(t))});let zo=Promise.resolve();function Io(e){const t=zo.then(()=>function(e){const t=(e,t,n)=>{e&&e.base&&mo&&Object.entries(e.base).forEach(([e,t])=>{Do&&/\.html?$/i.test(e)||(mo[e]=t)}),e&&e.ids&&po&&(Do?Object.entries(e.ids).forEach(([e,t])=>{po[e]=Object.assign({},po[e]),Object.entries(t||{}).forEach(([t,n])=>{String(n).includes(".")||(po[e][t]=n)})}):po=e.ids,Do||(ho=e.cids||null,bo.clear()));const r=Do&&e&&e.cids&&ho?e.cids:null,o=r?function(){const e=l.slice(0,c),t=mt(ut()),n=new Map,r=new Set(e.filter(e=>"st-node"===e.kind).map(e=>e.path)),o=new Set;e.forEach(e=>{"st-children"!==e.kind&&"st-order"!==e.kind||o.add(e.parent),"st-move"===e.kind&&(o.add(e.fromParent),o.add(e.toParent))});const i=e=>!!e&&([e,...e.querySelectorAll("[data-edit-key]")].some(e=>r.has(e.getAttribute("data-edit-key")))||[...o].some(n=>{if(!n)return!1;const r=t.get(n);return!!r&&(r===e||e.contains(r))}));return t.forEach((e,o)=>{if("!"===o[0]||i(e))return n.set(e,null);if("~"===o[0]){const s=v(o);if(r.has(s)||[...r].some(e=>{const n=t.get(e),r=t.get(s);return n&&r&&r.contains(n)})||i(t.get(s)))return n.set(e,null)}n.set(e,yo(v(o)))}),n}():null,i=e&&Array.isArray(e.stale)?e.stale:[];return no&&(no.stale=i),i.length&&document.dispatchEvent(new CustomEvent("edit:stale",{detail:{files:i}})),fo(t?{results:e.results.filter(e=>!(e&&(t.has(e.region)||n&&n.has(e))))}:e)&&(uo(t),r&&function(e,t){const n=mt(ut());Object.entries(e).forEach(([e,r])=>{if(!/\.html?$/i.test(e))return;r=r||{};const o={};new Set(Object.keys(r).map(ot)).forEach(i=>{const s=Object.keys(r).filter(e=>ot(e)===i).sort(st),a=[...n.keys()].filter(t=>ot(t)===i&&(()=>{const r=ce(n.get(t));return r&&le(r)===e})()).sort(st).map(e=>t.has(n.get(e))?t.get(n.get(e)):null),l=s.map(e=>r[e]);a.some((e,t)=>(at(a,l,t)||[]).length)?bo.add(i):s.forEach(e=>{o[e]=r[e]})}),ho[e]=o})}(r,o)),Bo(),e},n=(e,t)=>{if(!e||!Array.isArray(e.results)||Array.isArray(e.stale)&&e.stale.length)return null;const n=new Set(e.results.filter(e=>e&&null!=e.failed).map(e=>e.failed)),r=new Set(t.filter((t,n)=>e.results[n]&&"error"===e.results[n].status&&null==e.results[n].failed&&"static-tree"!==t.kind));if(!n.size&&!r.size||e.results.some((e,o)=>e&&"error"===e.status&&!n.has(t[o]&&t[o].region)&&!r.has(t[o])))return null;Co(n);const o=e=>r.has(e)||null!=e.region&&n.has(e.region);return t.some(e=>!o(e))?Object.assign(n,{own:r,out:o}):null},r=e=>"theme"===e.kind?"theme|"+(e.scope||"")+"|"+e.var:e.region,o=e=>{const t=ie(e);return t&&t._edit.rendered},i=e=>null!=e.region&&"theme"!==e.kind&&Qr.has(e.region),s=()=>{To(!0);const s=co();if(no&&"function"==typeof no.onPublish)return Promise.resolve(no.onPublish(s,{log:l,cursor:c})).then(t);if(!s.length)return Bo(),Promise.resolve({results:[]});const a=e=>(ko++,fetch("/__edit/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({patches:e,base:mo})}).then(e=>e.json()).catch(e=>{throw qo(null),e})),d=Co(new Set(s.filter(i).map(e=>e.region))),u=e=>({region:e.region,status:"error",reason:Zr.has(e.region)&&i(e)?`x-edit="${e.region}": ${Zr.get(e.region)}`:o(e.region)&&i(e)?`x-edit="${e.region}" is inside content ${o(e.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(e.region)}", which mnfst-run can't write`}),f=s.filter(e=>!d.has(e.region)),m=(n,o,i)=>{const a=new Set([...d,...o||[],...o?i.filter(o.out).map(r):[]]),l=new Set,c=s.map(e=>{if(d.has(e.region)){const t=u(e);return l.add(t),t}const t=n.results[i.indexOf(e)];return o&&o.out(e)&&l.add(t),t}),f=t(Object.assign({},n,{results:c}),a.size?a:void 0,l);return qo(n,!(!e||!e.rebase)),f};if(!f.length){const e=t({results:s.map(u)},d);return Promise.resolve(e)}return a(f).then(e=>{const t=n(e,f);if(!t)return m(e,null,f);qo(e,!1);const r=f.filter(e=>!t.out(e));return a(r).then(n=>{const o=f.map((o,i)=>t.out(o)?e.results[i]&&"error"===e.results[i].status?e.results[i]:{region:o.region,status:"error",reason:`not published: tied by a move to x-edit="${t.via.get(o.region)||[...t].find(e=>!t.via.has(e))}", which failed`}:n.results[r.indexOf(o)]);return m(Object.assign({},n,{results:o}),t,f)})})},a=e=>{const n=co();return n.length?t({results:n.map(t=>({region:t.region,status:"error",reason:e}))}):{results:[]}},d=no&&"function"==typeof no.onPublish||mo&&po?Promise.resolve(null):Eo?Promise.resolve("the source changed before this page could read its base from the dev server; reload to continue"):vo().then(()=>mo&&po?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 e=Object.assign({},mo);return vo(!0).then(()=>(Object.keys(mo||{}).some(t=>/\.html?$/i.test(t)&&e[t]!==mo[t])&&(Do=!0),s()))};return d.then(t=>t?a(t):e&&e.rebase?u():s())}(e));return zo=t.catch(()=>{}),t}let Do=!1;function Wo(){no&&(no.active=!0),ao()}function Fo(){no&&(no.active=!1),re().forEach(e=>{e._edit.gated&&e._armed&&(to(e),e._armed=!1)}),Ko()}function Ko(){no&&(no.canUndo=c>0,no.canRedo=c<l.length,no.version=(no.version||0)+1,xo&&setTimeout(Bo,0))}const Uo=e=>e._editField&&!e._editRich?e.textContent:I(e,e.innerHTML.trim()),Jo=e=>!!e.closest('[data-edit-hotkeys="off"]');function Xo(){const e=document.activeElement;if(!e||void 0===e._preEdit||!e.isContentEditable)return;const t=()=>{document.activeElement===e&&(ur(e),e._preEdit=Uo(e))};t(),setTimeout(t,0)}function Vo(e){if(e.altKey||!e.metaKey&&!e.ctrlKey)return null;const t=(e.key||"").toLowerCase();return"z"===t?e.shiftKey?"redo":"undo":"y"!==t||!e.ctrlKey||e.metaKey||e.shiftKey?null:"redo"}function Yo(e){if(e.defaultPrevented||s)return;const t=Vo(e);if(!t)return;const n="redo"===t,r=e.target&&1===e.target.nodeType?e.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 e=ce(o);if(!e||!io(e)||Jo(o))return}else{if(r.isContentEditable)return;if(!re().some(e=>io(e)&&!Jo(e)))return}r.isContentEditable&&void 0!==r._preEdit&&Uo(r)!==r._preEdit||(n?c>=l.length:0===c)||(e.preventDefault(),n?Nt():$t())}function Go(){if(l.length){if(!ho&&go&&l.some(e=>e.ids||e.id)){const e=go;return go=null,void Promise.race([e,new Promise(e=>setTimeout(e,4e3))]).then(Go,Go)}!function(){const e=e=>("st-move"===e.kind?[e.from,e.to]:null!=e.region?[e.region]:[]).some(e=>{const t=ie(e);return t&&!t._edit.persist});if(!l.some(e))return;let t=0;const n=l.filter((n,r)=>{const o=!e(n);return o&&r<c&&t++,o});l=n,c=t,We++,T()}();for(const[e,t]of Object.entries(Bt())){const n=ie(e);n&&"data"===t.kind&&Qo(n,()=>Je(n,"data",t.snap))}if(l.some(e=>/^st-/.test(e.kind))&&(pt(re()),ht()),l.some(e=>"cmp-main"===e.kind||"cmp-inst"===e.kind)&&Ge(),l.some(e=>"data-val"===e.kind)){const e=re().find(e=>"data"===me(e));e&&Qo(e,yt)}l.some(e=>"theme"===e.kind)&&Jr(),l.some(e=>"lock"===e.kind)&&re().forEach(jt),Ko()}}function Qo(e,t){const n=he(e),r=h(e);let o=0;const i=setInterval(()=>{let e=!1;try{e=Array.isArray(window.Alpine.evaluate(r,n))}catch{}e?(clearInterval(i),t()):++o>100&&clearInterval(i)},50)}let Zo=!1;function ei(){if(Zo||!window.Alpine||!Alpine.directive)return;Zo=!0,document.body&&!document.body.hasAttribute("x-data")&&document.body.setAttribute("x-data","{}"),Alpine.directive("edit",(e,{modifiers:t,expression:n},{cleanup:r})=>{te(e,t,n),ro&&!oo&&(oo=!0,queueMicrotask(()=>{oo=!1,ao()})),r(()=>function(e){Object.keys(Y).forEach(t=>{Y[t]===e&&delete Y[t]}),Br.delete(e),V.has(e)&&(e._armed&&(to(e),e._armed=!1),e._editObserver&&(e._editObserver.disconnect(),e._editObserver=null),V.delete(e),delete e._edit,oe(),e.removeAttribute("data-edit-area"),qt&&(qt===e||e.contains(qt))&&It(null),Ko())}(e))}),Alpine.store("edit",{active:!1,canUndo:!1,canRedo:!1,version:0,stale:[],conflicts:[],onPublish:null,toggle(){this.active?Fo():Wo()},on(){Wo()},off(){Fo()},undo:()=>$t(),redo:()=>Nt(),publish:e=>Io(e),patches:()=>co(),export:()=>JSON.parse(JSON.stringify({log:l,cursor:c})),get target(){return this.version,qt},set target(e){(e=>{It(e&&1===e.nodeType?Wt(e)||e:null)})(e)},can(e,t){return this.version,tn(e,void 0===t?qt:t)},lock:(e,t)=>Mt(void 0===e?qt:e,t,!0),unlock:(e,t)=>Mt(void 0===e?qt:e,t,!1),copy:e=>nn(e),cut:e=>ln(e),paste:e=>cn(e),duplicate:e=>sn(e),remove:e=>an(e),move:(e,t,n)=>function(e,t,n){const r=Wt(null==e?qt:e);if(!r||!Ut(r))return!1;const o=Ft(r),i="string"==typeof t?ie(t):t;if(!i||1!==i.nodeType||i===r||r.contains(i))return!1;const s=ce(i);if(!(o&&s&&io(o)&&io(s)&&Jt(i)))return!1;n&&n.parentElement!==i&&(n=null);const a=r.parentElement;if(!Be(r,i))return!1;if("data"===me(o))return i===a&&($e(r,e=>i.insertBefore(e,n?Re(n):null)),jn(o,i),!0);if("static"!==me(o)||"static"!==me(s))return!1;if(o!==s&&Kt(r)&&!Ee(r))return!1;const l=A(a),c=A(i);return $e(r,e=>i.insertBefore(e,n?Re(n):null)),i===a?Et(o,i,l):(wt(o,s,r,a,l,c),!0)}(e,t,n),nest(e){const t=Wt(void 0===e?qt:e);return!!t&&Ut(t)&&qn(t)},unnest(e){const t=Wt(void 0===e?qt:e);return!!t&&Ut(t)&&zn(t)},block:e=>Dt(e),attr:(e,t,n)=>Lr(e,t,n),classes:Pr,scope(e,t){return this.version,e&&1===e.nodeType?$r(e):null==e?$r(t):function(e,t){const n=Rr(null==t?qt:t);return!(!n||"instance"!==e&&"main"!==e||(n._editScope=e,zt(),0))}(e,t)},revert:e=>Nr(e),clearConflicts(){_=[],this.conflicts=[],T()}}),no=Alpine.store("edit");const n=()=>Alpine.store("edit");Alpine.magic("edit",n),window.__manifestEditMagic=n;const r=window.__manifestEditStubWrites;r&&Object.keys(r).forEach(e=>{try{no[e]=r[e]}catch{}delete r[e]}),window.__manifestEditStub&&setTimeout(()=>{window.__manifestEditStub.v++},0),(()=>{try{t=location.pathname;const n=JSON.parse(localStorage.getItem(e(t)));n&&8===n.v?(l=n.log||[],c=n.cursor??l.length,l.forEach(e=>u.add(e)),_=Array.isArray(n.conflicts)?n.conflicts:[],_.forEach(e=>x.add(e)),no&&(no.conflicts=_.slice())):n&&localStorage.removeItem(e(t))}catch{}})(),window.__mnfstEdit&&vo(),setTimeout(()=>{const e=()=>{ao(),Go()};if(!ho&&go&&l.some(e=>e.ids||e.id)){const t=go;go=null,Promise.race([t,new Promise(e=>setTimeout(e,4e3))]).then(e,e)}else e()},450),document.addEventListener("keydown",Yo),window.addEventListener("click",ir,!0),window.addEventListener("auxclick",ir,!0),document.addEventListener("contextmenu",un,!0),document.addEventListener("dropdown:context",un,!0),window.addEventListener("manifest:route-change",()=>{t!==location.pathname&&(t=location.pathname,T())}),function(){if(!window.__manifestAlpineStarted&&![...document.querySelectorAll("[x-data]")].some(e=>e._x_marker))return;const e=e=>/^x-edit(\.|$)/.test(e),t=[...document.querySelectorAll("*")].filter(t=>!t._edit&&[...t.attributes].some(t=>e(t.name)));t.forEach(t=>{t._x_marker&&[...t.attributes].filter(t=>e(t.name)).forEach(e=>t.setAttribute(e.name,e.value))}),t.some(e=>!e._x_marker)&&Alpine.initTree(document.body)}()}document.addEventListener("alpine:init",ei),window.Alpine&&Alpine.directive&&setTimeout(ei,0)}();
|
|
2
2
|
//# sourceMappingURL=manifest.edit.min.js.map
|