hyperclayjs 1.29.0 → 1.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -130,7 +130,7 @@ import 'hyperclayjs/presets/standard.js';
130
130
 
131
131
  | Module | Size | Description |
132
132
  |--------|------|-------------|
133
- | hyper-morph | 18.7KB | DOM morphing with content-based element matching |
133
+ | hyper-morph | 18.8KB | DOM morphing with content-based element matching |
134
134
  | hypercms | 72.4KB | Live edit-in-place CMS sidebar driven by a hyper-html-api rules tag. Pairs with [sortable] and [hyper-morph]. |
135
135
 
136
136
  ## Presets
@@ -140,12 +140,12 @@ Essential features for basic editing
140
140
 
141
141
  **Modules:** `save-core`, `snapshot`, `save-system`, `edit-mode-helpers`, `toast`, `save-toast`, `export-to-window`, `view-mode-excludes-edit-modules`
142
142
 
143
- ### Standard (~89.2KB)
143
+ ### Standard (~89.7KB)
144
144
  Standard feature set for most use cases
145
145
 
146
- **Modules:** `save-core`, `snapshot`, `save-system`, `unsaved-warning`, `edit-mode-helpers`, `persist`, `option-visibility`, `event-attrs`, `dom-helpers`, `toast`, `save-toast`, `export-to-window`, `view-mode-excludes-edit-modules`
146
+ **Modules:** `save-core`, `snapshot`, `save-system`, `unsaved-warning`, `edit-mode-helpers`, `persist`, `option-visibility`, `event-attrs`, `dom-helpers`, `data`, `toast`, `save-toast`, `export-to-window`, `view-mode-excludes-edit-modules`
147
147
 
148
- ### Everything (~323.4KB)
148
+ ### Everything (~324KB)
149
149
  All available features
150
150
 
151
151
  Includes all available modules across all categories.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperclayjs",
3
- "version": "1.29.0",
3
+ "version": "1.30.0",
4
4
  "description": "Modular JavaScript library for building interactive malleable HTML files with Hyperclay",
5
5
  "type": "module",
6
6
  "main": "src/hyperclay.js",
package/src/data.js ADDED
@@ -0,0 +1,10 @@
1
+ // Re-exports the vendored hyper-html-api data sugar as window.hyperclay
2
+ // .extractData / .applyData. The vendor file's wrapper attaches the public API
3
+ // to window.hyperclay during evaluation (see
4
+ // hyper-html-api/scripts/copy-to-hyperclayjs.js), so importing it is enough.
5
+ // No import-map entry needed — relative vendor import, same as undo.js. This is
6
+ // a core read/write primitive, so it is NOT edit-mode-only.
7
+
8
+ import { extractData, applyData, engine } from './vendor/hyper-html-api.vendor.js'
9
+
10
+ export { extractData, applyData, engine }
package/src/hyperclay.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * DO NOT EDIT THIS FILE DIRECTLY — it is generated from build/hyperclay.template.js
3
3
  *
4
- * HyperclayJS v1.29.0 - Minimal Browser-Native Loader
4
+ * HyperclayJS v1.30.0 - Minimal Browser-Native Loader
5
5
  *
6
6
  * Modules auto-init when imported (no separate init call needed).
7
7
  * Include `export-to-window` feature to export to window.hyperclay.
@@ -63,6 +63,7 @@ const MODULE_PATHS = {
63
63
  "hyper-morph": "./vendor/hyper-morph.vendor.js",
64
64
  "hypercms": "./vendor/hypercms.vendor.js",
65
65
  "undo": "./undo.js",
66
+ "data": "./data.js",
66
67
  "slugify": "./string-utilities/slugify.js",
67
68
  "copy-to-clipboard": "./string-utilities/copy-to-clipboard.js",
68
69
  "query-params": "./string-utilities/query.js",
@@ -101,6 +102,7 @@ const PRESETS = {
101
102
  "option-visibility",
102
103
  "event-attrs",
103
104
  "dom-helpers",
105
+ "data",
104
106
  "toast",
105
107
  "save-toast",
106
108
  "export-to-window",
@@ -143,6 +145,7 @@ const PRESETS = {
143
145
  "form-data",
144
146
  "hypercms",
145
147
  "undo",
148
+ "data",
146
149
  "slugify",
147
150
  "copy-to-clipboard",
148
151
  "query-params",
@@ -193,6 +196,7 @@ const PRESETS = {
193
196
  "hyper-morph",
194
197
  "hypercms",
195
198
  "undo",
199
+ "data",
196
200
  "slugify",
197
201
  "copy-to-clipboard",
198
202
  "query-params",
@@ -346,6 +350,8 @@ export const HyperMorph = window.hyperclayModules['hyper-morph']?.HyperMorph ??
346
350
  export const morph = window.hyperclayModules['hyper-morph']?.morph ?? window.hyperclayModules['hyper-morph']?.default;
347
351
  export const cms = window.hyperclayModules['hypercms']?.cms ?? window.hyperclayModules['hypercms']?.default;
348
352
  export const undo = window.hyperclayModules['undo']?.undo ?? window.hyperclayModules['undo']?.default;
353
+ export const extractData = window.hyperclayModules['data']?.extractData ?? window.hyperclayModules['data']?.default;
354
+ export const applyData = window.hyperclayModules['data']?.applyData ?? window.hyperclayModules['data']?.default;
349
355
  export const slugify = window.hyperclayModules['slugify']?.slugify ?? window.hyperclayModules['slugify']?.default;
350
356
  export const copyToClipboard = window.hyperclayModules['copy-to-clipboard']?.copyToClipboard ?? window.hyperclayModules['copy-to-clipboard']?.default;
351
357
  export const query = window.hyperclayModules['query-params']?.query ?? window.hyperclayModules['query-params']?.default;
@@ -0,0 +1,14 @@
1
+ var hyperHtmlApiData=(()=>{var k=Object.defineProperty;var ce=Object.getOwnPropertyDescriptor;var fe=Object.getOwnPropertyNames;var ue=Object.prototype.hasOwnProperty;var Y=(e,t)=>{for(var n in t)k(e,n,{get:t[n],enumerable:!0})},ae=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of fe(t))!ue.call(e,r)&&r!==n&&k(e,r,{get:()=>t[r],enumerable:!(o=ce(t,r))||o.enumerable});return e};var he=e=>ae(k({},"__esModule",{value:!0}),e);var Me={};Y(Me,{applyData:()=>z,default:()=>we,engine:()=>P,extractData:()=>X});var C=["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"],B=new Set(C),Q=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Z=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var j={};Y(j,{EmptyListInsert:()=>I,MAX_RULE_DEPTH:()=>A,MaxRuleDepthExceeded:()=>E,RuleTargetReadOnly:()=>w,RulesParseError:()=>S,ShapeMismatch:()=>b,UnknownRulesVersion:()=>N,UpgradeAlreadyRegistered:()=>U});var S=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},N=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},A=20,E=class extends Error{constructor(t){super(`rule depth exceeded ${A} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},b=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},I=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}},w=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},U=class extends Error{constructor(){super("upgrade transform already registered; only one registration is allowed per page."),this.name="UpgradeAlreadyRegistered"}};function g(e,t,n,o={}){return q(e,t,n,{depth:0,path:[]},o)}function q(e,t,n,o,r){if(o.depth>A)throw new E(o.path);if(typeof n=="string")return de(e,t,n,r);if(Array.isArray(n)){let[i,c]=n;return e.find(t,i,r).map((l,a)=>q(e,l,c,{depth:o.depth+1,path:[...o.path,a]},r))}if(typeof n=="object"&&n!==null){let i={};for(let[c,s]of Object.entries(n))i[c]=q(e,t,s,{depth:o.depth+1,path:[...o.path,c]},r);return i}return null}function de(e,t,n,o){if(n.endsWith("[]")){let i=n.slice(0,-2);return e.find(t,i,o).map(c=>e.text(c))}if(n.startsWith("@"))return ee(e,t,n.slice(1));if(n.includes("@")){let i=n.lastIndexOf("@"),c=n.slice(0,i),s=n.slice(i+1),l=c?e.find(t,c,o):[t];return l.length===0?null:ee(e,l[0],s)}if(n===".")return e.text(t);let r=e.find(t,n,o);return r.length===0?null:e.text(r[0])}function ee(e,t,n){if(B.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let o=e.attr(t,n);return o||null}var pe=.5;function v(e,t,n,o,r,i,c,s={}){let l=e.find(t,n,s);if(r.length===0){l.forEach(h=>e.remove(h));return}let a=r.length>l.length,u=l[0]||null;if(a&&!u&&(u=Re(e,t,n,s),!u))throw new I(i.path);let d=l.map(h=>me(e,h,o,s)),f=null;if(u){f=e.clone(u),s.templateAttr&&e.removeAttr(f,s.templateAttr);let h=e.stripIds(f);h>0&&console.warn(`[hyper-html-api] stripped ${h} id attribute(s) from cloned template at "${i.path.join(".")||"(root)"}"`)}let H=ye(r,d,o),R=l[0]||u,L=e.parent(R),se=l.length>0?Ee(e,L,R):0,K=new Set,W=r.map((h,m)=>{let p=H[m];if(p>=0)return K.add(p),l[p];let O=e.clone(f);return e.stripIds(O),O});l.forEach((h,m)=>{K.has(m)||e.remove(h)}),W.forEach((h,m)=>{let p=se+m;e.children(L).findIndex(le=>e.sameNode(le,h))!==p&&e.insertAt(L,h,p)}),W.forEach((h,m)=>{if(o===null){let p=r[m],O=p==null?"":String(p);e.text(h)!==O&&e.text(h,O)}else{let p=c(e,h,o,r[m],{depth:i.depth+1,path:[...i.path,m]},s);p&&p!==h&&(W[m]=p)}})}function me(e,t,n,o){return n===null?e.text(t):g(e,t,n,o)}function ye(e,t,n){let o=new Array(e.length).fill(-1),r=new Set;return e.forEach((i,c)=>{let s=-1,l=-1;t.forEach((a,u)=>{if(r.has(u))return;let d=ge(i,a,n),f=d===l&&s>=0?Math.abs(u-c)<Math.abs(s-c):!1;(d>l||f)&&(l=d,s=u)}),l>=pe&&(o[c]=s,r.add(s))}),o}function ge(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 Ee(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 Re(e,t,n,o){if(!o.templateAttr)return null;let r=t;for(;r;){let i=e.find(r,n,{includeRulesTag:!1});for(let c of i)if(e.attr(c,o.templateAttr)!=null)return c;r=e.parent(r)}return null}var te=new Set(["checked","selected","disabled","readOnly","paused"]);function T(e,t,n,o,r={}){let i=[];if(J(n,o,[],i),i.length)throw new b(i);$(e,t,n,o,{depth:0,path:[]},r)}function $(e,t,n,o,r,i={}){if(r.depth>A)throw new E(r.path);if(o===void 0)return t;if(typeof n=="string")return Oe(e,t,n,o,r,i);if(Array.isArray(n)){let[c,s]=n;return v(e,t,c,s,o,r,$,i),t}if(typeof n=="object"&&n!==null){for(let[c,s]of Object.entries(n)){let l=$(e,t,s,o==null?o:o[c],{depth:r.depth+1,path:[...r.path,c]},i);l&&l!==t&&(t=l)}return t}return t}function Oe(e,t,n,o,r,i){if(n.endsWith("[]")){let s=n.slice(0,-2);return v(e,t,s,null,o,r,$,i),t}if(n.startsWith("@"))return ne(e,t,n.slice(1),o);if(n.includes("@")){let s=n.lastIndexOf("@"),l=n.slice(0,s),a=n.slice(s+1),u=l?e.find(t,l,i):[t];return u.length===0||ne(e,u[0],a,o),t}if(n===".")return e.text(t,o==null?"":String(o)),t;let c=e.find(t,n,i);return c.length===0||e.text(c[0],o==null?"":String(o)),t}function ne(e,t,n,o){if(Z.has(n))throw new w(n);if(n==="outerHTML"){let r=o==null?"":String(o);return e.replaceWith(t,r)}return Q.has(n)?(e.prop(t,n,Se(n,o)),t):(e.attr(t,n,o==null?"":String(o)),t)}function Se(e,t){return t==null?te.has(e)?!1:"":te.has(e)?!!t:t}function J(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:_([...n,i]),expected:"scalar",got:M(r)})}):o.push({path:_(n),expected:"array",got:M(t)});return}t!==null&&typeof t=="object"&&o.push({path:_(n),expected:"scalar",got:M(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:_(n),expected:"array",got:M(t)});return}let r=e[1];t.forEach((i,c)=>J(r,i,[...n,c],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:_(n),expected:"object",got:M(t)});return}for(let[r,i]of Object.entries(e))J(i,t[r],[...n,r],o)}}}function M(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function _(e){return e.join(".")}function V(e){try{return JSON.parse(e)}catch(t){throw new S(`Invalid strict JSON: ${t.message}`,t)}}function D(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=[],c=0;for(;c<r.length;){let s=r[c];if(/\s/.test(s)){c++;continue}if("{}".includes(s)){i.push({type:s,value:s}),c++;continue}if(s==="["){let d=!1,f=c+1;for(;f<r.length&&/\s/.test(r[f]);)f++;if(f<r.length&&/[a-zA-Z_]/.test(r[f])&&(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,f=c+1;for(;f<r.length&&r[f]!==d;)r[f]==="\\"&&f++,f++;i.push({type:t.STRING,value:r.substring(c+1,f),quoted:!0,sourceQuote:d}),c=f+1;continue}let l=c,a;for(;l<r.length&&!/[{},]/.test(r[l]);)if(r[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"],f=!1;for(let H of d){let R=H.substring(1);if(r.substring(l+1,l+1+R.length)===R){f=!0,l+=R.length;break}}if(!f)break}else if(r[l]==="["){for(l++;l<r.length&&r[l]!=="]";){if(r[l]==='"'||r[l]==="'"){let d=r[l];for(l++;l<r.length&&r[l]!==d;)r[l]==="\\"&&l++,l++}l++}l<r.length&&r[l]==="]"&&l++}else l++;a=r.substring(c,l);let u=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(a)?u=t.NUMBER:a==="true"||a==="false"||a==="null"?u=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(a)&&(u=t.SELECTOR),i.push({type:u,value:a,quoted:!1}),c=l}return i}function o(r){let i="";for(let c=0;c<r.length;c++){let s=r[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=r[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,(a,u)=>u.length%2===0?u+'\\"':a)),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 r=n(e),i=o(r);return JSON.parse(i)}catch(r){throw new S("Invalid extraction rules syntax: "+r.message,r)}}var Ae="1",re=/^[a-zA-Z0-9_-]+$/;function x(e,t,n){let o;if(n===void 0)o="script[data-rules-name]";else{if(typeof n!="string"||!re.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${re})`);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],c=e.attr(i,"data-rules-version");if(c!==Ae)throw new N(c);return{rules:D(e.text(i)),tagNode:i}}function F(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 x(e,o,n)}return null}function oe(e,t,n,o){let r=F(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:c}=r;return{rules:i,tagNode:c,get:()=>g(e,t,i,o),set:s=>T(e,t,i,s,o)}}function xe(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Ne(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var be={find(e,t,n={}){let o=Ne(e);if(!o||!o.querySelectorAll)return[];let r=Array.from(o.querySelectorAll(t));n.includeRulesTag||(r=r.filter(c=>!xe(c)));let i=[];if(n.skip&&i.push(n.skip),n.templateAttr&&i.push("["+n.templateAttr+"]"),i.length){let c=i.join(", ");r=r.filter(s=>!s.closest||!s.closest(c))}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}},y=be;var P={extract:(e,t,n)=>g(y,e,t,n),apply:(e,t,n,o)=>T(y,e,t,n,o),findRulesIn:(e,t)=>x(y,e,t),findRules:(e,t)=>F(y,e,t),bind:(e,t,n)=>oe(y,e,t,n),parseStrict:V,parseRelaxed:D,errors:j,DOM_PROPERTIES:C},G=e=>!!e&&typeof e.nodeType=="number";function ie(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=y.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 x(y,t).rules}function X(e,t){let n=G(e)?e:document,o=G(e)?t:e;return o===void 0?g(y,n,ie(n)):P.bind(n,o).get()}function z(e,t,n){if(!G(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");return n===void 0?T(y,e,ie(e),t):P.bind(e,n).set(t),e}var Ie={engine:P,extractData:X,applyData:z},we=Ie;return he(Me);})();
2
+
3
+ // Auto-export to window unless suppressed by loader.
4
+ if (!window.__hyperclayNoAutoExport) {
5
+ window.hyperclay = window.hyperclay || {};
6
+ window.hyperclay.extractData = hyperHtmlApiData.extractData;
7
+ window.hyperclay.applyData = hyperHtmlApiData.applyData;
8
+ window.h = window.hyperclay;
9
+ }
10
+
11
+ export const engine = hyperHtmlApiData.engine;
12
+ export const extractData = hyperHtmlApiData.extractData;
13
+ export const applyData = hyperHtmlApiData.applyData;
14
+ export default hyperHtmlApiData;
@@ -1,4 +1,4 @@
1
- var HyperMorph=(()=>{var z=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var se=Object.prototype.hasOwnProperty;var ie=(s,c)=>{for(var a in c)z(s,a,{get:c[a],enumerable:!0})},ae=(s,c,a,d)=>{if(c&&typeof c=="object"||typeof c=="function")for(let h of re(c))!se.call(s,h)&&h!==a&&z(s,h,{get:()=>c[h],enumerable:!(d=ne(c,h))||d.enumerable});return s};var oe=s=>ae(z({},"__esModule",{value:!0}),s);var we={};ie(we,{HyperMorph:()=>W,default:()=>ke,defaults:()=>Se,morph:()=>ye});var J={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 ce(s){let c=5381;for(let a=0;a<s.length;a++)c=(c<<5)+c^s.charCodeAt(a);return Math.abs(c).toString(36)}function ue(s){if(s.classList&&s.classList.length>0)return Array.from(s.classList).sort().join(" ");let c=s.getAttribute?.("class");return c?c.split(/\s+/).filter(Boolean).sort().join(" "):""}function le(s,c){let a=[];for(let d of s.attributes||[]){let h=d.name;h==="id"||h==="class"||c.excludeAttributePrefixes.some(w=>h.startsWith(w))||c.includeAttributes.includes(h)&&a.push(`${h}=${d.value}`)}return a.sort().join("|")}function de(s,c){return(s.textContent||"").replace(/\s+/g," ").trim().slice(0,c.textHintLength)}function fe(s,c){let a=[s.tagName];return c.includeClasses&&a.push(ue(s)),a.push(le(s,c)),ce(a.join("|"))}function he(s){let c=s.tagName,a=1,d=s.previousElementSibling;for(;d;)d.tagName===c&&a++,d=d.previousElementSibling;return a}function pe(s,c){return s.id||s.getAttribute?.("role")?!0:c.landmarks.includes(s.tagName)}function me(s){if(s.id)return`#${s.id}`;let c=s.getAttribute?.("role");return c?`@${c}`:s.tagName}function ge(s,c){let a=[],d=s;for(;d&&d.tagName&&a.length<c.maxPathDepth;){let h=`${d.tagName}:${he(d)}`;if(a.unshift(h),d!==s&&pe(d,c)){a.unshift(me(d));break}d=d.parentElement}return a}function be(s,c){let a=0,d=s.length-1,h=c.length-1;for(;d>=0&&h>=0&&s[d]===c[h];)a++,d--,h--;return a}function q(s,c,a){if(a.has(s))return a.get(s);let d={signature:fe(s,c),path:ge(s,c),textHint:de(s,c)};return a.set(s,d),d}function ee(s,c,a,d){if(d.has(s))return d.get(s);let h=new Map,w=s.querySelectorAll("*"),E=0;for(let S of w){let H=q(S,c,a);H.domIndex=E++,h.has(H.signature)||h.set(H.signature,[]),h.get(H.signature).push(S)}return d.set(s,h),h}function Me(s,c,a){a.delete(s),c.delete(s);let d=s.querySelectorAll("*");for(let h of d)c.delete(h)}function U(s,c,a,d,h){let w=q(s,a,d),E=q(c,a,d),S=a.weights,H={},T=0;if(w.signature!==E.signature)return{score:0,breakdown:{rejected:"signature mismatch"}};T+=S.signature,H.signature=S.signature;let k=be(w.path,E.path)*S.pathSegment;T+=k,H.path=k;let v=!0;if(w.textHint&&E.textHint?w.textHint===E.textHint?(T+=S.textMatch,H.text=S.textMatch):(T-=S.textMismatch,H.text=-S.textMismatch,v=!1):w.textHint!==E.textHint&&(T-=S.textMismatch,H.text=-S.textMismatch,v=!1),h.candidateCount===1&&v&&(T+=S.uniqueCandidate,H.unique=S.uniqueCandidate),typeof w.domIndex=="number"&&typeof E.domIndex=="number"){let I=Math.abs(w.domIndex-E.domIndex),L=Math.min(I*S.positionPenalty,20);T-=L,H.drift=-L}return{score:T,breakdown:H}}function Q(s,c,a,d,h){if(a.excludeIds&&s.id)return null;let w=ee(c,a,d,h),E=q(s,a,d);if(typeof E.domIndex!="number"){let v=0,I=s.previousElementSibling;for(;I;)v++,I=I.previousElementSibling;E.domIndex=v}let S=w.get(E.signature)||[],H=a.excludeIds?S.filter(v=>!v.id):S;if(H.length===0)return null;let T=null,O=0,k=null;for(let v of H){let{score:I,breakdown:L}=U(s,v,a,d,{candidateCount:H.length});I>O&&(O=I,T=v,k=L)}return O<a.minConfidence?null:{element:T,confidence:O,breakdown:k}}function ve(s,c,a,d){let h=[],w=a.weights.signature+a.weights.slotMatch,E={slot:w};function S(k){if(k.children)return k.children;let v=k.childNodes;if(!v)return[];let I=[];for(let L=0;L<v.length;L++)v[L].nodeType===1&&I.push(v[L]);return I}function H(k,v){let I=S(k),L=S(v);if(I.length===L.length)for(let C=0;C<I.length;C++){let u=I[C],M=L[C];if(a.excludeIds&&(u.id||M.id)||u.tagName!==M.tagName)continue;let p=q(u,a,d).signature,A=q(M,a,d).signature;p!==A&&h.push({newEl:u,oldEl:M,score:w,breakdown:E}),H(u,M)}}function T(k,v){for(;;){if(k.tagName===v.tagName)return[k,v];let I=S(k);if(!k.tagName&&I.length===1){k=I[0];continue}let L=S(v);if(L.length===1&&L[0].tagName===k.tagName){v=L[0];continue}return null}}let O=T(s,c);return O&&H(O[0],O[1]),h}function X(s,c,a,d,h){let w=c.querySelectorAll("*"),E=ee(s,a,d,h),S=0;for(let k of w){let v=q(k,a,d);v.domIndex=S++}let H=[];for(let k of w){if(a.excludeIds&&k.id)continue;let v=q(k,a,d),I=E.get(v.signature)||[],L=a.excludeIds?I.filter(C=>!C.id):I;for(let C of L){let{score:u,breakdown:M}=U(k,C,a,d,{candidateCount:L.length});u>=a.minConfidence&&H.push({newEl:k,oldEl:C,score:u,breakdown:M})}}if(a.weights.slotMatch>0){let k=ve(c,s,a,d);for(let v of k)H.push(v)}H.sort((k,v)=>v.score-k.score);let T=new Map,O=new Set;for(let{newEl:k,oldEl:v}of H)T.has(k)||O.has(v)||(T.set(k,v),O.add(v));return T}function Z(s,c,a,d){let h=q(s,a,d),w=q(c,a,d),{score:E,breakdown:S}=U(s,c,a,d,{candidateCount:1});return{matches:E>=a.minConfidence,score:E,breakdown:S,newMeta:{signature:h.signature,path:h.path,textHint:h.textHint},oldMeta:{signature:w.signature,path:w.path,textHint:w.textHint}}}function te(s={}){let c={...J,...s,weights:{...J.weights,...s.weights}},a=new WeakMap,d=new WeakMap;return{findMatch:(h,w)=>Q(h,w,c,a,d),computeMatches:(h,w)=>X(h,w,c,a,d),explain:(h,w)=>Z(h,w,c,a),invalidate:h=>Me(h,a,d),session:()=>{let h=new WeakMap,w=new WeakMap;return{findMatch:(E,S)=>Q(E,S,c,h,w),computeMatches:(E,S)=>X(E,S,c,h,w),explain:(E,S)=>Z(E,S,c,h)}},getConfig:()=>({...c})}}var Ae=te(),W=(function(){"use strict";let s=()=>{};function c(u){if(!(u instanceof Element))return!1;if(u.hasAttribute("save-ignore"))return!0;if(u.tagName==="LINK"||u.tagName==="SCRIPT"){let M=u.getAttribute("src")||u.getAttribute("href")||"";if(M.startsWith("chrome-extension://")||M.startsWith("moz-extension://")||M.startsWith("safari-web-extension://"))return!0}return!1}function a(u,M){if(M!=="smart")return u.outerHTML;let p=u.getAttribute("src"),A=u.getAttribute("type")||"text/javascript";if(p)try{let b=new URL(p,window.location.href);return`ext:${A}:${b.origin}${b.pathname}${b.search}`}catch{return`ext:${A}:${p}`}else{let b=u.textContent.trim(),g=5381;for(let r=0;r<b.length;r++)g=(g<<5)+g^b.charCodeAt(r);return`inline:${A}:${Math.abs(g).toString(36)}`}}let d={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:s,afterNodeAdded:s,beforeNodeMorphed:s,afterNodeMorphed:s,beforeNodeRemoved:s,afterNodeRemoved:s,beforeAttributeUpdated:s},head:{style:"merge",shouldPreserve:u=>u.getAttribute("im-preserve")==="true",shouldReAppend:u=>u.getAttribute("im-re-append")==="true",shouldRemove:s,afterHeadMorphed:s},scripts:{handle:!1,matchMode:"outerHTML",shouldPreserve:u=>u.getAttribute("im-preserve")==="true",shouldReAppend:u=>u.getAttribute("im-re-append")==="true",shouldRemove:s,afterScriptsHandled:s},restoreFocus:!0},h={computeMatches(u,M){let{computeMatches:p}=Ae.session();return p(u,M)}};function w(u,M,p={}){u=L(u);let A=C(M),b=I(u,A,p),g=b.scripts.matchMode,r=new Set(Array.from(u.querySelectorAll("script")).map(n=>a(n,g))),l=S(b,()=>O(b,u,A,n=>n.morphStyle==="innerHTML"?(H(n,u,A),Array.from(u.childNodes)):E(n,u,A)));b.pantry.remove();let e=v(u,r,b);return e.length>0?l instanceof Promise?l.then(n=>Promise.all(e).then(()=>n)):Promise.all(e).then(()=>l):l}function E(u,M,p){let A=C(M);return H(u,A,p,M,M.nextSibling),Array.from(A.childNodes)}function S(u,M){if(!u.config.restoreFocus)return M();let p=document.activeElement;if(!(p instanceof HTMLInputElement||p instanceof HTMLTextAreaElement))return M();let{id:A,selectionStart:b,selectionEnd:g}=p,r=M();return A&&A!==document.activeElement?.getAttribute("id")&&(p=u.target.querySelector(`[id="${A}"]`),p?.focus()),p&&!p.selectionEnd&&g!=null&&p.setSelectionRange(b,g),r}let H=(function(){function u(e,n,i,t=null,o=null){n instanceof HTMLTemplateElement&&i instanceof HTMLTemplateElement&&(n=n.content,i=i.content),t||=n.firstChild;for(let f of i.childNodes){if(c(f))continue;if(t&&t!=o){let y=p(e,f,t,o);if(y){y!==t&&b(e,t,y),T(y,f,e),t=y.nextSibling;continue}}if(f instanceof Element){let y=f.getAttribute("id");if(e.persistentIds.has(y)){let N=g(n,y,t,e);T(N,f,e),t=N.nextSibling;continue}if(!e.idMap.has(f)){let N=e.hyperMatches.get(f);if(N&&!e.idMap.has(N)){l(n,N,t),T(N,f,e),t=N.nextSibling;continue}}}let m=M(n,f,t,e);m&&(t=m.nextSibling)}for(;t&&t!=o;){let f=t;t=t.nextSibling,c(f)||A(e,f)}}function M(e,n,i,t){if(t.callbacks.beforeNodeAdded(n)===!1)return null;if(t.idMap.has(n)){let o=document.createElement(n.tagName);return e.insertBefore(o,i),T(o,n,t),t.callbacks.afterNodeAdded(o),o}else{let o=document.importNode(n,!0);return e.insertBefore(o,i),t.callbacks.afterNodeAdded(o),o}}let p=(function(){function e(t,o,f,m){let y=o instanceof Element&&!t.idMap.has(o)?t.hyperMatches.get(o):null,N=null,$=o.nextSibling,D=0,x=f;for(;x&&x!=m;){if(i(x,o)){if(n(t,x,o)||x===y&&!t.idMap.has(x))return x;if(N===null){let V=x instanceof Element&&t.hyperMatchedOldElements.has(x);!t.idMap.has(x)&&!V&&(N=x)}}if(N===null&&$&&i(x,$)&&(D++,$=$.nextSibling,D>=2&&(N=void 0)),t.activeElementAndParents.includes(x))break;x=x.nextSibling}return N||null}function n(t,o,f){let m=t.idMap.get(o),y=t.idMap.get(f);if(!y||!m)return!1;for(let N of m)if(y.has(N))return!0;return!1}function i(t,o){let f=t,m=o;return f.nodeType===m.nodeType&&f.tagName===m.tagName&&(!f.getAttribute?.("id")||f.getAttribute?.("id")===m.getAttribute?.("id"))}return e})();function A(e,n){let i=n instanceof Element&&e.hyperMatchedOldElements.has(n)&&!e.idMap.has(n);if(e.idMap.has(n)||i)l(e.pantry,n,null);else{if(e.callbacks.beforeNodeRemoved(n)===!1)return;n.parentNode?.removeChild(n),e.callbacks.afterNodeRemoved(n)}}function b(e,n,i){let t=n;for(;t&&t!==i;){let o=t;t=t.nextSibling,c(o)||A(e,o)}return t}function g(e,n,i,t){let o=t.target.getAttribute?.("id")===n&&t.target||t.target.querySelector(`[id="${n}"]`)||t.pantry.querySelector(`[id="${n}"]`);return r(o,t),l(e,o,i),o}function r(e,n){let i=e.getAttribute("id");for(;e=e.parentNode;){let t=n.idMap.get(e);t&&(t.delete(i),t.size||n.idMap.delete(e))}}function l(e,n,i){if(e.moveBefore)try{e.moveBefore(n,i)}catch{e.insertBefore(n,i)}else e.insertBefore(n,i)}return u})(),T=(function(){function u(r,l,e){return e.ignoreActive&&r===document.activeElement?null:(e.callbacks.beforeNodeMorphed(r,l)===!1||(r instanceof HTMLHeadElement&&e.head.ignore||(r instanceof HTMLHeadElement&&e.head.style!=="morph"?k(r,l,e):(M(r,l,e),g(r,e)||H(e,r,l))),e.callbacks.afterNodeMorphed(r,l)),r)}function M(r,l,e){let n=l.nodeType;if(n===1){let i=r,t=l,o=i.attributes,f=t.attributes;for(let m of f)b(m.name,i,"update",e)||i.getAttribute(m.name)!==m.value&&i.setAttribute(m.name,m.value);for(let m=o.length-1;0<=m;m--){let y=o[m];if(y&&!t.hasAttribute(y.name)){if(b(y.name,i,"remove",e))continue;i.removeAttribute(y.name)}}g(i,e)||p(i,t,e)}(n===8||n===3)&&r.nodeValue!==l.nodeValue&&(r.nodeValue=l.nodeValue)}function p(r,l,e){if(r instanceof HTMLInputElement&&l instanceof HTMLInputElement&&l.type!=="file"){let n=l.value,i=r.value;A(r,l,"checked",e),A(r,l,"disabled",e),l.hasAttribute("value")?i!==n&&(b("value",r,"update",e)||(r.setAttribute("value",n),r.value=n)):b("value",r,"remove",e)||(r.value="",r.removeAttribute("value"))}else if(r instanceof HTMLOptionElement&&l instanceof HTMLOptionElement)A(r,l,"selected",e);else if(r instanceof HTMLTextAreaElement&&l instanceof HTMLTextAreaElement){let n=l.value,i=r.value;if(b("value",r,"update",e))return;n!==i&&(r.value=n),r.firstChild&&r.firstChild.nodeValue!==n&&(r.firstChild.nodeValue=n)}}function A(r,l,e,n){let i=l[e],t=r[e];if(i!==t){let o=b(e,r,"update",n);o||(r[e]=l[e]),i?o||r.setAttribute(e,""):b(e,r,"remove",n)||r.removeAttribute(e)}}function b(r,l,e,n){return r==="value"&&n.ignoreActiveValue&&l===document.activeElement?!0:n.callbacks.beforeAttributeUpdated(r,l,e)===!1}function g(r,l){return!!l.ignoreActiveValue&&r===document.activeElement&&r!==document.body}return u})();function O(u,M,p,A){if(u.head.block){let b=M.querySelector("head"),g=p.querySelector("head");if(b&&g){let r=k(b,g,u);return Promise.all(r).then(()=>{let l=Object.assign(u,{head:{block:!1,ignore:!0}});return A(l)})}}return A(u)}function k(u,M,p){let A=[],b=[],g=[],r=[],l=p.scripts.matchMode,e=t=>{if(t.tagName==="SCRIPT")return a(t,l);if(t.tagName==="LINK"&&l==="smart"){let o=t.getAttribute("href");if(o)try{let f=new URL(o,window.location.href);return`link:${t.getAttribute("rel")||""}:${f.origin}${f.pathname}${f.search}`}catch{}}return t.outerHTML},n=new Map;for(let t of M.children)c(t)||n.set(e(t),t);for(let t of u.children){let o=e(t),f=n.has(o),m=p.head.shouldReAppend(t),y=p.head.shouldPreserve(t);f||y?m?b.push(t):(n.delete(o),g.push(t)):p.head.style==="append"?m&&(b.push(t),r.push(t)):p.head.shouldRemove(t)!==!1&&!c(t)&&b.push(t)}r.push(...n.values());let i=[];for(let t of r){let o=document.createRange().createContextualFragment(t.outerHTML).firstChild;if(p.callbacks.beforeNodeAdded(o)!==!1){if("href"in o&&o.href||"src"in o&&o.src){let f,m=new Promise(function(y){f=y});o.addEventListener("load",function(){f()}),i.push(m)}u.appendChild(o),p.callbacks.afterNodeAdded(o),A.push(o)}}for(let t of b)p.callbacks.beforeNodeRemoved(t)!==!1&&(u.removeChild(t),p.callbacks.afterNodeRemoved(t));return p.head.afterHeadMorphed(u,{added:A,kept:g,removed:b}),i}function v(u,M,p){if(!p.scripts.handle)return[];let A=[],b=[],g=[],r=[],l=p.scripts.matchMode,e=Array.from(u.querySelectorAll("script"));for(let i of e){let t=a(i,l),o=M.has(t),f=p.scripts.shouldPreserve(i),m=p.scripts.shouldReAppend(i);o||f?m?(b.push(i),r.push(i)):g.push(i):r.push(i)}for(let i of M){let t=e.some(o=>o.outerHTML===i)}let n=[];for(let i of r){if(p.callbacks.beforeNodeAdded(i)===!1)continue;let t=document.createRange().createContextualFragment(i.outerHTML).firstChild;if(t.src){let o,f=new Promise(function(m){o=m});t.addEventListener("load",function(){o()}),t.addEventListener("error",function(){o()}),n.push(f)}i.replaceWith(t),p.callbacks.afterNodeAdded(t),A.push(t)}return p.scripts.afterScriptsHandled(u,{added:A,kept:g,removed:b}),n}let I=(function(){function u(e,n,i){let{persistentIds:t,idMap:o}=r(e,n),f=h.computeMatches(e,n);if(typeof i.key=="function"){let $=new Map,D=new Set,x=R=>{let B=i.key(R);B!=null&&($.has(B)?D.add(B):$.set(B,R))};e instanceof Element&&x(e);for(let R of e.querySelectorAll("*"))x(R);for(let R of D)$.delete(R);let V=new Map;for(let[R,B]of f)V.set(B,R);let P=n.__hyperMorphRoot||n,F=new Map,G=new Set,Y=R=>{let B=i.key(R);B!=null&&(F.has(B)?G.add(B):F.set(B,R))};P instanceof Element&&Y(P);for(let R of P.querySelectorAll("*"))Y(R);for(let R of G)F.delete(R);for(let[R,B]of F){let j=$.get(R);if(!j||j.tagName!==B.tagName)continue;let K=V.get(j);K&&K!==B&&f.delete(K);let _=f.get(B);_&&_!==j&&V.delete(_),f.set(B,j),V.set(j,B)}}let m=new Set;for(let $ of f.values())m.add($);let y=M(i),N=y.morphStyle||"outerHTML";if(!["innerHTML","outerHTML"].includes(N))throw`Do not understand how to morph style ${N}`;return{target:e,newContent:n,config:y,morphStyle:N,ignoreActive:y.ignoreActive,ignoreActiveValue:y.ignoreActiveValue,restoreFocus:y.restoreFocus,idMap:o,persistentIds:t,hyperMatches:f,hyperMatchedOldElements:m,pantry:p(),activeElementAndParents:A(e),callbacks:y.callbacks,head:y.head,scripts:y.scripts}}function M(e){let n=Object.assign({},d);return Object.assign(n,e),n.callbacks=Object.assign({},d.callbacks,e.callbacks),n.head=Object.assign({},d.head,e.head),n.scripts=Object.assign({},d.scripts,e.scripts),n}function p(){let e=document.createElement("div");return e.hidden=!0,document.body.insertAdjacentElement("afterend",e),e}function A(e){let n=[],i=document.activeElement;if(i?.tagName!=="BODY"&&e.contains(i))for(;i&&(n.push(i),i!==e);)i=i.parentElement;return n}function b(e){let n=Array.from(e.querySelectorAll("[id]"));return e.getAttribute?.("id")&&n.push(e),n}function g(e,n,i,t){for(let o of t){let f=o.getAttribute("id");if(n.has(f)){let m=o;for(;m;){let y=e.get(m);if(y==null&&(y=new Set,e.set(m,y)),y.add(f),m===i)break;m=m.parentElement}}}}function r(e,n){let i=b(e),t=b(n),o=l(i,t),f=new Map;g(f,o,e,i);let m=n.__hyperMorphRoot||n;return g(f,o,m,t),{persistentIds:o,idMap:f}}function l(e,n){let i=new Set,t=new Map;for(let{id:f,tagName:m}of e)t.has(f)?i.add(f):t.set(f,m);let o=new Set;for(let{id:f,tagName:m}of n)o.has(f)?i.add(f):t.get(f)===m&&o.add(f);for(let f of i)o.delete(f);return o}return u})(),{normalizeElement:L,normalizeParent:C}=(function(){let u=new WeakSet;function M(g){return g instanceof Document?g.documentElement:g}function p(g){if(g==null)return document.createElement("div");if(typeof g=="string")return p(b(g));if(u.has(g))return g;if(g instanceof Node){if(g.parentNode)return new A(g);{let r=document.createElement("div");return r.append(g),r}}else{let r=document.createElement("div");for(let l of[...g])r.append(l);return r}}class A{constructor(r){this.originalNode=r,this.realParentNode=r.parentNode,this.previousSibling=r.previousSibling,this.nextSibling=r.nextSibling}get childNodes(){let r=[],l=this.previousSibling?this.previousSibling.nextSibling:this.realParentNode.firstChild;for(;l&&l!=this.nextSibling;)r.push(l),l=l.nextSibling;return r}querySelectorAll(r){return this.childNodes.reduce((l,e)=>{if(e instanceof Element){e.matches(r)&&l.push(e);let n=e.querySelectorAll(r);for(let i=0;i<n.length;i++)l.push(n[i])}return l},[])}insertBefore(r,l){return this.realParentNode.insertBefore(r,l)}moveBefore(r,l){return this.realParentNode.moveBefore(r,l)}get __hyperMorphRoot(){return this.originalNode}}function b(g){let r=new DOMParser,l=g.replace(/<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim,"");if(l.match(/<\/html>/)||l.match(/<\/head>/)||l.match(/<\/body>/)){let e=r.parseFromString(g,"text/html");if(l.match(/<\/html>/))return u.add(e),e;{let n=e.firstChild;return n&&u.add(n),n}}else{let n=r.parseFromString("<body><template>"+g+"</template></body>","text/html").body.querySelector("template").content;return u.add(n),n}}return{normalizeElement:M,normalizeParent:p}})();return{morph:w,defaults:d}})();var ye=W.morph,Se=W.defaults,ke=W;return oe(we);})();
1
+ var HyperMorph=(()=>{var z=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var se=Object.prototype.hasOwnProperty;var ie=(s,u)=>{for(var a in u)z(s,a,{get:u[a],enumerable:!0})},ae=(s,u,a,f)=>{if(u&&typeof u=="object"||typeof u=="function")for(let h of re(u))!se.call(s,h)&&h!==a&&z(s,h,{get:()=>u[h],enumerable:!(f=ne(u,h))||f.enumerable});return s};var oe=s=>ae(z({},"__esModule",{value:!0}),s);var we={};ie(we,{HyperMorph:()=>W,default:()=>ke,defaults:()=>Se,morph:()=>Ae});var J={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 ue(s){let u=5381;for(let a=0;a<s.length;a++)u=(u<<5)+u^s.charCodeAt(a);return Math.abs(u).toString(36)}function ce(s){if(s.classList&&s.classList.length>0)return Array.from(s.classList).sort().join(" ");let u=s.getAttribute?.("class");return u?u.split(/\s+/).filter(Boolean).sort().join(" "):""}function le(s,u){let a=[];for(let f of s.attributes||[]){let h=f.name;h==="id"||h==="class"||u.excludeAttributePrefixes.some(w=>h.startsWith(w))||u.includeAttributes.includes(h)&&a.push(`${h}=${f.value}`)}return a.sort().join("|")}function fe(s,u){return(s.textContent||"").replace(/\s+/g," ").trim().slice(0,u.textHintLength)}function de(s,u){let a=[s.tagName];return u.includeClasses&&a.push(ce(s)),a.push(le(s,u)),ue(a.join("|"))}function he(s){let u=s.tagName,a=1,f=s.previousElementSibling;for(;f;)f.tagName===u&&a++,f=f.previousElementSibling;return a}function pe(s,u){return s.id||s.getAttribute?.("role")?!0:u.landmarks.includes(s.tagName)}function me(s){if(s.id)return`#${s.id}`;let u=s.getAttribute?.("role");return u?`@${u}`:s.tagName}function ge(s,u){let a=[],f=s;for(;f&&f.tagName&&a.length<u.maxPathDepth;){let h=`${f.tagName}:${he(f)}`;if(a.unshift(h),f!==s&&pe(f,u)){a.unshift(me(f));break}f=f.parentElement}return a}function be(s,u){let a=0,f=s.length-1,h=u.length-1;for(;f>=0&&h>=0&&s[f]===u[h];)a++,f--,h--;return a}function q(s,u,a){if(a.has(s))return a.get(s);let f={signature:de(s,u),path:ge(s,u),textHint:fe(s,u)};return a.set(s,f),f}function ee(s,u,a,f){if(f.has(s))return f.get(s);let h=new Map,w=s.querySelectorAll("*"),E=0;for(let S of w){let H=q(S,u,a);H.domIndex=E++,h.has(H.signature)||h.set(H.signature,[]),h.get(H.signature).push(S)}return f.set(s,h),h}function Me(s,u,a){a.delete(s),u.delete(s);let f=s.querySelectorAll("*");for(let h of f)u.delete(h)}function U(s,u,a,f,h){let w=q(s,a,f),E=q(u,a,f),S=a.weights,H={},T=0;if(w.signature!==E.signature)return{score:0,breakdown:{rejected:"signature mismatch"}};T+=S.signature,H.signature=S.signature;let k=be(w.path,E.path)*S.pathSegment;T+=k,H.path=k;let v=!0;if(w.textHint&&E.textHint?w.textHint===E.textHint?(T+=S.textMatch,H.text=S.textMatch):(T-=S.textMismatch,H.text=-S.textMismatch,v=!1):w.textHint!==E.textHint&&(T-=S.textMismatch,H.text=-S.textMismatch,v=!1),h.candidateCount===1&&v&&(T+=S.uniqueCandidate,H.unique=S.uniqueCandidate),typeof w.domIndex=="number"&&typeof E.domIndex=="number"){let I=Math.abs(w.domIndex-E.domIndex),L=Math.min(I*S.positionPenalty,20);T-=L,H.drift=-L}return{score:T,breakdown:H}}function Q(s,u,a,f,h){if(a.excludeIds&&s.id)return null;let w=ee(u,a,f,h),E=q(s,a,f);if(typeof E.domIndex!="number"){let v=0,I=s.previousElementSibling;for(;I;)v++,I=I.previousElementSibling;E.domIndex=v}let S=w.get(E.signature)||[],H=a.excludeIds?S.filter(v=>!v.id):S;if(H.length===0)return null;let T=null,O=0,k=null;for(let v of H){let{score:I,breakdown:L}=U(s,v,a,f,{candidateCount:H.length});I>O&&(O=I,T=v,k=L)}return O<a.minConfidence?null:{element:T,confidence:O,breakdown:k}}function ve(s,u,a,f){let h=[],w=a.weights.signature+a.weights.slotMatch,E={slot:w};function S(k){if(k.children)return k.children;let v=k.childNodes;if(!v)return[];let I=[];for(let L=0;L<v.length;L++)v[L].nodeType===1&&I.push(v[L]);return I}function H(k,v){let I=S(k),L=S(v);if(I.length===L.length)for(let C=0;C<I.length;C++){let c=I[C],M=L[C];if(a.excludeIds&&(c.id||M.id)||c.tagName!==M.tagName)continue;let p=q(c,a,f).signature,y=q(M,a,f).signature;p!==y&&h.push({newEl:c,oldEl:M,score:w,breakdown:E}),H(c,M)}}function T(k,v){for(;;){if(k.tagName===v.tagName)return[k,v];let I=S(k);if(!k.tagName&&I.length===1){k=I[0];continue}let L=S(v);if(L.length===1&&L[0].tagName===k.tagName){v=L[0];continue}return null}}let O=T(s,u);return O&&H(O[0],O[1]),h}function X(s,u,a,f,h){let w=u.querySelectorAll("*"),E=ee(s,a,f,h),S=0;for(let k of w){let v=q(k,a,f);v.domIndex=S++}let H=[];for(let k of w){if(a.excludeIds&&k.id)continue;let v=q(k,a,f),I=E.get(v.signature)||[],L=a.excludeIds?I.filter(C=>!C.id):I;for(let C of L){let{score:c,breakdown:M}=U(k,C,a,f,{candidateCount:L.length});c>=a.minConfidence&&H.push({newEl:k,oldEl:C,score:c,breakdown:M})}}if(a.weights.slotMatch>0){let k=ve(u,s,a,f);for(let v of k)H.push(v)}H.sort((k,v)=>v.score-k.score);let T=new Map,O=new Set;for(let{newEl:k,oldEl:v}of H)T.has(k)||O.has(v)||(T.set(k,v),O.add(v));return T}function Z(s,u,a,f){let h=q(s,a,f),w=q(u,a,f),{score:E,breakdown:S}=U(s,u,a,f,{candidateCount:1});return{matches:E>=a.minConfidence,score:E,breakdown:S,newMeta:{signature:h.signature,path:h.path,textHint:h.textHint},oldMeta:{signature:w.signature,path:w.path,textHint:w.textHint}}}function te(s={}){let u={...J,...s,weights:{...J.weights,...s.weights}},a=new WeakMap,f=new WeakMap;return{findMatch:(h,w)=>Q(h,w,u,a,f),computeMatches:(h,w)=>X(h,w,u,a,f),explain:(h,w)=>Z(h,w,u,a),invalidate:h=>Me(h,a,f),session:()=>{let h=new WeakMap,w=new WeakMap;return{findMatch:(E,S)=>Q(E,S,u,h,w),computeMatches:(E,S)=>X(E,S,u,h,w),explain:(E,S)=>Z(E,S,u,h)}},getConfig:()=>({...u})}}var ye=te(),W=(function(){"use strict";let s=()=>{};function u(c){if(!(c instanceof Element))return!1;if(c.hasAttribute("save-ignore"))return!0;if(c.tagName==="LINK"||c.tagName==="SCRIPT"){let M=c.getAttribute("src")||c.getAttribute("href")||"";if(M.startsWith("chrome-extension://")||M.startsWith("moz-extension://")||M.startsWith("safari-web-extension://"))return!0}return!1}function a(c,M){if(M!=="smart")return c.outerHTML;let p=c.getAttribute("src"),y=c.getAttribute("type")||"text/javascript";if(p)try{let b=new URL(p,window.location.href);return`ext:${y}:${b.origin}${b.pathname}${b.search}`}catch{return`ext:${y}:${p}`}else{let b=c.textContent.trim(),g=5381;for(let r=0;r<b.length;r++)g=(g<<5)+g^b.charCodeAt(r);return`inline:${y}:${Math.abs(g).toString(36)}`}}let f={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:s,afterNodeAdded:s,beforeNodeMorphed:s,afterNodeMorphed:s,beforeNodeRemoved:s,afterNodeRemoved:s,beforeAttributeUpdated:s},head:{style:"merge",shouldPreserve:c=>c.getAttribute("im-preserve")==="true",shouldReAppend:c=>c.getAttribute("im-re-append")==="true",shouldRemove:s,afterHeadMorphed:s},scripts:{handle:!1,matchMode:"outerHTML",shouldPreserve:c=>c.getAttribute("im-preserve")==="true",shouldReAppend:c=>c.getAttribute("im-re-append")==="true",shouldRemove:s,afterScriptsHandled:s},restoreFocus:!0},h={computeMatches(c,M){let{computeMatches:p}=ye.session();return p(c,M)}};function w(c,M,p={}){c=L(c);let y=C(M),b=I(c,y,p),g=b.scripts.matchMode,r=new Set(Array.from(c.querySelectorAll("script")).map(t=>a(t,g))),l=S(b,()=>O(b,c,y,t=>t.morphStyle==="innerHTML"?(H(t,c,y),Array.from(c.childNodes)):E(t,c,y)));b.pantry.remove();let e=v(c,r,b);return e.length>0?l instanceof Promise?l.then(t=>Promise.all(e).then(()=>t)):Promise.all(e).then(()=>l):l}function E(c,M,p){let y=C(M);return H(c,y,p,M,M.nextSibling),Array.from(y.childNodes)}function S(c,M){if(!c.config.restoreFocus)return M();let p=document.activeElement;if(!(p instanceof HTMLInputElement||p instanceof HTMLTextAreaElement))return M();let{id:y,selectionStart:b,selectionEnd:g}=p,r=M();return y&&y!==document.activeElement?.getAttribute("id")&&(p=c.target.querySelector(`[id="${y}"]`),p?.focus()),p&&!p.selectionEnd&&g!=null&&p.setSelectionRange(b,g),r}let H=(function(){function c(e,t,i,n=null,o=null){t instanceof HTMLTemplateElement&&i instanceof HTMLTemplateElement&&(t=t.content,i=i.content),n||=t.firstChild;for(let d of i.childNodes){if(u(d))continue;if(n&&n!=o){let A=p(e,d,n,o);if(A){A!==n&&b(e,n,A),T(A,d,e),n=A.nextSibling;continue}}if(d instanceof Element){let A=d.getAttribute("id");if(e.persistentIds.has(A)){let N=g(t,A,n,e);T(N,d,e),n=N.nextSibling;continue}if(!e.idMap.has(d)){let N=e.hyperMatches.get(d);if(N&&!e.idMap.has(N)){l(t,N,n),T(N,d,e),n=N.nextSibling;continue}}}let m=M(t,d,n,e);m&&(n=m.nextSibling)}for(;n&&n!=o;){let d=n;n=n.nextSibling,u(d)||y(e,d)}}function M(e,t,i,n){if(n.callbacks.beforeNodeAdded(t)===!1)return null;if(n.idMap.has(t)){let o=document.createElement(t.tagName);return e.insertBefore(o,i),T(o,t,n),n.callbacks.afterNodeAdded(o),o}else{let o=document.importNode(t,!0);return e.insertBefore(o,i),n.callbacks.afterNodeAdded(o),o}}let p=(function(){function e(n,o,d,m){let A=o instanceof Element&&!n.idMap.has(o)?n.hyperMatches.get(o):null,N=null,$=o.nextSibling,D=0,R=d;for(;R&&R!=m;){if(i(R,o)){if(t(n,R,o)||R===A&&!n.idMap.has(R))return R;if(N===null){let V=R instanceof Element&&n.hyperMatchedOldElements.has(R);!n.idMap.has(R)&&!V&&(N=R)}}if(N===null&&$&&i(R,$)&&(D++,$=$.nextSibling,D>=2&&(N=void 0)),n.activeElementAndParents.includes(R))break;R=R.nextSibling}return N||null}function t(n,o,d){let m=n.idMap.get(o),A=n.idMap.get(d);if(!A||!m)return!1;for(let N of m)if(A.has(N))return!0;return!1}function i(n,o){let d=n,m=o;return d.nodeType===m.nodeType&&d.tagName===m.tagName&&(!d.getAttribute?.("id")||d.getAttribute?.("id")===m.getAttribute?.("id"))}return e})();function y(e,t){let i=t instanceof Element&&e.hyperMatchedOldElements.has(t)&&!e.idMap.has(t);if(e.idMap.has(t)||i)l(e.pantry,t,null);else{if(e.callbacks.beforeNodeRemoved(t)===!1)return;t.parentNode?.removeChild(t),e.callbacks.afterNodeRemoved(t)}}function b(e,t,i){let n=t;for(;n&&n!==i;){let o=n;n=n.nextSibling,u(o)||y(e,o)}return n}function g(e,t,i,n){let o=n.target.getAttribute?.("id")===t&&n.target||n.target.querySelector(`[id="${t}"]`)||n.pantry.querySelector(`[id="${t}"]`);return r(o,n),l(e,o,i),o}function r(e,t){let i=e.getAttribute("id");for(;e=e.parentNode;){let n=t.idMap.get(e);n&&(n.delete(i),n.size||t.idMap.delete(e))}}function l(e,t,i){if(e.moveBefore)try{e.moveBefore(t,i)}catch{e.insertBefore(t,i)}else e.insertBefore(t,i)}return c})(),T=(function(){function c(r,l,e){return e.ignoreActive&&r===document.activeElement?null:(e.callbacks.beforeNodeMorphed(r,l)===!1||(r instanceof HTMLHeadElement&&e.head.ignore||(r instanceof HTMLHeadElement&&e.head.style!=="morph"?k(r,l,e):(M(r,l,e),g(r,e)||H(e,r,l))),e.callbacks.afterNodeMorphed(r,l)),r)}function M(r,l,e){let t=l.nodeType;if(t===1){let i=r,n=l,o=i.attributes,d=n.attributes;for(let m of d)b(m.name,i,"update",e)||i.getAttribute(m.name)!==m.value&&i.setAttribute(m.name,m.value);for(let m=o.length-1;0<=m;m--){let A=o[m];if(A&&!n.hasAttribute(A.name)){if(b(A.name,i,"remove",e))continue;i.removeAttribute(A.name)}}g(i,e)||p(i,n,e)}(t===8||t===3)&&r.nodeValue!==l.nodeValue&&(r.nodeValue=l.nodeValue)}function p(r,l,e){if(r instanceof HTMLInputElement&&l instanceof HTMLInputElement&&l.type!=="file"){let t=l.value,i=r.value;y(r,l,"checked",e),y(r,l,"disabled",e),e.formStateSync==="property"?i!==t&&(b("value",r,"update",e)||(r.value=t)):l.hasAttribute("value")?i!==t&&(b("value",r,"update",e)||(r.setAttribute("value",t),r.value=t)):b("value",r,"remove",e)||(r.value="",r.removeAttribute("value"))}else if(r instanceof HTMLOptionElement&&l instanceof HTMLOptionElement)y(r,l,"selected",e);else if(r instanceof HTMLTextAreaElement&&l instanceof HTMLTextAreaElement){let t=l.value,i=r.value;if(b("value",r,"update",e))return;t!==i&&(r.value=t),r.firstChild&&r.firstChild.nodeValue!==t&&(r.firstChild.nodeValue=t)}}function y(r,l,e,t){let i=l[e],n=r[e];if(i!==n){let o=b(e,r,"update",t);if(o||(r[e]=l[e]),t.formStateSync==="property")return;i?o||r.setAttribute(e,""):b(e,r,"remove",t)||r.removeAttribute(e)}}function b(r,l,e,t){return r==="value"&&t.ignoreActiveValue&&l===document.activeElement?!0:t.callbacks.beforeAttributeUpdated(r,l,e)===!1}function g(r,l){return!!l.ignoreActiveValue&&r===document.activeElement&&r!==document.body}return c})();function O(c,M,p,y){if(c.head.block){let b=M.querySelector("head"),g=p.querySelector("head");if(b&&g){let r=k(b,g,c);return Promise.all(r).then(()=>{let l=Object.assign(c,{head:{block:!1,ignore:!0}});return y(l)})}}return y(c)}function k(c,M,p){let y=[],b=[],g=[],r=[],l=p.scripts.matchMode,e=n=>{if(n.tagName==="SCRIPT")return a(n,l);if(n.tagName==="LINK"&&l==="smart"){let o=n.getAttribute("href");if(o)try{let d=new URL(o,window.location.href);return`link:${n.getAttribute("rel")||""}:${d.origin}${d.pathname}${d.search}`}catch{}}return n.outerHTML},t=new Map;for(let n of M.children)u(n)||t.set(e(n),n);for(let n of c.children){let o=e(n),d=t.has(o),m=p.head.shouldReAppend(n),A=p.head.shouldPreserve(n);d||A?m?b.push(n):(t.delete(o),g.push(n)):p.head.style==="append"?m&&(b.push(n),r.push(n)):p.head.shouldRemove(n)!==!1&&!u(n)&&b.push(n)}r.push(...t.values());let i=[];for(let n of r){let o=document.createRange().createContextualFragment(n.outerHTML).firstChild;if(p.callbacks.beforeNodeAdded(o)!==!1){if("href"in o&&o.href||"src"in o&&o.src){let d,m=new Promise(function(A){d=A});o.addEventListener("load",function(){d()}),i.push(m)}c.appendChild(o),p.callbacks.afterNodeAdded(o),y.push(o)}}for(let n of b)p.callbacks.beforeNodeRemoved(n)!==!1&&(c.removeChild(n),p.callbacks.afterNodeRemoved(n));return p.head.afterHeadMorphed(c,{added:y,kept:g,removed:b}),i}function v(c,M,p){if(!p.scripts.handle)return[];let y=[],b=[],g=[],r=[],l=p.scripts.matchMode,e=Array.from(c.querySelectorAll("script"));for(let i of e){let n=a(i,l),o=M.has(n),d=p.scripts.shouldPreserve(i),m=p.scripts.shouldReAppend(i);o||d?m?(b.push(i),r.push(i)):g.push(i):r.push(i)}for(let i of M){let n=e.some(o=>o.outerHTML===i)}let t=[];for(let i of r){if(p.callbacks.beforeNodeAdded(i)===!1)continue;let n=document.createRange().createContextualFragment(i.outerHTML).firstChild;if(n.src){let o,d=new Promise(function(m){o=m});n.addEventListener("load",function(){o()}),n.addEventListener("error",function(){o()}),t.push(d)}i.replaceWith(n),p.callbacks.afterNodeAdded(n),y.push(n)}return p.scripts.afterScriptsHandled(c,{added:y,kept:g,removed:b}),t}let I=(function(){function c(e,t,i){let{persistentIds:n,idMap:o}=r(e,t),d=h.computeMatches(e,t);if(typeof i.key=="function"){let $=new Map,D=new Set,R=x=>{let B=i.key(x);B!=null&&($.has(B)?D.add(B):$.set(B,x))};e instanceof Element&&R(e);for(let x of e.querySelectorAll("*"))R(x);for(let x of D)$.delete(x);let V=new Map;for(let[x,B]of d)V.set(B,x);let P=t.__hyperMorphRoot||t,F=new Map,G=new Set,Y=x=>{let B=i.key(x);B!=null&&(F.has(B)?G.add(B):F.set(B,x))};P instanceof Element&&Y(P);for(let x of P.querySelectorAll("*"))Y(x);for(let x of G)F.delete(x);for(let[x,B]of F){let j=$.get(x);if(!j||j.tagName!==B.tagName)continue;let K=V.get(j);K&&K!==B&&d.delete(K);let _=d.get(B);_&&_!==j&&V.delete(_),d.set(B,j),V.set(j,B)}}let m=new Set;for(let $ of d.values())m.add($);let A=M(i),N=A.morphStyle||"outerHTML";if(!["innerHTML","outerHTML"].includes(N))throw`Do not understand how to morph style ${N}`;return{target:e,newContent:t,config:A,morphStyle:N,ignoreActive:A.ignoreActive,ignoreActiveValue:A.ignoreActiveValue,restoreFocus:A.restoreFocus,formStateSync:A.formStateSync||"attribute",idMap:o,persistentIds:n,hyperMatches:d,hyperMatchedOldElements:m,pantry:p(),activeElementAndParents:y(e),callbacks:A.callbacks,head:A.head,scripts:A.scripts}}function M(e){let t=Object.assign({},f);return Object.assign(t,e),t.callbacks=Object.assign({},f.callbacks,e.callbacks),t.head=Object.assign({},f.head,e.head),t.scripts=Object.assign({},f.scripts,e.scripts),t}function p(){let e=document.createElement("div");return e.hidden=!0,document.body.insertAdjacentElement("afterend",e),e}function y(e){let t=[],i=document.activeElement;if(i?.tagName!=="BODY"&&e.contains(i))for(;i&&(t.push(i),i!==e);)i=i.parentElement;return t}function b(e){let t=Array.from(e.querySelectorAll("[id]"));return e.getAttribute?.("id")&&t.push(e),t}function g(e,t,i,n){for(let o of n){let d=o.getAttribute("id");if(t.has(d)){let m=o;for(;m;){let A=e.get(m);if(A==null&&(A=new Set,e.set(m,A)),A.add(d),m===i)break;m=m.parentElement}}}}function r(e,t){let i=b(e),n=b(t),o=l(i,n),d=new Map;g(d,o,e,i);let m=t.__hyperMorphRoot||t;return g(d,o,m,n),{persistentIds:o,idMap:d}}function l(e,t){let i=new Set,n=new Map;for(let{id:d,tagName:m}of e)n.has(d)?i.add(d):n.set(d,m);let o=new Set;for(let{id:d,tagName:m}of t)o.has(d)?i.add(d):n.get(d)===m&&o.add(d);for(let d of i)o.delete(d);return o}return c})(),{normalizeElement:L,normalizeParent:C}=(function(){let c=new WeakSet;function M(g){return g instanceof Document?g.documentElement:g}function p(g){if(g==null)return document.createElement("div");if(typeof g=="string")return p(b(g));if(c.has(g))return g;if(g instanceof Node){if(g.parentNode)return new y(g);{let r=document.createElement("div");return r.append(g),r}}else{let r=document.createElement("div");for(let l of[...g])r.append(l);return r}}class y{constructor(r){this.originalNode=r,this.realParentNode=r.parentNode,this.previousSibling=r.previousSibling,this.nextSibling=r.nextSibling}get childNodes(){let r=[],l=this.previousSibling?this.previousSibling.nextSibling:this.realParentNode.firstChild;for(;l&&l!=this.nextSibling;)r.push(l),l=l.nextSibling;return r}querySelectorAll(r){return this.childNodes.reduce((l,e)=>{if(e instanceof Element){e.matches(r)&&l.push(e);let t=e.querySelectorAll(r);for(let i=0;i<t.length;i++)l.push(t[i])}return l},[])}insertBefore(r,l){return this.realParentNode.insertBefore(r,l)}moveBefore(r,l){return this.realParentNode.moveBefore(r,l)}get __hyperMorphRoot(){return this.originalNode}}function b(g){let r=new DOMParser,l=g.replace(/<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim,"");if(l.match(/<\/html>/)||l.match(/<\/head>/)||l.match(/<\/body>/)){let e=r.parseFromString(g,"text/html");if(l.match(/<\/html>/))return c.add(e),e;{let t=e.firstChild;return t&&c.add(t),t}}else{let t=r.parseFromString("<body><template>"+g+"</template></body>","text/html").body.querySelector("template").content;return c.add(t),t}}return{normalizeElement:M,normalizeParent:p}})();return{morph:w,defaults:f}})();var Ae=W.morph,Se=W.defaults,ke=W;return oe(we);})();
2
2
 
3
3
  // Convenience morph wrapper with data-id support
4
4
  var morph = function(oldEl, newEl, options = {}) {