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