@webqit/oohtml 5.0.0 → 5.0.2

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 $e(...n){let e,r={runtimeParams:Je,transformerParams:Qe,parserParams:ze};for(;e=n.shift();){let{runtimeParams:t={},transformerParams:{globalsNoObserve:i=[],globalsOnlyPathsExcept:o=[],...s}={},parserParams:l={}}=e;r={runtimeParams:{...r.runtimeParams,...t},transformerParams:{...r.transformerParams,globalsNoObserve:[...r.transformerParams.globalsNoObserve,...i],globalsOnlyPathsExcept:[...r.transformerParams.globalsOnlyPathsExcept,...o],...s},parserParams:{...r.parserParams,...l}},n.devMode}return r}var ze={ecmaVersion:"latest",allowReturnOutsideFunction:!0,allowAwaitOutsideFunction:!1,allowSuperOutsideMethod:!1,preserveParens:!1,locations:!0},Qe={globalsNoObserve:["arguments","debugger"],globalsOnlyPathsExcept:[],originalSource:!0,locations:!0,compact:2},Je={apiVersion:3};function Oe(n){return(n=n.trim())&&n.startsWith("(")&&n.endsWith(")")}function ne(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 Ae(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 Q(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(Q(n,e,c.host,t,i)):s(!1)}function Se(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 V(n){return typeof n=="function"}function J(n){return n===null||n===""}function j(n){return arguments.length&&(n===void 0||typeof n>"u")}function S(n){return Array.isArray(n)||typeof n=="object"&&n||V(n)}function ue(n){return J(n)||j(n)||n===!1||n===0||S(n)&&!Object.keys(n).length}function w(n){return V(n)||n&&{}.toString.call(n)==="[object function]"}function Y(n){return n instanceof Number||typeof n=="number"}function I(n){return Y(n)||n!==!0&&n!==!1&&n!==null&&n!==""&&!isNaN(n*1)}function G(n){return n instanceof String||typeof n=="string"&&n!==null}function me(n){return!G(n)&&!j(n.length)}function ie(n,...e){return e.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n}function de(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 pe(n,e){var r=[];return de(n,e).forEach(t=>{ie(r,...Object.getOwnPropertyNames(t))}),r}function M(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,c)=>{!S(l)&&!w(l)||(r?pe(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)?[]:{},M([I(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 Z(...n){return M(n,(e,r,t)=>!0,!1,!1,!1)}function P(n,...e){if(!n||!["object","function"].includes(typeof n))throw new Error("Argument #1 must be of type object");let r=n[Symbol.for("wq")];if(r||(r=new oe,Object.defineProperty(n,Symbol.for("wq"),{value:r,enumerable:!1,configurable:!1,writable:!1})),!e.length)return r;let t,i;for(;t=e.shift();)(i=r)&&!(r=r.get(t))&&(r=new oe,i.set(t,r));return r}var oe=class extends Map{};function E(n,e=!0){return _(n)?n:!e&&x(n)?[n]:n!==!1&&n!==0&&ue(n)?[]:me(n)?Array.prototype.slice.call(n):x(n)?Object.values(n):[n]}function K(n,e,r={},t={}){e=E(e).slice();for(var i=n;!j(i)&&!J(i)&&e.length;){var o=e.shift();if(!(r.get?r.get(i,o):S(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 ge(n,e,r,t={},i={}){let o=(f,m,u)=>i.set?i.set(f,m,u):(I(e[l])&&_(f)?f.push(u):f[m]=u,!0);e=E(e);for(var s=n,l=0;l<e.length;l++)if(l<e.length-1){if(!s||!S(s)&&!w(s))return!1;var c=K(s,e[l],i);if(!S(c)){if(i.buildTree===!1)return!1;c=w(i.buildTree)?i.buildTree(l):I(e[l+1])?[]:{};var a=o(s,e[l],c);if(!a)return!1}s=c}else return o(s,e[l],r)}var ee=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 C=class{constructor(e){this.content=e,this.type=typeof e=="string"?"selector":"instance",this.kind=this.type==="instance"?null:Oe(e)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=Se(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 C)&&e.length===1?e=[[],void 0,e[0]]:x(e[1])&&e.length===2?e=[E(e[0],!1),void 0,e[1]]:e[0]=E(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 P(this.window,"realdom",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=>Q(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 C;[e=[],r=void 0,t={}]=this.resolveArgs(arguments);let{context:o}=this,s=ke(o,e);if(!r)return s;let l=t.lifecycleSignals&&this.createSignalGenerator();if(i)for(let c of s){let a=l?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 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&&Me.call(s,"intercept",()=>{});let c=new s.MutationObserver(u=>{u=He(u).map(p=>Le.call(s,p)),Ne.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 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||Me.call(s,l,u=>{this.forEachMatchingContext(l,u,Ne)});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 He(n){return n.reduce((e,r,t)=>e[t-1]?.attributeName===r.attributeName||P(r.target,"realdom","internalAttrInteractions").get(r.attributeName)?e:e.concat(r),[])}function Ne(n,e){let{context:r,spec:t,callback:i,params:o,atomics:s,originalFilterIsString:l,signalGenerator:c}=n;if(o.subtree||(e=e.filter(u=>u.target===r)),!e.length)return;let a=t.map(u=>u+"");if(o.atomic&&!s.size?e=ke(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:le(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?c.generate():{};i(f,m,r)}function le(n,e,r){let t=P(n,"realdom","internalAttrInteractions").get(e);P(n,"realdom","internalAttrInteractions").set(e,!0);let i=r();return P(n,"realdom","internalAttrInteractions").set(e,t),i}function ke(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:le(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:le(n,o.nodeName,()=>o.nodeValue),...t})}function Le({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 Me(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),P(f.target,"realdom","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=He(f).map(m=>Le.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=le(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 te=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(...ne(this.window,i,f))):(a.length&&m.push(...[...i.children].filter(u=>u.matches(a))),f.length&&m.push(...ne(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&&Fe.call(o,"sync",()=>{});let c=new o.MutationObserver(m=>m.forEach(u=>{ye.call(o,f,De.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=je.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||Fe.call(o,s,u=>{this.forEachMatchingContext(s,u,ye)});let l=new o.MutationObserver(u=>u.forEach(p=>{Array.isArray((p=De.call(o,p)).event)||ye.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=je.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 je(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,$=y=>(g.has(y)||g.set(y,{target:y,entrants:[],exits:[],type:"static",event:null}),g.get(y)),N=new WeakMap,h=y=>(N.has(y)||N.set(y,l.some(O=>y.matches(O+""))),N.get(y));for(let y of p)["entrants","exits"].forEach(O=>{o.generation&&O!==o.generation||n.$deliveryCache[O].has(y.target)||(O==="entrants"?!h(y.target):h(y.target))||(n.$deliveryCache[O].push(y.target),$(y.target)[O].push(y.target),$(y.target).event=y.event)});for(let[,y]of g){let O=s?.generate()||{};i(y,O,r)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function ye(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]=mt.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 mt(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"?Ae(this,c,s+""):c.matches&&c.matches(s+""));if((t||s.isXpathAttr)&&(l=o.reduce((c,a)=>s.kind==="xpath"?[...c,...ne(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=>Q(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 De({target:n,addedNodes:e,removedNodes:r}){let t=this,i;return i=E(e).reduce((o,s)=>o||t.webqit.realdom.domInterceptionRecords?.get(s),null),i=E(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 Fe(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,O)=>{t.realdom.domInterceptionNoRecurse.set(h,y);let d=O();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 O=y();return t.realdom.domInterceptionHooks.get("sync")?.forEach(d=>d(h)),O},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"]},$={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:O}),$[d][h]=b)});function y(...d){let b=Object.keys($).find(q=>this instanceof r[q]&&h in $[q]),D=$[b],A=()=>D[h].value.call(this,...d);if(t.realdom.domInterceptionNoRecurse.get(this)===h)return A();let T=[],v=[],H=this;["insertBefore"].includes(h)?v=[d[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(h)?(v=[d[1]],["beforebegin","afterend"].includes(d[0])&&(H=this.parentNode)):["setHTMLUnsafe","replaceChildren"].includes(h)?(T=[...this.childNodes],v=h==="replaceChildren"?[...d]:[d[0]]):["replaceWith","remove"].includes(h)?(T=[this],v=h==="replaceWith"?[...d]:[],H=this.parentNode):["replaceChild"].includes(h)?(T=[d[1]],v=[d[0]]):["removeChild"].includes(h)?T=[...d]:(v=[...d],["before","after"].includes(h)&&(H=this.parentNode));let re=h;if(["insertAdjacentHTML","setHTMLUnsafe"].includes(h)){let q=this.nodeName;if(h==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(d[0])){if(!this.parentNode)return D[h].value.call(this,...d);q=this.parentNode.nodeName}let F=i.createElement(q.includes("-")?"div":q);D.setHTMLUnsafe.value.call(F,v[0],h==="setHTMLUnsafe"?d[1]:{}),v=[...F.childNodes],h==="insertAdjacentHTML"?(re="insertAdjacentElement",d[1]=new f,u(d[1],"append",()=>d[1].append(...F.childNodes))):(re="replaceChildren",d=[...F.childNodes])}return H?p({target:H,entrants:v,exits:T,type:"interception",event:[this,h]},()=>D[re].value.call(this,...d)):A()}function O(d){let b=Object.keys($).find(R=>this instanceof r[R]&&h in $[R]),D=$[b],A=()=>D[h].set.call(this,d);if(this instanceof HTMLScriptElement||t.realdom.domInterceptionNoRecurse.get(this)===h)return A();let T=[],v=[],H=this;if(["outerHTML","outerText"].includes(h)?(T=[this],H=this.parentNode):this instanceof a?(H=this.content,T=[...this.content.childNodes]):T=[...this.childNodes],["outerHTML","innerHTML"].includes(h)){let R=this.nodeName;if(h==="outerHTML"){if(!this.parentNode)return A();R=this.parentNode.nodeName}let q=i.createElement(R.includes("-")?"div":R);if(u(q,h,()=>q[h]=d),v=this instanceof a?[...q.content.childNodes]:[...q.childNodes],this instanceof a&&this.hasAttribute("src")||this instanceof ShadowRoot){let F=W=>W.reduce((k,L)=>L instanceof HTMLScriptElement?k.concat(L):L instanceof a?k.concat(F([L.content])):(k=k.concat(F([...L.querySelectorAll?.("template")||[]].map(Xe=>Xe.content))),k.concat(...L.querySelectorAll?.("script")||[])),[]);for(let W of F(v)){if(this instanceof ShadowRoot){W.setAttribute("data-handling","manual");continue}let k=i.createElement("script");[...W.attributes].forEach(L=>k.setAttribute(L.name,L.value)),k.textContent=W.textContent,u(W,"replaceWith",()=>W.replaceWith(k))}}h==="outerHTML"?(d=new f,u(d,"append",()=>d.append(...v)),A=()=>u(this,"replaceWith",()=>l.prototype.replaceWith.call(this,d))):this instanceof a?A=()=>u(this.content,"replaceChildren",()=>this.content.replaceChildren(...v)):A=()=>u(this,"replaceChildren",()=>l.prototype.replaceChildren.call(this,...v))}return p({target:H,entrants:v,exits:T,type:"interception",event:[this,h]},A)}}),m}function Be(){dt.call(this),pt.call(this),ht.call(this)}function dt(){let n=this;n.CSS||(n.CSS={}),n.CSS.escape||(n.CSS.escape=e=>e.replace(/([\:@\~\$\&])/g,"\\$1"))}function pt(){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 ht(){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={},Be.call(n),n.webqit.realdom.meta=(...r)=>gt.call(n,...r),n.webqit.realdom.ready=(...r)=>we.call(n,...r),n.webqit.realdom.realtime=(r,t="dom")=>{if(t==="dom")return new te(r,n);if(t==="attr")return new B(r,n)};let e=new ee(n);return n.webqit.realdom.schedule=(r,...t)=>e[`on${r}`](...t),n.webqit.realdom.synthesizeWhile=(...r)=>e.synthesizeWhile(...r),n.webqit.realdom}function we(...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=>we.call(this,"interactive",o)),complete:new Promise(o=>we.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 gt(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 ge(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 ae(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)=>P(n,"oohtml",...e),wt={};function Ue(n,e,r){let t=this,i=Re.call(t);wt.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];Z(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}${ae(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 fe(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 ve(n={}){let{config:e,window:r}=Ue.call(this,"data-binding",n,{attr:{render:"render",itemIndex:"data-key"},tokens:{nodeType:"processing-instruction",tagStart:"?{",tagEnd:"}?",stateStart:"; [=",stateEnd:"]"},advanced:$e({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)}]`,xt.call(r,e)}function xt(n){let e=this,{webqit:{realdom:r}}=e;r.realtime(e.document).query(n.attrSelector,t=>{Ve.call(this,...t.exits),Ot.call(e,n,...t.entrants),queueMicrotask(()=>{},0)},{id:"data-binding:attr",live:!0,subtree:"cross-roots",timing:"sync",eventDetails:!0,staticSensitivity:!0}),r.realtime(e.document).query(`(${n.discreteBindingsSelector})`,t=>{Ve.call(this,...t.exits),vt.call(e,n,...t.entrants),queueMicrotask(()=>{})},{id:"data-binding:descrete",live:!0,subtree:"cross-roots",timing:"sync"})}function Ge(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 Ve(...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).liveProgramHandle.abort(),t.get(e).signals?.forEach(o=>o.abort()),t.delete(e),t.size||(i.abort(),X(r).delete("data-binding"))}}function bt(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 vt(n,...e){let r=this,t=e.reduce((i,o)=>{if(o.isBound)return i;let s=bt(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=$t.call(r,n,o.expr),{scope:c,bindings:a}=Ge.call(this,n,i.parentNode);Object.defineProperty(i,"$oohtml_internal_databinding_anchorNode",{value:s,configurable:!0});try{a.set(i,{liveProgramHandle:await(await l.bind(i,c)).execute()})}catch(f){console.log(f)}}}var xe=new Map;function $t(n,e){if(xe.has(e))return xe.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}${z(e)}${n.tokens.stateStart}" + content.length + "${n.tokens.stateEnd} ${n.tokens.tagEnd}"); }`;let{webqit:{LiveScript:t}}=this,{parserParams:i,compilerParams:o,runtimeParams:s}=n.advanced,l=new t(r,{parserParams:i,compilerParams:o,runtimeParams:s});return xe.set(e,l),l}async function Ot(n,...e){for(let r of e){let t=At.call(this,n,r.getAttribute(n.attr.render)),{scope:i,bindings:o}=Ge.call(this,n,r),s=[];Object.defineProperty(r,"$oohtml_internal_databinding_signals",{value:s,configurable:!0});try{o.set(r,{signals:s,liveProgramHandle:await(await t.bind(r,i)).execute()})}catch(l){console.log(l)}}}var be=new Map;function At(n,e){if(be.has(e))return be.get(e);let r={},t=-1,i=fe(e,";").map(f=>{let[m,u]=fe(f,":").map(h=>h.trim()),p=m[0],g=m.slice(1).trim(),$=`(${u})`,N=`(${$} ?? '')`;if(p==="&")return g.startsWith("--")?`$exec__(this.style, 'setProperty', "${z(g)}", ${N});`:`$assign__(this.style, "${z(g)}", ${N});`;if(p==="%")return`$exec__(this.classList, 'toggle', "${z(g)}", !!${$});`;if(p==="~")return g.startsWith("?")?`$exec__(this, 'toggleAttribute', "${z(g.substring(1).trim())}", !!${$});`:`$exec__(this, 'setAttribute', "${z(g)}", ${N});`;if(p==="#"){if(r[g])throw new Error(`Duplicate binding: ${m}.`);if(r[g]=!0,g==="text")return`$assign__(this, 'textContent', ${N});`;if(g==="html")return`$assign__(this, 'innerHTML', ${N});`;if(g==="items"){let[h,y]=fe(u,"/");if(!y)throw new Error(`Invalid ${p}items spec: ${f}; no import specifier.`);let[O,d,b,D]=h.trim().match(/(.*?[\)\s+])(of|in)([\(\{\[\s+].*)/i)||[];if(!O)throw new Error(`Invalid ${p}items spec: ${f}.`);if(d.startsWith("(")?d=d.trim().slice(1,-1).split(",").map(v=>v.trim()):d=[d],d.length>(b==="in"?3:2))throw new Error(`Invalid ${p}items spec: ${f}.`);let A=b==="in"?d[2]:d[1]||"$index__";return`console.log('-|---|---||');
2
- let $iteratee__ = ${D};
3
- let $import__ = this.${n.HTML_IMPORTS.api.import}( ${y.trim()}, true );
1
+ function $e(...n){let e,r={runtimeParams:Je,transformerParams:Qe,parserParams:ze};for(;e=n.shift();){let{runtimeParams:t={},transformerParams:{globalsNoObserve:i=[],globalsOnlyPathsExcept:o=[],...s}={},parserParams:l={}}=e;r={runtimeParams:{...r.runtimeParams,...t},transformerParams:{...r.transformerParams,globalsNoObserve:[...r.transformerParams.globalsNoObserve,...i],globalsOnlyPathsExcept:[...r.transformerParams.globalsOnlyPathsExcept,...o],...s},parserParams:{...r.parserParams,...l}},n.devMode}return r}var ze={ecmaVersion:"latest",allowReturnOutsideFunction:!0,allowAwaitOutsideFunction:!1,allowSuperOutsideMethod:!1,preserveParens:!1,locations:!0},Qe={globalsNoObserve:["arguments","debugger"],globalsOnlyPathsExcept:[],originalSource:!0,locations:!0,compact:2},Je={apiVersion:3};function Oe(n){return(n=n.trim())&&n.startsWith("(")&&n.endsWith(")")}function ne(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 Ae(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 Q(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(Q(n,e,a.host,t,i)):s(!1)}function Se(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 v(n){return!Array.isArray(n)&&typeof n=="object"&&n}function g(n){return Array.isArray(n)}function V(n){return typeof n=="function"}function J(n){return n===null||n===""}function D(n){return arguments.length&&(n===void 0||typeof n>"u")}function S(n){return Array.isArray(n)||typeof n=="object"&&n||V(n)}function ue(n){return J(n)||D(n)||n===!1||n===0||S(n)&&!Object.keys(n).length}function b(n){return V(n)||n&&{}.toString.call(n)==="[object function]"}function Y(n){return n instanceof Number||typeof n=="number"}function P(n){return Y(n)||n!==!0&&n!==!1&&n!==null&&n!==""&&!isNaN(n*1)}function G(n){return n instanceof String||typeof n=="string"&&n!==null}function me(n){return!G(n)&&!D(n.length)}function ie(n,...e){return e.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n}function de(t,e){e=e||Object.prototype,e=e&&!g(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 pe(n,e){var r=[];return de(n,e).forEach(t=>{ie(r,...Object.getOwnPropertyNames(t))}),r}function k(n,e,r=!1,t=!1,i=!1){var o=0,s=n.shift();if((P(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)=>{!S(l)&&!b(l)||(r?pe(l):Object.keys(l)).forEach(f=>{if(!!e(f,s,l,a)){var c=s[f],m=l[f];if((g(c)&&g(m)||v(c)&&v(m))&&(o===!0||o>0))s[f]=g(c)&&g(m)?[]:{},k([P(o)?o-1:o,s[f],c,m],e,r,t,i);else if(g(s)&&g(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 Z(...n){return k(n,(e,r,t)=>!0,!1,!1,!1)}function C(n,...e){if(!n||!["object","function"].includes(typeof n))throw new Error("Argument #1 must be of type object");let r=n[Symbol.for("wq")];if(r||(r=new oe,Object.defineProperty(n,Symbol.for("wq"),{value:r,enumerable:!1,configurable:!1,writable:!1})),!e.length)return r;let t,i;for(;t=e.shift();)(i=r)&&!(r=r.get(t))&&(r=new oe,i.set(t,r));return r}var oe=class extends Map{};function E(n,e=!0){return g(n)?n:!e&&v(n)?[n]:n!==!1&&n!==0&&ue(n)?[]:me(n)?Array.prototype.slice.call(n):v(n)?Object.values(n):[n]}function K(n,e,r={},t={}){e=E(e).slice();for(var i=n;!D(i)&&!J(i)&&e.length;){var o=e.shift();if(!(r.get?r.get(i,o):S(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 ge(n,e,r,t={},i={}){let o=(c,m,u)=>i.set?i.set(c,m,u):(P(e[l])&&g(c)?c.push(u):c[m]=u,!0);e=E(e);for(var s=n,l=0;l<e.length;l++)if(l<e.length-1){if(!s||!S(s)&&!b(s))return!1;var a=K(s,e[l],i);if(!S(a)){if(i.buildTree===!1)return!1;a=b(i.buildTree)?i.buildTree(l):P(e[l+1])?[]:{};var f=o(s,e[l],a);if(!f)return!1}s=a}else return o(s,e[l],r)}var ee=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 T=class{constructor(e){this.content=e,this.type=typeof e=="string"?"selector":"instance",this.kind=this.type==="instance"?null:Oe(e)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=Se(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(b(e[0])?e=[[],...e]:v(e[0])&&!(e[0]instanceof T)&&e.length===1?e=[[],void 0,e[0]]:v(e[1])&&e.length===2?e=[E(e[0],!1),void 0,e[1]]:e[0]=E(e[0],!1),e[0].filter(r=>typeof r!="string"&&!(r instanceof T)&&!(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 T?r:new T(r)),e}registry(...e){return C(this.window,"realdom",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=>Q(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&&b(i.disconnect)&&i.disconnect()||b(i)&&i()||v(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 T;[e=[],r=void 0,t={}]=this.resolveArgs(arguments);let{context:o}=this,s=ke(o,e);if(!r)return s;let l=t.lifecycleSignals&&this.createSignalGenerator();if(i)for(let a of s){let f=l?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 T;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&&Me.call(s,"intercept",()=>{});let a=new s.MutationObserver(u=>{u=He(u).map(p=>Le.call(s,p)),Ne.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 T;[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||Me.call(s,l,u=>{this.forEachMatchingContext(l,u,Ne)});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||C(r.target,"realdom","internalAttrInteractions").get(r.attributeName)?e:e.concat(r),[])}function Ne(n,e){let{context:r,spec:t,callback:i,params:o,atomics:s,originalFilterIsString:l,signalGenerator:a}=n;if(o.subtree||(e=e.filter(u=>u.target===r)),!e.length)return;let f=t.map(u=>u+"");if(o.atomic&&!s.size?e=ke(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:le(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?a.generate():{};i(c,m,r)}function le(n,e,r){let t=C(n,"realdom","internalAttrInteractions").get(e);C(n,"realdom","internalAttrInteractions").set(e,!0);let i=r();return C(n,"realdom","internalAttrInteractions").set(e,t),i}function ke(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:le(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:le(n,o.nodeName,()=>o.nodeValue),...t})}function Le({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 Me(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),C(c.target,"realdom","internalAttrInteractions").get(c.name))return m();t.realdom.attrInterceptionHooks.get("intercept")?.forEach(_=>_([c]));let p=m();return t.realdom.attrInterceptionHooks.get("sync")?.forEach(_=>_([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=>Le.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=le(this,m[0],()=>this.getAttribute(m[0]));["setAttribute","toggleAttribute"].includes(c)&&(u=m[1]),c==="toggleAttribute"&&u===void 0&&(u=p===null);let _={target:this,name:m[0],value:u,oldValue:p,type:"interception",event:[this,c]};return l(_,()=>f[c].call(this,...m))}}),s}var te=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=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],_)=>_.kind==="xpath"?[u,p.concat(_)]:[u.concat(_),p],[[],[]]),m=[];t.subtree?(f.length&&m.push(...i.querySelectorAll(f.join(","))),c.length&&m.push(...ne(this.window,i,c))):(f.length&&m.push(...[...i.children].filter(u=>u.matches(f))),c.length&&m.push(...ne(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&&Fe.call(o,"sync",()=>{});let a=new o.MutationObserver(m=>m.forEach(u=>{ye.call(o,c,De.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=je.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||Fe.call(o,s,u=>{this.forEachMatchingContext(s,u,ye)});let l=new o.MutationObserver(u=>u.forEach(p=>{Array.isArray((p=De.call(o,p)).event)||ye.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=je.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 je(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(_=>_[1]).concat(a(p)).concat(f(p));if(!(n.$attrs=Array.from(new Set(l.filter(p=>(p+"").includes("[")).reduce((p,_)=>p.concat(c(_+"")),[])))).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 _=new Map,x=y=>(_.has(y)||_.set(y,{target:y,entrants:[],exits:[],type:"static",event:null}),_.get(y)),H=new WeakMap,d=y=>(H.has(y)||H.set(y,l.some($=>y.matches($+""))),H.get(y));for(let y of p)["entrants","exits"].forEach($=>{o.generation&&$!==o.generation||n.$deliveryCache[$].has(y.target)||($==="entrants"?!d(y.target):d(y.target))||(n.$deliveryCache[$].push(y.target),x(y.target)[$].push(y.target),x(y.target).event=y.event)});for(let[,y]of _){let $=s?.generate()||{};i(y,$,r)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function ye(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]=mt.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 mt(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"?Ae(this,a,s+""):a.matches&&a.matches(s+""));if((t||s.isXpathAttr)&&(l=o.reduce((a,f)=>s.kind==="xpath"?[...a,...ne(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=>Q(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 De({target:n,addedNodes:e,removedNodes:r}){let t=this,i;return i=E(e).reduce((o,s)=>o||t.webqit.realdom.domInterceptionRecords?.get(s),null),i=E(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 Fe(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,y,$)=>{t.realdom.domInterceptionNoRecurse.set(d,y);let h=$();return t.realdom.domInterceptionNoRecurse.delete(d),h},p=(d,y)=>{d.entrants.concat(d.exits).forEach(h=>{clearTimeout(t.realdom.domInterceptionRecords.get(h)?.timeout),t.realdom.domInterceptionRecords.set(h,d.event);let w=setTimeout(()=>{t.realdom.domInterceptionRecords.delete(h)},0);Object.defineProperty(d.event,"timeout",{value:w,configurable:!0})}),t.realdom.domInterceptionHooks.get("intercept")?.forEach(h=>h(d));let $=y();return t.realdom.domInterceptionHooks.get("sync")?.forEach(h=>h(d)),$},_={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"]},x={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(_).reduce((d,y)=>d.concat(y),[])).forEach(d=>{Object.keys(_).forEach(h=>{if(!_[h].includes(d))return;let w=Object.getOwnPropertyDescriptor(r[h].prototype,d);!w||(Object.defineProperty(r[h].prototype,d,"value"in w?{...w,value:y}:{...w,set:$}),x[h][d]=w)});function y(...h){let w=Object.keys(x).find(M=>this instanceof r[M]&&d in x[M]),I=x[w],q=()=>I[d].value.call(this,...h);if(t.realdom.domInterceptionNoRecurse.get(this)===d)return q();let A=[],O=[],N=this;["insertBefore"].includes(d)?O=[h[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(d)?(O=[h[1]],["beforebegin","afterend"].includes(h[0])&&(N=this.parentNode)):["setHTMLUnsafe","replaceChildren"].includes(d)?(A=[...this.childNodes],O=d==="replaceChildren"?[...h]:[h[0]]):["replaceWith","remove"].includes(d)?(A=[this],O=d==="replaceWith"?[...h]:[],N=this.parentNode):["replaceChild"].includes(d)?(A=[h[1]],O=[h[0]]):["removeChild"].includes(d)?A=[...h]:(O=[...h],["before","after"].includes(d)&&(N=this.parentNode));let re=d;if(["insertAdjacentHTML","setHTMLUnsafe"].includes(d)){let M=this.nodeName;if(d==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(h[0])){if(!this.parentNode)return I[d].value.call(this,...h);M=this.parentNode.nodeName}let F=i.createElement(M.includes("-")?"div":M);I.setHTMLUnsafe.value.call(F,O[0],d==="setHTMLUnsafe"?h[1]:{}),O=[...F.childNodes],d==="insertAdjacentHTML"?(re="insertAdjacentElement",h[1]=new c,u(h[1],"append",()=>h[1].append(...F.childNodes))):(re="replaceChildren",h=[...F.childNodes])}return N?p({target:N,entrants:O,exits:A,type:"interception",event:[this,d]},()=>I[re].value.call(this,...h)):q()}function $(h){let w=Object.keys(x).find(R=>this instanceof r[R]&&d in x[R]),I=x[w],q=()=>I[d].set.call(this,h);if(this instanceof HTMLScriptElement||t.realdom.domInterceptionNoRecurse.get(this)===d)return q();let A=[],O=[],N=this;if(["outerHTML","outerText"].includes(d)?(A=[this],N=this.parentNode):this instanceof f?(N=this.content,A=[...this.content.childNodes]):A=[...this.childNodes],["outerHTML","innerHTML"].includes(d)){let R=this.nodeName;if(d==="outerHTML"){if(!this.parentNode)return q();R=this.parentNode.nodeName}let M=i.createElement(R.includes("-")?"div":R);if(u(M,d,()=>M[d]=h),O=this instanceof f?[...M.content.childNodes]:[...M.childNodes],this instanceof f&&this.hasAttribute("src")||this instanceof ShadowRoot){let F=W=>W.reduce((L,j)=>j instanceof HTMLScriptElement?L.concat(j):j instanceof f?L.concat(F([j.content])):(L=L.concat(F([...j.querySelectorAll?.("template")||[]].map(Xe=>Xe.content))),L.concat(...j.querySelectorAll?.("script")||[])),[]);for(let W of F(O)){if(this instanceof ShadowRoot){W.setAttribute("data-handling","manual");continue}let L=i.createElement("script");[...W.attributes].forEach(j=>L.setAttribute(j.name,j.value)),L.textContent=W.textContent,u(W,"replaceWith",()=>W.replaceWith(L))}}d==="outerHTML"?(h=new c,u(h,"append",()=>h.append(...O)),q=()=>u(this,"replaceWith",()=>l.prototype.replaceWith.call(this,h))):this instanceof f?q=()=>u(this.content,"replaceChildren",()=>this.content.replaceChildren(...O)):q=()=>u(this,"replaceChildren",()=>l.prototype.replaceChildren.call(this,...O))}return p({target:N,entrants:O,exits:A,type:"interception",event:[this,d]},q)}}),m}function Be(){dt.call(this),pt.call(this),ht.call(this)}function dt(){let n=this;n.CSS||(n.CSS={}),n.CSS.escape||(n.CSS.escape=e=>e.replace(/([\:@\~\$\&])/g,"\\$1"))}function pt(){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 ht(){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={},Be.call(n),n.webqit.realdom.meta=(...r)=>gt.call(n,...r),n.webqit.realdom.ready=(...r)=>we.call(n,...r),n.webqit.realdom.realtime=(r,t="dom")=>{if(t==="dom")return new te(r,n);if(t==="attr")return new B(r,n)};let e=new ee(n);return n.webqit.realdom.schedule=(r,...t)=>e[`on${r}`](...t),n.webqit.realdom.synthesizeWhile=(...r)=>e.synthesizeWhile(...r),n.webqit.realdom}function we(...n){let e="interactive",r;G(n[0])?(e=n[0],b(n[1])&&(r=n[1])):b(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=>we.call(this,"interactive",o)),complete:new Promise(o=>we.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 gt(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 ge(i,s[0].split("."),s[1]==="true"?!0:s[1]==="false"?!1:P(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 ae(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)=>C(n,"oohtml",...e),wt={};function Ue(n,e,r){let t=this,i=Re.call(t);wt.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];Z(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}${ae(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 fe(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 ve(n={}){let{config:e,window:r}=Ue.call(this,"data-binding",n,{attr:{render:"render",itemIndex:"data-key"},tokens:{nodeType:"processing-instruction",tagStart:"?{",tagEnd:"}?",stateStart:"; [=",stateEnd:"]"},advanced:$e({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)}]`,xt.call(r,e)}function xt(n){let e=this,{webqit:{realdom:r}}=e;r.realtime(e.document).query(n.attrSelector,t=>{Ve.call(this,...t.exits),Ot.call(e,n,...t.entrants),queueMicrotask(()=>{})},{id:"data-binding:attr",live:!0,subtree:"cross-roots",timing:"sync",eventDetails:!0,staticSensitivity:!0}),r.realtime(e.document).query(`(${n.discreteBindingsSelector})`,t=>{Ve.call(this,...t.exits),vt.call(e,n,...t.entrants),queueMicrotask(()=>{})},{id:"data-binding:descrete",live:!0,subtree:"cross-roots",timing:"sync"})}function Ge(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){throw new Error(`Error executing "${f}()": ${u.message} at ${u.cause}`)}})()},o.$assign__=(a,f,c)=>{(()=>{try{a[f]=c}catch(u){throw new Error(`Error executing "${f} = ${c}": ${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 Ve(...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).liveProgramHandle.abort(),t.get(e).signals?.forEach(o=>o.abort()),t.delete(e),t.size||(i.abort(),X(r).delete("data-binding"))}}function bt(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 vt(n,...e){let r=this,t=e.reduce((i,o)=>{if(o.isBound)return i;let s=bt(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=$t.call(r,n,o.expr),{scope:a,bindings:f}=Ge.call(this,n,i.parentNode);Object.defineProperty(i,"$oohtml_internal_databinding_anchorNode",{value:s,configurable:!0});try{f.set(i,{liveProgramHandle:await(await l.bind(i,a)).execute()})}catch(c){console.log(c)}}}var xe=new Map;function $t(n,e){if(xe.has(e))return xe.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}${z(e)}${n.tokens.stateStart}" + content.length + "${n.tokens.stateEnd} ${n.tokens.tagEnd}"); }`;let{webqit:{LiveScript:t,AsyncLiveScript:i}}=this,{parserParams:o,compilerParams:s,runtimeParams:l}=n.advanced,a=new(t||i)(r,{parserParams:o,compilerParams:s,runtimeParams:l});return xe.set(e,a),a}async function Ot(n,...e){for(let r of e){let t=At.call(this,n,r.getAttribute(n.attr.render)),{scope:i,bindings:o}=Ge.call(this,n,r),s=[];Object.defineProperty(r,"$oohtml_internal_databinding_signals",{value:s,configurable:!0});try{o.set(r,{signals:s,liveProgramHandle:await(await t.bind(r,i)).execute()})}catch(l){console.log(l)}}}var be=new Map;function At(n,e){if(be.has(e))return be.get(e);let r={},t=-1,i=fe(e,";").map(m=>{let[u,p]=fe(m,":").map(y=>y.trim()),_=u[0],x=u.slice(1).trim(),H=`(${p})`,d=`(${H} ?? '')`;if(_==="&")return x.startsWith("--")?`$exec__(this.style, 'setProperty', "${z(x)}", ${d});`:`$assign__(this.style, "${z(x)}", ${d});`;if(_==="%")return`$exec__(this.classList, 'toggle', "${z(x)}", !!${H});`;if(_==="~")return x.startsWith("?")?`$exec__(this, 'toggleAttribute', "${z(x.substring(1).trim())}", !!${H});`:`$exec__(this, 'setAttribute', "${z(x)}", ${d});`;if(_==="#"){if(r[x])throw new Error(`Duplicate binding: ${u}.`);if(r[x]=!0,x==="text")return`$assign__(this, 'textContent', ${d});`;if(x==="html")return`$assign__(this, 'innerHTML', ${d});`;if(x==="items"){let[y,$]=fe(p,"/");if(!$)throw new Error(`Invalid ${_}items spec: ${m}; no import specifier.`);let[h,w,I,q]=y.trim().match(/(.*?[\)\s+])(of|in)([\(\{\[\s+].*)/i)||[];if(!h)throw new Error(`Invalid ${_}items spec: ${m}.`);if(w.startsWith("(")?w=w.trim().slice(1,-1).split(",").map(N=>N.trim()):w=[w],w.length>(I==="in"?3:2))throw new Error(`Invalid ${_}items spec: ${m}.`);let A=I==="in"?w[2]:w[1]||"$index__";return`
2
+ let $iteratee__ = ${q};
3
+ let $import__ = this.${n.HTML_IMPORTS.api.import}( ${$.trim()}, true );
4
4
  this.$oohtml_internal_databinding_signals?.push( $import__ );
5
5
  if ( $import__.value && $iteratee__ ) {
6
6
  let $existing__ = new Map;
@@ -8,12 +8,12 @@ function $e(...n){let e,r={runtimeParams:Je,transformerParams:Qe,parserParams:ze
8
8
  $existing__.set( x.getAttribute( '${n.attr.itemIndex}' ), x );
9
9
  } );
10
10
  ${A?`let ${A} = -1;`:""}
11
- for ( let ${d[0]} ${b} $iteratee__ ) {
11
+ for ( let ${w[0]} ${I} $iteratee__ ) {
12
12
  ${A?`${A} ++;`:""}
13
- ${b==="in"&&d[1]?`let /*value*/${d[1]} = $iteratee__[ ${d[0]} ];`:""}
14
- let $itemBinding__ = { ${d.join(", ")} };
13
+ ${I==="in"&&w[1]?`let /*value*/${w[1]} = $iteratee__[ ${w[0]} ];`:""}
14
+ let $itemBinding__ = { ${w.join(", ")} };
15
15
 
16
- const $key___ = ( ${b==="in"?d[0]:A} ) + '';
16
+ const $key___ = ( ${I==="in"?w[0]:A} ) + '';
17
17
  let $itemNode__ = $existing__.get( $key___ );
18
18
  if ( $itemNode__ ) {
19
19
  $existing__.delete( $key___ );
@@ -25,15 +25,15 @@ function $e(...n){let e,r={runtimeParams:Je,transformerParams:Qe,parserParams:ze
25
25
  $exec__(this, 'appendChild', $itemNode__ );
26
26
  }
27
27
 
28
- if ( ${b==="in"?`!( ${d[0]} in $iteratee__ )`:`typeof ${d[0]} === 'undefined'`} ) { $itemNode__.remove(); }
28
+ if ( ${I==="in"?`!( ${w[0]} in $iteratee__ )`:`typeof ${w[0]} === 'undefined'`} ) { $itemNode__.remove(); }
29
29
  }
30
30
  $existing__.forEach( x => x.remove() );
31
31
  $existing__.clear();
32
- }`}}if(p==="@")return t++,`
33
- const handler${t} = event => ${u.startsWith("{")?u:$};
34
- this.addEventListener( '${g}', handler${t} );
35
- const abort${t} = () => this.removeEventListener( '${g}', handler${t} );
32
+ }`}}if(_==="@")return t++,`
33
+ const handler${t} = event => ${p.startsWith("{")?p:H};
34
+ this.addEventListener( '${x}', handler${t} );
35
+ const abort${t} = () => this.removeEventListener( '${x}', handler${t} );
36
36
  this.$oohtml_internal_databinding_signals?.push( { abort: abort${t} } );
37
- `;if(p==="$")return`$exec__(this, '${g}', ${$});`;if(f.trim())throw new Error(`Invalid binding: ${f}.`)}).join(`
38
- `),{webqit:{LiveScript:o}}=this,{parserParams:s,compilerParams:l,runtimeParams:c}=n.advanced,a=new o(i,{parserParams:s,compilerParams:l,runtimeParams:c});return be.set(e,a),a}var z=n=>n.replace(/"/g,'\\"');ve.call(window);
37
+ `;if(_==="$")return`$exec__(this, '${x}', ${H});`;if(m.trim())throw new Error(`Invalid binding: ${m}.`)}).join(`
38
+ `),{webqit:{LiveScript:o,AsyncLiveScript:s}}=this,{parserParams:l,compilerParams:a,runtimeParams:f}=n.advanced,c=new(o||s)(i,{parserParams:l,compilerParams:a,runtimeParams:f});return be.set(e,c),c}var z=n=>n.replace(/"/g,'\\"');ve.call(window);
39
39
  //# sourceMappingURL=data-binding.js.map