hyper-html-api 0.5.1 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/conformance/MANIFEST.json +6 -0
- package/conformance/cases/basic-scalar-and-list.expected.json +7 -0
- package/conformance/cases/basic-scalar-and-list.html +4 -0
- package/conformance/cases/basic-scalar-and-list.meta +4 -0
- package/conformance/cases/basic-scalar-and-list.parsed.json +4 -0
- package/conformance/cases/basic-scalar-and-list.rules +1 -0
- package/conformance/cases/cms-template-skipped-by-default.expected.json +7 -0
- package/conformance/cases/cms-template-skipped-by-default.html +7 -0
- package/conformance/cases/cms-template-skipped-by-default.meta +7 -0
- package/conformance/cases/cms-template-skipped-by-default.parsed.json +5 -0
- package/conformance/cases/cms-template-skipped-by-default.rules +1 -0
- package/conformance/cases/depth-at-limit-ok.expected.json +41 -0
- package/conformance/cases/depth-at-limit-ok.html +3 -0
- package/conformance/cases/depth-at-limit-ok.meta +6 -0
- package/conformance/cases/depth-at-limit-ok.parsed.json +41 -0
- package/conformance/cases/depth-at-limit-ok.rules +1 -0
- package/conformance/cases/depth-exceeded-path-contains-selector.error.json +5 -0
- package/conformance/cases/depth-exceeded-path-contains-selector.html +3 -0
- package/conformance/cases/depth-exceeded-path-contains-selector.meta +9 -0
- package/conformance/cases/depth-exceeded-path-contains-selector.parsed.json +43 -0
- package/conformance/cases/depth-exceeded-path-contains-selector.rules +1 -0
- package/conformance/cases/depth-exceeded.error.json +5 -0
- package/conformance/cases/depth-exceeded.html +3 -0
- package/conformance/cases/depth-exceeded.meta +6 -0
- package/conformance/cases/depth-exceeded.parsed.json +43 -0
- package/conformance/cases/depth-exceeded.rules +1 -0
- package/conformance/cases/props-boolean-on-any-element.expected.json +5 -0
- package/conformance/cases/props-boolean-on-any-element.html +3 -0
- package/conformance/cases/props-boolean-on-any-element.meta +7 -0
- package/conformance/cases/props-boolean-on-any-element.parsed.json +5 -0
- package/conformance/cases/props-boolean-on-any-element.rules +1 -0
- package/conformance/cases/props-empty-attr-vs-empty-prop.expected.json +4 -0
- package/conformance/cases/props-empty-attr-vs-empty-prop.html +3 -0
- package/conformance/cases/props-empty-attr-vs-empty-prop.meta +6 -0
- package/conformance/cases/props-empty-attr-vs-empty-prop.parsed.json +4 -0
- package/conformance/cases/props-empty-attr-vs-empty-prop.rules +1 -0
- package/conformance/cases/props-null-set.expected.json +9 -0
- package/conformance/cases/props-null-set.html +3 -0
- package/conformance/cases/props-null-set.meta +7 -0
- package/conformance/cases/props-null-set.parsed.json +9 -0
- package/conformance/cases/props-null-set.rules +1 -0
- package/conformance/cases/props-readonly-always-false.expected.json +4 -0
- package/conformance/cases/props-readonly-always-false.html +4 -0
- package/conformance/cases/props-readonly-always-false.meta +11 -0
- package/conformance/cases/props-readonly-always-false.parsed.json +4 -0
- package/conformance/cases/props-readonly-always-false.rules +1 -0
- package/conformance/cases/props-select-textarea-value-null.expected.json +5 -0
- package/conformance/cases/props-select-textarea-value-null.html +5 -0
- package/conformance/cases/props-select-textarea-value-null.meta +8 -0
- package/conformance/cases/props-select-textarea-value-null.parsed.json +5 -0
- package/conformance/cases/props-select-textarea-value-null.rules +1 -0
- package/conformance/cases/props-tagname-and-nodetype.expected.json +5 -0
- package/conformance/cases/props-tagname-and-nodetype.html +3 -0
- package/conformance/cases/props-tagname-and-nodetype.meta +6 -0
- package/conformance/cases/props-tagname-and-nodetype.parsed.json +5 -0
- package/conformance/cases/props-tagname-and-nodetype.rules +1 -0
- package/conformance/cases/props-type-is-node-type.expected.json +5 -0
- package/conformance/cases/props-type-is-node-type.html +5 -0
- package/conformance/cases/props-type-is-node-type.meta +11 -0
- package/conformance/cases/props-type-is-node-type.parsed.json +5 -0
- package/conformance/cases/props-type-is-node-type.rules +1 -0
- package/conformance/cases/rules-duplicate-keys-last-wins.expected.json +3 -0
- package/conformance/cases/rules-duplicate-keys-last-wins.html +4 -0
- package/conformance/cases/rules-duplicate-keys-last-wins.meta +5 -0
- package/conformance/cases/rules-duplicate-keys-last-wins.parsed.json +3 -0
- package/conformance/cases/rules-duplicate-keys-last-wins.rules +1 -0
- package/conformance/cases/rules-iterate-dot-leading-works.expected.json +10 -0
- package/conformance/cases/rules-iterate-dot-leading-works.html +3 -0
- package/conformance/cases/rules-iterate-dot-leading-works.meta +6 -0
- package/conformance/cases/rules-iterate-dot-leading-works.parsed.json +8 -0
- package/conformance/cases/rules-iterate-dot-leading-works.rules +1 -0
- package/conformance/cases/rules-iterate-lookahead-quoted.error.json +5 -0
- package/conformance/cases/rules-iterate-lookahead-quoted.html +3 -0
- package/conformance/cases/rules-iterate-lookahead-quoted.meta +7 -0
- package/conformance/cases/rules-iterate-lookahead-quoted.rules +1 -0
- package/conformance/cases/rules-iterate-lookahead-unquoted.error.json +5 -0
- package/conformance/cases/rules-iterate-lookahead-unquoted.html +3 -0
- package/conformance/cases/rules-iterate-lookahead-unquoted.meta +8 -0
- package/conformance/cases/rules-iterate-lookahead-unquoted.parsed.json +3 -0
- package/conformance/cases/rules-iterate-lookahead-unquoted.rules +1 -0
- package/conformance/cases/rules-lastindexof-at-split.expected.json +3 -0
- package/conformance/cases/rules-lastindexof-at-split.html +3 -0
- package/conformance/cases/rules-lastindexof-at-split.meta +11 -0
- package/conformance/cases/rules-lastindexof-at-split.parsed.json +3 -0
- package/conformance/cases/rules-lastindexof-at-split.rules +1 -0
- package/conformance/cases/rules-primitives-extract-null.expected.json +5 -0
- package/conformance/cases/rules-primitives-extract-null.html +3 -0
- package/conformance/cases/rules-primitives-extract-null.meta +6 -0
- package/conformance/cases/rules-primitives-extract-null.parsed.json +5 -0
- package/conformance/cases/rules-primitives-extract-null.rules +1 -0
- package/conformance/cases/rules-proto-key-omitted.expected.json +3 -0
- package/conformance/cases/rules-proto-key-omitted.html +3 -0
- package/conformance/cases/rules-proto-key-omitted.meta +7 -0
- package/conformance/cases/rules-proto-key-omitted.parsed.json +6 -0
- package/conformance/cases/rules-proto-key-omitted.rules +1 -0
- package/conformance/cases/rules-quoted-attr-in-unquoted-selector.error.json +5 -0
- package/conformance/cases/rules-quoted-attr-in-unquoted-selector.html +4 -0
- package/conformance/cases/rules-quoted-attr-in-unquoted-selector.meta +5 -0
- package/conformance/cases/rules-quoted-attr-in-unquoted-selector.rules +1 -0
- package/conformance/cases/rules-trailing-comma-dropped.expected.json +3 -0
- package/conformance/cases/rules-trailing-comma-dropped.html +3 -0
- package/conformance/cases/rules-trailing-comma-dropped.meta +5 -0
- package/conformance/cases/rules-trailing-comma-dropped.parsed.json +3 -0
- package/conformance/cases/rules-trailing-comma-dropped.rules +1 -0
- package/conformance/cases/rules-unwhitelisted-pseudo-breaks-tokenizer.error.json +5 -0
- package/conformance/cases/rules-unwhitelisted-pseudo-breaks-tokenizer.html +3 -0
- package/conformance/cases/rules-unwhitelisted-pseudo-breaks-tokenizer.meta +7 -0
- package/conformance/cases/rules-unwhitelisted-pseudo-breaks-tokenizer.rules +1 -0
- package/conformance/cases/rules-whitespace-clings.expected.json +4 -0
- package/conformance/cases/rules-whitespace-clings.html +4 -0
- package/conformance/cases/rules-whitespace-clings.meta +6 -0
- package/conformance/cases/rules-whitespace-clings.parsed.json +4 -0
- package/conformance/cases/rules-whitespace-clings.rules +1 -0
- package/conformance/cases/selector-unknown-pseudo-is-500.error.json +5 -0
- package/conformance/cases/selector-unknown-pseudo-is-500.html +4 -0
- package/conformance/cases/selector-unknown-pseudo-is-500.meta +7 -0
- package/conformance/cases/selector-unknown-pseudo-is-500.parsed.json +3 -0
- package/conformance/cases/selector-unknown-pseudo-is-500.rules +1 -0
- package/conformance/cases/tag-basic.expected.json +7 -0
- package/conformance/cases/tag-basic.html +5 -0
- package/conformance/cases/tag-basic.meta +6 -0
- package/conformance/cases/tag-basic.parsed.json +4 -0
- package/conformance/cases/tag-duplicate-names-first-wins.expected.json +3 -0
- package/conformance/cases/tag-duplicate-names-first-wins.html +6 -0
- package/conformance/cases/tag-duplicate-names-first-wins.meta +7 -0
- package/conformance/cases/tag-duplicate-names-first-wins.parsed.json +3 -0
- package/conformance/cases/tag-missing.error.json +5 -0
- package/conformance/cases/tag-missing.html +4 -0
- package/conformance/cases/tag-missing.meta +8 -0
- package/conformance/cases/tag-name-is-space-separated.expected.json +3 -0
- package/conformance/cases/tag-name-is-space-separated.html +4 -0
- package/conformance/cases/tag-name-is-space-separated.meta +6 -0
- package/conformance/cases/tag-name-is-space-separated.parsed.json +3 -0
- package/conformance/cases/tag-relaxed-body.expected.json +7 -0
- package/conformance/cases/tag-relaxed-body.html +5 -0
- package/conformance/cases/tag-relaxed-body.meta +7 -0
- package/conformance/cases/tag-relaxed-body.parsed.json +4 -0
- package/conformance/cases/tag-wrong-version.error.json +5 -0
- package/conformance/cases/tag-wrong-version.html +4 -0
- package/conformance/cases/tag-wrong-version.meta +6 -0
- package/conformance/cases/template-simple-vs-combinator.expected.json +7 -0
- package/conformance/cases/template-simple-vs-combinator.html +4 -0
- package/conformance/cases/template-simple-vs-combinator.meta +8 -0
- package/conformance/cases/template-simple-vs-combinator.parsed.json +4 -0
- package/conformance/cases/template-simple-vs-combinator.rules +1 -0
- package/conformance/cases/text-root-leaks-rules-tag.expected.json +4 -0
- package/conformance/cases/text-root-leaks-rules-tag.html +4 -0
- package/conformance/cases/text-root-leaks-rules-tag.meta +7 -0
- package/conformance/cases/text-root-leaks-rules-tag.parsed.json +4 -0
- package/conformance/cases/text-root-leaks-rules-tag.rules +1 -0
- package/conformance/cases/text-trim-asymmetry.expected.json +5 -0
- package/conformance/cases/text-trim-asymmetry.html +5 -0
- package/conformance/cases/text-trim-asymmetry.meta +6 -0
- package/conformance/cases/text-trim-asymmetry.parsed.json +5 -0
- package/conformance/cases/text-trim-asymmetry.rules +1 -0
- package/dist/hyper-html-api.engine.min.js +1 -1
- package/dist/hyper-html-api.min.js +4 -3
- package/dist/hyper-html-api.upgrade.min.js +2 -2
- package/package.json +13 -5
- package/src/cms/form-builder.js +3 -2
- package/src/dom-api.js +5 -0
- package/src/engine/apply.js +3 -2
- package/src/engine/diff.js +70 -13
- package/src/engine/extract.js +3 -2
- package/src/engine/index.js +1 -0
- package/src/engine/rule-syntax.js +43 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
var HyperHtmlApi=(()=>{var
|
|
2
|
-
`)?{type:"textarea"}:{type:"text"}}function Bt(e,t){if(!t||e==="."||e===""||e.startsWith("@"))return null;let n=e.includes("@")?e.split("@")[0]:e;if(!n)return null;try{return t.querySelector(n)}catch{return null}}function Wt(e){if(e.type==="textarea")return document.createElement("textarea");if(e.type==="select")return document.createElement("select");let t=document.createElement("input");return t.type=e.type==="checkbox"?"checkbox":e.type==="number"?"number":"text",t}function be(e){return typeof e=="number"?`#${e+1}`:String(e).replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/^\w/,t=>t.toUpperCase())}function Vt(e){return` \xB7 ${e}`}var it={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 qt(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return Math.abs(t).toString(36)}function Kt(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 zt(e,t){let n=[];for(let o of e.attributes||[]){let r=o.name;r==="id"||r==="class"||t.excludeAttributePrefixes.some(s=>r.startsWith(s))||t.includeAttributes.includes(r)&&n.push(`${r}=${o.value}`)}return n.sort().join("|")}function Jt(e,t){return(e.textContent||"").replace(/\s+/g," ").trim().slice(0,t.textHintLength)}function Yt(e,t){let n=[e.tagName];return t.includeClasses&&n.push(Kt(e)),n.push(zt(e,t)),qt(n.join("|"))}function Gt(e){let t=e.tagName,n=1,o=e.previousElementSibling;for(;o;)o.tagName===t&&n++,o=o.previousElementSibling;return n}function Xt(e,t){return e.id||e.getAttribute?.("role")?!0:t.landmarks.includes(e.tagName)}function Zt(e){if(e.id)return`#${e.id}`;let t=e.getAttribute?.("role");return t?`@${t}`:e.tagName}function Qt(e,t){let n=[],o=e;for(;o&&o.tagName&&n.length<t.maxPathDepth;){let r=`${o.tagName}:${Gt(o)}`;if(n.unshift(r),o!==e&&Xt(o,t)){n.unshift(Zt(o));break}o=o.parentElement}return n}function en(e,t){let n=0,o=e.length-1,r=t.length-1;for(;o>=0&&r>=0&&e[o]===t[r];)n++,o--,r--;return n}function j(e,t,n){if(n.has(e))return n.get(e);let o={signature:Yt(e,t),path:Qt(e,t),textHint:Jt(e,t)};return n.set(e,o),o}function ut(e,t,n,o){if(o.has(e))return o.get(e);let r=new Map,s=e.querySelectorAll("*"),a=0;for(let i of s){let c=j(i,t,n);c.domIndex=a++,r.has(c.signature)||r.set(c.signature,[]),r.get(c.signature).push(i)}return o.set(e,r),r}function tn(e,t,n){n.delete(e),t.delete(e);let o=e.querySelectorAll("*");for(let r of o)t.delete(r)}function Ce(e,t,n,o,r){let s=j(e,n,o),a=j(t,n,o),i=n.weights,c={},A=0;if(s.signature!==a.signature)return{score:0,breakdown:{rejected:"signature mismatch"}};A+=i.signature,c.signature=i.signature;let y=en(s.path,a.path)*i.pathSegment;A+=y,c.path=y;let p=!0;if(s.textHint&&a.textHint?s.textHint===a.textHint?(A+=i.textMatch,c.text=i.textMatch):(A-=i.textMismatch,c.text=-i.textMismatch,p=!1):s.textHint!==a.textHint&&(A-=i.textMismatch,c.text=-i.textMismatch,p=!1),r.candidateCount===1&&p&&(A+=i.uniqueCandidate,c.unique=i.uniqueCandidate),typeof s.domIndex=="number"&&typeof a.domIndex=="number"){let R=Math.abs(s.domIndex-a.domIndex),N=Math.min(R*i.positionPenalty,20);A-=N,c.drift=-N}return{score:A,breakdown:c}}function at(e,t,n,o,r){if(n.excludeIds&&e.id)return null;let s=ut(t,n,o,r),a=j(e,n,o);if(typeof a.domIndex!="number"){let p=0,R=e.previousElementSibling;for(;R;)p++,R=R.previousElementSibling;a.domIndex=p}let i=s.get(a.signature)||[],c=n.excludeIds?i.filter(p=>!p.id):i;if(c.length===0)return null;let A=null,x=0,y=null;for(let p of c){let{score:R,breakdown:N}=Ce(e,p,n,o,{candidateCount:c.length});R>x&&(x=R,A=p,y=N)}return x<n.minConfidence?null:{element:A,confidence:x,breakdown:y}}function nn(e,t,n,o){let r=[],s=n.weights.signature+n.weights.slotMatch,a={slot:s};function i(y){if(y.children)return y.children;let p=y.childNodes;if(!p)return[];let R=[];for(let N=0;N<p.length;N++)p[N].nodeType===1&&R.push(p[N]);return R}function c(y,p){let R=i(y),N=i(p);if(R.length===N.length)for(let C=0;C<R.length;C++){let g=R[C],T=N[C];if(n.excludeIds&&(g.id||T.id)||g.tagName!==T.tagName)continue;let E=j(g,n,o).signature,v=j(T,n,o).signature;E!==v&&r.push({newEl:g,oldEl:T,score:s,breakdown:a}),c(g,T)}}function A(y,p){for(;;){if(y.tagName===p.tagName)return[y,p];let R=i(y);if(!y.tagName&&R.length===1){y=R[0];continue}let N=i(p);if(N.length===1&&N[0].tagName===y.tagName){p=N[0];continue}return null}}let x=A(e,t);return x&&c(x[0],x[1]),r}function ct(e,t,n,o,r){let s=t.querySelectorAll("*"),a=ut(e,n,o,r),i=0;for(let y of s){let p=j(y,n,o);p.domIndex=i++}let c=[];for(let y of s){if(n.excludeIds&&y.id)continue;let p=j(y,n,o),R=a.get(p.signature)||[],N=n.excludeIds?R.filter(C=>!C.id):R;for(let C of N){let{score:g,breakdown:T}=Ce(y,C,n,o,{candidateCount:N.length});g>=n.minConfidence&&c.push({newEl:y,oldEl:C,score:g,breakdown:T})}}if(n.weights.slotMatch>0){let y=nn(t,e,n,o);for(let p of y)c.push(p)}c.sort((y,p)=>p.score-y.score);let A=new Map,x=new Set;for(let{newEl:y,oldEl:p}of c)A.has(y)||x.has(p)||(A.set(y,p),x.add(p));return A}function lt(e,t,n,o){let r=j(e,n,o),s=j(t,n,o),{score:a,breakdown:i}=Ce(e,t,n,o,{candidateCount:1});return{matches:a>=n.minConfidence,score:a,breakdown:i,newMeta:{signature:r.signature,path:r.path,textHint:r.textHint},oldMeta:{signature:s.signature,path:s.path,textHint:s.textHint}}}function ft(e={}){let t={...it,...e,weights:{...it.weights,...e.weights}},n=new WeakMap,o=new WeakMap;return{findMatch:(r,s)=>at(r,s,t,n,o),computeMatches:(r,s)=>ct(r,s,t,n,o),explain:(r,s)=>lt(r,s,t,n),invalidate:r=>tn(r,n,o),session:()=>{let r=new WeakMap,s=new WeakMap;return{findMatch:(a,i)=>at(a,i,t,r,s),computeMatches:(a,i)=>ct(a,i,t,r,s),explain:(a,i)=>lt(a,i,t,r)}},getConfig:()=>({...t})}}var rn=ft(),Le=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 T=g.getAttribute("src")||g.getAttribute("href")||"";if(T.startsWith("chrome-extension://")||T.startsWith("moz-extension://")||T.startsWith("safari-web-extension://"))return!0}return!1}function n(g,T){if(T!=="smart")return g.outerHTML;let E=g.getAttribute("src"),v=g.getAttribute("type")||"text/javascript";if(E)try{let w=new URL(E,window.location.href);return`ext:${v}:${w.origin}${w.pathname}${w.search}`}catch{return`ext:${v}:${E}`}else{let w=g.textContent.trim(),M=5381;for(let d=0;d<w.length;d++)M=(M<<5)+M^w.charCodeAt(d);return`inline:${v}:${Math.abs(M).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},r={computeMatches(g,T){let{computeMatches:E}=rn.session();return E(g,T)}};function s(g,T,E={}){g=N(g);let v=C(T),w=R(g,v,E),M=w.scripts.matchMode,d=new Set(Array.from(g.querySelectorAll("script")).map(u=>n(u,M))),b=i(w,()=>x(w,g,v,u=>u.morphStyle==="innerHTML"?(c(u,g,v),Array.from(g.childNodes)):a(u,g,v)));w.pantry.remove();let l=p(g,d,w);return l.length>0?b instanceof Promise?b.then(u=>Promise.all(l).then(()=>u)):Promise.all(l).then(()=>b):b}function a(g,T,E){let v=C(T);return c(g,v,E,T,T.nextSibling),Array.from(v.childNodes)}function i(g,T){if(!g.config.restoreFocus)return T();let E=document.activeElement;if(!(E instanceof HTMLInputElement||E instanceof HTMLTextAreaElement))return T();let{id:v,selectionStart:w,selectionEnd:M}=E,d=T();return v&&v!==document.activeElement?.getAttribute("id")&&(E=g.target.querySelector(`[id="${v}"]`),E?.focus()),E&&!E.selectionEnd&&M!=null&&E.setSelectionRange(w,M),d}let c=function(){function g(l,u,h,f=null,m=null){u instanceof HTMLTemplateElement&&h instanceof HTMLTemplateElement&&(u=u.content,h=h.content),f||=u.firstChild;for(let S of h.childNodes){if(t(S))continue;if(f&&f!=m){let I=E(l,S,f,m);if(I){I!==f&&w(l,f,I),A(I,S,l),f=I.nextSibling;continue}}if(S instanceof Element){let I=S.getAttribute("id");if(l.persistentIds.has(I)){let k=M(u,I,f,l);A(k,S,l),f=k.nextSibling;continue}if(!l.idMap.has(S)){let k=l.hyperMatches.get(S);if(k&&!l.idMap.has(k)){b(u,k,f),A(k,S,l),f=k.nextSibling;continue}}}let O=T(u,S,f,l);O&&(f=O.nextSibling)}for(;f&&f!=m;){let S=f;f=f.nextSibling,t(S)||v(l,S)}}function T(l,u,h,f){if(f.callbacks.beforeNodeAdded(u)===!1)return null;if(f.idMap.has(u)){let m=document.createElement(u.tagName);return l.insertBefore(m,h),A(m,u,f),f.callbacks.afterNodeAdded(m),m}else{let m=document.importNode(u,!0);return l.insertBefore(m,h),f.callbacks.afterNodeAdded(m),m}}let E=function(){function l(f,m,S,O){let I=m instanceof Element&&!f.idMap.has(m)?f.hyperMatches.get(m):null,k=null,$=m.nextSibling,ne=0,L=S;for(;L&&L!=O;){if(h(L,m)){if(u(f,L,m)||L===I&&!f.idMap.has(L))return L;if(k===null){let Y=L instanceof Element&&f.hyperMatchedOldElements.has(L);!f.idMap.has(L)&&!Y&&(k=L)}}if(k===null&&$&&h(L,$)&&(ne++,$=$.nextSibling,ne>=2&&(k=void 0)),f.activeElementAndParents.includes(L))break;L=L.nextSibling}return k||null}function u(f,m,S){let O=f.idMap.get(m),I=f.idMap.get(S);if(!I||!O)return!1;for(let k of O)if(I.has(k))return!0;return!1}function h(f,m){let S=f,O=m;return S.nodeType===O.nodeType&&S.tagName===O.tagName&&(!S.getAttribute?.("id")||S.getAttribute?.("id")===O.getAttribute?.("id"))}return l}();function v(l,u){let h=u instanceof Element&&l.hyperMatchedOldElements.has(u)&&!l.idMap.has(u);if(l.idMap.has(u)||h)b(l.pantry,u,null);else{if(l.callbacks.beforeNodeRemoved(u)===!1)return;u.parentNode?.removeChild(u),l.callbacks.afterNodeRemoved(u)}}function w(l,u,h){let f=u;for(;f&&f!==h;){let m=f;f=f.nextSibling,t(m)||v(l,m)}return f}function M(l,u,h,f){let m=f.target.getAttribute?.("id")===u&&f.target||f.target.querySelector(`[id="${u}"]`)||f.pantry.querySelector(`[id="${u}"]`);return d(m,f),b(l,m,h),m}function d(l,u){let h=l.getAttribute("id");for(;l=l.parentNode;){let f=u.idMap.get(l);f&&(f.delete(h),f.size||u.idMap.delete(l))}}function b(l,u,h){if(l.moveBefore)try{l.moveBefore(u,h)}catch{l.insertBefore(u,h)}else l.insertBefore(u,h)}return g}(),A=function(){function g(d,b,l){return l.ignoreActive&&d===document.activeElement?null:(l.callbacks.beforeNodeMorphed(d,b)===!1||(d instanceof HTMLHeadElement&&l.head.ignore||(d instanceof HTMLHeadElement&&l.head.style!=="morph"?y(d,b,l):(T(d,b,l),M(d,l)||c(l,d,b))),l.callbacks.afterNodeMorphed(d,b)),d)}function T(d,b,l){let u=b.nodeType;if(u===1){let h=d,f=b,m=h.attributes,S=f.attributes;for(let O of S)w(O.name,h,"update",l)||h.getAttribute(O.name)!==O.value&&h.setAttribute(O.name,O.value);for(let O=m.length-1;0<=O;O--){let I=m[O];if(I&&!f.hasAttribute(I.name)){if(w(I.name,h,"remove",l))continue;h.removeAttribute(I.name)}}M(h,l)||E(h,f,l)}(u===8||u===3)&&d.nodeValue!==b.nodeValue&&(d.nodeValue=b.nodeValue)}function E(d,b,l){if(d instanceof HTMLInputElement&&b instanceof HTMLInputElement&&b.type!=="file"){let u=b.value,h=d.value;v(d,b,"checked",l),v(d,b,"disabled",l),l.formStateSync==="property"?h!==u&&(w("value",d,"update",l)||(d.value=u)):b.hasAttribute("value")?h!==u&&(w("value",d,"update",l)||(d.setAttribute("value",u),d.value=u)):w("value",d,"remove",l)||(d.value="",d.removeAttribute("value"))}else if(d instanceof HTMLOptionElement&&b instanceof HTMLOptionElement)v(d,b,"selected",l);else if(d instanceof HTMLTextAreaElement&&b instanceof HTMLTextAreaElement){let u=b.value,h=d.value;if(w("value",d,"update",l))return;u!==h&&(d.value=u),d.firstChild&&d.firstChild.nodeValue!==u&&(d.firstChild.nodeValue=u)}}function v(d,b,l,u){let h=b[l],f=d[l];if(h!==f){let m=w(l,d,"update",u);if(m||(d[l]=b[l]),u.formStateSync==="property")return;h?m||d.setAttribute(l,""):w(l,d,"remove",u)||d.removeAttribute(l)}}function w(d,b,l,u){return d==="value"&&u.ignoreActiveValue&&b===document.activeElement?!0:u.callbacks.beforeAttributeUpdated(d,b,l)===!1}function M(d,b){return!!b.ignoreActiveValue&&d===document.activeElement&&d!==document.body}return g}();function x(g,T,E,v){if(g.head.block){let w=T.querySelector("head"),M=E.querySelector("head");if(w&&M){let d=y(w,M,g);return Promise.all(d).then(()=>{let b=Object.assign(g,{head:{block:!1,ignore:!0}});return v(b)})}}return v(g)}function y(g,T,E){let v=[],w=[],M=[],d=[],b=E.scripts.matchMode,l=f=>{if(f.tagName==="SCRIPT")return n(f,b);if(f.tagName==="LINK"&&b==="smart"){let m=f.getAttribute("href");if(m)try{let S=new URL(m,window.location.href);return`link:${f.getAttribute("rel")||""}:${S.origin}${S.pathname}${S.search}`}catch{}}return f.outerHTML},u=new Map;for(let f of T.children)t(f)||u.set(l(f),f);for(let f of g.children){let m=l(f),S=u.has(m),O=E.head.shouldReAppend(f),I=E.head.shouldPreserve(f);S||I?O?w.push(f):(u.delete(m),M.push(f)):E.head.style==="append"?O&&(w.push(f),d.push(f)):E.head.shouldRemove(f)!==!1&&!t(f)&&w.push(f)}d.push(...u.values());let h=[];for(let f of d){let m=document.createRange().createContextualFragment(f.outerHTML).firstChild;if(E.callbacks.beforeNodeAdded(m)!==!1){if("href"in m&&m.href||"src"in m&&m.src){let S,O=new Promise(function(I){S=I});m.addEventListener("load",function(){S()}),h.push(O)}g.appendChild(m),E.callbacks.afterNodeAdded(m),v.push(m)}}for(let f of w)E.callbacks.beforeNodeRemoved(f)!==!1&&(g.removeChild(f),E.callbacks.afterNodeRemoved(f));return E.head.afterHeadMorphed(g,{added:v,kept:M,removed:w}),h}function p(g,T,E){if(!E.scripts.handle)return[];let v=[],w=[],M=[],d=[],b=E.scripts.matchMode,l=Array.from(g.querySelectorAll("script"));for(let h of l){let f=n(h,b),m=T.has(f),S=E.scripts.shouldPreserve(h),O=E.scripts.shouldReAppend(h);m||S?O?(w.push(h),d.push(h)):M.push(h):d.push(h)}for(let h of T){let f=l.some(m=>m.outerHTML===h)}let u=[];for(let h of d){if(E.callbacks.beforeNodeAdded(h)===!1)continue;let f=document.createRange().createContextualFragment(h.outerHTML).firstChild;if(f.src){let m,S=new Promise(function(O){m=O});f.addEventListener("load",function(){m()}),f.addEventListener("error",function(){m()}),u.push(S)}h.replaceWith(f),E.callbacks.afterNodeAdded(f),v.push(f)}return E.scripts.afterScriptsHandled(g,{added:v,kept:M,removed:w}),u}let R=function(){function g(l,u,h){let{persistentIds:f,idMap:m}=d(l,u),S=r.computeMatches(l,u);if(typeof h.key=="function"){let $=new Map,ne=new Set,L=H=>{let P=h.key(H);P!=null&&($.has(P)?ne.add(P):$.set(P,H))};l instanceof Element&&L(l);for(let H of l.querySelectorAll("*"))L(H);for(let H of ne)$.delete(H);let Y=new Map;for(let[H,P]of S)Y.set(P,H);let xe=u.__hyperMorphRoot||u,he=new Map,et=new Set,tt=H=>{let P=h.key(H);P!=null&&(he.has(P)?et.add(P):he.set(P,H))};xe instanceof Element&&tt(xe);for(let H of xe.querySelectorAll("*"))tt(H);for(let H of et)he.delete(H);for(let[H,P]of he){let G=$.get(H);if(!G||G.tagName!==P.tagName)continue;let ve=Y.get(G);ve&&ve!==P&&S.delete(ve);let we=S.get(P);we&&we!==G&&Y.delete(we),S.set(P,G),Y.set(G,P)}}let O=new Set;for(let $ of S.values())O.add($);let I=T(h),k=I.morphStyle||"outerHTML";if(!["innerHTML","outerHTML"].includes(k))throw`Do not understand how to morph style ${k}`;return{target:l,newContent:u,config:I,morphStyle:k,ignoreActive:I.ignoreActive,ignoreActiveValue:I.ignoreActiveValue,restoreFocus:I.restoreFocus,formStateSync:I.formStateSync||"attribute",idMap:m,persistentIds:f,hyperMatches:S,hyperMatchedOldElements:O,pantry:E(),activeElementAndParents:v(l),callbacks:I.callbacks,head:I.head,scripts:I.scripts}}function T(l){let u=Object.assign({},o);return Object.assign(u,l),u.callbacks=Object.assign({},o.callbacks,l.callbacks),u.head=Object.assign({},o.head,l.head),u.scripts=Object.assign({},o.scripts,l.scripts),u}function E(){let l=document.createElement("div");return l.hidden=!0,document.body.insertAdjacentElement("afterend",l),l}function v(l){let u=[],h=document.activeElement;if(h?.tagName!=="BODY"&&l.contains(h))for(;h&&(u.push(h),h!==l);)h=h.parentElement;return u}function w(l){let u=Array.from(l.querySelectorAll("[id]"));return l.getAttribute?.("id")&&u.push(l),u}function M(l,u,h,f){for(let m of f){let S=m.getAttribute("id");if(u.has(S)){let O=m;for(;O;){let I=l.get(O);if(I==null&&(I=new Set,l.set(O,I)),I.add(S),O===h)break;O=O.parentElement}}}}function d(l,u){let h=w(l),f=w(u),m=b(h,f),S=new Map;M(S,m,l,h);let O=u.__hyperMorphRoot||u;return M(S,m,O,f),{persistentIds:m,idMap:S}}function b(l,u){let h=new Set,f=new Map;for(let{id:S,tagName:O}of l)f.has(S)?h.add(S):f.set(S,O);let m=new Set;for(let{id:S,tagName:O}of u)m.has(S)?h.add(S):f.get(S)===O&&m.add(S);for(let S of h)m.delete(S);return m}return g}(),{normalizeElement:N,normalizeParent:C}=function(){let g=new WeakSet;function T(M){return M instanceof Document?M.documentElement:M}function E(M){if(M==null)return document.createElement("div");if(typeof M=="string")return E(w(M));if(g.has(M))return M;if(M instanceof Node){if(M.parentNode)return new v(M);{let d=document.createElement("div");return d.append(M),d}}else{let d=document.createElement("div");for(let b of[...M])d.append(b);return d}}class v{constructor(d){this.originalNode=d,this.realParentNode=d.parentNode,this.previousSibling=d.previousSibling,this.nextSibling=d.nextSibling}get childNodes(){let d=[],b=this.previousSibling?this.previousSibling.nextSibling:this.realParentNode.firstChild;for(;b&&b!=this.nextSibling;)d.push(b),b=b.nextSibling;return d}querySelectorAll(d){return this.childNodes.reduce((b,l)=>{if(l instanceof Element){l.matches(d)&&b.push(l);let u=l.querySelectorAll(d);for(let h=0;h<u.length;h++)b.push(u[h])}return b},[])}insertBefore(d,b){return this.realParentNode.insertBefore(d,b)}moveBefore(d,b){return this.realParentNode.moveBefore(d,b)}get __hyperMorphRoot(){return this.originalNode}}function w(M){let d=new DOMParser,b=M.replace(/<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim,"");if(b.match(/<\/html>/)||b.match(/<\/head>/)||b.match(/<\/body>/)){let l=d.parseFromString(M,"text/html");if(b.match(/<\/html>/))return g.add(l),l;{let u=l.firstChild;return u&&g.add(u),u}}else{let u=d.parseFromString("<body><template>"+M+"</template></body>","text/html").body.querySelector("template").content;return g.add(u),u}}return{normalizeElement:T,normalizeParent:E}}();return{morph:s,defaults:o}}();var $n=Le.morph,jn=Le.defaults,dt=Le;function He(e,t,{onWidgetRemoved:n}={}){dt.morph(e,t,{morphStyle:"innerHTML",ignoreActiveValue:!0,restoreFocus:!0,formStateSync:"property",callbacks:{beforeNodeRemoved(o){let r=ye.get(o);r?.destroy&&r.destroy(),n?.(o)}}})}var sn="hha:upgrade-check:";function U(e,t){let n=e.querySelector(`meta[name="${t}"]`),o=n?n.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function Pe(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function pt(e,t){let n=Pe(e),o=Pe(t);if(!n||!o)return!1;let r=Math.max(n.length,o.length);for(let s=0;s<r;s++){let a=n[s]||0,i=o[s]||0;if(a!==i)return a>i}return!1}function an(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function cn(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function De({force:e=!1,doc:t,loc:n,fetchFn:o,now:r,ttlMs:s=864e5}={}){if(t=t||(typeof document<"u"?document:null),n=n||(typeof location<"u"?location:null),o=o||(p=>fetch(p)),r=r??Date.now(),!t)return null;let a=U(t,"hyper-source");if(!a)return null;let i=U(t,"hyper-version"),c;try{c=new URL(a,n?n.href:void 0)}catch{return null}if(n&&c.origin===n.origin&&c.pathname===n.pathname)return null;let A=`${sn}${c.href}:${i||"none"}`,x,y=e?null:an(A);if(y&&typeof y.checkedAt=="number"&&r-y.checkedAt<s)x=y.sourceVersion;else{try{let p=await o(c.href);if(!p.ok)throw new Error(`HTTP ${p.status}`);let R=await p.text(),N=new DOMParser().parseFromString(R,"text/html");x=U(N,"hyper-version")}catch{x=null}cn(A,{checkedAt:r,sourceVersion:x})}return x?{available:pt(x,i||"0.0.0"),currentVersion:i,sourceVersion:x,sourceUrl:c.href}:null}var Ae=["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"],_e=new Set(Ae),ht=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),mt=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var Se={};Re(Se,{EmptyListInsert:()=>se,MAX_RULE_DEPTH:()=>Q,MaxRuleDepthExceeded:()=>K,RuleTargetReadOnly:()=>ie,RulesParseError:()=>Z,ShapeMismatch:()=>oe,UnknownRulesVersion:()=>q});var Z=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},q=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},Q=20,K=class extends Error{constructor(t){super(`rule depth exceeded ${Q} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},oe=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},se=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}},ie=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}};function F(e,t,n,o={}){return $e(e,t,n,{depth:0,path:[]},o)}function $e(e,t,n,o,r){if(o.depth>Q)throw new K(o.path);if(typeof n=="string")return ln(e,t,n,r);if(Array.isArray(n)){let[s,a]=n;return e.find(t,s,r).map((c,A)=>$e(e,c,a,{depth:o.depth+1,path:[...o.path,A]},r))}if(typeof n=="object"&&n!==null){let s={};for(let[a,i]of Object.entries(n))s[a]=$e(e,t,i,{depth:o.depth+1,path:[...o.path,a]},r);return s}return null}function ln(e,t,n,o){if(n.endsWith("[]")){let s=n.slice(0,-2);return e.find(t,s,o).map(a=>e.text(a))}if(n.startsWith("@"))return gt(e,t,n.slice(1));if(n.includes("@")){let s=n.lastIndexOf("@"),a=n.slice(0,s),i=n.slice(s+1),c=a?e.find(t,a,o):[t];return c.length===0?null:gt(e,c[0],i)}if(n===".")return e.text(t);let r=e.find(t,n,o);return r.length===0?null:e.text(r[0])}function gt(e,t,n){if(_e.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let o=e.attr(t,n);return o||null}function un(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function fn(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var dn={find(e,t,n={}){let o=fn(e);if(!o||!o.querySelectorAll)return[];let r=Array.from(o.querySelectorAll(t));n.includeRulesTag||(r=r.filter(i=>!un(i)));let s=[];n.skip&&s.push(n.skip);let a=n.templateAttr===null?null:n.templateAttr||"cms-template";if(a&&s.push("["+a+"]"),s.length){let i=s.join(", ");r=r.filter(c=>!c.closest||!c.closest(i))}return r},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,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t)},prop(e,t,n){if(n===void 0){let o=e?e[t]:void 0;return o!==void 0?o:null}e[t]=n},clone(e){return e.cloneNode(!0)},insertAt(e,t,n){let o=e.children[n]||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 r=o.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},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}},D=dn;function je(e){try{return JSON.parse(e)}catch(t){throw new Z(`Invalid strict JSON: ${t.message}`,t)}}function z(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 n(r){let s=[],a=0;for(;a<r.length;){let i=r[a];if(/\s/.test(i)){a++;continue}if("{}".includes(i)){s.push({type:i,value:i}),a++;continue}if(i==="["){let y=!1,p=a+1;for(;p<r.length&&/\s/.test(r[p]);)p++;if(p<r.length&&/[a-zA-Z_]/.test(r[p])&&(y=!0),!y){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 y=i,p=a+1;for(;p<r.length&&r[p]!==y;)r[p]==="\\"&&p++,p++;s.push({type:t.STRING,value:r.substring(a+1,p),quoted:!0,sourceQuote:y}),a=p+1;continue}let c=a,A;for(;c<r.length&&!/[{},]/.test(r[c]);)if(r[c]===":"){let y=[":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"],p=!1;for(let R of y){let N=R.substring(1);if(r.substring(c+1,c+1+N.length)===N){p=!0,c+=N.length;break}}if(!p)break}else if(r[c]==="["){for(c++;c<r.length&&r[c]!=="]";){if(r[c]==='"'||r[c]==="'"){let y=r[c];for(c++;c<r.length&&r[c]!==y;)r[c]==="\\"&&c++,c++}c++}c<r.length&&r[c]==="]"&&c++}else c++;A=r.substring(a,c);let x=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(A)?x=t.NUMBER:A==="true"||A==="false"||A==="null"?x=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(A)&&(x=t.SELECTOR),s.push({type:x,value:A,quoted:!1}),a=c}return s}function o(r){let s="";for(let a=0;a<r.length;a++){let i=r[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=r[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,(A,x)=>x.length%2===0?x+'\\"':A)),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 r=n(e),s=o(r);return JSON.parse(s)}catch(r){throw new Z("Invalid extraction rules syntax: "+r.message,r)}}var Ue="1",yt=/^[a-zA-Z0-9_-]+$/;function ee(e,t,n){let o;if(n===void 0)o="script[data-rules-name]";else{if(typeof n!="string"||!yt.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${yt})`);o=`script[data-rules-name~="${n}"]`}let r=e.find(t,o,{includeRulesTag:!0});if(r.length===0)return null;n!==void 0&&r.length>1&&console.warn(`hyper-html-api: ${r.length} rules tags match data-rules-name~="${n}"; using the first.`);let s=r[0],a=e.attr(s,"data-rules-version");if(a!==Ue)throw new q(a);return{rules:z(e.text(s)),tagNode:s}}var pn="script[data-rules-name]";function bt(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function ae(e,t){let n=e.find(t,pn,{includeRulesTag:!0}),o=new Set,r=[];for(let s of n){let a=bt(e.attr(s,"data-rules-name"));if(!a)continue;if(o.has(a)){console.warn(`hyper-html-api: duplicate rules tag name "${a}"; using the first.`);continue}let i=e.attr(s,"data-rules-version");if(i!==Ue)throw new q(i);o.add(a),r.push({name:a,rules:z(e.text(s))})}return r}function Me(e,t){let n={};for(let{name:o,rules:r}of ae(e,t))n[o]=F(e,t,r);return n}function Fe(e){let t=e||document,n=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:Me(D,t),version:U(n,"hyper-version")}}var te=class extends Error{constructor(t,n){super(`could not fetch upgrade source: ${t}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=t,this.cause=n}},ce=class extends Error{constructor(t){super(`upgrade source has no rules tags; refusing to drop all existing data: ${t}`),this.name="UpgradeSourceHasNoRules",this.sourceUrl=t}},W=class extends Error{constructor(t,n){super(t),this.name="UpgradeTransformInvalid",this.cause=n}},le=class extends Error{constructor(t){super(`found ${t} script[type="text/hyper-upgrade"] tags; only one is allowed per document.`),this.name="UpgradeMultipleTransforms",this.count=t}};var At="text/hyper-upgrade";function Be(e,t){let n=e.find(t,`script[type="${At}"]`);if(n.length===0)return null;if(n.length>1)throw new le(n.length);return e.text(n[0])||null}var hn=new Function("url","return import(url)");async function We(e){let t=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(t),o;try{o=await hn(n)}catch(r){throw new W(`transform failed to load: ${r&&r.message?r.message:r}`,r)}finally{URL.revokeObjectURL(n)}if(typeof o.default!="function")throw new W("transform must `export default` a function");return o.default}var mn=.5;function Ve(e,t,n,o,r,s,a,i={}){let c=e.find(t,n,i);if(r.length===0){c.forEach(v=>e.remove(v));return}let A=r.length>c.length,x=c[0]||null;if(A&&!x&&(x=Sn(e,t,n,i),!x))throw new se(s.path);let y=c.map(v=>gn(e,v,o,i)),p=null;if(x){p=e.clone(x),i.templateAttr&&e.removeAttr(p,i.templateAttr);let v=e.stripIds(p);v>0&&console.warn(`[hyper-html-api] stripped ${v} id attribute(s) from cloned template at "${s.path.join(".")||"(root)"}"`)}let R=yn(r,y,o),N=c[0]||x,C=e.parent(N),g=c.length>0?An(e,C,N):0,T=new Set,E=r.map((v,w)=>{let M=R[w];if(M>=0)return T.add(M),c[M];let d=e.clone(p);return e.stripIds(d),d});c.forEach((v,w)=>{T.has(w)||e.remove(v)}),E.forEach((v,w)=>{let M=g+w;e.children(C).findIndex(l=>e.sameNode(l,v))!==M&&e.insertAt(C,v,M)}),E.forEach((v,w)=>{if(o===null){let M=r[w],d=M==null?"":String(M);e.text(v)!==d&&e.text(v,d)}else{let M=a(e,v,o,r[w],{depth:s.depth+1,path:[...s.path,w]},i);M&&M!==v&&(E[w]=M)}})}function gn(e,t,n,o){return n===null?e.text(t):F(e,t,n,o)}function yn(e,t,n){let o=new Array(e.length).fill(-1),r=new Set;return e.forEach((s,a)=>{let i=-1,c=-1;t.forEach((A,x)=>{if(r.has(x))return;let y=bn(s,A,n),p=y===c&&i>=0?Math.abs(x-a)<Math.abs(i-a):!1;(y>c||p)&&(c=y,i=x)}),c>=mn&&(o[a]=i,r.add(i))}),o}function bn(e,t,n){if(n===null)return e===t?1:0;let o=Object.keys(n||{});if(o.length===0)return 0;let r=0;for(let s of o)JSON.stringify(e?.[s])===JSON.stringify(t?.[s])&&r++;return r/o.length}function An(e,t,n){let o=e.children(t);for(let r=0;r<o.length;r++)if(e.sameNode(o[r],n))return r;return-1}function Sn(e,t,n,o){if(!o.templateAttr)return null;let r=t;for(;r;){let s=e.find(r,n,{includeRulesTag:!1,templateAttr:null});for(let a of s)if(e.attr(a,o.templateAttr)!=null)return a;r=e.parent(r)}return null}var St=new Set(["checked","selected","disabled","readOnly","paused"]);function V(e,t,n,o,r={}){let s=[];if(qe(n,o,[],s),s.length)throw new oe(s);Ee(e,t,n,o,{depth:0,path:[]},r)}function Ee(e,t,n,o,r,s={}){if(r.depth>Q)throw new K(r.path);if(o===void 0)return t;if(typeof n=="string")return Mn(e,t,n,o,r,s);if(Array.isArray(n)){let[a,i]=n;return Ve(e,t,a,i,o,r,Ee,s),t}if(typeof n=="object"&&n!==null){for(let[a,i]of Object.entries(n)){let c=Ee(e,t,i,o==null?o:o[a],{depth:r.depth+1,path:[...r.path,a]},s);c&&c!==t&&(t=c)}return t}return t}function Mn(e,t,n,o,r,s){if(n.endsWith("[]")){let i=n.slice(0,-2);return Ve(e,t,i,null,o,r,Ee,s),t}if(n.startsWith("@"))return Mt(e,t,n.slice(1),o);if(n.includes("@")){let i=n.lastIndexOf("@"),c=n.slice(0,i),A=n.slice(i+1),x=c?e.find(t,c,s):[t];return x.length===0||Mt(e,x[0],A,o),t}if(n===".")return e.text(t,o==null?"":String(o)),t;let a=e.find(t,n,s);return a.length===0||e.text(a[0],o==null?"":String(o)),t}function Mt(e,t,n,o){if(mt.has(n))throw new ie(n);if(n==="outerHTML"){let r=o==null?"":String(o);return e.replaceWith(t,r)}return ht.has(n)?(e.prop(t,n,En(n,o)),t):(e.attr(t,n,o==null?"":String(o)),t)}function En(e,t){return t==null?St.has(e)?!1:"":St.has(e)?!!t:t}function qe(e,t,n,o){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,s)=>{typeof r=="object"&&r!==null&&o.push({path:fe([...n,s]),expected:"scalar",got:ue(r)})}):o.push({path:fe(n),expected:"array",got:ue(t)});return}t!==null&&typeof t=="object"&&o.push({path:fe(n),expected:"scalar",got:ue(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:fe(n),expected:"array",got:ue(t)});return}let r=e[1];t.forEach((s,a)=>qe(r,s,[...n,a],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:fe(n),expected:"object",got:ue(t)});return}for(let[r,s]of Object.entries(e))qe(s,t[r],[...n,r],o)}}}function ue(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function fe(e){return e.join(".")}function de(e,t){let n={carriedOver:0,discarded:0,listItems:0},o=Ke(t,e,n);return ze(t,e,n),{data:o,summary:n}}function Ke(e,t,n){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(t)?(n.listItems+=t.length,n.carriedOver+=t.length,t):void 0:t==null||typeof t=="object"?void 0:(n.carriedOver++,t);if(Array.isArray(e)){let[,o]=e;return Array.isArray(t)?(n.listItems+=t.length,t.map(r=>Ke(o,r,n))):void 0}if(typeof e=="object"&&e!==null){let o={};for(let[r,s]of Object.entries(e)){let a=Ke(s,t?.[r],n);a!==void 0&&(o[r]=a)}return o}}function ze(e,t,n){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 r of Object.keys(t))o.has(r)?ze(e[r],t[r],n):n.discarded+=J(t[r]);return}if(Array.isArray(e)&&Array.isArray(t)){let o=e[1];t.forEach(r=>ze(o,r,n));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(n.discarded+=J(t))}}function J(e){return e==null?0:Array.isArray(e)?e.reduce((t,n)=>t+J(n),0):typeof e=="object"?Object.values(e).reduce((t,n)=>t+J(n),0):1}function Je(e,t,n){let o=ae(e,t),r={carriedOver:0,discarded:0,listItems:0},s={},a=new Set;for(let{name:i,rules:c}of o){if(a.add(i),!Object.prototype.hasOwnProperty.call(n,i)){s[i]={carriedOver:0,discarded:0,listItems:0};continue}let{data:A,summary:x}=de(n[i],c);V(e,t,c,A),s[i]=x,r.carriedOver+=x.carriedOver,r.discarded+=x.discarded,r.listItems+=x.listItems}for(let i of Object.keys(n))a.has(i)||(r.discarded+=J(n[i]));return{totals:r,byName:s,rulesTagCount:o.length}}async function Ye({sourceUrl:e,dataByName:t,fromVersion:n,doc:o,loc:r,fetchFn:s}={}){if(o=o||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),s=s||(T=>fetch(T)),!o)throw new Error("upgrade.run requires a document context");if(e=e||U(o,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let a=new URL(e,r?r.href:void 0);n=n!==void 0?n:U(o,"hyper-version"),t=t||Me(D,o);let i;try{i=await s(a.href)}catch(T){throw new te(a.href,T)}if(!i.ok)throw new te(a.href,new Error(`HTTP ${i.status}`));let c=await i.text(),A=new DOMParser().parseFromString(c,"text/html"),x=U(A,"hyper-version"),y=t,p=!1,R=Be(D,A);if(R){let E=await(await We(R))(y,{fromVersion:n,toVersion:x});if(!E||typeof E!="object"||Array.isArray(E))throw new W("transform must return a plain object map of { rulesName: data }");y=E,p=!0}let{totals:N,byName:C,rulesTagCount:g}=Je(D,A,y);if(g===0&&Object.keys(y).length>0)throw new ce(a.href);return{html:xn(A),fromVersion:n,toVersion:x,summary:{transformApplied:p,totals:N,byName:C}}}function xn(e){return`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
|
|
3
|
-
`+e.documentElement.outerHTML}function Ge(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null};if(typeof n=="string"){let o=t&&t.ownerDocument?t.ownerDocument:t;return ee(e,o,n)}return null}function Et(e,t,n,o){let r=Ge(e,t,n);if(!r){let i=typeof n=="string"?`data-rules-name~="${n}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${i}`)}let{rules:s,tagNode:a}=r;return{rules:s,tagNode:a,get:()=>F(e,t,s,o),set:i=>V(e,t,s,i,o)}}var pe={extract:(e,t,n)=>F(D,e,t,n),apply:(e,t,n,o)=>V(D,e,t,n,o),findRulesIn:(e,t)=>ee(D,e,t),findRules:(e,t)=>Ge(D,e,t),bind:(e,t,n)=>Et(D,e,t,n),parseStrict:je,parseRelaxed:z,errors:Se,DOM_PROPERTIES:Ae},Xe=e=>!!e&&typeof e.nodeType=="number";function xt(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=D.find(t,"script[data-rules-name]",{includeRulesTag:!0});if(n.length===0)throw new Error('hyper-html-api: no rules tag found. Add <script type="application/json" data-rules-name="\u2026" data-rules-version="1"> or pass rules.');if(n.length>1)throw new Error('hyper-html-api: multiple rules tags found; pass a name, e.g. extractData("api").');return ee(D,t).rules}function Ze(e,t){let n=Xe(e)?e:document,o=Xe(e)?t:e;return o===void 0?F(D,n,xt(n)):pe.bind(n,o).get()}function Qe(e,t,n){if(!Xe(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");return n===void 0?V(D,e,xt(e),t):pe.bind(e,n).set(t),e}var vt={buildForm:Ne,bindFormEvents:Ie,scaffold:X,morphForm:He,path:ge},wt={checkForUpdate:De,run:Ye,extractAll:Fe,shapeMatch:de};var Tn={engine:pe,cms:vt,upgrade:wt,extractData:Ze,applyData:Qe},Rn=Tn;return It(On);})();
|
|
1
|
+
var HyperHtmlApi=(()=>{var Ke=Object.defineProperty;var sn=Object.getOwnPropertyDescriptor;var an=Object.getOwnPropertyNames;var cn=Object.prototype.hasOwnProperty;var ze=(e,t)=>{for(var n in t)Ke(e,n,{get:t[n],enumerable:!0})},ln=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of an(t))!cn.call(e,r)&&r!==n&&Ke(e,r,{get:()=>t[r],enumerable:!(o=sn(t,r))||o.enumerable});return e};var un=e=>ln(Ke({},"__esModule",{value:!0}),e);var gr={};ze(gr,{applyData:()=>Mt,cms:()=>tn,default:()=>mr,engine:()=>Ce,extractData:()=>Et,upgrade:()=>nn});var He={};ze(He,{fromString:()=>Le,getRuleAtPath:()=>Je,getValueAtPath:()=>Ee,parseConfigKey:()=>dn,setAtPath:()=>re,toConfigKey:()=>fn,toString:()=>J});function J(e){return e.map(String).join(".")}function fn(e){return e.map(t=>typeof t=="number"?"*":String(t)).join(".")}function dn(e){return e===""?[]:e.split(".")}function Le(e){return e===""?[]:e.split(".").map(t=>/^\d+$/.test(t)?Number(t):t)}function Je(e,t){let n=e;for(let o of t){if(n==null||typeof n=="string")return;if(Array.isArray(n)){if(typeof o!="number"&&o!=="*")return;n=n[1];continue}if(typeof n=="object"){if(typeof o=="number"||!(o in n))return;n=n[o];continue}return}return n}function Ee(e,t){let n=e;for(let o of t){if(n==null)return;n=n[o]}return n}function re(e,t,n){if(t.length===0)return n;let[o,...r]=t;if(typeof o=="number"){let i=Array.isArray(e)?[...e]:[];return i[o]=re(i[o],r,n),i}return{...e&&typeof e=="object"?e:{},[o]:re((e||{})[o],r,n)}}function pe(e){if(typeof e=="string")return e.endsWith("[]")?[]:"";if(Array.isArray(e))return[];if(typeof e=="object"&&e!==null){let t={};for(let[n,o]of Object.entries(e))t[n]=pe(o);return t}return""}var Pe=new WeakMap;function oe(e){let t=0,n=null,o=-1;for(let r=0;r<e.length;r++){let i=e[r];i==="\\"?r++:n?i===n&&(n=null):i==='"'||i==="'"?n=i:i==="["||i==="("?t++:i==="]"||i===")"?t>0&&t--:i==="@"&&t===0&&(o=r)}return o}function me(e){let t=oe(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}var hn=new Set(["checked","selected","disabled","readOnly","paused"]);function Ge({rules:e,data:t,appRoot:n,cmsRoot:o}){let r=document.createDocumentFragment(),i={rules:e,appRoot:n,cmsRoot:o};return r.appendChild(Ze({rule:e,value:t,path:[],ctx:i})),r}function Ye(e,{rules:t,getData:n,onChange:o}){e.setAttribute("data-hha-form-root",""),Tt.set(e,{rules:t,getData:n,onChange:o}),pn()}var Tt=new WeakMap,Ot=!1;function pn(){Ot||(document.addEventListener("input",Rt,!0),document.addEventListener("change",Rt,!0),document.addEventListener("click",mn,!0),Ot=!0)}function Nt(e){if(!(e instanceof Element))return null;let t=e.closest("[data-hha-form-root]");return t&&Tt.get(t)||null}function mn(e){if(!(e.target instanceof Element))return;let t=e.target.closest("[data-hha-action]");if(!t||e.defaultPrevented)return;let n=Nt(t);if(!n)return;let{rules:o,getData:r,onChange:i}=n,a=t.getAttribute("data-hha-action"),s=Le(t.getAttribute("data-hha-path")||"");if(a==="scalar-array-add"){let c=Ee(r(),s)||[];i(re(r(),s,[...c,""]),{structural:!0});return}if(a==="object-array-add"){let c=Je(o,s);if(!Array.isArray(c))return;let A=Ee(r(),s)||[];i(re(r(),s,[...A,pe(c[1])]),{structural:!0});return}if(a==="array-remove"){if(s.length===0)return;let c=s.slice(0,-1),A=s[s.length-1],x=Ee(r(),c)||[];if(typeof A!="number")return;let w=x.filter((m,b)=>b!==A);i(re(r(),c,w),{structural:!0})}}function Rt(e){let t=e.target;if(!t?.matches?.("input, textarea, select"))return;let n=Nt(t);if(!n)return;let{getData:o,onChange:r}=n,i=t.closest("[data-hha-path]");if(!i)return;let a=Le(i.getAttribute("data-hha-path")||""),s=t.type==="checkbox"?t.checked:t.value;r(re(o(),a,s),{structural:!1})}function Ze({rule:e,value:t,path:n,ctx:o}){if(typeof e=="string")return e.endsWith("[]")?bn({rule:e,value:t,path:n,ctx:o}):yn({rule:e,value:t,path:n,ctx:o});if(Array.isArray(e))return An({rule:e,value:t,path:n,ctx:o});if(typeof e=="object"&&e!==null)return gn({rule:e,value:t,path:n,ctx:o});let r=document.createElement("span");return r.textContent="(unsupported rule)",r}function gn({rule:e,value:t,path:n,ctx:o}){let r=document.createElement("div");if(r.className="form-section",r.setAttribute("data-hha-path",J(n)),n.length>0){let i=document.createElement("div");i.className="form-section-label",i.textContent=je(n[n.length-1]),r.appendChild(i)}for(let[i,a]of Object.entries(e)){let s=[...n,i],c=t?.[i];r.appendChild(Ze({rule:a,value:c,path:s,ctx:o}))}return r}function yn({rule:e,value:t,path:n,ctx:o}){let r=document.createElement("div");r.className="field-row",r.setAttribute("data-hha-path",J(n));let i=document.createElement("div");i.className="field-body";let a=document.createElement("label");a.className="field-label",a.textContent=je(n[n.length-1]||".")+wn(e);let s=En(e,o.appRoot),c=Sn(s,{value:t,rule:e,path:n,appRoot:o.appRoot}),A=c.el;return A.classList.add(s.type==="textarea"?"field-textarea":"field-input"),i.appendChild(a),i.appendChild(A),r.appendChild(i),Pe.set(r,c),r}function bn({rule:e,value:t,path:n,ctx:o}){let r=document.createElement("div");r.className="form-section",r.setAttribute("data-hha-path",J(n));let i=document.createElement("div");i.className="form-section-label",i.textContent=je(n[n.length-1]),r.appendChild(i);let a=Array.isArray(t)?t:[],s=document.createElement("div");r.appendChild(s),a.forEach((A,x)=>{let w=[...n,x],m=document.createElement("div");m.className="scalar-array-row",m.setAttribute("data-hha-path",J(w));let b=document.createElement("input");b.type="text",b.className="field-input",b.value=A==null?"":String(A);let M=document.createElement("button");M.type="button",M.className="array-remove",M.textContent="\xD7",M.title="remove",M.setAttribute("data-hha-action","array-remove"),M.setAttribute("data-hha-path",J(w)),m.appendChild(b),m.appendChild(M),s.appendChild(m)});let c=document.createElement("button");return c.type="button",c.className="array-add",c.textContent="+ add",c.setAttribute("data-hha-action","scalar-array-add"),c.setAttribute("data-hha-path",J(n)),r.appendChild(c),r}function An({rule:e,value:t,path:n,ctx:o}){let[,r]=e,i=Array.isArray(t)?t:[],a=document.createElement("div");a.className="form-section",a.setAttribute("data-hha-path",J(n));let s=document.createElement("div");s.className="form-section-label",s.textContent=je(n[n.length-1]),a.appendChild(s),i.forEach((A,x)=>{let w=[...n,x],m=document.createElement("div");m.className="array-card",m.setAttribute("data-hha-path",J(w));let b=document.createElement("button");b.type="button",b.className="array-remove",b.textContent="\xD7",b.title="remove item",b.setAttribute("data-hha-action","array-remove"),b.setAttribute("data-hha-path",J(w)),m.appendChild(b);let M=Ze({rule:r,value:A,path:w,ctx:o});M.querySelector(".form-section-label")?.remove(),m.appendChild(M),a.appendChild(m)});let c=document.createElement("button");return c.type="button",c.className="array-add",c.textContent="+ add",c.setAttribute("data-hha-action","object-array-add"),c.setAttribute("data-hha-path",J(n)),a.appendChild(c),a}function Sn(e,t){let n=xn(e);if(e.type==="select"&&e.options)for(let o of e.options){let r=document.createElement("option");r.value=o.value,r.textContent=o.text,String(t.value)===o.value&&(r.selected=!0),n.appendChild(r)}else e.type==="checkbox"?n.checked=t.value===!0||t.value==="true"||t.value==="checked":(e.type,n.value=t.value==null?"":String(t.value));return{el:n,destroy(){},focus(){n.focus()},validate(){}}}function En(e,t){let n=null;if(e.startsWith("@")?n=e.slice(1):n=me(e).prop,n&&hn.has(n))return{type:"checkbox"};if(n==="innerHTML")return{type:"textarea"};let o=Mn(e,t);if(!o)return{type:"text"};let r=(o.tagName||"").toLowerCase();if(r==="textarea")return{type:"textarea"};if(r==="select")return{type:"select",options:Array.from(o.querySelectorAll("option")).map(s=>({value:s.getAttribute("value")||s.textContent,text:s.textContent.trim()||s.getAttribute("value")||""}))};if(r==="input"){let a=(o.getAttribute("type")||"text").toLowerCase();if(a==="checkbox"||a==="radio")return{type:"checkbox"};if(a==="number")return{type:"number"}}let i=(o.textContent||"").trim();return i.length>60||i.includes(`
|
|
2
|
+
`)?{type:"textarea"}:{type:"text"}}function Mn(e,t){if(!t||e==="."||e===""||e.startsWith("@"))return null;let n=me(e).selector;if(!n)return null;try{return t.querySelector(n)}catch{return null}}function xn(e){if(e.type==="textarea")return document.createElement("textarea");if(e.type==="select")return document.createElement("select");let t=document.createElement("input");return t.type=e.type==="checkbox"?"checkbox":e.type==="number"?"number":"text",t}function je(e){return typeof e=="number"?`#${e+1}`:String(e).replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/^\w/,t=>t.toUpperCase())}function wn(e){return` \xB7 ${e}`}var kt={includeClasses:!0,includeAttributes:["href","src","name","type","role","aria-label","alt","title"],excludeAttributePrefixes:["data-morph-","data-hyper-","data-im-"],textHintLength:64,excludeIds:!0,maxPathDepth:4,landmarks:["HEADER","NAV","MAIN","ASIDE","FOOTER","SECTION","ARTICLE"],weights:{signature:100,pathSegment:10,textMatch:20,textMismatch:25,uniqueCandidate:50,positionPenalty:1,maxDriftPenalty:19,slotMatch:30},minConfidence:101,maxScoredCandidates:16};function vn(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return Math.abs(t).toString(36)}function On(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 Rn(e,t){let n=[];for(let o of e.attributes||[]){let r=o.name;r==="id"||r==="class"||t.excludeAttributePrefixes.some(i=>r.startsWith(i))||t.includeAttributes.includes(r)&&n.push(`${r}=${o.value}`)}return n.sort().join("|")}function Tn(e,t){return(e.textContent||"").replace(/\s+/g," ").trim().slice(0,t.textHintLength)}function Nn(e,t){let n=[e.tagName];return t.includeClasses&&n.push(On(e)),n.push(Rn(e,t)),vn(n.join("|"))}function kn(e){let t=e.tagName,n=1,o=e.previousElementSibling;for(;o;)o.tagName===t&&n++,o=o.previousElementSibling;return n}function In(e,t){return e.getAttribute?.("id")||e.getAttribute?.("role")?!0:t.landmarks.includes(e.tagName)}function Cn(e){let t=e.getAttribute?.("id");if(t)return`#${t}`;let n=e.getAttribute?.("role");return n?`@${n}`:e.tagName}function Ln(e,t){let n=[],o=e;for(;o&&o.tagName&&n.length<t.maxPathDepth;){let r=`${o.tagName}:${kn(o)}`;if(n.unshift(r),o!==e&&In(o,t)){n.unshift(Cn(o));break}o=o.parentElement}return n}function Hn(e,t){let n=0,o=e.length-1,r=t.length-1;for(;o>=0&&r>=0&&e[o]===t[r];)n++,o--,r--;return n}function G(e,t,n){if(n.has(e))return n.get(e);let o={signature:Nn(e,t),path:Ln(e,t),textHint:Tn(e,t)};return n.set(e,o),o}function Ht(e,t,n,o){if(o.has(e))return o.get(e);let r=new Map,i=e.querySelectorAll("*"),a=0;for(let s of i){let c=G(s,t,n);c.domIndex=a++,!t.shouldIgnore?.(s)&&(r.has(c.signature)||r.set(c.signature,[]),r.get(c.signature).push(s))}return o.set(e,r),r}function Pn(e,t,n){n.delete(e),t.delete(e);let o=e.querySelectorAll("*");for(let r of o)t.delete(r)}function Qe(e,t,n,o,r){let i=G(e,n,o),a=G(t,n,o),s=n.weights,c={},A=0;if(i.signature!==a.signature)return{score:0,breakdown:{rejected:"signature mismatch"}};A+=s.signature,c.signature=s.signature;let w=Hn(i.path,a.path)*s.pathSegment;A+=w,c.path=w;let m=!0;if(i.textHint&&a.textHint?i.textHint===a.textHint?(A+=s.textMatch,c.text=s.textMatch):(A-=s.textMismatch,c.text=-s.textMismatch,m=!1):i.textHint!==a.textHint&&(A-=s.textMismatch,c.text=-s.textMismatch,m=!1),r.candidateCount===1&&m&&(A+=s.uniqueCandidate,c.unique=s.uniqueCandidate),typeof i.domIndex=="number"&&typeof a.domIndex=="number"){let b=Math.abs(i.domIndex-a.domIndex),M=Math.min(b*s.positionPenalty,s.maxDriftPenalty);A-=M,c.drift=-M}return{score:A,breakdown:c}}function It(e,t,n,o,r){if(n.excludeIds&&e.getAttribute("id"))return null;let i=Ht(t,n,o,r),a=G(e,n,o);if(typeof a.domIndex!="number"){let m=0,b=e.previousElementSibling;for(;b;)m++,b=b.previousElementSibling;a.domIndex=m}let s=i.get(a.signature)||[],c=n.excludeIds?s.filter(m=>!m.getAttribute("id")):s;if(c.length===0)return null;let A=null,x=0,w=null;for(let m of c){let{score:b,breakdown:M}=Qe(e,m,n,o,{candidateCount:c.length});b>x&&(x=b,A=m,w=M)}return x<n.minConfidence?null:{element:A,confidence:x,breakdown:w}}function jn(e,t,n,o){let r=[],i=n.weights.signature+n.weights.slotMatch,a={slot:i};function s(w){if(w.children)return w.children;let m=w.childNodes;if(!m)return[];let b=[];for(let M=0;M<m.length;M++)m[M].nodeType===1&&b.push(m[M]);return b}function c(w,m){let b=s(w),M=s(m);if(b.length===M.length)for(let L=0;L<b.length;L++){let j=b[L],P=M[L];if(n.shouldIgnore?.(j)||n.shouldIgnore?.(P)||n.excludeIds&&(j.getAttribute("id")||P.getAttribute("id"))||j.tagName!==P.tagName)continue;let D=G(j,n,o).signature,V=G(P,n,o).signature;D!==V&&r.push({newEl:j,oldEl:P,score:i,breakdown:a}),c(j,P)}}function A(w,m){for(;;){if(w.tagName===m.tagName)return[w,m];let b=s(w);if(!w.tagName&&b.length===1){w=b[0];continue}let M=s(m);if(M.length===1&&M[0].tagName===w.tagName){m=M[0];continue}return null}}let x=A(e,t);return x&&c(x[0],x[1]),r}function Ct(e,t,n,o,r){let i=t.querySelectorAll("*"),a=Ht(e,n,o,r),s=0;for(let b of i){let M=G(b,n,o);M.domIndex=s++}let c=[],A=new Map;function x(b,M,L){let j=new Set;if(b.textHint){let I=A.get(b.signature);if(!I){I=new Map;for(let U of M){let ee=G(U,n,o).textHint,te=I.get(ee);te||(te=[],I.set(ee,te)),te.push(U)}A.set(b.signature,I)}let K=I.get(b.textHint);if(K)for(let U=0;U<K.length&&U<L;U++)j.add(K[U])}let P=0,D=M.length;for(;P<D;){let I=P+D>>1;G(M[I],n,o).domIndex<b.domIndex?P=I+1:D=I}let V=Math.max(0,Math.min(P-(L>>1),M.length-L)),Y=Math.min(V+L,M.length);for(let I=V;I<Y;I++)j.add(M[I]);return[...j]}for(let b of i){if(n.shouldIgnore?.(b)||n.excludeIds&&b.getAttribute("id"))continue;let M=G(b,n,o),L=a.get(M.signature)||[],j=n.excludeIds?L.filter(V=>!V.getAttribute("id")):L,P=n.maxScoredCandidates,D=P&&j.length>P?x(M,j,P):j;for(let V of D){let{score:Y,breakdown:I}=Qe(b,V,n,o,{candidateCount:j.length});Y>=n.minConfidence&&c.push({newEl:b,oldEl:V,score:Y,breakdown:I})}}if(n.weights.slotMatch>0){let b=jn(t,e,n,o);for(let M of b)c.push(M)}c.sort((b,M)=>M.score-b.score);let w=new Map,m=new Set;for(let{newEl:b,oldEl:M}of c)w.has(b)||m.has(M)||(w.set(b,M),m.add(M));return w}function Lt(e,t,n,o){let r=G(e,n,o),i=G(t,n,o),{score:a,breakdown:s}=Qe(e,t,n,o,{candidateCount:1});return{matches:a>=n.minConfidence,score:a,breakdown:s,newMeta:{signature:r.signature,path:r.path,textHint:r.textHint},oldMeta:{signature:i.signature,path:i.path,textHint:i.textHint}}}function Pt(e={}){let t={...kt,...e,weights:{...kt.weights,...e.weights}},n=new WeakMap,o=new WeakMap;return{findMatch:(r,i)=>It(r,i,t,n,o),computeMatches:(r,i)=>Ct(r,i,t,n,o),explain:(r,i)=>Lt(r,i,t,n),invalidate:r=>Pn(r,n,o),session:()=>{let r=new WeakMap,i=new WeakMap;return{findMatch:(a,s)=>It(a,s,t,r,i),computeMatches:(a,s)=>Ct(a,s,t,r,i),explain:(a,s)=>Lt(a,s,t,r)}},getConfig:()=>({...t})}}function Xe(e,t){for(;;){for(;t<e.length&&/\s/.test(e[t]);)t++;if(e[t]==="/"&&e[t+1]==="/"){for(;t<e.length&&e[t]!==`
|
|
3
|
+
`;)t++;continue}if(e[t]==="/"&&e[t+1]==="*"){let n=e.indexOf("*/",t+2);if(n===-1)return e.length;t=n+2;continue}return t}}function jt(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(t,n)=>n.length%2===0?n+'\\"':t)}var _n=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,$n=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function _e(e){try{return JSON.parse(e)}catch{return JSON.parse(Dn(e))}}function Dn(e){let t="",n=0,o=(r,i)=>{throw new Error(`Invalid relaxed JSON: ${r} at position ${i}`)};for(;n<e.length&&(n=Xe(e,n),!(n>=e.length));){let r=e[n];if("{}[]:".includes(r)){t+=r,n++;continue}if(r===","){let s=Xe(e,n+1);if(e[s]==="}"||e[s]==="]"){n++;continue}t+=r,n++;continue}if(r==='"'||r==="'"){let s=n+1;for(;s<e.length&&e[s]!==r;)e[s]==="\\"&&s++,s++;s>=e.length&&o("unterminated string",n);let c=e.slice(n+1,s);r==="'"&&(c=jt(c)),t+='"'+c+'"',n=s+1;continue}let i=n;for(;i<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[i]);)i++;i===n&&o("unexpected character "+JSON.stringify(r),n);let a=e.slice(n,i);if(a==="true"||a==="false"||a==="null"||_n.test(a)){t+=a,n=i;continue}if($n.test(a)){if(e[Xe(e,i)]===":"){t+='"'+a+'"',n=i;continue}o("unquoted value "+JSON.stringify(a),n)}o("invalid token "+JSON.stringify(a),n)}return t}function _t(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 n(r){let i=[],a=0;for(;a<r.length;){let s=r[a];if(/\s/.test(s)){a++;continue}if("{}".includes(s)){i.push({type:s,value:s}),a++;continue}if(s==="["){let w=!1,m=a+1;for(;m<r.length&&/\s/.test(r[m]);)m++;if(m<r.length&&/[a-zA-Z_]/.test(r[m])&&(w=!0),!w){i.push({type:s,value:s}),a++;continue}}if(s==="]"){i.push({type:s,value:s}),a++;continue}if(s===":"){i.push({type:t.COLON,value:s}),a++;continue}if(s===","){i.push({type:t.COMMA,value:s}),a++;continue}if(s==='"'||s==="'"){let w=s,m=a+1;for(;m<r.length&&r[m]!==w;)r[m]==="\\"&&m++,m++;i.push({type:t.STRING,value:r.substring(a+1,m),quoted:!0,sourceQuote:w}),a=m+1;continue}let c=a,A;for(;c<r.length&&!/[{},]/.test(r[c]);)if(r[c]===":"){let w=[":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"],m=!1;for(let b of w){let M=b.substring(1);if(r.substring(c+1,c+1+M.length)===M){m=!0,c+=M.length;break}}if(!m)break}else if(r[c]==="["){for(c++;c<r.length&&r[c]!=="]";){if(r[c]==='"'||r[c]==="'"){let w=r[c];for(c++;c<r.length&&r[c]!==w;)r[c]==="\\"&&c++,c++}c++}c<r.length&&r[c]==="]"&&c++}else c++;A=r.substring(a,c);let x=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(A)?x=t.NUMBER:A==="true"||A==="false"||A==="null"?x=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(A)&&(x=t.SELECTOR),i.push({type:x,value:A,quoted:!1}),a=c}return i}function o(r){let i="";for(let a=0;a<r.length;a++){let s=r[a];if("{}".includes(s.type)||"[]".includes(s.type)){i+=s.value;continue}if(s.type===t.COLON){i+=s.value;continue}if(s.type===t.COMMA){let c=r[a+1];if(c&&(c.type==="}"||c.type==="]"))continue;i+=s.value;continue}if(s.type===t.STRING){let c=s.value;s.sourceQuote==="'"&&(c=jt(c)),i+=`"${c}"`;continue}if(s.type===t.NUMBER||s.type===t.BOOLEAN){i+=s.value;continue}i+=`"${s.value}"`}return i}try{let r=n(e),i=o(r);return JSON.parse(i)}catch(r){throw new Error("Invalid extraction rules syntax: "+r.message)}}var $=Symbol("hyper-morph-json-merge:missing"),$t=["id","_id","uuid","key","slug","code","name"];function ge(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Me(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Bn(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})}function se(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!se(e[n],t[n]))return!1;return!0}if(ge(e)&&ge(t)){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o of n)if(!Me(t,o)||!se(e[o],t[o]))return!1;return!0}return!1}function Dt(e,t,n,o){return se(t,n)?t:se(t,e)?n:se(n,e)?t:ge(t)&&ge(n)?Fn(ge(e)?e:{},t,n,o):Array.isArray(t)&&Array.isArray(n)?Vn(Array.isArray(e)?e:[],t,n,o):n}function Bt(e,t,n,o){return t===$&&n===$?$:t===$?e===$?n:se(n,e)?$:n:n===$?e===$?t:$:Dt(e,t,n,o)}function Fn(e,t,n,o){let r={},i=new Set([...Object.keys(e),...Object.keys(t),...Object.keys(n)]);for(let a of i){let s=Bt(Me(e,a)?e[a]:$,Me(t,a)?t[a]:$,Me(n,a)?n[a]:$,o);s!==$&&Bn(r,a,s)}return r}function Un(e){return e===null||typeof e!="object"}function $e(e){return typeof e+":"+String(e)}function qn(e,t){for(let n of t){let o=new Set;for(let r of n){if(!Me(r,e))return!1;let i=r[e];if(typeof i!="string"&&typeof i!="number")return!1;let a=$e(i);if(o.has(a))return!1;o.add(a)}}return!0}function Wn(e,t,n,o){let r=[e,t,n],i=!0;for(let a of r)for(let s of a)ge(s)||(i=!1);if(i){for(let a of o.keyCandidates)if(qn(a,r))return{kind:"keyed",field:a};return null}for(let a of r){let s=new Set;for(let c of a){if(!Un(c))return null;let A=$e(c);if(s.has(A))return null;s.add(A)}}return{kind:"self"}}function Vn(e,t,n,o){let r=Wn(e,t,n,o);if(!r)return n;let i=r.kind==="self"?$e:b=>$e(b[r.field]),a=b=>{let M=new Map;for(let L of b)M.set(i(L),L);return M},s=a(e),c=a(t),A=a(n),x=new Map,w=new Set([...s.keys(),...c.keys(),...A.keys()]);for(let b of w){let M=Bt(s.has(b)?s.get(b):$,c.has(b)?c.get(b):$,A.has(b)?A.get(b):$,o);M!==$&&x.set(b,M)}let m=[];for(let b of n){let M=i(b);x.has(M)&&m.push(M)}for(let b=0;b<t.length;b++){let M=i(t[b]);if(!x.has(M)||m.includes(M))continue;let L=0;for(let j=b-1;j>=0;j--){let P=m.indexOf(i(t[j]));if(P!==-1){L=P+1;break}}m.splice(L,0,M)}return m.map(b=>x.get(b))}function et(e,t,n,o={}){let r=o.keyCandidates?[...o.keyCandidates,...$t]:$t;return Dt(e===void 0?$:e,t,n,{keyCandidates:r})}function tt(e,t,n,o={}){let r=o.parse||_e,i=[],a=(w,m)=>{if(typeof w!="string")return $;try{return r(w)}catch(b){return i.push(`${m} side is not valid JSON (${b.message})`),$}},s=a(t,"local"),c=a(n,"remote");if(s===$)return{text:n,warnings:i};if(c===$)return{text:t,warnings:i};let A=a(e,"base"),x=et(A===$?void 0:A,s,c,o);return se(x,c)?{text:n,warnings:i}:se(x,s)?{text:t,warnings:i}:{text:JSON.stringify(x,null,2),warnings:i}}var nt=function(){"use strict";let e=()=>{},t='[save-ignore],[snapshot-remove],[no-snapshot],[no-save],[save-remove],[freeze],[save-freeze],[clay~="no-save"],[clay~="no-snapshot"],[clay~="freeze"]';function n(p){if(!(p instanceof Element))return!1;if(p.matches(t))return!0;if(p.tagName==="LINK"||p.tagName==="SCRIPT"){let O=p.getAttribute("src")||p.getAttribute("href")||"";if(O.startsWith("chrome-extension://")||O.startsWith("moz-extension://")||O.startsWith("safari-web-extension://"))return!0}return!1}function o(p){return p instanceof Element?p.closest(t)?!0:n(p):!1}let r=Pt({shouldIgnore:o});function i(p,O,v){if(v){let k=v.identityOf(p);if(k&&!v.disabled.has(k.key))return"hm-merge:"+k.key}if(O!=="smart")return p.outerHTML;let N=p.getAttribute("src"),R=p.getAttribute("type")||"text/javascript";if(N)try{let k=new URL(N,window.location.href);return`ext:${R}:${k.origin}${k.pathname}${k.search}`}catch{return`ext:${R}:${N}`}else{let k=p.textContent.trim(),h=5381;for(let E=0;E<k.length;E++)h=(h<<5)+h^k.charCodeAt(E);return`inline:${R}:${Math.abs(h).toString(36)}`}}let a="http://www.w3.org/1999/xhtml";function s(p){return p instanceof Element&&p.tagName==="SCRIPT"&&p.namespaceURI===a}function c(p){let O=document.createElement("div");O.innerHTML="<script><\/script>";let v=O.firstChild;for(let N of p.attributes)v.setAttribute(N.name,N.value);return v.textContent=p.textContent,v}function A(p){if(s(p))return c(p);if(p instanceof Element)for(let O of p.querySelectorAll("script"))s(O)&&O.replaceWith(c(O));return p}function x(p){let O=(p.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return O==="application/json"||O.endsWith("+json")}let w={match:p=>p.hasAttribute("merge"),identity:p=>p.getAttribute("merge")};function m(p,O,v){if(v.merge===!1)return null;let N=[w,...v.mergeTags||[]],R=new WeakMap,k=f=>{if(R.has(f))return R.get(f);let y=null;if(s(f)&&!f.getAttribute("src")&&!o(f)){let S=f;for(let T=0;T<N.length;T++)if(N[T].match(S)){if(!x(S))console.warn("[hyper-morph] merge ignored: script type is not JSON",S);else{let C=N[T].identity(S);C!=null&&C!==""&&(y={key:T+":"+C,raw:C,recognizer:N[T]})}break}}return R.set(f,y),y},h=new Set,E=f=>{let y=new Map,S=T=>{let C=k(T);C&&(y.has(C.key)?(h.add(C.key),console.warn(`[hyper-morph] merge disabled for duplicate identity "${C.raw}"`)):y.set(C.key,T))};s(f)&&S(f);for(let T of f.querySelectorAll("script"))S(T);return y},d=E(p),u=E(O.__hyperMorphRoot||O);if(d.size===0&&u.size===0)return null;let l=null;return{identityOf:k,disabled:h,oldByKey:d,newByKey:u,baseTexts:()=>{if(l)return l;l=new Map;let f=v.mergeBase;if(!f)return l;let y;typeof f=="string"?y=new DOMParser().parseFromString(f,"text/html").documentElement:f instanceof Document?y=f.documentElement:y=f;let S=T=>{let C=k(T);C&&!l.has(C.key)&&l.set(C.key,T.textContent)};s(y)&&S(y);for(let T of y.querySelectorAll("script"))S(T);return l}}}function b(p,O,v){let N=p.merge;if(!N)return!1;let R=N.identityOf(O);if(!R||N.disabled.has(R.key))return!1;let k=N.identityOf(v);if(!k||k.key!==R.key)return!1;let h=O,E=v,d=E.getAttribute("merge-key")||h.getAttribute("merge-key"),{text:u,warnings:l}=tt(N.baseTexts().get(R.key),h.textContent,E.textContent,{parse:R.recognizer.parse,keyCandidates:d?d.split(/[\s,]+/).filter(Boolean):void 0});for(let g of l)console.warn(`[hyper-morph] merge "${R.raw}": ${g}`);return h.textContent!==u&&(h.textContent=u),!0}let M={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:e,afterNodeAdded:e,beforeNodeMorphed:e,afterNodeMorphed:e,beforeNodeRemoved:e,afterNodeRemoved:e,beforeAttributeUpdated:e},head:{style:"merge",shouldPreserve:p=>p.getAttribute("im-preserve")==="true",shouldReAppend:p=>p.getAttribute("im-re-append")==="true",shouldRemove:e,afterHeadMorphed:e},scripts:{handle:!0,matchMode:"outerHTML",shouldPreserve:p=>p.getAttribute("im-preserve")==="true",shouldReAppend:p=>p.getAttribute("im-re-append")==="true",shouldRemove:e,afterScriptsHandled:e},restoreFocus:!0},L={computeMatches(p,O){let{computeMatches:v}=r.session();return v(p,O)}};function j(p,O,v={}){p=on(p);let N=xt(O),R=rn(p,N,v),k=R.scripts.handle?new Set(Array.from(p.querySelectorAll("script")).map(u=>i(u,R.scripts.matchMode,R.merge))):null,h=V(R),E=U(R,p,N,u=>u.morphStyle==="innerHTML"?(I(u,p,N),Array.from(p.childNodes)):D(u,p,N)),d=u=>{h&&Y(R,h),P(R);let l=k?qe(u,k,R):[];return l.length>0?Promise.all(l).then(()=>u):u};return E instanceof Promise?E.then(d):d(E)}function P(p){for(let O of Array.from(p.pantry.childNodes))p.callbacks.beforeNodeRemoved(O)!==!1&&p.callbacks.afterNodeRemoved(O);p.pantry.remove()}function D(p,O,v){let N=xt(O);return I(p,N,v,O,O.nextSibling),Array.from(N.childNodes)}function V(p){if(!p.config.restoreFocus)return null;let O=document.activeElement;if(!(O instanceof HTMLInputElement||O instanceof HTMLTextAreaElement))return null;let{id:v,selectionStart:N,selectionEnd:R}=O;return{element:O,id:v,selectionStart:N,selectionEnd:R}}function Y(p,O){let v=O.element;if(O.id&&O.id!==document.activeElement?.getAttribute("id")&&(v=p.target.querySelector(`[id="${CSS.escape(O.id)}"]`),v?.focus()),v&&!v.selectionEnd&&O.selectionEnd!=null)try{v.setSelectionRange(O.selectionStart,O.selectionEnd)}catch{}}let I=function(){function p(u,l,g,f=null,y=null){l instanceof HTMLTemplateElement&&g instanceof HTMLTemplateElement&&(l=l.content,g=g.content),f||=l.firstChild;for(let S of g.childNodes){if(n(S))continue;if(f&&f!=y){let C=v(u,S,f,y);if(C){C!==f&&R(u,f,C),K(C,S,u),f=C.nextSibling;continue}}if(S instanceof Element){let C=S.getAttribute("id");if(u.persistentIds.has(C)){let _=k(l,C,f,u);K(_,S,u),f=_.nextSibling;continue}if(!u.idMap.has(S)){let _=u.hyperMatches.get(S);if(_&&!u.idMap.has(_)&&!d(_,l)){E(l,_,f),K(_,S,u),f=_.nextSibling;continue}}}let T=O(l,S,f,u);T&&(f=T.nextSibling)}for(;f&&f!=y;){let S=f;f=f.nextSibling,n(S)||N(u,S)}}function O(u,l,g,f){if(f.callbacks.beforeNodeAdded(l)===!1)return null;if(f.idMap.has(l)){let y=l,S=document.createElementNS(y.namespaceURI,y.localName);return u.insertBefore(S,g),K(S,l,f),f.callbacks.afterNodeAdded(S),S}else{let y=A(document.importNode(l,!0));return u.insertBefore(y,g),f.callbacks.afterNodeAdded(y),y}}let v=function(){function u(f,y,S,T){let C=y instanceof Element&&!f.idMap.has(y)?f.hyperMatches.get(y):null,_=null,q=y.nextSibling,Z=0,H=S;for(;H&&H!=T;){if(n(H)){H=H.nextSibling;continue}if(g(H,y)){if(l(f,H,y)||H===C&&!f.idMap.has(H))return H;if(_===null){let z=H instanceof Element&&f.hyperMatchedOldElements.has(H);!f.idMap.has(H)&&!z&&(_=H)}}if(_===null&&q&&g(H,q)&&(Z++,q=q.nextSibling,Z>=2&&(_=void 0)),f.activeElementAndParents.includes(H))break;H=H.nextSibling}return _||null}function l(f,y,S){let T=f.idMap.get(y),C=f.idMap.get(S);if(!C||!T)return!1;for(let _ of T)if(C.has(_))return!0;return!1}function g(f,y){let S=f,T=y;return S.nodeType===T.nodeType&&S.tagName===T.tagName&&(!S.getAttribute?.("id")||S.getAttribute?.("id")===T.getAttribute?.("id"))}return u}();function N(u,l){let g=l instanceof Element&&u.hyperMatchedOldElements.has(l)&&!u.idMap.has(l);if(u.idMap.has(l)||g)E(u.pantry,l,null);else{if(u.callbacks.beforeNodeRemoved(l)===!1)return;l.parentNode?.removeChild(l),u.callbacks.afterNodeRemoved(l)}}function R(u,l,g){let f=l;for(;f&&f!==g;){let y=f;f=f.nextSibling,n(y)||N(u,y)}return f}function k(u,l,g,f){let y=f.target.getAttribute?.("id")===l&&f.target||f.target.querySelector(`[id="${CSS.escape(l)}"]`)||f.pantry.querySelector(`[id="${CSS.escape(l)}"]`);return h(y,f),E(u,y,g),y}function h(u,l){let g=u.getAttribute("id");for(;u=u.parentNode;){let f=l.idMap.get(u);f&&(f.delete(g),f.size||l.idMap.delete(u))}}function E(u,l,g){if(u.moveBefore)try{u.moveBefore(l,g)}catch{u.insertBefore(l,g)}else u.insertBefore(l,g)}function d(u,l){let g=l instanceof Element?l:l.realParentNode;return!!g&&u.contains(g)}return p}(),K=function(){function p(h,E,d){return d.ignoreActive&&h===document.activeElement?null:(d.callbacks.beforeNodeMorphed(h,E)===!1||(h instanceof HTMLHeadElement&&d.head.ignore||(h instanceof HTMLHeadElement&&d.head.style!=="morph"?te(h,E,d):(O(h,E,d),b(d,h,E)||k(h,d)||I(d,h,E))),d.callbacks.afterNodeMorphed(h,E)),h)}function O(h,E,d){let u=E.nodeType;if(u===1){let l=h,g=E,f=l.attributes,y=g.attributes;for(let S of y)R(S.name,l,"update",d)||l.getAttribute(S.name)!==S.value&&l.setAttribute(S.name,S.value);for(let S=f.length-1;0<=S;S--){let T=f[S];if(T&&!g.hasAttribute(T.name)){if(R(T.name,l,"remove",d))continue;l.removeAttribute(T.name)}}k(l,d)||v(l,g,d)}(u===8||u===3)&&h.nodeValue!==E.nodeValue&&(h.nodeValue=E.nodeValue)}function v(h,E,d){if(h instanceof HTMLInputElement&&E instanceof HTMLInputElement&&E.type!=="file"){let u=E.value,l=h.value;N(h,E,"checked",d),N(h,E,"disabled",d),d.formStateSync==="property"&&h.indeterminate!==E.indeterminate&&(h.indeterminate=E.indeterminate),d.formStateSync==="property"?l!==u&&(R("value",h,"update",d)||(h.value=u)):E.hasAttribute("value")?l!==u&&(R("value",h,"update",d)||(h.setAttribute("value",u),h.value=u)):R("value",h,"remove",d)||(h.value="",h.removeAttribute("value"))}else if(h instanceof HTMLOptionElement&&E instanceof HTMLOptionElement)N(h,E,"selected",d);else if(h instanceof HTMLTextAreaElement&&E instanceof HTMLTextAreaElement){let u=E.value,l=h.value;if(R("value",h,"update",d)||(u!==l&&(h.value=u),d.formStateSync==="property"))return;h.firstChild&&h.firstChild.nodeValue!==u&&(h.firstChild.nodeValue=u)}}function N(h,E,d,u){let l=E[d],g=h[d];if(l!==g){let f=R(d,h,"update",u);if(f||(h[d]=E[d]),u.formStateSync==="property")return;l?f||h.setAttribute(d,""):R(d,h,"remove",u)||h.removeAttribute(d)}}function R(h,E,d,u){return h==="value"&&u.ignoreActiveValue&&E===document.activeElement?!0:u.callbacks.beforeAttributeUpdated(h,E,d)===!1}function k(h,E){return!!E.ignoreActiveValue&&h===document.activeElement&&h!==document.body}return p}();function U(p,O,v,N){if(p.head.block){let R=O.querySelector("head"),k=v.querySelector("head");if(R&&k){let h=te(R,k,p);return Promise.all(h).then(()=>(p.head.block=!1,p.head.ignore=!0,N(p)))}}return N(p)}function ee(p){return p.tagName==="SCRIPT"?!!p.getAttribute("src"):p.tagName==="LINK"?(p.getAttribute("rel")||"").toLowerCase().split(/\s+/).includes("stylesheet")&&!!p.getAttribute("href"):!1}function te(p,O,v){let N=[],R=[],k=[],h=[],E=v.scripts.matchMode,d=g=>{if(g.tagName==="SCRIPT")return i(g,E,v.merge);if(g.tagName==="LINK"&&E==="smart"){let f=g.getAttribute("href");if(f)try{let y=new URL(f,window.location.href);return`link:${g.getAttribute("rel")||""}:${y.origin}${y.pathname}${y.search}`}catch{}}return g.outerHTML},u=new Map;for(let g of O.children){if(n(g))continue;let f=d(g),y=u.get(f);y||(y=[],u.set(f,y)),y.push(g)}for(let g of p.children){let f=d(g),y=u.get(f),S=!!(y&&y.length),T=v.head.shouldReAppend(g),C=v.head.shouldPreserve(g);if(S||C)if(T)R.push(g);else{if(y&&y.length){let _=y.pop();y.length||u.delete(f),b(v,g,_)}k.push(g)}else v.head.style==="append"?T&&(R.push(g),h.push(g)):v.head.shouldRemove(g)!==!1&&!n(g)&&R.push(g)}for(let g of u.values())h.push(...g);let l=[];for(let g of h){let f=document.createRange().createContextualFragment(g.outerHTML).firstChild;if(v.callbacks.beforeNodeAdded(f)!==!1){if(f instanceof Element&&ee(f)){let y,S=new Promise(function(T){y=T});f.addEventListener("load",function(){y()}),f.addEventListener("error",function(){y()}),l.push(S)}p.appendChild(f),v.callbacks.afterNodeAdded(f),N.push(f)}}for(let g of R)v.callbacks.beforeNodeRemoved(g)!==!1&&(p.removeChild(g),v.callbacks.afterNodeRemoved(g));return v.head.afterHeadMorphed(p,{added:N,kept:k,removed:R}),l}function qe(p,O,v){if(!v.scripts.handle)return[];let N=[],R=[],k=[],h=[],E=v.scripts.matchMode,d=[];for(let l of p)if(l instanceof Element){s(l)&&d.push(l);for(let g of l.querySelectorAll("script"))s(g)&&d.push(g)}for(let l of d){if(l.closest("head")||o(l))continue;let g=i(l,E,v.merge),f=O.has(g),y=v.scripts.shouldPreserve(l),S=v.scripts.shouldReAppend(l);f||y?S?(R.push(l),h.push(l)):k.push(l):h.push(l)}let u=[];for(let l of h){if(v.callbacks.beforeNodeAdded(l)===!1)continue;let g=document.createElement("script");for(let f of l.attributes)g.setAttribute(f.name,f.value);if(g.textContent=l.textContent,g.src){let f,y=new Promise(function(S){f=S});g.addEventListener("load",function(){f()}),g.addEventListener("error",function(){f()}),u.push(y)}l.replaceWith(g),v.callbacks.afterNodeAdded(g),N.push(g)}return v.scripts.afterScriptsHandled(v.target,{added:N,kept:k,removed:R}),u}let rn=function(){function p(d,u,l){let{persistentIds:g,idMap:f}=h(d,u),y=L.computeMatches(d,u);if(typeof l.key=="function"){let q=new Map,Z=new Set,H=B=>{let F=l.key(B);F!=null&&(q.has(F)?Z.add(F):q.set(F,B))};d instanceof Element&&H(d);for(let B of d.querySelectorAll("*"))H(B);for(let B of Z)q.delete(B);let z=new Map;for(let[B,F]of y)z.set(F,B);let ce=u.__hyperMorphRoot||u,ne=new Map,wt=new Set,vt=B=>{let F=l.key(B);F!=null&&(ne.has(F)?wt.add(F):ne.set(F,B))};ce instanceof Element&&vt(ce);for(let B of ce.querySelectorAll("*"))vt(B);for(let B of wt)ne.delete(B);for(let[B,F]of ne){let he=q.get(B);if(!he||he.tagName!==F.tagName)continue;let We=z.get(he);We&&We!==F&&y.delete(We);let Ve=y.get(F);Ve&&Ve!==he&&z.delete(Ve),y.set(F,he),z.set(he,F)}}let S=O(l),T=m(d,u,S.scripts);if(T){let q=new Map;for(let[Z,H]of y)q.set(H,Z);for(let[Z,H]of T.newByKey){if(T.disabled.has(Z))continue;let z=T.oldByKey.get(Z);if(!z)continue;let ce=q.get(z);ce&&ce!==H&&y.delete(ce);let ne=y.get(H);ne&&ne!==z&&q.delete(ne),y.set(H,z),q.set(z,H)}}let C=new Set;for(let q of y.values())C.add(q);let _=S.morphStyle||"outerHTML";if(!["innerHTML","outerHTML"].includes(_))throw new Error(`Do not understand how to morph style ${_}`);return{target:d,newContent:u,config:S,morphStyle:_,ignoreActive:S.ignoreActive,ignoreActiveValue:S.ignoreActiveValue,restoreFocus:S.restoreFocus,formStateSync:S.formStateSync||"attribute",idMap:f,persistentIds:g,hyperMatches:y,hyperMatchedOldElements:C,merge:T,pantry:v(),activeElementAndParents:N(d),callbacks:S.callbacks,head:S.head,scripts:S.scripts}}function O(d){let u=Object.assign({},M);return Object.assign(u,d),u.callbacks=Object.assign({},M.callbacks,d.callbacks),u.head=Object.assign({},M.head,d.head),u.scripts=Object.assign({},M.scripts,d.scripts),u}function v(){let d=document.createElement("div");return d.hidden=!0,document.body.insertAdjacentElement("afterend",d),d}function N(d){let u=[],l=document.activeElement;if(l?.tagName!=="BODY"&&d.contains(l))for(;l&&(u.push(l),l!==d);)l=l.parentElement;return u}function R(d){let u=Array.from(d.querySelectorAll("[id]"));return d.getAttribute?.("id")&&u.push(d),u}function k(d,u,l,g){for(let f of g){let y=f.getAttribute("id");if(u.has(y)){let S=f;for(;S;){let T=d.get(S);if(T==null&&(T=new Set,d.set(S,T)),T.add(y),S===l)break;S=S.parentElement}}}}function h(d,u){let l=R(d),g=R(u),f=E(l,g),y=new Map;k(y,f,d,l);let S=u.__hyperMorphRoot||u;return k(y,f,S,g),{persistentIds:f,idMap:y}}function E(d,u){let l=new Set,g=new Map;for(let y of d){let S=y.getAttribute("id");g.has(S)?l.add(S):g.set(S,y.tagName)}let f=new Set;for(let y of u){let S=y.getAttribute("id");f.has(S)?l.add(S):g.get(S)===y.tagName&&f.add(S)}for(let y of l)f.delete(y);return f}return p}(),{normalizeElement:on,normalizeParent:xt}=function(){let p=new WeakSet;function O(h){return h instanceof Document?h.documentElement:h}function v(h){if(h==null)return document.createElement("div");if(typeof h=="string")return v(k(h));if(p.has(h))return h;if(h instanceof Node){if(h.parentNode)return new N(h);{let E=document.createElement("div");return E.append(h),E}}else{let E=document.createElement("div");for(let d of[...h])E.append(d);return E}}class N{constructor(E){this.originalNode=E,this.realParentNode=E.parentNode,this.previousSibling=E.previousSibling,this.nextSibling=E.nextSibling}get childNodes(){let E=[],d=this.previousSibling?this.previousSibling.nextSibling:this.realParentNode.firstChild;for(;d&&d!=this.nextSibling;)E.push(d),d=d.nextSibling;return E}querySelectorAll(E){return this.childNodes.reduce((d,u)=>{if(u instanceof Element){u.matches(E)&&d.push(u);let l=u.querySelectorAll(E);for(let g=0;g<l.length;g++)d.push(l[g])}return d},[])}insertBefore(E,d){return this.realParentNode.insertBefore(E,d)}moveBefore(E,d){return this.realParentNode.moveBefore(E,d)}get __hyperMorphRoot(){return this.originalNode}}function R(h){let E=g=>`<${g}(?:\\s(?:[^>"']|"[^"]*"|'[^']*')*)?>`,d=h.replace(/<!--[\s\S]*?-->/g,"");for(let g of["script","style","textarea","title"])d=d.replace(new RegExp(`${E(g)}[\\s\\S]*?</${g}\\s*>`,"gi"),"");let u=new RegExp(`${E("svg")}[\\s\\S]*?</svg\\s*>`,"gi"),l;do l=d,d=d.replace(u,"");while(d!==l);return d}function k(h){let E=new DOMParser,d=R(h);if(d.match(/<\/html>/)||d.match(/<\/head>/)||d.match(/<\/body>/)){let u=E.parseFromString(h,"text/html");if(d.match(/<\/html>/))return p.add(u),u;{let l=u.firstChild;return l&&p.add(l),l}}else{let l=E.parseFromString("<body><template>"+h+"</template></body>","text/html").body.querySelector("template").content;return p.add(l),l}}return{normalizeElement:O,normalizeParent:v}}();return{morph:j,defaults:M,mergeJson:et,mergeScriptText:tt,parseJsonRelaxed:_e,parseRulesRelaxed:_t}}();var Lr=nt.morph,Hr=nt.defaults;var Ft=nt;function rt(e,t,{onWidgetRemoved:n}={}){Ft.morph(e,t,{morphStyle:"innerHTML",ignoreActiveValue:!0,restoreFocus:!0,formStateSync:"property",callbacks:{beforeNodeRemoved(o){let r=Pe.get(o);r?.destroy&&r.destroy(),n?.(o)}}})}var zn="hha:upgrade-check:";function Q(e,t){let n=e.querySelector(`meta[name="${t}"]`),o=n?n.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function ot(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function Ut(e,t){let n=ot(e),o=ot(t);if(!n||!o)return!1;let r=Math.max(n.length,o.length);for(let i=0;i<r;i++){let a=n[i]||0,s=o[i]||0;if(a!==s)return a>s}return!1}function Jn(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function Gn(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function st({force:e=!1,doc:t,loc:n,fetchFn:o,now:r,ttlMs:i=864e5}={}){if(t=t||(typeof document<"u"?document:null),n=n||(typeof location<"u"?location:null),o=o||(m=>fetch(m)),r=r??Date.now(),!t)return null;let a=Q(t,"hyper-source");if(!a)return null;let s=Q(t,"hyper-version"),c;try{c=new URL(a,n?n.href:void 0)}catch{return null}if(n&&c.origin===n.origin&&c.pathname===n.pathname)return null;let A=`${zn}${c.href}:${s||"none"}`,x,w=e?null:Jn(A);if(w&&typeof w.checkedAt=="number"&&r-w.checkedAt<i)x=w.sourceVersion;else{try{let m=await o(c.href);if(!m.ok)throw new Error(`HTTP ${m.status}`);let b=await m.text(),M=new DOMParser().parseFromString(b,"text/html");x=Q(M,"hyper-version")}catch{x=null}Gn(A,{checkedAt:r,sourceVersion:x})}return x?{available:Ut(x,s||"0.0.0"),currentVersion:s,sourceVersion:x,sourceUrl:c.href}:null}var De=["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(De),qt=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Wt=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var Be={};ze(Be,{EmptyListInsert:()=>we,MAX_RULE_DEPTH:()=>be,MaxRuleDepthExceeded:()=>ue,RuleTargetReadOnly:()=>ve,RulesParseError:()=>ye,ShapeMismatch:()=>xe,UnknownRulesVersion:()=>le});var ye=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},le=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},be=20,ue=class extends Error{constructor(t){super(`rule depth exceeded ${be} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},xe=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},we=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}},ve=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}};function X(e,t,n,o={}){return at(e,t,n,{depth:0,path:[]},o)}function at(e,t,n,o,r){if(o.depth>be)throw new ue(o.path);if(typeof n=="string")return Yn(e,t,n,r);if(Array.isArray(n)){let[i,a]=n;return e.find(t,i,r).map((c,A)=>at(e,c,a,{depth:o.depth+1,path:[...o.path,A]},r))}if(typeof n=="object"&&n!==null){let i={};for(let[a,s]of Object.entries(n))i[a]=at(e,t,s,{depth:o.depth+1,path:[...o.path,a]},r);return i}return null}function Yn(e,t,n,o){if(n.endsWith("[]")){let a=n.slice(0,-2);return e.find(t,a,o).map(s=>e.text(s))}if(n.startsWith("@"))return Vt(e,t,n.slice(1));let r=oe(n);if(r!==-1){let a=n.slice(0,r),s=n.slice(r+1),c=a?e.find(t,a,o):[t];return c.length===0?null:Vt(e,c[0],s)}if(n===".")return e.text(t);let i=e.find(t,n,o);return i.length===0?null:e.text(i[0])}function Vt(e,t,n){if(it.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let o=e.attr(t,n);return o||null}function Zn(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Qn(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var Xn={find(e,t,n={}){let o=Qn(e);if(!o||!o.querySelectorAll)return[];let r=Array.from(o.querySelectorAll(t));n.includeRulesTag||(r=r.filter(s=>!Zn(s)));let i=[];n.skip&&i.push(n.skip);let a=n.templateAttr===null?null:n.templateAttr||"cms-template";if(a&&i.push("["+a+"]"),i.length){let s=i.join(", ");r=r.filter(c=>!c.closest||!c.closest(s))}return r},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,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t)},prop(e,t,n){if(n===void 0){let o=e?e[t]:void 0;return o!==void 0?o:null}e[t]=n},clone(e){return e.cloneNode(!0)},insertAt(e,t,n){let o=e.children[n]||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 r=o.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},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}},W=Xn;function ct(e){try{return JSON.parse(e)}catch(t){throw new ye(`Invalid strict JSON: ${t.message}`,t)}}function fe(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 n(r){let i=[],a=0;for(;a<r.length;){let s=r[a];if(/\s/.test(s)){a++;continue}if("{}".includes(s)){i.push({type:s,value:s}),a++;continue}if(s==="["){let w=!1,m=a+1;for(;m<r.length&&/\s/.test(r[m]);)m++;if(m<r.length&&/[a-zA-Z_]/.test(r[m])&&(w=!0),!w){i.push({type:s,value:s}),a++;continue}}if(s==="]"){i.push({type:s,value:s}),a++;continue}if(s===":"){i.push({type:t.COLON,value:s}),a++;continue}if(s===","){i.push({type:t.COMMA,value:s}),a++;continue}if(s==='"'||s==="'"){let w=s,m=a+1;for(;m<r.length&&r[m]!==w;)r[m]==="\\"&&m++,m++;i.push({type:t.STRING,value:r.substring(a+1,m),quoted:!0,sourceQuote:w}),a=m+1;continue}let c=a,A;for(;c<r.length&&!/[{},]/.test(r[c]);)if(r[c]===":"){let w=[":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"],m=!1;for(let b of w){let M=b.substring(1);if(r.substring(c+1,c+1+M.length)===M){m=!0,c+=M.length;break}}if(!m)break}else if(r[c]==="["){for(c++;c<r.length&&r[c]!=="]";){if(r[c]==='"'||r[c]==="'"){let w=r[c];for(c++;c<r.length&&r[c]!==w;)r[c]==="\\"&&c++,c++}c++}c<r.length&&r[c]==="]"&&c++}else c++;A=r.substring(a,c);let x=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(A)?x=t.NUMBER:A==="true"||A==="false"||A==="null"?x=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(A)&&(x=t.SELECTOR),i.push({type:x,value:A,quoted:!1}),a=c}return i}function o(r){let i="";for(let a=0;a<r.length;a++){let s=r[a];if("{}".includes(s.type)||"[]".includes(s.type)){i+=s.value;continue}if(s.type===t.COLON){i+=s.value;continue}if(s.type===t.COMMA){let c=r[a+1];if(c&&(c.type==="}"||c.type==="]"))continue;i+=s.value;continue}if(s.type===t.STRING&&s.quoted){let c=s.value;s.sourceQuote==="'"&&(c=c.replace(/\\'/g,"'"),c=c.replace(/(\\*)"/g,(A,x)=>x.length%2===0?x+'\\"':A)),i+=`"${c}"`;continue}if(s.type===t.NUMBER||s.type===t.BOOLEAN){i+=s.value;continue}if(s.type===t.SELECTOR||s.type===t.IDENTIFIER){i+=`"${s.value}"`;continue}i+=`"${s.value}"`}return i}try{let r=n(e),i=o(r);return JSON.parse(i)}catch(r){throw new ye("Invalid extraction rules syntax: "+r.message,r)}}var lt="1",Kt=/^[a-zA-Z0-9_-]+$/;function Ae(e,t,n){let o;if(n===void 0)o="script[data-rules-name]";else{if(typeof n!="string"||!Kt.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${Kt})`);o=`script[data-rules-name~="${n}"]`}let r=e.find(t,o,{includeRulesTag:!0});if(r.length===0)return null;n!==void 0&&r.length>1&&console.warn(`hyper-html-api: ${r.length} rules tags match data-rules-name~="${n}"; using the first.`);let i=r[0],a=e.attr(i,"data-rules-version");if(a!==lt)throw new le(a);return{rules:fe(e.text(i)),tagNode:i}}var er="script[data-rules-name]";function zt(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function Oe(e,t){let n=e.find(t,er,{includeRulesTag:!0}),o=new Set,r=[];for(let i of n){let a=zt(e.attr(i,"data-rules-name"));if(!a)continue;if(o.has(a)){console.warn(`hyper-html-api: duplicate rules tag name "${a}"; using the first.`);continue}let s=e.attr(i,"data-rules-version");if(s!==lt)throw new le(s);o.add(a),r.push({name:a,rules:fe(e.text(i))})}return r}function Fe(e,t){let n={};for(let{name:o,rules:r}of Oe(e,t))n[o]=X(e,t,r);return n}function ut(e){let t=e||document,n=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:Fe(W,t),version:Q(n,"hyper-version")}}var Se=class extends Error{constructor(t,n){super(`could not fetch upgrade source: ${t}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=t,this.cause=n}},Re=class extends Error{constructor(t){super(`upgrade source has no rules tags; refusing to drop all existing data: ${t}`),this.name="UpgradeSourceHasNoRules",this.sourceUrl=t}},ie=class extends Error{constructor(t,n){super(t),this.name="UpgradeTransformInvalid",this.cause=n}},Te=class extends Error{constructor(t){super(`found ${t} script[type="text/hyper-upgrade"] tags; only one is allowed per document.`),this.name="UpgradeMultipleTransforms",this.count=t}};var Jt="text/hyper-upgrade";function ft(e,t){let n=e.find(t,`script[type="${Jt}"]`);if(n.length===0)return null;if(n.length>1)throw new Te(n.length);return e.text(n[0])||null}var tr=new Function("url","return import(url)");async function dt(e){let t=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(t),o;try{o=await tr(n)}catch(r){throw new ie(`transform failed to load: ${r&&r.message?r.message:r}`,r)}finally{URL.revokeObjectURL(n)}if(typeof o.default!="function")throw new ie("transform must `export default` a function");return o.default}var nr=.5;function ht(e,t,n,o,r,i,a,s={}){let c=e.find(t,n,s);if(r.length===0){c.forEach(I=>e.remove(I));return}let A=r.length>c.length,x=c[0]||null;if(A&&!x&&(x=ir(e,t,n,s),!x))throw new we(i.path);let w=c.map(I=>rr(e,I,o,s)),m=null;if(x){m=e.clone(x),s.templateAttr&&e.removeAttr(m,s.templateAttr);let I=e.stripIds(m);I>0&&console.warn(`[hyper-html-api] stripped ${I} id attribute(s) from cloned template at "${i.path.join(".")||"(root)"}"`)}let b=or(r,w,o),M=c[0]||x,L=e.parent(M),j=c.length>0?Yt(e,L,M):0,P=ar(e,c),D=new Set,V=[],Y=r.map((I,K)=>{let U=b[K];if(U>=0)return D.add(U),V.push(!1),c[U];V.push(!0);let ee=e.clone(m);return e.stripIds(ee),ee});if(c.forEach((I,K)=>{D.has(K)||e.remove(I)}),P){Y.forEach((I,K)=>{let U=j+K;e.children(L).findIndex(qe=>e.sameNode(qe,I))!==U&&e.insertAt(L,I,U)}),Gt(e,Y,o,r,i,a,s);return}cr(e,Y,V,L,j),Gt(e,Y,o,r,i,a,s)}function Gt(e,t,n,o,r,i,a){t.forEach((s,c)=>{if(n===null){let A=o[c],x=A==null?"":String(A);e.text(s)!==x&&e.text(s,x)}else{let A=i(e,s,n,o[c],{depth:r.depth+1,path:[...r.path,c]},a);A&&A!==s&&(t[c]=A)}})}function rr(e,t,n,o){return n===null?e.text(t):X(e,t,n,o)}function or(e,t,n){let o=new Array(e.length).fill(-1),r=new Set;return e.forEach((i,a)=>{let s=-1,c=-1;t.forEach((A,x)=>{if(r.has(x))return;let w=sr(i,A,n),m=w===c&&s>=0?Math.abs(x-a)<Math.abs(s-a):!1;(w>c||m)&&(c=w,s=x)}),c>=nr&&(o[a]=s,r.add(s))}),o}function sr(e,t,n){if(n===null)return e===t?1:0;let o=Object.keys(n||{});if(o.length===0)return 0;let r=0;for(let i of o)JSON.stringify(e?.[i])===JSON.stringify(t?.[i])&&r++;return r/o.length}function Yt(e,t,n){let o=e.children(t);for(let r=0;r<o.length;r++)if(e.sameNode(o[r],n))return r;return-1}function ir(e,t,n,o){if(!o.templateAttr)return null;let r=t;for(;r;){let i=e.find(r,n,{includeRulesTag:!1,templateAttr:null});for(let a of i)if(e.attr(a,o.templateAttr)!=null)return a;r=e.parent(r)}return null}function ar(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let o=e.children(n),r=[];for(let i of t){let a=o.findIndex(s=>e.sameNode(s,i));if(a===-1)return!1;r.push(a)}return r.sort((i,a)=>i-a),r[r.length-1]-r[0]===r.length-1}function cr(e,t,n,o,r){let i=null,a=r;for(let s=0;s<t.length;s++){if(!n[s]){i=t[s];continue}let c=i?e.parent(i):o;if(!c)continue;let A=i?Yt(e,c,i)+1:a++;e.insertAt(c,t[s],A),i=t[s]}}var Zt=new Set(["checked","selected","disabled","readOnly","paused"]);function ae(e,t,n,o,r={}){let i=[];if(pt(n,o,[],i),i.length)throw new xe(i);Ue(e,t,n,o,{depth:0,path:[]},r)}function Ue(e,t,n,o,r,i={}){if(r.depth>be)throw new ue(r.path);if(o===void 0)return t;if(typeof n=="string")return lr(e,t,n,o,r,i);if(Array.isArray(n)){let[a,s]=n;return ht(e,t,a,s,o,r,Ue,i),t}if(typeof n=="object"&&n!==null){for(let[a,s]of Object.entries(n)){let c=Ue(e,t,s,o==null?o:o[a],{depth:r.depth+1,path:[...r.path,a]},i);c&&c!==t&&(t=c)}return t}return t}function lr(e,t,n,o,r,i){if(n.endsWith("[]")){let c=n.slice(0,-2);return ht(e,t,c,null,o,r,Ue,i),t}if(n.startsWith("@"))return Qt(e,t,n.slice(1),o);let a=oe(n);if(a!==-1){let c=n.slice(0,a),A=n.slice(a+1),x=c?e.find(t,c,i):[t];return x.length===0||Qt(e,x[0],A,o),t}if(n===".")return e.text(t,o==null?"":String(o)),t;let s=e.find(t,n,i);return s.length===0||e.text(s[0],o==null?"":String(o)),t}function Qt(e,t,n,o){if(Wt.has(n))throw new ve(n);if(n==="outerHTML"){let r=o==null?"":String(o);return e.replaceWith(t,r)}return qt.has(n)?(e.prop(t,n,ur(n,o)),t):(e.attr(t,n,o==null?"":String(o)),t)}function ur(e,t){return t==null?Zt.has(e)?!1:"":Zt.has(e)?!!t:t}function pt(e,t,n,o){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,i)=>{typeof r=="object"&&r!==null&&o.push({path:ke([...n,i]),expected:"scalar",got:Ne(r)})}):o.push({path:ke(n),expected:"array",got:Ne(t)});return}t!==null&&typeof t=="object"&&o.push({path:ke(n),expected:"scalar",got:Ne(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:ke(n),expected:"array",got:Ne(t)});return}let r=e[1];t.forEach((i,a)=>pt(r,i,[...n,a],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:ke(n),expected:"object",got:Ne(t)});return}for(let[r,i]of Object.entries(e))pt(i,t[r],[...n,r],o)}}}function Ne(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function ke(e){return e.join(".")}function Ie(e,t){let n={carriedOver:0,discarded:0,listItems:0},o=mt(t,e,n);return gt(t,e,n),{data:o,summary:n}}function mt(e,t,n){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(t)?(n.listItems+=t.length,n.carriedOver+=t.length,t):void 0:t==null||typeof t=="object"?void 0:(n.carriedOver++,t);if(Array.isArray(e)){let[,o]=e;return Array.isArray(t)?(n.listItems+=t.length,t.map(r=>mt(o,r,n))):void 0}if(typeof e=="object"&&e!==null){let o={};for(let[r,i]of Object.entries(e)){let a=mt(i,t?.[r],n);a!==void 0&&(o[r]=a)}return o}}function gt(e,t,n){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 r of Object.keys(t))o.has(r)?gt(e[r],t[r],n):n.discarded+=de(t[r]);return}if(Array.isArray(e)&&Array.isArray(t)){let o=e[1];t.forEach(r=>gt(o,r,n));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(n.discarded+=de(t))}}function de(e){return e==null?0:Array.isArray(e)?e.reduce((t,n)=>t+de(n),0):typeof e=="object"?Object.values(e).reduce((t,n)=>t+de(n),0):1}function yt(e,t,n){let o=Oe(e,t),r={carriedOver:0,discarded:0,listItems:0},i={},a=new Set;for(let{name:s,rules:c}of o){if(a.add(s),!Object.prototype.hasOwnProperty.call(n,s)){i[s]={carriedOver:0,discarded:0,listItems:0};continue}let{data:A,summary:x}=Ie(n[s],c);ae(e,t,c,A),i[s]=x,r.carriedOver+=x.carriedOver,r.discarded+=x.discarded,r.listItems+=x.listItems}for(let s of Object.keys(n))a.has(s)||(r.discarded+=de(n[s]));return{totals:r,byName:i,rulesTagCount:o.length}}async function bt({sourceUrl:e,dataByName:t,fromVersion:n,doc:o,loc:r,fetchFn:i}={}){if(o=o||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),i=i||(P=>fetch(P)),!o)throw new Error("upgrade.run requires a document context");if(e=e||Q(o,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let a=new URL(e,r?r.href:void 0);n=n!==void 0?n:Q(o,"hyper-version"),t=t||Fe(W,o);let s;try{s=await i(a.href)}catch(P){throw new Se(a.href,P)}if(!s.ok)throw new Se(a.href,new Error(`HTTP ${s.status}`));let c=await s.text(),A=new DOMParser().parseFromString(c,"text/html"),x=Q(A,"hyper-version"),w=t,m=!1,b=ft(W,A);if(b){let D=await(await dt(b))(w,{fromVersion:n,toVersion:x});if(!D||typeof D!="object"||Array.isArray(D))throw new ie("transform must return a plain object map of { rulesName: data }");w=D,m=!0}let{totals:M,byName:L,rulesTagCount:j}=yt(W,A,w);if(j===0&&Object.keys(w).length>0)throw new Re(a.href);return{html:fr(A),fromVersion:n,toVersion:x,summary:{transformApplied:m,totals:M,byName:L}}}function fr(e){return`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
|
|
4
|
+
`+e.documentElement.outerHTML}function At(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null};if(typeof n=="string"){let o=t&&t.ownerDocument?t.ownerDocument:t;return Ae(e,o,n)}return null}function Xt(e,t,n,o){let r=At(e,t,n);if(!r){let s=typeof n=="string"?`data-rules-name~="${n}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${s}`)}let{rules:i,tagNode:a}=r;return{rules:i,tagNode:a,get:()=>X(e,t,i,o),set:s=>ae(e,t,i,s,o)}}var Ce={extract:(e,t,n)=>X(W,e,t,n),apply:(e,t,n,o)=>ae(W,e,t,n,o),findRulesIn:(e,t)=>Ae(W,e,t),findRules:(e,t)=>At(W,e,t),bind:(e,t,n)=>Xt(W,e,t,n),parseStrict:ct,parseRelaxed:fe,ruleAttrIndex:oe,splitRule:me,errors:Be,DOM_PROPERTIES:De},St=e=>!!e&&typeof e.nodeType=="number";function en(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=W.find(t,"script[data-rules-name]",{includeRulesTag:!0});if(n.length===0)throw new Error('hyper-html-api: no rules tag found. Add <script type="application/json" data-rules-name="\u2026" data-rules-version="1"> or pass rules.');if(n.length>1)throw new Error('hyper-html-api: multiple rules tags found; pass a name, e.g. extractData("api").');return Ae(W,t).rules}function Et(e,t){let n=St(e)?e:document,o=St(e)?t:e;return o===void 0?X(W,n,en(n)):Ce.bind(n,o).get()}function Mt(e,t,n){if(!St(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");return n===void 0?ae(W,e,en(e),t):Ce.bind(e,n).set(t),e}var tn={buildForm:Ge,bindFormEvents:Ye,scaffold:pe,morphForm:rt,path:He},nn={checkForUpdate:st,run:bt,extractAll:ut,shapeMatch:Ie};var pr={engine:Ce,cms:tn,upgrade:nn,extractData:Et,applyData:Mt},mr=pr;return un(gr);})();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var hyperHtmlApiUpgrade=(()=>{var Y=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var Se=Object.prototype.hasOwnProperty;var ie=(e,t)=>{for(var r in t)Y(e,r,{get:t[r],enumerable:!0})},be=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of we(t))!Se.call(e,n)&&n!==r&&Y(e,n,{get:()=>t[n],enumerable:!(o=Te(t,n))||o.enumerable});return e};var Ie=e=>be(Y({},"__esModule",{value:!0}),e);var Qe={};ie(Qe,{default:()=>Xe,engine:()=>re,upgrade:()=>Oe});var W=["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"],z=new Set(W),ce=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),le=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var B={};ie(B,{EmptyListInsert:()=>j,MAX_RULE_DEPTH:()=>P,MaxRuleDepthExceeded:()=>w,RuleTargetReadOnly:()=>C,RulesParseError:()=>_,ShapeMismatch:()=>L,UnknownRulesVersion:()=>T});var _=class extends Error{constructor(t,r){super(t),this.name="RulesParseError",this.cause=r}},T=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},P=20,w=class extends Error{constructor(t){super(`rule depth exceeded ${P} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},L=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},j=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}},C=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}};function E(e,t,r,o={}){return G(e,t,r,{depth:0,path:[]},o)}function G(e,t,r,o,n){if(o.depth>P)throw new w(o.path);if(typeof r=="string")return Ne(e,t,r,n);if(Array.isArray(r)){let[i,c]=r;return e.find(t,i,n).map((l,u)=>G(e,l,c,{depth:o.depth+1,path:[...o.path,u]},n))}if(typeof r=="object"&&r!==null){let i={};for(let[c,s]of Object.entries(r))i[c]=G(e,t,s,{depth:o.depth+1,path:[...o.path,c]},n);return i}return null}function Ne(e,t,r,o){if(r.endsWith("[]")){let i=r.slice(0,-2);return e.find(t,i,o).map(c=>e.text(c))}if(r.startsWith("@"))return fe(e,t,r.slice(1));if(r.includes("@")){let i=r.lastIndexOf("@"),c=r.slice(0,i),s=r.slice(i+1),l=c?e.find(t,c,o):[t];return l.length===0?null:fe(e,l[0],s)}if(r===".")return e.text(t);let n=e.find(t,r,o);return n.length===0?null:e.text(n[0])}function fe(e,t,r){if(z.has(r)){let n=e.prop(t,r);return n==null?null:String(n)}let o=e.attr(t,r);return o||null}var Me=.5;function X(e,t,r,o,n,i,c,s={}){let l=e.find(t,r,s);if(n.length===0){l.forEach(p=>e.remove(p));return}let u=n.length>l.length,f=l[0]||null;if(u&&!f&&(f=je(e,t,r,s),!f))throw new j(i.path);let d=l.map(p=>_e(e,p,o,s)),a=null;if(f){a=e.clone(f),s.templateAttr&&e.removeAttr(a,s.templateAttr);let p=e.stripIds(a);p>0&&console.warn(`[hyper-html-api] stripped ${p} id attribute(s) from cloned template at "${i.path.join(".")||"(root)"}"`)}let R=Pe(n,d,o),y=l[0]||f,N=e.parent(y),K=l.length>0?Le(e,N,y):0,A=new Set,O=n.map((p,g)=>{let h=R[g];if(h>=0)return A.add(h),l[h];let M=e.clone(a);return e.stripIds(M),M});l.forEach((p,g)=>{A.has(g)||e.remove(p)}),O.forEach((p,g)=>{let h=K+g;e.children(N).findIndex(Ae=>e.sameNode(Ae,p))!==h&&e.insertAt(N,p,h)}),O.forEach((p,g)=>{if(o===null){let h=n[g],M=h==null?"":String(h);e.text(p)!==M&&e.text(p,M)}else{let h=c(e,p,o,n[g],{depth:i.depth+1,path:[...i.path,g]},s);h&&h!==p&&(O[g]=h)}})}function _e(e,t,r,o){return r===null?e.text(t):E(e,t,r,o)}function Pe(e,t,r){let o=new Array(e.length).fill(-1),n=new Set;return e.forEach((i,c)=>{let s=-1,l=-1;t.forEach((u,f)=>{if(n.has(f))return;let d=De(i,u,r),a=d===l&&s>=0?Math.abs(f-c)<Math.abs(s-c):!1;(d>l||a)&&(l=d,s=f)}),l>=Me&&(o[c]=s,n.add(s))}),o}function De(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 i of o)JSON.stringify(e?.[i])===JSON.stringify(t?.[i])&&n++;return n/o.length}function Le(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 je(e,t,r,o){if(!o.templateAttr)return null;let n=t;for(;n;){let i=e.find(n,r,{includeRulesTag:!1,templateAttr:null});for(let c of i)if(e.attr(c,o.templateAttr)!=null)return c;n=e.parent(n)}return null}var ae=new Set(["checked","selected","disabled","readOnly","paused"]);function S(e,t,r,o,n={}){let i=[];if(Q(r,o,[],i),i.length)throw new L(i);q(e,t,r,o,{depth:0,path:[]},n)}function q(e,t,r,o,n,i={}){if(n.depth>P)throw new w(n.path);if(o===void 0)return t;if(typeof r=="string")return Ce(e,t,r,o,n,i);if(Array.isArray(r)){let[c,s]=r;return X(e,t,c,s,o,n,q,i),t}if(typeof r=="object"&&r!==null){for(let[c,s]of Object.entries(r)){let l=q(e,t,s,o==null?o:o[c],{depth:n.depth+1,path:[...n.path,c]},i);l&&l!==t&&(t=l)}return t}return t}function Ce(e,t,r,o,n,i){if(r.endsWith("[]")){let s=r.slice(0,-2);return X(e,t,s,null,o,n,q,i),t}if(r.startsWith("@"))return ue(e,t,r.slice(1),o);if(r.includes("@")){let s=r.lastIndexOf("@"),l=r.slice(0,s),u=r.slice(s+1),f=l?e.find(t,l,i):[t];return f.length===0||ue(e,f[0],u,o),t}if(r===".")return e.text(t,o==null?"":String(o)),t;let c=e.find(t,r,i);return c.length===0||e.text(c[0],o==null?"":String(o)),t}function ue(e,t,r,o){if(le.has(r))throw new C(r);if(r==="outerHTML"){let n=o==null?"":String(o);return e.replaceWith(t,n)}return ce.has(r)?(e.prop(t,r,ke(r,o)),t):(e.attr(t,r,o==null?"":String(o)),t)}function ke(e,t){return t==null?ae.has(e)?!1:"":ae.has(e)?!!t:t}function Q(e,t,r,o){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((n,i)=>{typeof n=="object"&&n!==null&&o.push({path:$([...r,i]),expected:"scalar",got:k(n)})}):o.push({path:$(r),expected:"array",got:k(t)});return}t!==null&&typeof t=="object"&&o.push({path:$(r),expected:"scalar",got:k(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:$(r),expected:"array",got:k(t)});return}let n=e[1];t.forEach((i,c)=>Q(n,i,[...r,c],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:$(r),expected:"object",got:k(t)});return}for(let[n,i]of Object.entries(e))Q(i,t[n],[...r,n],o)}}}function k(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function $(e){return e.join(".")}function Z(e){try{return JSON.parse(e)}catch(t){throw new _(`Invalid strict JSON: ${t.message}`,t)}}function b(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 i=[],c=0;for(;c<n.length;){let s=n[c];if(/\s/.test(s)){c++;continue}if("{}".includes(s)){i.push({type:s,value:s}),c++;continue}if(s==="["){let d=!1,a=c+1;for(;a<n.length&&/\s/.test(n[a]);)a++;if(a<n.length&&/[a-zA-Z_]/.test(n[a])&&(d=!0),!d){i.push({type:s,value:s}),c++;continue}}if(s==="]"){i.push({type:s,value:s}),c++;continue}if(s===":"){i.push({type:t.COLON,value:s}),c++;continue}if(s===","){i.push({type:t.COMMA,value:s}),c++;continue}if(s==='"'||s==="'"){let d=s,a=c+1;for(;a<n.length&&n[a]!==d;)n[a]==="\\"&&a++,a++;i.push({type:t.STRING,value:n.substring(c+1,a),quoted:!0,sourceQuote:d}),c=a+1;continue}let l=c,u;for(;l<n.length&&!/[{},]/.test(n[l]);)if(n[l]===":"){let d=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],a=!1;for(let R of d){let y=R.substring(1);if(n.substring(l+1,l+1+y.length)===y){a=!0,l+=y.length;break}}if(!a)break}else if(n[l]==="["){for(l++;l<n.length&&n[l]!=="]";){if(n[l]==='"'||n[l]==="'"){let d=n[l];for(l++;l<n.length&&n[l]!==d;)n[l]==="\\"&&l++,l++}l++}l<n.length&&n[l]==="]"&&l++}else l++;u=n.substring(c,l);let f=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(u)?f=t.NUMBER:u==="true"||u==="false"||u==="null"?f=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(u)&&(f=t.SELECTOR),i.push({type:f,value:u,quoted:!1}),c=l}return i}function o(n){let i="";for(let c=0;c<n.length;c++){let s=n[c];if("{}".includes(s.type)||"[]".includes(s.type)){i+=s.value;continue}if(s.type===t.COLON){i+=s.value;continue}if(s.type===t.COMMA){let l=n[c+1];if(l&&(l.type==="}"||l.type==="]"))continue;i+=s.value;continue}if(s.type===t.STRING&&s.quoted){let l=s.value;s.sourceQuote==="'"&&(l=l.replace(/\\'/g,"'"),l=l.replace(/(\\*)"/g,(u,f)=>f.length%2===0?f+'\\"':u)),i+=`"${l}"`;continue}if(s.type===t.NUMBER||s.type===t.BOOLEAN){i+=s.value;continue}if(s.type===t.SELECTOR||s.type===t.IDENTIFIER){i+=`"${s.value}"`;continue}i+=`"${s.value}"`}return i}try{let n=r(e),i=o(n);return JSON.parse(i)}catch(n){throw new _("Invalid extraction rules syntax: "+n.message,n)}}var ee="1",de=/^[a-zA-Z0-9_-]+$/;function U(e,t,r){let o;if(r===void 0)o="script[data-rules-name]";else{if(typeof r!="string"||!de.test(r))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(r)} (must match ${de})`);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 i=n[0],c=e.attr(i,"data-rules-version");if(c!==ee)throw new T(c);return{rules:b(e.text(i)),tagNode:i}}function te(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 U(e,o,r)}return null}function pe(e,t,r,o){let n=te(e,t,r);if(!n){let s=typeof r=="string"?`data-rules-name~="${r}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${s}`)}let{rules:i,tagNode:c}=n;return{rules:i,tagNode:c,get:()=>E(e,t,i,o),set:s=>S(e,t,i,s,o)}}function Ue(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function He(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var We={find(e,t,r={}){let o=He(e);if(!o||!o.querySelectorAll)return[];let n=Array.from(o.querySelectorAll(t));r.includeRulesTag||(n=n.filter(s=>!Ue(s)));let i=[];r.skip&&i.push(r.skip);let c=r.templateAttr===null?null:r.templateAttr||"cms-template";if(c&&i.push("["+c+"]"),i.length){let s=i.join(", ");n=n.filter(l=>!l.closest||!l.closest(s))}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}},m=We;var re={extract:(e,t,r)=>E(m,e,t,r),apply:(e,t,r,o)=>S(m,e,t,r,o),findRulesIn:(e,t)=>U(m,e,t),findRules:(e,t)=>te(m,e,t),bind:(e,t,r)=>pe(m,e,t,r),parseStrict:Z,parseRelaxed:b,errors:B,DOM_PROPERTIES:W};var Be="hha:upgrade-check:";function x(e,t){let r=e.querySelector(`meta[name="${t}"]`),o=r?r.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function he(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function qe(e,t){let r=he(e),o=he(t);if(!r||!o)return!1;let n=Math.max(r.length,o.length);for(let i=0;i<n;i++){let c=r[i]||0,s=o[i]||0;if(c!==s)return c>s}return!1}function Fe(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function Je(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function me({force:e=!1,doc:t,loc:r,fetchFn:o,now:n,ttlMs:i=864e5}={}){if(t=t||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),o=o||(a=>fetch(a)),n=n??Date.now(),!t)return null;let c=x(t,"hyper-source");if(!c)return null;let s=x(t,"hyper-version"),l;try{l=new URL(c,r?r.href:void 0)}catch{return null}if(r&&l.origin===r.origin&&l.pathname===r.pathname)return null;let u=`${Be}${l.href}:${s||"none"}`,f,d=e?null:Fe(u);if(d&&typeof d.checkedAt=="number"&&n-d.checkedAt<i)f=d.sourceVersion;else{try{let a=await o(l.href);if(!a.ok)throw new Error(`HTTP ${a.status}`);let R=await a.text(),y=new DOMParser().parseFromString(R,"text/html");f=x(y,"hyper-version")}catch{f=null}Je(u,{checkedAt:n,sourceVersion:f})}return f?{available:qe(f,s||"0.0.0"),currentVersion:s,sourceVersion:f,sourceUrl:l.href}:null}var Ve="script[data-rules-name]";function ve(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function F(e,t){let r=e.find(t,Ve,{includeRulesTag:!0}),o=new Set,n=[];for(let i of r){let c=ve(e.attr(i,"data-rules-name"));if(!c)continue;if(o.has(c)){console.warn(`hyper-html-api: duplicate rules tag name "${c}"; using the first.`);continue}let s=e.attr(i,"data-rules-version");if(s!==ee)throw new T(s);o.add(c),n.push({name:c,rules:b(e.text(i))})}return n}function ne(e,t){let r={};for(let{name:o,rules:n}of F(e,t))r[o]=E(e,t,n);return r}function ye(e){let t=e||document,r=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:ne(m,t),version:x(r,"hyper-version")}}var H=class extends Error{constructor(t,r){super(`could not fetch upgrade source: ${t}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=t,this.cause=r}},J=class extends Error{constructor(t){super(`upgrade source has no rules tags; refusing to drop all existing data: ${t}`),this.name="UpgradeSourceHasNoRules",this.sourceUrl=t}},I=class extends Error{constructor(t,r){super(t),this.name="UpgradeTransformInvalid",this.cause=r}},V=class extends Error{constructor(t){super(`found ${t} script[type="text/hyper-upgrade"] tags; only one is allowed per document.`),this.name="UpgradeMultipleTransforms",this.count=t}};var Ke="text/hyper-upgrade";function ge(e,t){let r=e.find(t,`script[type="${Ke}"]`);if(r.length===0)return null;if(r.length>1)throw new V(r.length);return e.text(r[0])||null}var Ye=new Function("url","return import(url)");async function Ee(e){let t=new Blob([e],{type:"text/javascript"}),r=URL.createObjectURL(t),o;try{o=await Ye(r)}catch(n){throw new I(`transform failed to load: ${n&&n.message?n.message:n}`,n)}finally{URL.revokeObjectURL(r)}if(typeof o.default!="function")throw new I("transform must `export default` a function");return o.default}function v(e,t){let r={carriedOver:0,discarded:0,listItems:0},o=oe(t,e,r);return se(t,e,r),{data:o,summary:r}}function oe(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||typeof t=="object"?void 0:(r.carriedOver++,t);if(Array.isArray(e)){let[,o]=e;return Array.isArray(t)?(r.listItems+=t.length,t.map(n=>oe(o,n,r))):void 0}if(typeof e=="object"&&e!==null){let o={};for(let[n,i]of Object.entries(e)){let c=oe(i,t?.[n],r);c!==void 0&&(o[n]=c)}return o}}function se(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)?se(e[n],t[n],r):r.discarded+=D(t[n]);return}if(Array.isArray(e)&&Array.isArray(t)){let o=e[1];t.forEach(n=>se(o,n,r));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(r.discarded+=D(t))}}function D(e){return e==null?0:Array.isArray(e)?e.reduce((t,r)=>t+D(r),0):typeof e=="object"?Object.values(e).reduce((t,r)=>t+D(r),0):1}function xe(e,t,r){let o=F(e,t),n={carriedOver:0,discarded:0,listItems:0},i={},c=new Set;for(let{name:s,rules:l}of o){if(c.add(s),!Object.prototype.hasOwnProperty.call(r,s)){i[s]={carriedOver:0,discarded:0,listItems:0};continue}let{data:u,summary:f}=v(r[s],l);S(e,t,l,u),i[s]=f,n.carriedOver+=f.carriedOver,n.discarded+=f.discarded,n.listItems+=f.listItems}for(let s of Object.keys(r))c.has(s)||(n.discarded+=D(r[s]));return{totals:n,byName:i,rulesTagCount:o.length}}async function Re({sourceUrl:e,dataByName:t,fromVersion:r,doc:o,loc:n,fetchFn:i}={}){if(o=o||(typeof document<"u"?document:null),n=n||(typeof location<"u"?location:null),i=i||(A=>fetch(A)),!o)throw new Error("upgrade.run requires a document context");if(e=e||x(o,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let c=new URL(e,n?n.href:void 0);r=r!==void 0?r:x(o,"hyper-version"),t=t||ne(m,o);let s;try{s=await i(c.href)}catch(A){throw new H(c.href,A)}if(!s.ok)throw new H(c.href,new Error(`HTTP ${s.status}`));let l=await s.text(),u=new DOMParser().parseFromString(l,"text/html"),f=x(u,"hyper-version"),d=t,a=!1,R=ge(m,u);if(R){let O=await(await Ee(R))(d,{fromVersion:r,toVersion:f});if(!O||typeof O!="object"||Array.isArray(O))throw new I("transform must return a plain object map of { rulesName: data }");d=O,a=!0}let{totals:y,byName:N,rulesTagCount:K}=xe(m,u,d);if(K===0&&Object.keys(d).length>0)throw new J(c.href);return{html:ze(u),fromVersion:r,toVersion:f,summary:{transformApplied:a,totals:y,byName:N}}}function ze(e){return`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
|
|
2
|
-
`+e.documentElement.outerHTML}var
|
|
1
|
+
var hyperHtmlApiUpgrade=(()=>{var X=Object.defineProperty;var Ne=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var Pe=Object.prototype.hasOwnProperty;var fe=(e,t)=>{for(var r in t)X(e,r,{get:t[r],enumerable:!0})},De=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of _e(t))!Pe.call(e,n)&&n!==r&&X(e,n,{get:()=>t[n],enumerable:!(o=Ne(t,n))||o.enumerable});return e};var Le=e=>De(X({},"__esModule",{value:!0}),e);var st={};fe(st,{default:()=>ot,engine:()=>ie,upgrade:()=>Ie});var q=["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"],Q=new Set(q),ae=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),pe=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var F={};fe(F,{EmptyListInsert:()=>j,MAX_RULE_DEPTH:()=>_,MaxRuleDepthExceeded:()=>w,RuleTargetReadOnly:()=>C,RulesParseError:()=>N,ShapeMismatch:()=>L,UnknownRulesVersion:()=>O});var N=class extends Error{constructor(t,r){super(t),this.name="RulesParseError",this.cause=r}},O=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},_=20,w=class extends Error{constructor(t){super(`rule depth exceeded ${_} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},L=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},j=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}},C=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}};function x(e){let t=0,r=null,o=-1;for(let n=0;n<e.length;n++){let s=e[n];s==="\\"?n++:r?s===r&&(r=null):s==='"'||s==="'"?r=s:s==="["||s==="("?t++:s==="]"||s===")"?t>0&&t--:s==="@"&&t===0&&(o=n)}return o}function Z(e){let t=x(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}function g(e,t,r,o={}){return ee(e,t,r,{depth:0,path:[]},o)}function ee(e,t,r,o,n){if(o.depth>_)throw new w(o.path);if(typeof r=="string")return je(e,t,r,n);if(Array.isArray(r)){let[s,l]=r;return e.find(t,s,n).map((c,f)=>ee(e,c,l,{depth:o.depth+1,path:[...o.path,f]},n))}if(typeof r=="object"&&r!==null){let s={};for(let[l,i]of Object.entries(r))s[l]=ee(e,t,i,{depth:o.depth+1,path:[...o.path,l]},n);return s}return null}function je(e,t,r,o){if(r.endsWith("[]")){let l=r.slice(0,-2);return e.find(t,l,o).map(i=>e.text(i))}if(r.startsWith("@"))return de(e,t,r.slice(1));let n=x(r);if(n!==-1){let l=r.slice(0,n),i=r.slice(n+1),c=l?e.find(t,l,o):[t];return c.length===0?null:de(e,c[0],i)}if(r===".")return e.text(t);let s=e.find(t,r,o);return s.length===0?null:e.text(s[0])}function de(e,t,r){if(Q.has(r)){let n=e.prop(t,r);return n==null?null:String(n)}let o=e.attr(t,r);return o||null}var Ce=.5;function te(e,t,r,o,n,s,l,i={}){let c=e.find(t,r,i);if(n.length===0){c.forEach(d=>e.remove(d));return}let f=n.length>c.length,u=c[0]||null;if(f&&!u&&(u=He(e,t,r,i),!u))throw new j(s.path);let p=c.map(d=>ke(e,d,o,i)),a=null;if(u){a=e.clone(u),i.templateAttr&&e.removeAttr(a,i.templateAttr);let d=e.stripIds(a);d>0&&console.warn(`[hyper-html-api] stripped ${d} id attribute(s) from cloned template at "${s.path.join(".")||"(root)"}"`)}let E=$e(n,p,o),m=c[0]||u,R=e.parent(m),W=c.length>0?me(e,R,m):0,I=We(e,c),A=new Set,Y=[],B=n.map((d,D)=>{let M=E[D];if(M>=0)return A.add(M),Y.push(!1),c[M];Y.push(!0);let z=e.clone(a);return e.stripIds(z),z});if(c.forEach((d,D)=>{A.has(D)||e.remove(d)}),I){B.forEach((d,D)=>{let M=W+D;e.children(R).findIndex(Me=>e.sameNode(Me,d))!==M&&e.insertAt(R,d,M)}),he(e,B,o,n,s,l,i);return}Be(e,B,Y,R,W),he(e,B,o,n,s,l,i)}function he(e,t,r,o,n,s,l){t.forEach((i,c)=>{if(r===null){let f=o[c],u=f==null?"":String(f);e.text(i)!==u&&e.text(i,u)}else{let f=s(e,i,r,o[c],{depth:n.depth+1,path:[...n.path,c]},l);f&&f!==i&&(t[c]=f)}})}function ke(e,t,r,o){return r===null?e.text(t):g(e,t,r,o)}function $e(e,t,r){let o=new Array(e.length).fill(-1),n=new Set;return e.forEach((s,l)=>{let i=-1,c=-1;t.forEach((f,u)=>{if(n.has(u))return;let p=Ue(s,f,r),a=p===c&&i>=0?Math.abs(u-l)<Math.abs(i-l):!1;(p>c||a)&&(c=p,i=u)}),c>=Ce&&(o[l]=i,n.add(i))}),o}function Ue(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 me(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 He(e,t,r,o){if(!o.templateAttr)return null;let n=t;for(;n;){let s=e.find(n,r,{includeRulesTag:!1,templateAttr:null});for(let l of s)if(e.attr(l,o.templateAttr)!=null)return l;n=e.parent(n)}return null}function We(e,t){if(t.length<=1)return!0;let r=e.parent(t[0]);if(!r)return!1;let o=e.children(r),n=[];for(let s of t){let l=o.findIndex(i=>e.sameNode(i,s));if(l===-1)return!1;n.push(l)}return n.sort((s,l)=>s-l),n[n.length-1]-n[0]===n.length-1}function Be(e,t,r,o,n){let s=null,l=n;for(let i=0;i<t.length;i++){if(!r[i]){s=t[i];continue}let c=s?e.parent(s):o;if(!c)continue;let f=s?me(e,c,s)+1:l++;e.insertAt(c,t[i],f),s=t[i]}}var ge=new Set(["checked","selected","disabled","readOnly","paused"]);function T(e,t,r,o,n={}){let s=[];if(re(r,o,[],s),s.length)throw new L(s);J(e,t,r,o,{depth:0,path:[]},n)}function J(e,t,r,o,n,s={}){if(n.depth>_)throw new w(n.path);if(o===void 0)return t;if(typeof r=="string")return qe(e,t,r,o,n,s);if(Array.isArray(r)){let[l,i]=r;return te(e,t,l,i,o,n,J,s),t}if(typeof r=="object"&&r!==null){for(let[l,i]of Object.entries(r)){let c=J(e,t,i,o==null?o:o[l],{depth:n.depth+1,path:[...n.path,l]},s);c&&c!==t&&(t=c)}return t}return t}function qe(e,t,r,o,n,s){if(r.endsWith("[]")){let c=r.slice(0,-2);return te(e,t,c,null,o,n,J,s),t}if(r.startsWith("@"))return ye(e,t,r.slice(1),o);let l=x(r);if(l!==-1){let c=r.slice(0,l),f=r.slice(l+1),u=c?e.find(t,c,s):[t];return u.length===0||ye(e,u[0],f,o),t}if(r===".")return e.text(t,o==null?"":String(o)),t;let i=e.find(t,r,s);return i.length===0||e.text(i[0],o==null?"":String(o)),t}function ye(e,t,r,o){if(pe.has(r))throw new C(r);if(r==="outerHTML"){let n=o==null?"":String(o);return e.replaceWith(t,n)}return ae.has(r)?(e.prop(t,r,Fe(r,o)),t):(e.attr(t,r,o==null?"":String(o)),t)}function Fe(e,t){return t==null?ge.has(e)?!1:"":ge.has(e)?!!t:t}function re(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:$([...r,s]),expected:"scalar",got:k(n)})}):o.push({path:$(r),expected:"array",got:k(t)});return}t!==null&&typeof t=="object"&&o.push({path:$(r),expected:"scalar",got:k(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:$(r),expected:"array",got:k(t)});return}let n=e[1];t.forEach((s,l)=>re(n,s,[...r,l],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:$(r),expected:"object",got:k(t)});return}for(let[n,s]of Object.entries(e))re(s,t[n],[...r,n],o)}}}function k(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function $(e){return e.join(".")}function ne(e){try{return JSON.parse(e)}catch(t){throw new N(`Invalid strict JSON: ${t.message}`,t)}}function S(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=[],l=0;for(;l<n.length;){let i=n[l];if(/\s/.test(i)){l++;continue}if("{}".includes(i)){s.push({type:i,value:i}),l++;continue}if(i==="["){let p=!1,a=l+1;for(;a<n.length&&/\s/.test(n[a]);)a++;if(a<n.length&&/[a-zA-Z_]/.test(n[a])&&(p=!0),!p){s.push({type:i,value:i}),l++;continue}}if(i==="]"){s.push({type:i,value:i}),l++;continue}if(i===":"){s.push({type:t.COLON,value:i}),l++;continue}if(i===","){s.push({type:t.COMMA,value:i}),l++;continue}if(i==='"'||i==="'"){let p=i,a=l+1;for(;a<n.length&&n[a]!==p;)n[a]==="\\"&&a++,a++;s.push({type:t.STRING,value:n.substring(l+1,a),quoted:!0,sourceQuote:p}),l=a+1;continue}let c=l,f;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"],a=!1;for(let E of p){let m=E.substring(1);if(n.substring(c+1,c+1+m.length)===m){a=!0,c+=m.length;break}}if(!a)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++;f=n.substring(l,c);let u=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(f)?u=t.NUMBER:f==="true"||f==="false"||f==="null"?u=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(f)&&(u=t.SELECTOR),s.push({type:u,value:f,quoted:!1}),l=c}return s}function o(n){let s="";for(let l=0;l<n.length;l++){let i=n[l];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[l+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,(f,u)=>u.length%2===0?u+'\\"':f)),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 N("Invalid extraction rules syntax: "+n.message,n)}}var oe="1",Ee=/^[a-zA-Z0-9_-]+$/;function U(e,t,r){let o;if(r===void 0)o="script[data-rules-name]";else{if(typeof r!="string"||!Ee.test(r))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(r)} (must match ${Ee})`);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],l=e.attr(s,"data-rules-version");if(l!==oe)throw new O(l);return{rules:S(e.text(s)),tagNode:s}}function se(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 U(e,o,r)}return null}function xe(e,t,r,o){let n=se(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:l}=n;return{rules:s,tagNode:l,get:()=>g(e,t,s,o),set:i=>T(e,t,s,i,o)}}function Ve(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function ve(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var Ke={find(e,t,r={}){let o=ve(e);if(!o||!o.querySelectorAll)return[];let n=Array.from(o.querySelectorAll(t));r.includeRulesTag||(n=n.filter(i=>!Ve(i)));let s=[];r.skip&&s.push(r.skip);let l=r.templateAttr===null?null:r.templateAttr||"cms-template";if(l&&s.push("["+l+"]"),s.length){let i=s.join(", ");n=n.filter(c=>!c.closest||!c.closest(i))}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}},h=Ke;var ie={extract:(e,t,r)=>g(h,e,t,r),apply:(e,t,r,o)=>T(h,e,t,r,o),findRulesIn:(e,t)=>U(h,e,t),findRules:(e,t)=>se(h,e,t),bind:(e,t,r)=>xe(h,e,t,r),parseStrict:ne,parseRelaxed:S,ruleAttrIndex:x,splitRule:Z,errors:F,DOM_PROPERTIES:q};var Ge="hha:upgrade-check:";function y(e,t){let r=e.querySelector(`meta[name="${t}"]`),o=r?r.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function Re(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function Ye(e,t){let r=Re(e),o=Re(t);if(!r||!o)return!1;let n=Math.max(r.length,o.length);for(let s=0;s<n;s++){let l=r[s]||0,i=o[s]||0;if(l!==i)return l>i}return!1}function ze(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function Xe(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function Ae({force:e=!1,doc:t,loc:r,fetchFn:o,now:n,ttlMs:s=864e5}={}){if(t=t||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),o=o||(a=>fetch(a)),n=n??Date.now(),!t)return null;let l=y(t,"hyper-source");if(!l)return null;let i=y(t,"hyper-version"),c;try{c=new URL(l,r?r.href:void 0)}catch{return null}if(r&&c.origin===r.origin&&c.pathname===r.pathname)return null;let f=`${Ge}${c.href}:${i||"none"}`,u,p=e?null:ze(f);if(p&&typeof p.checkedAt=="number"&&n-p.checkedAt<s)u=p.sourceVersion;else{try{let a=await o(c.href);if(!a.ok)throw new Error(`HTTP ${a.status}`);let E=await a.text(),m=new DOMParser().parseFromString(E,"text/html");u=y(m,"hyper-version")}catch{u=null}Xe(f,{checkedAt:n,sourceVersion:u})}return u?{available:Ye(u,i||"0.0.0"),currentVersion:i,sourceVersion:u,sourceUrl:c.href}:null}var Qe="script[data-rules-name]";function Ze(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function V(e,t){let r=e.find(t,Qe,{includeRulesTag:!0}),o=new Set,n=[];for(let s of r){let l=Ze(e.attr(s,"data-rules-name"));if(!l)continue;if(o.has(l)){console.warn(`hyper-html-api: duplicate rules tag name "${l}"; using the first.`);continue}let i=e.attr(s,"data-rules-version");if(i!==oe)throw new O(i);o.add(l),n.push({name:l,rules:S(e.text(s))})}return n}function le(e,t){let r={};for(let{name:o,rules:n}of V(e,t))r[o]=g(e,t,n);return r}function Oe(e){let t=e||document,r=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:le(h,t),version:y(r,"hyper-version")}}var H=class extends Error{constructor(t,r){super(`could not fetch upgrade source: ${t}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=t,this.cause=r}},v=class extends Error{constructor(t){super(`upgrade source has no rules tags; refusing to drop all existing data: ${t}`),this.name="UpgradeSourceHasNoRules",this.sourceUrl=t}},b=class extends Error{constructor(t,r){super(t),this.name="UpgradeTransformInvalid",this.cause=r}},K=class extends Error{constructor(t){super(`found ${t} script[type="text/hyper-upgrade"] tags; only one is allowed per document.`),this.name="UpgradeMultipleTransforms",this.count=t}};var et="text/hyper-upgrade";function we(e,t){let r=e.find(t,`script[type="${et}"]`);if(r.length===0)return null;if(r.length>1)throw new K(r.length);return e.text(r[0])||null}var tt=new Function("url","return import(url)");async function Te(e){let t=new Blob([e],{type:"text/javascript"}),r=URL.createObjectURL(t),o;try{o=await tt(r)}catch(n){throw new b(`transform failed to load: ${n&&n.message?n.message:n}`,n)}finally{URL.revokeObjectURL(r)}if(typeof o.default!="function")throw new b("transform must `export default` a function");return o.default}function G(e,t){let r={carriedOver:0,discarded:0,listItems:0},o=ce(t,e,r);return ue(t,e,r),{data:o,summary:r}}function ce(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||typeof t=="object"?void 0:(r.carriedOver++,t);if(Array.isArray(e)){let[,o]=e;return Array.isArray(t)?(r.listItems+=t.length,t.map(n=>ce(o,n,r))):void 0}if(typeof e=="object"&&e!==null){let o={};for(let[n,s]of Object.entries(e)){let l=ce(s,t?.[n],r);l!==void 0&&(o[n]=l)}return o}}function ue(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)?ue(e[n],t[n],r):r.discarded+=P(t[n]);return}if(Array.isArray(e)&&Array.isArray(t)){let o=e[1];t.forEach(n=>ue(o,n,r));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(r.discarded+=P(t))}}function P(e){return e==null?0:Array.isArray(e)?e.reduce((t,r)=>t+P(r),0):typeof e=="object"?Object.values(e).reduce((t,r)=>t+P(r),0):1}function Se(e,t,r){let o=V(e,t),n={carriedOver:0,discarded:0,listItems:0},s={},l=new Set;for(let{name:i,rules:c}of o){if(l.add(i),!Object.prototype.hasOwnProperty.call(r,i)){s[i]={carriedOver:0,discarded:0,listItems:0};continue}let{data:f,summary:u}=G(r[i],c);T(e,t,c,f),s[i]=u,n.carriedOver+=u.carriedOver,n.discarded+=u.discarded,n.listItems+=u.listItems}for(let i of Object.keys(r))l.has(i)||(n.discarded+=P(r[i]));return{totals:n,byName:s,rulesTagCount:o.length}}async function be({sourceUrl:e,dataByName:t,fromVersion:r,doc:o,loc:n,fetchFn:s}={}){if(o=o||(typeof document<"u"?document:null),n=n||(typeof location<"u"?location:null),s=s||(I=>fetch(I)),!o)throw new Error("upgrade.run requires a document context");if(e=e||y(o,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let l=new URL(e,n?n.href:void 0);r=r!==void 0?r:y(o,"hyper-version"),t=t||le(h,o);let i;try{i=await s(l.href)}catch(I){throw new H(l.href,I)}if(!i.ok)throw new H(l.href,new Error(`HTTP ${i.status}`));let c=await i.text(),f=new DOMParser().parseFromString(c,"text/html"),u=y(f,"hyper-version"),p=t,a=!1,E=we(h,f);if(E){let A=await(await Te(E))(p,{fromVersion:r,toVersion:u});if(!A||typeof A!="object"||Array.isArray(A))throw new b("transform must return a plain object map of { rulesName: data }");p=A,a=!0}let{totals:m,byName:R,rulesTagCount:W}=Se(h,f,p);if(W===0&&Object.keys(p).length>0)throw new v(l.href);return{html:rt(f),fromVersion:r,toVersion:u,summary:{transformApplied:a,totals:m,byName:R}}}function rt(e){return`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
|
|
2
|
+
`+e.documentElement.outerHTML}var Ie={checkForUpdate:Ae,run:be,extractAll:Oe,shapeMatch:G};var nt={engine:ie,upgrade:Ie},ot=nt;return Le(st);})();
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"apply",
|
|
10
10
|
"CMS"
|
|
11
11
|
],
|
|
12
|
-
"version": "0.
|
|
12
|
+
"version": "0.6.1",
|
|
13
13
|
"homepage": "https://github.com/panphora/hyper-html-api",
|
|
14
14
|
"bugs": {
|
|
15
15
|
"url": "https://github.com/panphora/hyper-html-api/issues"
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"LICENSE",
|
|
20
20
|
"README.md",
|
|
21
21
|
"src/**/*.js",
|
|
22
|
-
"dist/*.js"
|
|
22
|
+
"dist/*.js",
|
|
23
|
+
"conformance/**"
|
|
23
24
|
],
|
|
24
25
|
"main": "src/hyper-html-api.js",
|
|
25
26
|
"module": "src/hyper-html-api.js",
|
|
@@ -48,7 +49,9 @@
|
|
|
48
49
|
"test:webkit": "web-test-runner --playwright --browsers webkit",
|
|
49
50
|
"test:all": "web-test-runner --concurrency 1 --playwright --browsers chromium firefox webkit",
|
|
50
51
|
"test:node": "node --test 'test-node/**/*.test.js'",
|
|
51
|
-
"
|
|
52
|
+
"conformance:generate": "node scripts/conformance.mjs generate",
|
|
53
|
+
"conformance:check": "node scripts/conformance.mjs check",
|
|
54
|
+
"test:ci": "npm run test:node && npm run conformance:check && npm run test:all -- --fail-only && node test/lib/ensure-full-coverage.cjs",
|
|
52
55
|
"test:coverage": "npm run test:chrome && node test/lib/ensure-full-coverage.cjs",
|
|
53
56
|
"format": "prettier --write .",
|
|
54
57
|
"format:check": "prettier --check ."
|
|
@@ -58,14 +61,14 @@
|
|
|
58
61
|
"url": "git+https://github.com/panphora/hyper-html-api.git"
|
|
59
62
|
},
|
|
60
63
|
"dependencies": {
|
|
61
|
-
"hyper-morph": "^0.
|
|
64
|
+
"hyper-morph": "^0.4.0"
|
|
62
65
|
},
|
|
63
66
|
"devDependencies": {
|
|
64
67
|
"@web/test-runner": "^0.20.0",
|
|
65
68
|
"@web/test-runner-playwright": "^0.11.0",
|
|
66
69
|
"chai": "^4.3.6",
|
|
67
70
|
"chai-dom": "^1.11.0",
|
|
68
|
-
"cheerio": "
|
|
71
|
+
"cheerio": "1.2.0",
|
|
69
72
|
"esbuild": "^0.24.0",
|
|
70
73
|
"http-server": "^14.1.1",
|
|
71
74
|
"jsdom": "^29.0.2",
|
|
@@ -73,5 +76,10 @@
|
|
|
73
76
|
"mocha": "^11.0.1",
|
|
74
77
|
"prettier": "^3.4.2",
|
|
75
78
|
"sinon": "^9.2.4"
|
|
79
|
+
},
|
|
80
|
+
"hyper": {
|
|
81
|
+
"kind": "lib",
|
|
82
|
+
"status": "active",
|
|
83
|
+
"url": "https://github.com/panphora/hyper-html-api"
|
|
76
84
|
}
|
|
77
85
|
}
|
package/src/cms/form-builder.js
CHANGED
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
} from './path.js'
|
|
31
31
|
import { scaffold } from './scaffold.js'
|
|
32
32
|
import { widgetHandles } from './widget-handles.js'
|
|
33
|
+
import { splitRule } from '../engine/rule-syntax.js'
|
|
33
34
|
|
|
34
35
|
const BOOL_PROPS = new Set(['checked', 'selected', 'disabled', 'readOnly', 'paused'])
|
|
35
36
|
|
|
@@ -367,7 +368,7 @@ function invokeWidget(widget, ctx) {
|
|
|
367
368
|
function widgetFor(rule, appRoot) {
|
|
368
369
|
let propName = null
|
|
369
370
|
if (rule.startsWith('@')) propName = rule.slice(1)
|
|
370
|
-
else
|
|
371
|
+
else propName = splitRule(rule).prop
|
|
371
372
|
|
|
372
373
|
if (propName && BOOL_PROPS.has(propName)) return { type: 'checkbox' }
|
|
373
374
|
if (propName === 'innerHTML') return { type: 'textarea' }
|
|
@@ -399,7 +400,7 @@ function queryTarget(rule, appRoot) {
|
|
|
399
400
|
if (!appRoot) return null
|
|
400
401
|
if (rule === '.' || rule === '') return null
|
|
401
402
|
if (rule.startsWith('@')) return null
|
|
402
|
-
const selector = rule
|
|
403
|
+
const selector = splitRule(rule).selector
|
|
403
404
|
if (!selector) return null
|
|
404
405
|
try {
|
|
405
406
|
return appRoot.querySelector(selector)
|
package/src/dom-api.js
CHANGED
|
@@ -12,6 +12,11 @@ export const engine = {
|
|
|
12
12
|
bind: (root, source, opts) => engineMod.bind(domAdapter, root, source, opts),
|
|
13
13
|
parseStrict: engineMod.parseStrict,
|
|
14
14
|
parseRelaxed: engineMod.parseRelaxed,
|
|
15
|
+
// Adapter-free, like the parsers above: a consumer that has to split a rule
|
|
16
|
+
// the way the engine does needs this, and reimplementing it is exactly how
|
|
17
|
+
// four copies of the split drifted apart.
|
|
18
|
+
ruleAttrIndex: engineMod.ruleAttrIndex,
|
|
19
|
+
splitRule: engineMod.splitRule,
|
|
15
20
|
errors: engineMod.errors,
|
|
16
21
|
DOM_PROPERTIES: engineMod.DOM_PROPERTIES,
|
|
17
22
|
}
|
package/src/engine/apply.js
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
ShapeMismatch,
|
|
10
10
|
} from './errors.js'
|
|
11
11
|
import { listDiff } from './diff.js'
|
|
12
|
+
import { ruleAttrIndex } from './rule-syntax.js'
|
|
12
13
|
|
|
13
14
|
const BOOLEAN_PROPS = new Set(['checked', 'selected', 'disabled', 'readOnly', 'paused'])
|
|
14
15
|
|
|
@@ -64,8 +65,8 @@ function applyScalar(adapter, ctx, rule, value, trace, opts) {
|
|
|
64
65
|
return writePropOrAttr(adapter, ctx, rule.slice(1), value)
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
const at = ruleAttrIndex(rule)
|
|
69
|
+
if (at !== -1) {
|
|
69
70
|
const selector = rule.slice(0, at)
|
|
70
71
|
const name = rule.slice(at + 1)
|
|
71
72
|
const matches = selector ? adapter.find(ctx, selector, opts) : [ctx]
|