@panphora/clayjs 0.2.1 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +103 -7
- package/clay-data.js +1 -1
- package/clay-internals.js +19 -0
- package/clay.js +19 -3
- package/package.json +5 -2
- package/sap.js +5 -5
- package/src/attrs/onaftersave.js +12 -1
- package/src/attrs/refetch-on-save.js +4 -4
- package/src/attrs/save-freeze.js +47 -19
- package/src/core/admin-contenteditable.js +2 -2
- package/src/core/admin-inputs.js +2 -2
- package/src/core/admin-onclick.js +2 -2
- package/src/core/admin-resources.js +23 -14
- package/src/core/autosave.js +11 -1
- package/src/core/edit-mode.js +2 -2
- package/src/core/host-attrs.js +46 -0
- package/src/core/is-edit-mode.js +14 -6
- package/src/core/persist.js +12 -2
- package/src/core/save-core.js +199 -290
- package/src/core/save.js +121 -82
- package/src/core/snapshot.js +89 -36
- package/src/core/unsaved-warning.js +8 -2
- package/src/dom/all.js +4 -29
- package/src/dom/form-data.js +1 -1
- package/src/dom/nearest.js +11 -9
- package/src/internals/index.js +69 -0
- package/src/lib/cache-bust.js +10 -0
- package/src/lib/cookie.js +50 -15
- package/src/lib/extension-noise.js +5 -1
- package/src/lib/mutation.js +65 -18
- package/src/lib/region-policy.js +17 -2
- package/src/lib/root-attrs.js +45 -0
- package/src/lib/throttle.js +25 -13
- package/src/loader.js +18 -24
- package/src/options/options.js +1 -3
- package/src/plugins/demo.js +7 -1
- package/src/plugins/undo.js +3 -3
- package/src/sync/live-sync.js +77 -76
- package/src/ui/dialogs.js +10 -1
- package/src/ui/index.js +0 -10
- package/src/utils/debounce.js +24 -7
- package/src/vendor/control-serialize.vendor.js +2 -1
- package/src/vendor/hyper-undo.vendor.js +1 -1
- package/src/vendor/hypercms.vendor.js +29 -16
- package/src/vendor/richclay.vendor.js +29 -22
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var hypercms=(()=>{var nt=Object.defineProperty;var Jr=Object.getOwnPropertyDescriptor;var Xr=Object.getOwnPropertyNames;var Zr=Object.prototype.hasOwnProperty;var ot=(e,t)=>{for(var r in t)nt(e,r,{get:t[r],enumerable:!0})},Qr=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Xr(t))!Zr.call(e,n)&&n!==r&&nt(e,n,{get:()=>t[n],enumerable:!(i=Jr(t,n))||i.enumerable});return e};var ei=e=>Qr(nt({},"__esModule",{value:!0}),e);var fo={};ot(fo,{cms:()=>uo,default:()=>po});var Re=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],st=new Set(Re),Ut=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Wt=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var Me={};ot(Me,{EmptyListInsert:()=>fe,MAX_RULE_DEPTH:()=>ie,MaxRuleDepthExceeded:()=>G,RuleTargetReadOnly:()=>ge,RulesParseError:()=>re,ShapeMismatch:()=>pe,UnknownRulesVersion:()=>ue,UpgradeAlreadyRegistered:()=>Te});var re=class extends Error{constructor(t,r){super(t),this.name="RulesParseError",this.cause=r}},ue=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},ie=20,G=class extends Error{constructor(t){super(`rule depth exceeded ${ie} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},pe=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},fe=class extends Error{constructor(t){super(`cannot add items to empty list at "${t.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=t}},ge=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},Te=class extends Error{constructor(){super("upgrade transform already registered; only one registration is allowed per page."),this.name="UpgradeAlreadyRegistered"}};function U(e,t,r,i={}){return at(e,t,r,{depth:0,path:[]},i)}function at(e,t,r,i,n){if(i.depth>ie)throw new G(i.path);if(typeof r=="string")return ti(e,t,r,n);if(Array.isArray(r)){let[o,a]=r;return e.find(t,o,n).map((l,c)=>at(e,l,a,{depth:i.depth+1,path:[...i.path,c]},n))}if(typeof r=="object"&&r!==null){let o={};for(let[a,s]of Object.entries(r))o[a]=at(e,t,s,{depth:i.depth+1,path:[...i.path,a]},n);return o}return null}function ti(e,t,r,i){if(r.endsWith("[]")){let o=r.slice(0,-2);return e.find(t,o,i).map(a=>e.text(a))}if(r.startsWith("@"))return Vt(e,t,r.slice(1));if(r.includes("@")){let o=r.lastIndexOf("@"),a=r.slice(0,o),s=r.slice(o+1),l=a?e.find(t,a,i):[t];return l.length===0?null:Vt(e,l[0],s)}if(r===".")return e.text(t);let n=e.find(t,r,i);return n.length===0?null:e.text(n[0])}function Vt(e,t,r){if(st.has(r)){let n=e.prop(t,r);return n==null?null:String(n)}let i=e.attr(t,r);return i||null}var ri=.5;function lt(e,t,r,i,n,o,a,s={}){let l=e.find(t,r,s);if(n.length===0){l.forEach(S=>e.remove(S));return}let c=n.length>l.length,m=l[0]||null;if(c&&!m&&(m=ai(e,t,r,s),!m))throw new fe(o.path);let d=l.map(S=>ii(e,S,i,s)),u=null;if(m){u=e.clone(m),s.templateAttr&&e.removeAttr(u,s.templateAttr);let S=e.stripIds(u);S>0&&console.warn(`[hyper-html-api] stripped ${S} id attribute(s) from cloned template at "${o.path.join(".")||"(root)"}"`)}let y=ni(n,d,i),x=l[0]||m,M=e.parent(x),b=l.length>0?si(e,M,x):0,T=new Set,E=n.map((S,C)=>{let A=y[C];if(A>=0)return T.add(A),l[A];let g=e.clone(u);return e.stripIds(g),g});l.forEach((S,C)=>{T.has(C)||e.remove(S)}),E.forEach((S,C)=>{let A=b+C;e.children(M).findIndex(h=>e.sameNode(h,S))!==A&&e.insertAt(M,S,A)}),E.forEach((S,C)=>{if(i===null){let A=n[C],g=A==null?"":String(A);e.text(S)!==g&&e.text(S,g)}else{let A=a(e,S,i,n[C],{depth:o.depth+1,path:[...o.path,C]},s);A&&A!==S&&(E[C]=A)}})}function ii(e,t,r,i){return r===null?e.text(t):U(e,t,r,i)}function ni(e,t,r){let i=new Array(e.length).fill(-1),n=new Set;return e.forEach((o,a)=>{let s=-1,l=-1;t.forEach((c,m)=>{if(n.has(m))return;let d=oi(o,c,r),u=d===l&&s>=0?Math.abs(m-a)<Math.abs(s-a):!1;(d>l||u)&&(l=d,s=m)}),l>=ri&&(i[a]=s,n.add(s))}),i}function oi(e,t,r){if(r===null)return e===t?1:0;let i=Object.keys(r||{});if(i.length===0)return 0;let n=0;for(let o of i)JSON.stringify(e?.[o])===JSON.stringify(t?.[o])&&n++;return n/i.length}function si(e,t,r){let i=e.children(t);for(let n=0;n<i.length;n++)if(e.sameNode(i[n],r))return n;return-1}function ai(e,t,r,i){if(!i.templateAttr)return null;let n=t;for(;n;){let o=e.find(n,r,{includeRulesTag:!1});for(let a of o)if(e.attr(a,i.templateAttr)!=null)return a;n=e.parent(n)}return null}var Kt=new Set(["checked","selected","disabled","readOnly","paused"]);function Y(e,t,r,i,n={}){let o=[];if(ct(r,i,[],o),o.length)throw new pe(o);Oe(e,t,r,i,{depth:0,path:[]},n)}function Oe(e,t,r,i,n,o={}){if(n.depth>ie)throw new G(n.path);if(i===void 0)return t;if(typeof r=="string")return li(e,t,r,i,n,o);if(Array.isArray(r)){let[a,s]=r;return lt(e,t,a,s,i,n,Oe,o),t}if(typeof r=="object"&&r!==null){for(let[a,s]of Object.entries(r)){let l=Oe(e,t,s,i==null?i:i[a],{depth:n.depth+1,path:[...n.path,a]},o);l&&l!==t&&(t=l)}return t}return t}function li(e,t,r,i,n,o){if(r.endsWith("[]")){let s=r.slice(0,-2);return lt(e,t,s,null,i,n,Oe,o),t}if(r.startsWith("@"))return Gt(e,t,r.slice(1),i);if(r.includes("@")){let s=r.lastIndexOf("@"),l=r.slice(0,s),c=r.slice(s+1),m=l?e.find(t,l,o):[t];return m.length===0||Gt(e,m[0],c,i),t}if(r===".")return e.text(t,i==null?"":String(i)),t;let a=e.find(t,r,o);return a.length===0||e.text(a[0],i==null?"":String(i)),t}function Gt(e,t,r,i){if(Wt.has(r))throw new ge(r);if(r==="outerHTML"){let n=i==null?"":String(i);return e.replaceWith(t,n)}return Ut.has(r)?(e.prop(t,r,ci(r,i)),t):(e.attr(t,r,i==null?"":String(i)),t)}function ci(e,t){return t==null?Kt.has(e)?!1:"":Kt.has(e)?!!t:t}function ct(e,t,r,i){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((n,o)=>{typeof n=="object"&&n!==null&&i.push({path:ke([...r,o]),expected:"scalar",got:be(n)})}):i.push({path:ke(r),expected:"array",got:be(t)});return}t!==null&&typeof t=="object"&&i.push({path:ke(r),expected:"scalar",got:be(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){i.push({path:ke(r),expected:"array",got:be(t)});return}let n=e[1];t.forEach((o,a)=>ct(n,o,[...r,a],i));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){i.push({path:ke(r),expected:"object",got:be(t)});return}for(let[n,o]of Object.entries(e))ct(o,t[n],[...r,n],i)}}}function be(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function ke(e){return e.join(".")}function dt(e){try{return JSON.parse(e)}catch(t){throw new re(`Invalid strict JSON: ${t.message}`,t)}}function ye(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function r(n){let o=[],a=0;for(;a<n.length;){let s=n[a];if(/\s/.test(s)){a++;continue}if("{}".includes(s)){o.push({type:s,value:s}),a++;continue}if(s==="["){let d=!1,u=a+1;for(;u<n.length&&/\s/.test(n[u]);)u++;if(u<n.length&&/[a-zA-Z_]/.test(n[u])&&(d=!0),!d){o.push({type:s,value:s}),a++;continue}}if(s==="]"){o.push({type:s,value:s}),a++;continue}if(s===":"){o.push({type:t.COLON,value:s}),a++;continue}if(s===","){o.push({type:t.COMMA,value:s}),a++;continue}if(s==='"'||s==="'"){let d=s,u=a+1;for(;u<n.length&&n[u]!==d;)n[u]==="\\"&&u++,u++;o.push({type:t.STRING,value:n.substring(a+1,u),quoted:!0,sourceQuote:d}),a=u+1;continue}let l=a,c;for(;l<n.length&&!/[{},]/.test(n[l]);)if(n[l]===":"){let d=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],u=!1;for(let y of d){let x=y.substring(1);if(n.substring(l+1,l+1+x.length)===x){u=!0,l+=x.length;break}}if(!u)break}else if(n[l]==="["){for(l++;l<n.length&&n[l]!=="]";){if(n[l]==='"'||n[l]==="'"){let d=n[l];for(l++;l<n.length&&n[l]!==d;)n[l]==="\\"&&l++,l++}l++}l<n.length&&n[l]==="]"&&l++}else l++;c=n.substring(a,l);let m=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(c)?m=t.NUMBER:c==="true"||c==="false"||c==="null"?m=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(c)&&(m=t.SELECTOR),o.push({type:m,value:c,quoted:!1}),a=l}return o}function i(n){let o="";for(let a=0;a<n.length;a++){let s=n[a];if("{}".includes(s.type)||"[]".includes(s.type)){o+=s.value;continue}if(s.type===t.COLON){o+=s.value;continue}if(s.type===t.COMMA){let l=n[a+1];if(l&&(l.type==="}"||l.type==="]"))continue;o+=s.value;continue}if(s.type===t.STRING&&s.quoted){let l=s.value;s.sourceQuote==="'"&&(l=l.replace(/\\'/g,"'"),l=l.replace(/(\\*)"/g,(c,m)=>m.length%2===0?m+'\\"':c)),o+=`"${l}"`;continue}if(s.type===t.NUMBER||s.type===t.BOOLEAN){o+=s.value;continue}if(s.type===t.SELECTOR||s.type===t.IDENTIFIER){o+=`"${s.value}"`;continue}o+=`"${s.value}"`}return o}try{let n=r(e),o=i(n);return JSON.parse(o)}catch(n){throw new re("Invalid extraction rules syntax: "+n.message,n)}}var di="1",Yt=/^[a-zA-Z0-9_-]+$/;function J(e,t,r){let i;if(r===void 0)i="script[data-rules-name]";else{if(typeof r!="string"||!Yt.test(r))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(r)} (must match ${Yt})`);i=`script[data-rules-name~="${r}"]`}let n=e.find(t,i,{includeRulesTag:!0});if(n.length===0)return null;r!==void 0&&n.length>1&&console.warn(`hyper-html-api: ${n.length} rules tags match data-rules-name~="${r}"; using the first.`);let o=n[0],a=e.attr(o,"data-rules-version");if(a!==di)throw new ue(a);return{rules:ye(e.text(o)),tagNode:o}}function mt(e,t,r){if(r&&typeof r=="object")return{rules:r,tagNode:null};if(typeof r=="string"){let i=t&&t.ownerDocument?t.ownerDocument:t;return J(e,i,r)}return null}function Jt(e,t,r,i){let n=mt(e,t,r);if(!n){let s=typeof r=="string"?`data-rules-name~="${r}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${s}`)}let{rules:o,tagNode:a}=n;return{rules:o,tagNode:a,get:()=>U(e,t,o,i),set:s=>Y(e,t,o,s,i)}}var Qt={includeClasses:!0,includeAttributes:["href","src","name","type","role","aria-label","alt","title"],excludeAttributePrefixes:["data-morph-","data-hyper-","data-im-"],textHintLength:64,excludeIds:!0,maxPathDepth:4,landmarks:["HEADER","NAV","MAIN","ASIDE","FOOTER","SECTION","ARTICLE"],weights:{signature:100,pathSegment:10,textMatch:20,textMismatch:25,uniqueCandidate:50,positionPenalty:1,slotMatch:30},minConfidence:101};function ui(e){let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t^e.charCodeAt(r);return Math.abs(t).toString(36)}function pi(e){if(e.classList&&e.classList.length>0)return Array.from(e.classList).sort().join(" ");let t=e.getAttribute?.("class");return t?t.split(/\s+/).filter(Boolean).sort().join(" "):""}function fi(e,t){let r=[];for(let i of e.attributes||[]){let n=i.name;n==="id"||n==="class"||t.excludeAttributePrefixes.some(o=>n.startsWith(o))||t.includeAttributes.includes(n)&&r.push(`${n}=${i.value}`)}return r.sort().join("|")}function gi(e,t){return(e.textContent||"").replace(/\s+/g," ").trim().slice(0,t.textHintLength)}function bi(e,t){let r=[e.tagName];return t.includeClasses&&r.push(pi(e)),r.push(fi(e,t)),ui(r.join("|"))}function ki(e){let t=e.tagName,r=1,i=e.previousElementSibling;for(;i;)i.tagName===t&&r++,i=i.previousElementSibling;return r}function yi(e,t){return e.id||e.getAttribute?.("role")?!0:t.landmarks.includes(e.tagName)}function vi(e){if(e.id)return`#${e.id}`;let t=e.getAttribute?.("role");return t?`@${t}`:e.tagName}function xi(e,t){let r=[],i=e;for(;i&&i.tagName&&r.length<t.maxPathDepth;){let n=`${i.tagName}:${ki(i)}`;if(r.unshift(n),i!==e&&yi(i,t)){r.unshift(vi(i));break}i=i.parentElement}return r}function wi(e,t){let r=0,i=e.length-1,n=t.length-1;for(;i>=0&&n>=0&&e[i]===t[n];)r++,i--,n--;return r}function P(e,t,r){if(r.has(e))return r.get(e);let i={signature:bi(e,t),path:xi(e,t),textHint:gi(e,t)};return r.set(e,i),i}function ir(e,t,r,i){if(i.has(e))return i.get(e);let n=new Map,o=e.querySelectorAll("*"),a=0;for(let s of o){let l=P(s,t,r);l.domIndex=a++,n.has(l.signature)||n.set(l.signature,[]),n.get(l.signature).push(s)}return i.set(e,n),n}function _i(e,t,r){r.delete(e),t.delete(e);let i=e.querySelectorAll("*");for(let n of i)t.delete(n)}function ht(e,t,r,i,n){let o=P(e,r,i),a=P(t,r,i),s=r.weights,l={},c=0;if(o.signature!==a.signature)return{score:0,breakdown:{rejected:"signature mismatch"}};c+=s.signature,l.signature=s.signature;let d=wi(o.path,a.path)*s.pathSegment;c+=d,l.path=d;let u=!0;if(o.textHint&&a.textHint?o.textHint===a.textHint?(c+=s.textMatch,l.text=s.textMatch):(c-=s.textMismatch,l.text=-s.textMismatch,u=!1):o.textHint!==a.textHint&&(c-=s.textMismatch,l.text=-s.textMismatch,u=!1),n.candidateCount===1&&u&&(c+=s.uniqueCandidate,l.unique=s.uniqueCandidate),typeof o.domIndex=="number"&&typeof a.domIndex=="number"){let y=Math.abs(o.domIndex-a.domIndex),x=Math.min(y*s.positionPenalty,20);c-=x,l.drift=-x}return{score:c,breakdown:l}}function er(e,t,r,i,n){if(r.excludeIds&&e.id)return null;let o=ir(t,r,i,n),a=P(e,r,i);if(typeof a.domIndex!="number"){let u=0,y=e.previousElementSibling;for(;y;)u++,y=y.previousElementSibling;a.domIndex=u}let s=o.get(a.signature)||[],l=r.excludeIds?s.filter(u=>!u.id):s;if(l.length===0)return null;let c=null,m=0,d=null;for(let u of l){let{score:y,breakdown:x}=ht(e,u,r,i,{candidateCount:l.length});y>m&&(m=y,c=u,d=x)}return m<r.minConfidence?null:{element:c,confidence:m,breakdown:d}}function Ai(e,t,r,i){let n=[],o=r.weights.signature+r.weights.slotMatch,a={slot:o};function s(d){if(d.children)return d.children;let u=d.childNodes;if(!u)return[];let y=[];for(let x=0;x<u.length;x++)u[x].nodeType===1&&y.push(u[x]);return y}function l(d,u){let y=s(d),x=s(u);if(y.length===x.length)for(let M=0;M<y.length;M++){let b=y[M],T=x[M];if(r.excludeIds&&(b.id||T.id)||b.tagName!==T.tagName)continue;let E=P(b,r,i).signature,S=P(T,r,i).signature;E!==S&&n.push({newEl:b,oldEl:T,score:o,breakdown:a}),l(b,T)}}function c(d,u){for(;;){if(d.tagName===u.tagName)return[d,u];let y=s(d);if(!d.tagName&&y.length===1){d=y[0];continue}let x=s(u);if(x.length===1&&x[0].tagName===d.tagName){u=x[0];continue}return null}}let m=c(e,t);return m&&l(m[0],m[1]),n}function tr(e,t,r,i,n){let o=t.querySelectorAll("*"),a=ir(e,r,i,n),s=0;for(let d of o){let u=P(d,r,i);u.domIndex=s++}let l=[];for(let d of o){if(r.excludeIds&&d.id)continue;let u=P(d,r,i),y=a.get(u.signature)||[],x=r.excludeIds?y.filter(M=>!M.id):y;for(let M of x){let{score:b,breakdown:T}=ht(d,M,r,i,{candidateCount:x.length});b>=r.minConfidence&&l.push({newEl:d,oldEl:M,score:b,breakdown:T})}}if(r.weights.slotMatch>0){let d=Ai(t,e,r,i);for(let u of d)l.push(u)}l.sort((d,u)=>u.score-d.score);let c=new Map,m=new Set;for(let{newEl:d,oldEl:u}of l)c.has(d)||m.has(u)||(c.set(d,u),m.add(u));return c}function rr(e,t,r,i){let n=P(e,r,i),o=P(t,r,i),{score:a,breakdown:s}=ht(e,t,r,i,{candidateCount:1});return{matches:a>=r.minConfidence,score:a,breakdown:s,newMeta:{signature:n.signature,path:n.path,textHint:n.textHint},oldMeta:{signature:o.signature,path:o.path,textHint:o.textHint}}}function nr(e={}){let t={...Qt,...e,weights:{...Qt.weights,...e.weights}},r=new WeakMap,i=new WeakMap;return{findMatch:(n,o)=>er(n,o,t,r,i),computeMatches:(n,o)=>tr(n,o,t,r,i),explain:(n,o)=>rr(n,o,t,r),invalidate:n=>_i(n,r,i),session:()=>{let n=new WeakMap,o=new WeakMap;return{findMatch:(a,s)=>er(a,s,t,n,o),computeMatches:(a,s)=>tr(a,s,t,n,o),explain:(a,s)=>rr(a,s,t,n)}},getConfig:()=>({...t})}}var Si=nr(),ut=(function(){"use strict";let e=()=>{};function t(b){if(!(b instanceof Element))return!1;if(b.hasAttribute("save-ignore"))return!0;if(b.tagName==="LINK"||b.tagName==="SCRIPT"){let T=b.getAttribute("src")||b.getAttribute("href")||"";if(T.startsWith("chrome-extension://")||T.startsWith("moz-extension://")||T.startsWith("safari-web-extension://"))return!0}return!1}function r(b,T){if(T!=="smart")return b.outerHTML;let E=b.getAttribute("src"),S=b.getAttribute("type")||"text/javascript";if(E)try{let C=new URL(E,window.location.href);return`ext:${S}:${C.origin}${C.pathname}${C.search}`}catch{return`ext:${S}:${E}`}else{let C=b.textContent.trim(),A=5381;for(let g=0;g<C.length;g++)A=(A<<5)+A^C.charCodeAt(g);return`inline:${S}:${Math.abs(A).toString(36)}`}}let i={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:e,afterNodeAdded:e,beforeNodeMorphed:e,afterNodeMorphed:e,beforeNodeRemoved:e,afterNodeRemoved:e,beforeAttributeUpdated:e},head:{style:"merge",shouldPreserve:b=>b.getAttribute("im-preserve")==="true",shouldReAppend:b=>b.getAttribute("im-re-append")==="true",shouldRemove:e,afterHeadMorphed:e},scripts:{handle:!1,matchMode:"outerHTML",shouldPreserve:b=>b.getAttribute("im-preserve")==="true",shouldReAppend:b=>b.getAttribute("im-re-append")==="true",shouldRemove:e,afterScriptsHandled:e},restoreFocus:!0},n={computeMatches(b,T){let{computeMatches:E}=Si.session();return E(b,T)}};function o(b,T,E={}){b=x(b);let S=M(T),C=y(b,S,E),A=C.scripts.matchMode,g=new Set(Array.from(b.querySelectorAll("script")).map(p=>r(p,A))),w=s(C,()=>m(C,b,S,p=>p.morphStyle==="innerHTML"?(l(p,b,S),Array.from(b.childNodes)):a(p,b,S)));C.pantry.remove();let h=u(b,g,C);return h.length>0?w instanceof Promise?w.then(p=>Promise.all(h).then(()=>p)):Promise.all(h).then(()=>w):w}function a(b,T,E){let S=M(T);return l(b,S,E,T,T.nextSibling),Array.from(S.childNodes)}function s(b,T){if(!b.config.restoreFocus)return T();let E=document.activeElement;if(!(E instanceof HTMLInputElement||E instanceof HTMLTextAreaElement))return T();let{id:S,selectionStart:C,selectionEnd:A}=E,g=T();return S&&S!==document.activeElement?.getAttribute("id")&&(E=b.target.querySelector(`[id="${S}"]`),E?.focus()),E&&!E.selectionEnd&&A!=null&&E.setSelectionRange(C,A),g}let l=(function(){function b(h,p,k,f=null,v=null){p instanceof HTMLTemplateElement&&k instanceof HTMLTemplateElement&&(p=p.content,k=k.content),f||=p.firstChild;for(let _ of k.childNodes){if(t(_))continue;if(f&&f!=v){let O=E(h,_,f,v);if(O){O!==f&&C(h,f,O),c(O,_,h),f=O.nextSibling;continue}}if(_ instanceof Element){let O=_.getAttribute("id");if(h.persistentIds.has(O)){let j=A(p,O,f,h);c(j,_,h),f=j.nextSibling;continue}if(!h.idMap.has(_)){let j=h.hyperMatches.get(_);if(j&&!h.idMap.has(j)){w(p,j,f),c(j,_,h),f=j.nextSibling;continue}}}let R=T(p,_,f,h);R&&(f=R.nextSibling)}for(;f&&f!=v;){let _=f;f=f.nextSibling,t(_)||S(h,_)}}function T(h,p,k,f){if(f.callbacks.beforeNodeAdded(p)===!1)return null;if(f.idMap.has(p)){let v=document.createElement(p.tagName);return h.insertBefore(v,k),c(v,p,f),f.callbacks.afterNodeAdded(v),v}else{let v=document.importNode(p,!0);return h.insertBefore(v,k),f.callbacks.afterNodeAdded(v),v}}let E=(function(){function h(f,v,_,R){let O=v instanceof Element&&!f.idMap.has(v)?f.hyperMatches.get(v):null,j=null,$=v.nextSibling,he=0,N=_;for(;N&&N!=R;){if(k(N,v)){if(p(f,N,v)||N===O&&!f.idMap.has(N))return N;if(j===null){let ee=N instanceof Element&&f.hyperMatchedOldElements.has(N);!f.idMap.has(N)&&!ee&&(j=N)}}if(j===null&&$&&k(N,$)&&(he++,$=$.nextSibling,he>=2&&(j=void 0)),f.activeElementAndParents.includes(N))break;N=N.nextSibling}return j||null}function p(f,v,_){let R=f.idMap.get(v),O=f.idMap.get(_);if(!O||!R)return!1;for(let j of R)if(O.has(j))return!0;return!1}function k(f,v){let _=f,R=v;return _.nodeType===R.nodeType&&_.tagName===R.tagName&&(!_.getAttribute?.("id")||_.getAttribute?.("id")===R.getAttribute?.("id"))}return h})();function S(h,p){let k=p instanceof Element&&h.hyperMatchedOldElements.has(p)&&!h.idMap.has(p);if(h.idMap.has(p)||k)w(h.pantry,p,null);else{if(h.callbacks.beforeNodeRemoved(p)===!1)return;p.parentNode?.removeChild(p),h.callbacks.afterNodeRemoved(p)}}function C(h,p,k){let f=p;for(;f&&f!==k;){let v=f;f=f.nextSibling,t(v)||S(h,v)}return f}function A(h,p,k,f){let v=f.target.getAttribute?.("id")===p&&f.target||f.target.querySelector(`[id="${p}"]`)||f.pantry.querySelector(`[id="${p}"]`);return g(v,f),w(h,v,k),v}function g(h,p){let k=h.getAttribute("id");for(;h=h.parentNode;){let f=p.idMap.get(h);f&&(f.delete(k),f.size||p.idMap.delete(h))}}function w(h,p,k){if(h.moveBefore)try{h.moveBefore(p,k)}catch{h.insertBefore(p,k)}else h.insertBefore(p,k)}return b})(),c=(function(){function b(g,w,h){return h.ignoreActive&&g===document.activeElement?null:(h.callbacks.beforeNodeMorphed(g,w)===!1||(g instanceof HTMLHeadElement&&h.head.ignore||(g instanceof HTMLHeadElement&&h.head.style!=="morph"?d(g,w,h):(T(g,w,h),A(g,h)||l(h,g,w))),h.callbacks.afterNodeMorphed(g,w)),g)}function T(g,w,h){let p=w.nodeType;if(p===1){let k=g,f=w,v=k.attributes,_=f.attributes;for(let R of _)C(R.name,k,"update",h)||k.getAttribute(R.name)!==R.value&&k.setAttribute(R.name,R.value);for(let R=v.length-1;0<=R;R--){let O=v[R];if(O&&!f.hasAttribute(O.name)){if(C(O.name,k,"remove",h))continue;k.removeAttribute(O.name)}}A(k,h)||E(k,f,h)}(p===8||p===3)&&g.nodeValue!==w.nodeValue&&(g.nodeValue=w.nodeValue)}function E(g,w,h){if(g instanceof HTMLInputElement&&w instanceof HTMLInputElement&&w.type!=="file"){let p=w.value,k=g.value;S(g,w,"checked",h),S(g,w,"disabled",h),h.formStateSync==="property"?k!==p&&(C("value",g,"update",h)||(g.value=p)):w.hasAttribute("value")?k!==p&&(C("value",g,"update",h)||(g.setAttribute("value",p),g.value=p)):C("value",g,"remove",h)||(g.value="",g.removeAttribute("value"))}else if(g instanceof HTMLOptionElement&&w instanceof HTMLOptionElement)S(g,w,"selected",h);else if(g instanceof HTMLTextAreaElement&&w instanceof HTMLTextAreaElement){let p=w.value,k=g.value;if(C("value",g,"update",h))return;p!==k&&(g.value=p),g.firstChild&&g.firstChild.nodeValue!==p&&(g.firstChild.nodeValue=p)}}function S(g,w,h,p){let k=w[h],f=g[h];if(k!==f){let v=C(h,g,"update",p);if(v||(g[h]=w[h]),p.formStateSync==="property")return;k?v||g.setAttribute(h,""):C(h,g,"remove",p)||g.removeAttribute(h)}}function C(g,w,h,p){return g==="value"&&p.ignoreActiveValue&&w===document.activeElement?!0:p.callbacks.beforeAttributeUpdated(g,w,h)===!1}function A(g,w){return!!w.ignoreActiveValue&&g===document.activeElement&&g!==document.body}return b})();function m(b,T,E,S){if(b.head.block){let C=T.querySelector("head"),A=E.querySelector("head");if(C&&A){let g=d(C,A,b);return Promise.all(g).then(()=>{let w=Object.assign(b,{head:{block:!1,ignore:!0}});return S(w)})}}return S(b)}function d(b,T,E){let S=[],C=[],A=[],g=[],w=E.scripts.matchMode,h=f=>{if(f.tagName==="SCRIPT")return r(f,w);if(f.tagName==="LINK"&&w==="smart"){let v=f.getAttribute("href");if(v)try{let _=new URL(v,window.location.href);return`link:${f.getAttribute("rel")||""}:${_.origin}${_.pathname}${_.search}`}catch{}}return f.outerHTML},p=new Map;for(let f of T.children)t(f)||p.set(h(f),f);for(let f of b.children){let v=h(f),_=p.has(v),R=E.head.shouldReAppend(f),O=E.head.shouldPreserve(f);_||O?R?C.push(f):(p.delete(v),A.push(f)):E.head.style==="append"?R&&(C.push(f),g.push(f)):E.head.shouldRemove(f)!==!1&&!t(f)&&C.push(f)}g.push(...p.values());let k=[];for(let f of g){let v=document.createRange().createContextualFragment(f.outerHTML).firstChild;if(E.callbacks.beforeNodeAdded(v)!==!1){if("href"in v&&v.href||"src"in v&&v.src){let _,R=new Promise(function(O){_=O});v.addEventListener("load",function(){_()}),k.push(R)}b.appendChild(v),E.callbacks.afterNodeAdded(v),S.push(v)}}for(let f of C)E.callbacks.beforeNodeRemoved(f)!==!1&&(b.removeChild(f),E.callbacks.afterNodeRemoved(f));return E.head.afterHeadMorphed(b,{added:S,kept:A,removed:C}),k}function u(b,T,E){if(!E.scripts.handle)return[];let S=[],C=[],A=[],g=[],w=E.scripts.matchMode,h=Array.from(b.querySelectorAll("script"));for(let k of h){let f=r(k,w),v=T.has(f),_=E.scripts.shouldPreserve(k),R=E.scripts.shouldReAppend(k);v||_?R?(C.push(k),g.push(k)):A.push(k):g.push(k)}for(let k of T){let f=h.some(v=>v.outerHTML===k)}let p=[];for(let k of g){if(E.callbacks.beforeNodeAdded(k)===!1)continue;let f=document.createRange().createContextualFragment(k.outerHTML).firstChild;if(f.src){let v,_=new Promise(function(R){v=R});f.addEventListener("load",function(){v()}),f.addEventListener("error",function(){v()}),p.push(_)}k.replaceWith(f),E.callbacks.afterNodeAdded(f),S.push(f)}return E.scripts.afterScriptsHandled(b,{added:S,kept:A,removed:C}),p}let y=(function(){function b(h,p,k){let{persistentIds:f,idMap:v}=g(h,p),_=n.computeMatches(h,p);if(typeof k.key=="function"){let $=new Map,he=new Set,N=F=>{let I=k.key(F);I!=null&&($.has(I)?he.add(I):$.set(I,F))};h instanceof Element&&N(h);for(let F of h.querySelectorAll("*"))N(F);for(let F of he)$.delete(F);let ee=new Map;for(let[F,I]of _)ee.set(I,F);let tt=p.__hyperMorphRoot||p,Ce=new Map,Ht=new Set,zt=F=>{let I=k.key(F);I!=null&&(Ce.has(I)?Ht.add(I):Ce.set(I,F))};tt instanceof Element&&zt(tt);for(let F of tt.querySelectorAll("*"))zt(F);for(let F of Ht)Ce.delete(F);for(let[F,I]of Ce){let te=$.get(F);if(!te||te.tagName!==I.tagName)continue;let rt=ee.get(te);rt&&rt!==I&&_.delete(rt);let it=_.get(I);it&&it!==te&&ee.delete(it),_.set(I,te),ee.set(te,I)}}let R=new Set;for(let $ of _.values())R.add($);let O=T(k),j=O.morphStyle||"outerHTML";if(!["innerHTML","outerHTML"].includes(j))throw`Do not understand how to morph style ${j}`;return{target:h,newContent:p,config:O,morphStyle:j,ignoreActive:O.ignoreActive,ignoreActiveValue:O.ignoreActiveValue,restoreFocus:O.restoreFocus,formStateSync:O.formStateSync||"attribute",idMap:v,persistentIds:f,hyperMatches:_,hyperMatchedOldElements:R,pantry:E(),activeElementAndParents:S(h),callbacks:O.callbacks,head:O.head,scripts:O.scripts}}function T(h){let p=Object.assign({},i);return Object.assign(p,h),p.callbacks=Object.assign({},i.callbacks,h.callbacks),p.head=Object.assign({},i.head,h.head),p.scripts=Object.assign({},i.scripts,h.scripts),p}function E(){let h=document.createElement("div");return h.hidden=!0,document.body.insertAdjacentElement("afterend",h),h}function S(h){let p=[],k=document.activeElement;if(k?.tagName!=="BODY"&&h.contains(k))for(;k&&(p.push(k),k!==h);)k=k.parentElement;return p}function C(h){let p=Array.from(h.querySelectorAll("[id]"));return h.getAttribute?.("id")&&p.push(h),p}function A(h,p,k,f){for(let v of f){let _=v.getAttribute("id");if(p.has(_)){let R=v;for(;R;){let O=h.get(R);if(O==null&&(O=new Set,h.set(R,O)),O.add(_),R===k)break;R=R.parentElement}}}}function g(h,p){let k=C(h),f=C(p),v=w(k,f),_=new Map;A(_,v,h,k);let R=p.__hyperMorphRoot||p;return A(_,v,R,f),{persistentIds:v,idMap:_}}function w(h,p){let k=new Set,f=new Map;for(let{id:_,tagName:R}of h)f.has(_)?k.add(_):f.set(_,R);let v=new Set;for(let{id:_,tagName:R}of p)v.has(_)?k.add(_):f.get(_)===R&&v.add(_);for(let _ of k)v.delete(_);return v}return b})(),{normalizeElement:x,normalizeParent:M}=(function(){let b=new WeakSet;function T(A){return A instanceof Document?A.documentElement:A}function E(A){if(A==null)return document.createElement("div");if(typeof A=="string")return E(C(A));if(b.has(A))return A;if(A instanceof Node){if(A.parentNode)return new S(A);{let g=document.createElement("div");return g.append(A),g}}else{let g=document.createElement("div");for(let w of[...A])g.append(w);return g}}class S{constructor(g){this.originalNode=g,this.realParentNode=g.parentNode,this.previousSibling=g.previousSibling,this.nextSibling=g.nextSibling}get childNodes(){let g=[],w=this.previousSibling?this.previousSibling.nextSibling:this.realParentNode.firstChild;for(;w&&w!=this.nextSibling;)g.push(w),w=w.nextSibling;return g}querySelectorAll(g){return this.childNodes.reduce((w,h)=>{if(h instanceof Element){h.matches(g)&&w.push(h);let p=h.querySelectorAll(g);for(let k=0;k<p.length;k++)w.push(p[k])}return w},[])}insertBefore(g,w){return this.realParentNode.insertBefore(g,w)}moveBefore(g,w){return this.realParentNode.moveBefore(g,w)}get __hyperMorphRoot(){return this.originalNode}}function C(A){let g=new DOMParser,w=A.replace(/<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim,"");if(w.match(/<\/html>/)||w.match(/<\/head>/)||w.match(/<\/body>/)){let h=g.parseFromString(A,"text/html");if(w.match(/<\/html>/))return b.add(h),h;{let p=h.firstChild;return p&&b.add(p),p}}else{let p=g.parseFromString("<body><template>"+A+"</template></body>","text/html").body.querySelector("template").content;return b.add(p),p}}return{normalizeElement:T,normalizeParent:E}})();return{morph:o,defaults:i}})();var es=ut.morph,ts=ut.defaults,pt=ut;var Mi=null;function Le(){return Mi}function Ne(e,t){let r={carriedOver:0,discarded:0,listItems:0},i=ft(t,e,r);return gt(t,e,r),{data:i,summary:r}}function ft(e,t,r){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(t)?(r.listItems+=t.length,r.carriedOver+=t.length,t):void 0:t==null?void 0:(r.carriedOver++,t);if(Array.isArray(e)){let[,i]=e;return Array.isArray(t)?(r.listItems+=t.length,t.map(n=>ft(i,n,r))):void 0}if(typeof e=="object"&&e!==null){let i={};for(let[n,o]of Object.entries(e)){let a=ft(o,t?.[n],r);a!==void 0&&(i[n]=a)}return i}}function gt(e,t,r){if(t!=null){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(typeof t!="object"||Array.isArray(t))return;let i=new Set(Object.keys(e));for(let n of Object.keys(t))i.has(n)?gt(e[n],t[n],r):r.discarded+=je(t[n]);return}if(Array.isArray(e)&&Array.isArray(t)){let i=e[1];t.forEach(n=>gt(i,n,r));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(r.discarded+=je(t))}}function je(e){return e==null?0:Array.isArray(e)?e.reduce((t,r)=>t+je(r),0):typeof e=="object"?Object.values(e).reduce((t,r)=>t+je(r),0):1}function Oi(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Li(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var ji={find(e,t,r={}){let i=Li(e);if(!i||!i.querySelectorAll)return[];let n=Array.from(i.querySelectorAll(t));r.includeRulesTag||(n=n.filter(a=>!Oi(a)));let o=[];if(r.skip&&o.push(r.skip),r.templateAttr&&o.push("["+r.templateAttr+"]"),o.length){let a=o.join(", ");n=n.filter(s=>!s.closest||!s.closest(a))}return n},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t},attr(e,t,r){if(r===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,r)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t)},prop(e,t,r){if(r===void 0){let i=e?e[t]:void 0;return i!==void 0?i:null}e[t]=r},clone(e){return e.cloneNode(!0)},insertAt(e,t,r){let i=e.children[r]||null;e.insertBefore(t,i)},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let i=e.ownerDocument.createElement("template");i.innerHTML=t;let n=i.content.firstElementChild;if(!n)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(n,e),n},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(i=>{i.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}},H=ji;var Ni="_hyperHtmlApi",Fi="upgrade-helper",Ii="parentOrigin";function yt(e=typeof location<"u"?location:null){if(!e)return!1;try{return new URLSearchParams(e.search).get(Ni)===Fi}catch{return!1}}function or(e=typeof location<"u"?location:null){return e?new URLSearchParams(e.search).get(Ii):null}function vt({win:e,doc:t,parentOrigin:r}={}){if(e=e||(typeof window<"u"?window:null),t=t||(typeof document<"u"?document:null),!e||!t||(r=r||or(e.location),!r))return;let i=()=>qi({win:e,doc:t,parentOrigin:r});t.readyState==="loading"?t.addEventListener("DOMContentLoaded",i,{once:!0}):i()}function qi({win:e,doc:t,parentOrigin:r}){let i;try{i=J(H,t.body)}catch(l){return bt(e,r,l)}if(!i)return bt(e,r,new Error("helper-mode: no rules tag in v2 document"));let n=i.rules,o=$i(t,"hyper-version"),a=!!Le(),s=l=>{if(l.source!==e.parent||l.origin!==r)return;let c=l.data;if(!(!c||c.type!=="hha:upgrade-data")){e.removeEventListener("message",s);try{let m=Di({doc:t,rules:n,v1Data:c.v1Data});e.parent.postMessage({type:"hha:upgrade-result",html:m.html,summary:m.summary},r)}catch(m){bt(e,r,m)}}};e.addEventListener("message",s),e.parent.postMessage({type:"hha:upgrade-ready",rules:n,version:o,hasTransform:a},r)}function Di({doc:e,rules:t,v1Data:r}){let i=Le(),n=r,o=!1;i&&(n=i(r),o=!0);let{data:a,summary:s}=Ne(n,t);Y(H,e.body,t,a);let l=U(H,e.body,t);return{html:`<!DOCTYPE html>
|
|
2
|
-
`+e.documentElement.outerHTML,summary:{...s,transformApplied:o,appliedFieldCount:kt(l)}}}function bt(e,t,r){e.parent.postMessage({type:"hha:upgrade-error",name:r?.name||"Error",message:r?.message||String(r)},t)}function $i(e,t){let r=e.querySelector(`meta[name="${t}"]`);return r?r.getAttribute("content"):null}function kt(e){return e==null?0:Array.isArray(e)?e.reduce((t,r)=>t+kt(r),0):typeof e=="object"?Object.values(e).reduce((t,r)=>t+kt(r),0):1}var q={extract:(e,t,r)=>U(H,e,t,r),apply:(e,t,r,i)=>Y(H,e,t,r,i),findRulesIn:(e,t)=>J(H,e,t),findRules:(e,t)=>mt(H,e,t),bind:(e,t,r)=>Jt(H,e,t,r),parseStrict:dt,parseRelaxed:ye,errors:Me,DOM_PROPERTIES:Re};typeof window<"u"&&yt(window.location)&&vt({win:window,doc:document});var wt={};ot(wt,{fromString:()=>W,getRuleAtPath:()=>X,getValueAtPath:()=>Ui,setAtPath:()=>xt,toString:()=>zi});function zi(e){return e.map(String).join(".")}function W(e){return e===""?[]:e.split(".").map(t=>/^\d+$/.test(t)?Number(t):t)}function X(e,t){let r=e;for(let i of t){if(r==null)return;if(typeof r=="string"){if(r.endsWith("[]")&&(typeof i=="number"||i==="*")){r=r.slice(0,-2);continue}return}if(Array.isArray(r)){if(typeof i!="number"&&i!=="*")return;r=r[1];continue}if(typeof r=="object"){if(typeof i=="number"||!(i in r))return;r=r[i];continue}return}return r}function Ui(e,t){let r=e;for(let i of t){if(r==null)return;r=r[i]}return r}function xt(e,t,r){if(t.length===0)return r;let[i,...n]=t;if(typeof i=="number"){let o=Array.isArray(e)?[...e]:[];return o[i]=xt(o[i],n,r),o}return{...e&&typeof e=="object"?e:{},[i]:xt((e||{})[i],n,r)}}function ve(e){if(typeof e=="string")return e.endsWith("[]")?[]:"";if(Array.isArray(e))return[];if(typeof e=="object"&&e!==null){let t={};for(let[r,i]of Object.entries(e))t[r]=ve(i);return t}return""}function Fe(e,t,{ignoreActiveValue:r=!0}={}){pt.morph(e,t,{morphStyle:"innerHTML",ignoreActiveValue:r,restoreFocus:!0,formStateSync:"property"})}function qe(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/[-_]/g," ").replace(/\s+/g," ").trim().replace(/^./,t=>t.toUpperCase())}var Wi='<div class="hcms-drag-handle mirk-sortable__grip" aria-hidden="true"><div class="mirk-sortable__dots"><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span></div></div>',_t='<svg class="hcms-x" viewBox="0 0 16 16" shape-rendering="crispEdges" aria-hidden="true"><path d="M4 4 L12 12 M12 4 L4 12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square"></path></svg>',lr={"@scalar":`
|
|
1
|
+
var hypercms=(()=>{var St=Object.defineProperty;var Fn=Object.getOwnPropertyDescriptor;var qn=Object.getOwnPropertyNames;var Dn=Object.prototype.hasOwnProperty;var Et=(e,t)=>{for(var r in t)St(e,r,{get:t[r],enumerable:!0})},$n=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of qn(t))!Dn.call(e,i)&&i!==r&&St(e,i,{get:()=>t[i],enumerable:!(n=Fn(t,i))||n.enumerable});return e};var Bn=e=>$n(St({},"__esModule",{value:!0}),e);var bs={};Et(bs,{cms:()=>fs,default:()=>gs});function z(e){let t=0,r=null,n=-1;for(let i=0;i<e.length;i++){let o=e[i];o==="\\"?i++:r?o===r&&(r=null):o==='"'||o==="'"?r=o:o==="["||o==="("?t++:o==="]"||o===")"?t>0&&t--:o==="@"&&t===0&&(n=i)}return n}function Ke(e){let t=z(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}var pr={includeClasses:!0,includeAttributes:["href","src","name","type","role","aria-label","alt","title"],excludeAttributePrefixes:["data-morph-","data-hyper-","data-im-"],textHintLength:64,excludeIds:!0,maxPathDepth:4,landmarks:["HEADER","NAV","MAIN","ASIDE","FOOTER","SECTION","ARTICLE"],weights:{signature:100,pathSegment:10,textMatch:20,textMismatch:25,uniqueCandidate:50,positionPenalty:1,maxDriftPenalty:19,slotMatch:30},minConfidence:101,maxScoredCandidates:16};function zn(e){let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t^e.charCodeAt(r);return Math.abs(t).toString(36)}function Un(e){if(e.classList&&e.classList.length>0)return Array.from(e.classList).sort().join(" ");let t=e.getAttribute?.("class");return t?t.split(/\s+/).filter(Boolean).sort().join(" "):""}function Hn(e,t){let r=[];for(let n of e.attributes||[]){let i=n.name;i==="id"||i==="class"||t.excludeAttributePrefixes.some(o=>i.startsWith(o))||t.includeAttributes.includes(i)&&r.push(`${i}=${n.value}`)}return r.sort().join("|")}function Vn(e,t){return(e.textContent||"").replace(/\s+/g," ").trim().slice(0,t.textHintLength)}function Wn(e,t){let r=[e.tagName];return t.includeClasses&&r.push(Un(e)),r.push(Hn(e,t)),zn(r.join("|"))}function Kn(e){let t=e.tagName,r=1,n=e.previousElementSibling;for(;n;)n.tagName===t&&r++,n=n.previousElementSibling;return r}function Gn(e,t){return e.getAttribute?.("id")||e.getAttribute?.("role")?!0:t.landmarks.includes(e.tagName)}function Jn(e){let t=e.getAttribute?.("id");if(t)return`#${t}`;let r=e.getAttribute?.("role");return r?`@${r}`:e.tagName}function Yn(e,t){let r=[],n=e;for(;n&&n.tagName&&r.length<t.maxPathDepth;){let i=`${n.tagName}:${Kn(n)}`;if(r.unshift(i),n!==e&&Gn(n,t)){r.unshift(Jn(n));break}n=n.parentElement}return r}function Xn(e,t){let r=0,n=e.length-1,i=t.length-1;for(;n>=0&&i>=0&&e[n]===t[i];)r++,n--,i--;return r}function X(e,t,r){if(r.has(e))return r.get(e);let n={signature:Wn(e,t),path:Yn(e,t),textHint:Vn(e,t)};return r.set(e,n),n}function kr(e,t,r,n){if(n.has(e))return n.get(e);let i=new Map,o=e.querySelectorAll("*"),a=0;for(let s of o){let l=X(s,t,r);l.domIndex=a++,!t.shouldIgnore?.(s)&&(i.has(l.signature)||i.set(l.signature,[]),i.get(l.signature).push(s))}return n.set(e,i),i}function Zn(e,t,r){r.delete(e),t.delete(e);let n=e.querySelectorAll("*");for(let i of n)t.delete(i)}function Ct(e,t,r,n,i){let o=X(e,r,n),a=X(t,r,n),s=r.weights,l={},c=0;if(o.signature!==a.signature)return{score:0,breakdown:{rejected:"signature mismatch"}};c+=s.signature,l.signature=s.signature;let p=Xn(o.path,a.path)*s.pathSegment;c+=p,l.path=p;let d=!0;if(o.textHint&&a.textHint?o.textHint===a.textHint?(c+=s.textMatch,l.text=s.textMatch):(c-=s.textMismatch,l.text=-s.textMismatch,d=!1):o.textHint!==a.textHint&&(c-=s.textMismatch,l.text=-s.textMismatch,d=!1),i.candidateCount===1&&d&&(c+=s.uniqueCandidate,l.unique=s.uniqueCandidate),typeof o.domIndex=="number"&&typeof a.domIndex=="number"){let f=Math.abs(o.domIndex-a.domIndex),k=Math.min(f*s.positionPenalty,s.maxDriftPenalty);c-=k,l.drift=-k}return{score:c,breakdown:l}}function fr(e,t,r,n,i){if(r.excludeIds&&e.getAttribute("id"))return null;let o=kr(t,r,n,i),a=X(e,r,n);if(typeof a.domIndex!="number"){let d=0,f=e.previousElementSibling;for(;f;)d++,f=f.previousElementSibling;a.domIndex=d}let s=o.get(a.signature)||[],l=r.excludeIds?s.filter(d=>!d.getAttribute("id")):s;if(l.length===0)return null;let c=null,m=0,p=null;for(let d of l){let{score:f,breakdown:k}=Ct(e,d,r,n,{candidateCount:l.length});f>m&&(m=f,c=d,p=k)}return m<r.minConfidence?null:{element:c,confidence:m,breakdown:p}}function Qn(e,t,r,n){let i=[],o=r.weights.signature+r.weights.slotMatch,a={slot:o};function s(p){if(p.children)return p.children;let d=p.childNodes;if(!d)return[];let f=[];for(let k=0;k<d.length;k++)d[k].nodeType===1&&f.push(d[k]);return f}function l(p,d){let f=s(p),k=s(d);if(f.length===k.length)for(let R=0;R<f.length;R++){let O=f[R],F=k[R];if(r.shouldIgnore?.(O)||r.shouldIgnore?.(F)||r.excludeIds&&(O.getAttribute("id")||F.getAttribute("id"))||O.tagName!==F.tagName)continue;let J=X(O,r,n).signature,V=X(F,r,n).signature;J!==V&&i.push({newEl:O,oldEl:F,score:o,breakdown:a}),l(O,F)}}function c(p,d){for(;;){if(p.tagName===d.tagName)return[p,d];let f=s(p);if(!p.tagName&&f.length===1){p=f[0];continue}let k=s(d);if(k.length===1&&k[0].tagName===p.tagName){d=k[0];continue}return null}}let m=c(e,t);return m&&l(m[0],m[1]),i}function gr(e,t,r,n,i){let o=t.querySelectorAll("*"),a=kr(e,r,n,i),s=0;for(let f of o){let k=X(f,r,n);k.domIndex=s++}let l=[],c=new Map;function m(f,k,R){let O=new Set;if(f.textHint){let j=c.get(f.signature);if(!j){j=new Map;for(let U of k){let se=X(U,r,n).textHint,ae=j.get(se);ae||(ae=[],j.set(se,ae)),ae.push(U)}c.set(f.signature,j)}let G=j.get(f.textHint);if(G)for(let U=0;U<G.length&&U<R;U++)O.add(G[U])}let F=0,J=k.length;for(;F<J;){let j=F+J>>1;X(k[j],r,n).domIndex<f.domIndex?F=j+1:J=j}let V=Math.max(0,Math.min(F-(R>>1),k.length-R)),Q=Math.min(V+R,k.length);for(let j=V;j<Q;j++)O.add(k[j]);return[...O]}for(let f of o){if(r.shouldIgnore?.(f)||r.excludeIds&&f.getAttribute("id"))continue;let k=X(f,r,n),R=a.get(k.signature)||[],O=r.excludeIds?R.filter(V=>!V.getAttribute("id")):R,F=r.maxScoredCandidates,J=F&&O.length>F?m(k,O,F):O;for(let V of J){let{score:Q,breakdown:j}=Ct(f,V,r,n,{candidateCount:O.length});Q>=r.minConfidence&&l.push({newEl:f,oldEl:V,score:Q,breakdown:j})}}if(r.weights.slotMatch>0){let f=Qn(t,e,r,n);for(let k of f)l.push(k)}l.sort((f,k)=>k.score-f.score);let p=new Map,d=new Set;for(let{newEl:f,oldEl:k}of l)p.has(f)||d.has(k)||(p.set(f,k),d.add(k));return p}function br(e,t,r,n){let i=X(e,r,n),o=X(t,r,n),{score:a,breakdown:s}=Ct(e,t,r,n,{candidateCount:1});return{matches:a>=r.minConfidence,score:a,breakdown:s,newMeta:{signature:i.signature,path:i.path,textHint:i.textHint},oldMeta:{signature:o.signature,path:o.path,textHint:o.textHint}}}function yr(e={}){let t={...pr,...e,weights:{...pr.weights,...e.weights}},r=new WeakMap,n=new WeakMap;return{findMatch:(i,o)=>fr(i,o,t,r,n),computeMatches:(i,o)=>gr(i,o,t,r,n),explain:(i,o)=>br(i,o,t,r),invalidate:i=>Zn(i,r,n),session:()=>{let i=new WeakMap,o=new WeakMap;return{findMatch:(a,s)=>fr(a,s,t,i,o),computeMatches:(a,s)=>gr(a,s,t,i,o),explain:(a,s)=>br(a,s,t,i)}},getConfig:()=>({...t})}}function Rt(e,t){for(;;){for(;t<e.length&&/\s/.test(e[t]);)t++;if(e[t]==="/"&&e[t+1]==="/"){for(;t<e.length&&e[t]!==`
|
|
2
|
+
`;)t++;continue}if(e[t]==="/"&&e[t+1]==="*"){let r=e.indexOf("*/",t+2);if(r===-1)return e.length;t=r+2;continue}return t}}function vr(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(t,r)=>r.length%2===0?r+'\\"':t)}var ei=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,ti=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function Ge(e){try{return JSON.parse(e)}catch{return JSON.parse(ri(e))}}function ri(e){let t="",r=0,n=(i,o)=>{throw new Error(`Invalid relaxed JSON: ${i} at position ${o}`)};for(;r<e.length&&(r=Rt(e,r),!(r>=e.length));){let i=e[r];if("{}[]:".includes(i)){t+=i,r++;continue}if(i===","){let s=Rt(e,r+1);if(e[s]==="}"||e[s]==="]"){r++;continue}t+=i,r++;continue}if(i==='"'||i==="'"){let s=r+1;for(;s<e.length&&e[s]!==i;)e[s]==="\\"&&s++,s++;s>=e.length&&n("unterminated string",r);let l=e.slice(r+1,s);i==="'"&&(l=vr(l)),t+='"'+l+'"',r=s+1;continue}let o=r;for(;o<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[o]);)o++;o===r&&n("unexpected character "+JSON.stringify(i),r);let a=e.slice(r,o);if(a==="true"||a==="false"||a==="null"||ei.test(a)){t+=a,r=o;continue}if(ti.test(a)){if(e[Rt(e,o)]===":"){t+='"'+a+'"',r=o;continue}n("unquoted value "+JSON.stringify(a),r)}n("invalid token "+JSON.stringify(a),r)}return t}function xr(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function r(i){let o=[],a=0;for(;a<i.length;){let s=i[a];if(/\s/.test(s)){a++;continue}if("{}".includes(s)){o.push({type:s,value:s}),a++;continue}if(s==="["){let p=!1,d=a+1;for(;d<i.length&&/\s/.test(i[d]);)d++;if(d<i.length&&/[a-zA-Z_]/.test(i[d])&&(p=!0),!p){o.push({type:s,value:s}),a++;continue}}if(s==="]"){o.push({type:s,value:s}),a++;continue}if(s===":"){o.push({type:t.COLON,value:s}),a++;continue}if(s===","){o.push({type:t.COMMA,value:s}),a++;continue}if(s==='"'||s==="'"){let p=s,d=a+1;for(;d<i.length&&i[d]!==p;)i[d]==="\\"&&d++,d++;o.push({type:t.STRING,value:i.substring(a+1,d),quoted:!0,sourceQuote:p}),a=d+1;continue}let l=a,c;for(;l<i.length&&!/[{},]/.test(i[l]);)if(i[l]===":"){let p=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],d=!1;for(let f of p){let k=f.substring(1);if(i.substring(l+1,l+1+k.length)===k){d=!0,l+=k.length;break}}if(!d)break}else if(i[l]==="["){for(l++;l<i.length&&i[l]!=="]";){if(i[l]==='"'||i[l]==="'"){let p=i[l];for(l++;l<i.length&&i[l]!==p;)i[l]==="\\"&&l++,l++}l++}l<i.length&&i[l]==="]"&&l++}else l++;c=i.substring(a,l);let m=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(c)?m=t.NUMBER:c==="true"||c==="false"||c==="null"?m=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(c)&&(m=t.SELECTOR),o.push({type:m,value:c,quoted:!1}),a=l}return o}function n(i){let o="";for(let a=0;a<i.length;a++){let s=i[a];if("{}".includes(s.type)||"[]".includes(s.type)){o+=s.value;continue}if(s.type===t.COLON){o+=s.value;continue}if(s.type===t.COMMA){let l=i[a+1];if(l&&(l.type==="}"||l.type==="]"))continue;o+=s.value;continue}if(s.type===t.STRING){let l=s.value;s.sourceQuote==="'"&&(l=vr(l)),o+=`"${l}"`;continue}if(s.type===t.NUMBER||s.type===t.BOOLEAN){o+=s.value;continue}o+=`"${s.value}"`}return o}try{let i=r(e),o=n(i);return JSON.parse(o)}catch(i){throw new Error("Invalid extraction rules syntax: "+i.message)}}var $=Symbol("hyper-morph-json-merge:missing"),wr=["id","_id","uuid","key","slug","code","name"];function ke(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ne(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ni(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:!0,writable:!0,configurable:!0})}function ce(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!ce(e[r],t[r]))return!1;return!0}if(ke(e)&&ke(t)){let r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(let n of r)if(!Ne(t,n)||!ce(e[n],t[n]))return!1;return!0}return!1}function _r(e,t,r,n){return ce(t,r)?t:ce(t,e)?r:ce(r,e)?t:ke(t)&&ke(r)?ii(ke(e)?e:{},t,r,n):Array.isArray(t)&&Array.isArray(r)?li(Array.isArray(e)?e:[],t,r,n):r}function Ar(e,t,r,n){return t===$&&r===$?$:t===$?e===$?r:ce(r,e)?$:r:r===$?e===$?t:$:_r(e,t,r,n)}function ii(e,t,r,n){let i={},o=new Set([...Object.keys(e),...Object.keys(t),...Object.keys(r)]);for(let a of o){let s=Ar(Ne(e,a)?e[a]:$,Ne(t,a)?t[a]:$,Ne(r,a)?r[a]:$,n);s!==$&&ni(i,a,s)}return i}function oi(e){return e===null||typeof e!="object"}function Je(e){return typeof e+":"+String(e)}function si(e,t){for(let r of t){let n=new Set;for(let i of r){if(!Ne(i,e))return!1;let o=i[e];if(typeof o!="string"&&typeof o!="number")return!1;let a=Je(o);if(n.has(a))return!1;n.add(a)}}return!0}function ai(e,t,r,n){let i=[e,t,r],o=!0;for(let a of i)for(let s of a)ke(s)||(o=!1);if(o){for(let a of n.keyCandidates)if(si(a,i))return{kind:"keyed",field:a};return null}for(let a of i){let s=new Set;for(let l of a){if(!oi(l))return null;let c=Je(l);if(s.has(c))return null;s.add(c)}}return{kind:"self"}}function li(e,t,r,n){let i=ai(e,t,r,n);if(!i)return r;let o=i.kind==="self"?Je:f=>Je(f[i.field]),a=f=>{let k=new Map;for(let R of f)k.set(o(R),R);return k},s=a(e),l=a(t),c=a(r),m=new Map,p=new Set([...s.keys(),...l.keys(),...c.keys()]);for(let f of p){let k=Ar(s.has(f)?s.get(f):$,l.has(f)?l.get(f):$,c.has(f)?c.get(f):$,n);k!==$&&m.set(f,k)}let d=[];for(let f of r){let k=o(f);m.has(k)&&d.push(k)}for(let f=0;f<t.length;f++){let k=o(t[f]);if(!m.has(k)||d.includes(k))continue;let R=0;for(let O=f-1;O>=0;O--){let F=d.indexOf(o(t[O]));if(F!==-1){R=F+1;break}}d.splice(R,0,k)}return d.map(f=>m.get(f))}function Tt(e,t,r,n={}){let i=n.keyCandidates?[...n.keyCandidates,...wr]:wr;return _r(e===void 0?$:e,t,r,{keyCandidates:i})}function Mt(e,t,r,n={}){let i=n.parse||Ge,o=[],a=(p,d)=>{if(typeof p!="string")return $;try{return i(p)}catch(f){return o.push(`${d} side is not valid JSON (${f.message})`),$}},s=a(t,"local"),l=a(r,"remote");if(s===$)return{text:r,warnings:o};if(l===$)return{text:t,warnings:o};let c=a(e,"base"),m=Tt(c===$?void 0:c,s,l,n);return ce(m,l)?{text:r,warnings:o}:ce(m,s)?{text:t,warnings:o}:{text:JSON.stringify(m,null,2),warnings:o}}var Ot=(function(){"use strict";let e=()=>{},t='[save-ignore],[snapshot-remove],[no-snapshot],[no-save],[save-remove],[freeze],[save-freeze],[clay~="no-save"],[clay~="no-snapshot"],[clay~="freeze"]';function r(v){if(!(v instanceof Element))return!1;if(v.matches(t))return!0;if(v.tagName==="LINK"||v.tagName==="SCRIPT"){let E=v.getAttribute("src")||v.getAttribute("href")||"";if(E.startsWith("chrome-extension://")||E.startsWith("moz-extension://")||E.startsWith("safari-web-extension://"))return!0}return!1}function n(v){return v instanceof Element?v.closest(t)?!0:r(v):!1}let i=yr({shouldIgnore:n});function o(v,E,S){if(S){let N=S.identityOf(v);if(N&&!S.disabled.has(N.key))return"hm-merge:"+N.key}if(E!=="smart")return v.outerHTML;let M=v.getAttribute("src"),C=v.getAttribute("type")||"text/javascript";if(M)try{let N=new URL(M,window.location.href);return`ext:${C}:${N.origin}${N.pathname}${N.search}`}catch{return`ext:${C}:${M}`}else{let N=v.textContent.trim(),y=5381;for(let A=0;A<N.length;A++)y=(y<<5)+y^N.charCodeAt(A);return`inline:${C}:${Math.abs(y).toString(36)}`}}let a="http://www.w3.org/1999/xhtml";function s(v){return v instanceof Element&&v.tagName==="SCRIPT"&&v.namespaceURI===a}function l(v){let E=document.createElement("div");E.innerHTML="<script><\/script>";let S=E.firstChild;for(let M of v.attributes)S.setAttribute(M.name,M.value);return S.textContent=v.textContent,S}function c(v){if(s(v))return l(v);if(v instanceof Element)for(let E of v.querySelectorAll("script"))s(E)&&E.replaceWith(l(E));return v}function m(v){let E=(v.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return E==="application/json"||E.endsWith("+json")}let p={match:v=>v.hasAttribute("merge"),identity:v=>v.getAttribute("merge")};function d(v,E,S){if(S.merge===!1)return null;let M=[p,...S.mergeTags||[]],C=new WeakMap,N=g=>{if(C.has(g))return C.get(g);let w=null;if(s(g)&&!g.getAttribute("src")&&!n(g)){let _=g;for(let T=0;T<M.length;T++)if(M[T].match(_)){if(!m(_))console.warn("[hyper-morph] merge ignored: script type is not JSON",_);else{let L=M[T].identity(_);L!=null&&L!==""&&(w={key:T+":"+L,raw:L,recognizer:M[T]})}break}}return C.set(g,w),w},y=new Set,A=g=>{let w=new Map,_=T=>{let L=N(T);L&&(w.has(L.key)?(y.add(L.key),console.warn(`[hyper-morph] merge disabled for duplicate identity "${L.raw}"`)):w.set(L.key,T))};s(g)&&_(g);for(let T of g.querySelectorAll("script"))_(T);return w},b=A(v),h=A(E.__hyperMorphRoot||E);if(b.size===0&&h.size===0)return null;let u=null;return{identityOf:N,disabled:y,oldByKey:b,newByKey:h,baseTexts:()=>{if(u)return u;u=new Map;let g=S.mergeBase;if(!g)return u;let w;typeof g=="string"?w=new DOMParser().parseFromString(g,"text/html").documentElement:g instanceof Document?w=g.documentElement:w=g;let _=T=>{let L=N(T);L&&!u.has(L.key)&&u.set(L.key,T.textContent)};s(w)&&_(w);for(let T of w.querySelectorAll("script"))_(T);return u}}}function f(v,E,S){let M=v.merge;if(!M)return!1;let C=M.identityOf(E);if(!C||M.disabled.has(C.key))return!1;let N=M.identityOf(S);if(!N||N.key!==C.key)return!1;let y=E,A=S,b=A.getAttribute("merge-key")||y.getAttribute("merge-key"),{text:h,warnings:u}=Mt(M.baseTexts().get(C.key),y.textContent,A.textContent,{parse:C.recognizer.parse,keyCandidates:b?b.split(/[\s,]+/).filter(Boolean):void 0});for(let x of u)console.warn(`[hyper-morph] merge "${C.raw}": ${x}`);return y.textContent!==h&&(y.textContent=h),!0}let k={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:e,afterNodeAdded:e,beforeNodeMorphed:e,afterNodeMorphed:e,beforeNodeRemoved:e,afterNodeRemoved:e,beforeAttributeUpdated:e},head:{style:"merge",shouldPreserve:v=>v.getAttribute("im-preserve")==="true",shouldReAppend:v=>v.getAttribute("im-re-append")==="true",shouldRemove:e,afterHeadMorphed:e},scripts:{handle:!0,matchMode:"outerHTML",shouldPreserve:v=>v.getAttribute("im-preserve")==="true",shouldReAppend:v=>v.getAttribute("im-re-append")==="true",shouldRemove:e,afterScriptsHandled:e},restoreFocus:!0},R={computeMatches(v,E){let{computeMatches:S}=i.session();return S(v,E)}};function O(v,E,S={}){v=Ln(v);let M=cr(E),C=jn(v,M,S),N=C.scripts.handle?new Set(Array.from(v.querySelectorAll("script")).map(h=>o(h,C.scripts.matchMode,C.merge))):null,y=V(C),A=U(C,v,M,h=>h.morphStyle==="innerHTML"?(j(h,v,M),Array.from(v.childNodes)):J(h,v,M)),b=h=>{y&&Q(C,y),F(C);let u=N?wt(h,N,C):[];return u.length>0?Promise.all(u).then(()=>h):h};return A instanceof Promise?A.then(b):b(A)}function F(v){for(let E of Array.from(v.pantry.childNodes))v.callbacks.beforeNodeRemoved(E)!==!1&&v.callbacks.afterNodeRemoved(E);v.pantry.remove()}function J(v,E,S){let M=cr(E);return j(v,M,S,E,E.nextSibling),Array.from(M.childNodes)}function V(v){if(!v.config.restoreFocus)return null;let E=document.activeElement;if(!(E instanceof HTMLInputElement||E instanceof HTMLTextAreaElement))return null;let{id:S,selectionStart:M,selectionEnd:C}=E;return{element:E,id:S,selectionStart:M,selectionEnd:C}}function Q(v,E){let S=E.element;if(E.id&&E.id!==document.activeElement?.getAttribute("id")&&(S=v.target.querySelector(`[id="${CSS.escape(E.id)}"]`),S?.focus()),S&&!S.selectionEnd&&E.selectionEnd!=null)try{S.setSelectionRange(E.selectionStart,E.selectionEnd)}catch{}}let j=(function(){function v(h,u,x,g=null,w=null){u instanceof HTMLTemplateElement&&x instanceof HTMLTemplateElement&&(u=u.content,x=x.content),g||=u.firstChild;for(let _ of x.childNodes){if(r(_))continue;if(g&&g!=w){let L=S(h,_,g,w);if(L){L!==g&&C(h,g,L),G(L,_,h),g=L.nextSibling;continue}}if(_ instanceof Element){let L=_.getAttribute("id");if(h.persistentIds.has(L)){let D=N(u,L,g,h);G(D,_,h),g=D.nextSibling;continue}if(!h.idMap.has(_)){let D=h.hyperMatches.get(_);if(D&&!h.idMap.has(D)&&!b(D,u)){A(u,D,g),G(D,_,h),g=D.nextSibling;continue}}}let T=E(u,_,g,h);T&&(g=T.nextSibling)}for(;g&&g!=w;){let _=g;g=g.nextSibling,r(_)||M(h,_)}}function E(h,u,x,g){if(g.callbacks.beforeNodeAdded(u)===!1)return null;if(g.idMap.has(u)){let w=u,_=document.createElementNS(w.namespaceURI,w.localName);return h.insertBefore(_,x),G(_,u,g),g.callbacks.afterNodeAdded(_),_}else{let w=c(document.importNode(u,!0));return h.insertBefore(w,x),g.callbacks.afterNodeAdded(w),w}}let S=(function(){function h(g,w,_,T){let L=w instanceof Element&&!g.idMap.has(w)?g.hyperMatches.get(w):null,D=null,H=w.nextSibling,te=0,q=_;for(;q&&q!=T;){if(r(q)){q=q.nextSibling;continue}if(x(q,w)){if(u(g,q,w)||q===L&&!g.idMap.has(q))return q;if(D===null){let Y=q instanceof Element&&g.hyperMatchedOldElements.has(q);!g.idMap.has(q)&&!Y&&(D=q)}}if(D===null&&H&&x(q,H)&&(te++,H=H.nextSibling,te>=2&&(D=void 0)),g.activeElementAndParents.includes(q))break;q=q.nextSibling}return D||null}function u(g,w,_){let T=g.idMap.get(w),L=g.idMap.get(_);if(!L||!T)return!1;for(let D of T)if(L.has(D))return!0;return!1}function x(g,w){let _=g,T=w;return _.nodeType===T.nodeType&&_.tagName===T.tagName&&(!_.getAttribute?.("id")||_.getAttribute?.("id")===T.getAttribute?.("id"))}return h})();function M(h,u){let x=u instanceof Element&&h.hyperMatchedOldElements.has(u)&&!h.idMap.has(u);if(h.idMap.has(u)||x)A(h.pantry,u,null);else{if(h.callbacks.beforeNodeRemoved(u)===!1)return;u.parentNode?.removeChild(u),h.callbacks.afterNodeRemoved(u)}}function C(h,u,x){let g=u;for(;g&&g!==x;){let w=g;g=g.nextSibling,r(w)||M(h,w)}return g}function N(h,u,x,g){let w=g.target.getAttribute?.("id")===u&&g.target||g.target.querySelector(`[id="${CSS.escape(u)}"]`)||g.pantry.querySelector(`[id="${CSS.escape(u)}"]`);return y(w,g),A(h,w,x),w}function y(h,u){let x=h.getAttribute("id");for(;h=h.parentNode;){let g=u.idMap.get(h);g&&(g.delete(x),g.size||u.idMap.delete(h))}}function A(h,u,x){if(h.moveBefore)try{h.moveBefore(u,x)}catch{h.insertBefore(u,x)}else h.insertBefore(u,x)}function b(h,u){let x=u instanceof Element?u:u.realParentNode;return!!x&&h.contains(x)}return v})(),G=(function(){function v(y,A,b){return b.ignoreActive&&y===document.activeElement?null:(b.callbacks.beforeNodeMorphed(y,A)===!1||(y instanceof HTMLHeadElement&&b.head.ignore||(y instanceof HTMLHeadElement&&b.head.style!=="morph"?ae(y,A,b):(E(y,A,b),f(b,y,A)||N(y,b)||j(b,y,A))),b.callbacks.afterNodeMorphed(y,A)),y)}function E(y,A,b){let h=A.nodeType;if(h===1){let u=y,x=A,g=u.attributes,w=x.attributes;for(let _ of w)C(_.name,u,"update",b)||u.getAttribute(_.name)!==_.value&&u.setAttribute(_.name,_.value);for(let _=g.length-1;0<=_;_--){let T=g[_];if(T&&!x.hasAttribute(T.name)){if(C(T.name,u,"remove",b))continue;u.removeAttribute(T.name)}}N(u,b)||S(u,x,b)}(h===8||h===3)&&y.nodeValue!==A.nodeValue&&(y.nodeValue=A.nodeValue)}function S(y,A,b){if(y instanceof HTMLInputElement&&A instanceof HTMLInputElement&&A.type!=="file"){let h=A.value,u=y.value;M(y,A,"checked",b),M(y,A,"disabled",b),b.formStateSync==="property"&&y.indeterminate!==A.indeterminate&&(y.indeterminate=A.indeterminate),b.formStateSync==="property"?u!==h&&(C("value",y,"update",b)||(y.value=h)):A.hasAttribute("value")?u!==h&&(C("value",y,"update",b)||(y.setAttribute("value",h),y.value=h)):C("value",y,"remove",b)||(y.value="",y.removeAttribute("value"))}else if(y instanceof HTMLOptionElement&&A instanceof HTMLOptionElement)M(y,A,"selected",b);else if(y instanceof HTMLTextAreaElement&&A instanceof HTMLTextAreaElement){let h=A.value,u=y.value;if(C("value",y,"update",b)||(h!==u&&(y.value=h),b.formStateSync==="property"))return;y.firstChild&&y.firstChild.nodeValue!==h&&(y.firstChild.nodeValue=h)}}function M(y,A,b,h){let u=A[b],x=y[b];if(u!==x){let g=C(b,y,"update",h);if(g||(y[b]=A[b]),h.formStateSync==="property")return;u?g||y.setAttribute(b,""):C(b,y,"remove",h)||y.removeAttribute(b)}}function C(y,A,b,h){return y==="value"&&h.ignoreActiveValue&&A===document.activeElement?!0:h.callbacks.beforeAttributeUpdated(y,A,b)===!1}function N(y,A){return!!A.ignoreActiveValue&&y===document.activeElement&&y!==document.body}return v})();function U(v,E,S,M){if(v.head.block){let C=E.querySelector("head"),N=S.querySelector("head");if(C&&N){let y=ae(C,N,v);return Promise.all(y).then(()=>(v.head.block=!1,v.head.ignore=!0,M(v)))}}return M(v)}function se(v){return v.tagName==="SCRIPT"?!!v.getAttribute("src"):v.tagName==="LINK"?(v.getAttribute("rel")||"").toLowerCase().split(/\s+/).includes("stylesheet")&&!!v.getAttribute("href"):!1}function ae(v,E,S){let M=[],C=[],N=[],y=[],A=S.scripts.matchMode,b=x=>{if(x.tagName==="SCRIPT")return o(x,A,S.merge);if(x.tagName==="LINK"&&A==="smart"){let g=x.getAttribute("href");if(g)try{let w=new URL(g,window.location.href);return`link:${x.getAttribute("rel")||""}:${w.origin}${w.pathname}${w.search}`}catch{}}return x.outerHTML},h=new Map;for(let x of E.children){if(r(x))continue;let g=b(x),w=h.get(g);w||(w=[],h.set(g,w)),w.push(x)}for(let x of v.children){let g=b(x),w=h.get(g),_=!!(w&&w.length),T=S.head.shouldReAppend(x),L=S.head.shouldPreserve(x);if(_||L)if(T)C.push(x);else{if(w&&w.length){let D=w.pop();w.length||h.delete(g),f(S,x,D)}N.push(x)}else S.head.style==="append"?T&&(C.push(x),y.push(x)):S.head.shouldRemove(x)!==!1&&!r(x)&&C.push(x)}for(let x of h.values())y.push(...x);let u=[];for(let x of y){let g=document.createRange().createContextualFragment(x.outerHTML).firstChild;if(S.callbacks.beforeNodeAdded(g)!==!1){if(g instanceof Element&&se(g)){let w,_=new Promise(function(T){w=T});g.addEventListener("load",function(){w()}),g.addEventListener("error",function(){w()}),u.push(_)}v.appendChild(g),S.callbacks.afterNodeAdded(g),M.push(g)}}for(let x of C)S.callbacks.beforeNodeRemoved(x)!==!1&&(v.removeChild(x),S.callbacks.afterNodeRemoved(x));return S.head.afterHeadMorphed(v,{added:M,kept:N,removed:C}),u}function wt(v,E,S){if(!S.scripts.handle)return[];let M=[],C=[],N=[],y=[],A=S.scripts.matchMode,b=[];for(let u of v)if(u instanceof Element){s(u)&&b.push(u);for(let x of u.querySelectorAll("script"))s(x)&&b.push(x)}for(let u of b){if(u.closest("head")||n(u))continue;let x=o(u,A,S.merge),g=E.has(x),w=S.scripts.shouldPreserve(u),_=S.scripts.shouldReAppend(u);g||w?_?(C.push(u),y.push(u)):N.push(u):y.push(u)}let h=[];for(let u of y){if(S.callbacks.beforeNodeAdded(u)===!1)continue;let x=document.createElement("script");for(let g of u.attributes)x.setAttribute(g.name,g.value);if(x.textContent=u.textContent,x.src){let g,w=new Promise(function(_){g=_});x.addEventListener("load",function(){g()}),x.addEventListener("error",function(){g()}),h.push(w)}u.replaceWith(x),S.callbacks.afterNodeAdded(x),M.push(x)}return S.scripts.afterScriptsHandled(S.target,{added:M,kept:N,removed:C}),h}let jn=(function(){function v(b,h,u){let{persistentIds:x,idMap:g}=y(b,h),w=R.computeMatches(b,h);if(typeof u.key=="function"){let H=new Map,te=new Set,q=B=>{let P=u.key(B);P!=null&&(H.has(P)?te.add(P):H.set(P,B))};b instanceof Element&&q(b);for(let B of b.querySelectorAll("*"))q(B);for(let B of te)H.delete(B);let Y=new Map;for(let[B,P]of w)Y.set(P,B);let ue=h.__hyperMorphRoot||h,le=new Map,dr=new Set,mr=B=>{let P=u.key(B);P!=null&&(le.has(P)?dr.add(P):le.set(P,B))};ue instanceof Element&&mr(ue);for(let B of ue.querySelectorAll("*"))mr(B);for(let B of dr)le.delete(B);for(let[B,P]of le){let be=H.get(B);if(!be||be.tagName!==P.tagName)continue;let _t=Y.get(be);_t&&_t!==P&&w.delete(_t);let At=w.get(P);At&&At!==be&&Y.delete(At),w.set(P,be),Y.set(be,P)}}let _=E(u),T=d(b,h,_.scripts);if(T){let H=new Map;for(let[te,q]of w)H.set(q,te);for(let[te,q]of T.newByKey){if(T.disabled.has(te))continue;let Y=T.oldByKey.get(te);if(!Y)continue;let ue=H.get(Y);ue&&ue!==q&&w.delete(ue);let le=w.get(q);le&&le!==Y&&H.delete(le),w.set(q,Y),H.set(Y,q)}}let L=new Set;for(let H of w.values())L.add(H);let D=_.morphStyle||"outerHTML";if(!["innerHTML","outerHTML"].includes(D))throw new Error(`Do not understand how to morph style ${D}`);return{target:b,newContent:h,config:_,morphStyle:D,ignoreActive:_.ignoreActive,ignoreActiveValue:_.ignoreActiveValue,restoreFocus:_.restoreFocus,formStateSync:_.formStateSync||"attribute",idMap:g,persistentIds:x,hyperMatches:w,hyperMatchedOldElements:L,merge:T,pantry:S(),activeElementAndParents:M(b),callbacks:_.callbacks,head:_.head,scripts:_.scripts}}function E(b){let h=Object.assign({},k);return Object.assign(h,b),h.callbacks=Object.assign({},k.callbacks,b.callbacks),h.head=Object.assign({},k.head,b.head),h.scripts=Object.assign({},k.scripts,b.scripts),h}function S(){let b=document.createElement("div");return b.hidden=!0,document.body.insertAdjacentElement("afterend",b),b}function M(b){let h=[],u=document.activeElement;if(u?.tagName!=="BODY"&&b.contains(u))for(;u&&(h.push(u),u!==b);)u=u.parentElement;return h}function C(b){let h=Array.from(b.querySelectorAll("[id]"));return b.getAttribute?.("id")&&h.push(b),h}function N(b,h,u,x){for(let g of x){let w=g.getAttribute("id");if(h.has(w)){let _=g;for(;_;){let T=b.get(_);if(T==null&&(T=new Set,b.set(_,T)),T.add(w),_===u)break;_=_.parentElement}}}}function y(b,h){let u=C(b),x=C(h),g=A(u,x),w=new Map;N(w,g,b,u);let _=h.__hyperMorphRoot||h;return N(w,g,_,x),{persistentIds:g,idMap:w}}function A(b,h){let u=new Set,x=new Map;for(let w of b){let _=w.getAttribute("id");x.has(_)?u.add(_):x.set(_,w.tagName)}let g=new Set;for(let w of h){let _=w.getAttribute("id");g.has(_)?u.add(_):x.get(_)===w.tagName&&g.add(_)}for(let w of u)g.delete(w);return g}return v})(),{normalizeElement:Ln,normalizeParent:cr}=(function(){let v=new WeakSet;function E(y){return y instanceof Document?y.documentElement:y}function S(y){if(y==null)return document.createElement("div");if(typeof y=="string")return S(N(y));if(v.has(y))return y;if(y instanceof Node){if(y.parentNode)return new M(y);{let A=document.createElement("div");return A.append(y),A}}else{let A=document.createElement("div");for(let b of[...y])A.append(b);return A}}class M{constructor(A){this.originalNode=A,this.realParentNode=A.parentNode,this.previousSibling=A.previousSibling,this.nextSibling=A.nextSibling}get childNodes(){let A=[],b=this.previousSibling?this.previousSibling.nextSibling:this.realParentNode.firstChild;for(;b&&b!=this.nextSibling;)A.push(b),b=b.nextSibling;return A}querySelectorAll(A){return this.childNodes.reduce((b,h)=>{if(h instanceof Element){h.matches(A)&&b.push(h);let u=h.querySelectorAll(A);for(let x=0;x<u.length;x++)b.push(u[x])}return b},[])}insertBefore(A,b){return this.realParentNode.insertBefore(A,b)}moveBefore(A,b){return this.realParentNode.moveBefore(A,b)}get __hyperMorphRoot(){return this.originalNode}}function C(y){let A=x=>`<${x}(?:\\s(?:[^>"']|"[^"]*"|'[^']*')*)?>`,b=y.replace(/<!--[\s\S]*?-->/g,"");for(let x of["script","style","textarea","title"])b=b.replace(new RegExp(`${A(x)}[\\s\\S]*?</${x}\\s*>`,"gi"),"");let h=new RegExp(`${A("svg")}[\\s\\S]*?</svg\\s*>`,"gi"),u;do u=b,b=b.replace(h,"");while(b!==u);return b}function N(y){let A=new DOMParser,b=C(y);if(b.match(/<\/html>/)||b.match(/<\/head>/)||b.match(/<\/body>/)){let h=A.parseFromString(y,"text/html");if(b.match(/<\/html>/))return v.add(h),h;{let u=h.firstChild;return u&&v.add(u),u}}else{let u=A.parseFromString("<body><template>"+y+"</template></body>","text/html").body.querySelector("template").content;return v.add(u),u}}return{normalizeElement:E,normalizeParent:S}})();return{morph:O,defaults:k,mergeJson:Tt,mergeScriptText:Mt,parseJsonRelaxed:Ge,parseRulesRelaxed:xr}})();var $s=Ot.morph,Bs=Ot.defaults;var Nt=Ot;var Ye=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],It=new Set(Ye),Sr=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Er=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var Xe={};Et(Xe,{EmptyListInsert:()=>je,MAX_RULE_DEPTH:()=>xe,MaxRuleDepthExceeded:()=>he,RuleTargetReadOnly:()=>Le,RulesParseError:()=>ye,ShapeMismatch:()=>Ie,UnknownRulesVersion:()=>ve});var ye=class extends Error{constructor(t,r){super(t),this.name="RulesParseError",this.cause=r}},ve=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},xe=20,he=class extends Error{constructor(t){super(`rule depth exceeded ${xe} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},Ie=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},je=class extends Error{constructor(t){super(`cannot add items to empty list at "${t.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=t}},Le=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}};function de(e,t,r,n={}){return jt(e,t,r,{depth:0,path:[]},n)}function jt(e,t,r,n,i){if(n.depth>xe)throw new he(n.path);if(typeof r=="string")return hi(e,t,r,i);if(Array.isArray(r)){let[o,a]=r;return e.find(t,o,i).map((l,c)=>jt(e,l,a,{depth:n.depth+1,path:[...n.path,c]},i))}if(typeof r=="object"&&r!==null){let o={};for(let[a,s]of Object.entries(r))o[a]=jt(e,t,s,{depth:n.depth+1,path:[...n.path,a]},i);return o}return null}function hi(e,t,r,n){if(r.endsWith("[]")){let a=r.slice(0,-2);return e.find(t,a,n).map(s=>e.text(s))}if(r.startsWith("@"))return Cr(e,t,r.slice(1));let i=z(r);if(i!==-1){let a=r.slice(0,i),s=r.slice(i+1),l=a?e.find(t,a,n):[t];return l.length===0?null:Cr(e,l[0],s)}if(r===".")return e.text(t);let o=e.find(t,r,n);return o.length===0?null:e.text(o[0])}function Cr(e,t,r){if(It.has(r)){let i=e.prop(t,r);return i==null?null:String(i)}let n=e.attr(t,r);return n||null}function pi(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function fi(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var gi={find(e,t,r={}){let n=fi(e);if(!n||!n.querySelectorAll)return[];let i=Array.from(n.querySelectorAll(t));r.includeRulesTag||(i=i.filter(s=>!pi(s)));let o=[];r.skip&&o.push(r.skip);let a=r.templateAttr===null?null:r.templateAttr||"cms-template";if(a&&o.push("["+a+"]"),o.length){let s=o.join(", ");i=i.filter(l=>!l.closest||!l.closest(s))}return i},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t},attr(e,t,r){if(r===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,r)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t)},prop(e,t,r){if(r===void 0){let n=e?e[t]:void 0;return n!==void 0?n:null}e[t]=r},clone(e){return e.cloneNode(!0)},insertAt(e,t,r){let n=e.children[r]||null;e.insertBefore(t,n)},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let n=e.ownerDocument.createElement("template");n.innerHTML=t;let i=n.content.firstElementChild;if(!i)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(i,e),i},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(n=>{n.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}},re=gi;function Lt(e){try{return JSON.parse(e)}catch(t){throw new ye(`Invalid strict JSON: ${t.message}`,t)}}function we(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function r(i){let o=[],a=0;for(;a<i.length;){let s=i[a];if(/\s/.test(s)){a++;continue}if("{}".includes(s)){o.push({type:s,value:s}),a++;continue}if(s==="["){let p=!1,d=a+1;for(;d<i.length&&/\s/.test(i[d]);)d++;if(d<i.length&&/[a-zA-Z_]/.test(i[d])&&(p=!0),!p){o.push({type:s,value:s}),a++;continue}}if(s==="]"){o.push({type:s,value:s}),a++;continue}if(s===":"){o.push({type:t.COLON,value:s}),a++;continue}if(s===","){o.push({type:t.COMMA,value:s}),a++;continue}if(s==='"'||s==="'"){let p=s,d=a+1;for(;d<i.length&&i[d]!==p;)i[d]==="\\"&&d++,d++;o.push({type:t.STRING,value:i.substring(a+1,d),quoted:!0,sourceQuote:p}),a=d+1;continue}let l=a,c;for(;l<i.length&&!/[{},]/.test(i[l]);)if(i[l]===":"){let p=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],d=!1;for(let f of p){let k=f.substring(1);if(i.substring(l+1,l+1+k.length)===k){d=!0,l+=k.length;break}}if(!d)break}else if(i[l]==="["){for(l++;l<i.length&&i[l]!=="]";){if(i[l]==='"'||i[l]==="'"){let p=i[l];for(l++;l<i.length&&i[l]!==p;)i[l]==="\\"&&l++,l++}l++}l<i.length&&i[l]==="]"&&l++}else l++;c=i.substring(a,l);let m=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(c)?m=t.NUMBER:c==="true"||c==="false"||c==="null"?m=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(c)&&(m=t.SELECTOR),o.push({type:m,value:c,quoted:!1}),a=l}return o}function n(i){let o="";for(let a=0;a<i.length;a++){let s=i[a];if("{}".includes(s.type)||"[]".includes(s.type)){o+=s.value;continue}if(s.type===t.COLON){o+=s.value;continue}if(s.type===t.COMMA){let l=i[a+1];if(l&&(l.type==="}"||l.type==="]"))continue;o+=s.value;continue}if(s.type===t.STRING&&s.quoted){let l=s.value;s.sourceQuote==="'"&&(l=l.replace(/\\'/g,"'"),l=l.replace(/(\\*)"/g,(c,m)=>m.length%2===0?m+'\\"':c)),o+=`"${l}"`;continue}if(s.type===t.NUMBER||s.type===t.BOOLEAN){o+=s.value;continue}if(s.type===t.SELECTOR||s.type===t.IDENTIFIER){o+=`"${s.value}"`;continue}o+=`"${s.value}"`}return o}try{let i=r(e),o=n(i);return JSON.parse(o)}catch(i){throw new ye("Invalid extraction rules syntax: "+i.message,i)}}var Tr="1",Rr=/^[a-zA-Z0-9_-]+$/;function Fe(e,t,r){let n;if(r===void 0)n="script[data-rules-name]";else{if(typeof r!="string"||!Rr.test(r))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(r)} (must match ${Rr})`);n=`script[data-rules-name~="${r}"]`}let i=e.find(t,n,{includeRulesTag:!0});if(i.length===0)return null;r!==void 0&&i.length>1&&console.warn(`hyper-html-api: ${i.length} rules tags match data-rules-name~="${r}"; using the first.`);let o=i[0],a=e.attr(o,"data-rules-version");if(a!==Tr)throw new ve(a);return{rules:we(e.text(o)),tagNode:o}}var ba=new Function("url","return import(url)");var ki=.5;function Ft(e,t,r,n,i,o,a,s={}){let l=e.find(t,r,s);if(i.length===0){l.forEach(j=>e.remove(j));return}let c=i.length>l.length,m=l[0]||null;if(c&&!m&&(m=wi(e,t,r,s),!m))throw new je(o.path);let p=l.map(j=>yi(e,j,n,s)),d=null;if(m){d=e.clone(m),s.templateAttr&&e.removeAttr(d,s.templateAttr);let j=e.stripIds(d);j>0&&console.warn(`[hyper-html-api] stripped ${j} id attribute(s) from cloned template at "${o.path.join(".")||"(root)"}"`)}let f=vi(i,p,n),k=l[0]||m,R=e.parent(k),O=l.length>0?jr(e,R,k):0,F=_i(e,l),J=new Set,V=[],Q=i.map((j,G)=>{let U=f[G];if(U>=0)return J.add(U),V.push(!1),l[U];V.push(!0);let se=e.clone(d);return e.stripIds(se),se});if(l.forEach((j,G)=>{J.has(G)||e.remove(j)}),F){Q.forEach((j,G)=>{let U=O+G;e.children(R).findIndex(wt=>e.sameNode(wt,j))!==U&&e.insertAt(R,j,U)}),Ir(e,Q,n,i,o,a,s);return}Ai(e,Q,V,R,O),Ir(e,Q,n,i,o,a,s)}function Ir(e,t,r,n,i,o,a){t.forEach((s,l)=>{if(r===null){let c=n[l],m=c==null?"":String(c);e.text(s)!==m&&e.text(s,m)}else{let c=o(e,s,r,n[l],{depth:i.depth+1,path:[...i.path,l]},a);c&&c!==s&&(t[l]=c)}})}function yi(e,t,r,n){return r===null?e.text(t):de(e,t,r,n)}function vi(e,t,r){let n=new Array(e.length).fill(-1),i=new Set;return e.forEach((o,a)=>{let s=-1,l=-1;t.forEach((c,m)=>{if(i.has(m))return;let p=xi(o,c,r),d=p===l&&s>=0?Math.abs(m-a)<Math.abs(s-a):!1;(p>l||d)&&(l=p,s=m)}),l>=ki&&(n[a]=s,i.add(s))}),n}function xi(e,t,r){if(r===null)return e===t?1:0;let n=Object.keys(r||{});if(n.length===0)return 0;let i=0;for(let o of n)JSON.stringify(e?.[o])===JSON.stringify(t?.[o])&&i++;return i/n.length}function jr(e,t,r){let n=e.children(t);for(let i=0;i<n.length;i++)if(e.sameNode(n[i],r))return i;return-1}function wi(e,t,r,n){if(!n.templateAttr)return null;let i=t;for(;i;){let o=e.find(i,r,{includeRulesTag:!1,templateAttr:null});for(let a of o)if(e.attr(a,n.templateAttr)!=null)return a;i=e.parent(i)}return null}function _i(e,t){if(t.length<=1)return!0;let r=e.parent(t[0]);if(!r)return!1;let n=e.children(r),i=[];for(let o of t){let a=n.findIndex(s=>e.sameNode(s,o));if(a===-1)return!1;i.push(a)}return i.sort((o,a)=>o-a),i[i.length-1]-i[0]===i.length-1}function Ai(e,t,r,n,i){let o=null,a=i;for(let s=0;s<t.length;s++){if(!r[s]){o=t[s];continue}let l=o?e.parent(o):n;if(!l)continue;let c=o?jr(e,l,o)+1:a++;e.insertAt(l,t[s],c),o=t[s]}}var Lr=new Set(["checked","selected","disabled","readOnly","paused"]);function _e(e,t,r,n,i={}){let o=[];if(qt(r,n,[],o),o.length)throw new Ie(o);Ze(e,t,r,n,{depth:0,path:[]},i)}function Ze(e,t,r,n,i,o={}){if(i.depth>xe)throw new he(i.path);if(n===void 0)return t;if(typeof r=="string")return Si(e,t,r,n,i,o);if(Array.isArray(r)){let[a,s]=r;return Ft(e,t,a,s,n,i,Ze,o),t}if(typeof r=="object"&&r!==null){for(let[a,s]of Object.entries(r)){let l=Ze(e,t,s,n==null?n:n[a],{depth:i.depth+1,path:[...i.path,a]},o);l&&l!==t&&(t=l)}return t}return t}function Si(e,t,r,n,i,o){if(r.endsWith("[]")){let l=r.slice(0,-2);return Ft(e,t,l,null,n,i,Ze,o),t}if(r.startsWith("@"))return Fr(e,t,r.slice(1),n);let a=z(r);if(a!==-1){let l=r.slice(0,a),c=r.slice(a+1),m=l?e.find(t,l,o):[t];return m.length===0||Fr(e,m[0],c,n),t}if(r===".")return e.text(t,n==null?"":String(n)),t;let s=e.find(t,r,o);return s.length===0||e.text(s[0],n==null?"":String(n)),t}function Fr(e,t,r,n){if(Er.has(r))throw new Le(r);if(r==="outerHTML"){let i=n==null?"":String(n);return e.replaceWith(t,i)}return Sr.has(r)?(e.prop(t,r,Ei(r,n)),t):(e.attr(t,r,n==null?"":String(n)),t)}function Ei(e,t){return t==null?Lr.has(e)?!1:"":Lr.has(e)?!!t:t}function qt(e,t,r,n){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((i,o)=>{typeof i=="object"&&i!==null&&n.push({path:De([...r,o]),expected:"scalar",got:qe(i)})}):n.push({path:De(r),expected:"array",got:qe(t)});return}t!==null&&typeof t=="object"&&n.push({path:De(r),expected:"scalar",got:qe(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){n.push({path:De(r),expected:"array",got:qe(t)});return}let i=e[1];t.forEach((o,a)=>qt(i,o,[...r,a],n));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){n.push({path:De(r),expected:"object",got:qe(t)});return}for(let[i,o]of Object.entries(e))qt(o,t[i],[...r,i],n)}}}function qe(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function De(e){return e.join(".")}function Dt(e,t,r){if(r&&typeof r=="object")return{rules:r,tagNode:null};if(typeof r=="string"){let n=t&&t.ownerDocument?t.ownerDocument:t;return Fe(e,n,r)}return null}function Dr(e,t,r,n){let i=Dt(e,t,r);if(!i){let s=typeof r=="string"?`data-rules-name~="${r}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${s}`)}let{rules:o,tagNode:a}=i;return{rules:o,tagNode:a,get:()=>de(e,t,o,n),set:s=>_e(e,t,o,s,n)}}var W={extract:(e,t,r)=>de(re,e,t,r),apply:(e,t,r,n)=>_e(re,e,t,r,n),findRulesIn:(e,t)=>Fe(re,e,t),findRules:(e,t)=>Dt(re,e,t),bind:(e,t,r)=>Dr(re,e,t,r),parseStrict:Lt,parseRelaxed:we,ruleAttrIndex:z,splitRule:Ke,errors:Xe,DOM_PROPERTIES:Ye};var Bt={};Et(Bt,{fromString:()=>ie,getRuleAtPath:()=>pe,getValueAtPath:()=>Bi,setAtPath:()=>$t,toString:()=>$i});function $i(e){return e.map(String).join(".")}function ie(e){return e===""?[]:e.split(".").map(t=>/^\d+$/.test(t)?Number(t):t)}function pe(e,t){let r=e;for(let n of t){if(r==null)return;if(typeof r=="string"){if(r.endsWith("[]")&&(typeof n=="number"||n==="*")){r=r.slice(0,-2);continue}return}if(Array.isArray(r)){if(typeof n!="number"&&n!=="*")return;r=r[1];continue}if(typeof r=="object"){if(typeof n=="number"||!(n in r))return;r=r[n];continue}return}return r}function Bi(e,t){let r=e;for(let n of t){if(r==null)return;r=r[n]}return r}function $t(e,t,r){if(t.length===0)return r;let[n,...i]=t;if(typeof n=="number"){let o=Array.isArray(e)?[...e]:[];return o[n]=$t(o[n],i,r),o}return{...e&&typeof e=="object"?e:{},[n]:$t((e||{})[n],i,r)}}function $e(e){if(typeof e=="string")return e.endsWith("[]")?[]:"";if(Array.isArray(e))return[];if(typeof e=="object"&&e!==null){let t={};for(let[r,n]of Object.entries(e))t[r]=$e(n);return t}return""}function Qe(e,t,{ignoreActiveValue:r=!0}={}){Nt.morph(e,t,{morphStyle:"innerHTML",ignoreActiveValue:r,restoreFocus:!0,formStateSync:"property"})}function tt(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/[-_]/g," ").replace(/\s+/g," ").trim().replace(/^./,t=>t.toUpperCase())}var Pi='<div class="hcms-drag-handle mirk-sortable__grip" aria-hidden="true"><div class="mirk-sortable__dots"><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span></div></div>',Pt='<svg class="hcms-x" viewBox="0 0 16 16" shape-rendering="crispEdges" aria-hidden="true"><path d="M4 4 L12 12 M12 4 L4 12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square"></path></svg>',Pr={"@scalar":`
|
|
3
3
|
<label class="hcms-field" data-hcms-shape="scalar">
|
|
4
4
|
<span class="hcms-label" data-hcms-label></span>
|
|
5
5
|
<textarea class="mirk-textarea" rows="1" data-hcms-field></textarea>
|
|
@@ -39,13 +39,13 @@ var hypercms=(()=>{var nt=Object.defineProperty;var Jr=Object.getOwnPropertyDesc
|
|
|
39
39
|
</section>
|
|
40
40
|
`,"@object-array-item":`
|
|
41
41
|
<article class="hcms-card mirk-sortable__item" draggable="true">
|
|
42
|
-
${
|
|
42
|
+
${Pi}
|
|
43
43
|
<div class="hcms-card-body mirk-sortable__body">
|
|
44
44
|
<div class="hcms-card-fields"></div>
|
|
45
45
|
<div class="hcms-card-controls">
|
|
46
46
|
<button type="button" class="hcms-move hcms-move-up hcms-sr-only" data-hcms-action="move-up" aria-label="Move up">\u2191</button>
|
|
47
47
|
<button type="button" class="hcms-move hcms-move-down hcms-sr-only" data-hcms-action="move-down" aria-label="Move down">\u2193</button>
|
|
48
|
-
<button type="button" class="hcms-remove hcms-remove--card" data-hcms-action="remove" aria-label="Remove">${
|
|
48
|
+
<button type="button" class="hcms-remove hcms-remove--card" data-hcms-action="remove" aria-label="Remove">${Pt}</button>
|
|
49
49
|
</div>
|
|
50
50
|
</div>
|
|
51
51
|
<div class="hcms-error" hidden></div>
|
|
@@ -59,7 +59,7 @@ var hypercms=(()=>{var nt=Object.defineProperty;var Jr=Object.getOwnPropertyDesc
|
|
|
59
59
|
<span class="mirk-button__label">Choose</span>
|
|
60
60
|
</label>
|
|
61
61
|
<a class="mirk-file__name" data-hcms-field></a>
|
|
62
|
-
<button type="button" class="hcms-upload-clear" data-hcms-action="clear-upload" aria-label="Remove file">${
|
|
62
|
+
<button type="button" class="hcms-upload-clear" data-hcms-action="clear-upload" aria-label="Remove file">${Pt}</button>
|
|
63
63
|
</div>
|
|
64
64
|
<div class="hcms-error" hidden></div>
|
|
65
65
|
</div>
|
|
@@ -73,7 +73,7 @@ var hypercms=(()=>{var nt=Object.defineProperty;var Jr=Object.getOwnPropertyDesc
|
|
|
73
73
|
</label>
|
|
74
74
|
<figure class="mirk-image__thumb">
|
|
75
75
|
<span class="mirk-image__frame"><img class="mirk-image__preview" data-hcms-field alt="" /></span>
|
|
76
|
-
<button type="button" class="hcms-upload-clear hcms-upload-clear--badge" data-hcms-action="clear-upload" aria-label="Remove image">${
|
|
76
|
+
<button type="button" class="hcms-upload-clear hcms-upload-clear--badge" data-hcms-action="clear-upload" aria-label="Remove image">${Pt}</button>
|
|
77
77
|
</figure>
|
|
78
78
|
</div>
|
|
79
79
|
<div class="hcms-error" hidden></div>
|
|
@@ -147,11 +147,11 @@ var hypercms=(()=>{var nt=Object.defineProperty;var Jr=Object.getOwnPropertyDesc
|
|
|
147
147
|
<input class="hcms-chip-field" data-hcms-field aria-label="Item" placeholder="\u2026" />
|
|
148
148
|
<button type="button" class="hcms-remove" data-hcms-action="remove" aria-label="Remove">\xD7</button>
|
|
149
149
|
</span>
|
|
150
|
-
`},Vi=["@scalar","@object","@scalar-array","@scalar-array-item","@object-array","@object-array-item"];function De(e){let t=e.head||e.documentElement;if(t)for(let r of Vi)hr(e,t,r)}function At(e,t){if(!lr[t])return null;let r=e&&(e.head||e.documentElement);return r?hr(e,r,t):null}var sr={src:"@image",checked:"@checkbox",innerHTML:"@richtext"},Ie={image:"@image",file:"@file",checkbox:"@checkbox",toggle:"@toggle",select:"@select",radio:"@radio",textarea:"@textarea",number:"@number",richtext:"@richtext"},Ki=new Set([...Object.values(Ie),"@chips","@chips-item"]);function xe(e,t,r){if(typeof e!="string")return"@scalar";let i=e.lastIndexOf("@"),n=Pe(we(e,i),t,"data-hcms-component");if(n&&Ie[n]){let o=Ie[n],a=Array.isArray(r)&&r.some(s=>s==="*"||typeof s=="number");return o==="@number"&&!ar(e,i,t,a).every(Yi)||(o==="@checkbox"||o==="@toggle")&&(i<0||e.slice(i+1)!=="checked")&&!ar(e,i,t,a).every(Ji)?"@scalar":o}if(i>=0){let o=e.slice(i+1);if(sr[o])return sr[o]}return"@scalar"}function cr(e,t){if(typeof e!="string")return null;let r=e.lastIndexOf("@"),i=Pe(we(e,r),t,"data-hcms-component");return i&&Ie[i]||null}var Gi=/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/;function Yi(e){return e==null||e===""?!0:Gi.test(String(e))}function Ji(e){return e==null||e===""||e==="true"||e==="false"}function ar(e,t,r,i){if(!r||!r.querySelectorAll)return[];let n=we(e,t);if(!n||n===".")return[];let o=null;try{o=r.querySelectorAll(n)}catch{return[]}let a=t>=0?e.slice(t+1):null,s=[];for(let l of o)if(!(l.closest&&l.closest("[cms-template], [data-hcms-shell]"))&&(a?a==="value"&&"value"in l?s.push(l.value):s.push(l.getAttribute?l.getAttribute(a):null):s.push((l.textContent||"").trim()),!i))break;return s}function $e(e,t){if(typeof e!="string"||!e.endsWith("[]")||!t||!t.querySelector)return null;let r=e.slice(0,-2).trim();if(!r)return null;let i=null;try{i=t.querySelector(r)}catch{return null}let n=i&&i.closest?i.closest("[data-hcms-component]"):null;return(n&&n.getAttribute?n.getAttribute("data-hcms-component"):null)==="chips"?{array:"@chips",item:"@chips-item"}:null}function ne(e,t,r){let i=e.join("."),n=e.map(o=>typeof o=="number"?"*":o).join(".");return i&&B(r,i)||n&&n!==i&&B(r,n)||B(r,t)}function Be(e,t,r){let i=$e(e,r);if(!i)return null;let n=ne(t,i.array,r);return n&&n.getAttribute("data-hcms-tpl")===i.array?i:null}function dr(e,t){if(typeof e!="string")return null;let r=e.lastIndexOf("@"),i=Pe(we(e,r),t,"data-hcms-options");if(i==null)return null;let n=i.trim().split(/\s+/).filter(Boolean);return n.length?n:null}function mr(e,t){if(typeof e!="string")return null;let r=e.lastIndexOf("@");return Pe(we(e,r),t,"data-hcms-crop")}function we(e,t){return t>=0?e.slice(0,t):e}function Pe(e,t,r){if(!t||!t.querySelector||!e||e===".")return null;let i=null;try{i=t.querySelector(e)}catch{return null}return i&&i.getAttribute?i.getAttribute(r):null}function He(e,t){if(!e||t==null)return;r(t);function r(i){let n=Z(i);if(n==="scalar"){let o=xe(i,e);Ki.has(o)&&At(e,o);return}if(n==="scalar-array"){let o=$e(i,e);o&&(At(e,o.array),At(e,o.item));return}if(n==="object"){for(let o of Object.values(i))r(o);return}if(n==="object-array"){let o=i[1];if(o&&typeof o=="object"&&!Array.isArray(o))for(let a of Object.values(o))r(a);else r(o)}}}function hr(e,t,r){let i=B(e,r);if(i)return i;let n=e.createElement("template");return n.setAttribute("data-hcms-tpl",r),n.setAttribute("save-remove",""),n.innerHTML=lr[r].trim(),t.appendChild(n),n}function B(e,t){return!e||!e.querySelector?null:e.querySelector(`template[data-hcms-tpl="${Xi(t)}"]`)}function Xi(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}function Z(e){return typeof e=="string"?e.endsWith("[]")?"scalar-array":"scalar":Array.isArray(e)?"object-array":typeof e=="object"&&e!==null?"object":"scalar"}function _e(e){return e?!!(e.content||e).querySelector("[data-hcms-field]"):!1}var ur={IMG:"src",A:"href"};function ze(e){if(!e)return"value";let t=(e.tagName||"").toUpperCase();return t==="INPUT"?(e.getAttribute("type")||"text").toLowerCase()==="checkbox"?"checked":"value":t==="TEXTAREA"||t==="SELECT"?"value":ur[t]?ur[t]:e.hasAttribute&&e.hasAttribute("contenteditable")?"innerHTML":null}function pr(e,t){let r=(e.tagName||"").toUpperCase(),i=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),n=ze(e),a=`${gr(r,i)}[data-hcms-field="${oe(t)}"]`;return r==="INPUT"&&i==="radio"?`${a}:checked@value`:n?`${a}@${n}`:a}function Zi(e){let t=(e.tagName||"").toUpperCase(),r=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),i=ze(e),o=`${gr(t,r)}[data-hcms-field]`;return t==="INPUT"&&r==="radio"?`${o}:checked@value`:i?`${o}@${i}`:o}function gr(e,t){return e==="INPUT"?t?`input[type="${t}"]`:"input":e==="TEXTAREA"?"textarea":e==="SELECT"?"select":e==="IMG"?"img":e==="A"?"a":':not([data-hcms-shape="scalar"]):not([data-hcms-shape="object"]):not([data-hcms-shape="object-array"]):not([data-hcms-shape="scalar-array"])'}function oe(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var fr=new Set(["__proto__","constructor","prototype"]);function Ue(e,t){return r(e,[]);function r(c,m){let d=Z(c);if(d==="scalar")return i(c,m);if(d==="scalar-array")return n(c,m);if(d==="object-array")return o(c,m);if(d==="object"){let u=Object.create(null);for(let[y,x]of Object.entries(c)){if(fr.has(y))throw new Error(`hypercms: rule key "${y}" is forbidden at "${m.join(".")||"<root>"}"`);u[y]=r(x,[...m,y])}return u}return null}function i(c,m){let d=m.length?m[m.length-1]:null,u=typeof d=="string"?d:"__value",y=l(m,u);if(y)return pr(y,u);let x=s(xe(c,t,m),u);return x?pr(x,u):`input[data-hcms-field="${oe(u)}"]@value`}function n(c,m){let d=Be(c,m,t),u=d&&s(d.item,null)||s("@scalar-array-item",null),y=u?Zi(u):"input[data-hcms-field]@value";return[a(m,"[data-hcms-array-item]"),y]}function o(c,m){let[,d]=c,u=[...m,"*"],y=a(m,"[data-hcms-card]");if(d&&typeof d=="object"&&!Array.isArray(d)){let x=Object.create(null);for(let[M,b]of Object.entries(d)){if(fr.has(M))throw new Error(`hypercms: rule key "${M}" is forbidden at "${u.join(".")}"`);x[M]=r(b,[...u,M])}return[y,x]}return[y,r(d,[...u,0])]}function a(c,m){let d=c.length?c[c.length-1]:"",u=c.some(M=>M==="*"),y=c.join(".");return`${u?`[data-hcms-field="${oe(d)}"]`:`[data-hcms-path="${oe(y)}"]`} > .hcms-array-items > ${m}`}function s(c,m){if(!t)return null;let d=B(t,c);if(!d)return null;let u=d.content||d;if(m){let y=u.querySelector(`[data-hcms-field="${oe(m)}"]`);if(y)return y}return u.querySelector("[data-hcms-field]")}function l(c,m){if(!t)return null;let d=c.map(x=>typeof x=="number"?"*":x).join("."),y=[c.join("."),d];for(let x=c.length-1;x>=0;x--){let M=c.slice(0,x).map(b=>typeof b=="number"?"*":b);M.push("*"),y.push(M.join("."))}for(let x of y){if(!x)continue;let M=B(t,x);if(!M||!_e(M))continue;let b=M.content||M,T=b.querySelector(`[data-hcms-field="${oe(m)}"]`)||b.querySelector("[data-hcms-field]");if(T)return T}return null}}function St(e){if(!e)return"";let t=String(e).split(/[?#]/)[0],r=t.split("/").pop()||t;try{return decodeURIComponent(r)}catch{return r}}function We({pageRules:e,formRules:t,data:r,doc:i}){let n=i.createDocumentFragment(),o=Et(e,[],r,i);return o&&n.appendChild(o),n}function kr({shape:e,itemShape:t,pathArr:r,data:i,doc:n,itemKey:o}){if(e==="object-array-item")return vr(t,r,i,n);if(e==="scalar-array-item")return xr(r,i,n,o||null);throw new Error(`hypercms: buildItem called with unknown shape "${e}"`)}function Et(e,t,r,i){let n=Z(e);return n==="scalar"?Qi(e,t,r,i):n==="object"?nn(e,t,r,i):n==="object-array"?on(e,t,r,i):n==="scalar-array"?sn(e,t,r,i):null}function Qi(e,t,r,i){let n=xe(e,i,t),o=ne(t,n,i);if(!o)throw new Error(`hypercms: missing template for scalar at "${t.join(".")}"`);let a=cr(e,i);a==="@number"&&n==="@scalar"&&console.info(`[hypercms] field "${t.join(".")}" declares component "@number" but its value isn't a plain number; rendering a text input so the value is preserved`),(a==="@checkbox"||a==="@toggle")&&n==="@scalar"&&console.info(`[hypercms] field "${t.join(".")}" declares component "${a}" but its value isn't true/false; rendering a text input so the value is preserved`),yr(o,a===n?a:null,t);let s=se(o,i);ae(s,t);let l=o.getAttribute?.("data-hcms-tpl");if((n==="@select"||n==="@radio")&&l===n&&en(s,e,t,r,i,n),n==="@image"&&l==="@image"){let c=mr(e,i);c!=null&&!s.hasAttribute("data-hcms-crop")&&s.setAttribute("data-hcms-crop",c)}return an(s,V(t)),Ve(s,V(t)),Ke(s,V(t)),Er(s,r),n==="@file"&&rn(s),s}function yr(e,t,r){if(!t)return;let i=e.getAttribute?.("data-hcms-tpl");i&&i!==t&&console.info(`[hypercms] field "${r.join(".")}" declares component "${t}" but custom template "${i}" wins`)}function en(e,t,r,i,n,o){let a=dr(t,n),s=a?[...a]:[],l=i==null?"":String(i);if(l!==""&&!s.includes(l)&&s.unshift(l),!a&&(tn(e,"data-hcms-options required (space-separated values)"),s.length===0)){e.querySelector(".mirk-radio")?.remove();return}if(o==="@select"){let d=e.querySelector("select[data-hcms-field]");if(!d)return;for(let u of s){let y=n.createElement("option");y.value=u,y.textContent=qe(u),d.appendChild(y)}return}let c=e.querySelector(".mirk-radio");if(!c||!c.parentNode)return;let m=Ct(r.join("."));for(let d of s){let u=c.cloneNode(!0),y=u.querySelector('input[type="radio"]');y&&(y.value=d,y.name=m);let x=u.querySelector(".mirk-radio__label");x&&(x.textContent=qe(d)),c.parentNode.insertBefore(u,c)}c.remove()}function Ct(e){return"hcms-"+String(e).replace(/[^A-Za-z0-9_-]/g,"-")}function tn(e,t){let r=e.querySelector?e.querySelector(".hcms-error"):null;r&&(r.textContent=t,r.hidden=!1)}function rn(e){let t=e.querySelector?e.querySelector("a.mirk-file__name[data-hcms-field]"):null;t&&(t.textContent=St(t.getAttribute("href")))}function nn(e,t,r,i){let n=ne(t,"@object",i);if(!n)throw new Error(`hypercms: missing template for object at "${t.join(".")}"`);let o=se(n,i);if(ae(o,t),Ve(o,V(t)),Ke(o,V(t)),_e(n))return Rr(o,e,t),Cr(o,e,r),o;let a=Ge(o,".hcms-object-fields",n,t);for(let[s,l]of Object.entries(e)){let c=r==null?null:r[s],m=Et(l,[...t,s],c,i);m&&a.appendChild(m)}return o}function on(e,t,r,i){let n=ne(t,"@object-array",i);if(!n)throw new Error(`hypercms: missing template for object-array at "${t.join(".")}"`);let o=se(n,i);ae(o,t),Ve(o,V(t)),Ke(o,V(t)),_r(o,n),Sr(o,n,t);let a=Ge(o,".hcms-array-items",n,t),[,s]=e;return(Array.isArray(r)?r:[]).forEach((c,m)=>{let d=vr(s,[...t,m],c,i);d&&a.appendChild(d)}),Ar(o),o}function vr(e,t,r,i){let n=wr(t,"object-array-item",i);if(!n)throw new Error(`hypercms: missing item template for "${t.join(".")}"`);let o=se(n,i);if(o.setAttribute("data-hcms-card",""),o.classList.contains("hcms-card")||o.classList.add("hcms-card"),ae(o,t),_e(n))return e&&typeof e=="object"&&!Array.isArray(e)&&(Rr(o,e,t),Cr(o,e,r)),o;let a=Ge(o,".hcms-card-fields",n,t);if(e&&typeof e=="object"&&!Array.isArray(e))for(let[s,l]of Object.entries(e)){let c=r==null?null:r[s],m=Et(l,[...t,s],c,i);m&&a.appendChild(m)}return o}function sn(e,t,r,i){let n=$e(e,i),o=Be(e,t,i),a=n?n.array:"@scalar-array",s=ne(t,a,i);if(!s)throw new Error(`hypercms: missing template for scalar-array at "${t.join(".")}"`);yr(s,n?n.array:null,t);let l=se(s,i);ae(l,t),Ve(l,V(t)),Ke(l,V(t)),_r(l,s),Sr(l,s,t),o&&l.setAttribute("data-hcms-item-tpl",o.item);let c=Ge(l,".hcms-array-items",s,t);return(Array.isArray(r)?r:[]).forEach((d,u)=>{let y=xr([...t,u],d,i,o?o.item:null);y&&c.appendChild(y)}),Ar(l),l}function xr(e,t,r,i){let n=wr(e,"scalar-array-item",r,i);if(!n)throw new Error(`hypercms: missing item template for "${e.join(".")}"`);let o=se(n,r);return o.setAttribute("data-hcms-array-item",""),o.classList.contains("hcms-array-item")||o.classList.add("hcms-array-item"),ae(o,e),Er(o,t),o}function wr(e,t,r,i){let n=e.map(o=>typeof o=="number"?"*":o).join(".");return B(r,n)||i&&B(r,i)||B(r,"@"+t)}function se(e,t){let r=e.content||e,i=t.createElement("div");return i.appendChild(r.cloneNode(!0)),i.firstElementChild||i}function ae(e,t){e.setAttribute("data-hcms-path",t.join("."))}function an(e,t){let r=t==null?"":String(t);if(e.matches&&e.matches("[data-hcms-field]")){e.getAttribute("data-hcms-field")||e.setAttribute("data-hcms-field",r);return}(e.querySelectorAll?e.querySelectorAll("[data-hcms-field]"):[]).forEach(n=>{n.getAttribute("data-hcms-field")||n.setAttribute("data-hcms-field",r)})}function Ve(e,t){t==null||t===""||!e.setAttribute||e.hasAttribute?.("data-hcms-field")||e.setAttribute("data-hcms-field",String(t))}function Ke(e,t){if(t==null||t==="")return;(e.querySelectorAll?e.querySelectorAll("[data-hcms-label]"):[]).forEach(i=>{(i.textContent||"").trim()===""&&(i.textContent=qe(String(t)))})}function _r(e,t){["data-hcms-no-add","data-hcms-no-remove","data-hcms-no-reorder"].forEach(r=>{t.hasAttribute(r)&&e.setAttribute(r,"")}),["data-hcms-min-items","data-hcms-max-items"].forEach(r=>{t.hasAttribute(r)&&e.setAttribute(r,t.getAttribute(r))})}function Ar(e){let t=e.querySelector?e.querySelector(".hcms-array-items"):null;if(!t)return;let r=Array.from(t.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")),i=r.length,n=br(e,"data-hcms-max-items"),o=br(e,"data-hcms-min-items"),a=e.hasAttribute("data-hcms-no-add"),s=e.hasAttribute("data-hcms-no-remove"),l=e.hasAttribute("data-hcms-no-reorder"),c=e.querySelector('[data-hcms-action="add"]');c&&(c.hidden=a||n!=null&&i>=n),r.forEach((m,d)=>{let u=m.querySelector('[data-hcms-action="remove"]');u&&(u.hidden=s||o!=null&&i<=o);let y=m.querySelector('[data-hcms-action="move-up"]');y&&(y.hidden=l||d===0);let x=m.querySelector('[data-hcms-action="move-down"]');x&&(x.hidden=l||d===i-1)})}function br(e,t){if(!e||!e.hasAttribute(t))return null;let r=parseInt(e.getAttribute(t),10);return Number.isFinite(r)?r:null}function Sr(e,t,r){if(e.hasAttribute("data-hcms-no-reorder")||t.hasAttribute("data-hcms-no-reorder"))return;let i=e.querySelector(".hcms-array-items");if(!i)return;let n="hcms-"+r.join(".");i.setAttribute("sortable",n),i.setAttribute("onsorted","hypercmsCommit && hypercmsCommit()")}function V(e){return e.length?e[e.length-1]:null}function Er(e,t){let r=ln(e);if(r.length!==0)for(let i of r)Tr(i,t)}function ln(e){if(!e)return[];let t=[];return e.matches?.("[data-hcms-field]")&&cn(e)&&t.push(e),(e.querySelectorAll?e.querySelectorAll("input[data-hcms-field], textarea[data-hcms-field], select[data-hcms-field], img[data-hcms-field], a[data-hcms-field], [contenteditable][data-hcms-field]"):[]).forEach(i=>t.push(i)),t}function cn(e){let t=(e.tagName||"").toUpperCase();return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||t==="IMG"||t==="A"||e.hasAttribute?.("contenteditable"))}function Cr(e,t,r){(e.querySelectorAll?e.querySelectorAll("[data-hcms-field]"):[]).forEach(n=>{let o=n.getAttribute("data-hcms-field");if(!o)return;if(!t||typeof t!="object"||!(o in t)){console.warn(`[hypercms] inline template field "${o}" is not in the rule shape; ignoring`);return}let a=r==null?null:r[o];Tr(n,a)})}function Rr(e,t,r){if(!e.querySelectorAll)return;e.querySelectorAll("[data-hcms-field]").forEach(n=>{let o=n.getAttribute("data-hcms-field");if(!o||t&&typeof t=="object"&&!(o in t))return;let a=[...r,o].join(".");n.setAttribute("data-hcms-path",a)})}function Ge(e,t,r,i){if(!e.querySelector)return e;let n=e.querySelector(t);if(n)return n;let o=r?.getAttribute?.("data-hcms-tpl")||i.join(".");throw new Error(`hypercms: template "${o}" is in slotted mode but has no ${t} element`)}function Tr(e,t){let r=ze(e),i=(e.tagName||"").toUpperCase(),n=(e.getAttribute("type")||"").toLowerCase();if(i==="INPUT"&&n==="radio"){e.checked=e.value!=null&&String(e.value)===String(t??"");return}if(r==="checked"){e.checked=t===!0||t==="true";return}if(r){e[r]=t==null?"":String(t);return}e.textContent=t==null?"":String(t)}var Mr={skip:"[data-hcms-shell]",templateAttr:"cms-template"};function Or(e,t,r,i={}){let{observerHandle:n,shellRoot:o,structural:a,structuralPath:s}=i;n?.pause?.();try{if(!a)try{return q.apply(e,t,r,Mr),{ok:!0}}catch(d){return{ok:!1,error:d}}let l=dn(e,t,s),c=l?hn(l):null,m=l?null:pn(e,o);try{return q.apply(e,t,r,Mr),{ok:!0}}catch(d){return c?un(l,c):m&&fn(e,o,m),{ok:!1,error:d}}}finally{n?.resume?.()}}function dn(e,t,r){if(!r||!e)return null;let i=W(r),n=[],o=t;for(let a of i){if(typeof o=="string"||o==null||Array.isArray(o))break;if(typeof o=="object"&&a in o){if(n.push(a),o=o[a],Array.isArray(o)||typeof o=="string"&&o.endsWith("[]"))break}else return null}return!Array.isArray(o)&&!(typeof o=="string"&&o.endsWith("[]"))?null:mn(e,t,n)}function mn(e,t,r){if(r.length===0)return null;let i=e,n=t;for(let o=0;o<r.length;o++){let a=r[o];if(!n||typeof n!="object"||Array.isArray(n))return null;let s=n[a];if(s==null)return null;if(o===r.length-1){if(Array.isArray(s)){let[l]=s;return i.querySelector?.(l)?.parentElement||null}if(typeof s=="string"&&s.endsWith("[]")){let l=s.slice(0,-2);return i.querySelector?.(l)?.parentElement||null}return null}n=s}return null}function hn(e){let t=[];for(let r of Array.from(e.childNodes))t.push(r.cloneNode(!0));return t}function un(e,t){for(;e.firstChild;)e.removeChild(e.firstChild);for(let r of t)e.appendChild(r)}function pn(e,t){let r=[];for(let i of Array.from(e.childNodes))i===t||t&&i.contains?.(t)||r.push(i.cloneNode(!0));return r}function fn(e,t,r){for(let n of Array.from(e.childNodes))n===t||t&&n.contains?.(t)||e.removeChild(n);let i=gn(e,t);for(let n of r)e.insertBefore(n,i||null)}function gn(e,t){if(!t)return null;for(let r of Array.from(e.childNodes))if(r===t||r.contains?.(t))return r;return null}function Ye(e,t){if(!t||e==null)return e;return r(e);function r(i){if(typeof i=="string"){if(i.endsWith("[]")||i.lastIndexOf("@")>=0)return i;let n=null;try{n=t.querySelector(i)}catch{return i}return n&&n.children.length>0?i+"@innerHTML":i}if(Array.isArray(i))return i;if(i&&typeof i=="object"){let n=Object.create(null);for(let[o,a]of Object.entries(i))n[o]=r(a);return n}return i}}function Rt(e){if(!e||e.tagName!=="TEXTAREA")return;let t=e.ownerDocument.defaultView||(typeof window<"u"?window:null);t&&t.CSS&&t.CSS.supports&&t.CSS.supports("field-sizing: content")||(e.style.height="auto",e.style.height=e.scrollHeight+"px")}function le(e,t){if(!e||!e.querySelectorAll)return;e.querySelectorAll("textarea[data-hcms-field]").forEach(Rt);let r=t&&t.defaultView||(typeof window<"u"?window:null),i=r&&r.richclay&&r.richclay.RichClay||r&&r.hyperclay&&r.hyperclay.RichClay||(r&&typeof r.RichClay=="function"?r.RichClay:null);i&&e.querySelectorAll("[contenteditable][data-hcms-field]").forEach(n=>{if(n.__hcmsRichclay)return;let o;try{o=new i(n,{inline:!0,hyperclay:!1,toolbar:["bold","italic","link","undo","redo"]})}catch(s){console.warn("[hypercms] richclay activation failed; field stays plain contenteditable",s);return}n.__hcmsRichclay=o;let a=o&&o.squire;a&&typeof a.addEventListener=="function"&&a.addEventListener("input",()=>{let s=r&&r.Event||Event;n.dispatchEvent(new s("input",{bubbles:!0}))})})}var Tt=new WeakSet;function de(e,t){let r=typeof window<"u"&&window.hyperclay&&window.hyperclay.undo||null;if(!r)return t();r.pause();try{let i=t();return i&&i.ok?r.commitCaptured(e):r.discardCaptured(),i}finally{r.resume()}}function Ze(e){let t=typeof window<"u"&&window.hyperclay&&window.hyperclay.undo||null;if(!t)return e();t.pause();try{return e()}finally{t.discardCaptured(),t.resume()}}function Nr(e){let{formRoot:t}=e;if(!t||Tt.has(t))return;Tt.add(t);let r=a=>{let s=a.target;!s||!s.closest||s.closest("[data-hcms-form-root]")&&s.matches("input, textarea, select, [contenteditable][data-hcms-field]")&&(s.tagName==="TEXTAREA"&&Rt(s),!s.matches('input[type="file"]')&&(!s.closest("[data-hcms-field]")&&!s.hasAttribute?.("data-hcms-field")||Lr(s,e)))},i=a=>{let s=a.target;if(!(!s||!s.closest)&&s.closest("[data-hcms-form-root]")){if(s.matches('input[type="file"][data-hcms-upload]')){_n(s,e);return}s.matches('input[type="checkbox"], input[type="radio"], select')&&Lr(s,e)}},n=a=>{let s=a.target;if(!s||!s.closest)return;let l=s.closest("[data-hcms-action]");if(!l)return;let c=l.getAttribute("data-hcms-action");if(c==="add"||c==="remove"||c==="move-up"||c==="move-down"||c==="clear-upload"){if(!l.closest("[data-hcms-form-root]"))return}else if(c==="close"&&!l.closest("[data-hcms-shell]"))return;if(c==="add"){let m=l.closest("[data-hcms-path]");if(!m)return;let d=m.getAttribute("data-hcms-path");Mt(d,e)}else if(c==="remove"){let m=l.closest("[data-hcms-card], [data-hcms-array-item]");if(!m)return;Tn(m,e)}else if(c==="move-up"||c==="move-down"){let m=l.closest("[data-hcms-card], [data-hcms-array-item]");if(!m)return;Cn(m,c==="move-up"?-1:1,e)}else c==="clear-upload"?An(l,e):c==="close"&&e.onCloseRequested?.()},o=t.ownerDocument;o.addEventListener("input",r,!0),o.addEventListener("change",i,!0),o.addEventListener("click",n,!0),e.detachEvents=()=>{o.removeEventListener("input",r,!0),o.removeEventListener("change",i,!0),o.removeEventListener("click",n,!0),Tt.delete(t)}}var bn=new Set(["value","checked"]);function kn(e,t){if(!t)return null;let r=W(t);if(r.some(l=>typeof l=="number"||l==="*"))return null;let i=X(e.pageRules,r);if(typeof i!="string")return null;let n=i.lastIndexOf("@");if(n===-1)return null;let o=i.slice(n+1);if(!bn.has(o))return null;let a=i.slice(0,n),s=a?e.pageRoot.querySelector(a):e.pageRoot;return s?{el:s,prop:o,oldValue:s[o]}:null}function Lr(e,t){let i=(e.closest("[data-hcms-field]")||e).closest("[data-hcms-path]")?.getAttribute("data-hcms-path")||"",n=kn(t,i);if(z(D(t),{path:i,structural:!1},t),n){let o=typeof window<"u"&&window.hyperclay&&window.hyperclay.undo||null;o&&typeof o.recordValue=="function"&&o.recordValue(n.el,{prop:n.prop,oldValue:n.oldValue,newValue:n.el[n.prop]})}}var yn={type:"image/webp",quality:.85,maxWidth:2048,maxHeight:2048};async function vn(e,t){let r=t&&t.getAttribute?t.getAttribute("data-hcms-crop"):null;if(r==null)return{file:e};let i=typeof window<"u"&&window.hyperclay&&window.hyperclay.quickcrop||null;if(typeof i!="function")return{file:e};try{let n=await i(e,{aspect:xn(r),...yn});return n===null?null:{file:wn(n.blob,e.name),dataURL:n.dataURL}}catch(n){return Ae(t,n&&n.message||"Crop failed"),null}}function xn(e){let t=String(e??"").trim().toLowerCase();if(t===""||t==="free")return null;let r=t.match(/^(\d+(?:\.\d+)?)\s*[:/]\s*(\d+(?:\.\d+)?)$/);if(!r)return null;let i=parseFloat(r[1]),n=parseFloat(r[2]);return!i||!n?null:i/n}function wn(e,t){let r=e.type==="image/webp"?".webp":e.type==="image/jpeg"?".jpg":".png",i=String(t||"image").replace(/\.[^.]+$/,"");try{return new File([e],i+r,{type:e.type})}catch{return e}}async function _n(e,t){let r=e.files&&e.files[0];if(!r)return;let i=e.closest("[data-hcms-path]");if(!i)return;let n=i.getAttribute("data-hcms-path")||"";Ae(i,null);let o=await vn(r,i);if(!o||t.closed){Q(e);return}let a=o.file,s=o.dataURL||null,l=typeof window<"u"&&window.hyperclay&&window.hyperclay.uploadFileBasic||null,c=null;if(typeof l=="function")try{let m=await l(a);c=m&&m.uploads&&m.uploads[0]&&m.uploads[0].url}catch(m){if(t.closed){Q(e);return}Ae(i,m&&m.message||"Upload failed"),t.dispatch?.("hcms:error",{error:m,path:n}),Q(e);return}if(t.closed){Q(e);return}if(c||(c=s||En(a)),!c){Q(e);return}Ae(i,null),Fr(i,c,a.name),z(D(t),{path:n,structural:!1},t),Q(e)}function An(e,t){let r=e.closest("[data-hcms-path]");if(!r)return;let i=r.getAttribute("data-hcms-path")||"";Fr(r,"","");let n=r.querySelector('input[type="file"][data-hcms-upload]');n&&Q(n),Ae(r,null),z(D(t),{path:i,structural:!1},t)}function Sn(e){return e.querySelector?e.querySelector("img[data-hcms-field], a[data-hcms-field]"):null}function Fr(e,t,r){let i=Sn(e);if(!i)return;let n=(i.tagName||"").toUpperCase();n==="IMG"?i.src=t||"":n==="A"&&(i.href=t||"",i.textContent=t?r||St(t):"")}function Q(e){try{e.value=""}catch{}}function En(e){let t=typeof URL<"u"&&URL.createObjectURL?URL:null;if(!t)return"";try{return t.createObjectURL(e)}catch{return""}}function Ae(e,t){let r=e.querySelector?e.querySelector(":scope > .hcms-error"):null;r&&(t?(r.textContent=t,r.hidden=!1):(r.textContent="",r.hidden=!0))}function Mt(e,t){let{formRoot:r,pageRules:i}=t,n=r.querySelector(`[data-hcms-path="${In(e)}"]`);if(!n)throw new Error(`hypercms: no element at path "${e}"`);let o=n.querySelector(".hcms-array-items");if(!o)throw new Error(`hypercms: array container missing .hcms-array-items at "${e}"`);let a=W(e),s=jn(i,a),l=Array.isArray(s),c=typeof s=="string"&&s.endsWith("[]");if(!l&&!c)throw new Error(`hypercms: path "${e}" is not an array`);let m=Xe(n,"data-hcms-max-items"),d=o.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]");if(n.hasAttribute("data-hcms-no-add")||m!=null&&d.length>=m)return;let u=d.length,y=l?s[1]:s.replace(/\[\]$/,""),x=ve(l?y:"string"),M=kr({shape:l?"object-array-item":"scalar-array-item",itemShape:y,pathArr:[...a,u],data:x,doc:t.doc,itemKey:n.getAttribute("data-hcms-item-tpl")||null});return o.appendChild(M),le(M,t.doc),Lt(n),de(`Add ${e}`,()=>z(D(t),{path:e,structural:!0},t))}function Cn(e,t,r){let i=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]');if(!i||i.hasAttribute("data-hcms-no-reorder"))return;let n=i.querySelector(".hcms-array-items");if(!n)return;let o=Array.from(n.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")),a=o.indexOf(e);if(a<0)return;let s=a+t;if(s<0||s>=o.length)return;let l=e.querySelector(`[data-hcms-action="${t<0?"move-up":"move-down"}"]`);return t<0?n.insertBefore(e,o[s]):n.insertBefore(e,o[s].nextSibling),Nt(n),Lt(i),l&&typeof l.focus=="function"&&e.querySelector(`[data-hcms-action="${t<0?"move-up":"move-down"}"]`)?.focus?.(),de(`Reorder ${i.getAttribute("data-hcms-path")||""}`,()=>z(D(r),{path:i.getAttribute("data-hcms-path")||"",structural:!0},r))}var Je="Delete this item?";function Rn(e,t){let r=e&&e.getAttribute("data-hcms-confirm-remove");if(r!=null)return/^(off|false|no|0)$/i.test(r.trim())?null:r||Je;let i=t&&t.confirmRemove;return i===!1?null:typeof i=="string"?i||Je:i===!0||e&&e.getAttribute("data-hcms-shape")==="object-array"?Je:null}function Tn(e,t){let r=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]'),i=Rn(r,t);if(i==null)return ce(e,t);let n=typeof window<"u"&&(window.hyperclay?.consent||window.consent);typeof n=="function"?Promise.resolve(n(i)).then(()=>ce(e,t),()=>{}):typeof window<"u"&&typeof window.confirm=="function"?window.confirm(i)&&ce(e,t):ce(e,t)}function ce(e,t){let r=e.getAttribute("data-hcms-path")||"",i=e.parentElement,n=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]');if(!n?.hasAttribute("data-hcms-no-remove")){if(n){let o=Xe(n,"data-hcms-min-items"),a=n.querySelector(".hcms-array-items"),s=a?a.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]").length:0;if(o!=null&&s<=o)return}return e.remove(),i&&Nt(i),n&&Lt(n),de(`Remove ${r}`,()=>z(D(t),{path:r,structural:!0},t))}}function z(e,t,r){let i=Se(e);if(i===r.lastFingerprint)return{ok:!0,skipped:!0};let n=Or(r.pageRoot,r.pageRules,e,{observerHandle:r.observerHandle,shellRoot:r.shellRoot,structural:!!t.structural,structuralPath:t.path||null});return n.ok?(r.lastFingerprint=i,r.lastData=e,jr(r,null),r.dispatch?.("hcms:change",{data:e,path:t.path,structural:!!t.structural}),r.onChange?.(e,t)):(jr(r,Ln(n.error,t.path)),r.dispatch?.("hcms:error",{error:n.error,attemptedData:e}),r.onError?.(n.error)),n}function D(e){let t=q.extract(e.formRoot,e.formRules);return K(t,e.formRules)}function K(e,t){if(t==null||e==null)return e;if(typeof t=="string")return t.endsWith("@checked")?e===!0||e==="true":e;if(Array.isArray(t)){if(!Array.isArray(e))return e;let[,r]=t;return e.map(i=>K(i,r))}if(typeof t=="object"){if(typeof e!="object"||Array.isArray(e))return e;let r={};for(let[i,n]of Object.entries(t))r[i]=K(e[i],n);return r}return e}function jr(e,t){e.lastErrors=t&&t.length?t:null,Ot(e)}function Ot(e){if(Mn(e),e.errorEl&&(e.errorEl.textContent="",e.errorEl.hidden=!0),!e.lastErrors)return;let t=[];for(let{message:r,path:i}of e.lastErrors){if(i!=null&&i!==""){let n=On(e.formRoot,i);if(n){n.textContent=n.textContent?`${n.textContent}
|
|
151
|
-
${r}`:r,
|
|
152
|
-
`),e.errorEl.hidden=!1)}function
|
|
150
|
+
`},zi=["@scalar","@object","@scalar-array","@scalar-array-item","@object-array","@object-array-item"];function rt(e){let t=e.head||e.documentElement;if(t)for(let r of zi)Vr(e,t,r)}function zt(e,t){if(!Pr[t])return null;let r=e&&(e.head||e.documentElement);return r?Vr(e,r,t):null}var $r={src:"@image",checked:"@checkbox",innerHTML:"@richtext"},et={image:"@image",file:"@file",checkbox:"@checkbox",toggle:"@toggle",select:"@select",radio:"@radio",textarea:"@textarea",number:"@number",richtext:"@richtext"},Ui=new Set([...Object.values(et),"@chips","@chips-item"]);function Be(e,t,r){if(typeof e!="string")return"@scalar";let n=z(e),i=ot(Pe(e,n),t,"data-hcms-component");if(i&&et[i]){let o=et[i],a=Array.isArray(r)&&r.some(s=>s==="*"||typeof s=="number");return o==="@number"&&!Br(e,n,t,a).every(Vi)||(o==="@checkbox"||o==="@toggle")&&(n<0||e.slice(n+1)!=="checked")&&!Br(e,n,t,a).every(Wi)?"@scalar":o}if(n>=0){let o=e.slice(n+1);if($r[o])return $r[o]}return"@scalar"}function zr(e,t){if(typeof e!="string")return null;let r=z(e),n=ot(Pe(e,r),t,"data-hcms-component");return n&&et[n]||null}var Hi=/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/;function Vi(e){return e==null||e===""?!0:Hi.test(String(e))}function Wi(e){return e==null||e===""||e==="true"||e==="false"}function Br(e,t,r,n){if(!r||!r.querySelectorAll)return[];let i=Pe(e,t);if(!i||i===".")return[];let o=null;try{o=r.querySelectorAll(i)}catch{return[]}let a=t>=0?e.slice(t+1):null,s=[];for(let l of o)if(!(l.closest&&l.closest("[cms-template], [data-hcms-shell]"))&&(a?a==="value"&&"value"in l?s.push(l.value):s.push(l.getAttribute?l.getAttribute(a):null):s.push((l.textContent||"").trim()),!n))break;return s}function nt(e,t){if(typeof e!="string"||!e.endsWith("[]")||!t||!t.querySelector)return null;let r=e.slice(0,-2).trim();if(!r)return null;let n=null;try{n=t.querySelector(r)}catch{return null}let i=n&&n.closest?n.closest("[data-hcms-component]"):null;return(i&&i.getAttribute?i.getAttribute("data-hcms-component"):null)==="chips"?{array:"@chips",item:"@chips-item"}:null}function Ae(e,t,r){let n=e.join("."),i=e.map(o=>typeof o=="number"?"*":o).join(".");return n&&ee(r,n)||i&&i!==n&&ee(r,i)||ee(r,t)}function it(e,t,r){let n=nt(e,r);if(!n)return null;let i=Ae(t,n.array,r);return i&&i.getAttribute("data-hcms-tpl")===n.array?n:null}function Ur(e,t){if(typeof e!="string")return null;let r=z(e),n=ot(Pe(e,r),t,"data-hcms-options");if(n==null)return null;let i=n.trim().split(/\s+/).filter(Boolean);return i.length?i:null}function Hr(e,t){if(typeof e!="string")return null;let r=z(e);return ot(Pe(e,r),t,"data-hcms-crop")}function Pe(e,t){return t>=0?e.slice(0,t):e}function ot(e,t,r){if(!t||!t.querySelector||!e||e===".")return null;let n=null;try{n=t.querySelector(e)}catch{return null}return n&&n.getAttribute?n.getAttribute(r):null}function st(e,t){if(!e||t==null)return;r(t);function r(n){let i=fe(n);if(i==="scalar"){let o=Be(n,e);Ui.has(o)&&zt(e,o);return}if(i==="scalar-array"){let o=nt(n,e);o&&(zt(e,o.array),zt(e,o.item));return}if(i==="object"){for(let o of Object.values(n))r(o);return}if(i==="object-array"){let o=n[1];if(o&&typeof o=="object"&&!Array.isArray(o))for(let a of Object.values(o))r(a);else r(o)}}}function Vr(e,t,r){let n=ee(e,r);if(n)return n;let i=e.createElement("template");return i.setAttribute("data-hcms-tpl",r),i.setAttribute("save-remove",""),i.innerHTML=Pr[r].trim(),t.appendChild(i),i}function ee(e,t){return!e||!e.querySelector?null:e.querySelector(`template[data-hcms-tpl="${Ki(t)}"]`)}function Ki(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}function fe(e){return typeof e=="string"?e.endsWith("[]")?"scalar-array":"scalar":Array.isArray(e)?"object-array":typeof e=="object"&&e!==null?"object":"scalar"}function ze(e){return e?!!(e.content||e).querySelector("[data-hcms-field]"):!1}var Wr={IMG:"src",A:"href"};function at(e){if(!e)return"value";let t=(e.tagName||"").toUpperCase();return t==="INPUT"?(e.getAttribute("type")||"text").toLowerCase()==="checkbox"?"checked":"value":t==="TEXTAREA"||t==="SELECT"?"value":Wr[t]?Wr[t]:e.hasAttribute&&e.hasAttribute("contenteditable")?"innerHTML":null}function Kr(e,t){let r=(e.tagName||"").toUpperCase(),n=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),i=at(e),a=`${Jr(r,n)}[data-hcms-field="${Se(t)}"]`;return r==="INPUT"&&n==="radio"?`${a}:checked@value`:i?`${a}@${i}`:a}function Gi(e){let t=(e.tagName||"").toUpperCase(),r=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),n=at(e),o=`${Jr(t,r)}[data-hcms-field]`;return t==="INPUT"&&r==="radio"?`${o}:checked@value`:n?`${o}@${n}`:o}function Jr(e,t){return e==="INPUT"?t?`input[type="${t}"]`:"input":e==="TEXTAREA"?"textarea":e==="SELECT"?"select":e==="IMG"?"img":e==="A"?"a":':not([data-hcms-shape="scalar"]):not([data-hcms-shape="object"]):not([data-hcms-shape="object-array"]):not([data-hcms-shape="scalar-array"])'}function Se(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var Gr=new Set(["__proto__","constructor","prototype"]);function lt(e,t){return r(e,[]);function r(c,m){let p=fe(c);if(p==="scalar")return n(c,m);if(p==="scalar-array")return i(c,m);if(p==="object-array")return o(c,m);if(p==="object"){let d=Object.create(null);for(let[f,k]of Object.entries(c)){if(Gr.has(f))throw new Error(`hypercms: rule key "${f}" is forbidden at "${m.join(".")||"<root>"}"`);d[f]=r(k,[...m,f])}return d}return null}function n(c,m){let p=m.length?m[m.length-1]:null,d=typeof p=="string"?p:"__value",f=l(m,d);if(f)return Kr(f,d);let k=s(Be(c,t,m),d);return k?Kr(k,d):`input[data-hcms-field="${Se(d)}"]@value`}function i(c,m){let p=it(c,m,t),d=p&&s(p.item,null)||s("@scalar-array-item",null),f=d?Gi(d):"input[data-hcms-field]@value";return[a(m,"[data-hcms-array-item]"),f]}function o(c,m){let[,p]=c,d=[...m,"*"],f=a(m,"[data-hcms-card]");if(p&&typeof p=="object"&&!Array.isArray(p)){let k=Object.create(null);for(let[R,O]of Object.entries(p)){if(Gr.has(R))throw new Error(`hypercms: rule key "${R}" is forbidden at "${d.join(".")}"`);k[R]=r(O,[...d,R])}return[f,k]}return[f,r(p,[...d,0])]}function a(c,m){let p=c.length?c[c.length-1]:"",d=c.some(R=>R==="*"),f=c.join(".");return`${d?`[data-hcms-field="${Se(p)}"]`:`[data-hcms-path="${Se(f)}"]`} > .hcms-array-items > ${m}`}function s(c,m){if(!t)return null;let p=ee(t,c);if(!p)return null;let d=p.content||p;if(m){let f=d.querySelector(`[data-hcms-field="${Se(m)}"]`);if(f)return f}return d.querySelector("[data-hcms-field]")}function l(c,m){if(!t)return null;let p=c.map(k=>typeof k=="number"?"*":k).join("."),f=[c.join("."),p];for(let k=c.length-1;k>=0;k--){let R=c.slice(0,k).map(O=>typeof O=="number"?"*":O);R.push("*"),f.push(R.join("."))}for(let k of f){if(!k)continue;let R=ee(t,k);if(!R||!ze(R))continue;let O=R.content||R,F=O.querySelector(`[data-hcms-field="${Se(m)}"]`)||O.querySelector("[data-hcms-field]");if(F)return F}return null}}function Ut(e){if(!e)return"";let t=String(e).split(/[?#]/)[0],r=t.split("/").pop()||t;try{return decodeURIComponent(r)}catch{return r}}function ct({pageRules:e,formRules:t,data:r,doc:n}){let i=n.createDocumentFragment(),o=Ht(e,[],r,n);return o&&i.appendChild(o),i}function Xr({shape:e,itemShape:t,pathArr:r,data:n,doc:i,itemKey:o}){if(e==="object-array-item")return Qr(t,r,n,i);if(e==="scalar-array-item")return en(r,n,i,o||null);throw new Error(`hypercms: buildItem called with unknown shape "${e}"`)}function Ht(e,t,r,n){let i=fe(e);return i==="scalar"?Ji(e,t,r,n):i==="object"?Qi(e,t,r,n):i==="object-array"?eo(e,t,r,n):i==="scalar-array"?to(e,t,r,n):null}function Ji(e,t,r,n){let i=Be(e,n,t),o=Ae(t,i,n);if(!o)throw new Error(`hypercms: missing template for scalar at "${t.join(".")}"`);let a=zr(e,n);a==="@number"&&i==="@scalar"&&console.info(`[hypercms] field "${t.join(".")}" declares component "@number" but its value isn't a plain number; rendering a text input so the value is preserved`),(a==="@checkbox"||a==="@toggle")&&i==="@scalar"&&console.info(`[hypercms] field "${t.join(".")}" declares component "${a}" but its value isn't true/false; rendering a text input so the value is preserved`),Zr(o,a===i?a:null,t);let s=Ee(o,n);Ce(s,t);let l=o.getAttribute?.("data-hcms-tpl");if((i==="@select"||i==="@radio")&&l===i&&Yi(s,e,t,r,n,i),i==="@image"&&l==="@image"){let c=Hr(e,n);c!=null&&!s.hasAttribute("data-hcms-crop")&&s.setAttribute("data-hcms-crop",c)}return ro(s,oe(t)),dt(s,oe(t)),mt(s,oe(t)),sn(s,r),i==="@file"&&Zi(s),s}function Zr(e,t,r){if(!t)return;let n=e.getAttribute?.("data-hcms-tpl");n&&n!==t&&console.info(`[hypercms] field "${r.join(".")}" declares component "${t}" but custom template "${n}" wins`)}function Yi(e,t,r,n,i,o){let a=Ur(t,i),s=a?[...a]:[],l=n==null?"":String(n);if(l!==""&&!s.includes(l)&&s.unshift(l),!a&&(Xi(e,"data-hcms-options required (space-separated values)"),s.length===0)){e.querySelector(".mirk-radio")?.remove();return}if(o==="@select"){let p=e.querySelector("select[data-hcms-field]");if(!p)return;for(let d of s){let f=i.createElement("option");f.value=d,f.textContent=tt(d),p.appendChild(f)}return}let c=e.querySelector(".mirk-radio");if(!c||!c.parentNode)return;let m=Vt(r.join("."));for(let p of s){let d=c.cloneNode(!0),f=d.querySelector('input[type="radio"]');f&&(f.value=p,f.name=m);let k=d.querySelector(".mirk-radio__label");k&&(k.textContent=tt(p)),c.parentNode.insertBefore(d,c)}c.remove()}function Vt(e){return"hcms-"+String(e).replace(/[^A-Za-z0-9_-]/g,"-")}function Xi(e,t){let r=e.querySelector?e.querySelector(".hcms-error"):null;r&&(r.textContent=t,r.hidden=!1)}function Zi(e){let t=e.querySelector?e.querySelector("a.mirk-file__name[data-hcms-field]"):null;t&&(t.textContent=Ut(t.getAttribute("href")))}function Qi(e,t,r,n){let i=Ae(t,"@object",n);if(!i)throw new Error(`hypercms: missing template for object at "${t.join(".")}"`);let o=Ee(i,n);if(Ce(o,t),dt(o,oe(t)),mt(o,oe(t)),ze(i))return ln(o,e,t),an(o,e,r),o;let a=ut(o,".hcms-object-fields",i,t);for(let[s,l]of Object.entries(e)){let c=r==null?null:r[s],m=Ht(l,[...t,s],c,n);m&&a.appendChild(m)}return o}function eo(e,t,r,n){let i=Ae(t,"@object-array",n);if(!i)throw new Error(`hypercms: missing template for object-array at "${t.join(".")}"`);let o=Ee(i,n);Ce(o,t),dt(o,oe(t)),mt(o,oe(t)),rn(o,i),on(o,i,t);let a=ut(o,".hcms-array-items",i,t),[,s]=e;return(Array.isArray(r)?r:[]).forEach((c,m)=>{let p=Qr(s,[...t,m],c,n);p&&a.appendChild(p)}),nn(o),o}function Qr(e,t,r,n){let i=tn(t,"object-array-item",n);if(!i)throw new Error(`hypercms: missing item template for "${t.join(".")}"`);let o=Ee(i,n);if(o.setAttribute("data-hcms-card",""),o.classList.contains("hcms-card")||o.classList.add("hcms-card"),Ce(o,t),ze(i))return e&&typeof e=="object"&&!Array.isArray(e)&&(ln(o,e,t),an(o,e,r)),o;let a=ut(o,".hcms-card-fields",i,t);if(e&&typeof e=="object"&&!Array.isArray(e))for(let[s,l]of Object.entries(e)){let c=r==null?null:r[s],m=Ht(l,[...t,s],c,n);m&&a.appendChild(m)}return o}function to(e,t,r,n){let i=nt(e,n),o=it(e,t,n),a=i?i.array:"@scalar-array",s=Ae(t,a,n);if(!s)throw new Error(`hypercms: missing template for scalar-array at "${t.join(".")}"`);Zr(s,i?i.array:null,t);let l=Ee(s,n);Ce(l,t),dt(l,oe(t)),mt(l,oe(t)),rn(l,s),on(l,s,t),o&&l.setAttribute("data-hcms-item-tpl",o.item);let c=ut(l,".hcms-array-items",s,t);return(Array.isArray(r)?r:[]).forEach((p,d)=>{let f=en([...t,d],p,n,o?o.item:null);f&&c.appendChild(f)}),nn(l),l}function en(e,t,r,n){let i=tn(e,"scalar-array-item",r,n);if(!i)throw new Error(`hypercms: missing item template for "${e.join(".")}"`);let o=Ee(i,r);return o.setAttribute("data-hcms-array-item",""),o.classList.contains("hcms-array-item")||o.classList.add("hcms-array-item"),Ce(o,e),sn(o,t),o}function tn(e,t,r,n){let i=e.map(o=>typeof o=="number"?"*":o).join(".");return ee(r,i)||n&&ee(r,n)||ee(r,"@"+t)}function Ee(e,t){let r=e.content||e,n=t.createElement("div");return n.appendChild(r.cloneNode(!0)),n.firstElementChild||n}function Ce(e,t){e.setAttribute("data-hcms-path",t.join("."))}function ro(e,t){let r=t==null?"":String(t);if(e.matches&&e.matches("[data-hcms-field]")){e.getAttribute("data-hcms-field")||e.setAttribute("data-hcms-field",r);return}(e.querySelectorAll?e.querySelectorAll("[data-hcms-field]"):[]).forEach(i=>{i.getAttribute("data-hcms-field")||i.setAttribute("data-hcms-field",r)})}function dt(e,t){t==null||t===""||!e.setAttribute||e.hasAttribute?.("data-hcms-field")||e.setAttribute("data-hcms-field",String(t))}function mt(e,t){if(t==null||t==="")return;(e.querySelectorAll?e.querySelectorAll("[data-hcms-label]"):[]).forEach(n=>{(n.textContent||"").trim()===""&&(n.textContent=tt(String(t)))})}function rn(e,t){["data-hcms-no-add","data-hcms-no-remove","data-hcms-no-reorder"].forEach(r=>{t.hasAttribute(r)&&e.setAttribute(r,"")}),["data-hcms-min-items","data-hcms-max-items"].forEach(r=>{t.hasAttribute(r)&&e.setAttribute(r,t.getAttribute(r))})}function nn(e){let t=e.querySelector?e.querySelector(".hcms-array-items"):null;if(!t)return;let r=Array.from(t.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")),n=r.length,i=Yr(e,"data-hcms-max-items"),o=Yr(e,"data-hcms-min-items"),a=e.hasAttribute("data-hcms-no-add"),s=e.hasAttribute("data-hcms-no-remove"),l=e.hasAttribute("data-hcms-no-reorder"),c=e.querySelector('[data-hcms-action="add"]');c&&(c.hidden=a||i!=null&&n>=i),r.forEach((m,p)=>{let d=m.querySelector('[data-hcms-action="remove"]');d&&(d.hidden=s||o!=null&&n<=o);let f=m.querySelector('[data-hcms-action="move-up"]');f&&(f.hidden=l||p===0);let k=m.querySelector('[data-hcms-action="move-down"]');k&&(k.hidden=l||p===n-1)})}function Yr(e,t){if(!e||!e.hasAttribute(t))return null;let r=parseInt(e.getAttribute(t),10);return Number.isFinite(r)?r:null}function on(e,t,r){if(e.hasAttribute("data-hcms-no-reorder")||t.hasAttribute("data-hcms-no-reorder"))return;let n=e.querySelector(".hcms-array-items");if(!n)return;let i="hcms-"+r.join(".");n.setAttribute("sortable",i),n.setAttribute("onsorted","hypercmsCommit && hypercmsCommit()")}function oe(e){return e.length?e[e.length-1]:null}function sn(e,t){let r=no(e);if(r.length!==0)for(let n of r)cn(n,t)}function no(e){if(!e)return[];let t=[];return e.matches?.("[data-hcms-field]")&&io(e)&&t.push(e),(e.querySelectorAll?e.querySelectorAll("input[data-hcms-field], textarea[data-hcms-field], select[data-hcms-field], img[data-hcms-field], a[data-hcms-field], [contenteditable][data-hcms-field]"):[]).forEach(n=>t.push(n)),t}function io(e){let t=(e.tagName||"").toUpperCase();return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||t==="IMG"||t==="A"||e.hasAttribute?.("contenteditable"))}function an(e,t,r){(e.querySelectorAll?e.querySelectorAll("[data-hcms-field]"):[]).forEach(i=>{let o=i.getAttribute("data-hcms-field");if(!o)return;if(!t||typeof t!="object"||!(o in t)){console.warn(`[hypercms] inline template field "${o}" is not in the rule shape; ignoring`);return}let a=r==null?null:r[o];cn(i,a)})}function ln(e,t,r){if(!e.querySelectorAll)return;e.querySelectorAll("[data-hcms-field]").forEach(i=>{let o=i.getAttribute("data-hcms-field");if(!o||t&&typeof t=="object"&&!(o in t))return;let a=[...r,o].join(".");i.setAttribute("data-hcms-path",a)})}function ut(e,t,r,n){if(!e.querySelector)return e;let i=e.querySelector(t);if(i)return i;let o=r?.getAttribute?.("data-hcms-tpl")||n.join(".");throw new Error(`hypercms: template "${o}" is in slotted mode but has no ${t} element`)}function cn(e,t){let r=at(e),n=(e.tagName||"").toUpperCase(),i=(e.getAttribute("type")||"").toLowerCase();if(n==="INPUT"&&i==="radio"){e.checked=e.value!=null&&String(e.value)===String(t??"");return}if(r==="checked"){e.checked=t===!0||t==="true";return}if(r){e[r]=t==null?"":String(t);return}e.textContent=t==null?"":String(t)}var dn={skip:"[data-hcms-shell]",templateAttr:"cms-template"};function mn(e,t,r,n={}){let{observerHandle:i,shellRoot:o,structural:a,structuralPath:s}=n;i?.pause?.();try{if(!a)try{return W.apply(e,t,r,dn),{ok:!0}}catch(p){return{ok:!1,error:p}}let l=oo(e,t,s),c=l?ao(l):null,m=l?null:co(e,o);try{return W.apply(e,t,r,dn),{ok:!0}}catch(p){return c?lo(l,c):m&&mo(e,o,m),{ok:!1,error:p}}}finally{i?.resume?.()}}function oo(e,t,r){if(!r||!e)return null;let n=ie(r),i=[],o=t;for(let a of n){if(typeof o=="string"||o==null||Array.isArray(o))break;if(typeof o=="object"&&a in o){if(i.push(a),o=o[a],Array.isArray(o)||typeof o=="string"&&o.endsWith("[]"))break}else return null}return!Array.isArray(o)&&!(typeof o=="string"&&o.endsWith("[]"))?null:so(e,t,i)}function so(e,t,r){if(r.length===0)return null;let n=e,i=t;for(let o=0;o<r.length;o++){let a=r[o];if(!i||typeof i!="object"||Array.isArray(i))return null;let s=i[a];if(s==null)return null;if(o===r.length-1){if(Array.isArray(s)){let[l]=s;return n.querySelector?.(l)?.parentElement||null}if(typeof s=="string"&&s.endsWith("[]")){let l=s.slice(0,-2);return n.querySelector?.(l)?.parentElement||null}return null}i=s}return null}function ao(e){let t=[];for(let r of Array.from(e.childNodes))t.push(r.cloneNode(!0));return t}function lo(e,t){for(;e.firstChild;)e.removeChild(e.firstChild);for(let r of t)e.appendChild(r)}function co(e,t){let r=[];for(let n of Array.from(e.childNodes))n===t||t&&n.contains?.(t)||r.push(n.cloneNode(!0));return r}function mo(e,t,r){for(let i of Array.from(e.childNodes))i===t||t&&i.contains?.(t)||e.removeChild(i);let n=uo(e,t);for(let i of r)e.insertBefore(i,n||null)}function uo(e,t){if(!t)return null;for(let r of Array.from(e.childNodes))if(r===t||r.contains?.(t))return r;return null}var ho={Mutation:(e,t)=>e?.Mutation??t?.Mutation,undo:(e,t)=>e?.undo??t?.undo,onPrepareForSave:(e,t)=>e?.addDocumentTransform??t?.onPrepareForSave,consent:(e,t)=>e?.confirm??t?.consent,RichClay:(e,t)=>e?.RichClay??t?.RichClay,quickcrop:(e,t)=>e?.quickcrop??t?.quickcrop,uploadFileBasic:(e,t)=>e?.uploadFileBasic??t?.uploadFileBasic};function K(e,t){let r=ho[e];if(!r)throw new Error(`hypercms: unknown platform capability "${e}"`);let n=t||(typeof window<"u"?window:null);return n&&r(n.clay,n.hyperclay)||null}var un=["clay:mutation-ready","hyperclay:mutation-ready"],hn=["clay:sync-applied","hyperclay:livesync-applied"];function Wt(e,t,r){let n=null,i=o=>{n!==null&&n!==o.type||(n=o.type,queueMicrotask(()=>{n=null}),r(o))};for(let o of t)e.addEventListener(o,i);return()=>{for(let o of t)e.removeEventListener(o,i)}}function ht(e,t){if(!t||e==null)return e;return r(e);function r(n){if(typeof n=="string"){if(n.endsWith("[]")||z(n)!==-1)return n;let i=null;try{i=t.querySelector(n)}catch{return n}return i&&i.children.length>0?n+"@innerHTML":n}if(Array.isArray(n))return n;if(n&&typeof n=="object"){let i=Object.create(null);for(let[o,a]of Object.entries(n))i[o]=r(a);return i}return n}}function Kt(e){if(!e||e.tagName!=="TEXTAREA")return;let t=e.ownerDocument.defaultView||(typeof window<"u"?window:null);t&&t.CSS&&t.CSS.supports&&t.CSS.supports("field-sizing: content")||(e.style.height="auto",e.style.height=e.scrollHeight+"px")}function Re(e,t){if(!e||!e.querySelectorAll)return;e.querySelectorAll("textarea[data-hcms-field]").forEach(Kt);let r=t&&t.defaultView||(typeof window<"u"?window:null),n=r&&r.richclay&&r.richclay.RichClay||K("RichClay",r)||(r&&typeof r.RichClay=="function"?r.RichClay:null);n&&e.querySelectorAll("[contenteditable][data-hcms-field]").forEach(i=>{if(i.__hcmsRichclay)return;let o;try{o=new n(i,{inline:!0,hyperclay:!1,toolbar:["bold","italic","link","undo","redo"]})}catch(s){console.warn("[hypercms] richclay activation failed; field stays plain contenteditable",s);return}i.__hcmsRichclay=o;let a=o&&o.squire;a&&typeof a.addEventListener=="function"&&a.addEventListener("input",()=>{let s=r&&r.Event||Event;i.dispatchEvent(new s("input",{bubbles:!0}))})})}var Gt=new WeakSet;function Me(e,t){let r=K("undo");if(!r)return t();r.pause();try{let n=t();return n&&n.ok?r.commitCaptured(e):r.discardCaptured(),n}finally{r.resume()}}function gt(e){let t=K("undo");if(!t)return e();t.pause();try{return e()}finally{t.discardCaptured(),t.resume()}}function gn(e){let{formRoot:t}=e;if(!t||Gt.has(t))return;Gt.add(t);let r=a=>{let s=a.target;!s||!s.closest||s.closest("[data-hcms-form-root]")&&s.matches("input, textarea, select, [contenteditable][data-hcms-field]")&&(s.tagName==="TEXTAREA"&&Kt(s),!s.matches('input[type="file"]')&&(!s.closest("[data-hcms-field]")&&!s.hasAttribute?.("data-hcms-field")||pn(s,e)))},n=a=>{let s=a.target;if(!(!s||!s.closest)&&s.closest("[data-hcms-form-root]")){if(s.matches('input[type="file"][data-hcms-upload]')){vo(s,e);return}s.matches('input[type="checkbox"], input[type="radio"], select')&&pn(s,e)}},i=a=>{let s=a.target;if(!s||!s.closest)return;let l=s.closest("[data-hcms-action]");if(!l)return;let c=l.getAttribute("data-hcms-action");if(c==="add"||c==="remove"||c==="move-up"||c==="move-down"||c==="clear-upload"){if(!l.closest("[data-hcms-form-root]"))return}else if(c==="close"&&!l.closest("[data-hcms-shell]"))return;if(c==="add"){let m=l.closest("[data-hcms-path]");if(!m)return;let p=m.getAttribute("data-hcms-path");Jt(p,e)}else if(c==="remove"){let m=l.closest("[data-hcms-card], [data-hcms-array-item]");if(!m)return;Eo(m,e)}else if(c==="move-up"||c==="move-down"){let m=l.closest("[data-hcms-card], [data-hcms-array-item]");if(!m)return;Ao(m,c==="move-up"?-1:1,e)}else c==="clear-upload"?xo(l,e):c==="close"&&e.onCloseRequested?.()},o=t.ownerDocument;o.addEventListener("input",r,!0),o.addEventListener("change",n,!0),o.addEventListener("click",i,!0),e.detachEvents=()=>{o.removeEventListener("input",r,!0),o.removeEventListener("change",n,!0),o.removeEventListener("click",i,!0),Gt.delete(t)}}var po=new Set(["value","checked"]);function fo(e,t){if(!t)return null;let r=ie(t);if(r.some(l=>typeof l=="number"||l==="*"))return null;let n=pe(e.pageRules,r);if(typeof n!="string")return null;let i=W.ruleAttrIndex(n);if(i===-1)return null;let o=n.slice(i+1);if(!po.has(o))return null;let a=n.slice(0,i),s=a?e.pageRoot.querySelector(a):e.pageRoot;return s?{el:s,prop:o,oldValue:s[o]}:null}function pn(e,t){let n=(e.closest("[data-hcms-field]")||e).closest("[data-hcms-path]")?.getAttribute("data-hcms-path")||"",i=fo(t,n);if(ne(Z(t),{path:n,structural:!1},t),i){let o=K("undo");o&&typeof o.recordValue=="function"&&o.recordValue(i.el,{prop:i.prop,oldValue:i.oldValue,newValue:i.el[i.prop]})}}var go={type:"image/webp",quality:.85,maxWidth:2048,maxHeight:2048};async function bo(e,t){let r=t&&t.getAttribute?t.getAttribute("data-hcms-crop"):null;if(r==null)return{file:e};let n=K("quickcrop");if(typeof n!="function")return{file:e};try{let i=await n(e,{aspect:ko(r),...go});return i===null?null:{file:yo(i.blob,e.name),dataURL:i.dataURL}}catch(i){return Ue(t,i&&i.message||"Crop failed"),null}}function ko(e){let t=String(e??"").trim().toLowerCase();if(t===""||t==="free")return null;let r=t.match(/^(\d+(?:\.\d+)?)\s*[:/]\s*(\d+(?:\.\d+)?)$/);if(!r)return null;let n=parseFloat(r[1]),i=parseFloat(r[2]);return!n||!i?null:n/i}function yo(e,t){let r=e.type==="image/webp"?".webp":e.type==="image/jpeg"?".jpg":".png",n=String(t||"image").replace(/\.[^.]+$/,"");try{return new File([e],n+r,{type:e.type})}catch{return e}}async function vo(e,t){let r=e.files&&e.files[0];if(!r)return;let n=e.closest("[data-hcms-path]");if(!n)return;let i=n.getAttribute("data-hcms-path")||"";Ue(n,null);let o=await bo(r,n);if(!o||t.closed){ge(e);return}let a=o.file,s=o.dataURL||null,l=K("uploadFileBasic"),c=null;if(typeof l=="function")try{let m=await l(a);c=m&&m.uploads&&m.uploads[0]&&m.uploads[0].url}catch(m){if(t.closed){ge(e);return}Ue(n,m&&m.message||"Upload failed"),t.dispatch?.("hcms:error",{error:m,path:i}),ge(e);return}if(t.closed){ge(e);return}if(c||(c=s||_o(a)),!c){ge(e);return}Ue(n,null),bn(n,c,a.name),ne(Z(t),{path:i,structural:!1},t),ge(e)}function xo(e,t){let r=e.closest("[data-hcms-path]");if(!r)return;let n=r.getAttribute("data-hcms-path")||"";bn(r,"","");let i=r.querySelector('input[type="file"][data-hcms-upload]');i&&ge(i),Ue(r,null),ne(Z(t),{path:n,structural:!1},t)}function wo(e){return e.querySelector?e.querySelector("img[data-hcms-field], a[data-hcms-field]"):null}function bn(e,t,r){let n=wo(e);if(!n)return;let i=(n.tagName||"").toUpperCase();i==="IMG"?n.src=t||"":i==="A"&&(n.href=t||"",n.textContent=t?r||Ut(t):"")}function ge(e){try{e.value=""}catch{}}function _o(e){let t=typeof URL<"u"&&URL.createObjectURL?URL:null;if(!t)return"";try{return t.createObjectURL(e)}catch{return""}}function Ue(e,t){let r=e.querySelector?e.querySelector(":scope > .hcms-error"):null;r&&(t?(r.textContent=t,r.hidden=!1):(r.textContent="",r.hidden=!0))}function Jt(e,t){let{formRoot:r,pageRules:n}=t,i=r.querySelector(`[data-hcms-path="${Io(e)}"]`);if(!i)throw new Error(`hypercms: no element at path "${e}"`);let o=i.querySelector(".hcms-array-items");if(!o)throw new Error(`hypercms: array container missing .hcms-array-items at "${e}"`);let a=ie(e),s=Mo(n,a),l=Array.isArray(s),c=typeof s=="string"&&s.endsWith("[]");if(!l&&!c)throw new Error(`hypercms: path "${e}" is not an array`);let m=ft(i,"data-hcms-max-items"),p=o.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]");if(i.hasAttribute("data-hcms-no-add")||m!=null&&p.length>=m)return;let d=p.length,f=l?s[1]:s.replace(/\[\]$/,""),k=$e(l?f:"string"),R=Xr({shape:l?"object-array-item":"scalar-array-item",itemShape:f,pathArr:[...a,d],data:k,doc:t.doc,itemKey:i.getAttribute("data-hcms-item-tpl")||null});return o.appendChild(R),Re(R,t.doc),Xt(i),Me(`Add ${e}`,()=>ne(Z(t),{path:e,structural:!0},t))}function Ao(e,t,r){let n=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]');if(!n||n.hasAttribute("data-hcms-no-reorder"))return;let i=n.querySelector(".hcms-array-items");if(!i)return;let o=Array.from(i.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")),a=o.indexOf(e);if(a<0)return;let s=a+t;if(s<0||s>=o.length)return;let l=e.querySelector(`[data-hcms-action="${t<0?"move-up":"move-down"}"]`);return t<0?i.insertBefore(e,o[s]):i.insertBefore(e,o[s].nextSibling),Qt(i),Xt(n),l&&typeof l.focus=="function"&&e.querySelector(`[data-hcms-action="${t<0?"move-up":"move-down"}"]`)?.focus?.(),Me(`Reorder ${n.getAttribute("data-hcms-path")||""}`,()=>ne(Z(r),{path:n.getAttribute("data-hcms-path")||"",structural:!0},r))}var pt="Delete this item?";function So(e,t){let r=e&&e.getAttribute("data-hcms-confirm-remove");if(r!=null)return/^(off|false|no|0)$/i.test(r.trim())?null:r||pt;let n=t&&t.confirmRemove;return n===!1?null:typeof n=="string"?n||pt:n===!0||e&&e.getAttribute("data-hcms-shape")==="object-array"?pt:null}function Eo(e,t){let r=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]'),n=So(r,t);if(n==null)return Te(e,t);let i=K("consent")||typeof window<"u"&&window.consent;typeof i=="function"?Promise.resolve(i(n)).then(()=>Te(e,t),()=>{}):typeof window<"u"&&typeof window.confirm=="function"?window.confirm(n)&&Te(e,t):Te(e,t)}function Te(e,t){let r=e.getAttribute("data-hcms-path")||"",n=e.parentElement,i=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]');if(!i?.hasAttribute("data-hcms-no-remove")){if(i){let o=ft(i,"data-hcms-min-items"),a=i.querySelector(".hcms-array-items"),s=a?a.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]").length:0;if(o!=null&&s<=o)return}return e.remove(),n&&Qt(n),i&&Xt(i),Me(`Remove ${r}`,()=>ne(Z(t),{path:r,structural:!0},t))}}function ne(e,t,r){let n=He(e);if(n===r.lastFingerprint)return{ok:!0,skipped:!0};let i=mn(r.pageRoot,r.pageRules,e,{observerHandle:r.observerHandle,shellRoot:r.shellRoot,structural:!!t.structural,structuralPath:t.path||null});return i.ok?(r.lastFingerprint=n,r.lastData=e,fn(r,null),r.dispatch?.("hcms:change",{data:e,path:t.path,structural:!!t.structural}),r.onChange?.(e,t)):(fn(r,To(i.error,t.path)),r.dispatch?.("hcms:error",{error:i.error,attemptedData:e}),r.onError?.(i.error)),i}function Z(e){let t=W.extract(e.formRoot,e.formRules);return me(t,e.formRules)}function me(e,t){if(t==null||e==null)return e;if(typeof t=="string")return t.endsWith("@checked")?e===!0||e==="true":e;if(Array.isArray(t)){if(!Array.isArray(e))return e;let[,r]=t;return e.map(n=>me(n,r))}if(typeof t=="object"){if(typeof e!="object"||Array.isArray(e))return e;let r={};for(let[n,i]of Object.entries(t))r[n]=me(e[n],i);return r}return e}function fn(e,t){e.lastErrors=t&&t.length?t:null,Yt(e)}function Yt(e){if(Co(e),e.errorEl&&(e.errorEl.textContent="",e.errorEl.hidden=!0),!e.lastErrors)return;let t=[];for(let{message:r,path:n}of e.lastErrors){if(n!=null&&n!==""){let i=Ro(e.formRoot,n);if(i){i.textContent=i.textContent?`${i.textContent}
|
|
151
|
+
${r}`:r,i.hidden=!1;continue}}t.push(r)}t.length&&e.errorEl&&(e.errorEl.textContent=t.join(`
|
|
152
|
+
`),e.errorEl.hidden=!1)}function Co(e){if(e.formRoot)for(let t of e.formRoot.querySelectorAll(".hcms-error"))t.textContent="",t.hidden=!0}function Ro(e,t){if(!e)return null;let r=t.split(".");for(;r.length>0;){let n=r.join("."),i=typeof CSS<"u"&&CSS.escape?CSS.escape(n):n.replace(/[^a-zA-Z0-9_\-.*]/g,a=>"\\"+a),o=e.querySelector(`[data-hcms-path="${i}"]`);if(o){for(let a of o.children)if(a.classList&&a.classList.contains("hcms-error"))return a}r.pop()}return null}function To(e,t){return e?e.name==="EmptyListInsert"?[{message:"Add a seed item in HTML first.",path:t}]:e.name==="ShapeMismatch"&&Array.isArray(e.mismatches)&&e.mismatches.length?e.mismatches.map(r=>({message:`Shape mismatch: expected ${r.expected}, got ${r.got}`,path:r.path})):[{message:e.message||String(e),path:t}]:[{message:"unknown error",path:t}]}function Mo(e,t){let r=e;for(let n of t){if(r==null||typeof r=="string")return;if(Array.isArray(r)){if(typeof n!="number"&&n!=="*")return;r=r[1];continue}if(typeof r=="object"){if(typeof n=="number"||!(n in r))return;r=r[n];continue}return}return r}function ft(e,t){if(!e||!e.hasAttribute(t))return null;let r=parseInt(e.getAttribute(t),10);return Number.isFinite(r)?r:null}function Xt(e){if(!e)return;let t=e.querySelector(".hcms-array-items");if(!t)return;let r=Array.from(t.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")),n=r.length,i=ft(e,"data-hcms-max-items"),o=ft(e,"data-hcms-min-items"),a=e.hasAttribute("data-hcms-no-add"),s=e.hasAttribute("data-hcms-no-remove"),l=e.hasAttribute("data-hcms-no-reorder"),c=e.querySelector(':scope > .hcms-add, :scope > * > .hcms-add, :scope > [data-hcms-action="add"]');c&&(c.hidden=a||i!=null&&n>=i),r.forEach((m,p)=>{let d=m.querySelector('[data-hcms-action="remove"]');d&&(d.hidden=s||o!=null&&n<=o);let f=m.querySelector('[data-hcms-action="move-up"]');f&&(f.hidden=l||p===0);let k=m.querySelector('[data-hcms-action="move-down"]');k&&(k.hidden=l||p===n-1)})}function Zt(e){!e||!e.querySelectorAll||e.querySelectorAll(".hcms-array-items").forEach(t=>Qt(t))}function Qt(e){let t=e.querySelectorAll?Array.from(e.querySelectorAll('input[type="radio"][data-hcms-field]'),n=>[n,n.checked]):[],r=0;for(let n of e.children){if(!n.matches?.("[data-hcms-card], [data-hcms-array-item]"))continue;let i=n.getAttribute("data-hcms-path");if(!i)continue;let o=i.split(".");o[o.length-1]=String(r);let a=o.join(".");a!==i&&Oo(n,i,a),r++}for(let[n,i]of t)n.checked!==i&&(n.checked=i)}function Oo(e,t,r){let n=e.querySelectorAll("[data-hcms-path]");e.setAttribute("data-hcms-path",r);for(let i of n){let o=i.getAttribute("data-hcms-path");o===t?i.setAttribute("data-hcms-path",r):o&&o.startsWith(t+".")&&i.setAttribute("data-hcms-path",r+o.slice(t.length))}No(e)}function No(e){for(let t of e.querySelectorAll('input[type="radio"][data-hcms-field]')){if(!t.name||!t.name.startsWith("hcms-"))continue;let r=t.closest("[data-hcms-path]");r&&(t.name=Vt(r.getAttribute("data-hcms-path")))}}function He(e){return JSON.stringify(e,(t,r)=>{if(r&&typeof r=="object"&&!Array.isArray(r)){let n=Object.create(null);for(let i of Object.keys(r).sort())n[i]=r[i];return n}return r})}function Io(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var Bo={},bt="hcms-shell-styles",jo="hcms-bundled-styles-installed",Lo='a[href], area[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',Oe=new WeakSet,er="";function yn(e){er=e}var Fo=0;function kn(e){return String(e).replace(/[&<>"]/g,t=>({"&":"&","<":"<",">":">",'"':"""})[t])}function vn({mountTo:e,side:t="right",overlay:r=!1,showSaveButton:n=!1,title:i="Page content",eyebrow:o="Edit",theme:a=null,doc:s}){xn(s);let l=`hcms-shell-title-${++Fo}`,c=s.createElement("div");c.setAttribute("data-hcms-shell",""),c.setAttribute("save-remove",""),c.setAttribute("save-ignore",""),c.setAttribute("tabindex","-1"),c.setAttribute("role","dialog"),c.setAttribute("aria-modal","true"),c.setAttribute("aria-labelledby",l);let m=a==="dark"?" dark":a==="light"?" light":"";c.className="hcms-shell pixel-quiet hcms-side-"+t+(r?" hcms-overlay":"")+m;let p=kn(i),d=kn(o);c.innerHTML=`
|
|
153
153
|
<div class="hcms-shell-minibar" aria-hidden="true">
|
|
154
|
-
<span class="hcms-shell-minibar-title">${
|
|
154
|
+
<span class="hcms-shell-minibar-title">${p}</span>
|
|
155
155
|
<button type="button" class="hcms-shell-close mirk-button mirk-button--small" data-hcms-action="close" aria-label="Close">
|
|
156
156
|
<span class="mirk-button__label">\xD7</span>
|
|
157
157
|
</button>
|
|
@@ -159,22 +159,23 @@ ${r}`:r,n.hidden=!1;continue}}t.push(r)}t.length&&e.errorEl&&(e.errorEl.textCont
|
|
|
159
159
|
<div class="hcms-shell-body">
|
|
160
160
|
<header class="hcms-shell-header">
|
|
161
161
|
<div class="hcms-shell-heading">
|
|
162
|
-
<div class="hcms-shell-eyebrow">${
|
|
163
|
-
<h2 class="hcms-shell-title" id="${l}">${
|
|
162
|
+
<div class="hcms-shell-eyebrow">${d}</div>
|
|
163
|
+
<h2 class="hcms-shell-title" id="${l}">${p}</h2>
|
|
164
164
|
</div>
|
|
165
165
|
<button type="button" class="hcms-shell-close mirk-button mirk-button--small" data-hcms-action="close" aria-label="Close">
|
|
166
166
|
<span class="mirk-button__label">\xD7</span>
|
|
167
167
|
</button>
|
|
168
168
|
</header>
|
|
169
|
+
<div class="hcms-shell-notice" role="status" hidden></div>
|
|
169
170
|
<div class="hcms-shell-error" role="alert" hidden></div>
|
|
170
171
|
<div data-hcms-form-root class="hcms-form"></div>
|
|
171
|
-
<footer class="hcms-shell-footer"${
|
|
172
|
+
<footer class="hcms-shell-footer"${n?"":" hidden"}>
|
|
172
173
|
<button type="button" class="hcms-shell-save mirk-button" trigger-save>
|
|
173
174
|
<span class="mirk-button__label">Save</span>
|
|
174
175
|
</button>
|
|
175
176
|
</footer>
|
|
176
177
|
</div>
|
|
177
|
-
`,(e||s.body).appendChild(c);let
|
|
178
|
+
`,(e||s.body).appendChild(c);let k=s.body;k.classList.add("hcms-open"),r&&k.classList.add("hcms-overlay"),t==="left"&&k.classList.add("hcms-side-left");let R=$o(c,s),O=Do(c);return{root:c,formRoot:c.querySelector("[data-hcms-form-root]"),noticeEl:c.querySelector(".hcms-shell-notice"),errorEl:c.querySelector(".hcms-shell-error"),saveButton:c.querySelector(".hcms-shell-save"),destroy(){R.detach(),O.detach(),c.remove(),k.classList.remove("hcms-open","hcms-overlay","hcms-side-left")},restoreChrome(){qo(s),k.classList.add("hcms-open"),r&&k.classList.add("hcms-overlay"),t==="left"&&k.classList.add("hcms-side-left")}}}function qo(e){e&&(e.getElementById(bt)||e.querySelector("style[data-hcms-bundled-styles]")||(Oe.delete(e),xn(e)))}function xn(e){if(e&&!Oe.has(e)){if(e[jo]){Oe.add(e);return}if(e.getElementById(bt)||e.querySelector("style[data-hcms-bundled-styles]")){Oe.add(e);return}if(er){let t=e.createElement("style");t.id=bt,t.setAttribute("save-remove",""),t.setAttribute("save-ignore",""),t.textContent=er,(e.head||e.documentElement).appendChild(t),Oe.add(e);return}try{let t=new URL("./theme.generated.css",Bo.url).href,r=e.createElement("link");r.rel="stylesheet",r.id=bt,r.setAttribute("save-remove",""),r.setAttribute("save-ignore",""),r.href=t,(e.head||e.documentElement).appendChild(r),Oe.add(e)}catch{console.warn("hypercms: shell stylesheet not applied \u2014 cssText is empty and the co-located theme fallback is unavailable. Call installStyles(themeText) before opening the CMS.")}}}function Do(e){let t=e.querySelector(".hcms-shell-body"),r=e.querySelector(".hcms-shell-header");if(!t||!r||typeof t.addEventListener!="function")return{detach(){}};let n=()=>{let i=(r.offsetHeight||0)-12;e.classList.toggle("is-condensed",t.scrollTop>i)};return t.addEventListener("scroll",n,{passive:!0}),n(),{detach(){t.removeEventListener("scroll",n)}}}function $o(e,t){function r(n){if(n.key!=="Tab"||!e.contains(t.activeElement))return;let i=Array.from(e.querySelectorAll(Lo));if(i.length===0)return;let o=i[0],a=i[i.length-1];n.shiftKey&&t.activeElement===o?(n.preventDefault(),a.focus()):!n.shiftKey&&t.activeElement===a&&(n.preventDefault(),o.focus())}return t.addEventListener("keydown",r),{detach:()=>t.removeEventListener("keydown",r)}}var Po="[hypercms]",wn={skip:"[data-hcms-shell]",templateAttr:"cms-template"},_n={skip:"[data-hcms-shell]",templateAttr:null},tr=class extends Error{constructor(t,r,n){super(`hypercms: rule at "${t}" has an invalid CSS selector: "${r}"`),this.name="InvalidRuleSelector",this.path=t,this.selector=r,this.cause=n}};function yt(e,t){let r=[],n=[];return rr(e,t,[],r,n),{missing:Vo(r),twins:Wo(n)}}function rr(e,t,r,n,i){if(typeof t=="string"){let o=zo(t);if(!o)return;let a=kt(e,o,wn,r);if(t.endsWith("[]")){a.length===0&&kt(e,o,_n,r).length===0&&n.push(Ve(r));return}a.length===0?n.push(Ve(r)):a.length>1&&i.push({path:Ve(r),count:a.length});return}if(Array.isArray(t)){let[o,a]=t;if(typeof o!="string"||!o)return;let s=kt(e,o,wn,r);if(s.length===0){kt(e,o,_n,r).length===0&&n.push(Ve(r));return}for(let l of s)rr(l,a,[...r,"*"],n,i);return}if(t&&typeof t=="object")for(let[o,a]of Object.entries(t))rr(e,a,[...r,o],n,i)}function kt(e,t,r,n){try{return re.find(e,t,r)}catch(i){throw new tr(Ve(n),t,i)}}function zo(e){if(e==="."||e.startsWith("@"))return null;if(e.endsWith("[]"))return e.slice(0,-2)||null;let t=z(e);return(t===-1?e:e.slice(0,t))||null}function vt(e){Uo(e),Ho(e)}function Uo(e){let t=e.noticeEl;if(!t)return;let r=e.unresolved&&e.unresolved.missing||[];if(r.length===0){t.textContent="",t.hidden=!0;return}let n=r.length===1?"1 field no longer matches this page":`${r.length} fields no longer match this page`;t.textContent=`${n}: ${r.join(", ")}`,t.hidden=!1}function Ho(e){let t=e.unresolved&&e.unresolved.twins||[],r=t.map(n=>`${n.path}:${n.count}`).join("|");if(r!==e.lastTwinSignature){e.lastTwinSignature=r;for(let{path:n,count:i}of t)console.warn(`${Po} "${n}" matches ${i} elements; edits go to the first one.`)}}function Vo(e){return[...new Set(e)]}function Wo(e){let t=new Map;for(let r of e){let n=t.get(r.path);(!n||r.count>n.count)&&t.set(r.path,r)}return[...t.values()]}function Ve(e){return e.length?e.join("."):"(whole page)"}var Ko={skip:"[data-hcms-shell]",templateAttr:"cms-template"};function xt(e,{ignoreActiveValue:t}={}){let r=W.findRules(e.doc,e.rulesSource||"cms");r&&(e.pageRules=e.richText?ht(r.rules,e.pageRoot):r.rules,e.rulesTagNode=r.tagNode),rt(e.doc),st(e.doc,e.pageRules),e.formRules=lt(e.pageRules,e.doc),e.unresolved=yt(e.pageRoot,e.pageRules);let n=me(W.extract(e.pageRoot,e.pageRules,Ko),e.pageRules),i=ct({pageRules:e.pageRules,formRules:e.formRules,data:n,doc:e.doc});Qe(e.formRoot,i,{ignoreActiveValue:t}),Re(e.formRoot,e.doc),Yt(e),vt(e),e.updateFingerprint&&e.updateFingerprint()}function An({debounce:e=100,onRefresh:t}){let r=K("Mutation");if(!r||typeof r.onAnyChange!="function")throw new Error("hypercms: a mutation hub is required (clay.Mutation or hyperclay.Mutation). Load clayjs or hyperclayjs, or just the mutation utility, before initializing hypercms.");let n=0,i=r.onAnyChange({debounce:e},()=>{n>0||t()});return{unsubscribe:typeof i=="function"?i:()=>{},pause(){n++},resume(){n=Math.max(0,n-1)}}}var Go="[hypercms]";function Sn(e,t){if(!e||!e.querySelectorAll||!t)return;let r=Jo(t);e.querySelectorAll("template[data-hcms-tpl]").forEach(i=>{let o=i.getAttribute("data-hcms-tpl");o&&(o.startsWith("@")||r.has(o)||console.warn(`${Go} template "${o}" doesn't match any rule path; ignored`))})}function Jo(e){let t=new Set;return r([],e),t;function r(n,i){let o=n.join("."),a=n.map(l=>typeof l=="number"?"*":l).join(".");o&&t.add(o),a&&t.add(a);let s=fe(i);if(s==="object")for(let[l,c]of Object.entries(i))r([...n,l],c);else if(s==="object-array"||s==="scalar-array"){let l=[...n,"*"],c=l.map(m=>typeof m=="number"?"*":m).join(".");if(t.add(c),s==="object-array"){let m=i[1];if(m&&typeof m=="object"&&!Array.isArray(m))for(let[p,d]of Object.entries(m))r([...l,p],d)}}}}var En="hcms-toggle",Cn="hcms-toggle-style",Yo=`
|
|
178
179
|
#hcms-toggle {
|
|
179
180
|
position: fixed; right: 16px; bottom: 16px; z-index: 2147482900;
|
|
180
181
|
display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px;
|
|
@@ -188,7 +189,7 @@ body.hcms-open #hcms-toggle .hcms-toggle__open { display: none; }
|
|
|
188
189
|
body.hcms-open #hcms-toggle .hcms-toggle__close { display: inline; }
|
|
189
190
|
body.hcms-open:not(.hcms-overlay):not(.hcms-side-left) #hcms-toggle { right: calc(380px + 16px); }
|
|
190
191
|
body.hcms-open.hcms-overlay #hcms-toggle { display: none; }
|
|
191
|
-
`;function
|
|
192
|
+
`;function Xo({search:e="",cookie:t="",forced:r=null}={}){let n=typeof e=="string"?e:"",i=n.indexOf("?"),o=i===-1?n:n.slice(i+1),a=new URLSearchParams(o).get("editmode");return a?a==="true":r!=null?!!r:/(?:^|;\s*)isAdminOfCurrentResource=[^;]/.test(t)}function Zo({open:e,close:t,isOpen:r},n=document){let i=n.getElementById(En);if(i)return i;if(!n.getElementById(Cn)){let a=n.createElement("style");a.id=Cn,a.setAttribute("snapshot-remove",""),a.textContent=Yo,n.head.appendChild(a)}let o=n.createElement("button");return o.type="button",o.id=En,o.setAttribute("no-save",""),o.setAttribute("snapshot-remove",""),o.setAttribute("save-ignore",""),o.setAttribute("aria-label","Toggle content editor"),o.innerHTML='<span class="hcms-toggle__open">Edit content</span><span class="hcms-toggle__close">Close editor</span>',o.addEventListener("click",async()=>{try{r()?t():await e()}catch(a){console.warn("hypercms: toggle failed to open the CMS",a)}}),n.body.appendChild(o),o}function Rn(e){if(typeof window>"u"||typeof document>"u")return;let t=window.__hyperclayEditMode!=null?window.__hyperclayEditMode:null;if(!Xo({search:window.location.search,cookie:document.cookie,forced:t}))return;let r=()=>{document.body&&e.hasRules(document)&&Zo(e)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",r,{once:!0}):r()}function On(e){yn(e)}var I={isOpen:!1,ctx:null,shell:null,opts:null};function Tn(e,t){if(I.ctx!==e)return;let r=t==="livesync";t==="livesync"&&I.shell?.restoreChrome?.(),xt(e,{ignoreActiveValue:r})}var Mn=!1;function Qo(){if(Mn)return;let e=K("onPrepareForSave");typeof e=="function"&&(e(t=>{let r=t&&t.querySelector&&t.querySelector("body");r&&r.classList.remove("hcms-open","hcms-overlay","hcms-side-left")}),Mn=!0)}function or(e={}){if(I.isOpen){console.warn("cms.open() called while already open; ignoring");return}Qo();let t=e.pageRoot||(typeof document<"u"?document.body:null);if(!t)throw new Error("hypercms: no pageRoot available");let r=t.ownerDocument||(typeof document<"u"?document:null);if(!r)throw new Error("hypercms: no document available");let n=e.rules!==void 0?e.rules:"cms",i=W.findRules(r,n);if(!i){let f=typeof n=="string"?`data-rules-name~="${n}"`:"the provided rules object";throw new Error(`hypercms: no rules found for ${f}`)}let o=e.richText!==!1,a=o?ht(i.rules,t):i.rules,s=i.tagNode;rt(r),st(r,a),Sn(r,a);let l=lt(a,r),c=yt(t,a),m=me(W.extract(t,a,{skip:"[data-hcms-shell]",templateAttr:"cms-template"}),a),p=gt(()=>vn({mountTo:e.mountTo||r.body,side:e.side||"right",overlay:!!e.overlay,showSaveButton:!!e.showSaveButton,title:e.title,eyebrow:e.eyebrow,theme:e.theme,doc:r})),d={doc:r,pageRoot:t,pageRules:a,formRules:l,rulesTagNode:s,rulesSource:n,richText:o,formRoot:p.formRoot,shellRoot:p.root,errorEl:p.errorEl,noticeEl:p.noticeEl,unresolved:c,lastTwinSignature:null,lastFingerprint:null,lastData:null,observerHandle:null,undoUnsub:null,livesyncUnsub:null,onChange:e.onChange,onError:e.onError,confirmRemove:e.confirmRemove,previouslyFocused:r.activeElement,dispatch(f,k){let R=r.defaultView&&r.defaultView.CustomEvent||(typeof CustomEvent<"u"?CustomEvent:null);if(!R)return;let O=new R(f,{bubbles:!0,cancelable:f==="hcms:change",detail:k});p.root.dispatchEvent(O)},onCloseRequested(){sr()}};d.updateFingerprint=()=>{d.lastFingerprint=He(Z(d))};try{let f=ct({pageRules:a,formRules:l,data:m,doc:r});p.formRoot.appendChild(f),Re(p.formRoot,r),vt(d),gn(d),d.updateFingerprint(),d.observerHandle=An({onRefresh:()=>xt(d)});let k=K("undo");if(k&&typeof k.on=="function"){let O=()=>{if(I.ctx!==d)return;Tn(d,"undo");let F=me(W.extract(d.pageRoot,d.pageRules,{skip:"[data-hcms-shell]",templateAttr:"cms-template"}),d.pageRules);He(F)!==He(d.lastData)&&(d.lastData=F,d.onChange?.(F,{path:"",structural:!1}))};k.on("undo",O),k.on("redo",O),d.undoUnsub=()=>{k.off("undo",O),k.off("redo",O)}}let R=()=>Tn(d,"livesync");d.livesyncUnsub=Wt(r,hn,R),We.ctx=d,ts(r),es(p.root),I.isOpen=!0,I.ctx=d,I.shell=p,I.opts=e,d.dispatch("hcms:open",{pageRoot:t})}catch(f){throw d.observerHandle?.unsubscribe?.(),d.undoUnsub?.(),d.livesyncUnsub?.(),d.detachEvents?.(),We.ctx===d&&(We.ctx=null),gt(()=>p.destroy()),I.isOpen=!1,I.ctx=null,I.shell=null,I.opts=null,f}}function es(e){let r=e.querySelector('input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"])');r&&typeof r.focus=="function"&&r.focus()}var We={ctx:null};function ts(e){let t=e.defaultView||(typeof globalThis<"u"?globalThis:null);if(!t)return;let r=function(){let i=We.ctx;if(i)return Zt(i.formRoot),Me("Reorder",()=>ne(Z(i),{path:"",structural:!0},i))};typeof t.hypercmsCommit!="function"&&(t.hypercmsCommit=r),typeof globalThis<"u"&&typeof globalThis.hypercmsCommit!="function"&&(globalThis.hypercmsCommit=r)}var ir="cms";function rs(e){let t=typeof e=="string"?e:"",r=t.indexOf("?"),n=r===-1?t:t.slice(r+1);if(!n)return t;let i=new URLSearchParams(n);return i.get(ir)!=="true"?t:(i.set(ir,"false"),"?"+i.toString())}function ns(e){let t=typeof e=="string"?e:"",r=t.indexOf("?"),n=r===-1?t:t.slice(r+1);return n?new URLSearchParams(n).get(ir)==="true":!1}function is(){if(typeof window>"u"||!window.location||!window.history||typeof window.history.replaceState!="function")return;let e=window.location.search,t=rs(e);t!==e&&window.history.replaceState(window.history.state,"",t+window.location.hash)}function sr(){if(!I.isOpen)return;let{ctx:e,shell:t}=I;e.closed=!0;let r=e.previouslyFocused;if(e.dispatch("hcms:close",null),is(),e.observerHandle?.unsubscribe?.(),e.undoUnsub?.(),e.livesyncUnsub?.(),e.detachEvents?.(),gt(()=>t.destroy()),I.isOpen=!1,I.ctx=null,I.shell=null,I.opts=null,We.ctx=null,r&&typeof r.focus=="function")try{r.focus()}catch{}}function Nn(){I.isOpen&&xt(I.ctx)}function os(){return I.isOpen}var ss={getData(){return I.isOpen?Z(I.ctx):null},setValue(e,t){if(!I.isOpen)throw new Error("hypercms: cms is not open");let r=I.ctx,n=ie(e),i=pe(r.pageRules,n);if(i===void 0)throw new Error(`hypercms: no rule at path "${e}"`);if(typeof i!="string"||i.endsWith("[]"))throw new Error(`hypercms: setValue requires a leaf scalar path; "${e}" is not a leaf`);let o=as(r.formRoot,e);if(!o)throw new Error(`hypercms: no field element at path "${e}"`);ls(o,t,r.formRoot,e),ne(Z(r),{path:e,structural:!1},r)},addItem(e){if(!I.isOpen)throw new Error("hypercms: cms is not open");Jt(e,I.ctx)},removeItem(e){if(!I.isOpen)throw new Error("hypercms: cms is not open");let t=I.ctx,r=ie(e);if(typeof r[r.length-1]!="number")throw new Error(`hypercms: removeItem requires an item path; "${e}" is not an array index`);let i=pe(t.pageRules,r.slice(0,-1));if(!(Array.isArray(i)||typeof i=="string"&&i.endsWith("[]")))throw new Error(`hypercms: removeItem requires an item path; parent of "${e}" is not an array`);let a=t.formRoot.querySelector(`[data-hcms-path="${lr(e)}"]`);if(!a)throw new Error(`hypercms: no element at path "${e}"`);Te(a,t)},refresh:Nn,_commit(){if(!I.isOpen)return;let e=I.ctx;return Zt(e.formRoot),Me("Update",()=>ne(Z(e),{path:"",structural:!0},e))}};function as(e,t){let r=lr(t),n=`[data-hcms-path="${r}"] input[data-hcms-field], [data-hcms-path="${r}"] textarea[data-hcms-field], [data-hcms-path="${r}"] select[data-hcms-field], [data-hcms-path="${r}"] img[data-hcms-field], [data-hcms-path="${r}"] a[data-hcms-field], [data-hcms-path="${r}"] [contenteditable][data-hcms-field], input[data-hcms-path="${r}"][data-hcms-field], textarea[data-hcms-path="${r}"][data-hcms-field], select[data-hcms-path="${r}"][data-hcms-field], img[data-hcms-path="${r}"][data-hcms-field], a[data-hcms-path="${r}"][data-hcms-field], [contenteditable][data-hcms-path="${r}"][data-hcms-field]`;return e.querySelector(n)}function ls(e,t,r,n){let i=(e.tagName||"").toUpperCase(),o=(e.getAttribute("type")||"").toLowerCase();if(i==="INPUT"&&o==="checkbox"){e.checked=t===!0||t==="true";return}if(i==="INPUT"&&o==="radio"){let a=lr(n),s=r.querySelectorAll(`[data-hcms-path="${a}"][data-hcms-field][type="radio"], [data-hcms-path="${a}"] [data-hcms-field][type="radio"]`);s.length?s.forEach(l=>{l.checked=String(l.value)===String(t??"")}):e.checked=String(e.value)===String(t??"");return}if(i==="IMG"){e.src=t==null?"":String(t);return}if(i==="A"){e.href=t==null?"":String(t);return}if(e.hasAttribute&&e.hasAttribute("contenteditable")){e.innerHTML=t==null?"":String(t);return}if("value"in e){e.value=t==null?"":String(t);return}e.textContent=t==null?"":String(t)}var cs=250,ds=1e4;function ms(){typeof window>"u"||typeof document>"u"||ns(window.location?window.location.search:"")&&(I.isOpen||us(()=>{if(!I.isOpen)try{or()}catch(e){console.warn("hypercms: auto-open failed",e)}}))}function nr(){return!!document.body&&!!K("Mutation")}function us(e){if(nr()){queueMicrotask(e);return}let t=Date.now()+ds,r=!1,n=null,i=null,o=()=>{r||(r=!0,n!==null&&clearInterval(n),i&&i())};function a(){if(I.isOpen){o();return}nr()&&(o(),e())}i=Wt(document,un,a),n=setInterval(()=>{if(I.isOpen){o();return}if(nr()){o(),e();return}Date.now()>=t&&(o(),console.warn("hypercms: ?cms=true auto-open gave up \u2014 no mutation hub appeared. Load clayjs or hyperclayjs (or just the mutation utility) so the CMS can initialize."))},cs)}ms();Rn({open:or,close:sr,isOpen:os,hasRules:e=>!!W.findRules(e,"cms")});var ar={open:or,close:sr,refresh:Nn,api:ss,get isOpen(){return I.isOpen},path:Bt,scaffold:$e,morphForm:Qe};function lr(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var In=`/* GENERATED by scripts/build-theme.js from mirk-interface/mirk.css \u2014 DO NOT EDIT.
|
|
192
193
|
Source of truth: mirk-interface/mirk.css + src/theme/pixel-quiet.overrides.css.
|
|
193
194
|
Regenerate with: npm run build:theme */
|
|
194
195
|
|
|
@@ -1685,6 +1686,18 @@ body.hcms-open.hcms-overlay { overflow: hidden; }
|
|
|
1685
1686
|
.hcms-upload-clear--badge:hover { color: var(--mirk-destructive); border-color: var(--mirk-destructive); }
|
|
1686
1687
|
.hcms-upload-clear--badge .hcms-x { width: 10px; height: 10px; }
|
|
1687
1688
|
|
|
1689
|
+
/* ---------- UNRESOLVED-FIELDS NOTICE ---------- */
|
|
1690
|
+
.hcms-shell-notice {
|
|
1691
|
+
font-size: 12px;
|
|
1692
|
+
line-height: 1.45;
|
|
1693
|
+
color: var(--mirk-mark-fg);
|
|
1694
|
+
background: var(--mirk-bevel-bg);
|
|
1695
|
+
border: 1px solid var(--mirk-input-border);
|
|
1696
|
+
padding: 8px 12px;
|
|
1697
|
+
margin: 0 24px 8px;
|
|
1698
|
+
}
|
|
1699
|
+
.hcms-shell-notice[hidden] { display: none; }
|
|
1700
|
+
|
|
1688
1701
|
/* ---------- ERROR BANNER + inline errors ---------- */
|
|
1689
1702
|
.hcms-shell-error,
|
|
1690
1703
|
.hcms-error {
|
|
@@ -1736,7 +1749,7 @@ body.hcms-open.hcms-overlay { overflow: hidden; }
|
|
|
1736
1749
|
cursor: pointer;
|
|
1737
1750
|
}
|
|
1738
1751
|
.hcms-sr-only[hidden] { display: none; }
|
|
1739
|
-
`;typeof window<"u"&&typeof document<"u"&&(function(){if(window.__mirk)return;window.__mirk=!0;let e='<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 4 12 12M12 4 4 12" stroke="currentColor" stroke-width="2" stroke-linecap="square" fill="none"/></svg>';document.addEventListener("click",r=>{let
|
|
1752
|
+
`;typeof window<"u"&&typeof document<"u"&&(function(){if(window.__mirk)return;window.__mirk=!0;let e='<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 4 12 12M12 4 4 12" stroke="currentColor" stroke-width="2" stroke-linecap="square" fill="none"/></svg>';document.addEventListener("click",r=>{let n=r.target.closest(".mirk-number__step");if(!n)return;let i=n.closest(".mirk-number").querySelector("input[type=number]");i&&(n.dataset.step==="up"?i.stepUp():i.stepDown(),i.dispatchEvent(new Event("change",{bubbles:!0})))}),document.addEventListener("input",r=>{let n=r.target.closest(".mirk-slider__input");n&&n.closest(".mirk-slider").style.setProperty("--mirk-value",`${n.value}%`)}),document.addEventListener("change",r=>{let n=r.target.closest(".mirk-file__input");if(!n||!n.files.length)return;let i=n.closest(".mirk-file"),o=i.querySelector(".mirk-file__name");if(!o)return;let a=n.files[0],s=document.createElement("a");if(s.className="mirk-file__name",s.dataset.filled="",s.href=URL.createObjectURL(a),s.target="_blank",s.rel="noopener",s.textContent=a.name,o.replaceWith(s),!i.querySelector(".mirk-file__remove")){let l=document.createElement("button");l.type="button",l.className="mirk-file__remove",l.setAttribute("aria-label","Remove file"),l.innerHTML=e,s.after(l)}}),document.addEventListener("change",r=>{let n=r.target.closest(".mirk-image__input");if(!n||!n.files.length)return;let i=n.closest(".mirk-image"),o=i.querySelector(".mirk-image__preview");if(!o)return;let a=i.querySelector(".mirk-image__placeholder"),s=new FileReader;s.onload=l=>{o.src=l.target.result,o.removeAttribute("hidden"),a&&a.setAttribute("hidden",""),i.querySelector(".mirk-image__thumb")?.removeAttribute("hidden"),i.querySelector(".mirk-image__upload")?.setAttribute("hidden","")},s.readAsDataURL(n.files[0])}),document.addEventListener("click",r=>{let n=r.target.closest(".mirk-file__remove");if(n){let o=n.closest(".mirk-file"),a=o?.querySelector(".mirk-file__input"),s=o?.querySelector(".mirk-file__name");if(a&&(a.value=""),s){let l=document.createElement("span");l.className="mirk-file__name",l.textContent="No file chosen",s.replaceWith(l)}n.remove();return}let i=r.target.closest(".mirk-image__remove");if(i){let o=i.closest(".mirk-image"),a=o?.querySelector(".mirk-image__input"),s=o?.querySelector(".mirk-image__preview");a&&(a.value=""),s&&(s.removeAttribute("src"),s.setAttribute("hidden","")),o?.querySelector(".mirk-image__thumb")?.setAttribute("hidden",""),o?.querySelector(".mirk-image__upload")?.removeAttribute("hidden")}});function t(r,n){let i=document.createElement("span");i.textContent=r;let o=document.createElement("input");o.type="hidden",o.name="tags[]",o.value=r;let a=document.createElement("button");a.type="button",a.className="mirk-tags__remove",a.textContent="\xD7";let s=document.createElement("span");if(s.className="mirk-tags__chip",n){let l=document.createElement("span");l.className="mirk-tags__chip-inner",l.append(i,o,a),s.append(l)}else s.append(i,o,a);return s}document.addEventListener("keydown",r=>{let n=r.target.closest(".mirk-tags__input");if(!n)return;let i=n.closest(".mirk-tags");if(r.key==="Enter"||r.key===","){let o=n.value.trim();if(!o)return;r.preventDefault(),n.before(t(o,i.classList.contains("mirk-tags--round"))),n.value=""}else if(r.key==="Backspace"&&!n.value){let o=i.querySelectorAll(".mirk-tags__chip");o[o.length-1]?.remove()}}),document.addEventListener("click",r=>{let n=r.target.closest(".mirk-tags__remove");if(n){n.closest(".mirk-tags__chip").remove();return}let i=r.target.closest(".mirk-tags");i&&r.target===i&&i.querySelector(".mirk-tags__input")?.focus()}),document.addEventListener("click",r=>{let n=r.target.closest("[data-mirk-chip]");if(!n)return;let i=n.getAttribute("data-mirk-chip");if(i==="open")n.closest(".mirk-chip")?.classList.add("mirk-chip--open");else if(i==="collapse")n.closest(".mirk-chip")?.classList.remove("mirk-chip--open");else if(i==="changes"){let o=n.closest(".mirk-chip__panel")?.classList.toggle("is-changes");n.textContent=o?"(hide changes)":"(view changes)"}}),document.addEventListener("click",r=>{let n=r.target.closest("[data-copy-btn]");if(!n)return;let i=n.closest("[data-copy]");if(!i)return;let o=i.cloneNode(!0);o.querySelectorAll("[data-copy-btn]").forEach(l=>l.remove());let s=i.getAttribute("data-copy")==="text"?o.textContent.replace(/^\s+|\s+$/g,""):o.innerHTML.replace(/\s+data-copy(="[^"]*")?/g,"").replace(/^\s*\n/gm,"").trim();navigator.clipboard.writeText(s).then(()=>{let l=n.textContent;n.textContent="copied",n.dataset.copied="",setTimeout(()=>{n.textContent=l,delete n.dataset.copied},1200)}).catch(()=>{n.textContent="error",setTimeout(()=>{n.textContent="copy"},1200)})})})();On(In);var fs=ar,gs={cms:ar};return Bn(bs);})();
|
|
1740
1753
|
|
|
1741
1754
|
// Auto-export to window unless suppressed by loader.
|
|
1742
1755
|
// Per hypercms plan locked decision 3: flatten to hyperclay.hypercms.open(),
|