@webqit/oohtml 4.3.6 → 4.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- (()=>{function Ae(n){return(n=n.trim())&&n.startsWith("(")&&n.endsWith(")")}function ie(n,e,r,t=!0){r=(Array.isArray(r)?r:[r]).map(s=>(s+"").replace("(",t?"(.//":"(./")).join("|");let i=[],o;try{let s=n.document.evaluate(r,e,null,n.XPathResult.ANY_TYPE);for(;o=s.iterateNext();)i.push(o)}catch{}return i}function Se(n,e,r){r=(Array.isArray(r)?r:[r]).map(t=>(t+"").replace("(","(self::")).join("|");try{return n.document.evaluate(`${r}`,e,null,n.XPathResult.BOOLEAN_TYPE).booleanValue}catch{}}function z(n,e,r,t=!1,i=null){let o=i?.get(e)?.get(r);if(typeof o<"u")return o;let s=f=>(i?.has(e)||i?.set(e,new WeakMap),i?.get(e)?.set(r,f),f),l=e.getRootNode(),a=r.getRootNode();return l===a?s(e.contains(r)):t&&a instanceof n.ShadowRoot?s(z(n,e,a.host,t,i)):s(!1)}function Ee(n,e="|"){return[...n].reduce(([r,t,i,o],s)=>!r&&t===0&&(Array.isArray(e)?e:[e]).includes(s)?[r,t,[""].concat(i)]:(!r&&["(","[","{"].includes(s)&&!i[0].endsWith("\\")&&t++,!r&&[")","]","}"].includes(s)&&!i[0].endsWith("\\")&&t--,['"',"'","`"].includes(s)&&!i[0].endsWith("\\")&&(r=r===s?null:r||s),i[0]+=s,[r,t,i]),[null,0,[""]])[2].reverse()}function x(n){return!Array.isArray(n)&&typeof n=="object"&&n}function _(n){return Array.isArray(n)}function me(n,e,r=null){return _(e)?n.filter(t=>r?e.filter(i=>r(t,i)).length:e.indexOf(t)!==-1):[]}function E(n,...e){if(globalThis.webqit||(globalThis.webqit={}),globalThis.webqit.refs||Object.defineProperty(globalThis.webqit,"refs",{value:new J}),!arguments.length)return globalThis.webqit.refs;let r=globalThis.webqit.refs.get(n);r||(r=new J,globalThis.webqit.refs.set(n,r));let t,i;for(;t=e.shift();)(i=r)&&!(r=r.get(t))&&(r=new J,i.set(t,r));return r}var J=class extends Map{constructor(...e){super(...e),this.observers=new Set}set(e,r){let t=super.set(e,r);return this.fire("set",e,r,e),t}delete(e){let r=super.delete(e);return this.fire("delete",e),r}has(e){return this.fire("has",e),super.has(e)}get(e){return this.fire("get",e),super.get(e)}keyNames(){return Array.from(super.keys())}observe(e,r,t){let i={type:e,key:r,callback:t};return this.observers.add(i),()=>this.observers.delete(i)}unobserve(e,r,t){if(Array.isArray(e)||Array.isArray(r))throw new Error('The "type" and "key" arguments can only be strings.');for(let i of this.observers)!(oe([e,"*"],i.type)&&oe([r,"*"],i.key)&&i.callback===t)||this.observers.delete(i)}fire(e,r,...t){for(let i of this.observers)!(oe([e,"*"],i.type)&&oe([r,"*"],i.key))||i.callback(...t)}},oe=(n,e)=>Array.isArray(e)?me(n,e).length:n.includes(e);function V(n){return typeof n=="function"}function Y(n){return n===null||n===""}function k(n){return arguments.length&&(n===void 0||typeof n>"u")}function $(n){return Array.isArray(n)||typeof n=="object"&&n||V(n)}function de(n){return Y(n)||k(n)||n===!1||n===0||$(n)&&!Object.keys(n).length}function w(n){return V(n)||n&&{}.toString.call(n)==="[object function]"}function Z(n){return n instanceof Number||typeof n=="number"}function I(n){return Z(n)||n!==!0&&n!==!1&&n!==null&&n!==""&&!isNaN(n*1)}function G(n){return n instanceof String||typeof n=="string"&&n!==null}function pe(n){return!G(n)&&!k(n.length)}function se(n,...e){return e.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n}function he(t,e){e=e||Object.prototype,e=e&&!_(e)?[e]:e;for(var r=[],t=t;t&&(!e||e.indexOf(t)<0)&&t.name!=="default";)r.push(t),t=t?Object.getPrototypeOf(t):null;return r}function ge(n,e){var r=[];return he(n,e).forEach(t=>{se(r,...Object.getOwnPropertyNames(t))}),r}function N(n,e,r=!1,t=!1,i=!1){var o=0,s=n.shift();if((I(s)||s===!0||s===!1)&&(o=s,s=n.shift()),!n.length)throw new Error("_merge() requires two or more array/objects.");return n.forEach((l,a)=>{!$(l)&&!w(l)||(r?ge(l):Object.keys(l)).forEach(f=>{if(!!e(f,s,l,a)){var c=s[f],m=l[f];if((_(c)&&_(m)||x(c)&&x(m))&&(o===!0||o>0))s[f]=_(c)&&_(m)?[]:{},N([I(o)?o-1:o,s[f],c,m],e,r,t,i);else if(_(s)&&_(l))t?s[f]=m:s.push(m);else try{i?Object.defineProperty(s,f,Object.getOwnPropertyDescriptor(l,f)):s[f]=l[f]}catch{}}})}),s}function K(...n){return N(n,(e,r,t)=>!0,!1,!1,!1)}function O(n,e=!0){return _(n)?n:!e&&x(n)?[n]:n!==!1&&n!==0&&de(n)?[]:pe(n)?Array.prototype.slice.call(n):x(n)?Object.values(n):[n]}function ee(n,e,r={},t={}){e=O(e).slice();for(var i=n;!k(i)&&!Y(i)&&e.length;){var o=e.shift();if(!(r.get?r.get(i,o):$(i)?o in i:i[o])){t.exists=!1;return}i=r.get?r.get(i,o):i[o]}return t.exists=!0,i}function ye(n,e,r,t={},i={}){let o=(c,m,u)=>i.set?i.set(c,m,u):(I(e[l])&&_(c)?c.push(u):c[m]=u,!0);e=O(e);for(var s=n,l=0;l<e.length;l++)if(l<e.length-1){if(!s||!$(s)&&!w(s))return!1;var a=ee(s,e[l],i);if(!$(a)){if(i.buildTree===!1)return!1;a=w(i.buildTree)?i.buildTree(l):I(e[l+1])?[]:{};var f=o(s,e[l],a);if(!f)return!1}s=a}else return o(s,e[l],r)}var te=class{constructor(e,r=!1){Object.defineProperty(this,"window",{value:e}),Object.defineProperty(this,"readCallbacks",{value:new Set}),Object.defineProperty(this,"writeCallbacks",{value:new Set}),Object.defineProperty(this,"_synthesis",{value:0,writable:!0}),!r&&this.window.requestAnimationFrame?this._loop():this._synthesis++}get synthesis(){return this._synthesis}async synthesizeWhile(e){this._synthesis++,this._fulfill();let r=await e();return this._synthesis--,r}_fulfill(){for(let e of this.readCallbacks)e(),this.readCallbacks.delete(e);for(let e of this.writeCallbacks)e(),this.writeCallbacks.delete(e)}_loop(){this.window.requestAnimationFrame(()=>{this._fulfill(),this._loop()})}onread(e,r=!1){if(r)return new Promise(t=>{this.synthesis?t(e()):this.readCallbacks.add(()=>{t(e())})});this.synthesis?Promise.resolve().then(e):this.readCallbacks.add(e)}onwrite(e,r=!1){if(r)return new Promise(t=>{this.synthesis?t(e()):this.writeCallbacks.add(()=>{t(e())})});this.synthesis?Promise.resolve().then(e):this.writeCallbacks.add(e)}cycle(e,r,t){this.onread(()=>{let i=e(t),o=s=>{s!==void 0&&this.onwrite(()=>{let l=r(s,t),a=f=>{f!==void 0&&this.cycle(e,r,f)};l instanceof Promise?l.then(a):a(l)})};i instanceof Promise?i.then(o):o(i)})}};var C=class{constructor(e){this.content=e,this.type=typeof e=="string"?"selector":"instance",this.kind=this.type==="instance"?null:Ae(e)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=Ee(e.trim().slice(1,-1),"@").length>1)}toString(){return this.content}};var W=class{constructor(e,r,t){this.context=e,this.namespace=r,this.window=e.defaultView||e.ownerDocument?.defaultView||t,this.document=this.window.document,this.webqit=this.window.webqit,Object.defineProperty(this,"#",{value:{}})}resolveArgs(e){if(w(e[0])?e=[[],...e]:x(e[0])&&!(e[0]instanceof C)&&e.length===1?e=[[],void 0,e[0]]:x(e[1])&&e.length===2?e=[O(e[0],!1),void 0,e[1]]:e[0]=O(e[0],!1),e[0].filter(r=>typeof r!="string"&&!(r instanceof C)&&!(r instanceof this.window.Node)).length)throw new Error("Argument #2 must be either a string or a Node object, or a list of those.");return e[0]=e[0].map(r=>r instanceof C?r:new C(r)),e}registry(...e){return E("realdom.realtime",this.window,this.namespace,...e)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(e,r,t){let{window:i}=this,o=new Set,s=new WeakMap;for(let[l,a]of this.registry(e)){let f=[].concat(r).filter(m=>z(i,l.context,m.target,l.params.subtree==="cross-roots",s));if(!f.length)continue;let c=[l,Array.isArray(r)?f:f[0]];a?o.add(c):t.call(i,...c)}for(let l of o)t.call(i,...l);o.clear()}disconnectables(e,...r){let t={disconnect(){r.forEach(i=>i&&w(i.disconnect)&&i.disconnect()||w(i)&&i()||x(i)&&(i.disconnected=!0))}};return e&&e.addEventListener("abort",()=>t.disconnect()),t}};var D=class extends W{type="attr";constructor(e,...r){super(e,"attr",...r)}get(e,r=void 0,t={}){let i=typeof e=="string"||e instanceof C;[e=[],r=void 0,t={}]=this.resolveArgs(arguments);let{context:o}=this,s=Le(o,e);if(!r)return s;let l=t.lifecycleSignals&&this.createSignalGenerator();if(i)for(let a of s){let f=l?.generate()||{};r(a,f,o)}else{let a=l?.generate()||{};r(s,a,o)}if(t.live){l&&(t={...t,signalGenerator:l});let a=this.observe(i?e[0]:e,r,{newValue:!0,...t});return this.disconnectables(t.signal,a)}}observe(e,r,t={}){let i=typeof e=="string"||e instanceof C;if([e=[],r,t={}]=this.resolveArgs(arguments),["sync","intercept"].includes(t.timing))return this.observeSync(i?e[0]:e,r,t);if(t.timing&&t.timing!=="async")throw new Error(`Timing option "${t.timing}" invalid.`);let{context:o,window:s,webqit:l}=this;t.eventDetails&&!l.realdom.attrInterceptionHooks?.intercepting&&ke.call(s,"intercept",()=>{});let a=new s.MutationObserver(u=>{u=He(u).map(p=>je.call(s,p)),Pe.call(s,m,u,o)}),f={attributes:!0,attributeOldValue:t.oldValue,subtree:t.subtree&&!0};e.length&&(f.attributeFilter=e.map(u=>u+"")),a.observe(o,f);let c=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),m={context:o,spec:e,callback:r,params:t,atomics:new Map,originalFilterIsString:i,signalGenerator:c,disconnectable:a};return this.disconnectables(t.signal,a,c)}observeSync(e,r,t={}){let i=typeof e=="string"||e instanceof C;[e,r,t={}]=this.resolveArgs(arguments);let{context:o,window:s}=this;if(t.timing&&!["sync","intercept"].includes(t.timing))throw new Error(`Timing option "${t.timing}" invalid.`);let l=t.timing==="intercept"?"intercept":"sync";this.registry(l).size||ke.call(s,l,u=>{this.forEachMatchingContext(l,u,Pe)});let a={disconnect(){m.delete(c)}},f=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),c={context:o,spec:e,callback:r,params:t,atomics:new Map,originalFilterIsString:i,signalGenerator:f,disconnectable:a},m=this.registry(l);return m.set(c,!!c.params.deferred),this.disconnectables(t.signal,a,f)}};function He(n){return n.reduce((e,r,t)=>e[t-1]?.attributeName===r.attributeName||E(r.target,"internalAttrInteractions").get(r.attributeName)?e:e.concat(r),[])}function Pe(n,e){let{context:r,spec:t,callback:i,params:o,atomics:s,originalFilterIsString:l,signalGenerator:a}=n,f=t.map(u=>u+"");if(o.atomic&&!s.size?e=Le(r,t,e):o.timing!=="async"&&t.length&&(e=e.filter(u=>f.includes(u.name))),!e.length)return;o.newValue===null&&o.oldValue===null&&o.eventDetails||(e=e.map(u=>{let p;return o.eventDetails||({event:p,...u}=u),!o.oldValue&&"oldValue"in u&&({oldValue:p,...u}=u),!o.newValue&&"value"in u?{value:p,...u}=u:o.newValue&&typeof u.value>"u"&&(u={...u,value:fe(u.target,u.name,()=>u.target.getAttribute(u.name))}),u})),o.atomic&&(e.forEach(u=>s.set(u.name,u)),e=Array.from(s.entries()).map(([,u])=>u));let c=l?e[0]:e,m=a?.generate()||{};i(c,m,r)}function fe(n,e,r){let t=E(n,"internalAttrInteractions").get(e);E(n,"internalAttrInteractions").set(e,!0);let i=r();return E(n,"internalAttrInteractions").set(e,t),i}function Le(n,e,r=[]){let t={event:null,type:"attribute"};return e.length?e.map(o=>(o=o+"",r.find(s=>s.name===o)||{target:n,name:o,value:fe(n,o,()=>n.getAttribute(o)),...t})):Array.from(n.attributes).map(o=>r.find(s=>s.name===o.nodeName)||{target:n,name:o.nodeName,value:fe(n,o.nodeName,()=>o.nodeValue),...t})}function je({target:n,attributeName:e,value:r,oldValue:t}){let s=(this.webqit.realdom.attrInterceptionRecords?.get(n)||{})[e]?.[0]||"mutation";return{target:n,name:e,value:r,oldValue:t,type:"observation",event:s}}function ke(n,e){let r=this,{webqit:t,document:i,Element:o}=r;t.realdom.attrInterceptionHooks||Object.defineProperty(t.realdom,"attrInterceptionHooks",{value:new Map}),t.realdom.attrInterceptionHooks.has(n)||t.realdom.attrInterceptionHooks.set(n,new Set),t.realdom.attrInterceptionHooks.get(n).add(e);let s=()=>t.realdom.attrInterceptionHooks.get(n).delete(e);if(t.realdom.attrInterceptionHooks?.intercepting)return s;console.warn("Attr mutation APIs are now being intercepted."),t.realdom.attrInterceptionHooks.intercepting=!0,Object.defineProperty(t.realdom,"attrInterceptionRecords",{value:new Map});let l=(c,m)=>{t.realdom.attrInterceptionRecords.has(c.target)||t.realdom.attrInterceptionRecords.set(c.target,{});let u=t.realdom.attrInterceptionRecords.get(c.target);if(u[c.name]=u[c.name]||[],u[c.name].unshift(c.event),E(c.target,"internalAttrInteractions").get(c.name))return m();t.realdom.attrInterceptionHooks.get("intercept")?.forEach(y=>y([c]));let p=m();return t.realdom.attrInterceptionHooks.get("sync")?.forEach(y=>y([c])),p};new r.MutationObserver(c=>{c=c.filter(m=>!(r.webqit.realdom.attrInterceptionRecords?.get(m.target)||{})[m.attributeName]?.shift()),c=He(c).map(m=>je.call(r,m)),c.length&&(t.realdom.attrInterceptionHooks.get("intercept")?.forEach(m=>m(c)),t.realdom.attrInterceptionHooks.get("sync")?.forEach(m=>m(c)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let f=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(c=>{f[c]=o.prototype[c],o.prototype[c]=function(...m){let u,p=fe(this,m[0],()=>this.getAttribute(m[0]));["setAttribute","toggleAttribute"].includes(c)&&(u=m[1]),c==="toggleAttribute"&&u===void 0&&(u=p===null);let y={target:this,name:m[0],value:u,oldValue:p,type:"interception",event:[this,c]};return l(y,()=>f[c].call(this,...m))}}),s}var re=class extends W{constructor(e,...r){super(e,"tree",...r)}attr(e,r=void 0,t={}){let{context:i,window:o}=this;return new D(i,o).get(...arguments)}query(e,r=void 0,t={}){[e,r=void 0,t={}]=this.resolveArgs(arguments);let{context:i}=this,o=new Map,s=f=>(o.has(f)||o.set(f,{target:f,entrants:[],exits:[],type:"query",event:null}),o.get(f));if(!t.generation||t.generation==="entrants"){if(!e.length)[...i.children].forEach(f=>s(i).entrants.push(f));else if(e.every(f=>f.type==="selector")){let[f,c]=e.reduce(([u,p],y)=>y.kind==="xpath"?[u,p.concat(y)]:[u.concat(y),p],[[],[]]),m=[];t.subtree?(f.length&&m.push(...i.querySelectorAll(f.join(","))),c.length&&m.push(...ie(this.window,i,c))):(f.length&&m.push(...[...i.children].filter(u=>u.matches(f))),c.length&&m.push(...ie(this.window,i,c,!1))),m.forEach(u=>s(u.parentNode||i).entrants.push(u))}}if(!r)return o;let l={disconnected:!1},a=r&&t.lifecycleSignals&&this.createSignalGenerator();for(let[,f]of o){if(l.disconnected)break;let c=a?.generate()||{};r(f,c,i)}if(t.live){a&&(t={...t,signalGenerator:a});let f=this.observe(e,r,t);return this.disconnectables(t.signal,l,f)}return this.disconnectables(t.signal,l,a)}children(e,r=void 0,t={}){return[e,r=void 0,t={}]=this.resolveArgs(arguments),this.query(e,r,{...t,subtree:!1})}subtree(e,r=void 0,t={}){return[e,r=void 0,t={}]=this.resolveArgs(arguments),this.query(e,r,{...t,subtree:!0})}observe(e,r,t={}){if([e,r,t={}]=this.resolveArgs(arguments),["sync","intercept"].includes(t.timing))return this.observeSync(e,r,t);if(t.timing&&t.timing!=="async")throw new Error(`Timing option "${t.timing}" invalid.`);let{context:i,window:o,webqit:s,document:l}=this;t.eventDetails&&(s.realdom.domInterceptionRecordsAlwaysOn=!0),(l.readyState==="loading"||s.realdom.domInterceptionRecordsAlwaysOn)&&!s.realdom.domInterceptionHooks?.intercepting&&Be.call(o,"sync",()=>{});let a=new o.MutationObserver(m=>m.forEach(u=>{xe.call(o,c,Fe.call(o,u),i)}));a.observe(i,{childList:!0,subtree:t.subtree&&!0});let f=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),c={context:i,spec:e,callback:r,params:t,signalGenerator:f,disconnectable:a};if(t.staticSensitivity){let m=De.call(o,c);return this.disconnectables(t.signal,a,f,m)}return this.disconnectables(t.signal,a,f)}observeSync(e,r,t={}){[e,r,t={}]=this.resolveArgs(arguments);let{context:i,window:o}=this;if(t.timing&&!["sync","intercept"].includes(t.timing))throw new Error(`Timing option "${t.timing}" invalid.`);let s=t.timing==="intercept"?"intercept":"sync";this.registry(s).size||Be.call(o,s,u=>{this.forEachMatchingContext(s,u,xe)});let l=new o.MutationObserver(u=>u.forEach(p=>{Array.isArray((p=Fe.call(o,p)).event)||xe.call(o,c,p,i)}));l.observe(i,{childList:!0,subtree:t.subtree&&!0});let a={disconnect(){m.delete(c),l.disconnect()}},f=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),c={context:i,spec:e,callback:r,params:t,signalGenerator:f,disconnectable:a},m=this.registry(s);if(m.set(c,!!c.params.deferred),t.staticSensitivity){let u=De.call(o,c);return this.disconnectables(t.signal,a,f,u)}return this.disconnectables(t.signal,a,f)}track(e,r,t={}){return t={subtree:!0,...t},this.observe(e,i=>{i.entrants.length&&r(!0,Array.isArray(e)?i.entrants:i.entrants[0]),i.exits.length&&r(!1,Array.isArray(e)?i.exits:i.exits[0])},t)}};function De(n){let e=this,{context:r,spec:t,callback:i,params:o,signalGenerator:s}=n,l=t.filter(p=>p.kind==="css"),a=p=>p.match(/\.([\w-]+)/g)?.length?["class"]:[],f=p=>p.match(/#([\w-]+)/g)?.length?["id"]:[],c=p=>[...p.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(y=>y[1]).concat(a(p)).concat(f(p));if(!(n.$attrs=Array.from(new Set(l.filter(p=>(p+"").includes("[")).reduce((p,y)=>p.concat(c(y+"")),[])))).length)return;let m=new Set,u=new Set;return m.push=p=>(u.delete(p),m.add(p)),u.push=p=>(m.delete(p),u.add(p)),n.$deliveryCache={entrants:m,exits:u},new D(r,e).observe(n.$attrs,p=>{let y=new Map,A=g=>(y.has(g)||y.set(g,{target:g,entrants:[],exits:[],type:"static",event:null}),y.get(g)),R=new WeakMap,d=g=>(R.has(g)||R.set(g,l.some(b=>g.matches(b+""))),R.get(g));for(let g of p)["entrants","exits"].forEach(b=>{o.generation&&b!==o.generation||n.$deliveryCache[b].has(g.target)||(b==="entrants"?!d(g.target):d(g.target))||(n.$deliveryCache[b].push(g.target),A(g.target)[b].push(g.target),A(g.target).event=g.event)});for(let[,g]of y){let b=s?.generate()||{};i(g,b,r)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function xe(n,e){let{context:r,spec:t,callback:i,params:o,signalGenerator:s,$deliveryCache:l}=n,a={...e,entrants:[],exits:[]};if(o.eventDetails||delete a.event,["entrants","exits"].forEach(c=>{if(!(o.generation&&c!==o.generation)&&(t.length?a[c]=ct.call(this,t,o.subtree==="cross-roots",e[c],e.event!=="parse"):a[c]=[...e[c]],!!l))for(let m of a[c])l[c].push(m)}),!a.entrants.length&&!a.exits.length)return;let f=s?.generate()||{};i(a,f,r)}function ct(n,e,r,t){r=Array.isArray(r)?r:[...r];let i=(o,s)=>{if(s.type==="selector"){let l=s.isXpathAttr?[]:o.filter(a=>s.kind==="xpath"?Se(this,a,s+""):a.matches&&a.matches(s+""));if((t||s.isXpathAttr)&&(l=o.reduce((a,f)=>s.kind==="xpath"?[...a,...ie(this,f,s,t)]:f.querySelectorAll?[...a,...f.querySelectorAll(s+"")]:a,l)),l.length)return l}else if(o.includes(s.content)||t&&o.some(l=>z(this,l,s.content,e)))return[s.content]};return r.$$searchCache||(r.$$searchCache=new Map),n.reduce((o,s)=>{let l;return r.$$searchCache.has(s.content)?l=r.$$searchCache.get(s.content):(l=i(r,s)||[],s.type==="instance"&&r.$$searchCache.set(s.content,l)),o.concat(l)},[])}function Fe({target:n,addedNodes:e,removedNodes:r}){let t=this,i;return i=O(e).reduce((o,s)=>o||t.webqit.realdom.domInterceptionRecords?.get(s),null),i=O(r).reduce((o,s)=>o||t.webqit.realdom.domInterceptionRecords?.get(s),i),i=i||t.document.readyState==="loading"&&"parse"||"mutation",{target:n,entrants:e,exits:r,type:"observation",event:i}}function Be(n,e){let r=this,{webqit:t,document:i,Node:o,CharacterData:s,Element:l,HTMLElement:a,HTMLTemplateElement:f,DocumentFragment:c}=r;t.realdom.domInterceptionHooks||Object.defineProperty(t.realdom,"domInterceptionHooks",{value:new Map}),t.realdom.domInterceptionNoRecurse||Object.defineProperty(t.realdom,"domInterceptionNoRecurse",{value:new Map}),t.realdom.domInterceptionHooks.has(n)||t.realdom.domInterceptionHooks.set(n,new Set),t.realdom.domInterceptionHooks.get(n).add(e);let m=()=>t.realdom.domInterceptionHooks.get(n).delete(e);if(t.realdom.domInterceptionHooks?.intercepting)return m;console.warn("DOM mutation APIs are now being intercepted."),t.realdom.domInterceptionHooks.intercepting=!0,Object.defineProperty(t.realdom,"domInterceptionRecords",{value:new Map});let u=(d,g,b)=>{t.realdom.domInterceptionNoRecurse.set(d,g);let h=b();return t.realdom.domInterceptionNoRecurse.delete(d),h},p=(d,g)=>{d.entrants.concat(d.exits).forEach(h=>{clearTimeout(t.realdom.domInterceptionRecords.get(h)?.timeout),t.realdom.domInterceptionRecords.set(h,d.event);let S=setTimeout(()=>{t.realdom.domInterceptionRecords.delete(h)},0);Object.defineProperty(d.event,"timeout",{value:S,configurable:!0})}),t.realdom.domInterceptionHooks.get("intercept")?.forEach(h=>h(d));let b=g();return t.realdom.domInterceptionHooks.get("sync")?.forEach(h=>h(d)),b},y={ShadowRoot:["innerHTML","setHTMLUnsafe"],DocumentFragment:["replaceChildren","append","prepend"],Document:["replaceChildren","append","prepend"],HTMLElement:["outerText","innerText"],Element:["append","prepend","before","after","insertAdjacentElement","insertAdjacentHTML","remove","replaceChildren","replaceWith","setHTMLUnsafe","innerHTML","outerHTML"],CharacterData:["before","after","remove","replaceWith"],Node:["insertBefore","replaceChild","removeChild","appendChild","textContent","nodeValue"]},A={ShadowRoot:Object.create(null),DocumentFragment:Object.create(null),Document:Object.create(null),HTMLElement:Object.create(null),Element:Object.create(null),CharacterData:Object.create(null),Node:Object.create(null)};return new Set(Object.values(y).reduce((d,g)=>d.concat(g),[])).forEach(d=>{Object.keys(y).forEach(h=>{if(!y[h].includes(d))return;let S=Object.getOwnPropertyDescriptor(r[h].prototype,d);!S||(Object.defineProperty(r[h].prototype,d,"value"in S?{...S,value:g}:{...S,set:b}),A[h][d]=S)});function g(...h){let S=Object.keys(A).find(T=>this instanceof r[T]&&d in A[T]),U=A[S],H=()=>U[d].value.call(this,...h);if(t.realdom.domInterceptionNoRecurse.get(this)===d)return H();let M=[],v=[],L=this;["insertBefore"].includes(d)?v=[h[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(d)?(v=[h[1]],["beforebegin","afterend"].includes(h[0])&&(L=this.parentNode)):["setHTMLUnsafe","replaceChildren"].includes(d)?(M=[...this.childNodes],v=d==="replaceChildren"?[...h]:[h[0]]):["replaceWith","remove"].includes(d)?(M=[this],v=d==="replaceWith"?[...h]:[],L=this.parentNode):["replaceChild"].includes(d)?(M=[h[1]],v=[h[0]]):["removeChild"].includes(d)?M=[...h]:(v=[...h],["before","after"].includes(d)&&(L=this.parentNode));let ne=d;if(["insertAdjacentHTML","setHTMLUnsafe"].includes(d)){let T=this.nodeName;if(d==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(h[0])){if(!this.parentNode)return U[d].value.call(this,...h);T=this.parentNode.nodeName}let j=i.createElement(T.includes("-")?"div":T);U.setHTMLUnsafe.value.call(j,v[0],d==="setHTMLUnsafe"?h[1]:{}),v=[...j.childNodes],d==="insertAdjacentHTML"?(ne="insertAdjacentElement",h[1]=new c,u(h[1],"append",()=>h[1].append(...j.childNodes))):(ne="replaceChildren",h=[...j.childNodes])}return p({target:L,entrants:v,exits:M,type:"interception",event:[this,d]},()=>U[ne].value.call(this,...h))}function b(h){let S=Object.keys(A).find(F=>this instanceof r[F]&&d in A[F]),U=A[S],H=()=>U[d].set.call(this,h);if(this instanceof HTMLScriptElement||t.realdom.domInterceptionNoRecurse.get(this)===d)return H();let M=[],v=[],L=this;if(["outerHTML","outerText"].includes(d)?(M=[this],L=this.parentNode):this instanceof f?(L=this.content,M=[...this.content.childNodes]):M=[...this.childNodes],["outerHTML","innerHTML"].includes(d)){let F=this.nodeName;if(d==="outerHTML"){if(!this.parentNode)return H();F=this.parentNode.nodeName}let T=i.createElement(F.includes("-")?"div":F);if(u(T,d,()=>T[d]=h),v=this instanceof f?[...T.content.childNodes]:[...T.childNodes],this instanceof f&&this.hasAttribute("src")||this instanceof ShadowRoot){let j=B=>B.reduce((q,P)=>P instanceof HTMLScriptElement?q.concat(P):P instanceof f?q.concat(j([P.content])):(q=q.concat(j([...P.querySelectorAll?.("template")||[]].map(Qe=>Qe.content))),q.concat(...P.querySelectorAll?.("script")||[])),[]);for(let B of j(v)){if(this instanceof ShadowRoot){B.setAttribute("data-handling","manual");continue}let q=i.createElement("script");[...B.attributes].forEach(P=>q.setAttribute(P.name,P.value)),q.textContent=B.textContent,u(B,"replaceWith",()=>B.replaceWith(q))}}d==="outerHTML"?(h=new c,u(h,"append",()=>h.append(...v)),H=()=>u(this,"replaceWith",()=>l.prototype.replaceWith.call(this,h))):this instanceof f?H=()=>u(this.content,"replaceChildren",()=>this.content.replaceChildren(...v)):H=()=>u(this,"replaceChildren",()=>l.prototype.replaceChildren.call(this,...v))}return p({target:L,entrants:v,exits:M,type:"interception",event:[this,d]},H)}}),m}function We(){at.call(this),ut.call(this),mt.call(this)}function at(){let n=this;n.CSS||(n.CSS={}),n.CSS.escape||(n.CSS.escape=e=>e.replace(/([\:@\~\$\&])/g,"\\$1"))}function ut(){let n=this;"isConnected"in n.Node.prototype||Object.defineProperty(n.Node.prototype,"isConnected",{get:function(){return!this.ownerDocument||!(this.ownerDocument.compareDocumentPosition(this)&this.DOCUMENT_POSITION_DISCONNECTED)}})}function mt(){let n=this;n.Element.prototype.matches||(n.Element.prototype.matches=n.Element.prototype.matchesSelector||n.Element.prototype.mozMatchesSelector||n.Element.prototype.msMatchesSelector||n.Element.prototype.oMatchesSelector||n.Element.prototype.webkitMatchesSelector||function(e){for(var r=(this.document||this.ownerDocument).querySelectorAll(e),t=r.length;--t>=0&&r.item(t)!==this;);return t>-1})}function Re(){let n=this;if(n.webqit||(n.webqit={}),n.webqit.realdom)return n.webqit.realdom;n.webqit.realdom={},We.call(n),n.webqit.realdom.meta=(...r)=>dt.call(n,...r),n.webqit.realdom.ready=(...r)=>be.call(n,...r),n.webqit.realdom.realtime=(r,t="dom")=>{if(t==="dom")return new re(r,n);if(t==="attr")return new D(r,n)};let e=new te(n);return n.webqit.realdom.schedule=(r,...t)=>e[`on${r}`](...t),n.webqit.realdom.synthesizeWhile=(...r)=>e.synthesizeWhile(...r),n.webqit.realdom}function be(...n){let e="interactive",r;G(n[0])?(e=n[0],w(n[1])&&(r=n[1])):w(n[0])&&(r=n[0]);let t={interactive:["interactive","complete"],complete:["complete"]};if(!t[e])throw new Error(`Invalid ready-state timing: ${e}.`);let i=this;if(!r)return i.webqit.realdom.readyStatePromises||(i.webqit.realdom.readyStatePromises={interactive:new Promise(o=>be.call(this,"interactive",o)),complete:new Promise(o=>be.call(this,"complete",o))}),i.webqit.realdom.readyStatePromises[e];if(t[e].includes(i.document.readyState))return r(i);i.webqit.realdom.readyStateCallbacks||(i.webqit.realdom.readyStateCallbacks={interactive:[],complete:[]},i.document.addEventListener("readystatechange",()=>{let o=i.document.readyState;for(let s of i.webqit.realdom.readyStateCallbacks[o].splice(0))s(i)},!1)),i.webqit.realdom.readyStateCallbacks[e].push(r)}function dt(n){let e=this,r={},t;return(t=e.document.querySelector(`meta[name="${n}"]`))&&(r=(t.content||"").split(";").filter(i=>i).reduce((i,o)=>{let s=o.split("=").map(l=>l.trim());return ye(i,s[0].split("."),s[1]==="true"?!0:s[1]==="false"?!1:I(s[1])?parseInt(s[1]):s[1]),i},{})),{get name(){return n},get content(){return t.content},json(){return JSON.parse(JSON.stringify(r))}}}function ce(n,e){return typeof n!="string"?n:n.replace(/\w\S*/g,function(r){return r.charAt(0).toUpperCase()+(typeof e!==void 0&&e?r.substr(1).toLowerCase():r.substr(1))})}var X=(...n)=>E("oohtml",...n),gt={};function Ve(n,e,r){let t=this,i=Re.call(t);gt.window=t,t.webqitConfig||(t.webqitConfig=i.meta("webqit").json()),t.webqit||(t.webqit={}),t.webqit.oohtml||(t.webqit.oohtml={}),t.webqit.oohtml.configs||(t.webqit.oohtml.configs={});let o=n.toUpperCase().replace("-","_");if(!t.webqit.oohtml.configs[o]){t.webqit.oohtml.configs[o]={};let s=t.webqit.oohtml.configs[o];K(2,s,r,e,i.meta(n).json()),t.webqitConfig.prefix&&Object.keys(s).forEach(l=>{Object.keys(s[l]).forEach(a=>{l==="api"&&typeof s[l][a]=="string"?s[l][a]=`${t.webqitConfig.prefix}${ce(s[l][a])}`:["attr","elements"].includes(l)&&s[l][a]?.startsWith("data-")===!1&&(s[l][a]=`${t.webqitConfig.prefix}-${s[l][a]}`)})})}return{config:t.webqit.oohtml.configs[o],realdom:i,window:t}}function ae(n,e){return[...n].reduce(([r,t,i],o)=>!r&&t===0&&(Array.isArray(e)?e:[e]).includes(o)?[r,t,[""].concat(i)]:(!r&&["(","[","{"].includes(o)&&!i[0].endsWith("\\")&&t++,!r&&[")","]","}"].includes(o)&&!i[0].endsWith("\\")&&t--,['"',"'","`"].includes(o)&&!i[0].endsWith("\\")&&(r=r===o?null:r||o),i[0]+=o,[r,t,i]),[null,0,[""]])[2].reverse()}function Oe(n={}){let{config:e,window:r}=Ve.call(this,"data-binding",n,{attr:{render:"render",itemIndex:"data-key"},tokens:{nodeType:"processing-instruction",tagStart:"?{",tagEnd:"}?",stateStart:"; [=",stateEnd:"]"}});({CONTEXT_API:e.CONTEXT_API,BINDINGS_API:e.BINDINGS_API,HTML_IMPORTS:e.HTML_IMPORTS}=r.webqit.oohtml.configs),e.attrSelector=`[${r.CSS.escape(e.attr.render)}]`;let t=(i,o)=>{let s=`starts-with(., "${i}")`,l=`substring(., string-length(.) - string-length("${o}") + 1) = "${o}"`;return`${s} and ${l}`};e.discreteBindingsSelector=`comment()[${t(e.tokens.tagStart,e.tokens.tagEnd)}]`,_t.call(r,e)}function _t(n){let e=this,{webqit:{realdom:r}}=e;r.realtime(e.document).query(n.attrSelector,t=>{Ge.call(this,...t.exits),bt.call(e,n,...t.entrants)},{id:"data-binding:attr",live:!0,subtree:"cross-roots",timing:"sync",eventDetails:!0,staticSensitivity:!0}),r.realtime(e.document).query(`(${n.discreteBindingsSelector})`,t=>{Ge.call(this,...t.exits),wt.call(e,n,...t.entrants)},{id:"data-binding:descrete",live:!0,subtree:"cross-roots",timing:"sync"})}function Xe(n,e){let{webqit:{realdom:r,Observer:t,DOMBindingsContext:i}}=this;if(X(e).has("data-binding"))return X(e).get("data-binding");let o=Object.create(null),s=new AbortController;o.$exec__=(a,f,...c)=>{(()=>{try{a[f](...c)}catch(u){console.error(`Error executing "${f}": ${u.message} at ${u.cause}`)}})()},o.$assign__=(a,f,c)=>{(()=>{try{a[f]=c}catch(u){console.error(`${u.message} at ${u.cause}`)}})()},t.intercept(o,{get:(a,f,c)=>{if(!(a.key in o)){let m={...i.createRequest(a.key),live:!0,signal:s.signal};e[n.CONTEXT_API.api.contexts].request(m,u=>{t.set(o,a.key,u)})}return c(o[a.key]??(a.key in globalThis?globalThis[a.key]:void 0))},has:(a,f,c)=>c(!0)});let l={scope:o,abortController:s,bindings:new Map};return X(e).set("data-binding",l),l}function Ge(...n){for(let e of n){let r=e.nodeName==="#text"?e.parentNode:e,{bindings:t,abortController:i}=X(r).get("data-binding")||{};if(!t?.has(e))return;t.get(e).state.dispose(),t.get(e).signals?.forEach(o=>o.abort()),t.delete(e),t.size||(i.abort(),X(r).delete("data-binding"))}}function yt(n,e){let r=n.tokens.tagStart.split("").map(f=>`\\${f}`).join(""),t=n.tokens.tagEnd.split("").map(f=>`\\${f}`).join(""),i=n.tokens.stateStart.split("").map(f=>f===" "?"(?:\\s+)?":`\\${f}`).join(""),o=n.tokens.stateEnd.split("").map(f=>`\\${f}`).join(""),s=`^${r}(.*?)(?:${i}(\\d+)${o}(?:\\s+)?)?${t}$`,[,l,a]=e.match(new RegExp(s));return{raw:e,expr:l,span:parseInt(a??0)}}async function wt(n,...e){let r=this,t=e.reduce((i,o)=>{if(o.isBound)return i;let s=yt(n,o.nodeValue),l=o;if(s.span){if(l=o.nextSibling,l?.nodeName!=="#text"||l.nodeValue.length<s.span)return i;l.nodeValue.length>s.span&&l.splitText(s.span)}else l=o.ownerDocument.createTextNode(""),o.after(l);l.isBound=!0;let a=o;return r.webqit.env!=="server"&&(a.remove(),a=null),i.concat({textNode:l,template:s,anchorNode:a})},[]);for(let{textNode:i,template:o,anchorNode:s}of t){let l=xt.call(r,n,o.expr),{scope:a,bindings:f}=Xe.call(this,n,i.parentNode);Object.defineProperty(i,"$oohtml_internal_databinding_anchorNode",{value:s,configurable:!0});try{f.set(i,{state:await(await l.bind(i,a)).execute()})}catch(c){console.log(c)}}}var ve=new Map;function xt(n,e){if(ve.has(e))return ve.get(e);let r=`let content = ((${e}) ?? '') + '';`;r+="$assign__(this, 'nodeValue', content);",r+=`if ( this.$oohtml_internal_databinding_anchorNode ) { $assign__(this.$oohtml_internal_databinding_anchorNode, 'nodeValue', "${n.tokens.tagStart}${Q(e)}${n.tokens.stateStart}" + content.length + "${n.tokens.stateEnd} ${n.tokens.tagEnd}"); }`;let{webqit:{QuantumModule:t}}=this,i=new t(r);return ve.set(e,i),i}async function bt(n,...e){for(let r of e){let t=vt.call(this,n,r.getAttribute(n.attr.render)),{scope:i,bindings:o}=Xe.call(this,n,r),s=[];Object.defineProperty(r,"$oohtml_internal_databinding_signals",{value:s,configurable:!0});try{o.set(r,{signals:s,state:await(await t.bind(r,i)).execute()})}catch(l){console.log(l)}}}var $e=new Map;function vt(n,e){if($e.has(e))return $e.get(e);let r={},t=-1,i=ae(e,";").map(l=>{let[a,f]=ae(l,":").map(y=>y.trim()),c=a[0],m=a.slice(1).trim(),u=`(${f})`,p=`(${u} ?? '')`;if(c==="&")return m.startsWith("--")?`$exec__(this.style, 'setProperty', "${Q(m)}", ${p});`:`$assign__(this.style, "${Q(m)}", ${p});`;if(c==="%")return`$exec__(this.classList, 'toggle', "${Q(m)}", !!${u});`;if(c==="~")return m.startsWith("?")?`$exec__(this, 'toggleAttribute', "${Q(m.substring(1).trim())}", !!${u});`:`$exec__(this, 'setAttribute', "${Q(m)}", ${p});`;if(c==="#"){if(r[m])throw new Error(`Duplicate binding: ${a}.`);if(r[m]=!0,m==="text")return`$assign__(this, 'textContent', ${p});`;if(m==="html")return`$exec__(this, 'setHTMLUnsafe', ${p});`;if(m==="items"){let[y,A]=ae(f,"/");if(!A)throw new Error(`Invalid ${c}items spec: ${l}; no import specifier.`);let[R,d,g,b]=y.trim().match(/(.*?[\)\s+])(of|in)([\(\{\[\s+].*)/i)||[];if(!R)throw new Error(`Invalid ${c}items spec: ${l}.`);if(d.startsWith("(")?d=d.trim().slice(1,-1).split(",").map(S=>S.trim()):d=[d],d.length>(g==="in"?3:2))throw new Error(`Invalid ${c}items spec: ${l}.`);let h=g==="in"?d[2]:d[1]||"$index__";return`
2
- let $iteratee__ = ${b};
3
- let $import__ = this.${n.HTML_IMPORTS.api.import}( ${A.trim()}, true );
1
+ (()=>{function Ae(...n){let e,r={runtimeParams:Ze,compilerParams:Ye,parserParams:Je};for(;e=n.shift();){let{runtimeParams:t={},compilerParams:{globalsNoObserve:i=[],globalsOnlyPathsExcept:o=[],...s}={},parserParams:l={}}=e;r={runtimeParams:{...r.runtimeParams,...t},compilerParams:{...r.compilerParams,globalsNoObserve:[...r.compilerParams.globalsNoObserve,...i],globalsOnlyPathsExcept:[...r.compilerParams.globalsOnlyPathsExcept,...o],...s},parserParams:{...r.parserParams,...l}},n.devMode}return r}var Je={ecmaVersion:"latest",allowReturnOutsideFunction:!0,allowAwaitOutsideFunction:!1,allowSuperOutsideMethod:!1,preserveParens:!1,locations:!0},Ye={globalsNoObserve:["arguments","debugger"],globalsOnlyPathsExcept:[],originalSource:!0,locations:!0,compact:2},Ze={apiVersion:3};function Se(n){return(n=n.trim())&&n.startsWith("(")&&n.endsWith(")")}function ie(n,e,r,t=!0){r=(Array.isArray(r)?r:[r]).map(s=>(s+"").replace("(",t?"(.//":"(./")).join("|");let i=[],o;try{let s=n.document.evaluate(r,e,null,n.XPathResult.ANY_TYPE);for(;o=s.iterateNext();)i.push(o)}catch{}return i}function Ee(n,e,r){r=(Array.isArray(r)?r:[r]).map(t=>(t+"").replace("(","(self::")).join("|");try{return n.document.evaluate(`${r}`,e,null,n.XPathResult.BOOLEAN_TYPE).booleanValue}catch{}}function z(n,e,r,t=!1,i=null){let o=i?.get(e)?.get(r);if(typeof o<"u")return o;let s=a=>(i?.has(e)||i?.set(e,new WeakMap),i?.get(e)?.set(r,a),a),l=e.getRootNode(),c=r.getRootNode();return l===c?s(e.contains(r)):t&&c instanceof n.ShadowRoot?s(z(n,e,c.host,t,i)):s(!1)}function Ie(n,e="|"){return[...n].reduce(([r,t,i,o],s)=>!r&&t===0&&(Array.isArray(e)?e:[e]).includes(s)?[r,t,[""].concat(i)]:(!r&&["(","[","{"].includes(s)&&!i[0].endsWith("\\")&&t++,!r&&[")","]","}"].includes(s)&&!i[0].endsWith("\\")&&t--,['"',"'","`"].includes(s)&&!i[0].endsWith("\\")&&(r=r===s?null:r||s),i[0]+=s,[r,t,i]),[null,0,[""]])[2].reverse()}function x(n){return!Array.isArray(n)&&typeof n=="object"&&n}function _(n){return Array.isArray(n)}function me(n,e,r=null){return _(e)?n.filter(t=>r?e.filter(i=>r(t,i)).length:e.indexOf(t)!==-1):[]}function C(n,...e){if(globalThis.webqit||(globalThis.webqit={}),globalThis.webqit.refs||Object.defineProperty(globalThis.webqit,"refs",{value:new J}),!arguments.length)return globalThis.webqit.refs;let r=globalThis.webqit.refs.get(n);r||(r=new J,globalThis.webqit.refs.set(n,r));let t,i;for(;t=e.shift();)(i=r)&&!(r=r.get(t))&&(r=new J,i.set(t,r));return r}var J=class extends Map{constructor(...e){super(...e),this.observers=new Set}set(e,r){let t=super.set(e,r);return this.fire("set",e,r,e),t}delete(e){let r=super.delete(e);return this.fire("delete",e),r}has(e){return this.fire("has",e),super.has(e)}get(e){return this.fire("get",e),super.get(e)}keyNames(){return Array.from(super.keys())}observe(e,r,t){let i={type:e,key:r,callback:t};return this.observers.add(i),()=>this.observers.delete(i)}unobserve(e,r,t){if(Array.isArray(e)||Array.isArray(r))throw new Error('The "type" and "key" arguments can only be strings.');for(let i of this.observers)!(oe([e,"*"],i.type)&&oe([r,"*"],i.key)&&i.callback===t)||this.observers.delete(i)}fire(e,r,...t){for(let i of this.observers)!(oe([e,"*"],i.type)&&oe([r,"*"],i.key))||i.callback(...t)}},oe=(n,e)=>Array.isArray(e)?me(n,e).length:n.includes(e);function V(n){return typeof n=="function"}function Y(n){return n===null||n===""}function L(n){return arguments.length&&(n===void 0||typeof n>"u")}function A(n){return Array.isArray(n)||typeof n=="object"&&n||V(n)}function de(n){return Y(n)||L(n)||n===!1||n===0||A(n)&&!Object.keys(n).length}function w(n){return V(n)||n&&{}.toString.call(n)==="[object function]"}function Z(n){return n instanceof Number||typeof n=="number"}function T(n){return Z(n)||n!==!0&&n!==!1&&n!==null&&n!==""&&!isNaN(n*1)}function G(n){return n instanceof String||typeof n=="string"&&n!==null}function pe(n){return!G(n)&&!L(n.length)}function se(n,...e){return e.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n}function he(t,e){e=e||Object.prototype,e=e&&!_(e)?[e]:e;for(var r=[],t=t;t&&(!e||e.indexOf(t)<0)&&t.name!=="default";)r.push(t),t=t?Object.getPrototypeOf(t):null;return r}function ge(n,e){var r=[];return he(n,e).forEach(t=>{se(r,...Object.getOwnPropertyNames(t))}),r}function q(n,e,r=!1,t=!1,i=!1){var o=0,s=n.shift();if((T(s)||s===!0||s===!1)&&(o=s,s=n.shift()),!n.length)throw new Error("_merge() requires two or more array/objects.");return n.forEach((l,c)=>{!A(l)&&!w(l)||(r?ge(l):Object.keys(l)).forEach(a=>{if(!!e(a,s,l,c)){var f=s[a],m=l[a];if((_(f)&&_(m)||x(f)&&x(m))&&(o===!0||o>0))s[a]=_(f)&&_(m)?[]:{},q([T(o)?o-1:o,s[a],f,m],e,r,t,i);else if(_(s)&&_(l))t?s[a]=m:s.push(m);else try{i?Object.defineProperty(s,a,Object.getOwnPropertyDescriptor(l,a)):s[a]=l[a]}catch{}}})}),s}function K(...n){return q(n,(e,r,t)=>!0,!1,!1,!1)}function S(n,e=!0){return _(n)?n:!e&&x(n)?[n]:n!==!1&&n!==0&&de(n)?[]:pe(n)?Array.prototype.slice.call(n):x(n)?Object.values(n):[n]}function ee(n,e,r={},t={}){e=S(e).slice();for(var i=n;!L(i)&&!Y(i)&&e.length;){var o=e.shift();if(!(r.get?r.get(i,o):A(i)?o in i:i[o])){t.exists=!1;return}i=r.get?r.get(i,o):i[o]}return t.exists=!0,i}function ye(n,e,r,t={},i={}){let o=(f,m,u)=>i.set?i.set(f,m,u):(T(e[l])&&_(f)?f.push(u):f[m]=u,!0);e=S(e);for(var s=n,l=0;l<e.length;l++)if(l<e.length-1){if(!s||!A(s)&&!w(s))return!1;var c=ee(s,e[l],i);if(!A(c)){if(i.buildTree===!1)return!1;c=w(i.buildTree)?i.buildTree(l):T(e[l+1])?[]:{};var a=o(s,e[l],c);if(!a)return!1}s=c}else return o(s,e[l],r)}var te=class{constructor(e,r=!1){Object.defineProperty(this,"window",{value:e}),Object.defineProperty(this,"readCallbacks",{value:new Set}),Object.defineProperty(this,"writeCallbacks",{value:new Set}),Object.defineProperty(this,"_synthesis",{value:0,writable:!0}),!r&&this.window.requestAnimationFrame?this._loop():this._synthesis++}get synthesis(){return this._synthesis}async synthesizeWhile(e){this._synthesis++,this._fulfill();let r=await e();return this._synthesis--,r}_fulfill(){for(let e of this.readCallbacks)e(),this.readCallbacks.delete(e);for(let e of this.writeCallbacks)e(),this.writeCallbacks.delete(e)}_loop(){this.window.requestAnimationFrame(()=>{this._fulfill(),this._loop()})}onread(e,r=!1){if(r)return new Promise(t=>{this.synthesis?t(e()):this.readCallbacks.add(()=>{t(e())})});this.synthesis?Promise.resolve().then(e):this.readCallbacks.add(e)}onwrite(e,r=!1){if(r)return new Promise(t=>{this.synthesis?t(e()):this.writeCallbacks.add(()=>{t(e())})});this.synthesis?Promise.resolve().then(e):this.writeCallbacks.add(e)}cycle(e,r,t){this.onread(()=>{let i=e(t),o=s=>{s!==void 0&&this.onwrite(()=>{let l=r(s,t),c=a=>{a!==void 0&&this.cycle(e,r,a)};l instanceof Promise?l.then(c):c(l)})};i instanceof Promise?i.then(o):o(i)})}};var P=class{constructor(e){this.content=e,this.type=typeof e=="string"?"selector":"instance",this.kind=this.type==="instance"?null:Se(e)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=Ie(e.trim().slice(1,-1),"@").length>1)}toString(){return this.content}};var U=class{constructor(e,r,t){this.context=e,this.namespace=r,this.window=e.defaultView||e.ownerDocument?.defaultView||t,this.document=this.window.document,this.webqit=this.window.webqit,Object.defineProperty(this,"#",{value:{}})}resolveArgs(e){if(w(e[0])?e=[[],...e]:x(e[0])&&!(e[0]instanceof P)&&e.length===1?e=[[],void 0,e[0]]:x(e[1])&&e.length===2?e=[S(e[0],!1),void 0,e[1]]:e[0]=S(e[0],!1),e[0].filter(r=>typeof r!="string"&&!(r instanceof P)&&!(r instanceof this.window.Node)).length)throw new Error("Argument #2 must be either a string or a Node object, or a list of those.");return e[0]=e[0].map(r=>r instanceof P?r:new P(r)),e}registry(...e){return C("realdom.realtime",this.window,this.namespace,...e)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(e,r,t){let{window:i}=this,o=new Set,s=new WeakMap;for(let[l,c]of this.registry(e)){let a=[].concat(r).filter(m=>z(i,l.context,m.target,l.params.subtree==="cross-roots",s));if(!a.length)continue;let f=[l,Array.isArray(r)?a:a[0]];c?o.add(f):t.call(i,...f)}for(let l of o)t.call(i,...l);o.clear()}disconnectables(e,...r){let t={disconnect(){r.forEach(i=>i&&w(i.disconnect)&&i.disconnect()||w(i)&&i()||x(i)&&(i.disconnected=!0))}};return e&&e.addEventListener("abort",()=>t.disconnect()),t}};var B=class extends U{type="attr";constructor(e,...r){super(e,"attr",...r)}get(e,r=void 0,t={}){let i=typeof e=="string"||e instanceof P;[e=[],r=void 0,t={}]=this.resolveArgs(arguments);let{context:o}=this,s=je(o,e);if(!r)return s;let l=t.lifecycleSignals&&this.createSignalGenerator();if(i)for(let c of s){let a=l?.generate()||{};r(c,a,o)}else{let c=l?.generate()||{};r(s,c,o)}if(t.live){l&&(t={...t,signalGenerator:l});let c=this.observe(i?e[0]:e,r,{newValue:!0,...t});return this.disconnectables(t.signal,c)}}observe(e,r,t={}){let i=typeof e=="string"||e instanceof P;if([e=[],r,t={}]=this.resolveArgs(arguments),["sync","intercept"].includes(t.timing))return this.observeSync(i?e[0]:e,r,t);if(t.timing&&t.timing!=="async")throw new Error(`Timing option "${t.timing}" invalid.`);let{context:o,window:s,webqit:l}=this;t.eventDetails&&!l.realdom.attrInterceptionHooks?.intercepting&&He.call(s,"intercept",()=>{});let c=new s.MutationObserver(u=>{u=Le(u).map(p=>De.call(s,p)),ke.call(s,m,u,o)}),a={attributes:!0,attributeOldValue:t.oldValue,subtree:t.subtree&&!0};e.length&&(a.attributeFilter=e.map(u=>u+"")),c.observe(o,a);let f=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),m={context:o,spec:e,callback:r,params:t,atomics:new Map,originalFilterIsString:i,signalGenerator:f,disconnectable:c};return this.disconnectables(t.signal,c,f)}observeSync(e,r,t={}){let i=typeof e=="string"||e instanceof P;[e,r,t={}]=this.resolveArgs(arguments);let{context:o,window:s}=this;if(t.timing&&!["sync","intercept"].includes(t.timing))throw new Error(`Timing option "${t.timing}" invalid.`);let l=t.timing==="intercept"?"intercept":"sync";this.registry(l).size||He.call(s,l,u=>{this.forEachMatchingContext(l,u,ke)});let c={disconnect(){m.delete(f)}},a=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),f={context:o,spec:e,callback:r,params:t,atomics:new Map,originalFilterIsString:i,signalGenerator:a,disconnectable:c},m=this.registry(l);return m.set(f,!!f.params.deferred),this.disconnectables(t.signal,c,a)}};function Le(n){return n.reduce((e,r,t)=>e[t-1]?.attributeName===r.attributeName||C(r.target,"internalAttrInteractions").get(r.attributeName)?e:e.concat(r),[])}function ke(n,e){let{context:r,spec:t,callback:i,params:o,atomics:s,originalFilterIsString:l,signalGenerator:c}=n,a=t.map(u=>u+"");if(o.atomic&&!s.size?e=je(r,t,e):o.timing!=="async"&&t.length&&(e=e.filter(u=>a.includes(u.name))),!e.length)return;o.newValue===null&&o.oldValue===null&&o.eventDetails||(e=e.map(u=>{let p;return o.eventDetails||({event:p,...u}=u),!o.oldValue&&"oldValue"in u&&({oldValue:p,...u}=u),!o.newValue&&"value"in u?{value:p,...u}=u:o.newValue&&typeof u.value>"u"&&(u={...u,value:ae(u.target,u.name,()=>u.target.getAttribute(u.name))}),u})),o.atomic&&(e.forEach(u=>s.set(u.name,u)),e=Array.from(s.entries()).map(([,u])=>u));let f=l?e[0]:e,m=c?.generate()||{};i(f,m,r)}function ae(n,e,r){let t=C(n,"internalAttrInteractions").get(e);C(n,"internalAttrInteractions").set(e,!0);let i=r();return C(n,"internalAttrInteractions").set(e,t),i}function je(n,e,r=[]){let t={event:null,type:"attribute"};return e.length?e.map(o=>(o=o+"",r.find(s=>s.name===o)||{target:n,name:o,value:ae(n,o,()=>n.getAttribute(o)),...t})):Array.from(n.attributes).map(o=>r.find(s=>s.name===o.nodeName)||{target:n,name:o.nodeName,value:ae(n,o.nodeName,()=>o.nodeValue),...t})}function De({target:n,attributeName:e,value:r,oldValue:t}){let s=(this.webqit.realdom.attrInterceptionRecords?.get(n)||{})[e]?.[0]||"mutation";return{target:n,name:e,value:r,oldValue:t,type:"observation",event:s}}function He(n,e){let r=this,{webqit:t,document:i,Element:o}=r;t.realdom.attrInterceptionHooks||Object.defineProperty(t.realdom,"attrInterceptionHooks",{value:new Map}),t.realdom.attrInterceptionHooks.has(n)||t.realdom.attrInterceptionHooks.set(n,new Set),t.realdom.attrInterceptionHooks.get(n).add(e);let s=()=>t.realdom.attrInterceptionHooks.get(n).delete(e);if(t.realdom.attrInterceptionHooks?.intercepting)return s;console.warn("Attr mutation APIs are now being intercepted."),t.realdom.attrInterceptionHooks.intercepting=!0,Object.defineProperty(t.realdom,"attrInterceptionRecords",{value:new Map});let l=(f,m)=>{t.realdom.attrInterceptionRecords.has(f.target)||t.realdom.attrInterceptionRecords.set(f.target,{});let u=t.realdom.attrInterceptionRecords.get(f.target);if(u[f.name]=u[f.name]||[],u[f.name].unshift(f.event),C(f.target,"internalAttrInteractions").get(f.name))return m();t.realdom.attrInterceptionHooks.get("intercept")?.forEach(g=>g([f]));let p=m();return t.realdom.attrInterceptionHooks.get("sync")?.forEach(g=>g([f])),p};new r.MutationObserver(f=>{f=f.filter(m=>!(r.webqit.realdom.attrInterceptionRecords?.get(m.target)||{})[m.attributeName]?.shift()),f=Le(f).map(m=>De.call(r,m)),f.length&&(t.realdom.attrInterceptionHooks.get("intercept")?.forEach(m=>m(f)),t.realdom.attrInterceptionHooks.get("sync")?.forEach(m=>m(f)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let a=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(f=>{a[f]=o.prototype[f],o.prototype[f]=function(...m){let u,p=ae(this,m[0],()=>this.getAttribute(m[0]));["setAttribute","toggleAttribute"].includes(f)&&(u=m[1]),f==="toggleAttribute"&&u===void 0&&(u=p===null);let g={target:this,name:m[0],value:u,oldValue:p,type:"interception",event:[this,f]};return l(g,()=>a[f].call(this,...m))}}),s}var re=class extends U{constructor(e,...r){super(e,"tree",...r)}attr(e,r=void 0,t={}){let{context:i,window:o}=this;return new B(i,o).get(...arguments)}query(e,r=void 0,t={}){[e,r=void 0,t={}]=this.resolveArgs(arguments);let{context:i}=this,o=new Map,s=a=>(o.has(a)||o.set(a,{target:a,entrants:[],exits:[],type:"query",event:null}),o.get(a));if(!t.generation||t.generation==="entrants"){if(!e.length)[...i.children].forEach(a=>s(i).entrants.push(a));else if(e.every(a=>a.type==="selector")){let[a,f]=e.reduce(([u,p],g)=>g.kind==="xpath"?[u,p.concat(g)]:[u.concat(g),p],[[],[]]),m=[];t.subtree?(a.length&&m.push(...i.querySelectorAll(a.join(","))),f.length&&m.push(...ie(this.window,i,f))):(a.length&&m.push(...[...i.children].filter(u=>u.matches(a))),f.length&&m.push(...ie(this.window,i,f,!1))),m.forEach(u=>s(u.parentNode||i).entrants.push(u))}}if(!r)return o;let l={disconnected:!1},c=r&&t.lifecycleSignals&&this.createSignalGenerator();for(let[,a]of o){if(l.disconnected)break;let f=c?.generate()||{};r(a,f,i)}if(t.live){c&&(t={...t,signalGenerator:c});let a=this.observe(e,r,t);return this.disconnectables(t.signal,l,a)}return this.disconnectables(t.signal,l,c)}children(e,r=void 0,t={}){return[e,r=void 0,t={}]=this.resolveArgs(arguments),this.query(e,r,{...t,subtree:!1})}subtree(e,r=void 0,t={}){return[e,r=void 0,t={}]=this.resolveArgs(arguments),this.query(e,r,{...t,subtree:!0})}observe(e,r,t={}){if([e,r,t={}]=this.resolveArgs(arguments),["sync","intercept"].includes(t.timing))return this.observeSync(e,r,t);if(t.timing&&t.timing!=="async")throw new Error(`Timing option "${t.timing}" invalid.`);let{context:i,window:o,webqit:s,document:l}=this;t.eventDetails&&(s.realdom.domInterceptionRecordsAlwaysOn=!0),(l.readyState==="loading"||s.realdom.domInterceptionRecordsAlwaysOn)&&!s.realdom.domInterceptionHooks?.intercepting&&Re.call(o,"sync",()=>{});let c=new o.MutationObserver(m=>m.forEach(u=>{xe.call(o,f,Be.call(o,u),i)}));c.observe(i,{childList:!0,subtree:t.subtree&&!0});let a=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),f={context:i,spec:e,callback:r,params:t,signalGenerator:a,disconnectable:c};if(t.staticSensitivity){let m=Fe.call(o,f);return this.disconnectables(t.signal,c,a,m)}return this.disconnectables(t.signal,c,a)}observeSync(e,r,t={}){[e,r,t={}]=this.resolveArgs(arguments);let{context:i,window:o}=this;if(t.timing&&!["sync","intercept"].includes(t.timing))throw new Error(`Timing option "${t.timing}" invalid.`);let s=t.timing==="intercept"?"intercept":"sync";this.registry(s).size||Re.call(o,s,u=>{this.forEachMatchingContext(s,u,xe)});let l=new o.MutationObserver(u=>u.forEach(p=>{Array.isArray((p=Be.call(o,p)).event)||xe.call(o,f,p,i)}));l.observe(i,{childList:!0,subtree:t.subtree&&!0});let c={disconnect(){m.delete(f),l.disconnect()}},a=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),f={context:i,spec:e,callback:r,params:t,signalGenerator:a,disconnectable:c},m=this.registry(s);if(m.set(f,!!f.params.deferred),t.staticSensitivity){let u=Fe.call(o,f);return this.disconnectables(t.signal,c,a,u)}return this.disconnectables(t.signal,c,a)}track(e,r,t={}){return t={subtree:!0,...t},this.observe(e,i=>{i.entrants.length&&r(!0,Array.isArray(e)?i.entrants:i.entrants[0]),i.exits.length&&r(!1,Array.isArray(e)?i.exits:i.exits[0])},t)}};function Fe(n){let e=this,{context:r,spec:t,callback:i,params:o,signalGenerator:s}=n,l=t.filter(p=>p.kind==="css"),c=p=>p.match(/\.([\w-]+)/g)?.length?["class"]:[],a=p=>p.match(/#([\w-]+)/g)?.length?["id"]:[],f=p=>[...p.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(g=>g[1]).concat(c(p)).concat(a(p));if(!(n.$attrs=Array.from(new Set(l.filter(p=>(p+"").includes("[")).reduce((p,g)=>p.concat(f(g+"")),[])))).length)return;let m=new Set,u=new Set;return m.push=p=>(u.delete(p),m.add(p)),u.push=p=>(m.delete(p),u.add(p)),n.$deliveryCache={entrants:m,exits:u},new B(r,e).observe(n.$attrs,p=>{let g=new Map,v=y=>(g.has(y)||g.set(y,{target:y,entrants:[],exits:[],type:"static",event:null}),g.get(y)),M=new WeakMap,h=y=>(M.has(y)||M.set(y,l.some($=>y.matches($+""))),M.get(y));for(let y of p)["entrants","exits"].forEach($=>{o.generation&&$!==o.generation||n.$deliveryCache[$].has(y.target)||($==="entrants"?!h(y.target):h(y.target))||(n.$deliveryCache[$].push(y.target),v(y.target)[$].push(y.target),v(y.target).event=y.event)});for(let[,y]of g){let $=s?.generate()||{};i(y,$,r)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function xe(n,e){let{context:r,spec:t,callback:i,params:o,signalGenerator:s,$deliveryCache:l}=n,c={...e,entrants:[],exits:[]};if(o.eventDetails||delete c.event,["entrants","exits"].forEach(f=>{if(!(o.generation&&f!==o.generation)&&(t.length?c[f]=dt.call(this,t,o.subtree==="cross-roots",e[f],e.event!=="parse"):c[f]=[...e[f]],!!l))for(let m of c[f])l[f].push(m)}),!c.entrants.length&&!c.exits.length)return;let a=s?.generate()||{};i(c,a,r)}function dt(n,e,r,t){r=Array.isArray(r)?r:[...r];let i=(o,s)=>{if(s.type==="selector"){let l=s.isXpathAttr?[]:o.filter(c=>s.kind==="xpath"?Ee(this,c,s+""):c.matches&&c.matches(s+""));if((t||s.isXpathAttr)&&(l=o.reduce((c,a)=>s.kind==="xpath"?[...c,...ie(this,a,s,t)]:a.querySelectorAll?[...c,...a.querySelectorAll(s+"")]:c,l)),l.length)return l}else if(o.includes(s.content)||t&&o.some(l=>z(this,l,s.content,e)))return[s.content]};return r.$$searchCache||(r.$$searchCache=new Map),n.reduce((o,s)=>{let l;return r.$$searchCache.has(s.content)?l=r.$$searchCache.get(s.content):(l=i(r,s)||[],s.type==="instance"&&r.$$searchCache.set(s.content,l)),o.concat(l)},[])}function Be({target:n,addedNodes:e,removedNodes:r}){let t=this,i;return i=S(e).reduce((o,s)=>o||t.webqit.realdom.domInterceptionRecords?.get(s),null),i=S(r).reduce((o,s)=>o||t.webqit.realdom.domInterceptionRecords?.get(s),i),i=i||t.document.readyState==="loading"&&"parse"||"mutation",{target:n,entrants:e,exits:r,type:"observation",event:i}}function Re(n,e){let r=this,{webqit:t,document:i,Node:o,CharacterData:s,Element:l,HTMLElement:c,HTMLTemplateElement:a,DocumentFragment:f}=r;t.realdom.domInterceptionHooks||Object.defineProperty(t.realdom,"domInterceptionHooks",{value:new Map}),t.realdom.domInterceptionNoRecurse||Object.defineProperty(t.realdom,"domInterceptionNoRecurse",{value:new Map}),t.realdom.domInterceptionHooks.has(n)||t.realdom.domInterceptionHooks.set(n,new Set),t.realdom.domInterceptionHooks.get(n).add(e);let m=()=>t.realdom.domInterceptionHooks.get(n).delete(e);if(t.realdom.domInterceptionHooks?.intercepting)return m;console.warn("DOM mutation APIs are now being intercepted."),t.realdom.domInterceptionHooks.intercepting=!0,Object.defineProperty(t.realdom,"domInterceptionRecords",{value:new Map});let u=(h,y,$)=>{t.realdom.domInterceptionNoRecurse.set(h,y);let d=$();return t.realdom.domInterceptionNoRecurse.delete(h),d},p=(h,y)=>{h.entrants.concat(h.exits).forEach(d=>{clearTimeout(t.realdom.domInterceptionRecords.get(d)?.timeout),t.realdom.domInterceptionRecords.set(d,h.event);let b=setTimeout(()=>{t.realdom.domInterceptionRecords.delete(d)},0);Object.defineProperty(h.event,"timeout",{value:b,configurable:!0})}),t.realdom.domInterceptionHooks.get("intercept")?.forEach(d=>d(h));let $=y();return t.realdom.domInterceptionHooks.get("sync")?.forEach(d=>d(h)),$},g={ShadowRoot:["innerHTML","setHTMLUnsafe"],DocumentFragment:["replaceChildren","append","prepend"],Document:["replaceChildren","append","prepend"],HTMLElement:["outerText","innerText"],Element:["append","prepend","before","after","insertAdjacentElement","insertAdjacentHTML","remove","replaceChildren","replaceWith","setHTMLUnsafe","innerHTML","outerHTML"],CharacterData:["before","after","remove","replaceWith"],Node:["insertBefore","replaceChild","removeChild","appendChild","textContent","nodeValue"]},v={ShadowRoot:Object.create(null),DocumentFragment:Object.create(null),Document:Object.create(null),HTMLElement:Object.create(null),Element:Object.create(null),CharacterData:Object.create(null),Node:Object.create(null)};return new Set(Object.values(g).reduce((h,y)=>h.concat(y),[])).forEach(h=>{Object.keys(g).forEach(d=>{if(!g[d].includes(h))return;let b=Object.getOwnPropertyDescriptor(r[d].prototype,h);!b||(Object.defineProperty(r[d].prototype,h,"value"in b?{...b,value:y}:{...b,set:$}),v[d][h]=b)});function y(...d){let b=Object.keys(v).find(N=>this instanceof r[N]&&h in v[N]),j=v[b],E=()=>j[h].value.call(this,...d);if(t.realdom.domInterceptionNoRecurse.get(this)===h)return E();let I=[],O=[],D=this;["insertBefore"].includes(h)?O=[d[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(h)?(O=[d[1]],["beforebegin","afterend"].includes(d[0])&&(D=this.parentNode)):["setHTMLUnsafe","replaceChildren"].includes(h)?(I=[...this.childNodes],O=h==="replaceChildren"?[...d]:[d[0]]):["replaceWith","remove"].includes(h)?(I=[this],O=h==="replaceWith"?[...d]:[],D=this.parentNode):["replaceChild"].includes(h)?(I=[d[1]],O=[d[0]]):["removeChild"].includes(h)?I=[...d]:(O=[...d],["before","after"].includes(h)&&(D=this.parentNode));let ne=h;if(["insertAdjacentHTML","setHTMLUnsafe"].includes(h)){let N=this.nodeName;if(h==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(d[0])){if(!this.parentNode)return j[h].value.call(this,...d);N=this.parentNode.nodeName}let F=i.createElement(N.includes("-")?"div":N);j.setHTMLUnsafe.value.call(F,O[0],h==="setHTMLUnsafe"?d[1]:{}),O=[...F.childNodes],h==="insertAdjacentHTML"?(ne="insertAdjacentElement",d[1]=new f,u(d[1],"append",()=>d[1].append(...F.childNodes))):(ne="replaceChildren",d=[...F.childNodes])}return p({target:D,entrants:O,exits:I,type:"interception",event:[this,h]},()=>j[ne].value.call(this,...d))}function $(d){let b=Object.keys(v).find(R=>this instanceof r[R]&&h in v[R]),j=v[b],E=()=>j[h].set.call(this,d);if(this instanceof HTMLScriptElement||t.realdom.domInterceptionNoRecurse.get(this)===h)return E();let I=[],O=[],D=this;if(["outerHTML","outerText"].includes(h)?(I=[this],D=this.parentNode):this instanceof a?(D=this.content,I=[...this.content.childNodes]):I=[...this.childNodes],["outerHTML","innerHTML"].includes(h)){let R=this.nodeName;if(h==="outerHTML"){if(!this.parentNode)return E();R=this.parentNode.nodeName}let N=i.createElement(R.includes("-")?"div":R);if(u(N,h,()=>N[h]=d),O=this instanceof a?[...N.content.childNodes]:[...N.childNodes],this instanceof a&&this.hasAttribute("src")||this instanceof ShadowRoot){let F=W=>W.reduce((k,H)=>H instanceof HTMLScriptElement?k.concat(H):H instanceof a?k.concat(F([H.content])):(k=k.concat(F([...H.querySelectorAll?.("template")||[]].map(ze=>ze.content))),k.concat(...H.querySelectorAll?.("script")||[])),[]);for(let W of F(O)){if(this instanceof ShadowRoot){W.setAttribute("data-handling","manual");continue}let k=i.createElement("script");[...W.attributes].forEach(H=>k.setAttribute(H.name,H.value)),k.textContent=W.textContent,u(W,"replaceWith",()=>W.replaceWith(k))}}h==="outerHTML"?(d=new f,u(d,"append",()=>d.append(...O)),E=()=>u(this,"replaceWith",()=>l.prototype.replaceWith.call(this,d))):this instanceof a?E=()=>u(this.content,"replaceChildren",()=>this.content.replaceChildren(...O)):E=()=>u(this,"replaceChildren",()=>l.prototype.replaceChildren.call(this,...O))}return p({target:D,entrants:O,exits:I,type:"interception",event:[this,h]},E)}}),m}function We(){pt.call(this),ht.call(this),gt.call(this)}function pt(){let n=this;n.CSS||(n.CSS={}),n.CSS.escape||(n.CSS.escape=e=>e.replace(/([\:@\~\$\&])/g,"\\$1"))}function ht(){let n=this;"isConnected"in n.Node.prototype||Object.defineProperty(n.Node.prototype,"isConnected",{get:function(){return!this.ownerDocument||!(this.ownerDocument.compareDocumentPosition(this)&this.DOCUMENT_POSITION_DISCONNECTED)}})}function gt(){let n=this;n.Element.prototype.matches||(n.Element.prototype.matches=n.Element.prototype.matchesSelector||n.Element.prototype.mozMatchesSelector||n.Element.prototype.msMatchesSelector||n.Element.prototype.oMatchesSelector||n.Element.prototype.webkitMatchesSelector||function(e){for(var r=(this.document||this.ownerDocument).querySelectorAll(e),t=r.length;--t>=0&&r.item(t)!==this;);return t>-1})}function Ue(){let n=this;if(n.webqit||(n.webqit={}),n.webqit.realdom)return n.webqit.realdom;n.webqit.realdom={},We.call(n),n.webqit.realdom.meta=(...r)=>_t.call(n,...r),n.webqit.realdom.ready=(...r)=>be.call(n,...r),n.webqit.realdom.realtime=(r,t="dom")=>{if(t==="dom")return new re(r,n);if(t==="attr")return new B(r,n)};let e=new te(n);return n.webqit.realdom.schedule=(r,...t)=>e[`on${r}`](...t),n.webqit.realdom.synthesizeWhile=(...r)=>e.synthesizeWhile(...r),n.webqit.realdom}function be(...n){let e="interactive",r;G(n[0])?(e=n[0],w(n[1])&&(r=n[1])):w(n[0])&&(r=n[0]);let t={interactive:["interactive","complete"],complete:["complete"]};if(!t[e])throw new Error(`Invalid ready-state timing: ${e}.`);let i=this;if(!r)return i.webqit.realdom.readyStatePromises||(i.webqit.realdom.readyStatePromises={interactive:new Promise(o=>be.call(this,"interactive",o)),complete:new Promise(o=>be.call(this,"complete",o))}),i.webqit.realdom.readyStatePromises[e];if(t[e].includes(i.document.readyState))return r(i);i.webqit.realdom.readyStateCallbacks||(i.webqit.realdom.readyStateCallbacks={interactive:[],complete:[]},i.document.addEventListener("readystatechange",()=>{let o=i.document.readyState;for(let s of i.webqit.realdom.readyStateCallbacks[o].splice(0))s(i)},!1)),i.webqit.realdom.readyStateCallbacks[e].push(r)}function _t(n){let e=this,r={},t;return(t=e.document.querySelector(`meta[name="${n}"]`))&&(r=(t.content||"").split(";").filter(i=>i).reduce((i,o)=>{let s=o.split("=").map(l=>l.trim());return ye(i,s[0].split("."),s[1]==="true"?!0:s[1]==="false"?!1:T(s[1])?parseInt(s[1]):s[1]),i},{})),{get name(){return n},get content(){return t.content},json(){return JSON.parse(JSON.stringify(r))}}}function fe(n,e){return typeof n!="string"?n:n.replace(/\w\S*/g,function(r){return r.charAt(0).toUpperCase()+(typeof e!==void 0&&e?r.substr(1).toLowerCase():r.substr(1))})}var X=(...n)=>C("oohtml",...n),xt={};function Ge(n,e,r){let t=this,i=Ue.call(t);xt.window=t,t.webqitConfig||(t.webqitConfig=i.meta("webqit").json()),t.webqit||(t.webqit={}),t.webqit.oohtml||(t.webqit.oohtml={}),t.webqit.oohtml.configs||(t.webqit.oohtml.configs={});let o=n.toUpperCase().replace("-","_");if(!t.webqit.oohtml.configs[o]){t.webqit.oohtml.configs[o]={};let s=t.webqit.oohtml.configs[o];K(2,s,r,e,i.meta(n).json()),t.webqitConfig.prefix&&Object.keys(s).forEach(l=>{Object.keys(s[l]).forEach(c=>{l==="api"&&typeof s[l][c]=="string"?s[l][c]=`${t.webqitConfig.prefix}${fe(s[l][c])}`:["attr","elements"].includes(l)&&s[l][c]?.startsWith("data-")===!1&&(s[l][c]=`${t.webqitConfig.prefix}-${s[l][c]}`)})})}return{config:t.webqit.oohtml.configs[o],realdom:i,window:t}}function ce(n,e){return[...n].reduce(([r,t,i],o)=>!r&&t===0&&(Array.isArray(e)?e:[e]).includes(o)?[r,t,[""].concat(i)]:(!r&&["(","[","{"].includes(o)&&!i[0].endsWith("\\")&&t++,!r&&[")","]","}"].includes(o)&&!i[0].endsWith("\\")&&t--,['"',"'","`"].includes(o)&&!i[0].endsWith("\\")&&(r=r===o?null:r||o),i[0]+=o,[r,t,i]),[null,0,[""]])[2].reverse()}function Oe(n={}){let{config:e,window:r}=Ge.call(this,"data-binding",n,{attr:{render:"render",itemIndex:"data-key"},tokens:{nodeType:"processing-instruction",tagStart:"?{",tagEnd:"}?",stateStart:"; [=",stateEnd:"]"},advanced:Ae({runtimeParams:{spec:{handler:i=>{}}}})});({CONTEXT_API:e.CONTEXT_API,BINDINGS_API:e.BINDINGS_API,HTML_IMPORTS:e.HTML_IMPORTS}=r.webqit.oohtml.configs),e.attrSelector=`[${r.CSS.escape(e.attr.render)}]`;let t=(i,o)=>{let s=`starts-with(., "${i}")`,l=`substring(., string-length(.) - string-length("${o}") + 1) = "${o}"`;return`${s} and ${l}`};e.discreteBindingsSelector=`comment()[${t(e.tokens.tagStart,e.tokens.tagEnd)}]`,bt.call(r,e)}function bt(n){let e=this,{webqit:{realdom:r}}=e;r.realtime(e.document).query(n.attrSelector,t=>{Xe.call(this,...t.exits),At.call(e,n,...t.entrants)},{id:"data-binding:attr",live:!0,subtree:"cross-roots",timing:"sync",eventDetails:!0,staticSensitivity:!0}),r.realtime(e.document).query(`(${n.discreteBindingsSelector})`,t=>{Xe.call(this,...t.exits),$t.call(e,n,...t.entrants)},{id:"data-binding:descrete",live:!0,subtree:"cross-roots",timing:"sync"})}function Qe(n,e){let{webqit:{realdom:r,Observer:t,DOMBindingsContext:i}}=this;if(X(e).has("data-binding"))return X(e).get("data-binding");let o=Object.create(null),s=new AbortController;o.$exec__=(c,a,...f)=>{(()=>{try{c[a](...f)}catch(u){throw new Error(`Error executing "${a}()": ${u.message} at ${u.cause}`)}})()},o.$assign__=(c,a,f)=>{(()=>{try{c[a]=f}catch(u){throw new Error(`Error executing "${a} = ${f}": ${u.message} at ${u.cause}`)}})()},t.intercept(o,{get:(c,a,f)=>{if(!(c.key in o)){let m={...i.createRequest(c.key),live:!0,signal:s.signal};e[n.CONTEXT_API.api.contexts].request(m,u=>{t.set(o,c.key,u)})}return f(o[c.key]??(c.key in globalThis?globalThis[c.key]:void 0))},has:(c,a,f)=>f(!0)});let l={scope:o,abortController:s,bindings:new Map};return X(e).set("data-binding",l),l}function Xe(...n){for(let e of n){let r=e.nodeName==="#text"?e.parentNode:e,{bindings:t,abortController:i}=X(r).get("data-binding")||{};if(!t?.has(e))return;t.get(e).state.dispose(),t.get(e).signals?.forEach(o=>o.abort()),t.delete(e),t.size||(i.abort(),X(r).delete("data-binding"))}}function vt(n,e){let r=n.tokens.tagStart.split("").map(a=>`\\${a}`).join(""),t=n.tokens.tagEnd.split("").map(a=>`\\${a}`).join(""),i=n.tokens.stateStart.split("").map(a=>a===" "?"(?:\\s+)?":`\\${a}`).join(""),o=n.tokens.stateEnd.split("").map(a=>`\\${a}`).join(""),s=`^${r}(.*?)(?:${i}(\\d+)${o}(?:\\s+)?)?${t}$`,[,l,c]=e.match(new RegExp(s));return{raw:e,expr:l,span:parseInt(c??0)}}async function $t(n,...e){let r=this,t=e.reduce((i,o)=>{if(o.isBound)return i;let s=vt(n,o.nodeValue),l=o;if(s.span){if(l=o.nextSibling,l?.nodeName!=="#text"||l.nodeValue.length<s.span)return i;l.nodeValue.length>s.span&&l.splitText(s.span)}else l=o.ownerDocument.createTextNode(""),o.after(l);l.isBound=!0;let c=o;return r.webqit.env!=="server"&&(c.remove(),c=null),i.concat({textNode:l,template:s,anchorNode:c})},[]);for(let{textNode:i,template:o,anchorNode:s}of t){let l=Ot.call(r,n,o.expr),{scope:c,bindings:a}=Qe.call(this,n,i.parentNode);Object.defineProperty(i,"$oohtml_internal_databinding_anchorNode",{value:s,configurable:!0});try{a.set(i,{state:await(await l.bind(i,c)).execute()})}catch(f){console.log(f)}}}var ve=new Map;function Ot(n,e){if(ve.has(e))return ve.get(e);let r=`let content = ((${e}) ?? '') + '';`;r+="$assign__(this, 'nodeValue', content);",r+=`if ( this.$oohtml_internal_databinding_anchorNode ) { $assign__(this.$oohtml_internal_databinding_anchorNode, 'nodeValue', "${n.tokens.tagStart}${Q(e)}${n.tokens.stateStart}" + content.length + "${n.tokens.stateEnd} ${n.tokens.tagEnd}"); }`;let{webqit:{QuantumModule:t}}=this,{parserParams:i,compilerParams:o,runtimeParams:s}=n.advanced,l=new t(r,{parserParams:i,compilerParams:o,runtimeParams:s});return ve.set(e,l),l}async function At(n,...e){for(let r of e){let t=St.call(this,n,r.getAttribute(n.attr.render)),{scope:i,bindings:o}=Qe.call(this,n,r),s=[];Object.defineProperty(r,"$oohtml_internal_databinding_signals",{value:s,configurable:!0});try{o.set(r,{signals:s,state:await(await t.bind(r,i)).execute()})}catch(l){console.log(l)}}}var $e=new Map;function St(n,e){if($e.has(e))return $e.get(e);let r={},t=-1,i=ce(e,";").map(f=>{let[m,u]=ce(f,":").map(h=>h.trim()),p=m[0],g=m.slice(1).trim(),v=`(${u})`,M=`(${v} ?? '')`;if(p==="&")return g.startsWith("--")?`$exec__(this.style, 'setProperty', "${Q(g)}", ${M});`:`$assign__(this.style, "${Q(g)}", ${M});`;if(p==="%")return`$exec__(this.classList, 'toggle', "${Q(g)}", !!${v});`;if(p==="~")return g.startsWith("?")?`$exec__(this, 'toggleAttribute', "${Q(g.substring(1).trim())}", !!${v});`:`$exec__(this, 'setAttribute', "${Q(g)}", ${M});`;if(p==="#"){if(r[g])throw new Error(`Duplicate binding: ${m}.`);if(r[g]=!0,g==="text")return`$assign__(this, 'textContent', ${M});`;if(g==="html")return`$exec__(this, 'setHTMLUnsafe', ${M});`;if(g==="items"){let[h,y]=ce(u,"/");if(!y)throw new Error(`Invalid ${p}items spec: ${f}; no import specifier.`);let[$,d,b,j]=h.trim().match(/(.*?[\)\s+])(of|in)([\(\{\[\s+].*)/i)||[];if(!$)throw new Error(`Invalid ${p}items spec: ${f}.`);if(d.startsWith("(")?d=d.trim().slice(1,-1).split(",").map(I=>I.trim()):d=[d],d.length>(b==="in"?3:2))throw new Error(`Invalid ${p}items spec: ${f}.`);let E=b==="in"?d[2]:d[1]||"$index__";return`
2
+ let $iteratee__ = ${j};
3
+ let $import__ = this.${n.HTML_IMPORTS.api.import}( ${y.trim()}, true );
4
4
  this.$oohtml_internal_databinding_signals?.push( $import__ );
5
5
 
6
6
  if ( $import__.value && $iteratee__ ) {
@@ -8,13 +8,13 @@
8
8
  [ ...this.children ].filter( el => el.matches( '[${n.attr.itemIndex}]' ) ).forEach( x => {
9
9
  $existing__.set( x.getAttribute( '${n.attr.itemIndex}' ), x );
10
10
  } );
11
- ${h?`let ${h} = -1;`:""}
12
- for ( let ${d[0]} ${g} $iteratee__ ) {
13
- ${h?`${h} ++;`:""}
14
- ${g==="in"&&d[1]?`let ${d[1]} = $iteratee__[ ${d[0]} ];`:""}
11
+ ${E?`let ${E} = -1;`:""}
12
+ for ( let ${d[0]} ${b} $iteratee__ ) {
13
+ ${E?`${E} ++;`:""}
14
+ ${b==="in"&&d[1]?`let ${d[1]} = $iteratee__[ ${d[0]} ];`:""}
15
15
  const $itemBinding__ = { ${d.join(", ")} };
16
16
 
17
- const $key___ = ( ${g==="in"?d[0]:h} ) + '';
17
+ const $key___ = ( ${b==="in"?d[0]:E} ) + '';
18
18
  let $itemNode__ = $existing__.get( $key___ );
19
19
  if ( $itemNode__ ) {
20
20
  $existing__.delete( $key___ );
@@ -26,15 +26,15 @@
26
26
  $exec__(this, 'appendChild', $itemNode__ );
27
27
  }
28
28
 
29
- if ( ${g==="in"?`!( ${d[0]} in $iteratee__ )`:`typeof ${d[0]} === 'undefined'`} ) { $itemNode__.remove(); }
29
+ if ( ${b==="in"?`!( ${d[0]} in $iteratee__ )`:`typeof ${d[0]} === 'undefined'`} ) { $itemNode__.remove(); }
30
30
  }
31
31
  $existing__.forEach( x => x.remove() );
32
32
  $existing__.clear();
33
- }`}}if(c==="@")return t++,`
34
- const handler${t} = event => ${f.startsWith("{")?f:u};
35
- this.addEventListener( '${m}', handler${t} );
36
- const abort${t} = () => this.removeEventListener( '${m}', handler${t} );
33
+ }`}}if(p==="@")return t++,`
34
+ const handler${t} = event => ${u.startsWith("{")?u:v};
35
+ this.addEventListener( '${g}', handler${t} );
36
+ const abort${t} = () => this.removeEventListener( '${g}', handler${t} );
37
37
  this.$oohtml_internal_databinding_signals?.push( { abort: abort${t} } );
38
- `;if(c==="$")return`$exec__(this, '${m}', ${u});`;if(l.trim())throw new Error(`Invalid binding: ${l}.`)}).join(`
39
- `),{webqit:{QuantumModule:o}}=this,s=new o(i);return $e.set(e,s),s}var Q=n=>n.replace(/"/g,'\\"');Oe.call(window);})();
38
+ `;if(p==="$")return`$exec__(this, '${g}', ${v});`;if(f.trim())throw new Error(`Invalid binding: ${f}.`)}).join(`
39
+ `),{webqit:{QuantumModule:o}}=this,{parserParams:s,compilerParams:l,runtimeParams:c}=n.advanced,a=new o(i,{parserParams:s,compilerParams:l,runtimeParams:c});return $e.set(e,a),a}var Q=n=>n.replace(/"/g,'\\"');Oe.call(window);})();
40
40
  //# sourceMappingURL=data-binding.js.map