hyperclayjs 1.30.0 → 1.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
- var hypercms=(()=>{var _e=Object.defineProperty;var pr=Object.getOwnPropertyDescriptor;var yr=Object.getOwnPropertyNames;var gr=Object.prototype.hasOwnProperty;var Pe=(e,t)=>{for(var r in t)_e(e,r,{get:t[r],enumerable:!0})},br=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of yr(t))!gr.call(e,o)&&o!==r&&_e(e,o,{get:()=>t[o],enumerable:!(n=pr(t,o))||n.enumerable});return e};var Sr=e=>br(_e({},"__esModule",{value:!0}),e);var to={};Pe(to,{cms:()=>Qn,default:()=>eo});var Se=["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"],De=new Set(Se),xt=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Et=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var ve={};Pe(ve,{EmptyListInsert:()=>le,MAX_RULE_DEPTH:()=>ee,MaxRuleDepthExceeded:()=>z,RuleTargetReadOnly:()=>ue,RulesParseError:()=>Q,ShapeMismatch:()=>ce,UnknownRulesVersion:()=>ae,UpgradeAlreadyRegistered:()=>Ae});var Q=class extends Error{constructor(t,r){super(t),this.name="RulesParseError",this.cause=r}},ae=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},ee=20,z=class extends Error{constructor(t){super(`rule depth exceeded ${ee} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},ce=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},le=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}},ue=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},Ae=class extends Error{constructor(){super("upgrade transform already registered; only one registration is allowed per page."),this.name="UpgradeAlreadyRegistered"}};function B(e,t,r,n={}){return Ue(e,t,r,{depth:0,path:[]},n)}function Ue(e,t,r,n,o){if(n.depth>ee)throw new z(n.path);if(typeof r=="string")return Ar(e,t,r,o);if(Array.isArray(r)){let[s,a]=r;return e.find(t,s,o).map((c,u)=>Ue(e,c,a,{depth:n.depth+1,path:[...n.path,u]},o))}if(typeof r=="object"&&r!==null){let s={};for(let[a,i]of Object.entries(r))s[a]=Ue(e,t,i,{depth:n.depth+1,path:[...n.path,a]},o);return s}return null}function Ar(e,t,r,n){if(r.endsWith("[]")){let s=r.slice(0,-2);return e.find(t,s,n).map(a=>e.text(a))}if(r.startsWith("@"))return wt(e,t,r.slice(1));if(r.includes("@")){let s=r.lastIndexOf("@"),a=r.slice(0,s),i=r.slice(s+1),c=a?e.find(t,a,n):[t];return c.length===0?null:wt(e,c[0],i)}if(r===".")return e.text(t);let o=e.find(t,r,n);return o.length===0?null:e.text(o[0])}function wt(e,t,r){if(De.has(r)){let o=e.prop(t,r);return o==null?null:String(o)}let n=e.attr(t,r);return n||null}var vr=.5;function Be(e,t,r,n,o,s,a,i={}){let c=e.find(t,r,i);if(o.length===0){c.forEach(M=>e.remove(M));return}let u=o.length>c.length,d=c[0]||null;if(u&&!d&&(d=Tr(e,t,r,i),!d))throw new le(s.path);let p=c.map(M=>xr(e,M,n,i)),y=null;if(d){y=e.clone(d),i.templateAttr&&e.removeAttr(y,i.templateAttr);let M=e.stripIds(y);M>0&&console.warn(`[hyper-html-api] stripped ${M} id attribute(s) from cloned template at "${s.path.join(".")||"(root)"}"`)}let w=Er(o,p,n),E=c[0]||d,j=e.parent(E),b=c.length>0?Mr(e,j,E):0,k=new Set,T=o.map((M,R)=>{let x=w[R];if(x>=0)return k.add(x),c[x];let m=e.clone(y);return e.stripIds(m),m});c.forEach((M,R)=>{k.has(R)||e.remove(M)}),T.forEach((M,R)=>{let x=b+R;e.children(j).findIndex(l=>e.sameNode(l,M))!==x&&e.insertAt(j,M,x)}),T.forEach((M,R)=>{if(n===null){let x=o[R],m=x==null?"":String(x);e.text(M)!==m&&e.text(M,m)}else{let x=a(e,M,n,o[R],{depth:s.depth+1,path:[...s.path,R]},i);x&&x!==M&&(T[R]=x)}})}function xr(e,t,r,n){return r===null?e.text(t):B(e,t,r,n)}function Er(e,t,r){let n=new Array(e.length).fill(-1),o=new Set;return e.forEach((s,a)=>{let i=-1,c=-1;t.forEach((u,d)=>{if(o.has(d))return;let p=wr(s,u,r),y=p===c&&i>=0?Math.abs(d-a)<Math.abs(i-a):!1;(p>c||y)&&(c=p,i=d)}),c>=vr&&(n[a]=i,o.add(i))}),n}function wr(e,t,r){if(r===null)return e===t?1:0;let n=Object.keys(r||{});if(n.length===0)return 0;let o=0;for(let s of n)JSON.stringify(e?.[s])===JSON.stringify(t?.[s])&&o++;return o/n.length}function Mr(e,t,r){let n=e.children(t);for(let o=0;o<n.length;o++)if(e.sameNode(n[o],r))return o;return-1}function Tr(e,t,r,n){if(!n.templateAttr)return null;let o=t;for(;o;){let s=e.find(o,r,{includeRulesTag:!1});for(let a of s)if(e.attr(a,n.templateAttr)!=null)return a;o=e.parent(o)}return null}var Mt=new Set(["checked","selected","disabled","readOnly","paused"]);function G(e,t,r,n,o={}){let s=[];if(We(r,n,[],s),s.length)throw new ce(s);xe(e,t,r,n,{depth:0,path:[]},o)}function xe(e,t,r,n,o,s={}){if(o.depth>ee)throw new z(o.path);if(n===void 0)return t;if(typeof r=="string")return Rr(e,t,r,n,o,s);if(Array.isArray(r)){let[a,i]=r;return Be(e,t,a,i,n,o,xe,s),t}if(typeof r=="object"&&r!==null){for(let[a,i]of Object.entries(r)){let c=xe(e,t,i,n==null?n:n[a],{depth:o.depth+1,path:[...o.path,a]},s);c&&c!==t&&(t=c)}return t}return t}function Rr(e,t,r,n,o,s){if(r.endsWith("[]")){let i=r.slice(0,-2);return Be(e,t,i,null,n,o,xe,s),t}if(r.startsWith("@"))return Tt(e,t,r.slice(1),n);if(r.includes("@")){let i=r.lastIndexOf("@"),c=r.slice(0,i),u=r.slice(i+1),d=c?e.find(t,c,s):[t];return d.length===0||Tt(e,d[0],u,n),t}if(r===".")return e.text(t,n==null?"":String(n)),t;let a=e.find(t,r,s);return a.length===0||e.text(a[0],n==null?"":String(n)),t}function Tt(e,t,r,n){if(Et.has(r))throw new ue(r);if(r==="outerHTML"){let o=n==null?"":String(n);return e.replaceWith(t,o)}return xt.has(r)?(e.prop(t,r,Cr(r,n)),t):(e.attr(t,r,n==null?"":String(n)),t)}function Cr(e,t){return t==null?Mt.has(e)?!1:"":Mt.has(e)?!!t:t}function We(e,t,r,n){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((o,s)=>{typeof o=="object"&&o!==null&&n.push({path:fe([...r,s]),expected:"scalar",got:de(o)})}):n.push({path:fe(r),expected:"array",got:de(t)});return}t!==null&&typeof t=="object"&&n.push({path:fe(r),expected:"scalar",got:de(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){n.push({path:fe(r),expected:"array",got:de(t)});return}let o=e[1];t.forEach((s,a)=>We(o,s,[...r,a],n));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){n.push({path:fe(r),expected:"object",got:de(t)});return}for(let[o,s]of Object.entries(e))We(s,t[o],[...r,o],n)}}}function de(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function fe(e){return e.join(".")}function Ve(e){try{return JSON.parse(e)}catch(t){throw new Q(`Invalid strict JSON: ${t.message}`,t)}}function he(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(o){let s=[],a=0;for(;a<o.length;){let i=o[a];if(/\s/.test(i)){a++;continue}if("{}".includes(i)){s.push({type:i,value:i}),a++;continue}if(i==="["){let p=!1,y=a+1;for(;y<o.length&&/\s/.test(o[y]);)y++;if(y<o.length&&/[a-zA-Z_]/.test(o[y])&&(p=!0),!p){s.push({type:i,value:i}),a++;continue}}if(i==="]"){s.push({type:i,value:i}),a++;continue}if(i===":"){s.push({type:t.COLON,value:i}),a++;continue}if(i===","){s.push({type:t.COMMA,value:i}),a++;continue}if(i==='"'||i==="'"){let p=i,y=a+1;for(;y<o.length&&o[y]!==p;)o[y]==="\\"&&y++,y++;s.push({type:t.STRING,value:o.substring(a+1,y),quoted:!0,sourceQuote:p}),a=y+1;continue}let c=a,u;for(;c<o.length&&!/[{},]/.test(o[c]);)if(o[c]===":"){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"],y=!1;for(let w of p){let E=w.substring(1);if(o.substring(c+1,c+1+E.length)===E){y=!0,c+=E.length;break}}if(!y)break}else if(o[c]==="["){for(c++;c<o.length&&o[c]!=="]";){if(o[c]==='"'||o[c]==="'"){let p=o[c];for(c++;c<o.length&&o[c]!==p;)o[c]==="\\"&&c++,c++}c++}c<o.length&&o[c]==="]"&&c++}else c++;u=o.substring(a,c);let d=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(u)?d=t.NUMBER:u==="true"||u==="false"||u==="null"?d=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(u)&&(d=t.SELECTOR),s.push({type:d,value:u,quoted:!1}),a=c}return s}function n(o){let s="";for(let a=0;a<o.length;a++){let i=o[a];if("{}".includes(i.type)||"[]".includes(i.type)){s+=i.value;continue}if(i.type===t.COLON){s+=i.value;continue}if(i.type===t.COMMA){let c=o[a+1];if(c&&(c.type==="}"||c.type==="]"))continue;s+=i.value;continue}if(i.type===t.STRING&&i.quoted){let c=i.value;i.sourceQuote==="'"&&(c=c.replace(/\\'/g,"'"),c=c.replace(/(\\*)"/g,(u,d)=>d.length%2===0?d+'\\"':u)),s+=`"${c}"`;continue}if(i.type===t.NUMBER||i.type===t.BOOLEAN){s+=i.value;continue}if(i.type===t.SELECTOR||i.type===t.IDENTIFIER){s+=`"${i.value}"`;continue}s+=`"${i.value}"`}return s}try{let o=r(e),s=n(o);return JSON.parse(s)}catch(o){throw new Q("Invalid extraction rules syntax: "+o.message,o)}}var kr="1",Rt=/^[a-zA-Z0-9_-]+$/;function Y(e,t,r){let n;if(r===void 0)n="script[data-rules-name]";else{if(typeof r!="string"||!Rt.test(r))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(r)} (must match ${Rt})`);n=`script[data-rules-name~="${r}"]`}let o=e.find(t,n,{includeRulesTag:!0});if(o.length===0)return null;r!==void 0&&o.length>1&&console.warn(`hyper-html-api: ${o.length} rules tags match data-rules-name~="${r}"; using the first.`);let s=o[0],a=e.attr(s,"data-rules-version");if(a!==kr)throw new ae(a);return{rules:he(e.text(s)),tagNode:s}}function Ke(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 Y(e,n,r)}return null}function Ct(e,t,r,n){let o=Ke(e,t,r);if(!o){let i=typeof r=="string"?`data-rules-name~="${r}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${i}`)}let{rules:s,tagNode:a}=o;return{rules:s,tagNode:a,get:()=>B(e,t,s,n),set:i=>G(e,t,s,i,n)}}var jt={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 Ir(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 Nr(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 Lr(e,t){let r=[];for(let n of e.attributes||[]){let o=n.name;o==="id"||o==="class"||t.excludeAttributePrefixes.some(s=>o.startsWith(s))||t.includeAttributes.includes(o)&&r.push(`${o}=${n.value}`)}return r.sort().join("|")}function $r(e,t){return(e.textContent||"").replace(/\s+/g," ").trim().slice(0,t.textHintLength)}function Hr(e,t){let r=[e.tagName];return t.includeClasses&&r.push(Nr(e)),r.push(Lr(e,t)),Ir(r.join("|"))}function Fr(e){let t=e.tagName,r=1,n=e.previousElementSibling;for(;n;)n.tagName===t&&r++,n=n.previousElementSibling;return r}function qr(e,t){return e.id||e.getAttribute?.("role")?!0:t.landmarks.includes(e.tagName)}function _r(e){if(e.id)return`#${e.id}`;let t=e.getAttribute?.("role");return t?`@${t}`:e.tagName}function Pr(e,t){let r=[],n=e;for(;n&&n.tagName&&r.length<t.maxPathDepth;){let o=`${n.tagName}:${Fr(n)}`;if(r.unshift(o),n!==e&&qr(n,t)){r.unshift(_r(n));break}n=n.parentElement}return r}function Dr(e,t){let r=0,n=e.length-1,o=t.length-1;for(;n>=0&&o>=0&&e[n]===t[o];)r++,n--,o--;return r}function P(e,t,r){if(r.has(e))return r.get(e);let n={signature:Hr(e,t),path:Pr(e,t),textHint:$r(e,t)};return r.set(e,n),n}function $t(e,t,r,n){if(n.has(e))return n.get(e);let o=new Map,s=e.querySelectorAll("*"),a=0;for(let i of s){let c=P(i,t,r);c.domIndex=a++,o.has(c.signature)||o.set(c.signature,[]),o.get(c.signature).push(i)}return n.set(e,o),o}function Ur(e,t,r){r.delete(e),t.delete(e);let n=e.querySelectorAll("*");for(let o of n)t.delete(o)}function ze(e,t,r,n,o){let s=P(e,r,n),a=P(t,r,n),i=r.weights,c={},u=0;if(s.signature!==a.signature)return{score:0,breakdown:{rejected:"signature mismatch"}};u+=i.signature,c.signature=i.signature;let p=Dr(s.path,a.path)*i.pathSegment;u+=p,c.path=p;let y=!0;if(s.textHint&&a.textHint?s.textHint===a.textHint?(u+=i.textMatch,c.text=i.textMatch):(u-=i.textMismatch,c.text=-i.textMismatch,y=!1):s.textHint!==a.textHint&&(u-=i.textMismatch,c.text=-i.textMismatch,y=!1),o.candidateCount===1&&y&&(u+=i.uniqueCandidate,c.unique=i.uniqueCandidate),typeof s.domIndex=="number"&&typeof a.domIndex=="number"){let w=Math.abs(s.domIndex-a.domIndex),E=Math.min(w*i.positionPenalty,20);u-=E,c.drift=-E}return{score:u,breakdown:c}}function It(e,t,r,n,o){if(r.excludeIds&&e.id)return null;let s=$t(t,r,n,o),a=P(e,r,n);if(typeof a.domIndex!="number"){let y=0,w=e.previousElementSibling;for(;w;)y++,w=w.previousElementSibling;a.domIndex=y}let i=s.get(a.signature)||[],c=r.excludeIds?i.filter(y=>!y.id):i;if(c.length===0)return null;let u=null,d=0,p=null;for(let y of c){let{score:w,breakdown:E}=ze(e,y,r,n,{candidateCount:c.length});w>d&&(d=w,u=y,p=E)}return d<r.minConfidence?null:{element:u,confidence:d,breakdown:p}}function Br(e,t,r,n){let o=[],s=r.weights.signature+r.weights.slotMatch,a={slot:s};function i(p){if(p.children)return p.children;let y=p.childNodes;if(!y)return[];let w=[];for(let E=0;E<y.length;E++)y[E].nodeType===1&&w.push(y[E]);return w}function c(p,y){let w=i(p),E=i(y);if(w.length===E.length)for(let j=0;j<w.length;j++){let b=w[j],k=E[j];if(r.excludeIds&&(b.id||k.id)||b.tagName!==k.tagName)continue;let T=P(b,r,n).signature,M=P(k,r,n).signature;T!==M&&o.push({newEl:b,oldEl:k,score:s,breakdown:a}),c(b,k)}}function u(p,y){for(;;){if(p.tagName===y.tagName)return[p,y];let w=i(p);if(!p.tagName&&w.length===1){p=w[0];continue}let E=i(y);if(E.length===1&&E[0].tagName===p.tagName){y=E[0];continue}return null}}let d=u(e,t);return d&&c(d[0],d[1]),o}function Nt(e,t,r,n,o){let s=t.querySelectorAll("*"),a=$t(e,r,n,o),i=0;for(let p of s){let y=P(p,r,n);y.domIndex=i++}let c=[];for(let p of s){if(r.excludeIds&&p.id)continue;let y=P(p,r,n),w=a.get(y.signature)||[],E=r.excludeIds?w.filter(j=>!j.id):w;for(let j of E){let{score:b,breakdown:k}=ze(p,j,r,n,{candidateCount:E.length});b>=r.minConfidence&&c.push({newEl:p,oldEl:j,score:b,breakdown:k})}}if(r.weights.slotMatch>0){let p=Br(t,e,r,n);for(let y of p)c.push(y)}c.sort((p,y)=>y.score-p.score);let u=new Map,d=new Set;for(let{newEl:p,oldEl:y}of c)u.has(p)||d.has(y)||(u.set(p,y),d.add(y));return u}function Lt(e,t,r,n){let o=P(e,r,n),s=P(t,r,n),{score:a,breakdown:i}=ze(e,t,r,n,{candidateCount:1});return{matches:a>=r.minConfidence,score:a,breakdown:i,newMeta:{signature:o.signature,path:o.path,textHint:o.textHint},oldMeta:{signature:s.signature,path:s.path,textHint:s.textHint}}}function Ht(e={}){let t={...jt,...e,weights:{...jt.weights,...e.weights}},r=new WeakMap,n=new WeakMap;return{findMatch:(o,s)=>It(o,s,t,r,n),computeMatches:(o,s)=>Nt(o,s,t,r,n),explain:(o,s)=>Lt(o,s,t,r),invalidate:o=>Ur(o,r,n),session:()=>{let o=new WeakMap,s=new WeakMap;return{findMatch:(a,i)=>It(a,i,t,o,s),computeMatches:(a,i)=>Nt(a,i,t,o,s),explain:(a,i)=>Lt(a,i,t,o)}},getConfig:()=>({...t})}}var Wr=Ht(),Ge=(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 k=b.getAttribute("src")||b.getAttribute("href")||"";if(k.startsWith("chrome-extension://")||k.startsWith("moz-extension://")||k.startsWith("safari-web-extension://"))return!0}return!1}function r(b,k){if(k!=="smart")return b.outerHTML;let T=b.getAttribute("src"),M=b.getAttribute("type")||"text/javascript";if(T)try{let R=new URL(T,window.location.href);return`ext:${M}:${R.origin}${R.pathname}${R.search}`}catch{return`ext:${M}:${T}`}else{let R=b.textContent.trim(),x=5381;for(let m=0;m<R.length;m++)x=(x<<5)+x^R.charCodeAt(m);return`inline:${M}:${Math.abs(x).toString(36)}`}}let n={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},o={computeMatches(b,k){let{computeMatches:T}=Wr.session();return T(b,k)}};function s(b,k,T={}){b=E(b);let M=j(k),R=w(b,M,T),x=R.scripts.matchMode,m=new Set(Array.from(b.querySelectorAll("script")).map(f=>r(f,x))),A=i(R,()=>d(R,b,M,f=>f.morphStyle==="innerHTML"?(c(f,b,M),Array.from(b.childNodes)):a(f,b,M)));R.pantry.remove();let l=y(b,m,R);return l.length>0?A instanceof Promise?A.then(f=>Promise.all(l).then(()=>f)):Promise.all(l).then(()=>A):A}function a(b,k,T){let M=j(k);return c(b,M,T,k,k.nextSibling),Array.from(M.childNodes)}function i(b,k){if(!b.config.restoreFocus)return k();let T=document.activeElement;if(!(T instanceof HTMLInputElement||T instanceof HTMLTextAreaElement))return k();let{id:M,selectionStart:R,selectionEnd:x}=T,m=k();return M&&M!==document.activeElement?.getAttribute("id")&&(T=b.target.querySelector(`[id="${M}"]`),T?.focus()),T&&!T.selectionEnd&&x!=null&&T.setSelectionRange(R,x),m}let c=(function(){function b(l,f,g,h=null,S=null){f instanceof HTMLTemplateElement&&g instanceof HTMLTemplateElement&&(f=f.content,g=g.content),h||=f.firstChild;for(let v of g.childNodes){if(t(v))continue;if(h&&h!=S){let O=T(l,v,h,S);if(O){O!==h&&R(l,h,O),u(O,v,l),h=O.nextSibling;continue}}if(v instanceof Element){let O=v.getAttribute("id");if(l.persistentIds.has(O)){let N=x(f,O,h,l);u(N,v,l),h=N.nextSibling;continue}if(!l.idMap.has(v)){let N=l.hyperMatches.get(v);if(N&&!l.idMap.has(N)){A(f,N,h),u(N,v,l),h=N.nextSibling;continue}}}let C=k(f,v,h,l);C&&(h=C.nextSibling)}for(;h&&h!=S;){let v=h;h=h.nextSibling,t(v)||M(l,v)}}function k(l,f,g,h){if(h.callbacks.beforeNodeAdded(f)===!1)return null;if(h.idMap.has(f)){let S=document.createElement(f.tagName);return l.insertBefore(S,g),u(S,f,h),h.callbacks.afterNodeAdded(S),S}else{let S=document.importNode(f,!0);return l.insertBefore(S,g),h.callbacks.afterNodeAdded(S),S}}let T=(function(){function l(h,S,v,C){let O=S instanceof Element&&!h.idMap.has(S)?h.hyperMatches.get(S):null,N=null,F=S.nextSibling,ie=0,L=v;for(;L&&L!=C;){if(g(L,S)){if(f(h,L,S)||L===O&&!h.idMap.has(L))return L;if(N===null){let J=L instanceof Element&&h.hyperMatchedOldElements.has(L);!h.idMap.has(L)&&!J&&(N=L)}}if(N===null&&F&&g(L,F)&&(ie++,F=F.nextSibling,ie>=2&&(N=void 0)),h.activeElementAndParents.includes(L))break;L=L.nextSibling}return N||null}function f(h,S,v){let C=h.idMap.get(S),O=h.idMap.get(v);if(!O||!C)return!1;for(let N of C)if(O.has(N))return!0;return!1}function g(h,S){let v=h,C=S;return v.nodeType===C.nodeType&&v.tagName===C.tagName&&(!v.getAttribute?.("id")||v.getAttribute?.("id")===C.getAttribute?.("id"))}return l})();function M(l,f){let g=f instanceof Element&&l.hyperMatchedOldElements.has(f)&&!l.idMap.has(f);if(l.idMap.has(f)||g)A(l.pantry,f,null);else{if(l.callbacks.beforeNodeRemoved(f)===!1)return;f.parentNode?.removeChild(f),l.callbacks.afterNodeRemoved(f)}}function R(l,f,g){let h=f;for(;h&&h!==g;){let S=h;h=h.nextSibling,t(S)||M(l,S)}return h}function x(l,f,g,h){let S=h.target.getAttribute?.("id")===f&&h.target||h.target.querySelector(`[id="${f}"]`)||h.pantry.querySelector(`[id="${f}"]`);return m(S,h),A(l,S,g),S}function m(l,f){let g=l.getAttribute("id");for(;l=l.parentNode;){let h=f.idMap.get(l);h&&(h.delete(g),h.size||f.idMap.delete(l))}}function A(l,f,g){if(l.moveBefore)try{l.moveBefore(f,g)}catch{l.insertBefore(f,g)}else l.insertBefore(f,g)}return b})(),u=(function(){function b(m,A,l){return l.ignoreActive&&m===document.activeElement?null:(l.callbacks.beforeNodeMorphed(m,A)===!1||(m instanceof HTMLHeadElement&&l.head.ignore||(m instanceof HTMLHeadElement&&l.head.style!=="morph"?p(m,A,l):(k(m,A,l),x(m,l)||c(l,m,A))),l.callbacks.afterNodeMorphed(m,A)),m)}function k(m,A,l){let f=A.nodeType;if(f===1){let g=m,h=A,S=g.attributes,v=h.attributes;for(let C of v)R(C.name,g,"update",l)||g.getAttribute(C.name)!==C.value&&g.setAttribute(C.name,C.value);for(let C=S.length-1;0<=C;C--){let O=S[C];if(O&&!h.hasAttribute(O.name)){if(R(O.name,g,"remove",l))continue;g.removeAttribute(O.name)}}x(g,l)||T(g,h,l)}(f===8||f===3)&&m.nodeValue!==A.nodeValue&&(m.nodeValue=A.nodeValue)}function T(m,A,l){if(m instanceof HTMLInputElement&&A instanceof HTMLInputElement&&A.type!=="file"){let f=A.value,g=m.value;M(m,A,"checked",l),M(m,A,"disabled",l),l.formStateSync==="property"?g!==f&&(R("value",m,"update",l)||(m.value=f)):A.hasAttribute("value")?g!==f&&(R("value",m,"update",l)||(m.setAttribute("value",f),m.value=f)):R("value",m,"remove",l)||(m.value="",m.removeAttribute("value"))}else if(m instanceof HTMLOptionElement&&A instanceof HTMLOptionElement)M(m,A,"selected",l);else if(m instanceof HTMLTextAreaElement&&A instanceof HTMLTextAreaElement){let f=A.value,g=m.value;if(R("value",m,"update",l))return;f!==g&&(m.value=f),m.firstChild&&m.firstChild.nodeValue!==f&&(m.firstChild.nodeValue=f)}}function M(m,A,l,f){let g=A[l],h=m[l];if(g!==h){let S=R(l,m,"update",f);if(S||(m[l]=A[l]),f.formStateSync==="property")return;g?S||m.setAttribute(l,""):R(l,m,"remove",f)||m.removeAttribute(l)}}function R(m,A,l,f){return m==="value"&&f.ignoreActiveValue&&A===document.activeElement?!0:f.callbacks.beforeAttributeUpdated(m,A,l)===!1}function x(m,A){return!!A.ignoreActiveValue&&m===document.activeElement&&m!==document.body}return b})();function d(b,k,T,M){if(b.head.block){let R=k.querySelector("head"),x=T.querySelector("head");if(R&&x){let m=p(R,x,b);return Promise.all(m).then(()=>{let A=Object.assign(b,{head:{block:!1,ignore:!0}});return M(A)})}}return M(b)}function p(b,k,T){let M=[],R=[],x=[],m=[],A=T.scripts.matchMode,l=h=>{if(h.tagName==="SCRIPT")return r(h,A);if(h.tagName==="LINK"&&A==="smart"){let S=h.getAttribute("href");if(S)try{let v=new URL(S,window.location.href);return`link:${h.getAttribute("rel")||""}:${v.origin}${v.pathname}${v.search}`}catch{}}return h.outerHTML},f=new Map;for(let h of k.children)t(h)||f.set(l(h),h);for(let h of b.children){let S=l(h),v=f.has(S),C=T.head.shouldReAppend(h),O=T.head.shouldPreserve(h);v||O?C?R.push(h):(f.delete(S),x.push(h)):T.head.style==="append"?C&&(R.push(h),m.push(h)):T.head.shouldRemove(h)!==!1&&!t(h)&&R.push(h)}m.push(...f.values());let g=[];for(let h of m){let S=document.createRange().createContextualFragment(h.outerHTML).firstChild;if(T.callbacks.beforeNodeAdded(S)!==!1){if("href"in S&&S.href||"src"in S&&S.src){let v,C=new Promise(function(O){v=O});S.addEventListener("load",function(){v()}),g.push(C)}b.appendChild(S),T.callbacks.afterNodeAdded(S),M.push(S)}}for(let h of R)T.callbacks.beforeNodeRemoved(h)!==!1&&(b.removeChild(h),T.callbacks.afterNodeRemoved(h));return T.head.afterHeadMorphed(b,{added:M,kept:x,removed:R}),g}function y(b,k,T){if(!T.scripts.handle)return[];let M=[],R=[],x=[],m=[],A=T.scripts.matchMode,l=Array.from(b.querySelectorAll("script"));for(let g of l){let h=r(g,A),S=k.has(h),v=T.scripts.shouldPreserve(g),C=T.scripts.shouldReAppend(g);S||v?C?(R.push(g),m.push(g)):x.push(g):m.push(g)}for(let g of k){let h=l.some(S=>S.outerHTML===g)}let f=[];for(let g of m){if(T.callbacks.beforeNodeAdded(g)===!1)continue;let h=document.createRange().createContextualFragment(g.outerHTML).firstChild;if(h.src){let S,v=new Promise(function(C){S=C});h.addEventListener("load",function(){S()}),h.addEventListener("error",function(){S()}),f.push(v)}g.replaceWith(h),T.callbacks.afterNodeAdded(h),M.push(h)}return T.scripts.afterScriptsHandled(b,{added:M,kept:x,removed:R}),f}let w=(function(){function b(l,f,g){let{persistentIds:h,idMap:S}=m(l,f),v=o.computeMatches(l,f);if(typeof g.key=="function"){let F=new Map,ie=new Set,L=$=>{let H=g.key($);H!=null&&(F.has(H)?ie.add(H):F.set(H,$))};l instanceof Element&&L(l);for(let $ of l.querySelectorAll("*"))L($);for(let $ of ie)F.delete($);let J=new Map;for(let[$,H]of v)J.set(H,$);let He=f.__hyperMorphRoot||f,be=new Map,At=new Set,vt=$=>{let H=g.key($);H!=null&&(be.has(H)?At.add(H):be.set(H,$))};He instanceof Element&&vt(He);for(let $ of He.querySelectorAll("*"))vt($);for(let $ of At)be.delete($);for(let[$,H]of be){let X=F.get($);if(!X||X.tagName!==H.tagName)continue;let Fe=J.get(X);Fe&&Fe!==H&&v.delete(Fe);let qe=v.get(H);qe&&qe!==X&&J.delete(qe),v.set(H,X),J.set(X,H)}}let C=new Set;for(let F of v.values())C.add(F);let O=k(g),N=O.morphStyle||"outerHTML";if(!["innerHTML","outerHTML"].includes(N))throw`Do not understand how to morph style ${N}`;return{target:l,newContent:f,config:O,morphStyle:N,ignoreActive:O.ignoreActive,ignoreActiveValue:O.ignoreActiveValue,restoreFocus:O.restoreFocus,formStateSync:O.formStateSync||"attribute",idMap:S,persistentIds:h,hyperMatches:v,hyperMatchedOldElements:C,pantry:T(),activeElementAndParents:M(l),callbacks:O.callbacks,head:O.head,scripts:O.scripts}}function k(l){let f=Object.assign({},n);return Object.assign(f,l),f.callbacks=Object.assign({},n.callbacks,l.callbacks),f.head=Object.assign({},n.head,l.head),f.scripts=Object.assign({},n.scripts,l.scripts),f}function T(){let l=document.createElement("div");return l.hidden=!0,document.body.insertAdjacentElement("afterend",l),l}function M(l){let f=[],g=document.activeElement;if(g?.tagName!=="BODY"&&l.contains(g))for(;g&&(f.push(g),g!==l);)g=g.parentElement;return f}function R(l){let f=Array.from(l.querySelectorAll("[id]"));return l.getAttribute?.("id")&&f.push(l),f}function x(l,f,g,h){for(let S of h){let v=S.getAttribute("id");if(f.has(v)){let C=S;for(;C;){let O=l.get(C);if(O==null&&(O=new Set,l.set(C,O)),O.add(v),C===g)break;C=C.parentElement}}}}function m(l,f){let g=R(l),h=R(f),S=A(g,h),v=new Map;x(v,S,l,g);let C=f.__hyperMorphRoot||f;return x(v,S,C,h),{persistentIds:S,idMap:v}}function A(l,f){let g=new Set,h=new Map;for(let{id:v,tagName:C}of l)h.has(v)?g.add(v):h.set(v,C);let S=new Set;for(let{id:v,tagName:C}of f)S.has(v)?g.add(v):h.get(v)===C&&S.add(v);for(let v of g)S.delete(v);return S}return b})(),{normalizeElement:E,normalizeParent:j}=(function(){let b=new WeakSet;function k(x){return x instanceof Document?x.documentElement:x}function T(x){if(x==null)return document.createElement("div");if(typeof x=="string")return T(R(x));if(b.has(x))return x;if(x instanceof Node){if(x.parentNode)return new M(x);{let m=document.createElement("div");return m.append(x),m}}else{let m=document.createElement("div");for(let A of[...x])m.append(A);return m}}class M{constructor(m){this.originalNode=m,this.realParentNode=m.parentNode,this.previousSibling=m.previousSibling,this.nextSibling=m.nextSibling}get childNodes(){let m=[],A=this.previousSibling?this.previousSibling.nextSibling:this.realParentNode.firstChild;for(;A&&A!=this.nextSibling;)m.push(A),A=A.nextSibling;return m}querySelectorAll(m){return this.childNodes.reduce((A,l)=>{if(l instanceof Element){l.matches(m)&&A.push(l);let f=l.querySelectorAll(m);for(let g=0;g<f.length;g++)A.push(f[g])}return A},[])}insertBefore(m,A){return this.realParentNode.insertBefore(m,A)}moveBefore(m,A){return this.realParentNode.moveBefore(m,A)}get __hyperMorphRoot(){return this.originalNode}}function R(x){let m=new DOMParser,A=x.replace(/<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim,"");if(A.match(/<\/html>/)||A.match(/<\/head>/)||A.match(/<\/body>/)){let l=m.parseFromString(x,"text/html");if(A.match(/<\/html>/))return b.add(l),l;{let f=l.firstChild;return f&&b.add(f),f}}else{let f=m.parseFromString("<body><template>"+x+"</template></body>","text/html").body.querySelector("template").content;return b.add(f),f}}return{normalizeElement:k,normalizeParent:T}})();return{morph:s,defaults:n}})();var Do=Ge.morph,Uo=Ge.defaults,Ye=Ge;var Yr=null;function Ee(){return Yr}function Me(e,t){let r={carriedOver:0,discarded:0,listItems:0},n=Ze(t,e,r);return Je(t,e,r),{data:n,summary:r}}function Ze(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[,n]=e;return Array.isArray(t)?(r.listItems+=t.length,t.map(o=>Ze(n,o,r))):void 0}if(typeof e=="object"&&e!==null){let n={};for(let[o,s]of Object.entries(e)){let a=Ze(s,t?.[o],r);a!==void 0&&(n[o]=a)}return n}}function Je(e,t,r){if(t!=null){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(typeof t!="object"||Array.isArray(t))return;let n=new Set(Object.keys(e));for(let o of Object.keys(t))n.has(o)?Je(e[o],t[o],r):r.discarded+=we(t[o]);return}if(Array.isArray(e)&&Array.isArray(t)){let n=e[1];t.forEach(o=>Je(n,o,r));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(r.discarded+=we(t))}}function we(e){return e==null?0:Array.isArray(e)?e.reduce((t,r)=>t+we(r),0):typeof e=="object"?Object.values(e).reduce((t,r)=>t+we(r),0):1}function Zr(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Jr(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var Xr={find(e,t,r={}){let n=Jr(e);if(!n||!n.querySelectorAll)return[];let o=Array.from(n.querySelectorAll(t));r.includeRulesTag||(o=o.filter(a=>!Zr(a)));let s=[];if(r.skip&&s.push(r.skip),r.templateAttr&&s.push("["+r.templateAttr+"]"),s.length){let a=s.join(", ");o=o.filter(i=>!i.closest||!i.closest(a))}return o},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 o=n.content.firstElementChild;if(!o)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(o,e),o},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}},D=Xr;var Qr="_hyperHtmlApi",en="upgrade-helper",tn="parentOrigin";function et(e=typeof location<"u"?location:null){if(!e)return!1;try{return new URLSearchParams(e.search).get(Qr)===en}catch{return!1}}function Ft(e=typeof location<"u"?location:null){return e?new URLSearchParams(e.search).get(tn):null}function tt({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||Ft(e.location),!r))return;let n=()=>rn({win:e,doc:t,parentOrigin:r});t.readyState==="loading"?t.addEventListener("DOMContentLoaded",n,{once:!0}):n()}function rn({win:e,doc:t,parentOrigin:r}){let n;try{n=Y(D,t.body)}catch(c){return Xe(e,r,c)}if(!n)return Xe(e,r,new Error("helper-mode: no rules tag in v2 document"));let o=n.rules,s=on(t,"hyper-version"),a=!!Ee(),i=c=>{if(c.source!==e.parent||c.origin!==r)return;let u=c.data;if(!(!u||u.type!=="hha:upgrade-data")){e.removeEventListener("message",i);try{let d=nn({doc:t,rules:o,v1Data:u.v1Data});e.parent.postMessage({type:"hha:upgrade-result",html:d.html,summary:d.summary},r)}catch(d){Xe(e,r,d)}}};e.addEventListener("message",i),e.parent.postMessage({type:"hha:upgrade-ready",rules:o,version:s,hasTransform:a},r)}function nn({doc:e,rules:t,v1Data:r}){let n=Ee(),o=r,s=!1;n&&(o=n(r),s=!0);let{data:a,summary:i}=Me(o,t);G(D,e.body,t,a);let c=B(D,e.body,t);return{html:`<!DOCTYPE html>
2
- `+e.documentElement.outerHTML,summary:{...i,transformApplied:s,appliedFieldCount:Qe(c)}}}function Xe(e,t,r){e.parent.postMessage({type:"hha:upgrade-error",name:r?.name||"Error",message:r?.message||String(r)},t)}function on(e,t){let r=e.querySelector(`meta[name="${t}"]`);return r?r.getAttribute("content"):null}function Qe(e){return e==null?0:Array.isArray(e)?e.reduce((t,r)=>t+Qe(r),0):typeof e=="object"?Object.values(e).reduce((t,r)=>t+Qe(r),0):1}var q={extract:(e,t,r)=>B(D,e,t,r),apply:(e,t,r,n)=>G(D,e,t,r,n),findRulesIn:(e,t)=>Y(D,e,t),findRules:(e,t)=>Ke(D,e,t),bind:(e,t,r)=>Ct(D,e,t,r),parseStrict:Ve,parseRelaxed:he,errors:ve,DOM_PROPERTIES:Se};typeof window<"u"&&et(window.location)&&tt({win:window,doc:document});var nt={};Pe(nt,{fromString:()=>V,getRuleAtPath:()=>me,getValueAtPath:()=>un,setAtPath:()=>rt,toString:()=>ln});function ln(e){return e.map(String).join(".")}function V(e){return e===""?[]:e.split(".").map(t=>/^\d+$/.test(t)?Number(t):t)}function me(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 un(e,t){let r=e;for(let n of t){if(r==null)return;r=r[n]}return r}function rt(e,t,r){if(t.length===0)return r;let[n,...o]=t;if(typeof n=="number"){let s=Array.isArray(e)?[...e]:[];return s[n]=rt(s[n],o,r),s}return{...e&&typeof e=="object"?e:{},[n]:rt((e||{})[n],o,r)}}function pe(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]=pe(n);return t}return""}function Te(e,t){Ye.morph(e,t,{morphStyle:"innerHTML",ignoreActiveValue:!0,restoreFocus:!0,formStateSync:"property"})}function qt(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 _t={"@scalar":`
1
+ var hypercms=(()=>{var Ye=Object.defineProperty;var Lr=Object.getOwnPropertyDescriptor;var jr=Object.getOwnPropertyNames;var Nr=Object.prototype.hasOwnProperty;var Je=(e,t)=>{for(var r in t)Ye(e,r,{get:t[r],enumerable:!0})},Ir=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of jr(t))!Nr.call(e,i)&&i!==r&&Ye(e,i,{get:()=>t[i],enumerable:!(n=Lr(t,i))||n.enumerable});return e};var Fr=e=>Ir(Ye({},"__esModule",{value:!0}),e);var Di={};Je(Di,{cms:()=>qi,default:()=>$i});var Se=["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"],Xe=new Set(Se),Ot=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Lt=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var Ee={};Je(Ee,{EmptyListInsert:()=>he,MAX_RULE_DEPTH:()=>ne,MaxRuleDepthExceeded:()=>G,RuleTargetReadOnly:()=>fe,RulesParseError:()=>re,ShapeMismatch:()=>me,UnknownRulesVersion:()=>de,UpgradeAlreadyRegistered:()=>_e});var re=class extends Error{constructor(t,r){super(t),this.name="RulesParseError",this.cause=r}},de=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},ne=20,G=class extends Error{constructor(t){super(`rule depth exceeded ${ne} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},me=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},he=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}},fe=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},_e=class extends Error{constructor(){super("upgrade transform already registered; only one registration is allowed per page."),this.name="UpgradeAlreadyRegistered"}};function z(e,t,r,n={}){return Ze(e,t,r,{depth:0,path:[]},n)}function Ze(e,t,r,n,i){if(n.depth>ne)throw new G(n.path);if(typeof r=="string")return qr(e,t,r,i);if(Array.isArray(r)){let[o,a]=r;return e.find(t,o,i).map((l,u)=>Ze(e,l,a,{depth:n.depth+1,path:[...n.path,u]},i))}if(typeof r=="object"&&r!==null){let o={};for(let[a,s]of Object.entries(r))o[a]=Ze(e,t,s,{depth:n.depth+1,path:[...n.path,a]},i);return o}return null}function qr(e,t,r,n){if(r.endsWith("[]")){let o=r.slice(0,-2);return e.find(t,o,n).map(a=>e.text(a))}if(r.startsWith("@"))return jt(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,n):[t];return l.length===0?null:jt(e,l[0],s)}if(r===".")return e.text(t);let i=e.find(t,r,n);return i.length===0?null:e.text(i[0])}function jt(e,t,r){if(Xe.has(r)){let i=e.prop(t,r);return i==null?null:String(i)}let n=e.attr(t,r);return n||null}var $r=.5;function Qe(e,t,r,n,i,o,a,s={}){let l=e.find(t,r,s);if(i.length===0){l.forEach(_=>e.remove(_));return}let u=i.length>l.length,c=l[0]||null;if(u&&!c&&(c=Br(e,t,r,s),!c))throw new he(o.path);let f=l.map(_=>Dr(e,_,n,s)),b=null;if(c){b=e.clone(c),s.templateAttr&&e.removeAttr(b,s.templateAttr);let _=e.stripIds(b);_>0&&console.warn(`[hyper-html-api] stripped ${_} id attribute(s) from cloned template at "${o.path.join(".")||"(root)"}"`)}let w=Pr(i,f,n),v=l[0]||c,T=e.parent(v),y=l.length>0?Ur(e,T,v):0,R=new Set,E=i.map((_,M)=>{let S=w[M];if(S>=0)return R.add(S),l[S];let p=e.clone(b);return e.stripIds(p),p});l.forEach((_,M)=>{R.has(M)||e.remove(_)}),E.forEach((_,M)=>{let S=y+M;e.children(T).findIndex(d=>e.sameNode(d,_))!==S&&e.insertAt(T,_,S)}),E.forEach((_,M)=>{if(n===null){let S=i[M],p=S==null?"":String(S);e.text(_)!==p&&e.text(_,p)}else{let S=a(e,_,n,i[M],{depth:o.depth+1,path:[...o.path,M]},s);S&&S!==_&&(E[M]=S)}})}function Dr(e,t,r,n){return r===null?e.text(t):z(e,t,r,n)}function Pr(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((u,c)=>{if(i.has(c))return;let f=Hr(o,u,r),b=f===l&&s>=0?Math.abs(c-a)<Math.abs(s-a):!1;(f>l||b)&&(l=f,s=c)}),l>=$r&&(n[a]=s,i.add(s))}),n}function Hr(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 Ur(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 Br(e,t,r,n){if(!n.templateAttr)return null;let i=t;for(;i;){let o=e.find(i,r,{includeRulesTag:!1});for(let a of o)if(e.attr(a,n.templateAttr)!=null)return a;i=e.parent(i)}return null}var Nt=new Set(["checked","selected","disabled","readOnly","paused"]);function Y(e,t,r,n,i={}){let o=[];if(et(r,n,[],o),o.length)throw new me(o);Me(e,t,r,n,{depth:0,path:[]},i)}function Me(e,t,r,n,i,o={}){if(i.depth>ne)throw new G(i.path);if(n===void 0)return t;if(typeof r=="string")return zr(e,t,r,n,i,o);if(Array.isArray(r)){let[a,s]=r;return Qe(e,t,a,s,n,i,Me,o),t}if(typeof r=="object"&&r!==null){for(let[a,s]of Object.entries(r)){let l=Me(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 zr(e,t,r,n,i,o){if(r.endsWith("[]")){let s=r.slice(0,-2);return Qe(e,t,s,null,n,i,Me,o),t}if(r.startsWith("@"))return It(e,t,r.slice(1),n);if(r.includes("@")){let s=r.lastIndexOf("@"),l=r.slice(0,s),u=r.slice(s+1),c=l?e.find(t,l,o):[t];return c.length===0||It(e,c[0],u,n),t}if(r===".")return e.text(t,n==null?"":String(n)),t;let a=e.find(t,r,o);return a.length===0||e.text(a[0],n==null?"":String(n)),t}function It(e,t,r,n){if(Lt.has(r))throw new fe(r);if(r==="outerHTML"){let i=n==null?"":String(n);return e.replaceWith(t,i)}return Ot.has(r)?(e.prop(t,r,Wr(r,n)),t):(e.attr(t,r,n==null?"":String(n)),t)}function Wr(e,t){return t==null?Nt.has(e)?!1:"":Nt.has(e)?!!t:t}function et(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:be([...r,o]),expected:"scalar",got:pe(i)})}):n.push({path:be(r),expected:"array",got:pe(t)});return}t!==null&&typeof t=="object"&&n.push({path:be(r),expected:"scalar",got:pe(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){n.push({path:be(r),expected:"array",got:pe(t)});return}let i=e[1];t.forEach((o,a)=>et(i,o,[...r,a],n));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){n.push({path:be(r),expected:"object",got:pe(t)});return}for(let[i,o]of Object.entries(e))et(o,t[i],[...r,i],n)}}}function pe(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function be(e){return e.join(".")}function tt(e){try{return JSON.parse(e)}catch(t){throw new re(`Invalid strict JSON: ${t.message}`,t)}}function ge(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 f=!1,b=a+1;for(;b<i.length&&/\s/.test(i[b]);)b++;if(b<i.length&&/[a-zA-Z_]/.test(i[b])&&(f=!0),!f){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 f=s,b=a+1;for(;b<i.length&&i[b]!==f;)i[b]==="\\"&&b++,b++;o.push({type:t.STRING,value:i.substring(a+1,b),quoted:!0,sourceQuote:f}),a=b+1;continue}let l=a,u;for(;l<i.length&&!/[{},]/.test(i[l]);)if(i[l]===":"){let f=[":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"],b=!1;for(let w of f){let v=w.substring(1);if(i.substring(l+1,l+1+v.length)===v){b=!0,l+=v.length;break}}if(!b)break}else if(i[l]==="["){for(l++;l<i.length&&i[l]!=="]";){if(i[l]==='"'||i[l]==="'"){let f=i[l];for(l++;l<i.length&&i[l]!==f;)i[l]==="\\"&&l++,l++}l++}l<i.length&&i[l]==="]"&&l++}else l++;u=i.substring(a,l);let c=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(u)?c=t.NUMBER:u==="true"||u==="false"||u==="null"?c=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(u)&&(c=t.SELECTOR),o.push({type:c,value:u,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,(u,c)=>c.length%2===0?c+'\\"':u)),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 re("Invalid extraction rules syntax: "+i.message,i)}}var Vr="1",Ft=/^[a-zA-Z0-9_-]+$/;function J(e,t,r){let n;if(r===void 0)n="script[data-rules-name]";else{if(typeof r!="string"||!Ft.test(r))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(r)} (must match ${Ft})`);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!==Vr)throw new de(a);return{rules:ge(e.text(o)),tagNode:o}}function rt(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 J(e,n,r)}return null}function qt(e,t,r,n){let i=rt(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:()=>z(e,t,o,n),set:s=>Y(e,t,o,s,n)}}var Pt={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 Yr(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 Jr(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 Xr(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 Zr(e,t){return(e.textContent||"").replace(/\s+/g," ").trim().slice(0,t.textHintLength)}function Qr(e,t){let r=[e.tagName];return t.includeClasses&&r.push(Jr(e)),r.push(Xr(e,t)),Yr(r.join("|"))}function en(e){let t=e.tagName,r=1,n=e.previousElementSibling;for(;n;)n.tagName===t&&r++,n=n.previousElementSibling;return r}function tn(e,t){return e.id||e.getAttribute?.("role")?!0:t.landmarks.includes(e.tagName)}function rn(e){if(e.id)return`#${e.id}`;let t=e.getAttribute?.("role");return t?`@${t}`:e.tagName}function nn(e,t){let r=[],n=e;for(;n&&n.tagName&&r.length<t.maxPathDepth;){let i=`${n.tagName}:${en(n)}`;if(r.unshift(i),n!==e&&tn(n,t)){r.unshift(rn(n));break}n=n.parentElement}return r}function on(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 P(e,t,r){if(r.has(e))return r.get(e);let n={signature:Qr(e,t),path:nn(e,t),textHint:Zr(e,t)};return r.set(e,n),n}function zt(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=P(s,t,r);l.domIndex=a++,i.has(l.signature)||i.set(l.signature,[]),i.get(l.signature).push(s)}return n.set(e,i),i}function sn(e,t,r){r.delete(e),t.delete(e);let n=e.querySelectorAll("*");for(let i of n)t.delete(i)}function nt(e,t,r,n,i){let o=P(e,r,n),a=P(t,r,n),s=r.weights,l={},u=0;if(o.signature!==a.signature)return{score:0,breakdown:{rejected:"signature mismatch"}};u+=s.signature,l.signature=s.signature;let f=on(o.path,a.path)*s.pathSegment;u+=f,l.path=f;let b=!0;if(o.textHint&&a.textHint?o.textHint===a.textHint?(u+=s.textMatch,l.text=s.textMatch):(u-=s.textMismatch,l.text=-s.textMismatch,b=!1):o.textHint!==a.textHint&&(u-=s.textMismatch,l.text=-s.textMismatch,b=!1),i.candidateCount===1&&b&&(u+=s.uniqueCandidate,l.unique=s.uniqueCandidate),typeof o.domIndex=="number"&&typeof a.domIndex=="number"){let w=Math.abs(o.domIndex-a.domIndex),v=Math.min(w*s.positionPenalty,20);u-=v,l.drift=-v}return{score:u,breakdown:l}}function Ht(e,t,r,n,i){if(r.excludeIds&&e.id)return null;let o=zt(t,r,n,i),a=P(e,r,n);if(typeof a.domIndex!="number"){let b=0,w=e.previousElementSibling;for(;w;)b++,w=w.previousElementSibling;a.domIndex=b}let s=o.get(a.signature)||[],l=r.excludeIds?s.filter(b=>!b.id):s;if(l.length===0)return null;let u=null,c=0,f=null;for(let b of l){let{score:w,breakdown:v}=nt(e,b,r,n,{candidateCount:l.length});w>c&&(c=w,u=b,f=v)}return c<r.minConfidence?null:{element:u,confidence:c,breakdown:f}}function an(e,t,r,n){let i=[],o=r.weights.signature+r.weights.slotMatch,a={slot:o};function s(f){if(f.children)return f.children;let b=f.childNodes;if(!b)return[];let w=[];for(let v=0;v<b.length;v++)b[v].nodeType===1&&w.push(b[v]);return w}function l(f,b){let w=s(f),v=s(b);if(w.length===v.length)for(let T=0;T<w.length;T++){let y=w[T],R=v[T];if(r.excludeIds&&(y.id||R.id)||y.tagName!==R.tagName)continue;let E=P(y,r,n).signature,_=P(R,r,n).signature;E!==_&&i.push({newEl:y,oldEl:R,score:o,breakdown:a}),l(y,R)}}function u(f,b){for(;;){if(f.tagName===b.tagName)return[f,b];let w=s(f);if(!f.tagName&&w.length===1){f=w[0];continue}let v=s(b);if(v.length===1&&v[0].tagName===f.tagName){b=v[0];continue}return null}}let c=u(e,t);return c&&l(c[0],c[1]),i}function Ut(e,t,r,n,i){let o=t.querySelectorAll("*"),a=zt(e,r,n,i),s=0;for(let f of o){let b=P(f,r,n);b.domIndex=s++}let l=[];for(let f of o){if(r.excludeIds&&f.id)continue;let b=P(f,r,n),w=a.get(b.signature)||[],v=r.excludeIds?w.filter(T=>!T.id):w;for(let T of v){let{score:y,breakdown:R}=nt(f,T,r,n,{candidateCount:v.length});y>=r.minConfidence&&l.push({newEl:f,oldEl:T,score:y,breakdown:R})}}if(r.weights.slotMatch>0){let f=an(t,e,r,n);for(let b of f)l.push(b)}l.sort((f,b)=>b.score-f.score);let u=new Map,c=new Set;for(let{newEl:f,oldEl:b}of l)u.has(f)||c.has(b)||(u.set(f,b),c.add(b));return u}function Bt(e,t,r,n){let i=P(e,r,n),o=P(t,r,n),{score:a,breakdown:s}=nt(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 Wt(e={}){let t={...Pt,...e,weights:{...Pt.weights,...e.weights}},r=new WeakMap,n=new WeakMap;return{findMatch:(i,o)=>Ht(i,o,t,r,n),computeMatches:(i,o)=>Ut(i,o,t,r,n),explain:(i,o)=>Bt(i,o,t,r),invalidate:i=>sn(i,r,n),session:()=>{let i=new WeakMap,o=new WeakMap;return{findMatch:(a,s)=>Ht(a,s,t,i,o),computeMatches:(a,s)=>Ut(a,s,t,i,o),explain:(a,s)=>Bt(a,s,t,i)}},getConfig:()=>({...t})}}var ln=Wt(),it=(function(){"use strict";let e=()=>{};function t(y){if(!(y instanceof Element))return!1;if(y.hasAttribute("save-ignore"))return!0;if(y.tagName==="LINK"||y.tagName==="SCRIPT"){let R=y.getAttribute("src")||y.getAttribute("href")||"";if(R.startsWith("chrome-extension://")||R.startsWith("moz-extension://")||R.startsWith("safari-web-extension://"))return!0}return!1}function r(y,R){if(R!=="smart")return y.outerHTML;let E=y.getAttribute("src"),_=y.getAttribute("type")||"text/javascript";if(E)try{let M=new URL(E,window.location.href);return`ext:${_}:${M.origin}${M.pathname}${M.search}`}catch{return`ext:${_}:${E}`}else{let M=y.textContent.trim(),S=5381;for(let p=0;p<M.length;p++)S=(S<<5)+S^M.charCodeAt(p);return`inline:${_}:${Math.abs(S).toString(36)}`}}let n={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:e,afterNodeAdded:e,beforeNodeMorphed:e,afterNodeMorphed:e,beforeNodeRemoved:e,afterNodeRemoved:e,beforeAttributeUpdated:e},head:{style:"merge",shouldPreserve:y=>y.getAttribute("im-preserve")==="true",shouldReAppend:y=>y.getAttribute("im-re-append")==="true",shouldRemove:e,afterHeadMorphed:e},scripts:{handle:!1,matchMode:"outerHTML",shouldPreserve:y=>y.getAttribute("im-preserve")==="true",shouldReAppend:y=>y.getAttribute("im-re-append")==="true",shouldRemove:e,afterScriptsHandled:e},restoreFocus:!0},i={computeMatches(y,R){let{computeMatches:E}=ln.session();return E(y,R)}};function o(y,R,E={}){y=v(y);let _=T(R),M=w(y,_,E),S=M.scripts.matchMode,p=new Set(Array.from(y.querySelectorAll("script")).map(m=>r(m,S))),x=s(M,()=>c(M,y,_,m=>m.morphStyle==="innerHTML"?(l(m,y,_),Array.from(y.childNodes)):a(m,y,_)));M.pantry.remove();let d=b(y,p,M);return d.length>0?x instanceof Promise?x.then(m=>Promise.all(d).then(()=>m)):Promise.all(d).then(()=>x):x}function a(y,R,E){let _=T(R);return l(y,_,E,R,R.nextSibling),Array.from(_.childNodes)}function s(y,R){if(!y.config.restoreFocus)return R();let E=document.activeElement;if(!(E instanceof HTMLInputElement||E instanceof HTMLTextAreaElement))return R();let{id:_,selectionStart:M,selectionEnd:S}=E,p=R();return _&&_!==document.activeElement?.getAttribute("id")&&(E=y.target.querySelector(`[id="${_}"]`),E?.focus()),E&&!E.selectionEnd&&S!=null&&E.setSelectionRange(M,S),p}let l=(function(){function y(d,m,g,h=null,k=null){m instanceof HTMLTemplateElement&&g instanceof HTMLTemplateElement&&(m=m.content,g=g.content),h||=m.firstChild;for(let A of g.childNodes){if(t(A))continue;if(h&&h!=k){let O=E(d,A,h,k);if(O){O!==h&&M(d,h,O),u(O,A,d),h=O.nextSibling;continue}}if(A instanceof Element){let O=A.getAttribute("id");if(d.persistentIds.has(O)){let j=S(m,O,h,d);u(j,A,d),h=j.nextSibling;continue}if(!d.idMap.has(A)){let j=d.hyperMatches.get(A);if(j&&!d.idMap.has(j)){x(m,j,h),u(j,A,d),h=j.nextSibling;continue}}}let C=R(m,A,h,d);C&&(h=C.nextSibling)}for(;h&&h!=k;){let A=h;h=h.nextSibling,t(A)||_(d,A)}}function R(d,m,g,h){if(h.callbacks.beforeNodeAdded(m)===!1)return null;if(h.idMap.has(m)){let k=document.createElement(m.tagName);return d.insertBefore(k,g),u(k,m,h),h.callbacks.afterNodeAdded(k),k}else{let k=document.importNode(m,!0);return d.insertBefore(k,g),h.callbacks.afterNodeAdded(k),k}}let E=(function(){function d(h,k,A,C){let O=k instanceof Element&&!h.idMap.has(k)?h.hyperMatches.get(k):null,j=null,D=k.nextSibling,ue=0,N=A;for(;N&&N!=C;){if(g(N,k)){if(m(h,N,k)||N===O&&!h.idMap.has(N))return N;if(j===null){let ee=N instanceof Element&&h.hyperMatchedOldElements.has(N);!h.idMap.has(N)&&!ee&&(j=N)}}if(j===null&&D&&g(N,D)&&(ue++,D=D.nextSibling,ue>=2&&(j=void 0)),h.activeElementAndParents.includes(N))break;N=N.nextSibling}return j||null}function m(h,k,A){let C=h.idMap.get(k),O=h.idMap.get(A);if(!O||!C)return!1;for(let j of C)if(O.has(j))return!0;return!1}function g(h,k){let A=h,C=k;return A.nodeType===C.nodeType&&A.tagName===C.tagName&&(!A.getAttribute?.("id")||A.getAttribute?.("id")===C.getAttribute?.("id"))}return d})();function _(d,m){let g=m instanceof Element&&d.hyperMatchedOldElements.has(m)&&!d.idMap.has(m);if(d.idMap.has(m)||g)x(d.pantry,m,null);else{if(d.callbacks.beforeNodeRemoved(m)===!1)return;m.parentNode?.removeChild(m),d.callbacks.afterNodeRemoved(m)}}function M(d,m,g){let h=m;for(;h&&h!==g;){let k=h;h=h.nextSibling,t(k)||_(d,k)}return h}function S(d,m,g,h){let k=h.target.getAttribute?.("id")===m&&h.target||h.target.querySelector(`[id="${m}"]`)||h.pantry.querySelector(`[id="${m}"]`);return p(k,h),x(d,k,g),k}function p(d,m){let g=d.getAttribute("id");for(;d=d.parentNode;){let h=m.idMap.get(d);h&&(h.delete(g),h.size||m.idMap.delete(d))}}function x(d,m,g){if(d.moveBefore)try{d.moveBefore(m,g)}catch{d.insertBefore(m,g)}else d.insertBefore(m,g)}return y})(),u=(function(){function y(p,x,d){return d.ignoreActive&&p===document.activeElement?null:(d.callbacks.beforeNodeMorphed(p,x)===!1||(p instanceof HTMLHeadElement&&d.head.ignore||(p instanceof HTMLHeadElement&&d.head.style!=="morph"?f(p,x,d):(R(p,x,d),S(p,d)||l(d,p,x))),d.callbacks.afterNodeMorphed(p,x)),p)}function R(p,x,d){let m=x.nodeType;if(m===1){let g=p,h=x,k=g.attributes,A=h.attributes;for(let C of A)M(C.name,g,"update",d)||g.getAttribute(C.name)!==C.value&&g.setAttribute(C.name,C.value);for(let C=k.length-1;0<=C;C--){let O=k[C];if(O&&!h.hasAttribute(O.name)){if(M(O.name,g,"remove",d))continue;g.removeAttribute(O.name)}}S(g,d)||E(g,h,d)}(m===8||m===3)&&p.nodeValue!==x.nodeValue&&(p.nodeValue=x.nodeValue)}function E(p,x,d){if(p instanceof HTMLInputElement&&x instanceof HTMLInputElement&&x.type!=="file"){let m=x.value,g=p.value;_(p,x,"checked",d),_(p,x,"disabled",d),d.formStateSync==="property"?g!==m&&(M("value",p,"update",d)||(p.value=m)):x.hasAttribute("value")?g!==m&&(M("value",p,"update",d)||(p.setAttribute("value",m),p.value=m)):M("value",p,"remove",d)||(p.value="",p.removeAttribute("value"))}else if(p instanceof HTMLOptionElement&&x instanceof HTMLOptionElement)_(p,x,"selected",d);else if(p instanceof HTMLTextAreaElement&&x instanceof HTMLTextAreaElement){let m=x.value,g=p.value;if(M("value",p,"update",d))return;m!==g&&(p.value=m),p.firstChild&&p.firstChild.nodeValue!==m&&(p.firstChild.nodeValue=m)}}function _(p,x,d,m){let g=x[d],h=p[d];if(g!==h){let k=M(d,p,"update",m);if(k||(p[d]=x[d]),m.formStateSync==="property")return;g?k||p.setAttribute(d,""):M(d,p,"remove",m)||p.removeAttribute(d)}}function M(p,x,d,m){return p==="value"&&m.ignoreActiveValue&&x===document.activeElement?!0:m.callbacks.beforeAttributeUpdated(p,x,d)===!1}function S(p,x){return!!x.ignoreActiveValue&&p===document.activeElement&&p!==document.body}return y})();function c(y,R,E,_){if(y.head.block){let M=R.querySelector("head"),S=E.querySelector("head");if(M&&S){let p=f(M,S,y);return Promise.all(p).then(()=>{let x=Object.assign(y,{head:{block:!1,ignore:!0}});return _(x)})}}return _(y)}function f(y,R,E){let _=[],M=[],S=[],p=[],x=E.scripts.matchMode,d=h=>{if(h.tagName==="SCRIPT")return r(h,x);if(h.tagName==="LINK"&&x==="smart"){let k=h.getAttribute("href");if(k)try{let A=new URL(k,window.location.href);return`link:${h.getAttribute("rel")||""}:${A.origin}${A.pathname}${A.search}`}catch{}}return h.outerHTML},m=new Map;for(let h of R.children)t(h)||m.set(d(h),h);for(let h of y.children){let k=d(h),A=m.has(k),C=E.head.shouldReAppend(h),O=E.head.shouldPreserve(h);A||O?C?M.push(h):(m.delete(k),S.push(h)):E.head.style==="append"?C&&(M.push(h),p.push(h)):E.head.shouldRemove(h)!==!1&&!t(h)&&M.push(h)}p.push(...m.values());let g=[];for(let h of p){let k=document.createRange().createContextualFragment(h.outerHTML).firstChild;if(E.callbacks.beforeNodeAdded(k)!==!1){if("href"in k&&k.href||"src"in k&&k.src){let A,C=new Promise(function(O){A=O});k.addEventListener("load",function(){A()}),g.push(C)}y.appendChild(k),E.callbacks.afterNodeAdded(k),_.push(k)}}for(let h of M)E.callbacks.beforeNodeRemoved(h)!==!1&&(y.removeChild(h),E.callbacks.afterNodeRemoved(h));return E.head.afterHeadMorphed(y,{added:_,kept:S,removed:M}),g}function b(y,R,E){if(!E.scripts.handle)return[];let _=[],M=[],S=[],p=[],x=E.scripts.matchMode,d=Array.from(y.querySelectorAll("script"));for(let g of d){let h=r(g,x),k=R.has(h),A=E.scripts.shouldPreserve(g),C=E.scripts.shouldReAppend(g);k||A?C?(M.push(g),p.push(g)):S.push(g):p.push(g)}for(let g of R){let h=d.some(k=>k.outerHTML===g)}let m=[];for(let g of p){if(E.callbacks.beforeNodeAdded(g)===!1)continue;let h=document.createRange().createContextualFragment(g.outerHTML).firstChild;if(h.src){let k,A=new Promise(function(C){k=C});h.addEventListener("load",function(){k()}),h.addEventListener("error",function(){k()}),m.push(A)}g.replaceWith(h),E.callbacks.afterNodeAdded(h),_.push(h)}return E.scripts.afterScriptsHandled(y,{added:_,kept:S,removed:M}),m}let w=(function(){function y(d,m,g){let{persistentIds:h,idMap:k}=p(d,m),A=i.computeMatches(d,m);if(typeof g.key=="function"){let D=new Map,ue=new Set,N=I=>{let F=g.key(I);F!=null&&(D.has(F)?ue.add(F):D.set(F,I))};d instanceof Element&&N(d);for(let I of d.querySelectorAll("*"))N(I);for(let I of ue)D.delete(I);let ee=new Map;for(let[I,F]of A)ee.set(F,I);let Ve=m.__hyperMorphRoot||m,Ae=new Map,Rt=new Set,Tt=I=>{let F=g.key(I);F!=null&&(Ae.has(F)?Rt.add(F):Ae.set(F,I))};Ve instanceof Element&&Tt(Ve);for(let I of Ve.querySelectorAll("*"))Tt(I);for(let I of Rt)Ae.delete(I);for(let[I,F]of Ae){let te=D.get(I);if(!te||te.tagName!==F.tagName)continue;let Ke=ee.get(te);Ke&&Ke!==F&&A.delete(Ke);let Ge=A.get(F);Ge&&Ge!==te&&ee.delete(Ge),A.set(F,te),ee.set(te,F)}}let C=new Set;for(let D of A.values())C.add(D);let O=R(g),j=O.morphStyle||"outerHTML";if(!["innerHTML","outerHTML"].includes(j))throw`Do not understand how to morph style ${j}`;return{target:d,newContent:m,config:O,morphStyle:j,ignoreActive:O.ignoreActive,ignoreActiveValue:O.ignoreActiveValue,restoreFocus:O.restoreFocus,formStateSync:O.formStateSync||"attribute",idMap:k,persistentIds:h,hyperMatches:A,hyperMatchedOldElements:C,pantry:E(),activeElementAndParents:_(d),callbacks:O.callbacks,head:O.head,scripts:O.scripts}}function R(d){let m=Object.assign({},n);return Object.assign(m,d),m.callbacks=Object.assign({},n.callbacks,d.callbacks),m.head=Object.assign({},n.head,d.head),m.scripts=Object.assign({},n.scripts,d.scripts),m}function E(){let d=document.createElement("div");return d.hidden=!0,document.body.insertAdjacentElement("afterend",d),d}function _(d){let m=[],g=document.activeElement;if(g?.tagName!=="BODY"&&d.contains(g))for(;g&&(m.push(g),g!==d);)g=g.parentElement;return m}function M(d){let m=Array.from(d.querySelectorAll("[id]"));return d.getAttribute?.("id")&&m.push(d),m}function S(d,m,g,h){for(let k of h){let A=k.getAttribute("id");if(m.has(A)){let C=k;for(;C;){let O=d.get(C);if(O==null&&(O=new Set,d.set(C,O)),O.add(A),C===g)break;C=C.parentElement}}}}function p(d,m){let g=M(d),h=M(m),k=x(g,h),A=new Map;S(A,k,d,g);let C=m.__hyperMorphRoot||m;return S(A,k,C,h),{persistentIds:k,idMap:A}}function x(d,m){let g=new Set,h=new Map;for(let{id:A,tagName:C}of d)h.has(A)?g.add(A):h.set(A,C);let k=new Set;for(let{id:A,tagName:C}of m)k.has(A)?g.add(A):h.get(A)===C&&k.add(A);for(let A of g)k.delete(A);return k}return y})(),{normalizeElement:v,normalizeParent:T}=(function(){let y=new WeakSet;function R(S){return S instanceof Document?S.documentElement:S}function E(S){if(S==null)return document.createElement("div");if(typeof S=="string")return E(M(S));if(y.has(S))return S;if(S instanceof Node){if(S.parentNode)return new _(S);{let p=document.createElement("div");return p.append(S),p}}else{let p=document.createElement("div");for(let x of[...S])p.append(x);return p}}class _{constructor(p){this.originalNode=p,this.realParentNode=p.parentNode,this.previousSibling=p.previousSibling,this.nextSibling=p.nextSibling}get childNodes(){let p=[],x=this.previousSibling?this.previousSibling.nextSibling:this.realParentNode.firstChild;for(;x&&x!=this.nextSibling;)p.push(x),x=x.nextSibling;return p}querySelectorAll(p){return this.childNodes.reduce((x,d)=>{if(d instanceof Element){d.matches(p)&&x.push(d);let m=d.querySelectorAll(p);for(let g=0;g<m.length;g++)x.push(m[g])}return x},[])}insertBefore(p,x){return this.realParentNode.insertBefore(p,x)}moveBefore(p,x){return this.realParentNode.moveBefore(p,x)}get __hyperMorphRoot(){return this.originalNode}}function M(S){let p=new DOMParser,x=S.replace(/<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim,"");if(x.match(/<\/html>/)||x.match(/<\/head>/)||x.match(/<\/body>/)){let d=p.parseFromString(S,"text/html");if(x.match(/<\/html>/))return y.add(d),d;{let m=d.firstChild;return m&&y.add(m),m}}else{let m=p.parseFromString("<body><template>"+S+"</template></body>","text/html").body.querySelector("template").content;return y.add(m),m}}return{normalizeElement:R,normalizeParent:E}})();return{morph:o,defaults:n}})();var _o=it.morph,Eo=it.defaults,ot=it;var hn=null;function Ce(){return hn}function Te(e,t){let r={carriedOver:0,discarded:0,listItems:0},n=st(t,e,r);return at(t,e,r),{data:n,summary:r}}function st(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[,n]=e;return Array.isArray(t)?(r.listItems+=t.length,t.map(i=>st(n,i,r))):void 0}if(typeof e=="object"&&e!==null){let n={};for(let[i,o]of Object.entries(e)){let a=st(o,t?.[i],r);a!==void 0&&(n[i]=a)}return n}}function at(e,t,r){if(t!=null){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(typeof t!="object"||Array.isArray(t))return;let n=new Set(Object.keys(e));for(let i of Object.keys(t))n.has(i)?at(e[i],t[i],r):r.discarded+=Re(t[i]);return}if(Array.isArray(e)&&Array.isArray(t)){let n=e[1];t.forEach(i=>at(n,i,r));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(r.discarded+=Re(t))}}function Re(e){return e==null?0:Array.isArray(e)?e.reduce((t,r)=>t+Re(r),0):typeof e=="object"?Object.values(e).reduce((t,r)=>t+Re(r),0):1}function fn(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function pn(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var bn={find(e,t,r={}){let n=pn(e);if(!n||!n.querySelectorAll)return[];let i=Array.from(n.querySelectorAll(t));r.includeRulesTag||(i=i.filter(a=>!fn(a)));let o=[];if(r.skip&&o.push(r.skip),r.templateAttr&&o.push("["+r.templateAttr+"]"),o.length){let a=o.join(", ");i=i.filter(s=>!s.closest||!s.closest(a))}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}},H=bn;var gn="_hyperHtmlApi",yn="upgrade-helper",kn="parentOrigin";function ut(e=typeof location<"u"?location:null){if(!e)return!1;try{return new URLSearchParams(e.search).get(gn)===yn}catch{return!1}}function Vt(e=typeof location<"u"?location:null){return e?new URLSearchParams(e.search).get(kn):null}function dt({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||Vt(e.location),!r))return;let n=()=>vn({win:e,doc:t,parentOrigin:r});t.readyState==="loading"?t.addEventListener("DOMContentLoaded",n,{once:!0}):n()}function vn({win:e,doc:t,parentOrigin:r}){let n;try{n=J(H,t.body)}catch(l){return lt(e,r,l)}if(!n)return lt(e,r,new Error("helper-mode: no rules tag in v2 document"));let i=n.rules,o=wn(t,"hyper-version"),a=!!Ce(),s=l=>{if(l.source!==e.parent||l.origin!==r)return;let u=l.data;if(!(!u||u.type!=="hha:upgrade-data")){e.removeEventListener("message",s);try{let c=xn({doc:t,rules:i,v1Data:u.v1Data});e.parent.postMessage({type:"hha:upgrade-result",html:c.html,summary:c.summary},r)}catch(c){lt(e,r,c)}}};e.addEventListener("message",s),e.parent.postMessage({type:"hha:upgrade-ready",rules:i,version:o,hasTransform:a},r)}function xn({doc:e,rules:t,v1Data:r}){let n=Ce(),i=r,o=!1;n&&(i=n(r),o=!0);let{data:a,summary:s}=Te(i,t);Y(H,e.body,t,a);let l=z(H,e.body,t);return{html:`<!DOCTYPE html>
2
+ `+e.documentElement.outerHTML,summary:{...s,transformApplied:o,appliedFieldCount:ct(l)}}}function lt(e,t,r){e.parent.postMessage({type:"hha:upgrade-error",name:r?.name||"Error",message:r?.message||String(r)},t)}function wn(e,t){let r=e.querySelector(`meta[name="${t}"]`);return r?r.getAttribute("content"):null}function ct(e){return e==null?0:Array.isArray(e)?e.reduce((t,r)=>t+ct(r),0):typeof e=="object"?Object.values(e).reduce((t,r)=>t+ct(r),0):1}var q={extract:(e,t,r)=>z(H,e,t,r),apply:(e,t,r,n)=>Y(H,e,t,r,n),findRulesIn:(e,t)=>J(H,e,t),findRules:(e,t)=>rt(H,e,t),bind:(e,t,r)=>qt(H,e,t,r),parseStrict:tt,parseRelaxed:ge,errors:Ee,DOM_PROPERTIES:Se};typeof window<"u"&&ut(window.location)&&dt({win:window,doc:document});var ht={};Je(ht,{fromString:()=>W,getRuleAtPath:()=>X,getValueAtPath:()=>Mn,setAtPath:()=>mt,toString:()=>En});function En(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 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 Mn(e,t){let r=e;for(let n of t){if(r==null)return;r=r[n]}return r}function mt(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]=mt(o[n],i,r),o}return{...e&&typeof e=="object"?e:{},[n]:mt((e||{})[n],i,r)}}function ye(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]=ye(n);return t}return""}function Oe(e,t,{ignoreActiveValue:r=!0}={}){ot.morph(e,t,{morphStyle:"innerHTML",ignoreActiveValue:r,restoreFocus:!0,formStateSync:"property"})}function Gt(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 Cn='<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>',ft='<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>',Yt={"@scalar":`
3
3
  <label class="hcms-field" data-hcms-shape="scalar">
4
4
  <span class="hcms-label" data-hcms-label></span>
5
- <input class="hcms-input" data-hcms-field />
5
+ <input class="mirk-input" data-hcms-field />
6
6
  <div class="hcms-error" hidden></div>
7
7
  </label>
8
8
  `,"@object":`
@@ -18,319 +18,1140 @@ var hypercms=(()=>{var _e=Object.defineProperty;var pr=Object.getOwnPropertyDesc
18
18
  </header>
19
19
  <ul class="hcms-array-items"></ul>
20
20
  <div class="hcms-error" hidden></div>
21
- <button type="button" class="hcms-add" data-hcms-action="add">+ Add</button>
21
+ <button type="button" class="hcms-add mirk-button mirk-button--small" data-hcms-action="add"><span class="mirk-button__label">+ Add</span></button>
22
22
  </section>
23
23
  `,"@scalar-array-item":`
24
24
  <li class="hcms-array-item" draggable="true">
25
- <span class="hcms-drag-handle" aria-hidden="true">::</span>
26
- <input class="hcms-input" data-hcms-field />
25
+ <input class="mirk-input" data-hcms-field />
27
26
  <button type="button" class="hcms-move hcms-move-up hcms-sr-only" data-hcms-action="move-up" aria-label="Move up">\u2191</button>
28
27
  <button type="button" class="hcms-move hcms-move-down hcms-sr-only" data-hcms-action="move-down" aria-label="Move down">\u2193</button>
29
- <button type="button" class="hcms-remove" data-hcms-action="remove" aria-label="Remove">x</button>
28
+ <button type="button" class="hcms-remove" data-hcms-action="remove" aria-label="Remove">\xD7</button>
30
29
  <div class="hcms-error" hidden></div>
31
30
  </li>
32
31
  `,"@object-array":`
33
- <section class="hcms-array hcms-object-array" data-hcms-shape="object-array">
32
+ <section class="hcms-array hcms-object-array hcms-array--cards" data-hcms-shape="object-array">
34
33
  <header class="hcms-array-header">
35
34
  <h3 class="hcms-array-title" data-hcms-label></h3>
36
35
  </header>
37
36
  <div class="hcms-array-items"></div>
38
37
  <div class="hcms-error" hidden></div>
39
- <button type="button" class="hcms-add" data-hcms-action="add">+ Add</button>
38
+ <button type="button" class="hcms-add mirk-button mirk-button--small" data-hcms-action="add"><span class="mirk-button__label">+ Add</span></button>
40
39
  </section>
41
40
  `,"@object-array-item":`
42
- <article class="hcms-card" draggable="true">
43
- <header class="hcms-card-header">
44
- <span class="hcms-drag-handle" aria-hidden="true">::</span>
45
- <button type="button" class="hcms-move hcms-move-up hcms-sr-only" data-hcms-action="move-up" aria-label="Move up">\u2191</button>
46
- <button type="button" class="hcms-move hcms-move-down hcms-sr-only" data-hcms-action="move-down" aria-label="Move down">\u2193</button>
47
- <button type="button" class="hcms-remove" data-hcms-action="remove" aria-label="Remove">x</button>
48
- </header>
49
- <div class="hcms-card-fields"></div>
41
+ <article class="hcms-card mirk-sortable__item" draggable="true">
42
+ ${Cn}
43
+ <div class="hcms-card-body mirk-sortable__body">
44
+ <div class="hcms-card-fields"></div>
45
+ <div class="hcms-card-controls">
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
+ <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">${ft}</button>
49
+ </div>
50
+ </div>
50
51
  <div class="hcms-error" hidden></div>
51
52
  </article>
52
- `},dn=Object.keys(_t);function Re(e){let t=e.head||e.documentElement;if(t)for(let r of dn){if(U(e,r))continue;let n=e.createElement("template");n.setAttribute("data-hcms-tpl",r),n.setAttribute("save-remove",""),n.innerHTML=_t[r].trim(),t.appendChild(n)}}function U(e,t){return!e||!e.querySelector?null:e.querySelector(`template[data-hcms-tpl="${fn(t)}"]`)}function fn(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}function te(e){return typeof e=="string"?e.endsWith("[]")?"scalar-array":"scalar":Array.isArray(e)?"object-array":typeof e=="object"&&e!==null?"object":"scalar"}function ye(e){return e?!!(e.content||e).querySelector("[data-hcms-field]"):!1}var Pt={IMG:"src",A:"href"};function Ce(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":Pt[t]?Pt[t]:null}function Dt(e,t){let r=(e.tagName||"").toUpperCase(),n=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),o=Ce(e),a=`${Bt(r,n)}[data-hcms-field="${re(t)}"]`;return r==="INPUT"&&n==="radio"?`${a}:checked@value`:o?`${a}@${o}`:a}function hn(e){let t=(e.tagName||"").toUpperCase(),r=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),n=Ce(e),s=`${Bt(t,r)}[data-hcms-field]`;return t==="INPUT"&&r==="radio"?`${s}:checked@value`:n?`${s}@${n}`:s}function Bt(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 re(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var Ut=new Set(["__proto__","constructor","prototype"]);function ke(e,t){return r(e,[]);function r(u,d){let p=te(u);if(p==="scalar")return n(u,d);if(p==="scalar-array")return o(d);if(p==="object-array")return s(u,d);if(p==="object"){let y=Object.create(null);for(let[w,E]of Object.entries(u)){if(Ut.has(w))throw new Error(`hypercms: rule key "${w}" is forbidden at "${d.join(".")||"<root>"}"`);y[w]=r(E,[...d,w])}return y}return null}function n(u,d){let p=d.length?d[d.length-1]:null,y=typeof p=="string"?p:"__value",w=c(d,y);if(w)return Dt(w,y);let E=i("@scalar",y);return E?Dt(E,y):`input[data-hcms-field="${re(y)}"]@value`}function o(u){let d=i("@scalar-array-item",null),p=d?hn(d):"input[data-hcms-field]@value";return[a(u,"[data-hcms-array-item]"),p]}function s(u,d){let[,p]=u,y=[...d,"*"],w=a(d,"[data-hcms-card]");if(p&&typeof p=="object"&&!Array.isArray(p)){let E=Object.create(null);for(let[j,b]of Object.entries(p)){if(Ut.has(j))throw new Error(`hypercms: rule key "${j}" is forbidden at "${y.join(".")}"`);E[j]=r(b,[...y,j])}return[w,E]}return[w,r(p,[...y,0])]}function a(u,d){let p=u.length?u[u.length-1]:"",y=u.some(j=>j==="*"),w=u.join(".");return`${y?`[data-hcms-field="${re(p)}"]`:`[data-hcms-path="${re(w)}"]`} > .hcms-array-items > ${d}`}function i(u,d){if(!t)return null;let p=U(t,u);if(!p)return null;let y=p.content||p;if(d){let w=y.querySelector(`[data-hcms-field="${re(d)}"]`);if(w)return w}return y.querySelector("[data-hcms-field]")}function c(u,d){if(!t)return null;let p=u.map(E=>typeof E=="number"?"*":E).join("."),w=[u.join("."),p];for(let E=u.length-1;E>=0;E--){let j=u.slice(0,E).map(b=>typeof b=="number"?"*":b);j.push("*"),w.push(j.join("."))}for(let E of w){if(!E)continue;let j=U(t,E);if(!j||!ye(j))continue;let b=j.content||j,k=b.querySelector(`[data-hcms-field="${re(d)}"]`)||b.querySelector("[data-hcms-field]");if(k)return k}return null}}function Oe({pageRules:e,formRules:t,data:r,doc:n}){let o=n.createDocumentFragment(),s=ot(e,[],r,n);return s&&o.appendChild(s),o}function Vt({shape:e,itemShape:t,pathArr:r,data:n,doc:o}){if(e==="object-array-item")return Kt(t,r,n,o);if(e==="scalar-array-item")return zt(r,n,o);throw new Error(`hypercms: buildItem called with unknown shape "${e}"`)}function ot(e,t,r,n){let o=te(e);return o==="scalar"?mn(t,r,n):o==="object"?pn(e,t,r,n):o==="object-array"?yn(e,t,r,n):o==="scalar-array"?gn(e,t,r,n):null}function mn(e,t,r){let n=je(e,"@scalar",r);if(!n)throw new Error(`hypercms: missing template for scalar at "${e.join(".")}"`);let o=ne(n,r);return oe(o,e),bn(o,W(e)),Ie(o,W(e)),Ne(o,W(e)),Xt(o,t),o}function pn(e,t,r,n){let o=je(t,"@object",n);if(!o)throw new Error(`hypercms: missing template for object at "${t.join(".")}"`);let s=ne(o,n);if(oe(s,t),Ie(s,W(t)),Ne(s,W(t)),ye(o))return er(s,e,t),Qt(s,e,r),s;let a=Le(s,".hcms-object-fields",o,t);for(let[i,c]of Object.entries(e)){let u=r==null?null:r[i],d=ot(c,[...t,i],u,n);d&&a.appendChild(d)}return s}function yn(e,t,r,n){let o=je(t,"@object-array",n);if(!o)throw new Error(`hypercms: missing template for object-array at "${t.join(".")}"`);let s=ne(o,n);oe(s,t),Ie(s,W(t)),Ne(s,W(t)),Yt(s,o),Jt(s,o,t);let a=Le(s,".hcms-array-items",o,t),[,i]=e;return(Array.isArray(r)?r:[]).forEach((u,d)=>{let p=Kt(i,[...t,d],u,n);p&&a.appendChild(p)}),Zt(s),s}function Kt(e,t,r,n){let o=Gt(t,"object-array-item",n);if(!o)throw new Error(`hypercms: missing item template for "${t.join(".")}"`);let s=ne(o,n);if(s.setAttribute("data-hcms-card",""),s.classList.contains("hcms-card")||s.classList.add("hcms-card"),oe(s,t),ye(o))return e&&typeof e=="object"&&!Array.isArray(e)&&(er(s,e,t),Qt(s,e,r)),s;let a=Le(s,".hcms-card-fields",o,t);if(e&&typeof e=="object"&&!Array.isArray(e))for(let[i,c]of Object.entries(e)){let u=r==null?null:r[i],d=ot(c,[...t,i],u,n);d&&a.appendChild(d)}return s}function gn(e,t,r,n){let o=je(t,"@scalar-array",n);if(!o)throw new Error(`hypercms: missing template for scalar-array at "${t.join(".")}"`);let s=ne(o,n);oe(s,t),Ie(s,W(t)),Ne(s,W(t)),Yt(s,o),Jt(s,o,t);let a=Le(s,".hcms-array-items",o,t);return(Array.isArray(r)?r:[]).forEach((c,u)=>{let d=zt([...t,u],c,n);d&&a.appendChild(d)}),Zt(s),s}function zt(e,t,r){let n=Gt(e,"scalar-array-item",r);if(!n)throw new Error(`hypercms: missing item template for "${e.join(".")}"`);let o=ne(n,r);return o.setAttribute("data-hcms-array-item",""),o.classList.contains("hcms-array-item")||o.classList.add("hcms-array-item"),oe(o,e),Xt(o,t),o}function je(e,t,r){let n=e.join("."),o=e.map(s=>typeof s=="number"?"*":s).join(".");return n&&U(r,n)||o&&o!==n&&U(r,o)||U(r,t)}function Gt(e,t,r){let n=e.map(o=>typeof o=="number"?"*":o).join(".");return U(r,n)||U(r,"@"+t)}function ne(e,t){let r=e.content||e,n=t.createElement("div");return n.appendChild(r.cloneNode(!0)),n.firstElementChild||n}function oe(e,t){e.setAttribute("data-hcms-path",t.join("."))}function bn(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(o=>{o.getAttribute("data-hcms-field")||o.setAttribute("data-hcms-field",r)})}function Ie(e,t){t==null||t===""||!e.setAttribute||e.hasAttribute?.("data-hcms-field")||e.setAttribute("data-hcms-field",String(t))}function Ne(e,t){if(t==null||t==="")return;(e.querySelectorAll?e.querySelectorAll("[data-hcms-label]"):[]).forEach(n=>{(n.textContent||"").trim()===""&&(n.textContent=qt(String(t)))})}function Yt(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 Zt(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,o=Wt(e,"data-hcms-max-items"),s=Wt(e,"data-hcms-min-items"),a=e.hasAttribute("data-hcms-no-add"),i=e.hasAttribute("data-hcms-no-remove"),c=e.hasAttribute("data-hcms-no-reorder"),u=e.querySelector('[data-hcms-action="add"]');u&&(u.hidden=a||o!=null&&n>=o),r.forEach((d,p)=>{let y=d.querySelector('[data-hcms-action="remove"]');y&&(y.hidden=i||s!=null&&n<=s);let w=d.querySelector('[data-hcms-action="move-up"]');w&&(w.hidden=c||p===0);let E=d.querySelector('[data-hcms-action="move-down"]');E&&(E.hidden=c||p===n-1)})}function Wt(e,t){if(!e||!e.hasAttribute(t))return null;let r=parseInt(e.getAttribute(t),10);return Number.isFinite(r)?r:null}function Jt(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 o="hcms-"+r.join(".");n.setAttribute("sortable",o),n.setAttribute("onsorted","hypercmsCommit && hypercmsCommit()")}function W(e){return e.length?e[e.length-1]:null}function Xt(e,t){let r=Sn(e);if(r.length!==0)for(let n of r)tr(n,t)}function Sn(e){if(!e)return[];let t=[];return e.matches?.("[data-hcms-field]")&&An(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 An(e){let t=(e.tagName||"").toUpperCase();return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||t==="IMG"||t==="A"||e.hasAttribute?.("contenteditable"))}function Qt(e,t,r){(e.querySelectorAll?e.querySelectorAll("[data-hcms-field]"):[]).forEach(o=>{let s=o.getAttribute("data-hcms-field");if(!s)return;if(!t||typeof t!="object"||!(s in t)){console.warn(`[hypercms] inline template field "${s}" is not in the rule shape; ignoring`);return}let a=r==null?null:r[s];tr(o,a)})}function er(e,t,r){if(!e.querySelectorAll)return;e.querySelectorAll("[data-hcms-field]").forEach(o=>{let s=o.getAttribute("data-hcms-field");if(!s||t&&typeof t=="object"&&!(s in t))return;let a=[...r,s].join(".");o.setAttribute("data-hcms-path",a)})}function Le(e,t,r,n){if(!e.querySelector)return e;let o=e.querySelector(t);if(o)return o;let s=r?.getAttribute?.("data-hcms-tpl")||n.join(".");throw new Error(`hypercms: template "${s}" is in slotted mode but has no ${t} element`)}function tr(e,t){let r=Ce(e),n=(e.tagName||"").toUpperCase(),o=(e.getAttribute("type")||"").toLowerCase();if(n==="INPUT"&&o==="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 rr={skip:"[data-hcms-shell]",templateAttr:"cms-template"};function nr(e,t,r,n={}){let{observerHandle:o,shellRoot:s,structural:a,structuralPath:i}=n;o?.pause?.();try{if(!a)try{return q.apply(e,t,r,rr),{ok:!0}}catch(p){return{ok:!1,error:p}}let c=vn(e,t,i),u=c?En(c):null,d=c?null:Mn(e,s);try{return q.apply(e,t,r,rr),{ok:!0}}catch(p){return u?wn(c,u):d&&Tn(e,s,d),{ok:!1,error:p}}}finally{o?.resume?.()}}function vn(e,t,r){if(!r||!e)return null;let n=V(r),o=[],s=t;for(let a of n){if(typeof s=="string"||s==null||Array.isArray(s))break;if(typeof s=="object"&&a in s){if(o.push(a),s=s[a],Array.isArray(s)||typeof s=="string"&&s.endsWith("[]"))break}else return null}return!Array.isArray(s)&&!(typeof s=="string"&&s.endsWith("[]"))?null:xn(e,t,o)}function xn(e,t,r){if(r.length===0)return null;let n=e,o=t;for(let s=0;s<r.length;s++){let a=r[s];if(!o||typeof o!="object"||Array.isArray(o))return null;let i=o[a];if(i==null)return null;if(s===r.length-1){if(Array.isArray(i)){let[c]=i;return n.querySelector?.(c)?.parentElement||null}if(typeof i=="string"&&i.endsWith("[]")){let c=i.slice(0,-2);return n.querySelector?.(c)?.parentElement||null}return null}o=i}return null}function En(e){let t=[];for(let r of Array.from(e.childNodes))t.push(r.cloneNode(!0));return t}function wn(e,t){for(;e.firstChild;)e.removeChild(e.firstChild);for(let r of t)e.appendChild(r)}function Mn(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 Tn(e,t,r){for(let o of Array.from(e.childNodes))o===t||t&&o.contains?.(t)||e.removeChild(o);let n=Rn(e,t);for(let o of r)e.insertBefore(o,n||null)}function Rn(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 st=new WeakSet;function se(e,t){let r=typeof window<"u"&&window.hyperclay&&window.hyperclay.undo||null;if(!r)return t();r.pause();try{let n=t();return n&&n.ok?r.commitCaptured(e):r.discardCaptured(),n}finally{r.resume()}}function it(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 ir(e){let{formRoot:t}=e;if(!t||st.has(t))return;st.add(t);let r=a=>{let i=a.target;!i||!i.closest||i.closest("[data-hcms-form-root]")&&i.matches("input, textarea, select")&&(!i.closest("[data-hcms-field]")&&!i.hasAttribute?.("data-hcms-field")||or(i,e))},n=a=>{let i=a.target;!i||!i.closest||i.closest("[data-hcms-form-root]")&&i.matches('input[type="checkbox"], input[type="radio"], select')&&or(i,e)},o=a=>{let i=a.target;if(!i||!i.closest)return;let c=i.closest("[data-hcms-action]");if(!c)return;let u=c.getAttribute("data-hcms-action");if(u==="add"||u==="remove"||u==="move-up"||u==="move-down"){if(!c.closest("[data-hcms-form-root]"))return}else if((u==="close"||u==="save")&&!c.closest("[data-hcms-shell]"))return;if(u==="add"){let d=c.closest("[data-hcms-path]");if(!d)return;let p=d.getAttribute("data-hcms-path");at(p,e)}else if(u==="remove"){let d=c.closest("[data-hcms-card], [data-hcms-array-item]");if(!d)return;ct(d,e)}else if(u==="move-up"||u==="move-down"){let d=c.closest("[data-hcms-card], [data-hcms-array-item]");if(!d)return;Cn(d,u==="move-up"?-1:1,e)}else u==="close"?e.onCloseRequested?.():u==="save"&&kn(e)},s=t.ownerDocument;s.addEventListener("input",r,!0),s.addEventListener("change",n,!0),s.addEventListener("click",o,!0),e.detachEvents=()=>{s.removeEventListener("input",r,!0),s.removeEventListener("change",n,!0),s.removeEventListener("click",o,!0),st.delete(t)}}function or(e,t){let n=(e.closest("[data-hcms-field]")||e).closest("[data-hcms-path]")?.getAttribute("data-hcms-path")||"";K(_(t),{path:n,structural:!1},t)}function at(e,t){let{formRoot:r,pageRules:n}=t,o=r.querySelector(`[data-hcms-path="${$n(e)}"]`);if(!o)throw new Error(`hypercms: no element at path "${e}"`);let s=o.querySelector(".hcms-array-items");if(!s)throw new Error(`hypercms: array container missing .hcms-array-items at "${e}"`);let a=V(e),i=Nn(n,a),c=Array.isArray(i),u=typeof i=="string"&&i.endsWith("[]");if(!c&&!u)throw new Error(`hypercms: path "${e}" is not an array`);let d=$e(o,"data-hcms-max-items"),p=s.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]");if(o.hasAttribute("data-hcms-no-add")||d!=null&&p.length>=d)return;let y=p.length,w=c?i[1]:i.replace(/\[\]$/,""),E=pe(c?w:"string"),j=Vt({shape:c?"object-array-item":"scalar-array-item",itemShape:w,pathArr:[...a,y],data:E,doc:t.doc});return s.appendChild(j),ut(o),se(`Add ${e}`,()=>K(_(t),{path:e,structural:!0},t))}function Cn(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 o=n.querySelector(".hcms-array-items");if(!o)return;let s=Array.from(o.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")),a=s.indexOf(e);if(a<0)return;let i=a+t;if(i<0||i>=s.length)return;let c=e.querySelector(`[data-hcms-action="${t<0?"move-up":"move-down"}"]`);return t<0?o.insertBefore(e,s[i]):o.insertBefore(e,s[i].nextSibling),ft(o),ut(n),c&&typeof c.focus=="function"&&e.querySelector(`[data-hcms-action="${t<0?"move-up":"move-down"}"]`)?.focus?.(),se(`Reorder ${n.getAttribute("data-hcms-path")||""}`,()=>K(_(r),{path:n.getAttribute("data-hcms-path")||"",structural:!0},r))}function ct(e,t){let r=e.getAttribute("data-hcms-path")||"",n=e.parentElement,o=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]');if(!o?.hasAttribute("data-hcms-no-remove")){if(o){let s=$e(o,"data-hcms-min-items"),a=o.querySelector(".hcms-array-items"),i=a?a.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]").length:0;if(s!=null&&i<=s)return}return e.remove(),n&&ft(n),o&&ut(o),se(`Remove ${r}`,()=>K(_(t),{path:r,structural:!0},t))}}function kn(e){let t=_(e);e.dispatch?.("hcms:save",{data:t}),e.onSave?.(t)}function K(e,t,r){let n=ht(e);if(n===r.lastFingerprint)return{ok:!0,skipped:!0};let o=nr(r.pageRoot,r.pageRules,e,{observerHandle:r.observerHandle,shellRoot:r.shellRoot,structural:!!t.structural,structuralPath:t.path||null});return o.ok?(r.lastFingerprint=n,r.lastData=e,sr(r,null),r.dispatch?.("hcms:change",{data:e,path:t.path,structural:!!t.structural}),r.onChange?.(e,t)):(sr(r,In(o.error,t.path)),r.dispatch?.("hcms:error",{error:o.error,attemptedData:e}),r.onError?.(o.error)),o}function _(e){let t=q.extract(e.formRoot,e.formRules);return Z(t,e.formRules)}function Z(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=>Z(n,r))}if(typeof t=="object"){if(typeof e!="object"||Array.isArray(e))return e;let r={};for(let[n,o]of Object.entries(t))r[n]=Z(e[n],o);return r}return e}function sr(e,t){e.lastErrors=t&&t.length?t:null,lt(e)}function lt(e){if(On(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 o=jn(e.formRoot,n);if(o){o.textContent=o.textContent?`${o.textContent}
53
- ${r}`:r,o.hidden=!1;continue}}t.push(r)}t.length&&e.errorEl&&(e.errorEl.textContent=t.join(`
54
- `),e.errorEl.hidden=!1)}function On(e){if(e.formRoot)for(let t of e.formRoot.querySelectorAll(".hcms-error"))t.textContent="",t.hidden=!0}function jn(e,t){if(!e)return null;let r=t.split(".");for(;r.length>0;){let n=r.join("."),o=typeof CSS<"u"&&CSS.escape?CSS.escape(n):n.replace(/[^a-zA-Z0-9_\-.*]/g,a=>"\\"+a),s=e.querySelector(`[data-hcms-path="${o}"]`);if(s){for(let a of s.children)if(a.classList&&a.classList.contains("hcms-error"))return a}r.pop()}return null}function In(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 Nn(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 $e(e,t){if(!e||!e.hasAttribute(t))return null;let r=parseInt(e.getAttribute(t),10);return Number.isFinite(r)?r:null}function ut(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,o=$e(e,"data-hcms-max-items"),s=$e(e,"data-hcms-min-items"),a=e.hasAttribute("data-hcms-no-add"),i=e.hasAttribute("data-hcms-no-remove"),c=e.hasAttribute("data-hcms-no-reorder"),u=e.querySelector(':scope > .hcms-add, :scope > * > .hcms-add, :scope > [data-hcms-action="add"]');u&&(u.hidden=a||o!=null&&n>=o),r.forEach((d,p)=>{let y=d.querySelector('[data-hcms-action="remove"]');y&&(y.hidden=i||s!=null&&n<=s);let w=d.querySelector('[data-hcms-action="move-up"]');w&&(w.hidden=c||p===0);let E=d.querySelector('[data-hcms-action="move-down"]');E&&(E.hidden=c||p===n-1)})}function dt(e){!e||!e.querySelectorAll||e.querySelectorAll(".hcms-array-items").forEach(t=>ft(t))}function ft(e){let t=0;for(let r of e.children){if(!r.matches?.("[data-hcms-card], [data-hcms-array-item]"))continue;let n=r.getAttribute("data-hcms-path");if(!n)continue;let o=n.split(".");o[o.length-1]=String(t);let s=o.join(".");s!==n&&Ln(r,n,s),t++}}function Ln(e,t,r){let n=e.querySelectorAll("[data-hcms-path]");e.setAttribute("data-hcms-path",r);for(let o of n){let s=o.getAttribute("data-hcms-path");s===t?o.setAttribute("data-hcms-path",r):s&&s.startsWith(t+".")&&o.setAttribute("data-hcms-path",r+s.slice(t.length))}}function ht(e){return JSON.stringify(e,(t,r)=>{if(r&&typeof r=="object"&&!Array.isArray(r)){let n=Object.create(null);for(let o of Object.keys(r).sort())n[o]=r[o];return n}return r})}function $n(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var Dn={},mt="hcms-shell-styles",Hn="hcms-bundled-styles-installed",Fn='a[href], area[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',ge=new WeakSet,pt="";function ar(e){pt=e}var qn=0;function cr({mountTo:e,side:t="right",overlay:r=!1,showSaveButton:n=!1,doc:o}){_n(o);let s=`hcms-shell-title-${++qn}`,a=o.createElement("div");a.setAttribute("data-hcms-shell",""),a.setAttribute("save-remove",""),a.setAttribute("save-ignore",""),a.setAttribute("tabindex","-1"),a.setAttribute("role","dialog"),a.setAttribute("aria-modal","true"),a.setAttribute("aria-labelledby",s),a.className="hcms-shell hcms-side-"+t+(r?" hcms-overlay":""),a.innerHTML=`
55
- <header class="hcms-shell-header">
56
- <h2 class="hcms-shell-title" id="${s}">Edit</h2>
57
- <button type="button" class="hcms-shell-close" data-hcms-action="close" aria-label="Close">\xD7</button>
58
- </header>
59
- <div class="hcms-shell-error" role="alert" hidden></div>
60
- <div data-hcms-form-root class="hcms-form"></div>
61
- <footer class="hcms-shell-footer"${n?"":" hidden"}>
62
- <button type="button" class="hcms-shell-save" data-hcms-action="save">Save</button>
63
- </footer>
64
- `,(e||o.body).appendChild(a);let c=o.body;c.classList.add("hcms-open"),r&&c.classList.add("hcms-overlay"),t==="left"&&c.classList.add("hcms-side-left");let u=Pn(a,o);return{root:a,formRoot:a.querySelector("[data-hcms-form-root]"),errorEl:a.querySelector(".hcms-shell-error"),saveButton:a.querySelector(".hcms-shell-save"),destroy(){u.detach(),a.remove(),c.classList.remove("hcms-open","hcms-overlay","hcms-side-left")}}}function _n(e){if(e&&!ge.has(e)){if(e[Hn]){ge.add(e);return}if(e.getElementById(mt)||e.querySelector("style[data-hcms-bundled-styles]")){ge.add(e);return}if(pt){let t=e.createElement("style");t.id=mt,t.setAttribute("save-remove",""),t.textContent=pt,(e.head||e.documentElement).appendChild(t),ge.add(e);return}try{let t=new URL("./styles.css",Dn.url).href,r=e.createElement("link");r.rel="stylesheet",r.id=mt,r.setAttribute("save-remove",""),r.href=t,(e.head||e.documentElement).appendChild(r),ge.add(e)}catch{}}}function Pn(e,t){function r(n){if(n.key!=="Tab"||!e.contains(t.activeElement))return;let o=Array.from(e.querySelectorAll(Fn));if(o.length===0)return;let s=o[0],a=o[o.length-1];n.shiftKey&&t.activeElement===s?(n.preventDefault(),a.focus()):!n.shiftKey&&t.activeElement===a&&(n.preventDefault(),s.focus())}return t.addEventListener("keydown",r),{detach:()=>t.removeEventListener("keydown",r)}}var Un={skip:"[data-hcms-shell]",templateAttr:"cms-template"};function yt(e){let t=q.findRules(e.doc,e.rulesSource||"cms");t&&(e.pageRules=t.rules,e.rulesTagNode=t.tagNode),Re(e.doc),e.formRules=ke(e.pageRules,e.doc);let r=Z(q.extract(e.pageRoot,e.pageRules,Un),e.pageRules),n=Oe({pageRules:e.pageRules,formRules:e.formRules,data:r,doc:e.doc});Te(e.formRoot,n),lt(e),e.updateFingerprint&&e.updateFingerprint()}function lr({debounce:e=100,onRefresh:t}){let r=typeof window<"u"&&window.hyperclay&&window.hyperclay.Mutation||null;if(!r||typeof r.onAnyChange!="function")throw new Error("hypercms: window.hyperclay.Mutation is required. Load hyperclayjs (or just the mutation utility) before initializing hypercms.");let n=0,o=r.onAnyChange({debounce:e},()=>{n>0||t()});return{unsubscribe:typeof o=="function"?o:()=>{},pause(){n++},resume(){n=Math.max(0,n-1)}}}var Bn="[hypercms]";function ur(e,t){if(!e||!e.querySelectorAll||!t)return;let r=Wn(t);e.querySelectorAll("template[data-hcms-tpl]").forEach(o=>{let s=o.getAttribute("data-hcms-tpl");s&&(s.startsWith("@")||r.has(s)||console.warn(`${Bn} template "${s}" doesn't match any rule path; ignored`))})}function Wn(e){let t=new Set;return r([],e),t;function r(n,o){let s=n.join("."),a=n.map(c=>typeof c=="number"?"*":c).join(".");s&&t.add(s),a&&t.add(a);let i=te(o);if(i==="object")for(let[c,u]of Object.entries(o))r([...n,c],u);else if(i==="object-array"||i==="scalar-array"){let c=[...n,"*"],u=c.map(d=>typeof d=="number"?"*":d).join(".");if(t.add(u),i==="object-array"){let d=o[1];if(d&&typeof d=="object"&&!Array.isArray(d))for(let[p,y]of Object.entries(d))r([...c,p],y)}}}}function dr(e){ar(e)}var I={isOpen:!1,ctx:null,shell:null,opts:null};function Vn(e={}){if(I.isOpen){console.warn("cms.open() called while already open; ignoring");return}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",o=q.findRules(r,n);if(!o){let y=typeof n=="string"?`data-rules-name~="${n}"`:"the provided rules object";throw new Error(`hypercms: no rules found for ${y}`)}let s=o.rules,a=o.tagNode;Re(r),ur(r,s);let i=ke(s,r),c=Z(q.extract(t,s,{skip:"[data-hcms-shell]",templateAttr:"cms-template"}),s),u=it(()=>cr({mountTo:e.mountTo||r.body,side:e.side||"right",overlay:!!e.overlay,showSaveButton:!!e.showSaveButton,doc:r})),d={doc:r,pageRoot:t,pageRules:s,formRules:i,rulesTagNode:a,rulesSource:n,formRoot:u.formRoot,shellRoot:u.root,errorEl:u.errorEl,lastFingerprint:null,lastData:null,observerHandle:null,onChange:e.onChange,onError:e.onError,onSave:e.onSave,previouslyFocused:r.activeElement,dispatch(y,w){let E=r.defaultView&&r.defaultView.CustomEvent||(typeof CustomEvent<"u"?CustomEvent:null);if(!E)return;let j=new E(y,{bubbles:!0,cancelable:y==="hcms:change"||y==="hcms:save",detail:w});u.root.dispatchEvent(j)},onCloseRequested(){fr()}};d.updateFingerprint=()=>{d.lastFingerprint=ht(_(d))};let p=Oe({pageRules:s,formRules:i,data:c,doc:r});u.formRoot.appendChild(p),ir(d),d.updateFingerprint(),d.observerHandle=lr({onRefresh:()=>yt(d)}),gt.ctx=d,zn(r),Kn(u.root),I.isOpen=!0,I.ctx=d,I.shell=u,I.opts=e,d.dispatch("hcms:open",{pageRoot:t})}function Kn(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 gt={ctx:null};function zn(e){let t=e.defaultView||(typeof globalThis<"u"?globalThis:null);if(!t)return;let r=function(){let o=gt.ctx;if(o)return dt(o.formRoot),se("Reorder",()=>K(_(o),{path:"",structural:!0},o))};typeof t.hypercmsCommit!="function"&&(t.hypercmsCommit=r),typeof globalThis<"u"&&typeof globalThis.hypercmsCommit!="function"&&(globalThis.hypercmsCommit=r)}function fr(){if(!I.isOpen)return;let{ctx:e,shell:t}=I,r=e.previouslyFocused;if(e.dispatch("hcms:close",null),e.observerHandle?.unsubscribe?.(),e.detachEvents?.(),it(()=>t.destroy()),I.isOpen=!1,I.ctx=null,I.shell=null,I.opts=null,gt.ctx=null,r&&typeof r.focus=="function")try{r.focus()}catch{}}function hr(){I.isOpen&&yt(I.ctx)}var Gn={getData(){return I.isOpen?_(I.ctx):null},setValue(e,t){if(!I.isOpen)throw new Error("hypercms: cms is not open");let r=I.ctx,n=V(e),o=me(r.pageRules,n);if(o===void 0)throw new Error(`hypercms: no rule at path "${e}"`);if(typeof o!="string"||o.endsWith("[]"))throw new Error(`hypercms: setValue requires a leaf scalar path; "${e}" is not a leaf`);let s=Yn(r.formRoot,e);if(!s)throw new Error(`hypercms: no field element at path "${e}"`);Zn(s,t,r.formRoot,e),K(_(r),{path:e,structural:!1},r)},addItem(e){if(!I.isOpen)throw new Error("hypercms: cms is not open");at(e,I.ctx)},removeItem(e){if(!I.isOpen)throw new Error("hypercms: cms is not open");let t=I.ctx,r=V(e);if(typeof r[r.length-1]!="number")throw new Error(`hypercms: removeItem requires an item path; "${e}" is not an array index`);let o=me(t.pageRules,r.slice(0,-1));if(!(Array.isArray(o)||typeof o=="string"&&o.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="${St(e)}"]`);if(!a)throw new Error(`hypercms: no element at path "${e}"`);ct(a,t)},refresh:hr,_commit(){if(!I.isOpen)return;let e=I.ctx;return dt(e.formRoot),se("Update",()=>K(_(e),{path:"",structural:!0},e))}};function Yn(e,t){let r=St(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 Zn(e,t,r,n){let o=(e.tagName||"").toUpperCase(),s=(e.getAttribute("type")||"").toLowerCase();if(o==="INPUT"&&s==="checkbox"){e.checked=t===!0||t==="true";return}if(o==="INPUT"&&s==="radio"){let a=St(n),i=r.querySelectorAll(`[data-hcms-path="${a}"][data-hcms-field][type="radio"], [data-hcms-path="${a}"] [data-hcms-field][type="radio"]`);i.length?i.forEach(c=>{c.checked=String(c.value)===String(t??"")}):e.checked=String(e.value)===String(t??"");return}if(o==="IMG"){e.src=t==null?"":String(t);return}if(o==="A"){e.href=t==null?"":String(t);return}if("value"in e){e.value=t==null?"":String(t);return}e.textContent=t==null?"":String(t)}var bt={open:Vn,close:fr,refresh:hr,api:Gn,get isOpen(){return I.isOpen},path:nt,scaffold:pe,morphForm:Te};function St(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var mr=`.hcms-shell {
65
- --hcms-primary: #2563eb;
66
- --hcms-bg: #F6F7F9;
67
- --hcms-text: #0f172a;
68
- --hcms-muted: #64748b;
69
- --hcms-border: #e2e8f0;
70
- --hcms-error: #b91c1c;
71
- --hcms-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
72
- font-family: var(--hcms-font-family);
73
- font-size: 14px;
74
- line-height: 1.45;
75
- color: var(--hcms-text);
76
- background: var(--hcms-bg);
53
+ `,"@file":`
54
+ <div class="hcms-field hcms-upload hcms-upload--file" data-hcms-shape="scalar">
55
+ <span class="hcms-label" data-hcms-label></span>
56
+ <div class="mirk-file mirk-file--compact mirk-file--round">
57
+ <label class="mirk-button mirk-button--round mirk-button--small">
58
+ <input type="file" data-hcms-upload />
59
+ <span class="mirk-button__label">Choose</span>
60
+ </label>
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">${ft}</button>
63
+ </div>
64
+ <div class="hcms-error" hidden></div>
65
+ </div>
66
+ `,"@image":`
67
+ <div class="hcms-field hcms-upload hcms-upload--image" data-hcms-shape="scalar">
68
+ <span class="hcms-label" data-hcms-label></span>
69
+ <div class="mirk-image mirk-image--compact mirk-image--rounded">
70
+ <label class="mirk-button mirk-button--small mirk-image__upload">
71
+ <input type="file" accept="image/*" data-hcms-upload />
72
+ <span class="mirk-button__label">Upload image</span>
73
+ </label>
74
+ <figure class="mirk-image__thumb">
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">${ft}</button>
77
+ </figure>
78
+ </div>
79
+ <div class="hcms-error" hidden></div>
80
+ </div>
81
+ `},Rn=["@scalar","@object","@scalar-array","@scalar-array-item","@object-array","@object-array-item"];function Le(e){let t=e.head||e.documentElement;if(t)for(let r of Rn)Jt(e,t,r)}function Tn(e,t){if(!Yt[t])return null;let r=e&&(e.head||e.documentElement);return r?Jt(e,r,t):null}var Kt={src:"@image"},On=new Set(["@image","@file"]);function ke(e,t){if(typeof e!="string")return"@scalar";let r=e.lastIndexOf("@");if(r>=0){let i=e.slice(r+1);if(Kt[i])return Kt[i]}let n=Ln(e,r,t);return n==="image"?"@image":n==="file"?"@file":"@scalar"}function Ln(e,t,r){if(!r||!r.querySelector)return null;let n=t>=0?e.slice(0,t):e;if(!n||n===".")return null;let i=null;try{i=r.querySelector(n)}catch{return null}return i&&i.getAttribute?i.getAttribute("data-hcms-component"):null}function je(e,t){if(!e||t==null)return;r(t);function r(n){let i=Z(n);if(i==="scalar"){let o=ke(n,e);On.has(o)&&Tn(e,o);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 Jt(e,t,r){let n=U(e,r);if(n)return n;let i=e.createElement("template");return i.setAttribute("data-hcms-tpl",r),i.setAttribute("save-remove",""),i.innerHTML=Yt[r].trim(),t.appendChild(i),i}function U(e,t){return!e||!e.querySelector?null:e.querySelector(`template[data-hcms-tpl="${jn(t)}"]`)}function jn(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 ve(e){return e?!!(e.content||e).querySelector("[data-hcms-field]"):!1}var Xt={IMG:"src",A:"href"};function Ne(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":Xt[t]?Xt[t]:null}function Zt(e,t){let r=(e.tagName||"").toUpperCase(),n=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),i=Ne(e),a=`${er(r,n)}[data-hcms-field="${ie(t)}"]`;return r==="INPUT"&&n==="radio"?`${a}:checked@value`:i?`${a}@${i}`:a}function Nn(e){let t=(e.tagName||"").toUpperCase(),r=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),n=Ne(e),o=`${er(t,r)}[data-hcms-field]`;return t==="INPUT"&&r==="radio"?`${o}:checked@value`:n?`${o}@${n}`:o}function er(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 ie(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var Qt=new Set(["__proto__","constructor","prototype"]);function Ie(e,t){return r(e,[]);function r(u,c){let f=Z(u);if(f==="scalar")return n(u,c);if(f==="scalar-array")return i(c);if(f==="object-array")return o(u,c);if(f==="object"){let b=Object.create(null);for(let[w,v]of Object.entries(u)){if(Qt.has(w))throw new Error(`hypercms: rule key "${w}" is forbidden at "${c.join(".")||"<root>"}"`);b[w]=r(v,[...c,w])}return b}return null}function n(u,c){let f=c.length?c[c.length-1]:null,b=typeof f=="string"?f:"__value",w=l(c,b);if(w)return Zt(w,b);let v=s(ke(u,t),b);return v?Zt(v,b):`input[data-hcms-field="${ie(b)}"]@value`}function i(u){let c=s("@scalar-array-item",null),f=c?Nn(c):"input[data-hcms-field]@value";return[a(u,"[data-hcms-array-item]"),f]}function o(u,c){let[,f]=u,b=[...c,"*"],w=a(c,"[data-hcms-card]");if(f&&typeof f=="object"&&!Array.isArray(f)){let v=Object.create(null);for(let[T,y]of Object.entries(f)){if(Qt.has(T))throw new Error(`hypercms: rule key "${T}" is forbidden at "${b.join(".")}"`);v[T]=r(y,[...b,T])}return[w,v]}return[w,r(f,[...b,0])]}function a(u,c){let f=u.length?u[u.length-1]:"",b=u.some(T=>T==="*"),w=u.join(".");return`${b?`[data-hcms-field="${ie(f)}"]`:`[data-hcms-path="${ie(w)}"]`} > .hcms-array-items > ${c}`}function s(u,c){if(!t)return null;let f=U(t,u);if(!f)return null;let b=f.content||f;if(c){let w=b.querySelector(`[data-hcms-field="${ie(c)}"]`);if(w)return w}return b.querySelector("[data-hcms-field]")}function l(u,c){if(!t)return null;let f=u.map(v=>typeof v=="number"?"*":v).join("."),w=[u.join("."),f];for(let v=u.length-1;v>=0;v--){let T=u.slice(0,v).map(y=>typeof y=="number"?"*":y);T.push("*"),w.push(T.join("."))}for(let v of w){if(!v)continue;let T=U(t,v);if(!T||!ve(T))continue;let y=T.content||T,R=y.querySelector(`[data-hcms-field="${ie(c)}"]`)||y.querySelector("[data-hcms-field]");if(R)return R}return null}}function pt(e){if(!e)return"";let t=String(e).split(/[?#]/)[0],r=t.split("/").pop()||t;try{return decodeURIComponent(r)}catch{return r}}function Fe({pageRules:e,formRules:t,data:r,doc:n}){let i=n.createDocumentFragment(),o=bt(e,[],r,n);return o&&i.appendChild(o),i}function rr({shape:e,itemShape:t,pathArr:r,data:n,doc:i}){if(e==="object-array-item")return nr(t,r,n,i);if(e==="scalar-array-item")return ir(r,n,i);throw new Error(`hypercms: buildItem called with unknown shape "${e}"`)}function bt(e,t,r,n){let i=Z(e);return i==="scalar"?In(e,t,r,n):i==="object"?qn(e,t,r,n):i==="object-array"?$n(e,t,r,n):i==="scalar-array"?Dn(e,t,r,n):null}function In(e,t,r,n){let i=ke(e,n),o=qe(t,i,n);if(!o)throw new Error(`hypercms: missing template for scalar at "${t.join(".")}"`);let a=oe(o,n);return se(a,t),Pn(a,V(t)),$e(a,V(t)),De(a,V(t)),cr(a,r),i==="@file"&&Fn(a),a}function Fn(e){let t=e.querySelector?e.querySelector("a.mirk-file__name[data-hcms-field]"):null;t&&(t.textContent=pt(t.getAttribute("href")))}function qn(e,t,r,n){let i=qe(t,"@object",n);if(!i)throw new Error(`hypercms: missing template for object at "${t.join(".")}"`);let o=oe(i,n);if(se(o,t),$e(o,V(t)),De(o,V(t)),ve(i))return dr(o,e,t),ur(o,e,r),o;let a=Pe(o,".hcms-object-fields",i,t);for(let[s,l]of Object.entries(e)){let u=r==null?null:r[s],c=bt(l,[...t,s],u,n);c&&a.appendChild(c)}return o}function $n(e,t,r,n){let i=qe(t,"@object-array",n);if(!i)throw new Error(`hypercms: missing template for object-array at "${t.join(".")}"`);let o=oe(i,n);se(o,t),$e(o,V(t)),De(o,V(t)),sr(o,i),lr(o,i,t);let a=Pe(o,".hcms-array-items",i,t),[,s]=e;return(Array.isArray(r)?r:[]).forEach((u,c)=>{let f=nr(s,[...t,c],u,n);f&&a.appendChild(f)}),ar(o),o}function nr(e,t,r,n){let i=or(t,"object-array-item",n);if(!i)throw new Error(`hypercms: missing item template for "${t.join(".")}"`);let o=oe(i,n);if(o.setAttribute("data-hcms-card",""),o.classList.contains("hcms-card")||o.classList.add("hcms-card"),se(o,t),ve(i))return e&&typeof e=="object"&&!Array.isArray(e)&&(dr(o,e,t),ur(o,e,r)),o;let a=Pe(o,".hcms-card-fields",i,t);if(e&&typeof e=="object"&&!Array.isArray(e))for(let[s,l]of Object.entries(e)){let u=r==null?null:r[s],c=bt(l,[...t,s],u,n);c&&a.appendChild(c)}return o}function Dn(e,t,r,n){let i=qe(t,"@scalar-array",n);if(!i)throw new Error(`hypercms: missing template for scalar-array at "${t.join(".")}"`);let o=oe(i,n);se(o,t),$e(o,V(t)),De(o,V(t)),sr(o,i),lr(o,i,t);let a=Pe(o,".hcms-array-items",i,t);return(Array.isArray(r)?r:[]).forEach((l,u)=>{let c=ir([...t,u],l,n);c&&a.appendChild(c)}),ar(o),o}function ir(e,t,r){let n=or(e,"scalar-array-item",r);if(!n)throw new Error(`hypercms: missing item template for "${e.join(".")}"`);let i=oe(n,r);return i.setAttribute("data-hcms-array-item",""),i.classList.contains("hcms-array-item")||i.classList.add("hcms-array-item"),se(i,e),cr(i,t),i}function qe(e,t,r){let n=e.join("."),i=e.map(o=>typeof o=="number"?"*":o).join(".");return n&&U(r,n)||i&&i!==n&&U(r,i)||U(r,t)}function or(e,t,r){let n=e.map(i=>typeof i=="number"?"*":i).join(".");return U(r,n)||U(r,"@"+t)}function oe(e,t){let r=e.content||e,n=t.createElement("div");return n.appendChild(r.cloneNode(!0)),n.firstElementChild||n}function se(e,t){e.setAttribute("data-hcms-path",t.join("."))}function Pn(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 $e(e,t){t==null||t===""||!e.setAttribute||e.hasAttribute?.("data-hcms-field")||e.setAttribute("data-hcms-field",String(t))}function De(e,t){if(t==null||t==="")return;(e.querySelectorAll?e.querySelectorAll("[data-hcms-label]"):[]).forEach(n=>{(n.textContent||"").trim()===""&&(n.textContent=Gt(String(t)))})}function sr(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]")),n=r.length,i=tr(e,"data-hcms-max-items"),o=tr(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"),u=e.querySelector('[data-hcms-action="add"]');u&&(u.hidden=a||i!=null&&n>=i),r.forEach((c,f)=>{let b=c.querySelector('[data-hcms-action="remove"]');b&&(b.hidden=s||o!=null&&n<=o);let w=c.querySelector('[data-hcms-action="move-up"]');w&&(w.hidden=l||f===0);let v=c.querySelector('[data-hcms-action="move-down"]');v&&(v.hidden=l||f===n-1)})}function tr(e,t){if(!e||!e.hasAttribute(t))return null;let r=parseInt(e.getAttribute(t),10);return Number.isFinite(r)?r:null}function lr(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 V(e){return e.length?e[e.length-1]:null}function cr(e,t){let r=Hn(e);if(r.length!==0)for(let n of r)mr(n,t)}function Hn(e){if(!e)return[];let t=[];return e.matches?.("[data-hcms-field]")&&Un(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 Un(e){let t=(e.tagName||"").toUpperCase();return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||t==="IMG"||t==="A"||e.hasAttribute?.("contenteditable"))}function ur(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];mr(i,a)})}function dr(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 Pe(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 mr(e,t){let r=Ne(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 hr={skip:"[data-hcms-shell]",templateAttr:"cms-template"};function fr(e,t,r,n={}){let{observerHandle:i,shellRoot:o,structural:a,structuralPath:s}=n;i?.pause?.();try{if(!a)try{return q.apply(e,t,r,hr),{ok:!0}}catch(f){return{ok:!1,error:f}}let l=Bn(e,t,s),u=l?Wn(l):null,c=l?null:Kn(e,o);try{return q.apply(e,t,r,hr),{ok:!0}}catch(f){return u?Vn(l,u):c&&Gn(e,o,c),{ok:!1,error:f}}}finally{i?.resume?.()}}function Bn(e,t,r){if(!r||!e)return null;let n=W(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:zn(e,t,i)}function zn(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 Wn(e){let t=[];for(let r of Array.from(e.childNodes))t.push(r.cloneNode(!0));return t}function Vn(e,t){for(;e.firstChild;)e.removeChild(e.firstChild);for(let r of t)e.appendChild(r)}function Kn(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 Gn(e,t,r){for(let i of Array.from(e.childNodes))i===t||t&&i.contains?.(t)||e.removeChild(i);let n=Yn(e,t);for(let i of r)e.insertBefore(i,n||null)}function Yn(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 gt=new WeakSet;function le(e,t){let r=typeof window<"u"&&window.hyperclay&&window.hyperclay.undo||null;if(!r)return t();r.pause();try{let n=t();return n&&n.ok?r.commitCaptured(e):r.discardCaptured(),n}finally{r.resume()}}function Be(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 gr(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")&&(s.matches('input[type="file"]')||!s.closest("[data-hcms-field]")&&!s.hasAttribute?.("data-hcms-field")||pr(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]')){Qn(s,e);return}s.matches('input[type="checkbox"], input[type="radio"], select')&&pr(s,e)}},i=a=>{let s=a.target;if(!s||!s.closest)return;let l=s.closest("[data-hcms-action]");if(!l)return;let u=l.getAttribute("data-hcms-action");if(u==="add"||u==="remove"||u==="move-up"||u==="move-down"||u==="clear-upload"){if(!l.closest("[data-hcms-form-root]"))return}else if(u==="close"&&!l.closest("[data-hcms-shell]"))return;if(u==="add"){let c=l.closest("[data-hcms-path]");if(!c)return;let f=c.getAttribute("data-hcms-path");kt(f,e)}else if(u==="remove"){let c=l.closest("[data-hcms-card], [data-hcms-array-item]");if(!c)return;oi(c,e)}else if(u==="move-up"||u==="move-down"){let c=l.closest("[data-hcms-card], [data-hcms-array-item]");if(!c)return;ni(c,u==="move-up"?-1:1,e)}else u==="clear-upload"?ei(l,e):u==="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 Jn=new Set(["value","checked"]);function Xn(e,t){if(!t)return null;let r=W(t);if(r.some(l=>typeof l=="number"||l==="*"))return null;let n=X(e.pageRules,r);if(typeof n!="string")return null;let i=n.lastIndexOf("@");if(i===-1)return null;let o=n.slice(i+1);if(!Jn.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 pr(e,t){let n=(e.closest("[data-hcms-field]")||e).closest("[data-hcms-path]")?.getAttribute("data-hcms-path")||"",i=Xn(t,n);if(B($(t),{path:n,structural:!1},t),i){let o=typeof window<"u"&&window.hyperclay&&window.hyperclay.undo||null;o&&typeof o.recordValue=="function"&&o.recordValue(i.el,{prop:i.prop,oldValue:i.oldValue,newValue:i.el[i.prop]})}}async function Zn(e){return{file:e}}async function Qn(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")||"",o=await Zn(r,n);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,u=null;if(typeof l=="function")try{let c=await l(a);u=c&&c.uploads&&c.uploads[0]&&c.uploads[0].url}catch(c){if(t.closed){Q(e);return}yt(n,c&&c.message||"Upload failed"),t.dispatch?.("hcms:error",{error:c,path:i}),Q(e);return}if(t.closed){Q(e);return}if(u||(u=s||ri(a)),!u){Q(e);return}yt(n,null),yr(n,u,a.name),B($(t),{path:i,structural:!1},t),Q(e)}function ei(e,t){let r=e.closest("[data-hcms-path]");if(!r)return;let n=r.getAttribute("data-hcms-path")||"";yr(r,"","");let i=r.querySelector('input[type="file"][data-hcms-upload]');i&&Q(i),yt(r,null),B($(t),{path:n,structural:!1},t)}function ti(e){return e.querySelector?e.querySelector("img[data-hcms-field], a[data-hcms-field]"):null}function yr(e,t,r){let n=ti(e);if(!n)return;let i=(n.tagName||"").toUpperCase();i==="IMG"?n.src=t||"":i==="A"&&(n.href=t||"",n.textContent=t?r||pt(t):"")}function Q(e){try{e.value=""}catch{}}function ri(e){let t=typeof URL<"u"&&URL.createObjectURL?URL:null;if(!t)return"";try{return t.createObjectURL(e)}catch{return""}}function yt(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 kt(e,t){let{formRoot:r,pageRules:n}=t,i=r.querySelector(`[data-hcms-path="${di(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=W(e),s=ci(n,a),l=Array.isArray(s),u=typeof s=="string"&&s.endsWith("[]");if(!l&&!u)throw new Error(`hypercms: path "${e}" is not an array`);let c=Ue(i,"data-hcms-max-items"),f=o.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]");if(i.hasAttribute("data-hcms-no-add")||c!=null&&f.length>=c)return;let b=f.length,w=l?s[1]:s.replace(/\[\]$/,""),v=ye(l?w:"string"),T=rr({shape:l?"object-array-item":"scalar-array-item",itemShape:w,pathArr:[...a,b],data:v,doc:t.doc});return o.appendChild(T),xt(i),le(`Add ${e}`,()=>B($(t),{path:e,structural:!0},t))}function ni(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),At(i),xt(n),l&&typeof l.focus=="function"&&e.querySelector(`[data-hcms-action="${t<0?"move-up":"move-down"}"]`)?.focus?.(),le(`Reorder ${n.getAttribute("data-hcms-path")||""}`,()=>B($(r),{path:n.getAttribute("data-hcms-path")||"",structural:!0},r))}var He="Delete this item?";function ii(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||He;let n=t&&t.confirmRemove;return n===!1?null:typeof n=="string"?n||He:n===!0||e&&e.getAttribute("data-hcms-shape")==="object-array"?He:null}function oi(e,t){let r=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]'),n=ii(r,t);if(n==null)return ae(e,t);let i=typeof window<"u"&&(window.hyperclay?.consent||window.consent);typeof i=="function"?Promise.resolve(i(n)).then(()=>ae(e,t),()=>{}):typeof window<"u"&&typeof window.confirm=="function"?window.confirm(n)&&ae(e,t):ae(e,t)}function ae(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=Ue(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&&At(n),i&&xt(i),le(`Remove ${r}`,()=>B($(t),{path:r,structural:!0},t))}}function B(e,t,r){let n=xe(e);if(n===r.lastFingerprint)return{ok:!0,skipped:!0};let i=fr(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,br(r,null),r.dispatch?.("hcms:change",{data:e,path:t.path,structural:!!t.structural}),r.onChange?.(e,t)):(br(r,li(i.error,t.path)),r.dispatch?.("hcms:error",{error:i.error,attemptedData:e}),r.onError?.(i.error)),i}function $(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(n=>K(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]=K(e[n],i);return r}return e}function br(e,t){e.lastErrors=t&&t.length?t:null,vt(e)}function vt(e){if(si(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=ai(e.formRoot,n);if(i){i.textContent=i.textContent?`${i.textContent}
82
+ ${r}`:r,i.hidden=!1;continue}}t.push(r)}t.length&&e.errorEl&&(e.errorEl.textContent=t.join(`
83
+ `),e.errorEl.hidden=!1)}function si(e){if(e.formRoot)for(let t of e.formRoot.querySelectorAll(".hcms-error"))t.textContent="",t.hidden=!0}function ai(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 li(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 ci(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 Ue(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=Ue(e,"data-hcms-max-items"),o=Ue(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"),u=e.querySelector(':scope > .hcms-add, :scope > * > .hcms-add, :scope > [data-hcms-action="add"]');u&&(u.hidden=a||i!=null&&n>=i),r.forEach((c,f)=>{let b=c.querySelector('[data-hcms-action="remove"]');b&&(b.hidden=s||o!=null&&n<=o);let w=c.querySelector('[data-hcms-action="move-up"]');w&&(w.hidden=l||f===0);let v=c.querySelector('[data-hcms-action="move-down"]');v&&(v.hidden=l||f===n-1)})}function wt(e){!e||!e.querySelectorAll||e.querySelectorAll(".hcms-array-items").forEach(t=>At(t))}function At(e){let t=0;for(let r of e.children){if(!r.matches?.("[data-hcms-card], [data-hcms-array-item]"))continue;let n=r.getAttribute("data-hcms-path");if(!n)continue;let i=n.split(".");i[i.length-1]=String(t);let o=i.join(".");o!==n&&ui(r,n,o),t++}}function ui(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))}}function xe(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 di(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var yi={},ze="hcms-shell-styles",mi="hcms-bundled-styles-installed",hi='a[href], area[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',ce=new WeakSet,St="";function vr(e){St=e}var fi=0;function kr(e){return String(e).replace(/[&<>"]/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[t])}function xr({mountTo:e,side:t="right",overlay:r=!1,showSaveButton:n=!1,title:i="Page content",eyebrow:o="Edit",theme:a=null,doc:s}){wr(s);let l=`hcms-shell-title-${++fi}`,u=s.createElement("div");u.setAttribute("data-hcms-shell",""),u.setAttribute("save-remove",""),u.setAttribute("save-ignore",""),u.setAttribute("tabindex","-1"),u.setAttribute("role","dialog"),u.setAttribute("aria-modal","true"),u.setAttribute("aria-labelledby",l);let c=a==="dark"?" dark":a==="light"?" light":"";u.className="hcms-shell pixel-quiet hcms-side-"+t+(r?" hcms-overlay":"")+c;let f=kr(i),b=kr(o);u.innerHTML=`
84
+ <div class="hcms-shell-minibar" aria-hidden="true">
85
+ <span class="hcms-shell-minibar-title">${f}</span>
86
+ <button type="button" class="hcms-shell-close mirk-button mirk-button--small" data-hcms-action="close" aria-label="Close">
87
+ <span class="mirk-button__label">\xD7</span>
88
+ </button>
89
+ </div>
90
+ <div class="hcms-shell-body">
91
+ <header class="hcms-shell-header">
92
+ <div class="hcms-shell-heading">
93
+ <div class="hcms-shell-eyebrow">${b}</div>
94
+ <h2 class="hcms-shell-title" id="${l}">${f}</h2>
95
+ </div>
96
+ <button type="button" class="hcms-shell-close mirk-button mirk-button--small" data-hcms-action="close" aria-label="Close">
97
+ <span class="mirk-button__label">\xD7</span>
98
+ </button>
99
+ </header>
100
+ <div class="hcms-shell-error" role="alert" hidden></div>
101
+ <div data-hcms-form-root class="hcms-form"></div>
102
+ <footer class="hcms-shell-footer"${n?"":" hidden"}>
103
+ <button type="button" class="hcms-shell-save mirk-button" trigger-save>
104
+ <span class="mirk-button__label">Save</span>
105
+ </button>
106
+ </footer>
107
+ </div>
108
+ `,(e||s.body).appendChild(u);let v=s.body;v.classList.add("hcms-open"),r&&v.classList.add("hcms-overlay"),t==="left"&&v.classList.add("hcms-side-left");let T=gi(u,s),y=bi(u);return{root:u,formRoot:u.querySelector("[data-hcms-form-root]"),errorEl:u.querySelector(".hcms-shell-error"),saveButton:u.querySelector(".hcms-shell-save"),destroy(){T.detach(),y.detach(),u.remove(),v.classList.remove("hcms-open","hcms-overlay","hcms-side-left")},restoreChrome(){pi(s),v.classList.add("hcms-open"),r&&v.classList.add("hcms-overlay"),t==="left"&&v.classList.add("hcms-side-left")}}}function pi(e){e&&(e.getElementById(ze)||e.querySelector("style[data-hcms-bundled-styles]")||(ce.delete(e),wr(e)))}function wr(e){if(e&&!ce.has(e)){if(e[mi]){ce.add(e);return}if(e.getElementById(ze)||e.querySelector("style[data-hcms-bundled-styles]")){ce.add(e);return}if(St){let t=e.createElement("style");t.id=ze,t.setAttribute("save-remove",""),t.textContent=St,(e.head||e.documentElement).appendChild(t),ce.add(e);return}try{let t=new URL("./theme.generated.css",yi.url).href,r=e.createElement("link");r.rel="stylesheet",r.id=ze,r.setAttribute("save-remove",""),r.href=t,(e.head||e.documentElement).appendChild(r),ce.add(e)}catch{}}}function bi(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 gi(e,t){function r(n){if(n.key!=="Tab"||!e.contains(t.activeElement))return;let i=Array.from(e.querySelectorAll(hi));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 ki={skip:"[data-hcms-shell]",templateAttr:"cms-template"};function We(e,{ignoreActiveValue:t}={}){let r=q.findRules(e.doc,e.rulesSource||"cms");r&&(e.pageRules=r.rules,e.rulesTagNode=r.tagNode),Le(e.doc),je(e.doc,e.pageRules),e.formRules=Ie(e.pageRules,e.doc);let n=K(q.extract(e.pageRoot,e.pageRules,ki),e.pageRules),i=Fe({pageRules:e.pageRules,formRules:e.formRules,data:n,doc:e.doc});Oe(e.formRoot,i,{ignoreActiveValue:t}),vt(e),e.updateFingerprint&&e.updateFingerprint()}function Ar({debounce:e=100,onRefresh:t}){let r=typeof window<"u"&&window.hyperclay&&window.hyperclay.Mutation||null;if(!r||typeof r.onAnyChange!="function")throw new Error("hypercms: window.hyperclay.Mutation is required. Load 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 vi="[hypercms]";function Sr(e,t){if(!e||!e.querySelectorAll||!t)return;let r=xi(t);e.querySelectorAll("template[data-hcms-tpl]").forEach(i=>{let o=i.getAttribute("data-hcms-tpl");o&&(o.startsWith("@")||r.has(o)||console.warn(`${vi} template "${o}" doesn't match any rule path; ignored`))})}function xi(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=Z(i);if(s==="object")for(let[l,u]of Object.entries(i))r([...n,l],u);else if(s==="object-array"||s==="scalar-array"){let l=[...n,"*"],u=l.map(c=>typeof c=="number"?"*":c).join(".");if(t.add(u),s==="object-array"){let c=i[1];if(c&&typeof c=="object"&&!Array.isArray(c))for(let[f,b]of Object.entries(c))r([...l,f],b)}}}}function Mr(e){vr(e)}var L={isOpen:!1,ctx:null,shell:null,opts:null};function _r(e,t){if(L.ctx!==e)return;let r=t==="livesync";t==="livesync"&&L.shell?.restoreChrome?.(),We(e,{ignoreActiveValue:r})}var Er=!1;function wi(){if(Er)return;let e=typeof window<"u"&&window.hyperclay&&window.hyperclay.onPrepareForSave||null;typeof e=="function"&&(e(t=>{let r=t&&t.querySelector&&t.querySelector("body");r&&r.classList.remove("hcms-open","hcms-overlay","hcms-side-left")}),Er=!0)}function Cr(e={}){if(L.isOpen){console.warn("cms.open() called while already open; ignoring");return}wi();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=q.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=i.rules,a=i.tagNode;Le(r),je(r,o),Sr(r,o);let s=Ie(o,r),l=K(q.extract(t,o,{skip:"[data-hcms-shell]",templateAttr:"cms-template"}),o),u=Be(()=>xr({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})),c={doc:r,pageRoot:t,pageRules:o,formRules:s,rulesTagNode:a,rulesSource:n,formRoot:u.formRoot,shellRoot:u.root,errorEl:u.errorEl,lastFingerprint:null,lastData:null,observerHandle:null,undoUnsub:null,livesyncUnsub:null,onChange:e.onChange,onError:e.onError,confirmRemove:e.confirmRemove,previouslyFocused:r.activeElement,dispatch(f,b){let w=r.defaultView&&r.defaultView.CustomEvent||(typeof CustomEvent<"u"?CustomEvent:null);if(!w)return;let v=new w(f,{bubbles:!0,cancelable:f==="hcms:change",detail:b});u.root.dispatchEvent(v)},onCloseRequested(){Rr()}};c.updateFingerprint=()=>{c.lastFingerprint=xe($(c))};try{let f=Fe({pageRules:o,formRules:s,data:l,doc:r});u.formRoot.appendChild(f),gr(c),c.updateFingerprint(),c.observerHandle=Ar({onRefresh:()=>We(c)});let b=typeof window<"u"&&window.hyperclay&&window.hyperclay.undo||null;if(b&&typeof b.on=="function"){let v=()=>{if(L.ctx!==c)return;_r(c,"undo");let T=K(q.extract(c.pageRoot,c.pageRules,{skip:"[data-hcms-shell]",templateAttr:"cms-template"}),c.pageRules);xe(T)!==xe(c.lastData)&&(c.lastData=T,c.onChange?.(T,{path:"",structural:!1}))};b.on("undo",v),b.on("redo",v),c.undoUnsub=()=>{b.off("undo",v),b.off("redo",v)}}let w=()=>_r(c,"livesync");r.addEventListener("hyperclay:livesync-applied",w),c.livesyncUnsub=()=>r.removeEventListener("hyperclay:livesync-applied",w),we.ctx=c,Si(r),Ai(u.root),L.isOpen=!0,L.ctx=c,L.shell=u,L.opts=e,c.dispatch("hcms:open",{pageRoot:t})}catch(f){throw c.observerHandle?.unsubscribe?.(),c.undoUnsub?.(),c.livesyncUnsub?.(),c.detachEvents?.(),we.ctx===c&&(we.ctx=null),Be(()=>u.destroy()),L.isOpen=!1,L.ctx=null,L.shell=null,L.opts=null,f}}function Ai(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 Si(e){let t=e.defaultView||(typeof globalThis<"u"?globalThis:null);if(!t)return;let r=function(){let i=we.ctx;if(i)return wt(i.formRoot),le("Reorder",()=>B($(i),{path:"",structural:!0},i))};typeof t.hypercmsCommit!="function"&&(t.hypercmsCommit=r),typeof globalThis<"u"&&typeof globalThis.hypercmsCommit!="function"&&(globalThis.hypercmsCommit=r)}var Et="cms";function _i(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(Et)!=="true"?t:(i.set(Et,"false"),"?"+i.toString())}function Ei(e){let t=typeof e=="string"?e:"",r=t.indexOf("?"),n=r===-1?t:t.slice(r+1);return n?new URLSearchParams(n).get(Et)==="true":!1}function Mi(){if(typeof window>"u"||!window.location||!window.history||typeof window.history.replaceState!="function")return;let e=window.location.search,t=_i(e);t!==e&&window.history.replaceState(window.history.state,"",t+window.location.hash)}function Rr(){if(!L.isOpen)return;let{ctx:e,shell:t}=L;e.closed=!0;let r=e.previouslyFocused;if(e.dispatch("hcms:close",null),Mi(),e.observerHandle?.unsubscribe?.(),e.undoUnsub?.(),e.livesyncUnsub?.(),e.detachEvents?.(),Be(()=>t.destroy()),L.isOpen=!1,L.ctx=null,L.shell=null,L.opts=null,we.ctx=null,r&&typeof r.focus=="function")try{r.focus()}catch{}}function Tr(){L.isOpen&&We(L.ctx)}var Ci={getData(){return L.isOpen?$(L.ctx):null},setValue(e,t){if(!L.isOpen)throw new Error("hypercms: cms is not open");let r=L.ctx,n=W(e),i=X(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=Ri(r.formRoot,e);if(!o)throw new Error(`hypercms: no field element at path "${e}"`);Ti(o,t,r.formRoot,e),B($(r),{path:e,structural:!1},r)},addItem(e){if(!L.isOpen)throw new Error("hypercms: cms is not open");kt(e,L.ctx)},removeItem(e){if(!L.isOpen)throw new Error("hypercms: cms is not open");let t=L.ctx,r=W(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=X(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="${Ct(e)}"]`);if(!a)throw new Error(`hypercms: no element at path "${e}"`);ae(a,t)},refresh:Tr,_commit(){if(!L.isOpen)return;let e=L.ctx;return wt(e.formRoot),le("Update",()=>B($(e),{path:"",structural:!0},e))}};function Ri(e,t){let r=Ct(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 Ti(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=Ct(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("value"in e){e.value=t==null?"":String(t);return}e.textContent=t==null?"":String(t)}var Oi=250,Li=1e4;function ji(){typeof window>"u"||typeof document>"u"||Ei(window.location?window.location.search:"")&&(L.isOpen||Ni(()=>{if(!L.isOpen)try{Cr()}catch(e){console.warn("hypercms: auto-open failed",e)}}))}function _t(){return!!document.body&&!!(window.hyperclay&&window.hyperclay.Mutation)}function Ni(e){if(_t()){e();return}let t=Date.now()+Li,r=!1,n=null,i=()=>{r||(r=!0,n!==null&&clearInterval(n),document.removeEventListener("hyperclay:mutation-ready",o))};function o(){if(L.isOpen){i();return}_t()&&(i(),e())}document.addEventListener("hyperclay:mutation-ready",o,{once:!0}),n=setInterval(()=>{if(L.isOpen){i();return}if(_t()){i(),e();return}Date.now()>=t&&(i(),console.warn("hypercms: ?cms=true auto-open gave up \u2014 window.hyperclay.Mutation never appeared. Load hyperclayjs (or the mutation utility) so the CMS can initialize."))},Oi)}ji();var Mt={open:Cr,close:Rr,refresh:Tr,api:Ci,get isOpen(){return L.isOpen},path:ht,scaffold:ye,morphForm:Oe};function Ct(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var Or=`/* GENERATED by scripts/build-theme.js from mirk-ui-kit/mirk.css \u2014 DO NOT EDIT.
109
+ Source of truth: mirk-ui-kit/mirk.css + src/theme/pixel-quiet.overrides.css.
110
+ Regenerate with: npm run build:theme */
111
+
112
+ /* ===== mirk-interface@2.0.1, scoped to .hcms-shell ===== */
113
+ /*
114
+ * mirk.css \u2014 the mirk UI kit, v2.
115
+ * Hand-written, no build. Fourteen form components as semantic BEM classes in
116
+ * @layer components, so utilities (Tailwind or your own) always override them
117
+ * with zero !important. Renders fully standalone; Tailwind is optional.
118
+ *
119
+ * Two hinges (see mirk-ui-guide.md):
120
+ * 1. Components live in @layer components \u2192 utilities win.
121
+ * 2. State serializes into the DOM (native attrs, :has(), inline --mirk-value)
122
+ * so document.documentElement.outerHTML round-trips every visible state.
123
+ *
124
+ * This @layer statement makes the file self-sufficient without Tailwind, and
125
+ * merges into Tailwind's own order (@layer theme, base, components, utilities)
126
+ * when present.
127
+ */
128
+ @layer base, components;
129
+
130
+ @layer base {
131
+ /* Components are authored border-box (a 2px bevel must not grow the box). */
132
+ .hcms-shell *, .hcms-shell *::before, .hcms-shell *::after { box-sizing: border-box; }
133
+ .hcms-shell button, .hcms-shell input, .hcms-shell optgroup, .hcms-shell select, .hcms-shell textarea { margin: 0; }
134
+
135
+ @font-face {
136
+ font-family: 'Departure Mono';
137
+ src: url('https://cdn.jsdelivr.net/npm/mirk-interface@2.0.1/fonts/DepartureMono-1.500/DepartureMono-Regular.woff2') format('woff2');
138
+ font-weight: 400; font-style: normal; font-display: swap;
139
+ }
140
+
141
+ .hcms-shell { font-family: 'Departure Mono', ui-monospace, "Menlo", monospace; }
142
+ /* Preflight sets these to ui-monospace; keep them in Departure Mono. */
143
+ .hcms-shell pre, .hcms-shell code, .hcms-shell kbd, .hcms-shell samp { font-family: inherit; }
144
+
145
+ /* 28 tokens, one value each. light-dark() picks the side from color-scheme. */
146
+ .hcms-shell {
147
+ color-scheme: light dark; /* default: follow the OS */
148
+
149
+ --mirk-canvas: light-dark(#F7F2EA, #0B0C13);
150
+ --mirk-bg: light-dark(#F7F2EA, #1D1F2F);
151
+ --mirk-fg: light-dark(#15120e, #F6F7F9);
152
+ --mirk-accent: light-dark(#efefe5, #232639);
153
+ --mirk-destructive: light-dark(#d4183d, #ff5566);
154
+ --mirk-focus-color: light-dark(#BBA288, #5A607F);
155
+ --mirk-bevel-bg: light-dark(#e9d3bd, #1D1F2F);
156
+ --mirk-bevel-fg: light-dark(#15120e, #F6F7F9);
157
+ --mirk-bevel-tl: light-dark(#f3ddc7, #474C65);
158
+ --mirk-bevel-br: light-dark(#c2ad95, #131725);
159
+ --mirk-bevel-hover-bg: light-dark(#dfc9b3, #232639);
160
+ --mirk-pill-inner-top: light-dark(#efdac7, #232639);
161
+ --mirk-input-border: light-dark(#957E65, #6E738E);
162
+ --mirk-placeholder-color: light-dark(#7F7366, #545973);
163
+ --mirk-ctrl-bg: light-dark(#8C7660, #5F6582);
164
+ --mirk-toggle-bg: light-dark(#DFC9AF, #656D95);
165
+ --mirk-toggle-hi: light-dark(#E9D6C3, #7F87AD);
166
+ --mirk-toggle-lo: light-dark(#C7A88A, #505677);
167
+ --mirk-mark-fg: light-dark(#3F3225, #E1E3EA);
168
+ --mirk-sortable-dot: light-dark(#e2c5a6, #393f5b);
169
+ --mirk-sortable-shadow: light-dark(#c7a47f, #111527);
170
+ --mirk-sortable-label: light-dark(#231e18, #edeef2);
171
+ --mirk-sortable-placeholder: light-dark(#99826c, #6f7695);
172
+ --mirk-slider-fill: light-dark(#e9d3bd, #232639);
173
+ --mirk-slider-nub-bg: light-dark(#DFC9AF, #656D95);
174
+ --mirk-slider-nub-hi: light-dark(#E9D6C3, #7F87AD);
175
+ --mirk-slider-nub-lo: light-dark(#C7A88A, #505677);
176
+
177
+ --mirk-radius: 5px; /* the "rounded" corner */
178
+ --mirk-focus-offset: 2px; /* non-color \u2192 can't ride light-dark() */
179
+
180
+ background: var(--mirk-canvas);
181
+ color: var(--mirk-fg);
182
+ }
183
+
184
+ /* The one non-color token with a real light/dark split (was 2px / 3px). */
185
+ @media (prefers-color-scheme: dark) { .hcms-shell { --mirk-focus-offset: 3px; } }
186
+
187
+ /* Force a mode on any subtree with one attribute (class aliases for hosts that
188
+ prefer class-based theming and Tailwind's dark-variant convention). Each also
189
+ paints its own canvas so a wrapper visibly flips. */
190
+ .hcms-shell[data-theme="light"], .hcms-shell.light {
191
+ color-scheme: light; --mirk-focus-offset: 2px;
192
+ background: var(--mirk-canvas); color: var(--mirk-fg);
193
+ }
194
+ .hcms-shell[data-theme="dark"], .hcms-shell.dark {
195
+ color-scheme: dark; --mirk-focus-offset: 3px;
196
+ background: var(--mirk-canvas); color: var(--mirk-fg);
197
+ }
198
+
199
+ /* Brand-theme escape hatch:
200
+ [data-theme="sunset"] { color-scheme: light; --mirk-accent: #f0a868; \u2026 } */
201
+ }
202
+
203
+ @layer components {
204
+ /* Visually hidden, still focusable/announced. The hidden native input behind
205
+ every custom control relies on it; Tailwind is optional now. */
206
+ .hcms-shell .mirk-sr-only {
207
+ position: absolute; width: 1px; height: 1px;
208
+ padding: 0; margin: -1px; overflow: hidden;
209
+ clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0;
210
+ }
211
+
212
+ /* ============================ BUTTON ============================ */
213
+ .hcms-shell .mirk-button {
214
+ display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
215
+ font: inherit; line-height: 1.5; cursor: pointer; user-select: none;
216
+ text-align: center;
217
+ color: var(--mirk-bevel-fg);
218
+ background: var(--mirk-bevel-bg);
219
+ border: 2px solid;
220
+ /* Raised bevel: light top+left, dark right+bottom. Shorthand is T R B L. */
221
+ border-color: var(--mirk-bevel-tl) var(--mirk-bevel-br) var(--mirk-bevel-br) var(--mirk-bevel-tl);
222
+ padding: 4px 14px 5px; /* medium */
223
+ outline: none;
224
+ }
225
+ .hcms-shell .mirk-button__label { white-space: nowrap; user-select: none; display: inline-block; }
226
+
227
+ /* States, written once, shared by every size and shape. */
228
+ .hcms-shell .mirk-button:hover { background-color: var(--mirk-bevel-hover-bg); }
229
+ .hcms-shell .mirk-button:active {
230
+ border-color: var(--mirk-bevel-br) var(--mirk-bevel-tl) var(--mirk-bevel-tl) var(--mirk-bevel-br);
231
+ }
232
+ .hcms-shell .mirk-button:not(.mirk-button--round):active .mirk-button__label { translate: 1.5px 1.5px; }
233
+ /* Direct focus (a real <button>) or a focus-visible descendant (a <label>
234
+ wrapping a hidden input, as the file/image upload triggers do). */
235
+ .hcms-shell .mirk-button:focus-visible, .hcms-shell .mirk-button:has(:focus-visible) {
236
+ outline: 1px solid var(--mirk-focus-color); outline-offset: var(--mirk-focus-offset);
237
+ }
238
+ .hcms-shell .mirk-button:disabled { opacity: 0.5; cursor: not-allowed; }
239
+
240
+ /* Sizes set padding + font (rect); round re-homes padding to the label below. */
241
+ .hcms-shell .mirk-button--small { padding: 3px 12px; font-size: 14px; }
242
+ .hcms-shell .mirk-button--large { padding: 4px 17px 7px; font-size: 18px; border-width: 3px; }
243
+
244
+ /* Round register: a gradient pill frame with the label as the inner fill. */
245
+ .hcms-shell .mirk-button--round {
246
+ border: none; padding: 2px; border-radius: 14px;
247
+ background-color: var(--mirk-canvas);
248
+ background-image: linear-gradient(to top in oklab, var(--mirk-bevel-br), var(--mirk-bevel-tl));
249
+ opacity: 0.9; transition: opacity 0.15s cubic-bezier(0.4, 0, 0.2, 1);
250
+ }
251
+ .hcms-shell .mirk-button--round:hover { opacity: 1; }
252
+ .hcms-shell .mirk-button--round:active {
253
+ background-image: linear-gradient(to bottom in oklab, var(--mirk-bevel-br), var(--mirk-bevel-tl));
254
+ }
255
+ .hcms-shell .mirk-button--round .mirk-button__label {
256
+ display: flex; align-items: center; gap: 0.5rem;
257
+ padding: 4px 17px 6px; border-radius: 12px;
258
+ color: var(--mirk-bevel-fg);
259
+ background-color: var(--mirk-bevel-bg);
260
+ background-image: linear-gradient(to top in oklab, var(--mirk-bevel-bg), var(--mirk-pill-inner-top));
261
+ }
262
+ .hcms-shell .mirk-button--round.mirk-button--small { border-radius: 12px; }
263
+ .hcms-shell .mirk-button--round.mirk-button--small .mirk-button__label { padding: 2px 14px; border-radius: 10px; }
264
+ .hcms-shell .mirk-button--round.mirk-button--large { border-radius: 16px; }
265
+ .hcms-shell .mirk-button--round.mirk-button--large .mirk-button__label { padding: 7px 24px 9px; border-radius: 14px; }
266
+
267
+ /* ============================ TEXT INPUT ============================ */
268
+ .hcms-shell .mirk-input {
269
+ width: 100%;
270
+ background: var(--mirk-bevel-bg); color: var(--mirk-bevel-fg);
271
+ border: 1px solid var(--mirk-input-border);
272
+ padding: 5px 14px 6px; /* medium */
273
+ font: inherit; line-height: 1.5; border-radius: 0; outline: none;
274
+ }
275
+ .hcms-shell .mirk-input::placeholder { color: var(--mirk-placeholder-color); }
276
+ .hcms-shell .mirk-input:focus-visible {
277
+ outline: 1px solid var(--mirk-focus-color); outline-offset: var(--mirk-focus-offset);
278
+ }
279
+ .hcms-shell .mirk-input--small { padding: 4px 12px; font-size: 14px; }
280
+ .hcms-shell .mirk-input--large { padding: 6px 17px 9px; font-size: 18px; }
281
+ .hcms-shell .mirk-input--rounded { border-radius: var(--mirk-radius); }
282
+
283
+ /* ============================ TEXTAREA ============================ */
284
+ .hcms-shell .mirk-textarea {
285
+ width: 100%;
286
+ background: var(--mirk-bevel-bg); color: var(--mirk-bevel-fg);
287
+ border: 1px solid var(--mirk-input-border);
288
+ padding: 6px 17px 9px; font: inherit; font-size: 18px; line-height: 1.5;
289
+ border-radius: 0; outline: none; resize: vertical;
290
+ }
291
+ .hcms-shell .mirk-textarea::placeholder { color: var(--mirk-placeholder-color); }
292
+ .hcms-shell .mirk-textarea:focus-visible {
293
+ outline: 1px solid var(--mirk-focus-color); outline-offset: var(--mirk-focus-offset);
294
+ }
295
+ .hcms-shell .mirk-textarea--rounded { border-radius: var(--mirk-radius); }
296
+
297
+ /* ============================ NUMBER ============================ */
298
+ .hcms-shell .mirk-number {
299
+ display: flex; align-items: stretch; width: 100%;
300
+ background: var(--mirk-bevel-bg);
301
+ border: 1px solid var(--mirk-input-border); border-radius: 0;
302
+ }
303
+ .hcms-shell .mirk-number:has(:focus-visible) {
304
+ outline: 1px solid var(--mirk-focus-color); outline-offset: var(--mirk-focus-offset);
305
+ }
306
+ .hcms-shell .mirk-number__input {
307
+ flex: 1; min-width: 0; background: transparent; color: var(--mirk-bevel-fg);
308
+ padding: 5px 10px 6px 14px; /* medium */
309
+ font: inherit; line-height: 1.5; outline: none;
310
+ appearance: textfield; -webkit-appearance: textfield;
311
+ }
312
+ .hcms-shell .mirk-number__input::-webkit-outer-spin-button, .hcms-shell .mirk-number__input::-webkit-inner-spin-button { -webkit-appearance: none; appearance: none; }
313
+ .hcms-shell .mirk-number__steps { display: flex; flex-direction: column; padding: 2px; gap: 2px; }
314
+ .hcms-shell .mirk-number__step {
315
+ flex: 1; cursor: pointer; line-height: 1; padding: 0 10px; font-size: 9px; /* medium */
316
+ display: flex; align-items: center; justify-content: center;
317
+ background: var(--mirk-bevel-bg); outline: none;
318
+ border: 2px solid;
319
+ border-color: var(--mirk-bevel-tl) var(--mirk-bevel-br) var(--mirk-bevel-br) var(--mirk-bevel-tl);
320
+ }
321
+ .hcms-shell .mirk-number__step:hover { background: var(--mirk-bevel-hover-bg); }
322
+ .hcms-shell .mirk-number__step:active {
323
+ border-color: var(--mirk-bevel-br) var(--mirk-bevel-tl) var(--mirk-bevel-tl) var(--mirk-bevel-br);
324
+ }
325
+ .hcms-shell .mirk-number__step:focus-visible { outline: 1px solid var(--mirk-focus-color); outline-offset: 1px; }
326
+
327
+ .hcms-shell .mirk-number--small .mirk-number__input { padding: 4px 8px 4px 12px; font-size: 14px; }
328
+ .hcms-shell .mirk-number--small .mirk-number__step { padding: 0 8px; font-size: 8px; }
329
+ .hcms-shell .mirk-number--large .mirk-number__input { padding: 6px 12px 9px 17px; font-size: 18px; }
330
+ .hcms-shell .mirk-number--large .mirk-number__step { padding: 0 12px; font-size: 10px; }
331
+
332
+ .hcms-shell .mirk-number--rounded { border-radius: var(--mirk-radius); }
333
+ .hcms-shell .mirk-number--rounded .mirk-number__step { border-radius: 3px; }
334
+
335
+ /* ============================ SELECT / DROPDOWN ============================ */
336
+ /* Keeps appearance:none + a real chevron (renders identically everywhere today);
337
+ base-select/::picker is a future enhancement. */
338
+ .hcms-shell .mirk-select { position: relative; }
339
+ .hcms-shell .mirk-select__field {
340
+ width: 100%; appearance: none; -webkit-appearance: none;
341
+ background: var(--mirk-bevel-bg); color: var(--mirk-bevel-fg);
342
+ border: 2px solid;
343
+ border-color: var(--mirk-bevel-tl) var(--mirk-bevel-br) var(--mirk-bevel-br) var(--mirk-bevel-tl);
344
+ padding: 4px 40px 5px 14px; /* medium */
345
+ font: inherit; line-height: 1.5; border-radius: 0; outline: none;
346
+ }
347
+ .hcms-shell .mirk-select__field:focus-visible {
348
+ outline: 1px solid var(--mirk-focus-color); outline-offset: var(--mirk-focus-offset);
349
+ }
350
+ .hcms-shell .mirk-select__chevron {
351
+ pointer-events: none; position: absolute; top: 50%; right: 14px; /* medium */
352
+ translate: 0 -50%; rotate: 90deg; display: inline-block; line-height: 1; font-size: 20px;
353
+ }
354
+ .hcms-shell .mirk-select--small .mirk-select__field { padding: 3px 36px 3px 12px; font-size: 14px; }
355
+ .hcms-shell .mirk-select--small .mirk-select__chevron { right: 12px; font-size: 18px; }
356
+ .hcms-shell .mirk-select--large .mirk-select__field { padding: 4px 48px 7px 17px; font-size: 18px; border-width: 3px; }
357
+ .hcms-shell .mirk-select--large .mirk-select__chevron { right: 16px; font-size: 24px; }
358
+
359
+ /* Round: gradient pill frame around a borderless, pill-filled select. */
360
+ .hcms-shell .mirk-select--round .mirk-select__frame {
361
+ padding: 2px; border-radius: 14px; /* medium */
362
+ background-color: var(--mirk-canvas);
363
+ background-image: linear-gradient(to top in oklab, var(--mirk-bevel-br), var(--mirk-bevel-tl));
364
+ }
365
+ .hcms-shell .mirk-select--round .mirk-select__frame:has(:focus-visible) {
366
+ outline: 1px solid var(--mirk-focus-color); outline-offset: var(--mirk-focus-offset);
367
+ }
368
+ .hcms-shell .mirk-select--round .mirk-select__field {
369
+ border: none; background-color: transparent;
370
+ background-image: linear-gradient(to top in oklab, var(--mirk-bevel-bg), var(--mirk-pill-inner-top));
371
+ border-radius: 12px; padding: 4px 40px 6px 17px; /* medium */
372
+ }
373
+ .hcms-shell .mirk-select--round.mirk-select--small .mirk-select__frame { border-radius: 12px; }
374
+ .hcms-shell .mirk-select--round.mirk-select--small .mirk-select__field { border-radius: 10px; padding: 2px 36px 2px 14px; }
375
+ .hcms-shell .mirk-select--round.mirk-select--large .mirk-select__frame { border-radius: 16px; }
376
+ .hcms-shell .mirk-select--round.mirk-select--large .mirk-select__field { border-radius: 14px; padding: 7px 48px 9px 24px; }
377
+ .hcms-shell .mirk-select--round.mirk-select--large .mirk-select__chevron { right: 16px; font-size: 24px; }
378
+
379
+ /* ============================ CHECKBOX ============================ */
380
+ .hcms-shell .mirk-checkbox { display: inline-flex; align-items: center; gap: 0.75rem; cursor: pointer; width: fit-content; }
381
+ .hcms-shell .mirk-checkbox__box {
382
+ position: relative; flex-shrink: 0; width: 22px; height: 22px;
383
+ display: flex; align-items: center; justify-content: center; border-radius: 0;
384
+ background: var(--mirk-bevel-bg);
385
+ border: 2px solid;
386
+ border-color: var(--mirk-bevel-tl) var(--mirk-bevel-br) var(--mirk-bevel-br) var(--mirk-bevel-tl);
387
+ }
388
+ .hcms-shell .mirk-checkbox__mark {
389
+ opacity: 0; display: block; width: 6px; height: 12px;
390
+ border-right: 2.5px solid var(--mirk-mark-fg); border-bottom: 2.5px solid var(--mirk-mark-fg);
391
+ rotate: 45deg; translate: 0.5px -1.5px;
392
+ }
393
+ .hcms-shell .mirk-checkbox__label { font-size: 18px; line-height: 1.5; }
394
+
395
+ .hcms-shell .mirk-checkbox:has(:checked) .mirk-checkbox__box { border-color: var(--mirk-input-border); }
396
+ .hcms-shell .mirk-checkbox:has(:checked) .mirk-checkbox__mark { opacity: 1; }
397
+ .hcms-shell .mirk-checkbox:has(:focus-visible) .mirk-checkbox__box {
398
+ outline: 1px solid var(--mirk-focus-color); outline-offset: var(--mirk-focus-offset);
399
+ }
400
+
401
+ /* ============================ RADIO ============================ */
402
+ .hcms-shell .mirk-radio { display: inline-flex; align-items: center; gap: 0.75rem; cursor: pointer; width: fit-content; }
403
+ .hcms-shell .mirk-radio__ring {
404
+ position: relative; flex-shrink: 0; width: 25px; height: 25px; border-radius: 9999px;
405
+ background-image: linear-gradient(to top in oklab, var(--mirk-bevel-br), var(--mirk-bevel-tl));
406
+ }
407
+ .hcms-shell .mirk-radio__fill {
408
+ display: block; position: absolute; inset: 2px; border-radius: 9999px;
409
+ background-image: linear-gradient(to top in oklab, var(--mirk-bevel-bg), var(--mirk-pill-inner-top));
410
+ }
411
+ .hcms-shell .mirk-radio__dot {
412
+ display: none; position: absolute; top: 50%; left: 50%; translate: -50% -50%;
413
+ width: 9px; height: 9px; border-radius: 9999px; background: var(--mirk-mark-fg);
414
+ }
415
+ .hcms-shell .mirk-radio__label { font-size: 18px; line-height: 1.5; }
416
+
417
+ .hcms-shell .mirk-radio:has(:checked) .mirk-radio__ring {
418
+ background-image: none; background-color: var(--mirk-bevel-bg);
419
+ border: 2px solid var(--mirk-input-border);
420
+ }
421
+ .hcms-shell .mirk-radio:has(:checked) .mirk-radio__fill { display: none; }
422
+ .hcms-shell .mirk-radio:has(:checked) .mirk-radio__dot { display: block; }
423
+ .hcms-shell .mirk-radio:has(:focus-visible) .mirk-radio__ring {
424
+ outline: 1px solid var(--mirk-focus-color); outline-offset: var(--mirk-focus-offset);
425
+ }
426
+
427
+ /* ============================ TOGGLE ============================ */
428
+ .hcms-shell .mirk-toggle { display: inline-flex; align-items: center; gap: 0.75rem; cursor: pointer; width: fit-content; }
429
+ .hcms-shell .mirk-toggle__track {
430
+ position: relative; flex-shrink: 0; width: 49px; height: 27px; border-radius: 0;
431
+ border: 1px solid var(--mirk-input-border);
432
+ }
433
+ .hcms-shell .mirk-toggle__thumb {
434
+ position: absolute; top: 3px; left: 3px; width: 19px; height: 19px;
435
+ background-color: var(--mirk-toggle-bg);
436
+ border: 2px solid;
437
+ border-color: var(--mirk-toggle-hi) var(--mirk-toggle-lo) var(--mirk-toggle-lo) var(--mirk-toggle-hi);
438
+ transition-property: transform, translate, scale, rotate;
439
+ transition-duration: 0.15s; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
440
+ }
441
+ .hcms-shell .mirk-toggle__label { font-size: 18px; line-height: 1.5; }
442
+
443
+ .hcms-shell .mirk-toggle:has(:checked) .mirk-toggle__thumb { translate: 22px; }
444
+ .hcms-shell .mirk-toggle:has(:focus-visible) .mirk-toggle__track {
445
+ outline: 1px solid var(--mirk-focus-color); outline-offset: var(--mirk-focus-offset);
446
+ }
447
+
448
+ .hcms-shell .mirk-toggle--round .mirk-toggle__track { width: 50px; height: 29px; border-radius: 9999px; }
449
+ .hcms-shell .mirk-toggle--round .mirk-toggle__thumb {
450
+ width: 21px; height: 21px; border: none; border-radius: 9999px;
451
+ background-color: transparent;
452
+ background-image: linear-gradient(to top in oklab, var(--mirk-toggle-lo), var(--mirk-toggle-hi));
453
+ }
454
+ .hcms-shell .mirk-toggle--round .mirk-toggle__thumb::after {
455
+ content: ""; position: absolute; inset: 2px; border-radius: 9999px; background: var(--mirk-toggle-bg);
456
+ }
457
+ .hcms-shell .mirk-toggle--round:has(:checked) .mirk-toggle__thumb { translate: 21px; }
458
+
459
+ /* ============================ SLIDER ============================ */
460
+ .hcms-shell .mirk-slider { position: relative; height: 32px; width: 100%; --mirk-value: 0%; }
461
+ .hcms-shell .mirk-slider__input {
462
+ position: absolute; inset: 0; width: 100%; height: 100%;
463
+ opacity: 0; cursor: pointer; z-index: 10;
464
+ }
465
+ .hcms-shell .mirk-slider__track {
466
+ position: absolute; left: 0; right: 0; top: 50%; translate: 0 -50%; height: 12px;
467
+ background: var(--mirk-canvas); border: 1px solid var(--mirk-input-border); overflow: hidden;
468
+ }
469
+ .hcms-shell .mirk-slider__fill { height: 100%; width: var(--mirk-value); background: var(--mirk-slider-fill); }
470
+ .hcms-shell .mirk-slider__nub {
471
+ position: absolute; top: 50%; left: var(--mirk-value); translate: -50% -50%;
472
+ width: 21px; height: 21px; pointer-events: none;
473
+ background-color: var(--mirk-slider-nub-bg);
474
+ border: 2px solid;
475
+ border-color: var(--mirk-slider-nub-hi) var(--mirk-slider-nub-lo) var(--mirk-slider-nub-lo) var(--mirk-slider-nub-hi);
476
+ }
477
+ .hcms-shell .mirk-slider__input:focus-visible ~ .mirk-slider__nub {
478
+ outline: 1px solid var(--mirk-focus-color); outline-offset: var(--mirk-focus-offset);
479
+ }
480
+
481
+ .hcms-shell .mirk-slider--round .mirk-slider__track { height: 10px; border-radius: 9999px; }
482
+ .hcms-shell .mirk-slider--round .mirk-slider__nub {
483
+ width: 24px; height: 24px; border: none; border-radius: 9999px;
484
+ background-color: transparent;
485
+ background-image: linear-gradient(to top in oklab, var(--mirk-slider-nub-lo), var(--mirk-slider-nub-hi));
486
+ }
487
+ .hcms-shell .mirk-slider--round .mirk-slider__nub::after {
488
+ content: ""; position: absolute; inset: 2px; border-radius: 9999px; background: var(--mirk-slider-nub-bg);
489
+ }
490
+
491
+ /* ============================ DATE ============================ */
492
+ .hcms-shell .mirk-date { position: relative; }
493
+ .hcms-shell .mirk-date__field {
494
+ width: 100%; background: var(--mirk-bevel-bg); color: var(--mirk-bevel-fg);
495
+ border: 1px solid var(--mirk-input-border);
496
+ padding: 6px 44px 9px 17px; font: inherit; font-size: 18px; line-height: 1.5;
497
+ border-radius: 0; outline: none;
498
+ }
499
+ .hcms-shell .mirk-date__field:focus-visible {
500
+ outline: 1px solid var(--mirk-focus-color); outline-offset: var(--mirk-focus-offset);
501
+ }
502
+ .hcms-shell .mirk-date__field::-webkit-calendar-picker-indicator {
503
+ opacity: 0; position: absolute; right: 0; top: 0; bottom: 0; width: 44px; margin: 0; cursor: pointer;
504
+ }
505
+ .hcms-shell .mirk-date__field::-webkit-inner-spin-button { -webkit-appearance: none; appearance: none; }
506
+ .hcms-shell .mirk-date__field::-webkit-clear-button { -webkit-appearance: none; appearance: none; }
507
+ .hcms-shell .mirk-date__icon {
508
+ pointer-events: none; position: absolute; right: 16px; top: 50%; translate: 0 -50%;
509
+ }
510
+ .hcms-shell .mirk-date--rounded .mirk-date__field { border-radius: var(--mirk-radius); }
511
+
512
+ /* The native file/image inputs are visually hidden; their styled label drives
513
+ them, and the focus ring rides :has(:focus-visible) on button or container. */
514
+ .hcms-shell .mirk-file__input, .hcms-shell .mirk-image__input {
515
+ position: absolute; width: 1px; height: 1px;
516
+ padding: 0; margin: -1px; overflow: hidden;
517
+ clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0;
518
+ }
519
+
520
+ /* ============================ FILE ============================ */
521
+ .hcms-shell .mirk-file { display: flex; align-items: center; gap: 0.75rem; width: 100%; }
522
+ .hcms-shell .mirk-file__name {
523
+ color: var(--mirk-placeholder-color); font-size: 18px; line-height: 1.5;
524
+ min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
525
+ }
526
+ .hcms-shell .mirk-file__name[data-filled] { color: var(--mirk-bevel-fg); }
527
+
528
+ /* Compact: a shared bordered container holds a smaller button + the name. */
529
+ .hcms-shell .mirk-file--compact {
530
+ padding: 4px 8px; background: var(--mirk-bevel-bg);
531
+ border: 1px solid var(--mirk-input-border); border-radius: 0;
532
+ }
533
+ .hcms-shell .mirk-file--compact:has(:focus-visible) {
534
+ outline: 1px solid var(--mirk-focus-color); outline-offset: var(--mirk-focus-offset);
535
+ }
536
+ /* The upload trigger is a .mirk-button; nudge it onto the container's left
537
+ border so the bevel sits flush (covers compact and round-compact). */
538
+ .hcms-shell .mirk-file--compact .mirk-button { margin-left: -1px; }
539
+ .hcms-shell .mirk-file--compact .mirk-file__name { font-size: 16px; }
540
+ .hcms-shell .mirk-file--compact.mirk-file--round { border-radius: 15px; }
541
+
542
+ /* Filled: the name slot becomes a link to the chosen file, beside a bare \xD7 to
543
+ clear it (the tags-remove pattern). Empty keeps the placeholder span. */
544
+ .hcms-shell a.mirk-file__name { text-decoration: underline; text-underline-offset: 2px; }
545
+ .hcms-shell .mirk-file__remove {
546
+ appearance: none; -webkit-appearance: none; flex-shrink: 0;
547
+ display: inline-flex; align-items: center; justify-content: center;
548
+ margin: 0; padding: 0; border: 0; background: none; color: inherit;
549
+ cursor: pointer; line-height: 0;
550
+ }
551
+ .hcms-shell .mirk-file__remove svg { display: block; width: 14px; height: 14px; }
552
+ .hcms-shell .mirk-file__remove:hover { color: var(--mirk-destructive); }
553
+
554
+ /* ============================ IMAGE ============================ */
555
+ .hcms-shell .mirk-image { display: flex; flex-direction: column; gap: 0.5rem; }
556
+ .hcms-shell .mirk-image__frame {
557
+ position: relative; width: 120px; height: 120px; overflow: hidden; border-radius: 0;
558
+ display: flex; align-items: center; justify-content: center;
559
+ background: var(--mirk-bevel-bg); border: 1px solid var(--mirk-input-border);
560
+ color: var(--mirk-placeholder-color); font-size: 14px; line-height: 1.5;
561
+ }
562
+ .hcms-shell .mirk-image__preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
563
+ .hcms-shell .mirk-image--rounded .mirk-image__frame { border-radius: var(--mirk-radius); }
564
+ /* The upload trigger is a .mirk-button; keep it hugging its label instead of
565
+ stretching to fill this column-flex container. */
566
+ .hcms-shell .mirk-image .mirk-button { width: fit-content; }
567
+
568
+ /* Compact: a focused 56px thumbnail upload. Empty shows a small upload button;
569
+ once an image is chosen the button hides and a thumbnail + corner \xD7 takes its
570
+ place. The frame clips the image (overflow hidden) while the thumb wrapper
571
+ stays visible, so the \xD7 can sit just outside the corner without being cut. */
572
+ .hcms-shell .mirk-image--compact { flex-direction: row; align-items: center; gap: 0; }
573
+ .hcms-shell .mirk-image__thumb { position: relative; display: inline-block; width: fit-content; margin: 0; line-height: 0; }
574
+ .hcms-shell .mirk-image--compact .mirk-image__frame {
575
+ width: 56px; height: 56px; overflow: hidden; border-radius: 0;
576
+ border: 1px solid var(--mirk-input-border);
577
+ }
578
+ .hcms-shell .mirk-image--compact.mirk-image--rounded .mirk-image__frame { border-radius: var(--mirk-radius); }
579
+ .hcms-shell .mirk-image--compact .mirk-image__preview {
580
+ position: static; inset: auto; width: 100%; height: 100%; display: block; object-fit: cover;
581
+ }
582
+ .hcms-shell .mirk-image__remove {
583
+ position: absolute; top: -7px; right: -7px;
584
+ width: 18px; height: 18px; border-radius: 50%; padding: 0;
585
+ display: inline-flex; align-items: center; justify-content: center;
586
+ appearance: none; -webkit-appearance: none; cursor: pointer; line-height: 0;
587
+ color: var(--mirk-bevel-fg); background: var(--mirk-bevel-bg);
588
+ border: 1px solid var(--mirk-input-border);
589
+ }
590
+ .hcms-shell .mirk-image__remove svg { display: block; width: 10px; height: 10px; }
591
+ .hcms-shell .mirk-image__remove:hover { color: var(--mirk-destructive); border-color: var(--mirk-destructive); }
592
+
593
+ /* ============================ TAGS ============================ */
594
+ .hcms-shell .mirk-tags {
595
+ display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.5rem;
596
+ background: var(--mirk-bevel-bg); border: 1px solid var(--mirk-input-border);
597
+ border-radius: 0; cursor: text;
598
+ }
599
+ .hcms-shell .mirk-tags:has(:focus-visible) {
600
+ outline: 1px solid var(--mirk-focus-color); outline-offset: var(--mirk-focus-offset);
601
+ }
602
+ .hcms-shell .mirk-tags__chip {
603
+ display: inline-flex; align-items: center; gap: 0.5rem;
604
+ padding: 2px 8px 2px 12px; font-size: 14px; line-height: 1.5;
605
+ color: var(--mirk-bevel-fg); background: var(--mirk-bevel-bg);
606
+ border: 2px solid;
607
+ border-color: var(--mirk-bevel-tl) var(--mirk-bevel-br) var(--mirk-bevel-br) var(--mirk-bevel-tl);
608
+ }
609
+ .hcms-shell .mirk-tags__remove {
610
+ appearance: none; -webkit-appearance: none;
611
+ margin: 0; padding: 0; border: 0; background: none; color: inherit;
612
+ cursor: pointer; font-size: 14px; line-height: 1;
613
+ }
614
+ .hcms-shell .mirk-tags__remove:hover { color: var(--mirk-destructive); }
615
+ .hcms-shell .mirk-tags__input {
616
+ appearance: none; -webkit-appearance: none;
617
+ border: 0; padding: 0;
618
+ flex: 1; min-width: 120px; background: transparent; color: var(--mirk-bevel-fg);
619
+ outline: none; font-size: 18px; line-height: 1.5;
620
+ }
621
+ .hcms-shell .mirk-tags__input::placeholder { color: var(--mirk-placeholder-color); }
622
+
623
+ .hcms-shell .mirk-tags--round { border-radius: 15px; }
624
+ .hcms-shell .mirk-tags--round .mirk-tags__chip {
625
+ padding: 2px; border: none; border-radius: 12px;
626
+ background-color: transparent;
627
+ background-image: linear-gradient(to top in oklab, var(--mirk-bevel-br), var(--mirk-bevel-tl));
628
+ }
629
+ .hcms-shell .mirk-tags__chip-inner {
630
+ display: inline-flex; align-items: center; gap: 0.5rem;
631
+ padding: 1px 8px 1px 12px; border-radius: 10px;
632
+ color: var(--mirk-bevel-fg); background-color: var(--mirk-bevel-bg);
633
+ background-image: linear-gradient(to top in oklab, var(--mirk-bevel-bg), var(--mirk-pill-inner-top));
634
+ }
635
+
636
+ /* ============================ SORTABLE ============================ */
637
+ .hcms-shell .mirk-sortable { display: flex; flex-direction: column; gap: 0.5rem; }
638
+ .hcms-shell .mirk-sortable__item {
639
+ display: flex; flex-direction: row; width: 100%;
640
+ background: var(--mirk-bevel-bg); border: 1px solid var(--mirk-input-border);
641
+ }
642
+ .hcms-shell .mirk-sortable__grip {
643
+ width: 28px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
644
+ cursor: grab; border-right: 1px solid var(--mirk-input-border);
645
+ }
646
+ .hcms-shell .mirk-sortable__grip:active { cursor: grabbing; }
647
+ .hcms-shell .mirk-sortable__dots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px; }
648
+ .hcms-shell .mirk-sortable__dot {
649
+ display: block; width: 4px; height: 4px; background: var(--mirk-sortable-dot);
650
+ box-shadow: 1px 0 0 0 var(--mirk-sortable-shadow), 0 1px 0 0 var(--mirk-sortable-shadow), 1px 1px 0 0 var(--mirk-sortable-shadow);
651
+ }
652
+ .hcms-shell .mirk-sortable__body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
653
+ .hcms-shell .mirk-sortable__row { padding: 8px 17px 9px; }
654
+ .hcms-shell .mirk-sortable__row:not(:last-child) { border-bottom: 1px solid var(--mirk-input-border); }
655
+ .hcms-shell .mirk-sortable__label {
656
+ display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.2em;
657
+ margin-bottom: 2px; color: var(--mirk-sortable-label);
658
+ }
659
+ .hcms-shell .mirk-sortable__field {
660
+ width: 100%; background: transparent; color: var(--mirk-bevel-fg);
661
+ font-size: 18px; line-height: 1.5; outline: none;
662
+ }
663
+ .hcms-shell .mirk-sortable__field::placeholder { color: var(--mirk-sortable-placeholder); }
664
+ .hcms-shell .mirk-sortable__field:focus-visible {
665
+ outline: 1px solid var(--mirk-focus-color); outline-offset: var(--mirk-focus-offset);
666
+ }
667
+ }
668
+
669
+ /* Respect the machine \u2014 outside @layer components so it always wins. */
670
+ @media (prefers-reduced-motion: reduce) {
671
+ .hcms-shell .mirk-button--round, .hcms-shell .mirk-toggle__thumb { transition: none; }
672
+ .hcms-shell .mirk-button:active .mirk-button__label { translate: none; }
673
+ }
674
+ @media (forced-colors: active) {
675
+ .hcms-shell .mirk-button, .hcms-shell .mirk-select__field, .hcms-shell .mirk-checkbox__box, .hcms-shell .mirk-toggle__track { border: 1px solid ButtonText; }
676
+ }
677
+
678
+ /* ===== pixel-quiet overrides (hypercms-owned) ===== */
679
+ /* =====================================================================
680
+ Pixel Quiet \u2014 hypercms theme overrides (hypercms-owned).
681
+
682
+ Adapted from cms-sidebar/pixel-quiet/overrides.css. Two jobs:
683
+ 1. Retune --mirk-* tokens, scoped to .hcms-shell.pixel-quiet (never :root).
684
+ 2. Author the panel geometry + the functional chrome the static mockup
685
+ doesn't have (error banner, add/remove/move controls, the engine's
686
+ sortable cards, push / overlay / left-dock modes) on top of the
687
+ .hcms-* structural hooks.
688
+
689
+ This file is concatenated AFTER the scoped mirk base+components by
690
+ scripts/build-theme.js, so plain rules here win over mirk's @layer
691
+ components with zero !important. Loaded only inside .hcms-shell, so nothing
692
+ here leaks onto the host page.
693
+ ===================================================================== */
694
+
695
+ /* ============================================================
696
+ TOKEN RETUNE \u2014 LIGHT (warm cream, gentle near-equal bevel)
697
+ ============================================================ */
698
+ .hcms-shell.pixel-quiet {
699
+ color-scheme: light;
700
+ --mirk-canvas: #F7F2EA;
701
+ --mirk-bg: #F7F2EA;
702
+ --mirk-fg: #2B241B;
703
+ --mirk-accent: #efefe5;
704
+ --mirk-destructive: #C24A3A;
705
+ --mirk-focus-color: #C7AE93;
706
+
707
+ --mirk-bevel-bg: #FCF8F1;
708
+ --mirk-bevel-fg: #2B241B;
709
+ --mirk-bevel-tl: #F0E7D8;
710
+ --mirk-bevel-br: #E2D4BF;
711
+ --mirk-bevel-hover-bg: #F4ECDF;
712
+ --mirk-pill-inner-top: #FBF6EE;
713
+ --mirk-input-border: #D8C8AF;
714
+ --mirk-placeholder-color: #A8987F;
715
+
716
+ --mirk-mark-fg: #6B5942;
717
+ --mirk-toggle-bg: #EFDBBD;
718
+ --mirk-toggle-hi: #F4EADA;
719
+ --mirk-toggle-lo: #C2A87E;
720
+ --mirk-sortable-dot: #DDCBB0;
721
+ --mirk-sortable-shadow: #C9B493;
722
+ --mirk-sortable-label: #8C7B62;
723
+ --mirk-sortable-placeholder: #A8987F;
724
+
725
+ --mirk-radius: 5px;
726
+ --mirk-focus-offset: 2px;
727
+ }
728
+
729
+ /* dark token deltas, shared by the explicit .dark opt-in and OS preference */
730
+ .hcms-shell.pixel-quiet.dark,
731
+ .hcms-shell.pixel-quiet[data-theme="dark"] {
732
+ color-scheme: dark;
733
+ --mirk-canvas: #0B0C13;
734
+ --mirk-bg: #11131E;
735
+ --mirk-fg: #ECEAF2;
736
+ --mirk-accent: #1D1F2F;
737
+ --mirk-focus-color: #4A506B;
738
+
739
+ --mirk-bevel-bg: #1A1D2C;
740
+ --mirk-bevel-fg: #ECEAF2;
741
+ --mirk-bevel-tl: #2A2E42;
742
+ --mirk-bevel-br: #14182A;
743
+ --mirk-bevel-hover-bg: #202436;
744
+ --mirk-pill-inner-top: #202436;
745
+ --mirk-input-border: #353B52;
746
+ --mirk-placeholder-color: #6A7090;
747
+
748
+ --mirk-mark-fg: #C9CDE0;
749
+ --mirk-toggle-bg: #3E4660;
750
+ --mirk-toggle-hi: #4E567A;
751
+ --mirk-toggle-lo: #262B42;
752
+ --mirk-sortable-dot: #353B52;
753
+ --mirk-sortable-shadow: #0E1120;
754
+ --mirk-sortable-label: #8A90AB;
755
+ --mirk-sortable-placeholder: #6A7090;
756
+ }
757
+
758
+ /* Auto-dark on OS preference, unless the shell pins light with .light */
759
+ @media (prefers-color-scheme: dark) {
760
+ .hcms-shell.pixel-quiet:not(.light):not([data-theme="light"]) {
761
+ color-scheme: dark;
762
+ --mirk-canvas: #0B0C13;
763
+ --mirk-bg: #11131E;
764
+ --mirk-fg: #ECEAF2;
765
+ --mirk-accent: #1D1F2F;
766
+ --mirk-focus-color: #4A506B;
767
+
768
+ --mirk-bevel-bg: #1A1D2C;
769
+ --mirk-bevel-fg: #ECEAF2;
770
+ --mirk-bevel-tl: #2A2E42;
771
+ --mirk-bevel-br: #14182A;
772
+ --mirk-bevel-hover-bg: #202436;
773
+ --mirk-pill-inner-top: #202436;
774
+ --mirk-input-border: #353B52;
775
+ --mirk-placeholder-color: #6A7090;
776
+
777
+ --mirk-mark-fg: #C9CDE0;
778
+ --mirk-toggle-bg: #3E4660;
779
+ --mirk-toggle-hi: #4E567A;
780
+ --mirk-toggle-lo: #262B42;
781
+ --mirk-sortable-dot: #353B52;
782
+ --mirk-sortable-shadow: #0E1120;
783
+ --mirk-sortable-label: #8A90AB;
784
+ --mirk-sortable-placeholder: #6A7090;
785
+ }
786
+ }
787
+
788
+ /* ============================================================
789
+ SHELL GEOMETRY \u2014 fixed, docked panel, single column.
790
+ position: fixed makes the shell a containing block so the absolute
791
+ minibar anchors to it; flex column so the body owns the scroll.
792
+ ============================================================ */
793
+ .hcms-shell.pixel-quiet {
77
794
  box-sizing: border-box;
78
795
  position: fixed;
79
796
  top: 0;
80
- bottom: 0;
81
797
  right: 0;
82
- width: 100vw;
83
- max-width: 400px;
84
- overflow-y: auto;
85
- border-left: 1px solid var(--hcms-border);
798
+ bottom: 0;
799
+ width: 380px;
800
+ max-width: 100vw;
86
801
  z-index: 2147483000;
87
802
  display: flex;
88
803
  flex-direction: column;
89
- box-shadow: -4px 0 24px rgba(15, 23, 42, 0.08);
804
+ color: var(--mirk-fg);
805
+ background: var(--mirk-bg);
806
+ border-left: 1px solid var(--mirk-input-border);
807
+ box-shadow: -16px 0 48px -28px rgba(43, 36, 27, 0.45);
808
+ }
809
+ .hcms-shell.pixel-quiet.dark {
810
+ box-shadow: -16px 0 48px -28px rgba(0, 0, 0, 0.6);
90
811
  }
91
812
 
92
- .hcms-shell.hcms-side-left {
93
- left: 0;
813
+ .hcms-shell.pixel-quiet.hcms-side-left {
94
814
  right: auto;
815
+ left: 0;
95
816
  border-left: 0;
96
- border-right: 1px solid var(--hcms-border);
97
- box-shadow: 4px 0 24px rgba(15, 23, 42, 0.08);
817
+ border-right: 1px solid var(--mirk-input-border);
818
+ box-shadow: 16px 0 48px -28px rgba(43, 36, 27, 0.45);
98
819
  }
99
820
 
100
- .hcms-shell * {
101
- box-sizing: border-box;
821
+ /* Push the page over so docked content is never hidden underneath. */
822
+ body.hcms-open:not(.hcms-overlay) { padding-right: 380px; }
823
+ body.hcms-open.hcms-side-left:not(.hcms-overlay) { padding-right: 0; padding-left: 380px; }
824
+ body.hcms-open.hcms-overlay { overflow: hidden; }
825
+
826
+ @media (max-width: 799px) {
827
+ .hcms-shell.pixel-quiet { width: 100vw; }
828
+ body.hcms-open:not(.hcms-overlay),
829
+ body.hcms-open.hcms-side-left:not(.hcms-overlay) { padding-right: 0; padding-left: 0; }
830
+ body.hcms-open { overflow: hidden; }
102
831
  }
103
832
 
104
- .hcms-shell-header {
833
+ /* ---------- SCROLL REGION \u2014 holds the (scrollable) header + form + save ---------- */
834
+ .hcms-shell-body {
835
+ flex: 1;
836
+ min-height: 0;
837
+ overflow-y: auto;
838
+ }
839
+
840
+ /* ---------- CONDENSED MINIBAR \u2014 appears once the full header scrolls away ---------- */
841
+ .hcms-shell-minibar {
842
+ position: absolute;
843
+ top: 0;
844
+ left: 0;
845
+ right: 0;
846
+ z-index: 2;
105
847
  display: flex;
106
848
  align-items: center;
107
849
  justify-content: space-between;
108
- padding: 16px;
109
- border-bottom: 1px solid var(--hcms-border);
850
+ gap: 12px;
851
+ padding: 9px 24px 10px;
852
+ background: var(--mirk-bg);
853
+ border-bottom: 1px solid var(--mirk-input-border);
854
+ opacity: 0;
855
+ transform: translateY(-100%);
856
+ pointer-events: none;
857
+ transition: opacity 140ms ease, transform 160ms ease;
858
+ }
859
+ .hcms-shell.is-condensed .hcms-shell-minibar {
860
+ opacity: 1;
861
+ transform: none;
862
+ pointer-events: auto;
863
+ }
864
+ .hcms-shell-minibar-title {
865
+ font-size: 14px;
866
+ line-height: 1;
867
+ color: var(--mirk-fg);
868
+ white-space: nowrap;
869
+ overflow: hidden;
870
+ text-overflow: ellipsis;
110
871
  }
111
872
 
873
+ /* ---------- HEADER (no underline rule \u2014 whitespace separates the bands) ---------- */
874
+ .hcms-shell-header {
875
+ flex-shrink: 0;
876
+ display: flex;
877
+ align-items: flex-start;
878
+ justify-content: space-between;
879
+ gap: 12px;
880
+ padding: 24px 24px 4px;
881
+ }
882
+ .hcms-shell-heading { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
883
+ .hcms-shell-eyebrow {
884
+ font-size: 11px;
885
+ text-transform: uppercase;
886
+ letter-spacing: 0.18em;
887
+ color: var(--mirk-placeholder-color);
888
+ }
112
889
  .hcms-shell-title {
113
890
  margin: 0;
114
- font-size: 16px;
115
- font-weight: 600;
891
+ font-size: 18px;
892
+ font-weight: 400;
893
+ line-height: 1.2;
894
+ color: var(--mirk-fg);
116
895
  }
117
-
118
- .hcms-shell-close {
119
- background: transparent;
120
- border: 0;
121
- color: var(--hcms-muted);
122
- font-size: 24px;
896
+ .hcms-shell-close.mirk-button {
897
+ flex-shrink: 0;
898
+ padding: 2px 9px 3px;
123
899
  line-height: 1;
124
- cursor: pointer;
125
- padding: 4px 8px;
126
- border-radius: 6px;
127
- }
128
- .hcms-shell-close:hover { background: rgba(15, 23, 42, 0.06); color: var(--hcms-text); }
129
-
130
- .hcms-shell-error {
131
- margin: 12px 16px;
132
- padding: 10px 12px;
133
- background: #fef2f2;
134
- border: 1px solid #fecaca;
135
- color: var(--hcms-error);
136
- border-radius: 6px;
137
- font-size: 13px;
138
900
  }
901
+ .hcms-shell-close .mirk-button__label { font-size: 16px; }
139
902
 
903
+ /* ---------- FORM \u2014 generous, even vertical rhythm ---------- */
140
904
  .hcms-form {
141
- flex: 1;
142
- padding: 16px;
143
905
  display: flex;
144
906
  flex-direction: column;
145
- gap: 16px;
907
+ gap: 26px;
908
+ padding: 24px 24px 28px;
146
909
  }
147
910
 
148
- .hcms-field {
149
- display: flex;
150
- flex-direction: column;
151
- gap: 4px;
911
+ /* one labeled scalar field */
912
+ .hcms-field { display: flex; flex-direction: column; gap: 9px; }
913
+ .hcms-field--row {
914
+ flex-direction: row;
915
+ align-items: center;
916
+ justify-content: space-between;
152
917
  }
153
918
 
919
+ /* themed field label */
154
920
  .hcms-label {
155
- font-size: 12px;
156
- font-weight: 600;
157
- color: var(--hcms-muted);
921
+ font-size: 11px;
158
922
  text-transform: uppercase;
159
- letter-spacing: 0.04em;
923
+ letter-spacing: 0.14em;
924
+ color: var(--mirk-sortable-label);
160
925
  }
161
926
 
162
- .hcms-input {
163
- font-family: inherit;
164
- font-size: 14px;
165
- padding: 8px 10px;
166
- border: 1px solid var(--hcms-border);
167
- border-radius: 6px;
168
- background: #fdfdfd;
169
- color: var(--hcms-text);
170
- width: 100%;
927
+ /* comfortable control padding + readable size, in mirk's own mono */
928
+ .hcms-shell.pixel-quiet .mirk-input,
929
+ .hcms-shell.pixel-quiet .mirk-textarea {
930
+ font-size: 15px;
931
+ padding: 9px 14px 10px;
171
932
  }
172
- .hcms-input:focus {
173
- outline: 2px solid var(--hcms-primary);
174
- outline-offset: -1px;
175
- border-color: var(--hcms-primary);
933
+ .hcms-shell.pixel-quiet textarea.mirk-input { min-height: 76px; resize: vertical; }
934
+ .hcms-shell.pixel-quiet .mirk-select__field {
935
+ font-size: 15px;
936
+ padding: 8px 40px 9px 14px;
176
937
  }
938
+ .hcms-shell.pixel-quiet .mirk-radio__label,
939
+ .hcms-shell.pixel-quiet .mirk-toggle__label,
940
+ .hcms-shell.pixel-quiet .mirk-tags__input { font-size: 15px; }
177
941
 
178
- textarea.hcms-input { min-height: 80px; resize: vertical; }
942
+ /* inline radio row */
943
+ .hcms-radio-row { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
179
944
 
945
+ /* ---------- OBJECT GROUP \u2014 a quiet framed band, not a heavy card ---------- */
180
946
  .hcms-object {
181
947
  display: flex;
182
948
  flex-direction: column;
183
- gap: 12px;
184
- padding: 12px;
185
- border: 1px solid var(--hcms-border);
186
- border-radius: 8px;
187
- background: #fdfdfd;
949
+ gap: 16px;
950
+ }
951
+ .hcms-object-title {
952
+ margin: 0;
953
+ font-size: 11px;
954
+ font-weight: 400;
955
+ text-transform: uppercase;
956
+ letter-spacing: 0.14em;
957
+ color: var(--mirk-sortable-label);
188
958
  }
959
+ .hcms-object-fields { display: flex; flex-direction: column; gap: 16px; }
189
960
 
190
- .hcms-object-title,
961
+ /* ---------- SCALAR ARRAY \u2014 a calm list of mirk-input rows ---------- */
962
+ .hcms-array { display: flex; flex-direction: column; gap: 14px; }
963
+ .hcms-array-header { display: flex; align-items: baseline; justify-content: space-between; }
191
964
  .hcms-array-title {
192
- margin: 0 0 8px;
193
- font-size: 13px;
194
- font-weight: 600;
195
- color: var(--hcms-muted);
965
+ margin: 0;
966
+ font-size: 11px;
967
+ font-weight: 400;
196
968
  text-transform: uppercase;
197
- letter-spacing: 0.04em;
969
+ letter-spacing: 0.14em;
970
+ color: var(--mirk-sortable-label);
198
971
  }
199
-
200
- .hcms-array {
972
+ /* The generic stacked-list layout is unlayered, so it would beat mirk's
973
+ @layer-components rules on any slot that is also a mirk component. Exempt a
974
+ mirk tags box so it keeps mirk's own row-wrap layout and inner padding. */
975
+ .hcms-array-items:not(.mirk-tags) {
976
+ list-style: none;
977
+ margin: 0;
978
+ padding: 0;
201
979
  display: flex;
202
980
  flex-direction: column;
203
- gap: 8px;
981
+ gap: 10px;
204
982
  }
205
-
206
- .hcms-array-header {
983
+ .hcms-array-item {
207
984
  display: flex;
208
- justify-content: space-between;
209
- align-items: baseline;
985
+ align-items: center;
986
+ gap: 8px;
210
987
  }
988
+ .hcms-array-item .mirk-input { flex: 1; min-width: 0; }
211
989
 
212
- .hcms-array-items {
213
- display: flex;
214
- flex-direction: column;
215
- gap: 8px;
216
- list-style: none;
990
+ /* ---------- OBJECT ARRAY \u2014 mirk-sortable cards from the engine markup ---------- */
991
+ .hcms-array--cards .hcms-array-items { gap: 14px; }
992
+ .hcms-card.mirk-sortable__item { background: var(--mirk-bevel-bg); position: relative; }
993
+ .hcms-card .hcms-card-fields { display: flex; flex-direction: column; flex: 1; min-width: 0; }
994
+ .hcms-card .hcms-field {
995
+ gap: 2px;
996
+ padding: 8px 14px 9px;
997
+ }
998
+ .hcms-card .hcms-field:not(:last-child) { border-bottom: 1px solid var(--mirk-input-border); }
999
+ .hcms-card .hcms-label { letter-spacing: 0.16em; }
1000
+ /* fields inside a card read as quiet rows, not chunky boxed inputs */
1001
+ .hcms-card .mirk-input,
1002
+ .hcms-card .mirk-textarea {
1003
+ border: none;
1004
+ background: transparent;
217
1005
  padding: 0;
218
- margin: 0;
1006
+ font-size: 15px;
219
1007
  }
220
-
221
- .hcms-array-item,
222
- .hcms-card {
1008
+ .hcms-card .mirk-input:focus-visible,
1009
+ .hcms-card .mirk-textarea:focus-visible { outline: none; }
1010
+ /* the remove \xD7 is pulled out to the card corner (below), so the controls row
1011
+ now only holds the sr-only move buttons \u2014 collapse it until one is focused. */
1012
+ .hcms-card-controls {
223
1013
  display: flex;
224
1014
  align-items: center;
225
- gap: 8px;
226
- padding: 8px;
227
- background: #fdfdfd;
228
- border: 1px solid var(--hcms-border);
229
- border-radius: 6px;
1015
+ justify-content: flex-end;
1016
+ gap: 6px;
1017
+ padding: 0;
230
1018
  }
231
1019
 
232
- .hcms-card {
233
- flex-direction: column;
234
- align-items: stretch;
235
- padding: 12px;
236
- gap: 10px;
1020
+ /* quiet \xD7 remove control, shared by scalar-array rows and object-array cards */
1021
+ .hcms-remove {
1022
+ flex-shrink: 0;
1023
+ appearance: none;
1024
+ border: 0;
1025
+ background: none;
1026
+ color: var(--mirk-placeholder-color);
1027
+ cursor: pointer;
1028
+ font-size: 16px;
1029
+ line-height: 1;
1030
+ padding: 2px 6px;
237
1031
  }
1032
+ .hcms-remove:hover { color: var(--mirk-destructive); }
1033
+ .hcms-remove[hidden] { display: none; }
238
1034
 
239
- .hcms-card-header {
1035
+ /* object-array card: the delete control is a square corner button pinned
1036
+ top-right, carrying the card's own 1px border + a crisp-line \xD7 icon. */
1037
+ .hcms-remove--card {
1038
+ position: absolute;
1039
+ top: -1px;
1040
+ right: -1px;
1041
+ width: 18px;
1042
+ height: 18px;
1043
+ padding: 0;
240
1044
  display: flex;
241
- justify-content: space-between;
242
1045
  align-items: center;
1046
+ justify-content: center;
1047
+ border: 1px solid var(--mirk-input-border);
1048
+ background: var(--mirk-bevel-bg);
1049
+ color: var(--mirk-placeholder-color);
243
1050
  }
1051
+ .hcms-remove--card:hover { border-color: var(--mirk-destructive); }
1052
+ .hcms-remove--card .hcms-x { width: 64%; height: 64%; display: block; }
244
1053
 
245
- .hcms-card-fields {
246
- display: flex;
247
- flex-direction: column;
248
- gap: 10px;
249
- }
1054
+ /* "+ Add" \u2014 quiet, pinned left */
1055
+ .hcms-add.mirk-button { align-self: flex-start; }
250
1056
 
251
- .hcms-drag-handle {
252
- cursor: grab;
253
- color: var(--hcms-muted);
254
- user-select: none;
255
- font-family: monospace;
256
- font-size: 14px;
1057
+ /* ---------- UPLOAD COMPONENTS (@file / @image) ----------
1058
+ Built on the kit's mirk-file / mirk-image--compact chrome. The native picker
1059
+ is visually hidden but focusable (the mirk-button label is the visible
1060
+ trigger and rings via :has(:focus-visible)); it is NOT .mirk-*__input, so the
1061
+ vendored mirk runtime never handles it. The empty/filled chrome is driven by
1062
+ the bound leaf's value attribute (src/href) in CSS \u2014 no JS state to desync. */
1063
+ .hcms-upload input[type="file"] {
1064
+ position: absolute;
1065
+ width: 1px;
1066
+ height: 1px;
1067
+ padding: 0;
1068
+ margin: -1px;
1069
+ overflow: hidden;
1070
+ clip: rect(0, 0, 0, 0);
1071
+ white-space: nowrap;
1072
+ border: 0;
257
1073
  }
258
1074
 
259
- .hcms-remove,
260
- .hcms-add {
261
- font-family: inherit;
262
- background: transparent;
263
- border: 1px solid var(--hcms-border);
264
- border-radius: 6px;
265
- padding: 4px 10px;
266
- cursor: pointer;
267
- font-size: 13px;
268
- color: var(--hcms-muted);
269
- }
270
- .hcms-remove:hover { color: var(--hcms-error); border-color: #fecaca; }
271
- .hcms-add { align-self: flex-start; padding: 6px 12px; color: var(--hcms-text); }
272
- .hcms-add:hover { border-color: var(--hcms-primary); color: var(--hcms-primary); }
1075
+ /* @image: show the upload button until the bound <img> carries a real src. */
1076
+ .hcms-upload--image .mirk-image__thumb { display: none; }
1077
+ .hcms-upload--image:has(.mirk-image__preview[src]:not([src=""])) .mirk-image__upload { display: none; }
1078
+ .hcms-upload--image:has(.mirk-image__preview[src]:not([src=""])) .mirk-image__thumb { display: inline-block; }
273
1079
 
274
- .hcms-error {
275
- margin: 6px 0;
276
- padding: 6px 10px;
277
- background: #fef2f2;
278
- border: 1px solid #fecaca;
279
- color: var(--hcms-error);
280
- border-radius: 6px;
281
- font-size: 12px;
1080
+ /* @file: reveal the clear \xD7 and the filename only once the bound <a> has href. */
1081
+ .hcms-upload--file .hcms-upload-clear { display: none; }
1082
+ .hcms-upload--file:has(a.mirk-file__name[href]:not([href=""])) .hcms-upload-clear { display: inline-flex; }
1083
+ /* A filled filename uses the bright foreground (the kit's [data-filled] look),
1084
+ driven by the bound href so there's no JS attribute to keep in sync \u2014 the
1085
+ vendored runtime that would otherwise stamp data-filled is inert here. */
1086
+ .hcms-upload--file:has(a.mirk-file__name[href]:not([href=""])) a.mirk-file__name {
1087
+ color: var(--mirk-bevel-fg);
282
1088
  }
283
- .hcms-error[hidden] { display: none; }
284
-
285
- .hcms-shell-footer {
286
- border-top: 1px solid var(--hcms-border);
287
- padding: 12px 16px;
288
- display: flex;
289
- justify-content: flex-end;
1089
+ .hcms-upload--file a.mirk-file__name:empty {
1090
+ text-decoration: none;
1091
+ cursor: default;
1092
+ }
1093
+ .hcms-upload--file a.mirk-file__name:empty::after {
1094
+ content: "No file chosen";
1095
+ color: var(--mirk-placeholder-color);
290
1096
  }
291
1097
 
292
- .hcms-shell-save {
293
- font-family: inherit;
294
- background: var(--hcms-primary);
295
- color: #fdfdfd;
1098
+ /* clear-\xD7 (vendored-inert; data-hcms-action, never .mirk-*__remove). Bare \xD7 for
1099
+ @file, a pinned corner badge for @image \u2014 mirroring .hcms-remove / --card. */
1100
+ .hcms-upload-clear {
1101
+ flex-shrink: 0;
1102
+ appearance: none;
296
1103
  border: 0;
297
- border-radius: 6px;
298
- padding: 8px 16px;
299
- font-size: 14px;
1104
+ background: none;
1105
+ color: var(--mirk-placeholder-color);
300
1106
  cursor: pointer;
301
- font-weight: 500;
1107
+ line-height: 0;
1108
+ padding: 2px 4px;
1109
+ display: inline-flex;
1110
+ align-items: center;
1111
+ justify-content: center;
302
1112
  }
303
- .hcms-shell-save:hover { filter: brightness(1.08); }
1113
+ .hcms-upload-clear:hover { color: var(--mirk-destructive); }
1114
+ .hcms-upload-clear .hcms-x { display: block; width: 14px; height: 14px; }
304
1115
 
305
- @media (max-width: 799px) {
306
- .hcms-shell { max-width: 100vw; }
1116
+ .hcms-upload-clear--badge {
1117
+ position: absolute;
1118
+ top: -7px;
1119
+ right: -7px;
1120
+ width: 18px;
1121
+ height: 18px;
1122
+ padding: 0;
1123
+ border-radius: 50%;
1124
+ border: 1px solid var(--mirk-input-border);
1125
+ background: var(--mirk-bevel-bg);
1126
+ color: var(--mirk-bevel-fg);
307
1127
  }
1128
+ .hcms-upload-clear--badge:hover { color: var(--mirk-destructive); border-color: var(--mirk-destructive); }
1129
+ .hcms-upload-clear--badge .hcms-x { width: 10px; height: 10px; }
308
1130
 
309
- /* Scroll lock only when the sidebar covers the page (overlay + mobile fullscreen). In push mode the page keeps its own scroll. */
310
- body.hcms-open.hcms-overlay {
311
- overflow: hidden;
1131
+ /* ---------- ERROR BANNER + inline errors ---------- */
1132
+ .hcms-shell-error,
1133
+ .hcms-error {
1134
+ font-size: 12px;
1135
+ line-height: 1.45;
1136
+ color: var(--mirk-destructive);
1137
+ background: var(--mirk-bevel-bg);
1138
+ border: 1px solid var(--mirk-destructive);
1139
+ padding: 8px 12px;
312
1140
  }
1141
+ .hcms-shell-error { margin: 0 24px; }
1142
+ .hcms-error { margin-top: 6px; }
1143
+ .hcms-shell-error[hidden],
1144
+ .hcms-error[hidden] { display: none; }
313
1145
 
314
- body.hcms-open:not(.hcms-overlay) {
315
- padding-right: 400px;
316
- }
317
- body.hcms-open.hcms-side-left:not(.hcms-overlay) {
318
- padding-right: 0;
319
- padding-left: 400px;
320
- }
321
- @media (max-width: 799px) {
322
- body.hcms-open:not(.hcms-overlay),
323
- body.hcms-open.hcms-side-left:not(.hcms-overlay) {
324
- padding-right: 0;
325
- padding-left: 0;
326
- }
327
- body.hcms-open {
328
- overflow: hidden;
329
- }
1146
+ /* ---------- SAVE (sits at the end of the scrolling form, not pinned) ---------- */
1147
+ .hcms-shell-footer {
1148
+ display: flex;
1149
+ justify-content: flex-end;
1150
+ padding: 4px 24px 28px;
330
1151
  }
1152
+ .hcms-shell-footer[hidden] { display: none; }
331
1153
 
332
- /* sr-only: visually hidden but accessible to screen readers + becomes
333
- visible on keyboard focus, so keyboard users can see move buttons land. */
1154
+ /* ---------- sr-only move buttons: hidden, visible on keyboard focus ---------- */
334
1155
  .hcms-sr-only {
335
1156
  position: absolute;
336
1157
  width: 1px;
@@ -351,15 +1172,14 @@ body.hcms-open.hcms-side-left:not(.hcms-overlay) {
351
1172
  overflow: visible;
352
1173
  clip: auto;
353
1174
  white-space: normal;
354
- background: #F6F7F9;
355
- border: 1px solid #c0c8d6;
356
- border-radius: 3px;
357
- color: #1f2532;
1175
+ background: var(--mirk-bevel-bg);
1176
+ border: 1px solid var(--mirk-input-border);
1177
+ color: var(--mirk-fg);
358
1178
  font-size: 12px;
359
1179
  cursor: pointer;
360
1180
  }
361
1181
  .hcms-sr-only[hidden] { display: none; }
362
- `;dr(mr);var Qn=bt,eo={cms:bt};return Sr(to);})();
1182
+ `;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-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)})})})();Mr(Or);var qi=Mt,$i={cms:Mt};return Fr(Di);})();
363
1183
 
364
1184
  // Auto-export to window unless suppressed by loader.
365
1185
  // Per hypercms plan locked decision 3: flatten to hyperclay.hypercms.open(),